@aws-amplify/core 6.0.1-console-preview.0bbe168.0 → 6.0.1-console-preview.deaebd5.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/Hub/types/AuthTypes.d.ts +14 -0
- package/lib/I18n/I18n.d.ts +3 -19
- package/lib/I18n/I18n.js +5 -20
- package/lib/I18n/index.d.ts +3 -15
- package/lib/I18n/index.js +0 -12
- package/lib/I18n/types.d.ts +1 -4
- package/lib/I18n/types.js +5 -8
- package/lib/Platform/version.d.ts +1 -1
- package/lib/Platform/version.js +1 -1
- package/lib/libraryUtils.d.ts +1 -1
- package/lib/singleton/Auth/utils/index.js +10 -10
- package/lib/singleton/types.d.ts +2 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib-esm/Hub/types/AuthTypes.d.ts +14 -0
- package/lib-esm/I18n/I18n.d.ts +3 -19
- package/lib-esm/I18n/I18n.js +5 -20
- package/lib-esm/I18n/index.d.ts +3 -15
- package/lib-esm/I18n/index.js +0 -12
- package/lib-esm/I18n/types.d.ts +1 -4
- package/lib-esm/I18n/types.js +4 -7
- package/lib-esm/Platform/version.d.ts +1 -1
- package/lib-esm/Platform/version.js +1 -1
- package/lib-esm/libraryUtils.d.ts +1 -1
- package/lib-esm/singleton/Auth/utils/index.js +10 -10
- package/lib-esm/singleton/types.d.ts +2 -0
- package/lib-esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/Hub/types/AuthTypes.ts +10 -1
- package/src/I18n/I18n.ts +5 -21
- package/src/I18n/index.ts +3 -15
- package/src/I18n/types.ts +1 -4
- package/src/Platform/version.ts +1 -1
- package/src/libraryUtils.ts +1 -1
- package/src/singleton/Auth/utils/index.ts +14 -11
- package/src/singleton/types.ts +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-amplify/core",
|
|
3
|
-
"version": "6.0.1-console-preview.
|
|
3
|
+
"version": "6.0.1-console-preview.deaebd5.0+deaebd5",
|
|
4
4
|
"description": "Core category of aws-amplify",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"module": "./lib-esm/index.js",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"name": "Core (I18n)",
|
|
93
93
|
"path": "./lib-esm/index.js",
|
|
94
94
|
"import": "{ I18n }",
|
|
95
|
-
"limit": "
|
|
95
|
+
"limit": "4.82 kB"
|
|
96
96
|
},
|
|
97
97
|
{
|
|
98
98
|
"name": "Custom clients (fetch handler)",
|
|
@@ -185,5 +185,5 @@
|
|
|
185
185
|
"lib-esm"
|
|
186
186
|
]
|
|
187
187
|
},
|
|
188
|
-
"gitHead": "
|
|
188
|
+
"gitHead": "deaebd5a938733ff2b25aaec39c042843ef2289c"
|
|
189
189
|
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
type AuthUser = {
|
|
5
|
+
username: string;
|
|
6
|
+
userId: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
4
9
|
export type AuthHubEventData =
|
|
5
10
|
/** Dispatched when a user signs in with an oauth provider such as Google.*/
|
|
6
11
|
| { event: 'signInWithRedirect' }
|
|
@@ -11,4 +16,8 @@ export type AuthHubEventData =
|
|
|
11
16
|
/** Dispatched when there is an error in the refresh of tokens.*/
|
|
12
17
|
| { event: 'tokenRefresh_failure' }
|
|
13
18
|
/** Dispatched when there is a customState passed in the options of the `signInWithRedirect` API.*/
|
|
14
|
-
| { event: 'customOAuthState'; data: string }
|
|
19
|
+
| { event: 'customOAuthState'; data: string }
|
|
20
|
+
/** Dispatched when the user is signed-in.*/
|
|
21
|
+
| { event: 'signedIn'; data: AuthUser }
|
|
22
|
+
/** Dispatched after the user calls the `signOut` API successfully.*/
|
|
23
|
+
| { event: 'signedOut' };
|
package/src/I18n/I18n.ts
CHANGED
|
@@ -3,20 +3,18 @@
|
|
|
3
3
|
|
|
4
4
|
import { ConsoleLogger as Logger } from '../Logger';
|
|
5
5
|
import { Amplify } from '../singleton';
|
|
6
|
-
import {
|
|
6
|
+
import { I18nConfig } from './types';
|
|
7
7
|
|
|
8
8
|
const logger = new Logger('I18n');
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Language translation utility.
|
|
12
|
-
*
|
|
13
|
-
* @deprecated The I18n utility is on a deprecation path and will be removed in a future version of Amplify.
|
|
14
12
|
*/
|
|
15
13
|
export class I18n {
|
|
16
14
|
/**
|
|
17
15
|
* @private
|
|
18
16
|
*/
|
|
19
|
-
_options:
|
|
17
|
+
_options: I18nConfig | null = null;
|
|
20
18
|
|
|
21
19
|
/**
|
|
22
20
|
* @private
|
|
@@ -32,21 +30,17 @@ export class I18n {
|
|
|
32
30
|
* @constructor
|
|
33
31
|
* Initialize with configurations
|
|
34
32
|
* @param {Object} options
|
|
35
|
-
*
|
|
36
|
-
* @deprecated The I18n utility is on a deprecation path and will be removed in a future version of Amplify.
|
|
37
33
|
*/
|
|
38
34
|
constructor() {}
|
|
39
35
|
|
|
40
36
|
/**
|
|
41
37
|
* Sets the default language from the configuration when required.
|
|
42
|
-
*
|
|
43
|
-
* @deprecated The I18n utility is on a deprecation path and will be removed in a future version of Amplify.
|
|
44
38
|
*/
|
|
45
39
|
setDefaultLanguage() {
|
|
46
|
-
|
|
40
|
+
if (!this._lang) {
|
|
47
41
|
const i18nConfig = Amplify.getConfig().I18n;
|
|
48
42
|
this._lang = i18nConfig?.language;
|
|
49
|
-
}
|
|
43
|
+
}
|
|
50
44
|
|
|
51
45
|
// Default to window language if not set in config
|
|
52
46
|
if (
|
|
@@ -65,8 +59,6 @@ export class I18n {
|
|
|
65
59
|
* @method
|
|
66
60
|
* Explicitly setting language
|
|
67
61
|
* @param {String} lang
|
|
68
|
-
*
|
|
69
|
-
* @deprecated The I18n utility is on a deprecation path and will be removed in a future version of Amplify.
|
|
70
62
|
*/
|
|
71
63
|
setLanguage(lang: string) {
|
|
72
64
|
this._lang = lang;
|
|
@@ -77,8 +69,6 @@ export class I18n {
|
|
|
77
69
|
* Get value
|
|
78
70
|
* @param {String} key
|
|
79
71
|
* @param {String} defVal - Default value
|
|
80
|
-
*
|
|
81
|
-
* @deprecated The I18n utility is on a deprecation path and will be removed in a future version of Amplify.
|
|
82
72
|
*/
|
|
83
73
|
get(key: string, defVal: string | undefined = undefined) {
|
|
84
74
|
if (!this._lang) {
|
|
@@ -107,8 +97,6 @@ export class I18n {
|
|
|
107
97
|
* @param {String} key
|
|
108
98
|
* @param {String} language - Specified langurage to be used
|
|
109
99
|
* @param {String} defVal - Default value
|
|
110
|
-
*
|
|
111
|
-
* @deprecated The I18n utility is on a deprecation path and will be removed in a future version of Amplify.
|
|
112
100
|
*/
|
|
113
101
|
getByLanguage(key: string, language: string, defVal: string | null = null) {
|
|
114
102
|
if (!language) {
|
|
@@ -128,8 +116,6 @@ export class I18n {
|
|
|
128
116
|
* Add vocabularies for one language
|
|
129
117
|
* @param {String} language - Language of the dictionary
|
|
130
118
|
* @param {Object} vocabularies - Object that has key-value as dictionary entry
|
|
131
|
-
*
|
|
132
|
-
* @deprecated The I18n utility is on a deprecation path and will be removed in a future version of Amplify.
|
|
133
119
|
*/
|
|
134
120
|
putVocabulariesForLanguage(
|
|
135
121
|
language: string,
|
|
@@ -147,10 +133,8 @@ export class I18n {
|
|
|
147
133
|
* Add vocabularies for one language
|
|
148
134
|
* @param {Object} vocabularies - Object that has language as key,
|
|
149
135
|
* vocabularies of each language as value
|
|
150
|
-
*
|
|
151
|
-
* @deprecated The I18n utility is on a deprecation path and will be removed in a future version of Amplify.
|
|
152
136
|
*/
|
|
153
|
-
putVocabularies(vocabularies: Record<string,
|
|
137
|
+
putVocabularies(vocabularies: Record<string, Record<string, string>>) {
|
|
154
138
|
Object.keys(vocabularies).map(key => {
|
|
155
139
|
this.putVocabulariesForLanguage(key, vocabularies[key]);
|
|
156
140
|
});
|
package/src/I18n/index.ts
CHANGED
|
@@ -4,18 +4,16 @@
|
|
|
4
4
|
import { I18n as I18nClass } from './I18n';
|
|
5
5
|
|
|
6
6
|
import { ConsoleLogger as Logger } from '../Logger';
|
|
7
|
-
import {
|
|
7
|
+
import { I18nConfig } from './types';
|
|
8
8
|
import { assert, I18nErrorCode } from './errorHelpers';
|
|
9
9
|
|
|
10
10
|
const logger = new Logger('I18n');
|
|
11
11
|
|
|
12
|
-
let _config:
|
|
12
|
+
let _config: I18nConfig = { language: null };
|
|
13
13
|
let _i18n: I18nClass | null = null;
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Export I18n APIs
|
|
17
|
-
*
|
|
18
|
-
* @deprecated The I18n utility is on a deprecation path and will be removed in a future version of Amplify.
|
|
19
17
|
*/
|
|
20
18
|
export class I18n {
|
|
21
19
|
/**
|
|
@@ -45,8 +43,6 @@ export class I18n {
|
|
|
45
43
|
* @static
|
|
46
44
|
* @method
|
|
47
45
|
* Create an instance of I18n for the library
|
|
48
|
-
*
|
|
49
|
-
* @deprecated The I18n utility is on a deprecation path and will be removed in a future version of Amplify.
|
|
50
46
|
*/
|
|
51
47
|
static createInstance() {
|
|
52
48
|
logger.debug('create I18n instance');
|
|
@@ -60,8 +56,6 @@ export class I18n {
|
|
|
60
56
|
* @static @method
|
|
61
57
|
* Explicitly setting language
|
|
62
58
|
* @param {String} lang
|
|
63
|
-
*
|
|
64
|
-
* @deprecated The I18n utility is on a deprecation path and will be removed in a future version of Amplify.
|
|
65
59
|
*/
|
|
66
60
|
static setLanguage(lang: string) {
|
|
67
61
|
I18n.checkConfig();
|
|
@@ -75,8 +69,6 @@ export class I18n {
|
|
|
75
69
|
* Get value
|
|
76
70
|
* @param {String} key
|
|
77
71
|
* @param {String} defVal - Default value
|
|
78
|
-
*
|
|
79
|
-
* @deprecated The I18n utility is on a deprecation path and will be removed in a future version of Amplify.
|
|
80
72
|
*/
|
|
81
73
|
static get(key: string, defVal?: string) {
|
|
82
74
|
if (!I18n.checkConfig()) {
|
|
@@ -93,8 +85,6 @@ export class I18n {
|
|
|
93
85
|
* Add vocabularies for one language
|
|
94
86
|
* @param {String} langurage - Language of the dictionary
|
|
95
87
|
* @param {Object} vocabularies - Object that has key-value as dictionary entry
|
|
96
|
-
*
|
|
97
|
-
* @deprecated The I18n utility is on a deprecation path and will be removed in a future version of Amplify.
|
|
98
88
|
*/
|
|
99
89
|
static putVocabulariesForLanguage(
|
|
100
90
|
language: string,
|
|
@@ -112,10 +102,8 @@ export class I18n {
|
|
|
112
102
|
* Add vocabularies for one language
|
|
113
103
|
* @param {Object} vocabularies - Object that has language as key,
|
|
114
104
|
* vocabularies of each language as value
|
|
115
|
-
*
|
|
116
|
-
* @deprecated The I18n utility is on a deprecation path and will be removed in a future version of Amplify.
|
|
117
105
|
*/
|
|
118
|
-
static putVocabularies(vocabularies: Record<string, string
|
|
106
|
+
static putVocabularies(vocabularies: Record<string, Record<string, string>>) {
|
|
119
107
|
I18n.checkConfig();
|
|
120
108
|
assert(!!_i18n, I18nErrorCode.NotConfigured);
|
|
121
109
|
|
package/src/I18n/types.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
* @deprecated The I18n utility is on a deprecation path and will be removed in a future version of Amplify.
|
|
6
|
-
*/
|
|
7
|
-
export class I18nOptions {
|
|
4
|
+
export class I18nConfig {
|
|
8
5
|
language = null;
|
|
9
6
|
}
|
package/src/Platform/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// generated by genversion
|
|
2
|
-
export const version = '6.0.1-console-preview.
|
|
2
|
+
export const version = '6.0.1-console-preview.deaebd5.0+deaebd5';
|
package/src/libraryUtils.ts
CHANGED
|
@@ -34,7 +34,7 @@ export {
|
|
|
34
34
|
assertOAuthConfig,
|
|
35
35
|
} from './singleton/Auth/utils';
|
|
36
36
|
export { isTokenExpired } from './singleton/Auth';
|
|
37
|
-
export { GraphQLAuthModeKeys } from './singleton/API/types';
|
|
37
|
+
export { GraphQLAuthMode, GraphQLAuthModeKeys } from './singleton/API/types';
|
|
38
38
|
export { Signer } from './Signer';
|
|
39
39
|
|
|
40
40
|
// Logging utilities
|
|
@@ -78,15 +78,23 @@ function assertUserPoolAndIdentityPoolConfig(
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
export function decodeJWT(token: string): JWT {
|
|
81
|
-
const
|
|
82
|
-
|
|
81
|
+
const tokenParts = token.split('.');
|
|
82
|
+
|
|
83
|
+
if (tokenParts.length !== 3) {
|
|
83
84
|
throw new Error('Invalid token');
|
|
84
85
|
}
|
|
86
|
+
|
|
85
87
|
try {
|
|
86
|
-
const
|
|
87
|
-
const
|
|
88
|
-
const
|
|
89
|
-
|
|
88
|
+
const base64WithUrlSafe = tokenParts[1];
|
|
89
|
+
const base64 = base64WithUrlSafe.replace(/-/g, '+').replace(/_/g, '/');
|
|
90
|
+
const jsonStr = decodeURIComponent(
|
|
91
|
+
base64Decoder
|
|
92
|
+
.convert(base64)
|
|
93
|
+
.split('')
|
|
94
|
+
.map(char => `%${`00${char.charCodeAt(0).toString(16)}`.slice(-2)}`)
|
|
95
|
+
.join('')
|
|
96
|
+
);
|
|
97
|
+
const payload = JSON.parse(jsonStr);
|
|
90
98
|
|
|
91
99
|
return {
|
|
92
100
|
toString: () => token,
|
|
@@ -96,8 +104,3 @@ export function decodeJWT(token: string): JWT {
|
|
|
96
104
|
throw new Error('Invalid token payload');
|
|
97
105
|
}
|
|
98
106
|
}
|
|
99
|
-
|
|
100
|
-
function base64ToBytes(base64: string): Uint8Array {
|
|
101
|
-
const binString = base64Decoder.convert(base64);
|
|
102
|
-
return Uint8Array.from(binString, m => m.codePointAt(0) || 0);
|
|
103
|
-
}
|
package/src/singleton/types.ts
CHANGED
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
StorageAccessLevel,
|
|
19
19
|
StorageConfig,
|
|
20
20
|
} from './Storage/types';
|
|
21
|
+
import { I18nConfig } from '../I18n/types';
|
|
21
22
|
|
|
22
23
|
export type LegacyConfig = {
|
|
23
24
|
/**
|
|
@@ -32,7 +33,7 @@ export type ResourcesConfig = {
|
|
|
32
33
|
Auth?: AuthConfig;
|
|
33
34
|
// Cache?: CacheConfig;
|
|
34
35
|
// DataStore?: {};
|
|
35
|
-
|
|
36
|
+
I18n?: I18nConfig;
|
|
36
37
|
// Interactions?: {};
|
|
37
38
|
// Notifications?: {};
|
|
38
39
|
// Predictions?: {};
|