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