Add/update filtered-sum-bms benchmark

This commit is contained in:
2026-06-06 18:00:20 +00:00
parent 2944683db9
commit 260d5fa4a5
8045 changed files with 2651026 additions and 270206 deletions

201
spot-launcher/node_modules/@smithy/core/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

45
spot-launcher/node_modules/@smithy/core/README.md generated vendored Normal file
View File

@@ -0,0 +1,45 @@
# @smithy/core
[![NPM version](https://img.shields.io/npm/v/@smithy/core/latest.svg)](https://www.npmjs.com/package/@smithy/core)
[![NPM downloads](https://img.shields.io/npm/dm/@smithy/core.svg)](https://www.npmjs.com/package/@smithy/core)
> An internal package. You probably shouldn't use this package, at least directly.
This package provides common or core functionality for generic Smithy clients.
You do not need to explicitly install this package, since it will be installed during code generation if used.
## Development of `@smithy/core` submodules
Core submodules are organized for distribution via the `package.json` `exports` field.
`exports` is supported by default by the latest Node.js, webpack, and esbuild. For react-native, it can be
enabled via instructions found at [reactnative.dev/blog](https://reactnative.dev/blog/2023/06/21/package-exports-support), but we also provide a compatibility redirect.
Think of `@smithy/core` as a mono-package within the monorepo.
It preserves the benefits of modularization, for example to optimize Node.js initialization speed,
while making it easier to have a consistent version of core dependencies, reducing package sprawl when
installing a Smithy runtime client.
### Guide for submodules
- Each `index.ts` file corresponding to the pattern `./src/submodules/<MODULE_NAME>/index.ts` will be
published as a separate `dist-cjs` bundled submodule index using the `Inliner.js` build script.
- create a folder as `./src/submodules/<SUBMODULE>` including an `index.ts` file and a `README.md` file.
- The linter will throw an error on missing submodule metadata in `package.json` and the various `tsconfig.json` files, but it will automatically fix them if possible.
- a submodule is equivalent to a standalone `@smithy/<pkg>` package in that importing it in Node.js will resolve a separate bundle.
- submodules may not relatively import files from other submodules. Instead, directly use the `@scope/pkg/submodule` name as the import.
- The linter will check for this and throw an error.
- To the extent possible, correctly declaring submodule metadata is validated by the linter in `@smithy/core`.
The linter runs during `yarn build` and also as `yarn lint`.
### When should I create an `@smithy/core/submodule` vs. `@smithy/new-package`?
Keep in mind that the core package is installed by all downstream clients.
If the component functionality is upstream of multiple clients, it is
a good candidate for a core submodule. For example, if `middleware-retry` had been written
after the support for submodules was added, it would have been a submodule.
If the component's functionality is downstream of a client (rare), or only expected to be used by a very small
subset of clients, it could be written as a standalone package.

7
spot-launcher/node_modules/@smithy/core/cbor.d.ts generated vendored Normal file
View File

@@ -0,0 +1,7 @@
/**
* Do not edit:
* This is a compatibility redirect for contexts that do not understand package.json exports field.
*/
declare module "@smithy/core/cbor" {
export * from "@smithy/core/dist-types/submodules/cbor/index.d";
}

6
spot-launcher/node_modules/@smithy/core/cbor.js generated vendored Normal file
View File

@@ -0,0 +1,6 @@
/**
* Do not edit:
* This is a compatibility redirect for contexts that do not understand package.json exports field.
*/
module.exports = require("./dist-cjs/submodules/cbor/index.js");

View File

@@ -0,0 +1 @@
module.exports = require("./index.js");

View File

@@ -0,0 +1,454 @@
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/index.ts
var src_exports = {};
__export(src_exports, {
DefaultIdentityProviderConfig: () => DefaultIdentityProviderConfig,
EXPIRATION_MS: () => EXPIRATION_MS,
HttpApiKeyAuthSigner: () => HttpApiKeyAuthSigner,
HttpBearerAuthSigner: () => HttpBearerAuthSigner,
NoAuthSigner: () => NoAuthSigner,
createIsIdentityExpiredFunction: () => createIsIdentityExpiredFunction,
createPaginator: () => createPaginator,
doesIdentityRequireRefresh: () => doesIdentityRequireRefresh,
getHttpAuthSchemeEndpointRuleSetPlugin: () => getHttpAuthSchemeEndpointRuleSetPlugin,
getHttpAuthSchemePlugin: () => getHttpAuthSchemePlugin,
getHttpSigningPlugin: () => getHttpSigningPlugin,
getSmithyContext: () => getSmithyContext,
httpAuthSchemeEndpointRuleSetMiddlewareOptions: () => httpAuthSchemeEndpointRuleSetMiddlewareOptions,
httpAuthSchemeMiddleware: () => httpAuthSchemeMiddleware,
httpAuthSchemeMiddlewareOptions: () => httpAuthSchemeMiddlewareOptions,
httpSigningMiddleware: () => httpSigningMiddleware,
httpSigningMiddlewareOptions: () => httpSigningMiddlewareOptions,
isIdentityExpired: () => isIdentityExpired,
memoizeIdentityProvider: () => memoizeIdentityProvider,
normalizeProvider: () => normalizeProvider,
requestBuilder: () => import_protocols.requestBuilder,
setFeature: () => setFeature
});
module.exports = __toCommonJS(src_exports);
// src/getSmithyContext.ts
var import_types = require("@smithy/types");
var getSmithyContext = /* @__PURE__ */ __name((context) => context[import_types.SMITHY_CONTEXT_KEY] || (context[import_types.SMITHY_CONTEXT_KEY] = {}), "getSmithyContext");
// src/middleware-http-auth-scheme/httpAuthSchemeMiddleware.ts
var import_util_middleware = require("@smithy/util-middleware");
// src/middleware-http-auth-scheme/resolveAuthOptions.ts
var resolveAuthOptions = /* @__PURE__ */ __name((candidateAuthOptions, authSchemePreference) => {
if (!authSchemePreference || authSchemePreference.length === 0) {
return candidateAuthOptions;
}
const preferredAuthOptions = [];
for (const preferredSchemeName of authSchemePreference) {
for (const candidateAuthOption of candidateAuthOptions) {
const candidateAuthSchemeName = candidateAuthOption.schemeId.split("#")[1];
if (candidateAuthSchemeName === preferredSchemeName) {
preferredAuthOptions.push(candidateAuthOption);
}
}
}
for (const candidateAuthOption of candidateAuthOptions) {
if (!preferredAuthOptions.find(({ schemeId }) => schemeId === candidateAuthOption.schemeId)) {
preferredAuthOptions.push(candidateAuthOption);
}
}
return preferredAuthOptions;
}, "resolveAuthOptions");
// src/middleware-http-auth-scheme/httpAuthSchemeMiddleware.ts
function convertHttpAuthSchemesToMap(httpAuthSchemes) {
const map = /* @__PURE__ */ new Map();
for (const scheme of httpAuthSchemes) {
map.set(scheme.schemeId, scheme);
}
return map;
}
__name(convertHttpAuthSchemesToMap, "convertHttpAuthSchemesToMap");
var httpAuthSchemeMiddleware = /* @__PURE__ */ __name((config, mwOptions) => (next, context) => async (args) => {
const options = config.httpAuthSchemeProvider(
await mwOptions.httpAuthSchemeParametersProvider(config, context, args.input)
);
const authSchemePreference = config.authSchemePreference ? await config.authSchemePreference() : [];
const resolvedOptions = resolveAuthOptions(options, authSchemePreference);
const authSchemes = convertHttpAuthSchemesToMap(config.httpAuthSchemes);
const smithyContext = (0, import_util_middleware.getSmithyContext)(context);
const failureReasons = [];
for (const option of resolvedOptions) {
const scheme = authSchemes.get(option.schemeId);
if (!scheme) {
failureReasons.push(`HttpAuthScheme \`${option.schemeId}\` was not enabled for this service.`);
continue;
}
const identityProvider = scheme.identityProvider(await mwOptions.identityProviderConfigProvider(config));
if (!identityProvider) {
failureReasons.push(`HttpAuthScheme \`${option.schemeId}\` did not have an IdentityProvider configured.`);
continue;
}
const { identityProperties = {}, signingProperties = {} } = option.propertiesExtractor?.(config, context) || {};
option.identityProperties = Object.assign(option.identityProperties || {}, identityProperties);
option.signingProperties = Object.assign(option.signingProperties || {}, signingProperties);
smithyContext.selectedHttpAuthScheme = {
httpAuthOption: option,
identity: await identityProvider(option.identityProperties),
signer: scheme.signer
};
break;
}
if (!smithyContext.selectedHttpAuthScheme) {
throw new Error(failureReasons.join("\n"));
}
return next(args);
}, "httpAuthSchemeMiddleware");
// src/middleware-http-auth-scheme/getHttpAuthSchemeEndpointRuleSetPlugin.ts
var httpAuthSchemeEndpointRuleSetMiddlewareOptions = {
step: "serialize",
tags: ["HTTP_AUTH_SCHEME"],
name: "httpAuthSchemeMiddleware",
override: true,
relation: "before",
toMiddleware: "endpointV2Middleware"
};
var getHttpAuthSchemeEndpointRuleSetPlugin = /* @__PURE__ */ __name((config, {
httpAuthSchemeParametersProvider,
identityProviderConfigProvider
}) => ({
applyToStack: (clientStack) => {
clientStack.addRelativeTo(
httpAuthSchemeMiddleware(config, {
httpAuthSchemeParametersProvider,
identityProviderConfigProvider
}),
httpAuthSchemeEndpointRuleSetMiddlewareOptions
);
}
}), "getHttpAuthSchemeEndpointRuleSetPlugin");
// src/middleware-http-auth-scheme/getHttpAuthSchemePlugin.ts
var import_middleware_serde = require("@smithy/middleware-serde");
var httpAuthSchemeMiddlewareOptions = {
step: "serialize",
tags: ["HTTP_AUTH_SCHEME"],
name: "httpAuthSchemeMiddleware",
override: true,
relation: "before",
toMiddleware: import_middleware_serde.serializerMiddlewareOption.name
};
var getHttpAuthSchemePlugin = /* @__PURE__ */ __name((config, {
httpAuthSchemeParametersProvider,
identityProviderConfigProvider
}) => ({
applyToStack: (clientStack) => {
clientStack.addRelativeTo(
httpAuthSchemeMiddleware(config, {
httpAuthSchemeParametersProvider,
identityProviderConfigProvider
}),
httpAuthSchemeMiddlewareOptions
);
}
}), "getHttpAuthSchemePlugin");
// src/middleware-http-signing/httpSigningMiddleware.ts
var import_protocol_http = require("@smithy/protocol-http");
var defaultErrorHandler = /* @__PURE__ */ __name((signingProperties) => (error) => {
throw error;
}, "defaultErrorHandler");
var defaultSuccessHandler = /* @__PURE__ */ __name((httpResponse, signingProperties) => {
}, "defaultSuccessHandler");
var httpSigningMiddleware = /* @__PURE__ */ __name((config) => (next, context) => async (args) => {
if (!import_protocol_http.HttpRequest.isInstance(args.request)) {
return next(args);
}
const smithyContext = (0, import_util_middleware.getSmithyContext)(context);
const scheme = smithyContext.selectedHttpAuthScheme;
if (!scheme) {
throw new Error(`No HttpAuthScheme was selected: unable to sign request`);
}
const {
httpAuthOption: { signingProperties = {} },
identity,
signer
} = scheme;
const output = await next({
...args,
request: await signer.sign(args.request, identity, signingProperties)
}).catch((signer.errorHandler || defaultErrorHandler)(signingProperties));
(signer.successHandler || defaultSuccessHandler)(output.response, signingProperties);
return output;
}, "httpSigningMiddleware");
// src/middleware-http-signing/getHttpSigningMiddleware.ts
var httpSigningMiddlewareOptions = {
step: "finalizeRequest",
tags: ["HTTP_SIGNING"],
name: "httpSigningMiddleware",
aliases: ["apiKeyMiddleware", "tokenMiddleware", "awsAuthMiddleware"],
override: true,
relation: "after",
toMiddleware: "retryMiddleware"
};
var getHttpSigningPlugin = /* @__PURE__ */ __name((config) => ({
applyToStack: (clientStack) => {
clientStack.addRelativeTo(httpSigningMiddleware(config), httpSigningMiddlewareOptions);
}
}), "getHttpSigningPlugin");
// src/normalizeProvider.ts
var normalizeProvider = /* @__PURE__ */ __name((input) => {
if (typeof input === "function")
return input;
const promisified = Promise.resolve(input);
return () => promisified;
}, "normalizeProvider");
// src/pagination/createPaginator.ts
var makePagedClientRequest = /* @__PURE__ */ __name(async (CommandCtor, client, input, withCommand = (_) => _, ...args) => {
let command = new CommandCtor(input);
command = withCommand(command) ?? command;
return await client.send(command, ...args);
}, "makePagedClientRequest");
function createPaginator(ClientCtor, CommandCtor, inputTokenName, outputTokenName, pageSizeTokenName) {
return /* @__PURE__ */ __name(async function* paginateOperation(config, input, ...additionalArguments) {
const _input = input;
let token = config.startingToken ?? _input[inputTokenName];
let hasNext = true;
let page;
while (hasNext) {
_input[inputTokenName] = token;
if (pageSizeTokenName) {
_input[pageSizeTokenName] = _input[pageSizeTokenName] ?? config.pageSize;
}
if (config.client instanceof ClientCtor) {
page = await makePagedClientRequest(
CommandCtor,
config.client,
input,
config.withCommand,
...additionalArguments
);
} else {
throw new Error(`Invalid client, expected instance of ${ClientCtor.name}`);
}
yield page;
const prevToken = token;
token = get(page, outputTokenName);
hasNext = !!(token && (!config.stopOnSameToken || token !== prevToken));
}
return void 0;
}, "paginateOperation");
}
__name(createPaginator, "createPaginator");
var get = /* @__PURE__ */ __name((fromObject, path) => {
let cursor = fromObject;
const pathComponents = path.split(".");
for (const step of pathComponents) {
if (!cursor || typeof cursor !== "object") {
return void 0;
}
cursor = cursor[step];
}
return cursor;
}, "get");
// src/protocols/requestBuilder.ts
var import_protocols = require("@smithy/core/protocols");
// src/setFeature.ts
function setFeature(context, feature, value) {
if (!context.__smithy_context) {
context.__smithy_context = {
features: {}
};
} else if (!context.__smithy_context.features) {
context.__smithy_context.features = {};
}
context.__smithy_context.features[feature] = value;
}
__name(setFeature, "setFeature");
// src/util-identity-and-auth/DefaultIdentityProviderConfig.ts
var DefaultIdentityProviderConfig = class {
/**
* Creates an IdentityProviderConfig with a record of scheme IDs to identity providers.
*
* @param config scheme IDs and identity providers to configure
*/
constructor(config) {
this.authSchemes = /* @__PURE__ */ new Map();
for (const [key, value] of Object.entries(config)) {
if (value !== void 0) {
this.authSchemes.set(key, value);
}
}
}
static {
__name(this, "DefaultIdentityProviderConfig");
}
getIdentityProvider(schemeId) {
return this.authSchemes.get(schemeId);
}
};
// src/util-identity-and-auth/httpAuthSchemes/httpApiKeyAuth.ts
var HttpApiKeyAuthSigner = class {
static {
__name(this, "HttpApiKeyAuthSigner");
}
async sign(httpRequest, identity, signingProperties) {
if (!signingProperties) {
throw new Error(
"request could not be signed with `apiKey` since the `name` and `in` signer properties are missing"
);
}
if (!signingProperties.name) {
throw new Error("request could not be signed with `apiKey` since the `name` signer property is missing");
}
if (!signingProperties.in) {
throw new Error("request could not be signed with `apiKey` since the `in` signer property is missing");
}
if (!identity.apiKey) {
throw new Error("request could not be signed with `apiKey` since the `apiKey` is not defined");
}
const clonedRequest = import_protocol_http.HttpRequest.clone(httpRequest);
if (signingProperties.in === import_types.HttpApiKeyAuthLocation.QUERY) {
clonedRequest.query[signingProperties.name] = identity.apiKey;
} else if (signingProperties.in === import_types.HttpApiKeyAuthLocation.HEADER) {
clonedRequest.headers[signingProperties.name] = signingProperties.scheme ? `${signingProperties.scheme} ${identity.apiKey}` : identity.apiKey;
} else {
throw new Error(
"request can only be signed with `apiKey` locations `query` or `header`, but found: `" + signingProperties.in + "`"
);
}
return clonedRequest;
}
};
// src/util-identity-and-auth/httpAuthSchemes/httpBearerAuth.ts
var HttpBearerAuthSigner = class {
static {
__name(this, "HttpBearerAuthSigner");
}
async sign(httpRequest, identity, signingProperties) {
const clonedRequest = import_protocol_http.HttpRequest.clone(httpRequest);
if (!identity.token) {
throw new Error("request could not be signed with `token` since the `token` is not defined");
}
clonedRequest.headers["Authorization"] = `Bearer ${identity.token}`;
return clonedRequest;
}
};
// src/util-identity-and-auth/httpAuthSchemes/noAuth.ts
var NoAuthSigner = class {
static {
__name(this, "NoAuthSigner");
}
async sign(httpRequest, identity, signingProperties) {
return httpRequest;
}
};
// src/util-identity-and-auth/memoizeIdentityProvider.ts
var createIsIdentityExpiredFunction = /* @__PURE__ */ __name((expirationMs) => (identity) => doesIdentityRequireRefresh(identity) && identity.expiration.getTime() - Date.now() < expirationMs, "createIsIdentityExpiredFunction");
var EXPIRATION_MS = 3e5;
var isIdentityExpired = createIsIdentityExpiredFunction(EXPIRATION_MS);
var doesIdentityRequireRefresh = /* @__PURE__ */ __name((identity) => identity.expiration !== void 0, "doesIdentityRequireRefresh");
var memoizeIdentityProvider = /* @__PURE__ */ __name((provider, isExpired, requiresRefresh) => {
if (provider === void 0) {
return void 0;
}
const normalizedProvider = typeof provider !== "function" ? async () => Promise.resolve(provider) : provider;
let resolved;
let pending;
let hasResult;
let isConstant = false;
const coalesceProvider = /* @__PURE__ */ __name(async (options) => {
if (!pending) {
pending = normalizedProvider(options);
}
try {
resolved = await pending;
hasResult = true;
isConstant = false;
} finally {
pending = void 0;
}
return resolved;
}, "coalesceProvider");
if (isExpired === void 0) {
return async (options) => {
if (!hasResult || options?.forceRefresh) {
resolved = await coalesceProvider(options);
}
return resolved;
};
}
return async (options) => {
if (!hasResult || options?.forceRefresh) {
resolved = await coalesceProvider(options);
}
if (isConstant) {
return resolved;
}
if (!requiresRefresh(resolved)) {
isConstant = true;
return resolved;
}
if (isExpired(resolved)) {
await coalesceProvider(options);
return resolved;
}
return resolved;
};
}, "memoizeIdentityProvider");
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
createPaginator,
getSmithyContext,
httpAuthSchemeMiddleware,
httpAuthSchemeEndpointRuleSetMiddlewareOptions,
getHttpAuthSchemeEndpointRuleSetPlugin,
httpAuthSchemeMiddlewareOptions,
getHttpAuthSchemePlugin,
httpSigningMiddleware,
httpSigningMiddlewareOptions,
getHttpSigningPlugin,
normalizeProvider,
requestBuilder,
setFeature,
DefaultIdentityProviderConfig,
HttpApiKeyAuthSigner,
HttpBearerAuthSigner,
NoAuthSigner,
createIsIdentityExpiredFunction,
EXPIRATION_MS,
isIdentityExpired,
doesIdentityRequireRefresh,
memoizeIdentityProvider
});

View File

@@ -0,0 +1 @@
module.exports = require("../index.js");

View File

@@ -0,0 +1 @@
module.exports = require("../index.js");

View File

@@ -0,0 +1 @@
module.exports = require("../index.js");

View File

@@ -0,0 +1 @@
module.exports = require("../index.js");

View File

@@ -0,0 +1 @@
module.exports = require("../index.js");

View File

@@ -0,0 +1 @@
module.exports = require("../index.js");

View File

@@ -0,0 +1 @@
module.exports = require("../index.js");

View File

@@ -0,0 +1 @@
module.exports = require("../index.js");

View File

@@ -0,0 +1 @@
module.exports = require("./index.js");

View File

@@ -0,0 +1 @@
module.exports = require("../index.js");

View File

@@ -0,0 +1 @@
module.exports = require("../index.js");

View File

@@ -0,0 +1 @@
module.exports = require("./index.js");

View File

@@ -0,0 +1,733 @@
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/submodules/cbor/index.ts
var cbor_exports = {};
__export(cbor_exports, {
buildHttpRpcRequest: () => buildHttpRpcRequest,
cbor: () => cbor,
checkCborResponse: () => checkCborResponse,
dateToTag: () => dateToTag,
loadSmithyRpcV2CborErrorCode: () => loadSmithyRpcV2CborErrorCode,
parseCborBody: () => parseCborBody,
parseCborErrorBody: () => parseCborErrorBody,
tag: () => tag,
tagSymbol: () => tagSymbol
});
module.exports = __toCommonJS(cbor_exports);
// src/submodules/cbor/cbor-decode.ts
var import_util_utf8 = require("@smithy/util-utf8");
// src/submodules/cbor/cbor-types.ts
var majorUint64 = 0;
var majorNegativeInt64 = 1;
var majorUnstructuredByteString = 2;
var majorUtf8String = 3;
var majorList = 4;
var majorMap = 5;
var majorTag = 6;
var majorSpecial = 7;
var specialFalse = 20;
var specialTrue = 21;
var specialNull = 22;
var specialUndefined = 23;
var extendedOneByte = 24;
var extendedFloat16 = 25;
var extendedFloat32 = 26;
var extendedFloat64 = 27;
var minorIndefinite = 31;
function alloc(size) {
return typeof Buffer !== "undefined" ? Buffer.alloc(size) : new Uint8Array(size);
}
var tagSymbol = Symbol("@smithy/core/cbor::tagSymbol");
function tag(data2) {
data2[tagSymbol] = true;
return data2;
}
// src/submodules/cbor/cbor-decode.ts
var USE_TEXT_DECODER = typeof TextDecoder !== "undefined";
var USE_BUFFER = typeof Buffer !== "undefined";
var payload = alloc(0);
var dataView = new DataView(payload.buffer, payload.byteOffset, payload.byteLength);
var textDecoder = USE_TEXT_DECODER ? new TextDecoder() : null;
var _offset = 0;
function setPayload(bytes) {
payload = bytes;
dataView = new DataView(payload.buffer, payload.byteOffset, payload.byteLength);
}
function decode(at, to) {
if (at >= to) {
throw new Error("unexpected end of (decode) payload.");
}
const major = (payload[at] & 224) >> 5;
const minor = payload[at] & 31;
switch (major) {
case majorUint64:
case majorNegativeInt64:
case majorTag:
let unsignedInt;
let offset;
if (minor < 24) {
unsignedInt = minor;
offset = 1;
} else {
switch (minor) {
case extendedOneByte:
case extendedFloat16:
case extendedFloat32:
case extendedFloat64:
const countLength = minorValueToArgumentLength[minor];
const countOffset = countLength + 1;
offset = countOffset;
if (to - at < countOffset) {
throw new Error(`countLength ${countLength} greater than remaining buf len.`);
}
const countIndex = at + 1;
if (countLength === 1) {
unsignedInt = payload[countIndex];
} else if (countLength === 2) {
unsignedInt = dataView.getUint16(countIndex);
} else if (countLength === 4) {
unsignedInt = dataView.getUint32(countIndex);
} else {
unsignedInt = dataView.getBigUint64(countIndex);
}
break;
default:
throw new Error(`unexpected minor value ${minor}.`);
}
}
if (major === majorUint64) {
_offset = offset;
return castBigInt(unsignedInt);
} else if (major === majorNegativeInt64) {
let negativeInt;
if (typeof unsignedInt === "bigint") {
negativeInt = BigInt(-1) - unsignedInt;
} else {
negativeInt = -1 - unsignedInt;
}
_offset = offset;
return castBigInt(negativeInt);
} else {
const value = decode(at + offset, to);
const valueOffset = _offset;
_offset = offset + valueOffset;
return tag({ tag: castBigInt(unsignedInt), value });
}
case majorUtf8String:
case majorMap:
case majorList:
case majorUnstructuredByteString:
if (minor === minorIndefinite) {
switch (major) {
case majorUtf8String:
return decodeUtf8StringIndefinite(at, to);
case majorMap:
return decodeMapIndefinite(at, to);
case majorList:
return decodeListIndefinite(at, to);
case majorUnstructuredByteString:
return decodeUnstructuredByteStringIndefinite(at, to);
}
} else {
switch (major) {
case majorUtf8String:
return decodeUtf8String(at, to);
case majorMap:
return decodeMap(at, to);
case majorList:
return decodeList(at, to);
case majorUnstructuredByteString:
return decodeUnstructuredByteString(at, to);
}
}
default:
return decodeSpecial(at, to);
}
}
function bytesToUtf8(bytes, at, to) {
if (USE_BUFFER && bytes.constructor?.name === "Buffer") {
return bytes.toString("utf-8", at, to);
}
if (textDecoder) {
return textDecoder.decode(bytes.subarray(at, to));
}
return (0, import_util_utf8.toUtf8)(bytes.subarray(at, to));
}
function demote(bigInteger) {
const num = Number(bigInteger);
if (num < Number.MIN_SAFE_INTEGER || Number.MAX_SAFE_INTEGER < num) {
console.warn(new Error(`@smithy/core/cbor - truncating BigInt(${bigInteger}) to ${num} with loss of precision.`));
}
return num;
}
var minorValueToArgumentLength = {
[extendedOneByte]: 1,
[extendedFloat16]: 2,
[extendedFloat32]: 4,
[extendedFloat64]: 8
};
function bytesToFloat16(a, b) {
const sign = a >> 7;
const exponent = (a & 124) >> 2;
const fraction = (a & 3) << 8 | b;
const scalar = sign === 0 ? 1 : -1;
let exponentComponent;
let summation;
if (exponent === 0) {
if (fraction === 0) {
return 0;
} else {
exponentComponent = Math.pow(2, 1 - 15);
summation = 0;
}
} else if (exponent === 31) {
if (fraction === 0) {
return scalar * Infinity;
} else {
return NaN;
}
} else {
exponentComponent = Math.pow(2, exponent - 15);
summation = 1;
}
summation += fraction / 1024;
return scalar * (exponentComponent * summation);
}
function decodeCount(at, to) {
const minor = payload[at] & 31;
if (minor < 24) {
_offset = 1;
return minor;
}
if (minor === extendedOneByte || minor === extendedFloat16 || minor === extendedFloat32 || minor === extendedFloat64) {
const countLength = minorValueToArgumentLength[minor];
_offset = countLength + 1;
if (to - at < _offset) {
throw new Error(`countLength ${countLength} greater than remaining buf len.`);
}
const countIndex = at + 1;
if (countLength === 1) {
return payload[countIndex];
} else if (countLength === 2) {
return dataView.getUint16(countIndex);
} else if (countLength === 4) {
return dataView.getUint32(countIndex);
}
return demote(dataView.getBigUint64(countIndex));
}
throw new Error(`unexpected minor value ${minor}.`);
}
function decodeUtf8String(at, to) {
const length = decodeCount(at, to);
const offset = _offset;
at += offset;
if (to - at < length) {
throw new Error(`string len ${length} greater than remaining buf len.`);
}
const value = bytesToUtf8(payload, at, at + length);
_offset = offset + length;
return value;
}
function decodeUtf8StringIndefinite(at, to) {
at += 1;
const vector = [];
for (const base = at; at < to; ) {
if (payload[at] === 255) {
const data2 = alloc(vector.length);
data2.set(vector, 0);
_offset = at - base + 2;
return bytesToUtf8(data2, 0, data2.length);
}
const major = (payload[at] & 224) >> 5;
const minor = payload[at] & 31;
if (major !== majorUtf8String) {
throw new Error(`unexpected major type ${major} in indefinite string.`);
}
if (minor === minorIndefinite) {
throw new Error("nested indefinite string.");
}
const bytes = decodeUnstructuredByteString(at, to);
const length = _offset;
at += length;
for (let i = 0; i < bytes.length; ++i) {
vector.push(bytes[i]);
}
}
throw new Error("expected break marker.");
}
function decodeUnstructuredByteString(at, to) {
const length = decodeCount(at, to);
const offset = _offset;
at += offset;
if (to - at < length) {
throw new Error(`unstructured byte string len ${length} greater than remaining buf len.`);
}
const value = payload.subarray(at, at + length);
_offset = offset + length;
return value;
}
function decodeUnstructuredByteStringIndefinite(at, to) {
at += 1;
const vector = [];
for (const base = at; at < to; ) {
if (payload[at] === 255) {
const data2 = alloc(vector.length);
data2.set(vector, 0);
_offset = at - base + 2;
return data2;
}
const major = (payload[at] & 224) >> 5;
const minor = payload[at] & 31;
if (major !== majorUnstructuredByteString) {
throw new Error(`unexpected major type ${major} in indefinite string.`);
}
if (minor === minorIndefinite) {
throw new Error("nested indefinite string.");
}
const bytes = decodeUnstructuredByteString(at, to);
const length = _offset;
at += length;
for (let i = 0; i < bytes.length; ++i) {
vector.push(bytes[i]);
}
}
throw new Error("expected break marker.");
}
function decodeList(at, to) {
const listDataLength = decodeCount(at, to);
const offset = _offset;
at += offset;
const base = at;
const list = Array(listDataLength);
for (let i = 0; i < listDataLength; ++i) {
const item = decode(at, to);
const itemOffset = _offset;
list[i] = item;
at += itemOffset;
}
_offset = offset + (at - base);
return list;
}
function decodeListIndefinite(at, to) {
at += 1;
const list = [];
for (const base = at; at < to; ) {
if (payload[at] === 255) {
_offset = at - base + 2;
return list;
}
const item = decode(at, to);
const n = _offset;
at += n;
list.push(item);
}
throw new Error("expected break marker.");
}
function decodeMap(at, to) {
const mapDataLength = decodeCount(at, to);
const offset = _offset;
at += offset;
const base = at;
const map = {};
for (let i = 0; i < mapDataLength; ++i) {
if (at >= to) {
throw new Error("unexpected end of map payload.");
}
const major = (payload[at] & 224) >> 5;
if (major !== majorUtf8String) {
throw new Error(`unexpected major type ${major} for map key at index ${at}.`);
}
const key = decode(at, to);
at += _offset;
const value = decode(at, to);
at += _offset;
map[key] = value;
}
_offset = offset + (at - base);
return map;
}
function decodeMapIndefinite(at, to) {
at += 1;
const base = at;
const map = {};
for (; at < to; ) {
if (at >= to) {
throw new Error("unexpected end of map payload.");
}
if (payload[at] === 255) {
_offset = at - base + 2;
return map;
}
const major = (payload[at] & 224) >> 5;
if (major !== majorUtf8String) {
throw new Error(`unexpected major type ${major} for map key.`);
}
const key = decode(at, to);
at += _offset;
const value = decode(at, to);
at += _offset;
map[key] = value;
}
throw new Error("expected break marker.");
}
function decodeSpecial(at, to) {
const minor = payload[at] & 31;
switch (minor) {
case specialTrue:
case specialFalse:
_offset = 1;
return minor === specialTrue;
case specialNull:
_offset = 1;
return null;
case specialUndefined:
_offset = 1;
return null;
case extendedFloat16:
if (to - at < 3) {
throw new Error("incomplete float16 at end of buf.");
}
_offset = 3;
return bytesToFloat16(payload[at + 1], payload[at + 2]);
case extendedFloat32:
if (to - at < 5) {
throw new Error("incomplete float32 at end of buf.");
}
_offset = 5;
return dataView.getFloat32(at + 1);
case extendedFloat64:
if (to - at < 9) {
throw new Error("incomplete float64 at end of buf.");
}
_offset = 9;
return dataView.getFloat64(at + 1);
default:
throw new Error(`unexpected minor value ${minor}.`);
}
}
function castBigInt(bigInt) {
if (typeof bigInt === "number") {
return bigInt;
}
const num = Number(bigInt);
if (Number.MIN_SAFE_INTEGER <= num && num <= Number.MAX_SAFE_INTEGER) {
return num;
}
return bigInt;
}
// src/submodules/cbor/cbor-encode.ts
var import_util_utf82 = require("@smithy/util-utf8");
var USE_BUFFER2 = typeof Buffer !== "undefined";
var initialSize = 2048;
var data = alloc(initialSize);
var dataView2 = new DataView(data.buffer, data.byteOffset, data.byteLength);
var cursor = 0;
function ensureSpace(bytes) {
const remaining = data.byteLength - cursor;
if (remaining < bytes) {
if (cursor < 16e6) {
resize(Math.max(data.byteLength * 4, data.byteLength + bytes));
} else {
resize(data.byteLength + bytes + 16e6);
}
}
}
function toUint8Array() {
const out = alloc(cursor);
out.set(data.subarray(0, cursor), 0);
cursor = 0;
return out;
}
function resize(size) {
const old = data;
data = alloc(size);
if (old) {
if (old.copy) {
old.copy(data, 0, 0, old.byteLength);
} else {
data.set(old, 0);
}
}
dataView2 = new DataView(data.buffer, data.byteOffset, data.byteLength);
}
function encodeHeader(major, value) {
if (value < 24) {
data[cursor++] = major << 5 | value;
} else if (value < 1 << 8) {
data[cursor++] = major << 5 | 24;
data[cursor++] = value;
} else if (value < 1 << 16) {
data[cursor++] = major << 5 | extendedFloat16;
dataView2.setUint16(cursor, value);
cursor += 2;
} else if (value < 2 ** 32) {
data[cursor++] = major << 5 | extendedFloat32;
dataView2.setUint32(cursor, value);
cursor += 4;
} else {
data[cursor++] = major << 5 | extendedFloat64;
dataView2.setBigUint64(cursor, typeof value === "bigint" ? value : BigInt(value));
cursor += 8;
}
}
function encode(_input) {
const encodeStack = [_input];
while (encodeStack.length) {
const input = encodeStack.pop();
ensureSpace(typeof input === "string" ? input.length * 4 : 64);
if (typeof input === "string") {
if (USE_BUFFER2) {
encodeHeader(majorUtf8String, Buffer.byteLength(input));
cursor += data.write(input, cursor);
} else {
const bytes = (0, import_util_utf82.fromUtf8)(input);
encodeHeader(majorUtf8String, bytes.byteLength);
data.set(bytes, cursor);
cursor += bytes.byteLength;
}
continue;
} else if (typeof input === "number") {
if (Number.isInteger(input)) {
const nonNegative = input >= 0;
const major = nonNegative ? majorUint64 : majorNegativeInt64;
const value = nonNegative ? input : -input - 1;
if (value < 24) {
data[cursor++] = major << 5 | value;
} else if (value < 256) {
data[cursor++] = major << 5 | 24;
data[cursor++] = value;
} else if (value < 65536) {
data[cursor++] = major << 5 | extendedFloat16;
data[cursor++] = value >> 8;
data[cursor++] = value;
} else if (value < 4294967296) {
data[cursor++] = major << 5 | extendedFloat32;
dataView2.setUint32(cursor, value);
cursor += 4;
} else {
data[cursor++] = major << 5 | extendedFloat64;
dataView2.setBigUint64(cursor, BigInt(value));
cursor += 8;
}
continue;
}
data[cursor++] = majorSpecial << 5 | extendedFloat64;
dataView2.setFloat64(cursor, input);
cursor += 8;
continue;
} else if (typeof input === "bigint") {
const nonNegative = input >= 0;
const major = nonNegative ? majorUint64 : majorNegativeInt64;
const value = nonNegative ? input : -input - BigInt(1);
const n = Number(value);
if (n < 24) {
data[cursor++] = major << 5 | n;
} else if (n < 256) {
data[cursor++] = major << 5 | 24;
data[cursor++] = n;
} else if (n < 65536) {
data[cursor++] = major << 5 | extendedFloat16;
data[cursor++] = n >> 8;
data[cursor++] = n & 255;
} else if (n < 4294967296) {
data[cursor++] = major << 5 | extendedFloat32;
dataView2.setUint32(cursor, n);
cursor += 4;
} else {
data[cursor++] = major << 5 | extendedFloat64;
dataView2.setBigUint64(cursor, value);
cursor += 8;
}
continue;
} else if (input === null) {
data[cursor++] = majorSpecial << 5 | specialNull;
continue;
} else if (typeof input === "boolean") {
data[cursor++] = majorSpecial << 5 | (input ? specialTrue : specialFalse);
continue;
} else if (typeof input === "undefined") {
throw new Error("@smithy/core/cbor: client may not serialize undefined value.");
} else if (Array.isArray(input)) {
for (let i = input.length - 1; i >= 0; --i) {
encodeStack.push(input[i]);
}
encodeHeader(majorList, input.length);
continue;
} else if (typeof input.byteLength === "number") {
ensureSpace(input.length * 2);
encodeHeader(majorUnstructuredByteString, input.length);
data.set(input, cursor);
cursor += input.byteLength;
continue;
} else if (typeof input === "object") {
if (input[tagSymbol]) {
if ("tag" in input && "value" in input) {
encodeStack.push(input.value);
encodeHeader(majorTag, input.tag);
continue;
} else {
throw new Error(
"tag encountered with missing fields, need 'tag' and 'value', found: " + JSON.stringify(input)
);
}
}
const keys = Object.keys(input);
for (let i = keys.length - 1; i >= 0; --i) {
const key = keys[i];
encodeStack.push(input[key]);
encodeStack.push(key);
}
encodeHeader(majorMap, keys.length);
continue;
}
throw new Error(`data type ${input?.constructor?.name ?? typeof input} not compatible for encoding.`);
}
}
// src/submodules/cbor/cbor.ts
var cbor = {
deserialize(payload2) {
setPayload(payload2);
return decode(0, payload2.length);
},
serialize(input) {
try {
encode(input);
return toUint8Array();
} catch (e) {
toUint8Array();
throw e;
}
},
/**
* @public
* @param size - byte length to allocate.
*
* This may be used to garbage collect the CBOR
* shared encoding buffer space,
* e.g. resizeEncodingBuffer(0);
*
* This may also be used to pre-allocate more space for
* CBOR encoding, e.g. resizeEncodingBuffer(100_000_000);
*/
resizeEncodingBuffer(size) {
resize(size);
}
};
// src/submodules/cbor/parseCborBody.ts
var import_protocols = require("@smithy/core/protocols");
var import_protocol_http = require("@smithy/protocol-http");
var import_util_body_length_browser = require("@smithy/util-body-length-browser");
var parseCborBody = (streamBody, context) => {
return (0, import_protocols.collectBody)(streamBody, context).then(async (bytes) => {
if (bytes.length) {
try {
return cbor.deserialize(bytes);
} catch (e) {
Object.defineProperty(e, "$responseBodyText", {
value: context.utf8Encoder(bytes)
});
throw e;
}
}
return {};
});
};
var dateToTag = (date) => {
return tag({
tag: 1,
value: date.getTime() / 1e3
});
};
var parseCborErrorBody = async (errorBody, context) => {
const value = await parseCborBody(errorBody, context);
value.message = value.message ?? value.Message;
return value;
};
var loadSmithyRpcV2CborErrorCode = (output, data2) => {
const sanitizeErrorCode = (rawValue) => {
let cleanValue = rawValue;
if (typeof cleanValue === "number") {
cleanValue = cleanValue.toString();
}
if (cleanValue.indexOf(",") >= 0) {
cleanValue = cleanValue.split(",")[0];
}
if (cleanValue.indexOf(":") >= 0) {
cleanValue = cleanValue.split(":")[0];
}
if (cleanValue.indexOf("#") >= 0) {
cleanValue = cleanValue.split("#")[1];
}
return cleanValue;
};
if (data2["__type"] !== void 0) {
return sanitizeErrorCode(data2["__type"]);
}
if (data2.code !== void 0) {
return sanitizeErrorCode(data2.code);
}
};
var checkCborResponse = (response) => {
if (String(response.headers["smithy-protocol"]).toLowerCase() !== "rpc-v2-cbor") {
throw new Error("Malformed RPCv2 CBOR response, status: " + response.statusCode);
}
};
var buildHttpRpcRequest = async (context, headers, path, resolvedHostname, body) => {
const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
const contents = {
protocol,
hostname,
port,
method: "POST",
path: basePath.endsWith("/") ? basePath.slice(0, -1) + path : basePath + path,
headers: {
// intentional copy.
...headers
}
};
if (resolvedHostname !== void 0) {
contents.hostname = resolvedHostname;
}
if (body !== void 0) {
contents.body = body;
try {
contents.headers["content-length"] = String((0, import_util_body_length_browser.calculateBodyLength)(body));
} catch (e) {
}
}
return new import_protocol_http.HttpRequest(contents);
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
buildHttpRpcRequest,
cbor,
checkCborResponse,
dateToTag,
loadSmithyRpcV2CborErrorCode,
parseCborBody,
parseCborErrorBody,
tag,
tagSymbol
});

View File

@@ -0,0 +1,164 @@
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/submodules/protocols/index.ts
var protocols_exports = {};
__export(protocols_exports, {
RequestBuilder: () => RequestBuilder,
collectBody: () => collectBody,
extendedEncodeURIComponent: () => extendedEncodeURIComponent,
requestBuilder: () => requestBuilder,
resolvedPath: () => resolvedPath
});
module.exports = __toCommonJS(protocols_exports);
// src/submodules/protocols/collect-stream-body.ts
var import_util_stream = require("@smithy/util-stream");
var collectBody = async (streamBody = new Uint8Array(), context) => {
if (streamBody instanceof Uint8Array) {
return import_util_stream.Uint8ArrayBlobAdapter.mutate(streamBody);
}
if (!streamBody) {
return import_util_stream.Uint8ArrayBlobAdapter.mutate(new Uint8Array());
}
const fromContext = context.streamCollector(streamBody);
return import_util_stream.Uint8ArrayBlobAdapter.mutate(await fromContext);
};
// src/submodules/protocols/extended-encode-uri-component.ts
function extendedEncodeURIComponent(str) {
return encodeURIComponent(str).replace(/[!'()*]/g, function(c) {
return "%" + c.charCodeAt(0).toString(16).toUpperCase();
});
}
// src/submodules/protocols/requestBuilder.ts
var import_protocol_http = require("@smithy/protocol-http");
// src/submodules/protocols/resolve-path.ts
var resolvedPath = (resolvedPath2, input, memberName, labelValueProvider, uriLabel, isGreedyLabel) => {
if (input != null && input[memberName] !== void 0) {
const labelValue = labelValueProvider();
if (labelValue.length <= 0) {
throw new Error("Empty value provided for input HTTP label: " + memberName + ".");
}
resolvedPath2 = resolvedPath2.replace(
uriLabel,
isGreedyLabel ? labelValue.split("/").map((segment) => extendedEncodeURIComponent(segment)).join("/") : extendedEncodeURIComponent(labelValue)
);
} else {
throw new Error("No value provided for input HTTP label: " + memberName + ".");
}
return resolvedPath2;
};
// src/submodules/protocols/requestBuilder.ts
function requestBuilder(input, context) {
return new RequestBuilder(input, context);
}
var RequestBuilder = class {
constructor(input, context) {
this.input = input;
this.context = context;
this.query = {};
this.method = "";
this.headers = {};
this.path = "";
this.body = null;
this.hostname = "";
this.resolvePathStack = [];
}
async build() {
const { hostname, protocol = "https", port, path: basePath } = await this.context.endpoint();
this.path = basePath;
for (const resolvePath of this.resolvePathStack) {
resolvePath(this.path);
}
return new import_protocol_http.HttpRequest({
protocol,
hostname: this.hostname || hostname,
port,
method: this.method,
path: this.path,
query: this.query,
body: this.body,
headers: this.headers
});
}
/**
* Brevity setter for "hostname".
*/
hn(hostname) {
this.hostname = hostname;
return this;
}
/**
* Brevity initial builder for "basepath".
*/
bp(uriLabel) {
this.resolvePathStack.push((basePath) => {
this.path = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + uriLabel;
});
return this;
}
/**
* Brevity incremental builder for "path".
*/
p(memberName, labelValueProvider, uriLabel, isGreedyLabel) {
this.resolvePathStack.push((path) => {
this.path = resolvedPath(path, this.input, memberName, labelValueProvider, uriLabel, isGreedyLabel);
});
return this;
}
/**
* Brevity setter for "headers".
*/
h(headers) {
this.headers = headers;
return this;
}
/**
* Brevity setter for "query".
*/
q(query) {
this.query = query;
return this;
}
/**
* Brevity setter for "body".
*/
b(body) {
this.body = body;
return this;
}
/**
* Brevity setter for "method".
*/
m(method) {
this.method = method;
return this;
}
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
RequestBuilder,
collectBody,
extendedEncodeURIComponent,
requestBuilder,
resolvedPath
});

View File

@@ -0,0 +1,41 @@
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/submodules/serde/index.ts
var serde_exports = {};
__export(serde_exports, {
NumericValue: () => NumericValue,
nv: () => nv
});
module.exports = __toCommonJS(serde_exports);
// src/submodules/serde/value/NumericValue.ts
var NumericValue = class {
constructor(string, type) {
this.string = string;
this.type = type;
}
};
function nv(string) {
return new NumericValue(string, "bigDecimal");
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
NumericValue,
nv
});

