UNPKG

@aws-amplify/storage

Version:

Storage category of aws-amplify

1 lines 3.65 kB
{"version":3,"file":"base.mjs","sources":["../../../../../../../src/providers/s3/utils/client/s3control/base.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AmplifyUrl, getAmplifyUserAgent, } from '@aws-amplify/core/internals/utils';\nimport { getDnsSuffix, jitteredBackoff, } from '@aws-amplify/core/internals/aws-client-utils';\nimport { createRetryDecider, createXmlErrorParser } from '../utils';\nimport { assertValidationError } from '../../../../../errors/utils/assertValidationError';\nimport { StorageValidationErrorCode } from '../../../../../errors/types/validation';\n/**\n * The service name used to sign requests if the API requires authentication.\n */\nexport const SERVICE_NAME = 's3';\n/**\n * The endpoint resolver function that returns the endpoint URL for a given region, and input parameters.\n */\nconst endpointResolver = (options, apiInput) => {\n const { region, customEndpoint } = options;\n const { AccountId: accountId } = apiInput;\n let endpoint;\n if (customEndpoint) {\n assertValidationError(!customEndpoint.includes('://'), StorageValidationErrorCode.InvalidCustomEndpoint);\n endpoint = new AmplifyUrl(`https://${accountId}.${customEndpoint}`);\n }\n else {\n endpoint = new AmplifyUrl(`https://${accountId}.s3-control.${region}.${getDnsSuffix(region)}`);\n }\n return { url: endpoint };\n};\n/**\n * Error parser for the XML payload of S3 control plane error response. The\n * error's `Code` and `Message` locates at the nested `Error` element instead of\n * the XML root element.\n *\n * @example\n * ```\n * \t<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n * \t<ErrorResponse>\n * \t <Error>\n * \t\t <Code>AccessDenied</Code>\n * \t\t <Message>Access Denied</Message>\n * \t\t</Error>\n * \t\t<RequestId>656c76696e6727732072657175657374</RequestId>\n * \t\t<HostId>Uuag1LuByRx9e6j5Onimru9pO4ZVKnJ2Qz7/C1NPcfTWAtRPfTaOFg==</HostId>\n * \t</ErrorResponse>\n * \t```\n *\n * @internal\n */\nexport const parseXmlError = createXmlErrorParser();\n/**\n * @internal\n */\nexport const retryDecider = createRetryDecider(parseXmlError);\n/**\n * @internal\n */\nexport const defaultConfig = {\n service: SERVICE_NAME,\n endpointResolver,\n retryDecider,\n computeDelay: jitteredBackoff,\n userAgentValue: getAmplifyUserAgent(),\n uriEscapePath: false, // Required by S3. See https://github.com/aws/aws-sdk-js-v3/blob/9ba012dfa3a3429aa2db0f90b3b0b3a7a31f9bc3/packages/signature-v4/src/SignatureV4.ts#L76-L83\n};\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;AACA;AAMA;AACA;AACA;AACY,MAAC,YAAY,GAAG;AAC5B;AACA;AACA;AACA,MAAM,gBAAgB,GAAG,CAAC,OAAO,EAAE,QAAQ,KAAK;AAChD,IAAI,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,GAAG,OAAO;AAC9C,IAAI,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,QAAQ;AAC7C,IAAI,IAAI,QAAQ;AAChB,IAAI,IAAI,cAAc,EAAE;AACxB,QAAQ,qBAAqB,CAAC,CAAC,cAAc,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,0BAA0B,CAAC,qBAAqB,CAAC;AAChH,QAAQ,QAAQ,GAAG,IAAI,UAAU,CAAC,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC;AAC3E;AACA,SAAS;AACT,QAAQ,QAAQ,GAAG,IAAI,UAAU,CAAC,CAAC,QAAQ,EAAE,SAAS,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACtG;AACA,IAAI,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE;AAC5B,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,aAAa,GAAG,oBAAoB;AACjD;AACA;AACA;AACY,MAAC,YAAY,GAAG,kBAAkB,CAAC,aAAa;AAC5D;AACA;AACA;AACY,MAAC,aAAa,GAAG;AAC7B,IAAI,OAAO,EAAE,YAAY;AACzB,IAAI,gBAAgB;AACpB,IAAI,YAAY;AAChB,IAAI,YAAY,EAAE,eAAe;AACjC,IAAI,cAAc,EAAE,mBAAmB,EAAE;AACzC,IAAI,aAAa,EAAE,KAAK;AACxB;;;;"}