@smithy/experimental-identity-and-auth 0.0.6 → 0.0.8

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.
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/dist-cjs/index.js CHANGED
@@ -2,11 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./HttpAuthScheme"), exports);
5
+ tslib_1.__exportStar(require("./HttpAuthSchemeProvider"), exports);
5
6
  tslib_1.__exportStar(require("./HttpSigner"), exports);
6
7
  tslib_1.__exportStar(require("./IdentityProviderConfig"), exports);
7
8
  tslib_1.__exportStar(require("./SigV4Signer"), exports);
8
9
  tslib_1.__exportStar(require("./apiKeyIdentity"), exports);
9
10
  tslib_1.__exportStar(require("./httpApiKeyAuth"), exports);
10
11
  tslib_1.__exportStar(require("./httpBearerAuth"), exports);
12
+ tslib_1.__exportStar(require("./middleware-http-signing"), exports);
11
13
  tslib_1.__exportStar(require("./noAuth"), exports);
12
14
  tslib_1.__exportStar(require("./tokenIdentity"), exports);
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getHttpSigningPlugin = exports.httpSigningMiddlewareOptions = void 0;
4
+ const middleware_retry_1 = require("@smithy/middleware-retry");
5
+ const httpSigningMiddleware_1 = require("./httpSigningMiddleware");
6
+ exports.httpSigningMiddlewareOptions = {
7
+ step: "finalizeRequest",
8
+ tags: ["HTTP_SIGNING"],
9
+ name: "httpSigningMiddleware",
10
+ override: true,
11
+ relation: "after",
12
+ toMiddleware: middleware_retry_1.retryMiddlewareOptions.name,
13
+ };
14
+ const getHttpSigningPlugin = (config) => ({
15
+ applyToStack: (clientStack) => {
16
+ clientStack.addRelativeTo((0, httpSigningMiddleware_1.httpSigningMiddleware)(config), exports.httpSigningMiddlewareOptions);
17
+ },
18
+ });
19
+ exports.getHttpSigningPlugin = getHttpSigningPlugin;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.httpSigningMiddleware = void 0;
4
+ const protocol_http_1 = require("@smithy/protocol-http");
5
+ const types_1 = require("@smithy/types");
6
+ const util_middleware_1 = require("@smithy/util-middleware");
7
+ const httpSigningMiddleware = (config) => (next, context) => async (args) => {
8
+ if (!protocol_http_1.HttpRequest.isInstance(args.request)) {
9
+ return next(args);
10
+ }
11
+ const smithyContext = (0, util_middleware_1.getSmithyContext)(context);
12
+ const scheme = smithyContext.selectedHttpAuthScheme;
13
+ if (!scheme) {
14
+ throw new Error(`No HttpAuthScheme was selected: unable to sign request`);
15
+ }
16
+ const { httpAuthOption: { signingProperties }, identity, signer, } = scheme;
17
+ return next({
18
+ ...args,
19
+ request: signer.sign(args.request, identity, signingProperties || {}),
20
+ });
21
+ };
22
+ exports.httpSigningMiddleware = httpSigningMiddleware;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./httpSigningMiddleware"), exports);
5
+ tslib_1.__exportStar(require("./getHttpSigningMiddleware"), exports);
@@ -0,0 +1 @@
1
+ export {};
package/dist-es/index.js CHANGED
@@ -1,9 +1,11 @@
1
1
  export * from "./HttpAuthScheme";
2
+ export * from "./HttpAuthSchemeProvider";
2
3
  export * from "./HttpSigner";
3
4
  export * from "./IdentityProviderConfig";
4
5
  export * from "./SigV4Signer";
5
6
  export * from "./apiKeyIdentity";
6
7
  export * from "./httpApiKeyAuth";
7
8
  export * from "./httpBearerAuth";
9
+ export * from "./middleware-http-signing";
8
10
  export * from "./noAuth";
9
11
  export * from "./tokenIdentity";
