@aws-amplify/core 6.0.1-console-preview.047a1dd.0 → 6.0.1-next.054df96.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.
Files changed (122) hide show
  1. package/lib/Cache/Utils/CacheUtils.js +4 -2
  2. package/lib/Platform/version.d.ts +1 -1
  3. package/lib/Platform/version.js +1 -1
  4. package/lib/RNComponents/index.d.ts +6 -0
  5. package/lib/RNComponents/index.js +16 -0
  6. package/lib/{providers/pinpoint/utils → RNComponents}/isAppInForeground.js +4 -1
  7. package/lib/RNComponents/reactnative.d.ts +3 -0
  8. package/lib/RNComponents/reactnative.js +14 -0
  9. package/lib/{storage/CookieStorage.d.ts → StorageHelper/cookieStorage.d.ts} +3 -4
  10. package/lib/{storage/CookieStorage.js → StorageHelper/cookieStorage.js} +83 -35
  11. package/lib/StorageHelper/inMemoryStorage.d.ts +10 -0
  12. package/lib/StorageHelper/inMemoryStorage.js +82 -0
  13. package/lib/StorageHelper/index.d.ts +45 -0
  14. package/lib/StorageHelper/index.js +83 -0
  15. package/lib/{storage/DefaultStorage.native.d.ts → StorageHelper/localStorage.d.ts} +6 -7
  16. package/lib/{storage/KeyValueStorage.js → StorageHelper/localStorage.js} +15 -13
  17. package/lib/StorageHelper/reactnative.d.ts +83 -0
  18. package/lib/StorageHelper/reactnative.js +250 -0
  19. package/lib/{storage/KeyValueStorage.d.ts → StorageHelper/sessionStorage.d.ts} +4 -5
  20. package/lib/{storage/DefaultStorage.native.js → StorageHelper/sessionStorage.js} +43 -46
  21. package/lib/index.d.ts +1 -1
  22. package/lib/index.js +8 -6
  23. package/lib/libraryUtils.d.ts +1 -0
  24. package/lib/libraryUtils.js +5 -1
  25. package/lib/parseAWSExports.js +1 -20
  26. package/lib/providers/pinpoint/utils/PinpointEventBuffer.js +5 -7
  27. package/lib/singleton/types.d.ts +1 -4
  28. package/lib/tsconfig.tsbuildinfo +1 -1
  29. package/lib/types/storage.d.ts +0 -3
  30. package/lib-esm/Cache/Utils/CacheUtils.js +4 -2
  31. package/lib-esm/Platform/version.d.ts +1 -1
  32. package/lib-esm/Platform/version.js +1 -1
  33. package/lib-esm/RNComponents/index.d.ts +6 -0
  34. package/lib-esm/RNComponents/index.js +13 -0
  35. package/lib-esm/RNComponents/isAppInForeground.js +6 -0
  36. package/lib-esm/RNComponents/reactnative.d.ts +3 -0
  37. package/lib-esm/RNComponents/reactnative.js +6 -0
  38. package/lib-esm/{storage/CookieStorage.d.ts → StorageHelper/cookieStorage.d.ts} +3 -4
  39. package/lib-esm/{storage/CookieStorage.js → StorageHelper/cookieStorage.js} +61 -36
  40. package/lib-esm/StorageHelper/inMemoryStorage.d.ts +10 -0
  41. package/lib-esm/StorageHelper/inMemoryStorage.js +79 -0
  42. package/lib-esm/StorageHelper/index.d.ts +45 -0
  43. package/lib-esm/StorageHelper/index.js +76 -0
  44. package/lib-esm/{storage/DefaultStorage.native.d.ts → StorageHelper/localStorage.d.ts} +6 -7
  45. package/lib-esm/{storage/KeyValueStorage.js → StorageHelper/localStorage.js} +14 -12
  46. package/lib-esm/StorageHelper/reactnative.d.ts +83 -0
  47. package/lib-esm/StorageHelper/reactnative.js +244 -0
  48. package/lib-esm/{storage/KeyValueStorage.d.ts → StorageHelper/sessionStorage.d.ts} +4 -5
  49. package/lib-esm/{storage/DefaultStorage.native.js → StorageHelper/sessionStorage.js} +42 -45
  50. package/lib-esm/index.d.ts +1 -1
  51. package/lib-esm/index.js +1 -1
  52. package/lib-esm/libraryUtils.d.ts +1 -0
  53. package/lib-esm/libraryUtils.js +1 -0
  54. package/lib-esm/parseAWSExports.js +1 -20
  55. package/lib-esm/providers/pinpoint/utils/PinpointEventBuffer.js +5 -7
  56. package/lib-esm/singleton/types.d.ts +1 -4
  57. package/lib-esm/tsconfig.tsbuildinfo +1 -1
  58. package/lib-esm/types/storage.d.ts +0 -3
  59. package/package.json +4 -3
  60. package/src/Cache/Utils/CacheUtils.ts +4 -2
  61. package/src/Platform/version.ts +1 -1
  62. package/src/RNComponents/index.ts +16 -0
  63. package/src/RNComponents/isAppInForeground.ts +8 -0
  64. package/src/RNComponents/reactnative.ts +6 -0
  65. package/src/StorageHelper/cookieStorage.ts +99 -0
  66. package/src/StorageHelper/inMemoryStorage.ts +32 -0
  67. package/src/StorageHelper/index.ts +78 -0
  68. package/src/StorageHelper/localStorage.ts +60 -0
  69. package/src/StorageHelper/reactnative.ts +182 -0
  70. package/src/{storage/KeyValueStorage.ts → StorageHelper/sessionStorage.ts} +13 -10
  71. package/src/index.ts +6 -4
  72. package/src/libraryUtils.ts +1 -0
  73. package/src/parseAWSExports.ts +0 -26
  74. package/src/providers/pinpoint/utils/PinpointEventBuffer.ts +12 -16
  75. package/src/singleton/types.ts +1 -4
  76. package/src/types/storage.ts +0 -4
  77. package/lib/providers/pinpoint/utils/isAppInForeground.native.d.ts +0 -1
  78. package/lib/providers/pinpoint/utils/isAppInForeground.native.js +0 -9
  79. package/lib/singleton/API/types.d.ts +0 -34
  80. package/lib/singleton/API/types.js +0 -2
  81. package/lib/storage/CookieStorage.native.d.ts +0 -7
  82. package/lib/storage/CookieStorage.native.js +0 -32
  83. package/lib/storage/DefaultStorage.d.ts +0 -7
  84. package/lib/storage/DefaultStorage.js +0 -33
  85. package/lib/storage/InMemoryStorage.d.ts +0 -12
  86. package/lib/storage/InMemoryStorage.js +0 -41
  87. package/lib/storage/SessionStorage.d.ts +0 -7
  88. package/lib/storage/SessionStorage.js +0 -33
  89. package/lib/storage/index.d.ts +0 -7
  90. package/lib/storage/index.js +0 -14
  91. package/lib/storage/utils.d.ts +0 -10
  92. package/lib/storage/utils.js +0 -26
  93. package/lib-esm/providers/pinpoint/utils/isAppInForeground.js +0 -3
  94. package/lib-esm/providers/pinpoint/utils/isAppInForeground.native.d.ts +0 -1
  95. package/lib-esm/providers/pinpoint/utils/isAppInForeground.native.js +0 -5
  96. package/lib-esm/singleton/API/types.d.ts +0 -34
  97. package/lib-esm/singleton/API/types.js +0 -1
  98. package/lib-esm/storage/CookieStorage.native.d.ts +0 -7
  99. package/lib-esm/storage/CookieStorage.native.js +0 -29
  100. package/lib-esm/storage/DefaultStorage.d.ts +0 -7
  101. package/lib-esm/storage/DefaultStorage.js +0 -30
  102. package/lib-esm/storage/InMemoryStorage.d.ts +0 -12
  103. package/lib-esm/storage/InMemoryStorage.js +0 -38
  104. package/lib-esm/storage/SessionStorage.d.ts +0 -7
  105. package/lib-esm/storage/SessionStorage.js +0 -30
  106. package/lib-esm/storage/index.d.ts +0 -7
  107. package/lib-esm/storage/index.js +0 -10
  108. package/lib-esm/storage/utils.d.ts +0 -10
  109. package/lib-esm/storage/utils.js +0 -21
  110. package/src/providers/pinpoint/utils/isAppInForeground.native.ts +0 -7
  111. package/src/providers/pinpoint/utils/isAppInForeground.ts +0 -4
  112. package/src/singleton/API/types.ts +0 -31
  113. package/src/storage/CookieStorage.native.ts +0 -13
  114. package/src/storage/CookieStorage.ts +0 -72
  115. package/src/storage/DefaultStorage.native.ts +0 -78
  116. package/src/storage/DefaultStorage.ts +0 -14
  117. package/src/storage/InMemoryStorage.ts +0 -36
  118. package/src/storage/SessionStorage.ts +0 -14
  119. package/src/storage/index.ts +0 -13
  120. package/src/storage/utils.ts +0 -22
  121. /package/lib/{providers/pinpoint/utils → RNComponents}/isAppInForeground.d.ts +0 -0
  122. /package/lib-esm/{providers/pinpoint/utils → RNComponents}/isAppInForeground.d.ts +0 -0
