@aws-amplify/core 6.0.1-console-preview.67f944e.0 → 6.0.1-console-preview.0bbe168.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/Pinpoint/getInAppMessages.d.ts +1 -1
- package/lib/AwsClients/Pinpoint/putEvents.d.ts +1 -1
- package/lib/AwsClients/Pinpoint/updateEndpoint.d.ts +1 -1
- package/lib/BackgroundProcessManager/BackgroundManagerNotOpenError.d.ts +3 -0
- package/lib/BackgroundProcessManager/BackgroundManagerNotOpenError.js +28 -0
- package/{lib-esm/Util → lib/BackgroundProcessManager}/BackgroundProcessManager.d.ts +1 -23
- package/lib/{Util → BackgroundProcessManager}/BackgroundProcessManager.js +13 -56
- package/lib/BackgroundProcessManager/index.d.ts +1 -0
- package/lib/BackgroundProcessManager/index.js +7 -0
- package/lib/BackgroundProcessManager/types.d.ts +41 -0
- package/lib/BackgroundProcessManager/types.js +23 -0
- package/lib/Hub/index.js +2 -2
- package/lib/Logger/ConsoleLogger.js +2 -2
- package/lib/{Util → Mutex}/Mutex.d.ts +2 -15
- package/lib/{Util → Mutex}/Mutex.js +2 -1
- package/lib/Mutex/index.d.ts +1 -0
- package/lib/Mutex/index.js +7 -0
- package/lib/Mutex/types.d.ts +13 -0
- package/lib/Mutex/types.js +4 -0
- package/lib/Platform/version.d.ts +1 -1
- package/lib/Platform/version.js +1 -1
- package/lib/Reachability/Reachability.d.ts +6 -0
- package/lib/Reachability/Reachability.js +29 -0
- package/lib/Reachability/Reachability.native.d.ts +6 -0
- package/lib/{Util → Reachability}/Reachability.native.js +8 -10
- package/lib/Reachability/index.d.ts +1 -0
- package/lib/Reachability/index.js +7 -0
- package/lib/Reachability/types.d.ts +3 -0
- package/lib/Reachability/types.js +4 -0
- package/lib/ServiceWorker/ServiceWorker.js +2 -2
- package/lib/{Signer.js → Signer/Signer.js} +3 -3
- package/lib/Signer/index.d.ts +1 -0
- package/lib/Signer/index.js +7 -0
- package/lib/clients/middleware/retry/jitteredBackoff.js +2 -2
- package/lib/{Util/Constants.d.ts → constants.d.ts} +0 -2
- package/lib/{Util/Constants.js → constants.js} +1 -6
- package/lib/libraryUtils.d.ts +7 -6
- package/lib/libraryUtils.js +37 -49
- package/lib/providers/pinpoint/apis/updateEndpoint.d.ts +1 -1
- package/lib/providers/pinpoint/apis/updateEndpoint.js +7 -5
- package/lib/providers/pinpoint/types/pinpoint.d.ts +1 -0
- package/lib/singleton/Auth/utils/index.js +2 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/core.d.ts +4 -1
- package/lib/utils/convert/base64/base64Decoder.d.ts +2 -0
- package/lib/utils/convert/base64/base64Decoder.js +11 -0
- package/lib/utils/convert/base64/base64Encoder.d.ts +2 -0
- package/lib/utils/convert/base64/base64Encoder.js +18 -0
- package/lib/utils/convert/base64/bytesToString.d.ts +1 -0
- package/lib/utils/convert/base64/bytesToString.js +9 -0
- package/lib/utils/convert/index.d.ts +2 -0
- package/lib/utils/convert/index.js +9 -0
- package/lib/utils/convert/types.d.ts +9 -0
- package/lib/utils/convert/types.js +4 -0
- package/lib/utils/generateRandomString.d.ts +1 -0
- package/lib/utils/generateRandomString.js +14 -0
- package/lib/utils/globalHelpers/index.d.ts +3 -0
- package/lib/utils/globalHelpers/index.js +50 -0
- package/lib/utils/globalHelpers/index.native.d.ts +5 -0
- package/lib/utils/globalHelpers/index.native.js +27 -0
- package/lib/utils/index.d.ts +6 -0
- package/lib/utils/index.js +21 -0
- package/lib/utils/isBrowser.d.ts +1 -0
- package/lib/utils/isBrowser.js +9 -0
- package/lib/utils/isWebWorker.d.ts +1 -0
- package/lib/utils/isWebWorker.js +14 -0
- package/lib/utils/retry/NonRetryableError.d.ts +4 -0
- package/lib/utils/retry/NonRetryableError.js +30 -0
- package/lib/utils/retry/constants.d.ts +1 -0
- package/lib/utils/retry/constants.js +6 -0
- package/lib/utils/retry/index.d.ts +5 -0
- package/lib/utils/retry/index.js +15 -0
- package/lib/utils/retry/isNonRetryableError.d.ts +2 -0
- package/lib/utils/retry/isNonRetryableError.js +10 -0
- package/lib/utils/retry/jitteredBackoff.d.ts +6 -0
- package/lib/utils/retry/jitteredBackoff.js +20 -0
- package/lib/utils/retry/jitteredExponentialRetry.d.ts +5 -0
- package/lib/utils/retry/jitteredExponentialRetry.js +17 -0
- package/lib/utils/retry/retry.d.ts +6 -0
- package/lib/{Util/Retry.js → utils/retry/retry.js} +6 -57
- package/lib/utils/urlSafeDecode.d.ts +1 -0
- package/lib/{Util/StringUtils.js → utils/urlSafeDecode.js} +2 -9
- package/lib/utils/urlSafeEncode.d.ts +1 -0
- package/lib/utils/urlSafeEncode.js +12 -0
- package/lib-esm/AwsClients/Pinpoint/getInAppMessages.d.ts +1 -1
- package/lib-esm/AwsClients/Pinpoint/putEvents.d.ts +1 -1
- package/lib-esm/AwsClients/Pinpoint/updateEndpoint.d.ts +1 -1
- package/lib-esm/BackgroundProcessManager/BackgroundManagerNotOpenError.d.ts +3 -0
- package/lib-esm/BackgroundProcessManager/BackgroundManagerNotOpenError.js +25 -0
- package/{lib/Util → lib-esm/BackgroundProcessManager}/BackgroundProcessManager.d.ts +1 -23
- package/lib-esm/{Util → BackgroundProcessManager}/BackgroundProcessManager.js +4 -47
- package/lib-esm/BackgroundProcessManager/index.d.ts +1 -0
- package/lib-esm/BackgroundProcessManager/index.js +3 -0
- package/lib-esm/BackgroundProcessManager/types.d.ts +41 -0
- package/lib-esm/BackgroundProcessManager/types.js +20 -0
- package/lib-esm/Hub/index.js +1 -1
- package/lib-esm/Logger/ConsoleLogger.js +1 -1
- package/lib-esm/{Util → Mutex}/Mutex.d.ts +2 -15
- package/lib-esm/{Util → Mutex}/Mutex.js +1 -1
- package/lib-esm/Mutex/index.d.ts +1 -0
- package/lib-esm/Mutex/index.js +3 -0
- package/lib-esm/Mutex/types.d.ts +13 -0
- package/lib-esm/Mutex/types.js +3 -0
- package/lib-esm/Platform/version.d.ts +1 -1
- package/lib-esm/Platform/version.js +1 -1
- package/lib-esm/Reachability/Reachability.d.ts +6 -0
- package/lib-esm/Reachability/Reachability.js +26 -0
- package/lib-esm/Reachability/Reachability.native.d.ts +6 -0
- package/lib-esm/{Util → Reachability}/Reachability.native.js +6 -6
- package/lib-esm/Reachability/index.d.ts +1 -0
- package/lib-esm/Reachability/index.js +3 -0
- package/lib-esm/Reachability/types.d.ts +3 -0
- package/lib-esm/Reachability/types.js +3 -0
- package/lib-esm/ServiceWorker/ServiceWorker.js +1 -1
- package/lib-esm/{Signer.js → Signer/Signer.js} +2 -2
- package/lib-esm/Signer/index.d.ts +1 -0
- package/lib-esm/Signer/index.js +3 -0
- package/lib-esm/clients/middleware/retry/jitteredBackoff.js +1 -1
- package/lib-esm/{Util/Constants.d.ts → constants.d.ts} +0 -2
- package/lib-esm/{Util/Constants.js → constants.js} +0 -5
- package/lib-esm/libraryUtils.d.ts +7 -6
- package/lib-esm/libraryUtils.js +8 -8
- package/lib-esm/providers/pinpoint/apis/updateEndpoint.d.ts +1 -1
- package/lib-esm/providers/pinpoint/apis/updateEndpoint.js +7 -5
- package/lib-esm/providers/pinpoint/types/pinpoint.d.ts +1 -0
- package/lib-esm/singleton/Auth/utils/index.js +2 -1
- package/lib-esm/tsconfig.tsbuildinfo +1 -1
- package/lib-esm/types/core.d.ts +4 -1
- package/lib-esm/utils/convert/base64/base64Decoder.d.ts +2 -0
- package/lib-esm/utils/convert/base64/base64Decoder.js +8 -0
- package/lib-esm/utils/convert/base64/base64Encoder.d.ts +2 -0
- package/lib-esm/utils/convert/base64/base64Encoder.js +15 -0
- package/lib-esm/utils/convert/base64/bytesToString.d.ts +1 -0
- package/lib-esm/utils/convert/base64/bytesToString.js +5 -0
- package/lib-esm/utils/convert/index.d.ts +2 -0
- package/lib-esm/utils/convert/index.js +4 -0
- package/lib-esm/utils/convert/types.d.ts +9 -0
- package/lib-esm/utils/convert/types.js +3 -0
- package/lib-esm/utils/generateRandomString.d.ts +1 -0
- package/lib-esm/utils/generateRandomString.js +10 -0
- package/lib-esm/utils/globalHelpers/index.d.ts +3 -0
- package/lib-esm/utils/globalHelpers/index.js +44 -0
- package/lib-esm/utils/globalHelpers/index.native.d.ts +5 -0
- package/lib-esm/utils/globalHelpers/index.native.js +21 -0
- package/lib-esm/utils/index.d.ts +6 -0
- package/lib-esm/utils/index.js +8 -0
- package/lib-esm/utils/isBrowser.d.ts +1 -0
- package/lib-esm/utils/isBrowser.js +5 -0
- package/lib-esm/utils/isWebWorker.d.ts +1 -0
- package/lib-esm/utils/isWebWorker.js +10 -0
- package/lib-esm/utils/retry/NonRetryableError.d.ts +4 -0
- package/lib-esm/utils/retry/NonRetryableError.js +27 -0
- package/lib-esm/utils/retry/constants.d.ts +1 -0
- package/lib-esm/utils/retry/constants.js +3 -0
- package/lib-esm/utils/retry/index.d.ts +5 -0
- package/lib-esm/utils/retry/index.js +7 -0
- package/lib-esm/utils/retry/isNonRetryableError.d.ts +2 -0
- package/lib-esm/utils/retry/isNonRetryableError.js +6 -0
- package/lib-esm/utils/retry/jitteredBackoff.d.ts +6 -0
- package/lib-esm/utils/retry/jitteredBackoff.js +16 -0
- package/lib-esm/utils/retry/jitteredExponentialRetry.d.ts +5 -0
- package/lib-esm/utils/retry/jitteredExponentialRetry.js +13 -0
- package/lib-esm/utils/retry/retry.d.ts +6 -0
- package/lib-esm/{Util/Retry.js → utils/retry/retry.js} +4 -52
- package/lib-esm/{Util/StringUtils.d.ts → utils/urlSafeDecode.d.ts} +0 -1
- package/lib-esm/{Util/StringUtils.js → utils/urlSafeDecode.js} +0 -6
- package/{lib/Util/StringUtils.d.ts → lib-esm/utils/urlSafeEncode.d.ts} +0 -1
- package/lib-esm/utils/urlSafeEncode.js +8 -0
- package/package.json +7 -4
- package/src/BackgroundProcessManager/BackgroundManagerNotOpenError.ts +8 -0
- package/src/{Util → BackgroundProcessManager}/BackgroundProcessManager.ts +4 -58
- package/src/BackgroundProcessManager/index.ts +4 -0
- package/src/BackgroundProcessManager/types.ts +49 -0
- package/src/Hub/index.ts +1 -1
- package/src/Logger/ConsoleLogger.ts +1 -1
- package/src/{Util → Mutex}/Mutex.ts +2 -20
- package/src/Mutex/index.ts +4 -0
- package/src/Mutex/types.ts +20 -0
- package/src/Platform/version.ts +1 -1
- package/src/{Util → Reachability}/Reachability.native.ts +4 -11
- package/src/Reachability/Reachability.ts +35 -0
- package/src/Reachability/index.ts +4 -0
- package/src/Reachability/types.ts +6 -0
- package/src/ServiceWorker/ServiceWorker.ts +1 -1
- package/src/{Signer.ts → Signer/Signer.ts} +2 -2
- package/src/Signer/index.ts +4 -0
- package/src/clients/middleware/retry/jitteredBackoff.ts +1 -1
- package/src/{Util/Constants.ts → constants.ts} +0 -5
- package/src/libraryUtils.ts +16 -35
- package/src/providers/pinpoint/apis/updateEndpoint.ts +19 -3
- package/src/providers/pinpoint/types/pinpoint.ts +1 -0
- package/src/singleton/Auth/utils/index.ts +2 -1
- package/src/types/core.ts +4 -1
- package/src/utils/convert/base64/base64Decoder.ts +11 -0
- package/src/utils/convert/base64/base64Encoder.ts +18 -0
- package/src/utils/convert/base64/bytesToString.ts +6 -0
- package/src/utils/convert/index.ts +5 -0
- package/src/utils/convert/types.ts +17 -0
- package/src/utils/generateRandomString.ts +16 -0
- package/src/utils/globalHelpers/index.native.ts +28 -0
- package/src/utils/globalHelpers/index.ts +54 -0
- package/src/utils/index.ts +15 -0
- package/src/utils/isBrowser.ts +5 -0
- package/src/utils/isWebWorker.ts +13 -0
- package/src/utils/retry/NonRetryableError.ts +9 -0
- package/src/utils/retry/constants.ts +4 -0
- package/src/utils/retry/index.ts +8 -0
- package/src/utils/retry/isNonRetryableError.ts +9 -0
- package/src/utils/retry/jitteredBackoff.ts +21 -0
- package/src/utils/retry/jitteredExponentialRetry.ts +18 -0
- package/src/{Util/Retry.ts → utils/retry/retry.ts} +4 -44
- package/src/{Util/StringUtils.ts → utils/urlSafeDecode.ts} +0 -6
- package/src/utils/urlSafeEncode.ts +9 -0
- package/lib/Util/JS.d.ts +0 -29
- package/lib/Util/JS.js +0 -214
- package/lib/Util/Reachability.d.ts +0 -13
- package/lib/Util/Reachability.js +0 -69
- package/lib/Util/Reachability.native.d.ts +0 -12
- package/lib/Util/Retry.d.ts +0 -21
- package/lib/Util/index.d.ts +0 -7
- package/lib/Util/index.js +0 -31
- package/lib-esm/Util/JS.d.ts +0 -29
- package/lib-esm/Util/JS.js +0 -199
- package/lib-esm/Util/Reachability.d.ts +0 -13
- package/lib-esm/Util/Reachability.js +0 -64
- package/lib-esm/Util/Reachability.native.d.ts +0 -12
- package/lib-esm/Util/Retry.d.ts +0 -21
- package/lib-esm/Util/index.d.ts +0 -7
- package/lib-esm/Util/index.js +0 -9
- package/src/Util/JS.ts +0 -255
- package/src/Util/Reachability.ts +0 -58
- package/src/Util/index.ts +0 -23
- /package/lib/{Util → Signer}/DateUtils.d.ts +0 -0
- /package/lib/{Util → Signer}/DateUtils.js +0 -0
- /package/lib/{Signer.d.ts → Signer/Signer.d.ts} +0 -0
- /package/lib-esm/{Util → Signer}/DateUtils.d.ts +0 -0
- /package/lib-esm/{Util → Signer}/DateUtils.js +0 -0
- /package/lib-esm/{Signer.d.ts → Signer/Signer.d.ts} +0 -0
- /package/src/{Util → Signer}/DateUtils.ts +0 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { getBtoa } from '../../globalHelpers';
|
|
4
|
+
import { bytesToString } from './bytesToString';
|
|
5
|
+
export var base64Encoder = {
|
|
6
|
+
convert: function (input, _a) {
|
|
7
|
+
var _b = _a === void 0 ? { urlSafe: false } : _a, urlSafe = _b.urlSafe;
|
|
8
|
+
var inputStr = typeof input === 'string' ? input : bytesToString(input);
|
|
9
|
+
var encodedStr = getBtoa()(inputStr);
|
|
10
|
+
// see details about the char replacing at https://datatracker.ietf.org/doc/html/rfc4648#section-5
|
|
11
|
+
return urlSafe
|
|
12
|
+
? encodedStr.replace(/\+/g, '-').replace(/\//g, '_')
|
|
13
|
+
: encodedStr;
|
|
14
|
+
},
|
|
15
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function bytesToString(input: Uint8Array): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface Base64EncoderConvertOptions {
|
|
2
|
+
urlSafe: boolean;
|
|
3
|
+
}
|
|
4
|
+
export interface Base64Encoder {
|
|
5
|
+
convert(input: Uint8Array | string, options?: Base64EncoderConvertOptions): string;
|
|
6
|
+
}
|
|
7
|
+
export interface Base64Decoder {
|
|
8
|
+
convert(input: string): string;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const generateRandomString: (length: number) => string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
export var generateRandomString = function (length) {
|
|
4
|
+
var STATE_CHARSET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
5
|
+
var result = '';
|
|
6
|
+
for (var i = 0; i < length; i++) {
|
|
7
|
+
result += STATE_CHARSET.charAt(Math.floor(Math.random() * STATE_CHARSET.length));
|
|
8
|
+
}
|
|
9
|
+
return result;
|
|
10
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { AmplifyError } from '../../errors';
|
|
4
|
+
export var getCrypto = function () {
|
|
5
|
+
if (typeof window === 'object' && typeof window.crypto === 'object') {
|
|
6
|
+
return window.crypto;
|
|
7
|
+
}
|
|
8
|
+
// Next.js global polyfill
|
|
9
|
+
if (typeof crypto === 'object') {
|
|
10
|
+
return crypto;
|
|
11
|
+
}
|
|
12
|
+
throw new AmplifyError({
|
|
13
|
+
name: 'MissingPolyfill',
|
|
14
|
+
message: 'Cannot resolve the `crypto` function from the environment.',
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
export var getBtoa = function () {
|
|
18
|
+
// browser
|
|
19
|
+
if (typeof window !== 'undefined' && typeof window.btoa === 'function') {
|
|
20
|
+
return window.btoa;
|
|
21
|
+
}
|
|
22
|
+
// Next.js global polyfill
|
|
23
|
+
if (typeof btoa === 'function') {
|
|
24
|
+
return btoa;
|
|
25
|
+
}
|
|
26
|
+
throw new AmplifyError({
|
|
27
|
+
name: 'Base64EncoderError',
|
|
28
|
+
message: 'Cannot resolve the `btoa` function from the environment.',
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
export var getAtob = function () {
|
|
32
|
+
// browser
|
|
33
|
+
if (typeof window !== 'undefined' && typeof window.atob === 'function') {
|
|
34
|
+
return window.atob;
|
|
35
|
+
}
|
|
36
|
+
// Next.js global polyfill
|
|
37
|
+
if (typeof atob === 'function') {
|
|
38
|
+
return atob;
|
|
39
|
+
}
|
|
40
|
+
throw new AmplifyError({
|
|
41
|
+
name: 'Base64EncoderError',
|
|
42
|
+
message: 'Cannot resolve the `atob` function from the environment.',
|
|
43
|
+
});
|
|
44
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import 'react-native-get-random-values';
|
|
4
|
+
import { encode, decode } from 'base-64';
|
|
5
|
+
import { AmplifyError } from '../../errors';
|
|
6
|
+
export var getCrypto = function () {
|
|
7
|
+
if (typeof crypto !== 'undefined' &&
|
|
8
|
+
typeof crypto.getRandomValues === 'function') {
|
|
9
|
+
return crypto;
|
|
10
|
+
}
|
|
11
|
+
throw new AmplifyError({
|
|
12
|
+
name: 'MissingPolyfill',
|
|
13
|
+
message: 'Cannot resolve the `crypto` function from the environment.',
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
export var getBtoa = function () {
|
|
17
|
+
return encode;
|
|
18
|
+
};
|
|
19
|
+
export var getAtob = function () {
|
|
20
|
+
return decode;
|
|
21
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { generateRandomString } from './generateRandomString';
|
|
2
|
+
export { isBrowser } from './isBrowser';
|
|
3
|
+
export { isWebWorker } from './isWebWorker';
|
|
4
|
+
export { NonRetryableError, isNonRetryableError, jitteredBackoff, jitteredExponentialRetry, retry, } from './retry';
|
|
5
|
+
export { urlSafeDecode } from './urlSafeDecode';
|
|
6
|
+
export { urlSafeEncode } from './urlSafeEncode';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
export { generateRandomString } from './generateRandomString';
|
|
4
|
+
export { isBrowser } from './isBrowser';
|
|
5
|
+
export { isWebWorker } from './isWebWorker';
|
|
6
|
+
export { NonRetryableError, isNonRetryableError, jitteredBackoff, jitteredExponentialRetry, retry, } from './retry';
|
|
7
|
+
export { urlSafeDecode } from './urlSafeDecode';
|
|
8
|
+
export { urlSafeEncode } from './urlSafeEncode';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isBrowser: () => boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isWebWorker: () => boolean;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
export var isWebWorker = function () {
|
|
4
|
+
if (typeof self === 'undefined') {
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
var selfContext = self;
|
|
8
|
+
return (typeof selfContext.WorkerGlobalScope !== 'undefined' &&
|
|
9
|
+
self instanceof selfContext.WorkerGlobalScope);
|
|
10
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
var __extends = (this && this.__extends) || (function () {
|
|
4
|
+
var extendStatics = function (d, b) {
|
|
5
|
+
extendStatics = Object.setPrototypeOf ||
|
|
6
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
7
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
8
|
+
return extendStatics(d, b);
|
|
9
|
+
};
|
|
10
|
+
return function (d, b) {
|
|
11
|
+
if (typeof b !== "function" && b !== null)
|
|
12
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
13
|
+
extendStatics(d, b);
|
|
14
|
+
function __() { this.constructor = d; }
|
|
15
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
16
|
+
};
|
|
17
|
+
})();
|
|
18
|
+
var NonRetryableError = /** @class */ (function (_super) {
|
|
19
|
+
__extends(NonRetryableError, _super);
|
|
20
|
+
function NonRetryableError(message) {
|
|
21
|
+
var _this = _super.call(this, message) || this;
|
|
22
|
+
_this.nonRetryable = true;
|
|
23
|
+
return _this;
|
|
24
|
+
}
|
|
25
|
+
return NonRetryableError;
|
|
26
|
+
}(Error));
|
|
27
|
+
export { NonRetryableError };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const MAX_DELAY_MS: number;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { NonRetryableError } from './NonRetryableError';
|
|
2
|
+
export { isNonRetryableError } from './isNonRetryableError';
|
|
3
|
+
export { jitteredBackoff } from './jitteredBackoff';
|
|
4
|
+
export { jitteredExponentialRetry } from './jitteredExponentialRetry';
|
|
5
|
+
export { retry } from './retry';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
export { NonRetryableError } from './NonRetryableError';
|
|
4
|
+
export { isNonRetryableError } from './isNonRetryableError';
|
|
5
|
+
export { jitteredBackoff } from './jitteredBackoff';
|
|
6
|
+
export { jitteredExponentialRetry } from './jitteredExponentialRetry';
|
|
7
|
+
export { retry } from './retry';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { MAX_DELAY_MS } from './constants';
|
|
4
|
+
/**
|
|
5
|
+
* @private
|
|
6
|
+
* Internal use of Amplify only
|
|
7
|
+
*/
|
|
8
|
+
export function jitteredBackoff(maxDelayMs) {
|
|
9
|
+
if (maxDelayMs === void 0) { maxDelayMs = MAX_DELAY_MS; }
|
|
10
|
+
var BASE_TIME_MS = 100;
|
|
11
|
+
var JITTER_FACTOR = 100;
|
|
12
|
+
return function (attempt) {
|
|
13
|
+
var delay = Math.pow(2, attempt) * BASE_TIME_MS + JITTER_FACTOR * Math.random();
|
|
14
|
+
return delay > maxDelayMs ? false : delay;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { MAX_DELAY_MS } from './constants';
|
|
4
|
+
import { jitteredBackoff } from './jitteredBackoff';
|
|
5
|
+
import { retry } from './retry';
|
|
6
|
+
/**
|
|
7
|
+
* @private
|
|
8
|
+
* Internal use of Amplify only
|
|
9
|
+
*/
|
|
10
|
+
export var jitteredExponentialRetry = function (functionToRetry, args, maxDelayMs, onTerminate) {
|
|
11
|
+
if (maxDelayMs === void 0) { maxDelayMs = MAX_DELAY_MS; }
|
|
12
|
+
return retry(functionToRetry, args, jitteredBackoff(maxDelayMs), onTerminate);
|
|
13
|
+
};
|
|
@@ -1,18 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
extendStatics = Object.setPrototypeOf ||
|
|
4
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
-
return extendStatics(d, b);
|
|
7
|
-
};
|
|
8
|
-
return function (d, b) {
|
|
9
|
-
if (typeof b !== "function" && b !== null)
|
|
10
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
-
extendStatics(d, b);
|
|
12
|
-
function __() { this.constructor = d; }
|
|
13
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
-
};
|
|
15
|
-
})();
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
16
3
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
17
4
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
5
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -74,22 +61,9 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
74
61
|
}
|
|
75
62
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
76
63
|
};
|
|
77
|
-
import { ConsoleLogger as Logger } from '
|
|
64
|
+
import { ConsoleLogger as Logger } from '../../Logger/ConsoleLogger';
|
|
65
|
+
import { isNonRetryableError } from './isNonRetryableError';
|
|
78
66
|
var logger = new Logger('Util');
|
|
79
|
-
var NonRetryableError = /** @class */ (function (_super) {
|
|
80
|
-
__extends(NonRetryableError, _super);
|
|
81
|
-
function NonRetryableError(message) {
|
|
82
|
-
var _this = _super.call(this, message) || this;
|
|
83
|
-
_this.nonRetryable = true;
|
|
84
|
-
return _this;
|
|
85
|
-
}
|
|
86
|
-
return NonRetryableError;
|
|
87
|
-
}(Error));
|
|
88
|
-
export { NonRetryableError };
|
|
89
|
-
export var isNonRetryableError = function (obj) {
|
|
90
|
-
var key = 'nonRetryable';
|
|
91
|
-
return obj && obj[key];
|
|
92
|
-
};
|
|
93
67
|
/**
|
|
94
68
|
* @private
|
|
95
69
|
* Internal use of Amplify only
|
|
@@ -174,25 +148,3 @@ export function retry(functionToRetry, args, delayFn, onTerminate) {
|
|
|
174
148
|
});
|
|
175
149
|
});
|
|
176
150
|
}
|
|
177
|
-
var MAX_DELAY_MS = 5 * 60 * 1000;
|
|
178
|
-
/**
|
|
179
|
-
* @private
|
|
180
|
-
* Internal use of Amplify only
|
|
181
|
-
*/
|
|
182
|
-
export function jitteredBackoff(maxDelayMs) {
|
|
183
|
-
if (maxDelayMs === void 0) { maxDelayMs = MAX_DELAY_MS; }
|
|
184
|
-
var BASE_TIME_MS = 100;
|
|
185
|
-
var JITTER_FACTOR = 100;
|
|
186
|
-
return function (attempt) {
|
|
187
|
-
var delay = Math.pow(2, attempt) * BASE_TIME_MS + JITTER_FACTOR * Math.random();
|
|
188
|
-
return delay > maxDelayMs ? false : delay;
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* @private
|
|
193
|
-
* Internal use of Amplify only
|
|
194
|
-
*/
|
|
195
|
-
export var jitteredExponentialRetry = function (functionToRetry, args, maxDelayMs, onTerminate) {
|
|
196
|
-
if (maxDelayMs === void 0) { maxDelayMs = MAX_DELAY_MS; }
|
|
197
|
-
return retry(functionToRetry, args, jitteredBackoff(maxDelayMs), onTerminate);
|
|
198
|
-
};
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
export function urlSafeEncode(str) {
|
|
4
|
-
return str
|
|
5
|
-
.split('')
|
|
6
|
-
.map(function (char) { return char.charCodeAt(0).toString(16).padStart(2, '0'); })
|
|
7
|
-
.join('');
|
|
8
|
-
}
|
|
9
3
|
export function urlSafeDecode(hex) {
|
|
10
4
|
var matchArr = hex.match(/.{2}/g) || [];
|
|
11
5
|
return matchArr.map(function (char) { return String.fromCharCode(parseInt(char, 16)); }).join('');
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
export function urlSafeEncode(str) {
|
|
4
|
+
return str
|
|
5
|
+
.split('')
|
|
6
|
+
.map(function (char) { return char.charCodeAt(0).toString(16).padStart(2, '0'); })
|
|
7
|
+
.join('');
|
|
8
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-amplify/core",
|
|
3
|
-
"version": "6.0.1-console-preview.
|
|
3
|
+
"version": "6.0.1-console-preview.0bbe168.0+0bbe168",
|
|
4
4
|
"description": "Core category of aws-amplify",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"module": "./lib-esm/index.js",
|
|
@@ -64,18 +64,21 @@
|
|
|
64
64
|
"@aws-sdk/types": "3.398.0",
|
|
65
65
|
"@smithy/util-hex-encoding": "2.0.0",
|
|
66
66
|
"js-cookie": "^2.2.1",
|
|
67
|
+
"rxjs": "^7.8.1",
|
|
67
68
|
"tslib": "^2.5.0",
|
|
68
|
-
"uuid": "^9.0.0"
|
|
69
|
-
"zen-observable-ts": "0.8.19"
|
|
69
|
+
"uuid": "^9.0.0"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@react-native-async-storage/async-storage": "^1.17.12",
|
|
73
73
|
"@react-native-community/netinfo": "4.7.0",
|
|
74
|
+
"@types/base-64": "1.0.0",
|
|
74
75
|
"@types/js-cookie": "^2.2.7",
|
|
75
76
|
"@types/uuid": "^9.0.0",
|
|
77
|
+
"base-64": "1.0.0",
|
|
76
78
|
"find": "^0.2.7",
|
|
77
79
|
"genversion": "^2.2.0",
|
|
78
80
|
"react-native": "^0.68.7",
|
|
81
|
+
"react-native-get-random-values": "1.9.0",
|
|
79
82
|
"typescript": "5.0.2"
|
|
80
83
|
},
|
|
81
84
|
"size-limit": [
|
|
@@ -182,5 +185,5 @@
|
|
|
182
185
|
"lib-esm"
|
|
183
186
|
]
|
|
184
187
|
},
|
|
185
|
-
"gitHead": "
|
|
188
|
+
"gitHead": "0bbe168c66929877174b331c71f7666bb16529d6"
|
|
186
189
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
export class BackgroundManagerNotOpenError extends Error {
|
|
5
|
+
constructor(message: string) {
|
|
6
|
+
super(`BackgroundManagerNotOpenError: ${message}`);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { BackgroundManagerNotOpenError } from './BackgroundManagerNotOpenError';
|
|
5
|
+
import { BackgroundProcessManagerState, JobEntry } from './types';
|
|
6
|
+
|
|
3
7
|
/**
|
|
4
8
|
* @private For internal Amplify use.
|
|
5
9
|
*
|
|
@@ -415,61 +419,3 @@ export class BackgroundProcessManager {
|
|
|
415
419
|
this._state = BackgroundProcessManagerState.Open;
|
|
416
420
|
}
|
|
417
421
|
}
|
|
418
|
-
|
|
419
|
-
/**
|
|
420
|
-
*
|
|
421
|
-
*/
|
|
422
|
-
export class BackgroundManagerNotOpenError extends Error {
|
|
423
|
-
constructor(message: string) {
|
|
424
|
-
super(`BackgroundManagerNotOpenError: ${message}`);
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
/**
|
|
429
|
-
* All possible states a `BackgroundProcessManager` instance can be in.
|
|
430
|
-
*/
|
|
431
|
-
export enum BackgroundProcessManagerState {
|
|
432
|
-
/**
|
|
433
|
-
* Accepting new jobs.
|
|
434
|
-
*/
|
|
435
|
-
Open = 'Open',
|
|
436
|
-
|
|
437
|
-
/**
|
|
438
|
-
* Not accepting new jobs. Waiting for submitted jobs to complete.
|
|
439
|
-
*/
|
|
440
|
-
Closing = 'Closing',
|
|
441
|
-
|
|
442
|
-
/**
|
|
443
|
-
* Not accepting new jobs. All submitted jobs are complete.
|
|
444
|
-
*/
|
|
445
|
-
Closed = 'Closed',
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
/**
|
|
449
|
-
* Completely internal to `BackgroundProcessManager`, and describes the structure of
|
|
450
|
-
* an entry in the jobs registry.
|
|
451
|
-
*/
|
|
452
|
-
type JobEntry = {
|
|
453
|
-
/**
|
|
454
|
-
* The underlying promise provided by the job function to wait for.
|
|
455
|
-
*/
|
|
456
|
-
promise: Promise<any>;
|
|
457
|
-
|
|
458
|
-
/**
|
|
459
|
-
* Request the termination of the job.
|
|
460
|
-
*/
|
|
461
|
-
terminate: () => void;
|
|
462
|
-
|
|
463
|
-
/**
|
|
464
|
-
* An object provided by the caller that can be used to identify the description
|
|
465
|
-
* of the job, which can otherwise be unclear from the `promise` and
|
|
466
|
-
* `terminate` function. The `description` can be a string. (May be extended
|
|
467
|
-
* later to also support object refs.)
|
|
468
|
-
*
|
|
469
|
-
* Useful for troubleshooting why a manager is waiting for long periods of time
|
|
470
|
-
* on `close()`.
|
|
471
|
-
*/
|
|
472
|
-
description?: string;
|
|
473
|
-
};
|
|
474
|
-
|
|
475
|
-
const process = new BackgroundProcessManager();
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* All possible states a `BackgroundProcessManager` instance can be in.
|
|
6
|
+
*/
|
|
7
|
+
export enum BackgroundProcessManagerState {
|
|
8
|
+
/**
|
|
9
|
+
* Accepting new jobs.
|
|
10
|
+
*/
|
|
11
|
+
Open = 'Open',
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Not accepting new jobs. Waiting for submitted jobs to complete.
|
|
15
|
+
*/
|
|
16
|
+
Closing = 'Closing',
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Not accepting new jobs. All submitted jobs are complete.
|
|
20
|
+
*/
|
|
21
|
+
Closed = 'Closed',
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Completely internal to `BackgroundProcessManager`, and describes the structure of
|
|
26
|
+
* an entry in the jobs registry.
|
|
27
|
+
*/
|
|
28
|
+
export type JobEntry = {
|
|
29
|
+
/**
|
|
30
|
+
* The underlying promise provided by the job function to wait for.
|
|
31
|
+
*/
|
|
32
|
+
promise: Promise<any>;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Request the termination of the job.
|
|
36
|
+
*/
|
|
37
|
+
terminate: () => void;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* An object provided by the caller that can be used to identify the description
|
|
41
|
+
* of the job, which can otherwise be unclear from the `promise` and
|
|
42
|
+
* `terminate` function. The `description` can be a string. (May be extended
|
|
43
|
+
* later to also support object refs.)
|
|
44
|
+
*
|
|
45
|
+
* Useful for troubleshooting why a manager is waiting for long periods of time
|
|
46
|
+
* on `close()`.
|
|
47
|
+
*/
|
|
48
|
+
description?: string;
|
|
49
|
+
};
|
package/src/Hub/index.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { ConsoleLogger as Logger } from '../Logger';
|
|
5
|
-
import { NO_HUBCALLBACK_PROVIDED_EXCEPTION } from '../
|
|
5
|
+
import { NO_HUBCALLBACK_PROVIDED_EXCEPTION } from '../constants';
|
|
6
6
|
import { AmplifyError } from '../errors';
|
|
7
7
|
import {
|
|
8
8
|
AmplifyChannel,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { LoggingProvider, InputLogEvent } from '../types';
|
|
5
|
-
import { AWS_CLOUDWATCH_CATEGORY } from '../
|
|
5
|
+
import { AWS_CLOUDWATCH_CATEGORY } from '../constants';
|
|
6
6
|
import { Logger } from './logger-interface';
|
|
7
7
|
|
|
8
8
|
const LOG_LEVELS: Record<string, number> = {
|