@smithy/experimental-identity-and-auth 0.5.53 → 0.6.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 +16 -16
- package/dist-es/SigV4Signer.js +1 -1
- package/dist-es/endpointRuleSet.js +2 -2
- package/dist-es/httpApiKeyAuth.js +1 -1
- package/dist-es/httpBearerAuth.js +1 -1
- package/dist-es/middleware-http-auth-scheme/getHttpAuthSchemeEndpointRuleSetPlugin.js +1 -1
- package/dist-es/middleware-http-auth-scheme/getHttpAuthSchemePlugin.js +1 -1
- package/dist-es/middleware-http-auth-scheme/httpAuthSchemeMiddleware.js +1 -1
- package/dist-es/middleware-http-signing/getHttpSigningMiddleware.js +1 -1
- package/dist-es/middleware-http-signing/httpSigningMiddleware.js +2 -2
- package/dist-types/SigV4Signer.d.ts +1 -1
- package/dist-types/endpointRuleSet.d.ts +1 -1
- package/dist-types/httpApiKeyAuth.d.ts +2 -2
- package/dist-types/httpBearerAuth.d.ts +1 -1
- package/dist-types/middleware-http-auth-scheme/getHttpAuthSchemeEndpointRuleSetPlugin.d.ts +1 -1
- package/dist-types/middleware-http-auth-scheme/getHttpAuthSchemePlugin.d.ts +1 -1
- package/dist-types/middleware-http-auth-scheme/httpAuthSchemeMiddleware.d.ts +1 -1
- package/package.json +4 -7
package/dist-cjs/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var protocols = require('@smithy/core/protocols');
|
|
4
4
|
var signatureV4 = require('@smithy/signature-v4');
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
5
|
+
var client = require('@smithy/core/client');
|
|
6
|
+
var endpoints = require('@smithy/core/endpoints');
|
|
7
|
+
var serde = require('@smithy/core/serde');
|
|
8
|
+
var retry = require('@smithy/core/retry');
|
|
9
9
|
|
|
10
10
|
class DefaultIdentityProviderConfig {
|
|
11
11
|
authSchemes = new Map();
|
|
@@ -23,7 +23,7 @@ class DefaultIdentityProviderConfig {
|
|
|
23
23
|
|
|
24
24
|
class SigV4Signer {
|
|
25
25
|
async sign(httpRequest, identity, signingProperties) {
|
|
26
|
-
const clonedRequest =
|
|
26
|
+
const clonedRequest = protocols.HttpRequest.clone(httpRequest);
|
|
27
27
|
const signer = new signatureV4.SignatureV4({
|
|
28
28
|
applyChecksum: signingProperties.applyChecksum !== undefined ? signingProperties.applyChecksum : true,
|
|
29
29
|
credentials: identity,
|
|
@@ -83,12 +83,12 @@ const createEndpointRuleSetHttpAuthSchemeParametersProvider = (defaultHttpAuthSc
|
|
|
83
83
|
throw new Error(`Could not find \`input\` for \`defaultEndpointRuleSetHttpAuthSchemeParametersProvider\``);
|
|
84
84
|
}
|
|
85
85
|
const defaultParameters = await defaultHttpAuthSchemeParametersProvider(config, context, input);
|
|
86
|
-
const instructionsFn =
|
|
86
|
+
const instructionsFn = client.getSmithyContext(context)?.endpointRuleSet
|
|
87
87
|
?.getEndpointParameterInstructions;
|
|
88
88
|
if (!instructionsFn) {
|
|
89
89
|
throw new Error(`getEndpointParameterInstructions() is not defined on \`${context.commandName}\``);
|
|
90
90
|
}
|
|
91
|
-
const endpointParameters = await
|
|
91
|
+
const endpointParameters = await endpoints.resolveParams(input, { getEndpointParameterInstructions: instructionsFn }, config);
|
|
92
92
|
return Object.assign(defaultParameters, endpointParameters);
|
|
93
93
|
};
|
|
94
94
|
|
|
@@ -111,7 +111,7 @@ class HttpApiKeyAuthSigner {
|
|
|
111
111
|
if (!identity.apiKey) {
|
|
112
112
|
throw new Error("request could not be signed with `apiKey` since the `apiKey` is not defined");
|
|
113
113
|
}
|
|
114
|
-
const clonedRequest =
|
|
114
|
+
const clonedRequest = protocols.HttpRequest.clone(httpRequest);
|
|
115
115
|
if (signingProperties.in === exports.HttpApiKeyAuthLocation.QUERY) {
|
|
116
116
|
clonedRequest.query[signingProperties.name] = identity.apiKey;
|
|
117
117
|
}
|
|
@@ -132,7 +132,7 @@ class HttpApiKeyAuthSigner {
|
|
|
132
132
|
|
|
133
133
|
class HttpBearerAuthSigner {
|
|
134
134
|
async sign(httpRequest, identity, signingProperties) {
|
|
135
|
-
const clonedRequest =
|
|
135
|
+
const clonedRequest = protocols.HttpRequest.clone(httpRequest);
|
|
136
136
|
if (!identity.token) {
|
|
137
137
|
throw new Error("request could not be signed with `token` since the `token` is not defined");
|
|
138
138
|
}
|
|
@@ -207,7 +207,7 @@ function convertHttpAuthSchemesToMap(httpAuthSchemes) {
|
|
|
207
207
|
const httpAuthSchemeMiddleware = (config, mwOptions) => (next, context) => async (args) => {
|
|
208
208
|
const options = config.httpAuthSchemeProvider(await mwOptions.httpAuthSchemeParametersProvider(config, context, args.input));
|
|
209
209
|
const authSchemes = convertHttpAuthSchemesToMap(config.httpAuthSchemes);
|
|
210
|
-
const smithyContext =
|
|
210
|
+
const smithyContext = client.getSmithyContext(context);
|
|
211
211
|
const failureReasons = [];
|
|
212
212
|
for (const option of options) {
|
|
213
213
|
const scheme = authSchemes.get(option.schemeId);
|
|
@@ -242,7 +242,7 @@ const httpAuthSchemeEndpointRuleSetMiddlewareOptions = {
|
|
|
242
242
|
name: "httpAuthSchemeMiddleware",
|
|
243
243
|
override: true,
|
|
244
244
|
relation: "before",
|
|
245
|
-
toMiddleware:
|
|
245
|
+
toMiddleware: endpoints.endpointMiddlewareOptions.name,
|
|
246
246
|
};
|
|
247
247
|
const getHttpAuthSchemeEndpointRuleSetPlugin = (config, { httpAuthSchemeParametersProvider, identityProviderConfigProvider, }) => ({
|
|
248
248
|
applyToStack: (clientStack) => {
|
|
@@ -259,7 +259,7 @@ const httpAuthSchemeMiddlewareOptions = {
|
|
|
259
259
|
name: "httpAuthSchemeMiddleware",
|
|
260
260
|
override: true,
|
|
261
261
|
relation: "before",
|
|
262
|
-
toMiddleware:
|
|
262
|
+
toMiddleware: serde.serializerMiddlewareOption.name,
|
|
263
263
|
};
|
|
264
264
|
const getHttpAuthSchemePlugin = (config, { httpAuthSchemeParametersProvider, identityProviderConfigProvider, }) => ({
|
|
265
265
|
applyToStack: (clientStack) => {
|
|
@@ -271,10 +271,10 @@ const getHttpAuthSchemePlugin = (config, { httpAuthSchemeParametersProvider, ide
|
|
|
271
271
|
});
|
|
272
272
|
|
|
273
273
|
const httpSigningMiddleware = (config) => (next, context) => async (args) => {
|
|
274
|
-
if (!
|
|
274
|
+
if (!protocols.HttpRequest.isInstance(args.request)) {
|
|
275
275
|
return next(args);
|
|
276
276
|
}
|
|
277
|
-
const smithyContext =
|
|
277
|
+
const smithyContext = client.getSmithyContext(context);
|
|
278
278
|
const scheme = smithyContext.selectedHttpAuthScheme;
|
|
279
279
|
if (!scheme) {
|
|
280
280
|
throw new Error(`No HttpAuthScheme was selected: unable to sign request`);
|
|
@@ -293,7 +293,7 @@ const httpSigningMiddlewareOptions = {
|
|
|
293
293
|
aliases: ["apiKeyMiddleware", "tokenMiddleware", "awsAuthMiddleware"],
|
|
294
294
|
override: true,
|
|
295
295
|
relation: "after",
|
|
296
|
-
toMiddleware:
|
|
296
|
+
toMiddleware: retry.retryMiddlewareOptions.name,
|
|
297
297
|
};
|
|
298
298
|
const getHttpSigningPlugin = (config) => ({
|
|
299
299
|
applyToStack: (clientStack) => {
|
package/dist-es/SigV4Signer.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { getSmithyContext } from "@smithy/core/client";
|
|
2
|
+
import { resolveParams } from "@smithy/core/endpoints";
|
|
3
3
|
export const createEndpointRuleSetHttpAuthSchemeProvider = (defaultEndpointResolver, defaultHttpAuthSchemeResolver) => {
|
|
4
4
|
const endpointRuleSetHttpAuthSchemeProvider = (authParameters) => {
|
|
5
5
|
const endpoint = defaultEndpointResolver(authParameters);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { endpointMiddlewareOptions } from "@smithy/
|
|
1
|
+
import { endpointMiddlewareOptions } from "@smithy/core/endpoints";
|
|
2
2
|
import { httpAuthSchemeMiddleware } from "./httpAuthSchemeMiddleware";
|
|
3
3
|
export const httpAuthSchemeEndpointRuleSetMiddlewareOptions = {
|
|
4
4
|
step: "serialize",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { serializerMiddlewareOption } from "@smithy/
|
|
1
|
+
import { serializerMiddlewareOption } from "@smithy/core/serde";
|
|
2
2
|
import { httpAuthSchemeMiddleware } from "./httpAuthSchemeMiddleware";
|
|
3
3
|
export const httpAuthSchemeMiddlewareOptions = {
|
|
4
4
|
step: "serialize",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { getSmithyContext } from "@smithy/core/client";
|
|
2
|
+
import { HttpRequest } from "@smithy/core/protocols";
|
|
3
3
|
export const httpSigningMiddleware = (config) => (next, context) => async (args) => {
|
|
4
4
|
if (!HttpRequest.isInstance(args.request)) {
|
|
5
5
|
return next(args);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type EndpointParameterInstructions } from "@smithy/core/endpoints";
|
|
2
2
|
import type { EndpointParameters, EndpointV2, HandlerExecutionContext, Logger } from "@smithy/types";
|
|
3
3
|
import type { HttpAuthSchemeParameters, HttpAuthSchemeParametersProvider, HttpAuthSchemeProvider } from "./HttpAuthSchemeProvider";
|
|
4
4
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { HttpRequest } from "@smithy/
|
|
1
|
+
import { HttpRequest } from "@smithy/core/protocols";
|
|
2
2
|
import type { HttpRequest as IHttpRequest } from "@smithy/types";
|
|
3
|
-
import type { ApiKeyIdentity } from "./apiKeyIdentity";
|
|
4
3
|
import type { HttpSigner } from "./HttpSigner";
|
|
4
|
+
import type { ApiKeyIdentity } from "./apiKeyIdentity";
|
|
5
5
|
/**
|
|
6
6
|
* @internal
|
|
7
7
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HttpRequest } from "@smithy/
|
|
1
|
+
import { HttpRequest } from "@smithy/core/protocols";
|
|
2
2
|
import type { HttpRequest as IHttpRequest } from "@smithy/types";
|
|
3
3
|
import type { HttpSigner } from "./HttpSigner";
|
|
4
4
|
import type { TokenIdentity } from "./tokenIdentity";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { HandlerExecutionContext, Pluggable, RelativeMiddlewareOptions, SerializeHandlerOptions } from "@smithy/types";
|
|
2
2
|
import type { HttpAuthSchemeParameters, HttpAuthSchemeParametersProvider } from "../HttpAuthSchemeProvider";
|
|
3
3
|
import type { IdentityProviderConfig } from "../IdentityProviderConfig";
|
|
4
|
-
import type
|
|
4
|
+
import { type PreviouslyResolved } from "./httpAuthSchemeMiddleware";
|
|
5
5
|
/**
|
|
6
6
|
* @internal
|
|
7
7
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { HandlerExecutionContext, Pluggable, RelativeMiddlewareOptions, SerializeHandlerOptions } from "@smithy/types";
|
|
2
2
|
import type { HttpAuthSchemeParameters, HttpAuthSchemeParametersProvider } from "../HttpAuthSchemeProvider";
|
|
3
3
|
import type { IdentityProviderConfig } from "../IdentityProviderConfig";
|
|
4
|
-
import type
|
|
4
|
+
import { type PreviouslyResolved } from "./httpAuthSchemeMiddleware";
|
|
5
5
|
/**
|
|
6
6
|
* @internal
|
|
7
7
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { HandlerExecutionContext,
|
|
1
|
+
import type { HandlerExecutionContext, SMITHY_CONTEXT_KEY, SerializeMiddleware } from "@smithy/types";
|
|
2
2
|
import type { HttpAuthScheme, SelectedHttpAuthScheme } from "../HttpAuthScheme";
|
|
3
3
|
import type { HttpAuthSchemeParameters, HttpAuthSchemeParametersProvider, HttpAuthSchemeProvider } from "../HttpAuthSchemeProvider";
|
|
4
4
|
import type { IdentityProviderConfig } from "../IdentityProviderConfig";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smithy/experimental-identity-and-auth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "concurrently 'yarn:build:types' 'yarn:build:es:cjs'",
|
|
6
6
|
"build:es:cjs": "yarn g:tsc -p tsconfig.es.json && node ../../scripts/inline experimental-identity-and-auth",
|
|
@@ -26,13 +26,10 @@
|
|
|
26
26
|
"license": "Apache-2.0",
|
|
27
27
|
"sideEffects": false,
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@smithy/
|
|
30
|
-
"@smithy/middleware-retry": "^4.
|
|
31
|
-
"@smithy/
|
|
32
|
-
"@smithy/protocol-http": "^5.3.14",
|
|
33
|
-
"@smithy/signature-v4": "^5.3.14",
|
|
29
|
+
"@smithy/core": "^3.24.0",
|
|
30
|
+
"@smithy/middleware-retry": "^4.6.0",
|
|
31
|
+
"@smithy/signature-v4": "^5.4.0",
|
|
34
32
|
"@smithy/types": "^4.14.1",
|
|
35
|
-
"@smithy/util-middleware": "^4.2.14",
|
|
36
33
|
"tslib": "^2.6.2"
|
|
37
34
|
},
|
|
38
35
|
"engines": {
|