View File

@@ -0,0 +1 @@
module.exports = require("../index.js");

View File

@@ -0,0 +1 @@
module.exports = require("../../index.js");

View File

@@ -0,0 +1 @@
module.exports = require("../../index.js");

View File

@@ -0,0 +1 @@
module.exports = require("../../index.js");

View File

@@ -0,0 +1 @@
module.exports = require("../../index.js");

View File

@@ -0,0 +1 @@
module.exports = require("../index.js");

View File

@@ -0,0 +1 @@
module.exports = require("../index.js");

View File

@@ -0,0 +1,2 @@
import { SMITHY_CONTEXT_KEY } from "@smithy/types";
export const getSmithyContext = (context) => context[SMITHY_CONTEXT_KEY] || (context[SMITHY_CONTEXT_KEY] = {});

View File

@@ -0,0 +1,8 @@
export * from "./getSmithyContext";
export * from "./middleware-http-auth-scheme";
export * from "./middleware-http-signing";
export * from "./normalizeProvider";
export { createPaginator } from "./pagination/createPaginator";
export * from "./protocols/requestBuilder";
export * from "./setFeature";
export * from "./util-identity-and-auth";

View File

@@ -0,0 +1,17 @@
import { httpAuthSchemeMiddleware } from "./httpAuthSchemeMiddleware";
export const httpAuthSchemeEndpointRuleSetMiddlewareOptions = {
step: "serialize",
tags: ["HTTP_AUTH_SCHEME"],
name: "httpAuthSchemeMiddleware",
override: true,
relation: "before",
toMiddleware: "endpointV2Middleware",
};
export const getHttpAuthSchemeEndpointRuleSetPlugin = (config, { httpAuthSchemeParametersProvider, identityProviderConfigProvider, }) => ({
applyToStack: (clientStack) => {
clientStack.addRelativeTo(httpAuthSchemeMiddleware(config, {
httpAuthSchemeParametersProvider,
identityProviderConfigProvider,
}), httpAuthSchemeEndpointRuleSetMiddlewareOptions);
},
});

