@aws-amplify/core 6.0.1-console-preview.4b7d177.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 +1 -1
- package/lib/I18n/index.d.ts +1 -1
- 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/tsconfig.tsbuildinfo +1 -1
- package/lib-esm/Hub/types/AuthTypes.d.ts +14 -0
- package/lib-esm/I18n/I18n.d.ts +1 -1
- package/lib-esm/I18n/index.d.ts +1 -1
- 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/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/Hub/types/AuthTypes.ts +10 -1
- package/src/I18n/I18n.ts +1 -1
- package/src/I18n/index.ts +1 -1
- package/src/Platform/version.ts +1 -1
- package/src/libraryUtils.ts +1 -1
- package/src/singleton/Auth/utils/index.ts +14 -11
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",
|
|
@@ -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
|
@@ -134,7 +134,7 @@ export class I18n {
|
|
|
134
134
|
* @param {Object} vocabularies - Object that has language as key,
|
|
135
135
|
* vocabularies of each language as value
|
|
136
136
|
*/
|
|
137
|
-
putVocabularies(vocabularies: Record<string,
|
|
137
|
+
putVocabularies(vocabularies: Record<string, Record<string, string>>) {
|
|
138
138
|
Object.keys(vocabularies).map(key => {
|
|
139
139
|
this.putVocabulariesForLanguage(key, vocabularies[key]);
|
|
140
140
|
});
|
package/src/I18n/index.ts
CHANGED
|
@@ -103,7 +103,7 @@ export class I18n {
|
|
|
103
103
|
* @param {Object} vocabularies - Object that has language as key,
|
|
104
104
|
* vocabularies of each language as value
|
|
105
105
|
*/
|
|
106
|
-
static putVocabularies(vocabularies: Record<string, string
|
|
106
|
+
static putVocabularies(vocabularies: Record<string, Record<string, string>>) {
|
|
107
107
|
I18n.checkConfig();
|
|
108
108
|
assert(!!_i18n, I18nErrorCode.NotConfigured);
|
|
109
109
|
|
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
|
-
}
|