@verdocs/js-sdk 4.2.24 → 4.2.25

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
@@ -897,11 +897,12 @@ type TEnvironment = "verdocs" | "verdocs-stage";
897
897
  type TSessionChangedListener = (endpoint: VerdocsEndpoint, session: TSession, profile: IProfile | null) => void;
898
898
  interface VerdocsEndpointOptions {
899
899
  baseURL?: string;
900
- baseURLv2?: string;
901
900
  timeout?: number;
902
901
  environment?: TEnvironment;
903
902
  sessionType?: TSessionType;
904
903
  clientID?: string;
904
+ /** By default, sessions will be persisted to localStorage. Set `persist` to false to bypass this. */
905
+ persist?: boolean;
905
906
  }
906
907
  /**
907
908
  * VerdocsEndpoint is a class wrapper for a specific connection and authorization context for calling the Verdocs APIs.
@@ -927,8 +928,8 @@ interface VerdocsEndpointOptions {
927
928
  declare class VerdocsEndpoint {
928
929
  private environment;
929
930
  private sessionType;
931
+ private persist;
930
932
  private baseURL;
931
- private baseURLv2;
932
933
  private clientID;
933
934
  private timeout;
934
935
  private token;
@@ -972,11 +973,6 @@ declare class VerdocsEndpoint {
972
973
  * Get the current base URL. This should rarely be anything other than 'https://api.verdocs.com'.
973
974
  */
974
975
  getBaseURL(): string;
975
- /**
976
- * Get the current base URL for the v2 APIs.
977
- * This should rarely be anything other than 'https://api-v2.verdocs.com'.
978
- */
979
- getBaseURLv2(): string;
980
976
  /**
981
977
  * Get the current client ID, if set.
982
978
  */
@@ -1028,17 +1024,6 @@ declare class VerdocsEndpoint {
1028
1024
  * ```
1029
1025
  */
1030
1026
  setBaseURL(url: string): VerdocsEndpoint;
1031
- /**
1032
- * Set the base URL for API calls. Should be called only upon direction from Verdocs Customer Solutions Engineering.
1033
- *
1034
- * ```typescript
1035
- * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
1036
- *
1037
- * const endpoint = new VerdocsEndpoint();
1038
- * endpoint.setBaseURL('https://api.verdocs.com');
1039
- * ```
1040
- */
1041
- setBaseURLv2(url: string): VerdocsEndpoint;
1042
1027
  /**
1043
1028
  * Set the Client ID for Verdocs API calls.
1044
1029
  *
@@ -1111,7 +1096,7 @@ declare class VerdocsEndpoint {
1111
1096
  onSessionChanged(listener: TSessionChangedListener): () => void;
1112
1097
  /**
1113
1098
  * Load a persisted session from localStorage. Typically called once after the endpoint is configured
1114
- * when the app or component starts.
1099
+ * when the app or component starts. Ignored if the endpoint is configured to not persist sessions.
1115
1100
  */
1116
1101
  loadSession(): VerdocsEndpoint;
1117
1102
  }
package/dist/index.d.ts CHANGED
@@ -897,11 +897,12 @@ type TEnvironment = "verdocs" | "verdocs-stage";
897
897
  type TSessionChangedListener = (endpoint: VerdocsEndpoint, session: TSession, profile: IProfile | null) => void;
898
898
  interface VerdocsEndpointOptions {
899
899
  baseURL?: string;
900
- baseURLv2?: string;
901
900
  timeout?: number;
902
901
  environment?: TEnvironment;
903
902
  sessionType?: TSessionType;
904
903
  clientID?: string;
904
+ /** By default, sessions will be persisted to localStorage. Set `persist` to false to bypass this. */
905
+ persist?: boolean;
905
906
  }
906
907
  /**
907
908
  * VerdocsEndpoint is a class wrapper for a specific connection and authorization context for calling the Verdocs APIs.
@@ -927,8 +928,8 @@ interface VerdocsEndpointOptions {
927
928
  declare class VerdocsEndpoint {
928
929
  private environment;
929
930
  private sessionType;
931
+ private persist;
930
932
  private baseURL;
931
- private baseURLv2;
932
933
  private clientID;
933
934
  private timeout;
934
935
  private token;
@@ -972,11 +973,6 @@ declare class VerdocsEndpoint {
972
973
  * Get the current base URL. This should rarely be anything other than 'https://api.verdocs.com'.
973
974
  */
974
975
  getBaseURL(): string;
975
- /**
976
- * Get the current base URL for the v2 APIs.
977
- * This should rarely be anything other than 'https://api-v2.verdocs.com'.
978
- */
979
- getBaseURLv2(): string;
980
976
  /**
981
977
  * Get the current client ID, if set.
982
978
  */
@@ -1028,17 +1024,6 @@ declare class VerdocsEndpoint {
1028
1024
  * ```
1029
1025
  */
1030
1026
  setBaseURL(url: string): VerdocsEndpoint;
1031
- /**
1032
- * Set the base URL for API calls. Should be called only upon direction from Verdocs Customer Solutions Engineering.
1033
- *
1034
- * ```typescript
1035
- * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
1036
- *
1037
- * const endpoint = new VerdocsEndpoint();
1038
- * endpoint.setBaseURL('https://api.verdocs.com');
1039
- * ```
1040
- */
1041
- setBaseURLv2(url: string): VerdocsEndpoint;
1042
1027
  /**
1043
1028
  * Set the Client ID for Verdocs API calls.
1044
1029
  *
@@ -1111,7 +1096,7 @@ declare class VerdocsEndpoint {
1111
1096
  onSessionChanged(listener: TSessionChangedListener): () => void;
1112
1097
  /**
1113
1098
  * Load a persisted session from localStorage. Typically called once after the endpoint is configured
1114
- * when the app or component starts.
1099
+ * when the app or component starts. Ignored if the endpoint is configured to not persist sessions.
1115
1100
  */
1116
1101
  loadSession(): VerdocsEndpoint;
1117
1102
  }