@@ -0,0 +1,244 @@
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
+ };
37
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
38
+ // SPDX-License-Identifier: Apache-2.0
39
+ import AsyncStorage from '@react-native-async-storage/async-storage';
40
+ var MEMORY_KEY_PREFIX = '@MemoryStorage:';
41
+ var dataMemory = {};
42
+ /** @class */
43
+ var MemoryStorage = /** @class */ (function () {
44
+ function MemoryStorage() {
45
+ }
46
+ /**
47
+ * This is used to set a specific item in storage
48
+ * @param {string} key - the key for the item
49
+ * @param {object} value - the value
50
+ * @returns {string} value that was set
51
+ */
52
+ MemoryStorage.setItem = function (key, value) {
53
+ if (value) {
54
+ AsyncStorage.setItem(MEMORY_KEY_PREFIX + key, value);
55
+ dataMemory[key] = value;
56
+ return dataMemory[key];
57
+ }
58
+ };
59
+ /**
60
+ * This is used to get a specific key from storage
61
+ * @param {string} key - the key for the item
62
+ * This is used to clear the storage
63
+ * @returns {string} the data item
64
+ */
65
+ MemoryStorage.getItem = function (key) {
66
+ return Object.prototype.hasOwnProperty.call(dataMemory, key)
67
+ ? dataMemory[key]
68
+ : undefined;
69
+ };
70
+ /**
71
+ * This is used to remove an item from storage
72
+ * @param {string} key - the key being set
73
+ * @returns {string} value - value that was deleted
74
+ */
75
+ MemoryStorage.removeItem = function (key) {
76
+ AsyncStorage.removeItem(MEMORY_KEY_PREFIX + key);
77
+ return delete dataMemory[key];
78
+ };
79
+ /**
80
+ * This is used to clear the storage
81
+ * @returns {string} nothing
82
+ */
83
+ MemoryStorage.clear = function () {
84
+ dataMemory = {};
85
+ return dataMemory;
86
+ };
87
+ /**
88
+ * Will sync the MemoryStorage data from AsyncStorage to storageWindow MemoryStorage
89
+ * @returns {void}
90
+ */
91
+ MemoryStorage.sync = function () {
92
+ if (!MemoryStorage.syncPromise) {
93
+ MemoryStorage.syncPromise = new Promise(function (res, rej) {
94
+ AsyncStorage.getAllKeys(function (errKeys, keys) {
95
+ var _a;
96
+ if (errKeys)
97
+ rej(errKeys);
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 : [];
99
+ AsyncStorage.multiGet(memoryKeys, function (err, stores) {
100
+ if (err)
101
+ rej(err);
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
+ });
109
+ res();
110
+ });
111
+ });
112
+ });
113
+ }
114
+ return MemoryStorage.syncPromise;
115
+ };
116
+ MemoryStorage.syncPromise = null;
117
+ return MemoryStorage;
118
+ }());
119
+ var StorageHelper = /** @class */ (function () {
120
+ /**
121
+ * This is used to get a storage object
122
+ * @returns {object} the storage
123
+ */
124
+ function StorageHelper() {
125
+ this.storageWindow = MemoryStorage;
126
+ }
127
+ /**
128
+ * This is used to return the storage
129
+ * @returns {object} the storage
130
+ */
131
+ StorageHelper.prototype.getStorage = function () {
132
+ return this.storageWindow;
133
+ };
134
+ return StorageHelper;
135
+ }());
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();
@@ -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(storage?: Storage);
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 {};
@@ -36,14 +36,15 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
36
36
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
37
37
  }
