@aws-amplify/core 6.0.1-console-preview.4432977.0 → 6.0.1-console-preview.67f944e.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 (133) hide show
  1. package/lib/AwsClients/Pinpoint/errorHelpers.d.ts +5 -0
  2. package/lib/AwsClients/Pinpoint/errorHelpers.js +17 -0
  3. package/lib/AwsClients/Pinpoint/putEvents.js +2 -6
  4. package/lib/Cache/AsyncStorageCache.js +3 -10
  5. package/lib/Cache/BrowserStorageCache.js +5 -18
  6. package/lib/Cache/InMemoryCache.js +3 -10
  7. package/lib/Cache/Utils/CacheList.js +5 -18
  8. package/lib/Cache/Utils/errorHelpers.d.ts +8 -0
  9. package/lib/Cache/Utils/errorHelpers.js +29 -0
  10. package/lib/Hub/index.js +2 -2
  11. package/lib/Hub/types/AuthTypes.d.ts +5 -0
  12. package/lib/I18n/errorHelpers.d.ts +5 -0
  13. package/lib/I18n/errorHelpers.js +17 -0
  14. package/lib/I18n/index.js +5 -18
  15. package/lib/Platform/version.d.ts +1 -1
  16. package/lib/Platform/version.js +1 -1
  17. package/lib/ServiceWorker/ServiceWorker.js +13 -35
  18. package/lib/ServiceWorker/errorHelpers.d.ts +7 -0
  19. package/lib/ServiceWorker/errorHelpers.js +25 -0
  20. package/lib/Util/Constants.d.ts +0 -6
  21. package/lib/Util/Constants.js +1 -7
  22. package/lib/adapterCore/error/AmplifyServerContextError.d.ts +1 -1
  23. package/lib/adapterCore/error/AmplifyServerContextError.js +2 -2
  24. package/lib/{Util/Errors.d.ts → errors/AmplifyError.d.ts} +2 -9
  25. package/lib/{Util/Errors.js → errors/AmplifyError.js} +1 -18
  26. package/lib/errors/PlatformNotSupportedError.d.ts +4 -0
  27. package/lib/errors/PlatformNotSupportedError.js +33 -0
  28. package/lib/errors/createAssertionFunction.d.ts +3 -0
  29. package/lib/errors/createAssertionFunction.js +22 -0
  30. package/lib/errors/index.d.ts +3 -0
  31. package/lib/errors/index.js +11 -0
  32. package/lib/index.d.ts +1 -1
  33. package/lib/libraryUtils.d.ts +3 -4
  34. package/lib/libraryUtils.js +9 -10
  35. package/lib/parseAWSExports.js +3 -1
  36. package/lib/providers/pinpoint/apis/record.js +2 -2
  37. package/lib/singleton/Auth/utils/errorHelpers.d.ts +8 -0
  38. package/lib/singleton/Auth/utils/errorHelpers.js +33 -0
  39. package/lib/singleton/Auth/utils/index.d.ts +1 -1
  40. package/lib/singleton/Auth/utils/index.js +9 -25
  41. package/lib/singleton/Geo/types.d.ts +17 -0
  42. package/lib/singleton/Geo/types.js +4 -0
  43. package/lib/singleton/types.d.ts +3 -1
  44. package/lib/storage/DefaultStorage.native.js +2 -2
  45. package/lib/storage/KeyValueStorage.js +5 -5
  46. package/lib/tsconfig.tsbuildinfo +1 -1
  47. package/lib/types/errors.d.ts +8 -3
  48. package/lib/types/errors.js +6 -0
  49. package/lib-esm/AwsClients/Pinpoint/errorHelpers.d.ts +5 -0
  50. package/lib-esm/AwsClients/Pinpoint/errorHelpers.js +14 -0
  51. package/lib-esm/AwsClients/Pinpoint/putEvents.js +2 -6
  52. package/lib-esm/Cache/AsyncStorageCache.js +3 -10
  53. package/lib-esm/Cache/BrowserStorageCache.js +5 -18
  54. package/lib-esm/Cache/InMemoryCache.js +3 -10
  55. package/lib-esm/Cache/Utils/CacheList.js +5 -18
  56. package/lib-esm/Cache/Utils/errorHelpers.d.ts +8 -0
  57. package/lib-esm/Cache/Utils/errorHelpers.js +26 -0
  58. package/lib-esm/Hub/index.js +1 -1
  59. package/lib-esm/Hub/types/AuthTypes.d.ts +5 -0
  60. package/lib-esm/I18n/errorHelpers.d.ts +5 -0
  61. package/lib-esm/I18n/errorHelpers.js +14 -0
  62. package/lib-esm/I18n/index.js +5 -18
  63. package/lib-esm/Platform/version.d.ts +1 -1
  64. package/lib-esm/Platform/version.js +1 -1
  65. package/lib-esm/ServiceWorker/ServiceWorker.js +8 -30
  66. package/lib-esm/ServiceWorker/errorHelpers.d.ts +7 -0
  67. package/lib-esm/ServiceWorker/errorHelpers.js +22 -0
  68. package/lib-esm/Util/Constants.d.ts +0 -6
  69. package/lib-esm/Util/Constants.js +0 -6
  70. package/lib-esm/adapterCore/error/AmplifyServerContextError.d.ts +1 -1
  71. package/lib-esm/adapterCore/error/AmplifyServerContextError.js +1 -1
  72. package/lib-esm/{Util/Errors.d.ts → errors/AmplifyError.d.ts} +2 -9
  73. package/lib-esm/{Util/Errors.js → errors/AmplifyError.js} +0 -15
  74. package/lib-esm/errors/PlatformNotSupportedError.d.ts +4 -0
  75. package/lib-esm/errors/PlatformNotSupportedError.js +30 -0
  76. package/lib-esm/errors/createAssertionFunction.d.ts +3 -0
  77. package/lib-esm/errors/createAssertionFunction.js +18 -0
  78. package/lib-esm/errors/index.d.ts +3 -0
  79. package/lib-esm/errors/index.js +5 -0
  80. package/lib-esm/index.d.ts +1 -1
  81. package/lib-esm/libraryUtils.d.ts +3 -4
  82. package/lib-esm/libraryUtils.js +3 -3
  83. package/lib-esm/parseAWSExports.js +3 -1
  84. package/lib-esm/providers/pinpoint/apis/record.js +1 -1
  85. package/lib-esm/singleton/Auth/utils/errorHelpers.d.ts +8 -0
  86. package/lib-esm/singleton/Auth/utils/errorHelpers.js +30 -0
  87. package/lib-esm/singleton/Auth/utils/index.d.ts +1 -1
  88. package/lib-esm/singleton/Auth/utils/index.js +7 -23
  89. package/lib-esm/singleton/Geo/types.d.ts +17 -0
  90. package/lib-esm/singleton/Geo/types.js +3 -0
  91. package/lib-esm/singleton/types.d.ts +3 -1
  92. package/lib-esm/storage/DefaultStorage.native.js +1 -1
  93. package/lib-esm/storage/KeyValueStorage.js +5 -5
  94. package/lib-esm/tsconfig.tsbuildinfo +1 -1
  95. package/lib-esm/types/errors.d.ts +8 -3
  96. package/lib-esm/types/errors.js +5 -1
  97. package/package.json +2 -2
  98. package/src/AwsClients/Pinpoint/errorHelpers.ts +19 -0
  99. package/src/AwsClients/Pinpoint/putEvents.ts +2 -6
  100. package/src/Cache/AsyncStorageCache.ts +4 -10
  101. package/src/Cache/BrowserStorageCache.ts +5 -18
  102. package/src/Cache/InMemoryCache.ts +4 -11
  103. package/src/Cache/Utils/CacheList.ts +5 -18
  104. package/src/Cache/Utils/errorHelpers.ts +30 -0
  105. package/src/Hub/index.ts +1 -1
  106. package/src/Hub/types/AuthTypes.ts +3 -1
  107. package/src/I18n/errorHelpers.ts +18 -0
  108. package/src/I18n/index.ts +12 -24
  109. package/src/Platform/version.ts +1 -1
  110. package/src/ServiceWorker/ServiceWorker.ts +18 -30
  111. package/src/ServiceWorker/errorHelpers.ts +26 -0
  112. package/src/Util/Constants.ts +0 -6
  113. package/src/adapterCore/error/AmplifyServerContextError.ts +1 -1
  114. package/src/{Util/Errors.ts → errors/AmplifyError.ts} +2 -18
  115. package/src/errors/PlatformNotSupportedError.ts +14 -0
  116. package/src/errors/createAssertionFunction.ts +23 -0
  117. package/src/errors/index.ts +6 -0
  118. package/src/index.ts +1 -0
  119. package/src/libraryUtils.ts +11 -7
  120. package/src/parseAWSExports.ts +7 -1
  121. package/src/providers/pinpoint/apis/record.ts +1 -1
  122. package/src/singleton/Auth/utils/errorHelpers.ts +37 -0
  123. package/src/singleton/Auth/utils/index.ts +19 -26
  124. package/src/singleton/Geo/types.ts +20 -0
  125. package/src/singleton/types.ts +3 -0
  126. package/src/storage/DefaultStorage.native.ts +1 -1
  127. package/src/storage/KeyValueStorage.ts +5 -5
  128. package/src/types/errors.ts +14 -3
  129. package/lib/Util/errors/AssertError.d.ts +0 -2
  130. package/lib/Util/errors/AssertError.js +0 -11
  131. package/lib-esm/Util/errors/AssertError.d.ts +0 -2
  132. package/lib-esm/Util/errors/AssertError.js +0 -7
  133. package/src/Util/errors/AssertError.ts +0 -11
