@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 +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +15 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -4
- package/dist/index.mjs.map +1 -1
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -864,6 +864,13 @@ const changePassword = (endpoint, params) => endpoint.api //
|
|
|
864
864
|
* if (status !== 'OK') {
|
|
865
865
|
* window.alert(`Please check your email for instructions on how to reset your password.`);
|
|
866
866
|
* }
|
|
867
|
+
*
|
|
868
|
+
* // Collect code and new password from the user, then call:
|
|
869
|
+
*
|
|
870
|
+
* const {success} = await resetPassword({ email, code, new_password });
|
|
871
|
+
* if (status !== 'OK') {
|
|
872
|
+
* window.alert(`Please check your verification code and try again.`);
|
|
873
|
+
* }
|
|
867
874
|
* ```
|
|
868
875
|
*/
|
|
869
876
|
const resetPassword = (endpoint, params) => endpoint.api //
|
|
@@ -1265,8 +1272,10 @@ class VerdocsEndpoint {
|
|
|
1265
1272
|
*/
|
|
1266
1273
|
setToken(token) {
|
|
1267
1274
|
if (!token) {
|
|
1275
|
+
window.console.log('[JS_SDK] Clearing token');
|
|
1268
1276
|
return this.clearSession();
|
|
1269
1277
|
}
|
|
1278
|
+
window.console.log('[JS_SDK] Setting token', token.length);
|
|
1270
1279
|
const session = decodeAccessTokenBody(token);
|
|
1271
1280
|
if (session === null || (session.exp && session.exp * 1000 < new Date().getTime())) {
|
|
1272
1281
|
window.console.warn('[JS_SDK] Ignoring attempt to use expired session token');
|
|
@@ -1301,7 +1310,7 @@ class VerdocsEndpoint {
|
|
|
1301
1310
|
this.profile = null;
|
|
1302
1311
|
this.sub = null;
|
|
1303
1312
|
window?.console?.warn('Unable to load profile', e);
|
|
1304
|
-
this.
|
|
1313
|
+
this.clearSession();
|
|
1305
1314
|
});
|
|
1306
1315
|
return this;
|
|
1307
1316
|
}
|
|
@@ -1366,9 +1375,10 @@ class VerdocsEndpoint {
|
|
|
1366
1375
|
this.nextListenerId++;
|
|
1367
1376
|
const listenerSymbol = Symbol.for('' + this.nextListenerId);
|
|
1368
1377
|
this.sessionListeners.set(listenerSymbol, listener);
|
|
1369
|
-
// Perform an immediate notification
|
|
1370
|
-
|
|
1371
|
-
|
|
1378
|
+
// Perform an immediate notification if this listener subscribed after the session was already loaded.
|
|
1379
|
+
if (this.profile) {
|
|
1380
|
+
listener(this, this.session, this.profile);
|
|
1381
|
+
}
|
|
1372
1382
|
return () => {
|
|
1373
1383
|
this.sessionListeners.delete(listenerSymbol);
|
|
1374
1384
|
};
|
|
@@ -1383,6 +1393,7 @@ class VerdocsEndpoint {
|
|
|
1383
1393
|
}
|
|
1384
1394
|
const token = localStorage.getItem(this.sessionStorageKey());
|
|
1385
1395
|
if (!token) {
|
|
1396
|
+
window?.console?.debug('[JS_SDK] No cached session found', this.endpointId);
|
|
1386
1397
|
return this.clearSession();
|
|
1387
1398
|
}
|
|
1388
1399
|
// We sometimes get multiple loadSession calls from stacked components all needing to just ensure
|