38
38
  };
39
- import { AmplifyError } from '../libraryUtils';
40
- var ASYNC_STORAGE_MODULE = '@react-native-async-storage/async-storage';
41
- var MEMORY_KEY_PREFIX = '@MemoryStorage:';
42
- /**
43
- * @internal
44
- */
45
- var DefaultStorage = /** @class */ (function () {
46
- function DefaultStorage() {
39
+ import { PlatformNotSupportedError } from '../Util/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
+ }
47
48
  }
48
49
  /**
49
50
  * This is used to set a specific item in storage
@@ -51,9 +52,15 @@ var DefaultStorage = /** @class */ (function () {
51
52
  * @param {object} value - the value
52
53
  * @returns {string} value that was set
53
54
  */
54
- DefaultStorage.prototype.setItem = function (key, value) {
55
- this.assertModule(this.asyncStorage);
56
- return this.asyncStorage.setItem("".concat(MEMORY_KEY_PREFIX).concat(key), value);
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
+ });
57
64
  };
58
65
  /**
59
66
  * This is used to get a specific key from storage
@@ -61,54 +68,44 @@ var DefaultStorage = /** @class */ (function () {
61
68
  * This is used to clear the storage
62
69
  * @returns {string} the data item
63
70
  */
64
- DefaultStorage.prototype.getItem = function (key) {
65
- this.assertModule(this.asyncStorage);
66
- return this.asyncStorage.getItem("".concat(MEMORY_KEY_PREFIX).concat(key));
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
+ });
67
79
  };
68
80
  /**
69
81
  * This is used to remove an item from storage
70
82
  * @param {string} key - the key being set
71
83
  * @returns {string} value - value that was deleted
72
84
  */
73
- DefaultStorage.prototype.removeItem = function (key) {
74
- this.assertModule(this.asyncStorage);
75
- return this.asyncStorage.removeItem("".concat(MEMORY_KEY_PREFIX).concat(key));
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
+ });
76
94
  };
