@verdocs/js-sdk 4.2.79 → 4.2.80

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/dist/index.js CHANGED
@@ -1274,8 +1274,10 @@ class VerdocsEndpoint {
1274
1274
  */
1275
1275
  setToken(token) {
1276
1276
  if (!token) {
1277
+ window.console.log('[JS_SDK] Clearing token');
1277
1278
  return this.clearSession();
1278
1279
  }
1280
+ window.console.log('[JS_SDK] Setting token', token.length);
1279
1281
  const session = decodeAccessTokenBody(token);
1280
1282
  if (session === null || (session.exp && session.exp * 1000 < new Date().getTime())) {
1281
1283
  window.console.warn('[JS_SDK] Ignoring attempt to use expired session token');
@@ -1310,7 +1312,7 @@ class VerdocsEndpoint {
1310
1312
  this.profile = null;
1311
1313
  this.sub = null;
1312
1314
  window?.console?.warn('Unable to load profile', e);
1313
- this.notifySessionListeners();
1315
+ this.clearSession();
1314
1316
  });
1315
1317
  return this;
1316
1318
  }
@@ -1375,9 +1377,10 @@ class VerdocsEndpoint {
1375
1377
  this.nextListenerId++;
1376
1378
  const listenerSymbol = Symbol.for('' + this.nextListenerId);
1377
1379
  this.sessionListeners.set(listenerSymbol, listener);
1378
- // Perform an immediate notification in case this listener subscribed after the endpoint's session was
1379
- // already loaded.
1380
- listener(this, this.session, this.profile);
1380
+ // Perform an immediate notification if this listener subscribed after the session was already loaded.
1381
+ if (this.profile) {
1382
+ listener(this, this.session, this.profile);
1383
+ }
1381
1384
  return () => {
1382
1385
  this.sessionListeners.delete(listenerSymbol);
1383
1386
  };
@@ -1392,6 +1395,7 @@ class VerdocsEndpoint {
1392
1395
  }
1393
1396
  const token = localStorage.getItem(this.sessionStorageKey());
1394
1397
  if (!token) {
1398
+ window?.console?.debug('[JS_SDK] No cached session found', this.endpointId);
1395
1399
  return this.clearSession();
1396
1400
  }
1397
1401
  // We sometimes get multiple loadSession calls from stacked components all needing to just ensure