@verdocs/js-sdk 4.2.88 → 4.2.90

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
@@ -1099,7 +1099,7 @@ declare class VerdocsEndpoint {
1099
1099
  * endpoint.setToken(accessToken);
1100
1100
  * ```
1101
1101
  */
1102
- setToken(token: string | null): VerdocsEndpoint;
1102
+ setToken(token: string | null, sessionType?: TSessionType): VerdocsEndpoint;
1103
1103
  /**
1104
1104
  * Retrieves the current session token, if any. Tokens should rarely be used for direct actions, but this is
1105
1105
  * required by the `<VerdocsView>` and other components to authorize requests to raw PDF files.
@@ -1206,6 +1206,11 @@ interface ISignerTokenResponse {
1206
1206
  * a signing session is being started, so it is included here for convenience.
1207
1207
  */
1208
1208
  envelope: IEnvelope;
1209
+ /**
1210
+ * A copy of the recipient record related to the signing session. This is almost always needed when
1211
+ * a signing session is being started, so it is included here for convenience.
1212
+ */
1213
+ recipient: IRecipient;
1209
1214
  }
1210
1215
  interface IInPersonLinkResponse {
1211
1216
  /** A valid Verdocs Web URL that hosts a signing experience. */
package/dist/index.d.ts CHANGED
@@ -1099,7 +1099,7 @@ declare class VerdocsEndpoint {
1099
1099
  * endpoint.setToken(accessToken);
1100
1100
  * ```
1101
1101
  */
1102
- setToken(token: string | null): VerdocsEndpoint;
1102
+ setToken(token: string | null, sessionType?: TSessionType): VerdocsEndpoint;
1103
1103
  /**
1104
1104
  * Retrieves the current session token, if any. Tokens should rarely be used for direct actions, but this is
1105
1105
  * required by the `<VerdocsView>` and other components to authorize requests to raw PDF files.
@@ -1206,6 +1206,11 @@ interface ISignerTokenResponse {
1206
1206
  * a signing session is being started, so it is included here for convenience.
1207
1207
  */
1208
1208
  envelope: IEnvelope;
1209
+ /**
1210
+ * A copy of the recipient record related to the signing session. This is almost always needed when
1211
+ * a signing session is being started, so it is included here for convenience.
1212
+ */
1213
+ recipient: IRecipient;
1209
1214
  }
1210
1215
  interface IInPersonLinkResponse {
1211
1216
  /** A valid Verdocs Web URL that hosts a signing experience. */
package/dist/index.js CHANGED
@@ -1304,48 +1304,50 @@ class VerdocsEndpoint {
1304
1304
  * endpoint.setToken(accessToken);
1305
1305
  * ```
1306
1306
  */
1307
- setToken(token) {
1307
+ setToken(token, sessionType = 'user') {
1308
1308
  if (!token) {
1309
1309
  window.console.log('[JS_SDK] Clearing token');
1310
1310
  return this.clearSession();
1311
1311
  }
1312
- window.console.log('[JS_SDK] Setting token', token.length);
1313
1312
  const session = decodeAccessTokenBody(token);
1314
1313
  if (session === null || (session.exp && session.exp * 1000 < new Date().getTime())) {
1315
1314
  window.console.warn('[JS_SDK] Ignoring attempt to use expired session token');
1316
1315
  return this.clearSession();
1317
1316
  }
1317
+ window.console.log('[JS_SDK] Setting token', sessionType);
1318
1318
  this.token = token;
1319
1319
  this.session = session;
1320
+ this.sub = session.sub;
1321
+ this.sessionType = sessionType;
1320
1322
  if (this.sessionType === 'user') {
1321
1323
  this.api.defaults.headers.common.Authorization = `Bearer ${token}`;
1322
1324
  }
1323
1325
  else {
1326
+ // Required for legacy calls to rForm
1324
1327
  this.api.defaults.headers.common.signer = `Bearer ${token}`;
1328
+ this.api.defaults.headers.common.Authorization = `Bearer ${token}`;
1325
1329
  }
1326
- if (this.persist) {
1330
+ if (this.persist && sessionType === 'user') {
1327
1331
  localStorage.setItem(this.sessionStorageKey(), token);
1328
1332
  }
1329
- // NOTE: We don't attempt to de-dupe session/network operations because there are cases where we
1330
- // operate within an IFRAME and multiple siblings need to operate on the same session. This happens
1331
- // a lot in Storybook but may also happen in other environments as well. Rather than try to coordinate
1332
- // something weird that might break (e.g. in a mobile app), we just allow the dupe calls. We generate
1333
- // a unique ID for each endpoint just to help with debugging. It should not be taken as a bug if more
1334
- // than one endpoint ID is seen within the app's logs.
1335
- window?.console?.debug('[JS_SDK] Loading current profile...', this.endpointId, this.sub, session.sub);
1336
- this.sub = session.sub;
1337
- getCurrentProfile(this)
1338
- .then((r) => {
1339
- window?.console?.debug('[JS_SDK] Loaded profile', this.endpointId, r);
1340
- this.profile = r || null;
1333
+ if (this.sessionType === 'user') {
1334
+ window?.console?.debug('[JS_SDK] Loading current profile...', this.endpointId, this.sub, session.sub);
1335
+ getCurrentProfile(this)
1336
+ .then((r) => {
1337
+ window?.console?.debug('[JS_SDK] Loaded profile', this.endpointId, r);
1338
+ this.profile = r || null;
1339
+ this.notifySessionListeners();
1340
+ })
1341
+ .catch((e) => {
1342
+ this.profile = null;
1343
+ this.sub = null;
1344
+ window?.console?.warn('Unable to load profile', e);
1345
+ this.clearSession();
1346
+ });
1347
+ }
1348
+ else {
1341
1349
  this.notifySessionListeners();
1342
- })
1343
- .catch((e) => {
1344
- this.profile = null;
1345
- this.sub = null;
1346
- window?.console?.warn('Unable to load profile', e);
1347
- this.clearSession();
1348
- });
1350
+ }
1349
1351
  return this;
1350
1352
  }
1351
1353
  /**