UEA-Prodem
This commit is contained in:
+201
@@ -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 2018 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.
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
# `@aws-sdk/core`
|
||||
|
||||
This package provides common or core functionality to the AWS SDK for JavaScript (v3).
|
||||
|
||||
You do not need to explicitly install this package, since it will be transitively installed by AWS SDK clients.
|
||||
|
||||
## `@aws-sdk/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).
|
||||
|
||||
Think of `@aws-sdk/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 an SDK 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 `@aws-sdk/<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 `@aws-sdk/core`.
|
||||
The linter runs during `yarn build` and also as `yarn lint`.
|
||||
|
||||
### When should I create an `@aws-sdk/core/submodule` vs. `@aws-sdk/new-package`?
|
||||
|
||||
Keep in mind that the core package is installed by all AWS SDK clients.
|
||||
|
||||
If the component functionality is upstream of multiple clients, it is
|
||||
a good candidate for a core submodule. For example, XML serialization.
|
||||
|
||||
If the component's functionality is downstream of a client, for example S3 pre-signing,
|
||||
it should be a standalone package with potentially a peer or runtime dependency on an AWS SDK client.
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* Do not edit:
|
||||
* This is a compatibility redirect for contexts that do not understand package.json exports field.
|
||||
*/
|
||||
declare module "@aws-sdk/core/account-id-endpoint" {
|
||||
export * from "@aws-sdk/core/dist-types/submodules/account-id-endpoint/index.d";
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* Do not edit:
|
||||
* This is a compatibility redirect for contexts that do not understand package.json exports field.
|
||||
*/
|
||||
module.exports = require("./dist-cjs/submodules/account-id-endpoint/index.js");
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* Do not edit:
|
||||
* This is a compatibility redirect for contexts that do not understand package.json exports field.
|
||||
*/
|
||||
declare module "@aws-sdk/core/client" {
|
||||
export * from "@aws-sdk/core/dist-types/submodules/client/index.d";
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* Do not edit:
|
||||
* This is a compatibility redirect for contexts that do not understand package.json exports field.
|
||||
*/
|
||||
module.exports = require("./dist-cjs/submodules/client/index.js");
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
'use strict';
|
||||
|
||||
var client = require('@aws-sdk/core/client');
|
||||
var httpAuthSchemes = require('@aws-sdk/core/httpAuthSchemes');
|
||||
var protocols = require('@aws-sdk/core/protocols');
|
||||
|
||||
|
||||
|
||||
exports.emitWarningIfUnsupportedVersion = client.emitWarningIfUnsupportedVersion;
|
||||
exports.getLongPollPlugin = client.getLongPollPlugin;
|
||||
exports.setCredentialFeature = client.setCredentialFeature;
|
||||
exports.setFeature = client.setFeature;
|
||||
exports.setTokenFeature = client.setTokenFeature;
|
||||
exports.state = client.state;
|
||||
exports.AWSSDKSigV4Signer = httpAuthSchemes.AwsSdkSigV4Signer;
|
||||
exports.AwsSdkSigV4ASigner = httpAuthSchemes.AwsSdkSigV4ASigner;
|
||||
exports.AwsSdkSigV4Signer = httpAuthSchemes.AwsSdkSigV4Signer;
|
||||
exports.NODE_AUTH_SCHEME_PREFERENCE_OPTIONS = httpAuthSchemes.NODE_AUTH_SCHEME_PREFERENCE_OPTIONS;
|
||||
exports.NODE_SIGV4A_CONFIG_OPTIONS = httpAuthSchemes.NODE_SIGV4A_CONFIG_OPTIONS;
|
||||
exports.getBearerTokenEnvKey = httpAuthSchemes.getBearerTokenEnvKey;
|
||||
exports.resolveAWSSDKSigV4Config = httpAuthSchemes.resolveAwsSdkSigV4Config;
|
||||
exports.resolveAwsSdkSigV4AConfig = httpAuthSchemes.resolveAwsSdkSigV4AConfig;
|
||||
exports.resolveAwsSdkSigV4Config = httpAuthSchemes.resolveAwsSdkSigV4Config;
|
||||
exports.validateSigningProperties = httpAuthSchemes.validateSigningProperties;
|
||||
exports.AwsEc2QueryProtocol = protocols.AwsEc2QueryProtocol;
|
||||
exports.AwsJson1_0Protocol = protocols.AwsJson1_0Protocol;
|
||||
exports.AwsJson1_1Protocol = protocols.AwsJson1_1Protocol;
|
||||
exports.AwsJsonRpcProtocol = protocols.AwsJsonRpcProtocol;
|
||||
exports.AwsQueryProtocol = protocols.AwsQueryProtocol;
|
||||
exports.AwsRestJsonProtocol = protocols.AwsRestJsonProtocol;
|
||||
exports.AwsRestXmlProtocol = protocols.AwsRestXmlProtocol;
|
||||
exports.AwsSmithyRpcV2CborProtocol = protocols.AwsSmithyRpcV2CborProtocol;
|
||||
exports.JsonCodec = protocols.JsonCodec;
|
||||
exports.JsonShapeDeserializer = protocols.JsonShapeDeserializer;
|
||||
exports.JsonShapeSerializer = protocols.JsonShapeSerializer;
|
||||
exports.QueryShapeSerializer = protocols.QueryShapeSerializer;
|
||||
exports.XmlCodec = protocols.XmlCodec;
|
||||
exports.XmlShapeDeserializer = protocols.XmlShapeDeserializer;
|
||||
exports.XmlShapeSerializer = protocols.XmlShapeSerializer;
|
||||
exports._toBool = protocols._toBool;
|
||||
exports._toNum = protocols._toNum;
|
||||
exports._toStr = protocols._toStr;
|
||||
exports.awsExpectUnion = protocols.awsExpectUnion;
|
||||
exports.loadJsonRpcErrorCode = protocols.loadJsonRpcErrorCode;
|
||||
exports.loadRestJsonErrorCode = protocols.loadRestJsonErrorCode;
|
||||
exports.loadRestXmlErrorCode = protocols.loadRestXmlErrorCode;
|
||||
exports.parseJsonBody = protocols.parseJsonBody;
|
||||
exports.parseJsonErrorBody = protocols.parseJsonErrorBody;
|
||||
exports.parseXmlBody = protocols.parseXmlBody;
|
||||
exports.parseXmlErrorBody = protocols.parseXmlErrorBody;
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
'use strict';
|
||||
|
||||
var client = require('@smithy/core/client');
|
||||
|
||||
const DEFAULT_ACCOUNT_ID_ENDPOINT_MODE = "preferred";
|
||||
const ACCOUNT_ID_ENDPOINT_MODE_VALUES = ["disabled", "preferred", "required"];
|
||||
function validateAccountIdEndpointMode(value) {
|
||||
return ACCOUNT_ID_ENDPOINT_MODE_VALUES.includes(value);
|
||||
}
|
||||
|
||||
const resolveAccountIdEndpointModeConfig = (input) => {
|
||||
const { accountIdEndpointMode } = input;
|
||||
const accountIdEndpointModeProvider = client.normalizeProvider(accountIdEndpointMode ?? DEFAULT_ACCOUNT_ID_ENDPOINT_MODE);
|
||||
return Object.assign(input, {
|
||||
accountIdEndpointMode: async () => {
|
||||
const accIdMode = await accountIdEndpointModeProvider();
|
||||
if (!validateAccountIdEndpointMode(accIdMode)) {
|
||||
throw new Error(`Invalid value for accountIdEndpointMode: ${accIdMode}. Valid values are: "required", "preferred", "disabled".`);
|
||||
}
|
||||
return accIdMode;
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const err = "Invalid AccountIdEndpointMode value";
|
||||
const _throw = (message) => {
|
||||
throw new Error(message);
|
||||
};
|
||||
const ENV_ACCOUNT_ID_ENDPOINT_MODE = "AWS_ACCOUNT_ID_ENDPOINT_MODE";
|
||||
const CONFIG_ACCOUNT_ID_ENDPOINT_MODE = "account_id_endpoint_mode";
|
||||
const NODE_ACCOUNT_ID_ENDPOINT_MODE_CONFIG_OPTIONS = {
|
||||
environmentVariableSelector: (env) => {
|
||||
const value = env[ENV_ACCOUNT_ID_ENDPOINT_MODE];
|
||||
if (value && !validateAccountIdEndpointMode(value)) {
|
||||
_throw(err);
|
||||
}
|
||||
return value;
|
||||
},
|
||||
configFileSelector: (profile) => {
|
||||
const value = profile[CONFIG_ACCOUNT_ID_ENDPOINT_MODE];
|
||||
if (value && !validateAccountIdEndpointMode(value)) {
|
||||
_throw(err);
|
||||
}
|
||||
return value;
|
||||
},
|
||||
default: DEFAULT_ACCOUNT_ID_ENDPOINT_MODE,
|
||||
};
|
||||
|
||||
exports.ACCOUNT_ID_ENDPOINT_MODE_VALUES = ACCOUNT_ID_ENDPOINT_MODE_VALUES;
|
||||
exports.CONFIG_ACCOUNT_ID_ENDPOINT_MODE = CONFIG_ACCOUNT_ID_ENDPOINT_MODE;
|
||||
exports.DEFAULT_ACCOUNT_ID_ENDPOINT_MODE = DEFAULT_ACCOUNT_ID_ENDPOINT_MODE;
|
||||
exports.ENV_ACCOUNT_ID_ENDPOINT_MODE = ENV_ACCOUNT_ID_ENDPOINT_MODE;
|
||||
exports.NODE_ACCOUNT_ID_ENDPOINT_MODE_CONFIG_OPTIONS = NODE_ACCOUNT_ID_ENDPOINT_MODE_CONFIG_OPTIONS;
|
||||
exports.resolveAccountIdEndpointModeConfig = resolveAccountIdEndpointModeConfig;
|
||||
exports.validateAccountIdEndpointMode = validateAccountIdEndpointMode;
|
||||
+595
File diff suppressed because one or more lines are too long
+795
File diff suppressed because one or more lines are too long
+588
File diff suppressed because one or more lines are too long
+313
@@ -0,0 +1,313 @@
|
||||
'use strict';
|
||||
|
||||
var protocols = require('@smithy/core/protocols');
|
||||
var core = require('@smithy/core');
|
||||
var config = require('@smithy/core/config');
|
||||
var client = require('@aws-sdk/core/client');
|
||||
var signatureV4 = require('@smithy/signature-v4');
|
||||
|
||||
const getDateHeader = (response) => protocols.HttpResponse.isInstance(response) ? response.headers?.date ?? response.headers?.Date : undefined;
|
||||
|
||||
const getSkewCorrectedDate = (systemClockOffset) => new Date(Date.now() + systemClockOffset);
|
||||
|
||||
const isClockSkewed = (clockTime, systemClockOffset) => Math.abs(getSkewCorrectedDate(systemClockOffset).getTime() - clockTime) >= 300000;
|
||||
|
||||
const getUpdatedSystemClockOffset = (clockTime, currentSystemClockOffset) => {
|
||||
const clockTimeInMs = Date.parse(clockTime);
|
||||
if (isClockSkewed(clockTimeInMs, currentSystemClockOffset)) {
|
||||
return clockTimeInMs - Date.now();
|
||||
}
|
||||
return currentSystemClockOffset;
|
||||
};
|
||||
|
||||
const throwSigningPropertyError = (name, property) => {
|
||||
if (!property) {
|
||||
throw new Error(`Property \`${name}\` is not resolved for AWS SDK SigV4Auth`);
|
||||
}
|
||||
return property;
|
||||
};
|
||||
const validateSigningProperties = async (signingProperties) => {
|
||||
const context = throwSigningPropertyError("context", signingProperties.context);
|
||||
const config = throwSigningPropertyError("config", signingProperties.config);
|
||||
const authScheme = context.endpointV2?.properties?.authSchemes?.[0];
|
||||
const signerFunction = throwSigningPropertyError("signer", config.signer);
|
||||
const signer = await signerFunction(authScheme);
|
||||
const signingRegion = signingProperties?.signingRegion;
|
||||
const signingRegionSet = signingProperties?.signingRegionSet;
|
||||
const signingName = signingProperties?.signingName;
|
||||
return {
|
||||
config,
|
||||
signer,
|
||||
signingRegion,
|
||||
signingRegionSet,
|
||||
signingName,
|
||||
};
|
||||
};
|
||||
class AwsSdkSigV4Signer {
|
||||
async sign(httpRequest, identity, signingProperties) {
|
||||
if (!protocols.HttpRequest.isInstance(httpRequest)) {
|
||||
throw new Error("The request is not an instance of `HttpRequest` and cannot be signed");
|
||||
}
|
||||
const validatedProps = await validateSigningProperties(signingProperties);
|
||||
const { config, signer } = validatedProps;
|
||||
let { signingRegion, signingName } = validatedProps;
|
||||
const handlerExecutionContext = signingProperties.context;
|
||||
if (handlerExecutionContext?.authSchemes?.length ?? 0 > 1) {
|
||||
const [first, second] = handlerExecutionContext.authSchemes;
|
||||
if (first?.name === "sigv4a" && second?.name === "sigv4") {
|
||||
signingRegion = second?.signingRegion ?? signingRegion;
|
||||
signingName = second?.signingName ?? signingName;
|
||||
}
|
||||
}
|
||||
signingProperties._preRequestSystemClockOffset = config.systemClockOffset;
|
||||
const signedRequest = await signer.sign(httpRequest, {
|
||||
signingDate: getSkewCorrectedDate(config.systemClockOffset),
|
||||
signingRegion: signingRegion,
|
||||
signingService: signingName,
|
||||
});
|
||||
return signedRequest;
|
||||
}
|
||||
errorHandler(signingProperties) {
|
||||
return (error) => {
|
||||
const errorException = error;
|
||||
const serverTime = errorException.ServerTime ?? getDateHeader(errorException.$response);
|
||||
if (serverTime) {
|
||||
const config = throwSigningPropertyError("config", signingProperties.config);
|
||||
const preRequestOffset = signingProperties._preRequestSystemClockOffset;
|
||||
const newOffset = getUpdatedSystemClockOffset(serverTime, config.systemClockOffset);
|
||||
const isLocalCorrection = newOffset !== config.systemClockOffset;
|
||||
const isConcurrentCorrection = preRequestOffset !== undefined && preRequestOffset !== newOffset;
|
||||
const clockSkewCorrected = isLocalCorrection || isConcurrentCorrection;
|
||||
if (clockSkewCorrected && errorException.$metadata) {
|
||||
config.systemClockOffset = newOffset;
|
||||
errorException.$metadata.clockSkewCorrected = true;
|
||||
}
|
||||
}
|
||||
throw error;
|
||||
};
|
||||
}
|
||||
successHandler(httpResponse, signingProperties) {
|
||||
const dateHeader = getDateHeader(httpResponse);
|
||||
if (dateHeader) {
|
||||
const config = throwSigningPropertyError("config", signingProperties.config);
|
||||
config.systemClockOffset = getUpdatedSystemClockOffset(dateHeader, config.systemClockOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
const AWSSDKSigV4Signer = AwsSdkSigV4Signer;
|
||||
|
||||
class AwsSdkSigV4ASigner extends AwsSdkSigV4Signer {
|
||||
async sign(httpRequest, identity, signingProperties) {
|
||||
if (!protocols.HttpRequest.isInstance(httpRequest)) {
|
||||
throw new Error("The request is not an instance of `HttpRequest` and cannot be signed");
|
||||
}
|
||||
const { config, signer, signingRegion, signingRegionSet, signingName } = await validateSigningProperties(signingProperties);
|
||||
const configResolvedSigningRegionSet = await config.sigv4aSigningRegionSet?.();
|
||||
const multiRegionOverride = (configResolvedSigningRegionSet ??
|
||||
signingRegionSet ?? [signingRegion]).join(",");
|
||||
signingProperties._preRequestSystemClockOffset = config.systemClockOffset;
|
||||
const signedRequest = await signer.sign(httpRequest, {
|
||||
signingDate: getSkewCorrectedDate(config.systemClockOffset),
|
||||
signingRegion: multiRegionOverride,
|
||||
signingService: signingName,
|
||||
});
|
||||
return signedRequest;
|
||||
}
|
||||
}
|
||||
|
||||
const getArrayForCommaSeparatedString = (str) => typeof str === "string" && str.length > 0 ? str.split(",").map((item) => item.trim()) : [];
|
||||
|
||||
const getBearerTokenEnvKey = (signingName) => `AWS_BEARER_TOKEN_${signingName.replace(/[\s-]/g, "_").toUpperCase()}`;
|
||||
|
||||
const NODE_AUTH_SCHEME_PREFERENCE_ENV_KEY = "AWS_AUTH_SCHEME_PREFERENCE";
|
||||
const NODE_AUTH_SCHEME_PREFERENCE_CONFIG_KEY = "auth_scheme_preference";
|
||||
const NODE_AUTH_SCHEME_PREFERENCE_OPTIONS = {
|
||||
environmentVariableSelector: (env, options) => {
|
||||
if (options?.signingName) {
|
||||
const bearerTokenKey = getBearerTokenEnvKey(options.signingName);
|
||||
if (bearerTokenKey in env)
|
||||
return ["httpBearerAuth"];
|
||||
}
|
||||
if (!(NODE_AUTH_SCHEME_PREFERENCE_ENV_KEY in env))
|
||||
return undefined;
|
||||
return getArrayForCommaSeparatedString(env[NODE_AUTH_SCHEME_PREFERENCE_ENV_KEY]);
|
||||
},
|
||||
configFileSelector: (profile) => {
|
||||
if (!(NODE_AUTH_SCHEME_PREFERENCE_CONFIG_KEY in profile))
|
||||
return undefined;
|
||||
return getArrayForCommaSeparatedString(profile[NODE_AUTH_SCHEME_PREFERENCE_CONFIG_KEY]);
|
||||
},
|
||||
default: [],
|
||||
};
|
||||
|
||||
const resolveAwsSdkSigV4AConfig = (config) => {
|
||||
config.sigv4aSigningRegionSet = core.normalizeProvider(config.sigv4aSigningRegionSet);
|
||||
return config;
|
||||
};
|
||||
const NODE_SIGV4A_CONFIG_OPTIONS = {
|
||||
environmentVariableSelector(env) {
|
||||
if (env.AWS_SIGV4A_SIGNING_REGION_SET) {
|
||||
return env.AWS_SIGV4A_SIGNING_REGION_SET.split(",").map((_) => _.trim());
|
||||
}
|
||||
throw new config.ProviderError("AWS_SIGV4A_SIGNING_REGION_SET not set in env.", {
|
||||
tryNextLink: true,
|
||||
});
|
||||
},
|
||||
configFileSelector(profile) {
|
||||
if (profile.sigv4a_signing_region_set) {
|
||||
return (profile.sigv4a_signing_region_set ?? "").split(",").map((_) => _.trim());
|
||||
}
|
||||
throw new config.ProviderError("sigv4a_signing_region_set not set in profile.", {
|
||||
tryNextLink: true,
|
||||
});
|
||||
},
|
||||
default: undefined,
|
||||
};
|
||||
|
||||
const resolveAwsSdkSigV4Config = (config) => {
|
||||
let inputCredentials = config.credentials;
|
||||
let isUserSupplied = !!config.credentials;
|
||||
let resolvedCredentials = undefined;
|
||||
Object.defineProperty(config, "credentials", {
|
||||
set(credentials) {
|
||||
if (credentials && credentials !== inputCredentials && credentials !== resolvedCredentials) {
|
||||
isUserSupplied = true;
|
||||
}
|
||||
inputCredentials = credentials;
|
||||
const memoizedProvider = normalizeCredentialProvider(config, {
|
||||
credentials: inputCredentials,
|
||||
credentialDefaultProvider: config.credentialDefaultProvider,
|
||||
});
|
||||
const boundProvider = bindCallerConfig(config, memoizedProvider);
|
||||
if (isUserSupplied && !boundProvider.attributed) {
|
||||
const isCredentialObject = typeof inputCredentials === "object" && inputCredentials !== null;
|
||||
resolvedCredentials = async (options) => {
|
||||
const creds = await boundProvider(options);
|
||||
const attributedCreds = creds;
|
||||
if (isCredentialObject && (!attributedCreds.$source || Object.keys(attributedCreds.$source).length === 0)) {
|
||||
return client.setCredentialFeature(attributedCreds, "CREDENTIALS_CODE", "e");
|
||||
}
|
||||
return attributedCreds;
|
||||
};
|
||||
resolvedCredentials.memoized = boundProvider.memoized;
|
||||
resolvedCredentials.configBound = boundProvider.configBound;
|
||||
resolvedCredentials.attributed = true;
|
||||
}
|
||||
else {
|
||||
resolvedCredentials = boundProvider;
|
||||
}
|
||||
},
|
||||
get() {
|
||||
return resolvedCredentials;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
});
|
||||
config.credentials = inputCredentials;
|
||||
const { signingEscapePath = true, systemClockOffset = config.systemClockOffset || 0, sha256, } = config;
|
||||
let signer;
|
||||
if (config.signer) {
|
||||
signer = core.normalizeProvider(config.signer);
|
||||
}
|
||||
else if (config.regionInfoProvider) {
|
||||
signer = () => core.normalizeProvider(config.region)()
|
||||
.then(async (region) => [
|
||||
(await config.regionInfoProvider(region, {
|
||||
useFipsEndpoint: await config.useFipsEndpoint(),
|
||||
useDualstackEndpoint: await config.useDualstackEndpoint(),
|
||||
})) || {},
|
||||
region,
|
||||
])
|
||||
.then(([regionInfo, region]) => {
|
||||
const { signingRegion, signingService } = regionInfo;
|
||||
config.signingRegion = config.signingRegion || signingRegion || region;
|
||||
config.signingName = config.signingName || signingService || config.serviceId;
|
||||
const params = {
|
||||
...config,
|
||||
credentials: config.credentials,
|
||||
region: config.signingRegion,
|
||||
service: config.signingName,
|
||||
sha256,
|
||||
uriEscapePath: signingEscapePath,
|
||||
};
|
||||
const SignerCtor = config.signerConstructor || signatureV4.SignatureV4;
|
||||
return new SignerCtor(params);
|
||||
});
|
||||
}
|
||||
else {
|
||||
signer = async (authScheme) => {
|
||||
authScheme = Object.assign({}, {
|
||||
name: "sigv4",
|
||||
signingName: config.signingName || config.defaultSigningName,
|
||||
signingRegion: await core.normalizeProvider(config.region)(),
|
||||
properties: {},
|
||||
}, authScheme);
|
||||
const signingRegion = authScheme.signingRegion;
|
||||
const signingService = authScheme.signingName;
|
||||
config.signingRegion = config.signingRegion || signingRegion;
|
||||
config.signingName = config.signingName || signingService || config.serviceId;
|
||||
const params = {
|
||||
...config,
|
||||
credentials: config.credentials,
|
||||
region: config.signingRegion,
|
||||
service: config.signingName,
|
||||
sha256,
|
||||
uriEscapePath: signingEscapePath,
|
||||
};
|
||||
const SignerCtor = config.signerConstructor || signatureV4.SignatureV4;
|
||||
return new SignerCtor(params);
|
||||
};
|
||||
}
|
||||
const resolvedConfig = Object.assign(config, {
|
||||
systemClockOffset,
|
||||
signingEscapePath,
|
||||
signer,
|
||||
});
|
||||
return resolvedConfig;
|
||||
};
|
||||
const resolveAWSSDKSigV4Config = resolveAwsSdkSigV4Config;
|
||||
function normalizeCredentialProvider(config, { credentials, credentialDefaultProvider, }) {
|
||||
let credentialsProvider;
|
||||
if (credentials) {
|
||||
if (!credentials?.memoized) {
|
||||
credentialsProvider = core.memoizeIdentityProvider(credentials, core.isIdentityExpired, core.doesIdentityRequireRefresh);
|
||||
}
|
||||
else {
|
||||
credentialsProvider = credentials;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (credentialDefaultProvider) {
|
||||
credentialsProvider = core.normalizeProvider(credentialDefaultProvider(Object.assign({}, config, {
|
||||
parentClientConfig: config,
|
||||
})));
|
||||
}
|
||||
else {
|
||||
credentialsProvider = async () => {
|
||||
throw new Error("@aws-sdk/core::resolveAwsSdkSigV4Config - `credentials` not provided and no credentialDefaultProvider was configured.");
|
||||
};
|
||||
}
|
||||
}
|
||||
credentialsProvider.memoized = true;
|
||||
return credentialsProvider;
|
||||
}
|
||||
function bindCallerConfig(config, credentialsProvider) {
|
||||
if (credentialsProvider.configBound) {
|
||||
return credentialsProvider;
|
||||
}
|
||||
const fn = async (options) => credentialsProvider({ ...options, callerClientConfig: config });
|
||||
fn.memoized = credentialsProvider.memoized;
|
||||
fn.configBound = true;
|
||||
return fn;
|
||||
}
|
||||
|
||||
exports.AWSSDKSigV4Signer = AWSSDKSigV4Signer;
|
||||
exports.AwsSdkSigV4ASigner = AwsSdkSigV4ASigner;
|
||||
exports.AwsSdkSigV4Signer = AwsSdkSigV4Signer;
|
||||
exports.NODE_AUTH_SCHEME_PREFERENCE_OPTIONS = NODE_AUTH_SCHEME_PREFERENCE_OPTIONS;
|
||||
exports.NODE_SIGV4A_CONFIG_OPTIONS = NODE_SIGV4A_CONFIG_OPTIONS;
|
||||
exports.getBearerTokenEnvKey = getBearerTokenEnvKey;
|
||||
exports.resolveAWSSDKSigV4Config = resolveAWSSDKSigV4Config;
|
||||
exports.resolveAwsSdkSigV4AConfig = resolveAwsSdkSigV4AConfig;
|
||||
exports.resolveAwsSdkSigV4Config = resolveAwsSdkSigV4Config;
|
||||
exports.validateSigningProperties = validateSigningProperties;
|
||||
+1916
File diff suppressed because it is too large
Load Diff
+59
@@ -0,0 +1,59 @@
|
||||
'use strict';
|
||||
|
||||
var protocols = require('@smithy/core/protocols');
|
||||
|
||||
const validate = (str) => typeof str === "string" && str.indexOf("arn:") === 0 && str.split(":").length >= 6;
|
||||
const parse = (arn) => {
|
||||
const segments = arn.split(":");
|
||||
if (segments.length < 6 || segments[0] !== "arn")
|
||||
throw new Error("Malformed ARN");
|
||||
const [, partition, service, region, accountId, ...resource] = segments;
|
||||
return {
|
||||
partition,
|
||||
service,
|
||||
region,
|
||||
accountId,
|
||||
resource: resource.join(":"),
|
||||
};
|
||||
};
|
||||
const build = (arnObject) => {
|
||||
const { partition = "aws", service, region, accountId, resource } = arnObject;
|
||||
if ([service, region, accountId, resource].some((segment) => typeof segment !== "string")) {
|
||||
throw new Error("Input ARN object is invalid");
|
||||
}
|
||||
return `arn:${partition}:${service}:${region}:${accountId}:${resource}`;
|
||||
};
|
||||
|
||||
function formatUrl(request) {
|
||||
const { port, query } = request;
|
||||
let { protocol, path, hostname } = request;
|
||||
if (protocol && protocol.slice(-1) !== ":") {
|
||||
protocol += ":";
|
||||
}
|
||||
if (port) {
|
||||
hostname += `:${port}`;
|
||||
}
|
||||
if (path && path.charAt(0) !== "/") {
|
||||
path = `/${path}`;
|
||||
}
|
||||
let queryString = query ? protocols.buildQueryString(query) : "";
|
||||
if (queryString && queryString[0] !== "?") {
|
||||
queryString = `?${queryString}`;
|
||||
}
|
||||
let auth = "";
|
||||
if (request.username != null || request.password != null) {
|
||||
const username = request.username ?? "";
|
||||
const password = request.password ?? "";
|
||||
auth = `${username}:${password}@`;
|
||||
}
|
||||
let fragment = "";
|
||||
if (request.fragment) {
|
||||
fragment = `#${request.fragment}`;
|
||||
}
|
||||
return `${protocol}//${auth}${hostname}${path}${queryString}${fragment}`;
|
||||
}
|
||||
|
||||
exports.build = build;
|
||||
exports.formatUrl = formatUrl;
|
||||
exports.parse = parse;
|
||||
exports.validate = validate;
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
export { emitWarningIfUnsupportedVersion, getLongPollPlugin, setCredentialFeature, setFeature, setTokenFeature, state, } from "@aws-sdk/core/client";
|
||||
export { AwsSdkSigV4ASigner, AwsSdkSigV4Signer, AwsSdkSigV4Signer as AWSSDKSigV4Signer, getBearerTokenEnvKey, NODE_AUTH_SCHEME_PREFERENCE_OPTIONS, NODE_SIGV4A_CONFIG_OPTIONS, resolveAwsSdkSigV4AConfig, resolveAwsSdkSigV4Config, resolveAwsSdkSigV4Config as resolveAWSSDKSigV4Config, validateSigningProperties, } from "@aws-sdk/core/httpAuthSchemes";
|
||||
export { _toBool, _toNum, _toStr, awsExpectUnion, AwsEc2QueryProtocol, AwsJson1_0Protocol, AwsJson1_1Protocol, AwsJsonRpcProtocol, AwsQueryProtocol, AwsRestJsonProtocol, AwsRestXmlProtocol, AwsSmithyRpcV2CborProtocol, JsonCodec, JsonShapeDeserializer, JsonShapeSerializer, loadJsonRpcErrorCode, loadRestJsonErrorCode, loadRestXmlErrorCode, parseJsonBody, parseJsonErrorBody, parseXmlBody, parseXmlErrorBody, QueryShapeSerializer, XmlCodec, XmlShapeDeserializer, XmlShapeSerializer, } from "@aws-sdk/core/protocols";
|
||||
Generated
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
import { normalizeProvider } from "@smithy/core/client";
|
||||
import { DEFAULT_ACCOUNT_ID_ENDPOINT_MODE, validateAccountIdEndpointMode } from "./AccountIdEndpointModeConstants";
|
||||
export const resolveAccountIdEndpointModeConfig = (input) => {
|
||||
const { accountIdEndpointMode } = input;
|
||||
const accountIdEndpointModeProvider = normalizeProvider(accountIdEndpointMode ?? DEFAULT_ACCOUNT_ID_ENDPOINT_MODE);
|
||||
return Object.assign(input, {
|
||||
accountIdEndpointMode: async () => {
|
||||
const accIdMode = await accountIdEndpointModeProvider();
|
||||
if (!validateAccountIdEndpointMode(accIdMode)) {
|
||||
throw new Error(`Invalid value for accountIdEndpointMode: ${accIdMode}. Valid values are: "required", "preferred", "disabled".`);
|
||||
}
|
||||
return accIdMode;
|
||||
},
|
||||
});
|
||||
};
|
||||
Generated
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
export const DEFAULT_ACCOUNT_ID_ENDPOINT_MODE = "preferred";
|
||||
export const ACCOUNT_ID_ENDPOINT_MODE_VALUES = ["disabled", "preferred", "required"];
|
||||
export function validateAccountIdEndpointMode(value) {
|
||||
return ACCOUNT_ID_ENDPOINT_MODE_VALUES.includes(value);
|
||||
}
|
||||
Generated
Vendored
+24
@@ -0,0 +1,24 @@
|
||||
import { DEFAULT_ACCOUNT_ID_ENDPOINT_MODE, validateAccountIdEndpointMode } from "./AccountIdEndpointModeConstants";
|
||||
const err = "Invalid AccountIdEndpointMode value";
|
||||
const _throw = (message) => {
|
||||
throw new Error(message);
|
||||
};
|
||||
export const ENV_ACCOUNT_ID_ENDPOINT_MODE = "AWS_ACCOUNT_ID_ENDPOINT_MODE";
|
||||
export const CONFIG_ACCOUNT_ID_ENDPOINT_MODE = "account_id_endpoint_mode";
|
||||
export const NODE_ACCOUNT_ID_ENDPOINT_MODE_CONFIG_OPTIONS = {
|
||||
environmentVariableSelector: (env) => {
|
||||
const value = env[ENV_ACCOUNT_ID_ENDPOINT_MODE];
|
||||
if (value && !validateAccountIdEndpointMode(value)) {
|
||||
_throw(err);
|
||||
}
|
||||
return value;
|
||||
},
|
||||
configFileSelector: (profile) => {
|
||||
const value = profile[CONFIG_ACCOUNT_ID_ENDPOINT_MODE];
|
||||
if (value && !validateAccountIdEndpointMode(value)) {
|
||||
_throw(err);
|
||||
}
|
||||
return value;
|
||||
},
|
||||
default: DEFAULT_ACCOUNT_ID_ENDPOINT_MODE,
|
||||
};
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
export * from "./AccountIdEndpointModeConfigResolver";
|
||||
export * from "./AccountIdEndpointModeConstants";
|
||||
export * from "./NodeAccountIdEndpointModeConfigOptions";
|
||||
Generated
Vendored
+24
@@ -0,0 +1,24 @@
|
||||
export const state = {
|
||||
warningEmitted: false,
|
||||
};
|
||||
export const emitWarningIfUnsupportedVersion = (version) => {
|
||||
if (version && !state.warningEmitted) {
|
||||
if (process.env.AWS_SDK_JS_NODE_VERSION_SUPPORT_WARNING_DISABLED === "true") {
|
||||
state.warningEmitted = true;
|
||||
return;
|
||||
}
|
||||
const userMajorVersion = parseInt(version.substring(1, version.indexOf(".")));
|
||||
const vv = 22;
|
||||
if (userMajorVersion < vv) {
|
||||
state.warningEmitted = true;
|
||||
process.emitWarning(`NodeVersionSupportWarning: The AWS SDK for JavaScript (v3)
|
||||
versions published after the first week of January 2027
|
||||
will require node >=${vv}. You are running node ${version}.
|
||||
|
||||
To continue receiving updates to AWS services, bug fixes,
|
||||
and security updates please upgrade to node >=${vv}.
|
||||
|
||||
More information can be found at: https://a.co/c895JFp`);
|
||||
}
|
||||
}
|
||||
};
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
const no = Symbol.for("node-only");
|
||||
export const emitWarningIfUnsupportedVersion = no;
|
||||
export const state = no;
|
||||
export { getLongPollPlugin } from "./longPollMiddleware";
|
||||
export { setCredentialFeature } from "./setCredentialFeature";
|
||||
export { setFeature } from "./setFeature";
|
||||
export { setTokenFeature } from "./setTokenFeature";
|
||||
export { hostHeaderMiddleware, hostHeaderMiddlewareOptions, getHostHeaderPlugin, resolveHostHeaderConfig, } from "./middleware-host-header/hostHeaderMiddleware";
|
||||
export { loggerMiddleware, loggerMiddlewareOptions, getLoggerPlugin } from "./middleware-logger/loggerMiddleware";
|
||||
export { recursionDetectionMiddlewareOptions } from "./middleware-recursion-detection/configuration";
|
||||
export { getRecursionDetectionPlugin } from "./middleware-recursion-detection/getRecursionDetectionPlugin.browser";
|
||||
export { recursionDetectionMiddleware } from "./middleware-recursion-detection/recursionDetectionMiddleware.browser";
|
||||
export { DEFAULT_UA_APP_ID, resolveUserAgentConfig } from "./middleware-user-agent/configurations";
|
||||
export { userAgentMiddleware, getUserAgentMiddlewareOptions, getUserAgentPlugin, } from "./middleware-user-agent/user-agent-middleware";
|
||||
export { createDefaultUserAgentProvider, defaultUserAgent, fallback } from "./util-user-agent-browser/defaultUserAgent";
|
||||
export const crtAvailability = no;
|
||||
export const NODE_APP_ID_CONFIG_OPTIONS = no;
|
||||
export const UA_APP_ID_ENV_NAME = no;
|
||||
export const UA_APP_ID_INI_NAME = no;
|
||||
export { createUserAgentStringParsingProvider } from "./util-user-agent-browser/createUserAgentStringParsingProvider";
|
||||
export { awsEndpointFunctions } from "./util-endpoints/aws";
|
||||
export { resolveEndpoint } from "./util-endpoints/resolveEndpoint";
|
||||
export { resolveDefaultAwsRegionalEndpointsConfig, toEndpointV1, } from "./util-endpoints/resolveDefaultAwsRegionalEndpointsConfig";
|
||||
export { isIpAddress } from "./util-endpoints/lib/isIpAddress";
|
||||
export { isVirtualHostableS3Bucket } from "./util-endpoints/lib/aws/isVirtualHostableS3Bucket";
|
||||
export { parseArn } from "./util-endpoints/lib/aws/parseArn";
|
||||
export { partition, setPartitionInfo, useDefaultPartitionInfo, getUserAgentPrefix, } from "./util-endpoints/lib/aws/partition";
|
||||
export { EndpointError } from "./util-endpoints/types/EndpointError";
|
||||
export const REGION_ENV_NAME = no;
|
||||
export const REGION_INI_NAME = no;
|
||||
export const NODE_REGION_CONFIG_OPTIONS = no;
|
||||
export const NODE_REGION_CONFIG_FILE_OPTIONS = no;
|
||||
export { resolveRegionConfig } from "./region-config-resolver/awsRegionConfig";
|
||||
export { stsRegionDefaultResolver } from "./region-config-resolver/stsRegionDefaultResolver.browser";
|
||||
export const stsRegionWarning = no;
|
||||
export { getAwsRegionExtensionConfiguration, resolveAwsRegionExtensionConfiguration, } from "./region-config-resolver/extensions";
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
export { emitWarningIfUnsupportedVersion, state } from "./emitWarningIfUnsupportedVersion";
|
||||
export { getLongPollPlugin } from "./longPollMiddleware";
|
||||
export { setCredentialFeature } from "./setCredentialFeature";
|
||||
export { setFeature } from "./setFeature";
|
||||
export { setTokenFeature } from "./setTokenFeature";
|
||||
export { hostHeaderMiddleware, hostHeaderMiddlewareOptions, getHostHeaderPlugin, resolveHostHeaderConfig, } from "./middleware-host-header/hostHeaderMiddleware";
|
||||
export { loggerMiddleware, loggerMiddlewareOptions, getLoggerPlugin } from "./middleware-logger/loggerMiddleware";
|
||||
export { recursionDetectionMiddlewareOptions } from "./middleware-recursion-detection/configuration";
|
||||
export { getRecursionDetectionPlugin } from "./middleware-recursion-detection/getRecursionDetectionPlugin";
|
||||
export { recursionDetectionMiddleware } from "./middleware-recursion-detection/recursionDetectionMiddleware";
|
||||
export { DEFAULT_UA_APP_ID, resolveUserAgentConfig } from "./middleware-user-agent/configurations";
|
||||
export { userAgentMiddleware, getUserAgentMiddlewareOptions, getUserAgentPlugin, } from "./middleware-user-agent/user-agent-middleware";
|
||||
export { createDefaultUserAgentProvider, defaultUserAgent, crtAvailability, } from "./util-user-agent-node/defaultUserAgent";
|
||||
export { NODE_APP_ID_CONFIG_OPTIONS, UA_APP_ID_ENV_NAME, UA_APP_ID_INI_NAME, } from "./util-user-agent-node/nodeAppIdConfigOptions";
|
||||
export { fallback } from "./util-user-agent-browser/defaultUserAgent";
|
||||
export { createUserAgentStringParsingProvider } from "./util-user-agent-browser/createUserAgentStringParsingProvider";
|
||||
export { awsEndpointFunctions } from "./util-endpoints/aws";
|
||||
export { resolveEndpoint } from "./util-endpoints/resolveEndpoint";
|
||||
export { resolveDefaultAwsRegionalEndpointsConfig, toEndpointV1, } from "./util-endpoints/resolveDefaultAwsRegionalEndpointsConfig";
|
||||
export { isIpAddress } from "./util-endpoints/lib/isIpAddress";
|
||||
export { isVirtualHostableS3Bucket } from "./util-endpoints/lib/aws/isVirtualHostableS3Bucket";
|
||||
export { parseArn } from "./util-endpoints/lib/aws/parseArn";
|
||||
export { partition, setPartitionInfo, useDefaultPartitionInfo, getUserAgentPrefix, } from "./util-endpoints/lib/aws/partition";
|
||||
export { EndpointError } from "./util-endpoints/types/EndpointError";
|
||||
export { REGION_ENV_NAME, REGION_INI_NAME, NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS, resolveRegionConfig, } from "./region-config-resolver/awsRegionConfig";
|
||||
export { stsRegionDefaultResolver, warning as stsRegionWarning, } from "./region-config-resolver/stsRegionDefaultResolver";
|
||||
export { getAwsRegionExtensionConfiguration, resolveAwsRegionExtensionConfiguration, } from "./region-config-resolver/extensions";
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
const no = Symbol.for("node-only");
|
||||
export const emitWarningIfUnsupportedVersion = no;
|
||||
export const state = no;
|
||||
export { getLongPollPlugin } from "./longPollMiddleware";
|
||||
export { setCredentialFeature } from "./setCredentialFeature";
|
||||
export { setFeature } from "./setFeature";
|
||||
export { setTokenFeature } from "./setTokenFeature";
|
||||
export { hostHeaderMiddleware, hostHeaderMiddlewareOptions, getHostHeaderPlugin, resolveHostHeaderConfig, } from "./middleware-host-header/hostHeaderMiddleware";
|
||||
export { loggerMiddleware, loggerMiddlewareOptions, getLoggerPlugin } from "./middleware-logger/loggerMiddleware";
|
||||
export { recursionDetectionMiddlewareOptions } from "./middleware-recursion-detection/configuration";
|
||||
export { getRecursionDetectionPlugin } from "./middleware-recursion-detection/getRecursionDetectionPlugin.browser";
|
||||
export { recursionDetectionMiddleware } from "./middleware-recursion-detection/recursionDetectionMiddleware.native";
|
||||
export { DEFAULT_UA_APP_ID, resolveUserAgentConfig } from "./middleware-user-agent/configurations";
|
||||
export { userAgentMiddleware, getUserAgentMiddlewareOptions, getUserAgentPlugin, } from "./middleware-user-agent/user-agent-middleware";
|
||||
export { createDefaultUserAgentProvider, defaultUserAgent } from "./util-user-agent-browser/defaultUserAgent.native";
|
||||
export const crtAvailability = no;
|
||||
export const NODE_APP_ID_CONFIG_OPTIONS = no;
|
||||
export const UA_APP_ID_ENV_NAME = no;
|
||||
export const UA_APP_ID_INI_NAME = no;
|
||||
export { fallback } from "./util-user-agent-browser/defaultUserAgent";
|
||||
export { createUserAgentStringParsingProvider } from "./util-user-agent-browser/createUserAgentStringParsingProvider";
|
||||
export { awsEndpointFunctions } from "./util-endpoints/aws";
|
||||
export { resolveEndpoint } from "./util-endpoints/resolveEndpoint";
|
||||
export { resolveDefaultAwsRegionalEndpointsConfig, toEndpointV1, } from "./util-endpoints/resolveDefaultAwsRegionalEndpointsConfig";
|
||||
export { isIpAddress } from "./util-endpoints/lib/isIpAddress";
|
||||
export { isVirtualHostableS3Bucket } from "./util-endpoints/lib/aws/isVirtualHostableS3Bucket";
|
||||
export { parseArn } from "./util-endpoints/lib/aws/parseArn";
|
||||
export { partition, setPartitionInfo, useDefaultPartitionInfo, getUserAgentPrefix, } from "./util-endpoints/lib/aws/partition";
|
||||
export { EndpointError } from "./util-endpoints/types/EndpointError";
|
||||
export const REGION_ENV_NAME = no;
|
||||
export const REGION_INI_NAME = no;
|
||||
export const NODE_REGION_CONFIG_OPTIONS = no;
|
||||
export const NODE_REGION_CONFIG_FILE_OPTIONS = no;
|
||||
export { resolveRegionConfig } from "./region-config-resolver/awsRegionConfig";
|
||||
export { stsRegionDefaultResolver } from "./region-config-resolver/stsRegionDefaultResolver.native";
|
||||
export const stsRegionWarning = no;
|
||||
export { getAwsRegionExtensionConfiguration, resolveAwsRegionExtensionConfiguration, } from "./region-config-resolver/extensions";
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
export const longPollMiddleware = () => (next, context) => async (args) => {
|
||||
context.__retryLongPoll = true;
|
||||
return next(args);
|
||||
};
|
||||
export const longPollMiddlewareOptions = {
|
||||
name: "longPollMiddleware",
|
||||
tags: ["RETRY"],
|
||||
step: "initialize",
|
||||
override: true,
|
||||
};
|
||||
export const getLongPollPlugin = (options) => ({
|
||||
applyToStack: (clientStack) => {
|
||||
clientStack.add(longPollMiddleware(), longPollMiddlewareOptions);
|
||||
},
|
||||
});
|
||||
Generated
Vendored
+33
@@ -0,0 +1,33 @@
|
||||
import { HttpRequest } from "@smithy/core/protocols";
|
||||
export function resolveHostHeaderConfig(input) {
|
||||
return input;
|
||||
}
|
||||
export const hostHeaderMiddleware = (options) => (next) => async (args) => {
|
||||
if (!HttpRequest.isInstance(args.request))
|
||||
return next(args);
|
||||
const { request } = args;
|
||||
const { handlerProtocol = "" } = options.requestHandler.metadata || {};
|
||||
if (handlerProtocol.indexOf("h2") >= 0 && !request.headers[":authority"]) {
|
||||
delete request.headers["host"];
|
||||
request.headers[":authority"] = request.hostname + (request.port ? ":" + request.port : "");
|
||||
}
|
||||
else if (!request.headers["host"]) {
|
||||
let host = request.hostname;
|
||||
if (request.port != null)
|
||||
host += `:${request.port}`;
|
||||
request.headers["host"] = host;
|
||||
}
|
||||
return next(args);
|
||||
};
|
||||
export const hostHeaderMiddlewareOptions = {
|
||||
name: "hostHeaderMiddleware",
|
||||
step: "build",
|
||||
priority: "low",
|
||||
tags: ["HOST"],
|
||||
override: true,
|
||||
};
|
||||
export const getHostHeaderPlugin = (options) => ({
|
||||
applyToStack: (clientStack) => {
|
||||
clientStack.add(hostHeaderMiddleware(options), hostHeaderMiddlewareOptions);
|
||||
},
|
||||
});
|
||||
Generated
Vendored
+42
@@ -0,0 +1,42 @@
|
||||
export const loggerMiddleware = () => (next, context) => async (args) => {
|
||||
try {
|
||||
const response = await next(args);
|
||||
const { clientName, commandName, logger, dynamoDbDocumentClientOptions = {} } = context;
|
||||
const { overrideInputFilterSensitiveLog, overrideOutputFilterSensitiveLog } = dynamoDbDocumentClientOptions;
|
||||
const inputFilterSensitiveLog = overrideInputFilterSensitiveLog ?? context.inputFilterSensitiveLog;
|
||||
const outputFilterSensitiveLog = overrideOutputFilterSensitiveLog ?? context.outputFilterSensitiveLog;
|
||||
const { $metadata, ...outputWithoutMetadata } = response.output;
|
||||
logger?.info?.({
|
||||
clientName,
|
||||
commandName,
|
||||
input: inputFilterSensitiveLog(args.input),
|
||||
output: outputFilterSensitiveLog(outputWithoutMetadata),
|
||||
metadata: $metadata,
|
||||
});
|
||||
return response;
|
||||
}
|
||||
catch (error) {
|
||||
const { clientName, commandName, logger, dynamoDbDocumentClientOptions = {} } = context;
|
||||
const { overrideInputFilterSensitiveLog } = dynamoDbDocumentClientOptions;
|
||||
const inputFilterSensitiveLog = overrideInputFilterSensitiveLog ?? context.inputFilterSensitiveLog;
|
||||
logger?.error?.({
|
||||
clientName,
|
||||
commandName,
|
||||
input: inputFilterSensitiveLog(args.input),
|
||||
error,
|
||||
metadata: error.$metadata,
|
||||
});
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
export const loggerMiddlewareOptions = {
|
||||
name: "loggerMiddleware",
|
||||
tags: ["LOGGER"],
|
||||
step: "initialize",
|
||||
override: true,
|
||||
};
|
||||
export const getLoggerPlugin = (options) => ({
|
||||
applyToStack: (clientStack) => {
|
||||
clientStack.add(loggerMiddleware(), loggerMiddlewareOptions);
|
||||
},
|
||||
});
|
||||
node_modules/@aws-sdk/core/dist-es/submodules/client/middleware-recursion-detection/configuration.js
Generated
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
export const recursionDetectionMiddlewareOptions = {
|
||||
step: "build",
|
||||
tags: ["RECURSION_DETECTION"],
|
||||
name: "recursionDetectionMiddleware",
|
||||
override: true,
|
||||
priority: "low",
|
||||
};
|
||||
Generated
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
export const getRecursionDetectionPlugin = (options) => ({
|
||||
applyToStack: (clientStack) => { },
|
||||
});
|
||||
Generated
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
import { recursionDetectionMiddlewareOptions } from "./configuration";
|
||||
import { recursionDetectionMiddleware } from "./recursionDetectionMiddleware";
|
||||
export const getRecursionDetectionPlugin = (options) => ({
|
||||
applyToStack: (clientStack) => {
|
||||
clientStack.add(recursionDetectionMiddleware(), recursionDetectionMiddlewareOptions);
|
||||
},
|
||||
});
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
export const recursionDetectionMiddleware = () => (next) => async (args) => next(args);
|
||||
Generated
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
import { InvokeStore } from "@aws/lambda-invoke-store";
|
||||
import { HttpRequest } from "@smithy/core/protocols";
|
||||
const TRACE_ID_HEADER_NAME = "X-Amzn-Trace-Id";
|
||||
const ENV_LAMBDA_FUNCTION_NAME = "AWS_LAMBDA_FUNCTION_NAME";
|
||||
const ENV_TRACE_ID = "_X_AMZN_TRACE_ID";
|
||||
export const recursionDetectionMiddleware = () => (next) => async (args) => {
|
||||
const { request } = args;
|
||||
if (!HttpRequest.isInstance(request)) {
|
||||
return next(args);
|
||||
}
|
||||
const traceIdHeader = Object.keys(request.headers ?? {}).find((h) => h.toLowerCase() === TRACE_ID_HEADER_NAME.toLowerCase()) ??
|
||||
TRACE_ID_HEADER_NAME;
|
||||
if (request.headers.hasOwnProperty(traceIdHeader)) {
|
||||
return next(args);
|
||||
}
|
||||
const functionName = process.env[ENV_LAMBDA_FUNCTION_NAME];
|
||||
const traceIdFromEnv = process.env[ENV_TRACE_ID];
|
||||
const invokeStore = await InvokeStore.getInstanceAsync();
|
||||
const traceIdFromInvokeStore = invokeStore?.getXRayTraceId();
|
||||
const traceId = traceIdFromInvokeStore ?? traceIdFromEnv;
|
||||
const nonEmptyString = (str) => typeof str === "string" && str.length > 0;
|
||||
if (nonEmptyString(functionName) && nonEmptyString(traceId)) {
|
||||
request.headers[TRACE_ID_HEADER_NAME] = traceId;
|
||||
}
|
||||
return next({
|
||||
...args,
|
||||
request,
|
||||
});
|
||||
};
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
export const recursionDetectionMiddleware = () => (next) => async (args) => next(args);
|
||||
Generated
Vendored
+49
@@ -0,0 +1,49 @@
|
||||
import { RETRY_MODES } from "@smithy/core/retry";
|
||||
import { setFeature } from "../setFeature";
|
||||
const ACCOUNT_ID_ENDPOINT_REGEX = /\d{12}\.ddb/;
|
||||
export async function checkFeatures(context, config, args) {
|
||||
const request = args.request;
|
||||
if (request?.headers?.["smithy-protocol"] === "rpc-v2-cbor") {
|
||||
setFeature(context, "PROTOCOL_RPC_V2_CBOR", "M");
|
||||
}
|
||||
if (typeof config.retryStrategy === "function") {
|
||||
const retryStrategy = await config.retryStrategy();
|
||||
if (typeof retryStrategy.mode === "string") {
|
||||
switch (retryStrategy.mode) {
|
||||
case RETRY_MODES.ADAPTIVE:
|
||||
setFeature(context, "RETRY_MODE_ADAPTIVE", "F");
|
||||
break;
|
||||
case RETRY_MODES.STANDARD:
|
||||
setFeature(context, "RETRY_MODE_STANDARD", "E");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (typeof config.accountIdEndpointMode === "function") {
|
||||
const endpointV2 = context.endpointV2;
|
||||
if (String(endpointV2?.url?.hostname).match(ACCOUNT_ID_ENDPOINT_REGEX)) {
|
||||
setFeature(context, "ACCOUNT_ID_ENDPOINT", "O");
|
||||
}
|
||||
switch (await config.accountIdEndpointMode?.()) {
|
||||
case "disabled":
|
||||
setFeature(context, "ACCOUNT_ID_MODE_DISABLED", "Q");
|
||||
break;
|
||||
case "preferred":
|
||||
setFeature(context, "ACCOUNT_ID_MODE_PREFERRED", "P");
|
||||
break;
|
||||
case "required":
|
||||
setFeature(context, "ACCOUNT_ID_MODE_REQUIRED", "R");
|
||||
break;
|
||||
}
|
||||
}
|
||||
const identity = context.__smithy_context?.selectedHttpAuthScheme?.identity;
|
||||
if (identity?.$source) {
|
||||
const credentials = identity;
|
||||
if (credentials.accountId) {
|
||||
setFeature(context, "RESOLVED_ACCOUNT_ID", "T");
|
||||
}
|
||||
for (const [key, value] of Object.entries(credentials.$source ?? {})) {
|
||||
setFeature(context, key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
Generated
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
import { normalizeProvider } from "@smithy/core";
|
||||
export const DEFAULT_UA_APP_ID = undefined;
|
||||
function isValidUserAgentAppId(appId) {
|
||||
if (appId === undefined) {
|
||||
return true;
|
||||
}
|
||||
return typeof appId === "string" && appId.length <= 50;
|
||||
}
|
||||
export function resolveUserAgentConfig(input) {
|
||||
const normalizedAppIdProvider = normalizeProvider(input.userAgentAppId ?? DEFAULT_UA_APP_ID);
|
||||
const { customUserAgent } = input;
|
||||
return Object.assign(input, {
|
||||
customUserAgent: typeof customUserAgent === "string" ? [[customUserAgent]] : customUserAgent,
|
||||
userAgentAppId: async () => {
|
||||
const appId = await normalizedAppIdProvider();
|
||||
if (!isValidUserAgentAppId(appId)) {
|
||||
const logger = input.logger?.constructor?.name === "NoOpLogger" || !input.logger ? console : input.logger;
|
||||
if (typeof appId !== "string") {
|
||||
logger?.warn("userAgentAppId must be a string or undefined.");
|
||||
}
|
||||
else if (appId.length > 50) {
|
||||
logger?.warn("The provided userAgentAppId exceeds the maximum length of 50 characters.");
|
||||
}
|
||||
}
|
||||
return appId;
|
||||
},
|
||||
});
|
||||
}
|
||||
Generated
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
export const USER_AGENT = "user-agent";
|
||||
export const X_AMZ_USER_AGENT = "x-amz-user-agent";
|
||||
export const SPACE = " ";
|
||||
export const UA_NAME_SEPARATOR = "/";
|
||||
export const UA_NAME_ESCAPE_REGEX = /[^!$%&'*+\-.^_`|~\w]/g;
|
||||
export const UA_VALUE_ESCAPE_REGEX = /[^!$%&'*+\-.^_`|~\w#]/g;
|
||||
export const UA_ESCAPE_CHAR = "-";
|
||||
Generated
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
const BYTE_LIMIT = 1024;
|
||||
export function encodeFeatures(features) {
|
||||
let buffer = "";
|
||||
for (const key in features) {
|
||||
const val = features[key];
|
||||
if (buffer.length + val.length + 1 <= BYTE_LIMIT) {
|
||||
if (buffer.length) {
|
||||
buffer += "," + val;
|
||||
}
|
||||
else {
|
||||
buffer += val;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
Generated
Vendored
+82
@@ -0,0 +1,82 @@
|
||||
import { HttpRequest } from "@smithy/core/protocols";
|
||||
import { getUserAgentPrefix } from "../util-endpoints/lib/aws/partition";
|
||||
import { checkFeatures } from "./check-features";
|
||||
import { SPACE, UA_ESCAPE_CHAR, UA_NAME_ESCAPE_REGEX, UA_NAME_SEPARATOR, UA_VALUE_ESCAPE_REGEX, USER_AGENT, X_AMZ_USER_AGENT, } from "./constants";
|
||||
import { encodeFeatures } from "./encode-features";
|
||||
export const userAgentMiddleware = (options) => (next, context) => async (args) => {
|
||||
const { request } = args;
|
||||
if (!HttpRequest.isInstance(request)) {
|
||||
return next(args);
|
||||
}
|
||||
const { headers } = request;
|
||||
const userAgent = context?.userAgent?.map(escapeUserAgent) || [];
|
||||
const defaultUserAgent = (await options.defaultUserAgentProvider()).map(escapeUserAgent);
|
||||
await checkFeatures(context, options, args);
|
||||
const awsContext = context;
|
||||
defaultUserAgent.push(`m/${encodeFeatures(Object.assign({}, context.__smithy_context?.features, awsContext.__aws_sdk_context?.features))}`);
|
||||
const customUserAgent = options?.customUserAgent?.map(escapeUserAgent) || [];
|
||||
const appId = await options.userAgentAppId();
|
||||
if (appId) {
|
||||
defaultUserAgent.push(escapeUserAgent([`app`, `${appId}`]));
|
||||
}
|
||||
const prefix = getUserAgentPrefix();
|
||||
const sdkUserAgentValue = (prefix ? [prefix] : [])
|
||||
.concat([...defaultUserAgent, ...userAgent, ...customUserAgent])
|
||||
.join(SPACE);
|
||||
const normalUAValue = [
|
||||
...defaultUserAgent.filter((section) => section.startsWith("aws-sdk-")),
|
||||
...customUserAgent,
|
||||
].join(SPACE);
|
||||
if (options.runtime !== "browser") {
|
||||
if (normalUAValue) {
|
||||
headers[X_AMZ_USER_AGENT] = headers[X_AMZ_USER_AGENT]
|
||||
? `${headers[USER_AGENT]} ${normalUAValue}`
|
||||
: normalUAValue;
|
||||
}
|
||||
headers[USER_AGENT] = sdkUserAgentValue;
|
||||
}
|
||||
else {
|
||||
headers[X_AMZ_USER_AGENT] = sdkUserAgentValue;
|
||||
}
|
||||
return next({
|
||||
...args,
|
||||
request,
|
||||
});
|
||||
};
|
||||
const escapeUserAgent = (userAgentPair) => {
|
||||
const name = userAgentPair[0]
|
||||
.split(UA_NAME_SEPARATOR)
|
||||
.map((part) => part.replace(UA_NAME_ESCAPE_REGEX, UA_ESCAPE_CHAR))
|
||||
.join(UA_NAME_SEPARATOR);
|
||||
const version = userAgentPair[1]?.replace(UA_VALUE_ESCAPE_REGEX, UA_ESCAPE_CHAR);
|
||||
const prefixSeparatorIndex = name.indexOf(UA_NAME_SEPARATOR);
|
||||
const prefix = name.substring(0, prefixSeparatorIndex);
|
||||
let uaName = name.substring(prefixSeparatorIndex + 1);
|
||||
if (prefix === "api") {
|
||||
uaName = uaName.toLowerCase();
|
||||
}
|
||||
return [prefix, uaName, version]
|
||||
.filter((item) => item && item.length > 0)
|
||||
.reduce((acc, item, index) => {
|
||||
switch (index) {
|
||||
case 0:
|
||||
return item;
|
||||
case 1:
|
||||
return `${acc}/${item}`;
|
||||
default:
|
||||
return `${acc}#${item}`;
|
||||
}
|
||||
}, "");
|
||||
};
|
||||
export const getUserAgentMiddlewareOptions = {
|
||||
name: "getUserAgentMiddleware",
|
||||
step: "build",
|
||||
priority: "low",
|
||||
tags: ["SET_USER_AGENT", "USER_AGENT"],
|
||||
override: true,
|
||||
};
|
||||
export const getUserAgentPlugin = (config) => ({
|
||||
applyToStack: (clientStack) => {
|
||||
clientStack.add(userAgentMiddleware(config), getUserAgentMiddlewareOptions);
|
||||
},
|
||||
});
|
||||
Generated
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
export { REGION_ENV_NAME, REGION_INI_NAME, NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS, } from "@smithy/core/config";
|
||||
export { resolveRegionConfig } from "@smithy/core/config";
|
||||
Generated
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
export const getAwsRegionExtensionConfiguration = (runtimeConfig) => {
|
||||
return {
|
||||
setRegion(region) {
|
||||
runtimeConfig.region = region;
|
||||
},
|
||||
region() {
|
||||
return runtimeConfig.region;
|
||||
},
|
||||
};
|
||||
};
|
||||
export const resolveAwsRegionExtensionConfiguration = (awsRegionExtensionConfiguration) => {
|
||||
return {
|
||||
region: awsRegionExtensionConfiguration.region(),
|
||||
};
|
||||
};
|
||||
Generated
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
export function stsRegionDefaultResolver() {
|
||||
return async () => "us-east-1";
|
||||
}
|
||||
Generated
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
import { loadConfig, NODE_REGION_CONFIG_FILE_OPTIONS, NODE_REGION_CONFIG_OPTIONS, } from "@smithy/core/config";
|
||||
export function stsRegionDefaultResolver(loaderConfig = {}) {
|
||||
return loadConfig({
|
||||
...NODE_REGION_CONFIG_OPTIONS,
|
||||
async default() {
|
||||
if (!warning.silence) {
|
||||
console.warn("@aws-sdk - WARN - default STS region of us-east-1 used. See @aws-sdk/credential-providers README and set a region explicitly.");
|
||||
}
|
||||
return "us-east-1";
|
||||
},
|
||||
}, { ...NODE_REGION_CONFIG_FILE_OPTIONS, ...loaderConfig });
|
||||
}
|
||||
export const warning = {
|
||||
silence: false,
|
||||
};
|
||||
Generated
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
export function stsRegionDefaultResolver() {
|
||||
return async () => "us-east-1";
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
export function setCredentialFeature(credentials, feature, value) {
|
||||
if (!credentials.$source) {
|
||||
credentials.$source = {};
|
||||
}
|
||||
credentials.$source[feature] = value;
|
||||
return credentials;
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
import { Retry } from "@smithy/core/retry";
|
||||
Retry.v2026 ||= typeof process === "object" && process.env?.AWS_NEW_RETRIES_2026 === "true";
|
||||
export function setFeature(context, feature, value) {
|
||||
if (!context.__aws_sdk_context) {
|
||||
context.__aws_sdk_context = {
|
||||
features: {},
|
||||
};
|
||||
}
|
||||
else if (!context.__aws_sdk_context.features) {
|
||||
context.__aws_sdk_context.features = {};
|
||||
}
|
||||
context.__aws_sdk_context.features[feature] = value;
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
export function setTokenFeature(token, feature, value) {
|
||||
if (!token.$source) {
|
||||
token.$source = {};
|
||||
}
|
||||
token.$source[feature] = value;
|
||||
return token;
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import { customEndpointFunctions } from "@smithy/core/endpoints";
|
||||
import { isVirtualHostableS3Bucket } from "./lib/aws/isVirtualHostableS3Bucket";
|
||||
import { parseArn } from "./lib/aws/parseArn";
|
||||
import { partition } from "./lib/aws/partition";
|
||||
export const awsEndpointFunctions = {
|
||||
isVirtualHostableS3Bucket: isVirtualHostableS3Bucket,
|
||||
parseArn: parseArn,
|
||||
partition: partition,
|
||||
};
|
||||
customEndpointFunctions.aws = awsEndpointFunctions;
|
||||
Generated
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
import { isValidHostLabel } from "@smithy/core/endpoints";
|
||||
import { isIpAddress } from "../isIpAddress";
|
||||
export const isVirtualHostableS3Bucket = (value, allowSubDomains = false) => {
|
||||
if (allowSubDomains) {
|
||||
for (const label of value.split(".")) {
|
||||
if (!isVirtualHostableS3Bucket(label)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (!isValidHostLabel(value)) {
|
||||
return false;
|
||||
}
|
||||
if (value.length < 3 || value.length > 63) {
|
||||
return false;
|
||||
}
|
||||
if (value !== value.toLowerCase()) {
|
||||
return false;
|
||||
}
|
||||
if (isIpAddress(value)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
Generated
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
const ARN_DELIMITER = ":";
|
||||
const RESOURCE_DELIMITER = "/";
|
||||
export const parseArn = (value) => {
|
||||
const segments = value.split(ARN_DELIMITER);
|
||||
if (segments.length < 6)
|
||||
return null;
|
||||
const [arn, partition, service, region, accountId, ...resourcePath] = segments;
|
||||
if (arn !== "arn" || partition === "" || service === "" || resourcePath.join(ARN_DELIMITER) === "")
|
||||
return null;
|
||||
const resourceId = resourcePath.map((resource) => resource.split(RESOURCE_DELIMITER)).flat();
|
||||
return {
|
||||
partition,
|
||||
service,
|
||||
region,
|
||||
accountId,
|
||||
resourceId,
|
||||
};
|
||||
};
|
||||
Generated
Vendored
+41
@@ -0,0 +1,41 @@
|
||||
import { partitionsInfo } from "./partitions";
|
||||
let selectedPartitionsInfo = partitionsInfo;
|
||||
let selectedUserAgentPrefix = "";
|
||||
export const partition = (value) => {
|
||||
const { partitions } = selectedPartitionsInfo;
|
||||
for (const partition of partitions) {
|
||||
const { regions, outputs } = partition;
|
||||
for (const [region, regionData] of Object.entries(regions)) {
|
||||
if (region === value) {
|
||||
return {
|
||||
...outputs,
|
||||
...regionData,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const partition of partitions) {
|
||||
const { regionRegex, outputs } = partition;
|
||||
if (new RegExp(regionRegex).test(value)) {
|
||||
return {
|
||||
...outputs,
|
||||
};
|
||||
}
|
||||
}
|
||||
const DEFAULT_PARTITION = partitions.find((partition) => partition.id === "aws");
|
||||
if (!DEFAULT_PARTITION) {
|
||||
throw new Error("Provided region was not found in the partition array or regex," +
|
||||
" and default partition with id 'aws' doesn't exist.");
|
||||
}
|
||||
return {
|
||||
...DEFAULT_PARTITION.outputs,
|
||||
};
|
||||
};
|
||||
export const setPartitionInfo = (partitionsInfo, userAgentPrefix = "") => {
|
||||
selectedPartitionsInfo = partitionsInfo;
|
||||
selectedUserAgentPrefix = userAgentPrefix;
|
||||
};
|
||||
export const useDefaultPartitionInfo = () => {
|
||||
setPartitionInfo(partitionsInfo, "");
|
||||
};
|
||||
export const getUserAgentPrefix = () => selectedUserAgentPrefix;
|
||||
Generated
Vendored
+1
File diff suppressed because one or more lines are too long
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
export { isIpAddress } from "@smithy/core/endpoints";
|
||||
Generated
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
import { parseUrl } from "@smithy/core/protocols";
|
||||
export const resolveDefaultAwsRegionalEndpointsConfig = (input) => {
|
||||
if (typeof input.endpointProvider !== "function") {
|
||||
throw new Error("@aws-sdk/util-endpoint - endpointProvider and endpoint missing in config for this client.");
|
||||
}
|
||||
const { endpoint } = input;
|
||||
if (endpoint === undefined) {
|
||||
input.endpoint = async () => {
|
||||
return toEndpointV1(input.endpointProvider({
|
||||
Region: typeof input.region === "function" ? await input.region() : input.region,
|
||||
UseDualStack: typeof input.useDualstackEndpoint === "function"
|
||||
? await input.useDualstackEndpoint()
|
||||
: input.useDualstackEndpoint,
|
||||
UseFIPS: typeof input.useFipsEndpoint === "function" ? await input.useFipsEndpoint() : input.useFipsEndpoint,
|
||||
Endpoint: undefined,
|
||||
}, { logger: input.logger }));
|
||||
};
|
||||
}
|
||||
return input;
|
||||
};
|
||||
export const toEndpointV1 = (endpoint) => parseUrl(endpoint.url);
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
export { resolveEndpoint } from "@smithy/core/endpoints";
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
export { EndpointError } from "@smithy/core/endpoints";
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
Generated
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
export const createUserAgentStringParsingProvider = ({ serviceId, clientVersion }) => async (config) => {
|
||||
const module = await import("bowser");
|
||||
const parse = module.parse ?? module.default.parse ?? (() => "");
|
||||
const parsedUA = typeof window !== "undefined" && window?.navigator?.userAgent ? parse(window.navigator.userAgent) : undefined;
|
||||
const sections = [
|
||||
["aws-sdk-js", clientVersion],
|
||||
["ua", "2.1"],
|
||||
[`os/${parsedUA?.os?.name || "other"}`, parsedUA?.os?.version],
|
||||
["lang/js"],
|
||||
["md/browser", `${parsedUA?.browser?.name ?? "unknown"}_${parsedUA?.browser?.version ?? "unknown"}`],
|
||||
];
|
||||
if (serviceId) {
|
||||
sections.push([`api/${serviceId}`, clientVersion]);
|
||||
}
|
||||
const appId = await config?.userAgentAppId?.();
|
||||
if (appId) {
|
||||
sections.push([`app/${appId}`]);
|
||||
}
|
||||
return sections;
|
||||
};
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
export * from "./defaultUserAgent";
|
||||
Generated
Vendored
+53
@@ -0,0 +1,53 @@
|
||||
export { createUserAgentStringParsingProvider } from "./createUserAgentStringParsingProvider";
|
||||
export const createDefaultUserAgentProvider = ({ serviceId, clientVersion }) => async (config) => {
|
||||
const navigator = typeof window !== "undefined" ? window.navigator : undefined;
|
||||
const uaString = navigator?.userAgent ?? "";
|
||||
const osName = navigator?.userAgentData?.platform ?? fallback.os(uaString) ?? "other";
|
||||
const osVersion = undefined;
|
||||
const brands = navigator?.userAgentData?.brands ?? [];
|
||||
const brand = brands[brands.length - 1];
|
||||
const browserName = brand?.brand ?? fallback.browser(uaString) ?? "unknown";
|
||||
const browserVersion = brand?.version ?? "unknown";
|
||||
const sections = [
|
||||
["aws-sdk-js", clientVersion],
|
||||
["ua", "2.1"],
|
||||
[`os/${osName}`, osVersion],
|
||||
["lang/js"],
|
||||
["md/browser", `${browserName}_${browserVersion}`],
|
||||
];
|
||||
if (serviceId) {
|
||||
sections.push([`api/${serviceId}`, clientVersion]);
|
||||
}
|
||||
const appId = await config?.userAgentAppId?.();
|
||||
if (appId) {
|
||||
sections.push([`app/${appId}`]);
|
||||
}
|
||||
return sections;
|
||||
};
|
||||
export const fallback = {
|
||||
os(ua) {
|
||||
if (/iPhone|iPad|iPod/.test(ua))
|
||||
return "iOS";
|
||||
if (/Macintosh|Mac OS X/.test(ua))
|
||||
return "macOS";
|
||||
if (/Windows NT/.test(ua))
|
||||
return "Windows";
|
||||
if (/Android/.test(ua))
|
||||
return "Android";
|
||||
if (/Linux/.test(ua))
|
||||
return "Linux";
|
||||
return undefined;
|
||||
},
|
||||
browser(ua) {
|
||||
if (/EdgiOS|EdgA|Edg\//.test(ua))
|
||||
return "Microsoft Edge";
|
||||
if (/Firefox\//.test(ua))
|
||||
return "Firefox";
|
||||
if (/Chrome\//.test(ua))
|
||||
return "Chrome";
|
||||
if (/Safari\//.test(ua))
|
||||
return "Safari";
|
||||
return undefined;
|
||||
},
|
||||
};
|
||||
export const defaultUserAgent = createDefaultUserAgentProvider;
|
||||
Generated
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
export const createDefaultUserAgentProvider = ({ serviceId, clientVersion }) => async (config) => {
|
||||
const sections = [
|
||||
["aws-sdk-js", clientVersion],
|
||||
["ua", "2.1"],
|
||||
["os/other"],
|
||||
["lang/js"],
|
||||
["md/rn"],
|
||||
];
|
||||
if (serviceId) {
|
||||
sections.push([`api/${serviceId}`, clientVersion]);
|
||||
}
|
||||
const appId = await config?.userAgentAppId?.();
|
||||
if (appId) {
|
||||
sections.push([`app/${appId}`]);
|
||||
}
|
||||
return sections;
|
||||
};
|
||||
export const defaultUserAgent = createDefaultUserAgentProvider;
|
||||
Generated
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
export const crtAvailability = {
|
||||
isCrtAvailable: false,
|
||||
};
|
||||
Generated
Vendored
+36
@@ -0,0 +1,36 @@
|
||||
import { platform, release } from "node:os";
|
||||
import { env } from "node:process";
|
||||
import { getRuntimeUserAgentPair } from "./getRuntimeUserAgentPair";
|
||||
import { getTypeScriptUserAgentPair } from "./getTypeScriptUserAgentPair";
|
||||
import { isCrtAvailable } from "./is-crt-available";
|
||||
export { crtAvailability } from "./crt-availability";
|
||||
export const createDefaultUserAgentProvider = ({ serviceId, clientVersion }) => {
|
||||
const runtimeUserAgentPair = getRuntimeUserAgentPair();
|
||||
return async (config) => {
|
||||
const sections = [
|
||||
["aws-sdk-js", clientVersion],
|
||||
["ua", "2.1"],
|
||||
[`os/${platform()}`, release()],
|
||||
["lang/js"],
|
||||
runtimeUserAgentPair,
|
||||
];
|
||||
const typescriptUserAgentPair = await getTypeScriptUserAgentPair();
|
||||
if (typescriptUserAgentPair) {
|
||||
sections.push(typescriptUserAgentPair);
|
||||
}
|
||||
const crtAvailable = isCrtAvailable();
|
||||
if (crtAvailable) {
|
||||
sections.push(crtAvailable);
|
||||
}
|
||||
if (serviceId) {
|
||||
sections.push([`api/${serviceId}`, clientVersion]);
|
||||
}
|
||||
if (env.AWS_EXECUTION_ENV) {
|
||||
sections.push([`exec-env/${env.AWS_EXECUTION_ENV}`]);
|
||||
}
|
||||
const appId = await config?.userAgentAppId?.();
|
||||
const resolvedUserAgent = appId ? [...sections, [`app/${appId}`]] : [...sections];
|
||||
return resolvedUserAgent;
|
||||
};
|
||||
};
|
||||
export const defaultUserAgent = createDefaultUserAgentProvider;
|
||||
Generated
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
import { normalize, sep } from "node:path";
|
||||
export const getNodeModulesParentDirs = (dirname) => {
|
||||
const cwd = process.cwd();
|
||||
if (!dirname) {
|
||||
return [cwd];
|
||||
}
|
||||
const normalizedPath = normalize(dirname);
|
||||
const parts = normalizedPath.split(sep);
|
||||
const nodeModulesIndex = parts.indexOf("node_modules");
|
||||
const parentDir = nodeModulesIndex !== -1 ? parts.slice(0, nodeModulesIndex).join(sep) : normalizedPath;
|
||||
if (cwd === parentDir) {
|
||||
return [cwd];
|
||||
}
|
||||
return [parentDir, cwd];
|
||||
};
|
||||
node_modules/@aws-sdk/core/dist-es/submodules/client/util-user-agent-node/getRuntimeUserAgentPair.js
Generated
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
import { versions } from "node:process";
|
||||
export const getRuntimeUserAgentPair = () => {
|
||||
const runtimesToCheck = ["deno", "bun", "llrt"];
|
||||
for (const runtime of runtimesToCheck) {
|
||||
if (versions[runtime]) {
|
||||
return [`md/${runtime}`, versions[runtime]];
|
||||
}
|
||||
}
|
||||
return ["md/nodejs", versions.node];
|
||||
};
|
||||
Generated
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
import { getSanitizedTypeScriptVersion } from "./getSanitizedTypeScriptVersion";
|
||||
const ALLOWED_PREFIXES = ["^", "~", ">=", "<=", ">", "<"];
|
||||
const ALLOWED_DIST_TAGS = ["latest", "beta", "dev", "rc", "insiders", "next"];
|
||||
export const getSanitizedDevTypeScriptVersion = (version = "") => {
|
||||
if (ALLOWED_DIST_TAGS.includes(version)) {
|
||||
return version;
|
||||
}
|
||||
const prefix = ALLOWED_PREFIXES.find((p) => version.startsWith(p)) ?? "";
|
||||
const sanitizedTypeScriptVersion = getSanitizedTypeScriptVersion(version.slice(prefix.length));
|
||||
if (!sanitizedTypeScriptVersion) {
|
||||
return undefined;
|
||||
}
|
||||
return `${prefix}${sanitizedTypeScriptVersion}`;
|
||||
};
|
||||
Generated
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
const SEMVER_REGEX = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*)?$/;
|
||||
export const getSanitizedTypeScriptVersion = (version = "") => {
|
||||
const match = version.match(SEMVER_REGEX);
|
||||
if (!match) {
|
||||
return undefined;
|
||||
}
|
||||
const [major, minor, patch, prerelease] = [match[1], match[2], match[3], match[4]];
|
||||
return prerelease ? `${major}.${minor}.${patch}-${prerelease}` : `${major}.${minor}.${patch}`;
|
||||
};
|
||||
Generated
Vendored
+75
@@ -0,0 +1,75 @@
|
||||
import { booleanSelector, SelectorType } from "@smithy/core/config";
|
||||
import { readFile } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { getNodeModulesParentDirs } from "./getNodeModulesParentDirs";
|
||||
import { getSanitizedDevTypeScriptVersion } from "./getSanitizedDevTypeScriptVersion";
|
||||
import { getSanitizedTypeScriptVersion } from "./getSanitizedTypeScriptVersion";
|
||||
let tscVersion;
|
||||
const TS_PACKAGE_JSON = join("node_modules", "typescript", "package.json");
|
||||
export const getTypeScriptUserAgentPair = async () => {
|
||||
if (tscVersion === null) {
|
||||
return undefined;
|
||||
}
|
||||
else if (typeof tscVersion === "string") {
|
||||
return ["md/tsc", tscVersion];
|
||||
}
|
||||
let isTypeScriptDetectionDisabled = false;
|
||||
try {
|
||||
isTypeScriptDetectionDisabled =
|
||||
booleanSelector(process.env, "AWS_SDK_JS_TYPESCRIPT_DETECTION_DISABLED", SelectorType.ENV) || false;
|
||||
}
|
||||
catch { }
|
||||
if (isTypeScriptDetectionDisabled) {
|
||||
tscVersion = null;
|
||||
return undefined;
|
||||
}
|
||||
const dirname = typeof __dirname !== "undefined" ? __dirname : undefined;
|
||||
const nodeModulesParentDirs = getNodeModulesParentDirs(dirname);
|
||||
let versionFromApp;
|
||||
for (const nodeModulesParentDir of nodeModulesParentDirs) {
|
||||
try {
|
||||
const appPackageJsonPath = join(nodeModulesParentDir, "package.json");
|
||||
const packageJson = await readFile(appPackageJsonPath, "utf-8");
|
||||
const { dependencies, devDependencies } = JSON.parse(packageJson);
|
||||
const version = devDependencies?.typescript ?? dependencies?.typescript;
|
||||
if (typeof version !== "string") {
|
||||
continue;
|
||||
}
|
||||
versionFromApp = version;
|
||||
break;
|
||||
}
|
||||
catch {
|
||||
}
|
||||
}
|
||||
if (!versionFromApp) {
|
||||
tscVersion = null;
|
||||
return undefined;
|
||||
}
|
||||
let versionFromNodeModules;
|
||||
for (const nodeModulesParentDir of nodeModulesParentDirs) {
|
||||
try {
|
||||
const tsPackageJsonPath = join(nodeModulesParentDir, TS_PACKAGE_JSON);
|
||||
const packageJson = await readFile(tsPackageJsonPath, "utf-8");
|
||||
const { version } = JSON.parse(packageJson);
|
||||
const sanitizedVersion = getSanitizedTypeScriptVersion(version);
|
||||
if (typeof sanitizedVersion !== "string") {
|
||||
continue;
|
||||
}
|
||||
versionFromNodeModules = sanitizedVersion;
|
||||
break;
|
||||
}
|
||||
catch {
|
||||
}
|
||||
}
|
||||
if (versionFromNodeModules) {
|
||||
tscVersion = versionFromNodeModules;
|
||||
return ["md/tsc", tscVersion];
|
||||
}
|
||||
const sanitizedVersion = getSanitizedDevTypeScriptVersion(versionFromApp);
|
||||
if (typeof sanitizedVersion !== "string") {
|
||||
tscVersion = null;
|
||||
return undefined;
|
||||
}
|
||||
tscVersion = `dev_${sanitizedVersion}`;
|
||||
return ["md/tsc", tscVersion];
|
||||
};
|
||||
Generated
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
import { crtAvailability } from "./crt-availability";
|
||||
export const isCrtAvailable = () => {
|
||||
if (crtAvailability.isCrtAvailable) {
|
||||
return ["md/crt-avail"];
|
||||
}
|
||||
return null;
|
||||
};
|
||||
Generated
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
import { DEFAULT_UA_APP_ID } from "../middleware-user-agent/configurations";
|
||||
export const UA_APP_ID_ENV_NAME = "AWS_SDK_UA_APP_ID";
|
||||
export const UA_APP_ID_INI_NAME = "sdk_ua_app_id";
|
||||
const UA_APP_ID_INI_NAME_DEPRECATED = "sdk-ua-app-id";
|
||||
export const NODE_APP_ID_CONFIG_OPTIONS = {
|
||||
environmentVariableSelector: (env) => env[UA_APP_ID_ENV_NAME],
|
||||
configFileSelector: (profile) => profile[UA_APP_ID_INI_NAME] ?? profile[UA_APP_ID_INI_NAME_DEPRECATED],
|
||||
default: DEFAULT_UA_APP_ID,
|
||||
};
|
||||
Generated
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
import { HttpRequest } from "@smithy/core/protocols";
|
||||
import { getSkewCorrectedDate } from "../utils";
|
||||
import { AwsSdkSigV4Signer, validateSigningProperties } from "./AwsSdkSigV4Signer";
|
||||
export class AwsSdkSigV4ASigner extends AwsSdkSigV4Signer {
|
||||
async sign(httpRequest, identity, signingProperties) {
|
||||
if (!HttpRequest.isInstance(httpRequest)) {
|
||||
throw new Error("The request is not an instance of `HttpRequest` and cannot be signed");
|
||||
}
|
||||
const { config, signer, signingRegion, signingRegionSet, signingName } = await validateSigningProperties(signingProperties);
|
||||
const configResolvedSigningRegionSet = await config.sigv4aSigningRegionSet?.();
|
||||
const multiRegionOverride = (configResolvedSigningRegionSet ??
|
||||
signingRegionSet ?? [signingRegion]).join(",");
|
||||
signingProperties._preRequestSystemClockOffset = config.systemClockOffset;
|
||||
const signedRequest = await signer.sign(httpRequest, {
|
||||
signingDate: getSkewCorrectedDate(config.systemClockOffset),
|
||||
signingRegion: multiRegionOverride,
|
||||
signingService: signingName,
|
||||
});
|
||||
return signedRequest;
|
||||
}
|
||||
}
|
||||
Generated
Vendored
+77
@@ -0,0 +1,77 @@
|
||||
import { HttpRequest } from "@smithy/core/protocols";
|
||||
import { getDateHeader, getSkewCorrectedDate, getUpdatedSystemClockOffset } from "../utils";
|
||||
const throwSigningPropertyError = (name, property) => {
|
||||
if (!property) {
|
||||
throw new Error(`Property \`${name}\` is not resolved for AWS SDK SigV4Auth`);
|
||||
}
|
||||
return property;
|
||||
};
|
||||
export const validateSigningProperties = async (signingProperties) => {
|
||||
const context = throwSigningPropertyError("context", signingProperties.context);
|
||||
const config = throwSigningPropertyError("config", signingProperties.config);
|
||||
const authScheme = context.endpointV2?.properties?.authSchemes?.[0];
|
||||
const signerFunction = throwSigningPropertyError("signer", config.signer);
|
||||
const signer = await signerFunction(authScheme);
|
||||
const signingRegion = signingProperties?.signingRegion;
|
||||
const signingRegionSet = signingProperties?.signingRegionSet;
|
||||
const signingName = signingProperties?.signingName;
|
||||
return {
|
||||
config,
|
||||
signer,
|
||||
signingRegion,
|
||||
signingRegionSet,
|
||||
signingName,
|
||||
};
|
||||
};
|
||||
export class AwsSdkSigV4Signer {
|
||||
async sign(httpRequest, identity, signingProperties) {
|
||||
if (!HttpRequest.isInstance(httpRequest)) {
|
||||
throw new Error("The request is not an instance of `HttpRequest` and cannot be signed");
|
||||
}
|
||||
const validatedProps = await validateSigningProperties(signingProperties);
|
||||
const { config, signer } = validatedProps;
|
||||
let { signingRegion, signingName } = validatedProps;
|
||||
const handlerExecutionContext = signingProperties.context;
|
||||
if (handlerExecutionContext?.authSchemes?.length ?? 0 > 1) {
|
||||
const [first, second] = handlerExecutionContext.authSchemes;
|
||||
if (first?.name === "sigv4a" && second?.name === "sigv4") {
|
||||
signingRegion = second?.signingRegion ?? signingRegion;
|
||||
signingName = second?.signingName ?? signingName;
|
||||
}
|
||||
}
|
||||
signingProperties._preRequestSystemClockOffset = config.systemClockOffset;
|
||||
const signedRequest = await signer.sign(httpRequest, {
|
||||
signingDate: getSkewCorrectedDate(config.systemClockOffset),
|
||||
signingRegion: signingRegion,
|
||||
signingService: signingName,
|
||||
});
|
||||
return signedRequest;
|
||||
}
|
||||
errorHandler(signingProperties) {
|
||||
return (error) => {
|
||||
const errorException = error;
|
||||
const serverTime = errorException.ServerTime ?? getDateHeader(errorException.$response);
|
||||
if (serverTime) {
|
||||
const config = throwSigningPropertyError("config", signingProperties.config);
|
||||
const preRequestOffset = signingProperties._preRequestSystemClockOffset;
|
||||
const newOffset = getUpdatedSystemClockOffset(serverTime, config.systemClockOffset);
|
||||
const isLocalCorrection = newOffset !== config.systemClockOffset;
|
||||
const isConcurrentCorrection = preRequestOffset !== undefined && preRequestOffset !== newOffset;
|
||||
const clockSkewCorrected = isLocalCorrection || isConcurrentCorrection;
|
||||
if (clockSkewCorrected && errorException.$metadata) {
|
||||
config.systemClockOffset = newOffset;
|
||||
errorException.$metadata.clockSkewCorrected = true;
|
||||
}
|
||||
}
|
||||
throw error;
|
||||
};
|
||||
}
|
||||
successHandler(httpResponse, signingProperties) {
|
||||
const dateHeader = getDateHeader(httpResponse);
|
||||
if (dateHeader) {
|
||||
const config = throwSigningPropertyError("config", signingProperties.config);
|
||||
config.systemClockOffset = getUpdatedSystemClockOffset(dateHeader, config.systemClockOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
export const AWSSDKSigV4Signer = AwsSdkSigV4Signer;
|
||||
Generated
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
import { getArrayForCommaSeparatedString } from "../utils/getArrayForCommaSeparatedString";
|
||||
import { getBearerTokenEnvKey } from "../utils/getBearerTokenEnvKey";
|
||||
const NODE_AUTH_SCHEME_PREFERENCE_ENV_KEY = "AWS_AUTH_SCHEME_PREFERENCE";
|
||||
const NODE_AUTH_SCHEME_PREFERENCE_CONFIG_KEY = "auth_scheme_preference";
|
||||
export const NODE_AUTH_SCHEME_PREFERENCE_OPTIONS = {
|
||||
environmentVariableSelector: (env, options) => {
|
||||
if (options?.signingName) {
|
||||
const bearerTokenKey = getBearerTokenEnvKey(options.signingName);
|
||||
if (bearerTokenKey in env)
|
||||
return ["httpBearerAuth"];
|
||||
}
|
||||
if (!(NODE_AUTH_SCHEME_PREFERENCE_ENV_KEY in env))
|
||||
return undefined;
|
||||
return getArrayForCommaSeparatedString(env[NODE_AUTH_SCHEME_PREFERENCE_ENV_KEY]);
|
||||
},
|
||||
configFileSelector: (profile) => {
|
||||
if (!(NODE_AUTH_SCHEME_PREFERENCE_CONFIG_KEY in profile))
|
||||
return undefined;
|
||||
return getArrayForCommaSeparatedString(profile[NODE_AUTH_SCHEME_PREFERENCE_CONFIG_KEY]);
|
||||
},
|
||||
default: [],
|
||||
};
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
export { AwsSdkSigV4Signer, AWSSDKSigV4Signer, validateSigningProperties } from "./AwsSdkSigV4Signer";
|
||||
export { AwsSdkSigV4ASigner } from "./AwsSdkSigV4ASigner";
|
||||
export * from "./NODE_AUTH_SCHEME_PREFERENCE_OPTIONS";
|
||||
export * from "./resolveAwsSdkSigV4AConfig";
|
||||
export * from "./resolveAwsSdkSigV4Config";
|
||||
Generated
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
import { normalizeProvider } from "@smithy/core";
|
||||
import { ProviderError } from "@smithy/core/config";
|
||||
export const resolveAwsSdkSigV4AConfig = (config) => {
|
||||
config.sigv4aSigningRegionSet = normalizeProvider(config.sigv4aSigningRegionSet);
|
||||
return config;
|
||||
};
|
||||
export const NODE_SIGV4A_CONFIG_OPTIONS = {
|
||||
environmentVariableSelector(env) {
|
||||
if (env.AWS_SIGV4A_SIGNING_REGION_SET) {
|
||||
return env.AWS_SIGV4A_SIGNING_REGION_SET.split(",").map((_) => _.trim());
|
||||
}
|
||||
throw new ProviderError("AWS_SIGV4A_SIGNING_REGION_SET not set in env.", {
|
||||
tryNextLink: true,
|
||||
});
|
||||
},
|
||||
configFileSelector(profile) {
|
||||
if (profile.sigv4a_signing_region_set) {
|
||||
return (profile.sigv4a_signing_region_set ?? "").split(",").map((_) => _.trim());
|
||||
}
|
||||
throw new ProviderError("sigv4a_signing_region_set not set in profile.", {
|
||||
tryNextLink: true,
|
||||
});
|
||||
},
|
||||
default: undefined,
|
||||
};
|
||||
Generated
Vendored
+139
@@ -0,0 +1,139 @@
|
||||
import { setCredentialFeature } from "@aws-sdk/core/client";
|
||||
import { doesIdentityRequireRefresh, isIdentityExpired, memoizeIdentityProvider, normalizeProvider, } from "@smithy/core";
|
||||
import { SignatureV4 } from "@smithy/signature-v4";
|
||||
export const resolveAwsSdkSigV4Config = (config) => {
|
||||
let inputCredentials = config.credentials;
|
||||
let isUserSupplied = !!config.credentials;
|
||||
let resolvedCredentials = undefined;
|
||||
Object.defineProperty(config, "credentials", {
|
||||
set(credentials) {
|
||||
if (credentials && credentials !== inputCredentials && credentials !== resolvedCredentials) {
|
||||
isUserSupplied = true;
|
||||
}
|
||||
inputCredentials = credentials;
|
||||
const memoizedProvider = normalizeCredentialProvider(config, {
|
||||
credentials: inputCredentials,
|
||||
credentialDefaultProvider: config.credentialDefaultProvider,
|
||||
});
|
||||
const boundProvider = bindCallerConfig(config, memoizedProvider);
|
||||
if (isUserSupplied && !boundProvider.attributed) {
|
||||
const isCredentialObject = typeof inputCredentials === "object" && inputCredentials !== null;
|
||||
resolvedCredentials = async (options) => {
|
||||
const creds = await boundProvider(options);
|
||||
const attributedCreds = creds;
|
||||
if (isCredentialObject && (!attributedCreds.$source || Object.keys(attributedCreds.$source).length === 0)) {
|
||||
return setCredentialFeature(attributedCreds, "CREDENTIALS_CODE", "e");
|
||||
}
|
||||
return attributedCreds;
|
||||
};
|
||||
resolvedCredentials.memoized = boundProvider.memoized;
|
||||
resolvedCredentials.configBound = boundProvider.configBound;
|
||||
resolvedCredentials.attributed = true;
|
||||
}
|
||||
else {
|
||||
resolvedCredentials = boundProvider;
|
||||
}
|
||||
},
|
||||
get() {
|
||||
return resolvedCredentials;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
});
|
||||
config.credentials = inputCredentials;
|
||||
const { signingEscapePath = true, systemClockOffset = config.systemClockOffset || 0, sha256, } = config;
|
||||
let signer;
|
||||
if (config.signer) {
|
||||
signer = normalizeProvider(config.signer);
|
||||
}
|
||||
else if (config.regionInfoProvider) {
|
||||
signer = () => normalizeProvider(config.region)()
|
||||
.then(async (region) => [
|
||||
(await config.regionInfoProvider(region, {
|
||||
useFipsEndpoint: await config.useFipsEndpoint(),
|
||||
useDualstackEndpoint: await config.useDualstackEndpoint(),
|
||||
})) || {},
|
||||
region,
|
||||
])
|
||||
.then(([regionInfo, region]) => {
|
||||
const { signingRegion, signingService } = regionInfo;
|
||||
config.signingRegion = config.signingRegion || signingRegion || region;
|
||||
config.signingName = config.signingName || signingService || config.serviceId;
|
||||
const params = {
|
||||
...config,
|
||||
credentials: config.credentials,
|
||||
region: config.signingRegion,
|
||||
service: config.signingName,
|
||||
sha256,
|
||||
uriEscapePath: signingEscapePath,
|
||||
};
|
||||
const SignerCtor = config.signerConstructor || SignatureV4;
|
||||
return new SignerCtor(params);
|
||||
});
|
||||
}
|
||||
else {
|
||||
signer = async (authScheme) => {
|
||||
authScheme = Object.assign({}, {
|
||||
name: "sigv4",
|
||||
signingName: config.signingName || config.defaultSigningName,
|
||||
signingRegion: await normalizeProvider(config.region)(),
|
||||
properties: {},
|
||||
}, authScheme);
|
||||
const signingRegion = authScheme.signingRegion;
|
||||
const signingService = authScheme.signingName;
|
||||
config.signingRegion = config.signingRegion || signingRegion;
|
||||
config.signingName = config.signingName || signingService || config.serviceId;
|
||||
const params = {
|
||||
...config,
|
||||
credentials: config.credentials,
|
||||
region: config.signingRegion,
|
||||
service: config.signingName,
|
||||
sha256,
|
||||
uriEscapePath: signingEscapePath,
|
||||
};
|
||||
const SignerCtor = config.signerConstructor || SignatureV4;
|
||||
return new SignerCtor(params);
|
||||
};
|
||||
}
|
||||
const resolvedConfig = Object.assign(config, {
|
||||
systemClockOffset,
|
||||
signingEscapePath,
|
||||
signer,
|
||||
});
|
||||
return resolvedConfig;
|
||||
};
|
||||
export const resolveAWSSDKSigV4Config = resolveAwsSdkSigV4Config;
|
||||
function normalizeCredentialProvider(config, { credentials, credentialDefaultProvider, }) {
|
||||
let credentialsProvider;
|
||||
if (credentials) {
|
||||
if (!credentials?.memoized) {
|
||||
credentialsProvider = memoizeIdentityProvider(credentials, isIdentityExpired, doesIdentityRequireRefresh);
|
||||
}
|
||||
else {
|
||||
credentialsProvider = credentials;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (credentialDefaultProvider) {
|
||||
credentialsProvider = normalizeProvider(credentialDefaultProvider(Object.assign({}, config, {
|
||||
parentClientConfig: config,
|
||||
})));
|
||||
}
|
||||
else {
|
||||
credentialsProvider = async () => {
|
||||
throw new Error("@aws-sdk/core::resolveAwsSdkSigV4Config - `credentials` not provided and no credentialDefaultProvider was configured.");
|
||||
};
|
||||
}
|
||||
}
|
||||
credentialsProvider.memoized = true;
|
||||
return credentialsProvider;
|
||||
}
|
||||
function bindCallerConfig(config, credentialsProvider) {
|
||||
if (credentialsProvider.configBound) {
|
||||
return credentialsProvider;
|
||||
}
|
||||
const fn = async (options) => credentialsProvider({ ...options, callerClientConfig: config });
|
||||
fn.memoized = credentialsProvider.memoized;
|
||||
fn.configBound = true;
|
||||
return fn;
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
export * from "./aws_sdk";
|
||||
export * from "./utils/getBearerTokenEnvKey";
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
export const getArrayForCommaSeparatedString = (str) => typeof str === "string" && str.length > 0 ? str.split(",").map((item) => item.trim()) : [];
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
export const getBearerTokenEnvKey = (signingName) => `AWS_BEARER_TOKEN_${signingName.replace(/[\s-]/g, "_").toUpperCase()}`;
|
||||
Generated
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
import { HttpResponse } from "@smithy/core/protocols";
|
||||
export const getDateHeader = (response) => HttpResponse.isInstance(response) ? response.headers?.date ?? response.headers?.Date : undefined;
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
export const getSkewCorrectedDate = (systemClockOffset) => new Date(Date.now() + systemClockOffset);
|
||||
Generated
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
import { isClockSkewed } from "./isClockSkewed";
|
||||
export const getUpdatedSystemClockOffset = (clockTime, currentSystemClockOffset) => {
|
||||
const clockTimeInMs = Date.parse(clockTime);
|
||||
if (isClockSkewed(clockTimeInMs, currentSystemClockOffset)) {
|
||||
return clockTimeInMs - Date.now();
|
||||
}
|
||||
return currentSystemClockOffset;
|
||||
};
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
export * from "./getDateHeader";
|
||||
export * from "./getSkewCorrectedDate";
|
||||
export * from "./getUpdatedSystemClockOffset";
|
||||
Generated
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
import { getSkewCorrectedDate } from "./getSkewCorrectedDate";
|
||||
export const isClockSkewed = (clockTime, systemClockOffset) => Math.abs(getSkewCorrectedDate(systemClockOffset).getTime() - clockTime) >= 300000;
|
||||
Generated
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
export class SerdeContextConfig {
|
||||
serdeContext;
|
||||
setSerdeContext(serdeContext) {
|
||||
this.serdeContext = serdeContext;
|
||||
}
|
||||
}
|
||||
+141
@@ -0,0 +1,141 @@
|
||||
import { decorateServiceException } from "@smithy/core/client";
|
||||
import { NormalizedSchema, TypeRegistry } from "@smithy/core/schema";
|
||||
export class ProtocolLib {
|
||||
queryCompat;
|
||||
errorRegistry;
|
||||
constructor(queryCompat = false) {
|
||||
this.queryCompat = queryCompat;
|
||||
}
|
||||
resolveRestContentType(defaultContentType, inputSchema) {
|
||||
const members = inputSchema.getMemberSchemas();
|
||||
const httpPayloadMember = Object.values(members).find((m) => {
|
||||
return !!m.getMergedTraits().httpPayload;
|
||||
});
|
||||
if (httpPayloadMember) {
|
||||
const mediaType = httpPayloadMember.getMergedTraits().mediaType;
|
||||
if (mediaType) {
|
||||
return mediaType;
|
||||
}
|
||||
else if (httpPayloadMember.isStringSchema()) {
|
||||
return "text/plain";
|
||||
}
|
||||
else if (httpPayloadMember.isBlobSchema()) {
|
||||
return "application/octet-stream";
|
||||
}
|
||||
else {
|
||||
return defaultContentType;
|
||||
}
|
||||
}
|
||||
else if (!inputSchema.isUnitSchema()) {
|
||||
const hasBody = Object.values(members).find((m) => {
|
||||
const { httpQuery, httpQueryParams, httpHeader, httpLabel, httpPrefixHeaders } = m.getMergedTraits();
|
||||
const noPrefixHeaders = httpPrefixHeaders === void 0;
|
||||
return !httpQuery && !httpQueryParams && !httpHeader && !httpLabel && noPrefixHeaders;
|
||||
});
|
||||
if (hasBody) {
|
||||
return defaultContentType;
|
||||
}
|
||||
}
|
||||
}
|
||||
async getErrorSchemaOrThrowBaseException(errorIdentifier, defaultNamespace, response, dataObject, metadata, getErrorSchema) {
|
||||
let errorName = errorIdentifier;
|
||||
if (errorIdentifier.includes("#")) {
|
||||
[, errorName] = errorIdentifier.split("#");
|
||||
}
|
||||
const errorMetadata = {
|
||||
$metadata: metadata,
|
||||
$fault: response.statusCode < 500 ? "client" : "server",
|
||||
};
|
||||
if (!this.errorRegistry) {
|
||||
throw new Error("@aws-sdk/core/protocols - error handler not initialized.");
|
||||
}
|
||||
try {
|
||||
const errorSchema = getErrorSchema?.(this.errorRegistry, errorName) ??
|
||||
this.errorRegistry.getSchema(errorIdentifier);
|
||||
return { errorSchema, errorMetadata };
|
||||
}
|
||||
catch (e) {
|
||||
dataObject.message = dataObject.message ?? dataObject.Message ?? "UnknownError";
|
||||
const synthetic = this.errorRegistry;
|
||||
const baseExceptionSchema = synthetic.getBaseException();
|
||||
if (baseExceptionSchema) {
|
||||
const ErrorCtor = synthetic.getErrorCtor(baseExceptionSchema) ?? Error;
|
||||
throw this.decorateServiceException(Object.assign(new ErrorCtor({ name: errorName }), errorMetadata), dataObject);
|
||||
}
|
||||
const d = dataObject;
|
||||
const message = d?.message ?? d?.Message ?? d?.Error?.Message ?? d?.Error?.message;
|
||||
throw this.decorateServiceException(Object.assign(new Error(message), {
|
||||
name: errorName,
|
||||
}, errorMetadata), dataObject);
|
||||
}
|
||||
}
|
||||
compose(composite, errorIdentifier, defaultNamespace) {
|
||||
let namespace = defaultNamespace;
|
||||
if (errorIdentifier.includes("#")) {
|
||||
[namespace] = errorIdentifier.split("#");
|
||||
}
|
||||
const staticRegistry = TypeRegistry.for(namespace);
|
||||
const defaultSyntheticRegistry = TypeRegistry.for("smithy.ts.sdk.synthetic." + defaultNamespace);
|
||||
composite.copyFrom(staticRegistry);
|
||||
composite.copyFrom(defaultSyntheticRegistry);
|
||||
this.errorRegistry = composite;
|
||||
}
|
||||
decorateServiceException(exception, additions = {}) {
|
||||
if (this.queryCompat) {
|
||||
const msg = exception.Message ?? additions.Message;
|
||||
const error = decorateServiceException(exception, additions);
|
||||
if (msg) {
|
||||
error.message = msg;
|
||||
}
|
||||
const errorObj = error.Error ?? {};
|
||||
errorObj.Type = error.Error?.Type;
|
||||
errorObj.Code = error.Error?.Code;
|
||||
errorObj.Message = error.Error?.message ?? error.Error?.Message ?? msg;
|
||||
error.Error = errorObj;
|
||||
const reqId = error.$metadata.requestId;
|
||||
if (reqId) {
|
||||
error.RequestId = reqId;
|
||||
}
|
||||
return error;
|
||||
}
|
||||
return decorateServiceException(exception, additions);
|
||||
}
|
||||
setQueryCompatError(output, response) {
|
||||
const queryErrorHeader = response.headers?.["x-amzn-query-error"];
|
||||
if (output !== undefined && queryErrorHeader != null) {
|
||||
const [Code, Type] = queryErrorHeader.split(";");
|
||||
const keys = Object.keys(output);
|
||||
const Error = {
|
||||
Code,
|
||||
Type,
|
||||
};
|
||||
output.Code = Code;
|
||||
output.Type = Type;
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const k = keys[i];
|
||||
Error[k === "message" ? "Message" : k] = output[k];
|
||||
}
|
||||
delete Error.__type;
|
||||
output.Error = Error;
|
||||
}
|
||||
}
|
||||
queryCompatOutput(queryCompatErrorData, errorData) {
|
||||
if (queryCompatErrorData.Error) {
|
||||
errorData.Error = queryCompatErrorData.Error;
|
||||
}
|
||||
if (queryCompatErrorData.Type) {
|
||||
errorData.Type = queryCompatErrorData.Type;
|
||||
}
|
||||
if (queryCompatErrorData.Code) {
|
||||
errorData.Code = queryCompatErrorData.Code;
|
||||
}
|
||||
}
|
||||
findQueryCompatibleError(registry, errorName) {
|
||||
try {
|
||||
return registry.getSchema(errorName);
|
||||
}
|
||||
catch (e) {
|
||||
return registry.find((schema) => NormalizedSchema.of(schema).getMergedTraits().awsQueryError?.[0] === errorName);
|
||||
}
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
export class UnionSerde {
|
||||
from;
|
||||
to;
|
||||
keys;
|
||||
constructor(from, to) {
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
const keys = Object.keys(this.from);
|
||||
const set = new Set(keys);
|
||||
set.delete("__type");
|
||||
this.keys = set;
|
||||
}
|
||||
mark(key) {
|
||||
this.keys.delete(key);
|
||||
}
|
||||
hasUnknown() {
|
||||
return this.keys.size === 1 && Object.keys(this.to).length === 0;
|
||||
}
|
||||
writeUnknown() {
|
||||
if (this.hasUnknown()) {
|
||||
const k = this.keys.values().next().value;
|
||||
const v = this.from[k];
|
||||
this.to.$unknown = [k, v];
|
||||
}
|
||||
}
|
||||
}
|
||||
Generated
Vendored
+50
@@ -0,0 +1,50 @@
|
||||
import { loadSmithyRpcV2CborErrorCode, SmithyRpcV2CborProtocol } from "@smithy/core/cbor";
|
||||
import { NormalizedSchema } from "@smithy/core/schema";
|
||||
import { ProtocolLib } from "../ProtocolLib";
|
||||
export class AwsSmithyRpcV2CborProtocol extends SmithyRpcV2CborProtocol {
|
||||
awsQueryCompatible;
|
||||
mixin;
|
||||
constructor({ defaultNamespace, errorTypeRegistries, awsQueryCompatible, }) {
|
||||
super({ defaultNamespace, errorTypeRegistries });
|
||||
this.awsQueryCompatible = !!awsQueryCompatible;
|
||||
this.mixin = new ProtocolLib(this.awsQueryCompatible);
|
||||
}
|
||||
async serializeRequest(operationSchema, input, context) {
|
||||
const request = await super.serializeRequest(operationSchema, input, context);
|
||||
if (this.awsQueryCompatible) {
|
||||
request.headers["x-amzn-query-mode"] = "true";
|
||||
}
|
||||
return request;
|
||||
}
|
||||
async handleError(operationSchema, context, response, dataObject, metadata) {
|
||||
if (this.awsQueryCompatible) {
|
||||
this.mixin.setQueryCompatError(dataObject, response);
|
||||
}
|
||||
const errorName = (() => {
|
||||
const compatHeader = response.headers["x-amzn-query-error"];
|
||||
if (compatHeader && this.awsQueryCompatible) {
|
||||
return compatHeader.split(";")[0];
|
||||
}
|
||||
return loadSmithyRpcV2CborErrorCode(response, dataObject) ?? "Unknown";
|
||||
})();
|
||||
this.mixin.compose(this.compositeErrorRegistry, errorName, this.options.defaultNamespace);
|
||||
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorName, this.options.defaultNamespace, response, dataObject, metadata, this.awsQueryCompatible ? this.mixin.findQueryCompatibleError : undefined);
|
||||
const ns = NormalizedSchema.of(errorSchema);
|
||||
const message = dataObject.message ?? dataObject.Message ?? "UnknownError";
|
||||
const ErrorCtor = this.compositeErrorRegistry.getErrorCtor(errorSchema) ?? Error;
|
||||
const exception = new ErrorCtor({});
|
||||
const output = {};
|
||||
for (const [name, member] of ns.structIterator()) {
|
||||
if (dataObject[name] != null) {
|
||||
output[name] = this.deserializer.readValue(member, dataObject[name]);
|
||||
}
|
||||
}
|
||||
if (this.awsQueryCompatible) {
|
||||
this.mixin.queryCompatOutput(dataObject, output);
|
||||
}
|
||||
throw this.mixin.decorateServiceException(Object.assign(exception, errorMetadata, {
|
||||
$fault: ns.getMergedTraits().error,
|
||||
message,
|
||||
}, output), dataObject);
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
export const _toStr = (val) => {
|
||||
if (val == null) {
|
||||
return val;
|
||||
}
|
||||
if (typeof val === "number" || typeof val === "bigint") {
|
||||
const warning = new Error(`Received number ${val} where a string was expected.`);
|
||||
warning.name = "Warning";
|
||||
console.warn(warning);
|
||||
return String(val);
|
||||
}
|
||||
if (typeof val === "boolean") {
|
||||
const warning = new Error(`Received boolean ${val} where a string was expected.`);
|
||||
warning.name = "Warning";
|
||||
console.warn(warning);
|
||||
return String(val);
|
||||
}
|
||||
return val;
|
||||
};
|
||||
export const _toBool = (val) => {
|
||||
if (val == null) {
|
||||
return val;
|
||||
}
|
||||
if (typeof val === "number") {
|
||||
}
|
||||
if (typeof val === "string") {
|
||||
const lowercase = val.toLowerCase();
|
||||
if (val !== "" && lowercase !== "false" && lowercase !== "true") {
|
||||
const warning = new Error(`Received string "${val}" where a boolean was expected.`);
|
||||
warning.name = "Warning";
|
||||
console.warn(warning);
|
||||
}
|
||||
return val !== "" && lowercase !== "false";
|
||||
}
|
||||
return val;
|
||||
};
|
||||
export const _toNum = (val) => {
|
||||
if (val == null) {
|
||||
return val;
|
||||
}
|
||||
if (typeof val === "boolean") {
|
||||
}
|
||||
if (typeof val === "string") {
|
||||
const num = Number(val);
|
||||
if (num.toString() !== val) {
|
||||
const warning = new Error(`Received string "${val}" where a number was expected.`);
|
||||
warning.name = "Warning";
|
||||
console.warn(warning);
|
||||
return val;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
return val;
|
||||
};
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import { collectBody } from "@smithy/core/protocols";
|
||||
import { toUtf8 } from "@smithy/core/serde";
|
||||
export const collectBodyString = (streamBody, context) => collectBody(streamBody, context).then((body) => (context?.utf8Encoder ?? toUtf8)(body));
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
export * from "./cbor/AwsSmithyRpcV2CborProtocol";
|
||||
export * from "./coercing-serializers";
|
||||
export * from "./json/AwsJson1_0Protocol";
|
||||
export * from "./json/AwsJson1_1Protocol";
|
||||
export * from "./json/AwsJsonRpcProtocol";
|
||||
export * from "./json/AwsRestJsonProtocol";
|
||||
export * from "./json/JsonCodec";
|
||||
export * from "./json/JsonShapeDeserializer";
|
||||
export * from "./json/JsonShapeSerializer";
|
||||
export * from "./json/awsExpectUnion";
|
||||
export * from "./json/parseJsonBody";
|
||||
export * from "./query/AwsEc2QueryProtocol";
|
||||
export * from "./query/AwsQueryProtocol";
|
||||
export * from "./query/QuerySerializerSettings";
|
||||
export * from "./query/QueryShapeSerializer";
|
||||
export * from "./xml/AwsRestXmlProtocol";
|
||||
export * from "./xml/XmlCodec";
|
||||
export * from "./xml/XmlShapeDeserializer";
|
||||
export * from "./xml/XmlShapeSerializer";
|
||||
export * from "./xml/parseXmlBody";
|
||||
Generated
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
import { AwsJsonRpcProtocol } from "./AwsJsonRpcProtocol";
|
||||
export class AwsJson1_0Protocol extends AwsJsonRpcProtocol {
|
||||
constructor({ defaultNamespace, errorTypeRegistries, serviceTarget, awsQueryCompatible, jsonCodec, }) {
|
||||
super({
|
||||
defaultNamespace,
|
||||
errorTypeRegistries,
|
||||
serviceTarget,
|
||||
awsQueryCompatible,
|
||||
jsonCodec,
|
||||
});
|
||||
}
|
||||
getShapeId() {
|
||||
return "aws.protocols#awsJson1_0";
|
||||
}
|
||||
getJsonRpcVersion() {
|
||||
return "1.0";
|
||||
}
|
||||
getDefaultContentType() {
|
||||
return "application/x-amz-json-1.0";
|
||||
}
|
||||
}
|
||||
Generated
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
import { AwsJsonRpcProtocol } from "./AwsJsonRpcProtocol";
|
||||
export class AwsJson1_1Protocol extends AwsJsonRpcProtocol {
|
||||
constructor({ defaultNamespace, errorTypeRegistries, serviceTarget, awsQueryCompatible, jsonCodec, }) {
|
||||
super({
|
||||
defaultNamespace,
|
||||
errorTypeRegistries,
|
||||
serviceTarget,
|
||||
awsQueryCompatible,
|
||||
jsonCodec,
|
||||
});
|
||||
}
|
||||
getShapeId() {
|
||||
return "aws.protocols#awsJson1_1";
|
||||
}
|
||||
getJsonRpcVersion() {
|
||||
return "1.1";
|
||||
}
|
||||
getDefaultContentType() {
|
||||
return "application/x-amz-json-1.1";
|
||||
}
|
||||
}
|
||||
Generated
Vendored
+78
@@ -0,0 +1,78 @@
|
||||
import { RpcProtocol } from "@smithy/core/protocols";
|
||||
import { deref, NormalizedSchema } from "@smithy/core/schema";
|
||||
import { ProtocolLib } from "../ProtocolLib";
|
||||
import { JsonCodec } from "./JsonCodec";
|
||||
import { loadJsonRpcErrorCode } from "./parseJsonBody";
|
||||
export class AwsJsonRpcProtocol extends RpcProtocol {
|
||||
serializer;
|
||||
deserializer;
|
||||
serviceTarget;
|
||||
codec;
|
||||
mixin;
|
||||
awsQueryCompatible;
|
||||
constructor({ defaultNamespace, errorTypeRegistries, serviceTarget, awsQueryCompatible, jsonCodec, }) {
|
||||
super({
|
||||
defaultNamespace,
|
||||
errorTypeRegistries,
|
||||
});
|
||||
this.serviceTarget = serviceTarget;
|
||||
this.codec =
|
||||
jsonCodec ??
|
||||
new JsonCodec({
|
||||
timestampFormat: {
|
||||
useTrait: true,
|
||||
default: 7,
|
||||
},
|
||||
jsonName: false,
|
||||
});
|
||||
this.serializer = this.codec.createSerializer();
|
||||
this.deserializer = this.codec.createDeserializer();
|
||||
this.awsQueryCompatible = !!awsQueryCompatible;
|
||||
this.mixin = new ProtocolLib(this.awsQueryCompatible);
|
||||
}
|
||||
async serializeRequest(operationSchema, input, context) {
|
||||
const request = await super.serializeRequest(operationSchema, input, context);
|
||||
if (!request.path.endsWith("/")) {
|
||||
request.path += "/";
|
||||
}
|
||||
request.headers["content-type"] = `application/x-amz-json-${this.getJsonRpcVersion()}`;
|
||||
request.headers["x-amz-target"] = `${this.serviceTarget}.${operationSchema.name}`;
|
||||
if (this.awsQueryCompatible) {
|
||||
request.headers["x-amzn-query-mode"] = "true";
|
||||
}
|
||||
if (deref(operationSchema.input) === "unit" || !request.body) {
|
||||
request.body = "{}";
|
||||
}
|
||||
return request;
|
||||
}
|
||||
getPayloadCodec() {
|
||||
return this.codec;
|
||||
}
|
||||
async handleError(operationSchema, context, response, dataObject, metadata) {
|
||||
const { awsQueryCompatible } = this;
|
||||
if (awsQueryCompatible) {
|
||||
this.mixin.setQueryCompatError(dataObject, response);
|
||||
}
|
||||
const errorIdentifier = loadJsonRpcErrorCode(response, dataObject, awsQueryCompatible) ?? "Unknown";
|
||||
this.mixin.compose(this.compositeErrorRegistry, errorIdentifier, this.options.defaultNamespace);
|
||||
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, dataObject, metadata, awsQueryCompatible ? this.mixin.findQueryCompatibleError : undefined);
|
||||
const ns = NormalizedSchema.of(errorSchema);
|
||||
const message = dataObject.message ?? dataObject.Message ?? "UnknownError";
|
||||
const ErrorCtor = this.compositeErrorRegistry.getErrorCtor(errorSchema) ?? Error;
|
||||
const exception = new ErrorCtor({});
|
||||
const output = {};
|
||||
const errorDeserializer = this.codec.createDeserializer();
|
||||
for (const [name, member] of ns.structIterator()) {
|
||||
if (dataObject[name] != null) {
|
||||
output[name] = errorDeserializer.readObject(member, dataObject[name]);
|
||||
}
|
||||
}
|
||||
if (awsQueryCompatible) {
|
||||
this.mixin.queryCompatOutput(dataObject, output);
|
||||
}
|
||||
throw this.mixin.decorateServiceException(Object.assign(exception, errorMetadata, {
|
||||
$fault: ns.getMergedTraits().error,
|
||||
message,
|
||||
}, output), dataObject);
|
||||
}
|
||||
}
|
||||
Generated
Vendored
+85
@@ -0,0 +1,85 @@
|
||||
import { HttpBindingProtocol, HttpInterceptingShapeDeserializer, HttpInterceptingShapeSerializer, } from "@smithy/core/protocols";
|
||||
import { NormalizedSchema } from "@smithy/core/schema";
|
||||
import { ProtocolLib } from "../ProtocolLib";
|
||||
import { JsonCodec } from "./JsonCodec";
|
||||
import { loadRestJsonErrorCode } from "./parseJsonBody";
|
||||
export class AwsRestJsonProtocol extends HttpBindingProtocol {
|
||||
serializer;
|
||||
deserializer;
|
||||
codec;
|
||||
mixin = new ProtocolLib();
|
||||
constructor({ defaultNamespace, errorTypeRegistries, }) {
|
||||
super({
|
||||
defaultNamespace,
|
||||
errorTypeRegistries,
|
||||
});
|
||||
const settings = {
|
||||
timestampFormat: {
|
||||
useTrait: true,
|
||||
default: 7,
|
||||
},
|
||||
httpBindings: true,
|
||||
jsonName: true,
|
||||
};
|
||||
this.codec = new JsonCodec(settings);
|
||||
this.serializer = new HttpInterceptingShapeSerializer(this.codec.createSerializer(), settings);
|
||||
this.deserializer = new HttpInterceptingShapeDeserializer(this.codec.createDeserializer(), settings);
|
||||
}
|
||||
getShapeId() {
|
||||
return "aws.protocols#restJson1";
|
||||
}
|
||||
getPayloadCodec() {
|
||||
return this.codec;
|
||||
}
|
||||
setSerdeContext(serdeContext) {
|
||||
this.codec.setSerdeContext(serdeContext);
|
||||
super.setSerdeContext(serdeContext);
|
||||
}
|
||||
async serializeRequest(operationSchema, input, context) {
|
||||
const request = await super.serializeRequest(operationSchema, input, context);
|
||||
const inputSchema = NormalizedSchema.of(operationSchema.input);
|
||||
if (!request.headers["content-type"]) {
|
||||
const contentType = this.mixin.resolveRestContentType(this.getDefaultContentType(), inputSchema);
|
||||
if (contentType) {
|
||||
request.headers["content-type"] = contentType;
|
||||
}
|
||||
}
|
||||
if (request.body == null && request.headers["content-type"] === this.getDefaultContentType()) {
|
||||
request.body = "{}";
|
||||
}
|
||||
return request;
|
||||
}
|
||||
async deserializeResponse(operationSchema, context, response) {
|
||||
const output = await super.deserializeResponse(operationSchema, context, response);
|
||||
const outputSchema = NormalizedSchema.of(operationSchema.output);
|
||||
for (const [name, member] of outputSchema.structIterator()) {
|
||||
if (member.getMemberTraits().httpPayload && !(name in output)) {
|
||||
output[name] = null;
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
async handleError(operationSchema, context, response, dataObject, metadata) {
|
||||
const errorIdentifier = loadRestJsonErrorCode(response, dataObject) ?? "Unknown";
|
||||
this.mixin.compose(this.compositeErrorRegistry, errorIdentifier, this.options.defaultNamespace);
|
||||
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, dataObject, metadata);
|
||||
const ns = NormalizedSchema.of(errorSchema);
|
||||
const message = dataObject.message ?? dataObject.Message ?? "UnknownError";
|
||||
const ErrorCtor = this.compositeErrorRegistry.getErrorCtor(errorSchema) ?? Error;
|
||||
const exception = new ErrorCtor({});
|
||||
await this.deserializeHttpMessage(errorSchema, context, response, dataObject);
|
||||
const output = {};
|
||||
const errorDeserializer = this.codec.createDeserializer();
|
||||
for (const [name, member] of ns.structIterator()) {
|
||||
const target = member.getMergedTraits().jsonName ?? name;
|
||||
output[name] = errorDeserializer.readObject(member, dataObject[target]);
|
||||
}
|
||||
throw this.mixin.decorateServiceException(Object.assign(exception, errorMetadata, {
|
||||
$fault: ns.getMergedTraits().error,
|
||||
message,
|
||||
}, output), dataObject);
|
||||
}
|
||||
getDefaultContentType() {
|
||||
return "application/json";
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
import { SerdeContextConfig } from "../ConfigurableSerdeContext";
|
||||
import { JsonShapeDeserializer } from "./JsonShapeDeserializer";
|
||||
import { JsonShapeSerializer } from "./JsonShapeSerializer";
|
||||
export class JsonCodec extends SerdeContextConfig {
|
||||
settings;
|
||||
constructor(settings) {
|
||||
super();
|
||||
this.settings = settings;
|
||||
}
|
||||
createSerializer() {
|
||||
const serializer = new JsonShapeSerializer(this.settings);
|
||||
serializer.setSerdeContext(this.serdeContext);
|
||||
return serializer;
|
||||
}
|
||||
createDeserializer() {
|
||||
const deserializer = new JsonShapeDeserializer(this.settings);
|
||||
deserializer.setSerdeContext(this.serdeContext);
|
||||
return deserializer;
|
||||
}
|
||||
}
|
||||
Generated
Vendored
+151
@@ -0,0 +1,151 @@
|
||||
import { determineTimestampFormat } from "@smithy/core/protocols";
|
||||
import { NormalizedSchema } from "@smithy/core/schema";
|
||||
import { LazyJsonString, NumericValue, parseEpochTimestamp, parseRfc3339DateTimeWithOffset, parseRfc7231DateTime, } from "@smithy/core/serde";
|
||||
import { fromBase64 } from "@smithy/core/serde";
|
||||
import { SerdeContextConfig } from "../ConfigurableSerdeContext";
|
||||
import { UnionSerde } from "../UnionSerde";
|
||||
import { jsonReviver } from "./jsonReviver";
|
||||
import { parseJsonBody } from "./parseJsonBody";
|
||||
export class JsonShapeDeserializer extends SerdeContextConfig {
|
||||
settings;
|
||||
constructor(settings) {
|
||||
super();
|
||||
this.settings = settings;
|
||||
}
|
||||
async read(schema, data) {
|
||||
return this._read(schema, typeof data === "string" ? JSON.parse(data, jsonReviver) : await parseJsonBody(data, this.serdeContext));
|
||||
}
|
||||
readObject(schema, data) {
|
||||
return this._read(schema, data);
|
||||
}
|
||||
_read(schema, value) {
|
||||
const isObject = value !== null && typeof value === "object";
|
||||
const ns = NormalizedSchema.of(schema);
|
||||
if (isObject) {
|
||||
if (ns.isStructSchema()) {
|
||||
const record = value;
|
||||
const union = ns.isUnionSchema();
|
||||
const out = {};
|
||||
let nameMap = void 0;
|
||||
const { jsonName } = this.settings;
|
||||
if (jsonName) {
|
||||
nameMap = {};
|
||||
}
|
||||
let unionSerde;
|
||||
if (union) {
|
||||
unionSerde = new UnionSerde(record, out);
|
||||
}
|
||||
for (const [memberName, memberSchema] of ns.structIterator()) {
|
||||
let fromKey = memberName;
|
||||
if (jsonName) {
|
||||
fromKey = memberSchema.getMergedTraits().jsonName ?? fromKey;
|
||||
nameMap[fromKey] = memberName;
|
||||
}
|
||||
if (union) {
|
||||
unionSerde.mark(fromKey);
|
||||
}
|
||||
if (record[fromKey] != null) {
|
||||
out[memberName] = this._read(memberSchema, record[fromKey]);
|
||||
}
|
||||
}
|
||||
if (union) {
|
||||
unionSerde.writeUnknown();
|
||||
}
|
||||
else if (typeof record.__type === "string") {
|
||||
for (const k in record) {
|
||||
const v = record[k];
|
||||
const t = jsonName ? nameMap[k] ?? k : k;
|
||||
if (!(t in out)) {
|
||||
out[t] = v;
|
||||
}
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
if (Array.isArray(value) && ns.isListSchema()) {
|
||||
const listMember = ns.getValueSchema();
|
||||
const out = [];
|
||||
for (const item of value) {
|
||||
out.push(this._read(listMember, item));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
if (ns.isMapSchema()) {
|
||||
const mapMember = ns.getValueSchema();
|
||||
const out = {};
|
||||
for (const _k in value) {
|
||||
out[_k] = this._read(mapMember, value[_k]);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
}
|
||||
if (ns.isBlobSchema() && typeof value === "string") {
|
||||
return fromBase64(value);
|
||||
}
|
||||
const mediaType = ns.getMergedTraits().mediaType;
|
||||
if (ns.isStringSchema() && typeof value === "string" && mediaType) {
|
||||
const isJson = mediaType === "application/json" || mediaType.endsWith("+json");
|
||||
if (isJson) {
|
||||
return LazyJsonString.from(value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
if (ns.isTimestampSchema() && value != null) {
|
||||
const format = determineTimestampFormat(ns, this.settings);
|
||||
switch (format) {
|
||||
case 5:
|
||||
return parseRfc3339DateTimeWithOffset(value);
|
||||
case 6:
|
||||
return parseRfc7231DateTime(value);
|
||||
case 7:
|
||||
return parseEpochTimestamp(value);
|
||||
default:
|
||||
console.warn("Missing timestamp format, parsing value with Date constructor:", value);
|
||||
return new Date(value);
|
||||
}
|
||||
}
|
||||
if (ns.isBigIntegerSchema() && (typeof value === "number" || typeof value === "string")) {
|
||||
return BigInt(value);
|
||||
}
|
||||
if (ns.isBigDecimalSchema() && value != undefined) {
|
||||
if (value instanceof NumericValue) {
|
||||
return value;
|
||||
}
|
||||
const untyped = value;
|
||||
if (untyped.type === "bigDecimal" && "string" in untyped) {
|
||||
return new NumericValue(untyped.string, untyped.type);
|
||||
}
|
||||
return new NumericValue(String(value), "bigDecimal");
|
||||
}
|
||||
if (ns.isNumericSchema() && typeof value === "string") {
|
||||
switch (value) {
|
||||
case "Infinity":
|
||||
return Infinity;
|
||||
case "-Infinity":
|
||||
return -Infinity;
|
||||
case "NaN":
|
||||
return NaN;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
if (ns.isDocumentSchema()) {
|
||||
if (isObject) {
|
||||
const out = Array.isArray(value) ? [] : {};
|
||||
for (const k in value) {
|
||||
const v = value[k];
|
||||
if (v instanceof NumericValue) {
|
||||
out[k] = v;
|
||||
}
|
||||
else {
|
||||
out[k] = this._read(ns, v);
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
else {
|
||||
return structuredClone(value);
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user