@@ -0,0 +1,15 @@
1
+ import { retryMiddlewareOptions } from "@smithy/middleware-retry";
2
+ import { httpSigningMiddleware } from "./httpSigningMiddleware";
3
+ export const httpSigningMiddlewareOptions = {
4
+ step: "finalizeRequest",
5
+ tags: ["HTTP_SIGNING"],
6
+ name: "httpSigningMiddleware",
7
+ override: true,
8
+ relation: "after",
9
+ toMiddleware: retryMiddlewareOptions.name,
10
+ };
11
+ export const getHttpSigningPlugin = (config) => ({
12
+ applyToStack: (clientStack) => {
13
+ clientStack.addRelativeTo(httpSigningMiddleware(config), httpSigningMiddlewareOptions);
14
+ },
15
+ });
@@ -0,0 +1,18 @@
1
+ import { HttpRequest } from "@smithy/protocol-http";
2
+ import { SMITHY_CONTEXT_KEY, } from "@smithy/types";
3
+ import { getSmithyContext } from "@smithy/util-middleware";
4
+ export const httpSigningMiddleware = (config) => (next, context) => async (args) => {
5
+ if (!HttpRequest.isInstance(args.request)) {
6
+ return next(args);
7
+ }
8
+ const smithyContext = getSmithyContext(context);
9
+ const scheme = smithyContext.selectedHttpAuthScheme;
10
+ if (!scheme) {
11
+ throw new Error(`No HttpAuthScheme was selected: unable to sign request`);
12
+ }
13
+ const { httpAuthOption: { signingProperties }, identity, signer, } = scheme;
14
+ return next({
15
+ ...args,
16
+ request: signer.sign(args.request, identity, signingProperties || {}),
17
+ });
18
+ };
@@ -0,0 +1,2 @@
1
+ export * from "./httpSigningMiddleware";
2
+ export * from "./getHttpSigningMiddleware";
@@ -34,3 +34,11 @@ export interface HttpAuthOption {
34
34
  identityProperties?: Record<string, unknown>;
35
35
  signingProperties?: Record<string, unknown>;
36
36
  }
37
+ /**
38
+ * @internal
39
+ */
40
+ export interface SelectedHttpAuthScheme {
41
+ httpAuthOption: HttpAuthOption;
42
+ identity: Identity;
43
+ signer: HttpSigner;
44
+ }
@@ -0,0 +1,20 @@
1
+ import { HandlerExecutionContext } from "@smithy/types";
2
+ import { HttpAuthOption } from "./HttpAuthScheme";
3
+ /**
4
+ * @internal
5
+ */
6
+ export interface HttpAuthSchemeParameters {
7
+ operation?: string;
8
+ }
9
+ /**
10
+ * @internal
11
+ */
12
+ export interface HttpAuthSchemeProvider<TParameters extends HttpAuthSchemeParameters = HttpAuthSchemeParameters> {
13
+ (authParameters: TParameters): HttpAuthOption[];
14
+ }
15
+ /**
16
+ * @internal
17
+ */
18
+ export interface HttpAuthSchemeParametersProvider<C extends object = object, T extends HttpAuthSchemeParameters = HttpAuthSchemeParameters> {
19
+ (config: C, context: HandlerExecutionContext, input: Record<string, unknown>): Promise<T>;
20
+ }
@@ -1,9 +1,11 @@
1
1
  export * from "./HttpAuthScheme";
2
+ export * from "./HttpAuthSchemeProvider";
2
3
  export * from "./HttpSigner";
3
4
  export * from "./IdentityProviderConfig";
4
5
  export * from "./SigV4Signer";
5
6
  export * from "./apiKeyIdentity";
6
7
  export * from "./httpApiKeyAuth";
7
8
  export * from "./httpBearerAuth";
9
+ export * from "./middleware-http-signing";
8
10
  export * from "./noAuth";
9
11
  export * from "./tokenIdentity";
@@ -0,0 +1,9 @@
1
+ import { FinalizeRequestHandlerOptions, Pluggable, RelativeMiddlewareOptions } from "@smithy/types";
2
+ /**
3
+ * @internal
4
+ */
5
+ export declare const httpSigningMiddlewareOptions: FinalizeRequestHandlerOptions & RelativeMiddlewareOptions;
6
+ /**
7
+ * @internal
8
+ */
9
+ export declare const getHttpSigningPlugin: <Input extends object, Output extends object>(config: object) => Pluggable<Input, Output>;
@@ -0,0 +1,5 @@
1
+ import { FinalizeRequestMiddleware } from "@smithy/types";
2
+ /**
3
+ * @internal
4
+ */
5
+ export declare const httpSigningMiddleware: <Input extends object, Output extends object>(config: object) => FinalizeRequestMiddleware<Input, Output>;
@@ -0,0 +1,2 @@
1
+ export * from "./httpSigningMiddleware";
2
+ export * from "./getHttpSigningMiddleware";
@@ -34,3 +34,11 @@ export interface HttpAuthOption {
34
34
  identityProperties?: Record<string, unknown>;
35
35
  signingProperties?: Record<string, unknown>;
36
36
  }
