@aws-sdk/credential-provider-web-identity 3.178.0 → 3.183.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,14 @@
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.183.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.182.0...v3.183.0) (2022-10-03)
7
+
8
+ **Note:** Version bump only for package @aws-sdk/credential-provider-web-identity
9
+
10
+
11
+
12
+
13
+
6
14
  # [3.178.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.177.0...v3.178.0) (2022-09-23)
7
15
 
8
16
  **Note:** Version bump only for package @aws-sdk/credential-provider-web-identity
@@ -1,25 +1,23 @@
1
- import { __assign, __awaiter, __generator } from "tslib";
2
1
  import { CredentialsProviderError } from "@aws-sdk/property-provider";
3
2
  import { readFileSync } from "fs";
4
3
  import { fromWebToken } from "./fromWebToken";
5
- var ENV_TOKEN_FILE = "AWS_WEB_IDENTITY_TOKEN_FILE";
6
- var ENV_ROLE_ARN = "AWS_ROLE_ARN";
7
- var ENV_ROLE_SESSION_NAME = "AWS_ROLE_SESSION_NAME";
8
- export var fromTokenFile = function (init) {
9
- if (init === void 0) { init = {}; }
10
- return function () { return __awaiter(void 0, void 0, void 0, function () {
11
- return __generator(this, function (_a) {
12
- return [2, resolveTokenFile(init)];
13
- });
14
- }); };
4
+ const ENV_TOKEN_FILE = "AWS_WEB_IDENTITY_TOKEN_FILE";
5
+ const ENV_ROLE_ARN = "AWS_ROLE_ARN";
6
+ const ENV_ROLE_SESSION_NAME = "AWS_ROLE_SESSION_NAME";
7
+ export const fromTokenFile = (init = {}) => async () => {
8
+ return resolveTokenFile(init);
15
9
  };
16
- var resolveTokenFile = function (init) {
17
- var _a, _b, _c;
18
- var webIdentityTokenFile = (_a = init === null || init === void 0 ? void 0 : init.webIdentityTokenFile) !== null && _a !== void 0 ? _a : process.env[ENV_TOKEN_FILE];
19
- var roleArn = (_b = init === null || init === void 0 ? void 0 : init.roleArn) !== null && _b !== void 0 ? _b : process.env[ENV_ROLE_ARN];
20
- var roleSessionName = (_c = init === null || init === void 0 ? void 0 : init.roleSessionName) !== null && _c !== void 0 ? _c : process.env[ENV_ROLE_SESSION_NAME];
10
+ const resolveTokenFile = (init) => {
11
+ const webIdentityTokenFile = init?.webIdentityTokenFile ?? process.env[ENV_TOKEN_FILE];
12
+ const roleArn = init?.roleArn ?? process.env[ENV_ROLE_ARN];
13
+ const roleSessionName = init?.roleSessionName ?? process.env[ENV_ROLE_SESSION_NAME];
21
14
  if (!webIdentityTokenFile || !roleArn) {
22
15
  throw new CredentialsProviderError("Web identity configuration not specified");
23
16
  }
24
- return fromWebToken(__assign(__assign({}, init), { webIdentityToken: readFileSync(webIdentityTokenFile, { encoding: "ascii" }), roleArn: roleArn, roleSessionName: roleSessionName }))();
17
+ return fromWebToken({
18
+ ...init,
19
+ webIdentityToken: readFileSync(webIdentityTokenFile, { encoding: "ascii" }),
20
+ roleArn,
21
+ roleSessionName,
22
+ })();
25
23
  };
@@ -1,19 +1,17 @@
1
1
  import { CredentialsProviderError } from "@aws-sdk/property-provider";
2
- export var fromWebToken = function (init) {
3
- return function () {
4
- var roleArn = init.roleArn, roleSessionName = init.roleSessionName, webIdentityToken = init.webIdentityToken, providerId = init.providerId, policyArns = init.policyArns, policy = init.policy, durationSeconds = init.durationSeconds, roleAssumerWithWebIdentity = init.roleAssumerWithWebIdentity;
5
- if (!roleAssumerWithWebIdentity) {
6
- throw new CredentialsProviderError("Role Arn '".concat(roleArn, "' needs to be assumed with web identity,") +
7
- " but no role assumption callback was provided.", false);
8
- }
9
- return roleAssumerWithWebIdentity({
10
- RoleArn: roleArn,
11
- RoleSessionName: roleSessionName !== null && roleSessionName !== void 0 ? roleSessionName : "aws-sdk-js-session-".concat(Date.now()),
12
- WebIdentityToken: webIdentityToken,
13
- ProviderId: providerId,
14
- PolicyArns: policyArns,
15
- Policy: policy,
16
- DurationSeconds: durationSeconds,
17
- });
18
- };
2
+ export const fromWebToken = (init) => () => {
3
+ const { roleArn, roleSessionName, webIdentityToken, providerId, policyArns, policy, durationSeconds, roleAssumerWithWebIdentity, } = init;
4
+ if (!roleAssumerWithWebIdentity) {
5
+ throw new CredentialsProviderError(`Role Arn '${roleArn}' needs to be assumed with web identity,` +
6
+ ` but no role assumption callback was provided.`, false);
7
+ }
8
+ return roleAssumerWithWebIdentity({
9
+ RoleArn: roleArn,
10
+ RoleSessionName: roleSessionName ?? `aws-sdk-js-session-${Date.now()}`,
11
+ WebIdentityToken: webIdentityToken,
12
+ ProviderId: providerId,
13
+ PolicyArns: policyArns,
14
+ Policy: policy,
15
+ DurationSeconds: durationSeconds,
16
+ });
19
17
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/credential-provider-web-identity",
3
- "version": "3.178.0",
3
+ "version": "3.183.0",
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",
@@ -32,8 +32,8 @@
32
32
  },
33
33
  "license": "Apache-2.0",
34
34
  "dependencies": {
35
- "@aws-sdk/property-provider": "3.178.0",
36
- "@aws-sdk/types": "3.178.0",
35
+ "@aws-sdk/property-provider": "3.183.0",
36
+ "@aws-sdk/types": "3.183.0",
37
37
  "tslib": "^2.3.1"
38
38
  },
39
39
  "devDependencies": {