View File

@@ -0,0 +1,18 @@
import { serializerMiddlewareOption } from "@smithy/middleware-serde";
import { httpAuthSchemeMiddleware } from "./httpAuthSchemeMiddleware";
export const httpAuthSchemeMiddlewareOptions = {
step: "serialize",
tags: ["HTTP_AUTH_SCHEME"],
name: "httpAuthSchemeMiddleware",
override: true,
relation: "before",
toMiddleware: serializerMiddlewareOption.name,
};
export const getHttpAuthSchemePlugin = (config, { httpAuthSchemeParametersProvider, identityProviderConfigProvider, }) => ({
applyToStack: (clientStack) => {
clientStack.addRelativeTo(httpAuthSchemeMiddleware(config, {
httpAuthSchemeParametersProvider,
identityProviderConfigProvider,
}), httpAuthSchemeMiddlewareOptions);
},
});

View File

@@ -0,0 +1,43 @@
import { SMITHY_CONTEXT_KEY, } from "@smithy/types";
import { getSmithyContext } from "@smithy/util-middleware";
import { resolveAuthOptions } from "./resolveAuthOptions";
function convertHttpAuthSchemesToMap(httpAuthSchemes) {
const map = new Map();
for (const scheme of httpAuthSchemes) {
map.set(scheme.schemeId, scheme);
}
return map;
}
export const httpAuthSchemeMiddleware = (config, mwOptions) => (next, context) => async (args) => {
const options = config.httpAuthSchemeProvider(await mwOptions.httpAuthSchemeParametersProvider(config, context, args.input));
const authSchemePreference = config.authSchemePreference ? await config.authSchemePreference() : [];
const resolvedOptions = resolveAuthOptions(options, authSchemePreference);
const authSchemes = convertHttpAuthSchemesToMap(config.httpAuthSchemes);
const smithyContext = getSmithyContext(context);
const failureReasons = [];
for (const option of resolvedOptions) {
const scheme = authSchemes.get(option.schemeId);
if (!scheme) {
failureReasons.push(`HttpAuthScheme \`${option.schemeId}\` was not enabled for this service.`);
continue;
}
const identityProvider = scheme.identityProvider(await mwOptions.identityProviderConfigProvider(config));
if (!identityProvider) {
failureReasons.push(`HttpAuthScheme \`${option.schemeId}\` did not have an IdentityProvider configured.`);
continue;
}
const { identityProperties = {}, signingProperties = {} } = option.propertiesExtractor?.(config, context) || {};
option.identityProperties = Object.assign(option.identityProperties || {}, identityProperties);
option.signingProperties = Object.assign(option.signingProperties || {}, signingProperties);
smithyContext.selectedHttpAuthScheme = {
httpAuthOption: option,
identity: await identityProvider(option.identityProperties),
signer: scheme.signer,
};
break;
}
if (!smithyContext.selectedHttpAuthScheme) {
throw new Error(failureReasons.join("\n"));
}
return next(args);
};

