config-base.d.ts 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. import {Agent as httpAgent} from 'http';
  2. import {Agent as httpsAgent} from 'https';
  3. import {AWSError} from './error';
  4. import {Credentials, CredentialsOptions} from './credentials';
  5. import {CredentialProviderChain} from './credentials/credential_provider_chain';
  6. import {Token} from './token';
  7. import {TokenProviderChain} from './token/token_provider_chain';
  8. export class ConfigBase extends ConfigurationOptions{
  9. constructor(options?: ConfigurationOptions);
  10. /**
  11. * Loads credentials from the configuration object.
  12. */
  13. getCredentials(callback: (err: AWSError|null, credentials: Credentials|CredentialsOptions|null) => void): void;
  14. /**
  15. * Loads token from the token object.
  16. */
  17. getToken(callback: (err: AWSError|null, token: Token|null) => void): void;
  18. /**
  19. * Loads configuration data from a JSON file into this config object.
  20. * Loading configuration will reset all existing configuration on the object.
  21. * This feature is not supported in the browser environment of the SDK.
  22. *
  23. * @param {string} path - the path relative to your process's current working directory to load configuration from.
  24. */
  25. loadFromPath(path: string): ConfigBase;
  26. /**
  27. * Updates the current configuration object with new options.
  28. *
  29. * @param {ConfigurationOptions} options - a map of option keys and values.
  30. * @param {boolean} allowUnknownKeys - Whether unknown keys can be set on the configuration object.
  31. */
  32. update(options: ConfigurationOptions & {[key: string]: any}, allowUnknownKeys: true): void;
  33. /**
  34. * Updates the current configuration object with new options.
  35. *
  36. * @param {ConfigurationOptions} options - a map of option keys and values.
  37. * @param {boolean} allowUnknownKeys - Defaults to false. Whether unknown keys can be set on the configuration object.
  38. */
  39. update(options: ConfigurationOptions, allowUnknownKeys?: false): void;
  40. /**
  41. * Gets the promise dependency the SDK will use wherever Promises are returned.
  42. */
  43. getPromisesDependency(): typeof Promise | void;
  44. /**
  45. * Sets the promise dependency the SDK will use wherever Promises are returned.
  46. * @param {function} dep - a reference to a Promise constructor
  47. */
  48. setPromisesDependency(dep: any): void;
  49. }
  50. export interface HTTPOptions {
  51. /**
  52. * the URL to proxy requests through.
  53. */
  54. proxy?: string;
  55. /**
  56. * the Agent object to perform HTTP requests with.
  57. * Used for connection pooling.
  58. * Defaults to the global agent (http.globalAgent) for non-SSL connections.
  59. */
  60. agent?: httpAgent | httpsAgent;
  61. /**
  62. * The maximum time in milliseconds that the connection phase of the request
  63. * should be allowed to take. This only limits the connection phase and has
  64. * no impact once the socket has established a connection.
  65. * Used in node.js environments only.
  66. */
  67. connectTimeout?: number;
  68. /**
  69. * The number of milliseconds a request can take before automatically being terminated.
  70. * Defaults to two minutes (120000).
  71. */
  72. timeout?: number;
  73. /**
  74. * Whether the SDK will send asynchronous HTTP requests.
  75. * Used in the browser environment only.
  76. * Set to false to send requests synchronously.
  77. * Defaults to true (async on).
  78. */
  79. xhrAsync?: boolean;
  80. /**
  81. * Sets the 'withCredentials' property of an XMLHttpRequest object.
  82. * Used in the browser environment only.
  83. * Defaults to false.
  84. */
  85. xhrWithCredentials?: boolean;
  86. }
  87. export interface Logger {
  88. write?: (chunk: any, encoding?: string, callback?: () => void) => void
  89. log?: (...messages: any[]) => void;
  90. warn?: (...message: any[]) => void;
  91. }
  92. export interface ParamValidation {
  93. /**
  94. * Validates that a value meets the min constraint.
  95. * This is enabled by default when paramValidation is set to true.
  96. */
  97. min?: boolean
  98. /**
  99. * Validates that a value meets the max constraint.
  100. */
  101. max?: boolean
  102. /**
  103. * Validates that a string value matches a regular expression.
  104. */
  105. pattern?: boolean
  106. /**
  107. * Validates that a string value matches one of the allowable enum values.
  108. */
  109. enum?: boolean
  110. }
  111. export interface RetryDelayOptions {
  112. /**
  113. * The base number of milliseconds to use in the exponential backoff for operation retries.
  114. * Defaults to 100 ms.
  115. */
  116. base?: number
  117. /**
  118. * A custom function that accepts a retry count and error and returns the amount of time to delay in milliseconds. If the result is a non-zero negative value, no further retry attempts will be made.
  119. * The base option will be ignored if this option is supplied.
  120. */
  121. customBackoff?: (retryCount: number, err?: Error) => number
  122. }
  123. /**
  124. * Common configuration entries to construct a service client.
  125. */
  126. export abstract class ConfigurationOptions {
  127. /**
  128. * Whether to compute checksums for payload bodies when the service accepts it.
  129. * Currently supported in S3 only.
  130. */
  131. computeChecksums?: boolean
  132. /**
  133. * Whether types are converted when parsing response data.
  134. */
  135. convertResponseTypes?: boolean
  136. /**
  137. * Whether to apply a clock skew correction and retry requests that fail because of an skewed client clock.
  138. */
  139. correctClockSkew?: boolean
  140. /**
  141. * Sets a custom User-Agent string.
  142. * In node environments this will set the User-Agent header, but
  143. * browser environments this will set the X-Amz-User-Agent header.
  144. */
  145. customUserAgent?: string
  146. /**
  147. * The AWS credentials to sign requests with.
  148. */
  149. credentials?: Credentials|CredentialsOptions|null
  150. /**
  151. * The provider chain used to resolve credentials if no static credentials property is set.
  152. */
  153. credentialProvider?: CredentialProviderChain
  154. /**
  155. * The Token to authenticate requests with.
  156. */
  157. token?: Token|null
  158. /**
  159. * The provider chain used to resolve token if no static token property is set.
  160. */
  161. tokenProvider?: TokenProviderChain
  162. /**
  163. * AWS access key ID.
  164. *
  165. * @deprecated
  166. */
  167. accessKeyId?: string
  168. /**
  169. * AWS secret access key.
  170. *
  171. * @deprecated
  172. */
  173. secretAccessKey?: string
  174. /**
  175. * AWS session token.
  176. *
  177. * @deprecated
  178. */
  179. sessionToken?: string
  180. /**
  181. * A set of options to pass to the low-level HTTP request.
  182. */
  183. httpOptions?: HTTPOptions
  184. /**
  185. * An object that responds to .write() (like a stream) or .log() (like the console object) in order to log information about requests.
  186. */
  187. logger?: Logger
  188. /**
  189. * The maximum amount of redirects to follow for a service request.
  190. */
  191. maxRedirects?: number
  192. /**
  193. * The maximum amount of retries to perform for a service request.
  194. */
  195. maxRetries?: number
  196. /**
  197. * Returns whether input parameters should be validated against the operation description before sending the request.
  198. * Defaults to true.
  199. * Pass a map to enable any of the following specific validation features: min|max|pattern|enum
  200. */
  201. paramValidation?: ParamValidation|boolean
  202. /**
  203. * The region to send service requests to.
  204. */
  205. region?: string
  206. /**
  207. * Returns A set of options to configure the retry delay on retryable errors.
  208. */
  209. retryDelayOptions?: RetryDelayOptions
  210. /**
  211. * Whether the provided endpoint addresses an individual bucket.
  212. * false if it addresses the root API endpoint.
  213. */
  214. s3BucketEndpoint?: boolean
  215. /**
  216. * Whether to disable S3 body signing when using signature version v4.
  217. */
  218. s3DisableBodySigning?: boolean
  219. /**
  220. * Whether to force path style URLs for S3 objects.
  221. */
  222. s3ForcePathStyle?: boolean
  223. /**
  224. * When region is set to 'us-east-1', whether to send s3 request to global endpoints
  225. * or 'us-east-1' regional endpoints. This config is only applicable to S3 client;
  226. * Defaults to 'legacy'
  227. */
  228. s3UsEast1RegionalEndpoint?: "regional"|"legacy"
  229. /**
  230. * Whether to override the request region with the region inferred
  231. * from requested resource's ARN. Only available for S3 buckets
  232. * Defaults to `true`
  233. */
  234. s3UseArnRegion?: boolean
  235. /**
  236. * Whether the signature to sign requests with (overriding the API configuration) is cached.
  237. */
  238. signatureCache?: boolean
  239. /**
  240. * The signature version to sign requests with (overriding the API configuration).
  241. * Possible values: 'v2'|'v3'|'v4'
  242. */
  243. signatureVersion?: "v2"|"v3"|"v4"|string
  244. /**
  245. * Whether SSL is enabled for requests.
  246. */
  247. sslEnabled?: boolean
  248. /**
  249. * An offset value in milliseconds to apply to all signing times.
  250. */
  251. systemClockOffset?: number
  252. /**
  253. * Whether to use the Accelerate endpoint with the S3 service.
  254. */
  255. useAccelerateEndpoint?: boolean
  256. /**
  257. * Whether to validate the CRC32 checksum of HTTP response bodies returned
  258. * by DynamoDB.
  259. */
  260. dynamoDbCrc32?: boolean;
  261. /**
  262. * Whether to enable endpoint discovery for operations that allow optionally using an endpoint returned by
  263. * the service.
  264. */
  265. endpointDiscoveryEnabled?: boolean;
  266. /**
  267. * The size of the global cache storing endpoints from endpoint
  268. * discovery operations. Once endpoint cache is created, updating this setting
  269. * cannot change existing cache size.
  270. */
  271. endpointCacheSize?: number;
  272. /**
  273. * Whether to marshal request parameters to the prefix of hostname.
  274. */
  275. hostPrefixEnabled?: boolean;
  276. /**
  277. * Whether to send sts request to global endpoints or
  278. * regional endpoints.
  279. */
  280. stsRegionalEndpoints?: "legacy"|"regional";
  281. /**
  282. * Enables FIPS compatible endpoints.
  283. */
  284. useFipsEndpoint?: boolean;
  285. /**
  286. * Enables IPv6 dualstack endpoint.
  287. */
  288. useDualstackEndpoint?: boolean;
  289. }