@smithy/experimental-identity-and-auth 0.6.7 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-cjs/index.js +23 -24
- package/package.json +7 -7
package/dist-cjs/index.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var serde = require('@smithy/core/serde');
|
|
8
|
-
var retry = require('@smithy/core/retry');
|
|
1
|
+
const { HttpRequest } = require("@smithy/core/protocols");
|
|
2
|
+
const { SignatureV4 } = require("@smithy/signature-v4");
|
|
3
|
+
const { getSmithyContext } = require("@smithy/core/client");
|
|
4
|
+
const { resolveParams, endpointMiddlewareOptions } = require("@smithy/core/endpoints");
|
|
5
|
+
const { serializerMiddlewareOption } = require("@smithy/core/serde");
|
|
6
|
+
const { retryMiddlewareOptions } = require("@smithy/core/retry");
|
|
9
7
|
|
|
10
8
|
class DefaultIdentityProviderConfig {
|
|
11
9
|
authSchemes = new Map();
|
|
@@ -23,8 +21,8 @@ class DefaultIdentityProviderConfig {
|
|
|
23
21
|
|
|
24
22
|
class SigV4Signer {
|
|
25
23
|
async sign(httpRequest, identity, signingProperties) {
|
|
26
|
-
const clonedRequest =
|
|
27
|
-
const signer = new
|
|
24
|
+
const clonedRequest = HttpRequest.clone(httpRequest);
|
|
25
|
+
const signer = new SignatureV4({
|
|
28
26
|
applyChecksum: signingProperties.applyChecksum !== undefined ? signingProperties.applyChecksum : true,
|
|
29
27
|
credentials: identity,
|
|
30
28
|
region: signingProperties.region,
|
|
@@ -83,20 +81,20 @@ const createEndpointRuleSetHttpAuthSchemeParametersProvider = (defaultHttpAuthSc
|
|
|
83
81
|
throw new Error(`Could not find \`input\` for \`defaultEndpointRuleSetHttpAuthSchemeParametersProvider\``);
|
|
84
82
|
}
|
|
85
83
|
const defaultParameters = await defaultHttpAuthSchemeParametersProvider(config, context, input);
|
|
86
|
-
const instructionsFn =
|
|
84
|
+
const instructionsFn = getSmithyContext(context)?.endpointRuleSet
|
|
87
85
|
?.getEndpointParameterInstructions;
|
|
88
86
|
if (!instructionsFn) {
|
|
89
87
|
throw new Error(`getEndpointParameterInstructions() is not defined on \`${context.commandName}\``);
|
|
90
88
|
}
|
|
91
|
-
const endpointParameters = await
|
|
89
|
+
const endpointParameters = await resolveParams(input, { getEndpointParameterInstructions: instructionsFn }, config);
|
|
92
90
|
return Object.assign(defaultParameters, endpointParameters);
|
|
93
91
|
};
|
|
94
92
|
|
|
95
|
-
|
|
93
|
+
var HttpApiKeyAuthLocation;
|
|
96
94
|
(function (HttpApiKeyAuthLocation) {
|
|
97
95
|
HttpApiKeyAuthLocation["HEADER"] = "header";
|
|
98
96
|
HttpApiKeyAuthLocation["QUERY"] = "query";
|
|
99
|
-
})(
|
|
97
|
+
})(HttpApiKeyAuthLocation || (HttpApiKeyAuthLocation = {}));
|
|
100
98
|
class HttpApiKeyAuthSigner {
|
|
101
99
|
async sign(httpRequest, identity, signingProperties) {
|
|
102
100
|
if (!signingProperties) {
|
|
@@ -111,11 +109,11 @@ class HttpApiKeyAuthSigner {
|
|
|
111
109
|
if (!identity.apiKey) {
|
|
112
110
|
throw new Error("request could not be signed with `apiKey` since the `apiKey` is not defined");
|
|
113
111
|
}
|
|
114
|
-
const clonedRequest =
|
|
115
|
-
if (signingProperties.in ===
|
|
112
|
+
const clonedRequest = HttpRequest.clone(httpRequest);
|
|
113
|
+
if (signingProperties.in === HttpApiKeyAuthLocation.QUERY) {
|
|
116
114
|
clonedRequest.query[signingProperties.name] = identity.apiKey;
|
|
117
115
|
}
|
|
118
|
-
else if (signingProperties.in ===
|
|
116
|
+
else if (signingProperties.in === HttpApiKeyAuthLocation.HEADER) {
|
|
119
117
|
clonedRequest.headers[signingProperties.name] = signingProperties.scheme
|
|
120
118
|
? `${signingProperties.scheme} ${identity.apiKey}`
|
|
121
119
|
: identity.apiKey;
|
|
@@ -132,7 +130,7 @@ class HttpApiKeyAuthSigner {
|
|
|
132
130
|
|
|
133
131
|
class HttpBearerAuthSigner {
|
|
134
132
|
async sign(httpRequest, identity, signingProperties) {
|
|
135
|
-
const clonedRequest =
|
|
133
|
+
const clonedRequest = HttpRequest.clone(httpRequest);
|
|
136
134
|
if (!identity.token) {
|
|
137
135
|
throw new Error("request could not be signed with `token` since the `token` is not defined");
|
|
138
136
|
}
|
|
@@ -207,7 +205,7 @@ function convertHttpAuthSchemesToMap(httpAuthSchemes) {
|
|
|
207
205
|
const httpAuthSchemeMiddleware = (config, mwOptions) => (next, context) => async (args) => {
|
|
208
206
|
const options = config.httpAuthSchemeProvider(await mwOptions.httpAuthSchemeParametersProvider(config, context, args.input));
|
|
209
207
|
const authSchemes = convertHttpAuthSchemesToMap(config.httpAuthSchemes);
|
|
210
|
-
const smithyContext =
|
|
208
|
+
const smithyContext = getSmithyContext(context);
|
|
211
209
|
const failureReasons = [];
|
|
212
210
|
for (const option of options) {
|
|
213
211
|
const scheme = authSchemes.get(option.schemeId);
|
|
@@ -242,7 +240,7 @@ const httpAuthSchemeEndpointRuleSetMiddlewareOptions = {
|
|
|
242
240
|
name: "httpAuthSchemeMiddleware",
|
|
243
241
|
override: true,
|
|
244
242
|
relation: "before",
|
|
245
|
-
toMiddleware:
|
|
243
|
+
toMiddleware: endpointMiddlewareOptions.name,
|
|
246
244
|
};
|
|
247
245
|
const getHttpAuthSchemeEndpointRuleSetPlugin = (config, { httpAuthSchemeParametersProvider, identityProviderConfigProvider, }) => ({
|
|
248
246
|
applyToStack: (clientStack) => {
|
|
@@ -259,7 +257,7 @@ const httpAuthSchemeMiddlewareOptions = {
|
|
|
259
257
|
name: "httpAuthSchemeMiddleware",
|
|
260
258
|
override: true,
|
|
261
259
|
relation: "before",
|
|
262
|
-
toMiddleware:
|
|
260
|
+
toMiddleware: serializerMiddlewareOption.name,
|
|
263
261
|
};
|
|
264
262
|
const getHttpAuthSchemePlugin = (config, { httpAuthSchemeParametersProvider, identityProviderConfigProvider, }) => ({
|
|
265
263
|
applyToStack: (clientStack) => {
|
|
@@ -271,10 +269,10 @@ const getHttpAuthSchemePlugin = (config, { httpAuthSchemeParametersProvider, ide
|
|
|
271
269
|
});
|
|
272
270
|
|
|
273
271
|
const httpSigningMiddleware = (config) => (next, context) => async (args) => {
|
|
274
|
-
if (!
|
|
272
|
+
if (!HttpRequest.isInstance(args.request)) {
|
|
275
273
|
return next(args);
|
|
276
274
|
}
|
|
277
|
-
const smithyContext =
|
|
275
|
+
const smithyContext = getSmithyContext(context);
|
|
278
276
|
const scheme = smithyContext.selectedHttpAuthScheme;
|
|
279
277
|
if (!scheme) {
|
|
280
278
|
throw new Error(`No HttpAuthScheme was selected: unable to sign request`);
|
|
@@ -293,7 +291,7 @@ const httpSigningMiddlewareOptions = {
|
|
|
293
291
|
aliases: ["apiKeyMiddleware", "tokenMiddleware", "awsAuthMiddleware"],
|
|
294
292
|
override: true,
|
|
295
293
|
relation: "after",
|
|
296
|
-
toMiddleware:
|
|
294
|
+
toMiddleware: retryMiddlewareOptions.name,
|
|
297
295
|
};
|
|
298
296
|
const getHttpSigningPlugin = (config) => ({
|
|
299
297
|
applyToStack: (clientStack) => {
|
|
@@ -309,6 +307,7 @@ class NoAuthSigner {
|
|
|
309
307
|
|
|
310
308
|
exports.DefaultIdentityProviderConfig = DefaultIdentityProviderConfig;
|
|
311
309
|
exports.EXPIRATION_MS = EXPIRATION_MS;
|
|
310
|
+
exports.HttpApiKeyAuthLocation = HttpApiKeyAuthLocation;
|
|
312
311
|
exports.HttpApiKeyAuthSigner = HttpApiKeyAuthSigner;
|
|
313
312
|
exports.HttpBearerAuthSigner = HttpBearerAuthSigner;
|
|
314
313
|
exports.NoAuthSigner = NoAuthSigner;
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smithy/experimental-identity-and-auth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "concurrently 'yarn:build:types' 'yarn:build:es:cjs'",
|
|
6
|
-
"build:es:cjs": "yarn g:tsc -p tsconfig.es.json && node ../../scripts/inline",
|
|
7
|
-
"build:types": "yarn g:tsc -p tsconfig.types.json",
|
|
6
|
+
"build:es:cjs": "premove dist-es && yarn g:tsc -p tsconfig.es.json && node ../../scripts/inline",
|
|
7
|
+
"build:types": "premove dist-types && yarn g:tsc -p tsconfig.types.json",
|
|
8
8
|
"build:types:downlevel": "premove dist-types/ts3.4 && downlevel-dts dist-types dist-types/ts3.4",
|
|
9
|
-
"clean": "premove dist-cjs dist-es dist-types
|
|
9
|
+
"clean": "premove dist-cjs dist-es dist-types",
|
|
10
10
|
"format": "prettier --config ../../prettier.config.js --ignore-path ../../.prettierignore --write \"**/*.{ts,md,json}\"",
|
|
11
11
|
"lint": "eslint -c ../../.eslintrc.js \"src/**/*.ts\"",
|
|
12
12
|
"stage-release": "premove .release && yarn pack && mkdir ./.release && tar zxvf ./package.tgz --directory ./.release && rm ./package.tgz",
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
"license": "Apache-2.0",
|
|
27
27
|
"sideEffects": false,
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@smithy/core": "^3.
|
|
30
|
-
"@smithy/signature-v4": "^5.
|
|
31
|
-
"@smithy/types": "^4.
|
|
29
|
+
"@smithy/core": "^3.25.0",
|
|
30
|
+
"@smithy/signature-v4": "^5.5.0",
|
|
31
|
+
"@smithy/types": "^4.15.0",
|
|
32
32
|
"tslib": "^2.6.2"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|