@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,19 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { documentExists, processExists } from './helpers';
|
|
4
|
+
// Tested with react 18.2 - built using Vite
|
|
5
|
+
export function reactWebDetect() {
|
|
6
|
+
var elementKeyPrefixedWithReact = function (key) {
|
|
7
|
+
return key.startsWith('_react') || key.startsWith('__react');
|
|
8
|
+
};
|
|
9
|
+
var elementIsReactEnabled = function (element) {
|
|
10
|
+
return Object.keys(element).find(elementKeyPrefixedWithReact);
|
|
11
|
+
};
|
|
12
|
+
var allElementsWithId = function () { return Array.from(document.querySelectorAll('[id]')); };
|
|
13
|
+
return documentExists() && allElementsWithId().some(elementIsReactEnabled);
|
|
14
|
+
}
|
|
15
|
+
export function reactSSRDetect() {
|
|
16
|
+
return (processExists() &&
|
|
17
|
+
typeof process.env !== 'undefined' &&
|
|
18
|
+
!!Object.keys(process.env).find(function (key) { return key.includes('react'); }));
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function reactNativeDetect(): boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// Tested with react-native 0.17.7
|
|
4
|
+
export function reactNativeDetect() {
|
|
5
|
+
return (typeof navigator !== 'undefined' &&
|
|
6
|
+
typeof navigator.product !== 'undefined' &&
|
|
7
|
+
navigator.product === 'ReactNative');
|
|
8
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { keyPrefixMatch, processExists, windowExists } from './helpers';
|
|
4
|
+
// Tested with svelte 3.59
|
|
5
|
+
export function svelteWebDetect() {
|
|
6
|
+
return windowExists() && keyPrefixMatch(window, '__SVELTE');
|
|
7
|
+
}
|
|
8
|
+
export function svelteSSRDetect() {
|
|
9
|
+
return (processExists() &&
|
|
10
|
+
typeof process.env !== 'undefined' &&
|
|
11
|
+
!!Object.keys(process.env).find(function (key) { return key.includes('svelte'); }));
|
|
12
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { globalExists, keyPrefixMatch, windowExists } from './helpers';
|
|
4
|
+
// Tested with vue 3.3.2
|
|
5
|
+
export function vueWebDetect() {
|
|
6
|
+
return windowExists() && keyPrefixMatch(window, '__VUE');
|
|
7
|
+
}
|
|
8
|
+
export function vueSSRDetect() {
|
|
9
|
+
return globalExists() && keyPrefixMatch(global, '__VUE');
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function webDetect(): boolean;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const globalExists: () => boolean;
|
|
2
|
+
export declare const globalThisExists: () => boolean;
|
|
3
|
+
export declare const windowExists: () => boolean;
|
|
4
|
+
export declare const documentExists: () => boolean;
|
|
5
|
+
export declare const processExists: () => boolean;
|
|
6
|
+
export declare const keyPrefixMatch: (object: object, prefix: string) => boolean;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
export var globalExists = function () {
|
|
4
|
+
return typeof global !== 'undefined';
|
|
5
|
+
};
|
|
6
|
+
export var globalThisExists = function () {
|
|
7
|
+
return typeof globalThis !== 'undefined';
|
|
8
|
+
};
|
|
9
|
+
export var windowExists = function () {
|
|
10
|
+
return typeof window !== 'undefined';
|
|
11
|
+
};
|
|
12
|
+
export var documentExists = function () {
|
|
13
|
+
return typeof document !== 'undefined';
|
|
14
|
+
};
|
|
15
|
+
export var processExists = function () {
|
|
16
|
+
return typeof process !== 'undefined';
|
|
17
|
+
};
|
|
18
|
+
export var keyPrefixMatch = function (object, prefix) {
|
|
19
|
+
return !!Object.keys(object).find(function (key) { return key.startsWith(prefix); });
|
|
20
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { Framework } from '../types';
|
|
4
|
+
import { reactWebDetect, reactSSRDetect } from './React';
|
|
5
|
+
import { vueWebDetect, vueSSRDetect } from './Vue';
|
|
6
|
+
import { svelteWebDetect, svelteSSRDetect } from './Svelte';
|
|
7
|
+
import { nextWebDetect, nextSSRDetect } from './Next';
|
|
8
|
+
import { nuxtWebDetect, nuxtSSRDetect } from './Nuxt';
|
|
9
|
+
import { angularWebDetect, angularSSRDetect } from './Angular';
|
|
10
|
+
import { reactNativeDetect } from './ReactNative';
|
|
11
|
+
import { expoDetect } from './Expo';
|
|
12
|
+
import { webDetect } from './Web';
|
|
13
|
+
// These are in the order of detection where when both are detectable, the early Framework will be reported
|
|
14
|
+
var detectionMap = [
|
|
15
|
+
// First, detect mobile
|
|
16
|
+
{ platform: Framework.Expo, detectionMethod: expoDetect },
|
|
17
|
+
{ platform: Framework.ReactNative, detectionMethod: reactNativeDetect },
|
|
18
|
+
// Next, detect web frameworks
|
|
19
|
+
{ platform: Framework.NextJs, detectionMethod: nextWebDetect },
|
|
20
|
+
{ platform: Framework.Nuxt, detectionMethod: nuxtWebDetect },
|
|
21
|
+
{ platform: Framework.Angular, detectionMethod: angularWebDetect },
|
|
22
|
+
{ platform: Framework.React, detectionMethod: reactWebDetect },
|
|
23
|
+
{ platform: Framework.VueJs, detectionMethod: vueWebDetect },
|
|
24
|
+
{ platform: Framework.Svelte, detectionMethod: svelteWebDetect },
|
|
25
|
+
{ platform: Framework.WebUnknown, detectionMethod: webDetect },
|
|
26
|
+
// Last, detect ssr frameworks
|
|
27
|
+
{ platform: Framework.NextJsSSR, detectionMethod: nextSSRDetect },
|
|
28
|
+
{ platform: Framework.NuxtSSR, detectionMethod: nuxtSSRDetect },
|
|
29
|
+
{ platform: Framework.ReactSSR, detectionMethod: reactSSRDetect },
|
|
30
|
+
{ platform: Framework.VueJsSSR, detectionMethod: vueSSRDetect },
|
|
31
|
+
{ platform: Framework.AngularSSR, detectionMethod: angularSSRDetect },
|
|
32
|
+
{ platform: Framework.SvelteSSR, detectionMethod: svelteSSRDetect },
|
|
33
|
+
];
|
|
34
|
+
export function detect() {
|
|
35
|
+
var _a;
|
|
36
|
+
return (((_a = detectionMap.find(function (detectionEntry) { return detectionEntry.detectionMethod(); })) === null || _a === void 0 ? void 0 : _a.platform) || Framework.ServerSideUnknown);
|
|
37
|
+
}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import { CustomUserAgentDetails, Framework } from './types';
|
|
2
|
+
import { UserAgent as AWSUserAgent } from '@aws-sdk/types';
|
|
3
|
+
declare class PlatformBuilder {
|
|
2
4
|
userAgent: string;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
export declare const
|
|
5
|
+
get framework(): Framework;
|
|
6
|
+
get isReactNative(): boolean;
|
|
7
|
+
observeFrameworkChanges(fcn: () => void): void;
|
|
8
|
+
}
|
|
9
|
+
export declare const Platform: PlatformBuilder;
|
|
10
|
+
export declare const getAmplifyUserAgent: ({ category, action, framework, }?: CustomUserAgentDetails) => AWSUserAgent;
|
|
11
|
+
export declare const getAmplifyUserAgentString: (customUserAgentDetails?: CustomUserAgentDetails) => string;
|
|
12
|
+
export {};
|
|
@@ -1,27 +1,65 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
4
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
5
|
+
if (!m) return o;
|
|
6
|
+
var i = m.call(o), r, ar = [], e;
|
|
7
|
+
try {
|
|
8
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
9
|
+
}
|
|
10
|
+
catch (error) { e = { error: error }; }
|
|
11
|
+
finally {
|
|
12
|
+
try {
|
|
13
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
14
|
+
}
|
|
15
|
+
finally { if (e) throw e.error; }
|
|
16
|
+
}
|
|
17
|
+
return ar;
|
|
10
18
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
import { Framework } from './types';
|
|
20
|
+
import { version } from './version';
|
|
21
|
+
import { detectFramework, observeFrameworkChanges } from './detectFramework';
|
|
22
|
+
var BASE_USER_AGENT = "aws-amplify";
|
|
23
|
+
var PlatformBuilder = /** @class */ (function () {
|
|
24
|
+
function PlatformBuilder() {
|
|
25
|
+
this.userAgent = "".concat(BASE_USER_AGENT, "/").concat(version);
|
|
26
|
+
}
|
|
27
|
+
Object.defineProperty(PlatformBuilder.prototype, "framework", {
|
|
28
|
+
get: function () {
|
|
29
|
+
return detectFramework();
|
|
30
|
+
},
|
|
31
|
+
enumerable: false,
|
|
32
|
+
configurable: true
|
|
33
|
+
});
|
|
34
|
+
Object.defineProperty(PlatformBuilder.prototype, "isReactNative", {
|
|
35
|
+
get: function () {
|
|
36
|
+
return this.framework === Framework.ReactNative;
|
|
37
|
+
},
|
|
38
|
+
enumerable: false,
|
|
39
|
+
configurable: true
|
|
40
|
+
});
|
|
41
|
+
PlatformBuilder.prototype.observeFrameworkChanges = function (fcn) {
|
|
42
|
+
observeFrameworkChanges(fcn);
|
|
43
|
+
};
|
|
44
|
+
return PlatformBuilder;
|
|
45
|
+
}());
|
|
46
|
+
export var Platform = new PlatformBuilder();
|
|
47
|
+
export var getAmplifyUserAgent = function (_a) {
|
|
48
|
+
var _b = _a === void 0 ? {} : _a, category = _b.category, action = _b.action, framework = _b.framework;
|
|
49
|
+
var userAgent = [[BASE_USER_AGENT, version]];
|
|
50
|
+
if (category) {
|
|
51
|
+
userAgent.push([category, action]);
|
|
23
52
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
53
|
+
userAgent.push(['framework', detectFramework()]);
|
|
54
|
+
return userAgent;
|
|
55
|
+
};
|
|
56
|
+
export var getAmplifyUserAgentString = function (customUserAgentDetails) {
|
|
57
|
+
var userAgent = getAmplifyUserAgent(customUserAgentDetails);
|
|
58
|
+
var userAgentString = userAgent
|
|
59
|
+
.map(function (_a) {
|
|
60
|
+
var _b = __read(_a, 2), agentKey = _b[0], agentValue = _b[1];
|
|
61
|
+
return "".concat(agentKey, "/").concat(agentValue);
|
|
62
|
+
})
|
|
63
|
+
.join(' ');
|
|
64
|
+
return userAgentString;
|
|
27
65
|
};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
export declare enum Framework {
|
|
2
|
+
WebUnknown = "0",
|
|
3
|
+
React = "1",
|
|
4
|
+
NextJs = "2",
|
|
5
|
+
Angular = "3",
|
|
6
|
+
VueJs = "4",
|
|
7
|
+
Nuxt = "5",
|
|
8
|
+
Svelte = "6",
|
|
9
|
+
ServerSideUnknown = "100",
|
|
10
|
+
ReactSSR = "101",
|
|
11
|
+
NextJsSSR = "102",
|
|
12
|
+
AngularSSR = "103",
|
|
13
|
+
VueJsSSR = "104",
|
|
14
|
+
NuxtSSR = "105",
|
|
15
|
+
SvelteSSR = "106",
|
|
16
|
+
ReactNative = "201",
|
|
17
|
+
Expo = "202"
|
|
18
|
+
}
|
|
19
|
+
export declare enum Category {
|
|
20
|
+
API = "api",
|
|
21
|
+
Auth = "auth",
|
|
22
|
+
Analytics = "analytics",
|
|
23
|
+
DataStore = "datastore",
|
|
24
|
+
Geo = "geo",
|
|
25
|
+
InAppMessaging = "inappmessaging",
|
|
26
|
+
Interactions = "interactions",
|
|
27
|
+
Predictions = "predictions",
|
|
28
|
+
PubSub = "pubsub",
|
|
29
|
+
PushNotification = "pushnotification",
|
|
30
|
+
Storage = "storage"
|
|
31
|
+
}
|
|
32
|
+
export declare enum AnalyticsAction {
|
|
33
|
+
Record = "1",
|
|
34
|
+
UpdateEndpoint = "2"
|
|
35
|
+
}
|
|
36
|
+
export declare enum ApiAction {
|
|
37
|
+
GraphQl = "1",
|
|
38
|
+
Get = "2",
|
|
39
|
+
Post = "3",
|
|
40
|
+
Put = "4",
|
|
41
|
+
Patch = "5",
|
|
42
|
+
Del = "6",
|
|
43
|
+
Head = "7"
|
|
44
|
+
}
|
|
45
|
+
export declare enum AuthAction {
|
|
46
|
+
FederatedSignIn = "30"
|
|
47
|
+
}
|
|
48
|
+
export declare enum DataStoreAction {
|
|
49
|
+
Subscribe = "1",
|
|
50
|
+
GraphQl = "2"
|
|
51
|
+
}
|
|
52
|
+
export declare enum GeoAction {
|
|
53
|
+
None = "0"
|
|
54
|
+
}
|
|
55
|
+
export declare enum InAppMessagingAction {
|
|
56
|
+
None = "0"
|
|
57
|
+
}
|
|
58
|
+
export declare enum InteractionsAction {
|
|
59
|
+
None = "0"
|
|
60
|
+
}
|
|
61
|
+
export declare enum PredictionsAction {
|
|
62
|
+
Convert = "1",
|
|
63
|
+
Identify = "2",
|
|
64
|
+
Interpret = "3"
|
|
65
|
+
}
|
|
66
|
+
export declare enum PubSubAction {
|
|
67
|
+
Subscribe = "1"
|
|
68
|
+
}
|
|
69
|
+
export declare enum PushNotificationAction {
|
|
70
|
+
None = "0"
|
|
71
|
+
}
|
|
72
|
+
export declare enum StorageAction {
|
|
73
|
+
Put = "1",
|
|
74
|
+
Get = "2",
|
|
75
|
+
List = "3",
|
|
76
|
+
Copy = "4",
|
|
77
|
+
Remove = "5",
|
|
78
|
+
GetProperties = "6"
|
|
79
|
+
}
|
|
80
|
+
type ActionMap = {
|
|
81
|
+
[Category.Auth]: AuthAction;
|
|
82
|
+
[Category.API]: ApiAction;
|
|
83
|
+
[Category.Analytics]: AnalyticsAction;
|
|
84
|
+
[Category.DataStore]: DataStoreAction;
|
|
85
|
+
[Category.Geo]: GeoAction;
|
|
86
|
+
[Category.InAppMessaging]: InAppMessagingAction;
|
|
87
|
+
[Category.Interactions]: InteractionsAction;
|
|
88
|
+
[Category.Predictions]: PredictionsAction;
|
|
89
|
+
[Category.PubSub]: PubSubAction;
|
|
90
|
+
[Category.PushNotification]: PushNotificationAction;
|
|
91
|
+
[Category.Storage]: StorageAction;
|
|
92
|
+
};
|
|
93
|
+
type UserAgentDetailsWithCategory<T extends Category> = CustomUserAgentDetailsBase & {
|
|
94
|
+
category: T;
|
|
95
|
+
action: T extends keyof ActionMap ? ActionMap[T] : never;
|
|
96
|
+
};
|
|
97
|
+
type CustomUserAgentDetailsBase = {
|
|
98
|
+
framework?: Framework;
|
|
99
|
+
};
|
|
100
|
+
export type CustomUserAgentDetails = (CustomUserAgentDetailsBase & {
|
|
101
|
+
category?: never;
|
|
102
|
+
action?: never;
|
|
103
|
+
}) | UserAgentDetailsWithCategory<Category.API> | UserAgentDetailsWithCategory<Category.Auth> | UserAgentDetailsWithCategory<Category.Analytics> | UserAgentDetailsWithCategory<Category.DataStore> | UserAgentDetailsWithCategory<Category.Geo> | UserAgentDetailsWithCategory<Category.Interactions> | UserAgentDetailsWithCategory<Category.InAppMessaging> | UserAgentDetailsWithCategory<Category.Predictions> | UserAgentDetailsWithCategory<Category.PubSub> | UserAgentDetailsWithCategory<Category.PushNotification> | UserAgentDetailsWithCategory<Category.Storage>;
|
|
104
|
+
export {};
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
export var Framework;
|
|
4
|
+
(function (Framework) {
|
|
5
|
+
// < 100 - Web frameworks
|
|
6
|
+
Framework["WebUnknown"] = "0";
|
|
7
|
+
Framework["React"] = "1";
|
|
8
|
+
Framework["NextJs"] = "2";
|
|
9
|
+
Framework["Angular"] = "3";
|
|
10
|
+
Framework["VueJs"] = "4";
|
|
11
|
+
Framework["Nuxt"] = "5";
|
|
12
|
+
Framework["Svelte"] = "6";
|
|
13
|
+
// 100s - Server side frameworks
|
|
14
|
+
Framework["ServerSideUnknown"] = "100";
|
|
15
|
+
Framework["ReactSSR"] = "101";
|
|
16
|
+
Framework["NextJsSSR"] = "102";
|
|
17
|
+
Framework["AngularSSR"] = "103";
|
|
18
|
+
Framework["VueJsSSR"] = "104";
|
|
19
|
+
Framework["NuxtSSR"] = "105";
|
|
20
|
+
Framework["SvelteSSR"] = "106";
|
|
21
|
+
// 200s - Mobile framework
|
|
22
|
+
Framework["ReactNative"] = "201";
|
|
23
|
+
Framework["Expo"] = "202";
|
|
24
|
+
})(Framework || (Framework = {}));
|
|
25
|
+
export var Category;
|
|
26
|
+
(function (Category) {
|
|
27
|
+
Category["API"] = "api";
|
|
28
|
+
Category["Auth"] = "auth";
|
|
29
|
+
Category["Analytics"] = "analytics";
|
|
30
|
+
Category["DataStore"] = "datastore";
|
|
31
|
+
Category["Geo"] = "geo";
|
|
32
|
+
Category["InAppMessaging"] = "inappmessaging";
|
|
33
|
+
Category["Interactions"] = "interactions";
|
|
34
|
+
Category["Predictions"] = "predictions";
|
|
35
|
+
Category["PubSub"] = "pubsub";
|
|
36
|
+
Category["PushNotification"] = "pushnotification";
|
|
37
|
+
Category["Storage"] = "storage";
|
|
38
|
+
})(Category || (Category = {}));
|
|
39
|
+
export var AnalyticsAction;
|
|
40
|
+
(function (AnalyticsAction) {
|
|
41
|
+
AnalyticsAction["Record"] = "1";
|
|
42
|
+
AnalyticsAction["UpdateEndpoint"] = "2";
|
|
43
|
+
})(AnalyticsAction || (AnalyticsAction = {}));
|
|
44
|
+
export var ApiAction;
|
|
45
|
+
(function (ApiAction) {
|
|
46
|
+
ApiAction["GraphQl"] = "1";
|
|
47
|
+
ApiAction["Get"] = "2";
|
|
48
|
+
ApiAction["Post"] = "3";
|
|
49
|
+
ApiAction["Put"] = "4";
|
|
50
|
+
ApiAction["Patch"] = "5";
|
|
51
|
+
ApiAction["Del"] = "6";
|
|
52
|
+
ApiAction["Head"] = "7";
|
|
53
|
+
})(ApiAction || (ApiAction = {}));
|
|
54
|
+
export var AuthAction;
|
|
55
|
+
(function (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
|
+
AuthAction["FederatedSignIn"] = "30";
|
|
86
|
+
// CurrentUserInfo = '31',
|
|
87
|
+
// RememberDevice = '32',
|
|
88
|
+
// ForgetDevice = '33',
|
|
89
|
+
// FetchDevices = '34',
|
|
90
|
+
})(AuthAction || (AuthAction = {}));
|
|
91
|
+
export var DataStoreAction;
|
|
92
|
+
(function (DataStoreAction) {
|
|
93
|
+
DataStoreAction["Subscribe"] = "1";
|
|
94
|
+
DataStoreAction["GraphQl"] = "2";
|
|
95
|
+
})(DataStoreAction || (DataStoreAction = {}));
|
|
96
|
+
export var GeoAction;
|
|
97
|
+
(function (GeoAction) {
|
|
98
|
+
GeoAction["None"] = "0";
|
|
99
|
+
})(GeoAction || (GeoAction = {}));
|
|
100
|
+
export var InAppMessagingAction;
|
|
101
|
+
(function (InAppMessagingAction) {
|
|
102
|
+
InAppMessagingAction["None"] = "0";
|
|
103
|
+
})(InAppMessagingAction || (InAppMessagingAction = {}));
|
|
104
|
+
export var InteractionsAction;
|
|
105
|
+
(function (InteractionsAction) {
|
|
106
|
+
InteractionsAction["None"] = "0";
|
|
107
|
+
})(InteractionsAction || (InteractionsAction = {}));
|
|
108
|
+
export var PredictionsAction;
|
|
109
|
+
(function (PredictionsAction) {
|
|
110
|
+
PredictionsAction["Convert"] = "1";
|
|
111
|
+
PredictionsAction["Identify"] = "2";
|
|
112
|
+
PredictionsAction["Interpret"] = "3";
|
|
113
|
+
})(PredictionsAction || (PredictionsAction = {}));
|
|
114
|
+
export var PubSubAction;
|
|
115
|
+
(function (PubSubAction) {
|
|
116
|
+
PubSubAction["Subscribe"] = "1";
|
|
117
|
+
})(PubSubAction || (PubSubAction = {}));
|
|
118
|
+
export var PushNotificationAction;
|
|
119
|
+
(function (PushNotificationAction) {
|
|
120
|
+
PushNotificationAction["None"] = "0";
|
|
121
|
+
})(PushNotificationAction || (PushNotificationAction = {}));
|
|
122
|
+
export var StorageAction;
|
|
123
|
+
(function (StorageAction) {
|
|
124
|
+
StorageAction["Put"] = "1";
|
|
125
|
+
StorageAction["Get"] = "2";
|
|
126
|
+
StorageAction["List"] = "3";
|
|
127
|
+
StorageAction["Copy"] = "4";
|
|
128
|
+
StorageAction["Remove"] = "5";
|
|
129
|
+
StorageAction["GetProperties"] = "6";
|
|
130
|
+
})(StorageAction || (StorageAction = {}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "5.
|
|
1
|
+
export declare const version = "5.3.0";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// generated by genversion
|
|
2
|
-
export var version = '5.
|
|
2
|
+
export var version = '5.3.0';
|
|
@@ -36,7 +36,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
|
-
import { isClockSkewError } from '
|
|
39
|
+
import { isClockSkewError } from './isClockSkewError';
|
|
40
40
|
/**
|
|
41
41
|
* Get retry decider function
|
|
42
42
|
* @param errorParser Function to load JavaScript error from HTTP response
|
|
@@ -9,5 +9,6 @@ export interface SigningOptions {
|
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* Middleware that SigV4 signs request with AWS credentials, and correct system clock offset.
|
|
12
|
+
* This middleware is expected to be placed after retry middleware.
|
|
12
13
|
*/
|
|
13
14
|
export declare const signingMiddleware: ({ credentials, region, service, }: SigningOptions) => (next: MiddlewareHandler<HttpRequest, HttpResponse>) => (request: HttpRequest) => Promise<HttpResponse>;
|
|
@@ -36,12 +36,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
|
-
import { isClockSkewError } from '../../utils/isClockSkewError';
|
|
40
39
|
import { signRequest } from './signer/signatureV4';
|
|
41
40
|
import { getSkewCorrectedDate } from './utils/getSkewCorrectedDate';
|
|
42
41
|
import { getUpdatedSystemClockOffset } from './utils/getUpdatedSystemClockOffset';
|
|
43
42
|
/**
|
|
44
43
|
* Middleware that SigV4 signs request with AWS credentials, and correct system clock offset.
|
|
44
|
+
* This middleware is expected to be placed after retry middleware.
|
|
45
45
|
*/
|
|
46
46
|
export var signingMiddleware = function (_a) {
|
|
47
47
|
var credentials = _a.credentials, region = _a.region, service = _a.service;
|
|
@@ -49,7 +49,7 @@ export var signingMiddleware = function (_a) {
|
|
|
49
49
|
return function (next) {
|
|
50
50
|
return function signingMiddleware(request) {
|
|
51
51
|
return __awaiter(this, void 0, void 0, function () {
|
|
52
|
-
var signRequestOptions, signedRequest, response,
|
|
52
|
+
var signRequestOptions, signedRequest, response, dateString;
|
|
53
53
|
return __generator(this, function (_a) {
|
|
54
54
|
switch (_a.label) {
|
|
55
55
|
case 0:
|
|
@@ -63,35 +63,22 @@ export var signingMiddleware = function (_a) {
|
|
|
63
63
|
return [4 /*yield*/, signRequest(request, signRequestOptions)];
|
|
64
64
|
case 1:
|
|
65
65
|
signedRequest = _a.sent();
|
|
66
|
-
_a.label = 2;
|
|
67
|
-
case 2:
|
|
68
|
-
_a.trys.push([2, 4, , 5]);
|
|
69
66
|
return [4 /*yield*/, next(signedRequest)];
|
|
70
|
-
case
|
|
67
|
+
case 2:
|
|
71
68
|
response = _a.sent();
|
|
72
|
-
|
|
73
|
-
case 4:
|
|
74
|
-
error_1 = _a.sent();
|
|
75
|
-
dateString = shouldUseServerTime(error_1)
|
|
76
|
-
? error_1.ServerTime
|
|
77
|
-
: getDateHeader(error_1.$response);
|
|
69
|
+
dateString = getDateHeader(response);
|
|
78
70
|
if (dateString) {
|
|
79
71
|
currentSystemClockOffset = getUpdatedSystemClockOffset(Date.parse(dateString), currentSystemClockOffset);
|
|
80
72
|
}
|
|
81
|
-
|
|
82
|
-
case 5: return [2 /*return*/];
|
|
73
|
+
return [2 /*return*/, response];
|
|
83
74
|
}
|
|
84
75
|
});
|
|
85
76
|
});
|
|
86
77
|
};
|
|
87
78
|
};
|
|
88
79
|
};
|
|
89
|
-
var shouldUseServerTime = function (_a) {
|
|
90
|
-
var ServerTime = _a.ServerTime, Code = _a.Code;
|
|
91
|
-
return ServerTime && isClockSkewError(Code);
|
|
92
|
-
};
|
|
93
80
|
var getDateHeader = function (_a) {
|
|
94
|
-
var _b;
|
|
95
|
-
var
|
|
96
|
-
return (_b = headers === null || headers === void 0 ? void 0 : headers.date) !== null && _b !== void 0 ? _b : headers === null || headers === void 0 ? void 0 : headers.Date;
|
|
81
|
+
var _b, _c;
|
|
82
|
+
var _d = _a === void 0 ? {} : _a, headers = _d.headers;
|
|
83
|
+
return (_c = (_b = headers === null || headers === void 0 ? void 0 : headers.date) !== null && _b !== void 0 ? _b : headers === null || headers === void 0 ? void 0 : headers.Date) !== null && _c !== void 0 ? _c : headers === null || headers === void 0 ? void 0 : headers['x-amz-date'];
|
|
97
84
|
};
|
package/lib-esm/index.d.ts
CHANGED
|
@@ -17,7 +17,8 @@ export { ServiceWorker } from './ServiceWorker';
|
|
|
17
17
|
export { ICredentials } from './types';
|
|
18
18
|
export { StorageHelper, MemoryStorage } from './StorageHelper';
|
|
19
19
|
export { UniversalStorage } from './UniversalStorage';
|
|
20
|
-
export { Platform, getAmplifyUserAgent } from './Platform';
|
|
20
|
+
export { Platform, getAmplifyUserAgent, getAmplifyUserAgentString, } from './Platform';
|
|
21
|
+
export { ApiAction, AuthAction, AnalyticsAction, Category, CustomUserAgentDetails, DataStoreAction, Framework, GeoAction, InteractionsAction, InAppMessagingAction, PredictionsAction, PubSubAction, PushNotificationAction, StorageAction, } from './Platform/types';
|
|
21
22
|
export { INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER, USER_AGENT_HEADER, } from './constants';
|
|
22
23
|
export declare const Constants: {
|
|
23
24
|
userAgent: string;
|
package/lib-esm/index.js
CHANGED
|
@@ -19,7 +19,8 @@ export { Credentials, CredentialsClass } from './Credentials';
|
|
|
19
19
|
export { ServiceWorker } from './ServiceWorker';
|
|
20
20
|
export { StorageHelper, MemoryStorage } from './StorageHelper';
|
|
21
21
|
export { UniversalStorage } from './UniversalStorage';
|
|
22
|
-
export { Platform, getAmplifyUserAgent } from './Platform';
|
|
22
|
+
export { Platform, getAmplifyUserAgent, getAmplifyUserAgentString, } from './Platform';
|
|
23
|
+
export { ApiAction, AuthAction, AnalyticsAction, Category, DataStoreAction, Framework, GeoAction, InteractionsAction, InAppMessagingAction, PredictionsAction, PubSubAction, PushNotificationAction, StorageAction, } from './Platform/types';
|
|
23
24
|
export { INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER, USER_AGENT_HEADER, } from './constants';
|
|
24
25
|
export var Constants = {
|
|
25
26
|
userAgent: Platform.userAgent,
|