View File

@@ -0,0 +1,3 @@
export * from "./httpAuthSchemeMiddleware";
export * from "./getHttpAuthSchemeEndpointRuleSetPlugin";
export * from "./getHttpAuthSchemePlugin";

View File

@@ -0,0 +1,20 @@
export const resolveAuthOptions = (candidateAuthOptions, authSchemePreference) => {
if (!authSchemePreference || authSchemePreference.length === 0) {
return candidateAuthOptions;
}
const preferredAuthOptions = [];
for (const preferredSchemeName of authSchemePreference) {
for (const candidateAuthOption of candidateAuthOptions) {
const candidateAuthSchemeName = candidateAuthOption.schemeId.split("#")[1];
if (candidateAuthSchemeName === preferredSchemeName) {
preferredAuthOptions.push(candidateAuthOption);
}
}
}
for (const candidateAuthOption of candidateAuthOptions) {
if (!preferredAuthOptions.find(({ schemeId }) => schemeId === candidateAuthOption.schemeId)) {
preferredAuthOptions.push(candidateAuthOption);
}
}
return preferredAuthOptions;
};

View File

@@ -0,0 +1,15 @@
import { httpSigningMiddleware } from "./httpSigningMiddleware";
export const httpSigningMiddlewareOptions = {
step: "finalizeRequest",
tags: ["HTTP_SIGNING"],
name: "httpSigningMiddleware",
aliases: ["apiKeyMiddleware", "tokenMiddleware", "awsAuthMiddleware"],
override: true,
relation: "after",
toMiddleware: "retryMiddleware",
};
export const getHttpSigningPlugin = (config) => ({
applyToStack: (clientStack) => {
clientStack.addRelativeTo(httpSigningMiddleware(config), httpSigningMiddlewareOptions);
},
});

View File

@@ -0,0 +1,24 @@
import { HttpRequest } from "@smithy/protocol-http";
import { SMITHY_CONTEXT_KEY, } from "@smithy/types";
import { getSmithyContext } from "@smithy/util-middleware";
const defaultErrorHandler = (signingProperties) => (error) => {
throw error;
};
const defaultSuccessHandler = (httpResponse, signingProperties) => { };
export const httpSigningMiddleware = (config) => (next, context) => async (args) => {
if (!HttpRequest.isInstance(args.request)) {
return next(args);
}
const smithyContext = getSmithyContext(context);
const scheme = smithyContext.selectedHttpAuthScheme;
if (!scheme) {
throw new Error(`No HttpAuthScheme was selected: unable to sign request`);
}
const { httpAuthOption: { signingProperties = {} }, identity, signer, } = scheme;
const output = await next({
...args,
request: await signer.sign(args.request, identity, signingProperties),
}).catch((signer.errorHandler || defaultErrorHandler)(signingProperties));
(signer.successHandler || defaultSuccessHandler)(output.response, signingProperties);
return output;
};

View File

@@ -0,0 +1,2 @@
export * from "./httpSigningMiddleware";
export * from "./getHttpSigningMiddleware";

View File

@@ -0,0 +1,6 @@
export const normalizeProvider = (input) => {
if (typeof input === "function")
return input;
const promisified = Promise.resolve(input);
return () => promisified;
};

View File

