@smithy/property-provider 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-types/ts3.4/CredentialsProviderError.d.ts +17 -0
- package/dist-types/ts3.4/ProviderError.d.ts +17 -0
- package/dist-types/ts3.4/TokenProviderError.d.ts +17 -0
- package/dist-types/ts3.4/chain.d.ts +13 -0
- package/dist-types/ts3.4/fromStatic.d.ts +5 -0
- package/dist-types/ts3.4/index.d.ts +24 -0
- package/dist-types/ts3.4/memoize.d.ts +40 -0
- package/package.json +3 -3
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ProviderError } from "./ProviderError";
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*
|
|
5
|
+
* An error representing a failure of an individual credential provider.
|
|
6
|
+
*
|
|
7
|
+
* This error class has special meaning to the {@link chain} method. If a
|
|
8
|
+
* provider in the chain is rejected with an error, the chain will only proceed
|
|
9
|
+
* to the next provider if the value of the `tryNextLink` property on the error
|
|
10
|
+
* is truthy. This allows individual providers to halt the chain and also
|
|
11
|
+
* ensures the chain will stop if an entirely unexpected error is encountered.
|
|
12
|
+
*/
|
|
13
|
+
export declare class CredentialsProviderError extends ProviderError {
|
|
14
|
+
readonly tryNextLink: boolean;
|
|
15
|
+
name: string;
|
|
16
|
+
constructor(message: string, tryNextLink?: boolean);
|
|
17
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @internal
|
|
3
|
+
*
|
|
4
|
+
* An error representing a failure of an individual provider.
|
|
5
|
+
*
|
|
6
|
+
* This error class has special meaning to the {@link chain} method. If a
|
|
7
|
+
* provider in the chain is rejected with an error, the chain will only proceed
|
|
8
|
+
* to the next provider if the value of the `tryNextLink` property on the error
|
|
9
|
+
* is truthy. This allows individual providers to halt the chain and also
|
|
10
|
+
* ensures the chain will stop if an entirely unexpected error is encountered.
|
|
11
|
+
*/
|
|
12
|
+
export declare class ProviderError extends Error {
|
|
13
|
+
readonly tryNextLink: boolean;
|
|
14
|
+
name: string;
|
|
15
|
+
constructor(message: string, tryNextLink?: boolean);
|
|
16
|
+
static from(error: Error, tryNextLink?: boolean): ProviderError;
|
|
17
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ProviderError } from "./ProviderError";
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*
|
|
5
|
+
* An error representing a failure of an individual token provider.
|
|
6
|
+
*
|
|
7
|
+
* This error class has special meaning to the {@link chain} method. If a
|
|
8
|
+
* provider in the chain is rejected with an error, the chain will only proceed
|
|
9
|
+
* to the next provider if the value of the `tryNextLink` property on the error
|
|
10
|
+
* is truthy. This allows individual providers to halt the chain and also
|
|
11
|
+
* ensures the chain will stop if an entirely unexpected error is encountered.
|
|
12
|
+
*/
|
|
13
|
+
export declare class TokenProviderError extends ProviderError {
|
|
14
|
+
readonly tryNextLink: boolean;
|
|
15
|
+
name: string;
|
|
16
|
+
constructor(message: string, tryNextLink?: boolean);
|
|
17
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Provider } from "@smithy/types";
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*
|
|
5
|
+
* Compose a single credential provider function from multiple credential
|
|
6
|
+
* providers. The first provider in the argument list will always be invoked;
|
|
7
|
+
* subsequent providers in the list will be invoked in the order in which the
|
|
8
|
+
* were received if the preceding provider did not successfully resolve.
|
|
9
|
+
*
|
|
10
|
+
* If no providers were received or no provider resolves successfully, the
|
|
11
|
+
* returned promise will be rejected.
|
|
12
|
+
*/
|
|
13
|
+
export declare function chain<T>(...providers: Array<Provider<T>>): Provider<T>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @internal
|
|
3
|
+
*/
|
|
4
|
+
export * from "./CredentialsProviderError";
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export * from "./ProviderError";
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export * from "./TokenProviderError";
|
|
13
|
+
/**
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export * from "./chain";
|
|
17
|
+
/**
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
export * from "./fromStatic";
|
|
21
|
+
/**
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
export * from "./memoize";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { MemoizedProvider, Provider } from "@smithy/types";
|
|
2
|
+
interface MemoizeOverload {
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* Decorates a provider function with either static memoization.
|
|
6
|
+
*
|
|
7
|
+
* To create a statically memoized provider, supply a provider as the only
|
|
8
|
+
* argument to this function. The provider will be invoked once, and all
|
|
9
|
+
* invocations of the provider returned by `memoize` will return the same
|
|
10
|
+
* promise object.
|
|
11
|
+
*
|
|
12
|
+
* @param provider The provider whose result should be cached indefinitely.
|
|
13
|
+
*/
|
|
14
|
+
<T>(provider: Provider<T>): MemoizedProvider<T>;
|
|
15
|
+
/**
|
|
16
|
+
* Decorates a provider function with refreshing memoization.
|
|
17
|
+
*
|
|
18
|
+
* @param provider The provider whose result should be cached.
|
|
19
|
+
* @param isExpired A function that will evaluate the resolved value and
|
|
20
|
+
* determine if it is expired. For example, when
|
|
21
|
+
* memoizing AWS credential providers, this function
|
|
22
|
+
* should return `true` when the credential's
|
|
23
|
+
* expiration is in the past (or very near future) and
|
|
24
|
+
* `false` otherwise.
|
|
25
|
+
* @param requiresRefresh A function that will evaluate the resolved value and
|
|
26
|
+
* determine if it represents static value or one that
|
|
27
|
+
* will eventually need to be refreshed. For example,
|
|
28
|
+
* AWS credentials that have no defined expiration will
|
|
29
|
+
* never need to be refreshed, so this function would
|
|
30
|
+
* return `true` if the credentials resolved by the
|
|
31
|
+
* underlying provider had an expiration and `false`
|
|
32
|
+
* otherwise.
|
|
33
|
+
*/
|
|
34
|
+
<T>(provider: Provider<T>, isExpired: (resolved: T) => boolean, requiresRefresh?: (resolved: T) => boolean): MemoizedProvider<T>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
|
+
export declare const memoize: MemoizeOverload;
|
|
40
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smithy/property-provider",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"scripts": {
|
|
5
|
-
"build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
|
|
5
|
+
"build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types && yarn build:types:downlevel'",
|
|
6
6
|
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
7
7
|
"build:es": "tsc -p tsconfig.es.json",
|
|
8
8
|
"build:types": "tsc -p tsconfig.types.json",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"license": "Apache-2.0",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@smithy/types": "^1.1.
|
|
25
|
+
"@smithy/types": "^1.1.1",
|
|
26
26
|
"tslib": "^2.5.0"
|
|
27
27
|
},
|
|
28
28
|
"engines": {
|