@cdk8s/awscdk-resolver 0.0.643 → 0.0.644
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.jsii +3 -3
- package/lib/resolve.js +1 -1
- package/node_modules/@aws-sdk/client-cloudformation/dist-cjs/index.js +2 -1
- package/node_modules/@aws-sdk/client-cloudformation/dist-es/models/enums.js +1 -0
- package/node_modules/@aws-sdk/client-cloudformation/dist-types/commands/DescribeChangeSetCommand.d.ts +1 -1
- package/node_modules/@aws-sdk/client-cloudformation/dist-types/models/enums.d.ts +1 -0
- package/node_modules/@aws-sdk/client-cloudformation/dist-types/models/models_0.d.ts +7 -3
- package/node_modules/@aws-sdk/client-cloudformation/dist-types/ts3.4/models/enums.d.ts +1 -0
- package/node_modules/@aws-sdk/client-cloudformation/package.json +6 -6
- package/node_modules/@aws-sdk/core/dist-cjs/submodules/protocols/index.js +856 -57
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/index.js +8 -5
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/AwsJsonRpcProtocol.js +1 -1
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/AwsRestJsonProtocol.js +1 -1
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/JsonSettings.js +1 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/{JsonCodec.js → codec-v1/JsonCodec.js} +1 -1
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v1/JsonSettings.js +1 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/{JsonShapeDeserializer.js → codec-v1/JsonShapeDeserializer.js} +6 -6
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/{JsonShapeSerializer.js → codec-v1/JsonShapeSerializer.js} +3 -3
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v2/JsonBytesStringAdapter.js +103 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v2/JsonCodec2.js +20 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/{experimental/BufferJsonShapeDeserializer.js → codec-v2/JsonShapeDeserializer2.js} +38 -18
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/{experimental/ByteJsonShapeSerializer.js → codec-v2/JsonShapeSerializer2.js} +66 -60
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/index.d.ts +9 -6
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/AwsJson1_0Protocol.d.ts +1 -1
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/AwsJson1_1Protocol.d.ts +1 -1
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/AwsJsonRpcProtocol.d.ts +1 -1
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/AwsRestJsonProtocol.d.ts +1 -1
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/JsonSettings.d.ts +7 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/{JsonCodec.d.ts → codec-v1/JsonCodec.d.ts} +4 -8
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/codec-v1/JsonSettings.d.ts +7 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/{JsonShapeDeserializer.d.ts → codec-v1/JsonShapeDeserializer.d.ts} +3 -2
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/{JsonShapeSerializer.d.ts → codec-v1/JsonShapeSerializer.d.ts} +3 -2
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/codec-v2/JsonBytesStringAdapter.d.ts +51 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/codec-v2/JsonCodec2.d.ts +13 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/{experimental/BufferJsonShapeDeserializer.d.ts → codec-v2/JsonShapeDeserializer2.d.ts} +4 -3
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/{experimental/ByteJsonShapeSerializer.d.ts → codec-v2/JsonShapeSerializer2.d.ts} +19 -16
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/api-extractor-type-index.d.ts +4 -7
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/index.d.ts +61 -21
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/account-id-endpoint/AccountIdEndpointModeConfigResolver.d.ts +13 -27
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/account-id-endpoint/AccountIdEndpointModeConstants.d.ts +4 -16
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/account-id-endpoint/NodeAccountIdEndpointModeConfigOptions.d.ts +5 -14
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/account-id-endpoint/index.d.ts +16 -5
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/emitWarningIfUnsupportedVersion.d.ts +4 -11
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/index.browser.d.ts +107 -47
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/index.d.ts +112 -39
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/index.native.d.ts +107 -48
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/longPollMiddleware.d.ts +13 -14
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/middleware-host-header/hostHeaderMiddleware.d.ts +25 -35
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/middleware-logger/loggerMiddleware.d.ts +14 -4
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/middleware-recursion-detection/configuration.d.ts +2 -6
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/middleware-recursion-detection/getRecursionDetectionPlugin.browser.d.ts +2 -5
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/middleware-recursion-detection/getRecursionDetectionPlugin.d.ts +2 -5
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/middleware-recursion-detection/recursionDetectionMiddleware.browser.d.ts +2 -6
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/middleware-recursion-detection/recursionDetectionMiddleware.d.ts +2 -10
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/middleware-recursion-detection/recursionDetectionMiddleware.native.d.ts +2 -6
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/middleware-user-agent/check-features.d.ts +16 -20
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/middleware-user-agent/configurations.d.ts +21 -44
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/middleware-user-agent/constants.d.ts +7 -7
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/middleware-user-agent/encode-features.d.ts +2 -5
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/middleware-user-agent/user-agent-middleware.d.ts +18 -18
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/region-config-resolver/awsRegionConfig.d.ts +8 -11
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/region-config-resolver/extensions.d.ts +14 -16
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/region-config-resolver/stsRegionDefaultResolver.browser.d.ts +1 -4
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/region-config-resolver/stsRegionDefaultResolver.d.ts +7 -14
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/region-config-resolver/stsRegionDefaultResolver.native.d.ts +1 -4
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/setCredentialFeature.d.ts +6 -7
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/setFeature.d.ts +6 -12
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/setTokenFeature.d.ts +6 -7
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-endpoints/aws.d.ts +2 -2
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-endpoints/lib/aws/isVirtualHostableS3Bucket.d.ts +4 -5
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-endpoints/lib/aws/parseArn.d.ts +2 -7
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-endpoints/lib/aws/partition.d.ts +28 -38
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-endpoints/lib/aws/partitions.d.ts +647 -638
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-endpoints/lib/isIpAddress.d.ts +1 -1
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-endpoints/resolveDefaultAwsRegionalEndpointsConfig.d.ts +29 -56
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-endpoints/resolveEndpoint.d.ts +1 -1
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-endpoints/types/EndpointError.d.ts +1 -1
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-endpoints/types/EndpointRuleObject.d.ts +6 -1
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-endpoints/types/ErrorRuleObject.d.ts +1 -1
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-endpoints/types/RuleSetObject.d.ts +1 -1
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-endpoints/types/TreeRuleObject.d.ts +1 -1
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-endpoints/types/shared.d.ts +12 -1
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-user-agent-browser/configurations.d.ts +4 -7
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-user-agent-browser/createUserAgentStringParsingProvider.d.ts +7 -14
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-user-agent-browser/defaultUserAgent.browser.d.ts +7 -2
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-user-agent-browser/defaultUserAgent.d.ts +18 -27
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-user-agent-browser/defaultUserAgent.native.d.ts +13 -18
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-user-agent-node/crt-availability.d.ts +3 -8
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-user-agent-node/defaultUserAgent.d.ts +17 -28
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-user-agent-node/getRuntimeUserAgentPair.d.ts +2 -6
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-user-agent-node/is-crt-available.d.ts +2 -5
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-user-agent-node/nodeAppIdConfigOptions.d.ts +4 -13
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/httpAuthSchemes/aws_sdk/AwsSdkSigV4ASigner.d.ts +9 -10
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/httpAuthSchemes/aws_sdk/AwsSdkSigV4Signer.d.ts +39 -44
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/httpAuthSchemes/aws_sdk/NODE_AUTH_SCHEME_PREFERENCE_OPTIONS.d.ts +2 -5
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/httpAuthSchemes/aws_sdk/clock-skew-defaults.browser.d.ts +1 -6
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/httpAuthSchemes/aws_sdk/clock-skew-defaults.d.ts +1 -7
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/httpAuthSchemes/aws_sdk/clock-skew-node-config.d.ts +4 -13
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/httpAuthSchemes/aws_sdk/index.d.ts +23 -7
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/httpAuthSchemes/aws_sdk/resolveAwsSdkSigV4AConfig.d.ts +13 -38
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/httpAuthSchemes/aws_sdk/resolveAwsSdkSigV4Config.d.ts +57 -133
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/httpAuthSchemes/index.browser.d.ts +32 -11
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/httpAuthSchemes/index.d.ts +32 -9
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/httpAuthSchemes/utils/getArrayForCommaSeparatedString.d.ts +1 -8
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/httpAuthSchemes/utils/getBearerTokenEnvKey.d.ts +1 -6
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/httpAuthSchemes/utils/getDateHeader.d.ts +2 -8
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/httpAuthSchemes/utils/getSkewCorrectedDate.d.ts +1 -8
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/httpAuthSchemes/utils/getUpdatedSystemClockOffset.d.ts +6 -26
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/httpAuthSchemes/utils/index.d.ts +4 -4
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/httpAuthSchemes/utils/isClockSkewed.d.ts +1 -9
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/ConfigurableSerdeContext.d.ts +5 -8
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/ProtocolLib.d.ts +40 -74
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/UnionSerde.d.ts +9 -24
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/cbor/AwsSmithyRpcV2CborProtocol.d.ts +36 -25
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/coercing-serializers.d.ts +3 -18
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/common.d.ts +5 -2
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/index.d.ts +30 -22
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/AwsJson1_0Protocol.d.ts +21 -22
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/AwsJson1_1Protocol.d.ts +21 -22
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/AwsJsonRpcProtocol.d.ts +49 -29
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/AwsRestJsonProtocol.d.ts +49 -36
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/JsonSettings.d.ts +4 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/awsExpectUnion.d.ts +1 -7
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/codec-v1/JsonCodec.d.ts +11 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/codec-v1/JsonSettings.d.ts +4 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/codec-v1/JsonShapeDeserializer.d.ts +13 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/codec-v1/JsonShapeSerializer.d.ts +18 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/codec-v2/JsonBytesStringAdapter.d.ts +27 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/codec-v2/JsonCodec2.d.ts +9 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/codec-v2/JsonShapeDeserializer2.d.ts +15 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/codec-v2/JsonShapeSerializer2.d.ts +39 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/detectBufferParsing.d.ts +1 -1
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/jsonReplacer.d.ts +7 -21
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/jsonReviver.d.ts +7 -15
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/needsReviver.d.ts +2 -11
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/parseJsonBody.d.ts +14 -22
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/query/AwsEc2QueryProtocol.d.ts +18 -27
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/query/AwsQueryProtocol.d.ts +57 -49
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/query/QuerySerializerSettings.d.ts +7 -13
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/query/QueryShapeSerializer.d.ts +21 -16
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/writeKey.d.ts +1 -4
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/xml/AwsRestXmlProtocol.d.ts +47 -31
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/xml/XmlCodec.d.ts +17 -14
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/xml/XmlShapeDeserializer.d.ts +15 -20
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/xml/XmlShapeSerializer.d.ts +21 -21
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/xml/parseXmlBody.d.ts +4 -13
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/xml/simpleFormatXml.d.ts +1 -6
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/util/index.d.ts +3 -3
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/util/util-arn-parser/arn.d.ts +14 -32
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/util/util-format-url/format-url.d.ts +4 -2
- package/node_modules/@aws-sdk/core/package.json +3 -3
- package/node_modules/@aws-sdk/credential-provider-env/package.json +3 -3
- package/node_modules/@aws-sdk/credential-provider-http/package.json +5 -5
- package/node_modules/@aws-sdk/credential-provider-ini/package.json +11 -11
- package/node_modules/@aws-sdk/credential-provider-login/package.json +4 -4
- package/node_modules/@aws-sdk/credential-provider-node/package.json +9 -9
- package/node_modules/@aws-sdk/credential-provider-process/package.json +3 -3
- package/node_modules/@aws-sdk/credential-provider-sso/package.json +5 -5
- package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +4 -4
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/cognito-identity/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/signin/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/package.json +6 -6
- package/node_modules/@aws-sdk/signature-v4-multi-region/package.json +2 -2
- package/node_modules/@aws-sdk/token-providers/package.json +4 -4
- package/node_modules/@smithy/core/dist-cjs/submodules/cbor/index.js +1561 -337
- package/node_modules/@smithy/core/dist-es/submodules/cbor/CborCodec.js +4 -205
- package/node_modules/@smithy/core/dist-es/submodules/cbor/cbor-encode.js +1 -1
- package/node_modules/@smithy/core/dist-es/submodules/cbor/codec-v1/CborShapeDeserializer.js +113 -0
- package/node_modules/@smithy/core/dist-es/submodules/cbor/codec-v1/CborShapeSerializer.js +103 -0
- package/node_modules/@smithy/core/dist-es/submodules/cbor/codec-v2/CborShapeDeserializer2.js +621 -0
- package/node_modules/@smithy/core/dist-es/submodules/cbor/codec-v2/CborShapeSerializer2.js +602 -0
- package/node_modules/@smithy/core/dist-es/submodules/cbor/index.js +5 -1
- package/node_modules/@smithy/core/dist-types/submodules/cbor/CborCodec.d.ts +5 -27
- package/node_modules/@smithy/core/dist-types/submodules/cbor/SmithyRpcV2CborProtocol.d.ts +2 -2
- package/node_modules/@smithy/core/dist-types/submodules/cbor/codec-v1/CborShapeDeserializer.d.ts +13 -0
- package/node_modules/@smithy/core/dist-types/submodules/cbor/codec-v1/CborShapeSerializer.d.ts +15 -0
- package/node_modules/@smithy/core/dist-types/submodules/cbor/codec-v2/CborShapeDeserializer2.d.ts +18 -0
- package/node_modules/@smithy/core/dist-types/submodules/cbor/codec-v2/CborShapeSerializer2.d.ts +35 -0
- package/node_modules/@smithy/core/dist-types/submodules/cbor/index.d.ts +5 -1
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/cbor/CborCodec.d.ts +5 -27
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/cbor/SmithyRpcV2CborProtocol.d.ts +2 -2
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/cbor/codec-v1/CborShapeDeserializer.d.ts +13 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/cbor/codec-v1/CborShapeSerializer.d.ts +15 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/cbor/codec-v2/CborShapeDeserializer2.d.ts +18 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/cbor/codec-v2/CborShapeSerializer2.d.ts +35 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/cbor/index.d.ts +5 -1
- package/node_modules/@smithy/core/package.json +2 -1
- package/node_modules/@smithy/credential-provider-imds/package.json +2 -2
- package/node_modules/@smithy/fetch-http-handler/package.json +2 -2
- package/node_modules/@smithy/node-http-handler/package.json +2 -2
- package/node_modules/@smithy/signature-v4/package.json +2 -2
- package/package.json +5 -5
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/JsonCodec.d.ts +0 -19
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/JsonShapeDeserializer.d.ts +0 -13
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/JsonShapeSerializer.d.ts +0 -28
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/experimental/BufferJsonShapeDeserializer.d.ts +0 -29
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/experimental/ByteJsonShapeSerializer.d.ts +0 -57
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { nv, NumericValue, calculateBodyLength,
|
|
1
|
+
const { nv, NumericValue, calculateBodyLength, generateIdempotencyToken, fromBase64, _parseEpochTimestamp } = require("@smithy/core/serde");
|
|
2
2
|
const { HttpRequest, collectBody, SerdeContext, RpcProtocol } = require("@smithy/core/protocols");
|
|
3
3
|
const { NormalizedSchema, deref, TypeRegistry } = require("@smithy/core/schema");
|
|
4
4
|
const { getSmithyContext } = require("@smithy/core/transport");
|
|
@@ -29,23 +29,23 @@ function tag(data) {
|
|
|
29
29
|
return data;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
const USE_BUFFER$
|
|
33
|
-
const textDecoder = new TextDecoder();
|
|
34
|
-
let payload = alloc(0);
|
|
35
|
-
let isBuffer = false;
|
|
36
|
-
let dataView$
|
|
32
|
+
const USE_BUFFER$3 = typeof Buffer !== "undefined";
|
|
33
|
+
const textDecoder$1 = new TextDecoder();
|
|
34
|
+
let payload$1 = alloc(0);
|
|
35
|
+
let isBuffer$1 = false;
|
|
36
|
+
let dataView$2 = new DataView(payload$1.buffer, payload$1.byteOffset, payload$1.byteLength);
|
|
37
37
|
let _offset = 0;
|
|
38
38
|
function setPayload(bytes) {
|
|
39
|
-
payload = bytes;
|
|
40
|
-
isBuffer = USE_BUFFER$
|
|
41
|
-
dataView$
|
|
39
|
+
payload$1 = bytes;
|
|
40
|
+
isBuffer$1 = USE_BUFFER$3 && payload$1 instanceof Buffer;
|
|
41
|
+
dataView$2 = new DataView(payload$1.buffer, payload$1.byteOffset, payload$1.byteLength);
|
|
42
42
|
}
|
|
43
43
|
function decode(at, to) {
|
|
44
44
|
if (at >= to) {
|
|
45
45
|
throw new Error("unexpected end of (decode) payload.");
|
|
46
46
|
}
|
|
47
|
-
const major = (payload[at] & 0b1110_0000) >> 5;
|
|
48
|
-
const minor = payload[at] & 0b0001_1111;
|
|
47
|
+
const major = (payload$1[at] & 0b1110_0000) >> 5;
|
|
48
|
+
const minor = payload$1[at] & 0b0001_1111;
|
|
49
49
|
if (minor === minorIndefinite && 2 <= major && major <= 5) {
|
|
50
50
|
return decodeIndefinite(at, to);
|
|
51
51
|
}
|
|
@@ -63,36 +63,36 @@ function decode(at, to) {
|
|
|
63
63
|
switch (minor) {
|
|
64
64
|
case extendedOneByte:
|
|
65
65
|
if (to - at < 2) {
|
|
66
|
-
overflow(1);
|
|
66
|
+
overflow$1(1);
|
|
67
67
|
}
|
|
68
|
-
unsignedInt = payload[at + 1];
|
|
68
|
+
unsignedInt = payload$1[at + 1];
|
|
69
69
|
offset = 2;
|
|
70
70
|
break;
|
|
71
71
|
case extendedFloat16:
|
|
72
72
|
if (to - at < 3) {
|
|
73
|
-
overflow(2);
|
|
73
|
+
overflow$1(2);
|
|
74
74
|
}
|
|
75
|
-
unsignedInt = dataView$
|
|
75
|
+
unsignedInt = dataView$2.getUint16(at + 1);
|
|
76
76
|
offset = 3;
|
|
77
77
|
break;
|
|
78
78
|
case extendedFloat32:
|
|
79
79
|
if (to - at < 5) {
|
|
80
|
-
overflow(4);
|
|
80
|
+
overflow$1(4);
|
|
81
81
|
}
|
|
82
|
-
unsignedInt = dataView$
|
|
82
|
+
unsignedInt = dataView$2.getUint32(at + 1);
|
|
83
83
|
offset = 5;
|
|
84
84
|
break;
|
|
85
85
|
case extendedFloat64:
|
|
86
86
|
if (to - at < 9) {
|
|
87
|
-
overflow(8);
|
|
87
|
+
overflow$1(8);
|
|
88
88
|
}
|
|
89
89
|
{
|
|
90
|
-
const hi = dataView$
|
|
90
|
+
const hi = dataView$2.getUint32(at + 1);
|
|
91
91
|
if (hi < 0x00200000) {
|
|
92
|
-
unsignedInt = hi * 4294967296 + dataView$
|
|
92
|
+
unsignedInt = hi * 4294967296 + dataView$2.getUint32(at + 5);
|
|
93
93
|
}
|
|
94
94
|
else {
|
|
95
|
-
unsignedInt = dataView$
|
|
95
|
+
unsignedInt = dataView$2.getBigUint64(at + 1);
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
offset = 9;
|
|
@@ -103,7 +103,7 @@ function decode(at, to) {
|
|
|
103
103
|
}
|
|
104
104
|
if (major === majorUint64) {
|
|
105
105
|
_offset = offset;
|
|
106
|
-
return castBigInt(unsignedInt);
|
|
106
|
+
return castBigInt$1(unsignedInt);
|
|
107
107
|
}
|
|
108
108
|
else if (major === majorNegativeInt64) {
|
|
109
109
|
let negativeInt;
|
|
@@ -114,7 +114,7 @@ function decode(at, to) {
|
|
|
114
114
|
negativeInt = -1 - unsignedInt;
|
|
115
115
|
}
|
|
116
116
|
_offset = offset;
|
|
117
|
-
return castBigInt(negativeInt);
|
|
117
|
+
return castBigInt$1(negativeInt);
|
|
118
118
|
}
|
|
119
119
|
else {
|
|
120
120
|
return decodeTagValue(at, to, minor, unsignedInt, offset);
|
|
@@ -133,8 +133,8 @@ function decode(at, to) {
|
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
function decodeIndefinite(at, to) {
|
|
136
|
-
const major = (payload[at] & 0b1110_0000) >> 5;
|
|
137
|
-
const minor = payload[at] & 0b0001_1111;
|
|
136
|
+
const major = (payload$1[at] & 0b1110_0000) >> 5;
|
|
137
|
+
const minor = payload$1[at] & 0b0001_1111;
|
|
138
138
|
if (minor === minorIndefinite) {
|
|
139
139
|
switch (major) {
|
|
140
140
|
case majorUtf8String:
|
|
@@ -148,7 +148,7 @@ function decodeIndefinite(at, to) {
|
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
|
-
function bytesToFloat16(a, b) {
|
|
151
|
+
function bytesToFloat16$1(a, b) {
|
|
152
152
|
const sign = a >> 7;
|
|
153
153
|
const exponent = (a & 0b0111_1100) >> 2;
|
|
154
154
|
const fraction = ((a & 0b0000_0011) << 8) | b;
|
|
@@ -168,7 +168,7 @@ function bytesToFloat16(a, b) {
|
|
|
168
168
|
return scalar * (Math.pow(2, exponent - 15) * (1 + fraction / 1024));
|
|
169
169
|
}
|
|
170
170
|
function decodeMap(at, to) {
|
|
171
|
-
const mapDataLength = decodeCount(at, to);
|
|
171
|
+
const mapDataLength = decodeCount$1(at, to);
|
|
172
172
|
if (mapDataLength < 25) {
|
|
173
173
|
return decodeMapSmall(at, to, mapDataLength);
|
|
174
174
|
}
|
|
@@ -182,7 +182,7 @@ function decodeMapLarge(at, to, mapDataLength) {
|
|
|
182
182
|
for (let i = 0; i < mapDataLength; ++i) {
|
|
183
183
|
const key = decodeUtf8String(at, to);
|
|
184
184
|
at += _offset;
|
|
185
|
-
const valMajor = (payload[at] & 0b1110_0000) >> 5;
|
|
185
|
+
const valMajor = (payload$1[at] & 0b1110_0000) >> 5;
|
|
186
186
|
if (valMajor === majorUtf8String) {
|
|
187
187
|
map[key] = decodeUtf8String(at, to);
|
|
188
188
|
}
|
|
@@ -210,7 +210,7 @@ function decodeMapSmall(at, to, mapDataLength) {
|
|
|
210
210
|
return map;
|
|
211
211
|
}
|
|
212
212
|
function decodeList(at, to) {
|
|
213
|
-
const listDataLength = decodeCount(at, to);
|
|
213
|
+
const listDataLength = decodeCount$1(at, to);
|
|
214
214
|
const offset = _offset;
|
|
215
215
|
at += offset;
|
|
216
216
|
const base = at;
|
|
@@ -223,76 +223,76 @@ function decodeList(at, to) {
|
|
|
223
223
|
return list;
|
|
224
224
|
}
|
|
225
225
|
function decodeUtf8String(at, to) {
|
|
226
|
-
const length = decodeCount(at, to);
|
|
226
|
+
const length = decodeCount$1(at, to);
|
|
227
227
|
const offset = _offset;
|
|
228
228
|
at += offset;
|
|
229
229
|
if (to - at < length) {
|
|
230
|
-
overflow(length);
|
|
230
|
+
overflow$1(length);
|
|
231
231
|
}
|
|
232
232
|
_offset = offset + length;
|
|
233
233
|
if (length < 24) {
|
|
234
234
|
return decodeUtf8StringCached(at, length);
|
|
235
235
|
}
|
|
236
|
-
if (isBuffer) {
|
|
237
|
-
return payload.toString("utf-8", at, at + length);
|
|
236
|
+
if (isBuffer$1) {
|
|
237
|
+
return payload$1.toString("utf-8", at, at + length);
|
|
238
238
|
}
|
|
239
|
-
return textDecoder.decode(payload.subarray(at, at + length));
|
|
239
|
+
return textDecoder$1.decode(payload$1.subarray(at, at + length));
|
|
240
240
|
}
|
|
241
|
-
const stringCache = new Array(2048);
|
|
242
|
-
const stringCacheEpochs = new Uint16Array(2048);
|
|
243
|
-
let cacheEpoch = 0;
|
|
241
|
+
const stringCache$1 = new Array(2048);
|
|
242
|
+
const stringCacheEpochs$1 = new Uint16Array(2048);
|
|
243
|
+
let cacheEpoch$1 = 0;
|
|
244
244
|
function advanceDecodingEpoch() {
|
|
245
|
-
cacheEpoch = (cacheEpoch + 1) & 0b1111_1111_1111_1111;
|
|
245
|
+
cacheEpoch$1 = (cacheEpoch$1 + 1) & 0b1111_1111_1111_1111;
|
|
246
246
|
}
|
|
247
247
|
function decodeUtf8StringCached(at, length) {
|
|
248
248
|
let h = length;
|
|
249
249
|
for (let i = 0; i < length; ++i) {
|
|
250
|
-
h = (h * 31 + payload[at + i]) | 0;
|
|
250
|
+
h = (h * 31 + payload$1[at + i]) | 0;
|
|
251
251
|
}
|
|
252
252
|
const slot = (h >>> 0) & 2047;
|
|
253
|
-
const cached = stringCache[slot];
|
|
253
|
+
const cached = stringCache$1[slot];
|
|
254
254
|
if (cached !== undefined) {
|
|
255
255
|
if (cached.length === length) {
|
|
256
256
|
let match = true;
|
|
257
257
|
for (let i = 0; i < length; ++i) {
|
|
258
|
-
if (cached.charCodeAt(i) !== payload[at + i]) {
|
|
258
|
+
if (cached.charCodeAt(i) !== payload$1[at + i]) {
|
|
259
259
|
match = false;
|
|
260
260
|
break;
|
|
261
261
|
}
|
|
262
262
|
}
|
|
263
263
|
if (match) {
|
|
264
|
-
stringCacheEpochs[slot] = cacheEpoch;
|
|
264
|
+
stringCacheEpochs$1[slot] = cacheEpoch$1;
|
|
265
265
|
return cached;
|
|
266
266
|
}
|
|
267
267
|
}
|
|
268
268
|
}
|
|
269
|
-
const result = isBuffer
|
|
270
|
-
? payload.toString("utf-8", at, at + length)
|
|
271
|
-
: textDecoder.decode(payload.subarray(at, at + length));
|
|
272
|
-
if (stringCacheEpochs[slot] !== cacheEpoch) {
|
|
273
|
-
stringCache[slot] = result;
|
|
274
|
-
stringCacheEpochs[slot] = cacheEpoch;
|
|
269
|
+
const result = isBuffer$1
|
|
270
|
+
? payload$1.toString("utf-8", at, at + length)
|
|
271
|
+
: textDecoder$1.decode(payload$1.subarray(at, at + length));
|
|
272
|
+
if (stringCacheEpochs$1[slot] !== cacheEpoch$1) {
|
|
273
|
+
stringCache$1[slot] = result;
|
|
274
|
+
stringCacheEpochs$1[slot] = cacheEpoch$1;
|
|
275
275
|
}
|
|
276
276
|
return result;
|
|
277
277
|
}
|
|
278
278
|
function decodeUnstructuredByteString(at, to) {
|
|
279
|
-
const length = decodeCount(at, to);
|
|
279
|
+
const length = decodeCount$1(at, to);
|
|
280
280
|
const offset = _offset;
|
|
281
281
|
at += offset;
|
|
282
282
|
if (to - at < length) {
|
|
283
|
-
overflow(length);
|
|
283
|
+
overflow$1(length);
|
|
284
284
|
}
|
|
285
|
-
const value = payload.subarray(at, at + length);
|
|
285
|
+
const value = payload$1.subarray(at, at + length);
|
|
286
286
|
_offset = offset + length;
|
|
287
287
|
return value;
|
|
288
288
|
}
|
|
289
289
|
function decodeTagValue(at, to, minor, unsignedInt, offset) {
|
|
290
290
|
if (minor === 2 || minor === 3) {
|
|
291
|
-
const length = decodeCount(at + offset, to);
|
|
291
|
+
const length = decodeCount$1(at + offset, to);
|
|
292
292
|
let b = BigInt(0);
|
|
293
293
|
const start = at + offset + _offset;
|
|
294
294
|
for (let i = start; i < start + length; ++i) {
|
|
295
|
-
b = (b << BigInt(8)) | BigInt(payload[i]);
|
|
295
|
+
b = (b << BigInt(8)) | BigInt(payload$1[i]);
|
|
296
296
|
}
|
|
297
297
|
_offset = offset + _offset + length;
|
|
298
298
|
return minor === 3 ? -b - BigInt(1) : b;
|
|
@@ -323,11 +323,11 @@ function decodeTagValue(at, to, minor, unsignedInt, offset) {
|
|
|
323
323
|
const value = decode(at + offset, to);
|
|
324
324
|
const valueOffset = _offset;
|
|
325
325
|
_offset = offset + valueOffset;
|
|
326
|
-
return tag({ tag: castBigInt(unsignedInt), value });
|
|
326
|
+
return tag({ tag: castBigInt$1(unsignedInt), value });
|
|
327
327
|
}
|
|
328
328
|
}
|
|
329
329
|
function decodeSpecial(at, to) {
|
|
330
|
-
const minor = payload[at] & 0b0001_1111;
|
|
330
|
+
const minor = payload$1[at] & 0b0001_1111;
|
|
331
331
|
switch (minor) {
|
|
332
332
|
case specialTrue:
|
|
333
333
|
case specialFalse:
|
|
@@ -344,25 +344,25 @@ function decodeSpecial(at, to) {
|
|
|
344
344
|
throw new Error("incomplete float16 at end of buf.");
|
|
345
345
|
}
|
|
346
346
|
_offset = 3;
|
|
347
|
-
return bytesToFloat16(payload[at + 1], payload[at + 2]);
|
|
347
|
+
return bytesToFloat16$1(payload$1[at + 1], payload$1[at + 2]);
|
|
348
348
|
case extendedFloat32:
|
|
349
349
|
if (to - at < 5) {
|
|
350
350
|
throw new Error("incomplete float32 at end of buf.");
|
|
351
351
|
}
|
|
352
352
|
_offset = 5;
|
|
353
|
-
return dataView$
|
|
353
|
+
return dataView$2.getFloat32(at + 1);
|
|
354
354
|
case extendedFloat64:
|
|
355
355
|
if (to - at < 9) {
|
|
356
356
|
throw new Error("incomplete float64 at end of buf.");
|
|
357
357
|
}
|
|
358
358
|
_offset = 9;
|
|
359
|
-
return dataView$
|
|
359
|
+
return dataView$2.getFloat64(at + 1);
|
|
360
360
|
default:
|
|
361
361
|
unexpectedMinor(minor);
|
|
362
362
|
}
|
|
363
363
|
}
|
|
364
|
-
function decodeCount(at, to) {
|
|
365
|
-
const minor = payload[at] & 0b0001_1111;
|
|
364
|
+
function decodeCount$1(at, to) {
|
|
365
|
+
const minor = payload$1[at] & 0b0001_1111;
|
|
366
366
|
if (minor < 24) {
|
|
367
367
|
_offset = 1;
|
|
368
368
|
return minor;
|
|
@@ -370,28 +370,28 @@ function decodeCount(at, to) {
|
|
|
370
370
|
switch (minor) {
|
|
371
371
|
case extendedOneByte:
|
|
372
372
|
if (to - at < 2) {
|
|
373
|
-
overflow(1);
|
|
373
|
+
overflow$1(1);
|
|
374
374
|
}
|
|
375
375
|
_offset = 2;
|
|
376
|
-
return payload[at + 1];
|
|
376
|
+
return payload$1[at + 1];
|
|
377
377
|
case extendedFloat16:
|
|
378
378
|
if (to - at < 3) {
|
|
379
|
-
overflow(2);
|
|
379
|
+
overflow$1(2);
|
|
380
380
|
}
|
|
381
381
|
_offset = 3;
|
|
382
|
-
return dataView$
|
|
382
|
+
return dataView$2.getUint16(at + 1);
|
|
383
383
|
case extendedFloat32:
|
|
384
384
|
if (to - at < 5) {
|
|
385
|
-
overflow(4);
|
|
385
|
+
overflow$1(4);
|
|
386
386
|
}
|
|
387
387
|
_offset = 5;
|
|
388
|
-
return dataView$
|
|
388
|
+
return dataView$2.getUint32(at + 1);
|
|
389
389
|
case extendedFloat64:
|
|
390
390
|
if (to - at < 9) {
|
|
391
|
-
overflow(8);
|
|
391
|
+
overflow$1(8);
|
|
392
392
|
}
|
|
393
393
|
_offset = 9;
|
|
394
|
-
return demote(dataView$
|
|
394
|
+
return demote(dataView$2.getBigUint64(at + 1));
|
|
395
395
|
default:
|
|
396
396
|
unexpectedMinor(minor);
|
|
397
397
|
}
|
|
@@ -401,7 +401,7 @@ function decodeMapIndefinite(at, to) {
|
|
|
401
401
|
const base = at;
|
|
402
402
|
const map = {};
|
|
403
403
|
for (; at < to;) {
|
|
404
|
-
if (payload[at] === 0b1111_1111) {
|
|
404
|
+
if (payload$1[at] === 0b1111_1111) {
|
|
405
405
|
_offset = at - base + 2;
|
|
406
406
|
return map;
|
|
407
407
|
}
|
|
@@ -416,7 +416,7 @@ function decodeListIndefinite(at, to) {
|
|
|
416
416
|
at += 1;
|
|
417
417
|
const list = [];
|
|
418
418
|
for (const base = at; at < to;) {
|
|
419
|
-
if (payload[at] === 0b1111_1111) {
|
|
419
|
+
if (payload$1[at] === 0b1111_1111) {
|
|
420
420
|
_offset = at - base + 2;
|
|
421
421
|
return list;
|
|
422
422
|
}
|
|
@@ -429,17 +429,17 @@ function decodeUtf8StringIndefinite(at, to) {
|
|
|
429
429
|
at += 1;
|
|
430
430
|
const vector = [];
|
|
431
431
|
for (const base = at; at < to;) {
|
|
432
|
-
if (payload[at] === 0b1111_1111) {
|
|
432
|
+
if (payload$1[at] === 0b1111_1111) {
|
|
433
433
|
const data = alloc(vector.length);
|
|
434
434
|
data.set(vector, 0);
|
|
435
435
|
_offset = at - base + 2;
|
|
436
|
-
if (USE_BUFFER$
|
|
436
|
+
if (USE_BUFFER$3) {
|
|
437
437
|
return data.toString("utf-8", 0, data.length);
|
|
438
438
|
}
|
|
439
|
-
return textDecoder.decode(data);
|
|
439
|
+
return textDecoder$1.decode(data);
|
|
440
440
|
}
|
|
441
|
-
const major = (payload[at] & 0b1110_0000) >> 5;
|
|
442
|
-
const minor = payload[at] & 0b0001_1111;
|
|
441
|
+
const major = (payload$1[at] & 0b1110_0000) >> 5;
|
|
442
|
+
const minor = payload$1[at] & 0b0001_1111;
|
|
443
443
|
if (major !== majorUtf8String) {
|
|
444
444
|
unexpectedMajorInIndefiniteString(major);
|
|
445
445
|
}
|
|
@@ -459,14 +459,14 @@ function decodeUnstructuredByteStringIndefinite(at, to) {
|
|
|
459
459
|
at += 1;
|
|
460
460
|
const vector = [];
|
|
461
461
|
for (const base = at; at < to;) {
|
|
462
|
-
if (payload[at] === 0b1111_1111) {
|
|
462
|
+
if (payload$1[at] === 0b1111_1111) {
|
|
463
463
|
const data = alloc(vector.length);
|
|
464
464
|
data.set(vector, 0);
|
|
465
465
|
_offset = at - base + 2;
|
|
466
466
|
return data;
|
|
467
467
|
}
|
|
468
|
-
const major = (payload[at] & 0b1110_0000) >> 5;
|
|
469
|
-
const minor = payload[at] & 0b0001_1111;
|
|
468
|
+
const major = (payload$1[at] & 0b1110_0000) >> 5;
|
|
469
|
+
const minor = payload$1[at] & 0b0001_1111;
|
|
470
470
|
if (major !== majorUnstructuredByteString) {
|
|
471
471
|
unexpectedMajorInIndefiniteString(major);
|
|
472
472
|
}
|
|
@@ -482,7 +482,7 @@ function decodeUnstructuredByteStringIndefinite(at, to) {
|
|
|
482
482
|
}
|
|
483
483
|
throw new Error("expected break marker.");
|
|
484
484
|
}
|
|
485
|
-
function castBigInt(bigInt) {
|
|
485
|
+
function castBigInt$1(bigInt) {
|
|
486
486
|
if (typeof bigInt === "number") {
|
|
487
487
|
return bigInt;
|
|
488
488
|
}
|
|
@@ -499,7 +499,7 @@ function demote(bigInteger) {
|
|
|
499
499
|
}
|
|
500
500
|
return num;
|
|
501
501
|
}
|
|
502
|
-
function overflow(n) {
|
|
502
|
+
function overflow$1(n) {
|
|
503
503
|
throw new Error(`length ${n} greater than remaining buf len.`);
|
|
504
504
|
}
|
|
505
505
|
function unexpectedMinor(minor) {
|
|
@@ -509,25 +509,25 @@ function unexpectedMajorInIndefiniteString(major) {
|
|
|
509
509
|
throw new Error(`unexpected major type ${major} in indefinite string.`);
|
|
510
510
|
}
|
|
511
511
|
|
|
512
|
-
const USE_BUFFER = typeof Buffer !== "undefined";
|
|
512
|
+
const USE_BUFFER$2 = typeof Buffer !== "undefined";
|
|
513
513
|
const encodeStringCache = new Map();
|
|
514
|
-
let encodeCacheEpoch = 0;
|
|
515
|
-
let encodeCacheSaturated = false;
|
|
514
|
+
let encodeCacheEpoch$1 = 0;
|
|
515
|
+
let encodeCacheSaturated$1 = false;
|
|
516
516
|
const initialSize = 2048;
|
|
517
517
|
let data = alloc(initialSize);
|
|
518
|
-
let dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
519
|
-
let cursor = 0;
|
|
518
|
+
let dataView$1 = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
519
|
+
let cursor$1 = 0;
|
|
520
520
|
function encode(_input) {
|
|
521
521
|
const encodeStack = [_input];
|
|
522
522
|
while (encodeStack.length) {
|
|
523
523
|
const input = encodeStack.pop();
|
|
524
524
|
if (typeof input === "string") {
|
|
525
525
|
const len = input.length;
|
|
526
|
-
if (USE_BUFFER) {
|
|
526
|
+
if (USE_BUFFER$2) {
|
|
527
527
|
ensureSpace(len * 3 + 9);
|
|
528
528
|
if (len > 23) {
|
|
529
|
-
encodeHeader(majorUtf8String, Buffer.byteLength(input));
|
|
530
|
-
cursor += data.write(input, cursor);
|
|
529
|
+
encodeHeader$1(majorUtf8String, Buffer.byteLength(input));
|
|
530
|
+
cursor$1 += data.write(input, cursor$1);
|
|
531
531
|
}
|
|
532
532
|
else {
|
|
533
533
|
encodeStringCached(input);
|
|
@@ -536,8 +536,8 @@ function encode(_input) {
|
|
|
536
536
|
else {
|
|
537
537
|
const maxBytes = len * 3;
|
|
538
538
|
ensureSpace(maxBytes + 9);
|
|
539
|
-
const headerPos = cursor;
|
|
540
|
-
const result = new TextEncoder().encodeInto(input, data.subarray(cursor + 9));
|
|
539
|
+
const headerPos = cursor$1;
|
|
540
|
+
const result = new TextEncoder().encodeInto(input, data.subarray(cursor$1 + 9));
|
|
541
541
|
const byteLen = result.written;
|
|
542
542
|
let headerSize;
|
|
543
543
|
if (byteLen < 24) {
|
|
@@ -558,50 +558,50 @@ function encode(_input) {
|
|
|
558
558
|
if (headerSize < 9) {
|
|
559
559
|
data.copyWithin(headerPos + headerSize, headerPos + 9, headerPos + 9 + byteLen);
|
|
560
560
|
}
|
|
561
|
-
cursor = headerPos;
|
|
561
|
+
cursor$1 = headerPos;
|
|
562
562
|
encodeInteger(majorUtf8String, byteLen);
|
|
563
|
-
cursor += byteLen;
|
|
563
|
+
cursor$1 += byteLen;
|
|
564
564
|
}
|
|
565
565
|
continue;
|
|
566
566
|
}
|
|
567
|
-
if (data.byteLength - cursor < 9) {
|
|
567
|
+
if (data.byteLength - cursor$1 < 9) {
|
|
568
568
|
ensureSpace(64);
|
|
569
569
|
}
|
|
570
570
|
if (typeof input === "number") {
|
|
571
|
-
if (Number.isInteger(input)) {
|
|
571
|
+
if (Number.isInteger(input) && input >= -9007199254740992 && input <= 0x1fffffffffffff) {
|
|
572
572
|
const nonNegative = input >= 0;
|
|
573
573
|
const major = nonNegative ? majorUint64 : majorNegativeInt64;
|
|
574
574
|
const value = nonNegative ? input : -input - 1;
|
|
575
575
|
if (value < 24) {
|
|
576
|
-
data[cursor++] = (major << 5) | value;
|
|
576
|
+
data[cursor$1++] = (major << 5) | value;
|
|
577
577
|
}
|
|
578
578
|
else if (value < 256) {
|
|
579
|
-
data[cursor++] = (major << 5) | 24;
|
|
580
|
-
data[cursor++] = value;
|
|
579
|
+
data[cursor$1++] = (major << 5) | 24;
|
|
580
|
+
data[cursor$1++] = value;
|
|
581
581
|
}
|
|
582
582
|
else if (value < 65536) {
|
|
583
|
-
data[cursor++] = (major << 5) | extendedFloat16;
|
|
584
|
-
data[cursor++] = value >> 8;
|
|
585
|
-
data[cursor++] = value & 0xff;
|
|
583
|
+
data[cursor$1++] = (major << 5) | extendedFloat16;
|
|
584
|
+
data[cursor$1++] = value >> 8;
|
|
585
|
+
data[cursor$1++] = value & 0xff;
|
|
586
586
|
}
|
|
587
587
|
else if (value < 4294967296) {
|
|
588
|
-
data[cursor++] = (major << 5) | extendedFloat32;
|
|
589
|
-
dataView.setUint32(cursor, value);
|
|
590
|
-
cursor += 4;
|
|
588
|
+
data[cursor$1++] = (major << 5) | extendedFloat32;
|
|
589
|
+
dataView$1.setUint32(cursor$1, value);
|
|
590
|
+
cursor$1 += 4;
|
|
591
591
|
}
|
|
592
592
|
else {
|
|
593
|
-
data[cursor++] = (major << 5) | extendedFloat64;
|
|
593
|
+
data[cursor$1++] = (major << 5) | extendedFloat64;
|
|
594
594
|
const hi = (value / 4294967296) | 0;
|
|
595
595
|
const lo = (value - hi * 4294967296) | 0;
|
|
596
|
-
dataView.setUint32(cursor, hi);
|
|
597
|
-
dataView.setUint32(cursor + 4, lo);
|
|
598
|
-
cursor += 8;
|
|
596
|
+
dataView$1.setUint32(cursor$1, hi);
|
|
597
|
+
dataView$1.setUint32(cursor$1 + 4, lo);
|
|
598
|
+
cursor$1 += 8;
|
|
599
599
|
}
|
|
600
600
|
continue;
|
|
601
601
|
}
|
|
602
|
-
data[cursor++] = (majorSpecial << 5) | extendedFloat64;
|
|
603
|
-
dataView.setFloat64(cursor, input);
|
|
604
|
-
cursor += 8;
|
|
602
|
+
data[cursor$1++] = (majorSpecial << 5) | extendedFloat64;
|
|
603
|
+
dataView$1.setFloat64(cursor$1, input);
|
|
604
|
+
cursor$1 += 8;
|
|
605
605
|
continue;
|
|
606
606
|
}
|
|
607
607
|
else if (typeof input === "bigint") {
|
|
@@ -614,9 +614,9 @@ function encode(_input) {
|
|
|
614
614
|
encodeInteger(major, n);
|
|
615
615
|
}
|
|
616
616
|
else {
|
|
617
|
-
data[cursor++] = (major << 5) | extendedFloat64;
|
|
618
|
-
dataView.setBigUint64(cursor, value);
|
|
619
|
-
cursor += 8;
|
|
617
|
+
data[cursor$1++] = (major << 5) | extendedFloat64;
|
|
618
|
+
dataView$1.setBigUint64(cursor$1, value);
|
|
619
|
+
cursor$1 += 8;
|
|
620
620
|
}
|
|
621
621
|
}
|
|
622
622
|
else {
|
|
@@ -629,19 +629,19 @@ function encode(_input) {
|
|
|
629
629
|
b >>= BigInt(8);
|
|
630
630
|
}
|
|
631
631
|
ensureSpace(bigIntBytes.byteLength * 2 + 16);
|
|
632
|
-
data[cursor++] = nonNegative ? 0b110_00010 : 0b110_00011;
|
|
633
|
-
encodeHeader(majorUnstructuredByteString, bigIntBytes.byteLength);
|
|
634
|
-
data.set(bigIntBytes, cursor);
|
|
635
|
-
cursor += bigIntBytes.byteLength;
|
|
632
|
+
data[cursor$1++] = nonNegative ? 0b110_00010 : 0b110_00011;
|
|
633
|
+
encodeHeader$1(majorUnstructuredByteString, bigIntBytes.byteLength);
|
|
634
|
+
data.set(bigIntBytes, cursor$1);
|
|
635
|
+
cursor$1 += bigIntBytes.byteLength;
|
|
636
636
|
}
|
|
637
637
|
continue;
|
|
638
638
|
}
|
|
639
639
|
else if (input === null) {
|
|
640
|
-
data[cursor++] = (majorSpecial << 5) | specialNull;
|
|
640
|
+
data[cursor$1++] = (majorSpecial << 5) | specialNull;
|
|
641
641
|
continue;
|
|
642
642
|
}
|
|
643
643
|
else if (typeof input === "boolean") {
|
|
644
|
-
data[cursor++] = (majorSpecial << 5) | (input ? specialTrue : specialFalse);
|
|
644
|
+
data[cursor$1++] = (majorSpecial << 5) | (input ? specialTrue : specialFalse);
|
|
645
645
|
continue;
|
|
646
646
|
}
|
|
647
647
|
else if (typeof input === "undefined") {
|
|
@@ -658,8 +658,8 @@ function encode(_input) {
|
|
|
658
658
|
else if (typeof input.byteLength === "number") {
|
|
659
659
|
ensureSpace(input.length * 2 + 9);
|
|
660
660
|
encodeInteger(majorUnstructuredByteString, input.length);
|
|
661
|
-
data.set(input, cursor);
|
|
662
|
-
cursor += input.byteLength;
|
|
661
|
+
data.set(input, cursor$1);
|
|
662
|
+
cursor$1 += input.byteLength;
|
|
663
663
|
continue;
|
|
664
664
|
}
|
|
665
665
|
else if (typeof input === "object") {
|
|
@@ -667,7 +667,7 @@ function encode(_input) {
|
|
|
667
667
|
const decimalIndex = input.string.indexOf(".");
|
|
668
668
|
const exponent = decimalIndex === -1 ? 0 : decimalIndex - input.string.length + 1;
|
|
669
669
|
const mantissa = BigInt(input.string.replace(".", ""));
|
|
670
|
-
data[cursor++] = 0b110_00100;
|
|
670
|
+
data[cursor$1++] = 0b110_00100;
|
|
671
671
|
encodeInteger(majorList, 2);
|
|
672
672
|
encodeStack.push(mantissa);
|
|
673
673
|
encodeStack.push(exponent);
|
|
@@ -676,7 +676,7 @@ function encode(_input) {
|
|
|
676
676
|
if (input[tagSymbol]) {
|
|
677
677
|
if ("tag" in input && "value" in input) {
|
|
678
678
|
encodeStack.push(input.value);
|
|
679
|
-
encodeHeader(majorTag, input.tag);
|
|
679
|
+
encodeHeader$1(majorTag, input.tag);
|
|
680
680
|
continue;
|
|
681
681
|
}
|
|
682
682
|
else {
|
|
@@ -696,13 +696,13 @@ function encode(_input) {
|
|
|
696
696
|
}
|
|
697
697
|
}
|
|
698
698
|
function advanceEncodingEpoch() {
|
|
699
|
-
encodeCacheEpoch = (encodeCacheEpoch + 1) & 0b1111_1111_1111_1111;
|
|
700
|
-
encodeCacheSaturated = false;
|
|
699
|
+
encodeCacheEpoch$1 = (encodeCacheEpoch$1 + 1) & 0b1111_1111_1111_1111;
|
|
700
|
+
encodeCacheSaturated$1 = false;
|
|
701
701
|
}
|
|
702
702
|
function toUint8Array() {
|
|
703
|
-
const out = alloc(cursor);
|
|
704
|
-
out.set(data.subarray(0, cursor), 0);
|
|
705
|
-
cursor = 0;
|
|
703
|
+
const out = alloc(cursor$1);
|
|
704
|
+
out.set(data.subarray(0, cursor$1), 0);
|
|
705
|
+
cursor$1 = 0;
|
|
706
706
|
return out;
|
|
707
707
|
}
|
|
708
708
|
function resize(size) {
|
|
@@ -716,23 +716,23 @@ function resize(size) {
|
|
|
716
716
|
data.set(old, 0);
|
|
717
717
|
}
|
|
718
718
|
}
|
|
719
|
-
dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
719
|
+
dataView$1 = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
720
720
|
}
|
|
721
721
|
function encodeStringCached(input) {
|
|
722
722
|
const cached = encodeStringCache.get(input);
|
|
723
723
|
if (cached !== undefined) {
|
|
724
|
-
data.set(cached.bytes, cursor);
|
|
725
|
-
cursor += cached.bytes.length;
|
|
726
|
-
cached.epoch = encodeCacheEpoch;
|
|
724
|
+
data.set(cached.bytes, cursor$1);
|
|
725
|
+
cursor$1 += cached.bytes.length;
|
|
726
|
+
cached.epoch = encodeCacheEpoch$1;
|
|
727
727
|
return;
|
|
728
728
|
}
|
|
729
|
-
const start = cursor;
|
|
729
|
+
const start = cursor$1;
|
|
730
730
|
const byteLen = Buffer.byteLength(input);
|
|
731
731
|
encodeInteger(majorUtf8String, byteLen);
|
|
732
|
-
cursor += data.write(input, cursor);
|
|
733
|
-
const bytes = Uint8Array.prototype.slice.call(data, start, cursor);
|
|
732
|
+
cursor$1 += data.write(input, cursor$1);
|
|
733
|
+
const bytes = Uint8Array.prototype.slice.call(data, start, cursor$1);
|
|
734
734
|
if (encodeStringCache.size >= 2048) {
|
|
735
|
-
if (encodeCacheSaturated) {
|
|
735
|
+
if (encodeCacheSaturated$1) {
|
|
736
736
|
return;
|
|
737
737
|
}
|
|
738
738
|
let evicted = 0;
|
|
@@ -740,24 +740,24 @@ function encodeStringCached(input) {
|
|
|
740
740
|
if (evicted >= 1024) {
|
|
741
741
|
break;
|
|
742
742
|
}
|
|
743
|
-
if (entry.epoch !== encodeCacheEpoch) {
|
|
743
|
+
if (entry.epoch !== encodeCacheEpoch$1) {
|
|
744
744
|
encodeStringCache.delete(key);
|
|
745
745
|
evicted++;
|
|
746
746
|
}
|
|
747
747
|
}
|
|
748
748
|
if (evicted === 0) {
|
|
749
|
-
encodeCacheSaturated = true;
|
|
749
|
+
encodeCacheSaturated$1 = true;
|
|
750
750
|
return;
|
|
751
751
|
}
|
|
752
752
|
}
|
|
753
753
|
if (encodeStringCache.size < 2048) {
|
|
754
|
-
encodeStringCache.set(input, { epoch: encodeCacheEpoch, bytes });
|
|
754
|
+
encodeStringCache.set(input, { epoch: encodeCacheEpoch$1, bytes });
|
|
755
755
|
}
|
|
756
756
|
}
|
|
757
757
|
function ensureSpace(bytes) {
|
|
758
|
-
const remaining = data.byteLength - cursor;
|
|
758
|
+
const remaining = data.byteLength - cursor$1;
|
|
759
759
|
if (remaining < bytes) {
|
|
760
|
-
if (cursor < 16_000_000) {
|
|
760
|
+
if (cursor$1 < 16_000_000) {
|
|
761
761
|
resize(Math.max(data.byteLength * 4, data.byteLength + bytes));
|
|
762
762
|
}
|
|
763
763
|
else {
|
|
@@ -765,55 +765,55 @@ function ensureSpace(bytes) {
|
|
|
765
765
|
}
|
|
766
766
|
}
|
|
767
767
|
}
|
|
768
|
-
function encodeHeader(major, value) {
|
|
768
|
+
function encodeHeader$1(major, value) {
|
|
769
769
|
if (value < 24) {
|
|
770
|
-
data[cursor++] = (major << 5) | value;
|
|
770
|
+
data[cursor$1++] = (major << 5) | value;
|
|
771
771
|
}
|
|
772
772
|
else if (value < 256) {
|
|
773
|
-
data[cursor++] = (major << 5) | 24;
|
|
774
|
-
data[cursor++] = value;
|
|
773
|
+
data[cursor$1++] = (major << 5) | 24;
|
|
774
|
+
data[cursor$1++] = value;
|
|
775
775
|
}
|
|
776
776
|
else if (value < 65536) {
|
|
777
|
-
data[cursor++] = (major << 5) | extendedFloat16;
|
|
778
|
-
dataView.setUint16(cursor, value);
|
|
779
|
-
cursor += 2;
|
|
777
|
+
data[cursor$1++] = (major << 5) | extendedFloat16;
|
|
778
|
+
dataView$1.setUint16(cursor$1, value);
|
|
779
|
+
cursor$1 += 2;
|
|
780
780
|
}
|
|
781
781
|
else if (value < 4294967296) {
|
|
782
|
-
data[cursor++] = (major << 5) | extendedFloat32;
|
|
783
|
-
dataView.setUint32(cursor, value);
|
|
784
|
-
cursor += 4;
|
|
782
|
+
data[cursor$1++] = (major << 5) | extendedFloat32;
|
|
783
|
+
dataView$1.setUint32(cursor$1, value);
|
|
784
|
+
cursor$1 += 4;
|
|
785
785
|
}
|
|
786
786
|
else {
|
|
787
|
-
data[cursor++] = (major << 5) | extendedFloat64;
|
|
788
|
-
dataView.setBigUint64(cursor, typeof value === "bigint" ? value : BigInt(value));
|
|
789
|
-
cursor += 8;
|
|
787
|
+
data[cursor$1++] = (major << 5) | extendedFloat64;
|
|
788
|
+
dataView$1.setBigUint64(cursor$1, typeof value === "bigint" ? value : BigInt(value));
|
|
789
|
+
cursor$1 += 8;
|
|
790
790
|
}
|
|
791
791
|
}
|
|
792
792
|
function encodeInteger(major, value) {
|
|
793
793
|
if (value < 24) {
|
|
794
|
-
data[cursor++] = (major << 5) | value;
|
|
794
|
+
data[cursor$1++] = (major << 5) | value;
|
|
795
795
|
}
|
|
796
796
|
else if (value < 256) {
|
|
797
|
-
data[cursor++] = (major << 5) | 24;
|
|
798
|
-
data[cursor++] = value;
|
|
797
|
+
data[cursor$1++] = (major << 5) | 24;
|
|
798
|
+
data[cursor$1++] = value;
|
|
799
799
|
}
|
|
800
800
|
else if (value < 65536) {
|
|
801
|
-
data[cursor++] = (major << 5) | extendedFloat16;
|
|
802
|
-
data[cursor++] = value >> 8;
|
|
803
|
-
data[cursor++] = value & 0xff;
|
|
801
|
+
data[cursor$1++] = (major << 5) | extendedFloat16;
|
|
802
|
+
data[cursor$1++] = value >> 8;
|
|
803
|
+
data[cursor$1++] = value & 0xff;
|
|
804
804
|
}
|
|
805
805
|
else if (value < 4294967296) {
|
|
806
|
-
data[cursor++] = (major << 5) | extendedFloat32;
|
|
807
|
-
dataView.setUint32(cursor, value);
|
|
808
|
-
cursor += 4;
|
|
806
|
+
data[cursor$1++] = (major << 5) | extendedFloat32;
|
|
807
|
+
dataView$1.setUint32(cursor$1, value);
|
|
808
|
+
cursor$1 += 4;
|
|
809
809
|
}
|
|
810
810
|
else {
|
|
811
|
-
data[cursor++] = (major << 5) | extendedFloat64;
|
|
811
|
+
data[cursor$1++] = (major << 5) | extendedFloat64;
|
|
812
812
|
const hi = (value / 4294967296) | 0;
|
|
813
813
|
const lo = (value - hi * 4294967296) | 0;
|
|
814
|
-
dataView.setUint32(cursor, hi);
|
|
815
|
-
dataView.setUint32(cursor + 4, lo);
|
|
816
|
-
cursor += 8;
|
|
814
|
+
dataView$1.setUint32(cursor$1, hi);
|
|
815
|
+
dataView$1.setUint32(cursor$1 + 4, lo);
|
|
816
|
+
cursor$1 += 8;
|
|
817
817
|
}
|
|
818
818
|
}
|
|
819
819
|
|
|
@@ -933,216 +933,1229 @@ const buildHttpRpcRequest = async (context, headers, path, resolvedHostname, bod
|
|
|
933
933
|
return new HttpRequest(contents);
|
|
934
934
|
};
|
|
935
935
|
|
|
936
|
-
class
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
936
|
+
class CborShapeSerializer2 extends SerdeContext {
|
|
937
|
+
write(schema, value) {
|
|
938
|
+
cursor = 0;
|
|
939
|
+
const ns = NormalizedSchema.of(schema);
|
|
940
|
+
writeValue(ns, value, undefined, this.serdeContext);
|
|
941
941
|
}
|
|
942
|
-
|
|
943
|
-
const
|
|
944
|
-
|
|
945
|
-
|
|
942
|
+
flush() {
|
|
943
|
+
const result = buf.subarray(0, cursor);
|
|
944
|
+
cursor = 0;
|
|
945
|
+
buf = allocUnsafe(INITIAL_BUFFER_SIZE);
|
|
946
|
+
view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
947
|
+
return result;
|
|
946
948
|
}
|
|
947
949
|
}
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
950
|
+
const CBOR_STRUCT_CACHE = Symbol.for("@smithy/cbor-struct-cache");
|
|
951
|
+
function loadCborStructIterator(ns) {
|
|
952
|
+
const schema = ns.getSchema();
|
|
953
|
+
const existing = schema[CBOR_STRUCT_CACHE];
|
|
954
|
+
if (existing) {
|
|
955
|
+
return existing;
|
|
956
|
+
}
|
|
957
|
+
const memberNames = [];
|
|
958
|
+
const memberSchemas = [];
|
|
959
|
+
for (const [name, memberSchema] of ns.structIterator()) {
|
|
960
|
+
memberNames.push(name);
|
|
961
|
+
memberSchemas.push(memberSchema);
|
|
962
|
+
}
|
|
963
|
+
const encodedKeys = new Array(memberNames.length);
|
|
964
|
+
for (let i = 0; i < memberNames.length; ++i) {
|
|
965
|
+
encodedKeys[i] = encodeCborStringKey(memberNames[i]);
|
|
966
|
+
}
|
|
967
|
+
const cache = { memberNames, memberSchemas, encodedKeys };
|
|
968
|
+
schema[CBOR_STRUCT_CACHE] = cache;
|
|
969
|
+
return cache;
|
|
970
|
+
}
|
|
971
|
+
function encodeCborStringKey(s) {
|
|
972
|
+
let utf8Bytes;
|
|
973
|
+
if (USE_BUFFER$1) {
|
|
974
|
+
utf8Bytes = Buffer.from(s, "utf-8");
|
|
952
975
|
}
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
976
|
+
else {
|
|
977
|
+
utf8Bytes = new TextEncoder().encode(s);
|
|
978
|
+
}
|
|
979
|
+
const byteLen = utf8Bytes.length;
|
|
980
|
+
let headerSize;
|
|
981
|
+
if (byteLen < 24) {
|
|
982
|
+
headerSize = 1;
|
|
983
|
+
}
|
|
984
|
+
else if (byteLen < 256) {
|
|
985
|
+
headerSize = 2;
|
|
986
|
+
}
|
|
987
|
+
else {
|
|
988
|
+
headerSize = 3;
|
|
989
|
+
}
|
|
990
|
+
const result = new Uint8Array(headerSize + byteLen);
|
|
991
|
+
if (headerSize === 1) {
|
|
992
|
+
result[0] = (majorUtf8String << 5) | byteLen;
|
|
993
|
+
}
|
|
994
|
+
else if (headerSize === 2) {
|
|
995
|
+
result[0] = (majorUtf8String << 5) | 24;
|
|
996
|
+
result[1] = byteLen;
|
|
997
|
+
}
|
|
998
|
+
else {
|
|
999
|
+
result[0] = (majorUtf8String << 5) | extendedFloat16;
|
|
1000
|
+
result[1] = byteLen >> 8;
|
|
1001
|
+
result[2] = byteLen & 0xff;
|
|
1002
|
+
}
|
|
1003
|
+
result.set(utf8Bytes, headerSize);
|
|
1004
|
+
return result;
|
|
1005
|
+
}
|
|
1006
|
+
const USE_BUFFER$1 = typeof Buffer !== "undefined";
|
|
1007
|
+
const textEncoder = new TextEncoder();
|
|
1008
|
+
const INITIAL_BUFFER_SIZE = 2048;
|
|
1009
|
+
let buf = USE_BUFFER$1 ? Buffer.allocUnsafe(INITIAL_BUFFER_SIZE) : new Uint8Array(INITIAL_BUFFER_SIZE);
|
|
1010
|
+
let view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
1011
|
+
let cursor = 0;
|
|
1012
|
+
const STRING_CACHE_MAX = 2048;
|
|
1013
|
+
const stringEncodeCache = new Map();
|
|
1014
|
+
let encodeCacheEpoch = 0;
|
|
1015
|
+
let encodeCacheSaturated = false;
|
|
1016
|
+
function allocUnsafe(size) {
|
|
1017
|
+
return USE_BUFFER$1 ? Buffer.allocUnsafe(size) : new Uint8Array(size);
|
|
1018
|
+
}
|
|
1019
|
+
function writeValue(ns, value, container, serdeContext) {
|
|
1020
|
+
if (value == null) {
|
|
1021
|
+
if (value === undefined && ns.isIdempotencyToken()) {
|
|
1022
|
+
writeString(generateIdempotencyToken());
|
|
1023
|
+
return;
|
|
960
1024
|
}
|
|
1025
|
+
ensure(1);
|
|
1026
|
+
buf[cursor++] = (majorSpecial << 5) | specialNull;
|
|
1027
|
+
return;
|
|
1028
|
+
}
|
|
1029
|
+
if (ns.isUnitSchema()) {
|
|
1030
|
+
ensure(1);
|
|
1031
|
+
encodeHeader(majorMap, 0);
|
|
1032
|
+
return;
|
|
1033
|
+
}
|
|
1034
|
+
const isObject = typeof value === "object";
|
|
1035
|
+
if (isObject) {
|
|
961
1036
|
if (ns.isBlobSchema()) {
|
|
962
|
-
if (
|
|
963
|
-
|
|
1037
|
+
if (value instanceof Uint8Array) {
|
|
1038
|
+
writeBytes(value);
|
|
1039
|
+
return;
|
|
964
1040
|
}
|
|
965
|
-
return source;
|
|
966
1041
|
}
|
|
967
1042
|
if (ns.isTimestampSchema()) {
|
|
968
|
-
if (
|
|
969
|
-
|
|
1043
|
+
if (value instanceof Date) {
|
|
1044
|
+
writeTimestamp(value);
|
|
1045
|
+
return;
|
|
970
1046
|
}
|
|
971
|
-
return dateToTag(source);
|
|
972
1047
|
}
|
|
973
|
-
if (
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
1048
|
+
if (ns.isStructSchema()) {
|
|
1049
|
+
writeStruct(ns, value, serdeContext);
|
|
1050
|
+
return;
|
|
1051
|
+
}
|
|
1052
|
+
if (Array.isArray(value) && (ns.isListSchema() || ns.isDocumentSchema())) {
|
|
1053
|
+
writeList(ns, value, ns.isDocumentSchema(), serdeContext);
|
|
1054
|
+
return;
|
|
1055
|
+
}
|
|
1056
|
+
if (ns.isMapSchema()) {
|
|
1057
|
+
writeMap(ns, value, false, serdeContext);
|
|
1058
|
+
return;
|
|
1059
|
+
}
|
|
1060
|
+
if (value instanceof Date) {
|
|
1061
|
+
writeTimestamp(value);
|
|
1062
|
+
return;
|
|
1063
|
+
}
|
|
1064
|
+
if (value instanceof Uint8Array) {
|
|
1065
|
+
writeBytes(value);
|
|
1066
|
+
return;
|
|
1067
|
+
}
|
|
1068
|
+
if (value instanceof NumericValue) {
|
|
1069
|
+
writeNumericValue(value);
|
|
1070
|
+
return;
|
|
1071
|
+
}
|
|
1072
|
+
if (value[tagSymbol]) {
|
|
1073
|
+
const tagged = value;
|
|
1074
|
+
writeTag(tagged.tag, tagged.value);
|
|
1075
|
+
return;
|
|
1076
|
+
}
|
|
1077
|
+
if (ns.isDocumentSchema()) {
|
|
1078
|
+
if (Array.isArray(value)) {
|
|
1079
|
+
writeList(ns, value, true, serdeContext);
|
|
989
1080
|
}
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
const sparse = !!ns.getMergedTraits().sparse;
|
|
993
|
-
for (const key in sourceObject) {
|
|
994
|
-
const value = this.serialize(ns.getValueSchema(), sourceObject[key]);
|
|
995
|
-
if (value != null || sparse) {
|
|
996
|
-
newObject[key] = value;
|
|
997
|
-
}
|
|
998
|
-
}
|
|
1081
|
+
else {
|
|
1082
|
+
writeMap(ns, value, true, serdeContext);
|
|
999
1083
|
}
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1084
|
+
return;
|
|
1085
|
+
}
|
|
1086
|
+
if (ns.isBigDecimalSchema()) {
|
|
1087
|
+
writeUntypedValue(value);
|
|
1088
|
+
return;
|
|
1089
|
+
}
|
|
1090
|
+
writeMap(ns, value, true, serdeContext);
|
|
1091
|
+
return;
|
|
1092
|
+
}
|
|
1093
|
+
if (typeof value === "string") {
|
|
1094
|
+
if (ns.isBlobSchema()) {
|
|
1095
|
+
const bytes = (serdeContext?.base64Decoder ?? fromBase64)(value);
|
|
1096
|
+
writeBytes(bytes);
|
|
1097
|
+
return;
|
|
1098
|
+
}
|
|
1099
|
+
writeString(value);
|
|
1100
|
+
return;
|
|
1101
|
+
}
|
|
1102
|
+
if (typeof value === "number") {
|
|
1103
|
+
ensure(9);
|
|
1104
|
+
if (Number.isInteger(value) && value >= -9007199254740992 && value <= 0x1fffffffffffff) {
|
|
1105
|
+
writeInteger(value);
|
|
1106
|
+
}
|
|
1107
|
+
else {
|
|
1108
|
+
writeFloat64(value);
|
|
1109
|
+
}
|
|
1110
|
+
return;
|
|
1111
|
+
}
|
|
1112
|
+
if (typeof value === "boolean") {
|
|
1113
|
+
ensure(1);
|
|
1114
|
+
buf[cursor++] = (majorSpecial << 5) | (value ? specialTrue : specialFalse);
|
|
1115
|
+
return;
|
|
1116
|
+
}
|
|
1117
|
+
if (typeof value === "bigint") {
|
|
1118
|
+
writeBigInt(value);
|
|
1119
|
+
return;
|
|
1120
|
+
}
|
|
1121
|
+
writeString(String(value));
|
|
1122
|
+
}
|
|
1123
|
+
function writeStruct(ns, value, serdeContext) {
|
|
1124
|
+
if (ns.isUnionSchema()) {
|
|
1125
|
+
let wrote = false;
|
|
1126
|
+
for (const [memberName, memberSchema] of ns.structIterator()) {
|
|
1127
|
+
const item = value[memberName];
|
|
1128
|
+
if (item != null) {
|
|
1129
|
+
ensure(9);
|
|
1130
|
+
encodeHeader(majorMap, 1);
|
|
1131
|
+
writeString(memberName);
|
|
1132
|
+
writeValue(memberSchema, item, ns, serdeContext);
|
|
1133
|
+
wrote = true;
|
|
1134
|
+
break;
|
|
1019
1135
|
}
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1136
|
+
}
|
|
1137
|
+
if (!wrote) {
|
|
1138
|
+
const { $unknown } = value;
|
|
1139
|
+
if (Array.isArray($unknown)) {
|
|
1140
|
+
ensure(9);
|
|
1141
|
+
encodeHeader(majorMap, 1);
|
|
1142
|
+
writeString($unknown[0]);
|
|
1143
|
+
writeUntypedValue($unknown[1]);
|
|
1024
1144
|
}
|
|
1025
|
-
else
|
|
1026
|
-
|
|
1145
|
+
else {
|
|
1146
|
+
ensure(9);
|
|
1147
|
+
encodeHeader(majorMap, 0);
|
|
1027
1148
|
}
|
|
1028
|
-
return newObject;
|
|
1029
1149
|
}
|
|
1030
|
-
return
|
|
1150
|
+
return;
|
|
1031
1151
|
}
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1152
|
+
const cache = loadCborStructIterator(ns);
|
|
1153
|
+
const { memberNames, memberSchemas, encodedKeys } = cache;
|
|
1154
|
+
const z = memberNames.length;
|
|
1155
|
+
let headerSize;
|
|
1156
|
+
if (z < 24) {
|
|
1157
|
+
headerSize = 1;
|
|
1036
1158
|
}
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
read(schema, bytes) {
|
|
1040
|
-
const data = cbor.deserialize(bytes);
|
|
1041
|
-
return this.readValue(schema, data);
|
|
1159
|
+
else if (z < 256) {
|
|
1160
|
+
headerSize = 2;
|
|
1042
1161
|
}
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1162
|
+
else {
|
|
1163
|
+
headerSize = 3;
|
|
1164
|
+
}
|
|
1165
|
+
ensure(headerSize);
|
|
1166
|
+
const headerPos = cursor;
|
|
1167
|
+
cursor += headerSize;
|
|
1168
|
+
let count = 0;
|
|
1169
|
+
for (let i = 0; i < z; ++i) {
|
|
1170
|
+
const item = value[memberNames[i]];
|
|
1171
|
+
if (item == null && !memberSchemas[i].isIdempotencyToken()) {
|
|
1172
|
+
continue;
|
|
1173
|
+
}
|
|
1174
|
+
const key = encodedKeys[i];
|
|
1175
|
+
ensure(key.length);
|
|
1176
|
+
buf.set(key, cursor);
|
|
1177
|
+
cursor += key.length;
|
|
1178
|
+
writeValue(memberSchemas[i], item, ns, serdeContext);
|
|
1179
|
+
++count;
|
|
1180
|
+
}
|
|
1181
|
+
if (typeof value.__type === "string") {
|
|
1182
|
+
for (const k in value) {
|
|
1183
|
+
if (!memberNames.includes(k)) {
|
|
1184
|
+
writeString(k);
|
|
1185
|
+
writeUntypedValue(value[k]);
|
|
1186
|
+
++count;
|
|
1048
1187
|
}
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
if (headerSize === 1) {
|
|
1191
|
+
buf[headerPos] = (majorMap << 5) | count;
|
|
1192
|
+
}
|
|
1193
|
+
else if (headerSize === 2) {
|
|
1194
|
+
buf[headerPos] = (majorMap << 5) | 24;
|
|
1195
|
+
buf[headerPos + 1] = count;
|
|
1196
|
+
}
|
|
1197
|
+
else {
|
|
1198
|
+
buf[headerPos] = (majorMap << 5) | extendedFloat16;
|
|
1199
|
+
buf[headerPos + 1] = count >> 8;
|
|
1200
|
+
buf[headerPos + 2] = count & 0xff;
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
function writeList(ns, value, isDocument, serdeContext) {
|
|
1204
|
+
const sparse = !!ns.getMergedTraits().sparse;
|
|
1205
|
+
const valueSchema = ns.getValueSchema();
|
|
1206
|
+
if (isDocument || sparse) {
|
|
1207
|
+
const items = [];
|
|
1208
|
+
for (let i = 0; i < value.length; ++i) {
|
|
1209
|
+
const item = value[i];
|
|
1210
|
+
if (isDocument) {
|
|
1211
|
+
if (item !== undefined) {
|
|
1212
|
+
items.push(item);
|
|
1052
1213
|
}
|
|
1053
1214
|
}
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1215
|
+
else {
|
|
1216
|
+
if (item != null || sparse) {
|
|
1217
|
+
items.push(item);
|
|
1218
|
+
}
|
|
1058
1219
|
}
|
|
1059
|
-
return value;
|
|
1060
1220
|
}
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
typeof value === "bigint" ||
|
|
1066
|
-
typeof value === "symbol") {
|
|
1067
|
-
return value;
|
|
1221
|
+
ensure(9);
|
|
1222
|
+
encodeHeader(majorList, items.length);
|
|
1223
|
+
for (let i = 0; i < items.length; ++i) {
|
|
1224
|
+
writeValue(valueSchema, items[i], undefined, serdeContext);
|
|
1068
1225
|
}
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
if (
|
|
1074
|
-
|
|
1075
|
-
}
|
|
1076
|
-
if (value instanceof Date) {
|
|
1077
|
-
return value;
|
|
1078
|
-
}
|
|
1079
|
-
if (ns.isDocumentSchema()) {
|
|
1080
|
-
return value;
|
|
1081
|
-
}
|
|
1082
|
-
if (ns.isListSchema()) {
|
|
1083
|
-
const newArray = [];
|
|
1084
|
-
const memberSchema = ns.getValueSchema();
|
|
1085
|
-
for (const item of value) {
|
|
1086
|
-
const itemValue = this.readValue(memberSchema, item);
|
|
1087
|
-
newArray.push(itemValue);
|
|
1088
|
-
}
|
|
1089
|
-
return newArray;
|
|
1226
|
+
}
|
|
1227
|
+
else {
|
|
1228
|
+
let count = 0;
|
|
1229
|
+
for (let i = 0; i < value.length; ++i) {
|
|
1230
|
+
if (value[i] != null) {
|
|
1231
|
+
++count;
|
|
1090
1232
|
}
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
}
|
|
1233
|
+
}
|
|
1234
|
+
ensure(9);
|
|
1235
|
+
encodeHeader(majorList, count);
|
|
1236
|
+
for (let i = 0; i < value.length; ++i) {
|
|
1237
|
+
if (value[i] != null) {
|
|
1238
|
+
writeValue(valueSchema, value[i], undefined, serdeContext);
|
|
1098
1239
|
}
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
function writeMap(ns, value, isDocument, serdeContext) {
|
|
1244
|
+
const sparse = !!ns.getMergedTraits().sparse;
|
|
1245
|
+
const valueSchema = ns.getValueSchema();
|
|
1246
|
+
const keys = [];
|
|
1247
|
+
for (const k in value) {
|
|
1248
|
+
const v = value[k];
|
|
1249
|
+
if (isDocument ? v !== undefined : v != null || sparse) {
|
|
1250
|
+
keys.push(k);
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
ensure(9);
|
|
1254
|
+
encodeHeader(majorMap, keys.length);
|
|
1255
|
+
for (let i = 0; i < keys.length; ++i) {
|
|
1256
|
+
const k = keys[i];
|
|
1257
|
+
writeString(k);
|
|
1258
|
+
writeValue(valueSchema, value[k], undefined, serdeContext);
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
function writeUntypedValue(value) {
|
|
1262
|
+
if (value == null) {
|
|
1263
|
+
ensure(1);
|
|
1264
|
+
buf[cursor++] = (majorSpecial << 5) | specialNull;
|
|
1265
|
+
return;
|
|
1266
|
+
}
|
|
1267
|
+
if (typeof value === "string") {
|
|
1268
|
+
writeString(value);
|
|
1269
|
+
return;
|
|
1270
|
+
}
|
|
1271
|
+
if (typeof value === "number") {
|
|
1272
|
+
ensure(9);
|
|
1273
|
+
if (Number.isInteger(value) && value >= -9007199254740992 && value <= 0x1fffffffffffff) {
|
|
1274
|
+
writeInteger(value);
|
|
1275
|
+
}
|
|
1276
|
+
else {
|
|
1277
|
+
writeFloat64(value);
|
|
1278
|
+
}
|
|
1279
|
+
return;
|
|
1280
|
+
}
|
|
1281
|
+
if (typeof value === "boolean") {
|
|
1282
|
+
ensure(1);
|
|
1283
|
+
buf[cursor++] = (majorSpecial << 5) | (value ? specialTrue : specialFalse);
|
|
1284
|
+
return;
|
|
1285
|
+
}
|
|
1286
|
+
if (typeof value === "bigint") {
|
|
1287
|
+
writeBigInt(value);
|
|
1288
|
+
return;
|
|
1289
|
+
}
|
|
1290
|
+
if (value instanceof Uint8Array) {
|
|
1291
|
+
writeBytes(value);
|
|
1292
|
+
return;
|
|
1293
|
+
}
|
|
1294
|
+
if (value instanceof Date) {
|
|
1295
|
+
writeTimestamp(value);
|
|
1296
|
+
return;
|
|
1297
|
+
}
|
|
1298
|
+
if (value instanceof NumericValue) {
|
|
1299
|
+
writeNumericValue(value);
|
|
1300
|
+
return;
|
|
1301
|
+
}
|
|
1302
|
+
if (value[tagSymbol]) {
|
|
1303
|
+
const tagged = value;
|
|
1304
|
+
writeTag(tagged.tag, tagged.value);
|
|
1305
|
+
return;
|
|
1306
|
+
}
|
|
1307
|
+
if (Array.isArray(value)) {
|
|
1308
|
+
ensure(9);
|
|
1309
|
+
encodeHeader(majorList, value.length);
|
|
1310
|
+
for (let i = 0; i < value.length; ++i) {
|
|
1311
|
+
writeUntypedValue(value[i]);
|
|
1312
|
+
}
|
|
1313
|
+
return;
|
|
1314
|
+
}
|
|
1315
|
+
if (typeof value === "object") {
|
|
1316
|
+
const keys = Object.keys(value);
|
|
1317
|
+
ensure(9);
|
|
1318
|
+
encodeHeader(majorMap, keys.length);
|
|
1319
|
+
for (let i = 0; i < keys.length; ++i) {
|
|
1320
|
+
writeString(keys[i]);
|
|
1321
|
+
writeUntypedValue(value[keys[i]]);
|
|
1322
|
+
}
|
|
1323
|
+
return;
|
|
1324
|
+
}
|
|
1325
|
+
writeString(String(value));
|
|
1326
|
+
}
|
|
1327
|
+
function ensure(n) {
|
|
1328
|
+
if (cursor + n > buf.length) {
|
|
1329
|
+
let newSize = buf.length * 2;
|
|
1330
|
+
while (newSize < cursor + n) {
|
|
1331
|
+
newSize *= 2;
|
|
1332
|
+
}
|
|
1333
|
+
const next = allocUnsafe(newSize);
|
|
1334
|
+
next.set(buf.subarray(0, cursor));
|
|
1335
|
+
buf = next;
|
|
1336
|
+
view = new DataView(next.buffer, next.byteOffset, next.byteLength);
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
function encodeHeader(major, value) {
|
|
1340
|
+
if (value < 24) {
|
|
1341
|
+
buf[cursor++] = (major << 5) | value;
|
|
1342
|
+
}
|
|
1343
|
+
else if (value < 256) {
|
|
1344
|
+
buf[cursor++] = (major << 5) | 24;
|
|
1345
|
+
buf[cursor++] = value;
|
|
1346
|
+
}
|
|
1347
|
+
else if (value < 65536) {
|
|
1348
|
+
buf[cursor++] = (major << 5) | extendedFloat16;
|
|
1349
|
+
buf[cursor++] = value >> 8;
|
|
1350
|
+
buf[cursor++] = value & 0xff;
|
|
1351
|
+
}
|
|
1352
|
+
else if (value < 4294967296) {
|
|
1353
|
+
buf[cursor++] = (major << 5) | extendedFloat32;
|
|
1354
|
+
view.setUint32(cursor, value);
|
|
1355
|
+
cursor += 4;
|
|
1356
|
+
}
|
|
1357
|
+
else {
|
|
1358
|
+
buf[cursor++] = (major << 5) | extendedFloat64;
|
|
1359
|
+
const hi = (value / 4294967296) | 0;
|
|
1360
|
+
const lo = (value - hi * 4294967296) | 0;
|
|
1361
|
+
view.setUint32(cursor, hi);
|
|
1362
|
+
view.setUint32(cursor + 4, lo);
|
|
1363
|
+
cursor += 8;
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
function encodeBigHeader(major, value) {
|
|
1367
|
+
const n = Number(value);
|
|
1368
|
+
if (n < 4294967296) {
|
|
1369
|
+
encodeHeader(major, n);
|
|
1370
|
+
return;
|
|
1371
|
+
}
|
|
1372
|
+
buf[cursor++] = (major << 5) | extendedFloat64;
|
|
1373
|
+
view.setBigUint64(cursor, value);
|
|
1374
|
+
cursor += 8;
|
|
1375
|
+
}
|
|
1376
|
+
function writeString(s) {
|
|
1377
|
+
const len = s.length;
|
|
1378
|
+
if (len <= 23) {
|
|
1379
|
+
const cached = stringEncodeCache.get(s);
|
|
1380
|
+
if (cached) {
|
|
1381
|
+
ensure(cached.bytes.length);
|
|
1382
|
+
buf.set(cached.bytes, cursor);
|
|
1383
|
+
cursor += cached.bytes.length;
|
|
1384
|
+
cached.epoch = encodeCacheEpoch;
|
|
1385
|
+
return;
|
|
1386
|
+
}
|
|
1387
|
+
const start = cursor;
|
|
1388
|
+
writeStringUncached(s, len);
|
|
1389
|
+
const end = cursor;
|
|
1390
|
+
const bytes = Uint8Array.prototype.slice.call(buf, start, end);
|
|
1391
|
+
if (stringEncodeCache.size >= STRING_CACHE_MAX) {
|
|
1392
|
+
if (encodeCacheSaturated) {
|
|
1393
|
+
return;
|
|
1394
|
+
}
|
|
1395
|
+
let evicted = 0;
|
|
1396
|
+
for (const [key, entry] of stringEncodeCache) {
|
|
1397
|
+
if (evicted >= 1024) {
|
|
1398
|
+
break;
|
|
1109
1399
|
}
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
}
|
|
1114
|
-
if (value[key] != null) {
|
|
1115
|
-
newObject[key] = this.readValue(memberSchema, value[key]);
|
|
1116
|
-
}
|
|
1400
|
+
if (entry.epoch !== encodeCacheEpoch) {
|
|
1401
|
+
stringEncodeCache.delete(key);
|
|
1402
|
+
++evicted;
|
|
1117
1403
|
}
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1404
|
+
}
|
|
1405
|
+
if (evicted === 0) {
|
|
1406
|
+
encodeCacheSaturated = true;
|
|
1407
|
+
return;
|
|
1408
|
+
}
|
|
1409
|
+
}
|
|
1410
|
+
if (stringEncodeCache.size < STRING_CACHE_MAX) {
|
|
1411
|
+
stringEncodeCache.set(s, { epoch: encodeCacheEpoch, bytes });
|
|
1412
|
+
}
|
|
1413
|
+
return;
|
|
1414
|
+
}
|
|
1415
|
+
writeStringUncached(s, len);
|
|
1416
|
+
}
|
|
1417
|
+
function writeStringUncached(s, len) {
|
|
1418
|
+
if (USE_BUFFER$1) {
|
|
1419
|
+
const maxBytes = len * 3;
|
|
1420
|
+
ensure(maxBytes + 9);
|
|
1421
|
+
const byteLen = Buffer.byteLength(s);
|
|
1422
|
+
encodeHeader(majorUtf8String, byteLen);
|
|
1423
|
+
cursor += buf.write(s, cursor);
|
|
1424
|
+
}
|
|
1425
|
+
else {
|
|
1426
|
+
const maxBytes = len * 3;
|
|
1427
|
+
ensure(maxBytes + 9);
|
|
1428
|
+
const headerPos = cursor;
|
|
1429
|
+
const result = textEncoder.encodeInto(s, buf.subarray(headerPos + 9));
|
|
1430
|
+
const byteLen = result.written;
|
|
1431
|
+
let headerSize;
|
|
1432
|
+
if (byteLen < 24) {
|
|
1433
|
+
headerSize = 1;
|
|
1434
|
+
}
|
|
1435
|
+
else if (byteLen < 256) {
|
|
1436
|
+
headerSize = 2;
|
|
1437
|
+
}
|
|
1438
|
+
else if (byteLen < 65536) {
|
|
1439
|
+
headerSize = 3;
|
|
1440
|
+
}
|
|
1441
|
+
else if (byteLen < 4294967296) {
|
|
1442
|
+
headerSize = 5;
|
|
1443
|
+
}
|
|
1444
|
+
else {
|
|
1445
|
+
headerSize = 9;
|
|
1446
|
+
}
|
|
1447
|
+
if (headerSize < 9) {
|
|
1448
|
+
buf.copyWithin(headerPos + headerSize, headerPos + 9, headerPos + 9 + byteLen);
|
|
1449
|
+
}
|
|
1450
|
+
cursor = headerPos;
|
|
1451
|
+
encodeHeader(majorUtf8String, byteLen);
|
|
1452
|
+
cursor += byteLen;
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
function writeFloat64(value) {
|
|
1456
|
+
ensure(9);
|
|
1457
|
+
buf[cursor++] = (majorSpecial << 5) | extendedFloat64;
|
|
1458
|
+
view.setFloat64(cursor, value);
|
|
1459
|
+
cursor += 8;
|
|
1460
|
+
}
|
|
1461
|
+
function writeInteger(value) {
|
|
1462
|
+
ensure(9);
|
|
1463
|
+
const nonNegative = value >= 0;
|
|
1464
|
+
const major = nonNegative ? majorUint64 : majorNegativeInt64;
|
|
1465
|
+
const abs = nonNegative ? value : -value - 1;
|
|
1466
|
+
encodeHeader(major, abs);
|
|
1467
|
+
}
|
|
1468
|
+
function writeBigInt(value) {
|
|
1469
|
+
const nonNegative = value >= 0;
|
|
1470
|
+
const major = nonNegative ? majorUint64 : majorNegativeInt64;
|
|
1471
|
+
const abs = nonNegative ? value : -value - BigInt(1);
|
|
1472
|
+
if (abs < BigInt("18446744073709551616")) {
|
|
1473
|
+
ensure(9);
|
|
1474
|
+
encodeBigHeader(major, abs);
|
|
1475
|
+
}
|
|
1476
|
+
else {
|
|
1477
|
+
const binaryStr = abs.toString(2);
|
|
1478
|
+
const byteLen = Math.ceil(binaryStr.length / 8);
|
|
1479
|
+
const bigIntBytes = new Uint8Array(byteLen);
|
|
1480
|
+
let b = abs;
|
|
1481
|
+
for (let i = byteLen - 1; i >= 0; --i) {
|
|
1482
|
+
bigIntBytes[i] = Number(b & BigInt(255));
|
|
1483
|
+
b >>= BigInt(8);
|
|
1484
|
+
}
|
|
1485
|
+
ensure(byteLen + 16);
|
|
1486
|
+
buf[cursor++] = nonNegative ? 0b110_00010 : 0b110_00011;
|
|
1487
|
+
encodeHeader(majorUnstructuredByteString, byteLen);
|
|
1488
|
+
buf.set(bigIntBytes, cursor);
|
|
1489
|
+
cursor += byteLen;
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
function writeBytes(data) {
|
|
1493
|
+
ensure(data.length + 9);
|
|
1494
|
+
encodeHeader(majorUnstructuredByteString, data.length);
|
|
1495
|
+
buf.set(data, cursor);
|
|
1496
|
+
cursor += data.length;
|
|
1497
|
+
}
|
|
1498
|
+
function writeTag(tagValue, innerValue) {
|
|
1499
|
+
ensure(9);
|
|
1500
|
+
if (typeof tagValue === "bigint") {
|
|
1501
|
+
encodeBigHeader(majorTag, tagValue);
|
|
1502
|
+
}
|
|
1503
|
+
else {
|
|
1504
|
+
encodeHeader(majorTag, tagValue);
|
|
1505
|
+
}
|
|
1506
|
+
writeUntypedValue(innerValue);
|
|
1507
|
+
}
|
|
1508
|
+
function writeNumericValue(nv) {
|
|
1509
|
+
const decimalIndex = nv.string.indexOf(".");
|
|
1510
|
+
const exponent = decimalIndex === -1 ? 0 : decimalIndex - nv.string.length + 1;
|
|
1511
|
+
const mantissa = BigInt(nv.string.replace(".", ""));
|
|
1512
|
+
ensure(9);
|
|
1513
|
+
buf[cursor++] = 0b110_00100;
|
|
1514
|
+
encodeHeader(majorList, 2);
|
|
1515
|
+
ensure(9);
|
|
1516
|
+
writeInteger(exponent);
|
|
1517
|
+
writeBigInt(mantissa);
|
|
1518
|
+
}
|
|
1519
|
+
function writeTimestamp(date) {
|
|
1520
|
+
ensure(18);
|
|
1521
|
+
encodeHeader(majorTag, 1);
|
|
1522
|
+
const epochSecs = date.getTime() / 1000;
|
|
1523
|
+
if (Number.isInteger(epochSecs)) {
|
|
1524
|
+
writeInteger(epochSecs);
|
|
1525
|
+
}
|
|
1526
|
+
else {
|
|
1527
|
+
writeFloat64(epochSecs);
|
|
1528
|
+
}
|
|
1529
|
+
}
|
|
1530
|
+
|
|
1531
|
+
class CborShapeDeserializer2 extends SerdeContext {
|
|
1532
|
+
read(schema, bytes) {
|
|
1533
|
+
payload = bytes;
|
|
1534
|
+
isBuffer = USE_BUFFER && bytes instanceof Buffer;
|
|
1535
|
+
dataView = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
1536
|
+
pos = 0;
|
|
1537
|
+
end = bytes.length;
|
|
1538
|
+
cacheEpoch = (cacheEpoch + 1) & 0xffff;
|
|
1539
|
+
return readValue(NormalizedSchema.of(schema));
|
|
1540
|
+
}
|
|
1541
|
+
readValue(_schema, value) {
|
|
1542
|
+
return transformObject(NormalizedSchema.of(_schema), value);
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1545
|
+
const USE_BUFFER = typeof Buffer !== "undefined";
|
|
1546
|
+
const textDecoder = new TextDecoder();
|
|
1547
|
+
let payload = new Uint8Array(0);
|
|
1548
|
+
let isBuffer = false;
|
|
1549
|
+
let dataView = new DataView(new ArrayBuffer(0));
|
|
1550
|
+
let pos = 0;
|
|
1551
|
+
let end = 0;
|
|
1552
|
+
const STRING_CACHE_SIZE = 2048;
|
|
1553
|
+
const stringCache = new Array(STRING_CACHE_SIZE);
|
|
1554
|
+
const stringCacheEpochs = new Uint16Array(STRING_CACHE_SIZE);
|
|
1555
|
+
let cacheEpoch = 0;
|
|
1556
|
+
function readValue(ns) {
|
|
1557
|
+
if (pos >= end) {
|
|
1558
|
+
throw new Error("unexpected end of CBOR payload.");
|
|
1559
|
+
}
|
|
1560
|
+
const major = (payload[pos] & 0b1110_0000) >> 5;
|
|
1561
|
+
const minor = payload[pos] & 0b0001_1111;
|
|
1562
|
+
if (minor === minorIndefinite && major >= 2 && major <= 5) {
|
|
1563
|
+
return readIndefinite(ns, major);
|
|
1564
|
+
}
|
|
1565
|
+
switch (major) {
|
|
1566
|
+
case majorUint64:
|
|
1567
|
+
return readUnsignedInt();
|
|
1568
|
+
case majorNegativeInt64:
|
|
1569
|
+
return readNegativeInt();
|
|
1570
|
+
case majorUnstructuredByteString:
|
|
1571
|
+
return readByteString();
|
|
1572
|
+
case majorUtf8String:
|
|
1573
|
+
return readUtf8String();
|
|
1574
|
+
case majorList:
|
|
1575
|
+
return readList(ns);
|
|
1576
|
+
case majorMap:
|
|
1577
|
+
return readMap(ns);
|
|
1578
|
+
case majorTag:
|
|
1579
|
+
return readTag();
|
|
1580
|
+
case majorSpecial:
|
|
1581
|
+
return readSpecial();
|
|
1582
|
+
default:
|
|
1583
|
+
throw new Error(`unexpected CBOR major type ${major}.`);
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
function readList(ns) {
|
|
1587
|
+
const count = decodeCount();
|
|
1588
|
+
const memberSchema = ns.isListSchema() ? ns.getValueSchema() : ns;
|
|
1589
|
+
const list = Array(count);
|
|
1590
|
+
for (let i = 0; i < count; ++i) {
|
|
1591
|
+
list[i] = readValue(memberSchema);
|
|
1592
|
+
}
|
|
1593
|
+
return list;
|
|
1594
|
+
}
|
|
1595
|
+
function readMap(ns) {
|
|
1596
|
+
const count = decodeCount();
|
|
1597
|
+
if (ns.isStructSchema()) {
|
|
1598
|
+
const startPos = pos;
|
|
1599
|
+
return readStruct(ns, count, startPos);
|
|
1600
|
+
}
|
|
1601
|
+
const valueSchema = ns.isMapSchema() ? ns.getValueSchema() : ns;
|
|
1602
|
+
const map = {};
|
|
1603
|
+
for (let i = 0; i < count; ++i) {
|
|
1604
|
+
const key = readUtf8String();
|
|
1605
|
+
map[key] = readValue(valueSchema);
|
|
1606
|
+
}
|
|
1607
|
+
return map;
|
|
1608
|
+
}
|
|
1609
|
+
function readStruct(ns, count, startPos) {
|
|
1610
|
+
const isUnion = ns.isUnionSchema();
|
|
1611
|
+
const cache = loadCborStructIterator(ns);
|
|
1612
|
+
const { memberSchemas, encodedKeys, memberNames } = cache;
|
|
1613
|
+
const z = encodedKeys.length;
|
|
1614
|
+
const result = {};
|
|
1615
|
+
let unknownKey;
|
|
1616
|
+
let unknownValue;
|
|
1617
|
+
let unknownCount = 0;
|
|
1618
|
+
let hasType = false;
|
|
1619
|
+
let hint = 0;
|
|
1620
|
+
for (let i = 0; i < count; ++i) {
|
|
1621
|
+
const matchIdx = matchStructKey(encodedKeys, z, hint);
|
|
1622
|
+
if (matchIdx >= 0) {
|
|
1623
|
+
hint = matchIdx + 1;
|
|
1624
|
+
if (hint >= z) {
|
|
1625
|
+
hint = 0;
|
|
1626
|
+
}
|
|
1627
|
+
const val = readValue(memberSchemas[matchIdx]);
|
|
1628
|
+
if (val != null) {
|
|
1629
|
+
result[memberNames[matchIdx]] = val;
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
else {
|
|
1633
|
+
const key = readUtf8String();
|
|
1634
|
+
const val = readValue(NormalizedSchema.of(15));
|
|
1635
|
+
if (key === "__type" && typeof val === "string") {
|
|
1636
|
+
hasType = true;
|
|
1637
|
+
}
|
|
1638
|
+
else {
|
|
1639
|
+
unknownKey = key;
|
|
1640
|
+
unknownValue = val;
|
|
1641
|
+
++unknownCount;
|
|
1642
|
+
}
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1645
|
+
if (isUnion) {
|
|
1646
|
+
let resultEmpty = true;
|
|
1647
|
+
for (const _ in result) {
|
|
1648
|
+
resultEmpty = false;
|
|
1649
|
+
break;
|
|
1650
|
+
}
|
|
1651
|
+
if (resultEmpty && unknownCount === 1) {
|
|
1652
|
+
result.$unknown = [unknownKey, unknownValue];
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1655
|
+
else if (hasType) {
|
|
1656
|
+
pos = startPos;
|
|
1657
|
+
const docSchema = NormalizedSchema.of(15);
|
|
1658
|
+
for (let i = 0; i < count; ++i) {
|
|
1659
|
+
const key = readUtf8String();
|
|
1660
|
+
const val = readValue(docSchema);
|
|
1661
|
+
if (!(key in result)) {
|
|
1662
|
+
result[key] = val;
|
|
1663
|
+
}
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
return result;
|
|
1667
|
+
}
|
|
1668
|
+
function readTag(ns) {
|
|
1669
|
+
const tagNum = decodeArgument();
|
|
1670
|
+
const tagNumber = typeof tagNum === "bigint" ? Number(tagNum) : tagNum;
|
|
1671
|
+
if (tagNumber === 1) {
|
|
1672
|
+
const docSchema = NormalizedSchema.of(15);
|
|
1673
|
+
const epochValue = readValue(docSchema);
|
|
1674
|
+
return _parseEpochTimestamp(epochValue);
|
|
1675
|
+
}
|
|
1676
|
+
if (tagNumber === 2 || tagNumber === 3) {
|
|
1677
|
+
const byteStr = readByteString();
|
|
1678
|
+
let b = BigInt(0);
|
|
1679
|
+
for (let i = 0; i < byteStr.length; ++i) {
|
|
1680
|
+
b = (b << BigInt(8)) | BigInt(byteStr[i]);
|
|
1681
|
+
}
|
|
1682
|
+
return tagNumber === 3 ? -b - BigInt(1) : b;
|
|
1683
|
+
}
|
|
1684
|
+
if (tagNumber === 4) {
|
|
1685
|
+
const docSchema = NormalizedSchema.of(15);
|
|
1686
|
+
const pair = readValue(docSchema);
|
|
1687
|
+
const [exponent, mantissa] = pair;
|
|
1688
|
+
const normalizer = mantissa < 0 ? -1 : 1;
|
|
1689
|
+
const mantissaStr = "0".repeat(Math.abs(exponent) + 1) + String(BigInt(normalizer) * BigInt(mantissa));
|
|
1690
|
+
let numericString;
|
|
1691
|
+
const sign = mantissa < 0 ? "-" : "";
|
|
1692
|
+
numericString =
|
|
1693
|
+
exponent === 0
|
|
1694
|
+
? mantissaStr
|
|
1695
|
+
: mantissaStr.slice(0, mantissaStr.length + exponent) + "." + mantissaStr.slice(exponent);
|
|
1696
|
+
numericString = numericString.replace(/^0+/g, "");
|
|
1697
|
+
if (numericString === "") {
|
|
1698
|
+
numericString = "0";
|
|
1699
|
+
}
|
|
1700
|
+
if (numericString[0] === ".") {
|
|
1701
|
+
numericString = "0" + numericString;
|
|
1702
|
+
}
|
|
1703
|
+
numericString = sign + numericString;
|
|
1704
|
+
return nv(numericString);
|
|
1705
|
+
}
|
|
1706
|
+
const docSchema = NormalizedSchema.of(15);
|
|
1707
|
+
const innerValue = readValue(docSchema);
|
|
1708
|
+
return { tag: castBigInt(tagNum), value: innerValue };
|
|
1709
|
+
}
|
|
1710
|
+
function readIndefinite(ns, major) {
|
|
1711
|
+
switch (major) {
|
|
1712
|
+
case majorUtf8String:
|
|
1713
|
+
return readUtf8StringIndefinite();
|
|
1714
|
+
case majorUnstructuredByteString:
|
|
1715
|
+
return readByteStringIndefinite();
|
|
1716
|
+
case majorList:
|
|
1717
|
+
return readListIndefinite(ns);
|
|
1718
|
+
case majorMap:
|
|
1719
|
+
return readMapIndefinite(ns);
|
|
1720
|
+
default:
|
|
1721
|
+
throw new Error(`unexpected indefinite length for major ${major}.`);
|
|
1722
|
+
}
|
|
1723
|
+
}
|
|
1724
|
+
function readUtf8StringIndefinite() {
|
|
1725
|
+
pos += 1;
|
|
1726
|
+
const chunks = [];
|
|
1727
|
+
let totalLen = 0;
|
|
1728
|
+
while (pos < end) {
|
|
1729
|
+
if (payload[pos] === 0xff) {
|
|
1730
|
+
pos += 1;
|
|
1731
|
+
const combined = new Uint8Array(totalLen);
|
|
1732
|
+
let offset = 0;
|
|
1733
|
+
for (let i = 0; i < chunks.length; ++i) {
|
|
1734
|
+
combined.set(chunks[i], offset);
|
|
1735
|
+
offset += chunks[i].length;
|
|
1736
|
+
}
|
|
1737
|
+
if (USE_BUFFER) {
|
|
1738
|
+
return Buffer.from(combined.buffer, combined.byteOffset, combined.byteLength).toString("utf-8");
|
|
1739
|
+
}
|
|
1740
|
+
return textDecoder.decode(combined);
|
|
1741
|
+
}
|
|
1742
|
+
const bytes = readByteString();
|
|
1743
|
+
chunks.push(bytes);
|
|
1744
|
+
totalLen += bytes.length;
|
|
1745
|
+
}
|
|
1746
|
+
throw new Error("expected break marker.");
|
|
1747
|
+
}
|
|
1748
|
+
function readByteStringIndefinite() {
|
|
1749
|
+
pos += 1;
|
|
1750
|
+
const chunks = [];
|
|
1751
|
+
let totalLen = 0;
|
|
1752
|
+
while (pos < end) {
|
|
1753
|
+
if (payload[pos] === 0xff) {
|
|
1754
|
+
pos += 1;
|
|
1755
|
+
const combined = new Uint8Array(totalLen);
|
|
1756
|
+
let offset = 0;
|
|
1757
|
+
for (let i = 0; i < chunks.length; ++i) {
|
|
1758
|
+
combined.set(chunks[i], offset);
|
|
1759
|
+
offset += chunks[i].length;
|
|
1760
|
+
}
|
|
1761
|
+
return combined;
|
|
1762
|
+
}
|
|
1763
|
+
const bytes = readByteString();
|
|
1764
|
+
chunks.push(bytes);
|
|
1765
|
+
totalLen += bytes.length;
|
|
1766
|
+
}
|
|
1767
|
+
throw new Error("expected break marker.");
|
|
1768
|
+
}
|
|
1769
|
+
function readListIndefinite(ns) {
|
|
1770
|
+
pos += 1;
|
|
1771
|
+
const memberSchema = ns.isListSchema() ? ns.getValueSchema() : ns;
|
|
1772
|
+
const list = [];
|
|
1773
|
+
while (pos < end) {
|
|
1774
|
+
if (payload[pos] === 0xff) {
|
|
1775
|
+
pos += 1;
|
|
1776
|
+
return list;
|
|
1777
|
+
}
|
|
1778
|
+
list.push(readValue(memberSchema));
|
|
1779
|
+
}
|
|
1780
|
+
throw new Error("expected break marker.");
|
|
1781
|
+
}
|
|
1782
|
+
function readMapIndefinite(ns) {
|
|
1783
|
+
pos += 1;
|
|
1784
|
+
if (ns.isStructSchema()) {
|
|
1785
|
+
const cache = loadCborStructIterator(ns);
|
|
1786
|
+
const { memberSchemas, encodedKeys, memberNames } = cache;
|
|
1787
|
+
const z = encodedKeys.length;
|
|
1788
|
+
const isUnion = ns.isUnionSchema();
|
|
1789
|
+
const result = {};
|
|
1790
|
+
let unknownKey;
|
|
1791
|
+
let unknownValue;
|
|
1792
|
+
let unknownCount = 0;
|
|
1793
|
+
let hint = 0;
|
|
1794
|
+
while (pos < end) {
|
|
1795
|
+
if (payload[pos] === 0xff) {
|
|
1796
|
+
pos += 1;
|
|
1797
|
+
if (isUnion) {
|
|
1798
|
+
let resultEmpty = true;
|
|
1799
|
+
for (const _ in result) {
|
|
1800
|
+
resultEmpty = false;
|
|
1122
1801
|
break;
|
|
1123
1802
|
}
|
|
1124
|
-
if (
|
|
1125
|
-
|
|
1126
|
-
newObject.$unknown = [k, value[k]];
|
|
1803
|
+
if (resultEmpty && unknownCount === 1) {
|
|
1804
|
+
result.$unknown = [unknownKey, unknownValue];
|
|
1127
1805
|
}
|
|
1128
1806
|
}
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1807
|
+
return result;
|
|
1808
|
+
}
|
|
1809
|
+
const matchIdx = matchStructKey(encodedKeys, z, hint);
|
|
1810
|
+
if (matchIdx >= 0) {
|
|
1811
|
+
hint = matchIdx + 1;
|
|
1812
|
+
if (hint >= z) {
|
|
1813
|
+
hint = 0;
|
|
1814
|
+
}
|
|
1815
|
+
const val = readValue(memberSchemas[matchIdx]);
|
|
1816
|
+
if (val != null) {
|
|
1817
|
+
result[memberNames[matchIdx]] = val;
|
|
1818
|
+
}
|
|
1819
|
+
}
|
|
1820
|
+
else {
|
|
1821
|
+
const key = readUtf8String();
|
|
1822
|
+
const val = readValue(NormalizedSchema.of(15));
|
|
1823
|
+
if (key !== "__type") {
|
|
1824
|
+
unknownKey = key;
|
|
1825
|
+
unknownValue = val;
|
|
1826
|
+
++unknownCount;
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1829
|
+
}
|
|
1830
|
+
throw new Error("expected break marker.");
|
|
1831
|
+
}
|
|
1832
|
+
const valueSchema = ns.isMapSchema() ? ns.getValueSchema() : ns;
|
|
1833
|
+
const map = {};
|
|
1834
|
+
while (pos < end) {
|
|
1835
|
+
if (payload[pos] === 0xff) {
|
|
1836
|
+
pos += 1;
|
|
1837
|
+
return map;
|
|
1838
|
+
}
|
|
1839
|
+
const key = readUtf8String();
|
|
1840
|
+
map[key] = readValue(valueSchema);
|
|
1841
|
+
}
|
|
1842
|
+
throw new Error("expected break marker.");
|
|
1843
|
+
}
|
|
1844
|
+
function matchStructKey(encodedKeys, z, hint) {
|
|
1845
|
+
const hintKey = encodedKeys[hint];
|
|
1846
|
+
if (pos + hintKey.length <= end && bytesMatch(pos, hintKey)) {
|
|
1847
|
+
pos += hintKey.length;
|
|
1848
|
+
return hint;
|
|
1849
|
+
}
|
|
1850
|
+
for (let i = 0; i < z; ++i) {
|
|
1851
|
+
if (i === hint) {
|
|
1852
|
+
continue;
|
|
1853
|
+
}
|
|
1854
|
+
const ek = encodedKeys[i];
|
|
1855
|
+
if (pos + ek.length <= end && bytesMatch(pos, ek)) {
|
|
1856
|
+
pos += ek.length;
|
|
1857
|
+
return i;
|
|
1858
|
+
}
|
|
1859
|
+
}
|
|
1860
|
+
return -1;
|
|
1861
|
+
}
|
|
1862
|
+
function bytesMatch(at, expected) {
|
|
1863
|
+
const len = expected.length;
|
|
1864
|
+
if (payload[at] !== expected[0]) {
|
|
1865
|
+
return false;
|
|
1866
|
+
}
|
|
1867
|
+
for (let i = 1; i < len; ++i) {
|
|
1868
|
+
if (payload[at + i] !== expected[i]) {
|
|
1869
|
+
return false;
|
|
1870
|
+
}
|
|
1871
|
+
}
|
|
1872
|
+
return true;
|
|
1873
|
+
}
|
|
1874
|
+
function decodeArgument() {
|
|
1875
|
+
const minor = payload[pos] & 0b0001_1111;
|
|
1876
|
+
if (minor < 24) {
|
|
1877
|
+
pos += 1;
|
|
1878
|
+
return minor;
|
|
1879
|
+
}
|
|
1880
|
+
switch (minor) {
|
|
1881
|
+
case extendedOneByte:
|
|
1882
|
+
if (end - pos < 2) {
|
|
1883
|
+
overflow(1);
|
|
1884
|
+
}
|
|
1885
|
+
pos += 2;
|
|
1886
|
+
return payload[pos - 1];
|
|
1887
|
+
case extendedFloat16:
|
|
1888
|
+
if (end - pos < 3) {
|
|
1889
|
+
overflow(2);
|
|
1890
|
+
}
|
|
1891
|
+
pos += 3;
|
|
1892
|
+
return dataView.getUint16(pos - 2);
|
|
1893
|
+
case extendedFloat32:
|
|
1894
|
+
if (end - pos < 5) {
|
|
1895
|
+
overflow(4);
|
|
1896
|
+
}
|
|
1897
|
+
pos += 5;
|
|
1898
|
+
return dataView.getUint32(pos - 4);
|
|
1899
|
+
case extendedFloat64: {
|
|
1900
|
+
if (end - pos < 9) {
|
|
1901
|
+
overflow(8);
|
|
1902
|
+
}
|
|
1903
|
+
pos += 9;
|
|
1904
|
+
const hi = dataView.getUint32(pos - 8);
|
|
1905
|
+
if (hi < 0x00200000) {
|
|
1906
|
+
return hi * 4294967296 + dataView.getUint32(pos - 4);
|
|
1907
|
+
}
|
|
1908
|
+
return dataView.getBigUint64(pos - 8);
|
|
1909
|
+
}
|
|
1910
|
+
default:
|
|
1911
|
+
throw new Error(`unexpected minor value ${minor}.`);
|
|
1912
|
+
}
|
|
1913
|
+
}
|
|
1914
|
+
function decodeCount() {
|
|
1915
|
+
const val = decodeArgument();
|
|
1916
|
+
return typeof val === "bigint" ? Number(val) : val;
|
|
1917
|
+
}
|
|
1918
|
+
function readUnsignedInt() {
|
|
1919
|
+
const val = decodeArgument();
|
|
1920
|
+
return castBigInt(val);
|
|
1921
|
+
}
|
|
1922
|
+
function readNegativeInt() {
|
|
1923
|
+
const val = decodeArgument();
|
|
1924
|
+
if (typeof val === "bigint") {
|
|
1925
|
+
return BigInt(-1) - val;
|
|
1926
|
+
}
|
|
1927
|
+
return -1 - val;
|
|
1928
|
+
}
|
|
1929
|
+
function readByteString() {
|
|
1930
|
+
const length = decodeCount();
|
|
1931
|
+
if (end - pos < length) {
|
|
1932
|
+
overflow(length);
|
|
1933
|
+
}
|
|
1934
|
+
const start = pos;
|
|
1935
|
+
pos += length;
|
|
1936
|
+
return payload.subarray(start, start + length);
|
|
1937
|
+
}
|
|
1938
|
+
function readUtf8String() {
|
|
1939
|
+
const length = decodeCount();
|
|
1940
|
+
if (end - pos < length) {
|
|
1941
|
+
overflow(length);
|
|
1942
|
+
}
|
|
1943
|
+
const start = pos;
|
|
1944
|
+
pos += length;
|
|
1945
|
+
if (length < 24) {
|
|
1946
|
+
return decodeUtf8Cached(start, length);
|
|
1947
|
+
}
|
|
1948
|
+
if (isBuffer) {
|
|
1949
|
+
return payload.toString("utf-8", start, start + length);
|
|
1950
|
+
}
|
|
1951
|
+
return textDecoder.decode(payload.subarray(start, start + length));
|
|
1952
|
+
}
|
|
1953
|
+
function decodeUtf8Cached(at, length) {
|
|
1954
|
+
let h = length;
|
|
1955
|
+
for (let i = 0; i < length; ++i) {
|
|
1956
|
+
h = (h * 31 + payload[at + i]) | 0;
|
|
1957
|
+
}
|
|
1958
|
+
const slot = (h >>> 0) & (STRING_CACHE_SIZE - 1);
|
|
1959
|
+
const cached = stringCache[slot];
|
|
1960
|
+
if (cached !== undefined && cached.length === length) {
|
|
1961
|
+
let match = true;
|
|
1962
|
+
for (let i = 0; i < length; ++i) {
|
|
1963
|
+
if (cached.charCodeAt(i) !== payload[at + i]) {
|
|
1964
|
+
match = false;
|
|
1965
|
+
break;
|
|
1966
|
+
}
|
|
1967
|
+
}
|
|
1968
|
+
if (match) {
|
|
1969
|
+
stringCacheEpochs[slot] = cacheEpoch;
|
|
1970
|
+
return cached;
|
|
1971
|
+
}
|
|
1972
|
+
}
|
|
1973
|
+
const result = isBuffer
|
|
1974
|
+
? payload.toString("utf-8", at, at + length)
|
|
1975
|
+
: textDecoder.decode(payload.subarray(at, at + length));
|
|
1976
|
+
if (stringCacheEpochs[slot] !== cacheEpoch) {
|
|
1977
|
+
stringCache[slot] = result;
|
|
1978
|
+
stringCacheEpochs[slot] = cacheEpoch;
|
|
1979
|
+
}
|
|
1980
|
+
return result;
|
|
1981
|
+
}
|
|
1982
|
+
function readSpecial() {
|
|
1983
|
+
const p = pos;
|
|
1984
|
+
const minor = payload[p] & 0b0001_1111;
|
|
1985
|
+
switch (minor) {
|
|
1986
|
+
case specialTrue:
|
|
1987
|
+
pos = p + 1;
|
|
1988
|
+
return true;
|
|
1989
|
+
case specialFalse:
|
|
1990
|
+
pos = p + 1;
|
|
1991
|
+
return false;
|
|
1992
|
+
case specialNull:
|
|
1993
|
+
pos = p + 1;
|
|
1994
|
+
return null;
|
|
1995
|
+
case specialUndefined:
|
|
1996
|
+
pos = p + 1;
|
|
1997
|
+
return null;
|
|
1998
|
+
case extendedFloat16: {
|
|
1999
|
+
if (end - p < 3) {
|
|
2000
|
+
overflow(2);
|
|
2001
|
+
}
|
|
2002
|
+
pos = p + 3;
|
|
2003
|
+
return bytesToFloat16(payload[p + 1], payload[p + 2]);
|
|
2004
|
+
}
|
|
2005
|
+
case extendedFloat32: {
|
|
2006
|
+
if (end - p < 5) {
|
|
2007
|
+
overflow(4);
|
|
2008
|
+
}
|
|
2009
|
+
pos = p + 5;
|
|
2010
|
+
return dataView.getFloat32(p + 1);
|
|
2011
|
+
}
|
|
2012
|
+
case extendedFloat64: {
|
|
2013
|
+
if (end - p < 9) {
|
|
2014
|
+
overflow(8);
|
|
2015
|
+
}
|
|
2016
|
+
pos = p + 9;
|
|
2017
|
+
return dataView.getFloat64(p + 1);
|
|
2018
|
+
}
|
|
2019
|
+
default:
|
|
2020
|
+
throw new Error(`unexpected minor value ${minor} for major 7.`);
|
|
2021
|
+
}
|
|
2022
|
+
}
|
|
2023
|
+
function bytesToFloat16(a, b) {
|
|
2024
|
+
const sign = a >> 7;
|
|
2025
|
+
const exponent = (a & 0b0111_1100) >> 2;
|
|
2026
|
+
const fraction = ((a & 0b0000_0011) << 8) | b;
|
|
2027
|
+
const scalar = sign === 0 ? 1 : -1;
|
|
2028
|
+
if (exponent === 0b00000) {
|
|
2029
|
+
if (fraction === 0) {
|
|
2030
|
+
return 0;
|
|
2031
|
+
}
|
|
2032
|
+
return scalar * (Math.pow(2, 1 - 15) * (fraction / 1024));
|
|
2033
|
+
}
|
|
2034
|
+
else if (exponent === 0b11111) {
|
|
2035
|
+
if (fraction === 0) {
|
|
2036
|
+
return scalar * Infinity;
|
|
2037
|
+
}
|
|
2038
|
+
return NaN;
|
|
2039
|
+
}
|
|
2040
|
+
return scalar * (Math.pow(2, exponent - 15) * (1 + fraction / 1024));
|
|
2041
|
+
}
|
|
2042
|
+
function castBigInt(value) {
|
|
2043
|
+
if (typeof value === "number") {
|
|
2044
|
+
return value;
|
|
2045
|
+
}
|
|
2046
|
+
const num = Number(value);
|
|
2047
|
+
if (Number.MIN_SAFE_INTEGER <= num && num <= Number.MAX_SAFE_INTEGER) {
|
|
2048
|
+
return num;
|
|
2049
|
+
}
|
|
2050
|
+
return value;
|
|
2051
|
+
}
|
|
2052
|
+
function overflow(n) {
|
|
2053
|
+
throw new Error(`CBOR: length ${n} greater than remaining buffer length.`);
|
|
2054
|
+
}
|
|
2055
|
+
function transformObject(ns, value) {
|
|
2056
|
+
if (ns.isTimestampSchema()) {
|
|
2057
|
+
if (typeof value === "number") {
|
|
2058
|
+
return _parseEpochTimestamp(value);
|
|
2059
|
+
}
|
|
2060
|
+
if (typeof value === "object" && value !== null) {
|
|
2061
|
+
if (value.tag === 1 && "value" in value) {
|
|
2062
|
+
return _parseEpochTimestamp(value.value);
|
|
2063
|
+
}
|
|
2064
|
+
}
|
|
2065
|
+
}
|
|
2066
|
+
if (ns.isBlobSchema()) {
|
|
2067
|
+
return value;
|
|
2068
|
+
}
|
|
2069
|
+
if (typeof value === "undefined" ||
|
|
2070
|
+
typeof value === "boolean" ||
|
|
2071
|
+
typeof value === "number" ||
|
|
2072
|
+
typeof value === "string" ||
|
|
2073
|
+
typeof value === "bigint" ||
|
|
2074
|
+
typeof value === "symbol") {
|
|
2075
|
+
return value;
|
|
2076
|
+
}
|
|
2077
|
+
if (typeof value !== "object" || value === null) {
|
|
2078
|
+
return value;
|
|
2079
|
+
}
|
|
2080
|
+
if ("byteLength" in value) {
|
|
2081
|
+
return value;
|
|
2082
|
+
}
|
|
2083
|
+
if (value instanceof Date) {
|
|
2084
|
+
return value;
|
|
2085
|
+
}
|
|
2086
|
+
if (value instanceof NumericValue) {
|
|
2087
|
+
return value;
|
|
2088
|
+
}
|
|
2089
|
+
if (ns.isDocumentSchema()) {
|
|
2090
|
+
return value;
|
|
2091
|
+
}
|
|
2092
|
+
if (ns.isListSchema()) {
|
|
2093
|
+
const memberSchema = ns.getValueSchema();
|
|
2094
|
+
const out = [];
|
|
2095
|
+
for (const item of value) {
|
|
2096
|
+
out.push(transformObject(memberSchema, item));
|
|
2097
|
+
}
|
|
2098
|
+
return out;
|
|
2099
|
+
}
|
|
2100
|
+
const newObject = {};
|
|
2101
|
+
if (ns.isMapSchema()) {
|
|
2102
|
+
const targetSchema = ns.getValueSchema();
|
|
2103
|
+
for (const key in value) {
|
|
2104
|
+
newObject[key] = transformObject(targetSchema, value[key]);
|
|
2105
|
+
}
|
|
2106
|
+
}
|
|
2107
|
+
else if (ns.isStructSchema()) {
|
|
2108
|
+
const isUnion = ns.isUnionSchema();
|
|
2109
|
+
let keys;
|
|
2110
|
+
if (isUnion) {
|
|
2111
|
+
keys = new Set();
|
|
2112
|
+
for (const k in value) {
|
|
2113
|
+
if (k !== "__type") {
|
|
2114
|
+
keys.add(k);
|
|
1135
2115
|
}
|
|
1136
2116
|
}
|
|
1137
|
-
|
|
1138
|
-
|
|
2117
|
+
}
|
|
2118
|
+
for (const [key, memberSchema] of ns.structIterator()) {
|
|
2119
|
+
if (isUnion) {
|
|
2120
|
+
keys.delete(key);
|
|
2121
|
+
}
|
|
2122
|
+
if (value[key] != null) {
|
|
2123
|
+
newObject[key] = transformObject(memberSchema, value[key]);
|
|
1139
2124
|
}
|
|
1140
|
-
return newObject;
|
|
1141
2125
|
}
|
|
1142
|
-
|
|
1143
|
-
|
|
2126
|
+
if (isUnion && keys?.size === 1) {
|
|
2127
|
+
let newObjectEmpty = true;
|
|
2128
|
+
for (const _ in newObject) {
|
|
2129
|
+
newObjectEmpty = false;
|
|
2130
|
+
break;
|
|
2131
|
+
}
|
|
2132
|
+
if (newObjectEmpty) {
|
|
2133
|
+
const k = keys.values().next().value;
|
|
2134
|
+
newObject.$unknown = [k, value[k]];
|
|
2135
|
+
}
|
|
2136
|
+
}
|
|
2137
|
+
else if (typeof value.__type === "string") {
|
|
2138
|
+
for (const k in value) {
|
|
2139
|
+
if (!(k in newObject)) {
|
|
2140
|
+
newObject[k] = value[k];
|
|
2141
|
+
}
|
|
2142
|
+
}
|
|
1144
2143
|
}
|
|
1145
2144
|
}
|
|
2145
|
+
return newObject;
|
|
2146
|
+
}
|
|
2147
|
+
|
|
2148
|
+
class CborCodec extends SerdeContext {
|
|
2149
|
+
createSerializer() {
|
|
2150
|
+
const serializer = new CborShapeSerializer2();
|
|
2151
|
+
serializer.setSerdeContext(this.serdeContext);
|
|
2152
|
+
return serializer;
|
|
2153
|
+
}
|
|
2154
|
+
createDeserializer() {
|
|
2155
|
+
const deserializer = new CborShapeDeserializer2();
|
|
2156
|
+
deserializer.setSerdeContext(this.serdeContext);
|
|
2157
|
+
return deserializer;
|
|
2158
|
+
}
|
|
1146
2159
|
}
|
|
1147
2160
|
|
|
1148
2161
|
class SmithyRpcV2CborProtocol extends RpcProtocol {
|
|
@@ -1240,9 +2253,220 @@ class SmithyRpcV2CborProtocol extends RpcProtocol {
|
|
|
1240
2253
|
}
|
|
1241
2254
|
}
|
|
1242
2255
|
|
|
2256
|
+
class CborShapeSerializer extends SerdeContext {
|
|
2257
|
+
value;
|
|
2258
|
+
write(schema, value) {
|
|
2259
|
+
this.value = this.serialize(schema, value);
|
|
2260
|
+
}
|
|
2261
|
+
serialize(schema, source) {
|
|
2262
|
+
const ns = NormalizedSchema.of(schema);
|
|
2263
|
+
if (source == null) {
|
|
2264
|
+
if (ns.isIdempotencyToken()) {
|
|
2265
|
+
return generateIdempotencyToken();
|
|
2266
|
+
}
|
|
2267
|
+
return source;
|
|
2268
|
+
}
|
|
2269
|
+
if (ns.isBlobSchema()) {
|
|
2270
|
+
if (typeof source === "string") {
|
|
2271
|
+
return (this.serdeContext?.base64Decoder ?? fromBase64)(source);
|
|
2272
|
+
}
|
|
2273
|
+
return source;
|
|
2274
|
+
}
|
|
2275
|
+
if (ns.isTimestampSchema()) {
|
|
2276
|
+
if (typeof source === "number" || typeof source === "bigint") {
|
|
2277
|
+
return dateToTag(new Date((Number(source) / 1000) | 0));
|
|
2278
|
+
}
|
|
2279
|
+
return dateToTag(source);
|
|
2280
|
+
}
|
|
2281
|
+
if (typeof source === "function" || typeof source === "object") {
|
|
2282
|
+
const sourceObject = source;
|
|
2283
|
+
if (ns.isListSchema() && Array.isArray(sourceObject)) {
|
|
2284
|
+
const sparse = !!ns.getMergedTraits().sparse;
|
|
2285
|
+
const newArray = [];
|
|
2286
|
+
let i = 0;
|
|
2287
|
+
for (const item of sourceObject) {
|
|
2288
|
+
const value = this.serialize(ns.getValueSchema(), item);
|
|
2289
|
+
if (value != null || sparse) {
|
|
2290
|
+
newArray[i++] = value;
|
|
2291
|
+
}
|
|
2292
|
+
}
|
|
2293
|
+
return newArray;
|
|
2294
|
+
}
|
|
2295
|
+
if (sourceObject instanceof Date) {
|
|
2296
|
+
return dateToTag(sourceObject);
|
|
2297
|
+
}
|
|
2298
|
+
const newObject = {};
|
|
2299
|
+
if (ns.isMapSchema()) {
|
|
2300
|
+
const sparse = !!ns.getMergedTraits().sparse;
|
|
2301
|
+
for (const key in sourceObject) {
|
|
2302
|
+
const value = this.serialize(ns.getValueSchema(), sourceObject[key]);
|
|
2303
|
+
if (value != null || sparse) {
|
|
2304
|
+
newObject[key] = value;
|
|
2305
|
+
}
|
|
2306
|
+
}
|
|
2307
|
+
}
|
|
2308
|
+
else if (ns.isStructSchema()) {
|
|
2309
|
+
for (const [key, memberSchema] of ns.structIterator()) {
|
|
2310
|
+
const value = this.serialize(memberSchema, sourceObject[key]);
|
|
2311
|
+
if (value != null) {
|
|
2312
|
+
newObject[key] = value;
|
|
2313
|
+
}
|
|
2314
|
+
}
|
|
2315
|
+
const isUnion = ns.isUnionSchema();
|
|
2316
|
+
if (isUnion && Array.isArray(sourceObject.$unknown)) {
|
|
2317
|
+
const [k, v] = sourceObject.$unknown;
|
|
2318
|
+
newObject[k] = v;
|
|
2319
|
+
}
|
|
2320
|
+
else if (typeof sourceObject.__type === "string") {
|
|
2321
|
+
for (const k in sourceObject) {
|
|
2322
|
+
if (!(k in newObject)) {
|
|
2323
|
+
newObject[k] = this.serialize(15, sourceObject[k]);
|
|
2324
|
+
}
|
|
2325
|
+
}
|
|
2326
|
+
}
|
|
2327
|
+
}
|
|
2328
|
+
else if (ns.isDocumentSchema()) {
|
|
2329
|
+
if (Array.isArray(sourceObject)) {
|
|
2330
|
+
const newArray = [];
|
|
2331
|
+
let i = 0;
|
|
2332
|
+
for (const item of sourceObject) {
|
|
2333
|
+
newArray[i++] = this.serialize(ns.getValueSchema(), item);
|
|
2334
|
+
}
|
|
2335
|
+
return newArray;
|
|
2336
|
+
}
|
|
2337
|
+
for (const key in sourceObject) {
|
|
2338
|
+
newObject[key] = this.serialize(ns.getValueSchema(), sourceObject[key]);
|
|
2339
|
+
}
|
|
2340
|
+
}
|
|
2341
|
+
else if (ns.isBigDecimalSchema()) {
|
|
2342
|
+
return sourceObject;
|
|
2343
|
+
}
|
|
2344
|
+
return newObject;
|
|
2345
|
+
}
|
|
2346
|
+
return source;
|
|
2347
|
+
}
|
|
2348
|
+
flush() {
|
|
2349
|
+
const buffer = cbor.serialize(this.value);
|
|
2350
|
+
this.value = undefined;
|
|
2351
|
+
return buffer;
|
|
2352
|
+
}
|
|
2353
|
+
}
|
|
2354
|
+
|
|
2355
|
+
class CborShapeDeserializer extends SerdeContext {
|
|
2356
|
+
read(schema, bytes) {
|
|
2357
|
+
const data = cbor.deserialize(bytes);
|
|
2358
|
+
return this.readValue(schema, data);
|
|
2359
|
+
}
|
|
2360
|
+
readValue(_schema, value) {
|
|
2361
|
+
const ns = NormalizedSchema.of(_schema);
|
|
2362
|
+
if (ns.isTimestampSchema()) {
|
|
2363
|
+
if (typeof value === "number") {
|
|
2364
|
+
return _parseEpochTimestamp(value);
|
|
2365
|
+
}
|
|
2366
|
+
if (typeof value === "object") {
|
|
2367
|
+
if (value.tag === 1 && "value" in value) {
|
|
2368
|
+
return _parseEpochTimestamp(value.value);
|
|
2369
|
+
}
|
|
2370
|
+
}
|
|
2371
|
+
}
|
|
2372
|
+
if (ns.isBlobSchema()) {
|
|
2373
|
+
if (typeof value === "string") {
|
|
2374
|
+
return (this.serdeContext?.base64Decoder ?? fromBase64)(value);
|
|
2375
|
+
}
|
|
2376
|
+
return value;
|
|
2377
|
+
}
|
|
2378
|
+
if (typeof value === "undefined" ||
|
|
2379
|
+
typeof value === "boolean" ||
|
|
2380
|
+
typeof value === "number" ||
|
|
2381
|
+
typeof value === "string" ||
|
|
2382
|
+
typeof value === "bigint" ||
|
|
2383
|
+
typeof value === "symbol") {
|
|
2384
|
+
return value;
|
|
2385
|
+
}
|
|
2386
|
+
else if (typeof value === "object") {
|
|
2387
|
+
if (value === null) {
|
|
2388
|
+
return null;
|
|
2389
|
+
}
|
|
2390
|
+
if ("byteLength" in value) {
|
|
2391
|
+
return value;
|
|
2392
|
+
}
|
|
2393
|
+
if (value instanceof Date) {
|
|
2394
|
+
return value;
|
|
2395
|
+
}
|
|
2396
|
+
if (ns.isDocumentSchema()) {
|
|
2397
|
+
return value;
|
|
2398
|
+
}
|
|
2399
|
+
if (ns.isListSchema()) {
|
|
2400
|
+
const newArray = [];
|
|
2401
|
+
const memberSchema = ns.getValueSchema();
|
|
2402
|
+
for (const item of value) {
|
|
2403
|
+
const itemValue = this.readValue(memberSchema, item);
|
|
2404
|
+
newArray.push(itemValue);
|
|
2405
|
+
}
|
|
2406
|
+
return newArray;
|
|
2407
|
+
}
|
|
2408
|
+
const newObject = {};
|
|
2409
|
+
if (ns.isMapSchema()) {
|
|
2410
|
+
const targetSchema = ns.getValueSchema();
|
|
2411
|
+
for (const key in value) {
|
|
2412
|
+
const itemValue = this.readValue(targetSchema, value[key]);
|
|
2413
|
+
newObject[key] = itemValue;
|
|
2414
|
+
}
|
|
2415
|
+
}
|
|
2416
|
+
else if (ns.isStructSchema()) {
|
|
2417
|
+
const isUnion = ns.isUnionSchema();
|
|
2418
|
+
let keys;
|
|
2419
|
+
if (isUnion) {
|
|
2420
|
+
keys = new Set();
|
|
2421
|
+
for (const k in value) {
|
|
2422
|
+
if (k !== "__type") {
|
|
2423
|
+
keys.add(k);
|
|
2424
|
+
}
|
|
2425
|
+
}
|
|
2426
|
+
}
|
|
2427
|
+
for (const [key, memberSchema] of ns.structIterator()) {
|
|
2428
|
+
if (isUnion) {
|
|
2429
|
+
keys.delete(key);
|
|
2430
|
+
}
|
|
2431
|
+
if (value[key] != null) {
|
|
2432
|
+
newObject[key] = this.readValue(memberSchema, value[key]);
|
|
2433
|
+
}
|
|
2434
|
+
}
|
|
2435
|
+
if (isUnion && keys?.size === 1) {
|
|
2436
|
+
let newObjectEmpty = true;
|
|
2437
|
+
for (const _ in newObject) {
|
|
2438
|
+
newObjectEmpty = false;
|
|
2439
|
+
break;
|
|
2440
|
+
}
|
|
2441
|
+
if (newObjectEmpty) {
|
|
2442
|
+
const k = keys.values().next().value;
|
|
2443
|
+
newObject.$unknown = [k, value[k]];
|
|
2444
|
+
}
|
|
2445
|
+
}
|
|
2446
|
+
else if (typeof value.__type === "string") {
|
|
2447
|
+
for (const k in value) {
|
|
2448
|
+
if (!(k in newObject)) {
|
|
2449
|
+
newObject[k] = value[k];
|
|
2450
|
+
}
|
|
2451
|
+
}
|
|
2452
|
+
}
|
|
2453
|
+
}
|
|
2454
|
+
else if (value instanceof NumericValue) {
|
|
2455
|
+
return value;
|
|
2456
|
+
}
|
|
2457
|
+
return newObject;
|
|
2458
|
+
}
|
|
2459
|
+
else {
|
|
2460
|
+
return value;
|
|
2461
|
+
}
|
|
2462
|
+
}
|
|
2463
|
+
}
|
|
2464
|
+
|
|
1243
2465
|
exports.CborCodec = CborCodec;
|
|
1244
2466
|
exports.CborShapeDeserializer = CborShapeDeserializer;
|
|
2467
|
+
exports.CborShapeDeserializer2 = CborShapeDeserializer2;
|
|
1245
2468
|
exports.CborShapeSerializer = CborShapeSerializer;
|
|
2469
|
+
exports.CborShapeSerializer2 = CborShapeSerializer2;
|
|
1246
2470
|
exports.SmithyRpcV2CborProtocol = SmithyRpcV2CborProtocol;
|
|
1247
2471
|
exports.buildHttpRpcRequest = buildHttpRpcRequest;
|
|
1248
2472
|
exports.cbor = cbor;
|