@aws-sdk/credential-provider-web-identity
Advanced tools
Comparing version 3.186.0 to 3.188.0
@@ -6,2 +6,10 @@ # Change Log | ||
# [3.188.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.187.0...v3.188.0) (2022-10-13) | ||
**Note:** Version bump only for package @aws-sdk/credential-provider-web-identity | ||
# [3.186.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.185.0...v3.186.0) (2022-10-06) | ||
@@ -8,0 +16,0 @@ |
@@ -1,25 +0,23 @@ | ||
import { __assign, __awaiter, __generator } from "tslib"; | ||
import { CredentialsProviderError } from "@aws-sdk/property-provider"; | ||
import { readFileSync } from "fs"; | ||
import { fromWebToken } from "./fromWebToken"; | ||
var ENV_TOKEN_FILE = "AWS_WEB_IDENTITY_TOKEN_FILE"; | ||
var ENV_ROLE_ARN = "AWS_ROLE_ARN"; | ||
var ENV_ROLE_SESSION_NAME = "AWS_ROLE_SESSION_NAME"; | ||
export var fromTokenFile = function (init) { | ||
if (init === void 0) { init = {}; } | ||
return function () { return __awaiter(void 0, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2, resolveTokenFile(init)]; | ||
}); | ||
}); }; | ||
const ENV_TOKEN_FILE = "AWS_WEB_IDENTITY_TOKEN_FILE"; | ||
const ENV_ROLE_ARN = "AWS_ROLE_ARN"; | ||
const ENV_ROLE_SESSION_NAME = "AWS_ROLE_SESSION_NAME"; | ||
export const fromTokenFile = (init = {}) => async () => { | ||
return resolveTokenFile(init); | ||
}; | ||
var resolveTokenFile = function (init) { | ||
var _a, _b, _c; | ||
var webIdentityTokenFile = (_a = init === null || init === void 0 ? void 0 : init.webIdentityTokenFile) !== null && _a !== void 0 ? _a : process.env[ENV_TOKEN_FILE]; | ||
var roleArn = (_b = init === null || init === void 0 ? void 0 : init.roleArn) !== null && _b !== void 0 ? _b : process.env[ENV_ROLE_ARN]; | ||
var roleSessionName = (_c = init === null || init === void 0 ? void 0 : init.roleSessionName) !== null && _c !== void 0 ? _c : process.env[ENV_ROLE_SESSION_NAME]; | ||
const resolveTokenFile = (init) => { | ||
const webIdentityTokenFile = init?.webIdentityTokenFile ?? process.env[ENV_TOKEN_FILE]; | ||
const roleArn = init?.roleArn ?? process.env[ENV_ROLE_ARN]; | ||
const roleSessionName = init?.roleSessionName ?? process.env[ENV_ROLE_SESSION_NAME]; | ||
if (!webIdentityTokenFile || !roleArn) { | ||
throw new CredentialsProviderError("Web identity configuration not specified"); | ||
} | ||
return fromWebToken(__assign(__assign({}, init), { webIdentityToken: readFileSync(webIdentityTokenFile, { encoding: "ascii" }), roleArn: roleArn, roleSessionName: roleSessionName }))(); | ||
return fromWebToken({ | ||
...init, | ||
webIdentityToken: readFileSync(webIdentityTokenFile, { encoding: "ascii" }), | ||
roleArn, | ||
roleSessionName, | ||
})(); | ||
}; |
import { CredentialsProviderError } from "@aws-sdk/property-provider"; | ||
export var fromWebToken = function (init) { | ||
return function () { | ||
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; | ||
if (!roleAssumerWithWebIdentity) { | ||
throw new CredentialsProviderError("Role Arn '".concat(roleArn, "' needs to be assumed with web identity,") + | ||
" but no role assumption callback was provided.", false); | ||
} | ||
return roleAssumerWithWebIdentity({ | ||
RoleArn: roleArn, | ||
RoleSessionName: roleSessionName !== null && roleSessionName !== void 0 ? roleSessionName : "aws-sdk-js-session-".concat(Date.now()), | ||
WebIdentityToken: webIdentityToken, | ||
ProviderId: providerId, | ||
PolicyArns: policyArns, | ||
Policy: policy, | ||
DurationSeconds: durationSeconds, | ||
}); | ||
}; | ||
export const fromWebToken = (init) => () => { | ||
const { roleArn, roleSessionName, webIdentityToken, providerId, policyArns, policy, durationSeconds, roleAssumerWithWebIdentity, } = init; | ||
if (!roleAssumerWithWebIdentity) { | ||
throw new CredentialsProviderError(`Role Arn '${roleArn}' needs to be assumed with web identity,` + | ||
` but no role assumption callback was provided.`, false); | ||
} | ||
return roleAssumerWithWebIdentity({ | ||
RoleArn: roleArn, | ||
RoleSessionName: roleSessionName ?? `aws-sdk-js-session-${Date.now()}`, | ||
WebIdentityToken: webIdentityToken, | ||
ProviderId: providerId, | ||
PolicyArns: policyArns, | ||
Policy: policy, | ||
DurationSeconds: durationSeconds, | ||
}); | ||
}; |
{ | ||
"name": "@aws-sdk/credential-provider-web-identity", | ||
"version": "3.186.0", | ||
"version": "3.188.0", | ||
"description": "AWS credential provider that calls STS assumeRole for temporary AWS credentials", | ||
@@ -35,4 +35,4 @@ "main": "./dist-cjs/index.js", | ||
"dependencies": { | ||
"@aws-sdk/property-provider": "3.186.0", | ||
"@aws-sdk/types": "3.186.0", | ||
"@aws-sdk/property-provider": "3.188.0", | ||
"@aws-sdk/types": "3.188.0", | ||
"tslib": "^2.3.1" | ||
@@ -39,0 +39,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
137
4
4
2
43
39295
281
+ Added@aws-sdk/property-provider@3.188.0(transitive)
+ Added@aws-sdk/types@3.188.0(transitive)
- Removed@aws-sdk/property-provider@3.186.0(transitive)
- Removed@aws-sdk/types@3.186.0(transitive)
Updated@aws-sdk/types@3.188.0