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