@aws-amplify/core 5.8.2-unstable.c3ec8a5.0 → 6.0.1-console-preview.7919075.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/lib/Amplify.d.ts +18 -17
- package/lib/Amplify.js +9 -0
- package/lib/AwsClients/CognitoIdentity/base.d.ts +3 -10
- package/lib/AwsClients/CognitoIdentity/getCredentialsForIdentity.d.ts +3 -17
- package/lib/AwsClients/CognitoIdentity/getCredentialsForIdentity.js +8 -8
- package/lib/AwsClients/CognitoIdentity/getId.d.ts +3 -17
- package/lib/AwsClients/Pinpoint/base.d.ts +2 -10
- package/lib/AwsClients/Pinpoint/getInAppMessages.d.ts +3 -17
- package/lib/AwsClients/Pinpoint/getInAppMessages.js +1 -1
- package/lib/AwsClients/Pinpoint/putEvents.d.ts +3 -17
- package/lib/AwsClients/Pinpoint/putEvents.js +6 -0
- package/lib/AwsClients/Pinpoint/updateEndpoint.d.ts +3 -17
- package/lib/AwsClients/Pinpoint/updateEndpoint.js +2 -2
- package/lib/Cache/AsyncStorageCache.d.ts +154 -0
- package/lib/Cache/AsyncStorageCache.js +744 -0
- package/lib/Cache/BrowserStorageCache.d.ts +166 -0
- package/lib/Cache/BrowserStorageCache.js +469 -0
- package/lib/Cache/InMemoryCache.d.ts +129 -0
- package/lib/Cache/InMemoryCache.js +349 -0
- package/lib/Cache/StorageCache.d.ts +39 -0
- package/lib/Cache/StorageCache.js +121 -0
- package/lib/Cache/Utils/CacheList.d.ts +89 -0
- package/lib/Cache/Utils/CacheList.js +196 -0
- package/lib/Cache/Utils/CacheUtils.d.ts +25 -0
- package/lib/Cache/Utils/CacheUtils.js +88 -0
- package/lib/Cache/Utils/index.d.ts +2 -0
- package/lib/Cache/Utils/index.js +16 -0
- package/lib/Cache/reactnative.d.ts +3 -0
- package/lib/Cache/reactnative.js +8 -0
- package/lib/Cache/types/Cache.d.ts +55 -0
- package/lib/Cache/types/Cache.js +4 -0
- package/lib/Cache/types/index.d.ts +1 -0
- package/lib/Cache/types/index.js +19 -0
- package/lib/ClientDevice/android.js +3 -2
- package/lib/ClientDevice/ios.d.ts +2 -2
- package/lib/ClientDevice/ios.js +3 -2
- package/lib/ClientDevice/reactnative.js +3 -2
- package/lib/Credentials.d.ts +1 -1
- package/lib/Credentials.js +2 -1
- package/lib/Errors.d.ts +19 -0
- package/lib/Errors.js +50 -1
- package/lib/Hub.js +1 -0
- package/lib/I18n/I18n.d.ts +29 -9
- package/lib/I18n/I18n.js +30 -5
- package/lib/I18n/index.d.ts +18 -5
- package/lib/I18n/index.js +35 -5
- package/lib/I18n/types.d.ts +4 -1
- package/lib/I18n/types.js +3 -0
- package/lib/JS.d.ts +6 -6
- package/lib/Logger/ConsoleLogger.d.ts +11 -11
- package/lib/OAuthHelper/GoogleOAuth.js +2 -1
- package/lib/Platform/detectFramework.js +2 -1
- package/lib/Platform/detection/Next.d.ts +1 -1
- package/lib/Platform/detection/React.js +1 -0
- package/lib/Platform/version.d.ts +1 -1
- package/lib/Platform/version.js +1 -1
- package/lib/Providers/AWSCloudWatchProvider.d.ts +2 -2
- package/lib/Providers/AWSCloudWatchProvider.js +35 -12
- package/lib/RNComponents/index.d.ts +1 -1
- package/lib/RNComponents/reactnative.js +3 -2
- package/lib/ServiceWorker/ServiceWorker.d.ts +4 -4
- package/lib/ServiceWorker/ServiceWorker.js +37 -11
- package/lib/Signer.d.ts +14 -1
- package/lib/StorageHelper/cookieStorage.d.ts +13 -0
- package/lib/StorageHelper/cookieStorage.js +167 -0
- package/lib/StorageHelper/inMemoryStorage.d.ts +10 -0
- package/lib/StorageHelper/inMemoryStorage.js +82 -0
- package/lib/StorageHelper/index.d.ts +7 -3
- package/lib/StorageHelper/index.js +9 -1
- package/lib/StorageHelper/localStorage.d.ts +32 -0
- package/lib/StorageHelper/localStorage.js +114 -0
- package/lib/StorageHelper/reactnative.d.ts +71 -1
- package/lib/StorageHelper/reactnative.js +154 -10
- package/lib/StorageHelper/sessionStorage.d.ts +32 -0
- package/lib/StorageHelper/sessionStorage.js +114 -0
- package/lib/UniversalStorage/index.d.ts +2 -2
- package/lib/Util/BackgroundProcessManager.d.ts +2 -2
- package/lib/Util/BackgroundProcessManager.js +1 -0
- package/lib/Util/DateUtils.d.ts +12 -1
- package/lib/Util/Reachability.js +7 -5
- package/lib/Util/Reachability.native.d.ts +3 -2
- package/lib/Util/StringUtils.js +3 -10
- package/lib/Util/errors/AssertError.d.ts +2 -0
- package/lib/Util/errors/AssertError.js +11 -0
- package/lib/clients/middleware/retry/defaultRetryDecider.d.ts +1 -1
- package/lib/clients/middleware/retry/defaultRetryDecider.js +17 -13
- package/lib/clients/middleware/retry/isClockSkewError.js +1 -1
- package/lib/clients/middleware/retry/middleware.d.ts +1 -1
- package/lib/clients/middleware/retry/middleware.js +13 -13
- package/lib/clients/middleware/signing/signer/signatureV4/utils/dataHashHelpers.js +1 -1
- package/lib/clients/serde/responseInfo.js +1 -1
- package/lib/clients/types/aws.d.ts +4 -0
- package/lib/clients/types/index.d.ts +1 -1
- package/lib/constants.d.ts +7 -0
- package/lib/constants.js +9 -1
- package/lib/index.d.ts +18 -4
- package/lib/index.js +32 -5
- package/lib/parseAWSExports.d.ts +1 -1
- package/lib/singleton/Auth/index.d.ts +30 -0
- package/lib/singleton/Auth/index.js +133 -0
- package/lib/singleton/Auth/types.d.ts +95 -0
- package/lib/singleton/Auth/types.js +6 -0
- package/lib/singleton/Auth/utils/index.d.ts +5 -0
- package/lib/singleton/Auth/utils/index.js +52 -0
- package/lib/singleton/Storage/types.d.ts +14 -0
- package/lib/singleton/Storage/types.js +4 -0
- package/lib/singleton/index.d.ts +46 -0
- package/lib/singleton/index.js +160 -0
- package/lib/singleton/types.d.ts +21 -0
- package/lib/singleton/types.js +4 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/types.d.ts +31 -1
- package/lib/types/types.js +2 -0
- package/lib-esm/Amplify.d.ts +18 -17
- package/lib-esm/Amplify.js +9 -0
- package/lib-esm/AwsClients/CognitoIdentity/base.d.ts +3 -10
- package/lib-esm/AwsClients/CognitoIdentity/getCredentialsForIdentity.d.ts +3 -17
- package/lib-esm/AwsClients/CognitoIdentity/getCredentialsForIdentity.js +8 -8
- package/lib-esm/AwsClients/CognitoIdentity/getId.d.ts +3 -17
- package/lib-esm/AwsClients/Pinpoint/base.d.ts +2 -10
- package/lib-esm/AwsClients/Pinpoint/getInAppMessages.d.ts +3 -17
- package/lib-esm/AwsClients/Pinpoint/getInAppMessages.js +1 -1
- package/lib-esm/AwsClients/Pinpoint/putEvents.d.ts +3 -17
- package/lib-esm/AwsClients/Pinpoint/putEvents.js +6 -0
- package/lib-esm/AwsClients/Pinpoint/updateEndpoint.d.ts +3 -17
- package/lib-esm/AwsClients/Pinpoint/updateEndpoint.js +2 -2
- package/lib-esm/Cache/AsyncStorageCache.d.ts +154 -0
- package/lib-esm/Cache/AsyncStorageCache.js +737 -0
- package/lib-esm/Cache/BrowserStorageCache.d.ts +166 -0
- package/lib-esm/Cache/BrowserStorageCache.js +466 -0
- package/lib-esm/Cache/InMemoryCache.d.ts +129 -0
- package/lib-esm/Cache/InMemoryCache.js +346 -0
- package/lib-esm/Cache/StorageCache.d.ts +39 -0
- package/lib-esm/Cache/StorageCache.js +118 -0
- package/lib-esm/Cache/Utils/CacheList.d.ts +89 -0
- package/lib-esm/Cache/Utils/CacheList.js +194 -0
- package/lib-esm/Cache/Utils/CacheUtils.d.ts +25 -0
- package/lib-esm/Cache/Utils/CacheUtils.js +81 -0
- package/lib-esm/Cache/Utils/index.d.ts +2 -0
- package/lib-esm/Cache/Utils/index.js +4 -0
- package/lib-esm/Cache/reactnative.d.ts +3 -0
- package/lib-esm/Cache/reactnative.js +6 -0
- package/lib-esm/Cache/types/Cache.d.ts +55 -0
- package/lib-esm/Cache/types/Cache.js +3 -0
- package/lib-esm/Cache/types/index.d.ts +1 -0
- package/lib-esm/Cache/types/index.js +3 -0
- package/lib-esm/ClientDevice/android.js +1 -0
- package/lib-esm/ClientDevice/ios.d.ts +2 -2
- package/lib-esm/ClientDevice/ios.js +1 -0
- package/lib-esm/ClientDevice/reactnative.js +1 -0
- package/lib-esm/Credentials.d.ts +1 -1
- package/lib-esm/Credentials.js +2 -1
- package/lib-esm/Errors.d.ts +19 -0
- package/lib-esm/Errors.js +49 -0
- package/lib-esm/Hub.js +1 -0
- package/lib-esm/I18n/I18n.d.ts +29 -9
- package/lib-esm/I18n/I18n.js +30 -5
- package/lib-esm/I18n/index.d.ts +18 -5
- package/lib-esm/I18n/index.js +35 -5
- package/lib-esm/I18n/types.d.ts +4 -1
- package/lib-esm/I18n/types.js +3 -0
- package/lib-esm/JS.d.ts +6 -6
- package/lib-esm/Logger/ConsoleLogger.d.ts +11 -11
- package/lib-esm/OAuthHelper/GoogleOAuth.js +2 -1
- package/lib-esm/Platform/detectFramework.js +2 -1
- package/lib-esm/Platform/detection/Next.d.ts +1 -1
- package/lib-esm/Platform/detection/React.js +1 -0
- package/lib-esm/Platform/version.d.ts +1 -1
- package/lib-esm/Platform/version.js +1 -1
- package/lib-esm/Providers/AWSCloudWatchProvider.d.ts +2 -2
- package/lib-esm/Providers/AWSCloudWatchProvider.js +33 -10
- package/lib-esm/RNComponents/index.d.ts +1 -1
- package/lib-esm/RNComponents/reactnative.js +1 -0
- package/lib-esm/ServiceWorker/ServiceWorker.d.ts +4 -4
- package/lib-esm/ServiceWorker/ServiceWorker.js +37 -11
- package/lib-esm/Signer.d.ts +14 -1
- package/lib-esm/StorageHelper/cookieStorage.d.ts +13 -0
- package/lib-esm/StorageHelper/cookieStorage.js +141 -0
- package/lib-esm/StorageHelper/inMemoryStorage.d.ts +10 -0
- package/lib-esm/StorageHelper/inMemoryStorage.js +79 -0
- package/lib-esm/StorageHelper/index.d.ts +7 -3
- package/lib-esm/StorageHelper/index.js +4 -0
- package/lib-esm/StorageHelper/localStorage.d.ts +32 -0
- package/lib-esm/StorageHelper/localStorage.js +111 -0
- package/lib-esm/StorageHelper/reactnative.d.ts +71 -1
- package/lib-esm/StorageHelper/reactnative.js +153 -9
- package/lib-esm/StorageHelper/sessionStorage.d.ts +32 -0
- package/lib-esm/StorageHelper/sessionStorage.js +111 -0
- package/lib-esm/UniversalStorage/index.d.ts +2 -2
- package/lib-esm/Util/BackgroundProcessManager.d.ts +2 -2
- package/lib-esm/Util/BackgroundProcessManager.js +1 -0
- package/lib-esm/Util/DateUtils.d.ts +12 -1
- package/lib-esm/Util/Reachability.js +5 -3
- package/lib-esm/Util/Reachability.native.d.ts +3 -2
- package/lib-esm/Util/StringUtils.js +3 -10
- package/lib-esm/Util/errors/AssertError.d.ts +2 -0
- package/lib-esm/Util/errors/AssertError.js +7 -0
- package/lib-esm/clients/middleware/retry/defaultRetryDecider.d.ts +1 -1
- package/lib-esm/clients/middleware/retry/defaultRetryDecider.js +17 -13
- package/lib-esm/clients/middleware/retry/isClockSkewError.js +1 -1
- package/lib-esm/clients/middleware/retry/middleware.d.ts +1 -1
- package/lib-esm/clients/middleware/retry/middleware.js +13 -13
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/dataHashHelpers.js +1 -1
- package/lib-esm/clients/serde/responseInfo.js +1 -1
- package/lib-esm/clients/types/aws.d.ts +4 -0
- package/lib-esm/clients/types/index.d.ts +1 -1
- package/lib-esm/constants.d.ts +7 -0
- package/lib-esm/constants.js +8 -0
- package/lib-esm/index.d.ts +18 -4
- package/lib-esm/index.js +15 -3
- package/lib-esm/parseAWSExports.d.ts +1 -1
- package/lib-esm/singleton/Auth/index.d.ts +30 -0
- package/lib-esm/singleton/Auth/index.js +129 -0
- package/lib-esm/singleton/Auth/types.d.ts +95 -0
- package/lib-esm/singleton/Auth/types.js +5 -0
- package/lib-esm/singleton/Auth/utils/index.d.ts +5 -0
- package/lib-esm/singleton/Auth/utils/index.js +45 -0
- package/lib-esm/singleton/Storage/types.d.ts +14 -0
- package/lib-esm/singleton/Storage/types.js +3 -0
- package/lib-esm/singleton/index.d.ts +46 -0
- package/lib-esm/singleton/index.js +156 -0
- package/lib-esm/singleton/types.d.ts +21 -0
- package/lib-esm/singleton/types.js +3 -0
- package/lib-esm/tsconfig.tsbuildinfo +1 -1
- package/lib-esm/types/types.d.ts +31 -1
- package/lib-esm/types/types.js +2 -0
- package/package.json +38 -15
- package/src/Amplify.ts +9 -3
- package/src/AwsClients/CognitoIdentity/base.ts +2 -1
- package/src/AwsClients/CognitoIdentity/getCredentialsForIdentity.ts +13 -6
- package/src/AwsClients/Pinpoint/base.ts +6 -2
- package/src/AwsClients/Pinpoint/getInAppMessages.ts +1 -1
- package/src/AwsClients/Pinpoint/putEvents.ts +6 -0
- package/src/AwsClients/Pinpoint/updateEndpoint.ts +2 -2
- package/src/Cache/AsyncStorageCache.ts +500 -0
- package/src/Cache/BrowserStorageCache.ts +517 -0
- package/src/Cache/CHANGELOG.md +1227 -0
- package/src/Cache/InMemoryCache.ts +354 -0
- package/src/Cache/StorageCache.ts +157 -0
- package/src/Cache/Utils/CacheList.ts +198 -0
- package/src/Cache/Utils/CacheUtils.ts +92 -0
- package/src/Cache/Utils/index.ts +11 -0
- package/src/Cache/reactnative.ts +9 -0
- package/src/Cache/types/Cache.ts +75 -0
- package/src/Cache/types/index.ts +4 -0
- package/src/ClientDevice/android.ts +1 -1
- package/src/ClientDevice/ios.ts +2 -2
- package/src/ClientDevice/reactnative.ts +1 -1
- package/src/Credentials.ts +19 -17
- package/src/Errors.ts +41 -0
- package/src/Hub.ts +1 -0
- package/src/I18n/I18n.ts +40 -12
- package/src/I18n/index.ts +45 -12
- package/src/I18n/types.ts +3 -0
- package/src/JS.ts +24 -17
- package/src/Logger/ConsoleLogger.ts +10 -10
- package/src/OAuthHelper/FacebookOAuth.ts +2 -2
- package/src/OAuthHelper/GoogleOAuth.ts +9 -6
- package/src/Platform/detectFramework.ts +1 -1
- package/src/Platform/detection/React.ts +5 -3
- package/src/Platform/version.ts +1 -1
- package/src/Providers/AWSCloudWatchProvider.ts +39 -14
- package/src/RNComponents/index.ts +1 -1
- package/src/RNComponents/reactnative.ts +1 -1
- package/src/ServiceWorker/ServiceWorker.ts +58 -18
- package/src/Signer.ts +22 -3
- package/src/StorageHelper/cookieStorage.ts +99 -0
- package/src/StorageHelper/inMemoryStorage.ts +32 -0
- package/src/StorageHelper/index.ts +6 -1
- package/src/StorageHelper/localStorage.ts +60 -0
- package/src/StorageHelper/reactnative.ts +94 -14
- package/src/StorageHelper/sessionStorage.ts +60 -0
- package/src/Util/BackgroundProcessManager.ts +33 -9
- package/src/Util/DateUtils.ts +14 -5
- package/src/Util/Reachability.native.ts +3 -2
- package/src/Util/Reachability.ts +9 -7
- package/src/Util/Retry.ts +2 -1
- package/src/Util/StringUtils.ts +3 -10
- package/src/Util/errors/AssertError.ts +11 -0
- package/src/clients/handlers/fetch.ts +2 -2
- package/src/clients/middleware/retry/defaultRetryDecider.ts +12 -6
- package/src/clients/middleware/retry/isClockSkewError.ts +1 -1
- package/src/clients/middleware/retry/middleware.ts +9 -9
- package/src/clients/middleware/signing/middleware.ts +1 -1
- package/src/clients/middleware/signing/signer/signatureV4/utils/dataHashHelpers.ts +1 -1
- package/src/clients/serde/responseInfo.ts +2 -1
- package/src/clients/types/aws.ts +10 -0
- package/src/clients/types/index.ts +1 -0
- package/src/constants.ts +16 -0
- package/src/global.d.ts +11 -0
- package/src/index.ts +66 -4
- package/src/parseAWSExports.ts +1 -1
- package/src/singleton/Auth/index.ts +113 -0
- package/src/singleton/Auth/types.ts +129 -0
- package/src/singleton/Auth/utils/index.ts +68 -0
- package/src/singleton/Storage/types.ts +21 -0
- package/src/singleton/index.ts +144 -0
- package/src/singleton/types.ts +48 -0
- package/src/types/types.ts +38 -1
|
@@ -65,11 +65,13 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
65
65
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
66
66
|
exports.AWSCloudWatchProvider = void 0;
|
|
67
67
|
var client_cloudwatch_logs_1 = require("@aws-sdk/client-cloudwatch-logs");
|
|
68
|
-
var
|
|
68
|
+
var Credentials_1 = require("../Credentials");
|
|
69
69
|
var Logger_1 = require("../Logger");
|
|
70
70
|
var Platform_1 = require("../Platform");
|
|
71
71
|
var parseAWSExports_1 = require("../parseAWSExports");
|
|
72
72
|
var Constants_1 = require("../Util/Constants");
|
|
73
|
+
var AssertError_1 = require("../Util/errors/AssertError");
|
|
74
|
+
var constants_1 = require("../constants");
|
|
73
75
|
var logger = new Logger_1.ConsoleLogger('AWSCloudWatch');
|
|
74
76
|
var AWSCloudWatchProvider = /** @class */ (function () {
|
|
75
77
|
function AWSCloudWatchProvider(config) {
|
|
@@ -390,6 +392,7 @@ var AWSCloudWatchProvider = /** @class */ (function () {
|
|
|
390
392
|
});
|
|
391
393
|
};
|
|
392
394
|
AWSCloudWatchProvider.prototype._initCloudWatchLogs = function () {
|
|
395
|
+
assertsAWSClouldWatchOptions(this._config);
|
|
393
396
|
return new client_cloudwatch_logs_1.CloudWatchLogsClient({
|
|
394
397
|
region: this._config.region,
|
|
395
398
|
credentials: this._config.credentials,
|
|
@@ -402,11 +405,12 @@ var AWSCloudWatchProvider = /** @class */ (function () {
|
|
|
402
405
|
var _this = this;
|
|
403
406
|
return __generator(this, function (_a) {
|
|
404
407
|
switch (_a.label) {
|
|
405
|
-
case 0: return [4 /*yield*/,
|
|
408
|
+
case 0: return [4 /*yield*/, Credentials_1.Credentials.get()
|
|
406
409
|
.then(function (credentials) {
|
|
410
|
+
assertsAWSClouldWatchOptions(_this._config);
|
|
407
411
|
if (!credentials)
|
|
408
412
|
return false;
|
|
409
|
-
var cred =
|
|
413
|
+
var cred = Credentials_1.Credentials.shear(credentials);
|
|
410
414
|
logger.debug('set credentials for logging', cred);
|
|
411
415
|
_this._config.credentials = cred;
|
|
412
416
|
return true;
|
|
@@ -426,12 +430,21 @@ var AWSCloudWatchProvider = /** @class */ (function () {
|
|
|
426
430
|
return __generator(this, function (_a) {
|
|
427
431
|
switch (_a.label) {
|
|
428
432
|
case 0:
|
|
433
|
+
assertsAWSClouldWatchOptions(this._config);
|
|
429
434
|
if (this._nextSequenceToken && this._nextSequenceToken.length > 0) {
|
|
430
435
|
return [2 /*return*/, this._nextSequenceToken];
|
|
431
436
|
}
|
|
432
437
|
_a.label = 1;
|
|
433
438
|
case 1:
|
|
434
439
|
_a.trys.push([1, 4, , 5]);
|
|
440
|
+
(0, AssertError_1.asserts)(this._config.logGroupName !== undefined, {
|
|
441
|
+
name: constants_1.AWS_CLOUD_WATCH_PROVIDER_OPTIONS_EXCEPTION,
|
|
442
|
+
message: ' log group name is undefined',
|
|
443
|
+
});
|
|
444
|
+
(0, AssertError_1.asserts)(this._config.logStreamName !== undefined, {
|
|
445
|
+
name: constants_1.AWS_CLOUD_WATCH_PROVIDER_OPTIONS_EXCEPTION,
|
|
446
|
+
message: ' log stream name is undefined',
|
|
447
|
+
});
|
|
435
448
|
return [4 /*yield*/, this._validateLogGroupExistsAndCreate(this._config.logGroupName)];
|
|
436
449
|
case 2:
|
|
437
450
|
_a.sent();
|
|
@@ -458,9 +471,12 @@ var AWSCloudWatchProvider = /** @class */ (function () {
|
|
|
458
471
|
return __generator(this, function (_a) {
|
|
459
472
|
switch (_a.label) {
|
|
460
473
|
case 0:
|
|
461
|
-
|
|
462
|
-
|
|
474
|
+
assertsAWSClouldWatchOptions(this._config);
|
|
475
|
+
_a.label = 1;
|
|
463
476
|
case 1:
|
|
477
|
+
_a.trys.push([1, 4, , 5]);
|
|
478
|
+
return [4 /*yield*/, this._getNextSequenceToken()];
|
|
479
|
+
case 2:
|
|
464
480
|
seqToken = _a.sent();
|
|
465
481
|
logBatch = this._currentLogBatch.length === 0
|
|
466
482
|
? this._getBufferedBatchOfLogs()
|
|
@@ -473,16 +489,16 @@ var AWSCloudWatchProvider = /** @class */ (function () {
|
|
|
473
489
|
};
|
|
474
490
|
this._dataTracker.eventUploadInProgress = true;
|
|
475
491
|
return [4 /*yield*/, this._sendLogEvents(putLogsPayload)];
|
|
476
|
-
case
|
|
492
|
+
case 3:
|
|
477
493
|
sendLogEventsResponse = _a.sent();
|
|
478
|
-
this._nextSequenceToken = sendLogEventsResponse.nextSequenceToken;
|
|
494
|
+
this._nextSequenceToken = sendLogEventsResponse === null || sendLogEventsResponse === void 0 ? void 0 : sendLogEventsResponse.nextSequenceToken;
|
|
479
495
|
this._dataTracker.eventUploadInProgress = false;
|
|
480
496
|
this._currentLogBatch = [];
|
|
481
497
|
return [2 /*return*/, sendLogEventsResponse];
|
|
482
|
-
case
|
|
498
|
+
case 4:
|
|
483
499
|
err_5 = _a.sent();
|
|
484
500
|
logger.error("error during _safeUploadLogEvents: ".concat(err_5));
|
|
485
|
-
if (Constants_1.RETRY_ERROR_CODES.includes(err_5.name)) {
|
|
501
|
+
if (err_5 instanceof Error && Constants_1.RETRY_ERROR_CODES.includes(err_5.name)) {
|
|
486
502
|
this._getNewSequenceTokenAndSubmit({
|
|
487
503
|
logEvents: this._currentLogBatch,
|
|
488
504
|
logGroupName: this._config.logGroupName,
|
|
@@ -493,13 +509,14 @@ var AWSCloudWatchProvider = /** @class */ (function () {
|
|
|
493
509
|
this._dataTracker.eventUploadInProgress = false;
|
|
494
510
|
throw err_5;
|
|
495
511
|
}
|
|
496
|
-
return [3 /*break*/,
|
|
497
|
-
case
|
|
512
|
+
return [3 /*break*/, 5];
|
|
513
|
+
case 5: return [2 /*return*/];
|
|
498
514
|
}
|
|
499
515
|
});
|
|
500
516
|
});
|
|
501
517
|
};
|
|
502
518
|
AWSCloudWatchProvider.prototype._getBufferedBatchOfLogs = function () {
|
|
519
|
+
var _a;
|
|
503
520
|
/**
|
|
504
521
|
* CloudWatch has restrictions on the size of the log events that get sent up.
|
|
505
522
|
* We need to track both the size of each event and the total size of the batch
|
|
@@ -519,7 +536,7 @@ var AWSCloudWatchProvider = /** @class */ (function () {
|
|
|
519
536
|
if (eventSize > Constants_1.AWS_CLOUDWATCH_MAX_EVENT_SIZE) {
|
|
520
537
|
var errString = "Log entry exceeds maximum size for CloudWatch logs. Log size: ".concat(eventSize, ". Truncating log message.");
|
|
521
538
|
logger.warn(errString);
|
|
522
|
-
currentEvent.message = currentEvent.message.substring(0, eventSize);
|
|
539
|
+
currentEvent.message = (_a = currentEvent.message) === null || _a === void 0 ? void 0 : _a.substring(0, eventSize);
|
|
523
540
|
}
|
|
524
541
|
if (totalByteSize + eventSize > Constants_1.AWS_CLOUDWATCH_MAX_BATCH_EVENT_SIZE)
|
|
525
542
|
break;
|
|
@@ -594,3 +611,9 @@ var AWSCloudWatchProvider = /** @class */ (function () {
|
|
|
594
611
|
return AWSCloudWatchProvider;
|
|
595
612
|
}());
|
|
596
613
|
exports.AWSCloudWatchProvider = AWSCloudWatchProvider;
|
|
614
|
+
function assertsAWSClouldWatchOptions(options) {
|
|
615
|
+
return (0, AssertError_1.asserts)(options !== undefined, {
|
|
616
|
+
name: constants_1.AWS_CLOUD_WATCH_PROVIDER_OPTIONS_EXCEPTION,
|
|
617
|
+
message: 'AWSCloudWatchProviderOptions cannot be undefined',
|
|
618
|
+
});
|
|
619
|
+
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
4
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
4
|
};
|
|
7
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
6
|
exports.AsyncStorage = exports.AppState = exports.Linking = void 0;
|
|
7
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
8
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
9
|
+
// @ts-ignore
|
|
9
10
|
var react_native_1 = require("react-native");
|
|
10
11
|
Object.defineProperty(exports, "Linking", { enumerable: true, get: function () { return react_native_1.Linking; } });
|
|
11
12
|
Object.defineProperty(exports, "AppState", { enumerable: true, get: function () { return react_native_1.AppState; } });
|
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
* events based on the service worker lifecycle.
|
|
12
12
|
*/
|
|
13
13
|
export declare class ServiceWorkerClass {
|
|
14
|
-
private _serviceWorker
|
|
15
|
-
private _registration
|
|
16
|
-
private _publicKey
|
|
17
|
-
private _subscription
|
|
14
|
+
private _serviceWorker?;
|
|
15
|
+
private _registration?;
|
|
16
|
+
private _publicKey?;
|
|
17
|
+
private _subscription?;
|
|
18
18
|
private _logger;
|
|
19
19
|
constructor();
|
|
20
20
|
/**
|
|
@@ -18,6 +18,9 @@ exports.ServiceWorkerClass = void 0;
|
|
|
18
18
|
var Logger_1 = require("../Logger");
|
|
19
19
|
var JS_1 = require("../JS");
|
|
20
20
|
var Amplify_1 = require("../Amplify");
|
|
21
|
+
var AssertError_1 = require("../Util/errors/AssertError");
|
|
22
|
+
var Errors_1 = require("../Errors");
|
|
23
|
+
var constants_1 = require("../constants");
|
|
21
24
|
/**
|
|
22
25
|
* Provides a means to registering a service worker in the browser
|
|
23
26
|
* and communicating with it via postMessage events.
|
|
@@ -40,6 +43,10 @@ var ServiceWorkerClass = /** @class */ (function () {
|
|
|
40
43
|
* Get the currently active service worker
|
|
41
44
|
*/
|
|
42
45
|
get: function () {
|
|
46
|
+
(0, AssertError_1.asserts)(this._serviceWorker !== undefined, {
|
|
47
|
+
name: constants_1.SERVICE_WORKER_EXCEPTION,
|
|
48
|
+
message: 'Service Worker instance is undefined',
|
|
49
|
+
});
|
|
43
50
|
return this._serviceWorker;
|
|
44
51
|
},
|
|
45
52
|
enumerable: false,
|
|
@@ -86,11 +93,18 @@ var ServiceWorkerClass = /** @class */ (function () {
|
|
|
86
93
|
})
|
|
87
94
|
.catch(function (error) {
|
|
88
95
|
_this._logger.debug("Service Worker Registration Failed ".concat(error));
|
|
89
|
-
return reject(
|
|
96
|
+
return reject(new Errors_1.AmplifyError({
|
|
97
|
+
name: constants_1.SERVICE_WORKER_EXCEPTION,
|
|
98
|
+
message: 'Service Worker not available',
|
|
99
|
+
underlyingError: error,
|
|
100
|
+
}));
|
|
90
101
|
});
|
|
91
102
|
}
|
|
92
103
|
else {
|
|
93
|
-
return reject(new
|
|
104
|
+
return reject(new Errors_1.AmplifyError({
|
|
105
|
+
name: constants_1.SERVICE_WORKER_EXCEPTION,
|
|
106
|
+
message: 'Service Worker not available',
|
|
107
|
+
}));
|
|
94
108
|
}
|
|
95
109
|
});
|
|
96
110
|
};
|
|
@@ -107,11 +121,17 @@ var ServiceWorkerClass = /** @class */ (function () {
|
|
|
107
121
|
*/
|
|
108
122
|
ServiceWorkerClass.prototype.enablePush = function (publicKey) {
|
|
109
123
|
var _this = this;
|
|
110
|
-
|
|
111
|
-
|
|
124
|
+
(0, AssertError_1.asserts)(this._registration !== undefined, {
|
|
125
|
+
name: constants_1.SERVICE_WORKER_EXCEPTION,
|
|
126
|
+
message: 'Service Worker registration is undefined',
|
|
127
|
+
});
|
|
112
128
|
this._publicKey = publicKey;
|
|
113
129
|
return new Promise(function (resolve, reject) {
|
|
114
130
|
if ((0, JS_1.browserOrNode)().isBrowser) {
|
|
131
|
+
(0, AssertError_1.asserts)(_this._registration !== undefined, {
|
|
132
|
+
name: constants_1.SERVICE_WORKER_EXCEPTION,
|
|
133
|
+
message: 'Service Worker registration is undefined',
|
|
134
|
+
});
|
|
115
135
|
_this._registration.pushManager.getSubscription().then(function (subscription) {
|
|
116
136
|
if (subscription) {
|
|
117
137
|
_this._subscription = subscription;
|
|
@@ -120,8 +140,7 @@ var ServiceWorkerClass = /** @class */ (function () {
|
|
|
120
140
|
}
|
|
121
141
|
else {
|
|
122
142
|
_this._logger.debug("User is NOT subscribed to push");
|
|
123
|
-
return _this._registration.pushManager
|
|
124
|
-
.subscribe({
|
|
143
|
+
return _this._registration.pushManager.subscribe({
|
|
125
144
|
userVisibleOnly: true,
|
|
126
145
|
applicationServerKey: _this._urlB64ToUint8Array(publicKey),
|
|
127
146
|
})
|
|
@@ -137,7 +156,10 @@ var ServiceWorkerClass = /** @class */ (function () {
|
|
|
137
156
|
});
|
|
138
157
|
}
|
|
139
158
|
else {
|
|
140
|
-
return reject(new
|
|
159
|
+
return reject(new Errors_1.AmplifyError({
|
|
160
|
+
name: constants_1.SERVICE_WORKER_EXCEPTION,
|
|
161
|
+
message: 'Service Worker not available',
|
|
162
|
+
}));
|
|
141
163
|
}
|
|
142
164
|
});
|
|
143
165
|
};
|
|
@@ -176,10 +198,11 @@ var ServiceWorkerClass = /** @class */ (function () {
|
|
|
176
198
|
**/
|
|
177
199
|
ServiceWorkerClass.prototype._setupListeners = function () {
|
|
178
200
|
var _this = this;
|
|
179
|
-
this.
|
|
180
|
-
var currentState = _this.
|
|
201
|
+
this.serviceWorker.addEventListener('statechange', function (event) {
|
|
202
|
+
var currentState = _this.serviceWorker.state;
|
|
181
203
|
_this._logger.debug("ServiceWorker statechange: ".concat(currentState));
|
|
182
|
-
|
|
204
|
+
Amplify_1.Amplify.Analytics;
|
|
205
|
+
if (isAmplifyWithAnalytics(Amplify_1.Amplify)) {
|
|
183
206
|
Amplify_1.Amplify.Analytics.record({
|
|
184
207
|
name: 'ServiceWorker',
|
|
185
208
|
attributes: {
|
|
@@ -188,10 +211,13 @@ var ServiceWorkerClass = /** @class */ (function () {
|
|
|
188
211
|
});
|
|
189
212
|
}
|
|
190
213
|
});
|
|
191
|
-
this.
|
|
214
|
+
this.serviceWorker.addEventListener('message', function (event) {
|
|
192
215
|
_this._logger.debug("ServiceWorker message event: ".concat(event));
|
|
193
216
|
});
|
|
194
217
|
};
|
|
195
218
|
return ServiceWorkerClass;
|
|
196
219
|
}());
|
|
197
220
|
exports.ServiceWorkerClass = ServiceWorkerClass;
|
|
221
|
+
function isAmplifyWithAnalytics(amplify) {
|
|
222
|
+
return amplify.Analytics && typeof amplify.Analytics.record === 'function';
|
|
223
|
+
}
|
package/lib/Signer.d.ts
CHANGED
|
@@ -35,7 +35,20 @@ export declare class Signer {
|
|
|
35
35
|
*
|
|
36
36
|
* @returns {object} Signed HTTP request
|
|
37
37
|
*/
|
|
38
|
-
static sign(request:
|
|
38
|
+
static sign(request: {
|
|
39
|
+
headers: any;
|
|
40
|
+
body?: BodyInit;
|
|
41
|
+
data?: any;
|
|
42
|
+
url: string;
|
|
43
|
+
method: string;
|
|
44
|
+
}, accessInfo: {
|
|
45
|
+
access_key: string;
|
|
46
|
+
secret_key: string;
|
|
47
|
+
session_token: string;
|
|
48
|
+
}, serviceInfo: {
|
|
49
|
+
service: string;
|
|
50
|
+
region: string;
|
|
51
|
+
}): any;
|
|
39
52
|
static signUrl(urlToSign: string, accessInfo: any, serviceInfo?: any, expiration?: number): string;
|
|
40
53
|
static signUrl(request: any, accessInfo: any, serviceInfo?: any, expiration?: number): string;
|
|
41
54
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CookieStorageData, KeyValueStorageInterface, SameSite } from '../types';
|
|
2
|
+
export declare class CookieStorage implements KeyValueStorageInterface {
|
|
3
|
+
domain?: string;
|
|
4
|
+
path: string;
|
|
5
|
+
expires?: number;
|
|
6
|
+
secure?: boolean;
|
|
7
|
+
sameSite?: SameSite;
|
|
8
|
+
constructor(data?: CookieStorageData);
|
|
9
|
+
setItem(key: string, value: string): Promise<void>;
|
|
10
|
+
getItem(key: string): Promise<string>;
|
|
11
|
+
removeItem(key: string): Promise<void>;
|
|
12
|
+
clear(): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
35
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
36
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
37
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
38
|
+
function step(op) {
|
|
39
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
40
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
41
|
+
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;
|
|
42
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
43
|
+
switch (op[0]) {
|
|
44
|
+
case 0: case 1: t = op; break;
|
|
45
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
46
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
47
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
48
|
+
default:
|
|
49
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
50
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
51
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
52
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
53
|
+
if (t[2]) _.ops.pop();
|
|
54
|
+
_.trys.pop(); continue;
|
|
55
|
+
}
|
|
56
|
+
op = body.call(thisArg, _);
|
|
57
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
58
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
|
+
exports.CookieStorage = void 0;
|
|
63
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
64
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
65
|
+
// @ts-ignore
|
|
66
|
+
var Cookies = __importStar(require("js-cookie"));
|
|
67
|
+
var CookieStorage = /** @class */ (function () {
|
|
68
|
+
function CookieStorage(data) {
|
|
69
|
+
if (data === void 0) { data = {}; }
|
|
70
|
+
if (data.domain) {
|
|
71
|
+
this.domain = data.domain;
|
|
72
|
+
}
|
|
73
|
+
if (data.path) {
|
|
74
|
+
this.path = data.path;
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
this.path = '/';
|
|
78
|
+
}
|
|
79
|
+
if (Object.prototype.hasOwnProperty.call(data, 'expires')) {
|
|
80
|
+
this.expires = data.expires;
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
this.expires = 365;
|
|
84
|
+
}
|
|
85
|
+
if (Object.prototype.hasOwnProperty.call(data, 'secure')) {
|
|
86
|
+
this.secure = data.secure;
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
this.secure = true;
|
|
90
|
+
}
|
|
91
|
+
if (data.hasOwnProperty('sameSite')) {
|
|
92
|
+
if (!data.sameSite ||
|
|
93
|
+
!['strict', 'lax', 'none'].includes(data.sameSite)) {
|
|
94
|
+
throw new Error('The sameSite value of cookieStorage must be "lax", "strict" or "none".');
|
|
95
|
+
}
|
|
96
|
+
if (data.sameSite === 'none' && !this.secure) {
|
|
97
|
+
throw new Error('sameSite = None requires the Secure attribute in latest browser versions.');
|
|
98
|
+
}
|
|
99
|
+
this.sameSite = data.sameSite;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
CookieStorage.prototype.setItem = function (key, value) {
|
|
103
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
104
|
+
var options;
|
|
105
|
+
return __generator(this, function (_a) {
|
|
106
|
+
options = {
|
|
107
|
+
path: this.path,
|
|
108
|
+
expires: this.expires,
|
|
109
|
+
domain: this.domain,
|
|
110
|
+
secure: this.secure,
|
|
111
|
+
};
|
|
112
|
+
if (this.sameSite) {
|
|
113
|
+
options.sameSite = this.sameSite;
|
|
114
|
+
}
|
|
115
|
+
Cookies.set(key, value, options);
|
|
116
|
+
return [2 /*return*/, Cookies.get(key)];
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
CookieStorage.prototype.getItem = function (key) {
|
|
121
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
122
|
+
return __generator(this, function (_a) {
|
|
123
|
+
return [2 /*return*/, Cookies.get(key)];
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
CookieStorage.prototype.removeItem = function (key) {
|
|
128
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
129
|
+
var options;
|
|
130
|
+
return __generator(this, function (_a) {
|
|
131
|
+
options = {
|
|
132
|
+
path: this.path,
|
|
133
|
+
expires: this.expires,
|
|
134
|
+
domain: this.domain,
|
|
135
|
+
secure: this.secure,
|
|
136
|
+
};
|
|
137
|
+
if (this.sameSite) {
|
|
138
|
+
options.sameSite = this.sameSite;
|
|
139
|
+
}
|
|
140
|
+
Cookies.remove(key, options);
|
|
141
|
+
return [2 /*return*/];
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
CookieStorage.prototype.clear = function () {
|
|
146
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
147
|
+
var cookies, numKeys, promiseArray, index;
|
|
148
|
+
return __generator(this, function (_a) {
|
|
149
|
+
switch (_a.label) {
|
|
150
|
+
case 0:
|
|
151
|
+
cookies = Cookies.get();
|
|
152
|
+
numKeys = Object.keys(cookies).length;
|
|
153
|
+
promiseArray = [];
|
|
154
|
+
for (index = 0; index < numKeys; ++index) {
|
|
155
|
+
promiseArray.push(this.removeItem(Object.keys(cookies)[index]));
|
|
156
|
+
}
|
|
157
|
+
return [4 /*yield*/, Promise.all(promiseArray)];
|
|
158
|
+
case 1:
|
|
159
|
+
_a.sent();
|
|
160
|
+
return [2 /*return*/];
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
};
|
|
165
|
+
return CookieStorage;
|
|
166
|
+
}());
|
|
167
|
+
exports.CookieStorage = CookieStorage;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { KeyValueStorageInterface } from '../types';
|
|
2
|
+
declare class MemoryKeyValueStorageClass implements KeyValueStorageInterface {
|
|
3
|
+
myStorage: Record<string, string>;
|
|
4
|
+
setItem(key: string, value: string): Promise<void>;
|
|
5
|
+
getItem(key: string): Promise<string | null>;
|
|
6
|
+
removeItem(key: string): Promise<void>;
|
|
7
|
+
clear(): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
export declare const MemoryKeyValueStorage: MemoryKeyValueStorageClass;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
5
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
6
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
7
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
8
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
9
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
10
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
14
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
15
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
16
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
17
|
+
function step(op) {
|
|
18
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
19
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
20
|
+
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;
|
|
21
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
22
|
+
switch (op[0]) {
|
|
23
|
+
case 0: case 1: t = op; break;
|
|
24
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
25
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
26
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
27
|
+
default:
|
|
28
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
29
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
30
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
31
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
32
|
+
if (t[2]) _.ops.pop();
|
|
33
|
+
_.trys.pop(); continue;
|
|
34
|
+
}
|
|
35
|
+
op = body.call(thisArg, _);
|
|
36
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
37
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.MemoryKeyValueStorage = void 0;
|
|
42
|
+
var MemoryKeyValueStorageClass = /** @class */ (function () {
|
|
43
|
+
function MemoryKeyValueStorageClass() {
|
|
44
|
+
this.myStorage = {};
|
|
45
|
+
}
|
|
46
|
+
MemoryKeyValueStorageClass.prototype.setItem = function (key, value) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
48
|
+
return __generator(this, function (_a) {
|
|
49
|
+
this.myStorage[key] = value;
|
|
50
|
+
return [2 /*return*/];
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
MemoryKeyValueStorageClass.prototype.getItem = function (key) {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
56
|
+
return __generator(this, function (_a) {
|
|
57
|
+
return [2 /*return*/, this.myStorage[key]];
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
MemoryKeyValueStorageClass.prototype.removeItem = function (key) {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
63
|
+
return __generator(this, function (_a) {
|
|
64
|
+
delete this.myStorage[key];
|
|
65
|
+
return [2 /*return*/];
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
MemoryKeyValueStorageClass.prototype.clear = function () {
|
|
70
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
71
|
+
var _this = this;
|
|
72
|
+
return __generator(this, function (_a) {
|
|
73
|
+
Object.keys(this.myStorage).forEach(function (key) {
|
|
74
|
+
delete _this.myStorage[key];
|
|
75
|
+
});
|
|
76
|
+
return [2 /*return*/];
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
return MemoryKeyValueStorageClass;
|
|
81
|
+
}());
|
|
82
|
+
exports.MemoryKeyValueStorage = new MemoryKeyValueStorageClass();
|
|
@@ -6,14 +6,14 @@ export declare class MemoryStorage {
|
|
|
6
6
|
* @param {object} value - the value
|
|
7
7
|
* @returns {string} value that was set
|
|
8
8
|
*/
|
|
9
|
-
static setItem(key: string, value: any):
|
|
9
|
+
static setItem(key: string, value: any): string;
|
|
10
10
|
/**
|
|
11
11
|
* This is used to get a specific key from storage
|
|
12
12
|
* @param {string} key - the key for the item
|
|
13
13
|
* This is used to clear the storage
|
|
14
14
|
* @returns {string} the data item
|
|
15
15
|
*/
|
|
16
|
-
static getItem(key: string):
|
|
16
|
+
static getItem(key: string): string | undefined;
|
|
17
17
|
/**
|
|
18
18
|
* This is used to remove an item from storage
|
|
19
19
|
* @param {string} key - the key being set
|
|
@@ -24,7 +24,7 @@ export declare class MemoryStorage {
|
|
|
24
24
|
* This is used to clear the storage
|
|
25
25
|
* @returns {string} nothing
|
|
26
26
|
*/
|
|
27
|
-
static clear():
|
|
27
|
+
static clear(): Record<string, string>;
|
|
28
28
|
}
|
|
29
29
|
export declare class StorageHelper {
|
|
30
30
|
private storageWindow;
|
|
@@ -39,3 +39,7 @@ export declare class StorageHelper {
|
|
|
39
39
|
*/
|
|
40
40
|
getStorage(): any;
|
|
41
41
|
}
|
|
42
|
+
export { SessionStorage } from './sessionStorage';
|
|
43
|
+
export { LocalStorage } from './localStorage';
|
|
44
|
+
export { MemoryKeyValueStorage } from './inMemoryStorage';
|
|
45
|
+
export { CookieStorage } from './cookieStorage';
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.StorageHelper = exports.MemoryStorage = void 0;
|
|
5
|
+
exports.CookieStorage = exports.MemoryKeyValueStorage = exports.LocalStorage = exports.SessionStorage = exports.StorageHelper = exports.MemoryStorage = void 0;
|
|
6
6
|
var dataMemory = {};
|
|
7
7
|
/** @class */
|
|
8
8
|
var MemoryStorage = /** @class */ (function () {
|
|
@@ -73,3 +73,11 @@ var StorageHelper = /** @class */ (function () {
|
|
|
73
73
|
return StorageHelper;
|
|
74
74
|
}());
|
|
75
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; } });
|