@aws-amplify/core 5.4.1-unstable.f47d472.4 → 5.5.0
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/lib/AwsClients/CognitoIdentity/base.js +5 -1
- package/lib/AwsClients/Pinpoint/base.js +1 -1
- package/lib/Platform/detectFramework.d.ts +7 -0
- package/lib/Platform/detectFramework.js +53 -0
- package/lib/Platform/detection/Angular.d.ts +2 -0
- package/lib/Platform/detection/Angular.js +23 -0
- package/lib/Platform/detection/Expo.d.ts +1 -0
- package/lib/Platform/detection/Expo.js +12 -0
- package/lib/Platform/detection/Next.d.ts +2 -0
- package/lib/Platform/detection/Next.js +17 -0
- package/lib/Platform/detection/Nuxt.d.ts +2 -0
- package/lib/Platform/detection/Nuxt.js +18 -0
- package/lib/Platform/detection/React.d.ts +2 -0
- package/lib/Platform/detection/React.js +24 -0
- package/lib/Platform/detection/ReactNative.d.ts +1 -0
- package/lib/Platform/detection/ReactNative.js +12 -0
- package/lib/Platform/detection/Svelte.d.ts +2 -0
- package/lib/Platform/detection/Svelte.js +17 -0
- package/lib/Platform/detection/Vue.d.ts +2 -0
- package/lib/Platform/detection/Vue.js +15 -0
- package/lib/Platform/detection/Web.d.ts +1 -0
- package/lib/Platform/detection/Web.js +10 -0
- package/lib/Platform/detection/helpers.d.ts +6 -0
- package/lib/Platform/detection/helpers.js +29 -0
- package/lib/Platform/detection/index.d.ts +2 -0
- package/lib/Platform/detection/index.js +41 -0
- package/lib/Platform/index.d.ts +11 -6
- package/lib/Platform/index.js +63 -24
- package/lib/Platform/types.d.ts +104 -0
- package/lib/Platform/types.js +133 -0
- package/lib/Platform/version.d.ts +1 -1
- package/lib/Platform/version.js +1 -1
- package/lib/clients/middleware/retry/defaultRetryDecider.js +1 -1
- package/lib/clients/middleware/signing/middleware.d.ts +1 -0
- package/lib/clients/middleware/signing/middleware.js +8 -21
- package/lib/index.d.ts +2 -1
- package/lib/index.js +17 -2
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib-esm/AwsClients/CognitoIdentity/base.js +6 -2
- package/lib-esm/AwsClients/Pinpoint/base.js +2 -2
- package/lib-esm/Platform/detectFramework.d.ts +7 -0
- package/lib-esm/Platform/detectFramework.js +47 -0
- package/lib-esm/Platform/detection/Angular.d.ts +2 -0
- package/lib-esm/Platform/detection/Angular.js +18 -0
- package/lib-esm/Platform/detection/Expo.d.ts +1 -0
- package/lib-esm/Platform/detection/Expo.js +8 -0
- package/lib-esm/Platform/detection/Next.d.ts +2 -0
- package/lib-esm/Platform/detection/Next.js +12 -0
- package/lib-esm/Platform/detection/Nuxt.d.ts +2 -0
- package/lib-esm/Platform/detection/Nuxt.js +13 -0
- package/lib-esm/Platform/detection/React.d.ts +2 -0
- package/lib-esm/Platform/detection/React.js +19 -0
- package/lib-esm/Platform/detection/ReactNative.d.ts +1 -0
- package/lib-esm/Platform/detection/ReactNative.js +8 -0
- package/lib-esm/Platform/detection/Svelte.d.ts +2 -0
- package/lib-esm/Platform/detection/Svelte.js +12 -0
- package/lib-esm/Platform/detection/Vue.d.ts +2 -0
- package/lib-esm/Platform/detection/Vue.js +10 -0
- package/lib-esm/Platform/detection/Web.d.ts +1 -0
- package/lib-esm/Platform/detection/Web.js +6 -0
- package/lib-esm/Platform/detection/helpers.d.ts +6 -0
- package/lib-esm/Platform/detection/helpers.js +20 -0
- package/lib-esm/Platform/detection/index.d.ts +2 -0
- package/lib-esm/Platform/detection/index.js +37 -0
- package/lib-esm/Platform/index.d.ts +11 -6
- package/lib-esm/Platform/index.js +60 -22
- package/lib-esm/Platform/types.d.ts +104 -0
- package/lib-esm/Platform/types.js +130 -0
- package/lib-esm/Platform/version.d.ts +1 -1
- package/lib-esm/Platform/version.js +1 -1
- package/lib-esm/clients/middleware/retry/defaultRetryDecider.js +1 -1
- package/lib-esm/clients/middleware/signing/middleware.d.ts +1 -0
- package/lib-esm/clients/middleware/signing/middleware.js +8 -21
- package/lib-esm/index.d.ts +2 -1
- package/lib-esm/index.js +2 -1
- package/lib-esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/AwsClients/CognitoIdentity/base.ts +7 -2
- package/src/AwsClients/Pinpoint/base.ts +2 -2
- package/src/Platform/detectFramework.ts +57 -0
- package/src/Platform/detection/Angular.ts +26 -0
- package/src/Platform/detection/Expo.ts +11 -0
- package/src/Platform/detection/Next.ts +18 -0
- package/src/Platform/detection/Nuxt.ts +19 -0
- package/src/Platform/detection/React.ts +26 -0
- package/src/Platform/detection/ReactNative.ts +12 -0
- package/src/Platform/detection/Svelte.ts +18 -0
- package/src/Platform/detection/Vue.ts +13 -0
- package/src/Platform/detection/Web.ts +8 -0
- package/src/Platform/detection/helpers.ts +26 -0
- package/src/Platform/detection/index.ts +48 -0
- package/src/Platform/index.ts +42 -21
- package/src/Platform/types.ts +160 -0
- package/src/Platform/version.ts +1 -1
- package/src/clients/middleware/retry/defaultRetryDecider.ts +1 -1
- package/src/clients/middleware/signing/middleware.ts +13 -19
- package/src/index.ts +21 -1
- /package/lib/clients/{utils → middleware/retry}/isClockSkewError.d.ts +0 -0
- /package/lib/clients/{utils → middleware/retry}/isClockSkewError.js +0 -0
- /package/lib-esm/clients/{utils → middleware/retry}/isClockSkewError.d.ts +0 -0
- /package/lib-esm/clients/{utils → middleware/retry}/isClockSkewError.js +0 -0
- /package/src/clients/{utils → middleware/retry}/isClockSkewError.ts +0 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
// Tested with react-native 0.17.7
|
|
5
|
+
|
|
6
|
+
export function reactNativeDetect() {
|
|
7
|
+
return (
|
|
8
|
+
typeof navigator !== 'undefined' &&
|
|
9
|
+
typeof navigator.product !== 'undefined' &&
|
|
10
|
+
navigator.product === 'ReactNative'
|
|
11
|
+
);
|
|
12
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { keyPrefixMatch, processExists, windowExists } from './helpers';
|
|
5
|
+
|
|
6
|
+
// Tested with svelte 3.59
|
|
7
|
+
|
|
8
|
+
export function svelteWebDetect() {
|
|
9
|
+
return windowExists() && keyPrefixMatch(window, '__SVELTE');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function svelteSSRDetect() {
|
|
13
|
+
return (
|
|
14
|
+
processExists() &&
|
|
15
|
+
typeof process.env !== 'undefined' &&
|
|
16
|
+
!!Object.keys(process.env).find(key => key.includes('svelte'))
|
|
17
|
+
);
|
|
18
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { globalExists, keyPrefixMatch, windowExists } from './helpers';
|
|
5
|
+
|
|
6
|
+
// Tested with vue 3.3.2
|
|
7
|
+
|
|
8
|
+
export function vueWebDetect() {
|
|
9
|
+
return windowExists() && keyPrefixMatch(window, '__VUE');
|
|
10
|
+
}
|
|
11
|
+
export function vueSSRDetect() {
|
|
12
|
+
return globalExists() && keyPrefixMatch(global, '__VUE');
|
|
13
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
export const globalExists = () => {
|
|
5
|
+
return typeof global !== 'undefined';
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const globalThisExists = () => {
|
|
9
|
+
return typeof globalThis !== 'undefined';
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const windowExists = () => {
|
|
13
|
+
return typeof window !== 'undefined';
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const documentExists = () => {
|
|
17
|
+
return typeof document !== 'undefined';
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const processExists = () => {
|
|
21
|
+
return typeof process !== 'undefined';
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const keyPrefixMatch = (object: object, prefix: string) => {
|
|
25
|
+
return !!Object.keys(object).find(key => key.startsWith(prefix));
|
|
26
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { Framework } from '../types';
|
|
5
|
+
|
|
6
|
+
import { reactWebDetect, reactSSRDetect } from './React';
|
|
7
|
+
import { vueWebDetect, vueSSRDetect } from './Vue';
|
|
8
|
+
import { svelteWebDetect, svelteSSRDetect } from './Svelte';
|
|
9
|
+
import { nextWebDetect, nextSSRDetect } from './Next';
|
|
10
|
+
import { nuxtWebDetect, nuxtSSRDetect } from './Nuxt';
|
|
11
|
+
import { angularWebDetect, angularSSRDetect } from './Angular';
|
|
12
|
+
import { reactNativeDetect } from './ReactNative';
|
|
13
|
+
import { expoDetect } from './Expo';
|
|
14
|
+
import { webDetect } from './Web';
|
|
15
|
+
|
|
16
|
+
type PlatformDetectionEntry = {
|
|
17
|
+
platform: Framework;
|
|
18
|
+
detectionMethod: () => boolean;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// These are in the order of detection where when both are detectable, the early Framework will be reported
|
|
22
|
+
const detectionMap: PlatformDetectionEntry[] = [
|
|
23
|
+
// First, detect mobile
|
|
24
|
+
{ platform: Framework.Expo, detectionMethod: expoDetect },
|
|
25
|
+
{ platform: Framework.ReactNative, detectionMethod: reactNativeDetect },
|
|
26
|
+
// Next, detect web frameworks
|
|
27
|
+
{ platform: Framework.NextJs, detectionMethod: nextWebDetect },
|
|
28
|
+
{ platform: Framework.Nuxt, detectionMethod: nuxtWebDetect },
|
|
29
|
+
{ platform: Framework.Angular, detectionMethod: angularWebDetect },
|
|
30
|
+
{ platform: Framework.React, detectionMethod: reactWebDetect },
|
|
31
|
+
{ platform: Framework.VueJs, detectionMethod: vueWebDetect },
|
|
32
|
+
{ platform: Framework.Svelte, detectionMethod: svelteWebDetect },
|
|
33
|
+
{ platform: Framework.WebUnknown, detectionMethod: webDetect },
|
|
34
|
+
// Last, detect ssr frameworks
|
|
35
|
+
{ platform: Framework.NextJsSSR, detectionMethod: nextSSRDetect },
|
|
36
|
+
{ platform: Framework.NuxtSSR, detectionMethod: nuxtSSRDetect },
|
|
37
|
+
{ platform: Framework.ReactSSR, detectionMethod: reactSSRDetect },
|
|
38
|
+
{ platform: Framework.VueJsSSR, detectionMethod: vueSSRDetect },
|
|
39
|
+
{ platform: Framework.AngularSSR, detectionMethod: angularSSRDetect },
|
|
40
|
+
{ platform: Framework.SvelteSSR, detectionMethod: svelteSSRDetect },
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
export function detect() {
|
|
44
|
+
return (
|
|
45
|
+
detectionMap.find(detectionEntry => detectionEntry.detectionMethod())
|
|
46
|
+
?.platform || Framework.ServerSideUnknown
|
|
47
|
+
);
|
|
48
|
+
}
|
package/src/Platform/index.ts
CHANGED
|
@@ -1,30 +1,51 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { CustomUserAgentDetails, Framework } from './types';
|
|
3
5
|
import { version } from './version';
|
|
6
|
+
import { detectFramework, observeFrameworkChanges } from './detectFramework';
|
|
7
|
+
import { UserAgent as AWSUserAgent } from '@aws-sdk/types';
|
|
4
8
|
|
|
5
|
-
const BASE_USER_AGENT = `aws-amplify
|
|
9
|
+
const BASE_USER_AGENT = `aws-amplify`;
|
|
6
10
|
|
|
7
|
-
|
|
8
|
-
userAgent
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
Platform.isReactNative = true;
|
|
20
|
-
break;
|
|
21
|
-
default:
|
|
22
|
-
Platform.userAgent = `${BASE_USER_AGENT} js`;
|
|
23
|
-
Platform.isReactNative = false;
|
|
24
|
-
break;
|
|
11
|
+
class PlatformBuilder {
|
|
12
|
+
userAgent = `${BASE_USER_AGENT}/${version}`;
|
|
13
|
+
get framework() {
|
|
14
|
+
return detectFramework();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
get isReactNative() {
|
|
18
|
+
return this.framework === Framework.ReactNative;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
observeFrameworkChanges(fcn: () => void) {
|
|
22
|
+
observeFrameworkChanges(fcn);
|
|
25
23
|
}
|
|
26
24
|
}
|
|
27
25
|
|
|
28
|
-
export const
|
|
29
|
-
|
|
26
|
+
export const Platform = new PlatformBuilder();
|
|
27
|
+
|
|
28
|
+
export const getAmplifyUserAgent = ({
|
|
29
|
+
category,
|
|
30
|
+
action,
|
|
31
|
+
framework,
|
|
32
|
+
}: CustomUserAgentDetails = {}): AWSUserAgent => {
|
|
33
|
+
const userAgent: AWSUserAgent = [[BASE_USER_AGENT, version]];
|
|
34
|
+
if (category) {
|
|
35
|
+
userAgent.push([category, action]);
|
|
36
|
+
}
|
|
37
|
+
userAgent.push(['framework', detectFramework()]);
|
|
38
|
+
|
|
39
|
+
return userAgent;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const getAmplifyUserAgentString = (
|
|
43
|
+
customUserAgentDetails?: CustomUserAgentDetails
|
|
44
|
+
): string => {
|
|
45
|
+
const userAgent = getAmplifyUserAgent(customUserAgentDetails);
|
|
46
|
+
const userAgentString = userAgent
|
|
47
|
+
.map(([agentKey, agentValue]) => `${agentKey}/${agentValue}`)
|
|
48
|
+
.join(' ');
|
|
49
|
+
|
|
50
|
+
return userAgentString;
|
|
30
51
|
};
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
export enum Framework {
|
|
5
|
+
// < 100 - Web frameworks
|
|
6
|
+
WebUnknown = '0',
|
|
7
|
+
React = '1',
|
|
8
|
+
NextJs = '2',
|
|
9
|
+
Angular = '3',
|
|
10
|
+
VueJs = '4',
|
|
11
|
+
Nuxt = '5',
|
|
12
|
+
Svelte = '6',
|
|
13
|
+
|
|
14
|
+
// 100s - Server side frameworks
|
|
15
|
+
ServerSideUnknown = '100',
|
|
16
|
+
ReactSSR = '101',
|
|
17
|
+
NextJsSSR = '102',
|
|
18
|
+
AngularSSR = '103',
|
|
19
|
+
VueJsSSR = '104',
|
|
20
|
+
NuxtSSR = '105',
|
|
21
|
+
SvelteSSR = '106',
|
|
22
|
+
|
|
23
|
+
// 200s - Mobile framework
|
|
24
|
+
ReactNative = '201',
|
|
25
|
+
Expo = '202',
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export enum Category {
|
|
29
|
+
API = 'api',
|
|
30
|
+
Auth = 'auth',
|
|
31
|
+
Analytics = 'analytics',
|
|
32
|
+
DataStore = 'datastore',
|
|
33
|
+
Geo = 'geo',
|
|
34
|
+
InAppMessaging = 'inappmessaging',
|
|
35
|
+
Interactions = 'interactions',
|
|
36
|
+
Predictions = 'predictions',
|
|
37
|
+
PubSub = 'pubsub',
|
|
38
|
+
PushNotification = 'pushnotification',
|
|
39
|
+
Storage = 'storage',
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export enum AnalyticsAction {
|
|
43
|
+
Record = '1',
|
|
44
|
+
UpdateEndpoint = '2',
|
|
45
|
+
}
|
|
46
|
+
export enum ApiAction {
|
|
47
|
+
GraphQl = '1',
|
|
48
|
+
Get = '2',
|
|
49
|
+
Post = '3',
|
|
50
|
+
Put = '4',
|
|
51
|
+
Patch = '5',
|
|
52
|
+
Del = '6',
|
|
53
|
+
Head = '7',
|
|
54
|
+
}
|
|
55
|
+
export enum AuthAction {
|
|
56
|
+
// SignUp = '1',
|
|
57
|
+
// ConfirmSignUp = '2',
|
|
58
|
+
// ResendSignUp = '3',
|
|
59
|
+
// SignIn = '4',
|
|
60
|
+
// GetMFAOptions = '5',
|
|
61
|
+
// GetPreferredMFA = '6',
|
|
62
|
+
// SetPreferredMFA = '7',
|
|
63
|
+
// DisableSMS = '8',
|
|
64
|
+
// EnableSMS = '9',
|
|
65
|
+
// SetupTOTP = '10',
|
|
66
|
+
// VerifyTotpToken = '11',
|
|
67
|
+
// ConfirmSignIn = '12',
|
|
68
|
+
// CompleteNewPassword = '13',
|
|
69
|
+
// SendCustomChallengeAnswer = '14',
|
|
70
|
+
// DeleteUserAttributes = '15',
|
|
71
|
+
// DeleteUser = '16',
|
|
72
|
+
// UpdateUserAttributes = '17',
|
|
73
|
+
// UserAttributes = '18',
|
|
74
|
+
// CurrentUserPoolUser = '19',
|
|
75
|
+
// CurrentAuthenticatedUser = '20',
|
|
76
|
+
// CurrentSession = '21',
|
|
77
|
+
// VerifyUserAttribute = '22',
|
|
78
|
+
// VerifyUserAttributeSubmit = '23',
|
|
79
|
+
// VerifyCurrentUserAttribute = '24',
|
|
80
|
+
// VerifyCurrentUserAttributeSubmit = '25',
|
|
81
|
+
// SignOut = '26',
|
|
82
|
+
// ChangePassword = '27',
|
|
83
|
+
// ForgotPassword = '28',
|
|
84
|
+
// ForgotPasswordSubmit = '29',
|
|
85
|
+
FederatedSignIn = '30',
|
|
86
|
+
// CurrentUserInfo = '31',
|
|
87
|
+
// RememberDevice = '32',
|
|
88
|
+
// ForgetDevice = '33',
|
|
89
|
+
// FetchDevices = '34',
|
|
90
|
+
}
|
|
91
|
+
export enum DataStoreAction {
|
|
92
|
+
Subscribe = '1',
|
|
93
|
+
GraphQl = '2',
|
|
94
|
+
}
|
|
95
|
+
export enum GeoAction {
|
|
96
|
+
None = '0',
|
|
97
|
+
}
|
|
98
|
+
export enum InAppMessagingAction {
|
|
99
|
+
None = '0',
|
|
100
|
+
}
|
|
101
|
+
export enum InteractionsAction {
|
|
102
|
+
None = '0',
|
|
103
|
+
}
|
|
104
|
+
export enum PredictionsAction {
|
|
105
|
+
Convert = '1',
|
|
106
|
+
Identify = '2',
|
|
107
|
+
Interpret = '3',
|
|
108
|
+
}
|
|
109
|
+
export enum PubSubAction {
|
|
110
|
+
Subscribe = '1',
|
|
111
|
+
}
|
|
112
|
+
export enum PushNotificationAction {
|
|
113
|
+
None = '0',
|
|
114
|
+
}
|
|
115
|
+
export enum StorageAction {
|
|
116
|
+
Put = '1',
|
|
117
|
+
Get = '2',
|
|
118
|
+
List = '3',
|
|
119
|
+
Copy = '4',
|
|
120
|
+
Remove = '5',
|
|
121
|
+
GetProperties = '6',
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
type ActionMap = {
|
|
125
|
+
[Category.Auth]: AuthAction;
|
|
126
|
+
[Category.API]: ApiAction;
|
|
127
|
+
[Category.Analytics]: AnalyticsAction;
|
|
128
|
+
[Category.DataStore]: DataStoreAction;
|
|
129
|
+
[Category.Geo]: GeoAction;
|
|
130
|
+
[Category.InAppMessaging]: InAppMessagingAction;
|
|
131
|
+
[Category.Interactions]: InteractionsAction;
|
|
132
|
+
[Category.Predictions]: PredictionsAction;
|
|
133
|
+
[Category.PubSub]: PubSubAction;
|
|
134
|
+
[Category.PushNotification]: PushNotificationAction;
|
|
135
|
+
[Category.Storage]: StorageAction;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
type UserAgentDetailsWithCategory<T extends Category> =
|
|
139
|
+
CustomUserAgentDetailsBase & {
|
|
140
|
+
category: T;
|
|
141
|
+
action: T extends keyof ActionMap ? ActionMap[T] : never;
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
type CustomUserAgentDetailsBase = {
|
|
145
|
+
framework?: Framework;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
export type CustomUserAgentDetails =
|
|
149
|
+
| (CustomUserAgentDetailsBase & { category?: never; action?: never })
|
|
150
|
+
| UserAgentDetailsWithCategory<Category.API>
|
|
151
|
+
| UserAgentDetailsWithCategory<Category.Auth>
|
|
152
|
+
| UserAgentDetailsWithCategory<Category.Analytics>
|
|
153
|
+
| UserAgentDetailsWithCategory<Category.DataStore>
|
|
154
|
+
| UserAgentDetailsWithCategory<Category.Geo>
|
|
155
|
+
| UserAgentDetailsWithCategory<Category.Interactions>
|
|
156
|
+
| UserAgentDetailsWithCategory<Category.InAppMessaging>
|
|
157
|
+
| UserAgentDetailsWithCategory<Category.Predictions>
|
|
158
|
+
| UserAgentDetailsWithCategory<Category.PubSub>
|
|
159
|
+
| UserAgentDetailsWithCategory<Category.PushNotification>
|
|
160
|
+
| UserAgentDetailsWithCategory<Category.Storage>;
|
package/src/Platform/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// generated by genversion
|
|
2
|
-
export const version = '5.
|
|
2
|
+
export const version = '5.3.0';
|
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
HttpResponse,
|
|
8
8
|
MiddlewareHandler,
|
|
9
9
|
} from '../../types';
|
|
10
|
-
import { isClockSkewError } from '../../utils/isClockSkewError';
|
|
11
10
|
import { signRequest } from './signer/signatureV4';
|
|
12
11
|
import { getSkewCorrectedDate } from './utils/getSkewCorrectedDate';
|
|
13
12
|
import { getUpdatedSystemClockOffset } from './utils/getUpdatedSystemClockOffset';
|
|
@@ -23,6 +22,7 @@ export interface SigningOptions {
|
|
|
23
22
|
|
|
24
23
|
/**
|
|
25
24
|
* Middleware that SigV4 signs request with AWS credentials, and correct system clock offset.
|
|
25
|
+
* This middleware is expected to be placed after retry middleware.
|
|
26
26
|
*/
|
|
27
27
|
export const signingMiddleware = ({
|
|
28
28
|
credentials,
|
|
@@ -40,26 +40,20 @@ export const signingMiddleware = ({
|
|
|
40
40
|
signingService: service,
|
|
41
41
|
};
|
|
42
42
|
const signedRequest = await signRequest(request, signRequestOptions);
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
currentSystemClockOffset
|
|
52
|
-
|
|
53
|
-
currentSystemClockOffset
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
throw error;
|
|
43
|
+
const response = await next(signedRequest);
|
|
44
|
+
// Update system clock offset if response contains date header, regardless of the status code.
|
|
45
|
+
// non-2xx response will still be returned from next handler instead of thrown, because it's
|
|
46
|
+
// only thrown by the retry middleware.
|
|
47
|
+
const dateString = getDateHeader(response);
|
|
48
|
+
if (dateString) {
|
|
49
|
+
currentSystemClockOffset = getUpdatedSystemClockOffset(
|
|
50
|
+
Date.parse(dateString),
|
|
51
|
+
currentSystemClockOffset
|
|
52
|
+
);
|
|
57
53
|
}
|
|
54
|
+
return response;
|
|
58
55
|
};
|
|
59
56
|
};
|
|
60
57
|
|
|
61
|
-
const shouldUseServerTime = ({ ServerTime, Code }: any): boolean =>
|
|
62
|
-
ServerTime && isClockSkewError(Code);
|
|
63
|
-
|
|
64
58
|
const getDateHeader = ({ headers }: any = {}): string | undefined =>
|
|
65
|
-
headers?.date ?? headers?.Date;
|
|
59
|
+
headers?.date ?? headers?.Date ?? headers?.['x-amz-date'];
|
package/src/index.ts
CHANGED
|
@@ -35,7 +35,27 @@ export { ServiceWorker } from './ServiceWorker';
|
|
|
35
35
|
export { ICredentials } from './types';
|
|
36
36
|
export { StorageHelper, MemoryStorage } from './StorageHelper';
|
|
37
37
|
export { UniversalStorage } from './UniversalStorage';
|
|
38
|
-
export {
|
|
38
|
+
export {
|
|
39
|
+
Platform,
|
|
40
|
+
getAmplifyUserAgent,
|
|
41
|
+
getAmplifyUserAgentString,
|
|
42
|
+
} from './Platform';
|
|
43
|
+
export {
|
|
44
|
+
ApiAction,
|
|
45
|
+
AuthAction,
|
|
46
|
+
AnalyticsAction,
|
|
47
|
+
Category,
|
|
48
|
+
CustomUserAgentDetails,
|
|
49
|
+
DataStoreAction,
|
|
50
|
+
Framework,
|
|
51
|
+
GeoAction,
|
|
52
|
+
InteractionsAction,
|
|
53
|
+
InAppMessagingAction,
|
|
54
|
+
PredictionsAction,
|
|
55
|
+
PubSubAction,
|
|
56
|
+
PushNotificationAction,
|
|
57
|
+
StorageAction,
|
|
58
|
+
} from './Platform/types';
|
|
39
59
|
export {
|
|
40
60
|
INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER,
|
|
41
61
|
USER_AGENT_HEADER,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|