@jjrawlins/cdk-iam-policy-builder-helper 0.0.52 → 0.0.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.jsii +3 -3
- package/cdk-iam-policy-builder-helper/jsii/jsii.go +2 -2
- package/cdk-iam-policy-builder-helper/version +1 -1
- package/node_modules/@aws-sdk/client-iam/dist-cjs/index.js +13439 -13574
- package/node_modules/@aws-sdk/client-iam/package.json +6 -6
- package/node_modules/@aws-sdk/client-sso/dist-cjs/index.js +478 -596
- package/node_modules/@aws-sdk/client-sso/package.json +5 -5
- package/node_modules/@aws-sdk/core/dist-cjs/index.js +1969 -6
- package/node_modules/@aws-sdk/core/dist-cjs/submodules/account-id-endpoint/index.js +48 -88
- package/node_modules/@aws-sdk/core/dist-cjs/submodules/client/index.js +35 -74
- package/node_modules/@aws-sdk/core/dist-cjs/submodules/httpAuthSchemes/index.js +273 -365
- package/node_modules/@aws-sdk/core/dist-cjs/submodules/protocols/index.js +1581 -1863
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/AwsJsonRpcProtocol.js +2 -2
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/AwsRestJsonProtocol.js +2 -2
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/JsonShapeDeserializer.js +4 -4
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/JsonShapeSerializer.js +4 -4
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/query/AwsQueryProtocol.js +3 -3
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/query/QueryShapeSerializer.js +4 -4
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/xml/AwsRestXmlProtocol.js +2 -2
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/xml/XmlShapeSerializer.js +4 -4
- package/node_modules/@aws-sdk/core/dist-types/submodules/account-id-endpoint/AccountIdEndpointModeConfigResolver.d.ts +1 -1
- package/node_modules/@aws-sdk/core/dist-types/submodules/httpAuthSchemes/aws_sdk/AwsSdkSigV4ASigner.d.ts +1 -1
- package/node_modules/@aws-sdk/core/dist-types/submodules/httpAuthSchemes/aws_sdk/AwsSdkSigV4Signer.d.ts +1 -1
- package/node_modules/@aws-sdk/core/dist-types/submodules/httpAuthSchemes/aws_sdk/resolveAwsSdkSigV4AConfig.d.ts +1 -1
- package/node_modules/@aws-sdk/core/dist-types/submodules/httpAuthSchemes/aws_sdk/resolveAwsSdkSigV4Config.d.ts +1 -1
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/ConfigurableSerdeContext.d.ts +1 -1
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/JsonCodec.d.ts +1 -1
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/JsonShapeDeserializer.d.ts +1 -1
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/JsonShapeSerializer.d.ts +2 -2
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/query/QuerySerializerSettings.d.ts +1 -1
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/xml/XmlCodec.d.ts +1 -1
- package/node_modules/@aws-sdk/core/package.json +1 -1
- package/node_modules/@aws-sdk/credential-provider-env/dist-cjs/index.js +38 -73
- package/node_modules/@aws-sdk/credential-provider-env/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-http/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-ini/dist-cjs/index.js +194 -259
- package/node_modules/@aws-sdk/credential-provider-ini/package.json +8 -8
- package/node_modules/@aws-sdk/credential-provider-node/dist-cjs/index.js +72 -132
- package/node_modules/@aws-sdk/credential-provider-node/package.json +7 -7
- package/node_modules/@aws-sdk/credential-provider-process/dist-cjs/index.js +71 -107
- package/node_modules/@aws-sdk/credential-provider-process/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-sso/dist-cjs/index.js +176 -249
- package/node_modules/@aws-sdk/credential-provider-sso/dist-cjs/loadSso-CVy8iqsZ.js +14 -0
- package/node_modules/@aws-sdk/credential-provider-sso/package.json +4 -4
- package/node_modules/@aws-sdk/credential-provider-web-identity/dist-cjs/index.js +16 -25
- package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +3 -3
- package/node_modules/@aws-sdk/middleware-user-agent/dist-cjs/index.js +170 -203
- package/node_modules/@aws-sdk/middleware-user-agent/package.json +2 -2
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/index.js +2 -2
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/index.js +583 -858
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/index.js +795 -928
- package/node_modules/@aws-sdk/nested-clients/package.json +5 -5
- package/node_modules/@aws-sdk/token-providers/dist-cjs/index.js +147 -222
- package/node_modules/@aws-sdk/token-providers/package.json +3 -3
- package/node_modules/@aws-sdk/util-user-agent-browser/README.md +22 -3
- package/node_modules/@aws-sdk/util-user-agent-browser/dist-cjs/createUserAgentStringParsingProvider.js +57 -0
- package/node_modules/@aws-sdk/util-user-agent-browser/dist-cjs/index.js +39 -8
- package/node_modules/@aws-sdk/util-user-agent-browser/dist-es/createUserAgentStringParsingProvider.js +20 -0
- package/node_modules/@aws-sdk/util-user-agent-browser/dist-es/index.js +37 -6
- package/node_modules/@aws-sdk/util-user-agent-browser/dist-types/createUserAgentStringParsingProvider.d.ts +14 -0
- package/node_modules/@aws-sdk/util-user-agent-browser/dist-types/index.d.ts +14 -4
- package/node_modules/@aws-sdk/util-user-agent-browser/dist-types/index.native.d.ts +4 -3
- package/node_modules/@aws-sdk/util-user-agent-browser/dist-types/ts3.4/createUserAgentStringParsingProvider.d.ts +9 -0
- package/node_modules/@aws-sdk/util-user-agent-browser/dist-types/ts3.4/index.d.ts +5 -0
- package/node_modules/@aws-sdk/util-user-agent-browser/package.json +1 -1
- package/node_modules/@aws-sdk/util-user-agent-node/dist-cjs/index.js +50 -94
- package/node_modules/@aws-sdk/util-user-agent-node/dist-types/crt-availability.d.ts +1 -2
- package/node_modules/@aws-sdk/util-user-agent-node/dist-types/defaultUserAgent.d.ts +10 -5
- package/node_modules/@aws-sdk/util-user-agent-node/package.json +2 -2
- package/node_modules/@smithy/core/dist-cjs/submodules/cbor/index.js +1 -1
- package/node_modules/@smithy/core/dist-cjs/submodules/event-streams/index.js +5 -3
- package/node_modules/@smithy/core/dist-cjs/submodules/protocols/index.js +32 -30
- package/node_modules/@smithy/core/dist-cjs/submodules/schema/index.js +133 -202
- package/node_modules/@smithy/core/dist-cjs/submodules/serde/index.js +126 -34
- package/node_modules/@smithy/core/dist-es/submodules/cbor/CborCodec.js +2 -2
- package/node_modules/@smithy/core/dist-es/submodules/event-streams/EventStreamSerde.js +5 -3
- package/node_modules/@smithy/core/dist-es/submodules/protocols/HttpBindingProtocol.js +4 -4
- package/node_modules/@smithy/core/dist-es/submodules/protocols/HttpProtocol.js +3 -3
- package/node_modules/@smithy/core/dist-es/submodules/protocols/RpcProtocol.js +2 -2
- package/node_modules/@smithy/core/dist-es/submodules/protocols/serde/FromStringShapeDeserializer.js +19 -17
- package/node_modules/@smithy/core/dist-es/submodules/protocols/serde/ToStringShapeSerializer.js +4 -4
- package/node_modules/@smithy/core/dist-es/submodules/protocols/serde/determineTimestampFormat.js +5 -6
- package/node_modules/@smithy/core/dist-es/submodules/schema/index.js +1 -0
- package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/NormalizedSchema.js +82 -176
- package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/translateTraits.js +22 -0
- package/node_modules/@smithy/core/dist-es/submodules/serde/index.js +1 -0
- package/node_modules/@smithy/core/dist-es/submodules/serde/schema-serde-lib/schema-date-utils.js +110 -0
- package/node_modules/@smithy/core/dist-es/submodules/serde/value/NumericValue.js +4 -26
- package/node_modules/@smithy/core/dist-types/submodules/schema/index.d.ts +1 -0
- package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/NormalizedSchema.d.ts +5 -24
- package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/sentinels.d.ts +2 -0
- package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/translateTraits.d.ts +7 -0
- package/node_modules/@smithy/core/dist-types/submodules/serde/index.d.ts +1 -0
- package/node_modules/@smithy/core/dist-types/submodules/serde/schema-serde-lib/schema-date-utils.d.ts +47 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/index.d.ts +1 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/NormalizedSchema.d.ts +5 -24
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/sentinels.d.ts +2 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/translateTraits.d.ts +7 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/serde/index.d.ts +1 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/serde/schema-serde-lib/schema-date-utils.d.ts +47 -0
- package/node_modules/@smithy/core/package.json +3 -3
- package/node_modules/@smithy/fetch-http-handler/package.json +2 -2
- package/node_modules/@smithy/middleware-endpoint/package.json +2 -2
- package/node_modules/@smithy/middleware-retry/package.json +2 -2
- package/node_modules/@smithy/smithy-client/package.json +4 -4
- package/node_modules/@smithy/util-base64/dist-cjs/constants.browser.js +9 -32
- package/node_modules/@smithy/util-base64/dist-es/constants.browser.js +9 -28
- package/node_modules/@smithy/util-base64/dist-types/constants.browser.d.ts +5 -6
- package/node_modules/@smithy/util-base64/dist-types/ts3.4/constants.browser.d.ts +5 -6
- package/node_modules/@smithy/util-base64/package.json +1 -1
- package/node_modules/@smithy/util-body-length-node/dist-cjs/index.js +8 -6
- package/node_modules/@smithy/util-body-length-node/dist-es/calculateBodyLength.js +8 -6
- package/node_modules/@smithy/util-body-length-node/package.json +1 -1
- package/node_modules/@smithy/util-defaults-mode-browser/dist-cjs/resolveDefaultsModeConfig.js +11 -9
- package/node_modules/@smithy/util-defaults-mode-browser/dist-es/resolveDefaultsModeConfig.js +11 -8
- package/node_modules/@smithy/util-defaults-mode-browser/package.json +2 -3
- package/node_modules/@smithy/util-defaults-mode-node/package.json +2 -2
- package/node_modules/@smithy/util-stream/dist-cjs/index.js +3 -5
- package/node_modules/@smithy/util-stream/dist-es/blob/Uint8ArrayBlobAdapter.js +3 -5
- package/node_modules/@smithy/util-stream/dist-types/blob/Uint8ArrayBlobAdapter.d.ts +1 -0
- package/node_modules/@smithy/util-stream/dist-types/ts3.4/blob/Uint8ArrayBlobAdapter.d.ts +1 -0
- package/node_modules/@smithy/util-stream/package.json +3 -3
- package/package.json +3 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/nested-clients",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.907.0",
|
|
4
4
|
"description": "Nested clients for AWS SDK packages.",
|
|
5
5
|
"main": "./dist-cjs/index.js",
|
|
6
6
|
"module": "./dist-es/index.js",
|
|
@@ -29,16 +29,16 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@aws-crypto/sha256-browser": "5.2.0",
|
|
31
31
|
"@aws-crypto/sha256-js": "5.2.0",
|
|
32
|
-
"@aws-sdk/core": "3.
|
|
32
|
+
"@aws-sdk/core": "3.907.0",
|
|
33
33
|
"@aws-sdk/middleware-host-header": "3.901.0",
|
|
34
34
|
"@aws-sdk/middleware-logger": "3.901.0",
|
|
35
35
|
"@aws-sdk/middleware-recursion-detection": "3.901.0",
|
|
36
|
-
"@aws-sdk/middleware-user-agent": "3.
|
|
36
|
+
"@aws-sdk/middleware-user-agent": "3.907.0",
|
|
37
37
|
"@aws-sdk/region-config-resolver": "3.901.0",
|
|
38
38
|
"@aws-sdk/types": "3.901.0",
|
|
39
39
|
"@aws-sdk/util-endpoints": "3.901.0",
|
|
40
|
-
"@aws-sdk/util-user-agent-browser": "3.
|
|
41
|
-
"@aws-sdk/util-user-agent-node": "3.
|
|
40
|
+
"@aws-sdk/util-user-agent-browser": "3.907.0",
|
|
41
|
+
"@aws-sdk/util-user-agent-node": "3.907.0",
|
|
42
42
|
"@smithy/config-resolver": "^4.3.0",
|
|
43
43
|
"@smithy/core": "^3.14.0",
|
|
44
44
|
"@smithy/fetch-http-handler": "^5.3.0",
|
|
@@ -1,237 +1,162 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var client = require('@aws-sdk/core/client');
|
|
4
|
+
var httpAuthSchemes = require('@aws-sdk/core/httpAuthSchemes');
|
|
5
|
+
var propertyProvider = require('@smithy/property-provider');
|
|
6
|
+
var sharedIniFileLoader = require('@smithy/shared-ini-file-loader');
|
|
7
|
+
var fs = require('fs');
|
|
8
|
+
|
|
9
|
+
const fromEnvSigningName = ({ logger, signingName } = {}) => async () => {
|
|
10
|
+
logger?.debug?.("@aws-sdk/token-providers - fromEnvSigningName");
|
|
11
|
+
if (!signingName) {
|
|
12
|
+
throw new propertyProvider.TokenProviderError("Please pass 'signingName' to compute environment variable key", { logger });
|
|
13
|
+
}
|
|
14
|
+
const bearerTokenKey = httpAuthSchemes.getBearerTokenEnvKey(signingName);
|
|
15
|
+
if (!(bearerTokenKey in process.env)) {
|
|
16
|
+
throw new propertyProvider.TokenProviderError(`Token not present in '${bearerTokenKey}' environment variable`, { logger });
|
|
17
|
+
}
|
|
18
|
+
const token = { token: process.env[bearerTokenKey] };
|
|
19
|
+
client.setTokenFeature(token, "BEARER_SERVICE_ENV_VARS", "3");
|
|
20
|
+
return token;
|
|
20
21
|
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
-
|
|
31
|
-
// src/index.ts
|
|
32
|
-
var index_exports = {};
|
|
33
|
-
__export(index_exports, {
|
|
34
|
-
fromEnvSigningName: () => fromEnvSigningName,
|
|
35
|
-
fromSso: () => fromSso,
|
|
36
|
-
fromStatic: () => fromStatic,
|
|
37
|
-
nodeProvider: () => nodeProvider
|
|
38
|
-
});
|
|
39
|
-
module.exports = __toCommonJS(index_exports);
|
|
40
|
-
|
|
41
|
-
// src/fromEnvSigningName.ts
|
|
42
|
-
var import_client = require("@aws-sdk/core/client");
|
|
43
|
-
var import_httpAuthSchemes = require("@aws-sdk/core/httpAuthSchemes");
|
|
44
|
-
var import_property_provider = require("@smithy/property-provider");
|
|
45
|
-
var fromEnvSigningName = /* @__PURE__ */ __name(({ logger, signingName } = {}) => async () => {
|
|
46
|
-
logger?.debug?.("@aws-sdk/token-providers - fromEnvSigningName");
|
|
47
|
-
if (!signingName) {
|
|
48
|
-
throw new import_property_provider.TokenProviderError("Please pass 'signingName' to compute environment variable key", { logger });
|
|
49
|
-
}
|
|
50
|
-
const bearerTokenKey = (0, import_httpAuthSchemes.getBearerTokenEnvKey)(signingName);
|
|
51
|
-
if (!(bearerTokenKey in process.env)) {
|
|
52
|
-
throw new import_property_provider.TokenProviderError(`Token not present in '${bearerTokenKey}' environment variable`, { logger });
|
|
53
|
-
}
|
|
54
|
-
const token = { token: process.env[bearerTokenKey] };
|
|
55
|
-
(0, import_client.setTokenFeature)(token, "BEARER_SERVICE_ENV_VARS", "3");
|
|
56
|
-
return token;
|
|
57
|
-
}, "fromEnvSigningName");
|
|
58
|
-
|
|
59
|
-
// src/fromSso.ts
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
// src/constants.ts
|
|
64
|
-
var EXPIRE_WINDOW_MS = 5 * 60 * 1e3;
|
|
65
|
-
var REFRESH_MESSAGE = `To refresh this SSO session run 'aws sso login' with the corresponding profile.`;
|
|
66
22
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const { SSOOIDCClient } = await Promise.resolve().then(() => __toESM(require("@aws-sdk/nested-clients/sso-oidc")));
|
|
70
|
-
const ssoOidcClient = new SSOOIDCClient(
|
|
71
|
-
Object.assign({}, init.clientConfig ?? {}, {
|
|
72
|
-
region: ssoRegion ?? init.clientConfig?.region,
|
|
73
|
-
logger: init.clientConfig?.logger ?? init.parentClientConfig?.logger
|
|
74
|
-
})
|
|
75
|
-
);
|
|
76
|
-
return ssoOidcClient;
|
|
77
|
-
}, "getSsoOidcClient");
|
|
23
|
+
const EXPIRE_WINDOW_MS = 5 * 60 * 1000;
|
|
24
|
+
const REFRESH_MESSAGE = `To refresh this SSO session run 'aws sso login' with the corresponding profile.`;
|
|
78
25
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
refreshToken: ssoToken.refreshToken,
|
|
88
|
-
grantType: "refresh_token"
|
|
89
|
-
})
|
|
90
|
-
);
|
|
91
|
-
}, "getNewSsoOidcToken");
|
|
92
|
-
|
|
93
|
-
// src/validateTokenExpiry.ts
|
|
26
|
+
const getSsoOidcClient = async (ssoRegion, init = {}) => {
|
|
27
|
+
const { SSOOIDCClient } = await import('@aws-sdk/nested-clients/sso-oidc');
|
|
28
|
+
const ssoOidcClient = new SSOOIDCClient(Object.assign({}, init.clientConfig ?? {}, {
|
|
29
|
+
region: ssoRegion ?? init.clientConfig?.region,
|
|
30
|
+
logger: init.clientConfig?.logger ?? init.parentClientConfig?.logger,
|
|
31
|
+
}));
|
|
32
|
+
return ssoOidcClient;
|
|
33
|
+
};
|
|
94
34
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
35
|
+
const getNewSsoOidcToken = async (ssoToken, ssoRegion, init = {}) => {
|
|
36
|
+
const { CreateTokenCommand } = await import('@aws-sdk/nested-clients/sso-oidc');
|
|
37
|
+
const ssoOidcClient = await getSsoOidcClient(ssoRegion, init);
|
|
38
|
+
return ssoOidcClient.send(new CreateTokenCommand({
|
|
39
|
+
clientId: ssoToken.clientId,
|
|
40
|
+
clientSecret: ssoToken.clientSecret,
|
|
41
|
+
refreshToken: ssoToken.refreshToken,
|
|
42
|
+
grantType: "refresh_token",
|
|
43
|
+
}));
|
|
44
|
+
};
|
|
100
45
|
|
|
101
|
-
|
|
46
|
+
const validateTokenExpiry = (token) => {
|
|
47
|
+
if (token.expiration && token.expiration.getTime() < Date.now()) {
|
|
48
|
+
throw new propertyProvider.TokenProviderError(`Token is expired. ${REFRESH_MESSAGE}`, false);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
102
51
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
}, "validateTokenKey");
|
|
52
|
+
const validateTokenKey = (key, value, forRefresh = false) => {
|
|
53
|
+
if (typeof value === "undefined") {
|
|
54
|
+
throw new propertyProvider.TokenProviderError(`Value not present for '${key}' in SSO Token${forRefresh ? ". Cannot refresh" : ""}. ${REFRESH_MESSAGE}`, false);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
111
57
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
const tokenString = JSON.stringify(ssoToken, null, 2);
|
|
119
|
-
return writeFile(tokenFilepath, tokenString);
|
|
120
|
-
}, "writeSSOTokenToFile");
|
|
58
|
+
const { writeFile } = fs.promises;
|
|
59
|
+
const writeSSOTokenToFile = (id, ssoToken) => {
|
|
60
|
+
const tokenFilepath = sharedIniFileLoader.getSSOTokenFilepath(id);
|
|
61
|
+
const tokenString = JSON.stringify(ssoToken, null, 2);
|
|
62
|
+
return writeFile(tokenFilepath, tokenString);
|
|
63
|
+
};
|
|
121
64
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
65
|
+
const lastRefreshAttemptTime = new Date(0);
|
|
66
|
+
const fromSso = (_init = {}) => async ({ callerClientConfig } = {}) => {
|
|
67
|
+
const init = {
|
|
68
|
+
..._init,
|
|
69
|
+
parentClientConfig: {
|
|
70
|
+
...callerClientConfig,
|
|
71
|
+
..._init.parentClientConfig,
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
init.logger?.debug("@aws-sdk/token-providers - fromSso");
|
|
75
|
+
const profiles = await sharedIniFileLoader.parseKnownFiles(init);
|
|
76
|
+
const profileName = sharedIniFileLoader.getProfileName({
|
|
77
|
+
profile: init.profile ?? callerClientConfig?.profile,
|
|
78
|
+
});
|
|
79
|
+
const profile = profiles[profileName];
|
|
80
|
+
if (!profile) {
|
|
81
|
+
throw new propertyProvider.TokenProviderError(`Profile '${profileName}' could not be found in shared credentials file.`, false);
|
|
82
|
+
}
|
|
83
|
+
else if (!profile["sso_session"]) {
|
|
84
|
+
throw new propertyProvider.TokenProviderError(`Profile '${profileName}' is missing required property 'sso_session'.`);
|
|
130
85
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
});
|
|
137
|
-
const profile = profiles[profileName];
|
|
138
|
-
if (!profile) {
|
|
139
|
-
throw new import_property_provider.TokenProviderError(`Profile '${profileName}' could not be found in shared credentials file.`, false);
|
|
140
|
-
} else if (!profile["sso_session"]) {
|
|
141
|
-
throw new import_property_provider.TokenProviderError(`Profile '${profileName}' is missing required property 'sso_session'.`);
|
|
142
|
-
}
|
|
143
|
-
const ssoSessionName = profile["sso_session"];
|
|
144
|
-
const ssoSessions = await (0, import_shared_ini_file_loader.loadSsoSessionData)(init);
|
|
145
|
-
const ssoSession = ssoSessions[ssoSessionName];
|
|
146
|
-
if (!ssoSession) {
|
|
147
|
-
throw new import_property_provider.TokenProviderError(
|
|
148
|
-
`Sso session '${ssoSessionName}' could not be found in shared credentials file.`,
|
|
149
|
-
false
|
|
150
|
-
);
|
|
151
|
-
}
|
|
152
|
-
for (const ssoSessionRequiredKey of ["sso_start_url", "sso_region"]) {
|
|
153
|
-
if (!ssoSession[ssoSessionRequiredKey]) {
|
|
154
|
-
throw new import_property_provider.TokenProviderError(
|
|
155
|
-
`Sso session '${ssoSessionName}' is missing required property '${ssoSessionRequiredKey}'.`,
|
|
156
|
-
false
|
|
157
|
-
);
|
|
86
|
+
const ssoSessionName = profile["sso_session"];
|
|
87
|
+
const ssoSessions = await sharedIniFileLoader.loadSsoSessionData(init);
|
|
88
|
+
const ssoSession = ssoSessions[ssoSessionName];
|
|
89
|
+
if (!ssoSession) {
|
|
90
|
+
throw new propertyProvider.TokenProviderError(`Sso session '${ssoSessionName}' could not be found in shared credentials file.`, false);
|
|
158
91
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
`The SSO session token associated with profile=${profileName} was not found or is invalid. ${REFRESH_MESSAGE}`,
|
|
168
|
-
false
|
|
169
|
-
);
|
|
170
|
-
}
|
|
171
|
-
validateTokenKey("accessToken", ssoToken.accessToken);
|
|
172
|
-
validateTokenKey("expiresAt", ssoToken.expiresAt);
|
|
173
|
-
const { accessToken, expiresAt } = ssoToken;
|
|
174
|
-
const existingToken = { token: accessToken, expiration: new Date(expiresAt) };
|
|
175
|
-
if (existingToken.expiration.getTime() - Date.now() > EXPIRE_WINDOW_MS) {
|
|
176
|
-
return existingToken;
|
|
177
|
-
}
|
|
178
|
-
if (Date.now() - lastRefreshAttemptTime.getTime() < 30 * 1e3) {
|
|
179
|
-
validateTokenExpiry(existingToken);
|
|
180
|
-
return existingToken;
|
|
181
|
-
}
|
|
182
|
-
validateTokenKey("clientId", ssoToken.clientId, true);
|
|
183
|
-
validateTokenKey("clientSecret", ssoToken.clientSecret, true);
|
|
184
|
-
validateTokenKey("refreshToken", ssoToken.refreshToken, true);
|
|
185
|
-
try {
|
|
186
|
-
lastRefreshAttemptTime.setTime(Date.now());
|
|
187
|
-
const newSsoOidcToken = await getNewSsoOidcToken(ssoToken, ssoRegion, init);
|
|
188
|
-
validateTokenKey("accessToken", newSsoOidcToken.accessToken);
|
|
189
|
-
validateTokenKey("expiresIn", newSsoOidcToken.expiresIn);
|
|
190
|
-
const newTokenExpiration = new Date(Date.now() + newSsoOidcToken.expiresIn * 1e3);
|
|
92
|
+
for (const ssoSessionRequiredKey of ["sso_start_url", "sso_region"]) {
|
|
93
|
+
if (!ssoSession[ssoSessionRequiredKey]) {
|
|
94
|
+
throw new propertyProvider.TokenProviderError(`Sso session '${ssoSessionName}' is missing required property '${ssoSessionRequiredKey}'.`, false);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
ssoSession["sso_start_url"];
|
|
98
|
+
const ssoRegion = ssoSession["sso_region"];
|
|
99
|
+
let ssoToken;
|
|
191
100
|
try {
|
|
192
|
-
|
|
193
|
-
...ssoToken,
|
|
194
|
-
accessToken: newSsoOidcToken.accessToken,
|
|
195
|
-
expiresAt: newTokenExpiration.toISOString(),
|
|
196
|
-
refreshToken: newSsoOidcToken.refreshToken
|
|
197
|
-
});
|
|
198
|
-
} catch (error) {
|
|
101
|
+
ssoToken = await sharedIniFileLoader.getSSOTokenFromFile(ssoSessionName);
|
|
199
102
|
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
103
|
+
catch (e) {
|
|
104
|
+
throw new propertyProvider.TokenProviderError(`The SSO session token associated with profile=${profileName} was not found or is invalid. ${REFRESH_MESSAGE}`, false);
|
|
105
|
+
}
|
|
106
|
+
validateTokenKey("accessToken", ssoToken.accessToken);
|
|
107
|
+
validateTokenKey("expiresAt", ssoToken.expiresAt);
|
|
108
|
+
const { accessToken, expiresAt } = ssoToken;
|
|
109
|
+
const existingToken = { token: accessToken, expiration: new Date(expiresAt) };
|
|
110
|
+
if (existingToken.expiration.getTime() - Date.now() > EXPIRE_WINDOW_MS) {
|
|
111
|
+
return existingToken;
|
|
112
|
+
}
|
|
113
|
+
if (Date.now() - lastRefreshAttemptTime.getTime() < 30 * 1000) {
|
|
114
|
+
validateTokenExpiry(existingToken);
|
|
115
|
+
return existingToken;
|
|
116
|
+
}
|
|
117
|
+
validateTokenKey("clientId", ssoToken.clientId, true);
|
|
118
|
+
validateTokenKey("clientSecret", ssoToken.clientSecret, true);
|
|
119
|
+
validateTokenKey("refreshToken", ssoToken.refreshToken, true);
|
|
120
|
+
try {
|
|
121
|
+
lastRefreshAttemptTime.setTime(Date.now());
|
|
122
|
+
const newSsoOidcToken = await getNewSsoOidcToken(ssoToken, ssoRegion, init);
|
|
123
|
+
validateTokenKey("accessToken", newSsoOidcToken.accessToken);
|
|
124
|
+
validateTokenKey("expiresIn", newSsoOidcToken.expiresIn);
|
|
125
|
+
const newTokenExpiration = new Date(Date.now() + newSsoOidcToken.expiresIn * 1000);
|
|
126
|
+
try {
|
|
127
|
+
await writeSSOTokenToFile(ssoSessionName, {
|
|
128
|
+
...ssoToken,
|
|
129
|
+
accessToken: newSsoOidcToken.accessToken,
|
|
130
|
+
expiresAt: newTokenExpiration.toISOString(),
|
|
131
|
+
refreshToken: newSsoOidcToken.refreshToken,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
token: newSsoOidcToken.accessToken,
|
|
138
|
+
expiration: newTokenExpiration,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
validateTokenExpiry(existingToken);
|
|
143
|
+
return existingToken;
|
|
144
|
+
}
|
|
145
|
+
};
|
|
221
146
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
147
|
+
const fromStatic = ({ token, logger }) => async () => {
|
|
148
|
+
logger?.debug("@aws-sdk/token-providers - fromStatic");
|
|
149
|
+
if (!token || !token.token) {
|
|
150
|
+
throw new propertyProvider.TokenProviderError(`Please pass a valid token to fromStatic`, false);
|
|
151
|
+
}
|
|
152
|
+
return token;
|
|
153
|
+
};
|
|
230
154
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
fromStatic,
|
|
235
|
-
nodeProvider
|
|
236
|
-
});
|
|
155
|
+
const nodeProvider = (init = {}) => propertyProvider.memoize(propertyProvider.chain(fromSso(init), async () => {
|
|
156
|
+
throw new propertyProvider.TokenProviderError("Could not load token from any providers", false);
|
|
157
|
+
}), (token) => token.expiration !== undefined && token.expiration.getTime() - Date.now() < 300000, (token) => token.expiration !== undefined);
|
|
237
158
|
|
|
159
|
+
exports.fromEnvSigningName = fromEnvSigningName;
|
|
160
|
+
exports.fromSso = fromSso;
|
|
161
|
+
exports.fromStatic = fromStatic;
|
|
162
|
+
exports.nodeProvider = nodeProvider;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/token-providers",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.907.0",
|
|
4
4
|
"description": "A collection of token providers",
|
|
5
5
|
"main": "./dist-cjs/index.js",
|
|
6
6
|
"module": "./dist-es/index.js",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
},
|
|
30
30
|
"license": "Apache-2.0",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@aws-sdk/core": "3.
|
|
33
|
-
"@aws-sdk/nested-clients": "3.
|
|
32
|
+
"@aws-sdk/core": "3.907.0",
|
|
33
|
+
"@aws-sdk/nested-clients": "3.907.0",
|
|
34
34
|
"@aws-sdk/types": "3.901.0",
|
|
35
35
|
"@smithy/property-provider": "^4.2.0",
|
|
36
36
|
"@smithy/shared-ini-file-loader": "^4.3.0",
|
|
@@ -3,8 +3,27 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/@aws-sdk/util-user-agent-browser)
|
|
4
4
|
[](https://www.npmjs.com/package/@aws-sdk/util-user-agent-browser)
|
|
5
5
|
|
|
6
|
-
> An internal package
|
|
7
|
-
|
|
8
6
|
## Usage
|
|
9
7
|
|
|
10
|
-
|
|
8
|
+
In previous versions of the AWS SDK for JavaScript v3, the AWS SDK user agent header was provided by parsing the navigator user agent string with the `bowser` library.
|
|
9
|
+
|
|
10
|
+
This was later changed to browser feature detection using the native Navigator APIs, but if you would like to have the previous functionality, use the following code:
|
|
11
|
+
|
|
12
|
+
```js
|
|
13
|
+
import { createUserAgentStringParsingProvider } from "@aws-sdk/util-user-agent-browser";
|
|
14
|
+
|
|
15
|
+
import { S3Client } from "@aws-sdk/client-s3";
|
|
16
|
+
import pkgInfo from "@aws-sdk/client-s3/package.json";
|
|
17
|
+
// or any other client.
|
|
18
|
+
|
|
19
|
+
const client = new S3Client({
|
|
20
|
+
defaultUserAgentProvider: createUserAgentStringParsingProvider({
|
|
21
|
+
// For a client's serviceId, check the corresponding shared runtimeConfig file
|
|
22
|
+
// https://github.com/aws/aws-sdk-js-v3/blob/main/clients/client-s3/src/runtimeConfig.shared.ts
|
|
23
|
+
serviceId: "S3",
|
|
24
|
+
clientVersion: pkgInfo.version,
|
|
25
|
+
}),
|
|
26
|
+
});
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
This usage is not recommended, due to the size of the additional parsing library.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.createUserAgentStringParsingProvider = void 0;
|
|
37
|
+
const createUserAgentStringParsingProvider = ({ serviceId, clientVersion }) => async (config) => {
|
|
38
|
+
const module = await Promise.resolve().then(() => __importStar(require("bowser")));
|
|
39
|
+
const parse = module.parse ?? module.default.parse ?? (() => "");
|
|
40
|
+
const parsedUA = typeof window !== "undefined" && window?.navigator?.userAgent ? parse(window.navigator.userAgent) : undefined;
|
|
41
|
+
const sections = [
|
|
42
|
+
["aws-sdk-js", clientVersion],
|
|
43
|
+
["ua", "2.1"],
|
|
44
|
+
[`os/${parsedUA?.os?.name || "other"}`, parsedUA?.os?.version],
|
|
45
|
+
["lang/js"],
|
|
46
|
+
["md/browser", `${parsedUA?.browser?.name ?? "unknown"}_${parsedUA?.browser?.version ?? "unknown"}`],
|
|
47
|
+
];
|
|
48
|
+
if (serviceId) {
|
|
49
|
+
sections.push([`api/${serviceId}`, clientVersion]);
|
|
50
|
+
}
|
|
51
|
+
const appId = await config?.userAgentAppId?.();
|
|
52
|
+
if (appId) {
|
|
53
|
+
sections.push([`app/${appId}`]);
|
|
54
|
+
}
|
|
55
|
+
return sections;
|
|
56
|
+
};
|
|
57
|
+
exports.createUserAgentStringParsingProvider = createUserAgentStringParsingProvider;
|
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.defaultUserAgent = exports.createDefaultUserAgentProvider = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
exports.defaultUserAgent = exports.fallback = exports.createDefaultUserAgentProvider = exports.createUserAgentStringParsingProvider = void 0;
|
|
4
|
+
var createUserAgentStringParsingProvider_1 = require("./createUserAgentStringParsingProvider");
|
|
5
|
+
Object.defineProperty(exports, "createUserAgentStringParsingProvider", { enumerable: true, get: function () { return createUserAgentStringParsingProvider_1.createUserAgentStringParsingProvider; } });
|
|
6
6
|
const createDefaultUserAgentProvider = ({ serviceId, clientVersion }) => async (config) => {
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
const navigator = typeof window !== "undefined" ? window.navigator : undefined;
|
|
8
|
+
const uaString = navigator?.userAgent ?? "";
|
|
9
|
+
const osName = navigator?.userAgentData?.platform ?? exports.fallback.os(uaString) ?? "other";
|
|
10
|
+
const osVersion = undefined;
|
|
11
|
+
const brands = navigator?.userAgentData?.brands ?? [];
|
|
12
|
+
const brand = brands[brands.length - 1];
|
|
13
|
+
const browserName = brand?.brand ?? exports.fallback.browser(uaString) ?? "unknown";
|
|
14
|
+
const browserVersion = brand?.version ?? "unknown";
|
|
10
15
|
const sections = [
|
|
11
16
|
["aws-sdk-js", clientVersion],
|
|
12
17
|
["ua", "2.1"],
|
|
13
|
-
[`os/${
|
|
18
|
+
[`os/${osName}`, osVersion],
|
|
14
19
|
["lang/js"],
|
|
15
|
-
["md/browser", `${
|
|
20
|
+
["md/browser", `${browserName}_${browserVersion}`],
|
|
16
21
|
];
|
|
17
22
|
if (serviceId) {
|
|
18
23
|
sections.push([`api/${serviceId}`, clientVersion]);
|
|
@@ -24,4 +29,30 @@ const createDefaultUserAgentProvider = ({ serviceId, clientVersion }) => async (
|
|
|
24
29
|
return sections;
|
|
25
30
|
};
|
|
26
31
|
exports.createDefaultUserAgentProvider = createDefaultUserAgentProvider;
|
|
32
|
+
exports.fallback = {
|
|
33
|
+
os(ua) {
|
|
34
|
+
if (/iPhone|iPad|iPod/.test(ua))
|
|
35
|
+
return "iOS";
|
|
36
|
+
if (/Macintosh|Mac OS X/.test(ua))
|
|
37
|
+
return "macOS";
|
|
38
|
+
if (/Windows NT/.test(ua))
|
|
39
|
+
return "Windows";
|
|
40
|
+
if (/Android/.test(ua))
|
|
41
|
+
return "Android";
|
|
42
|
+
if (/Linux/.test(ua))
|
|
43
|
+
return "Linux";
|
|
44
|
+
return undefined;
|
|
45
|
+
},
|
|
46
|
+
browser(ua) {
|
|
47
|
+
if (/EdgiOS|EdgA|Edg\//.test(ua))
|
|
48
|
+
return "Microsoft Edge";
|
|
49
|
+
if (/Firefox\//.test(ua))
|
|
50
|
+
return "Firefox";
|
|
51
|
+
if (/Chrome\//.test(ua))
|
|
52
|
+
return "Chrome";
|
|
53
|
+
if (/Safari\//.test(ua))
|
|
54
|
+
return "Safari";
|
|
55
|
+
return undefined;
|
|
56
|
+
},
|
|
57
|
+
};
|
|
27
58
|
exports.defaultUserAgent = exports.createDefaultUserAgentProvider;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const createUserAgentStringParsingProvider = ({ serviceId, clientVersion }) => async (config) => {
|
|
2
|
+
const module = await import("bowser");
|
|
3
|
+
const parse = module.parse ?? module.default.parse ?? (() => "");
|
|
4
|
+
const parsedUA = typeof window !== "undefined" && window?.navigator?.userAgent ? parse(window.navigator.userAgent) : undefined;
|
|
5
|
+
const sections = [
|
|
6
|
+
["aws-sdk-js", clientVersion],
|
|
7
|
+
["ua", "2.1"],
|
|
8
|
+
[`os/${parsedUA?.os?.name || "other"}`, parsedUA?.os?.version],
|
|
9
|
+
["lang/js"],
|
|
10
|
+
["md/browser", `${parsedUA?.browser?.name ?? "unknown"}_${parsedUA?.browser?.version ?? "unknown"}`],
|
|
11
|
+
];
|
|
12
|
+
if (serviceId) {
|
|
13
|
+
sections.push([`api/${serviceId}`, clientVersion]);
|
|
14
|
+
}
|
|
15
|
+
const appId = await config?.userAgentAppId?.();
|
|
16
|
+
if (appId) {
|
|
17
|
+
sections.push([`app/${appId}`]);
|
|
18
|
+
}
|
|
19
|
+
return sections;
|
|
20
|
+
};
|