@@ -0,0 +1,41 @@
const makePagedClientRequest = async (CommandCtor, client, input, withCommand = (_) => _, ...args) => {
let command = new CommandCtor(input);
command = withCommand(command) ?? command;
return await client.send(command, ...args);
};
export function createPaginator(ClientCtor, CommandCtor, inputTokenName, outputTokenName, pageSizeTokenName) {
return async function* paginateOperation(config, input, ...additionalArguments) {
const _input = input;
let token = config.startingToken ?? _input[inputTokenName];
let hasNext = true;
let page;
while (hasNext) {
_input[inputTokenName] = token;
if (pageSizeTokenName) {
_input[pageSizeTokenName] = _input[pageSizeTokenName] ?? config.pageSize;
}
if (config.client instanceof ClientCtor) {
page = await makePagedClientRequest(CommandCtor, config.client, input, config.withCommand, ...additionalArguments);
}
else {
throw new Error(`Invalid client, expected instance of ${ClientCtor.name}`);
}
yield page;
const prevToken = token;
token = get(page, outputTokenName);
hasNext = !!(token && (!config.stopOnSameToken || token !== prevToken));
}
return undefined;
};
}
const get = (fromObject, path) => {
let cursor = fromObject;
const pathComponents = path.split(".");
for (const step of pathComponents) {
if (!cursor || typeof cursor !== "object") {
return undefined;
}
cursor = cursor[step];
}
return cursor;
};

View File

@@ -0,0 +1 @@
export { requestBuilder } from "@smithy/core/protocols";

View File

@@ -0,0 +1,11 @@
export function setFeature(context, feature, value) {
if (!context.__smithy_context) {
context.__smithy_context = {
features: {},
};
}
else if (!context.__smithy_context.features) {
context.__smithy_context.features = {};
}
context.__smithy_context.features[feature] = value;
}

View File

@@ -0,0 +1,391 @@
import { toUtf8 } from "@smithy/util-utf8";
import { alloc, extendedFloat16, extendedFloat32, extendedFloat64, extendedOneByte, majorList, majorMap, majorNegativeInt64, majorTag, majorUint64, majorUnstructuredByteString, majorUtf8String, minorIndefinite, specialFalse, specialNull, specialTrue, specialUndefined, tag, } from "./cbor-types";
const USE_TEXT_DECODER = typeof TextDecoder !== "undefined";
const USE_BUFFER = typeof Buffer !== "undefined";
let payload = alloc(0);
let dataView = new DataView(payload.buffer, payload.byteOffset, payload.byteLength);
const textDecoder = USE_TEXT_DECODER ? new TextDecoder() : null;
let _offset = 0;
export function setPayload(bytes) {
payload = bytes;
dataView = new DataView(payload.buffer, payload.byteOffset, payload.byteLength);
}
export function decode(at, to) {
if (at >= to) {
throw new Error("unexpected end of (decode) payload.");
}
const major = (payload[at] & 224) >> 5;
const minor = payload[at] & 31;
switch (major) {
case majorUint64:
case majorNegativeInt64:
case majorTag:
let unsignedInt;
let offset;
if (minor < 24) {
unsignedInt = minor;
offset = 1;
}
else {
switch (minor) {
case extendedOneByte:
case extendedFloat16:
case extendedFloat32:
case extendedFloat64:
const countLength = minorValueToArgumentLength[minor];
const countOffset = (countLength + 1);
offset = countOffset;
if (to - at < countOffset) {
throw new Error(`countLength ${countLength} greater than remaining buf len.`);
}
const countIndex = at + 1;
if (countLength === 1) {
unsignedInt = payload[countIndex];
}
else if (countLength === 2) {
unsignedInt = dataView.getUint16(countIndex);
}
else if (countLength === 4) {
unsignedInt = dataView.getUint32(countIndex);
}
else {
unsignedInt = dataView.getBigUint64(countIndex);
}
break;
default:
throw new Error(`unexpected minor value ${minor}.`);
}
}
if (major === majorUint64) {
_offset = offset;
return castBigInt(unsignedInt);
}
else if (major === majorNegativeInt64) {
let negativeInt;
if (typeof unsignedInt === "bigint") {
negativeInt = BigInt(-1) - unsignedInt;
}
else {
negativeInt = -1 - unsignedInt;
}
_offset = offset;
return castBigInt(negativeInt);
}
else {
const value = decode(at + offset, to);
const valueOffset = _offset;
_offset = offset + valueOffset;
return tag({ tag: castBigInt(unsignedInt), value });
}
case majorUtf8String:
case majorMap:
case majorList:
case majorUnstructuredByteString:
if (minor === minorIndefinite) {
switch (major) {
case majorUtf8String:
return decodeUtf8StringIndefinite(at, to);
case majorMap:
return decodeMapIndefinite(at, to);
case majorList:
return decodeListIndefinite(at, to);
case majorUnstructuredByteString:
return decodeUnstructuredByteStringIndefinite(at, to);
}
}
else {
switch (major) {
case majorUtf8String:
return decodeUtf8String(at, to);
case majorMap:
return decodeMap(at, to);
case majorList:
return decodeList(at, to);
case majorUnstructuredByteString:
return decodeUnstructuredByteString(at, to);
}
}
default:
return decodeSpecial(at, to);
}
}
function bytesToUtf8(bytes, at, to) {
if (USE_BUFFER && bytes.constructor?.name === "Buffer") {
return bytes.toString("utf-8", at, to);
}
if (textDecoder) {
return textDecoder.decode(bytes.subarray(at, to));
}
return toUtf8(bytes.subarray(at, to));
}
function demote(bigInteger) {
const num = Number(bigInteger);
if (num < Number.MIN_SAFE_INTEGER || Number.MAX_SAFE_INTEGER < num) {
console.warn(new Error(`@smithy/core/cbor - truncating BigInt(${bigInteger}) to ${num} with loss of precision.`));
}
return num;
}
const minorValueToArgumentLength = {
[extendedOneByte]: 1,
[extendedFloat16]: 2,
[extendedFloat32]: 4,
[extendedFloat64]: 8,
};
export function bytesToFloat16(a, b) {
const sign = a >> 7;
const exponent = (a & 124) >> 2;
const fraction = ((a & 3) << 8) | b;
const scalar = sign === 0 ? 1 : -1;
let exponentComponent;
let summation;
if (exponent === 0b00000) {
if (fraction === 0) {
return 0;
}
else {
exponentComponent = Math.pow(2, 1 - 15);
summation = 0;
}
}
else if (exponent === 0b11111) {
if (fraction === 0) {
return scalar * Infinity;
}
else {
return NaN;
}
}
else {
exponentComponent = Math.pow(2, exponent - 15);
summation = 1;
}
summation += fraction / 1024;
return scalar * (exponentComponent * summation);
}
function decodeCount(at, to) {
const minor = payload[at] & 31;
if (minor < 24) {
_offset = 1;
return minor;
}
if (minor === extendedOneByte ||
minor === extendedFloat16 ||
minor === extendedFloat32 ||
minor === extendedFloat64) {
const countLength = minorValueToArgumentLength[minor];
_offset = (countLength + 1);
if (to - at < _offset) {
throw new Error(`countLength ${countLength} greater than remaining buf len.`);
}
const countIndex = at + 1;
if (countLength === 1) {
return payload[countIndex];
}
else if (countLength === 2) {
return dataView.getUint16(countIndex);
}
else if (countLength === 4) {
return dataView.getUint32(countIndex);
}
return demote(dataView.getBigUint64(countIndex));
}
throw new Error(`unexpected minor value ${minor}.`);
}
function decodeUtf8String(at, to) {
const length = decodeCount(at, to);
const offset = _offset;
at += offset;
if (to - at < length) {
throw new Error(`string len ${length} greater than remaining buf len.`);
}
const value = bytesToUtf8(payload, at, at + length);
_offset = offset + length;
return value;
}
function decodeUtf8StringIndefinite(at, to) {
at += 1;
const vector = [];
for (const base = at; at < to;) {
if (payload[at] === 255) {
const data = alloc(vector.length);
data.set(vector, 0);
_offset = at - base + 2;
return bytesToUtf8(data, 0, data.length);
}
const major = (payload[at] & 224) >> 5;
const minor = payload[at] & 31;
if (major !== majorUtf8String) {
throw new Error(`unexpected major type ${major} in indefinite string.`);
}
if (minor === minorIndefinite) {
throw new Error("nested indefinite string.");
}
const bytes = decodeUnstructuredByteString(at, to);
const length = _offset;
at += length;
for (let i = 0; i < bytes.length; ++i) {
vector.push(bytes[i]);
}
}
throw new Error("expected break marker.");
}
function decodeUnstructuredByteString(at, to) {
const length = decodeCount(at, to);
const offset = _offset;
at += offset;
if (to - at < length) {
throw new Error(`unstructured byte string len ${length} greater than remaining buf len.`);
}
const value = payload.subarray(at, at + length);
_offset = offset + length;
return value;
}
function decodeUnstructuredByteStringIndefinite(at, to) {
at += 1;
const vector = [];
for (const base = at; at < to;) {
if (payload[at] === 255) {
const data = alloc(vector.length);
data.set(vector, 0);
_offset = at - base + 2;
return data;
}
const major = (payload[at] & 224) >> 5;
const minor = payload[at] & 31;
if (major !== majorUnstructuredByteString) {
throw new Error(`unexpected major type ${major} in indefinite string.`);
}
if (minor === minorIndefinite) {
throw new Error("nested indefinite string.");
}
const bytes = decodeUnstructuredByteString(at, to);
const length = _offset;
at += length;
for (let i = 0; i < bytes.length; ++i) {
vector.push(bytes[i]);
}
}
throw new Error("expected break marker.");
}
function decodeList(at, to) {
const listDataLength = decodeCount(at, to);
const offset = _offset;
at += offset;
const base = at;
const list = Array(listDataLength);
for (let i = 0; i < listDataLength; ++i) {
const item = decode(at, to);
const itemOffset = _offset;
list[i] = item;
at += itemOffset;
}
_offset = offset + (at - base);
return list;
}
function decodeListIndefinite(at, to) {
at += 1;
const list = [];
for (const base = at; at < to;) {
if (payload[at] === 255) {
_offset = at - base + 2;
return list;
}
const item = decode(at, to);
const n = _offset;
at += n;
list.push(item);
}
throw new Error("expected break marker.");
}
function decodeMap(at, to) {
const mapDataLength = decodeCount(at, to);
const offset = _offset;
at += offset;
const base = at;
const map = {};
for (let i = 0; i < mapDataLength; ++i) {
if (at >= to) {
throw new Error("unexpected end of map payload.");
}
const major = (payload[at] & 224) >> 5;
if (major !== majorUtf8String) {
throw new Error(`unexpected major type ${major} for map key at index ${at}.`);
}
const key = decode(at, to);
at += _offset;
const value = decode(at, to);
at += _offset;
map[key] = value;
}
_offset = offset + (at - base);
return map;
}
function decodeMapIndefinite(at, to) {
at += 1;
const base = at;
const map = {};
for (; at < to;) {
if (at >= to) {
throw new Error("unexpected end of map payload.");
}
if (payload[at] === 255) {
_offset = at - base + 2;
return map;
}
const major = (payload[at] & 224) >> 5;
if (major !== majorUtf8String) {
throw new Error(`unexpected major type ${major} for map key.`);
}
const key = decode(at, to);
at += _offset;
const value = decode(at, to);
at += _offset;
map[key] = value;
}
throw new Error("expected break marker.");
}
function decodeSpecial(at, to) {
const minor = payload[at] & 31;
switch (minor) {
case specialTrue:
case specialFalse:
_offset = 1;
return minor === specialTrue;
case specialNull:
_offset = 1;
return null;
case specialUndefined:
_offset = 1;
return null;
case extendedFloat16:
if (to - at < 3) {
throw new Error("incomplete float16 at end of buf.");
}
_offset = 3;
return bytesToFloat16(payload[at + 1], payload[at + 2]);
case extendedFloat32:
if (to - at < 5) {
throw new Error("incomplete float32 at end of buf.");
}
_offset = 5;
return dataView.getFloat32(at + 1);
case extendedFloat64:
if (to - at < 9) {
throw new Error("incomplete float64 at end of buf.");
}
_offset = 9;
return dataView.getFloat64(at + 1);
default:
throw new Error(`unexpected minor value ${minor}.`);
}
}
function castBigInt(bigInt) {
if (typeof bigInt === "number") {
return bigInt;
}
const num = Number(bigInt);
if (Number.MIN_SAFE_INTEGER <= num && num <= Number.MAX_SAFE_INTEGER) {
return num;
}
return bigInt;
}

View File