package/dist/index.js CHANGED
@@ -1041,12 +1041,10 @@ const requestLogger = (r) => {
1041
1041
  class VerdocsEndpoint {
1042
1042
  environment = 'verdocs';
1043
1043
  sessionType = 'user';
1044
+ persist = true;
1044
1045
  baseURL = (window.location.origin === 'https://beta.verdocs.com' || window.location.origin === 'https://stage.verdocs.com'
1045
1046
  ? 'https://stage-api.verdocs.com'
1046
1047
  : 'https://api.verdocs.com');
1047
- baseURLv2 = (window.location.origin === 'https://beta.verdocs.com' || window.location.origin === 'https://stage.verdocs.com'
1048
- ? 'https://stage-api.verdocs.com/v2'
1049
- : 'https://api.verdocs.com/v2');
1050
1048
  clientID = 'not-set';
1051
1049
  timeout = 60000;
1052
1050
  token = null;
@@ -1081,6 +1079,7 @@ class VerdocsEndpoint {
1081
1079
  this.environment = options?.environment || this.environment;
1082
1080
  this.sessionType = options?.sessionType || this.sessionType;
1083
1081
  this.clientID = options?.clientID || this.clientID;
1082
+ this.persist = options?.persist || this.persist;
1084
1083
  this.api = axios.create({ baseURL: this.baseURL, timeout: this.timeout });
1085
1084
  }
1086
1085
  setDefault() {
@@ -1111,13 +1110,6 @@ class VerdocsEndpoint {
1111
1110
  getBaseURL() {
1112
1111
  return this.baseURL;
1113
1112
  }
1114
- /**
1115
- * Get the current base URL for the v2 APIs.
1116
- * This should rarely be anything other than 'https://api-v2.verdocs.com'.
1117
- */
1118
- getBaseURLv2() {
1119
- return this.baseURLv2;
1120
- }
1121
1113
  /**
1122
1114
  * Get the current client ID, if set.
1123
1115
  */
@@ -1185,21 +1177,6 @@ class VerdocsEndpoint {
1185
1177
  this.api.defaults.baseURL = url;
1186
1178
  return this;
1187
1179
  }
1188
- /**
1189
- * Set the base URL for API calls. Should be called only upon direction from Verdocs Customer Solutions Engineering.
1190
- *
1191
- * ```typescript
1192
- * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
1193
- *
1194
- * const endpoint = new VerdocsEndpoint();
1195
- * endpoint.setBaseURL('https://api.verdocs.com');
1196
- * ```
1197
- */
1198
- setBaseURLv2(url) {
1199
- this.baseURLv2 = url;
1200
- // NOTE: We do not set this on the Axios instance because v1 is still the standard.
1201
- return this;
1202
- }
1203
1180
  /**
1204
1181
  * Set the Client ID for Verdocs API calls.
1205
1182
  *
@@ -1283,7 +1260,9 @@ class VerdocsEndpoint {
1283
1260
  else {
1284
1261
  this.api.defaults.headers.common.signer = `Bearer ${token}`;
1285
1262
  }
1286
- localStorage.setItem(this.sessionStorageKey(), token);
1263
+ if (this.persist) {
1264
+ localStorage.setItem(this.sessionStorageKey(), token);
1265
+ }
1287
1266
  getCurrentProfile(this)
1288
1267
  .then((r) => {
1289
1268
  window?.console?.debug('[JS_SDK] Loaded profile', r);
@@ -1311,7 +1290,9 @@ class VerdocsEndpoint {
1311
1290
  * Clear the active session.
1312
1291
  */
1313
1292
  clearSession() {
1314
- localStorage.removeItem(this.sessionStorageKey());
1293
+ if (this.persist) {
1294
+ localStorage.removeItem(this.sessionStorageKey());
1295
+ }
1315
1296
  delete this.api.defaults.headers.common.Authorization;
1316
1297
  delete this.api.defaults.headers.common.signer;
1317
1298
  this.session = null;
@@ -1324,7 +1305,9 @@ class VerdocsEndpoint {
1324
1305
  * Clear the active signing session.
1325
1306
  */
1326
1307
  clearSignerSession() {
1327
- localStorage.removeItem(this.sessionStorageKey());
1308
+ if (this.persist) {
1309
+ localStorage.removeItem(this.sessionStorageKey());
1310
+ }
1328
1311
  delete this.api.defaults.headers.common.Authorization;
1329
1312
  this.session = null;
1330
1313
  this.profile = null;
@@ -1356,9 +1339,12 @@ class VerdocsEndpoint {
1356
1339
  }
1357
1340
  /**
1358
1341
  * Load a persisted session from localStorage. Typically called once after the endpoint is configured
1359
- * when the app or component starts.
1342
+ * when the app or component starts. Ignored if the endpoint is configured to not persist sessions.
1360
1343
  */
1361
1344
  loadSession() {
1345
+ if (!this.persist) {
1346
+ return this;
1347
+ }
1362
1348
  const token = localStorage.getItem(this.sessionStorageKey());
1363
1349
  if (!token) {
1364
1350
  return this.clearSession();