@verdocs/js-sdk 5.1.3 → 5.1.5

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
@@ -1176,10 +1176,10 @@ const updateProfilePhoto = (endpoint, profileId, file, onUploadProgress) => {
1176
1176
  const ENDPOINT_KEY = Symbol.for('verdocs-default-endpoint');
1177
1177
  const BETA_ORIGINS = ['https://beta.verdocs.com', 'https://stage.verdocs.com', 'http://localhost:6006', 'http://localhost:5173'];
1178
1178
  const requestLogger = (r) => {
1179
- // tslint:disable-next-line
1180
- console.debug(`[JS-SDK] ${r.method.toUpperCase()} ${r.baseURL}${r.url}`, r.data ? JSON.stringify(r.data) : '');
1179
+ // TODO: Re-activate logging via an isomorphic approach
1181
1180
  return r;
1182
1181
  };
1182
+ const isBrowser = typeof globalThis$1.window !== 'undefined';
1183
1183
  /**
1184
1184
  * VerdocsEndpoint is a class wrapper for a specific connection and authorization context for calling the Verdocs APIs.
1185
1185
  * Endpoints can be used for isolated session tasks.
@@ -1205,7 +1205,7 @@ class VerdocsEndpoint {
1205
1205
  environment = 'verdocs';
1206
1206
  sessionType = 'user';
1207
1207
  persist = true;
1208
- baseURL = BETA_ORIGINS.includes(window?.location?.origin || '') ? 'https://stage-api.verdocs.com' : 'https://api.verdocs.com';
1208
+ baseURL = BETA_ORIGINS.includes(globalThis$1.window?.location?.origin || '') ? 'https://stage-api.verdocs.com' : 'https://api.verdocs.com';
1209
1209
  clientID = 'not-set';
1210
1210
  timeout = 60000;
1211
1211
  token = null;
@@ -1250,7 +1250,6 @@ class VerdocsEndpoint {
1250
1250
  }
1251
1251
  setDefault() {
1252
1252
  globalThis$1[ENDPOINT_KEY] = this;
1253
- window?.console?.debug('[JS_SDK] Set default endpoint', this.endpointId);
1254
1253
  }
1255
1254
  static getDefault() {
1256
1255
  if (!globalThis$1[ENDPOINT_KEY]) {
@@ -1411,23 +1410,20 @@ class VerdocsEndpoint {
1411
1410
  */
1412
1411
  setToken(token, sessionType = 'user') {
1413
1412
  if (!token) {
1414
- window?.console?.log('[JS_SDK] Clearing token');
1415
1413
  return this.clearSession();
1416
1414
  }
1417
1415
  const session = decodeAccessTokenBody(token);
1418
1416
  if (session === null || (session.exp && session.exp * 1000 < new Date().getTime())) {
1419
- window?.console?.warn('[JS_SDK] Ignoring attempt to use expired session token');
1420
1417
  return this.clearSession();
1421
1418
  }
1422
- window?.console?.log('[JS_SDK] Setting token', sessionType);
1423
1419
  this.token = token;
1424
1420
  this.session = session;
1425
1421
  this.sub = session.sub;
1426
1422
  this.sessionType = sessionType;
1427
1423
  if (this.sessionType === 'user') {
1428
1424
  this.api.defaults.headers.common.Authorization = `Bearer ${token}`;
1429
- if (this.persist) {
1430
- localStorage.setItem(this.sessionStorageKey(), token);
1425
+ if (this.persist && isBrowser) {
1426
+ globalThis$1.localStorage.setItem(this.sessionStorageKey(), token);
1431
1427
  }
1432
1428
  }
1433
1429
  else {
@@ -1437,17 +1433,14 @@ class VerdocsEndpoint {
1437
1433
  // this.api.defaults.headers.common.Authorization = `Bearer ${token}`;
1438
1434
  }
1439
1435
  if (this.sessionType === 'user') {
1440
- window?.console?.debug('[JS_SDK] Loading current profile...', this.endpointId, this.sub, session.sub);
1441
1436
  getCurrentProfile(this)
1442
1437
  .then((r) => {
1443
- window?.console?.debug('[JS_SDK] Loaded profile', this.endpointId, r);
1444
1438
  this.profile = r || null;
1445
1439
  this.notifySessionListeners();
1446
1440
  })
1447
1441
  .catch((e) => {
1448
1442
  this.profile = null;
1449
1443
  this.sub = null;
1450
- window?.console?.warn('Unable to load profile', e);
1451
1444
  // We can't clear the token verdocs-auth may be using temporarily during registration
1452
1445
  if (this.persist) {
1453
1446
  this.clearSession();
@@ -1473,7 +1466,6 @@ class VerdocsEndpoint {
1473
1466
  * Clear the active session.
1474
1467
  */
1475
1468
  clearSession() {
1476
- window?.console?.debug('[JS_SDK] Clearing session', this.endpointId);
1477
1469
  if (this.persist) {
1478
1470
  localStorage.removeItem(this.sessionStorageKey());
1479
1471
  }
@@ -1490,7 +1482,6 @@ class VerdocsEndpoint {
1490
1482
  * Clear the active signing session.
1491
1483
  */
1492
1484
  clearSignerSession() {
1493
- window?.console?.debug('[JS_SDK] Clearing signer session', this.endpointId);
1494
1485
  if (this.persist) {
1495
1486
  localStorage.removeItem(this.sessionStorageKey());
1496
1487
  }
@@ -1538,7 +1529,6 @@ class VerdocsEndpoint {
1538
1529
  }
1539
1530
  const token = localStorage.getItem(this.sessionStorageKey());
1540
1531
  if (!token) {
1541
- window?.console?.debug('[JS_SDK] No cached session found', this.endpointId);
1542
1532
  return this.clearSession();
1543
1533
  }
1544
1534
  // We sometimes get multiple loadSession calls from stacked components all needing to just ensure
@@ -3345,7 +3335,6 @@ const getTemplates = (endpoint, params) => endpoint.api //
3345
3335
  * @apiSuccess ITemplate . The requested template
3346
3336
  */
3347
3337
  const getTemplate = (endpoint, templateId) => {
3348
- window?.console?.log('[JS_SDK] Loading template', templateId);
3349
3338
  return endpoint.api //
3350
3339
  .get(`/v2/templates/${templateId}`)
3351
3340
  .then((r) => {