@aws-amplify/core 6.0.1-console-preview.7739091.0 → 6.0.1-preview-testing.64b45b1.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 +4 -2
- package/lib/Platform/version.d.ts +1 -1
- package/lib/Platform/version.js +1 -1
- package/lib/RNComponents/index.d.ts +1 -1
- package/lib/RNComponents/index.js +2 -2
- package/{lib-esm/storage/CookieStorage.d.ts → lib/StorageHelper/cookieStorage.d.ts} +3 -4
- package/lib/{storage/CookieStorage.js → StorageHelper/cookieStorage.js} +83 -35
- package/lib/StorageHelper/inMemoryStorage.d.ts +10 -0
- package/lib/StorageHelper/inMemoryStorage.js +82 -0
- package/lib/StorageHelper/index.d.ts +45 -0
- package/lib/StorageHelper/index.js +83 -0
- package/lib/{storage/DefaultStorage.native.d.ts → StorageHelper/localStorage.d.ts} +6 -7
- package/lib/{storage/KeyValueStorage.js → StorageHelper/localStorage.js} +15 -13
- package/lib/StorageHelper/reactnative.d.ts +83 -0
- package/lib/StorageHelper/reactnative.js +250 -0
- package/lib/{storage/KeyValueStorage.d.ts → StorageHelper/sessionStorage.d.ts} +4 -5
- package/lib/{storage/DefaultStorage.native.js → StorageHelper/sessionStorage.js} +43 -46
- package/lib/clients/handlers/authenticated.d.ts +1 -1
- package/lib/clients/handlers/fetch.js +2 -1
- 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 +0 -4
- package/lib/clients/types/http.d.ts +8 -0
- package/lib/clients/types/index.d.ts +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +8 -6
- package/lib/parseAWSExports.js +1 -20
- package/lib/providers/pinpoint/types/buffer.d.ts +1 -1
- package/lib/providers/pinpoint/types/pinpoint.d.ts +1 -1
- package/lib/singleton/types.d.ts +1 -4
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/storage.d.ts +0 -3
- 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 +4 -2
- package/lib-esm/Platform/version.d.ts +1 -1
- package/lib-esm/Platform/version.js +1 -1
- package/lib-esm/RNComponents/index.d.ts +1 -1
- package/lib-esm/RNComponents/index.js +2 -2
- package/{lib/storage/CookieStorage.d.ts → lib-esm/StorageHelper/cookieStorage.d.ts} +3 -4
- package/lib-esm/{storage/CookieStorage.js → StorageHelper/cookieStorage.js} +61 -36
- package/lib-esm/StorageHelper/inMemoryStorage.d.ts +10 -0
- package/lib-esm/StorageHelper/inMemoryStorage.js +79 -0
- package/lib-esm/StorageHelper/index.d.ts +45 -0
- package/lib-esm/StorageHelper/index.js +76 -0
- package/lib-esm/{storage/DefaultStorage.native.d.ts → StorageHelper/localStorage.d.ts} +6 -7
- package/lib-esm/{storage/KeyValueStorage.js → StorageHelper/localStorage.js} +14 -12
- package/lib-esm/StorageHelper/reactnative.d.ts +83 -0
- package/lib-esm/StorageHelper/reactnative.js +244 -0
- package/lib-esm/{storage/KeyValueStorage.d.ts → StorageHelper/sessionStorage.d.ts} +4 -5
- package/lib-esm/{storage/DefaultStorage.native.js → StorageHelper/sessionStorage.js} +42 -45
- package/lib-esm/clients/handlers/authenticated.d.ts +1 -1
- package/lib-esm/clients/handlers/fetch.js +2 -1
- 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 +0 -4
- 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 -1
- package/lib-esm/index.js +1 -1
- package/lib-esm/parseAWSExports.js +1 -20
- package/lib-esm/providers/pinpoint/types/buffer.d.ts +1 -1
- package/lib-esm/providers/pinpoint/types/pinpoint.d.ts +1 -1
- package/lib-esm/singleton/types.d.ts +1 -4
- package/lib-esm/tsconfig.tsbuildinfo +1 -1
- package/lib-esm/types/storage.d.ts +0 -3
- package/package.json +3 -3
- package/src/AwsClients/CognitoIdentity/base.ts +2 -2
- package/src/AwsClients/Pinpoint/base.ts +2 -6
- package/src/Cache/Utils/CacheUtils.ts +4 -2
- package/src/Platform/version.ts +1 -1
- package/src/RNComponents/index.ts +2 -2
- package/src/StorageHelper/cookieStorage.ts +99 -0
- package/src/StorageHelper/inMemoryStorage.ts +32 -0
- package/src/StorageHelper/index.ts +78 -0
- package/src/StorageHelper/localStorage.ts +60 -0
- package/src/StorageHelper/reactnative.ts +182 -0
- package/src/{storage/KeyValueStorage.ts → StorageHelper/sessionStorage.ts} +13 -10
- package/src/clients/handlers/authenticated.ts +2 -1
- package/src/clients/handlers/fetch.ts +2 -1
- package/src/clients/handlers/unauthenticated.ts +2 -1
- package/src/clients/internal/composeServiceApi.ts +10 -3
- package/src/clients/types/aws.ts +0 -10
- package/src/clients/types/http.ts +8 -0
- package/src/clients/types/index.ts +0 -1
- package/src/index.ts +6 -4
- package/src/parseAWSExports.ts +0 -26
- package/src/providers/pinpoint/types/buffer.ts +1 -1
- package/src/providers/pinpoint/types/pinpoint.ts +1 -1
- package/src/singleton/types.ts +1 -4
- package/src/types/storage.ts +0 -4
- package/lib/singleton/API/types.d.ts +0 -34
- package/lib/singleton/API/types.js +0 -2
- package/lib/storage/CookieStorage.native.d.ts +0 -7
- package/lib/storage/CookieStorage.native.js +0 -32
- package/lib/storage/DefaultStorage.d.ts +0 -7
- package/lib/storage/DefaultStorage.js +0 -33
- package/lib/storage/InMemoryStorage.d.ts +0 -12
- package/lib/storage/InMemoryStorage.js +0 -41
- package/lib/storage/SessionStorage.d.ts +0 -7
- package/lib/storage/SessionStorage.js +0 -33
- package/lib/storage/index.d.ts +0 -7
- package/lib/storage/index.js +0 -14
- package/lib/storage/utils.d.ts +0 -10
- package/lib/storage/utils.js +0 -26
- package/lib-esm/singleton/API/types.d.ts +0 -34
- package/lib-esm/singleton/API/types.js +0 -1
- package/lib-esm/storage/CookieStorage.native.d.ts +0 -7
- package/lib-esm/storage/CookieStorage.native.js +0 -29
- package/lib-esm/storage/DefaultStorage.d.ts +0 -7
- package/lib-esm/storage/DefaultStorage.js +0 -30
- package/lib-esm/storage/InMemoryStorage.d.ts +0 -12
- package/lib-esm/storage/InMemoryStorage.js +0 -38
- package/lib-esm/storage/SessionStorage.d.ts +0 -7
- package/lib-esm/storage/SessionStorage.js +0 -30
- package/lib-esm/storage/index.d.ts +0 -7
- package/lib-esm/storage/index.js +0 -10
- package/lib-esm/storage/utils.d.ts +0 -10
- package/lib-esm/storage/utils.js +0 -21
- package/src/singleton/API/types.ts +0 -31
- package/src/storage/CookieStorage.native.ts +0 -13
- package/src/storage/CookieStorage.ts +0 -72
- package/src/storage/DefaultStorage.native.ts +0 -78
- package/src/storage/DefaultStorage.ts +0 -14
- package/src/storage/InMemoryStorage.ts +0 -36
- package/src/storage/SessionStorage.ts +0 -14
- package/src/storage/index.ts +0 -13
- package/src/storage/utils.ts +0 -22
|
@@ -0,0 +1,83 @@
|
|
|
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.CookieStorage = exports.MemoryKeyValueStorage = exports.LocalStorage = exports.SessionStorage = exports.StorageHelper = exports.MemoryStorage = void 0;
|
|
6
|
+
var dataMemory = {};
|
|
7
|
+
/** @class */
|
|
8
|
+
var MemoryStorage = /** @class */ (function () {
|
|
9
|
+
function MemoryStorage() {
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* This is used to set a specific item in storage
|
|
13
|
+
* @param {string} key - the key for the item
|
|
14
|
+
* @param {object} value - the value
|
|
15
|
+
* @returns {string} value that was set
|
|
16
|
+
*/
|
|
17
|
+
MemoryStorage.setItem = function (key, value) {
|
|
18
|
+
dataMemory[key] = value;
|
|
19
|
+
return dataMemory[key];
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* This is used to get a specific key from storage
|
|
23
|
+
* @param {string} key - the key for the item
|
|
24
|
+
* This is used to clear the storage
|
|
25
|
+
* @returns {string} the data item
|
|
26
|
+
*/
|
|
27
|
+
MemoryStorage.getItem = function (key) {
|
|
28
|
+
return Object.prototype.hasOwnProperty.call(dataMemory, key)
|
|
29
|
+
? dataMemory[key]
|
|
30
|
+
: undefined;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* This is used to remove an item from storage
|
|
34
|
+
* @param {string} key - the key being set
|
|
35
|
+
* @returns {string} value - value that was deleted
|
|
36
|
+
*/
|
|
37
|
+
MemoryStorage.removeItem = function (key) {
|
|
38
|
+
return delete dataMemory[key];
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* This is used to clear the storage
|
|
42
|
+
* @returns {string} nothing
|
|
43
|
+
*/
|
|
44
|
+
MemoryStorage.clear = function () {
|
|
45
|
+
dataMemory = {};
|
|
46
|
+
return dataMemory;
|
|
47
|
+
};
|
|
48
|
+
return MemoryStorage;
|
|
49
|
+
}());
|
|
50
|
+
exports.MemoryStorage = MemoryStorage;
|
|
51
|
+
var StorageHelper = /** @class */ (function () {
|
|
52
|
+
/**
|
|
53
|
+
* This is used to get a storage object
|
|
54
|
+
* @returns {object} the storage
|
|
55
|
+
*/
|
|
56
|
+
function StorageHelper() {
|
|
57
|
+
try {
|
|
58
|
+
this.storageWindow = window.localStorage;
|
|
59
|
+
this.storageWindow.setItem('aws.amplify.test-ls', 1);
|
|
60
|
+
this.storageWindow.removeItem('aws.amplify.test-ls');
|
|
61
|
+
}
|
|
62
|
+
catch (exception) {
|
|
63
|
+
this.storageWindow = MemoryStorage;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* This is used to return the storage
|
|
68
|
+
* @returns {object} the storage
|
|
69
|
+
*/
|
|
70
|
+
StorageHelper.prototype.getStorage = function () {
|
|
71
|
+
return this.storageWindow;
|
|
72
|
+
};
|
|
73
|
+
return StorageHelper;
|
|
74
|
+
}());
|
|
75
|
+
exports.StorageHelper = StorageHelper;
|
|
76
|
+
var sessionStorage_1 = require("./sessionStorage");
|
|
77
|
+
Object.defineProperty(exports, "SessionStorage", { enumerable: true, get: function () { return sessionStorage_1.SessionStorage; } });
|
|
78
|
+
var localStorage_1 = require("./localStorage");
|
|
79
|
+
Object.defineProperty(exports, "LocalStorage", { enumerable: true, get: function () { return localStorage_1.LocalStorage; } });
|
|
80
|
+
var inMemoryStorage_1 = require("./inMemoryStorage");
|
|
81
|
+
Object.defineProperty(exports, "MemoryKeyValueStorage", { enumerable: true, get: function () { return inMemoryStorage_1.MemoryKeyValueStorage; } });
|
|
82
|
+
var cookieStorage_1 = require("./cookieStorage");
|
|
83
|
+
Object.defineProperty(exports, "CookieStorage", { enumerable: true, get: function () { return cookieStorage_1.CookieStorage; } });
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { KeyValueStorageInterface } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export declare class DefaultStorage implements KeyValueStorageInterface {
|
|
6
|
-
private asyncStorage?;
|
|
1
|
+
import { KeyValueStorageInterface } from "../types";
|
|
2
|
+
declare class LocalStorageClass implements KeyValueStorageInterface {
|
|
3
|
+
storage?: Storage;
|
|
4
|
+
constructor();
|
|
7
5
|
/**
|
|
8
6
|
* This is used to set a specific item in storage
|
|
9
7
|
* @param {string} key - the key for the item
|
|
@@ -29,5 +27,6 @@ export declare class DefaultStorage implements KeyValueStorageInterface {
|
|
|
29
27
|
* @returns {string} nothing
|
|
30
28
|
*/
|
|
31
29
|
clear(): Promise<void>;
|
|
32
|
-
private assertModule;
|
|
33
30
|
}
|
|
31
|
+
export declare const LocalStorage: LocalStorageClass;
|
|
32
|
+
export {};
|
|
@@ -38,14 +38,16 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
-
exports.
|
|
41
|
+
exports.LocalStorage = void 0;
|
|
42
42
|
var Errors_1 = require("../Util/Errors");
|
|
43
|
-
/**
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
var LocalStorageClass = /** @class */ (function () {
|
|
44
|
+
function LocalStorageClass() {
|
|
45
|
+
if (typeof window !== undefined) {
|
|
46
|
+
try {
|
|
47
|
+
this.storage = window === null || window === void 0 ? void 0 : window.localStorage;
|
|
48
|
+
}
|
|
49
|
+
catch (error) { }
|
|
50
|
+
}
|
|
49
51
|
}
|
|
50
52
|
/**
|
|
51
53
|
* This is used to set a specific item in storage
|
|
@@ -53,7 +55,7 @@ var KeyValueStorage = /** @class */ (function () {
|
|
|
53
55
|
* @param {object} value - the value
|
|
54
56
|
* @returns {string} value that was set
|
|
55
57
|
*/
|
|
56
|
-
|
|
58
|
+
LocalStorageClass.prototype.setItem = function (key, value) {
|
|
57
59
|
return __awaiter(this, void 0, void 0, function () {
|
|
58
60
|
return __generator(this, function (_a) {
|
|
59
61
|
if (!this.storage)
|
|
@@ -69,7 +71,7 @@ var KeyValueStorage = /** @class */ (function () {
|
|
|
69
71
|
* This is used to clear the storage
|
|
70
72
|
* @returns {string} the data item
|
|
71
73
|
*/
|
|
72
|
-
|
|
74
|
+
LocalStorageClass.prototype.getItem = function (key) {
|
|
73
75
|
return __awaiter(this, void 0, void 0, function () {
|
|
74
76
|
return __generator(this, function (_a) {
|
|
75
77
|
if (!this.storage)
|
|
@@ -83,7 +85,7 @@ var KeyValueStorage = /** @class */ (function () {
|
|
|
83
85
|
* @param {string} key - the key being set
|
|
84
86
|
* @returns {string} value - value that was deleted
|
|
85
87
|
*/
|
|
86
|
-
|
|
88
|
+
LocalStorageClass.prototype.removeItem = function (key) {
|
|
87
89
|
return __awaiter(this, void 0, void 0, function () {
|
|
88
90
|
return __generator(this, function (_a) {
|
|
89
91
|
if (!this.storage)
|
|
@@ -97,7 +99,7 @@ var KeyValueStorage = /** @class */ (function () {
|
|
|
97
99
|
* This is used to clear the storage
|
|
98
100
|
* @returns {string} nothing
|
|
99
101
|
*/
|
|
100
|
-
|
|
102
|
+
LocalStorageClass.prototype.clear = function () {
|
|
101
103
|
return __awaiter(this, void 0, void 0, function () {
|
|
102
104
|
return __generator(this, function (_a) {
|
|
103
105
|
if (!this.storage)
|
|
@@ -107,6 +109,6 @@ var KeyValueStorage = /** @class */ (function () {
|
|
|
107
109
|
});
|
|
108
110
|
});
|
|
109
111
|
};
|
|
110
|
-
return
|
|
112
|
+
return LocalStorageClass;
|
|
111
113
|
}());
|
|
112
|
-
exports.
|
|
114
|
+
exports.LocalStorage = new LocalStorageClass();
|
|
@@ -0,0 +1,83 @@
|
|
|
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
|
+
}
|
|
36
|
+
export declare class StorageHelper {
|
|
37
|
+
private storageWindow;
|
|
38
|
+
/**
|
|
39
|
+
* This is used to get a storage object
|
|
40
|
+
* @returns {object} the storage
|
|
41
|
+
*/
|
|
42
|
+
constructor();
|
|
43
|
+
/**
|
|
44
|
+
* This is used to return the storage
|
|
45
|
+
* @returns {object} the storage
|
|
46
|
+
*/
|
|
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>;
|
|
81
|
+
}
|
|
82
|
+
export declare const AsyncStorageKeyValue: AsyncStorageClass;
|
|
83
|
+
export {};
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
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;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.AsyncStorageKeyValue = exports.StorageHelper = void 0;
|
|
43
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
44
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
45
|
+
var async_storage_1 = __importDefault(require("@react-native-async-storage/async-storage"));
|
|
46
|
+
var MEMORY_KEY_PREFIX = '@MemoryStorage:';
|
|
47
|
+
var dataMemory = {};
|
|
48
|
+
/** @class */
|
|
49
|
+
var MemoryStorage = /** @class */ (function () {
|
|
50
|
+
function MemoryStorage() {
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* This is used to set a specific item in storage
|
|
54
|
+
* @param {string} key - the key for the item
|
|
55
|
+
* @param {object} value - the value
|
|
56
|
+
* @returns {string} value that was set
|
|
57
|
+
*/
|
|
58
|
+
MemoryStorage.setItem = function (key, value) {
|
|
59
|
+
if (value) {
|
|
60
|
+
async_storage_1.default.setItem(MEMORY_KEY_PREFIX + key, value);
|
|
61
|
+
dataMemory[key] = value;
|
|
62
|
+
return dataMemory[key];
|
|
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
|
+
MemoryStorage.getItem = function (key) {
|
|
72
|
+
return Object.prototype.hasOwnProperty.call(dataMemory, key)
|
|
73
|
+
? dataMemory[key]
|
|
74
|
+
: undefined;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* This is used to remove an item from storage
|
|
78
|
+
* @param {string} key - the key being set
|
|
79
|
+
* @returns {string} value - value that was deleted
|
|
80
|
+
*/
|
|
81
|
+
MemoryStorage.removeItem = function (key) {
|
|
82
|
+
async_storage_1.default.removeItem(MEMORY_KEY_PREFIX + key);
|
|
83
|
+
return delete dataMemory[key];
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* This is used to clear the storage
|
|
87
|
+
* @returns {string} nothing
|
|
88
|
+
*/
|
|
89
|
+
MemoryStorage.clear = function () {
|
|
90
|
+
dataMemory = {};
|
|
91
|
+
return dataMemory;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Will sync the MemoryStorage data from AsyncStorage to storageWindow MemoryStorage
|
|
95
|
+
* @returns {void}
|
|
96
|
+
*/
|
|
97
|
+
MemoryStorage.sync = function () {
|
|
98
|
+
if (!MemoryStorage.syncPromise) {
|
|
99
|
+
MemoryStorage.syncPromise = new Promise(function (res, rej) {
|
|
100
|
+
async_storage_1.default.getAllKeys(function (errKeys, keys) {
|
|
101
|
+
var _a;
|
|
102
|
+
if (errKeys)
|
|
103
|
+
rej(errKeys);
|
|
104
|
+
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 : [];
|
|
105
|
+
async_storage_1.default.multiGet(memoryKeys, function (err, stores) {
|
|
106
|
+
if (err)
|
|
107
|
+
rej(err);
|
|
108
|
+
stores &&
|
|
109
|
+
stores.map(function (result, index, store) {
|
|
110
|
+
var key = store[index][0];
|
|
111
|
+
var value = store[index][1];
|
|
112
|
+
var memoryKey = key.replace(MEMORY_KEY_PREFIX, '');
|
|
113
|
+
dataMemory[memoryKey] = value;
|
|
114
|
+
});
|
|
115
|
+
res();
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
return MemoryStorage.syncPromise;
|
|
121
|
+
};
|
|
122
|
+
MemoryStorage.syncPromise = null;
|
|
123
|
+
return MemoryStorage;
|
|
124
|
+
}());
|
|
125
|
+
var StorageHelper = /** @class */ (function () {
|
|
126
|
+
/**
|
|
127
|
+
* This is used to get a storage object
|
|
128
|
+
* @returns {object} the storage
|
|
129
|
+
*/
|
|
130
|
+
function StorageHelper() {
|
|
131
|
+
this.storageWindow = MemoryStorage;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* This is used to return the storage
|
|
135
|
+
* @returns {object} the storage
|
|
136
|
+
*/
|
|
137
|
+
StorageHelper.prototype.getStorage = function () {
|
|
138
|
+
return this.storageWindow;
|
|
139
|
+
};
|
|
140
|
+
return StorageHelper;
|
|
141
|
+
}());
|
|
142
|
+
exports.StorageHelper = StorageHelper;
|
|
143
|
+
var AsyncStorageClass = /** @class */ (function () {
|
|
144
|
+
function AsyncStorageClass() {
|
|
145
|
+
this.syncPromise = null;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* This is used to set a specific item in storage
|
|
149
|
+
* @param {string} key - the key for the item
|
|
150
|
+
* @param {object} value - the value
|
|
151
|
+
* @returns {string} value that was set
|
|
152
|
+
*/
|
|
153
|
+
AsyncStorageClass.prototype.setItem = function (key, value) {
|
|
154
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
155
|
+
return __generator(this, function (_a) {
|
|
156
|
+
switch (_a.label) {
|
|
157
|
+
case 0:
|
|
158
|
+
if (!value) return [3 /*break*/, 2];
|
|
159
|
+
return [4 /*yield*/, async_storage_1.default.setItem(MEMORY_KEY_PREFIX + key, value)];
|
|
160
|
+
case 1:
|
|
161
|
+
_a.sent();
|
|
162
|
+
dataMemory[key] = value;
|
|
163
|
+
_a.label = 2;
|
|
164
|
+
case 2: return [2 /*return*/];
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
};
|
|
169
|
+
/**
|
|
170
|
+
* This is used to get a specific key from storage
|
|
171
|
+
* @param {string} key - the key for the item
|
|
172
|
+
* This is used to clear the storage
|
|
173
|
+
* @returns {string} the data item
|
|
174
|
+
*/
|
|
175
|
+
AsyncStorageClass.prototype.getItem = function (key) {
|
|
176
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
177
|
+
return __generator(this, function (_a) {
|
|
178
|
+
return [2 /*return*/, Object.prototype.hasOwnProperty.call(dataMemory, key)
|
|
179
|
+
? dataMemory[key]
|
|
180
|
+
: null];
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
};
|
|
184
|
+
/**
|
|
185
|
+
* This is used to remove an item from storage
|
|
186
|
+
* @param {string} key - the key being set
|
|
187
|
+
* @returns {string} value - value that was deleted
|
|
188
|
+
*/
|
|
189
|
+
AsyncStorageClass.prototype.removeItem = function (key) {
|
|
190
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
191
|
+
return __generator(this, function (_a) {
|
|
192
|
+
switch (_a.label) {
|
|
193
|
+
case 0: return [4 /*yield*/, async_storage_1.default.removeItem(MEMORY_KEY_PREFIX + key)];
|
|
194
|
+
case 1:
|
|
195
|
+
_a.sent();
|
|
196
|
+
delete dataMemory[key];
|
|
197
|
+
return [2 /*return*/];
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
};
|
|
202
|
+
/**
|
|
203
|
+
* This is used to clear the storage
|
|
204
|
+
* @returns {string} nothing
|
|
205
|
+
*/
|
|
206
|
+
AsyncStorageClass.prototype.clear = function () {
|
|
207
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
208
|
+
return __generator(this, function (_a) {
|
|
209
|
+
dataMemory = {};
|
|
210
|
+
return [2 /*return*/];
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
};
|
|
214
|
+
/**
|
|
215
|
+
* Will sync the MemoryStorage data from AsyncStorage to storageWindow MemoryStorage
|
|
216
|
+
* @returns {void}
|
|
217
|
+
*/
|
|
218
|
+
AsyncStorageClass.prototype.sync = function () {
|
|
219
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
220
|
+
return __generator(this, function (_a) {
|
|
221
|
+
if (!this.syncPromise) {
|
|
222
|
+
this.syncPromise = new Promise(function (res, rej) {
|
|
223
|
+
async_storage_1.default.getAllKeys(function (errKeys, keys) {
|
|
224
|
+
var _a;
|
|
225
|
+
if (errKeys)
|
|
226
|
+
rej(errKeys);
|
|
227
|
+
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 : [];
|
|
228
|
+
async_storage_1.default.multiGet(memoryKeys, function (err, stores) {
|
|
229
|
+
if (err)
|
|
230
|
+
rej(err);
|
|
231
|
+
stores &&
|
|
232
|
+
stores.map(function (result, index, store) {
|
|
233
|
+
var key = store[index][0];
|
|
234
|
+
var value = store[index][1];
|
|
235
|
+
var memoryKey = key.replace(MEMORY_KEY_PREFIX, '');
|
|
236
|
+
dataMemory[memoryKey] = value;
|
|
237
|
+
});
|
|
238
|
+
res();
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
return [2 /*return*/];
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
};
|
|
247
|
+
return AsyncStorageClass;
|
|
248
|
+
}());
|
|
249
|
+
// TODO: Add this to the react-native Amplify package.
|
|
250
|
+
exports.AsyncStorageKeyValue = new AsyncStorageClass();
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { KeyValueStorageInterface } from '../types';
|
|
2
|
-
|
|
3
|
-
* @internal
|
|
4
|
-
*/
|
|
5
|
-
export declare class KeyValueStorage implements KeyValueStorageInterface {
|
|
2
|
+
declare class SessionStorageClass implements KeyValueStorageInterface {
|
|
6
3
|
storage?: Storage;
|
|
7
|
-
constructor(
|
|
4
|
+
constructor();
|
|
8
5
|
/**
|
|
9
6
|
* This is used to set a specific item in storage
|
|
10
7
|
* @param {string} key - the key for the item
|
|
@@ -31,3 +28,5 @@ export declare class KeyValueStorage implements KeyValueStorageInterface {
|
|
|
31
28
|
*/
|
|
32
29
|
clear(): Promise<void>;
|
|
33
30
|
}
|
|
31
|
+
export declare const SessionStorage: SessionStorageClass;
|
|
32
|
+
export {};
|
|
@@ -38,15 +38,16 @@ 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
|
-
|
|
41
|
+
exports.SessionStorage = void 0;
|
|
42
|
+
var Errors_1 = require("../Util/Errors");
|
|
43
|
+
var SessionStorageClass = /** @class */ (function () {
|
|
44
|
+
function SessionStorageClass() {
|
|
45
|
+
if (typeof window !== undefined) {
|
|
46
|
+
try {
|
|
47
|
+
this.storage = window === null || window === void 0 ? void 0 : window.sessionStorage;
|
|
48
|
+
}
|
|
49
|
+
catch (error) { }
|
|
50
|
+
}
|
|
50
51
|
}
|
|
51
52
|
/**
|
|
52
53
|
* This is used to set a specific item in storage
|
|
@@ -54,9 +55,15 @@ var DefaultStorage = /** @class */ (function () {
|
|
|
54
55
|
* @param {object} value - the value
|
|
55
56
|
* @returns {string} value that was set
|
|
56
57
|
*/
|
|
57
|
-
|
|
58
|
-
this
|
|
59
|
-
|
|
58
|
+
SessionStorageClass.prototype.setItem = function (key, value) {
|
|
59
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
60
|
+
return __generator(this, function (_a) {
|
|
61
|
+
if (!this.storage)
|
|
62
|
+
throw Errors_1.PlatformNotSupportedError;
|
|
63
|
+
this.storage.setItem(key, value);
|
|
64
|
+
return [2 /*return*/];
|
|
65
|
+
});
|
|
66
|
+
});
|
|
60
67
|
};
|
|
61
68
|
/**
|
|
62
69
|
* This is used to get a specific key from storage
|
|
@@ -64,54 +71,44 @@ var DefaultStorage = /** @class */ (function () {
|
|
|
64
71
|
* This is used to clear the storage
|
|
65
72
|
* @returns {string} the data item
|
|
66
73
|
*/
|
|
67
|
-
|
|
68
|
-
this
|
|
69
|
-
|
|
74
|
+
SessionStorageClass.prototype.getItem = function (key) {
|
|
75
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
76
|
+
return __generator(this, function (_a) {
|
|
77
|
+
if (!this.storage)
|
|
78
|
+
throw Errors_1.PlatformNotSupportedError;
|
|
79
|
+
return [2 /*return*/, this.storage.getItem(key)];
|
|
80
|
+
});
|
|
81
|
+
});
|
|
70
82
|
};
|
|
71
83
|
/**
|
|
72
84
|
* This is used to remove an item from storage
|
|
73
85
|
* @param {string} key - the key being set
|
|
74
86
|
* @returns {string} value - value that was deleted
|
|
75
87
|
*/
|
|
76
|
-
|
|
77
|
-
this
|
|
78
|
-
|
|
88
|
+
SessionStorageClass.prototype.removeItem = function (key) {
|
|
89
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
90
|
+
return __generator(this, function (_a) {
|
|
91
|
+
if (!this.storage)
|
|
92
|
+
throw Errors_1.PlatformNotSupportedError;
|
|
93
|
+
this.storage.removeItem(key);
|
|
94
|
+
return [2 /*return*/];
|
|
95
|
+
});
|
|
96
|
+
});
|
|
79
97
|
};
|
|
80
98
|
/**
|
|
81
99
|
* This is used to clear the storage
|
|
82
100
|
* @returns {string} nothing
|
|
83
101
|
*/
|
|
84
|
-
|
|
102
|
+
SessionStorageClass.prototype.clear = function () {
|
|
85
103
|
return __awaiter(this, void 0, void 0, function () {
|
|
86
|
-
var allKeys;
|
|
87
104
|
return __generator(this, function (_a) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
}
|
|
105
|
+
if (!this.storage)
|
|
106
|
+
throw Errors_1.PlatformNotSupportedError;
|
|
107
|
+
this.storage.clear();
|
|
108
|
+
return [2 /*return*/];
|
|
96
109
|
});
|
|
97
110
|
});
|
|
98
111
|
};
|
|
99
|
-
|
|
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;
|
|
112
|
+
return SessionStorageClass;
|
|
116
113
|
}());
|
|
117
|
-
exports.
|
|
114
|
+
exports.SessionStorage = new SessionStorageClass();
|
|
@@ -2,4 +2,4 @@ import { RetryOptions } from '../middleware/retry';
|
|
|
2
2
|
import { SigningOptions } from '../middleware/signing';
|
|
3
3
|
import { UserAgentOptions } from '../middleware/userAgent';
|
|
4
4
|
import { HttpRequest, HttpResponse } from '../types';
|
|
5
|
-
export declare const authenticatedHandler: (request: HttpRequest, options: UserAgentOptions & RetryOptions<HttpResponse> & SigningOptions) => Promise<HttpResponse>;
|
|
5
|
+
export declare const authenticatedHandler: (request: HttpRequest, options: UserAgentOptions & RetryOptions<HttpResponse> & SigningOptions & import("../types").HttpTransferOptions) => Promise<HttpResponse>;
|
|
@@ -57,7 +57,7 @@ var shouldSendBody = function (method) {
|
|
|
57
57
|
// TODO[AllanZhengYP]: we need to provide isCanceledError utility
|
|
58
58
|
var fetchTransferHandler = function (_a, _b) {
|
|
59
59
|
var url = _a.url, method = _a.method, headers = _a.headers, body = _a.body;
|
|
60
|
-
var abortSignal = _b.abortSignal;
|
|
60
|
+
var abortSignal = _b.abortSignal, cache = _b.cache;
|
|
61
61
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
62
62
|
var resp, e_1, responseHeaders, httpResponse, bodyWithMixin;
|
|
63
63
|
var _c, _d;
|
|
@@ -70,6 +70,7 @@ var fetchTransferHandler = function (_a, _b) {
|
|
|
70
70
|
headers: headers,
|
|
71
71
|
body: shouldSendBody(method) ? body : undefined,
|
|
72
72
|
signal: abortSignal,
|
|
73
|
+
cache: cache,
|
|
73
74
|
})];
|
|
74
75
|
case 1:
|
|
75
76
|
resp = _e.sent();
|