@aws-sdk/credential-provider-web-identity 3.972.55 → 3.972.57

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-cjs/index.js CHANGED
@@ -1,3 +1,58 @@
1
- var __exportStar = (m, e) => { Object.assign(e, m); };
2
- __exportStar(require("./fromTokenFile"), exports);
3
- __exportStar(require("./fromWebToken"), exports);
1
+ const { setCredentialFeature } = require("@aws-sdk/core/client");
2
+ const { CredentialsProviderError, externalDataInterceptor } = require("@smithy/core/config");
3
+ const { readFileSync } = require("node:fs");
4
+
5
+ const fromWebToken = (init) => async (awsIdentityProperties) => {
6
+ init.logger?.debug("@aws-sdk/credential-provider-web-identity - fromWebToken");
7
+ const { roleArn, roleSessionName, webIdentityToken, providerId, policyArns, policy, durationSeconds } = init;
8
+ let { roleAssumerWithWebIdentity } = init;
9
+ if (!roleAssumerWithWebIdentity) {
10
+ const { getDefaultRoleAssumerWithWebIdentity } = require('@aws-sdk/nested-clients/sts');
11
+ roleAssumerWithWebIdentity = getDefaultRoleAssumerWithWebIdentity({
12
+ ...init.clientConfig,
13
+ credentialProviderLogger: init.logger,
14
+ parentClientConfig: {
15
+ ...awsIdentityProperties?.callerClientConfig,
16
+ ...init.parentClientConfig,
17
+ },
18
+ }, init.clientPlugins);
19
+ }
20
+ return roleAssumerWithWebIdentity({
21
+ RoleArn: roleArn,
22
+ RoleSessionName: roleSessionName ?? `aws-sdk-js-session-${Date.now()}`,
23
+ WebIdentityToken: webIdentityToken,
24
+ ProviderId: providerId,
25
+ PolicyArns: policyArns,
26
+ Policy: policy,
27
+ DurationSeconds: durationSeconds,
28
+ });
29
+ };
30
+
31
+ const ENV_TOKEN_FILE = "AWS_WEB_IDENTITY_TOKEN_FILE";
32
+ const ENV_ROLE_ARN = "AWS_ROLE_ARN";
33
+ const ENV_ROLE_SESSION_NAME = "AWS_ROLE_SESSION_NAME";
34
+ const fromTokenFile = (init = {}) => async (awsIdentityProperties) => {
35
+ init.logger?.debug("@aws-sdk/credential-provider-web-identity - fromTokenFile");
36
+ const webIdentityTokenFile = init?.webIdentityTokenFile ?? process.env[ENV_TOKEN_FILE];
37
+ const roleArn = init?.roleArn ?? process.env[ENV_ROLE_ARN];
38
+ const roleSessionName = init?.roleSessionName ?? process.env[ENV_ROLE_SESSION_NAME];
39
+ if (!webIdentityTokenFile || !roleArn) {
40
+ throw new CredentialsProviderError("Web identity configuration not specified", {
41
+ logger: init.logger,
42
+ });
43
+ }
44
+ const credentials = await fromWebToken({
45
+ ...init,
46
+ webIdentityToken: externalDataInterceptor?.getTokenRecord?.()[webIdentityTokenFile] ??
47
+ readFileSync(webIdentityTokenFile, { encoding: "ascii" }),
48
+ roleArn,
49
+ roleSessionName,
50
+ })(awsIdentityProperties);
51
+ if (webIdentityTokenFile === process.env[ENV_TOKEN_FILE]) {
52
+ setCredentialFeature(credentials, "CREDENTIALS_ENV_VARS_STS_WEB_ID_TOKEN", "h");
53
+ }
54
+ return credentials;
55
+ };
56
+
57
+ exports.fromTokenFile = fromTokenFile;
58
+ exports.fromWebToken = fromWebToken;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/credential-provider-web-identity",
3
- "version": "3.972.55",
3
+ "version": "3.972.57",
4
4
  "description": "AWS credential provider that calls STS assumeRole for temporary AWS credentials",
5
5
  "main": "./dist-cjs/index.js",
6
6
  "module": "./dist-es/index.js",
@@ -20,8 +20,7 @@
20
20
  "./dist-es/fromTokenFile": false
21
21
  },