37
+ /**
38
+ * @internal
39
+ */
40
+ export interface SelectedHttpAuthScheme {
41
+ httpAuthOption: HttpAuthOption;
42
+ identity: Identity;
43
+ signer: HttpSigner;
44
+ }
@@ -0,0 +1,20 @@
1
+ import { HandlerExecutionContext } from "@smithy/types";
2
+ import { HttpAuthOption } from "./HttpAuthScheme";
3
+ /**
4
+ * @internal
5
+ */
6
+ export interface HttpAuthSchemeParameters {
7
+ operation?: string;
8
+ }
9
+ /**
10
+ * @internal
11
+ */
12
+ export interface HttpAuthSchemeProvider<TParameters extends HttpAuthSchemeParameters = HttpAuthSchemeParameters> {
13
+ (authParameters: TParameters): HttpAuthOption[];
14
+ }
15
+ /**
16
+ * @internal
17
+ */
18
+ export interface HttpAuthSchemeParametersProvider<C extends object = object, T extends HttpAuthSchemeParameters = HttpAuthSchemeParameters> {
19
+ (config: C, context: HandlerExecutionContext, input: Record<string, unknown>): Promise<T>;
20
+ }
@@ -1,9 +1,11 @@
1
1
  export * from "./HttpAuthScheme";
2
+ export * from "./HttpAuthSchemeProvider";
2
3
  export * from "./HttpSigner";
3
4
  export * from "./IdentityProviderConfig";
4
5
  export * from "./SigV4Signer";
5
6
  export * from "./apiKeyIdentity";
6
7
  export * from "./httpApiKeyAuth";
7
8
  export * from "./httpBearerAuth";
9
+ export * from "./middleware-http-signing";
8
10
  export * from "./noAuth";
9
11
  export * from "./tokenIdentity";
@@ -0,0 +1,9 @@
1
+ import { FinalizeRequestHandlerOptions, Pluggable, RelativeMiddlewareOptions } from "@smithy/types";
2
+ /**
3
+ * @internal
4
+ */
5
+ export declare const httpSigningMiddlewareOptions: FinalizeRequestHandlerOptions & RelativeMiddlewareOptions;
6
+ /**
7
+ * @internal
8
+ */
9
+ export declare const getHttpSigningPlugin: <Input extends object, Output extends object>(config: object) => Pluggable<Input, Output>;
@@ -0,0 +1,5 @@
1
+ import { FinalizeRequestMiddleware } from "@smithy/types";
2
+ /**
3
+ * @internal
4
+ */
5
+ export declare const httpSigningMiddleware: <Input extends object, Output extends object>(config: object) => FinalizeRequestMiddleware<Input, Output>;
@@ -0,0 +1,2 @@
1
+ export * from "./httpSigningMiddleware";
2
+ export * from "./getHttpSigningMiddleware";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smithy/experimental-identity-and-auth",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "scripts": {
5
5
  "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types && yarn build:types:downlevel'",
6
6
  "build:cjs": "tsc -p tsconfig.cjs.json",
@@ -23,9 +23,10 @@
23
23
  },
24
24
  "license": "Apache-2.0",
25
25
  "dependencies": {
26
- "@smithy/protocol-http": "^3.0.3",
27
- "@smithy/signature-v4": "^2.0.7",
28
- "@smithy/types": "^2.3.1",
26
+ "@smithy/middleware-retry": "^2.0.12",
27
+ "@smithy/protocol-http": "^3.0.5",
28
+ "@smithy/signature-v4": "^2.0.9",
29
+ "@smithy/types": "^2.3.3",
29
30
  "tslib": "^2.5.0"
30
31
  },
31
32
  "engines": {