@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 +4 -19
- package/dist/index.d.ts +4 -19
- package/dist/index.js +15 -29
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -29
- package/dist/index.mjs.map +1 -1
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1039,12 +1039,10 @@ const requestLogger = (r) => {
|
|
|
1039
1039
|
class VerdocsEndpoint {
|
|
1040
1040
|
environment = 'verdocs';
|
|
1041
1041
|
sessionType = 'user';
|
|
1042
|
+
persist = true;
|
|
1042
1043
|
baseURL = (window.location.origin === 'https://beta.verdocs.com' || window.location.origin === 'https://stage.verdocs.com'
|
|
1043
1044
|
? 'https://stage-api.verdocs.com'
|
|
1044
1045
|
: 'https://api.verdocs.com');
|
|
1045
|
-
baseURLv2 = (window.location.origin === 'https://beta.verdocs.com' || window.location.origin === 'https://stage.verdocs.com'
|
|
1046
|
-
? 'https://stage-api.verdocs.com/v2'
|
|
1047
|
-
: 'https://api.verdocs.com/v2');
|
|
1048
1046
|
clientID = 'not-set';
|
|
1049
1047
|
timeout = 60000;
|
|
1050
1048
|
token = null;
|
|
@@ -1079,6 +1077,7 @@ class VerdocsEndpoint {
|
|
|
1079
1077
|
this.environment = options?.environment || this.environment;
|
|
1080
1078
|
this.sessionType = options?.sessionType || this.sessionType;
|
|
1081
1079
|
this.clientID = options?.clientID || this.clientID;
|
|
1080
|
+
this.persist = options?.persist || this.persist;
|
|
1082
1081
|
this.api = axios.create({ baseURL: this.baseURL, timeout: this.timeout });
|
|
1083
1082
|
}
|
|
1084
1083
|
setDefault() {
|
|
@@ -1109,13 +1108,6 @@ class VerdocsEndpoint {
|
|
|
1109
1108
|
getBaseURL() {
|
|
1110
1109
|
return this.baseURL;
|
|
1111
1110
|
}
|
|
1112
|
-
/**
|
|
1113
|
-
* Get the current base URL for the v2 APIs.
|
|
1114
|
-
* This should rarely be anything other than 'https://api-v2.verdocs.com'.
|
|
1115
|
-
*/
|
|
1116
|
-
getBaseURLv2() {
|
|
1117
|
-
return this.baseURLv2;
|
|
1118
|
-
}
|
|
1119
1111
|
/**
|
|
1120
1112
|
* Get the current client ID, if set.
|
|
1121
1113
|
*/
|
|
@@ -1183,21 +1175,6 @@ class VerdocsEndpoint {
|
|
|
1183
1175
|
this.api.defaults.baseURL = url;
|
|
1184
1176
|
return this;
|
|
1185
1177
|
}
|
|
1186
|
-
/**
|
|
1187
|
-
* Set the base URL for API calls. Should be called only upon direction from Verdocs Customer Solutions Engineering.
|
|
1188
|
-
*
|
|
1189
|
-
* ```typescript
|
|
1190
|
-
* import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
|
|
1191
|
-
*
|
|
1192
|
-
* const endpoint = new VerdocsEndpoint();
|
|
1193
|
-
* endpoint.setBaseURL('https://api.verdocs.com');
|
|
1194
|
-
* ```
|
|
1195
|
-
*/
|
|
1196
|
-
setBaseURLv2(url) {
|
|
1197
|
-
this.baseURLv2 = url;
|
|
1198
|
-
// NOTE: We do not set this on the Axios instance because v1 is still the standard.
|
|
1199
|
-
return this;
|
|
1200
|
-
}
|
|
1201
1178
|
/**
|
|
1202
1179
|
* Set the Client ID for Verdocs API calls.
|
|
1203
1180
|
*
|
|
@@ -1281,7 +1258,9 @@ class VerdocsEndpoint {
|
|
|
1281
1258
|
else {
|
|
1282
1259
|
this.api.defaults.headers.common.signer = `Bearer ${token}`;
|
|
1283
1260
|
}
|
|
1284
|
-
|
|
1261
|
+
if (this.persist) {
|
|
1262
|
+
localStorage.setItem(this.sessionStorageKey(), token);
|
|
1263
|
+
}
|
|
1285
1264
|
getCurrentProfile(this)
|
|
1286
1265
|
.then((r) => {
|
|
1287
1266
|
window?.console?.debug('[JS_SDK] Loaded profile', r);
|
|
@@ -1309,7 +1288,9 @@ class VerdocsEndpoint {
|
|
|
1309
1288
|
* Clear the active session.
|
|
1310
1289
|
*/
|
|
1311
1290
|
clearSession() {
|
|
1312
|
-
|
|
1291
|
+
if (this.persist) {
|
|
1292
|
+
localStorage.removeItem(this.sessionStorageKey());
|
|
1293
|
+
}
|
|
1313
1294
|
delete this.api.defaults.headers.common.Authorization;
|
|
1314
1295
|
delete this.api.defaults.headers.common.signer;
|
|
1315
1296
|
this.session = null;
|
|
@@ -1322,7 +1303,9 @@ class VerdocsEndpoint {
|
|
|
1322
1303
|
* Clear the active signing session.
|
|
1323
1304
|
*/
|
|
1324
1305
|
clearSignerSession() {
|
|
1325
|
-
|
|
1306
|
+
if (this.persist) {
|
|
1307
|
+
localStorage.removeItem(this.sessionStorageKey());
|
|
1308
|
+
}
|
|
1326
1309
|
delete this.api.defaults.headers.common.Authorization;
|
|
1327
1310
|
this.session = null;
|
|
1328
1311
|
this.profile = null;
|
|
@@ -1354,9 +1337,12 @@ class VerdocsEndpoint {
|
|
|
1354
1337
|
}
|
|
1355
1338
|
/**
|
|
1356
1339
|
* Load a persisted session from localStorage. Typically called once after the endpoint is configured
|
|
1357
|
-
* when the app or component starts.
|
|
1340
|
+
* when the app or component starts. Ignored if the endpoint is configured to not persist sessions.
|
|
1358
1341
|
*/
|
|
1359
1342
|
loadSession() {
|
|
1343
|
+
if (!this.persist) {
|
|
1344
|
+
return this;
|
|
1345
|
+
}
|
|
1360
1346
|
const token = localStorage.getItem(this.sessionStorageKey());
|
|
1361
1347
|
if (!token) {
|
|
1362
1348
|
return this.clearSession();
|