@@ -0,0 +1,191 @@
import { fromUtf8 } from "@smithy/util-utf8";
import { extendedFloat16, extendedFloat32, extendedFloat64, majorList, majorMap, majorNegativeInt64, majorSpecial, majorTag, majorUint64, majorUnstructuredByteString, majorUtf8String, specialFalse, specialNull, specialTrue, tagSymbol, } from "./cbor-types";
import { alloc } from "./cbor-types";
const USE_BUFFER = typeof Buffer !== "undefined";
const initialSize = 2048;
let data = alloc(initialSize);
let dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);
let cursor = 0;
function ensureSpace(bytes) {
const remaining = data.byteLength - cursor;
if (remaining < bytes) {
if (cursor < 16000000) {
resize(Math.max(data.byteLength * 4, data.byteLength + bytes));
}
else {
resize(data.byteLength + bytes + 16000000);
}
}
}
export function toUint8Array() {
const out = alloc(cursor);
out.set(data.subarray(0, cursor), 0);
cursor = 0;
return out;
}
export function resize(size) {
const old = data;
data = alloc(size);
if (old) {
if (old.copy) {
old.copy(data, 0, 0, old.byteLength);
}
else {
data.set(old, 0);
}
}
dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);
}
function encodeHeader(major, value) {
if (value < 24) {
data[cursor++] = (major << 5) | value;
}
else if (value < 1 << 8) {
data[cursor++] = (major << 5) | 24;
data[cursor++] = value;
}
else if (value < 1 << 16) {
data[cursor++] = (major << 5) | extendedFloat16;
dataView.setUint16(cursor, value);
cursor += 2;
}
else if (value < 2 ** 32) {
data[cursor++] = (major << 5) | extendedFloat32;
dataView.setUint32(cursor, value);
cursor += 4;
}
else {
data[cursor++] = (major << 5) | extendedFloat64;
dataView.setBigUint64(cursor, typeof value === "bigint" ? value : BigInt(value));
cursor += 8;
}
}
export function encode(_input) {
const encodeStack = [_input];
while (encodeStack.length) {
const input = encodeStack.pop();
ensureSpace(typeof input === "string" ? input.length * 4 : 64);
if (typeof input === "string") {
if (USE_BUFFER) {
encodeHeader(majorUtf8String, Buffer.byteLength(input));
cursor += data.write(input, cursor);
}
else {
const bytes = fromUtf8(input);
encodeHeader(majorUtf8String, bytes.byteLength);
data.set(bytes, cursor);
cursor += bytes.byteLength;
}
continue;
}
else if (typeof input === "number") {
if (Number.isInteger(input)) {
const nonNegative = input >= 0;
const major = nonNegative ? majorUint64 : majorNegativeInt64;
const value = nonNegative ? input : -input - 1;
if (value < 24) {
data[cursor++] = (major << 5) | value;
}
else if (value < 256) {
data[cursor++] = (major << 5) | 24;
data[cursor++] = value;
}
else if (value < 65536) {
data[cursor++] = (major << 5) | extendedFloat16;
data[cursor++] = value >> 8;
data[cursor++] = value;
}
else if (value < 4294967296) {
data[cursor++] = (major << 5) | extendedFloat32;
dataView.setUint32(cursor, value);
cursor += 4;
}
else {
data[cursor++] = (major << 5) | extendedFloat64;
dataView.setBigUint64(cursor, BigInt(value));
cursor += 8;
}
continue;
}
data[cursor++] = (majorSpecial << 5) | extendedFloat64;
dataView.setFloat64(cursor, input);
cursor += 8;
continue;
}
else if (typeof input === "bigint") {
const nonNegative = input >= 0;
const major = nonNegative ? majorUint64 : majorNegativeInt64;
const value = nonNegative ? input : -input - BigInt(1);
const n = Number(value);
if (n < 24) {
data[cursor++] = (major << 5) | n;
}
else if (n < 256) {
data[cursor++] = (major << 5) | 24;
data[cursor++] = n;
}
else if (n < 65536) {
data[cursor++] = (major << 5) | extendedFloat16;
data[cursor++] = n >> 8;
data[cursor++] = n & 255;
}
else if (n < 4294967296) {
data[cursor++] = (major << 5) | extendedFloat32;
dataView.setUint32(cursor, n);
cursor += 4;
}
else {
data[cursor++] = (major << 5) | extendedFloat64;
dataView.setBigUint64(cursor, value);
cursor += 8;
}
continue;
}
else if (input === null) {
data[cursor++] = (majorSpecial << 5) | specialNull;
continue;
}
else if (typeof input === "boolean") {
data[cursor++] = (majorSpecial << 5) | (input ? specialTrue : specialFalse);
continue;
}
else if (typeof input === "undefined") {
throw new Error("@smithy/core/cbor: client may not serialize undefined value.");
}
else if (Array.isArray(input)) {
for (let i = input.length - 1; i >= 0; --i) {
encodeStack.push(input[i]);
}
encodeHeader(majorList, input.length);
continue;
}
else if (typeof input.byteLength === "number") {
ensureSpace(input.length * 2);
encodeHeader(majorUnstructuredByteString, input.length);
data.set(input, cursor);
cursor += input.byteLength;
continue;
}
else if (typeof input === "object") {
if (input[tagSymbol]) {
if ("tag" in input && "value" in input) {
encodeStack.push(input.value);
encodeHeader(majorTag, input.tag);
continue;
}
else {
throw new Error("tag encountered with missing fields, need 'tag' and 'value', found: " + JSON.stringify(input));
}
}
const keys = Object.keys(input);
for (let i = keys.length - 1; i >= 0; --i) {
const key = keys[i];
encodeStack.push(input[key]);
encodeStack.push(key);
}
encodeHeader(majorMap, keys.length);
continue;
}
throw new Error(`data type ${input?.constructor?.name ?? typeof input} not compatible for encoding.`);
}
}

View File

@@ -0,0 +1,25 @@
export const majorUint64 = 0;
export const majorNegativeInt64 = 1;
export const majorUnstructuredByteString = 2;
export const majorUtf8String = 3;
export const majorList = 4;
export const majorMap = 5;
export const majorTag = 6;
export const majorSpecial = 7;
export const specialFalse = 20;
export const specialTrue = 21;
export const specialNull = 22;
export const specialUndefined = 23;
export const extendedOneByte = 24;
export const extendedFloat16 = 25;
export const extendedFloat32 = 26;
export const extendedFloat64 = 27;
export const minorIndefinite = 31;
export function alloc(size) {
return typeof Buffer !== "undefined" ? Buffer.alloc(size) : new Uint8Array(size);
}
export const tagSymbol = Symbol("@smithy/core/cbor::tagSymbol");
export function tag(data) {
data[tagSymbol] = true;
return data;
}

View File

@@ -0,0 +1,21 @@
import { decode, setPayload } from "./cbor-decode";
import { encode, resize, toUint8Array } from "./cbor-encode";
export const cbor = {
deserialize(payload) {
setPayload(payload);
return decode(0, payload.length);
},
serialize(input) {
try {
encode(input);
return toUint8Array();
}
catch (e) {
toUint8Array();
throw e;
}
},
resizeEncodingBuffer(size) {
resize(size);
},
};

View File

@@ -0,0 +1,3 @@
export { cbor } from "./cbor";
export * from "./parseCborBody";
export { tagSymbol, tag } from "./cbor-types";

View File

@@ -0,0 +1,85 @@
import { collectBody } from "@smithy/core/protocols";
import { HttpRequest as __HttpRequest } from "@smithy/protocol-http";
import { calculateBodyLength } from "@smithy/util-body-length-browser";
import { cbor } from "./cbor";
import { tag, tagSymbol } from "./cbor-types";
export const parseCborBody = (streamBody, context) => {
return collectBody(streamBody, context).then(async (bytes) => {
if (bytes.length) {
try {
return cbor.deserialize(bytes);
}
catch (e) {
Object.defineProperty(e, "$responseBodyText", {
value: context.utf8Encoder(bytes),
});
throw e;
}
}
return {};
});
};
export const dateToTag = (date) => {
return tag({
tag: 1,
value: date.getTime() / 1000,
});
};
export const parseCborErrorBody = async (errorBody, context) => {
const value = await parseCborBody(errorBody, context);
value.message = value.message ?? value.Message;
return value;
};
export const loadSmithyRpcV2CborErrorCode = (output, data) => {
const sanitizeErrorCode = (rawValue) => {
let cleanValue = rawValue;
if (typeof cleanValue === "number") {
cleanValue = cleanValue.toString();
}
if (cleanValue.indexOf(",") >= 0) {
cleanValue = cleanValue.split(",")[0];
}
if (cleanValue.indexOf(":") >= 0) {
cleanValue = cleanValue.split(":")[0];
}
if (cleanValue.indexOf("#") >= 0) {
cleanValue = cleanValue.split("#")[1];
}
return cleanValue;
};
if (data["__type"] !== undefined) {
return sanitizeErrorCode(data["__type"]);
}
if (data.code !== undefined) {
return sanitizeErrorCode(data.code);
}
};
export const checkCborResponse = (response) => {
if (String(response.headers["smithy-protocol"]).toLowerCase() !== "rpc-v2-cbor") {
throw new Error("Malformed RPCv2 CBOR response, status: " + response.statusCode);
}
};
export const buildHttpRpcRequest = async (context, headers, path, resolvedHostname, body) => {
const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
const contents = {
protocol,
hostname,
port,
method: "POST",
path: basePath.endsWith("/") ? basePath.slice(0, -1) + path : basePath + path,
headers: {
...headers,
},
};
if (resolvedHostname !== undefined) {
contents.hostname = resolvedHostname;
}
if (body !== undefined) {
contents.body = body;
try {
contents.headers["content-length"] = String(calculateBodyLength(body));
}
catch (e) { }
}
return new __HttpRequest(contents);
};

View File

@@ -0,0 +1,11 @@
import { Uint8ArrayBlobAdapter } from "@smithy/util-stream";
export const collectBody = async (streamBody = new Uint8Array(), context) => {
if (streamBody instanceof Uint8Array) {
return Uint8ArrayBlobAdapter.mutate(streamBody);
}
if (!streamBody) {
return Uint8ArrayBlobAdapter.mutate(new Uint8Array());
}
const fromContext = context.streamCollector(streamBody);
return Uint8ArrayBlobAdapter.mutate(await fromContext);
};

View File

@@ -0,0 +1,5 @@
export function extendedEncodeURIComponent(str) {
return encodeURIComponent(str).replace(/[!'()*]/g, function (c) {
return "%" + c.charCodeAt(0).toString(16).toUpperCase();
});
}

View File

@@ -0,0 +1,4 @@
export * from "./collect-stream-body";
export * from "./extended-encode-uri-component";
export * from "./requestBuilder";
export * from "./resolve-path";

View File

@@ -0,0 +1,67 @@
import { HttpRequest } from "@smithy/protocol-http";
import { resolvedPath } from "./resolve-path";
export function requestBuilder(input, context) {
return new RequestBuilder(input, context);
}
export class RequestBuilder {
constructor(input, context) {
this.input = input;
this.context = context;
this.query = {};
this.method = "";
this.headers = {};
this.path = "";
this.body = null;
this.hostname = "";
this.resolvePathStack = [];
}
async build() {
const { hostname, protocol = "https", port, path: basePath } = await this.context.endpoint();
this.path = basePath;
for (const resolvePath of this.resolvePathStack) {
resolvePath(this.path);
}
return new HttpRequest({
protocol,
hostname: this.hostname || hostname,
port,
method: this.method,
path: this.path,
query: this.query,
body: this.body,
headers: this.headers,
});
}
hn(hostname) {
this.hostname = hostname;
return this;
}
bp(uriLabel) {
this.resolvePathStack.push((basePath) => {
this.path = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + uriLabel;
});
return this;
}
p(memberName, labelValueProvider, uriLabel, isGreedyLabel) {
this.resolvePathStack.push((path) => {
this.path = resolvedPath(path, this.input, memberName, labelValueProvider, uriLabel, isGreedyLabel);
});
return this;
}
h(headers) {
this.headers = headers;
return this;
}
q(query) {
this.query = query;
return this;
}
b(body) {
this.body = body;
return this;
}
m(method) {
this.method = method;
return this;
}
}

View File

@@ -0,0 +1,19 @@
import { extendedEncodeURIComponent } from "./extended-encode-uri-component";
export const resolvedPath = (resolvedPath, input, memberName, labelValueProvider, uriLabel, isGreedyLabel) => {
if (input != null && input[memberName] !== undefined) {
const labelValue = labelValueProvider();
if (labelValue.length <= 0) {
throw new Error("Empty value provided for input HTTP label: " + memberName + ".");
}
resolvedPath = resolvedPath.replace(uriLabel, isGreedyLabel
? labelValue
.split("/")
.map((segment) => extendedEncodeURIComponent(segment))
.join("/")
: extendedEncodeURIComponent(labelValue));
}
else {
throw new Error("No value provided for input HTTP label: " + memberName + ".");
}
return resolvedPath;
};

View File

@@ -0,0 +1 @@
export * from "./value/NumericValue";

View File

@@ -0,0 +1,9 @@
export class NumericValue {
constructor(string, type) {
this.string = string;
this.type = type;
}
}
export function nv(string) {
return new NumericValue(string, "bigDecimal");
}

View File

@@ -0,0 +1,13 @@
export class DefaultIdentityProviderConfig {
constructor(config) {
this.authSchemes = new Map();
for (const [key, value] of Object.entries(config)) {
if (value !== undefined) {
this.authSchemes.set(key, value);
}
}
}
getIdentityProvider(schemeId) {
return this.authSchemes.get(schemeId);
}
}

View File

@@ -0,0 +1,34 @@
import { HttpRequest } from "@smithy/protocol-http";
import { HttpApiKeyAuthLocation } from "@smithy/types";
export class HttpApiKeyAuthSigner {
async sign(httpRequest, identity, signingProperties) {
if (!signingProperties) {
throw new Error("request could not be signed with `apiKey` since the `name` and `in` signer properties are missing");
}
if (!signingProperties.name) {
throw new Error("request could not be signed with `apiKey` since the `name` signer property is missing");
}
if (!signingProperties.in) {
throw new Error("request could not be signed with `apiKey` since the `in` signer property is missing");
}
if (!identity.apiKey) {
throw new Error("request could not be signed with `apiKey` since the `apiKey` is not defined");
}
const clonedRequest = HttpRequest.clone(httpRequest);
if (signingProperties.in === HttpApiKeyAuthLocation.QUERY) {
clonedRequest.query[signingProperties.name] = identity.apiKey;
}
else if (signingProperties.in === HttpApiKeyAuthLocation.HEADER) {
clonedRequest.headers[signingProperties.name] = signingProperties.scheme
? `${signingProperties.scheme} ${identity.apiKey}`
: identity.apiKey;
}
else {
throw new Error("request can only be signed with `apiKey` locations `query` or `header`, " +
"but found: `" +
signingProperties.in +
"`");
}
return clonedRequest;
}
}

