@aws-amplify/core 5.5.3-graphql-api-functional-options.2 → 5.5.3-unstable.ec57e85.2
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/internals/aws-client-utils/composers/package.json +8 -0
- package/internals/aws-client-utils/package.json +4 -4
- package/lib/AwsClients/CognitoIdentity/base.d.ts +1 -1
- package/lib/AwsClients/CognitoIdentity/getCredentialsForIdentity.d.ts +14 -3
- package/lib/AwsClients/CognitoIdentity/getCredentialsForIdentity.js +2 -1
- package/lib/AwsClients/CognitoIdentity/getId.d.ts +14 -3
- package/lib/AwsClients/CognitoIdentity/getId.js +2 -1
- package/lib/AwsClients/Pinpoint/getInAppMessages.d.ts +13 -3
- package/lib/AwsClients/Pinpoint/putEvents.d.ts +13 -3
- package/lib/AwsClients/Pinpoint/updateEndpoint.d.ts +13 -3
- package/lib/Platform/version.d.ts +1 -1
- package/lib/Platform/version.js +1 -1
- package/lib/clients/handlers/fetch.js +4 -21
- package/lib/clients/index.d.ts +7 -2
- package/lib/clients/index.js +17 -4
- package/lib/clients/internal/composeServiceApi.d.ts +1 -1
- package/lib/clients/internal/composeServiceApi.js +1 -3
- package/lib/clients/internal/index.d.ts +7 -0
- package/lib/clients/internal/index.js +14 -0
- package/lib/clients/middleware/retry/middleware.d.ts +0 -7
- package/lib/clients/middleware/retry/middleware.js +37 -26
- package/lib/clients/middleware/signing/middleware.d.ts +9 -2
- package/lib/clients/middleware/signing/middleware.js +25 -14
- package/lib/clients/middleware/signing/signer/signatureV4/index.d.ts +2 -0
- package/lib/clients/middleware/signing/signer/signatureV4/index.js +3 -1
- package/lib/clients/middleware/signing/signer/signatureV4/index.native.d.ts +1 -0
- package/lib/clients/middleware/signing/signer/signatureV4/index.native.js +3 -1
- package/lib/clients/middleware/signing/signer/signatureV4/types/signer.d.ts +10 -1
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getCanonicalRequest.d.ts +3 -1
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getCanonicalRequest.js +5 -2
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getCanonicalUri.d.ts +3 -1
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getCanonicalUri.js +9 -2
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getSignature.d.ts +1 -1
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getSignature.js +2 -2
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getSigningValues.d.ts +1 -1
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getSigningValues.js +3 -2
- package/lib/clients/serde/responseInfo.js +4 -2
- package/lib/clients/types/aws.d.ts +4 -3
- package/lib/clients/utils/memoization.d.ts +9 -0
- package/lib/clients/utils/memoization.js +26 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib-esm/AwsClients/CognitoIdentity/base.d.ts +1 -1
- package/lib-esm/AwsClients/CognitoIdentity/getCredentialsForIdentity.d.ts +14 -3
- package/lib-esm/AwsClients/CognitoIdentity/getCredentialsForIdentity.js +2 -1
- package/lib-esm/AwsClients/CognitoIdentity/getId.d.ts +14 -3
- package/lib-esm/AwsClients/CognitoIdentity/getId.js +2 -1
- package/lib-esm/AwsClients/Pinpoint/getInAppMessages.d.ts +13 -3
- package/lib-esm/AwsClients/Pinpoint/putEvents.d.ts +13 -3
- package/lib-esm/AwsClients/Pinpoint/updateEndpoint.d.ts +13 -3
- package/lib-esm/Platform/version.d.ts +1 -1
- package/lib-esm/Platform/version.js +1 -1
- package/lib-esm/clients/handlers/fetch.js +1 -18
- package/lib-esm/clients/index.d.ts +7 -2
- package/lib-esm/clients/index.js +7 -2
- package/lib-esm/clients/internal/composeServiceApi.d.ts +1 -1
- package/lib-esm/clients/internal/composeServiceApi.js +1 -3
- package/lib-esm/clients/internal/index.d.ts +7 -0
- package/lib-esm/clients/internal/index.js +9 -0
- package/lib-esm/clients/middleware/retry/middleware.d.ts +0 -7
- package/lib-esm/clients/middleware/retry/middleware.js +36 -24
- package/lib-esm/clients/middleware/signing/middleware.d.ts +9 -2
- package/lib-esm/clients/middleware/signing/middleware.js +25 -14
- package/lib-esm/clients/middleware/signing/signer/signatureV4/index.d.ts +2 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/index.js +1 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/index.native.d.ts +1 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/index.native.js +1 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/types/signer.d.ts +10 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCanonicalRequest.d.ts +3 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCanonicalRequest.js +5 -2
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCanonicalUri.d.ts +3 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCanonicalUri.js +9 -2
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getSignature.d.ts +1 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getSignature.js +2 -2
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getSigningValues.d.ts +1 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getSigningValues.js +3 -2
- package/lib-esm/clients/serde/responseInfo.js +3 -1
- package/lib-esm/clients/types/aws.d.ts +4 -3
- package/lib-esm/clients/utils/memoization.d.ts +9 -0
- package/lib-esm/clients/utils/memoization.js +22 -0
- package/lib-esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -7
- package/src/AwsClients/CognitoIdentity/getCredentialsForIdentity.ts +1 -1
- package/src/AwsClients/CognitoIdentity/getId.ts +1 -1
- package/src/Platform/version.ts +1 -1
- package/src/clients/handlers/fetch.ts +1 -19
- package/src/clients/index.ts +15 -2
- package/src/clients/internal/composeServiceApi.ts +7 -4
- package/src/clients/internal/index.ts +10 -0
- package/src/clients/middleware/retry/middleware.ts +28 -24
- package/src/clients/middleware/signing/middleware.ts +13 -2
- package/src/clients/middleware/signing/signer/signatureV4/index.native.ts +1 -0
- package/src/clients/middleware/signing/signer/signatureV4/index.ts +2 -0
- package/src/clients/middleware/signing/signer/signatureV4/types/signer.ts +14 -1
- package/src/clients/middleware/signing/signer/signatureV4/utils/getCanonicalRequest.ts +7 -7
- package/src/clients/middleware/signing/signer/signatureV4/utils/getCanonicalUri.ts +11 -2
- package/src/clients/middleware/signing/signer/signatureV4/utils/getSignature.ts +2 -1
- package/src/clients/middleware/signing/signer/signatureV4/utils/getSigningValues.ts +2 -0
- package/src/clients/serde/responseInfo.ts +4 -2
- package/src/clients/types/aws.ts +4 -3
- package/src/clients/utils/memoization.ts +23 -0
|
@@ -4,6 +4,15 @@ export interface SignRequestOptions {
|
|
|
4
4
|
signingDate?: Date;
|
|
5
5
|
signingRegion: string;
|
|
6
6
|
signingService: string;
|
|
7
|
+
/**
|
|
8
|
+
* Whether to uri encode the path as part of canonical uri. It's used for S3 only where the pathname
|
|
9
|
+
* is already uri encoded, and the signing process is not expected to uri encode it again.
|
|
10
|
+
*
|
|
11
|
+
* @default true
|
|
12
|
+
*
|
|
13
|
+
* @see https://github.com/aws/aws-sdk-js-v3/blob/9ba012dfa3a3429aa2db0f90b3b0b3a7a31f9bc3/packages/signature-v4/src/SignatureV4.ts#L76-L83
|
|
14
|
+
*/
|
|
15
|
+
uriEscapePath?: boolean;
|
|
7
16
|
}
|
|
8
17
|
export interface PresignUrlOptions extends SignRequestOptions {
|
|
9
18
|
expiration?: number;
|
|
@@ -15,6 +24,6 @@ export interface FormattedDates {
|
|
|
15
24
|
longDate: string;
|
|
16
25
|
shortDate: string;
|
|
17
26
|
}
|
|
18
|
-
export interface SigningValues extends Credentials, FormattedDates, Pick<SignRequestOptions, 'signingRegion' | 'signingService'> {
|
|
27
|
+
export interface SigningValues extends Credentials, FormattedDates, Pick<SignRequestOptions, 'signingRegion' | 'signingService' | 'uriEscapePath'> {
|
|
19
28
|
credentialScope: string;
|
|
20
29
|
}
|
|
@@ -3,6 +3,8 @@ import { HttpRequest } from '../../../../../types';
|
|
|
3
3
|
* Returns a canonical request.
|
|
4
4
|
*
|
|
5
5
|
* @param request `HttpRequest` from which to create the canonical request from.
|
|
6
|
+
* @param uriEscapePath Whether to uri encode the path as part of canonical uri. It's used for S3 only where the
|
|
7
|
+
* pathname is already uri encoded, and the signing process is not expected to uri encode it again. Defaults to true.
|
|
6
8
|
* @returns String created by by concatenating the following strings, separated by newline characters:
|
|
7
9
|
* - HTTPMethod
|
|
8
10
|
* - CanonicalUri
|
|
@@ -13,4 +15,4 @@ import { HttpRequest } from '../../../../../types';
|
|
|
13
15
|
*
|
|
14
16
|
* @internal
|
|
15
17
|
*/
|
|
16
|
-
export declare const getCanonicalRequest: ({ body, headers, method, url
|
|
18
|
+
export declare const getCanonicalRequest: ({ body, headers, method, url }: HttpRequest, uriEscapePath?: boolean) => string;
|
|
@@ -12,6 +12,8 @@ var getSignedHeaders_1 = require("./getSignedHeaders");
|
|
|
12
12
|
* Returns a canonical request.
|
|
13
13
|
*
|
|
14
14
|
* @param request `HttpRequest` from which to create the canonical request from.
|
|
15
|
+
* @param uriEscapePath Whether to uri encode the path as part of canonical uri. It's used for S3 only where the
|
|
16
|
+
* pathname is already uri encoded, and the signing process is not expected to uri encode it again. Defaults to true.
|
|
15
17
|
* @returns String created by by concatenating the following strings, separated by newline characters:
|
|
16
18
|
* - HTTPMethod
|
|
17
19
|
* - CanonicalUri
|
|
@@ -22,11 +24,12 @@ var getSignedHeaders_1 = require("./getSignedHeaders");
|
|
|
22
24
|
*
|
|
23
25
|
* @internal
|
|
24
26
|
*/
|
|
25
|
-
var getCanonicalRequest = function (_a) {
|
|
27
|
+
var getCanonicalRequest = function (_a, uriEscapePath) {
|
|
26
28
|
var body = _a.body, headers = _a.headers, method = _a.method, url = _a.url;
|
|
29
|
+
if (uriEscapePath === void 0) { uriEscapePath = true; }
|
|
27
30
|
return [
|
|
28
31
|
method,
|
|
29
|
-
(0, getCanonicalUri_1.getCanonicalUri)(url.pathname),
|
|
32
|
+
(0, getCanonicalUri_1.getCanonicalUri)(url.pathname, uriEscapePath),
|
|
30
33
|
(0, getCanonicalQueryString_1.getCanonicalQueryString)(url.searchParams),
|
|
31
34
|
(0, getCanonicalHeaders_1.getCanonicalHeaders)(headers),
|
|
32
35
|
(0, getSignedHeaders_1.getSignedHeaders)(headers),
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
* Returns a canonical uri.
|
|
3
3
|
*
|
|
4
4
|
* @param pathname `pathname` from request url.
|
|
5
|
+
* @param uriEscapePath Whether to uri encode the path as part of canonical uri. It's used for S3 only where the
|
|
6
|
+
* pathname is already uri encoded, and the signing process is not expected to uri encode it again. Defaults to true.
|
|
5
7
|
* @returns URI-encoded version of the absolute path component URL (everything between the host and the question mark
|
|
6
8
|
* character (?) that starts the query string parameters). If the absolute path is empty, a forward slash character (/).
|
|
7
9
|
*
|
|
8
10
|
* @internal
|
|
9
11
|
*/
|
|
10
|
-
export declare const getCanonicalUri: (pathname: string) => string;
|
|
12
|
+
export declare const getCanonicalUri: (pathname: string, uriEscapePath?: boolean) => string;
|
|
@@ -7,12 +7,19 @@ exports.getCanonicalUri = void 0;
|
|
|
7
7
|
* Returns a canonical uri.
|
|
8
8
|
*
|
|
9
9
|
* @param pathname `pathname` from request url.
|
|
10
|
+
* @param uriEscapePath Whether to uri encode the path as part of canonical uri. It's used for S3 only where the
|
|
11
|
+
* pathname is already uri encoded, and the signing process is not expected to uri encode it again. Defaults to true.
|
|
10
12
|
* @returns URI-encoded version of the absolute path component URL (everything between the host and the question mark
|
|
11
13
|
* character (?) that starts the query string parameters). If the absolute path is empty, a forward slash character (/).
|
|
12
14
|
*
|
|
13
15
|
* @internal
|
|
14
16
|
*/
|
|
15
|
-
var getCanonicalUri = function (pathname) {
|
|
16
|
-
|
|
17
|
+
var getCanonicalUri = function (pathname, uriEscapePath) {
|
|
18
|
+
if (uriEscapePath === void 0) { uriEscapePath = true; }
|
|
19
|
+
return pathname
|
|
20
|
+
? uriEscapePath
|
|
21
|
+
? encodeURIComponent(pathname).replace(/%2F/g, '/')
|
|
22
|
+
: pathname
|
|
23
|
+
: '/';
|
|
17
24
|
};
|
|
18
25
|
exports.getCanonicalUri = getCanonicalUri;
|
|
@@ -10,4 +10,4 @@ import { SigningValues } from '../types/signer';
|
|
|
10
10
|
*
|
|
11
11
|
* @internal
|
|
12
12
|
*/
|
|
13
|
-
export declare const getSignature: (request: HttpRequest, { credentialScope, longDate, secretAccessKey, shortDate, signingRegion, signingService, }: SigningValues) => string;
|
|
13
|
+
export declare const getSignature: (request: HttpRequest, { credentialScope, longDate, secretAccessKey, shortDate, signingRegion, signingService, uriEscapePath, }: SigningValues) => string;
|
|
@@ -18,9 +18,9 @@ var getStringToSign_1 = require("./getStringToSign");
|
|
|
18
18
|
* @internal
|
|
19
19
|
*/
|
|
20
20
|
var getSignature = function (request, _a) {
|
|
21
|
-
var credentialScope = _a.credentialScope, longDate = _a.longDate, secretAccessKey = _a.secretAccessKey, shortDate = _a.shortDate, signingRegion = _a.signingRegion, signingService = _a.signingService;
|
|
21
|
+
var credentialScope = _a.credentialScope, longDate = _a.longDate, secretAccessKey = _a.secretAccessKey, shortDate = _a.shortDate, signingRegion = _a.signingRegion, signingService = _a.signingService, uriEscapePath = _a.uriEscapePath;
|
|
22
22
|
// step 1: create a canonical request
|
|
23
|
-
var canonicalRequest = (0, getCanonicalRequest_1.getCanonicalRequest)(request);
|
|
23
|
+
var canonicalRequest = (0, getCanonicalRequest_1.getCanonicalRequest)(request, uriEscapePath);
|
|
24
24
|
// step 2: create a hash of the canonical request
|
|
25
25
|
var hashedRequest = (0, dataHashHelpers_1.getHashedDataAsHex)(null, canonicalRequest);
|
|
26
26
|
// step 3: create a string to sign
|
|
@@ -8,4 +8,4 @@ import { SigningValues } from '../types/signer';
|
|
|
8
8
|
*
|
|
9
9
|
* @internal
|
|
10
10
|
*/
|
|
11
|
-
export declare const getSigningValues: ({ credentials, signingDate, signingRegion, signingService, }: SignRequestOptions) => SigningValues;
|
|
11
|
+
export declare const getSigningValues: ({ credentials, signingDate, signingRegion, signingService, uriEscapePath, }: SignRequestOptions) => SigningValues;
|
|
@@ -14,11 +14,11 @@ var getFormattedDates_1 = require("./getFormattedDates");
|
|
|
14
14
|
* @internal
|
|
15
15
|
*/
|
|
16
16
|
var getSigningValues = function (_a) {
|
|
17
|
-
var credentials = _a.credentials, _b = _a.signingDate, signingDate = _b === void 0 ? new Date() : _b, signingRegion = _a.signingRegion, signingService = _a.signingService;
|
|
17
|
+
var credentials = _a.credentials, _b = _a.signingDate, signingDate = _b === void 0 ? new Date() : _b, signingRegion = _a.signingRegion, signingService = _a.signingService, _c = _a.uriEscapePath, uriEscapePath = _c === void 0 ? true : _c;
|
|
18
18
|
// get properties from credentials
|
|
19
19
|
var accessKeyId = credentials.accessKeyId, secretAccessKey = credentials.secretAccessKey, sessionToken = credentials.sessionToken;
|
|
20
20
|
// get formatted dates for signing
|
|
21
|
-
var
|
|
21
|
+
var _d = (0, getFormattedDates_1.getFormattedDates)(signingDate), longDate = _d.longDate, shortDate = _d.shortDate;
|
|
22
22
|
// copy header and set signing properties
|
|
23
23
|
var credentialScope = (0, getCredentialScope_1.getCredentialScope)(shortDate, signingRegion, signingService);
|
|
24
24
|
return {
|
|
@@ -30,6 +30,7 @@ var getSigningValues = function (_a) {
|
|
|
30
30
|
shortDate: shortDate,
|
|
31
31
|
signingRegion: signingRegion,
|
|
32
32
|
signingService: signingService,
|
|
33
|
+
uriEscapePath: uriEscapePath,
|
|
33
34
|
};
|
|
34
35
|
};
|
|
35
36
|
exports.getSigningValues = getSigningValues;
|
|
@@ -14,10 +14,12 @@ var __assign = (this && this.__assign) || function () {
|
|
|
14
14
|
};
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.parseMetadata = void 0;
|
|
17
|
-
var middleware_1 = require("../middleware/retry/middleware");
|
|
18
17
|
var parseMetadata = function (response) {
|
|
19
18
|
var _a, _b;
|
|
20
19
|
var headers = response.headers, statusCode = response.statusCode;
|
|
21
|
-
return __assign(__assign({}, (
|
|
20
|
+
return __assign(__assign({}, (isMetadataBearer(response) ? response.$metadata : {})), { httpStatusCode: statusCode, requestId: (_b = (_a = headers['x-amzn-requestid']) !== null && _a !== void 0 ? _a : headers['x-amzn-request-id']) !== null && _b !== void 0 ? _b : headers['x-amz-request-id'], extendedRequestId: headers['x-amz-id-2'], cfId: headers['x-amz-cf-id'] });
|
|
22
21
|
};
|
|
23
22
|
exports.parseMetadata = parseMetadata;
|
|
23
|
+
var isMetadataBearer = function (response) {
|
|
24
|
+
return typeof (response === null || response === void 0 ? void 0 : response['$metadata']) === 'object';
|
|
25
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { MetadataBearer } from '@aws-sdk/types';
|
|
1
2
|
import { Endpoint } from './core';
|
|
2
3
|
import { HttpResponse } from './http';
|
|
3
|
-
export type { Credentials } from '@aws-sdk/types';
|
|
4
|
+
export type { Credentials, MetadataBearer } from '@aws-sdk/types';
|
|
4
5
|
export type SourceData = string | ArrayBuffer | ArrayBufferView;
|
|
5
6
|
/**
|
|
6
7
|
* Basic option type for endpoint resolvers. It contains region only.
|
|
@@ -10,10 +11,10 @@ export type EndpointResolverOptions = {
|
|
|
10
11
|
};
|
|
11
12
|
export interface ServiceClientOptions {
|
|
12
13
|
region: string;
|
|
13
|
-
endpointResolver: (options: EndpointResolverOptions) => Endpoint;
|
|
14
|
+
endpointResolver: (options: EndpointResolverOptions, input?: any) => Endpoint;
|
|
14
15
|
}
|
|
15
16
|
/**
|
|
16
17
|
* parse errors from given response. If no error code is found, return undefined.
|
|
17
18
|
* This function is protocol-specific (e.g. JSON, XML, etc.)
|
|
18
19
|
*/
|
|
19
|
-
export type ErrorParser = (response?: HttpResponse) => Promise<Error | undefined>;
|
|
20
|
+
export type ErrorParser = (response?: HttpResponse) => Promise<(Error & MetadataBearer) | undefined>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cache the payload of a response body. It allows multiple calls to the body,
|
|
3
|
+
* for example, when reading the body in both retry decider and error deserializer.
|
|
4
|
+
* Caching body is allowed here because we call the body accessor(blob(), json(),
|
|
5
|
+
* etc.) when body is small or streaming implementation is not available(RN).
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export declare const withMemoization: <T>(payloadAccessor: () => Promise<T>) => () => Promise<T>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.withMemoization = void 0;
|
|
6
|
+
/**
|
|
7
|
+
* Cache the payload of a response body. It allows multiple calls to the body,
|
|
8
|
+
* for example, when reading the body in both retry decider and error deserializer.
|
|
9
|
+
* Caching body is allowed here because we call the body accessor(blob(), json(),
|
|
10
|
+
* etc.) when body is small or streaming implementation is not available(RN).
|
|
11
|
+
*
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
var withMemoization = function (payloadAccessor) {
|
|
15
|
+
var cached;
|
|
16
|
+
return function () {
|
|
17
|
+
if (!cached) {
|
|
18
|
+
// Explicitly not awaiting. Intermediate await would add overhead and
|
|
19
|
+
// introduce a possible race in the event that this wrapper is called
|
|
20
|
+
// again before the first `payloadAccessor` call resolves.
|
|
21
|
+
cached = payloadAccessor();
|
|
22
|
+
}
|
|
23
|
+
return cached;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
exports.withMemoization = withMemoization;
|