77
95
  /**
78
96
  * This is used to clear the storage
79
97
  * @returns {string} nothing
80
98
  */
81
- DefaultStorage.prototype.clear = function () {
99
+ SessionStorageClass.prototype.clear = function () {
82
100
  return __awaiter(this, void 0, void 0, function () {
83
- var allKeys;
84
101
  return __generator(this, function (_a) {
85
- switch (_a.label) {
86
- case 0:
87
- this.assertModule(this.asyncStorage);
88
- return [4 /*yield*/, this.asyncStorage.getAllKeys()];
89
- case 1:
90
- allKeys = _a.sent();
91
- return [2 /*return*/, this.asyncStorage.multiRemove(allKeys.filter(function (key) { return key.startsWith(MEMORY_KEY_PREFIX); }))];
92
- }
102
+ if (!this.storage)
103
+ throw PlatformNotSupportedError;
104
+ this.storage.clear();
105
+ return [2 /*return*/];
93
106
  });
94
107
  });
95
108
  };
96
- DefaultStorage.prototype.assertModule = function (asyncStorage) {
97
- if (!!asyncStorage) {
98
- return;
99
- }
100
- try {
101
- this.asyncStorage = require(ASYNC_STORAGE_MODULE)
102
- .default;
103
- }
104
- catch (err) {
105
- throw new AmplifyError({
106
- name: 'NativeModuleException',
107
- message: "Unable to find ".concat(ASYNC_STORAGE_MODULE),
108
- recoverySuggestion: "Make sure to install ".concat(ASYNC_STORAGE_MODULE),
109
- });
110
- }
111
- };
112
- return DefaultStorage;
109
+ return SessionStorageClass;
113
110
  }());
