@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.
@@ -1,3 +1,7 @@
1
+ type AuthUser = {
2
+ username: string;
3
+ userId: string;
4
+ };
1
5
  export type AuthHubEventData =
2
6
  /** Dispatched when a user signs in with an oauth provider such as Google.*/
3
7
  {
@@ -19,4 +23,14 @@ export type AuthHubEventData =
19
23
  | {
20
24
  event: 'customOAuthState';
21
25
  data: string;
26
+ }
27
+ /** Dispatched when the user is signed-in.*/
28
+ | {
29
+ event: 'signedIn';
30
+ data: AuthUser;
31
+ }
32
+ /** Dispatched after the user calls the `signOut` API successfully.*/
33
+ | {
34
+ event: 'signedOut';
22
35
  };
36
+ export {};
@@ -59,5 +59,5 @@ export declare class I18n {
59
59
  * @param {Object} vocabularies - Object that has language as key,
60
60
  * vocabularies of each language as value
61
61
  */
62
- putVocabularies(vocabularies: Record<string, any>): void;
62
+ putVocabularies(vocabularies: Record<string, Record<string, string>>): void;
63
63
  }
@@ -45,6 +45,6 @@ export declare class I18n {
45
45
  * @param {Object} vocabularies - Object that has language as key,
46
46
  * vocabularies of each language as value
47
47
  */
48
- static putVocabularies(vocabularies: Record<string, string>): void;
48
+ static putVocabularies(vocabularies: Record<string, Record<string, string>>): void;
49
49
  static checkConfig(): boolean;
50
50
  }
@@ -1 +1 @@
1
- export declare const version = "6.0.1-console-preview.4b7d177.0+4b7d177";
1
+ export declare const version = "6.0.1-console-preview.deaebd5.0+deaebd5";
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = void 0;
4
4
  // generated by genversion
5
- exports.version = '6.0.1-console-preview.4b7d177.0+4b7d177';
5
+ exports.version = '6.0.1-console-preview.deaebd5.0+deaebd5';
@@ -4,7 +4,7 @@ export { LegacyConfig } from './singleton/types';
4
4
  export { JWT, StrictUnion, CognitoIdentityPoolConfig, JwtPayload, } from './singleton/Auth/types';
5
5
  export { decodeJWT, assertTokenProviderConfig, assertIdentityPoolIdConfig, assertOAuthConfig, } from './singleton/Auth/utils';
6
6
  export { isTokenExpired } from './singleton/Auth';
7
- export { GraphQLAuthModeKeys } from './singleton/API/types';
7
+ export { GraphQLAuthMode, GraphQLAuthModeKeys } from './singleton/API/types';
8
8
  export { Signer } from './Signer';
9
9
  export { ConsoleLogger, ConsoleLogger as Logger } from './Logger';
10
10
  export { ClientDevice } from './ClientDevice';
@@ -36,15 +36,19 @@ function assertUserPoolAndIdentityPoolConfig(authConfig) {
36
36
  return (0, errorHelpers_1.assert)(validConfig, errorHelpers_1.AuthConfigurationErrorCode.AuthUserPoolAndIdentityPoolException);
37
37
  }
38
38
  function decodeJWT(token) {
39
- var tokenSplitted = token.split('.');
40
- if (tokenSplitted.length !== 3) {
39
+ var tokenParts = token.split('.');
40
+ if (tokenParts.length !== 3) {
41
41
  throw new Error('Invalid token');
42
42
  }
43
43
  try {
44
- var payloadStringb64 = tokenSplitted[1];
45
- var payloadArrayBuffer = base64ToBytes(payloadStringb64);
46
- var decodeString = new TextDecoder().decode(payloadArrayBuffer);
47
- var payload = JSON.parse(decodeString);
44
+ var base64WithUrlSafe = tokenParts[1];
45
+ var base64_1 = base64WithUrlSafe.replace(/-/g, '+').replace(/_/g, '/');
46
+ var jsonStr = decodeURIComponent(convert_1.base64Decoder
47
+ .convert(base64_1)
48
+ .split('')
49
+ .map(function (char) { return "%".concat("00".concat(char.charCodeAt(0).toString(16)).slice(-2)); })
50
+ .join(''));
51
+ var payload = JSON.parse(jsonStr);
48
52
  return {
49
53
  toString: function () { return token; },
50
54
  payload: payload,
@@ -55,7 +59,3 @@ function decodeJWT(token) {
55
59
  }
56
60
  }
57
61
  exports.decodeJWT = decodeJWT;
58
- function base64ToBytes(base64) {
59
- var binString = convert_1.base64Decoder.convert(base64);
60
- return Uint8Array.from(binString, function (m) { return m.codePointAt(0) || 0; });
61
- }