@hemia/auth-sdk 0.0.17 → 0.0.19

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.
@@ -325,21 +325,24 @@ let AuthService = class AuthService {
325
325
  */
326
326
  async decodeIdToken(idToken) {
327
327
  try {
328
- const decode = this.jwtManager.getClaims(idToken);
328
+ const decode = this.jwtManager.decode(idToken, true);
329
329
  if (!decode) {
330
330
  return null;
331
331
  }
332
332
  const data = {
333
- email: decode.email || '',
334
- name: decode.name || '',
335
- given_name: decode.given_name,
336
- family_name: decode.family_name,
337
- picture: decode.picture,
338
- ...decode
333
+ email: decode.payload.email || '',
334
+ name: decode.payload.name || '',
335
+ given_name: decode.payload.given_name,
336
+ family_name: decode.payload.family_name,
337
+ picture: decode.payload.picture,
338
+ context: {
339
+ ...(decode.payload['https://hemia.mx/context'] || {})
340
+ }
339
341
  };
340
342
  return data;
341
343
  }
342
344
  catch (error) {
345
+ console.log('[decodeIdToken] ID Token Decode Error:', error);
343
346
  throw new Error('Failed to decode ID token');
344
347
  }
345
348
  }
@@ -327,21 +327,24 @@ exports.AuthService = class AuthService {
327
327
  */
328
328
  async decodeIdToken(idToken) {
329
329
  try {
330
- const decode = this.jwtManager.getClaims(idToken);
330
+ const decode = this.jwtManager.decode(idToken, true);
331
331
  if (!decode) {
332
332
  return null;
333
333
  }
334
334
  const data = {
335
- email: decode.email || '',
336
- name: decode.name || '',
337
- given_name: decode.given_name,
338
- family_name: decode.family_name,
339
- picture: decode.picture,
340
- ...decode
335
+ email: decode.payload.email || '',
336
+ name: decode.payload.name || '',
337
+ given_name: decode.payload.given_name,
338
+ family_name: decode.payload.family_name,
339
+ picture: decode.payload.picture,
340
+ context: {
341
+ ...(decode.payload['https://hemia.mx/context'] || {})
342
+ }
341
343
  };
342
344
  return data;
343
345
  }
344
346
  catch (error) {
347
+ console.log('[decodeIdToken] ID Token Decode Error:', error);
345
348
  throw new Error('Failed to decode ID token');
346
349
  }
347
350
  }
@@ -1,5 +1,5 @@
1
1
  export interface ISessionUser {
2
- sub: string;
2
+ sub?: string;
3
3
  email: string;
4
4
  name: string;
5
5
  given_name?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hemia/auth-sdk",
3
- "version": "0.0.17",
3
+ "version": "0.0.19",
4
4
  "description": "Hemia SDK for authentication",
5
5
  "main": "dist/hemia-auth-sdk.js",
6
6
  "module": "dist/hemia-auth-sdk.esm.js",