@verdocs/js-sdk 3.0.4 → 3.0.6

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.
@@ -114,11 +114,11 @@ export var getSigningSession = function (endpoint, params) { return __awaiter(vo
114
114
  return [2 /*return*/, endpoint.api //
115
115
  .get("/envelopes/".concat(params.envelopeId, "/recipients/").concat(encodeURIComponent(params.roleId), "/invitation/").concat(params.inviteCode))
116
116
  .then(function (r) {
117
- var _a, _b;
117
+ var _a;
118
118
  // Avoiding a jsonwebtoken dependency here - we don't actually need the whole library
119
119
  var signerToken = ((_a = r.headers) === null || _a === void 0 ? void 0 : _a.signer_token) || '';
120
120
  var session = decodeAccessTokenBody(signerToken);
121
- endpoint.setToken((_b = r.headers) === null || _b === void 0 ? void 0 : _b.signer_token);
121
+ endpoint.setToken(signerToken);
122
122
  return { recipient: r.data, session: session, signerToken: signerToken };
123
123
  })];
124
124
  });
@@ -19,7 +19,6 @@ export interface ISigningSession {
19
19
  aud: string;
20
20
  exp: number;
21
21
  iat: number;
22
- [key: string]: any;
23
22
  }
24
23
  export interface IInPersonAccessKey {
25
24
  id: string;
@@ -82,7 +82,11 @@ export var createTemplateDocument = function (endpoint, templateId, file, onUplo
82
82
  return endpoint.api //
83
83
  .post("/templates/".concat(templateId, "/documents"), formData, {
84
84
  timeout: 10000,
85
- onUploadProgress: function (event) { return onUploadProgress === null || onUploadProgress === void 0 ? void 0 : onUploadProgress(Math.floor((event.loaded * 100) / event.total), event.loaded, event.total); },
85
+ onUploadProgress: function (event) {
86
+ var total = event.total || 1;
87
+ var loaded = event.loaded || 0;
88
+ onUploadProgress === null || onUploadProgress === void 0 ? void 0 : onUploadProgress(Math.floor((loaded * 100) / (total || 1)), loaded, total || 1);
89
+ },
86
90
  })
87
91
  .then(function (r) { return r.data; });
88
92
  };
@@ -156,6 +156,7 @@ export interface ITemplateDocument {
156
156
  url: string;
157
157
  name: string;
158
158
  page_numbers: number;
159
+ order: number;
159
160
  id?: string;
160
161
  updated_at?: string;
161
162
  created_at?: string;
@@ -43,7 +43,7 @@ export declare class VerdocsEndpoint {
43
43
  /**
44
44
  * The current user session, or null if not authenticated. May be either a User or Signing session. If set, the
45
45
  * presence of the `document_id` field can be used to differentiate the types. Only signing sessions are associated
46
- * with Documents.
46
+ * with Envelopes.
47
47
  */
48
48
  session: TSession;
49
49
  api: AxiosInstance;
@@ -180,6 +180,10 @@ export declare class VerdocsEndpoint {
180
180
  * Clear the active session.
181
181
  */
182
182
  clearSession(): this;
183
+ /**
184
+ * Clear the active signing session.
185
+ */
186
+ clearSignerSession(): this;
183
187
  private notifySessionListeners;
184
188
  /**
185
189
  * Subscribe to session state change events.
@@ -52,7 +52,7 @@ var VerdocsEndpoint = /** @class */ (function () {
52
52
  /**
53
53
  * The current user session, or null if not authenticated. May be either a User or Signing session. If set, the
54
54
  * presence of the `document_id` field can be used to differentiate the types. Only signing sessions are associated
55
- * with Documents.
55
+ * with Envelopes.
56
56
  */
57
57
  this.session = null;
58
58
  this.baseURL = (options === null || options === void 0 ? void 0 : options.baseURL) || 'https://api.verdocs.com';
@@ -226,11 +226,17 @@ var VerdocsEndpoint = /** @class */ (function () {
226
226
  }
227
227
  var session = decodeAccessTokenBody(token);
228
228
  if (session === null || (session.exp && session.exp * 1000 < new Date().getTime())) {
229
+ window.console.warn('[JS_SDK] Ignoring attempt to use expired session token');
229
230
  return this.clearSession();
230
231
  }
231
232
  this.token = token;
232
233
  this.session = session;
233
- this.api.defaults.headers.common.Authorization = "Bearer ".concat(token);
234
+ if (this.sessionType === 'user') {
235
+ this.api.defaults.headers.common.Authorization = "Bearer ".concat(token);
236
+ }
237
+ else {
238
+ this.api.defaults.headers.common.signer = "Bearer ".concat(token);
239
+ }
234
240
  localStorage.setItem(this.sessionStorageKey(), token);
235
241
  this.notifySessionListeners();
236
242
  return this;
@@ -249,6 +255,18 @@ var VerdocsEndpoint = /** @class */ (function () {
249
255
  * Clear the active session.
250
256
  */
251
257
  VerdocsEndpoint.prototype.clearSession = function () {
258
+ localStorage.removeItem(this.sessionStorageKey());
259
+ delete this.api.defaults.headers.common.Authorization;
260
+ delete this.api.defaults.headers.common.signer;
261
+ this.session = null;
262
+ this.token = null;
263
+ this.notifySessionListeners();
264
+ return this;
265
+ };
266
+ /**
267
+ * Clear the active signing session.
268
+ */
269
+ VerdocsEndpoint.prototype.clearSignerSession = function () {
252
270
  localStorage.removeItem(this.sessionStorageKey());
253
271
  delete this.api.defaults.headers.common.Authorization;
254
272
  this.session = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdocs/js-sdk",
3
- "version": "3.0.4",
3
+ "version": "3.0.6",
4
4
  "private": false,
5
5
  "homepage": "https://github.com/Verdocs/js-sdk",
6
6
  "description": "Verdocs JS SDK",
@@ -45,7 +45,7 @@
45
45
  "access": "public"
46
46
  },
47
47
  "dependencies": {
48
- "axios": "^0.27.2"
48
+ "axios": "^1.2.2"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "typescript": "^4.7.3"
@@ -55,12 +55,12 @@
55
55
  "@types/jest": "^28.1.4",
56
56
  "axios-mock-adapter": "^1.21.2",
57
57
  "jest": "^28.1.2",
58
- "prettier": "^2.7.1",
58
+ "prettier": "^2.8.1",
59
59
  "ts-jest": "^28.0.8",
60
60
  "tslint": "^6.1.3",
61
61
  "tslint-config-prettier": "^1.18.0",
62
- "typedoc": "^0.23.11",
63
- "typedoc-plugin-markdown": "^3.13.4",
62
+ "typedoc": "^0.23.23",
63
+ "typedoc-plugin-markdown": "^3.14.0",
64
64
  "typescript": "^4.7.4"
65
65
  }
66
66
  }