@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.
- package/lib/AwsClients/Pinpoint/errorHelpers.d.ts +5 -0
- package/lib/AwsClients/Pinpoint/errorHelpers.js +17 -0
- package/lib/AwsClients/Pinpoint/putEvents.js +2 -6
- package/lib/Cache/AsyncStorageCache.js +3 -10
- package/lib/Cache/BrowserStorageCache.js +5 -18
- package/lib/Cache/InMemoryCache.js +3 -10
- package/lib/Cache/Utils/CacheList.js +5 -18
- package/lib/Cache/Utils/errorHelpers.d.ts +8 -0
- package/lib/Cache/Utils/errorHelpers.js +29 -0
- package/lib/Hub/index.js +2 -2
- package/lib/Hub/types/AuthTypes.d.ts +5 -0
- package/lib/I18n/errorHelpers.d.ts +5 -0
- package/lib/I18n/errorHelpers.js +17 -0
- package/lib/I18n/index.js +5 -18
- package/lib/Platform/version.d.ts +1 -1
- package/lib/Platform/version.js +1 -1
- package/lib/ServiceWorker/ServiceWorker.js +13 -35
- package/lib/ServiceWorker/errorHelpers.d.ts +7 -0
- package/lib/ServiceWorker/errorHelpers.js +25 -0
- package/lib/Util/Constants.d.ts +0 -6
- package/lib/Util/Constants.js +1 -7
- package/lib/adapterCore/error/AmplifyServerContextError.d.ts +1 -1
- package/lib/adapterCore/error/AmplifyServerContextError.js +2 -2
- package/lib/{Util/Errors.d.ts → errors/AmplifyError.d.ts} +2 -9
- package/lib/{Util/Errors.js → errors/AmplifyError.js} +1 -18
- package/lib/errors/PlatformNotSupportedError.d.ts +4 -0
- package/lib/errors/PlatformNotSupportedError.js +33 -0
- package/lib/errors/createAssertionFunction.d.ts +3 -0
- package/lib/errors/createAssertionFunction.js +22 -0
- package/lib/errors/index.d.ts +3 -0
- package/lib/errors/index.js +11 -0
- package/lib/index.d.ts +1 -1
- package/lib/libraryUtils.d.ts +3 -4
- package/lib/libraryUtils.js +9 -10
- package/lib/parseAWSExports.js +3 -1
- package/lib/providers/pinpoint/apis/record.js +2 -2
- package/lib/singleton/Auth/utils/errorHelpers.d.ts +8 -0
- package/lib/singleton/Auth/utils/errorHelpers.js +33 -0
- package/lib/singleton/Auth/utils/index.d.ts +1 -1
- package/lib/singleton/Auth/utils/index.js +9 -25
- package/lib/singleton/Geo/types.d.ts +17 -0
- package/lib/singleton/Geo/types.js +4 -0
- package/lib/singleton/types.d.ts +3 -1
- package/lib/storage/DefaultStorage.native.js +2 -2
- package/lib/storage/KeyValueStorage.js +5 -5
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/errors.d.ts +8 -3
- package/lib/types/errors.js +6 -0
- package/lib-esm/AwsClients/Pinpoint/errorHelpers.d.ts +5 -0
- package/lib-esm/AwsClients/Pinpoint/errorHelpers.js +14 -0
- package/lib-esm/AwsClients/Pinpoint/putEvents.js +2 -6
- package/lib-esm/Cache/AsyncStorageCache.js +3 -10
- package/lib-esm/Cache/BrowserStorageCache.js +5 -18
- package/lib-esm/Cache/InMemoryCache.js +3 -10
- package/lib-esm/Cache/Utils/CacheList.js +5 -18
- package/lib-esm/Cache/Utils/errorHelpers.d.ts +8 -0
- package/lib-esm/Cache/Utils/errorHelpers.js +26 -0
- package/lib-esm/Hub/index.js +1 -1
- package/lib-esm/Hub/types/AuthTypes.d.ts +5 -0
- package/lib-esm/I18n/errorHelpers.d.ts +5 -0
- package/lib-esm/I18n/errorHelpers.js +14 -0
- package/lib-esm/I18n/index.js +5 -18
- package/lib-esm/Platform/version.d.ts +1 -1
- package/lib-esm/Platform/version.js +1 -1
- package/lib-esm/ServiceWorker/ServiceWorker.js +8 -30
- package/lib-esm/ServiceWorker/errorHelpers.d.ts +7 -0
- package/lib-esm/ServiceWorker/errorHelpers.js +22 -0
- package/lib-esm/Util/Constants.d.ts +0 -6
- package/lib-esm/Util/Constants.js +0 -6
- package/lib-esm/adapterCore/error/AmplifyServerContextError.d.ts +1 -1
- package/lib-esm/adapterCore/error/AmplifyServerContextError.js +1 -1
- package/lib-esm/{Util/Errors.d.ts → errors/AmplifyError.d.ts} +2 -9
- package/lib-esm/{Util/Errors.js → errors/AmplifyError.js} +0 -15
- package/lib-esm/errors/PlatformNotSupportedError.d.ts +4 -0
- package/lib-esm/errors/PlatformNotSupportedError.js +30 -0
- package/lib-esm/errors/createAssertionFunction.d.ts +3 -0
- package/lib-esm/errors/createAssertionFunction.js +18 -0
- package/lib-esm/errors/index.d.ts +3 -0
- package/lib-esm/errors/index.js +5 -0
- package/lib-esm/index.d.ts +1 -1
- package/lib-esm/libraryUtils.d.ts +3 -4
- package/lib-esm/libraryUtils.js +3 -3
- package/lib-esm/parseAWSExports.js +3 -1
- package/lib-esm/providers/pinpoint/apis/record.js +1 -1
- package/lib-esm/singleton/Auth/utils/errorHelpers.d.ts +8 -0
- package/lib-esm/singleton/Auth/utils/errorHelpers.js +30 -0
- package/lib-esm/singleton/Auth/utils/index.d.ts +1 -1
- package/lib-esm/singleton/Auth/utils/index.js +7 -23
- package/lib-esm/singleton/Geo/types.d.ts +17 -0
- package/lib-esm/singleton/Geo/types.js +3 -0
- package/lib-esm/singleton/types.d.ts +3 -1
- package/lib-esm/storage/DefaultStorage.native.js +1 -1
- package/lib-esm/storage/KeyValueStorage.js +5 -5
- package/lib-esm/tsconfig.tsbuildinfo +1 -1
- package/lib-esm/types/errors.d.ts +8 -3
- package/lib-esm/types/errors.js +5 -1
- package/package.json +2 -2
- package/src/AwsClients/Pinpoint/errorHelpers.ts +19 -0
- package/src/AwsClients/Pinpoint/putEvents.ts +2 -6
- package/src/Cache/AsyncStorageCache.ts +4 -10
- package/src/Cache/BrowserStorageCache.ts +5 -18
- package/src/Cache/InMemoryCache.ts +4 -11
- package/src/Cache/Utils/CacheList.ts +5 -18
- package/src/Cache/Utils/errorHelpers.ts +30 -0
- package/src/Hub/index.ts +1 -1
- package/src/Hub/types/AuthTypes.ts +3 -1
- package/src/I18n/errorHelpers.ts +18 -0
- package/src/I18n/index.ts +12 -24
- package/src/Platform/version.ts +1 -1
- package/src/ServiceWorker/ServiceWorker.ts +18 -30
- package/src/ServiceWorker/errorHelpers.ts +26 -0
- package/src/Util/Constants.ts +0 -6
- package/src/adapterCore/error/AmplifyServerContextError.ts +1 -1
- package/src/{Util/Errors.ts → errors/AmplifyError.ts} +2 -18
- package/src/errors/PlatformNotSupportedError.ts +14 -0
- package/src/errors/createAssertionFunction.ts +23 -0
- package/src/errors/index.ts +6 -0
- package/src/index.ts +1 -0
- package/src/libraryUtils.ts +11 -7
- package/src/parseAWSExports.ts +7 -1
- package/src/providers/pinpoint/apis/record.ts +1 -1
- package/src/singleton/Auth/utils/errorHelpers.ts +37 -0
- package/src/singleton/Auth/utils/index.ts +19 -26
- package/src/singleton/Geo/types.ts +20 -0
- package/src/singleton/types.ts +3 -0
- package/src/storage/DefaultStorage.native.ts +1 -1
- package/src/storage/KeyValueStorage.ts +5 -5
- package/src/types/errors.ts +14 -3
- package/lib/Util/errors/AssertError.d.ts +0 -2
- package/lib/Util/errors/AssertError.js +0 -11
- package/lib-esm/Util/errors/AssertError.d.ts +0 -2
- package/lib-esm/Util/errors/AssertError.js +0 -7
- package/src/Util/errors/AssertError.ts +0 -11
|
@@ -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 {
|
|
3
|
+
import { AuthConfigurationErrorCode, assert } from './errorHelpers';
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
6
|
AuthConfig,
|
|
@@ -30,11 +30,10 @@ export function assertTokenProviderConfig(
|
|
|
30
30
|
!!cognitoConfig.userPoolClientId && !!cognitoConfig.userPoolClientId;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
return
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
});
|
|
33
|
+
return assert(
|
|
34
|
+
assertionValid,
|
|
35
|
+
AuthConfigurationErrorCode.AuthTokenConfigException
|
|
36
|
+
);
|
|
38
37
|
}
|
|
39
38
|
|
|
40
39
|
export function assertOAuthConfig(
|
|
@@ -46,15 +45,13 @@ export function assertOAuthConfig(
|
|
|
46
45
|
!!cognitoConfig?.loginWith?.oauth?.redirectSignIn &&
|
|
47
46
|
!!cognitoConfig?.loginWith?.oauth?.responseType;
|
|
48
47
|
|
|
49
|
-
return
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
'Make sure to call Amplify.configure with oauth parameter in your app',
|
|
54
|
-
});
|
|
48
|
+
return assert(
|
|
49
|
+
validOAuthConfig,
|
|
50
|
+
AuthConfigurationErrorCode.OAuthNotConfigureException
|
|
51
|
+
);
|
|
55
52
|
}
|
|
56
53
|
|
|
57
|
-
export function
|
|
54
|
+
export function assertIdentityPoolIdConfig(
|
|
58
55
|
cognitoConfig?: StrictUnion<
|
|
59
56
|
| CognitoUserPoolConfig
|
|
60
57
|
| CognitoUserPoolAndIdentityPoolConfig
|
|
@@ -62,25 +59,21 @@ export function assertIdentityPooIdConfig(
|
|
|
62
59
|
>
|
|
63
60
|
): asserts cognitoConfig is CognitoIdentityPoolConfig {
|
|
64
61
|
const validConfig = !!cognitoConfig?.identityPoolId;
|
|
65
|
-
return
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
'Make sure a valid identityPoolId is given in the config.',
|
|
70
|
-
});
|
|
62
|
+
return assert(
|
|
63
|
+
validConfig,
|
|
64
|
+
AuthConfigurationErrorCode.InvalidIdentityPoolIdException
|
|
65
|
+
);
|
|
71
66
|
}
|
|
72
67
|
|
|
73
|
-
function
|
|
68
|
+
function assertUserPoolAndIdentityPoolConfig(
|
|
74
69
|
authConfig: AuthConfig
|
|
75
70
|
): asserts authConfig is AuthUserPoolAndIdentityPoolConfig {
|
|
76
71
|
const validConfig =
|
|
77
72
|
!!authConfig?.Cognito.identityPoolId && !!authConfig?.Cognito.userPoolId;
|
|
78
|
-
return
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
'Make sure to call Amplify.configure in your app with UserPoolId and IdentityPoolId',
|
|
83
|
-
});
|
|
73
|
+
return assert(
|
|
74
|
+
validConfig,
|
|
75
|
+
AuthConfigurationErrorCode.AuthUserPoolAndIdentityPoolException
|
|
76
|
+
);
|
|
84
77
|
}
|
|
85
78
|
|
|
86
79
|
export function decodeJWT(token: string): JWT {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
export interface GeoConfig {
|
|
5
|
+
LocationService?: {
|
|
6
|
+
region: string;
|
|
7
|
+
maps?: {
|
|
8
|
+
items: {};
|
|
9
|
+
default: string;
|
|
10
|
+
};
|
|
11
|
+
searchIndices?: {
|
|
12
|
+
items: string[];
|
|
13
|
+
default: string;
|
|
14
|
+
};
|
|
15
|
+
geofenceCollections?: {
|
|
16
|
+
items: string[];
|
|
17
|
+
default: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
}
|
package/src/singleton/types.ts
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
GetCredentialsOptions,
|
|
13
13
|
CognitoIdentityPoolConfig,
|
|
14
14
|
} from './Auth/types';
|
|
15
|
+
import { GeoConfig } from './Geo/types';
|
|
15
16
|
import {
|
|
16
17
|
LibraryStorageOptions,
|
|
17
18
|
StorageAccessLevel,
|
|
@@ -36,6 +37,7 @@ export type ResourcesConfig = {
|
|
|
36
37
|
// Notifications?: {};
|
|
37
38
|
// Predictions?: {};
|
|
38
39
|
Storage?: StorageConfig;
|
|
40
|
+
Geo?: GeoConfig;
|
|
39
41
|
};
|
|
40
42
|
|
|
41
43
|
export type LibraryOptions = {
|
|
@@ -56,4 +58,5 @@ export {
|
|
|
56
58
|
StorageConfig,
|
|
57
59
|
AnalyticsConfig,
|
|
58
60
|
CognitoIdentityPoolConfig,
|
|
61
|
+
GeoConfig,
|
|
59
62
|
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import type { AsyncStorageStatic } from '@react-native-async-storage/async-storage';
|
|
5
|
-
import { AmplifyError } from '../
|
|
5
|
+
import { AmplifyError } from '../errors';
|
|
6
6
|
import { KeyValueStorageInterface } from '../types';
|
|
7
7
|
|
|
8
8
|
const ASYNC_STORAGE_MODULE = '@react-native-async-storage/async-storage';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { PlatformNotSupportedError } from '../
|
|
4
|
+
import { PlatformNotSupportedError } from '../errors';
|
|
5
5
|
import { KeyValueStorageInterface } from '../types';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -21,7 +21,7 @@ export class KeyValueStorage implements KeyValueStorageInterface {
|
|
|
21
21
|
* @returns {string} value that was set
|
|
22
22
|
*/
|
|
23
23
|
async setItem(key: string, value: string) {
|
|
24
|
-
if (!this.storage) throw PlatformNotSupportedError;
|
|
24
|
+
if (!this.storage) throw new PlatformNotSupportedError();
|
|
25
25
|
this.storage.setItem(key, value);
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -32,7 +32,7 @@ export class KeyValueStorage implements KeyValueStorageInterface {
|
|
|
32
32
|
* @returns {string} the data item
|
|
33
33
|
*/
|
|
34
34
|
async getItem(key: string) {
|
|
35
|
-
if (!this.storage) throw PlatformNotSupportedError;
|
|
35
|
+
if (!this.storage) throw new PlatformNotSupportedError();
|
|
36
36
|
return this.storage.getItem(key);
|
|
37
37
|
}
|
|
38
38
|
|
|
@@ -42,7 +42,7 @@ export class KeyValueStorage implements KeyValueStorageInterface {
|
|
|
42
42
|
* @returns {string} value - value that was deleted
|
|
43
43
|
*/
|
|
44
44
|
async removeItem(key: string) {
|
|
45
|
-
if (!this.storage) throw PlatformNotSupportedError;
|
|
45
|
+
if (!this.storage) throw new PlatformNotSupportedError();
|
|
46
46
|
this.storage.removeItem(key);
|
|
47
47
|
}
|
|
48
48
|
|
|
@@ -51,7 +51,7 @@ export class KeyValueStorage implements KeyValueStorageInterface {
|
|
|
51
51
|
* @returns {string} nothing
|
|
52
52
|
*/
|
|
53
53
|
async clear() {
|
|
54
|
-
if (!this.storage) throw PlatformNotSupportedError;
|
|
54
|
+
if (!this.storage) throw new PlatformNotSupportedError();
|
|
55
55
|
this.storage.clear();
|
|
56
56
|
}
|
|
57
57
|
}
|
package/src/types/errors.ts
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
export
|
|
4
|
+
export enum AmplifyErrorCode {
|
|
5
|
+
PlatformNotSupported = 'PlatformNotSupported',
|
|
6
|
+
Unknown = 'Unknown',
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type AmplifyErrorParams<ErrorCode extends string = string> = {
|
|
5
10
|
message: string;
|
|
6
|
-
name:
|
|
11
|
+
name: ErrorCode;
|
|
7
12
|
recoverySuggestion?: string;
|
|
8
13
|
underlyingError?: Error | unknown;
|
|
9
14
|
};
|
|
10
15
|
|
|
11
|
-
export type AmplifyErrorMap<ErrorCode extends string> = {
|
|
16
|
+
export type AmplifyErrorMap<ErrorCode extends string = string> = {
|
|
12
17
|
[name in ErrorCode]: {
|
|
13
18
|
message: string;
|
|
14
19
|
recoverySuggestion?: string;
|
|
@@ -19,3 +24,9 @@ export type ServiceError = {
|
|
|
19
24
|
name: string;
|
|
20
25
|
message: string;
|
|
21
26
|
};
|
|
27
|
+
|
|
28
|
+
export type AssertionFunction<ErrorCode extends string = string> = (
|
|
29
|
+
assertion: boolean,
|
|
30
|
+
name: ErrorCode,
|
|
31
|
+
additionalContext?: string
|
|
32
|
+
) => asserts assertion;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.asserts = void 0;
|
|
4
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
5
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
6
|
-
var Errors_1 = require("../Errors");
|
|
7
|
-
function asserts(assertion, errorParams) {
|
|
8
|
-
if (!assertion)
|
|
9
|
-
throw new Errors_1.AmplifyError(errorParams);
|
|
10
|
-
}
|
|
11
|
-
exports.asserts = asserts;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import { AmplifyError } from '../Errors';
|
|
4
|
-
import { ErrorParams } from '../../types';
|
|
5
|
-
|
|
6
|
-
export function asserts(
|
|
7
|
-
assertion: boolean,
|
|
8
|
-
errorParams: ErrorParams
|
|
9
|
-
): asserts assertion {
|
|
10
|
-
if (!assertion) throw new AmplifyError(errorParams);
|
|
11
|
-
}
|