@@ -41,7 +41,7 @@ import { getEndpointId } from '../utils';
41
41
  import { BUFFER_SIZE, FLUSH_INTERVAL, FLUSH_SIZE, RESEND_LIMIT, } from '../utils/constants';
42
42
  import { updateEndpoint } from './updateEndpoint';
43
43
  import { getEventBuffer } from '../utils/getEventBuffer';
44
- import { AmplifyError } from '../../../libraryUtils';
44
+ import { AmplifyError } from '../../../errors';
45
45
  // TODO(v6) Refactor when we add support for session tracking & `autoTrack`
46
46
  var session;
47
47
  /**
@@ -0,0 +1,8 @@
1
+ import { AssertionFunction } from '../../../types';
2
+ export declare enum AuthConfigurationErrorCode {
3
+ AuthTokenConfigException = "AuthTokenConfigException",
4
+ AuthUserPoolAndIdentityPoolException = "AuthUserPoolAndIdentityPoolException",
5
+ InvalidIdentityPoolIdException = "InvalidIdentityPoolIdException",
6
+ OAuthNotConfigureException = "OAuthNotConfigureException"
7
+ }
8
+ export declare const assert: AssertionFunction<AuthConfigurationErrorCode>;
@@ -0,0 +1,30 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ var _a;
4
+ import { createAssertionFunction } from '../../../errors';
5
+ export var AuthConfigurationErrorCode;
6
+ (function (AuthConfigurationErrorCode) {
7
+ AuthConfigurationErrorCode["AuthTokenConfigException"] = "AuthTokenConfigException";
8
+ AuthConfigurationErrorCode["AuthUserPoolAndIdentityPoolException"] = "AuthUserPoolAndIdentityPoolException";
9
+ AuthConfigurationErrorCode["InvalidIdentityPoolIdException"] = "InvalidIdentityPoolIdException";
10
+ AuthConfigurationErrorCode["OAuthNotConfigureException"] = "OAuthNotConfigureException";
11
+ })(AuthConfigurationErrorCode || (AuthConfigurationErrorCode = {}));
12
+ var authConfigurationErrorMap = (_a = {},
13
+ _a[AuthConfigurationErrorCode.AuthTokenConfigException] = {
14
+ message: 'Auth Token Provider not configured.',
15
+ recoverySuggestion: 'Make sure to call Amplify.configure in your app.',
16
+ },
17
+ _a[AuthConfigurationErrorCode.AuthUserPoolAndIdentityPoolException] = {
18
+ message: 'Auth UserPool or IdentityPool not configured.',
19
+ recoverySuggestion: 'Make sure to call Amplify.configure in your app with UserPoolId and IdentityPoolId.',
20
+ },
21
+ _a[AuthConfigurationErrorCode.InvalidIdentityPoolIdException] = {
22
+ message: 'Invalid identity pool id provided.',
23
+ recoverySuggestion: 'Make sure a valid identityPoolId is given in the config.',
24
+ },
25
+ _a[AuthConfigurationErrorCode.OAuthNotConfigureException] = {
26
+ message: 'oauth param not configured.',
27
+ recoverySuggestion: 'Make sure to call Amplify.configure with oauth parameter in your app.',
28
+ },
29
+ _a);
30
+ export var assert = createAssertionFunction(authConfigurationErrorMap);
@@ -1,5 +1,5 @@
1
1
  import { JWT, CognitoUserPoolWithOAuthConfig, CognitoUserPoolConfig, CognitoUserPoolAndIdentityPoolConfig, CognitoIdentityPoolConfig, StrictUnion } from '../types';
2
2
  export declare function assertTokenProviderConfig(cognitoConfig?: StrictUnion<CognitoUserPoolConfig | CognitoUserPoolAndIdentityPoolConfig | CognitoIdentityPoolConfig>): asserts cognitoConfig is CognitoUserPoolAndIdentityPoolConfig | CognitoUserPoolConfig;
3
3
  export declare function assertOAuthConfig(cognitoConfig?: CognitoUserPoolConfig | CognitoUserPoolAndIdentityPoolConfig): asserts cognitoConfig is CognitoUserPoolWithOAuthConfig;
4
- export declare function assertIdentityPooIdConfig(cognitoConfig?: StrictUnion<CognitoUserPoolConfig | CognitoUserPoolAndIdentityPoolConfig | CognitoIdentityPoolConfig>): asserts cognitoConfig is CognitoIdentityPoolConfig;
4
+ export declare function assertIdentityPoolIdConfig(cognitoConfig?: StrictUnion<CognitoUserPoolConfig | CognitoUserPoolAndIdentityPoolConfig | CognitoIdentityPoolConfig>): asserts cognitoConfig is CognitoIdentityPoolConfig;
5
5
  export declare function decodeJWT(token: string): JWT;
@@ -1,6 +1,6 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- import { asserts } from '../../../Util/errors/AssertError';
3
+ import { AuthConfigurationErrorCode, assert } from './errorHelpers';
4
4
  export function assertTokenProviderConfig(cognitoConfig) {
5
5
  var assertionValid = true; // assume valid until otherwise proveed
6
6
  if (!cognitoConfig) {
@@ -10,11 +10,7 @@ export function assertTokenProviderConfig(cognitoConfig) {
10
10
  assertionValid =
11
11
  !!cognitoConfig.userPoolClientId && !!cognitoConfig.userPoolClientId;
12
12
  }
13
- return asserts(assertionValid, {
14
- name: 'AuthTokenConfigException',
15
- message: 'Auth Token Provider not configured',
16
- recoverySuggestion: 'Make sure to call Amplify.configure in your app',
17
- });
13
+ return assert(assertionValid, AuthConfigurationErrorCode.AuthTokenConfigException);
18
14
  }
19
15
  export function assertOAuthConfig(cognitoConfig) {
20
16
  var _a, _b, _c, _d, _e, _f, _g, _h;
@@ -22,27 +18,15 @@ export function assertOAuthConfig(cognitoConfig) {
22
18
  !!((_d = (_c = cognitoConfig === null || cognitoConfig === void 0 ? void 0 : cognitoConfig.loginWith) === null || _c === void 0 ? void 0 : _c.oauth) === null || _d === void 0 ? void 0 : _d.redirectSignOut) &&
23
19
  !!((_f = (_e = cognitoConfig === null || cognitoConfig === void 0 ? void 0 : cognitoConfig.loginWith) === null || _e === void 0 ? void 0 : _e.oauth) === null || _f === void 0 ? void 0 : _f.redirectSignIn) &&
24
20
  !!((_h = (_g = cognitoConfig === null || cognitoConfig === void 0 ? void 0 : cognitoConfig.loginWith) === null || _g === void 0 ? void 0 : _g.oauth) === null || _h === void 0 ? void 0 : _h.responseType);
25
- return asserts(validOAuthConfig, {
26
- name: 'OAuthNotConfigureException',
27
- message: 'oauth param not configured',
28
- recoverySuggestion: 'Make sure to call Amplify.configure with oauth parameter in your app',
29
- });
21
+ return assert(validOAuthConfig, AuthConfigurationErrorCode.OAuthNotConfigureException);
30
22
  }
31
- export function assertIdentityPooIdConfig(cognitoConfig) {
23
+ export function assertIdentityPoolIdConfig(cognitoConfig) {
32
24
  var validConfig = !!(cognitoConfig === null || cognitoConfig === void 0 ? void 0 : cognitoConfig.identityPoolId);
33
- return asserts(validConfig, {
34
- name: 'InvalidIdentityPoolIdException',
35
- message: 'Invalid identity pool id provided.',
36
- recoverySuggestion: 'Make sure a valid identityPoolId is given in the config.',
37
- });
25
+ return assert(validConfig, AuthConfigurationErrorCode.InvalidIdentityPoolIdException);
38
26
  }
39
- function assertUserPoolAndIdentityPooConfig(authConfig) {
27
+ function assertUserPoolAndIdentityPoolConfig(authConfig) {
40
28
  var validConfig = !!(authConfig === null || authConfig === void 0 ? void 0 : authConfig.Cognito.identityPoolId) && !!(authConfig === null || authConfig === void 0 ? void 0 : authConfig.Cognito.userPoolId);
41
- return asserts(validConfig, {
42
- name: 'AuthUserPoolAndIdentityPoolException',
43
- message: 'Auth UserPool and IdentityPool not configured',
44
- recoverySuggestion: 'Make sure to call Amplify.configure in your app with UserPoolId and IdentityPoolId',
45
- });
29
+ return assert(validConfig, AuthConfigurationErrorCode.AuthUserPoolAndIdentityPoolException);
46
30
  }
47
31
  export function decodeJWT(token) {
48
32
  var tokenSplitted = token.split('.');
@@ -0,0 +1,17 @@
1
+ export interface GeoConfig {
2
+ LocationService?: {
3
+ region: string;
4
+ maps?: {
5
+ items: {};
6
+ default: string;
7
+ };
8
+ searchIndices?: {
9
+ items: string[];
10
+ default: string;
11
+ };
12
+ geofenceCollections?: {
13
+ items: string[];
14
+ default: string;
15
+ };
16
+ };
17
+ }
@@ -0,0 +1,3 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ export {};
@@ -1,6 +1,7 @@
1
1
  import { APIConfig, LibraryAPIOptions } from './API/types';
2
2
  import { AnalyticsConfig } from './Analytics/types';
3
3
  import { AuthConfig, LibraryAuthOptions, AuthUserPoolConfig, AuthIdentityPoolConfig, AuthUserPoolAndIdentityPoolConfig, GetCredentialsOptions, CognitoIdentityPoolConfig } from './Auth/types';
4
+ import { GeoConfig } from './Geo/types';
4
5
  import { LibraryStorageOptions, StorageAccessLevel, StorageConfig } from './Storage/types';
5
6
  export type LegacyConfig = {
6
7
  /**
@@ -13,6 +14,7 @@ export type ResourcesConfig = {
13
14
  Analytics?: AnalyticsConfig;
14
15
  Auth?: AuthConfig;
15
16
  Storage?: StorageConfig;
17
+ Geo?: GeoConfig;
16
18
  };
17
19
  export type LibraryOptions = {
18
20
  API?: LibraryAPIOptions;
@@ -20,4 +22,4 @@ export type LibraryOptions = {
20
22
  Storage?: LibraryStorageOptions;
21
23
  ssr?: boolean;
22
24
  };
23
- export { APIConfig, AuthConfig, AuthUserPoolConfig, AuthIdentityPoolConfig, AuthUserPoolAndIdentityPoolConfig, GetCredentialsOptions, StorageAccessLevel, StorageConfig, AnalyticsConfig, CognitoIdentityPoolConfig, };
25
+ export { APIConfig, AuthConfig, AuthUserPoolConfig, AuthIdentityPoolConfig, AuthUserPoolAndIdentityPoolConfig, GetCredentialsOptions, StorageAccessLevel, StorageConfig, AnalyticsConfig, CognitoIdentityPoolConfig, GeoConfig, };
@@ -36,7 +36,7 @@ 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';
39
+ import { AmplifyError } from '../errors';
40
40
  var ASYNC_STORAGE_MODULE = '@react-native-async-storage/async-storage';
41
41
  var MEMORY_KEY_PREFIX = '@MemoryStorage:';
42
42
  /**
@@ -36,7 +36,7 @@ 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 { PlatformNotSupportedError } from '../Util/Errors';
39
+ import { PlatformNotSupportedError } from '../errors';
40
40
  /**
41
41
  * @internal
42
42
  */
