chore: CI fixes (#1679)
* clean dist * switch to esbuild * chore: Update dist * update script version for token file test * fix license workflow * chore: Update dist * re-add release-please * newlines --------- Co-authored-by: GitHub Actions <github-aws-sdk-osds-automation@amazon.com>
This commit is contained in:
parent
0820d92983
commit
f8de47bf3e
33 changed files with 96817 additions and 150713 deletions
6
.generatelicensefile.json
Normal file
6
.generatelicensefile.json
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"inputs": ["./package.json"],
|
||||
"output": "./THIRD-PARTY",
|
||||
"overwrite": true,
|
||||
"ci": true
|
||||
}
|
||||
1
.github/workflows/package-dist.yml
vendored
1
.github/workflows/package-dist.yml
vendored
|
|
@ -47,5 +47,6 @@ jobs:
|
|||
git config user.email "github-aws-sdk-osds-automation@amazon.com"
|
||||
git remote set-url origin https://${{ env.OSDS_ACCESS_TOKEN }}@github.com/aws-actions/configure-aws-credentials.git
|
||||
git add dist
|
||||
git add THIRD-PARTY
|
||||
git commit -m "chore: Update dist" || echo "No changes to commit"
|
||||
git push --force origin
|
||||
|
|
|
|||
45
.github/workflows/release-please.yml
vendored
Normal file
45
.github/workflows/release-please.yml
vendored
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
---
|
||||
name: Release Please
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
id-token: write
|
||||
contents: write
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
release-please:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Configure AWS Credentials
|
||||
uses: aws-actions/configure-aws-credentials@v6
|
||||
with:
|
||||
aws-region: us-west-2
|
||||
role-to-assume: ${{ secrets.SECRETS_AWS_PACKAGING_ROLE_TO_ASSUME }}
|
||||
role-duration-seconds: 900
|
||||
role-session-name: ${{ github.run_id }}
|
||||
|
||||
- name: Get git credentials
|
||||
uses: aws-actions/aws-secretsmanager-get-secrets@v2
|
||||
with:
|
||||
parse-json-secrets: true
|
||||
secret-ids: |
|
||||
${{ secrets.OSDS_PACKAGING_ROLE }}
|
||||
|
||||
- name: Run release-please
|
||||
uses: googleapis/release-please-action@v4
|
||||
with:
|
||||
release-type: node
|
||||
token: ${{ env.OSDS_ACCESS_TOKEN }}
|
||||
config-file: release-please-config.json
|
||||
manifest-file: .release-please-manifest.json
|
||||
|
||||
2
.github/workflows/tests-integ-release.yml
vendored
2
.github/workflows/tests-integ-release.yml
vendored
|
|
@ -211,7 +211,7 @@ jobs:
|
|||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
- name: fetch token and write to file
|
||||
uses: actions/github-script@v7
|
||||
uses: actions/github-script@v8
|
||||
with:
|
||||
script: |
|
||||
const fs = require('fs');
|
||||
|
|
|
|||
5
.release-please-manifest.json
Normal file
5
.release-please-manifest.json
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
".release-please-manifest.json": "4.0.2",
|
||||
"package.json": "6.0.0",
|
||||
".": "6.0.0"
|
||||
}
|
||||
12295
THIRD-PARTY
12295
THIRD-PARTY
File diff suppressed because it is too large
Load diff
56
dist/121.index.js
generated
vendored
56
dist/121.index.js
generated
vendored
|
|
@ -1,56 +0,0 @@
|
|||
"use strict";
|
||||
exports.id = 121;
|
||||
exports.ids = [121];
|
||||
exports.modules = {
|
||||
|
||||
/***/ 7121:
|
||||
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
||||
|
||||
var __webpack_unused_export__;
|
||||
|
||||
|
||||
var client = __webpack_require__(5152);
|
||||
var propertyProvider = __webpack_require__(1238);
|
||||
|
||||
const ENV_KEY = "AWS_ACCESS_KEY_ID";
|
||||
const ENV_SECRET = "AWS_SECRET_ACCESS_KEY";
|
||||
const ENV_SESSION = "AWS_SESSION_TOKEN";
|
||||
const ENV_EXPIRATION = "AWS_CREDENTIAL_EXPIRATION";
|
||||
const ENV_CREDENTIAL_SCOPE = "AWS_CREDENTIAL_SCOPE";
|
||||
const ENV_ACCOUNT_ID = "AWS_ACCOUNT_ID";
|
||||
const fromEnv = (init) => async () => {
|
||||
init?.logger?.debug("@aws-sdk/credential-provider-env - fromEnv");
|
||||
const accessKeyId = process.env[ENV_KEY];
|
||||
const secretAccessKey = process.env[ENV_SECRET];
|
||||
const sessionToken = process.env[ENV_SESSION];
|
||||
const expiry = process.env[ENV_EXPIRATION];
|
||||
const credentialScope = process.env[ENV_CREDENTIAL_SCOPE];
|
||||
const accountId = process.env[ENV_ACCOUNT_ID];
|
||||
if (accessKeyId && secretAccessKey) {
|
||||
const credentials = {
|
||||
accessKeyId,
|
||||
secretAccessKey,
|
||||
...(sessionToken && { sessionToken }),
|
||||
...(expiry && { expiration: new Date(expiry) }),
|
||||
...(credentialScope && { credentialScope }),
|
||||
...(accountId && { accountId }),
|
||||
};
|
||||
client.setCredentialFeature(credentials, "CREDENTIALS_ENV_VARS", "g");
|
||||
return credentials;
|
||||
}
|
||||
throw new propertyProvider.CredentialsProviderError("Unable to find environment variable credentials.", { logger: init?.logger });
|
||||
};
|
||||
|
||||
__webpack_unused_export__ = ENV_ACCOUNT_ID;
|
||||
__webpack_unused_export__ = ENV_CREDENTIAL_SCOPE;
|
||||
__webpack_unused_export__ = ENV_EXPIRATION;
|
||||
__webpack_unused_export__ = ENV_KEY;
|
||||
__webpack_unused_export__ = ENV_SECRET;
|
||||
__webpack_unused_export__ = ENV_SESSION;
|
||||
exports.fromEnv = fromEnv;
|
||||
|
||||
|
||||
/***/ })
|
||||
|
||||
};
|
||||
;
|
||||
1320
dist/136.index.js
generated
vendored
1320
dist/136.index.js
generated
vendored
File diff suppressed because it is too large
Load diff
93
dist/360.index.js
generated
vendored
93
dist/360.index.js
generated
vendored
|
|
@ -1,93 +0,0 @@
|
|||
"use strict";
|
||||
exports.id = 360;
|
||||
exports.ids = [360];
|
||||
exports.modules = {
|
||||
|
||||
/***/ 5360:
|
||||
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
||||
|
||||
|
||||
|
||||
var sharedIniFileLoader = __webpack_require__(4964);
|
||||
var propertyProvider = __webpack_require__(1238);
|
||||
var child_process = __webpack_require__(5317);
|
||||
var util = __webpack_require__(9023);
|
||||
var client = __webpack_require__(5152);
|
||||
|
||||
const getValidatedProcessCredentials = (profileName, data, profiles) => {
|
||||
if (data.Version !== 1) {
|
||||
throw Error(`Profile ${profileName} credential_process did not return Version 1.`);
|
||||
}
|
||||
if (data.AccessKeyId === undefined || data.SecretAccessKey === undefined) {
|
||||
throw Error(`Profile ${profileName} credential_process returned invalid credentials.`);
|
||||
}
|
||||
if (data.Expiration) {
|
||||
const currentTime = new Date();
|
||||
const expireTime = new Date(data.Expiration);
|
||||
if (expireTime < currentTime) {
|
||||
throw Error(`Profile ${profileName} credential_process returned expired credentials.`);
|
||||
}
|
||||
}
|
||||
let accountId = data.AccountId;
|
||||
if (!accountId && profiles?.[profileName]?.aws_account_id) {
|
||||
accountId = profiles[profileName].aws_account_id;
|
||||
}
|
||||
const credentials = {
|
||||
accessKeyId: data.AccessKeyId,
|
||||
secretAccessKey: data.SecretAccessKey,
|
||||
...(data.SessionToken && { sessionToken: data.SessionToken }),
|
||||
...(data.Expiration && { expiration: new Date(data.Expiration) }),
|
||||
...(data.CredentialScope && { credentialScope: data.CredentialScope }),
|
||||
...(accountId && { accountId }),
|
||||
};
|
||||
client.setCredentialFeature(credentials, "CREDENTIALS_PROCESS", "w");
|
||||
return credentials;
|
||||
};
|
||||
|
||||
const resolveProcessCredentials = async (profileName, profiles, logger) => {
|
||||
const profile = profiles[profileName];
|
||||
if (profiles[profileName]) {
|
||||
const credentialProcess = profile["credential_process"];
|
||||
if (credentialProcess !== undefined) {
|
||||
const execPromise = util.promisify(sharedIniFileLoader.externalDataInterceptor?.getTokenRecord?.().exec ?? child_process.exec);
|
||||
try {
|
||||
const { stdout } = await execPromise(credentialProcess);
|
||||
let data;
|
||||
try {
|
||||
data = JSON.parse(stdout.trim());
|
||||
}
|
||||
catch {
|
||||
throw Error(`Profile ${profileName} credential_process returned invalid JSON.`);
|
||||
}
|
||||
return getValidatedProcessCredentials(profileName, data, profiles);
|
||||
}
|
||||
catch (error) {
|
||||
throw new propertyProvider.CredentialsProviderError(error.message, { logger });
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new propertyProvider.CredentialsProviderError(`Profile ${profileName} did not contain credential_process.`, { logger });
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new propertyProvider.CredentialsProviderError(`Profile ${profileName} could not be found in shared credentials file.`, {
|
||||
logger,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const fromProcess = (init = {}) => async ({ callerClientConfig } = {}) => {
|
||||
init.logger?.debug("@aws-sdk/credential-provider-process - fromProcess");
|
||||
const profiles = await sharedIniFileLoader.parseKnownFiles(init);
|
||||
return resolveProcessCredentials(sharedIniFileLoader.getProfileName({
|
||||
profile: init.profile ?? callerClientConfig?.profile,
|
||||
}), profiles, init.logger);
|
||||
};
|
||||
|
||||
exports.fromProcess = fromProcess;
|
||||
|
||||
|
||||
/***/ })
|
||||
|
||||
};
|
||||
;
|
||||
1160
dist/443.index.js
generated
vendored
1160
dist/443.index.js
generated
vendored
File diff suppressed because it is too large
Load diff
387
dist/566.index.js
generated
vendored
387
dist/566.index.js
generated
vendored
|
|
@ -1,387 +0,0 @@
|
|||
"use strict";
|
||||
exports.id = 566;
|
||||
exports.ids = [566];
|
||||
exports.modules = {
|
||||
|
||||
/***/ 566:
|
||||
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
||||
|
||||
var __webpack_unused_export__;
|
||||
|
||||
|
||||
var propertyProvider = __webpack_require__(1238);
|
||||
var url = __webpack_require__(7016);
|
||||
var buffer = __webpack_require__(181);
|
||||
var http = __webpack_require__(8611);
|
||||
var nodeConfigProvider = __webpack_require__(5704);
|
||||
var urlParser = __webpack_require__(4494);
|
||||
|
||||
function httpRequest(options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const req = http.request({
|
||||
method: "GET",
|
||||
...options,
|
||||
hostname: options.hostname?.replace(/^\[(.+)\]$/, "$1"),
|
||||
});
|
||||
req.on("error", (err) => {
|
||||
reject(Object.assign(new propertyProvider.ProviderError("Unable to connect to instance metadata service"), err));
|
||||
req.destroy();
|
||||
});
|
||||
req.on("timeout", () => {
|
||||
reject(new propertyProvider.ProviderError("TimeoutError from instance metadata service"));
|
||||
req.destroy();
|
||||
});
|
||||
req.on("response", (res) => {
|
||||
const { statusCode = 400 } = res;
|
||||
if (statusCode < 200 || 300 <= statusCode) {
|
||||
reject(Object.assign(new propertyProvider.ProviderError("Error response received from instance metadata service"), { statusCode }));
|
||||
req.destroy();
|
||||
}
|
||||
const chunks = [];
|
||||
res.on("data", (chunk) => {
|
||||
chunks.push(chunk);
|
||||
});
|
||||
res.on("end", () => {
|
||||
resolve(buffer.Buffer.concat(chunks));
|
||||
req.destroy();
|
||||
});
|
||||
});
|
||||
req.end();
|
||||
});
|
||||
}
|
||||
|
||||
const isImdsCredentials = (arg) => Boolean(arg) &&
|
||||
typeof arg === "object" &&
|
||||
typeof arg.AccessKeyId === "string" &&
|
||||
typeof arg.SecretAccessKey === "string" &&
|
||||
typeof arg.Token === "string" &&
|
||||
typeof arg.Expiration === "string";
|
||||
const fromImdsCredentials = (creds) => ({
|
||||
accessKeyId: creds.AccessKeyId,
|
||||
secretAccessKey: creds.SecretAccessKey,
|
||||
sessionToken: creds.Token,
|
||||
expiration: new Date(creds.Expiration),
|
||||
...(creds.AccountId && { accountId: creds.AccountId }),
|
||||
});
|
||||
|
||||
const DEFAULT_TIMEOUT = 1000;
|
||||
const DEFAULT_MAX_RETRIES = 0;
|
||||
const providerConfigFromInit = ({ maxRetries = DEFAULT_MAX_RETRIES, timeout = DEFAULT_TIMEOUT, }) => ({ maxRetries, timeout });
|
||||
|
||||
const retry = (toRetry, maxRetries) => {
|
||||
let promise = toRetry();
|
||||
for (let i = 0; i < maxRetries; i++) {
|
||||
promise = promise.catch(toRetry);
|
||||
}
|
||||
return promise;
|
||||
};
|
||||
|
||||
const ENV_CMDS_FULL_URI = "AWS_CONTAINER_CREDENTIALS_FULL_URI";
|
||||
const ENV_CMDS_RELATIVE_URI = "AWS_CONTAINER_CREDENTIALS_RELATIVE_URI";
|
||||
const ENV_CMDS_AUTH_TOKEN = "AWS_CONTAINER_AUTHORIZATION_TOKEN";
|
||||
const fromContainerMetadata = (init = {}) => {
|
||||
const { timeout, maxRetries } = providerConfigFromInit(init);
|
||||
return () => retry(async () => {
|
||||
const requestOptions = await getCmdsUri({ logger: init.logger });
|
||||
const credsResponse = JSON.parse(await requestFromEcsImds(timeout, requestOptions));
|
||||
if (!isImdsCredentials(credsResponse)) {
|
||||
throw new propertyProvider.CredentialsProviderError("Invalid response received from instance metadata service.", {
|
||||
logger: init.logger,
|
||||
});
|
||||
}
|
||||
return fromImdsCredentials(credsResponse);
|
||||
}, maxRetries);
|
||||
};
|
||||
const requestFromEcsImds = async (timeout, options) => {
|
||||
if (process.env[ENV_CMDS_AUTH_TOKEN]) {
|
||||
options.headers = {
|
||||
...options.headers,
|
||||
Authorization: process.env[ENV_CMDS_AUTH_TOKEN],
|
||||
};
|
||||
}
|
||||
const buffer = await httpRequest({
|
||||
...options,
|
||||
timeout,
|
||||
});
|
||||
return buffer.toString();
|
||||
};
|
||||
const CMDS_IP = "169.254.170.2";
|
||||
const GREENGRASS_HOSTS = {
|
||||
localhost: true,
|
||||
"127.0.0.1": true,
|
||||
};
|
||||
const GREENGRASS_PROTOCOLS = {
|
||||
"http:": true,
|
||||
"https:": true,
|
||||
};
|
||||
const getCmdsUri = async ({ logger }) => {
|
||||
if (process.env[ENV_CMDS_RELATIVE_URI]) {
|
||||
return {
|
||||
hostname: CMDS_IP,
|
||||
path: process.env[ENV_CMDS_RELATIVE_URI],
|
||||
};
|
||||
}
|
||||
if (process.env[ENV_CMDS_FULL_URI]) {
|
||||
const parsed = url.parse(process.env[ENV_CMDS_FULL_URI]);
|
||||
if (!parsed.hostname || !(parsed.hostname in GREENGRASS_HOSTS)) {
|
||||
throw new propertyProvider.CredentialsProviderError(`${parsed.hostname} is not a valid container metadata service hostname`, {
|
||||
tryNextLink: false,
|
||||
logger,
|
||||
});
|
||||
}
|
||||
if (!parsed.protocol || !(parsed.protocol in GREENGRASS_PROTOCOLS)) {
|
||||
throw new propertyProvider.CredentialsProviderError(`${parsed.protocol} is not a valid container metadata service protocol`, {
|
||||
tryNextLink: false,
|
||||
logger,
|
||||
});
|
||||
}
|
||||
return {
|
||||
...parsed,
|
||||
port: parsed.port ? parseInt(parsed.port, 10) : undefined,
|
||||
};
|
||||
}
|
||||
throw new propertyProvider.CredentialsProviderError("The container metadata credential provider cannot be used unless" +
|
||||
` the ${ENV_CMDS_RELATIVE_URI} or ${ENV_CMDS_FULL_URI} environment` +
|
||||
" variable is set", {
|
||||
tryNextLink: false,
|
||||
logger,
|
||||
});
|
||||
};
|
||||
|
||||
class InstanceMetadataV1FallbackError extends propertyProvider.CredentialsProviderError {
|
||||
tryNextLink;
|
||||
name = "InstanceMetadataV1FallbackError";
|
||||
constructor(message, tryNextLink = true) {
|
||||
super(message, tryNextLink);
|
||||
this.tryNextLink = tryNextLink;
|
||||
Object.setPrototypeOf(this, InstanceMetadataV1FallbackError.prototype);
|
||||
}
|
||||
}
|
||||
|
||||
exports.yI = void 0;
|
||||
(function (Endpoint) {
|
||||
Endpoint["IPv4"] = "http://169.254.169.254";
|
||||
Endpoint["IPv6"] = "http://[fd00:ec2::254]";
|
||||
})(exports.yI || (exports.yI = {}));
|
||||
|
||||
const ENV_ENDPOINT_NAME = "AWS_EC2_METADATA_SERVICE_ENDPOINT";
|
||||
const CONFIG_ENDPOINT_NAME = "ec2_metadata_service_endpoint";
|
||||
const ENDPOINT_CONFIG_OPTIONS = {
|
||||
environmentVariableSelector: (env) => env[ENV_ENDPOINT_NAME],
|
||||
configFileSelector: (profile) => profile[CONFIG_ENDPOINT_NAME],
|
||||
default: undefined,
|
||||
};
|
||||
|
||||
var EndpointMode;
|
||||
(function (EndpointMode) {
|
||||
EndpointMode["IPv4"] = "IPv4";
|
||||
EndpointMode["IPv6"] = "IPv6";
|
||||
})(EndpointMode || (EndpointMode = {}));
|
||||
|
||||
const ENV_ENDPOINT_MODE_NAME = "AWS_EC2_METADATA_SERVICE_ENDPOINT_MODE";
|
||||
const CONFIG_ENDPOINT_MODE_NAME = "ec2_metadata_service_endpoint_mode";
|
||||
const ENDPOINT_MODE_CONFIG_OPTIONS = {
|
||||
environmentVariableSelector: (env) => env[ENV_ENDPOINT_MODE_NAME],
|
||||
configFileSelector: (profile) => profile[CONFIG_ENDPOINT_MODE_NAME],
|
||||
default: EndpointMode.IPv4,
|
||||
};
|
||||
|
||||
const getInstanceMetadataEndpoint = async () => urlParser.parseUrl((await getFromEndpointConfig()) || (await getFromEndpointModeConfig()));
|
||||
const getFromEndpointConfig = async () => nodeConfigProvider.loadConfig(ENDPOINT_CONFIG_OPTIONS)();
|
||||
const getFromEndpointModeConfig = async () => {
|
||||
const endpointMode = await nodeConfigProvider.loadConfig(ENDPOINT_MODE_CONFIG_OPTIONS)();
|
||||
switch (endpointMode) {
|
||||
case EndpointMode.IPv4:
|
||||
return exports.yI.IPv4;
|
||||
case EndpointMode.IPv6:
|
||||
return exports.yI.IPv6;
|
||||
default:
|
||||
throw new Error(`Unsupported endpoint mode: ${endpointMode}.` + ` Select from ${Object.values(EndpointMode)}`);
|
||||
}
|
||||
};
|
||||
|
||||
const STATIC_STABILITY_REFRESH_INTERVAL_SECONDS = 5 * 60;
|
||||
const STATIC_STABILITY_REFRESH_INTERVAL_JITTER_WINDOW_SECONDS = 5 * 60;
|
||||
const STATIC_STABILITY_DOC_URL = "https://docs.aws.amazon.com/sdkref/latest/guide/feature-static-credentials.html";
|
||||
const getExtendedInstanceMetadataCredentials = (credentials, logger) => {
|
||||
const refreshInterval = STATIC_STABILITY_REFRESH_INTERVAL_SECONDS +
|
||||
Math.floor(Math.random() * STATIC_STABILITY_REFRESH_INTERVAL_JITTER_WINDOW_SECONDS);
|
||||
const newExpiration = new Date(Date.now() + refreshInterval * 1000);
|
||||
logger.warn("Attempting credential expiration extension due to a credential service availability issue. A refresh of these " +
|
||||
`credentials will be attempted after ${new Date(newExpiration)}.\nFor more information, please visit: ` +
|
||||
STATIC_STABILITY_DOC_URL);
|
||||
const originalExpiration = credentials.originalExpiration ?? credentials.expiration;
|
||||
return {
|
||||
...credentials,
|
||||
...(originalExpiration ? { originalExpiration } : {}),
|
||||
expiration: newExpiration,
|
||||
};
|
||||
};
|
||||
|
||||
const staticStabilityProvider = (provider, options = {}) => {
|
||||
const logger = options?.logger || console;
|
||||
let pastCredentials;
|
||||
return async () => {
|
||||
let credentials;
|
||||
try {
|
||||
credentials = await provider();
|
||||
if (credentials.expiration && credentials.expiration.getTime() < Date.now()) {
|
||||
credentials = getExtendedInstanceMetadataCredentials(credentials, logger);
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
if (pastCredentials) {
|
||||
logger.warn("Credential renew failed: ", e);
|
||||
credentials = getExtendedInstanceMetadataCredentials(pastCredentials, logger);
|
||||
}
|
||||
else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
pastCredentials = credentials;
|
||||
return credentials;
|
||||
};
|
||||
};
|
||||
|
||||
const IMDS_PATH = "/latest/meta-data/iam/security-credentials/";
|
||||
const IMDS_TOKEN_PATH = "/latest/api/token";
|
||||
const AWS_EC2_METADATA_V1_DISABLED = "AWS_EC2_METADATA_V1_DISABLED";
|
||||
const PROFILE_AWS_EC2_METADATA_V1_DISABLED = "ec2_metadata_v1_disabled";
|
||||
const X_AWS_EC2_METADATA_TOKEN = "x-aws-ec2-metadata-token";
|
||||
const fromInstanceMetadata = (init = {}) => staticStabilityProvider(getInstanceMetadataProvider(init), { logger: init.logger });
|
||||
const getInstanceMetadataProvider = (init = {}) => {
|
||||
let disableFetchToken = false;
|
||||
const { logger, profile } = init;
|
||||
const { timeout, maxRetries } = providerConfigFromInit(init);
|
||||
const getCredentials = async (maxRetries, options) => {
|
||||
const isImdsV1Fallback = disableFetchToken || options.headers?.[X_AWS_EC2_METADATA_TOKEN] == null;
|
||||
if (isImdsV1Fallback) {
|
||||
let fallbackBlockedFromProfile = false;
|
||||
let fallbackBlockedFromProcessEnv = false;
|
||||
const configValue = await nodeConfigProvider.loadConfig({
|
||||
environmentVariableSelector: (env) => {
|
||||
const envValue = env[AWS_EC2_METADATA_V1_DISABLED];
|
||||
fallbackBlockedFromProcessEnv = !!envValue && envValue !== "false";
|
||||
if (envValue === undefined) {
|
||||
throw new propertyProvider.CredentialsProviderError(`${AWS_EC2_METADATA_V1_DISABLED} not set in env, checking config file next.`, { logger: init.logger });
|
||||
}
|
||||
return fallbackBlockedFromProcessEnv;
|
||||
},
|
||||
configFileSelector: (profile) => {
|
||||
const profileValue = profile[PROFILE_AWS_EC2_METADATA_V1_DISABLED];
|
||||
fallbackBlockedFromProfile = !!profileValue && profileValue !== "false";
|
||||
return fallbackBlockedFromProfile;
|
||||
},
|
||||
default: false,
|
||||
}, {
|
||||
profile,
|
||||
})();
|
||||
if (init.ec2MetadataV1Disabled || configValue) {
|
||||
const causes = [];
|
||||
if (init.ec2MetadataV1Disabled)
|
||||
causes.push("credential provider initialization (runtime option ec2MetadataV1Disabled)");
|
||||
if (fallbackBlockedFromProfile)
|
||||
causes.push(`config file profile (${PROFILE_AWS_EC2_METADATA_V1_DISABLED})`);
|
||||
if (fallbackBlockedFromProcessEnv)
|
||||
causes.push(`process environment variable (${AWS_EC2_METADATA_V1_DISABLED})`);
|
||||
throw new InstanceMetadataV1FallbackError(`AWS EC2 Metadata v1 fallback has been blocked by AWS SDK configuration in the following: [${causes.join(", ")}].`);
|
||||
}
|
||||
}
|
||||
const imdsProfile = (await retry(async () => {
|
||||
let profile;
|
||||
try {
|
||||
profile = await getProfile(options);
|
||||
}
|
||||
catch (err) {
|
||||
if (err.statusCode === 401) {
|
||||
disableFetchToken = false;
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
return profile;
|
||||
}, maxRetries)).trim();
|
||||
return retry(async () => {
|
||||
let creds;
|
||||
try {
|
||||
creds = await getCredentialsFromProfile(imdsProfile, options, init);
|
||||
}
|
||||
catch (err) {
|
||||
if (err.statusCode === 401) {
|
||||
disableFetchToken = false;
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
return creds;
|
||||
}, maxRetries);
|
||||
};
|
||||
return async () => {
|
||||
const endpoint = await getInstanceMetadataEndpoint();
|
||||
if (disableFetchToken) {
|
||||
logger?.debug("AWS SDK Instance Metadata", "using v1 fallback (no token fetch)");
|
||||
return getCredentials(maxRetries, { ...endpoint, timeout });
|
||||
}
|
||||
else {
|
||||
let token;
|
||||
try {
|
||||
token = (await getMetadataToken({ ...endpoint, timeout })).toString();
|
||||
}
|
||||
catch (error) {
|
||||
if (error?.statusCode === 400) {
|
||||
throw Object.assign(error, {
|
||||
message: "EC2 Metadata token request returned error",
|
||||
});
|
||||
}
|
||||
else if (error.message === "TimeoutError" || [403, 404, 405].includes(error.statusCode)) {
|
||||
disableFetchToken = true;
|
||||
}
|
||||
logger?.debug("AWS SDK Instance Metadata", "using v1 fallback (initial)");
|
||||
return getCredentials(maxRetries, { ...endpoint, timeout });
|
||||
}
|
||||
return getCredentials(maxRetries, {
|
||||
...endpoint,
|
||||
headers: {
|
||||
[X_AWS_EC2_METADATA_TOKEN]: token,
|
||||
},
|
||||
timeout,
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
const getMetadataToken = async (options) => httpRequest({
|
||||
...options,
|
||||
path: IMDS_TOKEN_PATH,
|
||||
method: "PUT",
|
||||
headers: {
|
||||
"x-aws-ec2-metadata-token-ttl-seconds": "21600",
|
||||
},
|
||||
});
|
||||
const getProfile = async (options) => (await httpRequest({ ...options, path: IMDS_PATH })).toString();
|
||||
const getCredentialsFromProfile = async (profile, options, init) => {
|
||||
const credentialsResponse = JSON.parse((await httpRequest({
|
||||
...options,
|
||||
path: IMDS_PATH + profile,
|
||||
})).toString());
|
||||
if (!isImdsCredentials(credentialsResponse)) {
|
||||
throw new propertyProvider.CredentialsProviderError("Invalid response received from instance metadata service.", {
|
||||
logger: init.logger,
|
||||
});
|
||||
}
|
||||
return fromImdsCredentials(credentialsResponse);
|
||||
};
|
||||
|
||||
__webpack_unused_export__ = DEFAULT_MAX_RETRIES;
|
||||
__webpack_unused_export__ = DEFAULT_TIMEOUT;
|
||||
__webpack_unused_export__ = ENV_CMDS_AUTH_TOKEN;
|
||||
exports.ENV_CMDS_FULL_URI = ENV_CMDS_FULL_URI;
|
||||
exports.ENV_CMDS_RELATIVE_URI = ENV_CMDS_RELATIVE_URI;
|
||||
exports.fromContainerMetadata = fromContainerMetadata;
|
||||
exports.fromInstanceMetadata = fromInstanceMetadata;
|
||||
exports.getInstanceMetadataEndpoint = getInstanceMetadataEndpoint;
|
||||
exports.httpRequest = httpRequest;
|
||||
__webpack_unused_export__ = providerConfigFromInit;
|
||||
|
||||
|
||||
/***/ })
|
||||
|
||||
};
|
||||
;
|
||||
270
dist/579.index.js
generated
vendored
270
dist/579.index.js
generated
vendored
|
|
@ -1,270 +0,0 @@
|
|||
"use strict";
|
||||
exports.id = 579;
|
||||
exports.ids = [579];
|
||||
exports.modules = {
|
||||
|
||||
/***/ 6579:
|
||||
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
||||
|
||||
|
||||
|
||||
var utilUtf8 = __webpack_require__(1577);
|
||||
|
||||
class EventStreamSerde {
|
||||
marshaller;
|
||||
serializer;
|
||||
deserializer;
|
||||
serdeContext;
|
||||
defaultContentType;
|
||||
constructor({ marshaller, serializer, deserializer, serdeContext, defaultContentType, }) {
|
||||
this.marshaller = marshaller;
|
||||
this.serializer = serializer;
|
||||
this.deserializer = deserializer;
|
||||
this.serdeContext = serdeContext;
|
||||
this.defaultContentType = defaultContentType;
|
||||
}
|
||||
async serializeEventStream({ eventStream, requestSchema, initialRequest, }) {
|
||||
const marshaller = this.marshaller;
|
||||
const eventStreamMember = requestSchema.getEventStreamMember();
|
||||
const unionSchema = requestSchema.getMemberSchema(eventStreamMember);
|
||||
const serializer = this.serializer;
|
||||
const defaultContentType = this.defaultContentType;
|
||||
const initialRequestMarker = Symbol("initialRequestMarker");
|
||||
const eventStreamIterable = {
|
||||
async *[Symbol.asyncIterator]() {
|
||||
if (initialRequest) {
|
||||
const headers = {
|
||||
":event-type": { type: "string", value: "initial-request" },
|
||||
":message-type": { type: "string", value: "event" },
|
||||
":content-type": { type: "string", value: defaultContentType },
|
||||
};
|
||||
serializer.write(requestSchema, initialRequest);
|
||||
const body = serializer.flush();
|
||||
yield {
|
||||
[initialRequestMarker]: true,
|
||||
headers,
|
||||
body,
|
||||
};
|
||||
}
|
||||
for await (const page of eventStream) {
|
||||
yield page;
|
||||
}
|
||||
},
|
||||
};
|
||||
return marshaller.serialize(eventStreamIterable, (event) => {
|
||||
if (event[initialRequestMarker]) {
|
||||
return {
|
||||
headers: event.headers,
|
||||
body: event.body,
|
||||
};
|
||||
}
|
||||
const unionMember = Object.keys(event).find((key) => {
|
||||
return key !== "__type";
|
||||
}) ?? "";
|
||||
const { additionalHeaders, body, eventType, explicitPayloadContentType } = this.writeEventBody(unionMember, unionSchema, event);
|
||||
const headers = {
|
||||
":event-type": { type: "string", value: eventType },
|
||||
":message-type": { type: "string", value: "event" },
|
||||
":content-type": { type: "string", value: explicitPayloadContentType ?? defaultContentType },
|
||||
...additionalHeaders,
|
||||
};
|
||||
return {
|
||||
headers,
|
||||
body,
|
||||
};
|
||||
});
|
||||
}
|
||||
async deserializeEventStream({ response, responseSchema, initialResponseContainer, }) {
|
||||
const marshaller = this.marshaller;
|
||||
const eventStreamMember = responseSchema.getEventStreamMember();
|
||||
const unionSchema = responseSchema.getMemberSchema(eventStreamMember);
|
||||
const memberSchemas = unionSchema.getMemberSchemas();
|
||||
const initialResponseMarker = Symbol("initialResponseMarker");
|
||||
const asyncIterable = marshaller.deserialize(response.body, async (event) => {
|
||||
const unionMember = Object.keys(event).find((key) => {
|
||||
return key !== "__type";
|
||||
}) ?? "";
|
||||
const body = event[unionMember].body;
|
||||
if (unionMember === "initial-response") {
|
||||
const dataObject = await this.deserializer.read(responseSchema, body);
|
||||
delete dataObject[eventStreamMember];
|
||||
return {
|
||||
[initialResponseMarker]: true,
|
||||
...dataObject,
|
||||
};
|
||||
}
|
||||
else if (unionMember in memberSchemas) {
|
||||
const eventStreamSchema = memberSchemas[unionMember];
|
||||
if (eventStreamSchema.isStructSchema()) {
|
||||
const out = {};
|
||||
let hasBindings = false;
|
||||
for (const [name, member] of eventStreamSchema.structIterator()) {
|
||||
const { eventHeader, eventPayload } = member.getMergedTraits();
|
||||
hasBindings = hasBindings || Boolean(eventHeader || eventPayload);
|
||||
if (eventPayload) {
|
||||
if (member.isBlobSchema()) {
|
||||
out[name] = body;
|
||||
}
|
||||
else if (member.isStringSchema()) {
|
||||
out[name] = (this.serdeContext?.utf8Encoder ?? utilUtf8.toUtf8)(body);
|
||||
}
|
||||
else if (member.isStructSchema()) {
|
||||
out[name] = await this.deserializer.read(member, body);
|
||||
}
|
||||
}
|
||||
else if (eventHeader) {
|
||||
const value = event[unionMember].headers[name]?.value;
|
||||
if (value != null) {
|
||||
if (member.isNumericSchema()) {
|
||||
if (value && typeof value === "object" && "bytes" in value) {
|
||||
out[name] = BigInt(value.toString());
|
||||
}
|
||||
else {
|
||||
out[name] = Number(value);
|
||||
}
|
||||
}
|
||||
else {
|
||||
out[name] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hasBindings) {
|
||||
return {
|
||||
[unionMember]: out,
|
||||
};
|
||||
}
|
||||
if (body.byteLength === 0) {
|
||||
return {
|
||||
[unionMember]: {},
|
||||
};
|
||||
}
|
||||
}
|
||||
return {
|
||||
[unionMember]: await this.deserializer.read(eventStreamSchema, body),
|
||||
};
|
||||
}
|
||||
else {
|
||||
return {
|
||||
$unknown: event,
|
||||
};
|
||||
}
|
||||
});
|
||||
const asyncIterator = asyncIterable[Symbol.asyncIterator]();
|
||||
const firstEvent = await asyncIterator.next();
|
||||
if (firstEvent.done) {
|
||||
return asyncIterable;
|
||||
}
|
||||
if (firstEvent.value?.[initialResponseMarker]) {
|
||||
if (!responseSchema) {
|
||||
throw new Error("@smithy::core/protocols - initial-response event encountered in event stream but no response schema given.");
|
||||
}
|
||||
for (const [key, value] of Object.entries(firstEvent.value)) {
|
||||
initialResponseContainer[key] = value;
|
||||
}
|
||||
}
|
||||
return {
|
||||
async *[Symbol.asyncIterator]() {
|
||||
if (!firstEvent?.value?.[initialResponseMarker]) {
|
||||
yield firstEvent.value;
|
||||
}
|
||||
while (true) {
|
||||
const { done, value } = await asyncIterator.next();
|
||||
if (done) {
|
||||
break;
|
||||
}
|
||||
yield value;
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
writeEventBody(unionMember, unionSchema, event) {
|
||||
const serializer = this.serializer;
|
||||
let eventType = unionMember;
|
||||
let explicitPayloadMember = null;
|
||||
let explicitPayloadContentType;
|
||||
const isKnownSchema = (() => {
|
||||
const struct = unionSchema.getSchema();
|
||||
return struct[4].includes(unionMember);
|
||||
})();
|
||||
const additionalHeaders = {};
|
||||
if (!isKnownSchema) {
|
||||
const [type, value] = event[unionMember];
|
||||
eventType = type;
|
||||
serializer.write(15, value);
|
||||
}
|
||||
else {
|
||||
const eventSchema = unionSchema.getMemberSchema(unionMember);
|
||||
if (eventSchema.isStructSchema()) {
|
||||
for (const [memberName, memberSchema] of eventSchema.structIterator()) {
|
||||
const { eventHeader, eventPayload } = memberSchema.getMergedTraits();
|
||||
if (eventPayload) {
|
||||
explicitPayloadMember = memberName;
|
||||
}
|
||||
else if (eventHeader) {
|
||||
const value = event[unionMember][memberName];
|
||||
let type = "binary";
|
||||
if (memberSchema.isNumericSchema()) {
|
||||
if ((-2) ** 31 <= value && value <= 2 ** 31 - 1) {
|
||||
type = "integer";
|
||||
}
|
||||
else {
|
||||
type = "long";
|
||||
}
|
||||
}
|
||||
else if (memberSchema.isTimestampSchema()) {
|
||||
type = "timestamp";
|
||||
}
|
||||
else if (memberSchema.isStringSchema()) {
|
||||
type = "string";
|
||||
}
|
||||
else if (memberSchema.isBooleanSchema()) {
|
||||
type = "boolean";
|
||||
}
|
||||
if (value != null) {
|
||||
additionalHeaders[memberName] = {
|
||||
type,
|
||||
value,
|
||||
};
|
||||
delete event[unionMember][memberName];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (explicitPayloadMember !== null) {
|
||||
const payloadSchema = eventSchema.getMemberSchema(explicitPayloadMember);
|
||||
if (payloadSchema.isBlobSchema()) {
|
||||
explicitPayloadContentType = "application/octet-stream";
|
||||
}
|
||||
else if (payloadSchema.isStringSchema()) {
|
||||
explicitPayloadContentType = "text/plain";
|
||||
}
|
||||
serializer.write(payloadSchema, event[unionMember][explicitPayloadMember]);
|
||||
}
|
||||
else {
|
||||
serializer.write(eventSchema, event[unionMember]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new Error("@smithy/core/event-streams - non-struct member not supported in event stream union.");
|
||||
}
|
||||
}
|
||||
const messageSerialization = serializer.flush();
|
||||
const body = typeof messageSerialization === "string"
|
||||
? (this.serdeContext?.utf8Decoder ?? utilUtf8.fromUtf8)(messageSerialization)
|
||||
: messageSerialization;
|
||||
return {
|
||||
body,
|
||||
eventType,
|
||||
explicitPayloadContentType,
|
||||
additionalHeaders,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
exports.EventStreamSerde = EventStreamSerde;
|
||||
|
||||
|
||||
/***/ })
|
||||
|
||||
};
|
||||
;
|
||||
234
dist/605.index.js
generated
vendored
234
dist/605.index.js
generated
vendored
|
|
@ -1,234 +0,0 @@
|
|||
"use strict";
|
||||
exports.id = 605;
|
||||
exports.ids = [605];
|
||||
exports.modules = {
|
||||
|
||||
/***/ 1509:
|
||||
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
||||
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.checkUrl = void 0;
|
||||
const property_provider_1 = __webpack_require__(1238);
|
||||
const LOOPBACK_CIDR_IPv4 = "127.0.0.0/8";
|
||||
const LOOPBACK_CIDR_IPv6 = "::1/128";
|
||||
const ECS_CONTAINER_HOST = "169.254.170.2";
|
||||
const EKS_CONTAINER_HOST_IPv4 = "169.254.170.23";
|
||||
const EKS_CONTAINER_HOST_IPv6 = "[fd00:ec2::23]";
|
||||
const checkUrl = (url, logger) => {
|
||||
if (url.protocol === "https:") {
|
||||
return;
|
||||
}
|
||||
if (url.hostname === ECS_CONTAINER_HOST ||
|
||||
url.hostname === EKS_CONTAINER_HOST_IPv4 ||
|
||||
url.hostname === EKS_CONTAINER_HOST_IPv6) {
|
||||
return;
|
||||
}
|
||||
if (url.hostname.includes("[")) {
|
||||
if (url.hostname === "[::1]" || url.hostname === "[0000:0000:0000:0000:0000:0000:0000:0001]") {
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (url.hostname === "localhost") {
|
||||
return;
|
||||
}
|
||||
const ipComponents = url.hostname.split(".");
|
||||
const inRange = (component) => {
|
||||
const num = parseInt(component, 10);
|
||||
return 0 <= num && num <= 255;
|
||||
};
|
||||
if (ipComponents[0] === "127" &&
|
||||
inRange(ipComponents[1]) &&
|
||||
inRange(ipComponents[2]) &&
|
||||
inRange(ipComponents[3]) &&
|
||||
ipComponents.length === 4) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new property_provider_1.CredentialsProviderError(`URL not accepted. It must either be HTTPS or match one of the following:
|
||||
- loopback CIDR 127.0.0.0/8 or [::1/128]
|
||||
- ECS container host 169.254.170.2
|
||||
- EKS container host 169.254.170.23 or [fd00:ec2::23]`, { logger });
|
||||
};
|
||||
exports.checkUrl = checkUrl;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 6331:
|
||||
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
||||
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.fromHttp = void 0;
|
||||
const tslib_1 = __webpack_require__(1860);
|
||||
const client_1 = __webpack_require__(5152);
|
||||
const node_http_handler_1 = __webpack_require__(1279);
|
||||
const property_provider_1 = __webpack_require__(1238);
|
||||
const promises_1 = tslib_1.__importDefault(__webpack_require__(1943));
|
||||
const checkUrl_1 = __webpack_require__(1509);
|
||||
const requestHelpers_1 = __webpack_require__(8914);
|
||||
const retry_wrapper_1 = __webpack_require__(1122);
|
||||
const AWS_CONTAINER_CREDENTIALS_RELATIVE_URI = "AWS_CONTAINER_CREDENTIALS_RELATIVE_URI";
|
||||
const DEFAULT_LINK_LOCAL_HOST = "http://169.254.170.2";
|
||||
const AWS_CONTAINER_CREDENTIALS_FULL_URI = "AWS_CONTAINER_CREDENTIALS_FULL_URI";
|
||||
const AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE = "AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE";
|
||||
const AWS_CONTAINER_AUTHORIZATION_TOKEN = "AWS_CONTAINER_AUTHORIZATION_TOKEN";
|
||||
const fromHttp = (options = {}) => {
|
||||
options.logger?.debug("@aws-sdk/credential-provider-http - fromHttp");
|
||||
let host;
|
||||
const relative = options.awsContainerCredentialsRelativeUri ?? process.env[AWS_CONTAINER_CREDENTIALS_RELATIVE_URI];
|
||||
const full = options.awsContainerCredentialsFullUri ?? process.env[AWS_CONTAINER_CREDENTIALS_FULL_URI];
|
||||
const token = options.awsContainerAuthorizationToken ?? process.env[AWS_CONTAINER_AUTHORIZATION_TOKEN];
|
||||
const tokenFile = options.awsContainerAuthorizationTokenFile ?? process.env[AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE];
|
||||
const warn = options.logger?.constructor?.name === "NoOpLogger" || !options.logger?.warn
|
||||
? console.warn
|
||||
: options.logger.warn.bind(options.logger);
|
||||
if (relative && full) {
|
||||
warn("@aws-sdk/credential-provider-http: " +
|
||||
"you have set both awsContainerCredentialsRelativeUri and awsContainerCredentialsFullUri.");
|
||||
warn("awsContainerCredentialsFullUri will take precedence.");
|
||||
}
|
||||
if (token && tokenFile) {
|
||||
warn("@aws-sdk/credential-provider-http: " +
|
||||
"you have set both awsContainerAuthorizationToken and awsContainerAuthorizationTokenFile.");
|
||||
warn("awsContainerAuthorizationToken will take precedence.");
|
||||
}
|
||||
if (full) {
|
||||
host = full;
|
||||
}
|
||||
else if (relative) {
|
||||
host = `${DEFAULT_LINK_LOCAL_HOST}${relative}`;
|
||||
}
|
||||
else {
|
||||
throw new property_provider_1.CredentialsProviderError(`No HTTP credential provider host provided.
|
||||
Set AWS_CONTAINER_CREDENTIALS_FULL_URI or AWS_CONTAINER_CREDENTIALS_RELATIVE_URI.`, { logger: options.logger });
|
||||
}
|
||||
const url = new URL(host);
|
||||
(0, checkUrl_1.checkUrl)(url, options.logger);
|
||||
const requestHandler = node_http_handler_1.NodeHttpHandler.create({
|
||||
requestTimeout: options.timeout ?? 1000,
|
||||
connectionTimeout: options.timeout ?? 1000,
|
||||
});
|
||||
return (0, retry_wrapper_1.retryWrapper)(async () => {
|
||||
const request = (0, requestHelpers_1.createGetRequest)(url);
|
||||
if (token) {
|
||||
request.headers.Authorization = token;
|
||||
}
|
||||
else if (tokenFile) {
|
||||
request.headers.Authorization = (await promises_1.default.readFile(tokenFile)).toString();
|
||||
}
|
||||
try {
|
||||
const result = await requestHandler.handle(request);
|
||||
return (0, requestHelpers_1.getCredentials)(result.response).then((creds) => (0, client_1.setCredentialFeature)(creds, "CREDENTIALS_HTTP", "z"));
|
||||
}
|
||||
catch (e) {
|
||||
throw new property_provider_1.CredentialsProviderError(String(e), { logger: options.logger });
|
||||
}
|
||||
}, options.maxRetries ?? 3, options.timeout ?? 1000);
|
||||
};
|
||||
exports.fromHttp = fromHttp;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 8914:
|
||||
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
||||
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.createGetRequest = createGetRequest;
|
||||
exports.getCredentials = getCredentials;
|
||||
const property_provider_1 = __webpack_require__(1238);
|
||||
const protocol_http_1 = __webpack_require__(2356);
|
||||
const smithy_client_1 = __webpack_require__(1411);
|
||||
const util_stream_1 = __webpack_require__(4252);
|
||||
function createGetRequest(url) {
|
||||
return new protocol_http_1.HttpRequest({
|
||||
protocol: url.protocol,
|
||||
hostname: url.hostname,
|
||||
port: Number(url.port),
|
||||
path: url.pathname,
|
||||
query: Array.from(url.searchParams.entries()).reduce((acc, [k, v]) => {
|
||||
acc[k] = v;
|
||||
return acc;
|
||||
}, {}),
|
||||
fragment: url.hash,
|
||||
});
|
||||
}
|
||||
async function getCredentials(response, logger) {
|
||||
const stream = (0, util_stream_1.sdkStreamMixin)(response.body);
|
||||
const str = await stream.transformToString();
|
||||
if (response.statusCode === 200) {
|
||||
const parsed = JSON.parse(str);
|
||||
if (typeof parsed.AccessKeyId !== "string" ||
|
||||
typeof parsed.SecretAccessKey !== "string" ||
|
||||
typeof parsed.Token !== "string" ||
|
||||
typeof parsed.Expiration !== "string") {
|
||||
throw new property_provider_1.CredentialsProviderError("HTTP credential provider response not of the required format, an object matching: " +
|
||||
"{ AccessKeyId: string, SecretAccessKey: string, Token: string, Expiration: string(rfc3339) }", { logger });
|
||||
}
|
||||
return {
|
||||
accessKeyId: parsed.AccessKeyId,
|
||||
secretAccessKey: parsed.SecretAccessKey,
|
||||
sessionToken: parsed.Token,
|
||||
expiration: (0, smithy_client_1.parseRfc3339DateTime)(parsed.Expiration),
|
||||
};
|
||||
}
|
||||
if (response.statusCode >= 400 && response.statusCode < 500) {
|
||||
let parsedBody = {};
|
||||
try {
|
||||
parsedBody = JSON.parse(str);
|
||||
}
|
||||
catch (e) { }
|
||||
throw Object.assign(new property_provider_1.CredentialsProviderError(`Server responded with status: ${response.statusCode}`, { logger }), {
|
||||
Code: parsedBody.Code,
|
||||
Message: parsedBody.Message,
|
||||
});
|
||||
}
|
||||
throw new property_provider_1.CredentialsProviderError(`Server responded with status: ${response.statusCode}`, { logger });
|
||||
}
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 1122:
|
||||
/***/ ((__unused_webpack_module, exports) => {
|
||||
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.retryWrapper = void 0;
|
||||
const retryWrapper = (toRetry, maxRetries, delayMs) => {
|
||||
return async () => {
|
||||
for (let i = 0; i < maxRetries; ++i) {
|
||||
try {
|
||||
return await toRetry();
|
||||
}
|
||||
catch (e) {
|
||||
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
||||
}
|
||||
}
|
||||
return await toRetry();
|
||||
};
|
||||
};
|
||||
exports.retryWrapper = retryWrapper;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 8605:
|
||||
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
||||
|
||||
var __webpack_unused_export__;
|
||||
|
||||
__webpack_unused_export__ = ({ value: true });
|
||||
exports.fromHttp = void 0;
|
||||
var fromHttp_1 = __webpack_require__(6331);
|
||||
Object.defineProperty(exports, "fromHttp", ({ enumerable: true, get: function () { return fromHttp_1.fromHttp; } }));
|
||||
|
||||
|
||||
/***/ })
|
||||
|
||||
};
|
||||
;
|
||||
1009
dist/762.index.js
generated
vendored
1009
dist/762.index.js
generated
vendored
File diff suppressed because it is too large
Load diff
531
dist/869.index.js
generated
vendored
531
dist/869.index.js
generated
vendored
|
|
@ -1,531 +0,0 @@
|
|||
"use strict";
|
||||
exports.id = 869;
|
||||
exports.ids = [869];
|
||||
exports.modules = {
|
||||
|
||||
/***/ 5869:
|
||||
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
||||
|
||||
|
||||
|
||||
var sharedIniFileLoader = __webpack_require__(4964);
|
||||
var propertyProvider = __webpack_require__(1238);
|
||||
var client = __webpack_require__(5152);
|
||||
var credentialProviderLogin = __webpack_require__(4072);
|
||||
|
||||
const resolveCredentialSource = (credentialSource, profileName, logger) => {
|
||||
const sourceProvidersMap = {
|
||||
EcsContainer: async (options) => {
|
||||
const { fromHttp } = await __webpack_require__.e(/* import() */ 605).then(__webpack_require__.bind(__webpack_require__, 8605));
|
||||
const { fromContainerMetadata } = await __webpack_require__.e(/* import() */ 566).then(__webpack_require__.t.bind(__webpack_require__, 566, 19));
|
||||
logger?.debug("@aws-sdk/credential-provider-ini - credential_source is EcsContainer");
|
||||
return async () => propertyProvider.chain(fromHttp(options ?? {}), fromContainerMetadata(options))().then(setNamedProvider);
|
||||
},
|
||||
Ec2InstanceMetadata: async (options) => {
|
||||
logger?.debug("@aws-sdk/credential-provider-ini - credential_source is Ec2InstanceMetadata");
|
||||
const { fromInstanceMetadata } = await __webpack_require__.e(/* import() */ 566).then(__webpack_require__.t.bind(__webpack_require__, 566, 19));
|
||||
return async () => fromInstanceMetadata(options)().then(setNamedProvider);
|
||||
},
|
||||
Environment: async (options) => {
|
||||
logger?.debug("@aws-sdk/credential-provider-ini - credential_source is Environment");
|
||||
const { fromEnv } = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 5606, 19));
|
||||
return async () => fromEnv(options)().then(setNamedProvider);
|
||||
},
|
||||
};
|
||||
if (credentialSource in sourceProvidersMap) {
|
||||
return sourceProvidersMap[credentialSource];
|
||||
}
|
||||
else {
|
||||
throw new propertyProvider.CredentialsProviderError(`Unsupported credential source in profile ${profileName}. Got ${credentialSource}, ` +
|
||||
`expected EcsContainer or Ec2InstanceMetadata or Environment.`, { logger });
|
||||
}
|
||||
};
|
||||
const setNamedProvider = (creds) => client.setCredentialFeature(creds, "CREDENTIALS_PROFILE_NAMED_PROVIDER", "p");
|
||||
|
||||
const isAssumeRoleProfile = (arg, { profile = "default", logger } = {}) => {
|
||||
return (Boolean(arg) &&
|
||||
typeof arg === "object" &&
|
||||
typeof arg.role_arn === "string" &&
|
||||
["undefined", "string"].indexOf(typeof arg.role_session_name) > -1 &&
|
||||
["undefined", "string"].indexOf(typeof arg.external_id) > -1 &&
|
||||
["undefined", "string"].indexOf(typeof arg.mfa_serial) > -1 &&
|
||||
(isAssumeRoleWithSourceProfile(arg, { profile, logger }) || isCredentialSourceProfile(arg, { profile, logger })));
|
||||
};
|
||||
const isAssumeRoleWithSourceProfile = (arg, { profile, logger }) => {
|
||||
const withSourceProfile = typeof arg.source_profile === "string" && typeof arg.credential_source === "undefined";
|
||||
if (withSourceProfile) {
|
||||
logger?.debug?.(` ${profile} isAssumeRoleWithSourceProfile source_profile=${arg.source_profile}`);
|
||||
}
|
||||
return withSourceProfile;
|
||||
};
|
||||
const isCredentialSourceProfile = (arg, { profile, logger }) => {
|
||||
const withProviderProfile = typeof arg.credential_source === "string" && typeof arg.source_profile === "undefined";
|
||||
if (withProviderProfile) {
|
||||
logger?.debug?.(` ${profile} isCredentialSourceProfile credential_source=${arg.credential_source}`);
|
||||
}
|
||||
return withProviderProfile;
|
||||
};
|
||||
const resolveAssumeRoleCredentials = async (profileName, profiles, options, callerClientConfig, visitedProfiles = {}, resolveProfileData) => {
|
||||
options.logger?.debug("@aws-sdk/credential-provider-ini - resolveAssumeRoleCredentials (STS)");
|
||||
const profileData = profiles[profileName];
|
||||
const { source_profile, region } = profileData;
|
||||
if (!options.roleAssumer) {
|
||||
const { getDefaultRoleAssumer } = await __webpack_require__.e(/* import() */ 136).then(__webpack_require__.t.bind(__webpack_require__, 1136, 23));
|
||||
options.roleAssumer = getDefaultRoleAssumer({
|
||||
...options.clientConfig,
|
||||
credentialProviderLogger: options.logger,
|
||||
parentClientConfig: {
|
||||
...callerClientConfig,
|
||||
...options?.parentClientConfig,
|
||||
region: region ?? options?.parentClientConfig?.region ?? callerClientConfig?.region,
|
||||
},
|
||||
}, options.clientPlugins);
|
||||
}
|
||||
if (source_profile && source_profile in visitedProfiles) {
|
||||
throw new propertyProvider.CredentialsProviderError(`Detected a cycle attempting to resolve credentials for profile` +
|
||||
` ${sharedIniFileLoader.getProfileName(options)}. Profiles visited: ` +
|
||||
Object.keys(visitedProfiles).join(", "), { logger: options.logger });
|
||||
}
|
||||
options.logger?.debug(`@aws-sdk/credential-provider-ini - finding credential resolver using ${source_profile ? `source_profile=[${source_profile}]` : `profile=[${profileName}]`}`);
|
||||
const sourceCredsProvider = source_profile
|
||||
? resolveProfileData(source_profile, profiles, options, callerClientConfig, {
|
||||
...visitedProfiles,
|
||||
[source_profile]: true,
|
||||
}, isCredentialSourceWithoutRoleArn(profiles[source_profile] ?? {}))
|
||||
: (await resolveCredentialSource(profileData.credential_source, profileName, options.logger)(options))();
|
||||
if (isCredentialSourceWithoutRoleArn(profileData)) {
|
||||
return sourceCredsProvider.then((creds) => client.setCredentialFeature(creds, "CREDENTIALS_PROFILE_SOURCE_PROFILE", "o"));
|
||||
}
|
||||
else {
|
||||
const params = {
|
||||
RoleArn: profileData.role_arn,
|
||||
RoleSessionName: profileData.role_session_name || `aws-sdk-js-${Date.now()}`,
|
||||
ExternalId: profileData.external_id,
|
||||
DurationSeconds: parseInt(profileData.duration_seconds || "3600", 10),
|
||||
};
|
||||
const { mfa_serial } = profileData;
|
||||
if (mfa_serial) {
|
||||
if (!options.mfaCodeProvider) {
|
||||
throw new propertyProvider.CredentialsProviderError(`Profile ${profileName} requires multi-factor authentication, but no MFA code callback was provided.`, { logger: options.logger, tryNextLink: false });
|
||||
}
|
||||
params.SerialNumber = mfa_serial;
|
||||
params.TokenCode = await options.mfaCodeProvider(mfa_serial);
|
||||
}
|
||||
const sourceCreds = await sourceCredsProvider;
|
||||
return options.roleAssumer(sourceCreds, params).then((creds) => client.setCredentialFeature(creds, "CREDENTIALS_PROFILE_SOURCE_PROFILE", "o"));
|
||||
}
|
||||
};
|
||||
const isCredentialSourceWithoutRoleArn = (section) => {
|
||||
return !section.role_arn && !!section.credential_source;
|
||||
};
|
||||
|
||||
const isLoginProfile = (data) => {
|
||||
return Boolean(data && data.login_session);
|
||||
};
|
||||
const resolveLoginCredentials = async (profileName, options, callerClientConfig) => {
|
||||
const credentials = await credentialProviderLogin.fromLoginCredentials({
|
||||
...options,
|
||||
profile: profileName,
|
||||
})({ callerClientConfig });
|
||||
return client.setCredentialFeature(credentials, "CREDENTIALS_PROFILE_LOGIN", "AC");
|
||||
};
|
||||
|
||||
const isProcessProfile = (arg) => Boolean(arg) && typeof arg === "object" && typeof arg.credential_process === "string";
|
||||
const resolveProcessCredentials = async (options, profile) => __webpack_require__.e(/* import() */ 360).then(__webpack_require__.t.bind(__webpack_require__, 5360, 19)).then(({ fromProcess }) => fromProcess({
|
||||
...options,
|
||||
profile,
|
||||
})().then((creds) => client.setCredentialFeature(creds, "CREDENTIALS_PROFILE_PROCESS", "v")));
|
||||
|
||||
const resolveSsoCredentials = async (profile, profileData, options = {}, callerClientConfig) => {
|
||||
const { fromSSO } = await __webpack_require__.e(/* import() */ 998).then(__webpack_require__.t.bind(__webpack_require__, 998, 19));
|
||||
return fromSSO({
|
||||
profile,
|
||||
logger: options.logger,
|
||||
parentClientConfig: options.parentClientConfig,
|
||||
clientConfig: options.clientConfig,
|
||||
})({
|
||||
callerClientConfig,
|
||||
}).then((creds) => {
|
||||
if (profileData.sso_session) {
|
||||
return client.setCredentialFeature(creds, "CREDENTIALS_PROFILE_SSO", "r");
|
||||
}
|
||||
else {
|
||||
return client.setCredentialFeature(creds, "CREDENTIALS_PROFILE_SSO_LEGACY", "t");
|
||||
}
|
||||
});
|
||||
};
|
||||
const isSsoProfile = (arg) => arg &&
|
||||
(typeof arg.sso_start_url === "string" ||
|
||||
typeof arg.sso_account_id === "string" ||
|
||||
typeof arg.sso_session === "string" ||
|
||||
typeof arg.sso_region === "string" ||
|
||||
typeof arg.sso_role_name === "string");
|
||||
|
||||
const isStaticCredsProfile = (arg) => Boolean(arg) &&
|
||||
typeof arg === "object" &&
|
||||
typeof arg.aws_access_key_id === "string" &&
|
||||
typeof arg.aws_secret_access_key === "string" &&
|
||||
["undefined", "string"].indexOf(typeof arg.aws_session_token) > -1 &&
|
||||
["undefined", "string"].indexOf(typeof arg.aws_account_id) > -1;
|
||||
const resolveStaticCredentials = async (profile, options) => {
|
||||
options?.logger?.debug("@aws-sdk/credential-provider-ini - resolveStaticCredentials");
|
||||
const credentials = {
|
||||
accessKeyId: profile.aws_access_key_id,
|
||||
secretAccessKey: profile.aws_secret_access_key,
|
||||
sessionToken: profile.aws_session_token,
|
||||
...(profile.aws_credential_scope && { credentialScope: profile.aws_credential_scope }),
|
||||
...(profile.aws_account_id && { accountId: profile.aws_account_id }),
|
||||
};
|
||||
return client.setCredentialFeature(credentials, "CREDENTIALS_PROFILE", "n");
|
||||
};
|
||||
|
||||
const isWebIdentityProfile = (arg) => Boolean(arg) &&
|
||||
typeof arg === "object" &&
|
||||
typeof arg.web_identity_token_file === "string" &&
|
||||
typeof arg.role_arn === "string" &&
|
||||
["undefined", "string"].indexOf(typeof arg.role_session_name) > -1;
|
||||
const resolveWebIdentityCredentials = async (profile, options, callerClientConfig) => Promise.all(/* import() */[__webpack_require__.e(136), __webpack_require__.e(956)]).then(__webpack_require__.t.bind(__webpack_require__, 9956, 23)).then(({ fromTokenFile }) => fromTokenFile({
|
||||
webIdentityTokenFile: profile.web_identity_token_file,
|
||||
roleArn: profile.role_arn,
|
||||
roleSessionName: profile.role_session_name,
|
||||
roleAssumerWithWebIdentity: options.roleAssumerWithWebIdentity,
|
||||
logger: options.logger,
|
||||
parentClientConfig: options.parentClientConfig,
|
||||
})({
|
||||
callerClientConfig,
|
||||
}).then((creds) => client.setCredentialFeature(creds, "CREDENTIALS_PROFILE_STS_WEB_ID_TOKEN", "q")));
|
||||
|
||||
const resolveProfileData = async (profileName, profiles, options, callerClientConfig, visitedProfiles = {}, isAssumeRoleRecursiveCall = false) => {
|
||||
const data = profiles[profileName];
|
||||
if (Object.keys(visitedProfiles).length > 0 && isStaticCredsProfile(data)) {
|
||||
return resolveStaticCredentials(data, options);
|
||||
}
|
||||
if (isAssumeRoleRecursiveCall || isAssumeRoleProfile(data, { profile: profileName, logger: options.logger })) {
|
||||
return resolveAssumeRoleCredentials(profileName, profiles, options, callerClientConfig, visitedProfiles, resolveProfileData);
|
||||
}
|
||||
if (isStaticCredsProfile(data)) {
|
||||
return resolveStaticCredentials(data, options);
|
||||
}
|
||||
if (isWebIdentityProfile(data)) {
|
||||
return resolveWebIdentityCredentials(data, options, callerClientConfig);
|
||||
}
|
||||
if (isProcessProfile(data)) {
|
||||
return resolveProcessCredentials(options, profileName);
|
||||
}
|
||||
if (isSsoProfile(data)) {
|
||||
return await resolveSsoCredentials(profileName, data, options, callerClientConfig);
|
||||
}
|
||||
if (isLoginProfile(data)) {
|
||||
return resolveLoginCredentials(profileName, options, callerClientConfig);
|
||||
}
|
||||
throw new propertyProvider.CredentialsProviderError(`Could not resolve credentials using profile: [${profileName}] in configuration/credentials file(s).`, { logger: options.logger });
|
||||
};
|
||||
|
||||
const fromIni = (init = {}) => async ({ callerClientConfig } = {}) => {
|
||||
init.logger?.debug("@aws-sdk/credential-provider-ini - fromIni");
|
||||
const profiles = await sharedIniFileLoader.parseKnownFiles(init);
|
||||
return resolveProfileData(sharedIniFileLoader.getProfileName({
|
||||
profile: init.profile ?? callerClientConfig?.profile,
|
||||
}), profiles, init, callerClientConfig);
|
||||
};
|
||||
|
||||
exports.fromIni = fromIni;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 4072:
|
||||
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
||||
|
||||
|
||||
|
||||
var client = __webpack_require__(5152);
|
||||
var propertyProvider = __webpack_require__(1238);
|
||||
var sharedIniFileLoader = __webpack_require__(4964);
|
||||
var protocolHttp = __webpack_require__(2356);
|
||||
var node_crypto = __webpack_require__(7598);
|
||||
var node_fs = __webpack_require__(3024);
|
||||
var node_os = __webpack_require__(8161);
|
||||
var node_path = __webpack_require__(6760);
|
||||
|
||||
class LoginCredentialsFetcher {
|
||||
profileData;
|
||||
init;
|
||||
callerClientConfig;
|
||||
static REFRESH_THRESHOLD = 5 * 60 * 1000;
|
||||
constructor(profileData, init, callerClientConfig) {
|
||||
this.profileData = profileData;
|
||||
this.init = init;
|
||||
this.callerClientConfig = callerClientConfig;
|
||||
}
|
||||
async loadCredentials() {
|
||||
const token = await this.loadToken();
|
||||
if (!token) {
|
||||
throw new propertyProvider.CredentialsProviderError(`Failed to load a token for session ${this.loginSession}, please re-authenticate using aws login`, { tryNextLink: false, logger: this.logger });
|
||||
}
|
||||
const accessToken = token.accessToken;
|
||||
const now = Date.now();
|
||||
const expiryTime = new Date(accessToken.expiresAt).getTime();
|
||||
const timeUntilExpiry = expiryTime - now;
|
||||
if (timeUntilExpiry <= LoginCredentialsFetcher.REFRESH_THRESHOLD) {
|
||||
return this.refresh(token);
|
||||
}
|
||||
return {
|
||||
accessKeyId: accessToken.accessKeyId,
|
||||
secretAccessKey: accessToken.secretAccessKey,
|
||||
sessionToken: accessToken.sessionToken,
|
||||
accountId: accessToken.accountId,
|
||||
expiration: new Date(accessToken.expiresAt),
|
||||
};
|
||||
}
|
||||
get logger() {
|
||||
return this.init?.logger;
|
||||
}
|
||||
get loginSession() {
|
||||
return this.profileData.login_session;
|
||||
}
|
||||
async refresh(token) {
|
||||
const { SigninClient, CreateOAuth2TokenCommand } = await __webpack_require__.e(/* import() */ 762).then(__webpack_require__.t.bind(__webpack_require__, 9762, 19));
|
||||
const { logger, userAgentAppId } = this.callerClientConfig ?? {};
|
||||
const isH2 = (requestHandler) => {
|
||||
return requestHandler?.metadata?.handlerProtocol === "h2";
|
||||
};
|
||||
const requestHandler = isH2(this.callerClientConfig?.requestHandler)
|
||||
? undefined
|
||||
: this.callerClientConfig?.requestHandler;
|
||||
const region = this.profileData.region ?? (await this.callerClientConfig?.region?.()) ?? process.env.AWS_REGION;
|
||||
const client = new SigninClient({
|
||||
credentials: {
|
||||
accessKeyId: "",
|
||||
secretAccessKey: "",
|
||||
},
|
||||
region,
|
||||
requestHandler,
|
||||
logger,
|
||||
userAgentAppId,
|
||||
...this.init?.clientConfig,
|
||||
});
|
||||
this.createDPoPInterceptor(client.middlewareStack);
|
||||
const commandInput = {
|
||||
tokenInput: {
|
||||
clientId: token.clientId,
|
||||
refreshToken: token.refreshToken,
|
||||
grantType: "refresh_token",
|
||||
},
|
||||
};
|
||||
try {
|
||||
const response = await client.send(new CreateOAuth2TokenCommand(commandInput));
|
||||
const { accessKeyId, secretAccessKey, sessionToken } = response.tokenOutput?.accessToken ?? {};
|
||||
const { refreshToken, expiresIn } = response.tokenOutput ?? {};
|
||||
if (!accessKeyId || !secretAccessKey || !sessionToken || !refreshToken) {
|
||||
throw new propertyProvider.CredentialsProviderError("Token refresh response missing required fields", {
|
||||
logger: this.logger,
|
||||
tryNextLink: false,
|
||||
});
|
||||
}
|
||||
const expiresInMs = (expiresIn ?? 900) * 1000;
|
||||
const expiration = new Date(Date.now() + expiresInMs);
|
||||
const updatedToken = {
|
||||
...token,
|
||||
accessToken: {
|
||||
...token.accessToken,
|
||||
accessKeyId: accessKeyId,
|
||||
secretAccessKey: secretAccessKey,
|
||||
sessionToken: sessionToken,
|
||||
expiresAt: expiration.toISOString(),
|
||||
},
|
||||
refreshToken: refreshToken,
|
||||
};
|
||||
await this.saveToken(updatedToken);
|
||||
const newAccessToken = updatedToken.accessToken;
|
||||
return {
|
||||
accessKeyId: newAccessToken.accessKeyId,
|
||||
secretAccessKey: newAccessToken.secretAccessKey,
|
||||
sessionToken: newAccessToken.sessionToken,
|
||||
accountId: newAccessToken.accountId,
|
||||
expiration,
|
||||
};
|
||||
}
|
||||
catch (error) {
|
||||
if (error.name === "AccessDeniedException") {
|
||||
const errorType = error.error;
|
||||
let message;
|
||||
switch (errorType) {
|
||||
case "TOKEN_EXPIRED":
|
||||
message = "Your session has expired. Please reauthenticate.";
|
||||
break;
|
||||
case "USER_CREDENTIALS_CHANGED":
|
||||
message =
|
||||
"Unable to refresh credentials because of a change in your password. Please reauthenticate with your new password.";
|
||||
break;
|
||||
case "INSUFFICIENT_PERMISSIONS":
|
||||
message =
|
||||
"Unable to refresh credentials due to insufficient permissions. You may be missing permission for the 'CreateOAuth2Token' action.";
|
||||
break;
|
||||
default:
|
||||
message = `Failed to refresh token: ${String(error)}. Please re-authenticate using \`aws login\``;
|
||||
}
|
||||
throw new propertyProvider.CredentialsProviderError(message, { logger: this.logger, tryNextLink: false });
|
||||
}
|
||||
throw new propertyProvider.CredentialsProviderError(`Failed to refresh token: ${String(error)}. Please re-authenticate using aws login`, { logger: this.logger });
|
||||
}
|
||||
}
|
||||
async loadToken() {
|
||||
const tokenFilePath = this.getTokenFilePath();
|
||||
try {
|
||||
let tokenData;
|
||||
try {
|
||||
tokenData = await sharedIniFileLoader.readFile(tokenFilePath, { ignoreCache: this.init?.ignoreCache });
|
||||
}
|
||||
catch {
|
||||
tokenData = await node_fs.promises.readFile(tokenFilePath, "utf8");
|
||||
}
|
||||
const token = JSON.parse(tokenData);
|
||||
const missingFields = ["accessToken", "clientId", "refreshToken", "dpopKey"].filter((k) => !token[k]);
|
||||
if (!token.accessToken?.accountId) {
|
||||
missingFields.push("accountId");
|
||||
}
|
||||
if (missingFields.length > 0) {
|
||||
throw new propertyProvider.CredentialsProviderError(`Token validation failed, missing fields: ${missingFields.join(", ")}`, {
|
||||
logger: this.logger,
|
||||
tryNextLink: false,
|
||||
});
|
||||
}
|
||||
return token;
|
||||
}
|
||||
catch (error) {
|
||||
throw new propertyProvider.CredentialsProviderError(`Failed to load token from ${tokenFilePath}: ${String(error)}`, {
|
||||
logger: this.logger,
|
||||
tryNextLink: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
async saveToken(token) {
|
||||
const tokenFilePath = this.getTokenFilePath();
|
||||
const directory = node_path.dirname(tokenFilePath);
|
||||
try {
|
||||
await node_fs.promises.mkdir(directory, { recursive: true });
|
||||
}
|
||||
catch (error) {
|
||||
}
|
||||
await node_fs.promises.writeFile(tokenFilePath, JSON.stringify(token, null, 2), "utf8");
|
||||
}
|
||||
getTokenFilePath() {
|
||||
const directory = process.env.AWS_LOGIN_CACHE_DIRECTORY ?? node_path.join(node_os.homedir(), ".aws", "login", "cache");
|
||||
const loginSessionBytes = Buffer.from(this.loginSession, "utf8");
|
||||
const loginSessionSha256 = node_crypto.createHash("sha256").update(loginSessionBytes).digest("hex");
|
||||
return node_path.join(directory, `${loginSessionSha256}.json`);
|
||||
}
|
||||
derToRawSignature(derSignature) {
|
||||
let offset = 2;
|
||||
if (derSignature[offset] !== 0x02) {
|
||||
throw new Error("Invalid DER signature");
|
||||
}
|
||||
offset++;
|
||||
const rLength = derSignature[offset++];
|
||||
let r = derSignature.subarray(offset, offset + rLength);
|
||||
offset += rLength;
|
||||
if (derSignature[offset] !== 0x02) {
|
||||
throw new Error("Invalid DER signature");
|
||||
}
|
||||
offset++;
|
||||
const sLength = derSignature[offset++];
|
||||
let s = derSignature.subarray(offset, offset + sLength);
|
||||
r = r[0] === 0x00 ? r.subarray(1) : r;
|
||||
s = s[0] === 0x00 ? s.subarray(1) : s;
|
||||
const rPadded = Buffer.concat([Buffer.alloc(32 - r.length), r]);
|
||||
const sPadded = Buffer.concat([Buffer.alloc(32 - s.length), s]);
|
||||
return Buffer.concat([rPadded, sPadded]);
|
||||
}
|
||||
createDPoPInterceptor(middlewareStack) {
|
||||
middlewareStack.add((next) => async (args) => {
|
||||
if (protocolHttp.HttpRequest.isInstance(args.request)) {
|
||||
const request = args.request;
|
||||
const actualEndpoint = `${request.protocol}//${request.hostname}${request.port ? `:${request.port}` : ""}${request.path}`;
|
||||
const dpop = await this.generateDpop(request.method, actualEndpoint);
|
||||
request.headers = {
|
||||
...request.headers,
|
||||
DPoP: dpop,
|
||||
};
|
||||
}
|
||||
return next(args);
|
||||
}, {
|
||||
step: "finalizeRequest",
|
||||
name: "dpopInterceptor",
|
||||
override: true,
|
||||
});
|
||||
}
|
||||
async generateDpop(method = "POST", endpoint) {
|
||||
const token = await this.loadToken();
|
||||
try {
|
||||
const privateKey = node_crypto.createPrivateKey({
|
||||
key: token.dpopKey,
|
||||
format: "pem",
|
||||
type: "sec1",
|
||||
});
|
||||
const publicKey = node_crypto.createPublicKey(privateKey);
|
||||
const publicDer = publicKey.export({ format: "der", type: "spki" });
|
||||
let pointStart = -1;
|
||||
for (let i = 0; i < publicDer.length; i++) {
|
||||
if (publicDer[i] === 0x04) {
|
||||
pointStart = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
const x = publicDer.slice(pointStart + 1, pointStart + 33);
|
||||
const y = publicDer.slice(pointStart + 33, pointStart + 65);
|
||||
const header = {
|
||||
alg: "ES256",
|
||||
typ: "dpop+jwt",
|
||||
jwk: {
|
||||
kty: "EC",
|
||||
crv: "P-256",
|
||||
x: x.toString("base64url"),
|
||||
y: y.toString("base64url"),
|
||||
},
|
||||
};
|
||||
const payload = {
|
||||
jti: crypto.randomUUID(),
|
||||
htm: method,
|
||||
htu: endpoint,
|
||||
iat: Math.floor(Date.now() / 1000),
|
||||
};
|
||||
const headerB64 = Buffer.from(JSON.stringify(header)).toString("base64url");
|
||||
const payloadB64 = Buffer.from(JSON.stringify(payload)).toString("base64url");
|
||||
const message = `${headerB64}.${payloadB64}`;
|
||||
const asn1Signature = node_crypto.sign("sha256", Buffer.from(message), privateKey);
|
||||
const rawSignature = this.derToRawSignature(asn1Signature);
|
||||
const signatureB64 = rawSignature.toString("base64url");
|
||||
return `${message}.${signatureB64}`;
|
||||
}
|
||||
catch (error) {
|
||||
throw new propertyProvider.CredentialsProviderError(`Failed to generate Dpop proof: ${error instanceof Error ? error.message : String(error)}`, { logger: this.logger, tryNextLink: false });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const fromLoginCredentials = (init) => async ({ callerClientConfig } = {}) => {
|
||||
init?.logger?.debug?.("@aws-sdk/credential-providers - fromLoginCredentials");
|
||||
const profiles = await sharedIniFileLoader.parseKnownFiles(init || {});
|
||||
const profileName = sharedIniFileLoader.getProfileName({
|
||||
profile: init?.profile ?? callerClientConfig?.profile,
|
||||
});
|
||||
const profile = profiles[profileName];
|
||||
if (!profile?.login_session) {
|
||||
throw new propertyProvider.CredentialsProviderError(`Profile ${profileName} does not contain login_session.`, {
|
||||
tryNextLink: true,
|
||||
logger: init?.logger,
|
||||
});
|
||||
}
|
||||
const fetcher = new LoginCredentialsFetcher(profile, init, callerClientConfig);
|
||||
const credentials = await fetcher.loadCredentials();
|
||||
return client.setCredentialFeature(credentials, "CREDENTIALS_LOGIN", "AD");
|
||||
};
|
||||
|
||||
exports.fromLoginCredentials = fromLoginCredentials;
|
||||
|
||||
|
||||
/***/ })
|
||||
|
||||
};
|
||||
;
|
||||
143
dist/956.index.js
generated
vendored
143
dist/956.index.js
generated
vendored
|
|
@ -1,143 +0,0 @@
|
|||
"use strict";
|
||||
exports.id = 956;
|
||||
exports.ids = [956];
|
||||
exports.modules = {
|
||||
|
||||
/***/ 8079:
|
||||
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
||||
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.fromTokenFile = void 0;
|
||||
const client_1 = __webpack_require__(5152);
|
||||
const property_provider_1 = __webpack_require__(1238);
|
||||
const shared_ini_file_loader_1 = __webpack_require__(4964);
|
||||
const fs_1 = __webpack_require__(9896);
|
||||
const fromWebToken_1 = __webpack_require__(4453);
|
||||
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";
|
||||
const fromTokenFile = (init = {}) => async (awsIdentityProperties) => {
|
||||
init.logger?.debug("@aws-sdk/credential-provider-web-identity - fromTokenFile");
|
||||
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 property_provider_1.CredentialsProviderError("Web identity configuration not specified", {
|
||||
logger: init.logger,
|
||||
});
|
||||
}
|
||||
const credentials = await (0, fromWebToken_1.fromWebToken)({
|
||||
...init,
|
||||
webIdentityToken: shared_ini_file_loader_1.externalDataInterceptor?.getTokenRecord?.()[webIdentityTokenFile] ??
|
||||
(0, fs_1.readFileSync)(webIdentityTokenFile, { encoding: "ascii" }),
|
||||
roleArn,
|
||||
roleSessionName,
|
||||
})(awsIdentityProperties);
|
||||
if (webIdentityTokenFile === process.env[ENV_TOKEN_FILE]) {
|
||||
(0, client_1.setCredentialFeature)(credentials, "CREDENTIALS_ENV_VARS_STS_WEB_ID_TOKEN", "h");
|
||||
}
|
||||
return credentials;
|
||||
};
|
||||
exports.fromTokenFile = fromTokenFile;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 4453:
|
||||
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
||||
|
||||
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.fromWebToken = void 0;
|
||||
const fromWebToken = (init) => async (awsIdentityProperties) => {
|
||||
init.logger?.debug("@aws-sdk/credential-provider-web-identity - fromWebToken");
|
||||
const { roleArn, roleSessionName, webIdentityToken, providerId, policyArns, policy, durationSeconds } = init;
|
||||
let { roleAssumerWithWebIdentity } = init;
|
||||
if (!roleAssumerWithWebIdentity) {
|
||||
const { getDefaultRoleAssumerWithWebIdentity } = await Promise.resolve().then(() => __importStar(__webpack_require__(1136)));
|
||||
roleAssumerWithWebIdentity = getDefaultRoleAssumerWithWebIdentity({
|
||||
...init.clientConfig,
|
||||
credentialProviderLogger: init.logger,
|
||||
parentClientConfig: {
|
||||
...awsIdentityProperties?.callerClientConfig,
|
||||
...init.parentClientConfig,
|
||||
},
|
||||
}, init.clientPlugins);
|
||||
}
|
||||
return roleAssumerWithWebIdentity({
|
||||
RoleArn: roleArn,
|
||||
RoleSessionName: roleSessionName ?? `aws-sdk-js-session-${Date.now()}`,
|
||||
WebIdentityToken: webIdentityToken,
|
||||
ProviderId: providerId,
|
||||
PolicyArns: policyArns,
|
||||
Policy: policy,
|
||||
DurationSeconds: durationSeconds,
|
||||
});
|
||||
};
|
||||
exports.fromWebToken = fromWebToken;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 9956:
|
||||
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
||||
|
||||
|
||||
|
||||
var fromTokenFile = __webpack_require__(8079);
|
||||
var fromWebToken = __webpack_require__(4453);
|
||||
|
||||
|
||||
|
||||
Object.keys(fromTokenFile).forEach(function (k) {
|
||||
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
||||
enumerable: true,
|
||||
get: function () { return fromTokenFile[k]; }
|
||||
});
|
||||
});
|
||||
Object.keys(fromWebToken).forEach(function (k) {
|
||||
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
||||
enumerable: true,
|
||||
get: function () { return fromWebToken[k]; }
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
/***/ })
|
||||
|
||||
};
|
||||
;
|
||||
1799
dist/998.index.js
generated
vendored
1799
dist/998.index.js
generated
vendored
File diff suppressed because it is too large
Load diff
56
dist/cleanup/121.index.js
generated
vendored
56
dist/cleanup/121.index.js
generated
vendored
|
|
@ -1,56 +0,0 @@
|
|||
"use strict";
|
||||
exports.id = 121;
|
||||
exports.ids = [121];
|
||||
exports.modules = {
|
||||
|
||||
/***/ 7121:
|
||||
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
||||
|
||||
var __webpack_unused_export__;
|
||||
|
||||
|
||||
var client = __webpack_require__(5152);
|
||||
var propertyProvider = __webpack_require__(1238);
|
||||
|
||||
const ENV_KEY = "AWS_ACCESS_KEY_ID";
|
||||
const ENV_SECRET = "AWS_SECRET_ACCESS_KEY";
|
||||
const ENV_SESSION = "AWS_SESSION_TOKEN";
|
||||
const ENV_EXPIRATION = "AWS_CREDENTIAL_EXPIRATION";
|
||||
const ENV_CREDENTIAL_SCOPE = "AWS_CREDENTIAL_SCOPE";
|
||||
const ENV_ACCOUNT_ID = "AWS_ACCOUNT_ID";
|
||||
const fromEnv = (init) => async () => {
|
||||
init?.logger?.debug("@aws-sdk/credential-provider-env - fromEnv");
|
||||
const accessKeyId = process.env[ENV_KEY];
|
||||
const secretAccessKey = process.env[ENV_SECRET];
|
||||
const sessionToken = process.env[ENV_SESSION];
|
||||
const expiry = process.env[ENV_EXPIRATION];
|
||||
const credentialScope = process.env[ENV_CREDENTIAL_SCOPE];
|
||||
const accountId = process.env[ENV_ACCOUNT_ID];
|
||||
if (accessKeyId && secretAccessKey) {
|
||||
const credentials = {
|
||||
accessKeyId,
|
||||
secretAccessKey,
|
||||
...(sessionToken && { sessionToken }),
|
||||
...(expiry && { expiration: new Date(expiry) }),
|
||||
...(credentialScope && { credentialScope }),
|
||||
...(accountId && { accountId }),
|
||||
};
|
||||
client.setCredentialFeature(credentials, "CREDENTIALS_ENV_VARS", "g");
|
||||
return credentials;
|
||||
}
|
||||
throw new propertyProvider.CredentialsProviderError("Unable to find environment variable credentials.", { logger: init?.logger });
|
||||
};
|
||||
|
||||
__webpack_unused_export__ = ENV_ACCOUNT_ID;
|
||||
__webpack_unused_export__ = ENV_CREDENTIAL_SCOPE;
|
||||
__webpack_unused_export__ = ENV_EXPIRATION;
|
||||
__webpack_unused_export__ = ENV_KEY;
|
||||
__webpack_unused_export__ = ENV_SECRET;
|
||||
__webpack_unused_export__ = ENV_SESSION;
|
||||
exports.fromEnv = fromEnv;
|
||||
|
||||
|
||||
/***/ })
|
||||
|
||||
};
|
||||
;
|
||||
1320
dist/cleanup/136.index.js
generated
vendored
1320
dist/cleanup/136.index.js
generated
vendored
File diff suppressed because it is too large
Load diff
93
dist/cleanup/360.index.js
generated
vendored
93
dist/cleanup/360.index.js
generated
vendored
|
|
@ -1,93 +0,0 @@
|
|||
"use strict";
|
||||
exports.id = 360;
|
||||
exports.ids = [360];
|
||||
exports.modules = {
|
||||
|
||||
/***/ 5360:
|
||||
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
||||
|
||||
|
||||
|
||||
var sharedIniFileLoader = __webpack_require__(4964);
|
||||
var propertyProvider = __webpack_require__(1238);
|
||||
var child_process = __webpack_require__(5317);
|
||||
var util = __webpack_require__(9023);
|
||||
var client = __webpack_require__(5152);
|
||||
|
||||
const getValidatedProcessCredentials = (profileName, data, profiles) => {
|
||||
if (data.Version !== 1) {
|
||||
throw Error(`Profile ${profileName} credential_process did not return Version 1.`);
|
||||
}
|
||||
if (data.AccessKeyId === undefined || data.SecretAccessKey === undefined) {
|
||||
throw Error(`Profile ${profileName} credential_process returned invalid credentials.`);
|
||||
}
|
||||
if (data.Expiration) {
|
||||
const currentTime = new Date();
|
||||
const expireTime = new Date(data.Expiration);
|
||||
if (expireTime < currentTime) {
|
||||
throw Error(`Profile ${profileName} credential_process returned expired credentials.`);
|
||||
}
|
||||
}
|
||||
let accountId = data.AccountId;
|
||||
if (!accountId && profiles?.[profileName]?.aws_account_id) {
|
||||
accountId = profiles[profileName].aws_account_id;
|
||||
}
|
||||
const credentials = {
|
||||
accessKeyId: data.AccessKeyId,
|
||||
secretAccessKey: data.SecretAccessKey,
|
||||
...(data.SessionToken && { sessionToken: data.SessionToken }),
|
||||
...(data.Expiration && { expiration: new Date(data.Expiration) }),
|
||||
...(data.CredentialScope && { credentialScope: data.CredentialScope }),
|
||||
...(accountId && { accountId }),
|
||||
};
|
||||
client.setCredentialFeature(credentials, "CREDENTIALS_PROCESS", "w");
|
||||
return credentials;
|
||||
};
|
||||
|
||||
const resolveProcessCredentials = async (profileName, profiles, logger) => {
|
||||
const profile = profiles[profileName];
|
||||
if (profiles[profileName]) {
|
||||
const credentialProcess = profile["credential_process"];
|
||||
if (credentialProcess !== undefined) {
|
||||
const execPromise = util.promisify(sharedIniFileLoader.externalDataInterceptor?.getTokenRecord?.().exec ?? child_process.exec);
|
||||
try {
|
||||
const { stdout } = await execPromise(credentialProcess);
|
||||
let data;
|
||||
try {
|
||||
data = JSON.parse(stdout.trim());
|
||||
}
|
||||
catch {
|
||||
throw Error(`Profile ${profileName} credential_process returned invalid JSON.`);
|
||||
}
|
||||
return getValidatedProcessCredentials(profileName, data, profiles);
|
||||
}
|
||||
catch (error) {
|
||||
throw new propertyProvider.CredentialsProviderError(error.message, { logger });
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new propertyProvider.CredentialsProviderError(`Profile ${profileName} did not contain credential_process.`, { logger });
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new propertyProvider.CredentialsProviderError(`Profile ${profileName} could not be found in shared credentials file.`, {
|
||||
logger,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const fromProcess = (init = {}) => async ({ callerClientConfig } = {}) => {
|
||||
init.logger?.debug("@aws-sdk/credential-provider-process - fromProcess");
|
||||
const profiles = await sharedIniFileLoader.parseKnownFiles(init);
|
||||
return resolveProcessCredentials(sharedIniFileLoader.getProfileName({
|
||||
profile: init.profile ?? callerClientConfig?.profile,
|
||||
}), profiles, init.logger);
|
||||
};
|
||||
|
||||
exports.fromProcess = fromProcess;
|
||||
|
||||
|
||||
/***/ })
|
||||
|
||||
};
|
||||
;
|
||||
1160
dist/cleanup/443.index.js
generated
vendored
1160
dist/cleanup/443.index.js
generated
vendored
File diff suppressed because it is too large
Load diff
387
dist/cleanup/566.index.js
generated
vendored
387
dist/cleanup/566.index.js
generated
vendored
|
|
@ -1,387 +0,0 @@
|
|||
"use strict";
|
||||
exports.id = 566;
|
||||
exports.ids = [566];
|
||||
exports.modules = {
|
||||
|
||||
/***/ 566:
|
||||
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
||||
|
||||
var __webpack_unused_export__;
|
||||
|
||||
|
||||
var propertyProvider = __webpack_require__(1238);
|
||||
var url = __webpack_require__(7016);
|
||||
var buffer = __webpack_require__(181);
|
||||
var http = __webpack_require__(8611);
|
||||
var nodeConfigProvider = __webpack_require__(5704);
|
||||
var urlParser = __webpack_require__(4494);
|
||||
|
||||
function httpRequest(options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const req = http.request({
|
||||
method: "GET",
|
||||
...options,
|
||||
hostname: options.hostname?.replace(/^\[(.+)\]$/, "$1"),
|
||||
});
|
||||
req.on("error", (err) => {
|
||||
reject(Object.assign(new propertyProvider.ProviderError("Unable to connect to instance metadata service"), err));
|
||||
req.destroy();
|
||||
});
|
||||
req.on("timeout", () => {
|
||||
reject(new propertyProvider.ProviderError("TimeoutError from instance metadata service"));
|
||||
req.destroy();
|
||||
});
|
||||
req.on("response", (res) => {
|
||||
const { statusCode = 400 } = res;
|
||||
if (statusCode < 200 || 300 <= statusCode) {
|
||||
reject(Object.assign(new propertyProvider.ProviderError("Error response received from instance metadata service"), { statusCode }));
|
||||
req.destroy();
|
||||
}
|
||||
const chunks = [];
|
||||
res.on("data", (chunk) => {
|
||||
chunks.push(chunk);
|
||||
});
|
||||
res.on("end", () => {
|
||||
resolve(buffer.Buffer.concat(chunks));
|
||||
req.destroy();
|
||||
});
|
||||
});
|
||||
req.end();
|
||||
});
|
||||
}
|
||||
|
||||
const isImdsCredentials = (arg) => Boolean(arg) &&
|
||||
typeof arg === "object" &&
|
||||
typeof arg.AccessKeyId === "string" &&
|
||||
typeof arg.SecretAccessKey === "string" &&
|
||||
typeof arg.Token === "string" &&
|
||||
typeof arg.Expiration === "string";
|
||||
const fromImdsCredentials = (creds) => ({
|
||||
accessKeyId: creds.AccessKeyId,
|
||||
secretAccessKey: creds.SecretAccessKey,
|
||||
sessionToken: creds.Token,
|
||||
expiration: new Date(creds.Expiration),
|
||||
...(creds.AccountId && { accountId: creds.AccountId }),
|
||||
});
|
||||
|
||||
const DEFAULT_TIMEOUT = 1000;
|
||||
const DEFAULT_MAX_RETRIES = 0;
|
||||
const providerConfigFromInit = ({ maxRetries = DEFAULT_MAX_RETRIES, timeout = DEFAULT_TIMEOUT, }) => ({ maxRetries, timeout });
|
||||
|
||||
const retry = (toRetry, maxRetries) => {
|
||||
let promise = toRetry();
|
||||
for (let i = 0; i < maxRetries; i++) {
|
||||
promise = promise.catch(toRetry);
|
||||
}
|
||||
return promise;
|
||||
};
|
||||
|
||||
const ENV_CMDS_FULL_URI = "AWS_CONTAINER_CREDENTIALS_FULL_URI";
|
||||
const ENV_CMDS_RELATIVE_URI = "AWS_CONTAINER_CREDENTIALS_RELATIVE_URI";
|
||||
const ENV_CMDS_AUTH_TOKEN = "AWS_CONTAINER_AUTHORIZATION_TOKEN";
|
||||
const fromContainerMetadata = (init = {}) => {
|
||||
const { timeout, maxRetries } = providerConfigFromInit(init);
|
||||
return () => retry(async () => {
|
||||
const requestOptions = await getCmdsUri({ logger: init.logger });
|
||||
const credsResponse = JSON.parse(await requestFromEcsImds(timeout, requestOptions));
|
||||
if (!isImdsCredentials(credsResponse)) {
|
||||
throw new propertyProvider.CredentialsProviderError("Invalid response received from instance metadata service.", {
|
||||
logger: init.logger,
|
||||
});
|
||||
}
|
||||
return fromImdsCredentials(credsResponse);
|
||||
}, maxRetries);
|
||||
};
|
||||
const requestFromEcsImds = async (timeout, options) => {
|
||||
if (process.env[ENV_CMDS_AUTH_TOKEN]) {
|
||||
options.headers = {
|
||||
...options.headers,
|
||||
Authorization: process.env[ENV_CMDS_AUTH_TOKEN],
|
||||
};
|
||||
}
|
||||
const buffer = await httpRequest({
|
||||
...options,
|
||||
timeout,
|
||||
});
|
||||
return buffer.toString();
|
||||
};
|
||||
const CMDS_IP = "169.254.170.2";
|
||||
const GREENGRASS_HOSTS = {
|
||||
localhost: true,
|
||||
"127.0.0.1": true,
|
||||
};
|
||||
const GREENGRASS_PROTOCOLS = {
|
||||
"http:": true,
|
||||
"https:": true,
|
||||
};
|
||||
const getCmdsUri = async ({ logger }) => {
|
||||
if (process.env[ENV_CMDS_RELATIVE_URI]) {
|
||||
return {
|
||||
hostname: CMDS_IP,
|
||||
path: process.env[ENV_CMDS_RELATIVE_URI],
|
||||
};
|
||||
}
|
||||
if (process.env[ENV_CMDS_FULL_URI]) {
|
||||
const parsed = url.parse(process.env[ENV_CMDS_FULL_URI]);
|
||||
if (!parsed.hostname || !(parsed.hostname in GREENGRASS_HOSTS)) {
|
||||
throw new propertyProvider.CredentialsProviderError(`${parsed.hostname} is not a valid container metadata service hostname`, {
|
||||
tryNextLink: false,
|
||||
logger,
|
||||
});
|
||||
}
|
||||
if (!parsed.protocol || !(parsed.protocol in GREENGRASS_PROTOCOLS)) {
|
||||
throw new propertyProvider.CredentialsProviderError(`${parsed.protocol} is not a valid container metadata service protocol`, {
|
||||
tryNextLink: false,
|
||||
logger,
|
||||
});
|
||||
}
|
||||
return {
|
||||
...parsed,
|
||||
port: parsed.port ? parseInt(parsed.port, 10) : undefined,
|
||||
};
|
||||
}
|
||||
throw new propertyProvider.CredentialsProviderError("The container metadata credential provider cannot be used unless" +
|
||||
` the ${ENV_CMDS_RELATIVE_URI} or ${ENV_CMDS_FULL_URI} environment` +
|
||||
" variable is set", {
|
||||
tryNextLink: false,
|
||||
logger,
|
||||
});
|
||||
};
|
||||
|
||||
class InstanceMetadataV1FallbackError extends propertyProvider.CredentialsProviderError {
|
||||
tryNextLink;
|
||||
name = "InstanceMetadataV1FallbackError";
|
||||
constructor(message, tryNextLink = true) {
|
||||
super(message, tryNextLink);
|
||||
this.tryNextLink = tryNextLink;
|
||||
Object.setPrototypeOf(this, InstanceMetadataV1FallbackError.prototype);
|
||||
}
|
||||
}
|
||||
|
||||
exports.yI = void 0;
|
||||
(function (Endpoint) {
|
||||
Endpoint["IPv4"] = "http://169.254.169.254";
|
||||
Endpoint["IPv6"] = "http://[fd00:ec2::254]";
|
||||
})(exports.yI || (exports.yI = {}));
|
||||
|
||||
const ENV_ENDPOINT_NAME = "AWS_EC2_METADATA_SERVICE_ENDPOINT";
|
||||
const CONFIG_ENDPOINT_NAME = "ec2_metadata_service_endpoint";
|
||||
const ENDPOINT_CONFIG_OPTIONS = {
|
||||
environmentVariableSelector: (env) => env[ENV_ENDPOINT_NAME],
|
||||
configFileSelector: (profile) => profile[CONFIG_ENDPOINT_NAME],
|
||||
default: undefined,
|
||||
};
|
||||
|
||||
var EndpointMode;
|
||||
(function (EndpointMode) {
|
||||
EndpointMode["IPv4"] = "IPv4";
|
||||
EndpointMode["IPv6"] = "IPv6";
|
||||
})(EndpointMode || (EndpointMode = {}));
|
||||
|
||||
const ENV_ENDPOINT_MODE_NAME = "AWS_EC2_METADATA_SERVICE_ENDPOINT_MODE";
|
||||
const CONFIG_ENDPOINT_MODE_NAME = "ec2_metadata_service_endpoint_mode";
|
||||
const ENDPOINT_MODE_CONFIG_OPTIONS = {
|
||||
environmentVariableSelector: (env) => env[ENV_ENDPOINT_MODE_NAME],
|
||||
configFileSelector: (profile) => profile[CONFIG_ENDPOINT_MODE_NAME],
|
||||
default: EndpointMode.IPv4,
|
||||
};
|
||||
|
||||
const getInstanceMetadataEndpoint = async () => urlParser.parseUrl((await getFromEndpointConfig()) || (await getFromEndpointModeConfig()));
|
||||
const getFromEndpointConfig = async () => nodeConfigProvider.loadConfig(ENDPOINT_CONFIG_OPTIONS)();
|
||||
const getFromEndpointModeConfig = async () => {
|
||||
const endpointMode = await nodeConfigProvider.loadConfig(ENDPOINT_MODE_CONFIG_OPTIONS)();
|
||||
switch (endpointMode) {
|
||||
case EndpointMode.IPv4:
|
||||
return exports.yI.IPv4;
|
||||
case EndpointMode.IPv6:
|
||||
return exports.yI.IPv6;
|
||||
default:
|
||||
throw new Error(`Unsupported endpoint mode: ${endpointMode}.` + ` Select from ${Object.values(EndpointMode)}`);
|
||||
}
|
||||
};
|
||||
|
||||
const STATIC_STABILITY_REFRESH_INTERVAL_SECONDS = 5 * 60;
|
||||
const STATIC_STABILITY_REFRESH_INTERVAL_JITTER_WINDOW_SECONDS = 5 * 60;
|
||||
const STATIC_STABILITY_DOC_URL = "https://docs.aws.amazon.com/sdkref/latest/guide/feature-static-credentials.html";
|
||||
const getExtendedInstanceMetadataCredentials = (credentials, logger) => {
|
||||
const refreshInterval = STATIC_STABILITY_REFRESH_INTERVAL_SECONDS +
|
||||
Math.floor(Math.random() * STATIC_STABILITY_REFRESH_INTERVAL_JITTER_WINDOW_SECONDS);
|
||||
const newExpiration = new Date(Date.now() + refreshInterval * 1000);
|
||||
logger.warn("Attempting credential expiration extension due to a credential service availability issue. A refresh of these " +
|
||||
`credentials will be attempted after ${new Date(newExpiration)}.\nFor more information, please visit: ` +
|
||||
STATIC_STABILITY_DOC_URL);
|
||||
const originalExpiration = credentials.originalExpiration ?? credentials.expiration;
|
||||
return {
|
||||
...credentials,
|
||||
...(originalExpiration ? { originalExpiration } : {}),
|
||||
expiration: newExpiration,
|
||||
};
|
||||
};
|
||||
|
||||
const staticStabilityProvider = (provider, options = {}) => {
|
||||
const logger = options?.logger || console;
|
||||
let pastCredentials;
|
||||
return async () => {
|
||||
let credentials;
|
||||
try {
|
||||
credentials = await provider();
|
||||
if (credentials.expiration && credentials.expiration.getTime() < Date.now()) {
|
||||
credentials = getExtendedInstanceMetadataCredentials(credentials, logger);
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
if (pastCredentials) {
|
||||
logger.warn("Credential renew failed: ", e);
|
||||
credentials = getExtendedInstanceMetadataCredentials(pastCredentials, logger);
|
||||
}
|
||||
else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
pastCredentials = credentials;
|
||||
return credentials;
|
||||
};
|
||||
};
|
||||
|
||||
const IMDS_PATH = "/latest/meta-data/iam/security-credentials/";
|
||||
const IMDS_TOKEN_PATH = "/latest/api/token";
|
||||
const AWS_EC2_METADATA_V1_DISABLED = "AWS_EC2_METADATA_V1_DISABLED";
|
||||
const PROFILE_AWS_EC2_METADATA_V1_DISABLED = "ec2_metadata_v1_disabled";
|
||||
const X_AWS_EC2_METADATA_TOKEN = "x-aws-ec2-metadata-token";
|
||||
const fromInstanceMetadata = (init = {}) => staticStabilityProvider(getInstanceMetadataProvider(init), { logger: init.logger });
|
||||
const getInstanceMetadataProvider = (init = {}) => {
|
||||
let disableFetchToken = false;
|
||||
const { logger, profile } = init;
|
||||
const { timeout, maxRetries } = providerConfigFromInit(init);
|
||||
const getCredentials = async (maxRetries, options) => {
|
||||
const isImdsV1Fallback = disableFetchToken || options.headers?.[X_AWS_EC2_METADATA_TOKEN] == null;
|
||||
if (isImdsV1Fallback) {
|
||||
let fallbackBlockedFromProfile = false;
|
||||
let fallbackBlockedFromProcessEnv = false;
|
||||
const configValue = await nodeConfigProvider.loadConfig({
|
||||
environmentVariableSelector: (env) => {
|
||||
const envValue = env[AWS_EC2_METADATA_V1_DISABLED];
|
||||
fallbackBlockedFromProcessEnv = !!envValue && envValue !== "false";
|
||||
if (envValue === undefined) {
|
||||
throw new propertyProvider.CredentialsProviderError(`${AWS_EC2_METADATA_V1_DISABLED} not set in env, checking config file next.`, { logger: init.logger });
|
||||
}
|
||||
return fallbackBlockedFromProcessEnv;
|
||||
},
|
||||
configFileSelector: (profile) => {
|
||||
const profileValue = profile[PROFILE_AWS_EC2_METADATA_V1_DISABLED];
|
||||
fallbackBlockedFromProfile = !!profileValue && profileValue !== "false";
|
||||
return fallbackBlockedFromProfile;
|
||||
},
|
||||
default: false,
|
||||
}, {
|
||||
profile,
|
||||
})();
|
||||
if (init.ec2MetadataV1Disabled || configValue) {
|
||||
const causes = [];
|
||||
if (init.ec2MetadataV1Disabled)
|
||||
causes.push("credential provider initialization (runtime option ec2MetadataV1Disabled)");
|
||||
if (fallbackBlockedFromProfile)
|
||||
causes.push(`config file profile (${PROFILE_AWS_EC2_METADATA_V1_DISABLED})`);
|
||||
if (fallbackBlockedFromProcessEnv)
|
||||
causes.push(`process environment variable (${AWS_EC2_METADATA_V1_DISABLED})`);
|
||||
throw new InstanceMetadataV1FallbackError(`AWS EC2 Metadata v1 fallback has been blocked by AWS SDK configuration in the following: [${causes.join(", ")}].`);
|
||||
}
|
||||
}
|
||||
const imdsProfile = (await retry(async () => {
|
||||
let profile;
|
||||
try {
|
||||
profile = await getProfile(options);
|
||||
}
|
||||
catch (err) {
|
||||
if (err.statusCode === 401) {
|
||||
disableFetchToken = false;
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
return profile;
|
||||
}, maxRetries)).trim();
|
||||
return retry(async () => {
|
||||
let creds;
|
||||
try {
|
||||
creds = await getCredentialsFromProfile(imdsProfile, options, init);
|
||||
}
|
||||
catch (err) {
|
||||
if (err.statusCode === 401) {
|
||||
disableFetchToken = false;
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
return creds;
|
||||
}, maxRetries);
|
||||
};
|
||||
return async () => {
|
||||
const endpoint = await getInstanceMetadataEndpoint();
|
||||
if (disableFetchToken) {
|
||||
logger?.debug("AWS SDK Instance Metadata", "using v1 fallback (no token fetch)");
|
||||
return getCredentials(maxRetries, { ...endpoint, timeout });
|
||||
}
|
||||
else {
|
||||
let token;
|
||||
try {
|
||||
token = (await getMetadataToken({ ...endpoint, timeout })).toString();
|
||||
}
|
||||
catch (error) {
|
||||
if (error?.statusCode === 400) {
|
||||
throw Object.assign(error, {
|
||||
message: "EC2 Metadata token request returned error",
|
||||
});
|
||||
}
|
||||
else if (error.message === "TimeoutError" || [403, 404, 405].includes(error.statusCode)) {
|
||||
disableFetchToken = true;
|
||||
}
|
||||
logger?.debug("AWS SDK Instance Metadata", "using v1 fallback (initial)");
|
||||
return getCredentials(maxRetries, { ...endpoint, timeout });
|
||||
}
|
||||
return getCredentials(maxRetries, {
|
||||
...endpoint,
|
||||
headers: {
|
||||
[X_AWS_EC2_METADATA_TOKEN]: token,
|
||||
},
|
||||
timeout,
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
const getMetadataToken = async (options) => httpRequest({
|
||||
...options,
|
||||
path: IMDS_TOKEN_PATH,
|
||||
method: "PUT",
|
||||
headers: {
|
||||
"x-aws-ec2-metadata-token-ttl-seconds": "21600",
|
||||
},
|
||||
});
|
||||
const getProfile = async (options) => (await httpRequest({ ...options, path: IMDS_PATH })).toString();
|
||||
const getCredentialsFromProfile = async (profile, options, init) => {
|
||||
const credentialsResponse = JSON.parse((await httpRequest({
|
||||
...options,
|
||||
path: IMDS_PATH + profile,
|
||||
})).toString());
|
||||
if (!isImdsCredentials(credentialsResponse)) {
|
||||
throw new propertyProvider.CredentialsProviderError("Invalid response received from instance metadata service.", {
|
||||
logger: init.logger,
|
||||
});
|
||||
}
|
||||
return fromImdsCredentials(credentialsResponse);
|
||||
};
|
||||
|
||||
__webpack_unused_export__ = DEFAULT_MAX_RETRIES;
|
||||
__webpack_unused_export__ = DEFAULT_TIMEOUT;
|
||||
__webpack_unused_export__ = ENV_CMDS_AUTH_TOKEN;
|
||||
exports.ENV_CMDS_FULL_URI = ENV_CMDS_FULL_URI;
|
||||
exports.ENV_CMDS_RELATIVE_URI = ENV_CMDS_RELATIVE_URI;
|
||||
exports.fromContainerMetadata = fromContainerMetadata;
|
||||
exports.fromInstanceMetadata = fromInstanceMetadata;
|
||||
exports.getInstanceMetadataEndpoint = getInstanceMetadataEndpoint;
|
||||
exports.httpRequest = httpRequest;
|
||||
__webpack_unused_export__ = providerConfigFromInit;
|
||||
|
||||
|
||||
/***/ })
|
||||
|
||||
};
|
||||
;
|
||||
270
dist/cleanup/579.index.js
generated
vendored
270
dist/cleanup/579.index.js
generated
vendored
|
|
@ -1,270 +0,0 @@
|
|||
"use strict";
|
||||
exports.id = 579;
|
||||
exports.ids = [579];
|
||||
exports.modules = {
|
||||
|
||||
/***/ 6579:
|
||||
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
||||
|
||||
|
||||
|
||||
var utilUtf8 = __webpack_require__(1577);
|
||||
|
||||
class EventStreamSerde {
|
||||
marshaller;
|
||||
serializer;
|
||||
deserializer;
|
||||
serdeContext;
|
||||
defaultContentType;
|
||||
constructor({ marshaller, serializer, deserializer, serdeContext, defaultContentType, }) {
|
||||
this.marshaller = marshaller;
|
||||
this.serializer = serializer;
|
||||
this.deserializer = deserializer;
|
||||
this.serdeContext = serdeContext;
|
||||
this.defaultContentType = defaultContentType;
|
||||
}
|
||||
async serializeEventStream({ eventStream, requestSchema, initialRequest, }) {
|
||||
const marshaller = this.marshaller;
|
||||
const eventStreamMember = requestSchema.getEventStreamMember();
|
||||
const unionSchema = requestSchema.getMemberSchema(eventStreamMember);
|
||||
const serializer = this.serializer;
|
||||
const defaultContentType = this.defaultContentType;
|
||||
const initialRequestMarker = Symbol("initialRequestMarker");
|
||||
const eventStreamIterable = {
|
||||
async *[Symbol.asyncIterator]() {
|
||||
if (initialRequest) {
|
||||
const headers = {
|
||||
":event-type": { type: "string", value: "initial-request" },
|
||||
":message-type": { type: "string", value: "event" },
|
||||
":content-type": { type: "string", value: defaultContentType },
|
||||
};
|
||||
serializer.write(requestSchema, initialRequest);
|
||||
const body = serializer.flush();
|
||||
yield {
|
||||
[initialRequestMarker]: true,
|
||||
headers,
|
||||
body,
|
||||
};
|
||||
}
|
||||
for await (const page of eventStream) {
|
||||
yield page;
|
||||
}
|
||||
},
|
||||
};
|
||||
return marshaller.serialize(eventStreamIterable, (event) => {
|
||||
if (event[initialRequestMarker]) {
|
||||
return {
|
||||
headers: event.headers,
|
||||
body: event.body,
|
||||
};
|
||||
}
|
||||
const unionMember = Object.keys(event).find((key) => {
|
||||
return key !== "__type";
|
||||
}) ?? "";
|
||||
const { additionalHeaders, body, eventType, explicitPayloadContentType } = this.writeEventBody(unionMember, unionSchema, event);
|
||||
const headers = {
|
||||
":event-type": { type: "string", value: eventType },
|
||||
":message-type": { type: "string", value: "event" },
|
||||
":content-type": { type: "string", value: explicitPayloadContentType ?? defaultContentType },
|
||||
...additionalHeaders,
|
||||
};
|
||||
return {
|
||||
headers,
|
||||
body,
|
||||
};
|
||||
});
|
||||
}
|
||||
async deserializeEventStream({ response, responseSchema, initialResponseContainer, }) {
|
||||
const marshaller = this.marshaller;
|
||||
const eventStreamMember = responseSchema.getEventStreamMember();
|
||||
const unionSchema = responseSchema.getMemberSchema(eventStreamMember);
|
||||
const memberSchemas = unionSchema.getMemberSchemas();
|
||||
const initialResponseMarker = Symbol("initialResponseMarker");
|
||||
const asyncIterable = marshaller.deserialize(response.body, async (event) => {
|
||||
const unionMember = Object.keys(event).find((key) => {
|
||||
return key !== "__type";
|
||||
}) ?? "";
|
||||
const body = event[unionMember].body;
|
||||
if (unionMember === "initial-response") {
|
||||
const dataObject = await this.deserializer.read(responseSchema, body);
|
||||
delete dataObject[eventStreamMember];
|
||||
return {
|
||||
[initialResponseMarker]: true,
|
||||
...dataObject,
|
||||
};
|
||||
}
|
||||
else if (unionMember in memberSchemas) {
|
||||
const eventStreamSchema = memberSchemas[unionMember];
|
||||
if (eventStreamSchema.isStructSchema()) {
|
||||
const out = {};
|
||||
let hasBindings = false;
|
||||
for (const [name, member] of eventStreamSchema.structIterator()) {
|
||||
const { eventHeader, eventPayload } = member.getMergedTraits();
|
||||
hasBindings = hasBindings || Boolean(eventHeader || eventPayload);
|
||||
if (eventPayload) {
|
||||
if (member.isBlobSchema()) {
|
||||
out[name] = body;
|
||||
}
|
||||
else if (member.isStringSchema()) {
|
||||
out[name] = (this.serdeContext?.utf8Encoder ?? utilUtf8.toUtf8)(body);
|
||||
}
|
||||
else if (member.isStructSchema()) {
|
||||
out[name] = await this.deserializer.read(member, body);
|
||||
}
|
||||
}
|
||||
else if (eventHeader) {
|
||||
const value = event[unionMember].headers[name]?.value;
|
||||
if (value != null) {
|
||||
if (member.isNumericSchema()) {
|
||||
if (value && typeof value === "object" && "bytes" in value) {
|
||||
out[name] = BigInt(value.toString());
|
||||
}
|
||||
else {
|
||||
out[name] = Number(value);
|
||||
}
|
||||
}
|
||||
else {
|
||||
out[name] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hasBindings) {
|
||||
return {
|
||||
[unionMember]: out,
|
||||
};
|
||||
}
|
||||
if (body.byteLength === 0) {
|
||||
return {
|
||||
[unionMember]: {},
|
||||
};
|
||||
}
|
||||
}
|
||||
return {
|
||||
[unionMember]: await this.deserializer.read(eventStreamSchema, body),
|
||||
};
|
||||
}
|
||||
else {
|
||||
return {
|
||||
$unknown: event,
|
||||
};
|
||||
}
|
||||
});
|
||||
const asyncIterator = asyncIterable[Symbol.asyncIterator]();
|
||||
const firstEvent = await asyncIterator.next();
|
||||
if (firstEvent.done) {
|
||||
return asyncIterable;
|
||||
}
|
||||
if (firstEvent.value?.[initialResponseMarker]) {
|
||||
if (!responseSchema) {
|
||||
throw new Error("@smithy::core/protocols - initial-response event encountered in event stream but no response schema given.");
|
||||
}
|
||||
for (const [key, value] of Object.entries(firstEvent.value)) {
|
||||
initialResponseContainer[key] = value;
|
||||
}
|
||||
}
|
||||
return {
|
||||
async *[Symbol.asyncIterator]() {
|
||||
if (!firstEvent?.value?.[initialResponseMarker]) {
|
||||
yield firstEvent.value;
|
||||
}
|
||||
while (true) {
|
||||
const { done, value } = await asyncIterator.next();
|
||||
if (done) {
|
||||
break;
|
||||
}
|
||||
yield value;
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
writeEventBody(unionMember, unionSchema, event) {
|
||||
const serializer = this.serializer;
|
||||
let eventType = unionMember;
|
||||
let explicitPayloadMember = null;
|
||||
let explicitPayloadContentType;
|
||||
const isKnownSchema = (() => {
|
||||
const struct = unionSchema.getSchema();
|
||||
return struct[4].includes(unionMember);
|
||||
})();
|
||||
const additionalHeaders = {};
|
||||
if (!isKnownSchema) {
|
||||
const [type, value] = event[unionMember];
|
||||
eventType = type;
|
||||
serializer.write(15, value);
|
||||
}
|
||||
else {
|
||||
const eventSchema = unionSchema.getMemberSchema(unionMember);
|
||||
if (eventSchema.isStructSchema()) {
|
||||
for (const [memberName, memberSchema] of eventSchema.structIterator()) {
|
||||
const { eventHeader, eventPayload } = memberSchema.getMergedTraits();
|
||||
if (eventPayload) {
|
||||
explicitPayloadMember = memberName;
|
||||
}
|
||||
else if (eventHeader) {
|
||||
const value = event[unionMember][memberName];
|
||||
let type = "binary";
|
||||
if (memberSchema.isNumericSchema()) {
|
||||
if ((-2) ** 31 <= value && value <= 2 ** 31 - 1) {
|
||||
type = "integer";
|
||||
}
|
||||
else {
|
||||
type = "long";
|
||||
}
|
||||
}
|
||||
else if (memberSchema.isTimestampSchema()) {
|
||||
type = "timestamp";
|
||||
}
|
||||
else if (memberSchema.isStringSchema()) {
|
||||
type = "string";
|
||||
}
|
||||
else if (memberSchema.isBooleanSchema()) {
|
||||
type = "boolean";
|
||||
}
|
||||
if (value != null) {
|
||||
additionalHeaders[memberName] = {
|
||||
type,
|
||||
value,
|
||||
};
|
||||
delete event[unionMember][memberName];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (explicitPayloadMember !== null) {
|
||||
const payloadSchema = eventSchema.getMemberSchema(explicitPayloadMember);
|
||||
if (payloadSchema.isBlobSchema()) {
|
||||
explicitPayloadContentType = "application/octet-stream";
|
||||
}
|
||||
else if (payloadSchema.isStringSchema()) {
|
||||
explicitPayloadContentType = "text/plain";
|
||||
}
|
||||
serializer.write(payloadSchema, event[unionMember][explicitPayloadMember]);
|
||||
}
|
||||
else {
|
||||
serializer.write(eventSchema, event[unionMember]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new Error("@smithy/core/event-streams - non-struct member not supported in event stream union.");
|
||||
}
|
||||
}
|
||||
const messageSerialization = serializer.flush();
|
||||
const body = typeof messageSerialization === "string"
|
||||
? (this.serdeContext?.utf8Decoder ?? utilUtf8.fromUtf8)(messageSerialization)
|
||||
: messageSerialization;
|
||||
return {
|
||||
body,
|
||||
eventType,
|
||||
explicitPayloadContentType,
|
||||
additionalHeaders,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
exports.EventStreamSerde = EventStreamSerde;
|
||||
|
||||
|
||||
/***/ })
|
||||
|
||||
};
|
||||
;
|
||||
234
dist/cleanup/605.index.js
generated
vendored
234
dist/cleanup/605.index.js
generated
vendored
|
|
@ -1,234 +0,0 @@
|
|||
"use strict";
|
||||
exports.id = 605;
|
||||
exports.ids = [605];
|
||||
exports.modules = {
|
||||
|
||||
/***/ 1509:
|
||||
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
||||
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.checkUrl = void 0;
|
||||
const property_provider_1 = __webpack_require__(1238);
|
||||
const LOOPBACK_CIDR_IPv4 = "127.0.0.0/8";
|
||||
const LOOPBACK_CIDR_IPv6 = "::1/128";
|
||||
const ECS_CONTAINER_HOST = "169.254.170.2";
|
||||
const EKS_CONTAINER_HOST_IPv4 = "169.254.170.23";
|
||||
const EKS_CONTAINER_HOST_IPv6 = "[fd00:ec2::23]";
|
||||
const checkUrl = (url, logger) => {
|
||||
if (url.protocol === "https:") {
|
||||
return;
|
||||
}
|
||||
if (url.hostname === ECS_CONTAINER_HOST ||
|
||||
url.hostname === EKS_CONTAINER_HOST_IPv4 ||
|
||||
url.hostname === EKS_CONTAINER_HOST_IPv6) {
|
||||
return;
|
||||
}
|
||||
if (url.hostname.includes("[")) {
|
||||
if (url.hostname === "[::1]" || url.hostname === "[0000:0000:0000:0000:0000:0000:0000:0001]") {
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (url.hostname === "localhost") {
|
||||
return;
|
||||
}
|
||||
const ipComponents = url.hostname.split(".");
|
||||
const inRange = (component) => {
|
||||
const num = parseInt(component, 10);
|
||||
return 0 <= num && num <= 255;
|
||||
};
|
||||
if (ipComponents[0] === "127" &&
|
||||
inRange(ipComponents[1]) &&
|
||||
inRange(ipComponents[2]) &&
|
||||
inRange(ipComponents[3]) &&
|
||||
ipComponents.length === 4) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new property_provider_1.CredentialsProviderError(`URL not accepted. It must either be HTTPS or match one of the following:
|
||||
- loopback CIDR 127.0.0.0/8 or [::1/128]
|
||||
- ECS container host 169.254.170.2
|
||||
- EKS container host 169.254.170.23 or [fd00:ec2::23]`, { logger });
|
||||
};
|
||||
exports.checkUrl = checkUrl;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 8712:
|
||||
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
||||
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.fromHttp = void 0;
|
||||
const tslib_1 = __webpack_require__(1860);
|
||||
const client_1 = __webpack_require__(5152);
|
||||
const node_http_handler_1 = __webpack_require__(1279);
|
||||
const property_provider_1 = __webpack_require__(1238);
|
||||
const promises_1 = tslib_1.__importDefault(__webpack_require__(1943));
|
||||
const checkUrl_1 = __webpack_require__(1509);
|
||||
const requestHelpers_1 = __webpack_require__(8914);
|
||||
const retry_wrapper_1 = __webpack_require__(1122);
|
||||
const AWS_CONTAINER_CREDENTIALS_RELATIVE_URI = "AWS_CONTAINER_CREDENTIALS_RELATIVE_URI";
|
||||
const DEFAULT_LINK_LOCAL_HOST = "http://169.254.170.2";
|
||||
const AWS_CONTAINER_CREDENTIALS_FULL_URI = "AWS_CONTAINER_CREDENTIALS_FULL_URI";
|
||||
const AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE = "AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE";
|
||||
const AWS_CONTAINER_AUTHORIZATION_TOKEN = "AWS_CONTAINER_AUTHORIZATION_TOKEN";
|
||||
const fromHttp = (options = {}) => {
|
||||
options.logger?.debug("@aws-sdk/credential-provider-http - fromHttp");
|
||||
let host;
|
||||
const relative = options.awsContainerCredentialsRelativeUri ?? process.env[AWS_CONTAINER_CREDENTIALS_RELATIVE_URI];
|
||||
const full = options.awsContainerCredentialsFullUri ?? process.env[AWS_CONTAINER_CREDENTIALS_FULL_URI];
|
||||
const token = options.awsContainerAuthorizationToken ?? process.env[AWS_CONTAINER_AUTHORIZATION_TOKEN];
|
||||
const tokenFile = options.awsContainerAuthorizationTokenFile ?? process.env[AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE];
|
||||
const warn = options.logger?.constructor?.name === "NoOpLogger" || !options.logger?.warn
|
||||
? console.warn
|
||||
: options.logger.warn.bind(options.logger);
|
||||
if (relative && full) {
|
||||
warn("@aws-sdk/credential-provider-http: " +
|
||||
"you have set both awsContainerCredentialsRelativeUri and awsContainerCredentialsFullUri.");
|
||||
warn("awsContainerCredentialsFullUri will take precedence.");
|
||||
}
|
||||
if (token && tokenFile) {
|
||||
warn("@aws-sdk/credential-provider-http: " +
|
||||
"you have set both awsContainerAuthorizationToken and awsContainerAuthorizationTokenFile.");
|
||||
warn("awsContainerAuthorizationToken will take precedence.");
|
||||
}
|
||||
if (full) {
|
||||
host = full;
|
||||
}
|
||||
else if (relative) {
|
||||
host = `${DEFAULT_LINK_LOCAL_HOST}${relative}`;
|
||||
}
|
||||
else {
|
||||
throw new property_provider_1.CredentialsProviderError(`No HTTP credential provider host provided.
|
||||
Set AWS_CONTAINER_CREDENTIALS_FULL_URI or AWS_CONTAINER_CREDENTIALS_RELATIVE_URI.`, { logger: options.logger });
|
||||
}
|
||||
const url = new URL(host);
|
||||
(0, checkUrl_1.checkUrl)(url, options.logger);
|
||||
const requestHandler = node_http_handler_1.NodeHttpHandler.create({
|
||||
requestTimeout: options.timeout ?? 1000,
|
||||
connectionTimeout: options.timeout ?? 1000,
|
||||
});
|
||||
return (0, retry_wrapper_1.retryWrapper)(async () => {
|
||||
const request = (0, requestHelpers_1.createGetRequest)(url);
|
||||
if (token) {
|
||||
request.headers.Authorization = token;
|
||||
}
|
||||
else if (tokenFile) {
|
||||
request.headers.Authorization = (await promises_1.default.readFile(tokenFile)).toString();
|
||||
}
|
||||
try {
|
||||
const result = await requestHandler.handle(request);
|
||||
return (0, requestHelpers_1.getCredentials)(result.response).then((creds) => (0, client_1.setCredentialFeature)(creds, "CREDENTIALS_HTTP", "z"));
|
||||
}
|
||||
catch (e) {
|
||||
throw new property_provider_1.CredentialsProviderError(String(e), { logger: options.logger });
|
||||
}
|
||||
}, options.maxRetries ?? 3, options.timeout ?? 1000);
|
||||
};
|
||||
exports.fromHttp = fromHttp;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 8914:
|
||||
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
||||
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.createGetRequest = createGetRequest;
|
||||
exports.getCredentials = getCredentials;
|
||||
const property_provider_1 = __webpack_require__(1238);
|
||||
const protocol_http_1 = __webpack_require__(2356);
|
||||
const smithy_client_1 = __webpack_require__(1411);
|
||||
const util_stream_1 = __webpack_require__(4252);
|
||||
function createGetRequest(url) {
|
||||
return new protocol_http_1.HttpRequest({
|
||||
protocol: url.protocol,
|
||||
hostname: url.hostname,
|
||||
port: Number(url.port),
|
||||
path: url.pathname,
|
||||
query: Array.from(url.searchParams.entries()).reduce((acc, [k, v]) => {
|
||||
acc[k] = v;
|
||||
return acc;
|
||||
}, {}),
|
||||
fragment: url.hash,
|
||||
});
|
||||
}
|
||||
async function getCredentials(response, logger) {
|
||||
const stream = (0, util_stream_1.sdkStreamMixin)(response.body);
|
||||
const str = await stream.transformToString();
|
||||
if (response.statusCode === 200) {
|
||||
const parsed = JSON.parse(str);
|
||||
if (typeof parsed.AccessKeyId !== "string" ||
|
||||
typeof parsed.SecretAccessKey !== "string" ||
|
||||
typeof parsed.Token !== "string" ||
|
||||
typeof parsed.Expiration !== "string") {
|
||||
throw new property_provider_1.CredentialsProviderError("HTTP credential provider response not of the required format, an object matching: " +
|
||||
"{ AccessKeyId: string, SecretAccessKey: string, Token: string, Expiration: string(rfc3339) }", { logger });
|
||||
}
|
||||
return {
|
||||
accessKeyId: parsed.AccessKeyId,
|
||||
secretAccessKey: parsed.SecretAccessKey,
|
||||
sessionToken: parsed.Token,
|
||||
expiration: (0, smithy_client_1.parseRfc3339DateTime)(parsed.Expiration),
|
||||
};
|
||||
}
|
||||
if (response.statusCode >= 400 && response.statusCode < 500) {
|
||||
let parsedBody = {};
|
||||
try {
|
||||
parsedBody = JSON.parse(str);
|
||||
}
|
||||
catch (e) { }
|
||||
throw Object.assign(new property_provider_1.CredentialsProviderError(`Server responded with status: ${response.statusCode}`, { logger }), {
|
||||
Code: parsedBody.Code,
|
||||
Message: parsedBody.Message,
|
||||
});
|
||||
}
|
||||
throw new property_provider_1.CredentialsProviderError(`Server responded with status: ${response.statusCode}`, { logger });
|
||||
}
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 1122:
|
||||
/***/ ((__unused_webpack_module, exports) => {
|
||||
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.retryWrapper = void 0;
|
||||
const retryWrapper = (toRetry, maxRetries, delayMs) => {
|
||||
return async () => {
|
||||
for (let i = 0; i < maxRetries; ++i) {
|
||||
try {
|
||||
return await toRetry();
|
||||
}
|
||||
catch (e) {
|
||||
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
||||
}
|
||||
}
|
||||
return await toRetry();
|
||||
};
|
||||
};
|
||||
exports.retryWrapper = retryWrapper;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 8605:
|
||||
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
||||
|
||||
var __webpack_unused_export__;
|
||||
|
||||
__webpack_unused_export__ = ({ value: true });
|
||||
exports.fromHttp = void 0;
|
||||
var fromHttp_1 = __webpack_require__(8712);
|
||||
Object.defineProperty(exports, "fromHttp", ({ enumerable: true, get: function () { return fromHttp_1.fromHttp; } }));
|
||||
|
||||
|
||||
/***/ })
|
||||
|
||||
};
|
||||
;
|
||||
1009
dist/cleanup/762.index.js
generated
vendored
1009
dist/cleanup/762.index.js
generated
vendored
File diff suppressed because it is too large
Load diff
531
dist/cleanup/869.index.js
generated
vendored
531
dist/cleanup/869.index.js
generated
vendored
|
|
@ -1,531 +0,0 @@
|
|||
"use strict";
|
||||
exports.id = 869;
|
||||
exports.ids = [869];
|
||||
exports.modules = {
|
||||
|
||||
/***/ 5869:
|
||||
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
||||
|
||||
|
||||
|
||||
var sharedIniFileLoader = __webpack_require__(4964);
|
||||
var propertyProvider = __webpack_require__(1238);
|
||||
var client = __webpack_require__(5152);
|
||||
var credentialProviderLogin = __webpack_require__(4072);
|
||||
|
||||
const resolveCredentialSource = (credentialSource, profileName, logger) => {
|
||||
const sourceProvidersMap = {
|
||||
EcsContainer: async (options) => {
|
||||
const { fromHttp } = await __webpack_require__.e(/* import() */ 605).then(__webpack_require__.bind(__webpack_require__, 8605));
|
||||
const { fromContainerMetadata } = await __webpack_require__.e(/* import() */ 566).then(__webpack_require__.t.bind(__webpack_require__, 566, 19));
|
||||
logger?.debug("@aws-sdk/credential-provider-ini - credential_source is EcsContainer");
|
||||
return async () => propertyProvider.chain(fromHttp(options ?? {}), fromContainerMetadata(options))().then(setNamedProvider);
|
||||
},
|
||||
Ec2InstanceMetadata: async (options) => {
|
||||
logger?.debug("@aws-sdk/credential-provider-ini - credential_source is Ec2InstanceMetadata");
|
||||
const { fromInstanceMetadata } = await __webpack_require__.e(/* import() */ 566).then(__webpack_require__.t.bind(__webpack_require__, 566, 19));
|
||||
return async () => fromInstanceMetadata(options)().then(setNamedProvider);
|
||||
},
|
||||
Environment: async (options) => {
|
||||
logger?.debug("@aws-sdk/credential-provider-ini - credential_source is Environment");
|
||||
const { fromEnv } = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 5606, 19));
|
||||
return async () => fromEnv(options)().then(setNamedProvider);
|
||||
},
|
||||
};
|
||||
if (credentialSource in sourceProvidersMap) {
|
||||
return sourceProvidersMap[credentialSource];
|
||||
}
|
||||
else {
|
||||
throw new propertyProvider.CredentialsProviderError(`Unsupported credential source in profile ${profileName}. Got ${credentialSource}, ` +
|
||||
`expected EcsContainer or Ec2InstanceMetadata or Environment.`, { logger });
|
||||
}
|
||||
};
|
||||
const setNamedProvider = (creds) => client.setCredentialFeature(creds, "CREDENTIALS_PROFILE_NAMED_PROVIDER", "p");
|
||||
|
||||
const isAssumeRoleProfile = (arg, { profile = "default", logger } = {}) => {
|
||||
return (Boolean(arg) &&
|
||||
typeof arg === "object" &&
|
||||
typeof arg.role_arn === "string" &&
|
||||
["undefined", "string"].indexOf(typeof arg.role_session_name) > -1 &&
|
||||
["undefined", "string"].indexOf(typeof arg.external_id) > -1 &&
|
||||
["undefined", "string"].indexOf(typeof arg.mfa_serial) > -1 &&
|
||||
(isAssumeRoleWithSourceProfile(arg, { profile, logger }) || isCredentialSourceProfile(arg, { profile, logger })));
|
||||
};
|
||||
const isAssumeRoleWithSourceProfile = (arg, { profile, logger }) => {
|
||||
const withSourceProfile = typeof arg.source_profile === "string" && typeof arg.credential_source === "undefined";
|
||||
if (withSourceProfile) {
|
||||
logger?.debug?.(` ${profile} isAssumeRoleWithSourceProfile source_profile=${arg.source_profile}`);
|
||||
}
|
||||
return withSourceProfile;
|
||||
};
|
||||
const isCredentialSourceProfile = (arg, { profile, logger }) => {
|
||||
const withProviderProfile = typeof arg.credential_source === "string" && typeof arg.source_profile === "undefined";
|
||||
if (withProviderProfile) {
|
||||
logger?.debug?.(` ${profile} isCredentialSourceProfile credential_source=${arg.credential_source}`);
|
||||
}
|
||||
return withProviderProfile;
|
||||
};
|
||||
const resolveAssumeRoleCredentials = async (profileName, profiles, options, callerClientConfig, visitedProfiles = {}, resolveProfileData) => {
|
||||
options.logger?.debug("@aws-sdk/credential-provider-ini - resolveAssumeRoleCredentials (STS)");
|
||||
const profileData = profiles[profileName];
|
||||
const { source_profile, region } = profileData;
|
||||
if (!options.roleAssumer) {
|
||||
const { getDefaultRoleAssumer } = await __webpack_require__.e(/* import() */ 136).then(__webpack_require__.t.bind(__webpack_require__, 1136, 23));
|
||||
options.roleAssumer = getDefaultRoleAssumer({
|
||||
...options.clientConfig,
|
||||
credentialProviderLogger: options.logger,
|
||||
parentClientConfig: {
|
||||
...callerClientConfig,
|
||||
...options?.parentClientConfig,
|
||||
region: region ?? options?.parentClientConfig?.region ?? callerClientConfig?.region,
|
||||
},
|
||||
}, options.clientPlugins);
|
||||
}
|
||||
if (source_profile && source_profile in visitedProfiles) {
|
||||
throw new propertyProvider.CredentialsProviderError(`Detected a cycle attempting to resolve credentials for profile` +
|
||||
` ${sharedIniFileLoader.getProfileName(options)}. Profiles visited: ` +
|
||||
Object.keys(visitedProfiles).join(", "), { logger: options.logger });
|
||||
}
|
||||
options.logger?.debug(`@aws-sdk/credential-provider-ini - finding credential resolver using ${source_profile ? `source_profile=[${source_profile}]` : `profile=[${profileName}]`}`);
|
||||
const sourceCredsProvider = source_profile
|
||||
? resolveProfileData(source_profile, profiles, options, callerClientConfig, {
|
||||
...visitedProfiles,
|
||||
[source_profile]: true,
|
||||
}, isCredentialSourceWithoutRoleArn(profiles[source_profile] ?? {}))
|
||||
: (await resolveCredentialSource(profileData.credential_source, profileName, options.logger)(options))();
|
||||
if (isCredentialSourceWithoutRoleArn(profileData)) {
|
||||
return sourceCredsProvider.then((creds) => client.setCredentialFeature(creds, "CREDENTIALS_PROFILE_SOURCE_PROFILE", "o"));
|
||||
}
|
||||
else {
|
||||
const params = {
|
||||
RoleArn: profileData.role_arn,
|
||||
RoleSessionName: profileData.role_session_name || `aws-sdk-js-${Date.now()}`,
|
||||
ExternalId: profileData.external_id,
|
||||
DurationSeconds: parseInt(profileData.duration_seconds || "3600", 10),
|
||||
};
|
||||
const { mfa_serial } = profileData;
|
||||
if (mfa_serial) {
|
||||
if (!options.mfaCodeProvider) {
|
||||
throw new propertyProvider.CredentialsProviderError(`Profile ${profileName} requires multi-factor authentication, but no MFA code callback was provided.`, { logger: options.logger, tryNextLink: false });
|
||||
}
|
||||
params.SerialNumber = mfa_serial;
|
||||
params.TokenCode = await options.mfaCodeProvider(mfa_serial);
|
||||
}
|
||||
const sourceCreds = await sourceCredsProvider;
|
||||
return options.roleAssumer(sourceCreds, params).then((creds) => client.setCredentialFeature(creds, "CREDENTIALS_PROFILE_SOURCE_PROFILE", "o"));
|
||||
}
|
||||
};
|
||||
const isCredentialSourceWithoutRoleArn = (section) => {
|
||||
return !section.role_arn && !!section.credential_source;
|
||||
};
|
||||
|
||||
const isLoginProfile = (data) => {
|
||||
return Boolean(data && data.login_session);
|
||||
};
|
||||
const resolveLoginCredentials = async (profileName, options, callerClientConfig) => {
|
||||
const credentials = await credentialProviderLogin.fromLoginCredentials({
|
||||
...options,
|
||||
profile: profileName,
|
||||
})({ callerClientConfig });
|
||||
return client.setCredentialFeature(credentials, "CREDENTIALS_PROFILE_LOGIN", "AC");
|
||||
};
|
||||
|
||||
const isProcessProfile = (arg) => Boolean(arg) && typeof arg === "object" && typeof arg.credential_process === "string";
|
||||
const resolveProcessCredentials = async (options, profile) => __webpack_require__.e(/* import() */ 360).then(__webpack_require__.t.bind(__webpack_require__, 5360, 19)).then(({ fromProcess }) => fromProcess({
|
||||
...options,
|
||||
profile,
|
||||
})().then((creds) => client.setCredentialFeature(creds, "CREDENTIALS_PROFILE_PROCESS", "v")));
|
||||
|
||||
const resolveSsoCredentials = async (profile, profileData, options = {}, callerClientConfig) => {
|
||||
const { fromSSO } = await __webpack_require__.e(/* import() */ 998).then(__webpack_require__.t.bind(__webpack_require__, 998, 19));
|
||||
return fromSSO({
|
||||
profile,
|
||||
logger: options.logger,
|
||||
parentClientConfig: options.parentClientConfig,
|
||||
clientConfig: options.clientConfig,
|
||||
})({
|
||||
callerClientConfig,
|
||||
}).then((creds) => {
|
||||
if (profileData.sso_session) {
|
||||
return client.setCredentialFeature(creds, "CREDENTIALS_PROFILE_SSO", "r");
|
||||
}
|
||||
else {
|
||||
return client.setCredentialFeature(creds, "CREDENTIALS_PROFILE_SSO_LEGACY", "t");
|
||||
}
|
||||
});
|
||||
};
|
||||
const isSsoProfile = (arg) => arg &&
|
||||
(typeof arg.sso_start_url === "string" ||
|
||||
typeof arg.sso_account_id === "string" ||
|
||||
typeof arg.sso_session === "string" ||
|
||||
typeof arg.sso_region === "string" ||
|
||||
typeof arg.sso_role_name === "string");
|
||||
|
||||
const isStaticCredsProfile = (arg) => Boolean(arg) &&
|
||||
typeof arg === "object" &&
|
||||
typeof arg.aws_access_key_id === "string" &&
|
||||
typeof arg.aws_secret_access_key === "string" &&
|
||||
["undefined", "string"].indexOf(typeof arg.aws_session_token) > -1 &&
|
||||
["undefined", "string"].indexOf(typeof arg.aws_account_id) > -1;
|
||||
const resolveStaticCredentials = async (profile, options) => {
|
||||
options?.logger?.debug("@aws-sdk/credential-provider-ini - resolveStaticCredentials");
|
||||
const credentials = {
|
||||
accessKeyId: profile.aws_access_key_id,
|
||||
secretAccessKey: profile.aws_secret_access_key,
|
||||
sessionToken: profile.aws_session_token,
|
||||
...(profile.aws_credential_scope && { credentialScope: profile.aws_credential_scope }),
|
||||
...(profile.aws_account_id && { accountId: profile.aws_account_id }),
|
||||
};
|
||||
return client.setCredentialFeature(credentials, "CREDENTIALS_PROFILE", "n");
|
||||
};
|
||||
|
||||
const isWebIdentityProfile = (arg) => Boolean(arg) &&
|
||||
typeof arg === "object" &&
|
||||
typeof arg.web_identity_token_file === "string" &&
|
||||
typeof arg.role_arn === "string" &&
|
||||
["undefined", "string"].indexOf(typeof arg.role_session_name) > -1;
|
||||
const resolveWebIdentityCredentials = async (profile, options, callerClientConfig) => Promise.all(/* import() */[__webpack_require__.e(136), __webpack_require__.e(956)]).then(__webpack_require__.t.bind(__webpack_require__, 9956, 23)).then(({ fromTokenFile }) => fromTokenFile({
|
||||
webIdentityTokenFile: profile.web_identity_token_file,
|
||||
roleArn: profile.role_arn,
|
||||
roleSessionName: profile.role_session_name,
|
||||
roleAssumerWithWebIdentity: options.roleAssumerWithWebIdentity,
|
||||
logger: options.logger,
|
||||
parentClientConfig: options.parentClientConfig,
|
||||
})({
|
||||
callerClientConfig,
|
||||
}).then((creds) => client.setCredentialFeature(creds, "CREDENTIALS_PROFILE_STS_WEB_ID_TOKEN", "q")));
|
||||
|
||||
const resolveProfileData = async (profileName, profiles, options, callerClientConfig, visitedProfiles = {}, isAssumeRoleRecursiveCall = false) => {
|
||||
const data = profiles[profileName];
|
||||
if (Object.keys(visitedProfiles).length > 0 && isStaticCredsProfile(data)) {
|
||||
return resolveStaticCredentials(data, options);
|
||||
}
|
||||
if (isAssumeRoleRecursiveCall || isAssumeRoleProfile(data, { profile: profileName, logger: options.logger })) {
|
||||
return resolveAssumeRoleCredentials(profileName, profiles, options, callerClientConfig, visitedProfiles, resolveProfileData);
|
||||
}
|
||||
if (isStaticCredsProfile(data)) {
|
||||
return resolveStaticCredentials(data, options);
|
||||
}
|
||||
if (isWebIdentityProfile(data)) {
|
||||
return resolveWebIdentityCredentials(data, options, callerClientConfig);
|
||||
}
|
||||
if (isProcessProfile(data)) {
|
||||
return resolveProcessCredentials(options, profileName);
|
||||
}
|
||||
if (isSsoProfile(data)) {
|
||||
return await resolveSsoCredentials(profileName, data, options, callerClientConfig);
|
||||
}
|
||||
if (isLoginProfile(data)) {
|
||||
return resolveLoginCredentials(profileName, options, callerClientConfig);
|
||||
}
|
||||
throw new propertyProvider.CredentialsProviderError(`Could not resolve credentials using profile: [${profileName}] in configuration/credentials file(s).`, { logger: options.logger });
|
||||
};
|
||||
|
||||
const fromIni = (init = {}) => async ({ callerClientConfig } = {}) => {
|
||||
init.logger?.debug("@aws-sdk/credential-provider-ini - fromIni");
|
||||
const profiles = await sharedIniFileLoader.parseKnownFiles(init);
|
||||
return resolveProfileData(sharedIniFileLoader.getProfileName({
|
||||
profile: init.profile ?? callerClientConfig?.profile,
|
||||
}), profiles, init, callerClientConfig);
|
||||
};
|
||||
|
||||
exports.fromIni = fromIni;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 4072:
|
||||
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
||||
|
||||
|
||||
|
||||
var client = __webpack_require__(5152);
|
||||
var propertyProvider = __webpack_require__(1238);
|
||||
var sharedIniFileLoader = __webpack_require__(4964);
|
||||
var protocolHttp = __webpack_require__(2356);
|
||||
var node_crypto = __webpack_require__(7598);
|
||||
var node_fs = __webpack_require__(3024);
|
||||
var node_os = __webpack_require__(8161);
|
||||
var node_path = __webpack_require__(6760);
|
||||
|
||||
class LoginCredentialsFetcher {
|
||||
profileData;
|
||||
init;
|
||||
callerClientConfig;
|
||||
static REFRESH_THRESHOLD = 5 * 60 * 1000;
|
||||
constructor(profileData, init, callerClientConfig) {
|
||||
this.profileData = profileData;
|
||||
this.init = init;
|
||||
this.callerClientConfig = callerClientConfig;
|
||||
}
|
||||
async loadCredentials() {
|
||||
const token = await this.loadToken();
|
||||
if (!token) {
|
||||
throw new propertyProvider.CredentialsProviderError(`Failed to load a token for session ${this.loginSession}, please re-authenticate using aws login`, { tryNextLink: false, logger: this.logger });
|
||||
}
|
||||
const accessToken = token.accessToken;
|
||||
const now = Date.now();
|
||||
const expiryTime = new Date(accessToken.expiresAt).getTime();
|
||||
const timeUntilExpiry = expiryTime - now;
|
||||
if (timeUntilExpiry <= LoginCredentialsFetcher.REFRESH_THRESHOLD) {
|
||||
return this.refresh(token);
|
||||
}
|
||||
return {
|
||||
accessKeyId: accessToken.accessKeyId,
|
||||
secretAccessKey: accessToken.secretAccessKey,
|
||||
sessionToken: accessToken.sessionToken,
|
||||
accountId: accessToken.accountId,
|
||||
expiration: new Date(accessToken.expiresAt),
|
||||
};
|
||||
}
|
||||
get logger() {
|
||||
return this.init?.logger;
|
||||
}
|
||||
get loginSession() {
|
||||
return this.profileData.login_session;
|
||||
}
|
||||
async refresh(token) {
|
||||
const { SigninClient, CreateOAuth2TokenCommand } = await __webpack_require__.e(/* import() */ 762).then(__webpack_require__.t.bind(__webpack_require__, 9762, 19));
|
||||
const { logger, userAgentAppId } = this.callerClientConfig ?? {};
|
||||
const isH2 = (requestHandler) => {
|
||||
return requestHandler?.metadata?.handlerProtocol === "h2";
|
||||
};
|
||||
const requestHandler = isH2(this.callerClientConfig?.requestHandler)
|
||||
? undefined
|
||||
: this.callerClientConfig?.requestHandler;
|
||||
const region = this.profileData.region ?? (await this.callerClientConfig?.region?.()) ?? process.env.AWS_REGION;
|
||||
const client = new SigninClient({
|
||||
credentials: {
|
||||
accessKeyId: "",
|
||||
secretAccessKey: "",
|
||||
},
|
||||
region,
|
||||
requestHandler,
|
||||
logger,
|
||||
userAgentAppId,
|
||||
...this.init?.clientConfig,
|
||||
});
|
||||
this.createDPoPInterceptor(client.middlewareStack);
|
||||
const commandInput = {
|
||||
tokenInput: {
|
||||
clientId: token.clientId,
|
||||
refreshToken: token.refreshToken,
|
||||
grantType: "refresh_token",
|
||||
},
|
||||
};
|
||||
try {
|
||||
const response = await client.send(new CreateOAuth2TokenCommand(commandInput));
|
||||
const { accessKeyId, secretAccessKey, sessionToken } = response.tokenOutput?.accessToken ?? {};
|
||||
const { refreshToken, expiresIn } = response.tokenOutput ?? {};
|
||||
if (!accessKeyId || !secretAccessKey || !sessionToken || !refreshToken) {
|
||||
throw new propertyProvider.CredentialsProviderError("Token refresh response missing required fields", {
|
||||
logger: this.logger,
|
||||
tryNextLink: false,
|
||||
});
|
||||
}
|
||||
const expiresInMs = (expiresIn ?? 900) * 1000;
|
||||
const expiration = new Date(Date.now() + expiresInMs);
|
||||
const updatedToken = {
|
||||
...token,
|
||||
accessToken: {
|
||||
...token.accessToken,
|
||||
accessKeyId: accessKeyId,
|
||||
secretAccessKey: secretAccessKey,
|
||||
sessionToken: sessionToken,
|
||||
expiresAt: expiration.toISOString(),
|
||||
},
|
||||
refreshToken: refreshToken,
|
||||
};
|
||||
await this.saveToken(updatedToken);
|
||||
const newAccessToken = updatedToken.accessToken;
|
||||
return {
|
||||
accessKeyId: newAccessToken.accessKeyId,
|
||||
secretAccessKey: newAccessToken.secretAccessKey,
|
||||
sessionToken: newAccessToken.sessionToken,
|
||||
accountId: newAccessToken.accountId,
|
||||
expiration,
|
||||
};
|
||||
}
|
||||
catch (error) {
|
||||
if (error.name === "AccessDeniedException") {
|
||||
const errorType = error.error;
|
||||
let message;
|
||||
switch (errorType) {
|
||||
case "TOKEN_EXPIRED":
|
||||
message = "Your session has expired. Please reauthenticate.";
|
||||
break;
|
||||
case "USER_CREDENTIALS_CHANGED":
|
||||
message =
|
||||
"Unable to refresh credentials because of a change in your password. Please reauthenticate with your new password.";
|
||||
break;
|
||||
case "INSUFFICIENT_PERMISSIONS":
|
||||
message =
|
||||
"Unable to refresh credentials due to insufficient permissions. You may be missing permission for the 'CreateOAuth2Token' action.";
|
||||
break;
|
||||
default:
|
||||
message = `Failed to refresh token: ${String(error)}. Please re-authenticate using \`aws login\``;
|
||||
}
|
||||
throw new propertyProvider.CredentialsProviderError(message, { logger: this.logger, tryNextLink: false });
|
||||
}
|
||||
throw new propertyProvider.CredentialsProviderError(`Failed to refresh token: ${String(error)}. Please re-authenticate using aws login`, { logger: this.logger });
|
||||
}
|
||||
}
|
||||
async loadToken() {
|
||||
const tokenFilePath = this.getTokenFilePath();
|
||||
try {
|
||||
let tokenData;
|
||||
try {
|
||||
tokenData = await sharedIniFileLoader.readFile(tokenFilePath, { ignoreCache: this.init?.ignoreCache });
|
||||
}
|
||||
catch {
|
||||
tokenData = await node_fs.promises.readFile(tokenFilePath, "utf8");
|
||||
}
|
||||
const token = JSON.parse(tokenData);
|
||||
const missingFields = ["accessToken", "clientId", "refreshToken", "dpopKey"].filter((k) => !token[k]);
|
||||
if (!token.accessToken?.accountId) {
|
||||
missingFields.push("accountId");
|
||||
}
|
||||
if (missingFields.length > 0) {
|
||||
throw new propertyProvider.CredentialsProviderError(`Token validation failed, missing fields: ${missingFields.join(", ")}`, {
|
||||
logger: this.logger,
|
||||
tryNextLink: false,
|
||||
});
|
||||
}
|
||||
return token;
|
||||
}
|
||||
catch (error) {
|
||||
throw new propertyProvider.CredentialsProviderError(`Failed to load token from ${tokenFilePath}: ${String(error)}`, {
|
||||
logger: this.logger,
|
||||
tryNextLink: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
async saveToken(token) {
|
||||
const tokenFilePath = this.getTokenFilePath();
|
||||
const directory = node_path.dirname(tokenFilePath);
|
||||
try {
|
||||
await node_fs.promises.mkdir(directory, { recursive: true });
|
||||
}
|
||||
catch (error) {
|
||||
}
|
||||
await node_fs.promises.writeFile(tokenFilePath, JSON.stringify(token, null, 2), "utf8");
|
||||
}
|
||||
getTokenFilePath() {
|
||||
const directory = process.env.AWS_LOGIN_CACHE_DIRECTORY ?? node_path.join(node_os.homedir(), ".aws", "login", "cache");
|
||||
const loginSessionBytes = Buffer.from(this.loginSession, "utf8");
|
||||
const loginSessionSha256 = node_crypto.createHash("sha256").update(loginSessionBytes).digest("hex");
|
||||
return node_path.join(directory, `${loginSessionSha256}.json`);
|
||||
}
|
||||
derToRawSignature(derSignature) {
|
||||
let offset = 2;
|
||||
if (derSignature[offset] !== 0x02) {
|
||||
throw new Error("Invalid DER signature");
|
||||
}
|
||||
offset++;
|
||||
const rLength = derSignature[offset++];
|
||||
let r = derSignature.subarray(offset, offset + rLength);
|
||||
offset += rLength;
|
||||
if (derSignature[offset] !== 0x02) {
|
||||
throw new Error("Invalid DER signature");
|
||||
}
|
||||
offset++;
|
||||
const sLength = derSignature[offset++];
|
||||
let s = derSignature.subarray(offset, offset + sLength);
|
||||
r = r[0] === 0x00 ? r.subarray(1) : r;
|
||||
s = s[0] === 0x00 ? s.subarray(1) : s;
|
||||
const rPadded = Buffer.concat([Buffer.alloc(32 - r.length), r]);
|
||||
const sPadded = Buffer.concat([Buffer.alloc(32 - s.length), s]);
|
||||
return Buffer.concat([rPadded, sPadded]);
|
||||
}
|
||||
createDPoPInterceptor(middlewareStack) {
|
||||
middlewareStack.add((next) => async (args) => {
|
||||
if (protocolHttp.HttpRequest.isInstance(args.request)) {
|
||||
const request = args.request;
|
||||
const actualEndpoint = `${request.protocol}//${request.hostname}${request.port ? `:${request.port}` : ""}${request.path}`;
|
||||
const dpop = await this.generateDpop(request.method, actualEndpoint);
|
||||
request.headers = {
|
||||
...request.headers,
|
||||
DPoP: dpop,
|
||||
};
|
||||
}
|
||||
return next(args);
|
||||
}, {
|
||||
step: "finalizeRequest",
|
||||
name: "dpopInterceptor",
|
||||
override: true,
|
||||
});
|
||||
}
|
||||
async generateDpop(method = "POST", endpoint) {
|
||||
const token = await this.loadToken();
|
||||
try {
|
||||
const privateKey = node_crypto.createPrivateKey({
|
||||
key: token.dpopKey,
|
||||
format: "pem",
|
||||
type: "sec1",
|
||||
});
|
||||
const publicKey = node_crypto.createPublicKey(privateKey);
|
||||
const publicDer = publicKey.export({ format: "der", type: "spki" });
|
||||
let pointStart = -1;
|
||||
for (let i = 0; i < publicDer.length; i++) {
|
||||
if (publicDer[i] === 0x04) {
|
||||
pointStart = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
const x = publicDer.slice(pointStart + 1, pointStart + 33);
|
||||
const y = publicDer.slice(pointStart + 33, pointStart + 65);
|
||||
const header = {
|
||||
alg: "ES256",
|
||||
typ: "dpop+jwt",
|
||||
jwk: {
|
||||
kty: "EC",
|
||||
crv: "P-256",
|
||||
x: x.toString("base64url"),
|
||||
y: y.toString("base64url"),
|
||||
},
|
||||
};
|
||||
const payload = {
|
||||
jti: crypto.randomUUID(),
|
||||
htm: method,
|
||||
htu: endpoint,
|
||||
iat: Math.floor(Date.now() / 1000),
|
||||
};
|
||||
const headerB64 = Buffer.from(JSON.stringify(header)).toString("base64url");
|
||||
const payloadB64 = Buffer.from(JSON.stringify(payload)).toString("base64url");
|
||||
const message = `${headerB64}.${payloadB64}`;
|
||||
const asn1Signature = node_crypto.sign("sha256", Buffer.from(message), privateKey);
|
||||
const rawSignature = this.derToRawSignature(asn1Signature);
|
||||
const signatureB64 = rawSignature.toString("base64url");
|
||||
return `${message}.${signatureB64}`;
|
||||
}
|
||||
catch (error) {
|
||||
throw new propertyProvider.CredentialsProviderError(`Failed to generate Dpop proof: ${error instanceof Error ? error.message : String(error)}`, { logger: this.logger, tryNextLink: false });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const fromLoginCredentials = (init) => async ({ callerClientConfig } = {}) => {
|
||||
init?.logger?.debug?.("@aws-sdk/credential-providers - fromLoginCredentials");
|
||||
const profiles = await sharedIniFileLoader.parseKnownFiles(init || {});
|
||||
const profileName = sharedIniFileLoader.getProfileName({
|
||||
profile: init?.profile ?? callerClientConfig?.profile,
|
||||
});
|
||||
const profile = profiles[profileName];
|
||||
if (!profile?.login_session) {
|
||||
throw new propertyProvider.CredentialsProviderError(`Profile ${profileName} does not contain login_session.`, {
|
||||
tryNextLink: true,
|
||||
logger: init?.logger,
|
||||
});
|
||||
}
|
||||
const fetcher = new LoginCredentialsFetcher(profile, init, callerClientConfig);
|
||||
const credentials = await fetcher.loadCredentials();
|
||||
return client.setCredentialFeature(credentials, "CREDENTIALS_LOGIN", "AD");
|
||||
};
|
||||
|
||||
exports.fromLoginCredentials = fromLoginCredentials;
|
||||
|
||||
|
||||
/***/ })
|
||||
|
||||
};
|
||||
;
|
||||
143
dist/cleanup/956.index.js
generated
vendored
143
dist/cleanup/956.index.js
generated
vendored
|
|
@ -1,143 +0,0 @@
|
|||
"use strict";
|
||||
exports.id = 956;
|
||||
exports.ids = [956];
|
||||
exports.modules = {
|
||||
|
||||
/***/ 8079:
|
||||
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
||||
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.fromTokenFile = void 0;
|
||||
const client_1 = __webpack_require__(5152);
|
||||
const property_provider_1 = __webpack_require__(1238);
|
||||
const shared_ini_file_loader_1 = __webpack_require__(4964);
|
||||
const fs_1 = __webpack_require__(9896);
|
||||
const fromWebToken_1 = __webpack_require__(4453);
|
||||
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";
|
||||
const fromTokenFile = (init = {}) => async (awsIdentityProperties) => {
|
||||
init.logger?.debug("@aws-sdk/credential-provider-web-identity - fromTokenFile");
|
||||
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 property_provider_1.CredentialsProviderError("Web identity configuration not specified", {
|
||||
logger: init.logger,
|
||||
});
|
||||
}
|
||||
const credentials = await (0, fromWebToken_1.fromWebToken)({
|
||||
...init,
|
||||
webIdentityToken: shared_ini_file_loader_1.externalDataInterceptor?.getTokenRecord?.()[webIdentityTokenFile] ??
|
||||
(0, fs_1.readFileSync)(webIdentityTokenFile, { encoding: "ascii" }),
|
||||
roleArn,
|
||||
roleSessionName,
|
||||
})(awsIdentityProperties);
|
||||
if (webIdentityTokenFile === process.env[ENV_TOKEN_FILE]) {
|
||||
(0, client_1.setCredentialFeature)(credentials, "CREDENTIALS_ENV_VARS_STS_WEB_ID_TOKEN", "h");
|
||||
}
|
||||
return credentials;
|
||||
};
|
||||
exports.fromTokenFile = fromTokenFile;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 4453:
|
||||
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
||||
|
||||
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.fromWebToken = void 0;
|
||||
const fromWebToken = (init) => async (awsIdentityProperties) => {
|
||||
init.logger?.debug("@aws-sdk/credential-provider-web-identity - fromWebToken");
|
||||
const { roleArn, roleSessionName, webIdentityToken, providerId, policyArns, policy, durationSeconds } = init;
|
||||
let { roleAssumerWithWebIdentity } = init;
|
||||
if (!roleAssumerWithWebIdentity) {
|
||||
const { getDefaultRoleAssumerWithWebIdentity } = await Promise.resolve().then(() => __importStar(__webpack_require__(1136)));
|
||||
roleAssumerWithWebIdentity = getDefaultRoleAssumerWithWebIdentity({
|
||||
...init.clientConfig,
|
||||
credentialProviderLogger: init.logger,
|
||||
parentClientConfig: {
|
||||
...awsIdentityProperties?.callerClientConfig,
|
||||
...init.parentClientConfig,
|
||||
},
|
||||
}, init.clientPlugins);
|
||||
}
|
||||
return roleAssumerWithWebIdentity({
|
||||
RoleArn: roleArn,
|
||||
RoleSessionName: roleSessionName ?? `aws-sdk-js-session-${Date.now()}`,
|
||||
WebIdentityToken: webIdentityToken,
|
||||
ProviderId: providerId,
|
||||
PolicyArns: policyArns,
|
||||
Policy: policy,
|
||||
DurationSeconds: durationSeconds,
|
||||
});
|
||||
};
|
||||
exports.fromWebToken = fromWebToken;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 9956:
|
||||
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
||||
|
||||
|
||||
|
||||
var fromTokenFile = __webpack_require__(8079);
|
||||
var fromWebToken = __webpack_require__(4453);
|
||||
|
||||
|
||||
|
||||
Object.keys(fromTokenFile).forEach(function (k) {
|
||||
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
||||
enumerable: true,
|
||||
get: function () { return fromTokenFile[k]; }
|
||||
});
|
||||
});
|
||||
Object.keys(fromWebToken).forEach(function (k) {
|
||||
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
||||
enumerable: true,
|
||||
get: function () { return fromWebToken[k]; }
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
/***/ })
|
||||
|
||||
};
|
||||
;
|
||||
1799
dist/cleanup/998.index.js
generated
vendored
1799
dist/cleanup/998.index.js
generated
vendored
File diff suppressed because it is too large
Load diff
67317
dist/cleanup/index.js
generated
vendored
67317
dist/cleanup/index.js
generated
vendored
File diff suppressed because one or more lines are too long
150753
dist/index.js
generated
vendored
150753
dist/index.js
generated
vendored
File diff suppressed because one or more lines are too long
3620
package-lock.json
generated
3620
package-lock.json
generated
File diff suppressed because it is too large
Load diff
10
package.json
10
package.json
|
|
@ -6,9 +6,10 @@
|
|||
"build": "tsc",
|
||||
"lint": "biome check --error-on-warnings ./src",
|
||||
"lint:fix": "biome check --write ./src",
|
||||
"package": "npm run build && ncc build --license THIRD-PARTY -o dist && ncc build src/cleanup/index.ts -o dist/cleanup && cpy dist/THIRD-PARTY . && del-cli dist/THIRD-PARTY",
|
||||
"package": "esbuild src/index.ts --bundle --platform=node --target=node24 --outfile=dist/index.js && esbuild src/cleanup/index.ts --bundle --platform=node --target=node24 --outfile=dist/cleanup/index.js && npm run license",
|
||||
"test": "npm run lint && vitest run && npm run build",
|
||||
"clean": "del-cli coverage test-reports node_modules"
|
||||
"clean": "del-cli coverage test-reports node_modules",
|
||||
"license": "generate-license-file --config ./.generatelicensefile.json"
|
||||
},
|
||||
"author": {
|
||||
"name": "Amazon.com, Inc. or its affiliates",
|
||||
|
|
@ -20,11 +21,10 @@
|
|||
"@biomejs/biome": "2.4.6",
|
||||
"@smithy/property-provider": "^4.2.11",
|
||||
"@types/node": "^25.4.0",
|
||||
"@vercel/ncc": "^0.38.4",
|
||||
"@vitest/coverage-v8": "^3.2.4",
|
||||
"aws-sdk-client-mock": "^4.1.0",
|
||||
"cpy-cli": "^7.0.0",
|
||||
"del-cli": "^7.0.0",
|
||||
"esbuild": "^0.27.3",
|
||||
"generate-license-file": "^4.1.1",
|
||||
"json-schema": "^0.4.0",
|
||||
"memfs": "^4.56.11",
|
||||
"standard-version": "^9.5.0",
|
||||
|
|
|
|||
14
release-please-config.json
Normal file
14
release-please-config.json
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"packages": {
|
||||
".": {
|
||||
"changelog-path": "CHANGELOG.md",
|
||||
"release-type": "node",
|
||||
"bump-minor-pre-major": false,
|
||||
"bump-patch-for-minor-pre-major": false,
|
||||
"draft": false,
|
||||
"prerelease": false,
|
||||
"exclude-paths": [".github", "dist"]
|
||||
}
|
||||
},
|
||||
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue