@aws-amplify/core 6.0.1-console-preview.814dea6.0 → 6.0.1-console-preview.047a1dd.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.d.ts +12 -4
- package/lib/AwsClients/CognitoIdentity/base.js +1 -0
- package/lib/AwsClients/CognitoIdentity/getCredentialsForIdentity.d.ts +15 -3
- package/lib/AwsClients/CognitoIdentity/getId.d.ts +15 -3
- package/lib/AwsClients/Pinpoint/base.d.ts +10 -2
- package/lib/AwsClients/Pinpoint/getInAppMessages.d.ts +17 -3
- package/lib/AwsClients/Pinpoint/putEvents.d.ts +17 -3
- package/lib/AwsClients/Pinpoint/updateEndpoint.d.ts +17 -3
- package/lib/Cache/Utils/CacheUtils.js +2 -4
- package/lib/Platform/version.d.ts +1 -1
- package/lib/Platform/version.js +1 -1
- package/lib/ServiceWorker/ServiceWorker.js +1 -1
- package/lib/Util/JS.d.ts +1 -4
- package/lib/Util/JS.js +4 -11
- package/lib/Util/Reachability.js +0 -3
- package/lib/clients/handlers/authenticated.d.ts +1 -1
- package/lib/clients/handlers/fetch.d.ts +0 -1
- package/lib/clients/handlers/fetch.js +2 -2
- package/lib/clients/handlers/unauthenticated.d.ts +1 -1
- package/lib/clients/internal/composeServiceApi.d.ts +5 -3
- package/lib/clients/types/aws.d.ts +1 -5
- package/lib/clients/types/http.d.ts +8 -0
- package/lib/clients/types/index.d.ts +1 -1
- package/lib/index.d.ts +1 -2
- package/lib/index.js +6 -10
- package/lib/libraryUtils.d.ts +3 -3
- package/lib/libraryUtils.js +5 -10
- package/lib/parseAWSExports.js +20 -1
- package/lib/providers/pinpoint/apis/record.d.ts +2 -2
- package/lib/providers/pinpoint/apis/record.js +3 -3
- package/lib/providers/pinpoint/apis/updateEndpoint.d.ts +2 -2
- package/lib/providers/pinpoint/types/buffer.d.ts +1 -1
- package/lib/providers/pinpoint/types/pinpoint.d.ts +3 -3
- package/lib/providers/pinpoint/utils/PinpointEventBuffer.js +7 -5
- package/lib/providers/pinpoint/utils/isAppInForeground.d.ts +1 -0
- package/lib/{RNComponents → providers/pinpoint/utils}/isAppInForeground.js +1 -4
- package/lib/providers/pinpoint/utils/isAppInForeground.native.d.ts +1 -0
- package/lib/providers/pinpoint/utils/isAppInForeground.native.js +9 -0
- package/lib/singleton/API/types.d.ts +34 -0
- package/lib/singleton/API/types.js +2 -0
- package/lib/singleton/Amplify.d.ts +2 -2
- package/lib/singleton/Amplify.js +9 -1
- package/lib/singleton/Auth/index.d.ts +2 -1
- package/lib/singleton/Auth/index.js +22 -12
- package/lib/singleton/Auth/utils/index.js +3 -3
- package/lib/singleton/Storage/types.d.ts +5 -0
- package/lib/singleton/types.d.ts +10 -1
- package/lib/{StorageHelper/cookieStorage.d.ts → storage/CookieStorage.d.ts} +4 -3
- package/lib/{StorageHelper/cookieStorage.js → storage/CookieStorage.js} +35 -83
- package/lib/storage/CookieStorage.native.d.ts +7 -0
- package/lib/storage/CookieStorage.native.js +32 -0
- package/lib/storage/DefaultStorage.d.ts +7 -0
- package/lib/storage/DefaultStorage.js +33 -0
- package/{lib-esm/StorageHelper/localStorage.d.ts → lib/storage/DefaultStorage.native.d.ts} +7 -6
- package/lib/{StorageHelper/sessionStorage.js → storage/DefaultStorage.native.js} +46 -43
- package/lib/storage/InMemoryStorage.d.ts +12 -0
- package/lib/storage/InMemoryStorage.js +41 -0
- package/lib/{StorageHelper/sessionStorage.d.ts → storage/KeyValueStorage.d.ts} +5 -4
- package/lib/{StorageHelper/localStorage.js → storage/KeyValueStorage.js} +13 -15
- package/lib/storage/SessionStorage.d.ts +7 -0
- package/lib/storage/SessionStorage.js +33 -0
- package/lib/storage/index.d.ts +7 -0
- package/lib/storage/index.js +14 -0
- package/lib/storage/utils.d.ts +10 -0
- package/lib/storage/utils.js +26 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/storage.d.ts +3 -0
- package/lib-esm/AwsClients/CognitoIdentity/base.d.ts +12 -4
- package/lib-esm/AwsClients/CognitoIdentity/base.js +1 -0
- package/lib-esm/AwsClients/CognitoIdentity/getCredentialsForIdentity.d.ts +15 -3
- package/lib-esm/AwsClients/CognitoIdentity/getId.d.ts +15 -3
- package/lib-esm/AwsClients/Pinpoint/base.d.ts +10 -2
- package/lib-esm/AwsClients/Pinpoint/getInAppMessages.d.ts +17 -3
- package/lib-esm/AwsClients/Pinpoint/putEvents.d.ts +17 -3
- package/lib-esm/AwsClients/Pinpoint/updateEndpoint.d.ts +17 -3
- package/lib-esm/Cache/Utils/CacheUtils.js +2 -4
- package/lib-esm/Platform/version.d.ts +1 -1
- package/lib-esm/Platform/version.js +1 -1
- package/lib-esm/ServiceWorker/ServiceWorker.js +2 -2
- package/lib-esm/Util/JS.d.ts +1 -4
- package/lib-esm/Util/JS.js +2 -9
- package/lib-esm/Util/Reachability.js +1 -4
- package/lib-esm/clients/handlers/authenticated.d.ts +1 -1
- package/lib-esm/clients/handlers/fetch.d.ts +0 -1
- package/lib-esm/clients/handlers/fetch.js +2 -2
- package/lib-esm/clients/handlers/unauthenticated.d.ts +1 -1
- package/lib-esm/clients/internal/composeServiceApi.d.ts +5 -3
- package/lib-esm/clients/types/aws.d.ts +1 -5
- package/lib-esm/clients/types/http.d.ts +8 -0
- package/lib-esm/clients/types/index.d.ts +1 -1
- package/lib-esm/index.d.ts +1 -2
- package/lib-esm/index.js +1 -2
- package/lib-esm/libraryUtils.d.ts +3 -3
- package/lib-esm/libraryUtils.js +2 -3
- package/lib-esm/parseAWSExports.js +20 -1
- package/lib-esm/providers/pinpoint/apis/record.d.ts +2 -2
- package/lib-esm/providers/pinpoint/apis/record.js +3 -3
- package/lib-esm/providers/pinpoint/apis/updateEndpoint.d.ts +2 -2
- package/lib-esm/providers/pinpoint/types/buffer.d.ts +1 -1
- package/lib-esm/providers/pinpoint/types/pinpoint.d.ts +3 -3
- package/lib-esm/providers/pinpoint/utils/PinpointEventBuffer.js +7 -5
- package/lib-esm/providers/pinpoint/utils/isAppInForeground.js +3 -0
- package/lib-esm/providers/pinpoint/utils/isAppInForeground.native.js +5 -0
- package/lib-esm/singleton/API/types.d.ts +34 -0
- package/lib-esm/singleton/API/types.js +1 -0
- package/lib-esm/singleton/Amplify.d.ts +2 -2
- package/lib-esm/singleton/Amplify.js +9 -1
- package/lib-esm/singleton/Auth/index.d.ts +2 -1
- package/lib-esm/singleton/Auth/index.js +22 -12
- package/lib-esm/singleton/Auth/utils/index.js +3 -3
- package/lib-esm/singleton/Storage/types.d.ts +5 -0
- package/lib-esm/singleton/types.d.ts +10 -1
- package/lib-esm/{StorageHelper/cookieStorage.d.ts → storage/CookieStorage.d.ts} +4 -3
- package/lib-esm/{StorageHelper/cookieStorage.js → storage/CookieStorage.js} +36 -61
- package/lib-esm/storage/CookieStorage.native.d.ts +7 -0
- package/lib-esm/storage/CookieStorage.native.js +29 -0
- package/lib-esm/storage/DefaultStorage.d.ts +7 -0
- package/lib-esm/storage/DefaultStorage.js +30 -0
- package/{lib/StorageHelper/localStorage.d.ts → lib-esm/storage/DefaultStorage.native.d.ts} +7 -6
- package/lib-esm/{StorageHelper/sessionStorage.js → storage/DefaultStorage.native.js} +45 -42
- package/lib-esm/storage/InMemoryStorage.d.ts +12 -0
- package/lib-esm/storage/InMemoryStorage.js +38 -0
- package/lib-esm/{StorageHelper/sessionStorage.d.ts → storage/KeyValueStorage.d.ts} +5 -4
- package/lib-esm/{StorageHelper/localStorage.js → storage/KeyValueStorage.js} +12 -14
- package/lib-esm/storage/SessionStorage.d.ts +7 -0
- package/lib-esm/storage/SessionStorage.js +30 -0
- package/lib-esm/storage/index.d.ts +7 -0
- package/lib-esm/storage/index.js +10 -0
- package/lib-esm/storage/utils.d.ts +10 -0
- package/lib-esm/storage/utils.js +21 -0
- package/lib-esm/tsconfig.tsbuildinfo +1 -1
- package/lib-esm/types/storage.d.ts +3 -0
- package/package.json +3 -6
- package/src/AwsClients/CognitoIdentity/base.ts +2 -2
- package/src/AwsClients/Pinpoint/base.ts +2 -6
- package/src/Cache/Utils/CacheUtils.ts +2 -4
- package/src/Platform/version.ts +1 -1
- package/src/ServiceWorker/ServiceWorker.ts +2 -2
- package/src/Util/JS.ts +2 -13
- package/src/Util/Reachability.ts +1 -5
- package/src/clients/handlers/authenticated.ts +2 -1
- package/src/clients/handlers/fetch.ts +2 -2
- package/src/clients/handlers/unauthenticated.ts +2 -1
- package/src/clients/internal/composeServiceApi.ts +10 -3
- package/src/clients/types/aws.ts +4 -11
- package/src/clients/types/http.ts +8 -0
- package/src/clients/types/index.ts +0 -1
- package/src/index.ts +4 -8
- package/src/libraryUtils.ts +3 -4
- package/src/parseAWSExports.ts +26 -0
- package/src/providers/pinpoint/apis/record.ts +8 -8
- package/src/providers/pinpoint/apis/updateEndpoint.ts +2 -2
- package/src/providers/pinpoint/types/buffer.ts +1 -1
- package/src/providers/pinpoint/types/pinpoint.ts +8 -7
- package/src/providers/pinpoint/utils/PinpointEventBuffer.ts +16 -12
- package/src/providers/pinpoint/utils/isAppInForeground.native.ts +7 -0
- package/src/providers/pinpoint/utils/isAppInForeground.ts +4 -0
- package/src/singleton/API/types.ts +31 -0
- package/src/singleton/Amplify.ts +12 -3
- package/src/singleton/Auth/index.ts +9 -2
- package/src/singleton/Auth/utils/index.ts +3 -3
- package/src/singleton/Storage/types.ts +6 -2
- package/src/singleton/types.ts +11 -1
- package/src/storage/CookieStorage.native.ts +13 -0
- package/src/storage/CookieStorage.ts +72 -0
- package/src/storage/DefaultStorage.native.ts +78 -0
- package/src/storage/DefaultStorage.ts +14 -0
- package/src/storage/InMemoryStorage.ts +36 -0
- package/src/{StorageHelper/sessionStorage.ts → storage/KeyValueStorage.ts} +10 -13
- package/src/storage/SessionStorage.ts +14 -0
- package/src/storage/index.ts +13 -0
- package/src/storage/utils.ts +22 -0
- package/src/types/storage.ts +4 -0
- package/lib/OAuthHelper/FacebookOAuth.d.ts +0 -6
- package/lib/OAuthHelper/FacebookOAuth.js +0 -124
- package/lib/OAuthHelper/GoogleOAuth.d.ts +0 -6
- package/lib/OAuthHelper/GoogleOAuth.js +0 -134
- package/lib/OAuthHelper/index.d.ts +0 -4
- package/lib/OAuthHelper/index.js +0 -9
- package/lib/RNComponents/index.d.ts +0 -6
- package/lib/RNComponents/index.js +0 -16
- package/lib/RNComponents/reactnative.d.ts +0 -3
- package/lib/RNComponents/reactnative.js +0 -14
- package/lib/StorageHelper/inMemoryStorage.d.ts +0 -10
- package/lib/StorageHelper/inMemoryStorage.js +0 -82
- package/lib/StorageHelper/index.d.ts +0 -45
- package/lib/StorageHelper/index.js +0 -83
- package/lib/StorageHelper/reactnative.d.ts +0 -83
- package/lib/StorageHelper/reactnative.js +0 -250
- package/lib-esm/OAuthHelper/FacebookOAuth.d.ts +0 -6
- package/lib-esm/OAuthHelper/FacebookOAuth.js +0 -121
- package/lib-esm/OAuthHelper/GoogleOAuth.d.ts +0 -6
- package/lib-esm/OAuthHelper/GoogleOAuth.js +0 -131
- package/lib-esm/OAuthHelper/index.d.ts +0 -4
- package/lib-esm/OAuthHelper/index.js +0 -6
- package/lib-esm/RNComponents/index.d.ts +0 -6
- package/lib-esm/RNComponents/index.js +0 -13
- package/lib-esm/RNComponents/isAppInForeground.js +0 -6
- package/lib-esm/RNComponents/reactnative.d.ts +0 -3
- package/lib-esm/RNComponents/reactnative.js +0 -6
- package/lib-esm/StorageHelper/inMemoryStorage.d.ts +0 -10
- package/lib-esm/StorageHelper/inMemoryStorage.js +0 -79
- package/lib-esm/StorageHelper/index.d.ts +0 -45
- package/lib-esm/StorageHelper/index.js +0 -76
- package/lib-esm/StorageHelper/reactnative.d.ts +0 -83
- package/lib-esm/StorageHelper/reactnative.js +0 -244
- package/src/OAuthHelper/FacebookOAuth.ts +0 -83
- package/src/OAuthHelper/GoogleOAuth.ts +0 -97
- package/src/OAuthHelper/index.ts +0 -7
- package/src/RNComponents/index.ts +0 -16
- package/src/RNComponents/isAppInForeground.ts +0 -8
- package/src/RNComponents/reactnative.ts +0 -6
- package/src/StorageHelper/cookieStorage.ts +0 -99
- package/src/StorageHelper/inMemoryStorage.ts +0 -32
- package/src/StorageHelper/index.ts +0 -78
- package/src/StorageHelper/localStorage.ts +0 -60
- package/src/StorageHelper/reactnative.ts +0 -182
- /package/lib-esm/{RNComponents → providers/pinpoint/utils}/isAppInForeground.d.ts +0 -0
- /package/{lib/RNComponents/isAppInForeground.d.ts → lib-esm/providers/pinpoint/utils/isAppInForeground.native.d.ts} +0 -0
|
@@ -38,16 +38,15 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
-
exports.
|
|
42
|
-
var
|
|
43
|
-
var
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
41
|
+
exports.DefaultStorage = void 0;
|
|
42
|
+
var libraryUtils_1 = require("../libraryUtils");
|
|
43
|
+
var ASYNC_STORAGE_MODULE = '@react-native-async-storage/async-storage';
|
|
44
|
+
var MEMORY_KEY_PREFIX = '@MemoryStorage:';
|
|
45
|
+
/**
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
var DefaultStorage = /** @class */ (function () {
|
|
49
|
+
function DefaultStorage() {
|
|
51
50
|
}
|
|
52
51
|
/**
|
|
53
52
|
* This is used to set a specific item in storage
|
|
@@ -55,15 +54,9 @@ var SessionStorageClass = /** @class */ (function () {
|
|
|
55
54
|
* @param {object} value - the value
|
|
56
55
|
* @returns {string} value that was set
|
|
57
56
|
*/
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (!this.storage)
|
|
62
|
-
throw Errors_1.PlatformNotSupportedError;
|
|
63
|
-
this.storage.setItem(key, value);
|
|
64
|
-
return [2 /*return*/];
|
|
65
|
-
});
|
|
66
|
-
});
|
|
57
|
+
DefaultStorage.prototype.setItem = function (key, value) {
|
|
58
|
+
this.assertModule(this.asyncStorage);
|
|
59
|
+
return this.asyncStorage.setItem("".concat(MEMORY_KEY_PREFIX).concat(key), value);
|
|
67
60
|
};
|
|
68
61
|
/**
|
|
69
62
|
* This is used to get a specific key from storage
|
|
@@ -71,44 +64,54 @@ var SessionStorageClass = /** @class */ (function () {
|
|
|
71
64
|
* This is used to clear the storage
|
|
72
65
|
* @returns {string} the data item
|
|
73
66
|
*/
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if (!this.storage)
|
|
78
|
-
throw Errors_1.PlatformNotSupportedError;
|
|
79
|
-
return [2 /*return*/, this.storage.getItem(key)];
|
|
80
|
-
});
|
|
81
|
-
});
|
|
67
|
+
DefaultStorage.prototype.getItem = function (key) {
|
|
68
|
+
this.assertModule(this.asyncStorage);
|
|
69
|
+
return this.asyncStorage.getItem("".concat(MEMORY_KEY_PREFIX).concat(key));
|
|
82
70
|
};
|
|
83
71
|
/**
|
|
84
72
|
* This is used to remove an item from storage
|
|
85
73
|
* @param {string} key - the key being set
|
|
86
74
|
* @returns {string} value - value that was deleted
|
|
87
75
|
*/
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
if (!this.storage)
|
|
92
|
-
throw Errors_1.PlatformNotSupportedError;
|
|
93
|
-
this.storage.removeItem(key);
|
|
94
|
-
return [2 /*return*/];
|
|
95
|
-
});
|
|
96
|
-
});
|
|
76
|
+
DefaultStorage.prototype.removeItem = function (key) {
|
|
77
|
+
this.assertModule(this.asyncStorage);
|
|
78
|
+
return this.asyncStorage.removeItem("".concat(MEMORY_KEY_PREFIX).concat(key));
|
|
97
79
|
};
|
|
98
80
|
/**
|
|
99
81
|
* This is used to clear the storage
|
|
100
82
|
* @returns {string} nothing
|
|
101
83
|
*/
|
|
102
|
-
|
|
84
|
+
DefaultStorage.prototype.clear = function () {
|
|
103
85
|
return __awaiter(this, void 0, void 0, function () {
|
|
86
|
+
var allKeys;
|
|
104
87
|
return __generator(this, function (_a) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
88
|
+
switch (_a.label) {
|
|
89
|
+
case 0:
|
|
90
|
+
this.assertModule(this.asyncStorage);
|
|
91
|
+
return [4 /*yield*/, this.asyncStorage.getAllKeys()];
|
|
92
|
+
case 1:
|
|
93
|
+
allKeys = _a.sent();
|
|
94
|
+
return [2 /*return*/, this.asyncStorage.multiRemove(allKeys.filter(function (key) { return key.startsWith(MEMORY_KEY_PREFIX); }))];
|
|
95
|
+
}
|
|
109
96
|
});
|
|
110
97
|
});
|
|
111
98
|
};
|
|
112
|
-
|
|
99
|
+
DefaultStorage.prototype.assertModule = function (asyncStorage) {
|
|
100
|
+
if (!!asyncStorage) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
try {
|
|
104
|
+
this.asyncStorage = require(ASYNC_STORAGE_MODULE)
|
|
105
|
+
.default;
|
|
106
|
+
}
|
|
107
|
+
catch (err) {
|
|
108
|
+
throw new libraryUtils_1.AmplifyError({
|
|
109
|
+
name: 'NativeModuleException',
|
|
110
|
+
message: "Unable to find ".concat(ASYNC_STORAGE_MODULE),
|
|
111
|
+
recoverySuggestion: "Make sure to install ".concat(ASYNC_STORAGE_MODULE),
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
return DefaultStorage;
|
|
113
116
|
}());
|
|
114
|
-
exports.
|
|
117
|
+
exports.DefaultStorage = DefaultStorage;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @internal
|
|
3
|
+
*/
|
|
4
|
+
export declare class InMemoryStorage implements Storage {
|
|
5
|
+
storage: Map<string, string>;
|
|
6
|
+
get length(): number;
|
|
7
|
+
key(index: number): string | null;
|
|
8
|
+
setItem(key: string, value: string): void;
|
|
9
|
+
getItem(key: string): string | null;
|
|
10
|
+
removeItem(key: string): void;
|
|
11
|
+
clear(): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.InMemoryStorage = void 0;
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
var InMemoryStorage = /** @class */ (function () {
|
|
10
|
+
function InMemoryStorage() {
|
|
11
|
+
this.storage = new Map();
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(InMemoryStorage.prototype, "length", {
|
|
14
|
+
get: function () {
|
|
15
|
+
return this.storage.size;
|
|
16
|
+
},
|
|
17
|
+
enumerable: false,
|
|
18
|
+
configurable: true
|
|
19
|
+
});
|
|
20
|
+
InMemoryStorage.prototype.key = function (index) {
|
|
21
|
+
if (index > this.length - 1) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
return Array.from(this.storage.keys())[index];
|
|
25
|
+
};
|
|
26
|
+
InMemoryStorage.prototype.setItem = function (key, value) {
|
|
27
|
+
this.storage.set(key, value);
|
|
28
|
+
};
|
|
29
|
+
InMemoryStorage.prototype.getItem = function (key) {
|
|
30
|
+
var _a;
|
|
31
|
+
return (_a = this.storage.get(key)) !== null && _a !== void 0 ? _a : null;
|
|
32
|
+
};
|
|
33
|
+
InMemoryStorage.prototype.removeItem = function (key) {
|
|
34
|
+
this.storage.delete(key);
|
|
35
|
+
};
|
|
36
|
+
InMemoryStorage.prototype.clear = function () {
|
|
37
|
+
this.storage.clear();
|
|
38
|
+
};
|
|
39
|
+
return InMemoryStorage;
|
|
40
|
+
}());
|
|
41
|
+
exports.InMemoryStorage = InMemoryStorage;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { KeyValueStorageInterface } from '../types';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export declare class KeyValueStorage implements KeyValueStorageInterface {
|
|
3
6
|
storage?: Storage;
|
|
4
|
-
constructor();
|
|
7
|
+
constructor(storage?: Storage);
|
|
5
8
|
/**
|
|
6
9
|
* This is used to set a specific item in storage
|
|
7
10
|
* @param {string} key - the key for the item
|
|
@@ -28,5 +31,3 @@ declare class SessionStorageClass implements KeyValueStorageInterface {
|
|
|
28
31
|
*/
|
|
29
32
|
clear(): Promise<void>;
|
|
30
33
|
}
|
|
31
|
-
export declare const SessionStorage: SessionStorageClass;
|
|
32
|
-
export {};
|
|
@@ -38,16 +38,14 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
-
exports.
|
|
41
|
+
exports.KeyValueStorage = void 0;
|
|
42
42
|
var Errors_1 = require("../Util/Errors");
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
catch (error) { }
|
|
50
|
-
}
|
|
43
|
+
/**
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
|
+
var KeyValueStorage = /** @class */ (function () {
|
|
47
|
+
function KeyValueStorage(storage) {
|
|
48
|
+
this.storage = storage;
|
|
51
49
|
}
|
|
52
50
|
/**
|
|
53
51
|
* This is used to set a specific item in storage
|
|
@@ -55,7 +53,7 @@ var LocalStorageClass = /** @class */ (function () {
|
|
|
55
53
|
* @param {object} value - the value
|
|
56
54
|
* @returns {string} value that was set
|
|
57
55
|
*/
|
|
58
|
-
|
|
56
|
+
KeyValueStorage.prototype.setItem = function (key, value) {
|
|
59
57
|
return __awaiter(this, void 0, void 0, function () {
|
|
60
58
|
return __generator(this, function (_a) {
|
|
61
59
|
if (!this.storage)
|
|
@@ -71,7 +69,7 @@ var LocalStorageClass = /** @class */ (function () {
|
|
|
71
69
|
* This is used to clear the storage
|
|
72
70
|
* @returns {string} the data item
|
|
73
71
|
*/
|
|
74
|
-
|
|
72
|
+
KeyValueStorage.prototype.getItem = function (key) {
|
|
75
73
|
return __awaiter(this, void 0, void 0, function () {
|
|
76
74
|
return __generator(this, function (_a) {
|
|
77
75
|
if (!this.storage)
|
|
@@ -85,7 +83,7 @@ var LocalStorageClass = /** @class */ (function () {
|
|
|
85
83
|
* @param {string} key - the key being set
|
|
86
84
|
* @returns {string} value - value that was deleted
|
|
87
85
|
*/
|
|
88
|
-
|
|
86
|
+
KeyValueStorage.prototype.removeItem = function (key) {
|
|
89
87
|
return __awaiter(this, void 0, void 0, function () {
|
|
90
88
|
return __generator(this, function (_a) {
|
|
91
89
|
if (!this.storage)
|
|
@@ -99,7 +97,7 @@ var LocalStorageClass = /** @class */ (function () {
|
|
|
99
97
|
* This is used to clear the storage
|
|
100
98
|
* @returns {string} nothing
|
|
101
99
|
*/
|
|
102
|
-
|
|
100
|
+
KeyValueStorage.prototype.clear = function () {
|
|
103
101
|
return __awaiter(this, void 0, void 0, function () {
|
|
104
102
|
return __generator(this, function (_a) {
|
|
105
103
|
if (!this.storage)
|
|
@@ -109,6 +107,6 @@ var LocalStorageClass = /** @class */ (function () {
|
|
|
109
107
|
});
|
|
110
108
|
});
|
|
111
109
|
};
|
|
112
|
-
return
|
|
110
|
+
return KeyValueStorage;
|
|
113
111
|
}());
|
|
114
|
-
exports.
|
|
112
|
+
exports.KeyValueStorage = KeyValueStorage;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
var __extends = (this && this.__extends) || (function () {
|
|
5
|
+
var extendStatics = function (d, b) {
|
|
6
|
+
extendStatics = Object.setPrototypeOf ||
|
|
7
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
8
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
9
|
+
return extendStatics(d, b);
|
|
10
|
+
};
|
|
11
|
+
return function (d, b) {
|
|
12
|
+
if (typeof b !== "function" && b !== null)
|
|
13
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
14
|
+
extendStatics(d, b);
|
|
15
|
+
function __() { this.constructor = d; }
|
|
16
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
17
|
+
};
|
|
18
|
+
})();
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.SessionStorage = void 0;
|
|
21
|
+
var KeyValueStorage_1 = require("./KeyValueStorage");
|
|
22
|
+
var utils_1 = require("./utils");
|
|
23
|
+
/**
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
var SessionStorage = /** @class */ (function (_super) {
|
|
27
|
+
__extends(SessionStorage, _super);
|
|
28
|
+
function SessionStorage() {
|
|
29
|
+
return _super.call(this, (0, utils_1.getSessionStorageWithFallback)()) || this;
|
|
30
|
+
}
|
|
31
|
+
return SessionStorage;
|
|
32
|
+
}(KeyValueStorage_1.KeyValueStorage));
|
|
33
|
+
exports.SessionStorage = SessionStorage;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DefaultStorage } from './DefaultStorage';
|
|
2
|
+
import { KeyValueStorage } from './KeyValueStorage';
|
|
3
|
+
import { SessionStorage } from './SessionStorage';
|
|
4
|
+
export { CookieStorage } from './CookieStorage';
|
|
5
|
+
export declare const defaultStorage: DefaultStorage;
|
|
6
|
+
export declare const sessionStorage: SessionStorage;
|
|
7
|
+
export declare const sharedInMemoryStorage: KeyValueStorage;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.sharedInMemoryStorage = exports.sessionStorage = exports.defaultStorage = exports.CookieStorage = void 0;
|
|
6
|
+
var DefaultStorage_1 = require("./DefaultStorage");
|
|
7
|
+
var InMemoryStorage_1 = require("./InMemoryStorage");
|
|
8
|
+
var KeyValueStorage_1 = require("./KeyValueStorage");
|
|
9
|
+
var SessionStorage_1 = require("./SessionStorage");
|
|
10
|
+
var CookieStorage_1 = require("./CookieStorage");
|
|
11
|
+
Object.defineProperty(exports, "CookieStorage", { enumerable: true, get: function () { return CookieStorage_1.CookieStorage; } });
|
|
12
|
+
exports.defaultStorage = new DefaultStorage_1.DefaultStorage();
|
|
13
|
+
exports.sessionStorage = new SessionStorage_1.SessionStorage();
|
|
14
|
+
exports.sharedInMemoryStorage = new KeyValueStorage_1.KeyValueStorage(new InMemoryStorage_1.InMemoryStorage());
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @internal
|
|
3
|
+
* @returns Either a reference to window.localStorage or an in-memory storage as fallback
|
|
4
|
+
*/
|
|
5
|
+
export declare const getDefaultStorageWithFallback: () => Storage;
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
* @returns Either a reference to window.sessionStorage or an in-memory storage as fallback
|
|
9
|
+
*/
|
|
10
|
+
export declare const getSessionStorageWithFallback: () => Storage;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.getSessionStorageWithFallback = exports.getDefaultStorageWithFallback = void 0;
|
|
6
|
+
var InMemoryStorage_1 = require("./InMemoryStorage");
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
* @returns Either a reference to window.localStorage or an in-memory storage as fallback
|
|
10
|
+
*/
|
|
11
|
+
var getDefaultStorageWithFallback = function () {
|
|
12
|
+
return typeof window !== 'undefined' && window.localStorage
|
|
13
|
+
? window.localStorage
|
|
14
|
+
: new InMemoryStorage_1.InMemoryStorage();
|
|
15
|
+
};
|
|
16
|
+
exports.getDefaultStorageWithFallback = getDefaultStorageWithFallback;
|
|
17
|
+
/**
|
|
18
|
+
* @internal
|
|
19
|
+
* @returns Either a reference to window.sessionStorage or an in-memory storage as fallback
|
|
20
|
+
*/
|
|
21
|
+
var getSessionStorageWithFallback = function () {
|
|
22
|
+
return typeof window !== 'undefined' && window.sessionStorage
|
|
23
|
+
? window.sessionStorage
|
|
24
|
+
: new InMemoryStorage_1.InMemoryStorage();
|
|
25
|
+
};
|
|
26
|
+
exports.getSessionStorageWithFallback = getSessionStorageWithFallback;
|