@@ -54,7 +54,7 @@ var KeyValueStorage = /** @class */ (function () {
54
54
  return __awaiter(this, void 0, void 0, function () {
55
55
  return __generator(this, function (_a) {
56
56
  if (!this.storage)
57
- throw PlatformNotSupportedError;
57
+ throw new PlatformNotSupportedError();
58
58
  this.storage.setItem(key, value);
59
59
  return [2 /*return*/];
60
60
  });
@@ -70,7 +70,7 @@ var KeyValueStorage = /** @class */ (function () {
70
70
  return __awaiter(this, void 0, void 0, function () {
71
71
  return __generator(this, function (_a) {
72
72
  if (!this.storage)
73
- throw PlatformNotSupportedError;
73
+ throw new PlatformNotSupportedError();
74
74
  return [2 /*return*/, this.storage.getItem(key)];
75
75
  });
76
76
  });
@@ -84,7 +84,7 @@ var KeyValueStorage = /** @class */ (function () {
84
84
  return __awaiter(this, void 0, void 0, function () {
85
85
  return __generator(this, function (_a) {
86
86
  if (!this.storage)
87
- throw PlatformNotSupportedError;
87
+ throw new PlatformNotSupportedError();
88
88
  this.storage.removeItem(key);
89
89
  return [2 /*return*/];
90
90
  });
@@ -98,7 +98,7 @@ var KeyValueStorage = /** @class */ (function () {
98
98
  return __awaiter(this, void 0, void 0, function () {
99
99
  return __generator(this, function (_a) {
100
100
  if (!this.storage)
101
- throw PlatformNotSupportedError;
101
+ throw new PlatformNotSupportedError();
102
102
  this.storage.clear();
103
103
  return [2 /*return*/];
104
104
  });