View File

@@ -0,0 +1,11 @@
import { HttpRequest } from "@smithy/protocol-http";
export class HttpBearerAuthSigner {
async sign(httpRequest, identity, signingProperties) {
const clonedRequest = HttpRequest.clone(httpRequest);
if (!identity.token) {
throw new Error("request could not be signed with `token` since the `token` is not defined");
}
clonedRequest.headers["Authorization"] = `Bearer ${identity.token}`;
return clonedRequest;
}
}

View File

@@ -0,0 +1,3 @@
export * from "./httpApiKeyAuth";
export * from "./httpBearerAuth";
export * from "./noAuth";

View File

@@ -0,0 +1,5 @@
export class NoAuthSigner {
async sign(httpRequest, identity, signingProperties) {
return httpRequest;
}
}

View File

@@ -0,0 +1,3 @@
export * from "./DefaultIdentityProviderConfig";
export * from "./httpAuthSchemes";
export * from "./memoizeIdentityProvider";

View File

@@ -0,0 +1,53 @@
export const createIsIdentityExpiredFunction = (expirationMs) => (identity) => doesIdentityRequireRefresh(identity) && identity.expiration.getTime() - Date.now() < expirationMs;
export const EXPIRATION_MS = 300000;
export const isIdentityExpired = createIsIdentityExpiredFunction(EXPIRATION_MS);
export const doesIdentityRequireRefresh = (identity) => identity.expiration !== undefined;
export const memoizeIdentityProvider = (provider, isExpired, requiresRefresh) => {
if (provider === undefined) {
return undefined;
}
const normalizedProvider = typeof provider !== "function" ? async () => Promise.resolve(provider) : provider;
let resolved;
let pending;
let hasResult;
let isConstant = false;
const coalesceProvider = async (options) => {
if (!pending) {
pending = normalizedProvider(options);
}
try {
resolved = await pending;
hasResult = true;
isConstant = false;
}
finally {
pending = undefined;
}
return resolved;
};
if (isExpired === undefined) {
return async (options) => {
if (!hasResult || options?.forceRefresh) {
resolved = await coalesceProvider(options);
}
return resolved;
};
}
return async (options) => {
if (!hasResult || options?.forceRefresh) {
resolved = await coalesceProvider(options);
}
if (isConstant) {
return resolved;
}
if (!requiresRefresh(resolved)) {
isConstant = true;
return resolved;
}
if (isExpired(resolved)) {
await coalesceProvider(options);
return resolved;
}
return resolved;
};
};

View File

@@ -0,0 +1,5 @@
import { HandlerExecutionContext } from "@smithy/types";
/**
* @internal
*/
export declare const getSmithyContext: (context: HandlerExecutionContext) => Record<string, unknown>;

View File

@@ -0,0 +1,8 @@
export * from "./getSmithyContext";
export * from "./middleware-http-auth-scheme";
export * from "./middleware-http-signing";
export * from "./normalizeProvider";
export { createPaginator } from "./pagination/createPaginator";
export * from "./protocols/requestBuilder";
export * from "./setFeature";
export * from "./util-identity-and-auth";

View File

@@ -0,0 +1,18 @@
import { HandlerExecutionContext, HttpAuthSchemeParameters, HttpAuthSchemeParametersProvider, IdentityProviderConfig, Pluggable, RelativeMiddlewareOptions, SerializeHandlerOptions } from "@smithy/types";
import { PreviouslyResolved } from "./httpAuthSchemeMiddleware";
/**
* @internal
*/
export declare const httpAuthSchemeEndpointRuleSetMiddlewareOptions: SerializeHandlerOptions & RelativeMiddlewareOptions;
/**
* @internal
*/
interface HttpAuthSchemeEndpointRuleSetPluginOptions<TConfig extends object, TContext extends HandlerExecutionContext, TParameters extends HttpAuthSchemeParameters, TInput extends object> {
httpAuthSchemeParametersProvider: HttpAuthSchemeParametersProvider<TConfig, TContext, TParameters, TInput>;
identityProviderConfigProvider: (config: TConfig) => Promise<IdentityProviderConfig>;
}
/**
* @internal
*/
export declare const getHttpAuthSchemeEndpointRuleSetPlugin: <TConfig extends object, TContext extends HandlerExecutionContext, TParameters extends HttpAuthSchemeParameters, TInput extends object>(config: TConfig & PreviouslyResolved<TParameters>, { httpAuthSchemeParametersProvider, identityProviderConfigProvider, }: HttpAuthSchemeEndpointRuleSetPluginOptions<TConfig, TContext, TParameters, TInput>) => Pluggable<any, any>;
export {};

View File

@@ -0,0 +1,18 @@
import { HandlerExecutionContext, HttpAuthSchemeParameters, HttpAuthSchemeParametersProvider, IdentityProviderConfig, Pluggable, RelativeMiddlewareOptions, SerializeHandlerOptions } from "@smithy/types";
import { PreviouslyResolved } from "./httpAuthSchemeMiddleware";
/**
* @internal
*/
export declare const httpAuthSchemeMiddlewareOptions: SerializeHandlerOptions & RelativeMiddlewareOptions;
/**
* @internal
*/
interface HttpAuthSchemePluginOptions<TConfig extends object, TContext extends HandlerExecutionContext, TParameters extends HttpAuthSchemeParameters, TInput extends object> {
httpAuthSchemeParametersProvider: HttpAuthSchemeParametersProvider<TConfig, TContext, TParameters, TInput>;
identityProviderConfigProvider: (config: TConfig) => Promise<IdentityProviderConfig>;
}
/**
* @internal
*/
export declare const getHttpAuthSchemePlugin: <TConfig extends object, TContext extends HandlerExecutionContext, TParameters extends HttpAuthSchemeParameters, TInput extends object>(config: TConfig & PreviouslyResolved<TParameters>, { httpAuthSchemeParametersProvider, identityProviderConfigProvider, }: HttpAuthSchemePluginOptions<TConfig, TContext, TParameters, TInput>) => Pluggable<any, any>;
export {};

View File

@@ -0,0 +1,33 @@
import { HandlerExecutionContext, HttpAuthScheme, HttpAuthSchemeParameters, HttpAuthSchemeParametersProvider, HttpAuthSchemeProvider, IdentityProviderConfig, Provider, SelectedHttpAuthScheme, SerializeMiddleware, SMITHY_CONTEXT_KEY } from "@smithy/types";
/**
* @internal
*/
export interface PreviouslyResolved<TParameters extends HttpAuthSchemeParameters> {
authSchemePreference?: Provider<string[]>;
httpAuthSchemes: HttpAuthScheme[];
httpAuthSchemeProvider: HttpAuthSchemeProvider<TParameters>;
}
/**
* @internal
*/
interface HttpAuthSchemeMiddlewareOptions<TConfig extends object, TContext extends HandlerExecutionContext, TParameters extends HttpAuthSchemeParameters, TInput extends object> {
httpAuthSchemeParametersProvider: HttpAuthSchemeParametersProvider<TConfig, TContext, TParameters, TInput>;
identityProviderConfigProvider: (config: TConfig) => Promise<IdentityProviderConfig>;
}
/**
* @internal
*/
interface HttpAuthSchemeMiddlewareSmithyContext extends Record<string, unknown> {
selectedHttpAuthScheme?: SelectedHttpAuthScheme;
}
/**
* @internal
*/
interface HttpAuthSchemeMiddlewareHandlerExecutionContext extends HandlerExecutionContext {
[SMITHY_CONTEXT_KEY]?: HttpAuthSchemeMiddlewareSmithyContext;
}
/**
* @internal
*/
export declare const httpAuthSchemeMiddleware: <TInput extends object, Output extends object, TConfig extends object, TContext extends HttpAuthSchemeMiddlewareHandlerExecutionContext, TParameters extends HttpAuthSchemeParameters>(config: TConfig & PreviouslyResolved<TParameters>, mwOptions: HttpAuthSchemeMiddlewareOptions<TConfig, TContext, TParameters, TInput>) => SerializeMiddleware<TInput, Output>;
export {};

View File

@@ -0,0 +1,3 @@
export * from "./httpAuthSchemeMiddleware";
export * from "./getHttpAuthSchemeEndpointRuleSetPlugin";
export * from "./getHttpAuthSchemePlugin";

View File

@@ -0,0 +1,10 @@
import { HttpAuthOption } from "@smithy/types";
/**
* Resolves list of auth options based on the supported ones, vs the preference list.
*
* @param candidateAuthOptions list of supported auth options selected by the standard
* resolution process (model-based, endpoints 2.0, etc.)
* @param authSchemePreference list of auth schemes preferred by user.
* @returns
*/
export declare const resolveAuthOptions: (candidateAuthOptions: HttpAuthOption[], authSchemePreference: string[]) => HttpAuthOption[];

View File

@@ -0,0 +1,9 @@
import { FinalizeRequestHandlerOptions, Pluggable, RelativeMiddlewareOptions } from "@smithy/types";
/**
* @internal
*/
export declare const httpSigningMiddlewareOptions: FinalizeRequestHandlerOptions & RelativeMiddlewareOptions;
/**
* @internal
*/
export declare const getHttpSigningPlugin: <Input extends object, Output extends object>(config: object) => Pluggable<Input, Output>;

View File

@@ -0,0 +1,5 @@
import { FinalizeRequestMiddleware } from "@smithy/types";
/**
* @internal
*/
export declare const httpSigningMiddleware: <Input extends object, Output extends object>(config: object) => FinalizeRequestMiddleware<Input, Output>;

View File

@@ -0,0 +1,2 @@
export * from "./httpSigningMiddleware";
export * from "./getHttpSigningMiddleware";

View File

@@ -0,0 +1,7 @@
import { Provider } from "@smithy/types";
/**
* @internal
*
* @returns a provider function for the input value if it isn't already one.
*/
export declare const normalizeProvider: <T>(input: T | Provider<T>) => Provider<T>;

View File

@@ -0,0 +1,7 @@
import type { PaginationConfiguration, Paginator } from "@smithy/types";
/**
* @internal
*
* Creates a paginator.
*/
export declare function createPaginator<PaginationConfigType extends PaginationConfiguration, InputType extends object, OutputType extends object>(ClientCtor: any, CommandCtor: any, inputTokenName: string, outputTokenName: string, pageSizeTokenName?: string): (config: PaginationConfigType, input: InputType, ...additionalArguments: any[]) => Paginator<OutputType>;

View File

@@ -0,0 +1,5 @@
/**
* @internal
* Backwards compatibility re-export.
*/
export { requestBuilder } from "@smithy/core/protocols";

View File

@@ -0,0 +1,12 @@
import type { HandlerExecutionContext, SmithyFeatures } from "@smithy/types";
/**
* @internal
* Indicates to the request context that a given feature is active.
*
* @param context - handler execution context.
* @param feature - readable name of feature.
* @param value - encoding value of feature. This is required because the
* specification asks the library not to include a runtime lookup of all
* the feature identifiers.
*/
export declare function setFeature<F extends keyof SmithyFeatures>(context: HandlerExecutionContext, feature: F, value: SmithyFeatures[F]): void;

View File

@@ -0,0 +1,17 @@
import { CborValueType, Float32, Uint8, Uint32 } from "./cbor-types";
/**
* @internal
* @param bytes - to be set as the decode source.
*
* Sets the decode bytearray source and its data view.
*/
export declare function setPayload(bytes: Uint8Array): void;
/**
* @internal
* Decodes the data between the two indices.
*/
export declare function decode(at: Uint32, to: Uint32): CborValueType;
/**
* @internal
*/
export declare function bytesToFloat16(a: Uint8, b: Uint8): Float32;

View File

@@ -0,0 +1,9 @@
/**
* @internal
*/
export declare function toUint8Array(): Uint8Array;
export declare function resize(size: number): void;
/**
* @param _input - JS data object.
*/
export declare function encode(_input: any): void;

View File

@@ -0,0 +1,62 @@
export type CborItemType = undefined | boolean | number | bigint | [CborUnstructuredByteStringType, Uint64] | string | CborTagType;
export type CborTagType = {
tag: Uint64 | number;
value: CborValueType;
[tagSymbol]: true;
};
export type CborUnstructuredByteStringType = Uint8Array;
export type CborListType<T = any> = Array<T>;
export type CborMapType<T = any> = Record<string, T>;
export type CborCollectionType<T = any> = CborMapType<T> | CborListType<T>;
export type CborValueType = CborItemType | CborCollectionType | any;
export type CborArgumentLength = 1 | 2 | 4 | 8;
export type CborArgumentLengthOffset = 1 | 2 | 3 | 5 | 9;
export type CborOffset = number;
export type Uint8 = number;
export type Uint32 = number;
export type Uint64 = bigint;
export type Float32 = number;
export type Int64 = bigint;
export type Float16Binary = number;
export type Float32Binary = number;
export type CborMajorType = typeof majorUint64 | typeof majorNegativeInt64 | typeof majorUnstructuredByteString | typeof majorUtf8String | typeof majorList | typeof majorMap | typeof majorTag | typeof majorSpecial;
export declare const majorUint64 = 0;
export declare const majorNegativeInt64 = 1;
export declare const majorUnstructuredByteString = 2;
export declare const majorUtf8String = 3;
export declare const majorList = 4;
export declare const majorMap = 5;
export declare const majorTag = 6;
export declare const majorSpecial = 7;
export declare const specialFalse = 20;
export declare const specialTrue = 21;
export declare const specialNull = 22;
export declare const specialUndefined = 23;
export declare const extendedOneByte = 24;
export declare const extendedFloat16 = 25;
export declare const extendedFloat32 = 26;
export declare const extendedFloat64 = 27;
export declare const minorIndefinite = 31;
export declare function alloc(size: number): Uint8Array<ArrayBuffer> | Buffer<ArrayBuffer>;
/**
* @public
*
* The presence of this symbol as an object key indicates it should be considered a tag
* for CBOR serialization purposes.
*
* The object must also have the properties "tag" and "value".
*/
export declare const tagSymbol: unique symbol;
/**
* @public
* Applies the tag symbol to the object.
*/
export declare function tag(data: {
tag: number | bigint;
value: any;
[tagSymbol]?: true;
}): {
tag: number | bigint;
value: any;
[tagSymbol]: true;
};

