@verdocs/js-sdk 4.2.76 → 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.d.mts CHANGED
@@ -1907,10 +1907,19 @@ declare const changePassword: (endpoint: VerdocsEndpoint, params: IChangePasswor
1907
1907
  * if (status !== 'OK') {
1908
1908
  * window.alert(`Please check your email for instructions on how to reset your password.`);
1909
1909
  * }
1910
+ *
1911
+ * // Collect code and new password from the user, then call:
1912
+ *
1913
+ * const {success} = await resetPassword({ email, code, new_password });
1914
+ * if (status !== 'OK') {
1915
+ * window.alert(`Please check your verification code and try again.`);
1916
+ * }
1910
1917
  * ```
1911
1918
  */
1912
1919
  declare const resetPassword: (endpoint: VerdocsEndpoint, params: {
1913
1920
  email: string;
1921
+ code?: string;
1922
+ new_password?: string;
1914
1923
  }) => Promise<{
1915
1924
  success: boolean;
1916
1925
  }>;
package/dist/index.d.ts CHANGED
@@ -1907,10 +1907,19 @@ declare const changePassword: (endpoint: VerdocsEndpoint, params: IChangePasswor
1907
1907
  * if (status !== 'OK') {
1908
1908
  * window.alert(`Please check your email for instructions on how to reset your password.`);
1909
1909
  * }
1910
+ *
1911
+ * // Collect code and new password from the user, then call:
1912
+ *
1913
+ * const {success} = await resetPassword({ email, code, new_password });
1914
+ * if (status !== 'OK') {
1915
+ * window.alert(`Please check your verification code and try again.`);
1916
+ * }
1910
1917
  * ```
1911
1918
  */
1912
1919
  declare const resetPassword: (endpoint: VerdocsEndpoint, params: {
1913
1920
  email: string;
1921
+ code?: string;
1922
+ new_password?: string;
1914
1923
  }) => Promise<{
1915
1924
  success: boolean;
1916
1925
  }>;
package/dist/index.js CHANGED
@@ -866,6 +866,13 @@ const changePassword = (endpoint, params) => endpoint.api //
866
866
  * if (status !== 'OK') {
867
867
  * window.alert(`Please check your email for instructions on how to reset your password.`);
868
868
  * }
869
+ *
870
+ * // Collect code and new password from the user, then call:
871
+ *
872
+ * const {success} = await resetPassword({ email, code, new_password });
873
+ * if (status !== 'OK') {
874
+ * window.alert(`Please check your verification code and try again.`);
875
+ * }
869
876
  * ```
870
877
  */
871
878
  const resetPassword = (endpoint, params) => endpoint.api //
@@ -1267,8 +1274,10 @@ class VerdocsEndpoint {
1267
1274
  */
1268
1275
  setToken(token) {
1269
1276
  if (!token) {
1277
+ window.console.log('[JS_SDK] Clearing token');
1270
1278
  return this.clearSession();
1271
1279
  }
1280
+ window.console.log('[JS_SDK] Setting token', token.length);
1272
1281
  const session = decodeAccessTokenBody(token);
1273
1282
  if (session === null || (session.exp && session.exp * 1000 < new Date().getTime())) {
1274
1283
  window.console.warn('[JS_SDK] Ignoring attempt to use expired session token');
@@ -1303,7 +1312,7 @@ class VerdocsEndpoint {
1303
1312
  this.profile = null;
1304
1313
  this.sub = null;
1305
1314
  window?.console?.warn('Unable to load profile', e);
1306
- this.notifySessionListeners();
1315
+ this.clearSession();
1307
1316
  });
1308
1317
  return this;
1309
1318
  }
@@ -1368,9 +1377,10 @@ class VerdocsEndpoint {
1368
1377
  this.nextListenerId++;
1369
1378
  const listenerSymbol = Symbol.for('' + this.nextListenerId);
1370
1379
  this.sessionListeners.set(listenerSymbol, listener);
1371
- // Perform an immediate notification in case this listener subscribed after the endpoint's session was
1372
- // already loaded.
1373
- 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
+ }
1374
1384
  return () => {
1375
1385
  this.sessionListeners.delete(listenerSymbol);
1376
1386
  };
@@ -1385,6 +1395,7 @@ class VerdocsEndpoint {
1385
1395
  }
1386
1396
  const token = localStorage.getItem(this.sessionStorageKey());
1387
1397
  if (!token) {
1398
+ window?.console?.debug('[JS_SDK] No cached session found', this.endpointId);
1388
1399
  return this.clearSession();
1389
1400
  }
1390
1401
  // We sometimes get multiple loadSession calls from stacked components all needing to just ensure