@smithy/core 3.23.12 → 3.23.14

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.
Files changed (104) hide show
  1. package/README.md +12 -1
  2. package/dist-cjs/getSmithyContext.js +6 -0
  3. package/dist-cjs/index.js +1 -1
  4. package/dist-cjs/middleware-http-auth-scheme/getHttpAuthSchemeEndpointRuleSetPlugin.js +21 -0
  5. package/dist-cjs/middleware-http-auth-scheme/getHttpAuthSchemePlugin.js +21 -0
  6. package/dist-cjs/middleware-http-auth-scheme/httpAuthSchemeMiddleware.js +46 -0
  7. package/dist-cjs/middleware-http-auth-scheme/index.js +6 -0
  8. package/dist-cjs/middleware-http-auth-scheme/resolveAuthOptions.js +24 -0
  9. package/dist-cjs/middleware-http-signing/getHttpSigningMiddleware.js +19 -0
  10. package/dist-cjs/middleware-http-signing/httpSigningMiddleware.js +27 -0
  11. package/dist-cjs/middleware-http-signing/index.js +5 -0
  12. package/dist-cjs/normalizeProvider.js +10 -0
  13. package/dist-cjs/pagination/createPaginator.js +44 -0
  14. package/dist-cjs/request-builder/requestBuilder.js +5 -0
  15. package/dist-cjs/setFeature.js +14 -0
  16. package/dist-cjs/submodules/protocols/index.js +8 -17
  17. package/dist-cjs/util-identity-and-auth/DefaultIdentityProviderConfig.js +17 -0
  18. package/dist-cjs/util-identity-and-auth/httpAuthSchemes/httpApiKeyAuth.js +38 -0
  19. package/dist-cjs/util-identity-and-auth/httpAuthSchemes/httpBearerAuth.js +15 -0
  20. package/dist-cjs/util-identity-and-auth/httpAuthSchemes/index.js +6 -0
  21. package/dist-cjs/util-identity-and-auth/httpAuthSchemes/noAuth.js +9 -0
  22. package/dist-cjs/util-identity-and-auth/index.js +6 -0
  23. package/dist-cjs/util-identity-and-auth/memoizeIdentityProvider.js +61 -0
  24. package/dist-es/submodules/protocols/HttpBindingProtocol.js +1 -8
  25. package/dist-es/submodules/protocols/RpcProtocol.js +7 -9
  26. package/dist-types/submodules/protocols/RpcProtocol.d.ts +1 -1
  27. package/package.json +15 -16
  28. package/dist-types/ts3.4/getSmithyContext.d.ts +0 -5
  29. package/dist-types/ts3.4/index.d.ts +0 -8
  30. package/dist-types/ts3.4/middleware-http-auth-scheme/getHttpAuthSchemeEndpointRuleSetPlugin.d.ts +0 -18
  31. package/dist-types/ts3.4/middleware-http-auth-scheme/getHttpAuthSchemePlugin.d.ts +0 -18
  32. package/dist-types/ts3.4/middleware-http-auth-scheme/httpAuthSchemeMiddleware.d.ts +0 -33
  33. package/dist-types/ts3.4/middleware-http-auth-scheme/index.d.ts +0 -3
  34. package/dist-types/ts3.4/middleware-http-auth-scheme/resolveAuthOptions.d.ts +0 -10
  35. package/dist-types/ts3.4/middleware-http-signing/getHttpSigningMiddleware.d.ts +0 -9
  36. package/dist-types/ts3.4/middleware-http-signing/httpSigningMiddleware.d.ts +0 -5
  37. package/dist-types/ts3.4/middleware-http-signing/index.d.ts +0 -2
  38. package/dist-types/ts3.4/normalizeProvider.d.ts +0 -7
  39. package/dist-types/ts3.4/pagination/createPaginator.d.ts +0 -7
  40. package/dist-types/ts3.4/request-builder/requestBuilder.d.ts +0 -5
  41. package/dist-types/ts3.4/setFeature.d.ts +0 -12
  42. package/dist-types/ts3.4/submodules/cbor/CborCodec.d.ts +0 -33
  43. package/dist-types/ts3.4/submodules/cbor/SmithyRpcV2CborProtocol.d.ts +0 -28
  44. package/dist-types/ts3.4/submodules/cbor/byte-printer.d.ts +0 -6
  45. package/dist-types/ts3.4/submodules/cbor/cbor-decode.d.ts +0 -17
  46. package/dist-types/ts3.4/submodules/cbor/cbor-encode.d.ts +0 -9
  47. package/dist-types/ts3.4/submodules/cbor/cbor-types.d.ts +0 -65
  48. package/dist-types/ts3.4/submodules/cbor/cbor.d.ts +0 -26
  49. package/dist-types/ts3.4/submodules/cbor/index.d.ts +0 -5
  50. package/dist-types/ts3.4/submodules/cbor/parseCborBody.d.ts +0 -31
  51. package/dist-types/ts3.4/submodules/endpoints/index.d.ts +0 -1
  52. package/dist-types/ts3.4/submodules/endpoints/toEndpointV1.d.ts +0 -6
  53. package/dist-types/ts3.4/submodules/event-streams/EventStreamSerde.d.ts +0 -60
  54. package/dist-types/ts3.4/submodules/event-streams/index.d.ts +0 -1
  55. package/dist-types/ts3.4/submodules/protocols/HttpBindingProtocol.d.ts +0 -31
  56. package/dist-types/ts3.4/submodules/protocols/HttpProtocol.d.ts +0 -89
  57. package/dist-types/ts3.4/submodules/protocols/RpcProtocol.d.ts +0 -16
  58. package/dist-types/ts3.4/submodules/protocols/SerdeContext.d.ts +0 -16
  59. package/dist-types/ts3.4/submodules/protocols/collect-stream-body.d.ts +0 -10
  60. package/dist-types/ts3.4/submodules/protocols/extended-encode-uri-component.d.ts +0 -7
  61. package/dist-types/ts3.4/submodules/protocols/index.d.ts +0 -13
  62. package/dist-types/ts3.4/submodules/protocols/requestBuilder.d.ts +0 -51
  63. package/dist-types/ts3.4/submodules/protocols/resolve-path.d.ts +0 -4
  64. package/dist-types/ts3.4/submodules/protocols/serde/FromStringShapeDeserializer.d.ts +0 -13
  65. package/dist-types/ts3.4/submodules/protocols/serde/HttpInterceptingShapeDeserializer.d.ts +0 -21
  66. package/dist-types/ts3.4/submodules/protocols/serde/HttpInterceptingShapeSerializer.d.ts +0 -23
  67. package/dist-types/ts3.4/submodules/protocols/serde/ToStringShapeSerializer.d.ts +0 -14
  68. package/dist-types/ts3.4/submodules/protocols/serde/determineTimestampFormat.d.ts +0 -9
  69. package/dist-types/ts3.4/submodules/schema/TypeRegistry.d.ts +0 -71
  70. package/dist-types/ts3.4/submodules/schema/deref.d.ts +0 -6
  71. package/dist-types/ts3.4/submodules/schema/index.d.ts +0 -14
  72. package/dist-types/ts3.4/submodules/schema/middleware/getSchemaSerdePlugin.d.ts +0 -14
  73. package/dist-types/ts3.4/submodules/schema/middleware/schema-middleware-types.d.ts +0 -11
  74. package/dist-types/ts3.4/submodules/schema/middleware/schemaDeserializationMiddleware.d.ts +0 -9
  75. package/dist-types/ts3.4/submodules/schema/middleware/schemaSerializationMiddleware.d.ts +0 -6
  76. package/dist-types/ts3.4/submodules/schema/schemas/ErrorSchema.d.ts +0 -37
  77. package/dist-types/ts3.4/submodules/schema/schemas/ListSchema.d.ts +0 -23
  78. package/dist-types/ts3.4/submodules/schema/schemas/MapSchema.d.ts +0 -24
  79. package/dist-types/ts3.4/submodules/schema/schemas/NormalizedSchema.d.ts +0 -146
  80. package/dist-types/ts3.4/submodules/schema/schemas/OperationSchema.d.ts +0 -23
  81. package/dist-types/ts3.4/submodules/schema/schemas/Schema.d.ts +0 -16
  82. package/dist-types/ts3.4/submodules/schema/schemas/SimpleSchema.d.ts +0 -28
  83. package/dist-types/ts3.4/submodules/schema/schemas/StructureSchema.d.ts +0 -23
  84. package/dist-types/ts3.4/submodules/schema/schemas/operation.d.ts +0 -7
  85. package/dist-types/ts3.4/submodules/schema/schemas/sentinels.d.ts +0 -23
  86. package/dist-types/ts3.4/submodules/schema/schemas/translateTraits.d.ts +0 -13
  87. package/dist-types/ts3.4/submodules/serde/copyDocumentWithTransform.d.ts +0 -6
  88. package/dist-types/ts3.4/submodules/serde/date-utils.d.ts +0 -73
  89. package/dist-types/ts3.4/submodules/serde/generateIdempotencyToken.d.ts +0 -2
  90. package/dist-types/ts3.4/submodules/serde/index.d.ts +0 -10
  91. package/dist-types/ts3.4/submodules/serde/lazy-json.d.ts +0 -45
  92. package/dist-types/ts3.4/submodules/serde/parse-utils.d.ts +0 -270
  93. package/dist-types/ts3.4/submodules/serde/quote-header.d.ts +0 -6
  94. package/dist-types/ts3.4/submodules/serde/schema-serde-lib/schema-date-utils.d.ts +0 -47
  95. package/dist-types/ts3.4/submodules/serde/split-every.d.ts +0 -11
  96. package/dist-types/ts3.4/submodules/serde/split-header.d.ts +0 -5
  97. package/dist-types/ts3.4/submodules/serde/value/NumericValue.d.ts +0 -33
  98. package/dist-types/ts3.4/util-identity-and-auth/DefaultIdentityProviderConfig.d.ts +0 -15
  99. package/dist-types/ts3.4/util-identity-and-auth/httpAuthSchemes/httpApiKeyAuth.d.ts +0 -8
  100. package/dist-types/ts3.4/util-identity-and-auth/httpAuthSchemes/httpBearerAuth.d.ts +0 -8
  101. package/dist-types/ts3.4/util-identity-and-auth/httpAuthSchemes/index.d.ts +0 -3
  102. package/dist-types/ts3.4/util-identity-and-auth/httpAuthSchemes/noAuth.d.ts +0 -8
  103. package/dist-types/ts3.4/util-identity-and-auth/index.d.ts +0 -3
  104. package/dist-types/ts3.4/util-identity-and-auth/memoizeIdentityProvider.d.ts +0 -30