View File

@@ -0,0 +1,26 @@
/**
* This implementation is synchronous and only implements the parts of CBOR
* specification used by Smithy RPCv2 CBOR protocol.
*
* This cbor serde implementation is derived from AWS SDK for Go's implementation.
* @see https://github.com/aws/smithy-go/tree/main/encoding/cbor
*
* The cbor-x implementation was also instructional:
* @see https://github.com/kriszyp/cbor-x
*/
export declare const cbor: {
deserialize(payload: Uint8Array): any;
serialize(input: any): Uint8Array<ArrayBufferLike>;
/**
* @public
* @param size - byte length to allocate.
*
* This may be used to garbage collect the CBOR
* shared encoding buffer space,
* e.g. resizeEncodingBuffer(0);
*
* This may also be used to pre-allocate more space for
* CBOR encoding, e.g. resizeEncodingBuffer(100_000_000);
*/
resizeEncodingBuffer(size: number): void;
};

View File

@@ -0,0 +1,3 @@
export { cbor } from "./cbor";
export * from "./parseCborBody";
export { tagSymbol, tag } from "./cbor-types";

View File

@@ -0,0 +1,31 @@
import { HttpRequest as __HttpRequest } from "@smithy/protocol-http";
import { HeaderBag as __HeaderBag, HttpResponse, SerdeContext as __SerdeContext, SerdeContext } from "@smithy/types";
import { tagSymbol } from "./cbor-types";
/**
* @internal
*/
export declare const parseCborBody: (streamBody: any, context: SerdeContext) => any;
/**
* @internal
*/
export declare const dateToTag: (date: Date) => {
tag: number | bigint;
value: any;
[tagSymbol]: true;
};
/**
* @internal
*/
export declare const parseCborErrorBody: (errorBody: any, context: SerdeContext) => Promise<any>;
/**
* @internal
*/
export declare const loadSmithyRpcV2CborErrorCode: (output: HttpResponse, data: any) => string | undefined;
/**
* @internal
*/
export declare const checkCborResponse: (response: HttpResponse) => void;
/**
* @internal
*/
export declare const buildHttpRpcRequest: (context: __SerdeContext, headers: __HeaderBag, path: string, resolvedHostname: string | undefined, body: any) => Promise<__HttpRequest>;

View File

@@ -0,0 +1,10 @@
import { SerdeContext } from "@smithy/types";
import { Uint8ArrayBlobAdapter } from "@smithy/util-stream";
/**
* @internal
*
* Collect low-level response body stream to Uint8Array.
*/
export declare const collectBody: (streamBody: any | undefined, context: {
streamCollector: SerdeContext["streamCollector"];
}) => Promise<Uint8ArrayBlobAdapter>;

View File

@@ -0,0 +1,7 @@
/**
* @internal
*
* Function that wraps encodeURIComponent to encode additional characters
* to fully adhere to RFC 3986.
*/
export declare function extendedEncodeURIComponent(str: string): string;

View File

@@ -0,0 +1,4 @@
export * from "./collect-stream-body";
export * from "./extended-encode-uri-component";
export * from "./requestBuilder";
export * from "./resolve-path";

View File

@@ -0,0 +1,51 @@
import { HttpRequest } from "@smithy/protocol-http";
import type { SerdeContext } from "@smithy/types";
/**
* @internal
* used in code-generated serde.
*/
export declare function requestBuilder(input: any, context: SerdeContext): RequestBuilder;
/**
* @internal
*/
export declare class RequestBuilder {
private input;
private context;
private query;
private method;
private headers;
private path;
private body;
private hostname;
private resolvePathStack;
constructor(input: any, context: SerdeContext);
build(): Promise<HttpRequest>;
/**
* Brevity setter for "hostname".
*/
hn(hostname: string): this;
/**
* Brevity initial builder for "basepath".
*/
bp(uriLabel: string): this;
/**
* Brevity incremental builder for "path".
*/
p(memberName: string, labelValueProvider: () => string | undefined, uriLabel: string, isGreedyLabel: boolean): this;
/**
* Brevity setter for "headers".
*/
h(headers: Record<string, string>): this;
/**
* Brevity setter for "query".
*/
q(query: Record<string, string>): this;
/**
* Brevity setter for "body".
*/
b(body: any): this;
/**
* Brevity setter for "method".
*/
m(method: string): this;
}

View File

@@ -0,0 +1,4 @@
/**
* @internal
*/
export declare const resolvedPath: (resolvedPath: string, input: unknown, memberName: string, labelValueProvider: () => string | undefined, uriLabel: string, isGreedyLabel: boolean) => string;

View File

@@ -0,0 +1 @@
export * from "./value/NumericValue";

View File

@@ -0,0 +1,31 @@
/**
* Types which may be represented by {@link NumericValue}.
*
* There is currently only one option, because BigInteger and Long should
* use JS BigInt directly, and all other numeric types can be contained in JS Number.
*
* @public
*/
export type NumericType = "bigDecimal";
/**
* Serialization container for Smithy simple types that do not have a
* direct JavaScript runtime representation.
*
* This container does not perform numeric mathematical operations.
* It is a container for discerning a value's true type.
*
* It allows storage of numeric types not representable in JS without
* making a decision on what numeric library to use.
*
* @public
*/
export declare class NumericValue {
readonly string: string;
readonly type: NumericType;
constructor(string: string, type: NumericType);
}
/**
* Serde shortcut.
* @internal
*/
export declare function nv(string: string): NumericValue;

View File

@@ -0,0 +1,5 @@
import { HandlerExecutionContext } from "@smithy/types";
/**
* @internal
*/
export declare const getSmithyContext: (context: HandlerExecutionContext) => Record<string, unknown>;

View File

@@ -0,0 +1,8 @@
export * from "./getSmithyContext";
export * from "./middleware-http-auth-scheme";
export * from "./middleware-http-signing";
export * from "./normalizeProvider";
export { createPaginator } from "./pagination/createPaginator";
export * from "./protocols/requestBuilder";
export * from "./setFeature";
export * from "./util-identity-and-auth";

View File

@@ -0,0 +1,18 @@
import { HandlerExecutionContext, HttpAuthSchemeParameters, HttpAuthSchemeParametersProvider, IdentityProviderConfig, Pluggable, RelativeMiddlewareOptions, SerializeHandlerOptions } from "@smithy/types";
import { PreviouslyResolved } from "./httpAuthSchemeMiddleware";
/**
* @internal
*/
export declare const httpAuthSchemeEndpointRuleSetMiddlewareOptions: SerializeHandlerOptions & RelativeMiddlewareOptions;
/**
* @internal
*/
interface HttpAuthSchemeEndpointRuleSetPluginOptions<TConfig extends object, TContext extends HandlerExecutionContext, TParameters extends HttpAuthSchemeParameters, TInput extends object> {
httpAuthSchemeParametersProvider: HttpAuthSchemeParametersProvider<TConfig, TContext, TParameters, TInput>;
identityProviderConfigProvider: (config: TConfig) => Promise<IdentityProviderConfig>;
}
/**
* @internal
*/
export declare const getHttpAuthSchemeEndpointRuleSetPlugin: <TConfig extends object, TContext extends HandlerExecutionContext, TParameters extends HttpAuthSchemeParameters, TInput extends object>(config: TConfig & PreviouslyResolved<TParameters>, { httpAuthSchemeParametersProvider, identityProviderConfigProvider, }: HttpAuthSchemeEndpointRuleSetPluginOptions<TConfig, TContext, TParameters, TInput>) => Pluggable<any, any>;
export {};

View File

@@ -0,0 +1,18 @@
import { HandlerExecutionContext, HttpAuthSchemeParameters, HttpAuthSchemeParametersProvider, IdentityProviderConfig, Pluggable, RelativeMiddlewareOptions, SerializeHandlerOptions } from "@smithy/types";
import { PreviouslyResolved } from "./httpAuthSchemeMiddleware";
/**
* @internal
*/
export declare const httpAuthSchemeMiddlewareOptions: SerializeHandlerOptions & RelativeMiddlewareOptions;
/**
* @internal
*/
interface HttpAuthSchemePluginOptions<TConfig extends object, TContext extends HandlerExecutionContext, TParameters extends HttpAuthSchemeParameters, TInput extends object> {
httpAuthSchemeParametersProvider: HttpAuthSchemeParametersProvider<TConfig, TContext, TParameters, TInput>;
identityProviderConfigProvider: (config: TConfig) => Promise<IdentityProviderConfig>;
}
/**
* @internal
*/
export declare const getHttpAuthSchemePlugin: <TConfig extends object, TContext extends HandlerExecutionContext, TParameters extends HttpAuthSchemeParameters, TInput extends object>(config: TConfig & PreviouslyResolved<TParameters>, { httpAuthSchemeParametersProvider, identityProviderConfigProvider, }: HttpAuthSchemePluginOptions<TConfig, TContext, TParameters, TInput>) => Pluggable<any, any>;
export {};

View File

@@ -0,0 +1,33 @@
import { HandlerExecutionContext, HttpAuthScheme, HttpAuthSchemeParameters, HttpAuthSchemeParametersProvider, HttpAuthSchemeProvider, IdentityProviderConfig, Provider, SelectedHttpAuthScheme, SerializeMiddleware, SMITHY_CONTEXT_KEY } from "@smithy/types";
/**
* @internal
*/
export interface PreviouslyResolved<TParameters extends HttpAuthSchemeParameters> {
authSchemePreference?: Provider<string[]>;
httpAuthSchemes: HttpAuthScheme[];
httpAuthSchemeProvider: HttpAuthSchemeProvider<TParameters>;
}
/**
* @internal
*/
interface HttpAuthSchemeMiddlewareOptions<TConfig extends object, TContext extends HandlerExecutionContext, TParameters extends HttpAuthSchemeParameters, TInput extends object> {
httpAuthSchemeParametersProvider: HttpAuthSchemeParametersProvider<TConfig, TContext, TParameters, TInput>;
identityProviderConfigProvider: (config: TConfig) => Promise<IdentityProviderConfig>;
}
/**
* @internal
*/
interface HttpAuthSchemeMiddlewareSmithyContext extends Record<string, unknown> {
selectedHttpAuthScheme?: SelectedHttpAuthScheme;
}
/**
* @internal
*/
interface HttpAuthSchemeMiddlewareHandlerExecutionContext extends HandlerExecutionContext {
[SMITHY_CONTEXT_KEY]?: HttpAuthSchemeMiddlewareSmithyContext;
}
/**
* @internal
*/
export declare const httpAuthSchemeMiddleware: <TInput extends object, Output extends object, TConfig extends object, TContext extends HttpAuthSchemeMiddlewareHandlerExecutionContext, TParameters extends HttpAuthSchemeParameters>(config: TConfig & PreviouslyResolved<TParameters>, mwOptions: HttpAuthSchemeMiddlewareOptions<TConfig, TContext, TParameters, TInput>) => SerializeMiddleware<TInput, Output>;
export {};

View File

@@ -0,0 +1,3 @@
export * from "./httpAuthSchemeMiddleware";
export * from "./getHttpAuthSchemeEndpointRuleSetPlugin";
export * from "./getHttpAuthSchemePlugin";

View File

@@ -0,0 +1,10 @@
import { HttpAuthOption } from "@smithy/types";
/**
* Resolves list of auth options based on the supported ones, vs the preference list.
*
* @param candidateAuthOptions list of supported auth options selected by the standard
* resolution process (model-based, endpoints 2.0, etc.)
* @param authSchemePreference list of auth schemes preferred by user.
* @returns
*/
export declare const resolveAuthOptions: (candidateAuthOptions: HttpAuthOption[], authSchemePreference: string[]) => HttpAuthOption[];

View File

@@ -0,0 +1,9 @@
import { FinalizeRequestHandlerOptions, Pluggable, RelativeMiddlewareOptions } from "@smithy/types";
/**
* @internal
*/
export declare const httpSigningMiddlewareOptions: FinalizeRequestHandlerOptions & RelativeMiddlewareOptions;
/**
* @internal
*/
export declare const getHttpSigningPlugin: <Input extends object, Output extends object>(config: object) => Pluggable<Input, Output>;

View File

@@ -0,0 +1,5 @@
import { FinalizeRequestMiddleware } from "@smithy/types";
/**
* @internal
*/
export declare const httpSigningMiddleware: <Input extends object, Output extends object>(config: object) => FinalizeRequestMiddleware<Input, Output>;

View File

@@ -0,0 +1,2 @@
export * from "./httpSigningMiddleware";
export * from "./getHttpSigningMiddleware";

View File

@@ -0,0 +1,7 @@
import { Provider } from "@smithy/types";
/**
* @internal
*
* @returns a provider function for the input value if it isn't already one.
*/
export declare const normalizeProvider: <T>(input: T | Provider<T>) => Provider<T>;

Some files were not shown because too many files have changed in this diff Show More