@shawnstack/quickforge 1.3.20 → 1.3.21
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/README.md +348 -348
- package/dist/assets/{anthropic-Bj3HAZgj.js → anthropic--qj3xmqE.js} +1 -1
- package/dist/assets/{azure-openai-responses-IdZZrSrI.js → azure-openai-responses-DDRaS-MZ.js} +1 -1
- package/dist/assets/{google-Brt_lS1J.js → google-C-8-FIZS.js} +1 -1
- package/dist/assets/{google-vertex-B6HsoZ34.js → google-vertex-Dw2y_nqS.js} +1 -1
- package/dist/assets/{index-D0W9hAl_.css → index-B-WkttzD.css} +1 -1
- package/dist/assets/{index-D0CVLdX_.js → index-DRGbHzkd.js} +4 -4
- package/dist/assets/{mistral-CenXqwPz.js → mistral-u_5S4wj6.js} +1 -1
- package/dist/assets/{openai-codex-responses-D9ffGwbj.js → openai-codex-responses-CWZGpchs.js} +1 -1
- package/dist/assets/{openai-completions-eWdeSGBG.js → openai-completions-C_DdwPuH.js} +1 -1
- package/dist/assets/{openai-responses-Cavpmjeu.js → openai-responses-CMp0ziUV.js} +1 -1
- package/dist/assets/{openai-responses-shared-DF3ZGaUx.js → openai-responses-shared-CORWeerT.js} +1 -1
- package/dist/index.html +2 -2
- package/node_modules/@aws-sdk/client-bedrock-runtime/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/LICENSE +201 -0
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/README.md +62 -0
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-cjs/index.js +156 -0
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/constants.js +2 -0
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/fromEnvSigningName.js +16 -0
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/fromSso.js +80 -0
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/fromStatic.js +8 -0
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/getNewSsoOidcToken.js +11 -0
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/getSsoOidcClient.js +10 -0
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/index.js +4 -0
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/nodeProvider.js +5 -0
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/validateTokenExpiry.js +7 -0
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/validateTokenKey.js +7 -0
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/writeSSOTokenToFile.js +8 -0
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/package.json +69 -0
- package/node_modules/@aws-sdk/token-providers/package.json +1 -1
- package/node_modules/@smithy/core/dist-cjs/index.js +3 -4
- package/node_modules/@smithy/core/dist-cjs/submodules/client/index.js +3 -11
- package/node_modules/@smithy/core/dist-cjs/submodules/config/index.browser.js +2 -2
- package/node_modules/@smithy/core/dist-cjs/submodules/config/index.js +2 -2
- package/node_modules/@smithy/core/dist-cjs/submodules/config/index.native.js +2 -2
- package/node_modules/@smithy/core/dist-cjs/submodules/endpoints/index.browser.js +9 -40
- package/node_modules/@smithy/core/dist-cjs/submodules/endpoints/index.js +9 -40
- package/node_modules/@smithy/core/dist-cjs/submodules/protocols/index.js +12 -142
- package/node_modules/@smithy/core/dist-cjs/submodules/schema/index.js +7 -9
- package/node_modules/@smithy/core/dist-cjs/submodules/serde/index.browser.js +2 -2
- package/node_modules/@smithy/core/dist-cjs/submodules/serde/index.js +2 -2
- package/node_modules/@smithy/core/dist-cjs/submodules/serde/index.native.js +2 -2
- package/node_modules/@smithy/core/dist-cjs/submodules/transport/index.js +184 -0
- package/node_modules/@smithy/core/dist-es/index.js +6 -6
- package/node_modules/@smithy/core/dist-es/submodules/client/index.js +2 -2
- package/node_modules/@smithy/core/dist-es/submodules/config/config-resolver/regionConfig/checkRegion.js +1 -1
- package/node_modules/@smithy/core/dist-es/submodules/endpoints/index.browser.js +2 -2
- package/node_modules/@smithy/core/dist-es/submodules/endpoints/index.js +2 -2
- package/node_modules/@smithy/core/dist-es/submodules/endpoints/middleware-endpoint/adaptors/toEndpointV1.js +1 -1
- package/node_modules/@smithy/core/dist-es/submodules/endpoints/middleware-endpoint/resolveEndpointConfig.js +1 -1
- package/node_modules/@smithy/core/dist-es/submodules/endpoints/util-endpoints/lib/index.js +1 -1
- package/node_modules/@smithy/core/dist-es/submodules/protocols/HttpBindingProtocol.js +1 -1
- package/node_modules/@smithy/core/dist-es/submodules/protocols/HttpProtocol.js +1 -2
- package/node_modules/@smithy/core/dist-es/submodules/protocols/RpcProtocol.js +1 -1
- package/node_modules/@smithy/core/dist-es/submodules/protocols/index.js +5 -5
- package/node_modules/@smithy/core/dist-es/submodules/protocols/middleware-content-length/contentLengthMiddleware.js +1 -1
- package/node_modules/@smithy/core/dist-es/submodules/protocols/requestBuilder.js +1 -1
- package/node_modules/@smithy/core/dist-es/submodules/schema/middleware/schemaDeserializationMiddleware.js +3 -4
- package/node_modules/@smithy/core/dist-es/submodules/schema/middleware/schemaSerializationMiddleware.js +1 -2
- package/node_modules/@smithy/core/dist-es/submodules/serde/middleware-serde/deserializerMiddleware.js +1 -1
- package/node_modules/@smithy/core/dist-es/submodules/transport/index.js +9 -0
- package/node_modules/@smithy/core/dist-es/submodules/{protocols/url-parser → transport}/parseUrl.js +1 -1
- package/node_modules/@smithy/core/dist-es/submodules/{endpoints → transport}/toEndpointV1.js +1 -1
- package/node_modules/@smithy/core/package.json +19 -10
- package/node_modules/@smithy/core/transport.js +5 -0
- package/node_modules/@smithy/credential-provider-imds/package.json +2 -2
- package/node_modules/@smithy/fetch-http-handler/package.json +2 -2
- package/node_modules/@smithy/node-http-handler/package.json +2 -2
- package/node_modules/@smithy/signature-v4/package.json +2 -2
- package/node_modules/eventsource-parser/README.md +31 -0
- package/node_modules/eventsource-parser/dist/index.cjs +21 -10
- package/node_modules/eventsource-parser/dist/index.js +21 -10
- package/node_modules/eventsource-parser/dist/stream.cjs +4 -3
- package/node_modules/eventsource-parser/dist/stream.js +4 -3
- package/node_modules/eventsource-parser/package.json +8 -8
- package/package.json +1 -1
- package/node_modules/@smithy/core/dist-cjs/getSmithyContext.js +0 -6
- package/node_modules/@smithy/core/dist-cjs/middleware-http-auth-scheme/getHttpAuthSchemeEndpointRuleSetPlugin.js +0 -21
- package/node_modules/@smithy/core/dist-cjs/middleware-http-auth-scheme/getHttpAuthSchemePlugin.js +0 -21
- package/node_modules/@smithy/core/dist-cjs/middleware-http-auth-scheme/httpAuthSchemeMiddleware.js +0 -46
- package/node_modules/@smithy/core/dist-cjs/middleware-http-auth-scheme/index.js +0 -6
- package/node_modules/@smithy/core/dist-cjs/middleware-http-auth-scheme/resolveAuthOptions.js +0 -24
- package/node_modules/@smithy/core/dist-cjs/middleware-http-signing/getHttpSigningMiddleware.js +0 -19
- package/node_modules/@smithy/core/dist-cjs/middleware-http-signing/httpSigningMiddleware.js +0 -27
- package/node_modules/@smithy/core/dist-cjs/middleware-http-signing/index.js +0 -5
- package/node_modules/@smithy/core/dist-cjs/normalizeProvider.js +0 -10
- package/node_modules/@smithy/core/dist-cjs/pagination/createPaginator.js +0 -44
- package/node_modules/@smithy/core/dist-cjs/request-builder/requestBuilder.js +0 -5
- package/node_modules/@smithy/core/dist-cjs/setFeature.js +0 -14
- package/node_modules/@smithy/core/dist-cjs/util-identity-and-auth/DefaultIdentityProviderConfig.js +0 -18
- package/node_modules/@smithy/core/dist-cjs/util-identity-and-auth/httpAuthSchemes/httpApiKeyAuth.js +0 -38
- package/node_modules/@smithy/core/dist-cjs/util-identity-and-auth/httpAuthSchemes/httpBearerAuth.js +0 -15
- package/node_modules/@smithy/core/dist-cjs/util-identity-and-auth/httpAuthSchemes/index.js +0 -6
- package/node_modules/@smithy/core/dist-cjs/util-identity-and-auth/httpAuthSchemes/noAuth.js +0 -9
- package/node_modules/@smithy/core/dist-cjs/util-identity-and-auth/index.js +0 -6
- package/node_modules/@smithy/core/dist-cjs/util-identity-and-auth/memoizeIdentityProvider.js +0 -61
- package/node_modules/@smithy/core/dist-es/request-builder/requestBuilder.js +0 -1
- package/node_modules/@smithy/core/dist-es/submodules/client/util-middleware/getSmithyContext.js +0 -2
- package/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/TestVectors.fixture.js +0 -146
- package/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/vectorTypes.fixture.js +0 -1
- package/node_modules/@smithy/credential-provider-imds/dist-es/remoteProvider/index.js +0 -2
- package/node_modules/@smithy/node-http-handler/dist-es/readable.mock.js +0 -21
- package/node_modules/@smithy/node-http-handler/dist-es/server.mock.js +0 -88
- package/node_modules/@smithy/node-http-handler/dist-es/stream-collector/readable.mock.js +0 -21
- package/node_modules/@smithy/signature-v4/dist-es/suite.fixture.js +0 -399
- /package/node_modules/@smithy/core/dist-es/{middleware-http-auth-scheme → legacy-root-exports/middleware-http-auth-scheme}/getHttpAuthSchemeEndpointRuleSetPlugin.js +0 -0
- /package/node_modules/@smithy/core/dist-es/{middleware-http-auth-scheme → legacy-root-exports/middleware-http-auth-scheme}/getHttpAuthSchemePlugin.js +0 -0
- /package/node_modules/@smithy/core/dist-es/{middleware-http-auth-scheme → legacy-root-exports/middleware-http-auth-scheme}/httpAuthSchemeMiddleware.js +0 -0
- /package/node_modules/@smithy/core/dist-es/{middleware-http-auth-scheme → legacy-root-exports/middleware-http-auth-scheme}/index.js +0 -0
- /package/node_modules/@smithy/core/dist-es/{middleware-http-auth-scheme → legacy-root-exports/middleware-http-auth-scheme}/resolveAuthOptions.js +0 -0
- /package/node_modules/@smithy/core/dist-es/{middleware-http-signing → legacy-root-exports/middleware-http-signing}/getHttpSigningMiddleware.js +0 -0
- /package/node_modules/@smithy/core/dist-es/{middleware-http-signing → legacy-root-exports/middleware-http-signing}/httpSigningMiddleware.js +0 -0
- /package/node_modules/@smithy/core/dist-es/{middleware-http-signing → legacy-root-exports/middleware-http-signing}/index.js +0 -0
- /package/node_modules/@smithy/core/dist-es/{pagination → legacy-root-exports/pagination}/createPaginator.js +0 -0
- /package/node_modules/@smithy/core/dist-es/{util-identity-and-auth → legacy-root-exports/util-identity-and-auth}/DefaultIdentityProviderConfig.js +0 -0
- /package/node_modules/@smithy/core/dist-es/{util-identity-and-auth → legacy-root-exports/util-identity-and-auth}/httpAuthSchemes/httpApiKeyAuth.js +0 -0
- /package/node_modules/@smithy/core/dist-es/{util-identity-and-auth → legacy-root-exports/util-identity-and-auth}/httpAuthSchemes/httpBearerAuth.js +0 -0
- /package/node_modules/@smithy/core/dist-es/{util-identity-and-auth → legacy-root-exports/util-identity-and-auth}/httpAuthSchemes/index.js +0 -0
- /package/node_modules/@smithy/core/dist-es/{util-identity-and-auth → legacy-root-exports/util-identity-and-auth}/httpAuthSchemes/noAuth.js +0 -0
- /package/node_modules/@smithy/core/dist-es/{util-identity-and-auth → legacy-root-exports/util-identity-and-auth}/index.js +0 -0
- /package/node_modules/@smithy/core/dist-es/{util-identity-and-auth → legacy-root-exports/util-identity-and-auth}/memoizeIdentityProvider.js +0 -0
- /package/node_modules/@smithy/core/dist-es/{getSmithyContext.js → submodules/transport/getSmithyContext.js} +0 -0
- /package/node_modules/@smithy/core/dist-es/submodules/{protocols/protocol-http → transport}/httpRequest.js +0 -0
- /package/node_modules/@smithy/core/dist-es/submodules/{protocols/protocol-http → transport}/httpResponse.js +0 -0
- /package/node_modules/@smithy/core/dist-es/submodules/{endpoints/util-endpoints/lib → transport}/isValidHostLabel.js +0 -0
- /package/node_modules/@smithy/core/dist-es/submodules/{protocols/protocol-http → transport}/isValidHostname.js +0 -0
- /package/node_modules/@smithy/core/dist-es/submodules/{client/util-middleware → transport}/normalizeProvider.js +0 -0
- /package/node_modules/@smithy/core/dist-es/submodules/{protocols/querystring-parser → transport}/parseQueryString.js +0 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var client = require('@aws-sdk/core/client');
|
|
4
|
+
var httpAuthSchemes = require('@aws-sdk/core/httpAuthSchemes');
|
|
5
|
+
var config = require('@smithy/core/config');
|
|
6
|
+
var node_fs = require('node:fs');
|
|
7
|
+
|
|
8
|
+
const fromEnvSigningName = ({ logger, signingName } = {}) => async () => {
|
|
9
|
+
logger?.debug?.("@aws-sdk/token-providers - fromEnvSigningName");
|
|
10
|
+
if (!signingName) {
|
|
11
|
+
throw new config.TokenProviderError("Please pass 'signingName' to compute environment variable key", { logger });
|
|
12
|
+
}
|
|
13
|
+
const bearerTokenKey = httpAuthSchemes.getBearerTokenEnvKey(signingName);
|
|
14
|
+
if (!(bearerTokenKey in process.env)) {
|
|
15
|
+
throw new config.TokenProviderError(`Token not present in '${bearerTokenKey}' environment variable`, { logger });
|
|
16
|
+
}
|
|
17
|
+
const token = { token: process.env[bearerTokenKey] };
|
|
18
|
+
client.setTokenFeature(token, "BEARER_SERVICE_ENV_VARS", "3");
|
|
19
|
+
return token;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const EXPIRE_WINDOW_MS = 5 * 60 * 1000;
|
|
23
|
+
const REFRESH_MESSAGE = `To refresh this SSO session run 'aws sso login' with the corresponding profile.`;
|
|
24
|
+
|
|
25
|
+
const getSsoOidcClient = async (ssoRegion, init = {}, callerClientConfig) => {
|
|
26
|
+
const { SSOOIDCClient } = await import('@aws-sdk/nested-clients/sso-oidc');
|
|
27
|
+
const coalesce = (prop) => init.clientConfig?.[prop] ?? init.parentClientConfig?.[prop] ?? callerClientConfig?.[prop];
|
|
28
|
+
const ssoOidcClient = new SSOOIDCClient(Object.assign({}, init.clientConfig ?? {}, {
|
|
29
|
+
region: ssoRegion ?? init.clientConfig?.region,
|
|
30
|
+
logger: coalesce("logger"),
|
|
31
|
+
userAgentAppId: coalesce("userAgentAppId"),
|
|
32
|
+
}));
|
|
33
|
+
return ssoOidcClient;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const getNewSsoOidcToken = async (ssoToken, ssoRegion, init = {}, callerClientConfig) => {
|
|
37
|
+
const { CreateTokenCommand } = await import('@aws-sdk/nested-clients/sso-oidc');
|
|
38
|
+
const ssoOidcClient = await getSsoOidcClient(ssoRegion, init, callerClientConfig);
|
|
39
|
+
return ssoOidcClient.send(new CreateTokenCommand({
|
|
40
|
+
clientId: ssoToken.clientId,
|
|
41
|
+
clientSecret: ssoToken.clientSecret,
|
|
42
|
+
refreshToken: ssoToken.refreshToken,
|
|
43
|
+
grantType: "refresh_token",
|
|
44
|
+
}));
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const validateTokenExpiry = (token) => {
|
|
48
|
+
if (token.expiration && token.expiration.getTime() < Date.now()) {
|
|
49
|
+
throw new config.TokenProviderError(`Token is expired. ${REFRESH_MESSAGE}`, false);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const validateTokenKey = (key, value, forRefresh = false) => {
|
|
54
|
+
if (typeof value === "undefined") {
|
|
55
|
+
throw new config.TokenProviderError(`Value not present for '${key}' in SSO Token${forRefresh ? ". Cannot refresh" : ""}. ${REFRESH_MESSAGE}`, false);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const { writeFile } = node_fs.promises;
|
|
60
|
+
const writeSSOTokenToFile = (id, ssoToken) => {
|
|
61
|
+
const tokenFilepath = config.getSSOTokenFilepath(id);
|
|
62
|
+
const tokenString = JSON.stringify(ssoToken, null, 2);
|
|
63
|
+
return writeFile(tokenFilepath, tokenString);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const lastRefreshAttemptTime = new Date(0);
|
|
67
|
+
const fromSso = (init = {}) => async ({ callerClientConfig } = {}) => {
|
|
68
|
+
init.logger?.debug("@aws-sdk/token-providers - fromSso");
|
|
69
|
+
const profiles = await config.parseKnownFiles(init);
|
|
70
|
+
const profileName = config.getProfileName({
|
|
71
|
+
profile: init.profile ?? callerClientConfig?.profile,
|
|
72
|
+
});
|
|
73
|
+
const profile = profiles[profileName];
|
|
74
|
+
if (!profile) {
|
|
75
|
+
throw new config.TokenProviderError(`Profile '${profileName}' could not be found in shared credentials file.`, false);
|
|
76
|
+
}
|
|
77
|
+
else if (!profile["sso_session"]) {
|
|
78
|
+
throw new config.TokenProviderError(`Profile '${profileName}' is missing required property 'sso_session'.`);
|
|
79
|
+
}
|
|
80
|
+
const ssoSessionName = profile["sso_session"];
|
|
81
|
+
const ssoSessions = await config.loadSsoSessionData(init);
|
|
82
|
+
const ssoSession = ssoSessions[ssoSessionName];
|
|
83
|
+
if (!ssoSession) {
|
|
84
|
+
throw new config.TokenProviderError(`Sso session '${ssoSessionName}' could not be found in shared credentials file.`, false);
|
|
85
|
+
}
|
|
86
|
+
for (const ssoSessionRequiredKey of ["sso_start_url", "sso_region"]) {
|
|
87
|
+
if (!ssoSession[ssoSessionRequiredKey]) {
|
|
88
|
+
throw new config.TokenProviderError(`Sso session '${ssoSessionName}' is missing required property '${ssoSessionRequiredKey}'.`, false);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
ssoSession["sso_start_url"];
|
|
92
|
+
const ssoRegion = ssoSession["sso_region"];
|
|
93
|
+
let ssoToken;
|
|
94
|
+
try {
|
|
95
|
+
ssoToken = await config.getSSOTokenFromFile(ssoSessionName);
|
|
96
|
+
}
|
|
97
|
+
catch (e) {
|
|
98
|
+
throw new config.TokenProviderError(`The SSO session token associated with profile=${profileName} was not found or is invalid. ${REFRESH_MESSAGE}`, false);
|
|
99
|
+
}
|
|
100
|
+
validateTokenKey("accessToken", ssoToken.accessToken);
|
|
101
|
+
validateTokenKey("expiresAt", ssoToken.expiresAt);
|
|
102
|
+
const { accessToken, expiresAt } = ssoToken;
|
|
103
|
+
const existingToken = { token: accessToken, expiration: new Date(expiresAt) };
|
|
104
|
+
if (existingToken.expiration.getTime() - Date.now() > EXPIRE_WINDOW_MS) {
|
|
105
|
+
return existingToken;
|
|
106
|
+
}
|
|
107
|
+
if (Date.now() - lastRefreshAttemptTime.getTime() < 30 * 1000) {
|
|
108
|
+
validateTokenExpiry(existingToken);
|
|
109
|
+
return existingToken;
|
|
110
|
+
}
|
|
111
|
+
validateTokenKey("clientId", ssoToken.clientId, true);
|
|
112
|
+
validateTokenKey("clientSecret", ssoToken.clientSecret, true);
|
|
113
|
+
validateTokenKey("refreshToken", ssoToken.refreshToken, true);
|
|
114
|
+
try {
|
|
115
|
+
lastRefreshAttemptTime.setTime(Date.now());
|
|
116
|
+
const newSsoOidcToken = await getNewSsoOidcToken(ssoToken, ssoRegion, init, callerClientConfig);
|
|
117
|
+
validateTokenKey("accessToken", newSsoOidcToken.accessToken);
|
|
118
|
+
validateTokenKey("expiresIn", newSsoOidcToken.expiresIn);
|
|
119
|
+
const newTokenExpiration = new Date(Date.now() + newSsoOidcToken.expiresIn * 1000);
|
|
120
|
+
try {
|
|
121
|
+
await writeSSOTokenToFile(ssoSessionName, {
|
|
122
|
+
...ssoToken,
|
|
123
|
+
accessToken: newSsoOidcToken.accessToken,
|
|
124
|
+
expiresAt: newTokenExpiration.toISOString(),
|
|
125
|
+
refreshToken: newSsoOidcToken.refreshToken,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
token: newSsoOidcToken.accessToken,
|
|
132
|
+
expiration: newTokenExpiration,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
validateTokenExpiry(existingToken);
|
|
137
|
+
return existingToken;
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
const fromStatic = ({ token, logger }) => async () => {
|
|
142
|
+
logger?.debug("@aws-sdk/token-providers - fromStatic");
|
|
143
|
+
if (!token || !token.token) {
|
|
144
|
+
throw new config.TokenProviderError(`Please pass a valid token to fromStatic`, false);
|
|
145
|
+
}
|
|
146
|
+
return token;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
const nodeProvider = (init = {}) => config.memoize(config.chain(fromSso(init), async () => {
|
|
150
|
+
throw new config.TokenProviderError("Could not load token from any providers", false);
|
|
151
|
+
}), (token) => token.expiration !== undefined && token.expiration.getTime() - Date.now() < 300000, (token) => token.expiration !== undefined);
|
|
152
|
+
|
|
153
|
+
exports.fromEnvSigningName = fromEnvSigningName;
|
|
154
|
+
exports.fromSso = fromSso;
|
|
155
|
+
exports.fromStatic = fromStatic;
|
|
156
|
+
exports.nodeProvider = nodeProvider;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { setTokenFeature } from "@aws-sdk/core/client";
|
|
2
|
+
import { getBearerTokenEnvKey } from "@aws-sdk/core/httpAuthSchemes";
|
|
3
|
+
import { TokenProviderError } from "@smithy/core/config";
|
|
4
|
+
export const fromEnvSigningName = ({ logger, signingName } = {}) => async () => {
|
|
5
|
+
logger?.debug?.("@aws-sdk/token-providers - fromEnvSigningName");
|
|
6
|
+
if (!signingName) {
|
|
7
|
+
throw new TokenProviderError("Please pass 'signingName' to compute environment variable key", { logger });
|
|
8
|
+
}
|
|
9
|
+
const bearerTokenKey = getBearerTokenEnvKey(signingName);
|
|
10
|
+
if (!(bearerTokenKey in process.env)) {
|
|
11
|
+
throw new TokenProviderError(`Token not present in '${bearerTokenKey}' environment variable`, { logger });
|
|
12
|
+
}
|
|
13
|
+
const token = { token: process.env[bearerTokenKey] };
|
|
14
|
+
setTokenFeature(token, "BEARER_SERVICE_ENV_VARS", "3");
|
|
15
|
+
return token;
|
|
16
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { getProfileName, getSSOTokenFromFile, loadSsoSessionData, parseKnownFiles, TokenProviderError, } from "@smithy/core/config";
|
|
2
|
+
import { EXPIRE_WINDOW_MS, REFRESH_MESSAGE } from "./constants";
|
|
3
|
+
import { getNewSsoOidcToken } from "./getNewSsoOidcToken";
|
|
4
|
+
import { validateTokenExpiry } from "./validateTokenExpiry";
|
|
5
|
+
import { validateTokenKey } from "./validateTokenKey";
|
|
6
|
+
import { writeSSOTokenToFile } from "./writeSSOTokenToFile";
|
|
7
|
+
const lastRefreshAttemptTime = new Date(0);
|
|
8
|
+
export const fromSso = (init = {}) => async ({ callerClientConfig } = {}) => {
|
|
9
|
+
init.logger?.debug("@aws-sdk/token-providers - fromSso");
|
|
10
|
+
const profiles = await parseKnownFiles(init);
|
|
11
|
+
const profileName = getProfileName({
|
|
12
|
+
profile: init.profile ?? callerClientConfig?.profile,
|
|
13
|
+
});
|
|
14
|
+
const profile = profiles[profileName];
|
|
15
|
+
if (!profile) {
|
|
16
|
+
throw new TokenProviderError(`Profile '${profileName}' could not be found in shared credentials file.`, false);
|
|
17
|
+
}
|
|
18
|
+
else if (!profile["sso_session"]) {
|
|
19
|
+
throw new TokenProviderError(`Profile '${profileName}' is missing required property 'sso_session'.`);
|
|
20
|
+
}
|
|
21
|
+
const ssoSessionName = profile["sso_session"];
|
|
22
|
+
const ssoSessions = await loadSsoSessionData(init);
|
|
23
|
+
const ssoSession = ssoSessions[ssoSessionName];
|
|
24
|
+
if (!ssoSession) {
|
|
25
|
+
throw new TokenProviderError(`Sso session '${ssoSessionName}' could not be found in shared credentials file.`, false);
|
|
26
|
+
}
|
|
27
|
+
for (const ssoSessionRequiredKey of ["sso_start_url", "sso_region"]) {
|
|
28
|
+
if (!ssoSession[ssoSessionRequiredKey]) {
|
|
29
|
+
throw new TokenProviderError(`Sso session '${ssoSessionName}' is missing required property '${ssoSessionRequiredKey}'.`, false);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const ssoStartUrl = ssoSession["sso_start_url"];
|
|
33
|
+
const ssoRegion = ssoSession["sso_region"];
|
|
34
|
+
let ssoToken;
|
|
35
|
+
try {
|
|
36
|
+
ssoToken = await getSSOTokenFromFile(ssoSessionName);
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
throw new TokenProviderError(`The SSO session token associated with profile=${profileName} was not found or is invalid. ${REFRESH_MESSAGE}`, false);
|
|
40
|
+
}
|
|
41
|
+
validateTokenKey("accessToken", ssoToken.accessToken);
|
|
42
|
+
validateTokenKey("expiresAt", ssoToken.expiresAt);
|
|
43
|
+
const { accessToken, expiresAt } = ssoToken;
|
|
44
|
+
const existingToken = { token: accessToken, expiration: new Date(expiresAt) };
|
|
45
|
+
if (existingToken.expiration.getTime() - Date.now() > EXPIRE_WINDOW_MS) {
|
|
46
|
+
return existingToken;
|
|
47
|
+
}
|
|
48
|
+
if (Date.now() - lastRefreshAttemptTime.getTime() < 30 * 1000) {
|
|
49
|
+
validateTokenExpiry(existingToken);
|
|
50
|
+
return existingToken;
|
|
51
|
+
}
|
|
52
|
+
validateTokenKey("clientId", ssoToken.clientId, true);
|
|
53
|
+
validateTokenKey("clientSecret", ssoToken.clientSecret, true);
|
|
54
|
+
validateTokenKey("refreshToken", ssoToken.refreshToken, true);
|
|
55
|
+
try {
|
|
56
|
+
lastRefreshAttemptTime.setTime(Date.now());
|
|
57
|
+
const newSsoOidcToken = await getNewSsoOidcToken(ssoToken, ssoRegion, init, callerClientConfig);
|
|
58
|
+
validateTokenKey("accessToken", newSsoOidcToken.accessToken);
|
|
59
|
+
validateTokenKey("expiresIn", newSsoOidcToken.expiresIn);
|
|
60
|
+
const newTokenExpiration = new Date(Date.now() + newSsoOidcToken.expiresIn * 1000);
|
|
61
|
+
try {
|
|
62
|
+
await writeSSOTokenToFile(ssoSessionName, {
|
|
63
|
+
...ssoToken,
|
|
64
|
+
accessToken: newSsoOidcToken.accessToken,
|
|
65
|
+
expiresAt: newTokenExpiration.toISOString(),
|
|
66
|
+
refreshToken: newSsoOidcToken.refreshToken,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
token: newSsoOidcToken.accessToken,
|
|
73
|
+
expiration: newTokenExpiration,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
validateTokenExpiry(existingToken);
|
|
78
|
+
return existingToken;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TokenProviderError } from "@smithy/core/config";
|
|
2
|
+
export const fromStatic = ({ token, logger }) => async () => {
|
|
3
|
+
logger?.debug("@aws-sdk/token-providers - fromStatic");
|
|
4
|
+
if (!token || !token.token) {
|
|
5
|
+
throw new TokenProviderError(`Please pass a valid token to fromStatic`, false);
|
|
6
|
+
}
|
|
7
|
+
return token;
|
|
8
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { getSsoOidcClient } from "./getSsoOidcClient";
|
|
2
|
+
export const getNewSsoOidcToken = async (ssoToken, ssoRegion, init = {}, callerClientConfig) => {
|
|
3
|
+
const { CreateTokenCommand } = await import("@aws-sdk/nested-clients/sso-oidc");
|
|
4
|
+
const ssoOidcClient = await getSsoOidcClient(ssoRegion, init, callerClientConfig);
|
|
5
|
+
return ssoOidcClient.send(new CreateTokenCommand({
|
|
6
|
+
clientId: ssoToken.clientId,
|
|
7
|
+
clientSecret: ssoToken.clientSecret,
|
|
8
|
+
refreshToken: ssoToken.refreshToken,
|
|
9
|
+
grantType: "refresh_token",
|
|
10
|
+
}));
|
|
11
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const getSsoOidcClient = async (ssoRegion, init = {}, callerClientConfig) => {
|
|
2
|
+
const { SSOOIDCClient } = await import("@aws-sdk/nested-clients/sso-oidc");
|
|
3
|
+
const coalesce = (prop) => init.clientConfig?.[prop] ?? init.parentClientConfig?.[prop] ?? callerClientConfig?.[prop];
|
|
4
|
+
const ssoOidcClient = new SSOOIDCClient(Object.assign({}, init.clientConfig ?? {}, {
|
|
5
|
+
region: ssoRegion ?? init.clientConfig?.region,
|
|
6
|
+
logger: coalesce("logger"),
|
|
7
|
+
userAgentAppId: coalesce("userAgentAppId"),
|
|
8
|
+
}));
|
|
9
|
+
return ssoOidcClient;
|
|
10
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { chain, memoize, TokenProviderError } from "@smithy/core/config";
|
|
2
|
+
import { fromSso } from "./fromSso";
|
|
3
|
+
export const nodeProvider = (init = {}) => memoize(chain(fromSso(init), async () => {
|
|
4
|
+
throw new TokenProviderError("Could not load token from any providers", false);
|
|
5
|
+
}), (token) => token.expiration !== undefined && token.expiration.getTime() - Date.now() < 300000, (token) => token.expiration !== undefined);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TokenProviderError } from "@smithy/core/config";
|
|
2
|
+
import { REFRESH_MESSAGE } from "./constants";
|
|
3
|
+
export const validateTokenExpiry = (token) => {
|
|
4
|
+
if (token.expiration && token.expiration.getTime() < Date.now()) {
|
|
5
|
+
throw new TokenProviderError(`Token is expired. ${REFRESH_MESSAGE}`, false);
|
|
6
|
+
}
|
|
7
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TokenProviderError } from "@smithy/core/config";
|
|
2
|
+
import { REFRESH_MESSAGE } from "./constants";
|
|
3
|
+
export const validateTokenKey = (key, value, forRefresh = false) => {
|
|
4
|
+
if (typeof value === "undefined") {
|
|
5
|
+
throw new TokenProviderError(`Value not present for '${key}' in SSO Token${forRefresh ? ". Cannot refresh" : ""}. ${REFRESH_MESSAGE}`, false);
|
|
6
|
+
}
|
|
7
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { getSSOTokenFilepath } from "@smithy/core/config";
|
|
2
|
+
import { promises as fsPromises } from "node:fs";
|
|
3
|
+
const { writeFile } = fsPromises;
|
|
4
|
+
export const writeSSOTokenToFile = (id, ssoToken) => {
|
|
5
|
+
const tokenFilepath = getSSOTokenFilepath(id);
|
|
6
|
+
const tokenString = JSON.stringify(ssoToken, null, 2);
|
|
7
|
+
return writeFile(tokenFilepath, tokenString);
|
|
8
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aws-sdk/token-providers",
|
|
3
|
+
"version": "3.1054.0",
|
|
4
|
+
"description": "A collection of token providers",
|
|
5
|
+
"main": "./dist-cjs/index.js",
|
|
6
|
+
"module": "./dist-es/index.js",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "concurrently 'yarn:build:types' 'yarn:build:es' && yarn build:cjs",
|
|
9
|
+
"build:cjs": "node ../../scripts/compilation/inline token-providers",
|
|
10
|
+
"build:es": "tsc -p tsconfig.es.json",
|
|
11
|
+
"build:include:deps": "yarn g:turbo run build -F=\"$npm_package_name\"",
|
|
12
|
+
"build:types": "tsc -p tsconfig.types.json",
|
|
13
|
+
"build:types:downlevel": "downlevel-dts dist-types dist-types/ts3.4",
|
|
14
|
+
"clean": "premove dist-cjs dist-es dist-types tsconfig.cjs.tsbuildinfo tsconfig.es.tsbuildinfo tsconfig.types.tsbuildinfo",
|
|
15
|
+
"extract:docs": "api-extractor run --local",
|
|
16
|
+
"test": "yarn g:vitest run",
|
|
17
|
+
"test:watch": "yarn g:vitest watch",
|
|
18
|
+
"test:integration": "yarn g:vitest run -c vitest.config.integ.mts",
|
|
19
|
+
"test:integration:watch": "yarn g:vitest watch -c vitest.config.integ.mts"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"aws",
|
|
23
|
+
"token"
|
|
24
|
+
],
|
|
25
|
+
"sideEffects": false,
|
|
26
|
+
"author": {
|
|
27
|
+
"name": "AWS SDK for JavaScript Team",
|
|
28
|
+
"url": "https://aws.amazon.com/javascript/"
|
|
29
|
+
},
|
|
30
|
+
"license": "Apache-2.0",
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@aws-sdk/core": "^3.974.14",
|
|
33
|
+
"@aws-sdk/nested-clients": "^3.997.12",
|
|
34
|
+
"@aws-sdk/types": "^3.973.9",
|
|
35
|
+
"@smithy/core": "^3.24.3",
|
|
36
|
+
"@smithy/types": "^4.14.2",
|
|
37
|
+
"tslib": "^2.6.2"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@tsconfig/recommended": "1.0.1",
|
|
41
|
+
"@types/node": "^20.14.8",
|
|
42
|
+
"concurrently": "7.0.0",
|
|
43
|
+
"downlevel-dts": "0.10.1",
|
|
44
|
+
"premove": "4.0.0",
|
|
45
|
+
"typescript": "~5.8.3"
|
|
46
|
+
},
|
|
47
|
+
"types": "./dist-types/index.d.ts",
|
|
48
|
+
"engines": {
|
|
49
|
+
"node": ">=20.0.0"
|
|
50
|
+
},
|
|
51
|
+
"typesVersions": {
|
|
52
|
+
"<4.5": {
|
|
53
|
+
"dist-types/*": [
|
|
54
|
+
"dist-types/ts3.4/*"
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"files": [
|
|
59
|
+
"dist-*/**"
|
|
60
|
+
],
|
|
61
|
+
"browser": {},
|
|
62
|
+
"react-native": {},
|
|
63
|
+
"homepage": "https://github.com/aws/aws-sdk-js-v3/tree/main/packages/token-providers",
|
|
64
|
+
"repository": {
|
|
65
|
+
"type": "git",
|
|
66
|
+
"url": "https://github.com/aws/aws-sdk-js-v3.git",
|
|
67
|
+
"directory": "packages/token-providers"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var transport = require('@smithy/core/transport');
|
|
4
4
|
var protocols = require('@smithy/core/protocols');
|
|
5
|
+
var types = require('@smithy/types');
|
|
5
6
|
var client = require('@smithy/core/client');
|
|
6
7
|
|
|
7
|
-
const getSmithyContext = (context) => context[types.SMITHY_CONTEXT_KEY] || (context[types.SMITHY_CONTEXT_KEY] = {});
|
|
8
|
-
|
|
9
8
|
const resolveAuthOptions = (candidateAuthOptions, authSchemePreference) => {
|
|
10
9
|
if (!authSchemePreference || authSchemePreference.length === 0) {
|
|
11
10
|
return candidateAuthOptions;
|
|
@@ -321,6 +320,7 @@ const memoizeIdentityProvider = (provider, isExpired, requiresRefresh) => {
|
|
|
321
320
|
};
|
|
322
321
|
};
|
|
323
322
|
|
|
323
|
+
exports.getSmithyContext = transport.getSmithyContext;
|
|
324
324
|
exports.requestBuilder = protocols.requestBuilder;
|
|
325
325
|
exports.DefaultIdentityProviderConfig = DefaultIdentityProviderConfig;
|
|
326
326
|
exports.EXPIRATION_MS = EXPIRATION_MS;
|
|
@@ -333,7 +333,6 @@ exports.doesIdentityRequireRefresh = doesIdentityRequireRefresh;
|
|
|
333
333
|
exports.getHttpAuthSchemeEndpointRuleSetPlugin = getHttpAuthSchemeEndpointRuleSetPlugin;
|
|
334
334
|
exports.getHttpAuthSchemePlugin = getHttpAuthSchemePlugin;
|
|
335
335
|
exports.getHttpSigningPlugin = getHttpSigningPlugin;
|
|
336
|
-
exports.getSmithyContext = getSmithyContext;
|
|
337
336
|
exports.httpAuthSchemeEndpointRuleSetMiddlewareOptions = httpAuthSchemeEndpointRuleSetMiddlewareOptions;
|
|
338
337
|
exports.httpAuthSchemeMiddleware = httpAuthSchemeMiddleware;
|
|
339
338
|
exports.httpAuthSchemeMiddlewareOptions = httpAuthSchemeMiddlewareOptions;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var transport = require('@smithy/core/transport');
|
|
3
4
|
var types = require('@smithy/types');
|
|
4
5
|
var schema = require('@smithy/core/schema');
|
|
5
6
|
|
|
@@ -285,15 +286,6 @@ const priorityWeights = {
|
|
|
285
286
|
low: 1,
|
|
286
287
|
};
|
|
287
288
|
|
|
288
|
-
const getSmithyContext = (context) => context[types.SMITHY_CONTEXT_KEY] || (context[types.SMITHY_CONTEXT_KEY] = {});
|
|
289
|
-
|
|
290
|
-
const normalizeProvider = (input) => {
|
|
291
|
-
if (typeof input === "function")
|
|
292
|
-
return input;
|
|
293
|
-
const promisified = Promise.resolve(input);
|
|
294
|
-
return () => promisified;
|
|
295
|
-
};
|
|
296
|
-
|
|
297
289
|
const invalidFunction = (message) => () => {
|
|
298
290
|
throw new Error(message);
|
|
299
291
|
};
|
|
@@ -1097,6 +1089,8 @@ const _json = (obj) => {
|
|
|
1097
1089
|
return obj;
|
|
1098
1090
|
};
|
|
1099
1091
|
|
|
1092
|
+
exports.getSmithyContext = transport.getSmithyContext;
|
|
1093
|
+
exports.normalizeProvider = transport.normalizeProvider;
|
|
1100
1094
|
exports.AlgorithmId = types.AlgorithmId;
|
|
1101
1095
|
exports.Client = Client;
|
|
1102
1096
|
exports.Command = Command;
|
|
@@ -1116,14 +1110,12 @@ exports.getChecksumConfiguration = getChecksumConfiguration;
|
|
|
1116
1110
|
exports.getDefaultClientConfiguration = getDefaultClientConfiguration;
|
|
1117
1111
|
exports.getDefaultExtensionConfiguration = getDefaultExtensionConfiguration;
|
|
1118
1112
|
exports.getRetryConfiguration = getRetryConfiguration;
|
|
1119
|
-
exports.getSmithyContext = getSmithyContext;
|
|
1120
1113
|
exports.getValueFromTextNode = getValueFromTextNode;
|
|
1121
1114
|
exports.invalidFunction = invalidFunction;
|
|
1122
1115
|
exports.invalidProvider = invalidProvider;
|
|
1123
1116
|
exports.isSerializableHeaderValue = isSerializableHeaderValue;
|
|
1124
1117
|
exports.loadConfigsForDefaultMode = loadConfigsForDefaultMode;
|
|
1125
1118
|
exports.map = map;
|
|
1126
|
-
exports.normalizeProvider = normalizeProvider;
|
|
1127
1119
|
exports.resolveChecksumRuntimeConfig = resolveChecksumRuntimeConfig;
|
|
1128
1120
|
exports.resolveDefaultRuntimeConfig = resolveDefaultRuntimeConfig;
|
|
1129
1121
|
exports.resolveRetryRuntimeConfig = resolveRetryRuntimeConfig;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var client = require('@smithy/core/client');
|
|
4
|
-
var
|
|
4
|
+
var transport = require('@smithy/core/transport');
|
|
5
5
|
|
|
6
6
|
class ProviderError extends Error {
|
|
7
7
|
name = "ProviderError";
|
|
@@ -178,7 +178,7 @@ const resolveEndpointsConfig = (input) => {
|
|
|
178
178
|
};
|
|
179
179
|
|
|
180
180
|
const validRegions = new Set();
|
|
181
|
-
const checkRegion = (region, check =
|
|
181
|
+
const checkRegion = (region, check = transport.isValidHostLabel) => {
|
|
182
182
|
if (!validRegions.has(region) && !check(region)) {
|
|
183
183
|
if (region === "*") {
|
|
184
184
|
console.warn(`@smithy/config-resolver WARN - Please use the caller region instead of "*". See "sigv4a" in https://github.com/aws/aws-sdk-js-v3/blob/main/supplemental-docs/CLIENTS.md.`);
|
|
@@ -6,7 +6,7 @@ var node_crypto = require('node:crypto');
|
|
|
6
6
|
var promises = require('node:fs/promises');
|
|
7
7
|
var types = require('@smithy/types');
|
|
8
8
|
var client = require('@smithy/core/client');
|
|
9
|
-
var
|
|
9
|
+
var transport = require('@smithy/core/transport');
|
|
10
10
|
|
|
11
11
|
class ProviderError extends Error {
|
|
12
12
|
name = "ProviderError";
|
|
@@ -486,7 +486,7 @@ const NODE_REGION_CONFIG_FILE_OPTIONS = {
|
|
|
486
486
|
};
|
|
487
487
|
|
|
488
488
|
const validRegions = new Set();
|
|
489
|
-
const checkRegion = (region, check =
|
|
489
|
+
const checkRegion = (region, check = transport.isValidHostLabel) => {
|
|
490
490
|
if (!validRegions.has(region) && !check(region)) {
|
|
491
491
|
if (region === "*") {
|
|
492
492
|
console.warn(`@smithy/config-resolver WARN - Please use the caller region instead of "*". See "sigv4a" in https://github.com/aws/aws-sdk-js-v3/blob/main/supplemental-docs/CLIENTS.md.`);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var client = require('@smithy/core/client');
|
|
4
|
-
var
|
|
4
|
+
var transport = require('@smithy/core/transport');
|
|
5
5
|
|
|
6
6
|
class ProviderError extends Error {
|
|
7
7
|
name = "ProviderError";
|
|
@@ -178,7 +178,7 @@ const resolveEndpointsConfig = (input) => {
|
|
|
178
178
|
};
|
|
179
179
|
|
|
180
180
|
const validRegions = new Set();
|
|
181
|
-
const checkRegion = (region, check =
|
|
181
|
+
const checkRegion = (region, check = transport.isValidHostLabel) => {
|
|
182
182
|
if (!validRegions.has(region) && !check(region)) {
|
|
183
183
|
if (region === "*") {
|
|
184
184
|
console.warn(`@smithy/config-resolver WARN - Please use the caller region instead of "*". See "sigv4a" in https://github.com/aws/aws-sdk-js-v3/blob/main/supplemental-docs/CLIENTS.md.`);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var transport = require('@smithy/core/transport');
|
|
4
4
|
var client = require('@smithy/core/client');
|
|
5
5
|
var types = require('@smithy/types');
|
|
6
6
|
|
|
@@ -93,23 +93,6 @@ const createConfigValueProvider = (configKey, canonicalEndpointParamKey, config,
|
|
|
93
93
|
return configProvider;
|
|
94
94
|
};
|
|
95
95
|
|
|
96
|
-
const toEndpointV1 = (endpoint) => {
|
|
97
|
-
if (typeof endpoint === "object") {
|
|
98
|
-
if ("url" in endpoint) {
|
|
99
|
-
const v1Endpoint = protocols.parseUrl(endpoint.url);
|
|
100
|
-
if (endpoint.headers) {
|
|
101
|
-
v1Endpoint.headers = {};
|
|
102
|
-
for (const name in endpoint.headers) {
|
|
103
|
-
v1Endpoint.headers[name.toLowerCase()] = endpoint.headers[name].join(", ");
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
return v1Endpoint;
|
|
107
|
-
}
|
|
108
|
-
return endpoint;
|
|
109
|
-
}
|
|
110
|
-
return protocols.parseUrl(endpoint);
|
|
111
|
-
};
|
|
112
|
-
|
|
113
96
|
function bindGetEndpointFromInstructions(getEndpointFromConfig) {
|
|
114
97
|
return async (commandInput, instructionsSupplier, clientConfig, context) => {
|
|
115
98
|
if (!clientConfig.isCustomEndpoint) {
|
|
@@ -121,7 +104,7 @@ function bindGetEndpointFromInstructions(getEndpointFromConfig) {
|
|
|
121
104
|
endpointFromConfig = await getEndpointFromConfig(clientConfig.serviceId);
|
|
122
105
|
}
|
|
123
106
|
if (endpointFromConfig) {
|
|
124
|
-
clientConfig.endpoint = () => Promise.resolve(toEndpointV1(endpointFromConfig));
|
|
107
|
+
clientConfig.endpoint = () => Promise.resolve(transport.toEndpointV1(endpointFromConfig));
|
|
125
108
|
clientConfig.isCustomEndpoint = true;
|
|
126
109
|
}
|
|
127
110
|
}
|
|
@@ -245,14 +228,14 @@ function bindResolveEndpointConfig(getEndpointFromConfig) {
|
|
|
245
228
|
return (input) => {
|
|
246
229
|
const tls = input.tls ?? true;
|
|
247
230
|
const { endpoint, useDualstackEndpoint, useFipsEndpoint } = input;
|
|
248
|
-
const customEndpointProvider = endpoint != null ? async () => toEndpointV1(await
|
|
231
|
+
const customEndpointProvider = endpoint != null ? async () => transport.toEndpointV1(await transport.normalizeProvider(endpoint)()) : undefined;
|
|
249
232
|
const isCustomEndpoint = !!endpoint;
|
|
250
233
|
const resolvedConfig = Object.assign(input, {
|
|
251
234
|
endpoint: customEndpointProvider,
|
|
252
235
|
tls,
|
|
253
236
|
isCustomEndpoint,
|
|
254
|
-
useDualstackEndpoint:
|
|
255
|
-
useFipsEndpoint:
|
|
237
|
+
useDualstackEndpoint: transport.normalizeProvider(useDualstackEndpoint ?? false),
|
|
238
|
+
useFipsEndpoint: transport.normalizeProvider(useFipsEndpoint ?? false),
|
|
256
239
|
});
|
|
257
240
|
let configuredEndpointPromise = undefined;
|
|
258
241
|
resolvedConfig.serviceConfiguredEndpoint = async () => {
|
|
@@ -405,20 +388,6 @@ const getAttr = (value, path) => getAttrPathList(path).reduce((acc, index) => {
|
|
|
405
388
|
|
|
406
389
|
const isSet = (value) => value != null;
|
|
407
390
|
|
|
408
|
-
const VALID_HOST_LABEL_REGEX = new RegExp(`^(?!.*-$)(?!-)[a-zA-Z0-9-]{1,63}$`);
|
|
409
|
-
const isValidHostLabel = (value, allowSubDomains = false) => {
|
|
410
|
-
if (!allowSubDomains) {
|
|
411
|
-
return VALID_HOST_LABEL_REGEX.test(value);
|
|
412
|
-
}
|
|
413
|
-
const labels = value.split(".");
|
|
414
|
-
for (const label of labels) {
|
|
415
|
-
if (!isValidHostLabel(label)) {
|
|
416
|
-
return false;
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
return true;
|
|
420
|
-
};
|
|
421
|
-
|
|
422
391
|
function ite(condition, trueValue, falseValue) {
|
|
423
392
|
return condition ? trueValue : falseValue;
|
|
424
393
|
}
|
|
@@ -511,7 +480,7 @@ const endpointFunctions = {
|
|
|
511
480
|
coalesce,
|
|
512
481
|
getAttr,
|
|
513
482
|
isSet,
|
|
514
|
-
isValidHostLabel,
|
|
483
|
+
isValidHostLabel: transport.isValidHostLabel,
|
|
515
484
|
ite,
|
|
516
485
|
not,
|
|
517
486
|
parseURL,
|
|
@@ -841,6 +810,9 @@ const resolveEndpointConfig = bindResolveEndpointConfig(getEndpointFromConfig);
|
|
|
841
810
|
const endpointMiddleware = bindEndpointMiddleware(getEndpointFromConfig);
|
|
842
811
|
const getEndpointPlugin = bindGetEndpointPlugin(getEndpointFromConfig);
|
|
843
812
|
|
|
813
|
+
exports.isValidHostLabel = transport.isValidHostLabel;
|
|
814
|
+
exports.middlewareEndpointToEndpointV1 = transport.toEndpointV1;
|
|
815
|
+
exports.toEndpointV1 = transport.toEndpointV1;
|
|
844
816
|
exports.BinaryDecisionDiagram = BinaryDecisionDiagram;
|
|
845
817
|
exports.EndpointCache = EndpointCache;
|
|
846
818
|
exports.EndpointError = EndpointError;
|
|
@@ -851,10 +823,7 @@ exports.endpointMiddlewareOptions = endpointMiddlewareOptions;
|
|
|
851
823
|
exports.getEndpointFromInstructions = getEndpointFromInstructions;
|
|
852
824
|
exports.getEndpointPlugin = getEndpointPlugin;
|
|
853
825
|
exports.isIpAddress = isIpAddress;
|
|
854
|
-
exports.isValidHostLabel = isValidHostLabel;
|
|
855
|
-
exports.middlewareEndpointToEndpointV1 = toEndpointV1;
|
|
856
826
|
exports.resolveEndpoint = resolveEndpoint;
|
|
857
827
|
exports.resolveEndpointConfig = resolveEndpointConfig;
|
|
858
828
|
exports.resolveEndpointRequiredConfig = resolveEndpointRequiredConfig;
|
|
859
829
|
exports.resolveParams = resolveParams;
|
|
860
|
-
exports.toEndpointV1 = toEndpointV1;
|