@aws-sdk/credential-providers
Advanced tools
Comparing version 3.629.0 to 3.630.0
@@ -5,8 +5,9 @@ "use strict"; | ||
const tslib_1 = require("tslib"); | ||
tslib_1.__exportStar(require("./createCredentialChain"), exports); | ||
tslib_1.__exportStar(require("./fromCognitoIdentity"), exports); | ||
tslib_1.__exportStar(require("./fromCognitoIdentityPool"), exports); | ||
tslib_1.__exportStar(require("./fromContainerMetadata"), exports); | ||
tslib_1.__exportStar(require("./fromEnv"), exports); | ||
var credential_provider_http_1 = require("@aws-sdk/credential-provider-http"); | ||
Object.defineProperty(exports, "fromHttp", { enumerable: true, get: function () { return credential_provider_http_1.fromHttp; } }); | ||
tslib_1.__exportStar(require("./fromEnv"), exports); | ||
tslib_1.__exportStar(require("./fromIni"), exports); | ||
@@ -13,0 +14,0 @@ tslib_1.__exportStar(require("./fromInstanceMetadata"), exports); |
@@ -0,6 +1,7 @@ | ||
export * from "./createCredentialChain"; | ||
export * from "./fromCognitoIdentity"; | ||
export * from "./fromCognitoIdentityPool"; | ||
export * from "./fromContainerMetadata"; | ||
export { fromHttp } from "@aws-sdk/credential-provider-http"; | ||
export * from "./fromEnv"; | ||
export { fromHttp } from "@aws-sdk/credential-provider-http"; | ||
export * from "./fromIni"; | ||
@@ -7,0 +8,0 @@ export * from "./fromInstanceMetadata"; |
@@ -0,6 +1,7 @@ | ||
export * from "./createCredentialChain"; | ||
export * from "./fromCognitoIdentity"; | ||
export * from "./fromCognitoIdentityPool"; | ||
export * from "./fromContainerMetadata"; | ||
export { fromHttp, FromHttpOptions, HttpProviderCredentials } from "@aws-sdk/credential-provider-http"; | ||
export * from "./fromEnv"; | ||
export { fromHttp, FromHttpOptions, HttpProviderCredentials } from "@aws-sdk/credential-provider-http"; | ||
export * from "./fromIni"; | ||
@@ -7,0 +8,0 @@ export * from "./fromInstanceMetadata"; |
@@ -0,5 +1,5 @@ | ||
export * from "./createCredentialChain"; | ||
export * from "./fromCognitoIdentity"; | ||
export * from "./fromCognitoIdentityPool"; | ||
export * from "./fromContainerMetadata"; | ||
export * from "./fromEnv"; | ||
export { | ||
@@ -10,2 +10,3 @@ fromHttp, | ||
} from "@aws-sdk/credential-provider-http"; | ||
export * from "./fromEnv"; | ||
export * from "./fromIni"; | ||
@@ -12,0 +13,0 @@ export * from "./fromInstanceMetadata"; |
{ | ||
"name": "@aws-sdk/credential-providers", | ||
"version": "3.629.0", | ||
"version": "3.630.0", | ||
"description": "A collection of credential providers, without requiring service clients like STS, Cognito", | ||
@@ -5,0 +5,0 @@ "main": "./dist-cjs/index.js", |
@@ -28,2 +28,3 @@ # @aws-sdk/credential-providers | ||
1. [From Node.js default credentials provider chain](#fromNodeProviderChain) | ||
1. [Creating a custom credentials chain](#createCredentialChain) | ||
@@ -708,3 +709,3 @@ ## `fromCognitoIdentity()` | ||
//... | ||
const client = new FooClient({ credentials: fromSSO({ profile: "my-sso-profile" })}); | ||
const client = new FooClient({ credentials: fromSSO({ profile: "my-sso-profile" }) }); | ||
``` | ||
@@ -716,3 +717,3 @@ | ||
//... | ||
const client = new FooClient({ credentials: fromIni({ profile: "my-sso-profile" })}); | ||
const client = new FooClient({ credentials: fromIni({ profile: "my-sso-profile" }) }); | ||
``` | ||
@@ -790,2 +791,56 @@ | ||
## `createCredentialChain()` | ||
You can use this helper to create a credential chain of your own. | ||
A credential chain is created from a list of functions of the signature () => Promise<[AwsCredentialIdentity](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-smithy-types/Interface/AwsCredentialIdentity/)>, | ||
composed together such that the overall chain has the **same** signature. | ||
That is why you can provide the chained credential provider to the same field (`credentials`) as any single provider function. | ||
All the providers from this package are compatible, and can be used to create such a chain. | ||
As with _any_ function provided to the `credentials` SDK client constructor configuration field, if the credential object returned does not contain | ||
an `expiration` (type `Date`), the client will only ever call the provider function once. You do not need to memoize this function. | ||
To enable automatic refresh, the credential provider function should set an `expiration` (`Date`) field. When this expiration approaches within 5 minutes, the | ||
provider function will be called again by the client in the course of making SDK requests. | ||
To assist with this, the `createCredentialChain` has a chainable helper `.expireAfter(milliseconds: number)`. An example is included below. | ||
```ts | ||
import { fromEnv, fromIni, createCredentialChain } from "@aws-sdk/credential-providers"; | ||
import { S3 } from "@aws-sdk/client-s3"; | ||
// You can mix existing AWS SDK credential providers | ||
// and custom async functions returning credential objects. | ||
new S3({ | ||
credentials: createCredentialChain( | ||
fromEnv(), | ||
async () => { | ||
// credentials customized by your code... | ||
return credentials; | ||
}, | ||
fromIni() | ||
), | ||
}); | ||
// Set a max duration on the credentials (client side only). | ||
// A set expiration will cause the credentials function to be called again | ||
// when the time left is less than 5 minutes. | ||
new S3({ | ||
// This setting indicates expiry after 15 minutes (in milliseconds) with `15 * 60_000`. | ||
// Due to the 5 minute expiry window, the function will be called approximately every | ||
// 10 minutes under continuous usage of this client. | ||
credentials: createCredentialChain(fromEnv(), fromIni()).expireAfter(15 * 60_000), | ||
}); | ||
// Apply shared init properties. | ||
const init = { logger: console }; | ||
new S3({ | ||
credentials: createCredentialChain(fromEnv(init), fromIni(init)), | ||
}); | ||
``` | ||
## Add Custom Headers to STS assume-role calls | ||
@@ -792,0 +847,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
96747
67
978
882