@hemia/auth-sdk 0.0.18 → 0.0.20

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.
@@ -192,8 +192,8 @@ let AuthService = class AuthService {
192
192
  createdAt: new Date().toISOString(),
193
193
  sessionId: session_id
194
194
  };
195
- const expiresSession = Date.now() + (session_expires_in ? session_expires_in * 1000 : 0);
196
- await this.storage.set(`x-session:${sessionId}`, sessionData, expiresSession);
195
+ const ttlSeconds = session_expires_in || 604800;
196
+ await this.storage.set(`x-session:${sessionId}`, sessionData, ttlSeconds);
197
197
  return {
198
198
  sessionId,
199
199
  expiresIn: expires_in,
@@ -325,7 +325,7 @@ let AuthService = class AuthService {
325
325
  */
326
326
  async decodeIdToken(idToken) {
327
327
  try {
328
- const decode = this.jwtManager.decode(idToken);
328
+ const decode = this.jwtManager.decode(idToken, true);
329
329
  if (!decode) {
330
330
  return null;
331
331
  }
@@ -336,12 +336,13 @@ let AuthService = class AuthService {
336
336
  family_name: decode.payload.family_name,
337
337
  picture: decode.payload.picture,
338
338
  context: {
339
- ...decode.payload['https://hemia.mx/context']
339
+ ...(decode.payload['https://hemia.mx/context'] || {})
340
340
  }
341
341
  };
342
342
  return data;
343
343
  }
344
344
  catch (error) {
345
+ console.log('[decodeIdToken] ID Token Decode Error:', error);
345
346
  throw new Error('Failed to decode ID token');
346
347
  }
347
348
  }
@@ -375,8 +376,8 @@ let AuthService = class AuthService {
375
376
  sessionId: session_id || '',
376
377
  createdAt: Date.now().toString()
377
378
  };
378
- const expiresSession = Date.now() + (session_expires_in ? session_expires_in * 1000 : 0);
379
- await this.storage.set(`x-session:${sessionId}`, updatedSession, expiresSession);
379
+ const ttlSeconds = session_expires_in || 604800;
380
+ await this.storage.set(`x-session:${sessionId}`, updatedSession, ttlSeconds);
380
381
  return updatedSession;
381
382
  }
382
383
  };
@@ -194,8 +194,8 @@ exports.AuthService = class AuthService {
194
194
  createdAt: new Date().toISOString(),
195
195
  sessionId: session_id
196
196
  };
197
- const expiresSession = Date.now() + (session_expires_in ? session_expires_in * 1000 : 0);
198
- await this.storage.set(`x-session:${sessionId}`, sessionData, expiresSession);
197
+ const ttlSeconds = session_expires_in || 604800;
198
+ await this.storage.set(`x-session:${sessionId}`, sessionData, ttlSeconds);
199
199
  return {
200
200
  sessionId,
201
201
  expiresIn: expires_in,
@@ -327,7 +327,7 @@ exports.AuthService = class AuthService {
327
327
  */
328
328
  async decodeIdToken(idToken) {
329
329
  try {
330
- const decode = this.jwtManager.decode(idToken);
330
+ const decode = this.jwtManager.decode(idToken, true);
331
331
  if (!decode) {
332
332
  return null;
333
333
  }
@@ -338,12 +338,13 @@ exports.AuthService = class AuthService {
338
338
  family_name: decode.payload.family_name,
339
339
  picture: decode.payload.picture,
340
340
  context: {
341
- ...decode.payload['https://hemia.mx/context']
341
+ ...(decode.payload['https://hemia.mx/context'] || {})
342
342
  }
343
343
  };
344
344
  return data;
345
345
  }
346
346
  catch (error) {
347
+ console.log('[decodeIdToken] ID Token Decode Error:', error);
347
348
  throw new Error('Failed to decode ID token');
348
349
  }
349
350
  }
@@ -377,8 +378,8 @@ exports.AuthService = class AuthService {
377
378
  sessionId: session_id || '',
378
379
  createdAt: Date.now().toString()
379
380
  };
380
- const expiresSession = Date.now() + (session_expires_in ? session_expires_in * 1000 : 0);
381
- await this.storage.set(`x-session:${sessionId}`, updatedSession, expiresSession);
381
+ const ttlSeconds = session_expires_in || 604800;
382
+ await this.storage.set(`x-session:${sessionId}`, updatedSession, ttlSeconds);
382
383
  return updatedSession;
383
384
  }
384
385
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hemia/auth-sdk",
3
- "version": "0.0.18",
3
+ "version": "0.0.20",
4
4
  "description": "Hemia SDK for authentication",
5
5
  "main": "dist/hemia-auth-sdk.js",
6
6
  "module": "dist/hemia-auth-sdk.esm.js",