@aws-sdk/credential-providers 3.85.0 → 3.87.0

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/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [3.87.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.86.0...v3.87.0) (2022-05-09)
7
+
8
+
9
+ ### Features
10
+
11
+ * **credential-providers:** expose node.js default credential provider chain ([#3588](https://github.com/aws/aws-sdk-js-v3/issues/3588)) ([51aaffc](https://github.com/aws/aws-sdk-js-v3/commit/51aaffc37838e403b5934132bfe2c277a28c3ea5))
12
+
13
+
14
+
15
+
16
+
6
17
  # [3.85.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.84.0...v3.85.0) (2022-05-05)
7
18
 
8
19
  **Note:** Version bump only for package @aws-sdk/credential-providers
package/README.md CHANGED
@@ -23,6 +23,7 @@ A collection of all credential providers, with default clients.
23
23
  1. [Supported Configuration](#supported-configuration)
24
24
  1. [SSO login with AWS CLI](#sso-login-with-the-aws-cli)
25
25
  1. [Sample Files](#sample-files-2)
26
+ 1. [From Node.js default credentials provider chain](#fromNodeProviderChain)
26
27
 
27
28
  ## `fromCognitoIdentity()`
28
29
 
@@ -119,7 +120,7 @@ const client = new FooClient({
119
120
  // Optional. The master credentials used to get and refresh temporary credentials from AWS STS.
120
121
  // If skipped, it uses the default credential resolved by internal STS client.
121
122
  masterCredentials: fromTemporaryCredentials({
122
- params: { RoleArn: "arn:aws:iam::1234567890:role/RoleA" }
123
+ params: { RoleArn: "arn:aws:iam::1234567890:role/RoleA" },
123
124
  }),
124
125
  // Required. Options passed to STS AssumeRole operation.
125
126
  params: {
@@ -129,16 +130,16 @@ const client = new FooClient({
129
130
  // session name with prefix of 'aws-sdk-js-'.
130
131
  RoleSessionName: "aws-sdk-js-123",
131
132
  // Optional. The duration, in seconds, of the role session.
132
- DurationSeconds: 3600
133
+ DurationSeconds: 3600,
133
134
  // ... For more options see https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRole.html
134
135
  },
135
136
  // Optional. Custom STS client configurations overriding the default ones.
136
137
  clientConfig: { region },
137
138
  // Optional. A function that returns a promise fulfilled with an MFA token code for the provided
138
139
  // MFA Serial code. Required if `params` has `SerialNumber` config.
139
- mfaCodeProvider: async mfaSerial => {
140
- return "token"
141
- }
140
+ mfaCodeProvider: async (mfaSerial) => {
141
+ return "token";
142
+ },
142
143
  }),
143
144
  });
144
145
  ```
@@ -593,7 +594,7 @@ Successfully signed out of all SSO profiles.
593
594
  ### Sample files
594
595
 
595
596
  This credential provider is only applicable if the profile specified in shared configuration and
596
- credentials files contain ALL of the following entries:
597
+ credentials files contain ALL of the following entries.
597
598
 
598
599
  #### `~/.aws/credentials`
599
600
 
@@ -615,6 +616,40 @@ sso_role_name = SampleRole
615
616
  sso_start_url = https://d-abc123.awsapps.com/start
616
617
  ```
617
618
 
619
+ ## `fromNodeProviderChain()`
620
+
621
+ The credential provider used as default in the Node.js clients, but with default role assumers so
622
+ you don't need to import them from STS client and supply them manually. You normally don't need
623
+ to use this explicitly in the client constructor. It is useful for utility functions requiring
624
+ credentials like S3 presigner, or RDS signer.
625
+
626
+ This credential provider will attempt to find credentials from the following sources (listed in
627
+ order of precedence):
628
+
629
+ - [Environment variables exposed via `process.env`](#fromenv)
630
+ - [SSO credentials from token cache](#fromsso)
631
+ - [Web identity token credentials](#fromtokenfile)
632
+ - [Shared credentials and config ini files](#fromini)
633
+ - [The EC2/ECS Instance Metadata Service](#fromcontainermetadata-and-frominstancemetadata)
634
+
635
+ This credential provider will invoke one provider at a time and only
636
+ continue to the next if no credentials have been located. For example, if
637
+ the process finds values defined via the `AWS_ACCESS_KEY_ID` and
638
+ `AWS_SECRET_ACCESS_KEY` environment variables, the files at
639
+ `~/.aws/credentials` and `~/.aws/config` will not be read, nor will any
640
+ messages be sent to the Instance Metadata Service
641
+
642
+ ```js
643
+ import { fromNodeProviderChain } from "@aws-sdk/credential-providers"; // ES6 import
644
+ // const { fromNodeProviderChain } = require("@aws-sdk/credential-providers") // CommonJS import
645
+ const credentialProvider = fromNodeProviderChain({
646
+ //...any input of fromEnv(), fromSSO(), fromTokenFile(), fromIni(),
647
+ // fromProcess(), fromInstanceMetadata(), fromContainerMetadata()
648
+ // Optional. Custom STS client configurations overriding the default ones.
649
+ clientConfig: { region },
650
+ });
651
+ ```
652
+
618
653
  [getcredentialsforidentity_api]: https://docs.aws.amazon.com/cognitoidentity/latest/APIReference/API_GetCredentialsForIdentity.html
619
654
  [getid_api]: https://docs.aws.amazon.com/cognitoidentity/latest/APIReference/API_GetId.html
620
655
  [assumerole_api]: https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRole.html
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fromNodeProviderChain = void 0;
4
+ const client_sts_1 = require("@aws-sdk/client-sts");
5
+ const credential_provider_node_1 = require("@aws-sdk/credential-provider-node");
6
+ const fromNodeProviderChain = (init = {}) => {
7
+ var _a, _b;
8
+ return (0, credential_provider_node_1.defaultProvider)({
9
+ ...init,
10
+ roleAssumer: (_a = init.roleAssumer) !== null && _a !== void 0 ? _a : (0, client_sts_1.getDefaultRoleAssumer)(init.clientConfig),
11
+ roleAssumerWithWebIdentity: (_b = init.roleAssumerWithWebIdentity) !== null && _b !== void 0 ? _b : (0, client_sts_1.getDefaultRoleAssumerWithWebIdentity)(init.clientConfig),
12
+ });
13
+ };
14
+ exports.fromNodeProviderChain = fromNodeProviderChain;
package/dist-cjs/index.js CHANGED
@@ -7,6 +7,7 @@ tslib_1.__exportStar(require("./fromContainerMetadata"), exports);
7
7
  tslib_1.__exportStar(require("./fromEnv"), exports);
8
8
  tslib_1.__exportStar(require("./fromIni"), exports);
9
9
  tslib_1.__exportStar(require("./fromInstanceMetadata"), exports);
10
+ tslib_1.__exportStar(require("./fromNodeProviderChain"), exports);
10
11
  tslib_1.__exportStar(require("./fromProcess"), exports);
11
12
  tslib_1.__exportStar(require("./fromSSO"), exports);
12
13
  tslib_1.__exportStar(require("./fromTemporaryCredentials"), exports);
@@ -0,0 +1,8 @@
1
+ import { __assign } from "tslib";
2
+ import { getDefaultRoleAssumer, getDefaultRoleAssumerWithWebIdentity } from "@aws-sdk/client-sts";
3
+ import { defaultProvider } from "@aws-sdk/credential-provider-node";
4
+ export var fromNodeProviderChain = function (init) {
5
+ var _a, _b;
6
+ if (init === void 0) { init = {}; }
7
+ return defaultProvider(__assign(__assign({}, init), { roleAssumer: (_a = init.roleAssumer) !== null && _a !== void 0 ? _a : getDefaultRoleAssumer(init.clientConfig), roleAssumerWithWebIdentity: (_b = init.roleAssumerWithWebIdentity) !== null && _b !== void 0 ? _b : getDefaultRoleAssumerWithWebIdentity(init.clientConfig) }));
8
+ };
package/dist-es/index.js CHANGED
@@ -4,6 +4,7 @@ export * from "./fromContainerMetadata";
4
4
  export * from "./fromEnv";
5
5
  export * from "./fromIni";
6
6
  export * from "./fromInstanceMetadata";
7
+ export * from "./fromNodeProviderChain";
7
8
  export * from "./fromProcess";
8
9
  export * from "./fromSSO";
9
10
  export * from "./fromTemporaryCredentials";
@@ -0,0 +1,29 @@
1
+ import { STSClientConfig } from "@aws-sdk/client-sts";
2
+ import { DefaultProviderInit } from "@aws-sdk/credential-provider-node";
3
+ import { CredentialProvider } from "@aws-sdk/types";
4
+ export interface fromNodeProviderChainInit extends DefaultProviderInit {
5
+ clientConfig?: STSClientConfig;
6
+ }
7
+ /**
8
+ * This is the same credential provider as {@link defaultProvider|the default provider for Node.js SDK},
9
+ * but with default role assumers so you don't need to import them from
10
+ * STS client and supply them manually.
11
+ *
12
+ * You normally don't need to use this explicitly in the client constructor.
13
+ * It is useful for utility functions requiring credentials like S3 presigner,
14
+ * or RDS signer.
15
+ *
16
+ * ```js
17
+ * import { fromNodeProviderChain } from "@aws-sdk/credential-providers"; // ES6 import
18
+ * // const { fromNodeProviderChain } = require("@aws-sdk/credential-providers") // CommonJS import
19
+ *
20
+ * const credentialProvider = fromNodeProviderChain({
21
+ * //...any input of fromEnv(), fromSSO(), fromTokenFile(), fromIni(),
22
+ * // fromProcess(), fromInstanceMetadata(), fromContainerMetadata()
23
+ *
24
+ * // Optional. Custom STS client configurations overriding the default ones.
25
+ * clientConfig: { region },
26
+ * })
27
+ * ```
28
+ */
29
+ export declare const fromNodeProviderChain: (init?: fromNodeProviderChainInit) => CredentialProvider;
@@ -4,6 +4,7 @@ export * from "./fromContainerMetadata";
4
4
  export * from "./fromEnv";
5
5
  export * from "./fromIni";
6
6
  export * from "./fromInstanceMetadata";
7
+ export * from "./fromNodeProviderChain";
7
8
  export * from "./fromProcess";
8
9
  export * from "./fromSSO";
9
10
  export * from "./fromTemporaryCredentials";
@@ -0,0 +1,8 @@
1
+ import { STSClientConfig } from "@aws-sdk/client-sts";
2
+ import { DefaultProviderInit } from "@aws-sdk/credential-provider-node";
3
+ import { CredentialProvider } from "@aws-sdk/types";
4
+ export interface fromNodeProviderChainInit extends DefaultProviderInit {
5
+ clientConfig?: STSClientConfig;
6
+ }
7
+
8
+ export declare const fromNodeProviderChain: (init?: fromNodeProviderChainInit) => CredentialProvider;
@@ -4,6 +4,7 @@ export * from "./fromContainerMetadata";
4
4
  export * from "./fromEnv";
5
5
  export * from "./fromIni";
6
6
  export * from "./fromInstanceMetadata";
7
+ export * from "./fromNodeProviderChain";
7
8
  export * from "./fromProcess";
8
9
  export * from "./fromSSO";
9
10
  export * from "./fromTemporaryCredentials";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/credential-providers",
3
- "version": "3.85.0",
3
+ "version": "3.87.0",
4
4
  "description": "A collection of credential providers, without requiring service clients like STS, Cognito",
5
5
  "main": "./dist-cjs/index.js",
6
6
  "module": "./dist-es/index.js",
@@ -26,13 +26,14 @@
26
26
  },
27
27
  "license": "Apache-2.0",
28
28
  "dependencies": {
29
- "@aws-sdk/client-cognito-identity": "3.85.0",
29
+ "@aws-sdk/client-cognito-identity": "3.87.0",
30
30
  "@aws-sdk/client-sso": "3.85.0",
31
- "@aws-sdk/client-sts": "3.85.0",
32
- "@aws-sdk/credential-provider-cognito-identity": "3.85.0",
31
+ "@aws-sdk/client-sts": "3.87.0",
32
+ "@aws-sdk/credential-provider-cognito-identity": "3.87.0",
33
33
  "@aws-sdk/credential-provider-env": "3.78.0",
34
34
  "@aws-sdk/credential-provider-imds": "3.81.0",
35
35
  "@aws-sdk/credential-provider-ini": "3.85.0",
36
+ "@aws-sdk/credential-provider-node": "3.87.0",
36
37
  "@aws-sdk/credential-provider-process": "3.80.0",
37
38
  "@aws-sdk/credential-provider-sso": "3.85.0",
38
39
  "@aws-sdk/credential-provider-web-identity": "3.78.0",