22
22
  "react-native": {
23
- "./dist-es/fromTokenFile": false,
24
- "./dist-cjs/fromTokenFile": false
23
+ "./dist-es/fromTokenFile": false
25
24
  },
26
25
  "keywords": [
27
26
  "aws",
@@ -34,11 +33,11 @@
34
33
  },
35
34
  "license": "Apache-2.0",
36
35
  "dependencies": {
37
- "@aws-sdk/core": "^3.974.23",
38
- "@aws-sdk/nested-clients": "^3.997.23",
39
- "@aws-sdk/types": "^3.973.13",
40
- "@smithy/core": "^3.24.6",
41
- "@smithy/types": "^4.14.3",
36
+ "@aws-sdk/core": "^3.974.25",
37
+ "@aws-sdk/nested-clients": "^3.997.25",
38
+ "@aws-sdk/types": "^3.973.14",
39
+ "@smithy/core": "^3.28.0",
40
+ "@smithy/types": "^4.15.0",
42
41
  "tslib": "^2.6.2"
43
42
  },
44
43
  "devDependencies": {
@@ -1,29 +0,0 @@
1
- const { setCredentialFeature } = require("@aws-sdk/core/client");
2
- const { CredentialsProviderError, externalDataInterceptor } = require("@smithy/core/config");
3
- const { readFileSync } = require("node:fs");
4
- const { fromWebToken } = require("./fromWebToken");
5
- const ENV_TOKEN_FILE = "AWS_WEB_IDENTITY_TOKEN_FILE";
6
- const ENV_ROLE_ARN = "AWS_ROLE_ARN";
7
- const ENV_ROLE_SESSION_NAME = "AWS_ROLE_SESSION_NAME";
8
- exports.fromTokenFile = (init = {}) => async (awsIdentityProperties) => {
9
- init.logger?.debug("@aws-sdk/credential-provider-web-identity - fromTokenFile");
10
- const webIdentityTokenFile = init?.webIdentityTokenFile ?? process.env[ENV_TOKEN_FILE];
11
- const roleArn = init?.roleArn ?? process.env[ENV_ROLE_ARN];
12
- const roleSessionName = init?.roleSessionName ?? process.env[ENV_ROLE_SESSION_NAME];
13
- if (!webIdentityTokenFile || !roleArn) {
14
- throw new CredentialsProviderError("Web identity configuration not specified", {
15
- logger: init.logger,
16
- });
17
- }
18
- const credentials = await fromWebToken({
19
- ...init,
20
- webIdentityToken: externalDataInterceptor?.getTokenRecord?.()[webIdentityTokenFile] ??
21
- readFileSync(webIdentityTokenFile, { encoding: "ascii" }),
22
- roleArn,
23
- roleSessionName,
24
- })(awsIdentityProperties);
25
- if (webIdentityTokenFile === process.env[ENV_TOKEN_FILE]) {
26
- setCredentialFeature(credentials, "CREDENTIALS_ENV_VARS_STS_WEB_ID_TOKEN", "h");
27
- }
28
- return credentials;
29
- };
@@ -1,25 +0,0 @@
1
- exports.fromWebToken = (init) => async (awsIdentityProperties) => {
2
- init.logger?.debug("@aws-sdk/credential-provider-web-identity - fromWebToken");
3
- const { roleArn, roleSessionName, webIdentityToken, providerId, policyArns, policy, durationSeconds } = init;
4
- let { roleAssumerWithWebIdentity } = init;
5
- if (!roleAssumerWithWebIdentity) {
6
- const { getDefaultRoleAssumerWithWebIdentity } = require("@aws-sdk/nested-clients/sts");
7
- roleAssumerWithWebIdentity = getDefaultRoleAssumerWithWebIdentity({
8
- ...init.clientConfig,
9
- credentialProviderLogger: init.logger,
10
- parentClientConfig: {
11
- ...awsIdentityProperties?.callerClientConfig,
12
- ...init.parentClientConfig,
13
- },
14
- }, init.clientPlugins);
15
- }
16
- return roleAssumerWithWebIdentity({
17
- RoleArn: roleArn,
18
- RoleSessionName: roleSessionName ?? `aws-sdk-js-session-${Date.now()}`,
19
- WebIdentityToken: webIdentityToken,
20
- ProviderId: providerId,
21
- PolicyArns: policyArns,
22
- Policy: policy,
23
- DurationSeconds: durationSeconds,
24
- });
25
- };