@verdocs/js-sdk 4.0.6 → 4.0.9

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.mjs CHANGED
@@ -1,692 +1,252 @@
1
1
  import axios from 'axios';
2
2
 
3
- /* tslint:disable:no-bitwise */
4
- const b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
5
- // Regular expression to check formal correctness of base64 encoded strings
6
- const b64re = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/;
7
3
  /**
8
- * Simplified, Node/Browser-safe alternative to atob() for base64 decoding.
9
- * Modified from https://github.com/MaxArt2501/base64-js/blob/master/base64.js
4
+ * Given a `rgba(r,g,b,a)` string value, returns the hex equivalent, dropping the alpha channel.
10
5
  */
11
- const AtoB = (str) => {
12
- // atob can work with strings with whitespaces, even inside the encoded part,
13
- // but only \t, \n, \f, \r and ' ', which can be stripped.
14
- str = String(str).replace(/[\t\n\f\r ]+/g, '');
15
- if (!b64re.test(str))
16
- throw new TypeError("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");
17
- // Adding the padding if missing, for semplicity
18
- str += '=='.slice(2 - (str.length & 3));
19
- let bitmap;
20
- let result = '';
21
- let r1;
22
- let r2;
23
- let i = 0;
24
- for (; i < str.length;) {
25
- bitmap =
26
- (b64.indexOf(str.charAt(i++)) << 18) |
27
- (b64.indexOf(str.charAt(i++)) << 12) |
28
- ((r1 = b64.indexOf(str.charAt(i++))) << 6) |
29
- (r2 = b64.indexOf(str.charAt(i++)));
30
- result +=
31
- r1 === 64
32
- ? String.fromCharCode((bitmap >> 16) & 255)
33
- : r2 === 64
34
- ? String.fromCharCode((bitmap >> 16) & 255, (bitmap >> 8) & 255)
35
- : String.fromCharCode((bitmap >> 16) & 255, (bitmap >> 8) & 255, bitmap & 255);
6
+ function getRGB(rgba) {
7
+ const rgbNumbers = rgba.replace('rgba(', '').replace(')', '').split(',');
8
+ const rgbObject = {
9
+ red: +rgbNumbers[0],
10
+ green: +rgbNumbers[1],
11
+ blue: +rgbNumbers[2],
12
+ alpha: +rgbNumbers[3],
13
+ };
14
+ const alpha = 1 - rgbObject.alpha;
15
+ const red = Math.round((rgbObject.alpha * (rgbObject.red / 255) + alpha) * 255);
16
+ const green = Math.round((rgbObject.alpha * (rgbObject.green / 255) + alpha) * 255);
17
+ const blue = Math.round((rgbObject.alpha * (rgbObject.blue / 255) + alpha) * 255);
18
+ return '#' + rgbToHex(red) + rgbToHex(green) + rgbToHex(blue);
19
+ }
20
+ /**
21
+ * Given an RGB string value, returns the hex equivalent.
22
+ */
23
+ function rgbToHex(rgb) {
24
+ const hex = rgb.toString(16);
25
+ if (hex.length < 2) {
26
+ return '0' + hex;
36
27
  }
37
- return result;
38
- };
28
+ return hex;
29
+ }
39
30
  /**
40
- * Decode the body of a JWT. This helper may allow front-end applications to avoid a dependency on `jsonwebtoken` in
41
- * many cases. Note that this should only be used for true JWTs. Opaque tokens will cause this to throw.
31
+ * Given a signer role index, return the color code for that signer.
42
32
  */
43
- const decodeJWTBody = (token) => JSON.parse(AtoB((token || '').split('.')[1] || ''));
33
+ function getRGBA(roleIndex) {
34
+ switch (roleIndex % 10) {
35
+ case 0:
36
+ return roleIndex === 0 ? 'rgba(255, 193, 7, 0.4)' : 'rgba(134, 134, 134, 0.3)'; // #FFE69C
37
+ case 1:
38
+ return 'rgba(156, 39, 176, .4)'; // '#E3C3E9'
39
+ case 2:
40
+ return 'rgba(33, 150, 243, .4)'; // '#C1E1FB'
41
+ case 3:
42
+ return 'rgba(220, 231, 117, 0.3)';
43
+ case 4:
44
+ return 'rgba(121, 134, 203, 0.3)';
45
+ case 5:
46
+ return 'rgba(77, 182, 172, 0.3)';
47
+ case 6:
48
+ return 'rgba(255, 202, 165, 0.3)';
49
+ case 7:
50
+ return 'rgba(2, 247, 190, 0.3)';
51
+ case 8:
52
+ return 'rgba(255, 138, 101, 0.3)';
53
+ case 9:
54
+ return 'rgba(82, 255, 79, 0.3)';
55
+ default:
56
+ return 'rgba(229, 115, 155, 0.3)';
57
+ }
58
+ }
44
59
  /**
45
- * Decode the body of an Verdocs access token. Note that raw tokens contain namespaced fields, e.g.
46
- * `https://verdocs.com/profile_id`. To make these tokens easier to use in front-end code, this name-spacing
47
- * will be removed. Note that user and signing sessions have different access token formats. The calling
48
- * application should distinguish between the two based on the context of the authenticated session, or by
49
- * the presence of the `document_id` field, which will only be present for signing sessions.
60
+ * Given a role name, return a color code for it. This works by computing a hash code so the specific color returned
61
+ * is not specified explicitly, but will be the same for every call with the same input value.
50
62
  */
51
- const decodeAccessTokenBody = (token) => {
52
- let decoded;
53
- try {
54
- decoded = decodeJWTBody(token);
55
- if (decoded === null) {
56
- return null;
63
+ function nameToRGBA(str) {
64
+ if (!!str) {
65
+ const validNum = parseInt(str.slice(-1), 10);
66
+ if (!isNaN(validNum)) {
67
+ str += (validNum * 99).toString();
68
+ }
69
+ let hash = 0;
70
+ for (let i = 0; i < str.length; i++) {
71
+ // tslint:disable-next-line:no-bitwise
72
+ hash = str.charCodeAt(i) + ((hash << 5) - hash);
57
73
  }
74
+ hash = Math.round(hash / 1.3);
75
+ // tslint:disable-next-line:no-bitwise
76
+ const c = (hash & 0x00ffff08).toString(16).toUpperCase();
77
+ const hex = '#' + '00000'.substring(0, 6 - c.length) + c;
78
+ const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
79
+ const color = {
80
+ r: parseInt(result[1], 16),
81
+ g: parseInt(result[2], 16),
82
+ b: parseInt(result[3], 16),
83
+ };
84
+ return `rgba(${color.r}, ${color.g}, ${color.b}, 0.2)`;
58
85
  }
59
- catch (e) {
60
- return null;
86
+ }
87
+ /**
88
+ * Helper function to obtain a color code given a role name given various possible inputs.
89
+ */
90
+ function getRoleColor(name, roles, index) {
91
+ if (index) {
92
+ return getRGBA(index);
61
93
  }
62
- Object.keys(decoded).forEach((key) => {
63
- if (typeof key === 'string' && key.startsWith('https://verdocs.com/')) {
64
- decoded[key.replace('https://verdocs.com/', '')] = decoded[key];
65
- delete decoded[key];
94
+ else if (roles && roles.length > 0) {
95
+ const roleIndex = roles.findIndex((role) => role === name);
96
+ if (roleIndex > -1) {
97
+ return getRGBA(roleIndex);
66
98
  }
67
- });
68
- return decoded;
69
- };
70
-
71
- function getDefaultExportFromCjs (x) {
72
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
99
+ else {
100
+ return nameToRGBA(name);
101
+ }
102
+ }
103
+ else {
104
+ return nameToRGBA(name);
105
+ }
73
106
  }
74
107
 
75
- // This file provides a polyfill for managing globals in both NodeJS and browser environments. This is
76
- // an anti-pattern we'd hoped to avoid, but we have several projects dependending on one common library
77
- // (this js-sdk) and we want that library to provide a common endpoint to all callers (so authentication
78
- // tokens only need to be tracked in one place). The trouble is, one of those libraries is based on
79
- // StencilJS and is compiling its modules into Web Components. Because of how module resolution works,
80
- // when those Components load js-sdk they get a separate instance. Without messy options like having to
81
- // pass raw data from the caller to each Component, or pass around references to a common Endpoint, they
82
- // have no way to access authenticated sessions unless we make the Endpoint a true global.
83
- //
84
- // @credit https://github.com/medikoo/es5-ext/blob/master/global.js
85
- // @credit https://mathiasbynens.be/notes/globalthis
86
- var naiveFallback = function () {
87
- if (typeof self === 'object' && self)
88
- return self;
89
- if (typeof window === 'object' && window)
90
- return window;
91
- throw new Error('Unable to resolve global `this`');
92
- };
93
- var globalThis_1 = (function () {
94
- if (this)
95
- return this;
96
- // Unexpected strict mode (may happen if e.g. bundled into ESM module)
97
- // Fallback to standard globalThis if available
98
- if (typeof globalThis === 'object' && globalThis)
99
- return globalThis;
100
- // Thanks @mathiasbynens -> https://mathiasbynens.be/notes/globalthis
101
- // In all ES5+ engines global object inherits from Object.prototype
102
- // (if you approached one that doesn't please report)
103
- try {
104
- Object.defineProperty(Object.prototype, '__global__', {
105
- get: function () {
106
- return this;
107
- },
108
- configurable: true,
109
- });
108
+ const YEAR = 365 * 24 * 60 * 60;
109
+ // const MONTH = 30 * 24 * 60 * 60;
110
+ const WEEK = 7 * 24 * 60 * 60;
111
+ const DAY = 24 * 60 * 60;
112
+ const HOUR = 60 * 60;
113
+ const MINUTE = 60;
114
+ const formatShortTimeAgo = (val) => {
115
+ if (val === undefined || val === null) {
116
+ return '';
110
117
  }
111
- catch (error) {
112
- // Unfortunate case of updates to Object.prototype being restricted
113
- // via preventExtensions, seal or freeze
114
- return naiveFallback();
118
+ let dateInput;
119
+ if (typeof val === 'string' || typeof val === 'number') {
120
+ dateInput = new Date(val);
115
121
  }
116
- try {
117
- // Safari case (window.__global__ works, but __global__ does not)
118
- if (!__global__)
119
- return naiveFallback();
120
- return __global__;
122
+ else if (typeof val === 'object') {
123
+ dateInput = val;
121
124
  }
122
- finally {
123
- delete Object.prototype.__global__;
125
+ else {
126
+ return '';
124
127
  }
125
- })();
126
-
127
- var globalThis$1 = /*@__PURE__*/getDefaultExportFromCjs(globalThis_1);
128
-
129
- // @credit https://derickbailey.com/2016/03/09/creating-a-true-singleton-in-node-js-with-es6-symbols/
130
- // Also see globalThis for comments about why we're doing this in the first place.
131
- const ENDPOINT_KEY = Symbol.for('verdocs-default-endpoint');
132
- const requestLogger = (r) => {
133
- // tslint:disable-next-line
134
- console.debug(`[JS-SDK] ${r.method.toUpperCase()} ${r.baseURL}${r.url}`, r.data ? JSON.stringify(r.data) : '');
135
- return r;
128
+ const timeDiff = Math.floor((new Date().getTime() - dateInput.getTime()) / 1000);
129
+ if (timeDiff >= YEAR) {
130
+ return Math.floor(timeDiff / YEAR) + 'Y';
131
+ }
132
+ // if (timeDiff >= MONTH) {
133
+ // return Math.floor(timeDiff / MONTH) + 'M';
134
+ // }
135
+ if (timeDiff >= WEEK) {
136
+ return Math.floor(timeDiff / WEEK) + 'W';
137
+ }
138
+ if (timeDiff >= DAY) {
139
+ return Math.floor(timeDiff / DAY) + 'D';
140
+ }
141
+ if (timeDiff >= HOUR) {
142
+ return Math.floor(timeDiff / HOUR) + 'H';
143
+ }
144
+ if (timeDiff >= MINUTE) {
145
+ return Math.floor(timeDiff / MINUTE) + 'M';
146
+ }
147
+ return `${timeDiff}S`;
136
148
  };
137
- /**
138
- * VerdocsEndpoint is a class wrapper for a specific connection and authorization context for calling the Verdocs APIs.
139
- * Endpoints can be used for isolated session tasks.
140
- *
141
- * For instance, ephemeral signing sessions may be created independently of a caller's status as an authenticated user.
142
- * In that case, an Endpoint can be created and authenticated, used for calls related to signing operations, then
143
- * discarded once signing is complete.
144
- *
145
- * Note that endpoint configuration functions return the instance, so they can be chained, e.g.
146
- *
147
- * ```typescript
148
- * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
149
- *
150
- * const endpoint = new VerdocsEndpoint();
151
- * endpoint
152
- * .setSessionType('signing')
153
- * .logRequests(true)
154
- * .setClientID('1234)
155
- * .setTimeout(30000);
156
- * ```
157
- */
158
- class VerdocsEndpoint {
159
- environment = 'verdocs';
160
- sessionType = 'user';
161
- baseURL = (window.location.origin === 'https://beta.verdocs.com' || window.location.origin === 'https://stage.verdocs.com'
162
- ? 'https://stage-api.verdocs.com'
163
- : 'https://api.verdocs.com');
164
- clientID = 'not-set';
165
- timeout = 60000;
166
- token = null;
167
- nextListenerId = 0;
168
- sessionListeners = new Map();
169
- requestLoggerId = null;
170
- /**
171
- * The current user session, or null if not authenticated. May be either a User or Signing session. If set, the
172
- * presence of the `document_id` field can be used to differentiate the types. Only signing sessions are associated
173
- * with Envelopes.
174
- */
175
- session = null;
176
- api;
177
- /**
178
- * Create a new VerdocsEndpoint to call Verdocs platform services.
179
- *
180
- * ```typescript
181
- * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
182
- * const endpoint = new VerdocsEndpoint();
183
- * ```
184
- */
185
- constructor(options) {
186
- this.baseURL = options?.baseURL || this.baseURL;
187
- this.timeout = options?.timeout || this.timeout;
188
- this.environment = options?.environment || this.environment;
189
- this.sessionType = options?.sessionType || this.sessionType;
190
- this.clientID = options?.clientID || this.clientID;
191
- this.api = axios.create({ baseURL: this.baseURL, timeout: this.timeout });
192
- }
193
- setDefault() {
194
- globalThis$1[ENDPOINT_KEY] = this;
195
- }
196
- static getDefault() {
197
- if (!globalThis$1[ENDPOINT_KEY]) {
198
- globalThis$1[ENDPOINT_KEY] = new VerdocsEndpoint();
199
- window.console.debug('[JS_SDK] Created default endpoint', globalThis$1[ENDPOINT_KEY].baseURL);
200
- }
201
- return globalThis$1[ENDPOINT_KEY];
202
- }
203
- /**
204
- * Get the current environment.
205
- */
206
- getEnvironment() {
207
- return this.environment;
208
- }
209
- /**
210
- * Get the current session type.
211
- */
212
- getSessionType() {
213
- return this.sessionType;
214
- }
215
- /**
216
- * Get the current base URL. This should rarely be anything other than 'https://api.verdocs.com'.
217
- */
218
- getBaseURL() {
219
- return this.baseURL;
220
- }
221
- /**
222
- * Get the current client ID, if set.
223
- */
224
- getClientID() {
225
- return this.clientID;
226
- }
227
- /**
228
- * Get the current timeout.
229
- */
230
- getTimeout() {
231
- return this.timeout;
232
- }
233
- /**
234
- * Get the current session, if any.
235
- */
236
- getSession() {
237
- return this.session;
238
- }
239
- /**
240
- * Set the operating environment. This should rarely be anything other than 'verdocs'.
241
- *
242
- * ```typescript
243
- * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
244
- *
245
- * const endpoint = new VerdocsEndpoint();
246
- * endpoint.setEnvironment('verdocs-stage');
247
- * ```
248
- */
249
- setEnvironment(environment) {
250
- this.environment = environment;
251
- return this;
252
- }
253
- /**
254
- * Set the session type. In general this should be done immediately when the endpoint is created. Changing the
255
- * session type may be done at any time, but may have unintended consequences if the endpoint is shared between
256
- * multiple widgets.
257
- *
258
- * Changing the session type will clear/reload the action session. This may trigger notifications to session state
259
- * observers. Apps that use observers to trigger UI updates such as logging the user out should be prepared to
260
- * handle this event.
261
- *
262
- * ```typescript
263
- * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
264
- *
265
- * const endpoint = new VerdocsEndpoint();
266
- * endpoint.setEnvironment('verdocs-stage');
267
- * ```
268
- */
269
- setSessionType(sessionType) {
270
- this.sessionType = sessionType;
271
- return this;
149
+ function timePeriod(type) {
150
+ let endDate = new Date().getTime();
151
+ const today = new Date();
152
+ const month = today.getMonth();
153
+ const year = today.getFullYear();
154
+ let startDate = null;
155
+ switch (type) {
156
+ case '30d':
157
+ startDate = endDate - 60 * 60 * 24 * 30 * 1000;
158
+ break;
159
+ case '60d':
160
+ startDate = endDate - 60 * 60 * 24 * 60 * 1000;
161
+ break;
162
+ case '6m':
163
+ startDate = endDate - 60 * 60 * 24 * 30 * 6 * 1000;
164
+ break;
165
+ case 'this_month':
166
+ startDate = new Date(year, month, 1).getTime();
167
+ break;
168
+ case 'last_month':
169
+ startDate = new Date(year, month - 1, 1).getTime();
170
+ endDate = new Date(year, month, 0).getTime();
171
+ break;
172
+ case 'this_year':
173
+ startDate = new Date(year, 0, 1);
174
+ break;
175
+ case 'all_time':
176
+ default:
177
+ return null;
272
178
  }
273
- /**
274
- * Set the base URL for API calls. Should be called only upon direction from Verdocs Customer Solutions Engineering.
275
- *
276
- * ```typescript
277
- * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
278
- *
279
- * const endpoint = new VerdocsEndpoint();
280
- * endpoint.setBaseURL('https://api.verdocs.com');
281
- * ```
282
- */
283
- setBaseURL(url) {
284
- this.baseURL = url;
285
- this.api.defaults.baseURL = url;
286
- return this;
179
+ if (startDate === null && endDate === null) {
180
+ return null;
287
181
  }
288
- /**
289
- * Set the Client ID for Verdocs API calls.
290
- *
291
- * ```typescript
292
- * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
293
- *
294
- * const endpoint = new VerdocsEndpoint();
295
- * endpoint.setClientID('1234);
296
- * ```
297
- */
298
- setClientID(clientID) {
299
- this.clientID = clientID;
300
- this.api.defaults.headers.common['X-Client-ID'] = clientID;
301
- return this;
182
+ return {
183
+ start_time: new Date(startDate).toISOString(),
184
+ end_time: new Date(endDate).toISOString(),
185
+ };
186
+ }
187
+
188
+ function getRTop(y, fieldHeight, iTextHeight, yRatio) {
189
+ return iTextHeight - (y + fieldHeight) * yRatio;
190
+ }
191
+ function getRLeft(x, ratio) {
192
+ return x * ratio;
193
+ }
194
+ function getRValue(y, ratio) {
195
+ return y * ratio;
196
+ }
197
+ function blobToBase64(image) {
198
+ const fileReader = new FileReader();
199
+ return new Promise((resolve, reject) => {
200
+ fileReader.onerror = () => {
201
+ reject(new DOMException('Problem reading blob.'));
202
+ };
203
+ fileReader.onload = () => {
204
+ resolve(fileReader.result);
205
+ };
206
+ fileReader.readAsDataURL(image);
207
+ });
208
+ }
209
+ function rescale(r, n) {
210
+ return r * n;
211
+ }
212
+
213
+ /**
214
+ * Given a File, extract the file's content as a base64 encoded data URL. The response will have a prefix that
215
+ * includes the MIME type of the file, e.g. "data:image/jpeg;base64,iVBORw0K......"
216
+ */
217
+ const fileToDataUrl = (file) => new Promise((resolve, reject) => {
218
+ const reader = new FileReader();
219
+ reader.onload = () => resolve({
220
+ lastModified: file.lastModified,
221
+ size: file.size,
222
+ type: file.type,
223
+ name: file.name,
224
+ data: reader.result,
225
+ });
226
+ reader.onerror = reject;
227
+ if (file) {
228
+ reader.readAsDataURL(file);
302
229
  }
303
- /**
304
- * Set the timeout for API calls in milliseconds. 5000-20000ms is recommended for most purposes. 15000ms is the default.
305
- * Note that some calls may involve rendering operations that require some time to complete, so very short timeouts
306
- * are not recommended.
307
- *
308
- * ```typescript
309
- * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
310
- *
311
- * const endpoint = new VerdocsEndpoint();
312
- * endpoint.setTimeout(3000);
313
- * ```
314
- */
315
- setTimeout(timeout) {
316
- this.timeout = timeout;
317
- this.api.defaults.timeout = timeout;
318
- return this;
230
+ else {
231
+ reject(new Error('Invalid file'));
319
232
  }
320
- /**
321
- * Enable or disable request logging. This may expose sensitive data in the console log, so it should only be used for debugging.
322
- *
323
- * ```typescript
324
- * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
325
- *
326
- * const endpoint = new VerdocsEndpoint();
327
- * endpoint.logRequests(true);
328
- * ```
329
- */
330
- logRequests(enable) {
331
- if (enable && this.requestLoggerId === null) {
332
- this.requestLoggerId = this.api.interceptors.request.use(requestLogger);
333
- }
334
- else if (!enable && this.requestLoggerId !== null) {
335
- this.api.interceptors.request.eject(this.requestLoggerId);
336
- }
337
- return this;
338
- }
339
- /**
340
- * Set the authorization token that will be used for Verdocs API calls. This will also set the session metadata
341
- * and notify any listeners of the new data.
342
- *
343
- * If this Endpoint will be used for non-default purposes (e.g. signing, or in an alternate environment) those
344
- * settings should be made before calling this. Sessions are persisted to localStorage, and the environment and
345
- * type become part of the storage key.
346
- *
347
- * ```typescript
348
- * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
349
- *
350
- * const endpoint = new VerdocsEndpoint();
351
- * endpoint.setToken(accessToken);
352
- * ```
353
- */
354
- setToken(token) {
355
- if (!token) {
356
- return this.clearSession();
357
- }
358
- const session = decodeAccessTokenBody(token);
359
- if (session === null || (session.exp && session.exp * 1000 < new Date().getTime())) {
360
- window.console.warn('[JS_SDK] Ignoring attempt to use expired session token');
361
- return this.clearSession();
362
- }
363
- this.token = token;
364
- this.session = session;
365
- if (this.sessionType === 'user') {
366
- this.api.defaults.headers.common.Authorization = `Bearer ${token}`;
367
- }
368
- else {
369
- this.api.defaults.headers.common.signer = `Bearer ${token}`;
370
- }
371
- localStorage.setItem(this.sessionStorageKey(), token);
372
- this.notifySessionListeners();
373
- return this;
374
- }
375
- /**
376
- * Retrieves the current session token, if any. Tokens should rarely be used for direct actions, but this is
377
- * required by the `<VerdocsView>` and other components to authorize requests to raw PDF files.
378
- */
379
- getToken() {
380
- return this.token;
381
- }
382
- sessionStorageKey() {
383
- return `verdocs-session-${this.getSessionType()}-${this.getEnvironment()}`;
384
- }
385
- /**
386
- * Clear the active session.
387
- */
388
- clearSession() {
389
- localStorage.removeItem(this.sessionStorageKey());
390
- delete this.api.defaults.headers.common.Authorization;
391
- delete this.api.defaults.headers.common.signer;
392
- this.session = null;
393
- this.token = null;
394
- this.notifySessionListeners();
395
- return this;
396
- }
397
- /**
398
- * Clear the active signing session.
399
- */
400
- clearSignerSession() {
401
- localStorage.removeItem(this.sessionStorageKey());
402
- delete this.api.defaults.headers.common.Authorization;
403
- this.session = null;
404
- this.token = null;
405
- this.notifySessionListeners();
406
- return this;
407
- }
408
- notifySessionListeners() {
409
- this.sessionListeners.forEach((listener) => {
410
- try {
411
- listener(this, this.session);
412
- }
413
- catch (e) {
414
- // NOOP
415
- }
416
- });
417
- }
418
- /**
419
- * Subscribe to session state change events.
420
- */
421
- onSessionChanged(listener) {
422
- // There's no value in randomizing this, a simple counter is fine
423
- this.nextListenerId++;
424
- const listenerSymbol = Symbol.for('' + this.nextListenerId);
425
- this.sessionListeners.set(listenerSymbol, listener);
426
- return () => {
427
- this.sessionListeners.delete(listenerSymbol);
428
- };
429
- }
430
- /**
431
- * Load a persisted session from localStorage. Typically called once after the endpoint is configured when the app
432
- * or component starts.
433
- */
434
- loadSession() {
435
- const token = localStorage.getItem(this.sessionStorageKey());
436
- if (!token) {
437
- return this.clearSession();
438
- }
439
- return this.setToken(token);
440
- }
441
- }
442
-
443
- /**
444
- * Given a `rgba(r,g,b,a)` string value, returns the hex equivalent, dropping the alpha channel.
445
- */
446
- function getRGB(rgba) {
447
- const rgbNumbers = rgba.replace('rgba(', '').replace(')', '').split(',');
448
- const rgbObject = {
449
- red: +rgbNumbers[0],
450
- green: +rgbNumbers[1],
451
- blue: +rgbNumbers[2],
452
- alpha: +rgbNumbers[3],
453
- };
454
- const alpha = 1 - rgbObject.alpha;
455
- const red = Math.round((rgbObject.alpha * (rgbObject.red / 255) + alpha) * 255);
456
- const green = Math.round((rgbObject.alpha * (rgbObject.green / 255) + alpha) * 255);
457
- const blue = Math.round((rgbObject.alpha * (rgbObject.blue / 255) + alpha) * 255);
458
- return '#' + rgbToHex(red) + rgbToHex(green) + rgbToHex(blue);
459
- }
460
- /**
461
- * Given an RGB string value, returns the hex equivalent.
462
- */
463
- function rgbToHex(rgb) {
464
- const hex = rgb.toString(16);
465
- if (hex.length < 2) {
466
- return '0' + hex;
467
- }
468
- return hex;
469
- }
470
- /**
471
- * Given a signer role index, return the color code for that signer.
472
- */
473
- function getRGBA(roleIndex) {
474
- switch (roleIndex % 10) {
475
- case 0:
476
- return roleIndex === 0 ? 'rgba(255, 193, 7, 0.4)' : 'rgba(134, 134, 134, 0.3)'; // #FFE69C
477
- case 1:
478
- return 'rgba(156, 39, 176, .4)'; // '#E3C3E9'
479
- case 2:
480
- return 'rgba(33, 150, 243, .4)'; // '#C1E1FB'
481
- case 3:
482
- return 'rgba(220, 231, 117, 0.3)';
483
- case 4:
484
- return 'rgba(121, 134, 203, 0.3)';
485
- case 5:
486
- return 'rgba(77, 182, 172, 0.3)';
487
- case 6:
488
- return 'rgba(255, 202, 165, 0.3)';
489
- case 7:
490
- return 'rgba(2, 247, 190, 0.3)';
491
- case 8:
492
- return 'rgba(255, 138, 101, 0.3)';
493
- case 9:
494
- return 'rgba(82, 255, 79, 0.3)';
495
- default:
496
- return 'rgba(229, 115, 155, 0.3)';
497
- }
498
- }
499
- /**
500
- * Given a role name, return a color code for it. This works by computing a hash code so the specific color returned
501
- * is not specified explicitly, but will be the same for every call with the same input value.
502
- */
503
- function nameToRGBA(str) {
504
- if (!!str) {
505
- const validNum = parseInt(str.slice(-1), 10);
506
- if (!isNaN(validNum)) {
507
- str += (validNum * 99).toString();
508
- }
509
- let hash = 0;
510
- for (let i = 0; i < str.length; i++) {
511
- // tslint:disable-next-line:no-bitwise
512
- hash = str.charCodeAt(i) + ((hash << 5) - hash);
513
- }
514
- hash = Math.round(hash / 1.3);
515
- // tslint:disable-next-line:no-bitwise
516
- const c = (hash & 0x00ffff08).toString(16).toUpperCase();
517
- const hex = '#' + '00000'.substring(0, 6 - c.length) + c;
518
- const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
519
- const color = {
520
- r: parseInt(result[1], 16),
521
- g: parseInt(result[2], 16),
522
- b: parseInt(result[3], 16),
523
- };
524
- return `rgba(${color.r}, ${color.g}, ${color.b}, 0.2)`;
525
- }
526
- }
233
+ });
527
234
  /**
528
- * Helper function to obtain a color code given a role name given various possible inputs.
235
+ * Trigger a download dialog to save a blob as a file on disk.
529
236
  */
530
- function getRoleColor(name, roles, index) {
531
- if (index) {
532
- return getRGBA(index);
533
- }
534
- else if (roles && roles.length > 0) {
535
- const roleIndex = roles.findIndex((role) => role === name);
536
- if (roleIndex > -1) {
537
- return getRGBA(roleIndex);
538
- }
539
- else {
540
- return nameToRGBA(name);
541
- }
542
- }
543
- else {
544
- return nameToRGBA(name);
545
- }
546
- }
547
-
548
- const YEAR = 365 * 24 * 60 * 60;
549
- // const MONTH = 30 * 24 * 60 * 60;
550
- const WEEK = 7 * 24 * 60 * 60;
551
- const DAY = 24 * 60 * 60;
552
- const HOUR = 60 * 60;
553
- const MINUTE = 60;
554
- const formatShortTimeAgo = (val) => {
555
- if (val === undefined || val === null) {
556
- return '';
557
- }
558
- let dateInput;
559
- if (typeof val === 'string' || typeof val === 'number') {
560
- dateInput = new Date(val);
561
- }
562
- else if (typeof val === 'object') {
563
- dateInput = val;
564
- }
565
- else {
566
- return '';
567
- }
568
- const timeDiff = Math.floor((new Date().getTime() - dateInput.getTime()) / 1000);
569
- if (timeDiff >= YEAR) {
570
- return Math.floor(timeDiff / YEAR) + 'Y';
571
- }
572
- // if (timeDiff >= MONTH) {
573
- // return Math.floor(timeDiff / MONTH) + 'M';
574
- // }
575
- if (timeDiff >= WEEK) {
576
- return Math.floor(timeDiff / WEEK) + 'W';
577
- }
578
- if (timeDiff >= DAY) {
579
- return Math.floor(timeDiff / DAY) + 'D';
580
- }
581
- if (timeDiff >= HOUR) {
582
- return Math.floor(timeDiff / HOUR) + 'H';
583
- }
584
- if (timeDiff >= MINUTE) {
585
- return Math.floor(timeDiff / MINUTE) + 'M';
586
- }
587
- return `${timeDiff}S`;
588
- };
589
- function timePeriod(type) {
590
- let endDate = new Date().getTime();
591
- const today = new Date();
592
- const month = today.getMonth();
593
- const year = today.getFullYear();
594
- let startDate = null;
595
- switch (type) {
596
- case '30d':
597
- startDate = endDate - 60 * 60 * 24 * 30 * 1000;
598
- break;
599
- case '60d':
600
- startDate = endDate - 60 * 60 * 24 * 60 * 1000;
601
- break;
602
- case '6m':
603
- startDate = endDate - 60 * 60 * 24 * 30 * 6 * 1000;
604
- break;
605
- case 'this_month':
606
- startDate = new Date(year, month, 1).getTime();
607
- break;
608
- case 'last_month':
609
- startDate = new Date(year, month - 1, 1).getTime();
610
- endDate = new Date(year, month, 0).getTime();
611
- break;
612
- case 'this_year':
613
- startDate = new Date(year, 0, 1);
614
- break;
615
- case 'all_time':
616
- default:
617
- return null;
618
- }
619
- if (startDate === null && endDate === null) {
620
- return null;
621
- }
622
- return {
623
- start_time: new Date(startDate).toISOString(),
624
- end_time: new Date(endDate).toISOString(),
625
- };
626
- }
627
-
628
- function getRTop(y, fieldHeight, iTextHeight, yRatio) {
629
- return iTextHeight - (y + fieldHeight) * yRatio;
630
- }
631
- function getRLeft(x, ratio) {
632
- return x * ratio;
633
- }
634
- function getRValue(y, ratio) {
635
- return y * ratio;
636
- }
637
- function blobToBase64(image) {
638
- const fileReader = new FileReader();
639
- return new Promise((resolve, reject) => {
640
- fileReader.onerror = () => {
641
- reject(new DOMException('Problem reading blob.'));
642
- };
643
- fileReader.onload = () => {
644
- resolve(fileReader.result);
645
- };
646
- fileReader.readAsDataURL(image);
647
- });
648
- }
649
- function rescale(r, n) {
650
- return r * n;
651
- }
652
-
653
- /**
654
- * Given a File, extract the file's content as a base64 encoded data URL. The response will have a prefix that
655
- * includes the MIME type of the file, e.g. "data:image/jpeg;base64,iVBORw0K......"
656
- */
657
- const fileToDataUrl = (file) => new Promise((resolve, reject) => {
658
- const reader = new FileReader();
659
- reader.onload = () => resolve({
660
- lastModified: file.lastModified,
661
- size: file.size,
662
- type: file.type,
663
- name: file.name,
664
- data: reader.result,
665
- });
666
- reader.onerror = reject;
667
- if (file) {
668
- reader.readAsDataURL(file);
669
- }
670
- else {
671
- reject(new Error('Invalid file'));
672
- }
673
- });
674
- /**
675
- * Trigger a download dialog to save a blob as a file on disk.
676
- */
677
- const downloadBlob = (blob, name = 'file.pdf') => {
678
- const blobUrl = URL.createObjectURL(blob);
679
- const link = document.createElement('a');
680
- link.href = blobUrl;
681
- link.download = name;
682
- document.body.appendChild(link);
683
- link.dispatchEvent(new MouseEvent('click', {
684
- bubbles: true,
685
- cancelable: true,
686
- view: window,
687
- }));
688
- document.body.removeChild(link);
689
- };
237
+ const downloadBlob = (blob, name = 'file.pdf') => {
238
+ const blobUrl = URL.createObjectURL(blob);
239
+ const link = document.createElement('a');
240
+ link.href = blobUrl;
241
+ link.download = name;
242
+ document.body.appendChild(link);
243
+ link.dispatchEvent(new MouseEvent('click', {
244
+ bubbles: true,
245
+ cancelable: true,
246
+ view: window,
247
+ }));
248
+ document.body.removeChild(link);
249
+ };
690
250
 
691
251
  const Countries = [
692
252
  { code: '+7 840', name: 'Abkhazia', value: '+7' },
@@ -933,179 +493,644 @@ function getCountryByCode(code) {
933
493
  if (isFrenchGuiana(code)) {
934
494
  return { code: '+594', name: 'French Guiana', value: '+594' };
935
495
  }
936
- else if (isGuadeloupe(code)) {
937
- return { code: '+590', name: 'Guadeloupe', value: '+590' };
496
+ else if (isGuadeloupe(code)) {
497
+ return { code: '+590', name: 'Guadeloupe', value: '+590' };
498
+ }
499
+ else if (isMartinique(code)) {
500
+ return { code: '+596', name: 'Martinique', value: '+596' };
501
+ }
502
+ else if (isMayotte(code)) {
503
+ return { code: '+262', name: 'Mayotte or Réunion', value: '+262' };
504
+ }
505
+ return null;
506
+ }
507
+ function isFrenchGuiana(code) {
508
+ return '+594' === code.substring(0, 4);
509
+ }
510
+ function isGuadeloupe(code) {
511
+ return '+590' === code.substring(0, 4);
512
+ }
513
+ function isMartinique(code) {
514
+ return '+596' === code.substring(0, 4);
515
+ }
516
+ function isMayotte(code) {
517
+ return '+262' === code.substring(0, 4);
518
+ }
519
+ function getPlusOneCountry(code) {
520
+ let info = null;
521
+ switch (code.substring(0, 5)) {
522
+ case '+1684':
523
+ info = { code: '+1', name: 'American Samoa', value: '+1' };
524
+ break;
525
+ case '+1264':
526
+ info = { code: '+1', name: 'Anguilla', value: '+1' };
527
+ break;
528
+ case '+1268':
529
+ info = { code: '+1', name: 'Antigua and Barbuda', value: '+1' };
530
+ break;
531
+ case '+1242':
532
+ info = { code: '+1', name: 'Bahamas', value: '+1' };
533
+ break;
534
+ case '+1246':
535
+ info = { code: '+1', name: 'Barbados', value: '+1' };
536
+ break;
537
+ case '+1441':
538
+ info = { code: '+1', name: 'Bermuda', value: '+1' };
539
+ break;
540
+ case '+1284':
541
+ info = { code: '+1', name: 'British Virgin Islands', value: '+1' };
542
+ break;
543
+ case '+1':
544
+ info = { code: '+1', name: '', value: '+1' };
545
+ break;
546
+ }
547
+ return info;
548
+ }
549
+ function isCanada(code) {
550
+ const canadianAreaCodes = [
551
+ '403',
552
+ '587',
553
+ '780',
554
+ '825',
555
+ '604',
556
+ '250',
557
+ '778',
558
+ '236',
559
+ '204',
560
+ '431',
561
+ '506',
562
+ '709',
563
+ '867',
564
+ '782',
565
+ '902',
566
+ '867',
567
+ '548',
568
+ '705',
569
+ '365',
570
+ '613',
571
+ '807',
572
+ '226',
573
+ '289',
574
+ '437',
575
+ '519',
576
+ '647',
577
+ '905',
578
+ '249',
579
+ '343',
580
+ '416',
581
+ '902',
582
+ '782',
583
+ '450',
584
+ '418',
585
+ '579',
586
+ '873',
587
+ '367',
588
+ '514',
589
+ '581',
590
+ '819',
591
+ '438',
592
+ '639',
593
+ '306',
594
+ '867',
595
+ ];
596
+ const areaCode = code.substring(0, 5);
597
+ return canadianAreaCodes.findIndex((x) => '+1' + x === areaCode) > -1;
598
+ }
599
+ function isAmericanSamoa(code) {
600
+ return code.substring(0, 5) === '+1684';
601
+ }
602
+ function isDominicanRepublic(code) {
603
+ return '+1809' === code.substring(0, 5) || '+1829' === code.substring(0, 5) || '+1849' === code.substring(0, 5);
604
+ }
605
+ function isPuertoRico(code) {
606
+ return code.substring(0, 5) === '+' || code.substring(0, 5) === '+';
607
+ }
608
+ // need to finish
609
+ function getMatchingCountry(code, substrings) {
610
+ const toMatch = code.substring(0, substrings);
611
+ return Countries.filter((c) => c.code === toMatch).length;
612
+ }
613
+ // const e164Regex = new RegExp(/\+[1-9]\d{6,14}/g);
614
+ // export function simpleE164Validator(code: string) {
615
+ // return (code !== null && code.length < 16 && code.length > 6 && e164Regex.test(code)) || code === '' || code === null;
616
+ // }
617
+
618
+ /**
619
+ * Capitalize the first letter of a string.
620
+ */
621
+ const capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1);
622
+ /**
623
+ * Convert a phone-number-like string to E164 format.
624
+ * @see https://46elks.com/kb/e164
625
+ */
626
+ const convertToE164 = (input) => {
627
+ // "(212) 555-1212" => +12125551212
628
+ // "+46766861004" => "+46766861004"
629
+ // "212-555-1212" => +12125551212
630
+ // "212.555.1212" => +12125551212
631
+ // "212 555 1212" => +12125551212
632
+ let temp = (input || '').trim();
633
+ // If we are already prefixed, assume the user did it deliberately and attempt to use what they entered. We also short-circuit blanks.
634
+ if (!temp || temp.startsWith('+')) {
635
+ return temp;
636
+ }
637
+ // Remove any spaces, parenthesis or other punctuation.
638
+ temp = temp.replace(/[^0-9]/g, '');
639
+ // If the number begins with a zero, remove the leading zero. Do not combine this with the previous step because it needs to be removed
640
+ // whether it's the actual first character e.g. `0(5)` or just the first digit e.g. `(05`.
641
+ temp = temp.replace(/^0/g, '');
642
+ // Prepend the country code and +. We're assuming US in this case given the target demographic. Users in other countries would/should be
643
+ // already entering a prefix so they'd shortcut out of this routine via the + prefix check.
644
+ return `+1${temp}`;
645
+ };
646
+
647
+ /**
648
+ * Create an array containing a sequence of integers, e.g. [START, START+1, START+2, ...] This is frequently useful
649
+ * in rendering operations when there is no source array to .map() across.
650
+ */
651
+ const integerSequence = (start, count) => Array(count)
652
+ .fill(1)
653
+ .map((_, index) => index + start);
654
+ /**
655
+ * Format a profile's full name
656
+ */
657
+ const formatFullName = (profile) => profile ? `${capitalize(profile.first_name)} ${capitalize(profile.last_name)}` : 'Invalid User';
658
+ /**
659
+ * Format a profile's initials
660
+ */
661
+ const formatInitials = (profile) => profile ? `${capitalize(profile.first_name).charAt(0)} ${capitalize(profile.last_name).charAt(0)}` : '--';
662
+ /**
663
+ * Generate suggested initials for a full name, e.g. "John Doe" will yield "JD".
664
+ */
665
+ const fullNameToInitials = (name) => name
666
+ .split(' ')
667
+ .map((word) => word[0])
668
+ .join('');
669
+
670
+ /* tslint:disable:no-bitwise */
671
+ const b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
672
+ // Regular expression to check formal correctness of base64 encoded strings
673
+ const b64re = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/;
674
+ /**
675
+ * Simplified, Node/Browser-safe alternative to atob() for base64 decoding.
676
+ * Modified from https://github.com/MaxArt2501/base64-js/blob/master/base64.js
677
+ */
678
+ const AtoB = (str) => {
679
+ // atob can work with strings with whitespaces, even inside the encoded part,
680
+ // but only \t, \n, \f, \r and ' ', which can be stripped.
681
+ str = String(str).replace(/[\t\n\f\r ]+/g, '');
682
+ if (!b64re.test(str))
683
+ throw new TypeError("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");
684
+ // Adding the padding if missing, for semplicity
685
+ str += '=='.slice(2 - (str.length & 3));
686
+ let bitmap;
687
+ let result = '';
688
+ let r1;
689
+ let r2;
690
+ let i = 0;
691
+ for (; i < str.length;) {
692
+ bitmap =
693
+ (b64.indexOf(str.charAt(i++)) << 18) |
694
+ (b64.indexOf(str.charAt(i++)) << 12) |
695
+ ((r1 = b64.indexOf(str.charAt(i++))) << 6) |
696
+ (r2 = b64.indexOf(str.charAt(i++)));
697
+ result +=
698
+ r1 === 64
699
+ ? String.fromCharCode((bitmap >> 16) & 255)
700
+ : r2 === 64
701
+ ? String.fromCharCode((bitmap >> 16) & 255, (bitmap >> 8) & 255)
702
+ : String.fromCharCode((bitmap >> 16) & 255, (bitmap >> 8) & 255, bitmap & 255);
703
+ }
704
+ return result;
705
+ };
706
+ /**
707
+ * Decode the body of a JWT. This helper may allow front-end applications to avoid a dependency on `jsonwebtoken` in
708
+ * many cases. Note that this should only be used for true JWTs. Opaque tokens will cause this to throw.
709
+ */
710
+ const decodeJWTBody = (token) => JSON.parse(AtoB((token || '').split('.')[1] || ''));
711
+ /**
712
+ * Decode the body of an Verdocs access token. Note that raw tokens contain namespaced fields, e.g.
713
+ * `https://verdocs.com/profile_id`. To make these tokens easier to use in front-end code, this name-spacing
714
+ * will be removed. Note that user and signing sessions have different access token formats. The calling
715
+ * application should distinguish between the two based on the context of the authenticated session, or by
716
+ * the presence of the `document_id` field, which will only be present for signing sessions.
717
+ */
718
+ const decodeAccessTokenBody = (token) => {
719
+ let decoded;
720
+ try {
721
+ decoded = decodeJWTBody(token);
722
+ if (decoded === null) {
723
+ return null;
724
+ }
725
+ }
726
+ catch (e) {
727
+ return null;
728
+ }
729
+ Object.keys(decoded).forEach((key) => {
730
+ if (typeof key === 'string' && key.startsWith('https://verdocs.com/')) {
731
+ decoded[key.replace('https://verdocs.com/', '')] = decoded[key];
732
+ delete decoded[key];
733
+ }
734
+ });
735
+ return decoded;
736
+ };
737
+
738
+ function getDefaultExportFromCjs (x) {
739
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
740
+ }
741
+
742
+ // This file provides a polyfill for managing globals in both NodeJS and browser environments. This is
743
+ // an anti-pattern we'd hoped to avoid, but we have several projects dependending on one common library
744
+ // (this js-sdk) and we want that library to provide a common endpoint to all callers (so authentication
745
+ // tokens only need to be tracked in one place). The trouble is, one of those libraries is based on
746
+ // StencilJS and is compiling its modules into Web Components. Because of how module resolution works,
747
+ // when those Components load js-sdk they get a separate instance. Without messy options like having to
748
+ // pass raw data from the caller to each Component, or pass around references to a common Endpoint, they
749
+ // have no way to access authenticated sessions unless we make the Endpoint a true global.
750
+ //
751
+ // @credit https://github.com/medikoo/es5-ext/blob/master/global.js
752
+ // @credit https://mathiasbynens.be/notes/globalthis
753
+ var naiveFallback = function () {
754
+ if (typeof self === 'object' && self)
755
+ return self;
756
+ if (typeof window === 'object' && window)
757
+ return window;
758
+ throw new Error('Unable to resolve global `this`');
759
+ };
760
+ var globalThis_1 = (function () {
761
+ if (this)
762
+ return this;
763
+ // Unexpected strict mode (may happen if e.g. bundled into ESM module)
764
+ // Fallback to standard globalThis if available
765
+ if (typeof globalThis === 'object' && globalThis)
766
+ return globalThis;
767
+ // Thanks @mathiasbynens -> https://mathiasbynens.be/notes/globalthis
768
+ // In all ES5+ engines global object inherits from Object.prototype
769
+ // (if you approached one that doesn't please report)
770
+ try {
771
+ Object.defineProperty(Object.prototype, '__global__', {
772
+ get: function () {
773
+ return this;
774
+ },
775
+ configurable: true,
776
+ });
777
+ }
778
+ catch (error) {
779
+ // Unfortunate case of updates to Object.prototype being restricted
780
+ // via preventExtensions, seal or freeze
781
+ return naiveFallback();
782
+ }
783
+ try {
784
+ // Safari case (window.__global__ works, but __global__ does not)
785
+ if (!__global__)
786
+ return naiveFallback();
787
+ return __global__;
788
+ }
789
+ finally {
790
+ delete Object.prototype.__global__;
791
+ }
792
+ })();
793
+
794
+ var globalThis$1 = /*@__PURE__*/getDefaultExportFromCjs(globalThis_1);
795
+
796
+ // @credit https://derickbailey.com/2016/03/09/creating-a-true-singleton-in-node-js-with-es6-symbols/
797
+ // Also see globalThis for comments about why we're doing this in the first place.
798
+ const ENDPOINT_KEY = Symbol.for('vƒbaseerdocs-default-endpoint');
799
+ const requestLogger = (r) => {
800
+ // tslint:disable-next-line
801
+ console.debug(`[JS-SDK] ${r.method.toUpperCase()} ${r.baseURL}${r.url}`, r.data ? JSON.stringify(r.data) : '');
802
+ return r;
803
+ };
804
+ /**
805
+ * VerdocsEndpoint is a class wrapper for a specific connection and authorization context for calling the Verdocs APIs.
806
+ * Endpoints can be used for isolated session tasks.
807
+ *
808
+ * For instance, ephemeral signing sessions may be created independently of a caller's status as an authenticated user.
809
+ * In that case, an Endpoint can be created and authenticated, used for calls related to signing operations, then
810
+ * discarded once signing is complete.
811
+ *
812
+ * Note that endpoint configuration functions return the instance, so they can be chained, e.g.
813
+ *
814
+ * ```typescript
815
+ * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
816
+ *
817
+ * const endpoint = new VerdocsEndpoint();
818
+ * endpoint
819
+ * .setSessionType('signing')
820
+ * .logRequests(true)
821
+ * .setClientID('1234)
822
+ * .setTimeout(30000);
823
+ * ```
824
+ */
825
+ class VerdocsEndpoint {
826
+ environment = 'verdocs';
827
+ sessionType = 'user';
828
+ baseURL = (window.location.origin === 'https://beta.verdocs.com' || window.location.origin === 'https://stage.verdocs.com'
829
+ ? 'https://stage-api.verdocs.com'
830
+ : 'https://api.verdocs.com');
831
+ baseURLv2 = (window.location.origin === 'https://beta.verdocs.com' || window.location.origin === 'https://stage.verdocs.com'
832
+ ? 'https://stage-api.verdocs.com/v2'
833
+ : 'https://api.verdocs.com/v2');
834
+ clientID = 'not-set';
835
+ timeout = 60000;
836
+ token = null;
837
+ nextListenerId = 0;
838
+ sessionListeners = new Map();
839
+ requestLoggerId = null;
840
+ /**
841
+ * The current user session, or null if not authenticated. May be either a User or Signing session. If set, the
842
+ * presence of the `document_id` field can be used to differentiate the types. Only signing sessions are associated
843
+ * with Envelopes.
844
+ */
845
+ session = null;
846
+ api;
847
+ /**
848
+ * Create a new VerdocsEndpoint to call Verdocs platform services.
849
+ *
850
+ * ```typescript
851
+ * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
852
+ * const endpoint = new VerdocsEndpoint();
853
+ * ```
854
+ */
855
+ constructor(options) {
856
+ this.baseURL = options?.baseURL || this.baseURL;
857
+ this.timeout = options?.timeout || this.timeout;
858
+ this.environment = options?.environment || this.environment;
859
+ this.sessionType = options?.sessionType || this.sessionType;
860
+ this.clientID = options?.clientID || this.clientID;
861
+ this.api = axios.create({ baseURL: this.baseURL, timeout: this.timeout });
862
+ }
863
+ setDefault() {
864
+ globalThis$1[ENDPOINT_KEY] = this;
865
+ }
866
+ static getDefault() {
867
+ if (!globalThis$1[ENDPOINT_KEY]) {
868
+ globalThis$1[ENDPOINT_KEY] = new VerdocsEndpoint();
869
+ window.console.debug('[JS_SDK] Created default endpoint', globalThis$1[ENDPOINT_KEY].baseURL);
870
+ }
871
+ return globalThis$1[ENDPOINT_KEY];
872
+ }
873
+ /**
874
+ * Get the current environment.
875
+ */
876
+ getEnvironment() {
877
+ return this.environment;
878
+ }
879
+ /**
880
+ * Get the current session type.
881
+ */
882
+ getSessionType() {
883
+ return this.sessionType;
884
+ }
885
+ /**
886
+ * Get the current base URL. This should rarely be anything other than 'https://api.verdocs.com'.
887
+ */
888
+ getBaseURL() {
889
+ return this.baseURL;
890
+ }
891
+ /**
892
+ * Get the current base URL for the v2 APIs.
893
+ * This should rarely be anything other than 'https://api-v2.verdocs.com'.
894
+ */
895
+ getBaseURLv2() {
896
+ return this.baseURLv2;
897
+ }
898
+ /**
899
+ * Get the current client ID, if set.
900
+ */
901
+ getClientID() {
902
+ return this.clientID;
903
+ }
904
+ /**
905
+ * Get the current timeout.
906
+ */
907
+ getTimeout() {
908
+ return this.timeout;
909
+ }
910
+ /**
911
+ * Get the current session, if any.
912
+ */
913
+ getSession() {
914
+ return this.session;
915
+ }
916
+ /**
917
+ * Set the operating environment. This should rarely be anything other than 'verdocs'.
918
+ *
919
+ * ```typescript
920
+ * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
921
+ *
922
+ * const endpoint = new VerdocsEndpoint();
923
+ * endpoint.setEnvironment('verdocs-stage');
924
+ * ```
925
+ */
926
+ setEnvironment(environment) {
927
+ this.environment = environment;
928
+ return this;
929
+ }
930
+ /**
931
+ * Set the session type. In general this should be done immediately when the endpoint is created. Changing the
932
+ * session type may be done at any time, but may have unintended consequences if the endpoint is shared between
933
+ * multiple widgets.
934
+ *
935
+ * Changing the session type will clear/reload the action session. This may trigger notifications to session state
936
+ * observers. Apps that use observers to trigger UI updates such as logging the user out should be prepared to
937
+ * handle this event.
938
+ *
939
+ * ```typescript
940
+ * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
941
+ *
942
+ * const endpoint = new VerdocsEndpoint();
943
+ * endpoint.setEnvironment('verdocs-stage');
944
+ * ```
945
+ */
946
+ setSessionType(sessionType) {
947
+ this.sessionType = sessionType;
948
+ return this;
949
+ }
950
+ /**
951
+ * Set the base URL for API calls. Should be called only upon direction from Verdocs Customer Solutions Engineering.
952
+ *
953
+ * ```typescript
954
+ * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
955
+ *
956
+ * const endpoint = new VerdocsEndpoint();
957
+ * endpoint.setBaseURL('https://api.verdocs.com');
958
+ * ```
959
+ */
960
+ setBaseURL(url) {
961
+ this.baseURL = url;
962
+ this.api.defaults.baseURL = url;
963
+ return this;
964
+ }
965
+ /**
966
+ * Set the base URL for API calls. Should be called only upon direction from Verdocs Customer Solutions Engineering.
967
+ *
968
+ * ```typescript
969
+ * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
970
+ *
971
+ * const endpoint = new VerdocsEndpoint();
972
+ * endpoint.setBaseURL('https://api.verdocs.com');
973
+ * ```
974
+ */
975
+ setBaseURLv2(url) {
976
+ this.baseURLv2 = url;
977
+ // NOTE: We do not set this on the Axios instance because v1 is still the standard.
978
+ return this;
979
+ }
980
+ /**
981
+ * Set the Client ID for Verdocs API calls.
982
+ *
983
+ * ```typescript
984
+ * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
985
+ *
986
+ * const endpoint = new VerdocsEndpoint();
987
+ * endpoint.setClientID('1234);
988
+ * ```
989
+ */
990
+ setClientID(clientID) {
991
+ this.clientID = clientID;
992
+ this.api.defaults.headers.common['X-Client-ID'] = clientID;
993
+ return this;
994
+ }
995
+ /**
996
+ * Set the timeout for API calls in milliseconds. 5000-20000ms is recommended for most purposes. 15000ms is the default.
997
+ * Note that some calls may involve rendering operations that require some time to complete, so very short timeouts
998
+ * are not recommended.
999
+ *
1000
+ * ```typescript
1001
+ * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
1002
+ *
1003
+ * const endpoint = new VerdocsEndpoint();
1004
+ * endpoint.setTimeout(3000);
1005
+ * ```
1006
+ */
1007
+ setTimeout(timeout) {
1008
+ this.timeout = timeout;
1009
+ this.api.defaults.timeout = timeout;
1010
+ return this;
1011
+ }
1012
+ /**
1013
+ * Enable or disable request logging. This may expose sensitive data in the console log, so it should only be used for debugging.
1014
+ *
1015
+ * ```typescript
1016
+ * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
1017
+ *
1018
+ * const endpoint = new VerdocsEndpoint();
1019
+ * endpoint.logRequests(true);
1020
+ * ```
1021
+ */
1022
+ logRequests(enable) {
1023
+ if (enable && this.requestLoggerId === null) {
1024
+ this.requestLoggerId = this.api.interceptors.request.use(requestLogger);
1025
+ }
1026
+ else if (!enable && this.requestLoggerId !== null) {
1027
+ this.api.interceptors.request.eject(this.requestLoggerId);
1028
+ }
1029
+ return this;
1030
+ }
1031
+ /**
1032
+ * Set the authorization token that will be used for Verdocs API calls. This will also set the session metadata
1033
+ * and notify any listeners of the new data.
1034
+ *
1035
+ * If this Endpoint will be used for non-default purposes (e.g. signing, or in an alternate environment) those
1036
+ * settings should be made before calling this. Sessions are persisted to localStorage, and the environment and
1037
+ * type become part of the storage key.
1038
+ *
1039
+ * ```typescript
1040
+ * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
1041
+ *
1042
+ * const endpoint = new VerdocsEndpoint();
1043
+ * endpoint.setToken(accessToken);
1044
+ * ```
1045
+ */
1046
+ setToken(token) {
1047
+ if (!token) {
1048
+ return this.clearSession();
1049
+ }
1050
+ const session = decodeAccessTokenBody(token);
1051
+ if (session === null || (session.exp && session.exp * 1000 < new Date().getTime())) {
1052
+ window.console.warn('[JS_SDK] Ignoring attempt to use expired session token');
1053
+ return this.clearSession();
1054
+ }
1055
+ this.token = token;
1056
+ this.session = session;
1057
+ if (this.sessionType === 'user') {
1058
+ this.api.defaults.headers.common.Authorization = `Bearer ${token}`;
1059
+ }
1060
+ else {
1061
+ this.api.defaults.headers.common.signer = `Bearer ${token}`;
1062
+ }
1063
+ localStorage.setItem(this.sessionStorageKey(), token);
1064
+ this.notifySessionListeners();
1065
+ return this;
1066
+ }
1067
+ /**
1068
+ * Retrieves the current session token, if any. Tokens should rarely be used for direct actions, but this is
1069
+ * required by the `<VerdocsView>` and other components to authorize requests to raw PDF files.
1070
+ */
1071
+ getToken() {
1072
+ return this.token;
938
1073
  }
939
- else if (isMartinique(code)) {
940
- return { code: '+596', name: 'Martinique', value: '+596' };
1074
+ sessionStorageKey() {
1075
+ return `verdocs-session-${this.getSessionType()}-${this.getEnvironment()}`;
941
1076
  }
942
- else if (isMayotte(code)) {
943
- return { code: '+262', name: 'Mayotte or Réunion', value: '+262' };
1077
+ /**
1078
+ * Clear the active session.
1079
+ */
1080
+ clearSession() {
1081
+ localStorage.removeItem(this.sessionStorageKey());
1082
+ delete this.api.defaults.headers.common.Authorization;
1083
+ delete this.api.defaults.headers.common.signer;
1084
+ this.session = null;
1085
+ this.token = null;
1086
+ this.notifySessionListeners();
1087
+ return this;
944
1088
  }
945
- return null;
946
- }
947
- function isFrenchGuiana(code) {
948
- return '+594' === code.substring(0, 4);
949
- }
950
- function isGuadeloupe(code) {
951
- return '+590' === code.substring(0, 4);
952
- }
953
- function isMartinique(code) {
954
- return '+596' === code.substring(0, 4);
955
- }
956
- function isMayotte(code) {
957
- return '+262' === code.substring(0, 4);
958
- }
959
- function getPlusOneCountry(code) {
960
- let info = null;
961
- switch (code.substring(0, 5)) {
962
- case '+1684':
963
- info = { code: '+1', name: 'American Samoa', value: '+1' };
964
- break;
965
- case '+1264':
966
- info = { code: '+1', name: 'Anguilla', value: '+1' };
967
- break;
968
- case '+1268':
969
- info = { code: '+1', name: 'Antigua and Barbuda', value: '+1' };
970
- break;
971
- case '+1242':
972
- info = { code: '+1', name: 'Bahamas', value: '+1' };
973
- break;
974
- case '+1246':
975
- info = { code: '+1', name: 'Barbados', value: '+1' };
976
- break;
977
- case '+1441':
978
- info = { code: '+1', name: 'Bermuda', value: '+1' };
979
- break;
980
- case '+1284':
981
- info = { code: '+1', name: 'British Virgin Islands', value: '+1' };
982
- break;
983
- case '+1':
984
- info = { code: '+1', name: '', value: '+1' };
985
- break;
1089
+ /**
1090
+ * Clear the active signing session.
1091
+ */
1092
+ clearSignerSession() {
1093
+ localStorage.removeItem(this.sessionStorageKey());
1094
+ delete this.api.defaults.headers.common.Authorization;
1095
+ this.session = null;
1096
+ this.token = null;
1097
+ this.notifySessionListeners();
1098
+ return this;
986
1099
  }
987
- return info;
988
- }
989
- function isCanada(code) {
990
- const canadianAreaCodes = [
991
- '403',
992
- '587',
993
- '780',
994
- '825',
995
- '604',
996
- '250',
997
- '778',
998
- '236',
999
- '204',
1000
- '431',
1001
- '506',
1002
- '709',
1003
- '867',
1004
- '782',
1005
- '902',
1006
- '867',
1007
- '548',
1008
- '705',
1009
- '365',
1010
- '613',
1011
- '807',
1012
- '226',
1013
- '289',
1014
- '437',
1015
- '519',
1016
- '647',
1017
- '905',
1018
- '249',
1019
- '343',
1020
- '416',
1021
- '902',
1022
- '782',
1023
- '450',
1024
- '418',
1025
- '579',
1026
- '873',
1027
- '367',
1028
- '514',
1029
- '581',
1030
- '819',
1031
- '438',
1032
- '639',
1033
- '306',
1034
- '867',
1035
- ];
1036
- const areaCode = code.substring(0, 5);
1037
- return canadianAreaCodes.findIndex((x) => '+1' + x === areaCode) > -1;
1038
- }
1039
- function isAmericanSamoa(code) {
1040
- return code.substring(0, 5) === '+1684';
1041
- }
1042
- function isDominicanRepublic(code) {
1043
- return '+1809' === code.substring(0, 5) || '+1829' === code.substring(0, 5) || '+1849' === code.substring(0, 5);
1044
- }
1045
- function isPuertoRico(code) {
1046
- return code.substring(0, 5) === '+' || code.substring(0, 5) === '+';
1047
- }
1048
- // need to finish
1049
- function getMatchingCountry(code, substrings) {
1050
- const toMatch = code.substring(0, substrings);
1051
- return Countries.filter((c) => c.code === toMatch).length;
1052
- }
1053
- // const e164Regex = new RegExp(/\+[1-9]\d{6,14}/g);
1054
- // export function simpleE164Validator(code: string) {
1055
- // return (code !== null && code.length < 16 && code.length > 6 && e164Regex.test(code)) || code === '' || code === null;
1056
- // }
1057
-
1058
- /**
1059
- * Capitalize the first letter of a string.
1060
- */
1061
- const capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1);
1062
- /**
1063
- * Convert a phone-number-like string to E164 format.
1064
- * @see https://46elks.com/kb/e164
1065
- */
1066
- const convertToE164 = (input) => {
1067
- // "(212) 555-1212" => +12125551212
1068
- // "+46766861004" => "+46766861004"
1069
- // "212-555-1212" => +12125551212
1070
- // "212.555.1212" => +12125551212
1071
- // "212 555 1212" => +12125551212
1072
- let temp = (input || '').trim();
1073
- // If we are already prefixed, assume the user did it deliberately and attempt to use what they entered. We also short-circuit blanks.
1074
- if (!temp || temp.startsWith('+')) {
1075
- return temp;
1100
+ notifySessionListeners() {
1101
+ this.sessionListeners.forEach((listener) => {
1102
+ try {
1103
+ listener(this, this.session);
1104
+ }
1105
+ catch (e) {
1106
+ // NOOP
1107
+ }
1108
+ });
1076
1109
  }
1077
- // Remove any spaces, parenthesis or other punctuation.
1078
- temp = temp.replace(/[^0-9]/g, '');
1079
- // If the number begins with a zero, remove the leading zero. Do not combine this with the previous step because it needs to be removed
1080
- // whether it's the actual first character e.g. `0(5)` or just the first digit e.g. `(05`.
1081
- temp = temp.replace(/^0/g, '');
1082
- // Prepend the country code and +. We're assuming US in this case given the target demographic. Users in other countries would/should be
1083
- // already entering a prefix so they'd shortcut out of this routine via the + prefix check.
1084
- return `+1${temp}`;
1085
- };
1086
-
1087
- /**
1088
- * Create an array containing a sequence of integers, e.g. [START, START+1, START+2, ...] This is frequently useful
1089
- * in rendering operations when there is no source array to .map() across.
1090
- */
1091
- const integerSequence = (start, count) => Array(count)
1092
- .fill(1)
1093
- .map((_, index) => index + start);
1094
- /**
1095
- * Format a profile's full name
1096
- */
1097
- const formatFullName = (profile) => profile ? `${capitalize(profile.first_name)} ${capitalize(profile.last_name)}` : 'Invalid User';
1098
- /**
1099
- * Format a profile's initials
1100
- */
1101
- const formatInitials = (profile) => profile ? `${capitalize(profile.first_name).charAt(0)} ${capitalize(profile.last_name).charAt(0)}` : '--';
1102
- /**
1103
- * Generate suggested initials for a full name, e.g. "John Doe" will yield "JD".
1104
- */
1105
- const fullNameToInitials = (name) => name
1106
- .split(' ')
1107
- .map((word) => word[0])
1108
- .join('');
1110
+ /**
1111
+ * Subscribe to session state change events.
1112
+ */
1113
+ onSessionChanged(listener) {
1114
+ // There's no value in randomizing this, a simple counter is fine
1115
+ this.nextListenerId++;
1116
+ const listenerSymbol = Symbol.for('' + this.nextListenerId);
1117
+ this.sessionListeners.set(listenerSymbol, listener);
1118
+ return () => {
1119
+ this.sessionListeners.delete(listenerSymbol);
1120
+ };
1121
+ }
1122
+ /**
1123
+ * Load a persisted session from localStorage. Typically called once after the endpoint is configured when the app
1124
+ * or component starts.
1125
+ */
1126
+ loadSession() {
1127
+ const token = localStorage.getItem(this.sessionStorageKey());
1128
+ if (!token) {
1129
+ return this.clearSession();
1130
+ }
1131
+ return this.setToken(token);
1132
+ }
1133
+ }
1109
1134
 
1110
1135
  /**
1111
1136
  * Create an envelope
@@ -2495,18 +2520,6 @@ const getCurrentProfile = (endpoint) => endpoint.api //
2495
2520
  const getRoles = (endpoint) => endpoint.api //
2496
2521
  .get('/roles')
2497
2522
  .then((r) => r.data);
2498
- /**
2499
- * Get a list of system roles.
2500
- *
2501
- * ```typescript
2502
- * import {Profiles} from '@verdocs/js-sdk/Users';
2503
- *
2504
- * const permissions = await Profiles.getPermissions();
2505
- * ```
2506
- */
2507
- const getPermissions = (endpoint) => endpoint.api //
2508
- .get('/permissions')
2509
- .then((r) => r.data);
2510
2523
  /**
2511
2524
  * Create a profile. If the caller does not have a "current" profile set, the new profile will be made current.
2512
2525
  *
@@ -2532,18 +2545,6 @@ const createProfile = (endpoint, params) => endpoint.api //
2532
2545
  const getProfile = (endpoint, profileId) => endpoint.api //
2533
2546
  .get(`/profiles/${profileId}`)
2534
2547
  .then((r) => r.data);
2535
- /**
2536
- * Get a profile's permissions. The caller must have admin access to the given profile.
2537
- *
2538
- * ```typescript
2539
- * import {Profiles} from '@verdocs/js-sdk/Users';
2540
- *
2541
- * const permissions = await Profiles.getProfilePermissions('PROFILEID');
2542
- * ```
2543
- */
2544
- const getProfilePermissions = (endpoint, profileId) => endpoint.api //
2545
- .get(`/profiles/${profileId}/permissions`)
2546
- .then((r) => r.data);
2547
2548
  /**
2548
2549
  * Get a profile's groups.
2549
2550
  *
@@ -2580,8 +2581,11 @@ const switchProfile = (endpoint, profileId) => endpoint.api //
2580
2581
  * ```
2581
2582
  */
2582
2583
  const updateProfile = (endpoint, profileId, params) => endpoint.api //
2583
- .put(`/profiles/${profileId}`, params)
2584
+ .put(`/profiles/${profileId}`, params, { baseURL: endpoint.getBaseURLv2() })
2584
2585
  .then((r) => r.data);
2586
+ // endpoint.api //
2587
+ // .post<IEnvelopeSummaries>('/envelopes/list', params, {baseURL: endpoint.getBaseURLv2()})
2588
+ // .then((r) => r.data);
2585
2589
  /**
2586
2590
  * Delete a profile. If the requested profile is the caller's curent profile, the next available profile will be selected.
2587
2591
  *
@@ -2613,5 +2617,5 @@ const recordSignupSurvey = (endpoint, params) => endpoint.api //
2613
2617
  .post('/user/signup', params)
2614
2618
  .then((r) => r.data);
2615
2619
 
2616
- export { AtoB, Countries, VerdocsEndpoint, acceptOrganizationInvitation, addGroupMembers, addGroupPermission, addOrganizationMemberRole, addTemplateTag, authenticateApp, authenticateUser, billingPlaceholder, blobToBase64, canPerformTemplateAction, cancelEnvelope, capitalize, claimNewUser, convertToE164, createApiKey, createBusinessAccount, createEnvelope, createEnvelopeReminder, createField, createInitials, createOrganization, createOrganizationInvitation, createProfile, createSignature, createTag, createTemplate, createTemplateDocument, createTemplateFromSharepoint, createTemplateReminder, createTemplateRole, createTemplatev2, createUser, declineOrganizationInvitation, decodeAccessTokenBody, decodeJWTBody, deleteApiKey, deleteEnvelopeFieldAttachment, deleteEnvelopeReminder, deleteField, deleteGroupMembers, deleteGroupPermission, deleteOrganization, deleteOrganizationInvitation, deleteOrganizationMember, deleteOrganizationMemberRole, deleteProfile, deleteSignature, deleteTemplate, deleteTemplateDocument, deleteTemplateReminder, deleteTemplateRole, deleteTemplateTag, downloadBlob, envelopeIsActive, envelopeIsComplete, envelopeRecipientAgree, envelopeRecipientChangeOwner, envelopeRecipientDecline, envelopeRecipientPrepare, envelopeRecipientSubmit, envelopeRecipientUpdateName, fileToDataUrl, formatFullName, formatInitials, formatShortTimeAgo, fullNameToInitials, getAllTags, getApiKeys, getCountryByCode, getCurrentProfile, getDocumentDownloadLink, getDocumentPreviewLink, getEnvelope, getEnvelopeDocument, getEnvelopeDocumentPageDisplayUri, getEnvelopeFile, getEnvelopeRecipients, getEnvelopeReminder, getEnvelopesByTemplateId, getEnvelopesSummary, getFieldAttachment, getGroup, getGroupByName, getGroupMembers, getGroups, getInPersonLink, getMatchingCountry, getNextRecipient, getNotifications, getOrganization, getOrganizationInvitation, getOrganizationInvitations, getOrganizationMemberPlans, getOrganizationMembers, getOrganizations, getPermissions, getPlusOneCountry, getProfile, getProfileGroups, getProfilePermissions, getProfiles, getRGB, getRGBA, getRLeft, getRTop, getRValue, getRecipientsWithActions, getRoleColor, getRoles, getSignature, getSignatures, getSignerToken, getSigningSession, getStars, getTag, getTemplate, getTemplateDocument, getTemplateDocumentFile, getTemplateDocumentPageDisplayUri, getTemplateDocumentThumbnail, getTemplateDocuments, getTemplateOwnerInfo, getTemplateReminder, getTemplateRole, getTemplateRoleFields, getTemplateRoles, getTemplateTags, getTemplates, getTemplatesSummary, getValidator, getValidators, getWebhooks, hasRequiredPermissions, integerSequence, isAmericanSamoa, isCanada, isDominicanRepublic, isFrenchGuiana, isGuadeloupe, isMartinique, isMayotte, isPuertoRico, isValidEmail, isValidPhone, isValidRoleName, isValidTag, listEnvelopes, listTemplates, nameToRGBA, recipientCanAct, recipientHasAction, recordSignupSurvey, refreshTokens, rescale, resendInvitation, resendOrganizationInvitation, resendVerification, resetPassword, rotateApiKey, searchEnvelopes, searchTemplates, sendDelegate, setWebhooks, switchProfile, throttledGetEnvelope, throttledGetTemplate, timePeriod, toggleStar, updateApiKey, updateEmail, updateEnvelopeField, updateEnvelopeFieldInitials, updateEnvelopeFieldSignature, updateEnvelopeReminder, updateField, updateOrganization, updateOrganizationInvitation, updatePassword, updateProfile, updateRecipient, updateTemplate, updateTemplateReminder, updateTemplateRole, uploadEnvelopeFieldAttachment, userCanAct, userCanCancelEnvelope, userCanFinishEnvelope, userCanSignNow, userHasPermissions, userIsEnvelopeOwner, userIsEnvelopeRecipient, validateToken };
2620
+ export { AtoB, Countries, VerdocsEndpoint, acceptOrganizationInvitation, addGroupMembers, addGroupPermission, addOrganizationMemberRole, addTemplateTag, authenticateApp, authenticateUser, billingPlaceholder, blobToBase64, canPerformTemplateAction, cancelEnvelope, capitalize, claimNewUser, convertToE164, createApiKey, createBusinessAccount, createEnvelope, createEnvelopeReminder, createField, createInitials, createOrganization, createOrganizationInvitation, createProfile, createSignature, createTag, createTemplate, createTemplateDocument, createTemplateFromSharepoint, createTemplateReminder, createTemplateRole, createTemplatev2, createUser, declineOrganizationInvitation, decodeAccessTokenBody, decodeJWTBody, deleteApiKey, deleteEnvelopeFieldAttachment, deleteEnvelopeReminder, deleteField, deleteGroupMembers, deleteGroupPermission, deleteOrganization, deleteOrganizationInvitation, deleteOrganizationMember, deleteOrganizationMemberRole, deleteProfile, deleteSignature, deleteTemplate, deleteTemplateDocument, deleteTemplateReminder, deleteTemplateRole, deleteTemplateTag, downloadBlob, envelopeIsActive, envelopeIsComplete, envelopeRecipientAgree, envelopeRecipientChangeOwner, envelopeRecipientDecline, envelopeRecipientPrepare, envelopeRecipientSubmit, envelopeRecipientUpdateName, fileToDataUrl, formatFullName, formatInitials, formatShortTimeAgo, fullNameToInitials, getAllTags, getApiKeys, getCountryByCode, getCurrentProfile, getDocumentDownloadLink, getDocumentPreviewLink, getEnvelope, getEnvelopeDocument, getEnvelopeDocumentPageDisplayUri, getEnvelopeFile, getEnvelopeRecipients, getEnvelopeReminder, getEnvelopesByTemplateId, getEnvelopesSummary, getFieldAttachment, getGroup, getGroupByName, getGroupMembers, getGroups, getInPersonLink, getMatchingCountry, getNextRecipient, getNotifications, getOrganization, getOrganizationInvitation, getOrganizationInvitations, getOrganizationMemberPlans, getOrganizationMembers, getOrganizations, getPlusOneCountry, getProfile, getProfileGroups, getProfiles, getRGB, getRGBA, getRLeft, getRTop, getRValue, getRecipientsWithActions, getRoleColor, getRoles, getSignature, getSignatures, getSignerToken, getSigningSession, getStars, getTag, getTemplate, getTemplateDocument, getTemplateDocumentFile, getTemplateDocumentPageDisplayUri, getTemplateDocumentThumbnail, getTemplateDocuments, getTemplateOwnerInfo, getTemplateReminder, getTemplateRole, getTemplateRoleFields, getTemplateRoles, getTemplateTags, getTemplates, getTemplatesSummary, getValidator, getValidators, getWebhooks, hasRequiredPermissions, integerSequence, isAmericanSamoa, isCanada, isDominicanRepublic, isFrenchGuiana, isGuadeloupe, isMartinique, isMayotte, isPuertoRico, isValidEmail, isValidPhone, isValidRoleName, isValidTag, listEnvelopes, listTemplates, nameToRGBA, recipientCanAct, recipientHasAction, recordSignupSurvey, refreshTokens, rescale, resendInvitation, resendOrganizationInvitation, resendVerification, resetPassword, rotateApiKey, searchEnvelopes, searchTemplates, sendDelegate, setWebhooks, switchProfile, throttledGetEnvelope, throttledGetTemplate, timePeriod, toggleStar, updateApiKey, updateEmail, updateEnvelopeField, updateEnvelopeFieldInitials, updateEnvelopeFieldSignature, updateEnvelopeReminder, updateField, updateOrganization, updateOrganizationInvitation, updatePassword, updateProfile, updateRecipient, updateTemplate, updateTemplateReminder, updateTemplateRole, uploadEnvelopeFieldAttachment, userCanAct, userCanCancelEnvelope, userCanFinishEnvelope, userCanSignNow, userHasPermissions, userIsEnvelopeOwner, userIsEnvelopeRecipient, validateToken };
2617
2621
  //# sourceMappingURL=index.mjs.map