114
- export { DefaultStorage };
111
+ export var SessionStorage = new SessionStorageClass();
@@ -5,7 +5,7 @@ export { AuthConfig, AuthUserPoolConfig, AuthUserPoolAndIdentityPoolConfig, Stor
5
5
  export { Amplify, fetchAuthSession, AmplifyClass as AmplifyClassV6, clearCredentials, } from './singleton';
6
6
  export { getCredentialsForIdentity, getId, GetCredentialsForIdentityInput, GetCredentialsForIdentityOutput, } from './AwsClients/CognitoIdentity';
7
7
  export { UserProfile } from './types';
8
- export { CookieStorage, defaultStorage, sessionStorage, sharedInMemoryStorage, } from './storage';
8
+ export { StorageHelper, MemoryStorage, LocalStorage, CookieStorage, SessionStorage, MemoryKeyValueStorage, } from './StorageHelper';
9
9
  export { KeyValueStorageInterface } from './types';
10
10
  import { BrowserStorageCache } from './Cache/BrowserStorageCache';
11
11
  export { InMemoryCache } from './Cache/InMemoryCache';
package/lib-esm/index.js CHANGED
@@ -9,7 +9,7 @@ export { Amplify, fetchAuthSession, AmplifyClass as AmplifyClassV6, clearCredent
9
9
  // AWSClients exports
10
10
  export { getCredentialsForIdentity, getId, } from './AwsClients/CognitoIdentity';
11
11
  // Storage helpers
12
- export { CookieStorage, defaultStorage, sessionStorage, sharedInMemoryStorage, } from './storage';
12
+ export { StorageHelper, MemoryStorage, LocalStorage, CookieStorage, SessionStorage, MemoryKeyValueStorage, } from './StorageHelper';
13
13
  // Cache exports
14
14
  import { BrowserStorageCache } from './Cache/BrowserStorageCache';
15
15
  export { InMemoryCache } from './Cache/InMemoryCache';
@@ -16,6 +16,7 @@ export { ServiceWorker } from './ServiceWorker';
16
16
  export { AWS_CLOUDWATCH_CATEGORY, BackgroundManagerNotOpenError, BackgroundProcessManager, BackgroundProcessManagerState, DateUtils, Mutex, NO_CREDS_ERROR_STRING, NonRetryableError, RETRY_ERROR_CODES, Reachability, isNonRetryableError, jitteredBackoff, jitteredExponentialRetry, retry, urlSafeDecode, urlSafeEncode, } from './Util';
17
17
  export { asserts } from './Util/errors/AssertError';
18
18
  export { invalidParameter, missingConfig, AmplifyError, AmplifyErrorString, } from './Util/Errors';
19
+ export { AppState, AsyncStorage, Linking } from './RNComponents';
19
20
  export { ErrorParams, AmplifyErrorMap, ServiceError } from './types';
20
21
  export { INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER, USER_AGENT_HEADER, } from './Util/Constants';
21
22
  export { fetchAuthSession } from './singleton/apis/internal/fetchAuthSession';
@@ -27,6 +27,7 @@ export { ServiceWorker } from './ServiceWorker';
27
27
  export { AWS_CLOUDWATCH_CATEGORY, BackgroundManagerNotOpenError, BackgroundProcessManager, BackgroundProcessManagerState, DateUtils, Mutex, NO_CREDS_ERROR_STRING, NonRetryableError, RETRY_ERROR_CODES, Reachability, isNonRetryableError, jitteredBackoff, jitteredExponentialRetry, retry, urlSafeDecode, urlSafeEncode, } from './Util';
28
28
  export { asserts } from './Util/errors/AssertError';
29
29
  export { invalidParameter, missingConfig, AmplifyError, AmplifyErrorString, } from './Util/Errors';
30
+ export { AppState, AsyncStorage, Linking } from './RNComponents';
30
31
  export { INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER, USER_AGENT_HEADER, } from './Util/Constants';
31
32
  export { fetchAuthSession } from './singleton/apis/internal/fetchAuthSession';
32
33
  export { AMPLIFY_SYMBOL } from './Hub';
@@ -9,11 +9,6 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
- var authTypeMapping = {
13
- API_KEY: 'apiKey',
14
- AWS_IAM: 'iam',
15
- AMAZON_COGNITO_USER_POOLS: 'jwt',
16
- };
17
12
  /**
18
13
  * This utility converts the `aws-exports.js` file generated by the Amplify CLI into a {@link ResourcesConfig} object
19
14
  * consumable by Amplify.
@@ -24,7 +19,7 @@ var authTypeMapping = {
24
19
  */
25
20
  export var parseAWSExports = function (config) {
26
21
  if (config === void 0) { config = {}; }
27
- var aws_appsync_apiKey = config.aws_appsync_apiKey, aws_appsync_authenticationType = config.aws_appsync_authenticationType, aws_appsync_graphqlEndpoint = config.aws_appsync_graphqlEndpoint, aws_appsync_region = config.aws_appsync_region, aws_cognito_identity_pool_id = config.aws_cognito_identity_pool_id, aws_cognito_sign_up_verification_method = config.aws_cognito_sign_up_verification_method, aws_mandatory_sign_in = config.aws_mandatory_sign_in, aws_mobile_analytics_app_id = config.aws_mobile_analytics_app_id, aws_mobile_analytics_app_region = config.aws_mobile_analytics_app_region, aws_user_files_s3_bucket = config.aws_user_files_s3_bucket, aws_user_files_s3_bucket_region = config.aws_user_files_s3_bucket_region, aws_user_files_s3_dangerously_connect_to_http_endpoint_for_testing = config.aws_user_files_s3_dangerously_connect_to_http_endpoint_for_testing, aws_user_pools_id = config.aws_user_pools_id, aws_user_pools_web_client_id = config.aws_user_pools_web_client_id, geo = config.geo, oauth = config.oauth;
22
+ var aws_cognito_identity_pool_id = config.aws_cognito_identity_pool_id, aws_cognito_sign_up_verification_method = config.aws_cognito_sign_up_verification_method, aws_mandatory_sign_in = config.aws_mandatory_sign_in, aws_mobile_analytics_app_id = config.aws_mobile_analytics_app_id, aws_mobile_analytics_app_region = config.aws_mobile_analytics_app_region, aws_user_files_s3_bucket = config.aws_user_files_s3_bucket, aws_user_files_s3_bucket_region = config.aws_user_files_s3_bucket_region, aws_user_files_s3_dangerously_connect_to_http_endpoint_for_testing = config.aws_user_files_s3_dangerously_connect_to_http_endpoint_for_testing, aws_user_pools_id = config.aws_user_pools_id, aws_user_pools_web_client_id = config.aws_user_pools_web_client_id, geo = config.geo, oauth = config.oauth;
28
23
  var amplifyConfig = {};
29
24
  // Analytics
30
25
  if (aws_mobile_analytics_app_id) {
@@ -35,20 +30,6 @@ export var parseAWSExports = function (config) {
35
30
  },
36
31
  };
37
32
  }
38
- // TODO: Need to support all API configurations
39
- // API
40
- if (aws_appsync_graphqlEndpoint) {
41
- amplifyConfig.API = {
42
- AppSync: {
43
- defaultAuthMode: {
44
- type: authTypeMapping[aws_appsync_authenticationType],
45
- apiKey: aws_appsync_apiKey,
46
- },
47
- endpoint: aws_appsync_graphqlEndpoint,
48
- region: aws_appsync_region,
49
- },
50
- };
51
- }
52
33
  // Auth
53
34
  if (aws_cognito_identity_pool_id || aws_user_pools_id) {
54
35
  amplifyConfig.Auth = {
@@ -74,7 +74,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
74
74
  };
75
75
  import { ConsoleLogger as Logger } from '../../../Logger';
76
76
  import { putEvents, } from '../../../AwsClients/Pinpoint';
77
- import { isAppInForeground } from './isAppInForeground';
77
+ import { isAppInForeground } from '../../../RNComponents/isAppInForeground';
78
78
  var logger = new Logger('PinpointEventBuffer');
79
79
  var RETRYABLE_CODES = [429, 500];
80
80
  var ACCEPTED_CODES = [202];
@@ -91,9 +91,7 @@ var PinpointEventBuffer = /** @class */ (function () {
91
91
  PinpointEventBuffer.prototype.push = function (event) {
92
92
  var _a;
93
93
  if (this._buffer.length >= this._config.bufferSize) {
94
- logger.debug('Exceeded Pinpoint event buffer limits, event dropped.', {
95
- eventId: event.eventId,
96
- });
94
+ logger.debug('Exceeded Pinpoint event buffer limits, event dropped.', { eventId: event.eventId });
97
95
  return;
98
96
  }
99
97
  this._buffer.push((_a = {}, _a[event.eventId] = event, _a));
@@ -232,7 +230,7 @@ var PinpointEventBuffer = /** @class */ (function () {
232
230
  logger.warn('Pinpoint event failed to send.', {
233
231
  eventId: eventId,
234
232
  name: name,
235
- message: Message,
233
+ message: Message
236
234
  });
237
235
  });
238
236
  });
@@ -252,14 +250,14 @@ var PinpointEventBuffer = /** @class */ (function () {
252
250
  logger.debug('Resending event.', {
253
251
  eventId: eventId,
254
252
  name: name,
255
- remainingAttempts: bufferedEvent.resendLimit,
253
+ remainingAttempts: bufferedEvent.resendLimit
256
254
  });
257
255
  eligibleEvents.push((_a = {}, _a[eventId] = bufferedEvent, _a));
258
256
  return;
259
257
  }
260
258
  logger.debug('No retry attempts remaining for event.', {
261
259
  eventId: eventId,
262
- name: name,
260
+ name: name
263
261
  });
264
262
  });
265
263
  // add the events to the front of the buffer
@@ -1,4 +1,3 @@
1
- import { APIConfig, LibraryAPIOptions } from './API/types';
2
1
  import { AnalyticsConfig } from './Analytics/types';
3
2
  import { AuthConfig, LibraryAuthOptions, AuthUserPoolConfig, AuthIdentityPoolConfig, AuthUserPoolAndIdentityPoolConfig, GetCredentialsOptions, CognitoIdentityPoolConfig } from './Auth/types';
4
3
  import { LibraryStorageOptions, StorageAccessLevel, StorageConfig } from './Storage/types';
@@ -9,15 +8,13 @@ export type LegacyConfig = {
9
8
  aws_project_region?: string;
10
9
  };
11
10
  export type ResourcesConfig = {
12
- API?: APIConfig;
13
11
  Analytics?: AnalyticsConfig;
14
12
  Auth?: AuthConfig;
15
13
  Storage?: StorageConfig;
16
14
  };
17
15
  export type LibraryOptions = {
18
- API?: LibraryAPIOptions;
19
16
  Auth?: LibraryAuthOptions;
20
17
  Storage?: LibraryStorageOptions;
21
18
  ssr?: boolean;
22
19
  };
23
- export { APIConfig, AuthConfig, AuthUserPoolConfig, AuthIdentityPoolConfig, AuthUserPoolAndIdentityPoolConfig, GetCredentialsOptions, StorageAccessLevel, StorageConfig, AnalyticsConfig, CognitoIdentityPoolConfig, };
20
+ export { AuthConfig, AuthUserPoolConfig, AuthIdentityPoolConfig, AuthUserPoolAndIdentityPoolConfig, GetCredentialsOptions, StorageAccessLevel, StorageConfig, AnalyticsConfig, CognitoIdentityPoolConfig, };