@aws-amplify/core 5.8.2 → 6.0.1-console-preview.f63250a.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/README.md +3 -0
- package/lib/Amplify.d.ts +18 -17
- package/lib/Amplify.js +9 -0
- package/lib/AwsClients/CognitoIdentity/base.d.ts +3 -10
- package/lib/AwsClients/CognitoIdentity/getCredentialsForIdentity.d.ts +3 -17
- package/lib/AwsClients/CognitoIdentity/getCredentialsForIdentity.js +8 -8
- package/lib/AwsClients/CognitoIdentity/getId.d.ts +3 -17
- package/lib/AwsClients/Pinpoint/base.d.ts +2 -10
- package/lib/AwsClients/Pinpoint/getInAppMessages.d.ts +3 -17
- package/lib/AwsClients/Pinpoint/getInAppMessages.js +1 -1
- package/lib/AwsClients/Pinpoint/putEvents.d.ts +3 -17
- package/lib/AwsClients/Pinpoint/putEvents.js +6 -0
- package/lib/AwsClients/Pinpoint/updateEndpoint.d.ts +3 -17
- package/lib/AwsClients/Pinpoint/updateEndpoint.js +2 -2
- package/lib/Cache/AsyncStorageCache.d.ts +154 -0
- package/lib/Cache/AsyncStorageCache.js +744 -0
- package/lib/Cache/BrowserStorageCache.d.ts +166 -0
- package/lib/Cache/BrowserStorageCache.js +469 -0
- package/lib/Cache/InMemoryCache.d.ts +129 -0
- package/lib/Cache/InMemoryCache.js +349 -0
- package/lib/Cache/StorageCache.d.ts +39 -0
- package/lib/Cache/StorageCache.js +121 -0
- package/lib/Cache/Utils/CacheList.d.ts +89 -0
- package/lib/Cache/Utils/CacheList.js +196 -0
- package/lib/Cache/Utils/CacheUtils.d.ts +25 -0
- package/lib/Cache/Utils/CacheUtils.js +88 -0
- package/lib/Cache/Utils/index.d.ts +2 -0
- package/lib/Cache/Utils/index.js +16 -0
- package/lib/Cache/reactnative.d.ts +3 -0
- package/lib/Cache/reactnative.js +8 -0
- package/lib/Cache/types/Cache.d.ts +55 -0
- package/lib/Cache/types/Cache.js +4 -0
- package/lib/Cache/types/index.d.ts +1 -0
- package/lib/Cache/types/index.js +19 -0
- package/lib/ClientDevice/android.js +3 -2
- package/lib/ClientDevice/ios.d.ts +2 -2
- package/lib/ClientDevice/ios.js +3 -2
- package/lib/ClientDevice/reactnative.js +3 -2
- package/lib/Credentials.d.ts +1 -1
- package/lib/Credentials.js +2 -1
- package/lib/Errors.d.ts +19 -0
- package/lib/Errors.js +50 -1
- package/lib/Hub.js +1 -0
- package/lib/I18n/I18n.d.ts +29 -9
- package/lib/I18n/I18n.js +30 -5
- package/lib/I18n/index.d.ts +18 -5
- package/lib/I18n/index.js +35 -5
- package/lib/I18n/types.d.ts +4 -1
- package/lib/I18n/types.js +3 -0
- package/lib/JS.d.ts +6 -6
- package/lib/Logger/ConsoleLogger.d.ts +11 -11
- package/lib/OAuthHelper/GoogleOAuth.js +2 -1
- package/lib/Platform/detectFramework.js +2 -1
- package/lib/Platform/detection/Next.d.ts +1 -1
- package/lib/Platform/detection/React.js +1 -0
- package/lib/Platform/version.d.ts +1 -1
- package/lib/Platform/version.js +1 -1
- package/lib/Providers/AWSCloudWatchProvider.d.ts +2 -2
- package/lib/Providers/AWSCloudWatchProvider.js +35 -12
- package/lib/RNComponents/index.d.ts +1 -1
- package/lib/RNComponents/reactnative.js +3 -2
- package/lib/ServiceWorker/ServiceWorker.d.ts +4 -4
- package/lib/ServiceWorker/ServiceWorker.js +37 -11
- package/lib/Signer.d.ts +14 -1
- package/lib/StorageHelper/cookieStorage.d.ts +13 -0
- package/lib/StorageHelper/cookieStorage.js +167 -0
- package/lib/StorageHelper/inMemoryStorage.d.ts +10 -0
- package/lib/StorageHelper/inMemoryStorage.js +82 -0
- package/lib/StorageHelper/index.d.ts +7 -3
- package/lib/StorageHelper/index.js +9 -1
- package/lib/StorageHelper/localStorage.d.ts +32 -0
- package/lib/StorageHelper/localStorage.js +114 -0
- package/lib/StorageHelper/reactnative.d.ts +71 -1
- package/lib/StorageHelper/reactnative.js +154 -10
- package/lib/StorageHelper/sessionStorage.d.ts +32 -0
- package/lib/StorageHelper/sessionStorage.js +114 -0
- package/lib/UniversalStorage/index.d.ts +2 -2
- package/lib/Util/BackgroundProcessManager.d.ts +2 -2
- package/lib/Util/BackgroundProcessManager.js +1 -0
- package/lib/Util/DateUtils.d.ts +12 -1
- package/lib/Util/Reachability.js +7 -5
- package/lib/Util/Reachability.native.d.ts +3 -2
- package/lib/Util/StringUtils.js +3 -10
- package/lib/Util/errors/AssertError.d.ts +2 -0
- package/lib/Util/errors/AssertError.js +11 -0
- package/lib/clients/middleware/retry/defaultRetryDecider.d.ts +1 -1
- package/lib/clients/middleware/retry/defaultRetryDecider.js +17 -13
- package/lib/clients/middleware/retry/isClockSkewError.js +1 -1
- package/lib/clients/middleware/retry/middleware.d.ts +1 -1
- package/lib/clients/middleware/retry/middleware.js +13 -13
- package/lib/clients/middleware/signing/signer/signatureV4/utils/dataHashHelpers.js +1 -1
- package/lib/clients/serde/responseInfo.js +1 -1
- package/lib/clients/types/aws.d.ts +4 -0
- package/lib/clients/types/index.d.ts +1 -1
- package/lib/constants.d.ts +7 -0
- package/lib/constants.js +9 -1
- package/lib/index.d.ts +18 -4
- package/lib/index.js +32 -5
- package/lib/parseAWSExports.d.ts +1 -1
- package/lib/singleton/Auth/index.d.ts +30 -0
- package/lib/singleton/Auth/index.js +133 -0
- package/lib/singleton/Auth/types.d.ts +95 -0
- package/lib/singleton/Auth/types.js +6 -0
- package/lib/singleton/Auth/utils/index.d.ts +5 -0
- package/lib/singleton/Auth/utils/index.js +52 -0
- package/lib/singleton/Storage/types.d.ts +14 -0
- package/lib/singleton/Storage/types.js +4 -0
- package/lib/singleton/index.d.ts +46 -0
- package/lib/singleton/index.js +147 -0
- package/lib/singleton/types.d.ts +21 -0
- package/lib/singleton/types.js +4 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/types.d.ts +31 -1
- package/lib/types/types.js +2 -0
- package/lib-esm/Amplify.d.ts +18 -17
- package/lib-esm/Amplify.js +9 -0
- package/lib-esm/AwsClients/CognitoIdentity/base.d.ts +3 -10
- package/lib-esm/AwsClients/CognitoIdentity/getCredentialsForIdentity.d.ts +3 -17
- package/lib-esm/AwsClients/CognitoIdentity/getCredentialsForIdentity.js +8 -8
- package/lib-esm/AwsClients/CognitoIdentity/getId.d.ts +3 -17
- package/lib-esm/AwsClients/Pinpoint/base.d.ts +2 -10
- package/lib-esm/AwsClients/Pinpoint/getInAppMessages.d.ts +3 -17
- package/lib-esm/AwsClients/Pinpoint/getInAppMessages.js +1 -1
- package/lib-esm/AwsClients/Pinpoint/putEvents.d.ts +3 -17
- package/lib-esm/AwsClients/Pinpoint/putEvents.js +6 -0
- package/lib-esm/AwsClients/Pinpoint/updateEndpoint.d.ts +3 -17
- package/lib-esm/AwsClients/Pinpoint/updateEndpoint.js +2 -2
- package/lib-esm/Cache/AsyncStorageCache.d.ts +154 -0
- package/lib-esm/Cache/AsyncStorageCache.js +737 -0
- package/lib-esm/Cache/BrowserStorageCache.d.ts +166 -0
- package/lib-esm/Cache/BrowserStorageCache.js +466 -0
- package/lib-esm/Cache/InMemoryCache.d.ts +129 -0
- package/lib-esm/Cache/InMemoryCache.js +346 -0
- package/lib-esm/Cache/StorageCache.d.ts +39 -0
- package/lib-esm/Cache/StorageCache.js +118 -0
- package/lib-esm/Cache/Utils/CacheList.d.ts +89 -0
- package/lib-esm/Cache/Utils/CacheList.js +194 -0
- package/lib-esm/Cache/Utils/CacheUtils.d.ts +25 -0
- package/lib-esm/Cache/Utils/CacheUtils.js +81 -0
- package/lib-esm/Cache/Utils/index.d.ts +2 -0
- package/lib-esm/Cache/Utils/index.js +4 -0
- package/lib-esm/Cache/reactnative.d.ts +3 -0
- package/lib-esm/Cache/reactnative.js +6 -0
- package/lib-esm/Cache/types/Cache.d.ts +55 -0
- package/lib-esm/Cache/types/Cache.js +3 -0
- package/lib-esm/Cache/types/index.d.ts +1 -0
- package/lib-esm/Cache/types/index.js +3 -0
- package/lib-esm/ClientDevice/android.js +1 -0
- package/lib-esm/ClientDevice/ios.d.ts +2 -2
- package/lib-esm/ClientDevice/ios.js +1 -0
- package/lib-esm/ClientDevice/reactnative.js +1 -0
- package/lib-esm/Credentials.d.ts +1 -1
- package/lib-esm/Credentials.js +2 -1
- package/lib-esm/Errors.d.ts +19 -0
- package/lib-esm/Errors.js +49 -0
- package/lib-esm/Hub.js +1 -0
- package/lib-esm/I18n/I18n.d.ts +29 -9
- package/lib-esm/I18n/I18n.js +30 -5
- package/lib-esm/I18n/index.d.ts +18 -5
- package/lib-esm/I18n/index.js +35 -5
- package/lib-esm/I18n/types.d.ts +4 -1
- package/lib-esm/I18n/types.js +3 -0
- package/lib-esm/JS.d.ts +6 -6
- package/lib-esm/Logger/ConsoleLogger.d.ts +11 -11
- package/lib-esm/OAuthHelper/GoogleOAuth.js +2 -1
- package/lib-esm/Platform/detectFramework.js +2 -1
- package/lib-esm/Platform/detection/Next.d.ts +1 -1
- package/lib-esm/Platform/detection/React.js +1 -0
- package/lib-esm/Platform/version.d.ts +1 -1
- package/lib-esm/Platform/version.js +1 -1
- package/lib-esm/Providers/AWSCloudWatchProvider.d.ts +2 -2
- package/lib-esm/Providers/AWSCloudWatchProvider.js +33 -10
- package/lib-esm/RNComponents/index.d.ts +1 -1
- package/lib-esm/RNComponents/reactnative.js +1 -0
- package/lib-esm/ServiceWorker/ServiceWorker.d.ts +4 -4
- package/lib-esm/ServiceWorker/ServiceWorker.js +37 -11
- package/lib-esm/Signer.d.ts +14 -1
- package/lib-esm/StorageHelper/cookieStorage.d.ts +13 -0
- package/lib-esm/StorageHelper/cookieStorage.js +141 -0
- package/lib-esm/StorageHelper/inMemoryStorage.d.ts +10 -0
- package/lib-esm/StorageHelper/inMemoryStorage.js +79 -0
- package/lib-esm/StorageHelper/index.d.ts +7 -3
- package/lib-esm/StorageHelper/index.js +4 -0
- package/lib-esm/StorageHelper/localStorage.d.ts +32 -0
- package/lib-esm/StorageHelper/localStorage.js +111 -0
- package/lib-esm/StorageHelper/reactnative.d.ts +71 -1
- package/lib-esm/StorageHelper/reactnative.js +153 -9
- package/lib-esm/StorageHelper/sessionStorage.d.ts +32 -0
- package/lib-esm/StorageHelper/sessionStorage.js +111 -0
- package/lib-esm/UniversalStorage/index.d.ts +2 -2
- package/lib-esm/Util/BackgroundProcessManager.d.ts +2 -2
- package/lib-esm/Util/BackgroundProcessManager.js +1 -0
- package/lib-esm/Util/DateUtils.d.ts +12 -1
- package/lib-esm/Util/Reachability.js +5 -3
- package/lib-esm/Util/Reachability.native.d.ts +3 -2
- package/lib-esm/Util/StringUtils.js +3 -10
- package/lib-esm/Util/errors/AssertError.d.ts +2 -0
- package/lib-esm/Util/errors/AssertError.js +7 -0
- package/lib-esm/clients/middleware/retry/defaultRetryDecider.d.ts +1 -1
- package/lib-esm/clients/middleware/retry/defaultRetryDecider.js +17 -13
- package/lib-esm/clients/middleware/retry/isClockSkewError.js +1 -1
- package/lib-esm/clients/middleware/retry/middleware.d.ts +1 -1
- package/lib-esm/clients/middleware/retry/middleware.js +13 -13
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/dataHashHelpers.js +1 -1
- package/lib-esm/clients/serde/responseInfo.js +1 -1
- package/lib-esm/clients/types/aws.d.ts +4 -0
- package/lib-esm/clients/types/index.d.ts +1 -1
- package/lib-esm/constants.d.ts +7 -0
- package/lib-esm/constants.js +8 -0
- package/lib-esm/index.d.ts +18 -4
- package/lib-esm/index.js +15 -3
- package/lib-esm/parseAWSExports.d.ts +1 -1
- package/lib-esm/singleton/Auth/index.d.ts +30 -0
- package/lib-esm/singleton/Auth/index.js +129 -0
- package/lib-esm/singleton/Auth/types.d.ts +95 -0
- package/lib-esm/singleton/Auth/types.js +5 -0
- package/lib-esm/singleton/Auth/utils/index.d.ts +5 -0
- package/lib-esm/singleton/Auth/utils/index.js +45 -0
- package/lib-esm/singleton/Storage/types.d.ts +14 -0
- package/lib-esm/singleton/Storage/types.js +3 -0
- package/lib-esm/singleton/index.d.ts +46 -0
- package/lib-esm/singleton/index.js +143 -0
- package/lib-esm/singleton/types.d.ts +21 -0
- package/lib-esm/singleton/types.js +3 -0
- package/lib-esm/tsconfig.tsbuildinfo +1 -1
- package/lib-esm/types/types.d.ts +31 -1
- package/lib-esm/types/types.js +2 -0
- package/package.json +38 -15
- package/src/Amplify.ts +9 -3
- package/src/AwsClients/CognitoIdentity/base.ts +2 -1
- package/src/AwsClients/CognitoIdentity/getCredentialsForIdentity.ts +13 -6
- package/src/AwsClients/Pinpoint/base.ts +6 -2
- package/src/AwsClients/Pinpoint/getInAppMessages.ts +1 -1
- package/src/AwsClients/Pinpoint/putEvents.ts +6 -0
- package/src/AwsClients/Pinpoint/updateEndpoint.ts +2 -2
- package/src/Cache/AsyncStorageCache.ts +500 -0
- package/src/Cache/BrowserStorageCache.ts +517 -0
- package/src/Cache/CHANGELOG.md +1227 -0
- package/src/Cache/InMemoryCache.ts +354 -0
- package/src/Cache/StorageCache.ts +157 -0
- package/src/Cache/Utils/CacheList.ts +198 -0
- package/src/Cache/Utils/CacheUtils.ts +92 -0
- package/src/Cache/Utils/index.ts +11 -0
- package/src/Cache/reactnative.ts +9 -0
- package/src/Cache/types/Cache.ts +75 -0
- package/src/Cache/types/index.ts +4 -0
- package/src/ClientDevice/android.ts +1 -1
- package/src/ClientDevice/ios.ts +2 -2
- package/src/ClientDevice/reactnative.ts +1 -1
- package/src/Credentials.ts +19 -17
- package/src/Errors.ts +41 -0
- package/src/Hub.ts +1 -0
- package/src/I18n/I18n.ts +40 -12
- package/src/I18n/index.ts +45 -12
- package/src/I18n/types.ts +3 -0
- package/src/JS.ts +24 -17
- package/src/Logger/ConsoleLogger.ts +10 -10
- package/src/OAuthHelper/FacebookOAuth.ts +2 -2
- package/src/OAuthHelper/GoogleOAuth.ts +9 -6
- package/src/Platform/detectFramework.ts +1 -1
- package/src/Platform/detection/React.ts +5 -3
- package/src/Platform/version.ts +1 -1
- package/src/Providers/AWSCloudWatchProvider.ts +39 -14
- package/src/RNComponents/index.ts +1 -1
- package/src/RNComponents/reactnative.ts +1 -1
- package/src/ServiceWorker/ServiceWorker.ts +58 -18
- package/src/Signer.ts +22 -3
- package/src/StorageHelper/cookieStorage.ts +99 -0
- package/src/StorageHelper/inMemoryStorage.ts +32 -0
- package/src/StorageHelper/index.ts +6 -1
- package/src/StorageHelper/localStorage.ts +60 -0
- package/src/StorageHelper/reactnative.ts +94 -14
- package/src/StorageHelper/sessionStorage.ts +60 -0
- package/src/Util/BackgroundProcessManager.ts +33 -9
- package/src/Util/DateUtils.ts +14 -5
- package/src/Util/Reachability.native.ts +3 -2
- package/src/Util/Reachability.ts +9 -7
- package/src/Util/Retry.ts +2 -1
- package/src/Util/StringUtils.ts +3 -10
- package/src/Util/errors/AssertError.ts +11 -0
- package/src/clients/handlers/fetch.ts +2 -2
- package/src/clients/middleware/retry/defaultRetryDecider.ts +12 -6
- package/src/clients/middleware/retry/isClockSkewError.ts +1 -1
- package/src/clients/middleware/retry/middleware.ts +9 -9
- package/src/clients/middleware/signing/middleware.ts +1 -1
- package/src/clients/middleware/signing/signer/signatureV4/utils/dataHashHelpers.ts +1 -1
- package/src/clients/serde/responseInfo.ts +2 -1
- package/src/clients/types/aws.ts +10 -0
- package/src/clients/types/index.ts +1 -0
- package/src/constants.ts +16 -0
- package/src/global.d.ts +11 -0
- package/src/index.ts +66 -4
- package/src/parseAWSExports.ts +1 -1
- package/src/singleton/Auth/index.ts +113 -0
- package/src/singleton/Auth/types.ts +129 -0
- package/src/singleton/Auth/utils/index.ts +68 -0
- package/src/singleton/Storage/types.ts +21 -0
- package/src/singleton/index.ts +131 -0
- package/src/singleton/types.ts +48 -0
- package/src/types/types.ts +38 -1
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
13
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
14
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
15
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
16
|
+
function step(op) {
|
|
17
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
18
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
19
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
20
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
21
|
+
switch (op[0]) {
|
|
22
|
+
case 0: case 1: t = op; break;
|
|
23
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
24
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
25
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
26
|
+
default:
|
|
27
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
28
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
29
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
30
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
31
|
+
if (t[2]) _.ops.pop();
|
|
32
|
+
_.trys.pop(); continue;
|
|
33
|
+
}
|
|
34
|
+
op = body.call(thisArg, _);
|
|
35
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
36
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
import { PlatformNotSupportedError } from '../Errors';
|
|
40
|
+
var LocalStorageClass = /** @class */ (function () {
|
|
41
|
+
function LocalStorageClass() {
|
|
42
|
+
if (typeof window !== undefined) {
|
|
43
|
+
try {
|
|
44
|
+
this.storage = window === null || window === void 0 ? void 0 : window.localStorage;
|
|
45
|
+
}
|
|
46
|
+
catch (error) { }
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* This is used to set a specific item in storage
|
|
51
|
+
* @param {string} key - the key for the item
|
|
52
|
+
* @param {object} value - the value
|
|
53
|
+
* @returns {string} value that was set
|
|
54
|
+
*/
|
|
55
|
+
LocalStorageClass.prototype.setItem = function (key, value) {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
57
|
+
return __generator(this, function (_a) {
|
|
58
|
+
if (!this.storage)
|
|
59
|
+
throw PlatformNotSupportedError;
|
|
60
|
+
this.storage.setItem(key, value);
|
|
61
|
+
return [2 /*return*/];
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* This is used to get a specific key from storage
|
|
67
|
+
* @param {string} key - the key for the item
|
|
68
|
+
* This is used to clear the storage
|
|
69
|
+
* @returns {string} the data item
|
|
70
|
+
*/
|
|
71
|
+
LocalStorageClass.prototype.getItem = function (key) {
|
|
72
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
73
|
+
return __generator(this, function (_a) {
|
|
74
|
+
if (!this.storage)
|
|
75
|
+
throw PlatformNotSupportedError;
|
|
76
|
+
return [2 /*return*/, this.storage.getItem(key)];
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* This is used to remove an item from storage
|
|
82
|
+
* @param {string} key - the key being set
|
|
83
|
+
* @returns {string} value - value that was deleted
|
|
84
|
+
*/
|
|
85
|
+
LocalStorageClass.prototype.removeItem = function (key) {
|
|
86
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
87
|
+
return __generator(this, function (_a) {
|
|
88
|
+
if (!this.storage)
|
|
89
|
+
throw PlatformNotSupportedError;
|
|
90
|
+
this.storage.removeItem(key);
|
|
91
|
+
return [2 /*return*/];
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* This is used to clear the storage
|
|
97
|
+
* @returns {string} nothing
|
|
98
|
+
*/
|
|
99
|
+
LocalStorageClass.prototype.clear = function () {
|
|
100
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
101
|
+
return __generator(this, function (_a) {
|
|
102
|
+
if (!this.storage)
|
|
103
|
+
throw PlatformNotSupportedError;
|
|
104
|
+
this.storage.clear();
|
|
105
|
+
return [2 /*return*/];
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
return LocalStorageClass;
|
|
110
|
+
}());
|
|
111
|
+
export var LocalStorage = new LocalStorageClass();
|
|
@@ -1,3 +1,38 @@
|
|
|
1
|
+
import { KeyValueStorageInterface } from '../types';
|
|
2
|
+
/** @class */
|
|
3
|
+
declare class MemoryStorage {
|
|
4
|
+
static syncPromise: Promise<void> | null;
|
|
5
|
+
/**
|
|
6
|
+
* This is used to set a specific item in storage
|
|
7
|
+
* @param {string} key - the key for the item
|
|
8
|
+
* @param {object} value - the value
|
|
9
|
+
* @returns {string} value that was set
|
|
10
|
+
*/
|
|
11
|
+
static setItem(key: string, value: string): string | null | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* This is used to get a specific key from storage
|
|
14
|
+
* @param {string} key - the key for the item
|
|
15
|
+
* This is used to clear the storage
|
|
16
|
+
* @returns {string} the data item
|
|
17
|
+
*/
|
|
18
|
+
static getItem(key: string): string | null | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* This is used to remove an item from storage
|
|
21
|
+
* @param {string} key - the key being set
|
|
22
|
+
* @returns {string} value - value that was deleted
|
|
23
|
+
*/
|
|
24
|
+
static removeItem(key: string): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* This is used to clear the storage
|
|
27
|
+
* @returns {string} nothing
|
|
28
|
+
*/
|
|
29
|
+
static clear(): Record<string, string | null>;
|
|
30
|
+
/**
|
|
31
|
+
* Will sync the MemoryStorage data from AsyncStorage to storageWindow MemoryStorage
|
|
32
|
+
* @returns {void}
|
|
33
|
+
*/
|
|
34
|
+
static sync(): Promise<void>;
|
|
35
|
+
}
|
|
1
36
|
export declare class StorageHelper {
|
|
2
37
|
private storageWindow;
|
|
3
38
|
/**
|
|
@@ -9,5 +44,40 @@ export declare class StorageHelper {
|
|
|
9
44
|
* This is used to return the storage
|
|
10
45
|
* @returns {object} the storage
|
|
11
46
|
*/
|
|
12
|
-
getStorage():
|
|
47
|
+
getStorage(): typeof MemoryStorage;
|
|
48
|
+
}
|
|
49
|
+
declare class AsyncStorageClass implements KeyValueStorageInterface {
|
|
50
|
+
syncPromise: Promise<void> | null;
|
|
51
|
+
/**
|
|
52
|
+
* This is used to set a specific item in storage
|
|
53
|
+
* @param {string} key - the key for the item
|
|
54
|
+
* @param {object} value - the value
|
|
55
|
+
* @returns {string} value that was set
|
|
56
|
+
*/
|
|
57
|
+
setItem(key: string, value: string): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* This is used to get a specific key from storage
|
|
60
|
+
* @param {string} key - the key for the item
|
|
61
|
+
* This is used to clear the storage
|
|
62
|
+
* @returns {string} the data item
|
|
63
|
+
*/
|
|
64
|
+
getItem(key: string): Promise<string | null>;
|
|
65
|
+
/**
|
|
66
|
+
* This is used to remove an item from storage
|
|
67
|
+
* @param {string} key - the key being set
|
|
68
|
+
* @returns {string} value - value that was deleted
|
|
69
|
+
*/
|
|
70
|
+
removeItem(key: string): Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* This is used to clear the storage
|
|
73
|
+
* @returns {string} nothing
|
|
74
|
+
*/
|
|
75
|
+
clear(): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Will sync the MemoryStorage data from AsyncStorage to storageWindow MemoryStorage
|
|
78
|
+
* @returns {void}
|
|
79
|
+
*/
|
|
80
|
+
sync(): Promise<void>;
|
|
13
81
|
}
|
|
82
|
+
export declare const AsyncStorageKeyValue: AsyncStorageClass;
|
|
83
|
+
export {};
|
|
@@ -1,3 +1,39 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
1
37
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
38
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
39
|
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
@@ -56,20 +92,20 @@ var MemoryStorage = /** @class */ (function () {
|
|
|
56
92
|
if (!MemoryStorage.syncPromise) {
|
|
57
93
|
MemoryStorage.syncPromise = new Promise(function (res, rej) {
|
|
58
94
|
AsyncStorage.getAllKeys(function (errKeys, keys) {
|
|
95
|
+
var _a;
|
|
59
96
|
if (errKeys)
|
|
60
97
|
rej(errKeys);
|
|
61
|
-
var memoryKeys = keys.filter(function (key) {
|
|
62
|
-
return key.startsWith(MEMORY_KEY_PREFIX);
|
|
63
|
-
});
|
|
98
|
+
var memoryKeys = (_a = keys === null || keys === void 0 ? void 0 : keys.filter(function (key) { return key.startsWith(MEMORY_KEY_PREFIX); })) !== null && _a !== void 0 ? _a : [];
|
|
64
99
|
AsyncStorage.multiGet(memoryKeys, function (err, stores) {
|
|
65
100
|
if (err)
|
|
66
101
|
rej(err);
|
|
67
|
-
stores
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
102
|
+
stores &&
|
|
103
|
+
stores.map(function (result, index, store) {
|
|
104
|
+
var key = store[index][0];
|
|
105
|
+
var value = store[index][1];
|
|
106
|
+
var memoryKey = key.replace(MEMORY_KEY_PREFIX, '');
|
|
107
|
+
dataMemory[memoryKey] = value;
|
|
108
|
+
});
|
|
73
109
|
res();
|
|
74
110
|
});
|
|
75
111
|
});
|
|
@@ -98,3 +134,111 @@ var StorageHelper = /** @class */ (function () {
|
|
|
98
134
|
return StorageHelper;
|
|
99
135
|
}());
|
|
100
136
|
export { StorageHelper };
|
|
137
|
+
var AsyncStorageClass = /** @class */ (function () {
|
|
138
|
+
function AsyncStorageClass() {
|
|
139
|
+
this.syncPromise = null;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* This is used to set a specific item in storage
|
|
143
|
+
* @param {string} key - the key for the item
|
|
144
|
+
* @param {object} value - the value
|
|
145
|
+
* @returns {string} value that was set
|
|
146
|
+
*/
|
|
147
|
+
AsyncStorageClass.prototype.setItem = function (key, value) {
|
|
148
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
149
|
+
return __generator(this, function (_a) {
|
|
150
|
+
switch (_a.label) {
|
|
151
|
+
case 0:
|
|
152
|
+
if (!value) return [3 /*break*/, 2];
|
|
153
|
+
return [4 /*yield*/, AsyncStorage.setItem(MEMORY_KEY_PREFIX + key, value)];
|
|
154
|
+
case 1:
|
|
155
|
+
_a.sent();
|
|
156
|
+
dataMemory[key] = value;
|
|
157
|
+
_a.label = 2;
|
|
158
|
+
case 2: return [2 /*return*/];
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* This is used to get a specific key from storage
|
|
165
|
+
* @param {string} key - the key for the item
|
|
166
|
+
* This is used to clear the storage
|
|
167
|
+
* @returns {string} the data item
|
|
168
|
+
*/
|
|
169
|
+
AsyncStorageClass.prototype.getItem = function (key) {
|
|
170
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
171
|
+
return __generator(this, function (_a) {
|
|
172
|
+
return [2 /*return*/, Object.prototype.hasOwnProperty.call(dataMemory, key)
|
|
173
|
+
? dataMemory[key]
|
|
174
|
+
: null];
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
/**
|
|
179
|
+
* This is used to remove an item from storage
|
|
180
|
+
* @param {string} key - the key being set
|
|
181
|
+
* @returns {string} value - value that was deleted
|
|
182
|
+
*/
|
|
183
|
+
AsyncStorageClass.prototype.removeItem = function (key) {
|
|
184
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
185
|
+
return __generator(this, function (_a) {
|
|
186
|
+
switch (_a.label) {
|
|
187
|
+
case 0: return [4 /*yield*/, AsyncStorage.removeItem(MEMORY_KEY_PREFIX + key)];
|
|
188
|
+
case 1:
|
|
189
|
+
_a.sent();
|
|
190
|
+
delete dataMemory[key];
|
|
191
|
+
return [2 /*return*/];
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
};
|
|
196
|
+
/**
|
|
197
|
+
* This is used to clear the storage
|
|
198
|
+
* @returns {string} nothing
|
|
199
|
+
*/
|
|
200
|
+
AsyncStorageClass.prototype.clear = function () {
|
|
201
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
202
|
+
return __generator(this, function (_a) {
|
|
203
|
+
dataMemory = {};
|
|
204
|
+
return [2 /*return*/];
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
};
|
|
208
|
+
/**
|
|
209
|
+
* Will sync the MemoryStorage data from AsyncStorage to storageWindow MemoryStorage
|
|
210
|
+
* @returns {void}
|
|
211
|
+
*/
|
|
212
|
+
AsyncStorageClass.prototype.sync = function () {
|
|
213
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
214
|
+
return __generator(this, function (_a) {
|
|
215
|
+
if (!this.syncPromise) {
|
|
216
|
+
this.syncPromise = new Promise(function (res, rej) {
|
|
217
|
+
AsyncStorage.getAllKeys(function (errKeys, keys) {
|
|
218
|
+
var _a;
|
|
219
|
+
if (errKeys)
|
|
220
|
+
rej(errKeys);
|
|
221
|
+
var memoryKeys = (_a = keys === null || keys === void 0 ? void 0 : keys.filter(function (key) { return key.startsWith(MEMORY_KEY_PREFIX); })) !== null && _a !== void 0 ? _a : [];
|
|
222
|
+
AsyncStorage.multiGet(memoryKeys, function (err, stores) {
|
|
223
|
+
if (err)
|
|
224
|
+
rej(err);
|
|
225
|
+
stores &&
|
|
226
|
+
stores.map(function (result, index, store) {
|
|
227
|
+
var key = store[index][0];
|
|
228
|
+
var value = store[index][1];
|
|
229
|
+
var memoryKey = key.replace(MEMORY_KEY_PREFIX, '');
|
|
230
|
+
dataMemory[memoryKey] = value;
|
|
231
|
+
});
|
|
232
|
+
res();
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
return [2 /*return*/];
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
};
|
|
241
|
+
return AsyncStorageClass;
|
|
242
|
+
}());
|
|
243
|
+
// TODO: Add this to the react-native Amplify package.
|
|
244
|
+
export var AsyncStorageKeyValue = new AsyncStorageClass();
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { KeyValueStorageInterface } from '../types';
|
|
2
|
+
declare class SessionStorageClass implements KeyValueStorageInterface {
|
|
3
|
+
storage?: Storage;
|
|
4
|
+
constructor();
|
|
5
|
+
/**
|
|
6
|
+
* This is used to set a specific item in storage
|
|
7
|
+
* @param {string} key - the key for the item
|
|
8
|
+
* @param {object} value - the value
|
|
9
|
+
* @returns {string} value that was set
|
|
10
|
+
*/
|
|
11
|
+
setItem(key: string, value: string): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* This is used to get a specific key from storage
|
|
14
|
+
* @param {string} key - the key for the item
|
|
15
|
+
* This is used to clear the storage
|
|
16
|
+
* @returns {string} the data item
|
|
17
|
+
*/
|
|
18
|
+
getItem(key: string): Promise<string | null>;
|
|
19
|
+
/**
|
|
20
|
+
* This is used to remove an item from storage
|
|
21
|
+
* @param {string} key - the key being set
|
|
22
|
+
* @returns {string} value - value that was deleted
|
|
23
|
+
*/
|
|
24
|
+
removeItem(key: string): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* This is used to clear the storage
|
|
27
|
+
* @returns {string} nothing
|
|
28
|
+
*/
|
|
29
|
+
clear(): Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
export declare const SessionStorage: SessionStorageClass;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
13
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
14
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
15
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
16
|
+
function step(op) {
|
|
17
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
18
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
19
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
20
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
21
|
+
switch (op[0]) {
|
|
22
|
+
case 0: case 1: t = op; break;
|
|
23
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
24
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
25
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
26
|
+
default:
|
|
27
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
28
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
29
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
30
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
31
|
+
if (t[2]) _.ops.pop();
|
|
32
|
+
_.trys.pop(); continue;
|
|
33
|
+
}
|
|
34
|
+
op = body.call(thisArg, _);
|
|
35
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
36
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
import { PlatformNotSupportedError } from '../Errors';
|
|
40
|
+
var SessionStorageClass = /** @class */ (function () {
|
|
41
|
+
function SessionStorageClass() {
|
|
42
|
+
if (typeof window !== undefined) {
|
|
43
|
+
try {
|
|
44
|
+
this.storage = window === null || window === void 0 ? void 0 : window.sessionStorage;
|
|
45
|
+
}
|
|
46
|
+
catch (error) { }
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* This is used to set a specific item in storage
|
|
51
|
+
* @param {string} key - the key for the item
|
|
52
|
+
* @param {object} value - the value
|
|
53
|
+
* @returns {string} value that was set
|
|
54
|
+
*/
|
|
55
|
+
SessionStorageClass.prototype.setItem = function (key, value) {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
57
|
+
return __generator(this, function (_a) {
|
|
58
|
+
if (!this.storage)
|
|
59
|
+
throw PlatformNotSupportedError;
|
|
60
|
+
this.storage.setItem(key, value);
|
|
61
|
+
return [2 /*return*/];
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* This is used to get a specific key from storage
|
|
67
|
+
* @param {string} key - the key for the item
|
|
68
|
+
* This is used to clear the storage
|
|
69
|
+
* @returns {string} the data item
|
|
70
|
+
*/
|
|
71
|
+
SessionStorageClass.prototype.getItem = function (key) {
|
|
72
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
73
|
+
return __generator(this, function (_a) {
|
|
74
|
+
if (!this.storage)
|
|
75
|
+
throw PlatformNotSupportedError;
|
|
76
|
+
return [2 /*return*/, this.storage.getItem(key)];
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* This is used to remove an item from storage
|
|
82
|
+
* @param {string} key - the key being set
|
|
83
|
+
* @returns {string} value - value that was deleted
|
|
84
|
+
*/
|
|
85
|
+
SessionStorageClass.prototype.removeItem = function (key) {
|
|
86
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
87
|
+
return __generator(this, function (_a) {
|
|
88
|
+
if (!this.storage)
|
|
89
|
+
throw PlatformNotSupportedError;
|
|
90
|
+
this.storage.removeItem(key);
|
|
91
|
+
return [2 /*return*/];
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* This is used to clear the storage
|
|
97
|
+
* @returns {string} nothing
|
|
98
|
+
*/
|
|
99
|
+
SessionStorageClass.prototype.clear = function () {
|
|
100
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
101
|
+
return __generator(this, function (_a) {
|
|
102
|
+
if (!this.storage)
|
|
103
|
+
throw PlatformNotSupportedError;
|
|
104
|
+
this.storage.clear();
|
|
105
|
+
return [2 /*return*/];
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
return SessionStorageClass;
|
|
110
|
+
}());
|
|
111
|
+
export var SessionStorage = new SessionStorageClass();
|
|
@@ -9,8 +9,8 @@ export declare class UniversalStorage implements Storage {
|
|
|
9
9
|
constructor(context?: Context);
|
|
10
10
|
get length(): number;
|
|
11
11
|
clear(): void;
|
|
12
|
-
getItem(key: keyof Store): string;
|
|
13
|
-
protected getLocalItem(key: keyof Store): string;
|
|
12
|
+
getItem(key: keyof Store): string | null;
|
|
13
|
+
protected getLocalItem(key: keyof Store): string | null;
|
|
14
14
|
protected getUniversalItem(key: keyof Store): any;
|
|
15
15
|
key(index: number): string;
|
|
16
16
|
removeItem(key: string): void;
|
|
@@ -73,7 +73,7 @@ export declare class BackgroundProcessManager {
|
|
|
73
73
|
* @param job The inner job manager to await.
|
|
74
74
|
* @param description Optional description to help identify pending jobs.
|
|
75
75
|
*/
|
|
76
|
-
add(job: BackgroundProcessManager, description?: string):
|
|
76
|
+
add<T>(job: BackgroundProcessManager, description?: string): Promise<T>;
|
|
77
77
|
/**
|
|
78
78
|
* Adds a **cleaner** function that doesn't immediately get executed.
|
|
79
79
|
* Instead, the caller gets a **terminate** function back. The *cleaner* is
|
|
@@ -132,7 +132,7 @@ export declare class BackgroundProcessManager {
|
|
|
132
132
|
*
|
|
133
133
|
* @returns descriptions as an array.
|
|
134
134
|
*/
|
|
135
|
-
get pending(): string[];
|
|
135
|
+
get pending(): (string | undefined)[];
|
|
136
136
|
/**
|
|
137
137
|
* Whether the manager is accepting new jobs.
|
|
138
138
|
*/
|
|
@@ -4,4 +4,15 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @see https://github.com/aws/aws-sdk-js/blob/6edf586dcc1de7fe8fbfbbd9a0d2b1847921e6e1/lib/util.js#L262
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
type DateUtils = {
|
|
8
|
+
clockOffset: number;
|
|
9
|
+
getDateWithClockOffset: () => Date;
|
|
10
|
+
getClockOffset: () => number;
|
|
11
|
+
getHeaderStringFromDate: (date: Date) => string;
|
|
12
|
+
getDateFromHeaderString: (header: string) => Date;
|
|
13
|
+
isClockSkewed: (serverDate: Date) => boolean;
|
|
14
|
+
isClockSkewError: (error: any) => boolean;
|
|
15
|
+
setClockOffset: (offset: number) => void;
|
|
16
|
+
};
|
|
17
|
+
export declare const DateUtils: DateUtils;
|
|
18
|
+
export {};
|
|
@@ -11,8 +11,8 @@ var __values = (this && this.__values) || function(o) {
|
|
|
11
11
|
};
|
|
12
12
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
13
13
|
// SPDX-License-Identifier: Apache-2.0
|
|
14
|
-
import { browserOrNode, isWebWorker } from '@aws-amplify/core';
|
|
15
14
|
import Observable from 'zen-observable-ts';
|
|
15
|
+
import { browserOrNode, isWebWorker } from '../JS';
|
|
16
16
|
var ReachabilityNavigator = /** @class */ (function () {
|
|
17
17
|
function ReachabilityNavigator() {
|
|
18
18
|
}
|
|
@@ -31,7 +31,8 @@ var ReachabilityNavigator = /** @class */ (function () {
|
|
|
31
31
|
return function () {
|
|
32
32
|
globalObj.removeEventListener('online', notifyOnline);
|
|
33
33
|
globalObj.removeEventListener('offline', notifyOffline);
|
|
34
|
-
ReachabilityNavigator._observers =
|
|
34
|
+
ReachabilityNavigator._observers =
|
|
35
|
+
ReachabilityNavigator._observers.filter(function (_observer) { return _observer !== observer; });
|
|
35
36
|
};
|
|
36
37
|
});
|
|
37
38
|
};
|
|
@@ -40,7 +41,8 @@ var ReachabilityNavigator = /** @class */ (function () {
|
|
|
40
41
|
var e_1, _a;
|
|
41
42
|
var _loop_1 = function (observer) {
|
|
42
43
|
if (observer.closed) {
|
|
43
|
-
ReachabilityNavigator._observers =
|
|
44
|
+
ReachabilityNavigator._observers =
|
|
45
|
+
ReachabilityNavigator._observers.filter(function (_observer) { return _observer !== observer; });
|
|
44
46
|
return "continue";
|
|
45
47
|
}
|
|
46
48
|
observer.next(status);
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import Observable from 'zen-observable-ts';
|
|
2
|
+
import type NetInfo from '@react-native-community/netinfo';
|
|
2
3
|
type NetworkStatus = {
|
|
3
4
|
online: boolean;
|
|
4
5
|
};
|
|
5
6
|
export default class ReachabilityNavigator implements Reachability {
|
|
6
|
-
networkMonitor(netInfo?:
|
|
7
|
+
networkMonitor(netInfo?: typeof NetInfo): Observable<NetworkStatus>;
|
|
7
8
|
}
|
|
8
9
|
interface Reachability {
|
|
9
|
-
networkMonitor(netInfo?:
|
|
10
|
+
networkMonitor(netInfo?: typeof NetInfo): Observable<NetworkStatus>;
|
|
10
11
|
}
|
|
11
12
|
export {};
|
|
@@ -3,17 +3,10 @@
|
|
|
3
3
|
export function urlSafeEncode(str) {
|
|
4
4
|
return str
|
|
5
5
|
.split('')
|
|
6
|
-
.map(function (char) {
|
|
7
|
-
return char
|
|
8
|
-
.charCodeAt(0)
|
|
9
|
-
.toString(16)
|
|
10
|
-
.padStart(2, '0');
|
|
11
|
-
})
|
|
6
|
+
.map(function (char) { return char.charCodeAt(0).toString(16).padStart(2, '0'); })
|
|
12
7
|
.join('');
|
|
13
8
|
}
|
|
14
9
|
export function urlSafeDecode(hex) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
.map(function (char) { return String.fromCharCode(parseInt(char, 16)); })
|
|
18
|
-
.join('');
|
|
10
|
+
var matchArr = hex.match(/.{2}/g) || [];
|
|
11
|
+
return matchArr.map(function (char) { return String.fromCharCode(parseInt(char, 16)); }).join('');
|
|
19
12
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
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 function asserts(assertion, errorParams) {
|
|
5
|
+
if (!assertion)
|
|
6
|
+
throw new AmplifyError(errorParams);
|
|
7
|
+
}
|
|
@@ -3,4 +3,4 @@ import { HttpResponse, ErrorParser } from '../../types';
|
|
|
3
3
|
* Get retry decider function
|
|
4
4
|
* @param errorParser Function to load JavaScript error from HTTP response
|
|
5
5
|
*/
|
|
6
|
-
export declare const getRetryDecider: (errorParser: ErrorParser) => (response?: HttpResponse, error?:
|
|
6
|
+
export declare const getRetryDecider: (errorParser: ErrorParser) => (response?: HttpResponse, error?: unknown) => Promise<boolean>;
|