package/README.md CHANGED
@@ -3,7 +3,18 @@
3
3
  [![NPM version](https://img.shields.io/npm/v/@smithy/core/latest.svg)](https://www.npmjs.com/package/@smithy/core)
4
4
  [![NPM downloads](https://img.shields.io/npm/dm/@smithy/core.svg)](https://www.npmjs.com/package/@smithy/core)
5
5
 
6
- > An internal package. You probably shouldn't use this package, at least directly.
6
+ ### :warning: Internal API :warning:
7
+
8
+ > This is an internal package.
9
+ > That means this is used as a dependency for other, public packages, but
10
+ > should not be taken directly as a dependency in your application's `package.json`.
11
+
12
+ > If you are updating the version of this package, for example to bring in a
13
+ > bug-fix, you should do so by updating your application lockfile with
14
+ > e.g. `npm up @scope/package` or equivalent command in another
15
+ > package manager, rather than taking a direct dependency.
16
+
17
+ ---
7
18
 
8
19
  This package provides common or core functionality for generic Smithy clients.
9
20
 
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSmithyContext = void 0;
4
+ const types_1 = require("@smithy/types");
5
+ const getSmithyContext = (context) => context[types_1.SMITHY_CONTEXT_KEY] || (context[types_1.SMITHY_CONTEXT_KEY] = {});
6
+ exports.getSmithyContext = getSmithyContext;
package/dist-cjs/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  var types = require('@smithy/types');
4
- var utilMiddleware = require('@smithy/util-middleware');
5
4
  var protocolHttp = require('@smithy/protocol-http');
5
+ var utilMiddleware = require('@smithy/util-middleware');
6
6
  var protocols = require('@smithy/core/protocols');
7
7
 
8
8
  const getSmithyContext = (context) => context[types.SMITHY_CONTEXT_KEY] || (context[types.SMITHY_CONTEXT_KEY] = {});
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getHttpAuthSchemeEndpointRuleSetPlugin = exports.httpAuthSchemeEndpointRuleSetMiddlewareOptions = void 0;
4
+ const httpAuthSchemeMiddleware_1 = require("./httpAuthSchemeMiddleware");
5
+ exports.httpAuthSchemeEndpointRuleSetMiddlewareOptions = {
6
+ step: "serialize",
7
+ tags: ["HTTP_AUTH_SCHEME"],
8
+ name: "httpAuthSchemeMiddleware",
9
+ override: true,
10
+ relation: "before",
11
+ toMiddleware: "endpointV2Middleware",
12
+ };
13
+ const getHttpAuthSchemeEndpointRuleSetPlugin = (config, { httpAuthSchemeParametersProvider, identityProviderConfigProvider, }) => ({
14
+ applyToStack: (clientStack) => {
15
+ clientStack.addRelativeTo((0, httpAuthSchemeMiddleware_1.httpAuthSchemeMiddleware)(config, {
16
+ httpAuthSchemeParametersProvider,
17
+ identityProviderConfigProvider,
18
+ }), exports.httpAuthSchemeEndpointRuleSetMiddlewareOptions);
19
+ },
20
+ });
21
+ exports.getHttpAuthSchemeEndpointRuleSetPlugin = getHttpAuthSchemeEndpointRuleSetPlugin;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getHttpAuthSchemePlugin = exports.httpAuthSchemeMiddlewareOptions = void 0;
4
+ const httpAuthSchemeMiddleware_1 = require("./httpAuthSchemeMiddleware");
5
+ exports.httpAuthSchemeMiddlewareOptions = {
6
+ step: "serialize",
7
+ tags: ["HTTP_AUTH_SCHEME"],
8
+ name: "httpAuthSchemeMiddleware",
9
+ override: true,
10
+ relation: "before",
11
+ toMiddleware: "serializerMiddleware",
12
+ };
13
+ const getHttpAuthSchemePlugin = (config, { httpAuthSchemeParametersProvider, identityProviderConfigProvider, }) => ({
14
+ applyToStack: (clientStack) => {
15
+ clientStack.addRelativeTo((0, httpAuthSchemeMiddleware_1.httpAuthSchemeMiddleware)(config, {
16
+ httpAuthSchemeParametersProvider,
17
+ identityProviderConfigProvider,
18
+ }), exports.httpAuthSchemeMiddlewareOptions);
19
+ },
20
+ });
21
+ exports.getHttpAuthSchemePlugin = getHttpAuthSchemePlugin;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.httpAuthSchemeMiddleware = void 0;
4
+ const util_middleware_1 = require("@smithy/util-middleware");
5
+ const resolveAuthOptions_1 = require("./resolveAuthOptions");
6
+ function convertHttpAuthSchemesToMap(httpAuthSchemes) {
7
+ const map = new Map();
8
+ for (const scheme of httpAuthSchemes) {
9
+ map.set(scheme.schemeId, scheme);
10
+ }
11
+ return map;
12
+ }
13
+ const httpAuthSchemeMiddleware = (config, mwOptions) => (next, context) => async (args) => {
14
+ const options = config.httpAuthSchemeProvider(await mwOptions.httpAuthSchemeParametersProvider(config, context, args.input));
15
+ const authSchemePreference = config.authSchemePreference ? await config.authSchemePreference() : [];
16
+ const resolvedOptions = (0, resolveAuthOptions_1.resolveAuthOptions)(options, authSchemePreference);
17
+ const authSchemes = convertHttpAuthSchemesToMap(config.httpAuthSchemes);
18
+ const smithyContext = (0, util_middleware_1.getSmithyContext)(context);
19
+ const failureReasons = [];
20
+ for (const option of resolvedOptions) {
21
+ const scheme = authSchemes.get(option.schemeId);
22
+ if (!scheme) {
23
+ failureReasons.push(`HttpAuthScheme \`${option.schemeId}\` was not enabled for this service.`);
24
+ continue;
25
+ }
26
+ const identityProvider = scheme.identityProvider(await mwOptions.identityProviderConfigProvider(config));
27
+ if (!identityProvider) {
28
+ failureReasons.push(`HttpAuthScheme \`${option.schemeId}\` did not have an IdentityProvider configured.`);
29
+ continue;
30
+ }
31
+ const { identityProperties = {}, signingProperties = {} } = option.propertiesExtractor?.(config, context) || {};
32
+ option.identityProperties = Object.assign(option.identityProperties || {}, identityProperties);
33
+ option.signingProperties = Object.assign(option.signingProperties || {}, signingProperties);
34
+ smithyContext.selectedHttpAuthScheme = {
35
+ httpAuthOption: option,
36
+ identity: await identityProvider(option.identityProperties),
37
+ signer: scheme.signer,
38
+ };
39
+ break;
40
+ }
41
+ if (!smithyContext.selectedHttpAuthScheme) {
42
+ throw new Error(failureReasons.join("\n"));
43
+ }
44
+ return next(args);
45
+ };
46
+ exports.httpAuthSchemeMiddleware = httpAuthSchemeMiddleware;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./httpAuthSchemeMiddleware"), exports);
5
+ tslib_1.__exportStar(require("./getHttpAuthSchemeEndpointRuleSetPlugin"), exports);
6
+ tslib_1.__exportStar(require("./getHttpAuthSchemePlugin"), exports);
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveAuthOptions = void 0;
4
+ const resolveAuthOptions = (candidateAuthOptions, authSchemePreference) => {
5
+ if (!authSchemePreference || authSchemePreference.length === 0) {
6
+ return candidateAuthOptions;
7
+ }
8
+ const preferredAuthOptions = [];
9
+ for (const preferredSchemeName of authSchemePreference) {
10
+ for (const candidateAuthOption of candidateAuthOptions) {
11
+ const candidateAuthSchemeName = candidateAuthOption.schemeId.split("#")[1];
12
+ if (candidateAuthSchemeName === preferredSchemeName) {
13
+ preferredAuthOptions.push(candidateAuthOption);
14
+ }
15
+ }
16
+ }
17
+ for (const candidateAuthOption of candidateAuthOptions) {
18
+ if (!preferredAuthOptions.find(({ schemeId }) => schemeId === candidateAuthOption.schemeId)) {
19
+ preferredAuthOptions.push(candidateAuthOption);
20
+ }
21
+ }
22
+ return preferredAuthOptions;
23
+ };
24
+ exports.resolveAuthOptions = resolveAuthOptions;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getHttpSigningPlugin = exports.httpSigningMiddlewareOptions = void 0;
4
+ const httpSigningMiddleware_1 = require("./httpSigningMiddleware");
5
+ exports.httpSigningMiddlewareOptions = {
6
+ step: "finalizeRequest",
7
+ tags: ["HTTP_SIGNING"],
8
+ name: "httpSigningMiddleware",
9
+ aliases: ["apiKeyMiddleware", "tokenMiddleware", "awsAuthMiddleware"],
10
+ override: true,
11
+ relation: "after",
12
+ toMiddleware: "retryMiddleware",
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,27 @@
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 util_middleware_1 = require("@smithy/util-middleware");
6
+ const defaultErrorHandler = (signingProperties) => (error) => {
7
+ throw error;
8
+ };
9
+ const defaultSuccessHandler = (httpResponse, signingProperties) => { };
10
+ const httpSigningMiddleware = (config) => (next, context) => async (args) => {
11
+ if (!protocol_http_1.HttpRequest.isInstance(args.request)) {
12
+ return next(args);
13
+ }
14
+ const smithyContext = (0, util_middleware_1.getSmithyContext)(context);
15
+ const scheme = smithyContext.selectedHttpAuthScheme;
16
+ if (!scheme) {
17
+ throw new Error(`No HttpAuthScheme was selected: unable to sign request`);
18
+ }
19
+ const { httpAuthOption: { signingProperties = {} }, identity, signer, } = scheme;
20
+ const output = await next({
21
+ ...args,
22
+ request: await signer.sign(args.request, identity, signingProperties),
23
+ }).catch((signer.errorHandler || defaultErrorHandler)(signingProperties));
24
+ (signer.successHandler || defaultSuccessHandler)(output.response, signingProperties);
25
+ return output;
26
+ };
27
+ 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,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeProvider = void 0;
4
+ const normalizeProvider = (input) => {
5
+ if (typeof input === "function")
6
+ return input;
7
+ const promisified = Promise.resolve(input);
8
+ return () => promisified;
9
+ };
10
+ exports.normalizeProvider = normalizeProvider;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createPaginator = createPaginator;
4
+ const makePagedClientRequest = async (CommandCtor, client, input, withCommand = (_) => _, ...args) => {
5
+ let command = new CommandCtor(input);
6
+ command = withCommand(command) ?? command;
7
+ return await client.send(command, ...args);
8
+ };
9
+ function createPaginator(ClientCtor, CommandCtor, inputTokenName, outputTokenName, pageSizeTokenName) {
10
+ return async function* paginateOperation(config, input, ...additionalArguments) {
11
+ const _input = input;
12
+ let token = config.startingToken ?? _input[inputTokenName];
13
+ let hasNext = true;
14
+ let page;
15
+ while (hasNext) {
16
+ _input[inputTokenName] = token;
17
+ if (pageSizeTokenName) {
18
+ _input[pageSizeTokenName] = _input[pageSizeTokenName] ?? config.pageSize;
19
+ }
20
+ if (config.client instanceof ClientCtor) {
21
+ page = await makePagedClientRequest(CommandCtor, config.client, input, config.withCommand, ...additionalArguments);
22
+ }
23
+ else {
24
+ throw new Error(`Invalid client, expected instance of ${ClientCtor.name}`);
25
+ }
26
+ yield page;
27
+ const prevToken = token;
28
+ token = get(page, outputTokenName);
29
+ hasNext = !!(token && (!config.stopOnSameToken || token !== prevToken));
30
+ }
31
+ return undefined;
32
+ };
33
+ }
34
+ const get = (fromObject, path) => {
35
+ let cursor = fromObject;
36
+ const pathComponents = path.split(".");
37
+ for (const step of pathComponents) {
38
+ if (!cursor || typeof cursor !== "object") {
39
+ return undefined;
40
+ }
41
+ cursor = cursor[step];
42
+ }
43
+ return cursor;
44
+ };
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.requestBuilder = void 0;
4
+ var protocols_1 = require("@smithy/core/protocols");
5
+ Object.defineProperty(exports, "requestBuilder", { enumerable: true, get: function () { return protocols_1.requestBuilder; } });
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setFeature = setFeature;
4
+ function setFeature(context, feature, value) {
5
+ if (!context.__smithy_context) {
6
+ context.__smithy_context = {
7
+ features: {},
8
+ };
9
+ }
10
+ else if (!context.__smithy_context.features) {
11
+ context.__smithy_context.features = {};
12
+ }
13
+ context.__smithy_context.features[feature] = value;
14
+ }
@@ -166,9 +166,7 @@ class HttpProtocol extends SerdeContext {
166
166
 
167
167
  class HttpBindingProtocol extends HttpProtocol {
168
168
  async serializeRequest(operationSchema, _input, context) {
169
- const input = {
170
- ...(_input ?? {}),
171
- };
169
+ const input = _input && typeof _input === "object" ? _input : {};
172
170
  const serializer = this.serializer;
173
171
  const query = {};
174
172
  const headers = {};
@@ -236,7 +234,6 @@ class HttpBindingProtocol extends HttpProtocol {
236
234
  serializer.write(memberNs, inputMemberValue);
237
235
  payload = serializer.flush();
238
236
  }
239
- delete input[memberName];
240
237
  }
241
238
  else if (memberTraits.httpLabel) {
242
239
  serializer.write(memberNs, inputMemberValue);
@@ -247,12 +244,10 @@ class HttpBindingProtocol extends HttpProtocol {
247
244
  else if (request.path.includes(`{${memberName}}`)) {
248
245
  request.path = request.path.replace(`{${memberName}}`, extendedEncodeURIComponent(replacement));
249
246
  }
250
- delete input[memberName];
251
247
  }
252
248
  else if (memberTraits.httpHeader) {
253
249
  serializer.write(memberNs, inputMemberValue);
254
250
  headers[memberTraits.httpHeader.toLowerCase()] = String(serializer.flush());
255
- delete input[memberName];
256
251
  }
257
252
  else if (typeof memberTraits.httpPrefixHeaders === "string") {
258
253
  for (const [key, val] of Object.entries(inputMemberValue)) {
@@ -260,11 +255,9 @@ class HttpBindingProtocol extends HttpProtocol {
260
255
  serializer.write([memberNs.getValueSchema(), { httpHeader: amalgam }], val);
261
256
  headers[amalgam.toLowerCase()] = serializer.flush();
262
257
  }
263
- delete input[memberName];
264
258
  }
265
259
  else if (memberTraits.httpQuery || memberTraits.httpQueryParams) {
266
260
  this.serializeQuery(memberNs, inputMemberValue, query);
267
- delete input[memberName];
268
261
  }
269
262
  else {
270
263
  hasNonHttpBindingMember = true;
@@ -452,7 +445,7 @@ class HttpBindingProtocol extends HttpProtocol {
452
445
  }
453
446
 
454
447
  class RpcProtocol extends HttpProtocol {
455
- async serializeRequest(operationSchema, input, context) {
448
+ async serializeRequest(operationSchema, _input, context) {
456
449
  const serializer = this.serializer;
457
450
  const query = {};
458
451
  const headers = {};
@@ -460,6 +453,7 @@ class RpcProtocol extends HttpProtocol {
460
453
  const ns = schema.NormalizedSchema.of(operationSchema?.input);
461
454
  const schema$1 = ns.getSchema();
462
455
  let payload;
456
+ const input = _input && typeof _input === "object" ? _input : {};
463
457
  const request = new protocolHttp.HttpRequest({
464
458
  protocol: "",
465
459
  hostname: "",
@@ -474,29 +468,26 @@ class RpcProtocol extends HttpProtocol {
474
468
  this.updateServiceEndpoint(request, endpoint);
475
469
  this.setHostPrefix(request, operationSchema, input);
476
470
  }
477
- const _input = {
478
- ...input,
479
- };
480
471
  if (input) {
481
472
  const eventStreamMember = ns.getEventStreamMember();
482
473
  if (eventStreamMember) {
483
- if (_input[eventStreamMember]) {
474
+ if (input[eventStreamMember]) {
484
475
  const initialRequest = {};
485
476
  for (const [memberName, memberSchema] of ns.structIterator()) {
486
- if (memberName !== eventStreamMember && _input[memberName]) {
487
- serializer.write(memberSchema, _input[memberName]);
477
+ if (memberName !== eventStreamMember && input[memberName]) {
478
+ serializer.write(memberSchema, input[memberName]);
488
479
  initialRequest[memberName] = serializer.flush();
489
480
  }
490
481
  }
491
482
  payload = await this.serializeEventStream({
492
- eventStream: _input[eventStreamMember],
483
+ eventStream: input[eventStreamMember],
493
484
  requestSchema: ns,
494
485
  initialRequest,
495
486
  });
496
487
  }
497
488
  }
498
489
  else {
499
- serializer.write(schema$1, _input);
490
+ serializer.write(schema$1, input);
500
491
  payload = serializer.flush();
501
492
  }
502
493
  }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DefaultIdentityProviderConfig = void 0;
4
+ class DefaultIdentityProviderConfig {
5
+ authSchemes = new Map();
6
+ constructor(config) {
7
+ for (const [key, value] of Object.entries(config)) {
8
+ if (value !== undefined) {
9
+ this.authSchemes.set(key, value);
10
+ }
11
+ }
12
+ }
13
+ getIdentityProvider(schemeId) {
14
+ return this.authSchemes.get(schemeId);
15
+ }
16
+ }
17
+ exports.DefaultIdentityProviderConfig = DefaultIdentityProviderConfig;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HttpApiKeyAuthSigner = void 0;
4
+ const protocol_http_1 = require("@smithy/protocol-http");
5
+ const types_1 = require("@smithy/types");
6
+ class HttpApiKeyAuthSigner {
7
+ async sign(httpRequest, identity, signingProperties) {
8
+ if (!signingProperties) {
9
+ throw new Error("request could not be signed with `apiKey` since the `name` and `in` signer properties are missing");
10
+ }
11
+ if (!signingProperties.name) {
12
+ throw new Error("request could not be signed with `apiKey` since the `name` signer property is missing");
13
+ }
14
+ if (!signingProperties.in) {
15
+ throw new Error("request could not be signed with `apiKey` since the `in` signer property is missing");
16
+ }
17
+ if (!identity.apiKey) {
18
+ throw new Error("request could not be signed with `apiKey` since the `apiKey` is not defined");
19
+ }
20
+ const clonedRequest = protocol_http_1.HttpRequest.clone(httpRequest);
21
+ if (signingProperties.in === types_1.HttpApiKeyAuthLocation.QUERY) {
22
+ clonedRequest.query[signingProperties.name] = identity.apiKey;
23
+ }
24
+ else if (signingProperties.in === types_1.HttpApiKeyAuthLocation.HEADER) {
25
+ clonedRequest.headers[signingProperties.name] = signingProperties.scheme
26
+ ? `${signingProperties.scheme} ${identity.apiKey}`
27
+ : identity.apiKey;
28
+ }
29
+ else {
30
+ throw new Error("request can only be signed with `apiKey` locations `query` or `header`, " +
31
+ "but found: `" +
32
+ signingProperties.in +
33
+ "`");
34
+ }
35
+ return clonedRequest;
36
+ }
37
+ }
38
+ exports.HttpApiKeyAuthSigner = HttpApiKeyAuthSigner;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HttpBearerAuthSigner = void 0;
4
+ const protocol_http_1 = require("@smithy/protocol-http");
5
+ class HttpBearerAuthSigner {
6
+ async sign(httpRequest, identity, signingProperties) {
7
+ const clonedRequest = protocol_http_1.HttpRequest.clone(httpRequest);
8
+ if (!identity.token) {
9
+ throw new Error("request could not be signed with `token` since the `token` is not defined");
10
+ }
11
+ clonedRequest.headers["Authorization"] = `Bearer ${identity.token}`;
12
+ return clonedRequest;
13
+ }
14
+ }
15
+ exports.HttpBearerAuthSigner = HttpBearerAuthSigner;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./httpApiKeyAuth"), exports);
5
+ tslib_1.__exportStar(require("./httpBearerAuth"), exports);
6
+ tslib_1.__exportStar(require("./noAuth"), exports);
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NoAuthSigner = void 0;
4
+ class NoAuthSigner {
5
+ async sign(httpRequest, identity, signingProperties) {
6
+ return httpRequest;
7
+ }
8
+ }
9
+ exports.NoAuthSigner = NoAuthSigner;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./DefaultIdentityProviderConfig"), exports);
5
+ tslib_1.__exportStar(require("./httpAuthSchemes"), exports);
6
+ tslib_1.__exportStar(require("./memoizeIdentityProvider"), exports);
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.memoizeIdentityProvider = exports.doesIdentityRequireRefresh = exports.isIdentityExpired = exports.EXPIRATION_MS = exports.createIsIdentityExpiredFunction = void 0;
4
+ const createIsIdentityExpiredFunction = (expirationMs) => function isIdentityExpired(identity) {
5
+ return (0, exports.doesIdentityRequireRefresh)(identity) && identity.expiration.getTime() - Date.now() < expirationMs;
6
+ };
7
+ exports.createIsIdentityExpiredFunction = createIsIdentityExpiredFunction;
8
+ exports.EXPIRATION_MS = 300_000;
9
+ exports.isIdentityExpired = (0, exports.createIsIdentityExpiredFunction)(exports.EXPIRATION_MS);
10
+ const doesIdentityRequireRefresh = (identity) => identity.expiration !== undefined;
11
+ exports.doesIdentityRequireRefresh = doesIdentityRequireRefresh;
12
+ const memoizeIdentityProvider = (provider, isExpired, requiresRefresh) => {
13
+ if (provider === undefined) {
14
+ return undefined;
15
+ }
16
+ const normalizedProvider = typeof provider !== "function" ? async () => Promise.resolve(provider) : provider;
17
+ let resolved;
18
+ let pending;
19
+ let hasResult;
20
+ let isConstant = false;
21
+ const coalesceProvider = async (options) => {
22
+ if (!pending) {
23
+ pending = normalizedProvider(options);
24
+ }
25
+ try {
26
+ resolved = await pending;
27
+ hasResult = true;
28
+ isConstant = false;
29
+ }
30
+ finally {
31
+ pending = undefined;
32
+ }
33
+ return resolved;
34
+ };
35
+ if (isExpired === undefined) {
36
+ return async (options) => {
37
+ if (!hasResult || options?.forceRefresh) {
38
+ resolved = await coalesceProvider(options);
39
+ }
40
+ return resolved;
41
+ };
42
+ }
43
+ return async (options) => {
44
+ if (!hasResult || options?.forceRefresh) {
45
+ resolved = await coalesceProvider(options);
46
+ }
47
+ if (isConstant) {
48
+ return resolved;
49
+ }
50
+ if (!requiresRefresh(resolved)) {
51
+ isConstant = true;
52
+ return resolved;
53
+ }
54
+ if (isExpired(resolved)) {
55
+ await coalesceProvider(options);
56
+ return resolved;
57
+ }
58
+ return resolved;
59
+ };
60
+ };
61
+ exports.memoizeIdentityProvider = memoizeIdentityProvider;
@@ -7,9 +7,7 @@ import { extendedEncodeURIComponent } from "./extended-encode-uri-component";
7
7
  import { HttpProtocol } from "./HttpProtocol";
8
8
  export class HttpBindingProtocol extends HttpProtocol {
9
9
  async serializeRequest(operationSchema, _input, context) {
10
- const input = {
11
- ...(_input ?? {}),
12
- };
10
+ const input = _input && typeof _input === "object" ? _input : {};
13
11
  const serializer = this.serializer;
14
12
  const query = {};
15
13
  const headers = {};
@@ -77,7 +75,6 @@ export class HttpBindingProtocol extends HttpProtocol {
77
75
  serializer.write(memberNs, inputMemberValue);
78
76
  payload = serializer.flush();
79
77
  }
80
- delete input[memberName];
81
78
  }
82
79
  else if (memberTraits.httpLabel) {
83
80
  serializer.write(memberNs, inputMemberValue);
@@ -88,12 +85,10 @@ export class HttpBindingProtocol extends HttpProtocol {
88
85
  else if (request.path.includes(`{${memberName}}`)) {
89
86
  request.path = request.path.replace(`{${memberName}}`, extendedEncodeURIComponent(replacement));
90
87
  }
91
- delete input[memberName];
92
88
  }
93
89
  else if (memberTraits.httpHeader) {
94
90
  serializer.write(memberNs, inputMemberValue);
95
91
  headers[memberTraits.httpHeader.toLowerCase()] = String(serializer.flush());
96
- delete input[memberName];
97
92
  }
98
93
  else if (typeof memberTraits.httpPrefixHeaders === "string") {
99
94
  for (const [key, val] of Object.entries(inputMemberValue)) {
@@ -101,11 +96,9 @@ export class HttpBindingProtocol extends HttpProtocol {
101
96
  serializer.write([memberNs.getValueSchema(), { httpHeader: amalgam }], val);
102
97
  headers[amalgam.toLowerCase()] = serializer.flush();
103
98
  }
104
- delete input[memberName];
105
99
  }
106
100
  else if (memberTraits.httpQuery || memberTraits.httpQueryParams) {
107
101
  this.serializeQuery(memberNs, inputMemberValue, query);
108
- delete input[memberName];
109
102
  }
110
103
  else {
111
104
  hasNonHttpBindingMember = true;
@@ -3,7 +3,7 @@ import { HttpRequest } from "@smithy/protocol-http";
3
3
  import { collectBody } from "./collect-stream-body";
4
4
  import { HttpProtocol } from "./HttpProtocol";
5
5
  export class RpcProtocol extends HttpProtocol {
6
- async serializeRequest(operationSchema, input, context) {
6
+ async serializeRequest(operationSchema, _input, context) {
7
7
  const serializer = this.serializer;
8
8
  const query = {};
9
9
  const headers = {};
@@ -11,6 +11,7 @@ export class RpcProtocol extends HttpProtocol {
11
11
  const ns = NormalizedSchema.of(operationSchema?.input);
12
12
  const schema = ns.getSchema();
13
13
  let payload;
14
+ const input = _input && typeof _input === "object" ? _input : {};
14
15
  const request = new HttpRequest({
15
16
  protocol: "",
16
17
  hostname: "",
@@ -25,29 +26,26 @@ export class RpcProtocol extends HttpProtocol {
25
26
  this.updateServiceEndpoint(request, endpoint);
26
27
  this.setHostPrefix(request, operationSchema, input);
27
28
  }
28
- const _input = {
29
- ...input,
30
- };
31
29
  if (input) {
32
30
  const eventStreamMember = ns.getEventStreamMember();
33
31
  if (eventStreamMember) {
34
- if (_input[eventStreamMember]) {
32
+ if (input[eventStreamMember]) {
35
33
  const initialRequest = {};
36
34
  for (const [memberName, memberSchema] of ns.structIterator()) {
37
- if (memberName !== eventStreamMember && _input[memberName]) {
38
- serializer.write(memberSchema, _input[memberName]);
35
+ if (memberName !== eventStreamMember && input[memberName]) {
36
+ serializer.write(memberSchema, input[memberName]);
39
37
  initialRequest[memberName] = serializer.flush();
40
38
  }
41
39
  }
42
40
  payload = await this.serializeEventStream({
43
- eventStream: _input[eventStreamMember],
41
+ eventStream: input[eventStreamMember],
44
42
  requestSchema: ns,
45
43
  initialRequest,
46
44
  });
47
45
  }
48
46
  }
49
47
  else {
50
- serializer.write(schema, _input);
48
+ serializer.write(schema, input);
51
49
  payload = serializer.flush();
52
50
  }
53
51
  }