@verdocs/js-sdk 3.10.30 → 4.0.1

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.
Files changed (112) hide show
  1. package/dist/README.md +75 -0
  2. package/dist/index.d.mts +40458 -0
  3. package/dist/index.d.ts +40458 -0
  4. package/dist/index.js +3040 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/index.mjs +3032 -0
  7. package/dist/index.mjs.map +1 -0
  8. package/dist/package.json +76 -0
  9. package/dist/tsconfig.json +16 -0
  10. package/package.json +28 -20
  11. package/.github/workflows/generate-docs.yml +0 -41
  12. package/Envelopes/Envelopes.d.ts +0 -242
  13. package/Envelopes/Envelopes.js +0 -339
  14. package/Envelopes/Initials.d.ts +0 -15
  15. package/Envelopes/Initials.js +0 -13
  16. package/Envelopes/Permissions.d.ts +0 -52
  17. package/Envelopes/Permissions.js +0 -84
  18. package/Envelopes/Recipients.d.ts +0 -89
  19. package/Envelopes/Recipients.js +0 -112
  20. package/Envelopes/Reminders.d.ts +0 -23
  21. package/Envelopes/Reminders.js +0 -33
  22. package/Envelopes/Signatures.d.ts +0 -28
  23. package/Envelopes/Signatures.js +0 -37
  24. package/Envelopes/Types.d.ts +0 -390
  25. package/Envelopes/Types.js +0 -45
  26. package/Envelopes/index.d.ts +0 -7
  27. package/Envelopes/index.js +0 -7
  28. package/Organizations/ApiKeys.d.ts +0 -64
  29. package/Organizations/ApiKeys.js +0 -82
  30. package/Organizations/Groups.d.ts +0 -47
  31. package/Organizations/Groups.js +0 -76
  32. package/Organizations/Invitations.d.ts +0 -24
  33. package/Organizations/Invitations.js +0 -45
  34. package/Organizations/Members.d.ts +0 -12
  35. package/Organizations/Members.js +0 -30
  36. package/Organizations/Organizations.d.ts +0 -27
  37. package/Organizations/Organizations.js +0 -45
  38. package/Organizations/Types.d.ts +0 -104
  39. package/Organizations/Types.js +0 -1
  40. package/Organizations/Webhooks.d.ts +0 -34
  41. package/Organizations/Webhooks.js +0 -10
  42. package/Organizations/Whitelabel.d.ts +0 -31
  43. package/Organizations/Whitelabel.js +0 -38
  44. package/Organizations/index.d.ts +0 -16
  45. package/Organizations/index.js +0 -16
  46. package/Sessions/Types.d.ts +0 -54
  47. package/Sessions/Types.js +0 -1
  48. package/Sessions/index.d.ts +0 -6
  49. package/Sessions/index.js +0 -7
  50. package/Templates/Actions.d.ts +0 -26
  51. package/Templates/Actions.js +0 -104
  52. package/Templates/Fields.d.ts +0 -14
  53. package/Templates/Fields.js +0 -24
  54. package/Templates/Pages.d.ts +0 -30
  55. package/Templates/Pages.js +0 -41
  56. package/Templates/Permissions.d.ts +0 -73
  57. package/Templates/Permissions.js +0 -124
  58. package/Templates/Reminders.d.ts +0 -23
  59. package/Templates/Reminders.js +0 -33
  60. package/Templates/Roles.d.ts +0 -16
  61. package/Templates/Roles.js +0 -42
  62. package/Templates/Stars.d.ts +0 -10
  63. package/Templates/Stars.js +0 -16
  64. package/Templates/Tags.d.ts +0 -33
  65. package/Templates/Tags.js +0 -55
  66. package/Templates/TemplateDocuments.d.ts +0 -66
  67. package/Templates/TemplateDocuments.js +0 -139
  68. package/Templates/Templates.d.ts +0 -284
  69. package/Templates/Templates.js +0 -309
  70. package/Templates/Types.d.ts +0 -346
  71. package/Templates/Types.js +0 -29
  72. package/Templates/Validators.d.ts +0 -21
  73. package/Templates/Validators.js +0 -27
  74. package/Templates/index.d.ts +0 -11
  75. package/Templates/index.js +0 -11
  76. package/Users/Auth.d.ts +0 -123
  77. package/Users/Auth.js +0 -142
  78. package/Users/Billing.d.ts +0 -1
  79. package/Users/Billing.js +0 -2
  80. package/Users/Notifications.d.ts +0 -2
  81. package/Users/Notifications.js +0 -43
  82. package/Users/Profiles.d.ts +0 -151
  83. package/Users/Profiles.js +0 -179
  84. package/Users/Types.d.ts +0 -146
  85. package/Users/Types.js +0 -47
  86. package/Users/index.d.ts +0 -5
  87. package/Users/index.js +0 -5
  88. package/Utils/Colors.d.ts +0 -18
  89. package/Utils/Colors.js +0 -102
  90. package/Utils/DateTime.d.ts +0 -6
  91. package/Utils/DateTime.js +0 -79
  92. package/Utils/Fields.d.ts +0 -5
  93. package/Utils/Fields.js +0 -24
  94. package/Utils/Files.d.ts +0 -16
  95. package/Utils/Files.js +0 -42
  96. package/Utils/Locales.d.ts +0 -17
  97. package/Utils/Locales.js +0 -1358
  98. package/Utils/Primitives.d.ts +0 -18
  99. package/Utils/Primitives.js +0 -31
  100. package/Utils/Strings.d.ts +0 -9
  101. package/Utils/Strings.js +0 -28
  102. package/Utils/Token.d.ts +0 -19
  103. package/Utils/Token.js +0 -67
  104. package/Utils/globalThis.d.ts +0 -2
  105. package/Utils/globalThis.js +0 -52
  106. package/Utils/index.d.ts +0 -8
  107. package/Utils/index.js +0 -8
  108. package/VerdocsEndpoint.d.ts +0 -199
  109. package/VerdocsEndpoint.js +0 -319
  110. package/index.d.ts +0 -18
  111. package/index.js +0 -18
  112. package/tsconfig-typedoc.json +0 -26
package/dist/index.js ADDED
@@ -0,0 +1,3040 @@
1
+ 'use strict';
2
+
3
+ var axios = require('axios');
4
+
5
+ /* tslint:disable:no-bitwise */
6
+ const b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
7
+ // Regular expression to check formal correctness of base64 encoded strings
8
+ const b64re = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/;
9
+ /**
10
+ * Simplified, Node/Browser-safe alternative to atob() for base64 decoding.
11
+ * Modified from https://github.com/MaxArt2501/base64-js/blob/master/base64.js
12
+ */
13
+ const AtoB = (str) => {
14
+ // atob can work with strings with whitespaces, even inside the encoded part,
15
+ // but only \t, \n, \f, \r and ' ', which can be stripped.
16
+ str = String(str).replace(/[\t\n\f\r ]+/g, '');
17
+ if (!b64re.test(str))
18
+ throw new TypeError("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");
19
+ // Adding the padding if missing, for semplicity
20
+ str += '=='.slice(2 - (str.length & 3));
21
+ let bitmap;
22
+ let result = '';
23
+ let r1;
24
+ let r2;
25
+ let i = 0;
26
+ for (; i < str.length;) {
27
+ bitmap =
28
+ (b64.indexOf(str.charAt(i++)) << 18) |
29
+ (b64.indexOf(str.charAt(i++)) << 12) |
30
+ ((r1 = b64.indexOf(str.charAt(i++))) << 6) |
31
+ (r2 = b64.indexOf(str.charAt(i++)));
32
+ result +=
33
+ r1 === 64
34
+ ? String.fromCharCode((bitmap >> 16) & 255)
35
+ : r2 === 64
36
+ ? String.fromCharCode((bitmap >> 16) & 255, (bitmap >> 8) & 255)
37
+ : String.fromCharCode((bitmap >> 16) & 255, (bitmap >> 8) & 255, bitmap & 255);
38
+ }
39
+ return result;
40
+ };
41
+ /**
42
+ * Decode the body of a JWT. This helper may allow front-end applications to avoid a dependency on `jsonwebtoken` in
43
+ * many cases. Note that this should only be used for true JWTs. Opaque tokens will cause this to throw.
44
+ */
45
+ const decodeJWTBody = (token) => JSON.parse(AtoB((token || '').split('.')[1] || ''));
46
+ /**
47
+ * Decode the body of an Verdocs access token. Note that raw tokens contain namespaced fields, e.g.
48
+ * `https://verdocs.com/profile_id`. To make these tokens easier to use in front-end code, this name-spacing
49
+ * will be removed. Note that user and signing sessions have different access token formats. The calling
50
+ * application should distinguish between the two based on the context of the authenticated session, or by
51
+ * the presence of the `document_id` field, which will only be present for signing sessions.
52
+ */
53
+ const decodeAccessTokenBody = (token) => {
54
+ let decoded;
55
+ try {
56
+ decoded = decodeJWTBody(token);
57
+ if (decoded === null) {
58
+ return null;
59
+ }
60
+ }
61
+ catch (e) {
62
+ return null;
63
+ }
64
+ Object.keys(decoded).forEach((key) => {
65
+ if (typeof key === 'string' && key.startsWith('https://verdocs.com/')) {
66
+ decoded[key.replace('https://verdocs.com/', '')] = decoded[key];
67
+ delete decoded[key];
68
+ }
69
+ });
70
+ return decoded;
71
+ };
72
+
73
+ var Token = /*#__PURE__*/Object.freeze({
74
+ __proto__: null,
75
+ AtoB: AtoB,
76
+ decodeAccessTokenBody: decodeAccessTokenBody,
77
+ decodeJWTBody: decodeJWTBody
78
+ });
79
+
80
+ function getDefaultExportFromCjs (x) {
81
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
82
+ }
83
+
84
+ // This file provides a polyfill for managing globals in both NodeJS and browser environments. This is
85
+ // an anti-pattern we'd hoped to avoid, but we have several projects dependending on one common library
86
+ // (this js-sdk) and we want that library to provide a common endpoint to all callers (so authentication
87
+ // tokens only need to be tracked in one place). The trouble is, one of those libraries is based on
88
+ // StencilJS and is compiling its modules into Web Components. Because of how module resolution works,
89
+ // when those Components load js-sdk they get a separate instance. Without messy options like having to
90
+ // pass raw data from the caller to each Component, or pass around references to a common Endpoint, they
91
+ // have no way to access authenticated sessions unless we make the Endpoint a true global.
92
+ //
93
+ // @credit https://github.com/medikoo/es5-ext/blob/master/global.js
94
+ // @credit https://mathiasbynens.be/notes/globalthis
95
+ var naiveFallback = function () {
96
+ if (typeof self === 'object' && self)
97
+ return self;
98
+ if (typeof window === 'object' && window)
99
+ return window;
100
+ throw new Error('Unable to resolve global `this`');
101
+ };
102
+ var globalThis_1 = (function () {
103
+ if (this)
104
+ return this;
105
+ // Unexpected strict mode (may happen if e.g. bundled into ESM module)
106
+ // Fallback to standard globalThis if available
107
+ if (typeof globalThis === 'object' && globalThis)
108
+ return globalThis;
109
+ // Thanks @mathiasbynens -> https://mathiasbynens.be/notes/globalthis
110
+ // In all ES5+ engines global object inherits from Object.prototype
111
+ // (if you approached one that doesn't please report)
112
+ try {
113
+ Object.defineProperty(Object.prototype, '__global__', {
114
+ get: function () {
115
+ return this;
116
+ },
117
+ configurable: true,
118
+ });
119
+ }
120
+ catch (error) {
121
+ // Unfortunate case of updates to Object.prototype being restricted
122
+ // via preventExtensions, seal or freeze
123
+ return naiveFallback();
124
+ }
125
+ try {
126
+ // Safari case (window.__global__ works, but __global__ does not)
127
+ if (!__global__)
128
+ return naiveFallback();
129
+ return __global__;
130
+ }
131
+ finally {
132
+ delete Object.prototype.__global__;
133
+ }
134
+ })();
135
+
136
+ var globalThis$1 = /*@__PURE__*/getDefaultExportFromCjs(globalThis_1);
137
+
138
+ // @credit https://derickbailey.com/2016/03/09/creating-a-true-singleton-in-node-js-with-es6-symbols/
139
+ // Also see globalThis for comments about why we're doing this in the first place.
140
+ const ENDPOINT_KEY = Symbol.for('verdocs-default-endpoint');
141
+ const requestLogger = (r) => {
142
+ // tslint:disable-next-line
143
+ console.debug(`[JS-SDK] ${r.method.toUpperCase()} ${r.baseURL}${r.url}`, r.data ? JSON.stringify(r.data) : '');
144
+ return r;
145
+ };
146
+ /**
147
+ * VerdocsEndpoint is a class wrapper for a specific connection and authorization context for calling the Verdocs APIs.
148
+ * Endpoints can be used for isolated session tasks.
149
+ *
150
+ * For instance, ephemeral signing sessions may be created independently of a caller's status as an authenticated user.
151
+ * In that case, an Endpoint can be created and authenticated, used for calls related to signing operations, then
152
+ * discarded once signing is complete.
153
+ *
154
+ * Note that endpoint configuration functions return the instance, so they can be chained, e.g.
155
+ *
156
+ * ```typescript
157
+ * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
158
+ *
159
+ * const endpoint = new VerdocsEndpoint();
160
+ * endpoint
161
+ * .setSessionType('signing')
162
+ * .logRequests(true)
163
+ * .setClientID('1234)
164
+ * .setTimeout(30000);
165
+ * ```
166
+ */
167
+ class VerdocsEndpoint {
168
+ environment = 'verdocs';
169
+ sessionType = 'user';
170
+ baseURL = (window.location.origin === 'https://beta.verdocs.com' || window.location.origin === 'https://stage.verdocs.com'
171
+ ? 'https://stage-api.verdocs.com'
172
+ : 'https://api.verdocs.com');
173
+ clientID = 'not-set';
174
+ timeout = 60000;
175
+ token = null;
176
+ nextListenerId = 0;
177
+ sessionListeners = new Map();
178
+ requestLoggerId = null;
179
+ /**
180
+ * The current user session, or null if not authenticated. May be either a User or Signing session. If set, the
181
+ * presence of the `document_id` field can be used to differentiate the types. Only signing sessions are associated
182
+ * with Envelopes.
183
+ */
184
+ session = null;
185
+ api;
186
+ /**
187
+ * Create a new VerdocsEndpoint to call Verdocs platform services.
188
+ *
189
+ * ```typescript
190
+ * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
191
+ * const endpoint = new VerdocsEndpoint();
192
+ * ```
193
+ */
194
+ constructor(options) {
195
+ this.baseURL = options?.baseURL || this.baseURL;
196
+ this.timeout = options?.timeout || this.timeout;
197
+ this.environment = options?.environment || this.environment;
198
+ this.sessionType = options?.sessionType || this.sessionType;
199
+ this.clientID = options?.clientID || this.clientID;
200
+ this.api = axios.create({ baseURL: this.baseURL, timeout: this.timeout });
201
+ }
202
+ setDefault() {
203
+ globalThis$1[ENDPOINT_KEY] = this;
204
+ }
205
+ static getDefault() {
206
+ if (!globalThis$1[ENDPOINT_KEY]) {
207
+ globalThis$1[ENDPOINT_KEY] = new VerdocsEndpoint();
208
+ window.console.debug('[JS_SDK] Created default endpoint', globalThis$1[ENDPOINT_KEY].baseURL);
209
+ }
210
+ return globalThis$1[ENDPOINT_KEY];
211
+ }
212
+ /**
213
+ * Get the current environment.
214
+ */
215
+ getEnvironment() {
216
+ return this.environment;
217
+ }
218
+ /**
219
+ * Get the current session type.
220
+ */
221
+ getSessionType() {
222
+ return this.sessionType;
223
+ }
224
+ /**
225
+ * Get the current base URL. This should rarely be anything other than 'https://api.verdocs.com'.
226
+ */
227
+ getBaseURL() {
228
+ return this.baseURL;
229
+ }
230
+ /**
231
+ * Get the current client ID, if set.
232
+ */
233
+ getClientID() {
234
+ return this.clientID;
235
+ }
236
+ /**
237
+ * Get the current timeout.
238
+ */
239
+ getTimeout() {
240
+ return this.timeout;
241
+ }
242
+ /**
243
+ * Get the current session, if any.
244
+ */
245
+ getSession() {
246
+ return this.session;
247
+ }
248
+ /**
249
+ * Set the operating environment. This should rarely be anything other than 'verdocs'.
250
+ *
251
+ * ```typescript
252
+ * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
253
+ *
254
+ * const endpoint = new VerdocsEndpoint();
255
+ * endpoint.setEnvironment('verdocs-stage');
256
+ * ```
257
+ */
258
+ setEnvironment(environment) {
259
+ this.environment = environment;
260
+ return this;
261
+ }
262
+ /**
263
+ * Set the session type. In general this should be done immediately when the endpoint is created. Changing the
264
+ * session type may be done at any time, but may have unintended consequences if the endpoint is shared between
265
+ * multiple widgets.
266
+ *
267
+ * Changing the session type will clear/reload the action session. This may trigger notifications to session state
268
+ * observers. Apps that use observers to trigger UI updates such as logging the user out should be prepared to
269
+ * handle this event.
270
+ *
271
+ * ```typescript
272
+ * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
273
+ *
274
+ * const endpoint = new VerdocsEndpoint();
275
+ * endpoint.setEnvironment('verdocs-stage');
276
+ * ```
277
+ */
278
+ setSessionType(sessionType) {
279
+ this.sessionType = sessionType;
280
+ return this;
281
+ }
282
+ /**
283
+ * Set the base URL for API calls. Should be called only upon direction from Verdocs Customer Solutions Engineering.
284
+ *
285
+ * ```typescript
286
+ * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
287
+ *
288
+ * const endpoint = new VerdocsEndpoint();
289
+ * endpoint.setBaseURL('https://api.verdocs.com');
290
+ * ```
291
+ */
292
+ setBaseURL(url) {
293
+ this.baseURL = url;
294
+ this.api.defaults.baseURL = url;
295
+ return this;
296
+ }
297
+ /**
298
+ * Set the Client ID for Verdocs API calls.
299
+ *
300
+ * ```typescript
301
+ * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
302
+ *
303
+ * const endpoint = new VerdocsEndpoint();
304
+ * endpoint.setClientID('1234);
305
+ * ```
306
+ */
307
+ setClientID(clientID) {
308
+ this.clientID = clientID;
309
+ this.api.defaults.headers.common['X-Client-ID'] = clientID;
310
+ return this;
311
+ }
312
+ /**
313
+ * Set the timeout for API calls in milliseconds. 5000-20000ms is recommended for most purposes. 15000ms is the default.
314
+ * Note that some calls may involve rendering operations that require some time to complete, so very short timeouts
315
+ * are not recommended.
316
+ *
317
+ * ```typescript
318
+ * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
319
+ *
320
+ * const endpoint = new VerdocsEndpoint();
321
+ * endpoint.setTimeout(3000);
322
+ * ```
323
+ */
324
+ setTimeout(timeout) {
325
+ this.timeout = timeout;
326
+ this.api.defaults.timeout = timeout;
327
+ return this;
328
+ }
329
+ /**
330
+ * Enable or disable request logging. This may expose sensitive data in the console log, so it should only be used for debugging.
331
+ *
332
+ * ```typescript
333
+ * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
334
+ *
335
+ * const endpoint = new VerdocsEndpoint();
336
+ * endpoint.logRequests(true);
337
+ * ```
338
+ */
339
+ logRequests(enable) {
340
+ if (enable && this.requestLoggerId === null) {
341
+ this.requestLoggerId = this.api.interceptors.request.use(requestLogger);
342
+ }
343
+ else if (!enable && this.requestLoggerId !== null) {
344
+ this.api.interceptors.request.eject(this.requestLoggerId);
345
+ }
346
+ return this;
347
+ }
348
+ /**
349
+ * Set the authorization token that will be used for Verdocs API calls. This will also set the session metadata
350
+ * and notify any listeners of the new data.
351
+ *
352
+ * If this Endpoint will be used for non-default purposes (e.g. signing, or in an alternate environment) those
353
+ * settings should be made before calling this. Sessions are persisted to localStorage, and the environment and
354
+ * type become part of the storage key.
355
+ *
356
+ * ```typescript
357
+ * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
358
+ *
359
+ * const endpoint = new VerdocsEndpoint();
360
+ * endpoint.setToken(accessToken);
361
+ * ```
362
+ */
363
+ setToken(token) {
364
+ if (!token) {
365
+ return this.clearSession();
366
+ }
367
+ const session = decodeAccessTokenBody(token);
368
+ if (session === null || (session.exp && session.exp * 1000 < new Date().getTime())) {
369
+ window.console.warn('[JS_SDK] Ignoring attempt to use expired session token');
370
+ return this.clearSession();
371
+ }
372
+ this.token = token;
373
+ this.session = session;
374
+ if (this.sessionType === 'user') {
375
+ this.api.defaults.headers.common.Authorization = `Bearer ${token}`;
376
+ }
377
+ else {
378
+ this.api.defaults.headers.common.signer = `Bearer ${token}`;
379
+ }
380
+ localStorage.setItem(this.sessionStorageKey(), token);
381
+ this.notifySessionListeners();
382
+ return this;
383
+ }
384
+ /**
385
+ * Retrieves the current session token, if any. Tokens should rarely be used for direct actions, but this is
386
+ * required by the `<VerdocsView>` and other components to authorize requests to raw PDF files.
387
+ */
388
+ getToken() {
389
+ return this.token;
390
+ }
391
+ sessionStorageKey() {
392
+ return `verdocs-session-${this.getSessionType()}-${this.getEnvironment()}`;
393
+ }
394
+ /**
395
+ * Clear the active session.
396
+ */
397
+ clearSession() {
398
+ localStorage.removeItem(this.sessionStorageKey());
399
+ delete this.api.defaults.headers.common.Authorization;
400
+ delete this.api.defaults.headers.common.signer;
401
+ this.session = null;
402
+ this.token = null;
403
+ this.notifySessionListeners();
404
+ return this;
405
+ }
406
+ /**
407
+ * Clear the active signing session.
408
+ */
409
+ clearSignerSession() {
410
+ localStorage.removeItem(this.sessionStorageKey());
411
+ delete this.api.defaults.headers.common.Authorization;
412
+ this.session = null;
413
+ this.token = null;
414
+ this.notifySessionListeners();
415
+ return this;
416
+ }
417
+ notifySessionListeners() {
418
+ this.sessionListeners.forEach((listener) => {
419
+ try {
420
+ listener(this, this.session);
421
+ }
422
+ catch (e) {
423
+ // NOOP
424
+ }
425
+ });
426
+ }
427
+ /**
428
+ * Subscribe to session state change events.
429
+ */
430
+ onSessionChanged(listener) {
431
+ // There's no value in randomizing this, a simple counter is fine
432
+ this.nextListenerId++;
433
+ const listenerSymbol = Symbol.for('' + this.nextListenerId);
434
+ this.sessionListeners.set(listenerSymbol, listener);
435
+ return () => {
436
+ this.sessionListeners.delete(listenerSymbol);
437
+ };
438
+ }
439
+ /**
440
+ * Load a persisted session from localStorage. Typically called once after the endpoint is configured when the app
441
+ * or component starts.
442
+ */
443
+ loadSession() {
444
+ const token = localStorage.getItem(this.sessionStorageKey());
445
+ if (!token) {
446
+ return this.clearSession();
447
+ }
448
+ return this.setToken(token);
449
+ }
450
+ }
451
+
452
+ /**
453
+ * Create an envelope
454
+ *
455
+ * ```typescript
456
+ * import {Envelopes, ICreateEnvelopeRole, ICreateEnvelopeRequest} from '@verdocs/js-sdk/Envelopes';
457
+ *
458
+ * const role1: ICreateEnvelopeRole = {
459
+ * type: 'signer',
460
+ * name: 'Seller',
461
+ * full_name: 'Paige Turner',
462
+ * email: 'paige.turner@nomail.com',
463
+ * phone: '',
464
+ * sequence: 1,
465
+ * delegator: false,
466
+ * message: '',
467
+ * };
468
+ *
469
+ * const role2: ICreateEnvelopeRole = {
470
+ * type: 'signer',
471
+ * name: 'Buyer',
472
+ * full_name: 'Will Power',
473
+ * email: 'will.power@nomail.com',
474
+ * phone: '',
475
+ * sequence: 2,
476
+ * delegator: false,
477
+ * message: '',
478
+ * };
479
+ *
480
+ * const request: ICreateEnvelopeRequest = {template_id: 'd2338742-f3a1-465b-8592-806587413cc1', name: 'Bill of Sale', roles: [role1, role2]};
481
+ * const {id, recipients} = await Envelopes.createEnvelope(VerdocsEndpoint.getDefault(), request);
482
+ * ```
483
+ */
484
+ const createEnvelope = async (endpoint, request) => endpoint.api //
485
+ .post('/envelopes', request)
486
+ .then((r) => r.data);
487
+ /**
488
+ * Get a summary of currently active envelopes.
489
+ *
490
+ * ```typescript
491
+ * import {Envelopes} from '@verdocs/js-sdk/Envelopes';
492
+ *
493
+ * const {action_required, completed, waiting_on_others} = await Envelopes.getSummary(VerdocsEndpoint.getDefault());
494
+ * ```
495
+ */
496
+ const getSummary$1 = async (endpoint, page) => endpoint.api //
497
+ .post('/envelopes/summary', { page })
498
+ .then((r) => r.data);
499
+ /**
500
+ * Search for envelopes matching various criteria.
501
+ *
502
+ * ```typescript
503
+ * import {Envelopes} from '@verdocs/js-sdk/Envelopes';
504
+ *
505
+ * const {result, page, total} = await Envelopes.search(VerdocsEndpoint.getDefault(), { ... });
506
+ * ```
507
+ */
508
+ const searchEnvelopes = async (endpoint, params) => endpoint.api //
509
+ .post('/envelopes/search', params)
510
+ .then((r) => r.data);
511
+ /**
512
+ * Get a signing session for an Envelope.
513
+ */
514
+ const getSigningSession = async (endpoint, params) => {
515
+ window.console.log('[JS_SDK] getSigningSession', params, endpoint.api);
516
+ return endpoint.api //
517
+ .get(`/envelopes/${params.envelopeId}/recipients/${encodeURIComponent(params.roleId)}/invitation/${params.inviteCode}`)
518
+ .then((r) => {
519
+ // Avoiding a jsonwebtoken dependency here - we don't actually need the whole library
520
+ const signerToken = r.headers?.signer_token || '';
521
+ const session = decodeAccessTokenBody(signerToken);
522
+ endpoint.setToken(signerToken);
523
+ return { recipient: r.data, session, signerToken };
524
+ });
525
+ };
526
+ /**
527
+ * Get the list of recipients for an Envelope.
528
+ */
529
+ const getEnvelopeRecipients = async (endpoint, envelopeId) => endpoint.api //
530
+ .get(`/envelopes/${envelopeId}/recipients`)
531
+ .then((r) => r.data);
532
+ /**
533
+ * Get all metadata for an Envelope.
534
+ */
535
+ const getEnvelope = async (endpoint, envelopeId) => endpoint.api //
536
+ .get(`/envelopes/${envelopeId}`)
537
+ .then((r) => r.data);
538
+ /**
539
+ * Get an Envelope Document
540
+ */
541
+ const getEnvelopeDocument = async (endpoint, envelopeId, documentId) => endpoint.api //
542
+ .get(`/envelopes/${envelopeId}/envelope_documents/${documentId}`)
543
+ .then((r) => r.data);
544
+ /**
545
+ * Get a pre-signed download link for an Envelope Document. This link expires quickly, so it should
546
+ * be accessed immediately and never shared. Content-Disposition will be set to "download".
547
+ */
548
+ const getDocumentDownloadLink = async (endpoint, envelopeId, documentId) => endpoint.api //
549
+ .get(`/envelopes/${envelopeId}/envelope_documents/${documentId}?download=true`)
550
+ .then((r) => r.data);
551
+ /**
552
+ * Get a pre-signed preview link for an Envelope Document. This link expires quickly, so it should
553
+ * be accessed immediately and never shared. Content-Disposition will be set to "inline".
554
+ */
555
+ const getDocumentPreviewLink = async (endpoint, envelopeId, documentId) => endpoint.api //
556
+ .get(`/envelopes/${envelopeId}/envelope_documents/${documentId}?preview=true`)
557
+ .then((r) => r.data);
558
+ /**
559
+ * Cancel an Envelope.
560
+ */
561
+ const cancelEnvelope = async (endpoint, envelopeId) => endpoint.api //
562
+ .put(`/envelopes/${envelopeId}`, { action: 'cancel' })
563
+ .then((r) => r.data);
564
+ /**
565
+ * Get (binary download) a file attached to an Envelope. It is important to use this method
566
+ * rather than a direct A HREF or similar link to set the authorization headers for the
567
+ * request.
568
+ */
569
+ const getEnvelopeFile = async (endpoint, envelopeId, documentId) => endpoint.api //
570
+ .get(`/envelopes/${envelopeId}/envelope_documents/${documentId}?file=true`, { responseType: 'blob' })
571
+ .then((r) => r.data);
572
+ /**
573
+ * Update a Document field. Typically called during the signing process as a Recipient fills in fields.
574
+ */
575
+ const updateEnvelopeField = async (endpoint, envelopeId, fieldName, value) => endpoint.api //
576
+ .put(`/envelopes/${envelopeId}/fields/${fieldName}`, value)
577
+ .then((r) => r.data);
578
+ /**
579
+ * Update a Document signature field. Signature fields are ID-driven. Call `Document.createSignature()` first to create a
580
+ * signature for a Recipient, then call `Documents.updateDocumentFieldSignature()` to attach it to a field.
581
+ */
582
+ const updateEnvelopeFieldSignature = async (endpoint, envelopeId, fieldName, signatureId) => endpoint.api //
583
+ .put(`/envelopes/${envelopeId}/fields/${fieldName}/signature/${signatureId}`)
584
+ .then((r) => r.data);
585
+ /**
586
+ * Update a Document signature field. Signature fields are ID-driven. Call `Document.createSignature()` first to create a
587
+ * signature for a Recipient, then call `Documents.updateDocumentFieldSignature()` to attach it to a field.
588
+ */
589
+ const updateEnvelopeFieldInitials = async (endpoint, envelopeId, fieldName, initialId) => endpoint.api //
590
+ .put(`/envelopes/${envelopeId}/fields/${fieldName}/initial/${initialId}`)
591
+ .then((r) => r.data);
592
+ /**
593
+ * Upload an attachment.
594
+ */
595
+ const uploadEnvelopeFieldAttachment = async (endpoint, envelopeId, fieldName, file, onUploadProgress) => {
596
+ const formData = new FormData();
597
+ formData.append('document', file, file.name);
598
+ return endpoint.api //
599
+ .put(`/envelopes/${envelopeId}/fields/${fieldName}`, formData, {
600
+ timeout: 120000,
601
+ onUploadProgress: (event) => {
602
+ const total = event.total || 1;
603
+ const loaded = event.loaded || 0;
604
+ onUploadProgress?.(Math.floor((loaded * 100) / (total || 1)), loaded, total || 1);
605
+ },
606
+ })
607
+ .then((r) => r.data);
608
+ };
609
+ /**
610
+ * Delete an attachment.
611
+ */
612
+ const deleteEnvelopeFieldAttachment = async (endpoint, envelopeId, fieldName, file, onUploadProgress) => {
613
+ const formData = new FormData();
614
+ // Omitting file is the trigger here
615
+ return endpoint.api //
616
+ .put(`/envelopes/${envelopeId}/fields/${fieldName}`, formData, {
617
+ timeout: 120000,
618
+ onUploadProgress: (event) => {
619
+ const total = event.total || 1;
620
+ const loaded = event.loaded || 0;
621
+ onUploadProgress?.(Math.floor((loaded * 100) / (total || 1)), loaded, total || 1);
622
+ },
623
+ })
624
+ .then((r) => r.data);
625
+ };
626
+ /**
627
+ * Get the attached file for an attachment field (if any)
628
+ */
629
+ const getFieldAttachment = async (endpoint, envelopeId, fieldName) => endpoint.api //
630
+ .get(`/envelopes/${envelopeId}/fields/${fieldName}/document`, { responseType: 'blob' })
631
+ .then((r) => r.data);
632
+ /**
633
+ * Get a display URI for a given page in a file attached to an envelope document. These pages are rendered server-side
634
+ * into PNG resources suitable for display in IMG tags although they may be used elsewhere. Note that these are intended
635
+ * for DISPLAY ONLY, are not legally binding documents, and do not contain any encoded metadata from participants.
636
+ */
637
+ const getEnvelopeDocumentPageDisplayUri = async (endpoint, envelopeId, documentId, page, type = 'original') => endpoint.api
638
+ .get(`/envelopes/${envelopeId}/envelope_documents/${documentId}/pages/${page}/image?type=${type}`, { timeout: 20000 })
639
+ .then((r) => r.data);
640
+ const cachedEnvelopes = {};
641
+ /**
642
+ * Wrapper for `getEnvelope()` that limits queries to one every 2 seconds per template ID.
643
+ * This is intended for use in component hierarchies that all rely on the same template
644
+ * to avoid unnecessary repeat server calls.
645
+ */
646
+ const throttledGetEnvelope = (endpoint, envelopeId) => {
647
+ if (cachedEnvelopes[envelopeId] && cachedEnvelopes[envelopeId].loaded + 2000 < new Date().getTime()) {
648
+ return cachedEnvelopes[envelopeId].envelope;
649
+ }
650
+ return getEnvelope(endpoint, envelopeId).then((envelope) => {
651
+ cachedEnvelopes[envelopeId] = { loaded: new Date().getTime(), envelope };
652
+ return envelope;
653
+ });
654
+ };
655
+ /**a
656
+ * Lists all envelopes accessible by the caller, with optional filters.
657
+ *
658
+ * ```typescript
659
+ * import {Envelopes} from '@verdocs/js-sdk/Envelopes';
660
+ *
661
+ * const {totals, envelopes} = await Envelopes.listEnvelopes((VerdocsEndpoint.getDefault(), { q: 'test', sort: 'created_at' });
662
+ * ```
663
+ */
664
+ const listEnvelopes = (endpoint, params) => endpoint.api //
665
+ .post('/envelopes/list', params)
666
+ .then((r) => r.data);
667
+
668
+ var Envelopes = /*#__PURE__*/Object.freeze({
669
+ __proto__: null,
670
+ cancelEnvelope: cancelEnvelope,
671
+ createEnvelope: createEnvelope,
672
+ deleteEnvelopeFieldAttachment: deleteEnvelopeFieldAttachment,
673
+ getDocumentDownloadLink: getDocumentDownloadLink,
674
+ getDocumentPreviewLink: getDocumentPreviewLink,
675
+ getEnvelope: getEnvelope,
676
+ getEnvelopeDocument: getEnvelopeDocument,
677
+ getEnvelopeDocumentPageDisplayUri: getEnvelopeDocumentPageDisplayUri,
678
+ getEnvelopeFile: getEnvelopeFile,
679
+ getEnvelopeRecipients: getEnvelopeRecipients,
680
+ getFieldAttachment: getFieldAttachment,
681
+ getSigningSession: getSigningSession,
682
+ getSummary: getSummary$1,
683
+ listEnvelopes: listEnvelopes,
684
+ searchEnvelopes: searchEnvelopes,
685
+ throttledGetEnvelope: throttledGetEnvelope,
686
+ updateEnvelopeField: updateEnvelopeField,
687
+ updateEnvelopeFieldInitials: updateEnvelopeFieldInitials,
688
+ updateEnvelopeFieldSignature: updateEnvelopeFieldSignature,
689
+ uploadEnvelopeFieldAttachment: uploadEnvelopeFieldAttachment
690
+ });
691
+
692
+ /**
693
+ * Various helpers to identify available operations for an envelope by a user.
694
+ *
695
+ * @module
696
+ */
697
+ /**
698
+ * Check to see if the user owns the envelope.
699
+ */
700
+ const userIsEnvelopeOwner = (session, envelope) => envelope.profile_id === session?.profile_id;
701
+ /**
702
+ * Check to see if the user owns the envelope.
703
+ */
704
+ const userIsEnvelopeRecipient = (session, envelope) => envelope.profile_id === session?.profile_id;
705
+ /**
706
+ * Check to see if the envelope has pending actions.
707
+ */
708
+ const envelopeIsActive = (envelope) => envelope.status !== 'complete' && envelope.status !== 'declined' && envelope.status !== 'canceled';
709
+ /**
710
+ * Check to see if the envelope has been completed.
711
+ */
712
+ const envelopeIsComplete = (envelope) => envelope.status !== 'complete';
713
+ /**
714
+ * Check to see if the user owns the envelope.
715
+ */
716
+ const userCanCancelEnvelope = (session, envelope) => userIsEnvelopeOwner(session, envelope) &&
717
+ envelope.status !== 'complete' &&
718
+ envelope.status !== 'declined' &&
719
+ envelope.status !== 'canceled';
720
+ /**
721
+ * Check to see if the user owns the envelope.
722
+ */
723
+ const userCanFinishEnvelope = (session, envelope) => userIsEnvelopeOwner(session, envelope) &&
724
+ envelope.status !== 'complete' &&
725
+ envelope.status !== 'declined' &&
726
+ envelope.status !== 'canceled';
727
+ /**
728
+ * Returns true if the recipient has a pending action. Note that this does not necessarily mean the recipient can act (yet).
729
+ */
730
+ const recipientHasAction = (recipient) => !['submitted', 'canceled', 'declined'].includes(recipient.status);
731
+ /**
732
+ * Returns the recipients who still have a pending action. Note that not all of these recipients may be able to act (yet).
733
+ */
734
+ const getRecipientsWithActions = (envelope) => (envelope?.recipients || []).filter(recipientHasAction);
735
+ /**
736
+ * Returns true if the recipient can act.
737
+ */
738
+ const recipientCanAct = (recipient, recipientsWithActions) => recipient.sequence === recipientsWithActions?.[0]?.sequence;
739
+ /**
740
+ * Returns true if the user can act.
741
+ */
742
+ const userCanAct = (email, recipientsWithActions) => {
743
+ const recipient = recipientsWithActions.find((r) => r.email === email);
744
+ return recipient && recipient.sequence === recipientsWithActions?.[0]?.sequence;
745
+ };
746
+ /**
747
+ * Returns true if the user can act.
748
+ */
749
+ const userCanSignNow = (session, envelope) => {
750
+ if (!session) {
751
+ return false;
752
+ }
753
+ const recipientsWithActions = getRecipientsWithActions(envelope);
754
+ const myRecipient = recipientsWithActions.find((r) => r.profile_id === session?.profile_id || r.email === session?.email);
755
+ return (myRecipient &&
756
+ envelopeIsActive(envelope) &&
757
+ userIsEnvelopeRecipient(session, envelope) &&
758
+ recipientCanAct(myRecipient, recipientsWithActions));
759
+ };
760
+ const getNextRecipient = (envelope) => {
761
+ const recipientsWithActions = getRecipientsWithActions(envelope);
762
+ return recipientsWithActions?.[0];
763
+ };
764
+
765
+ var Permissions = /*#__PURE__*/Object.freeze({
766
+ __proto__: null,
767
+ envelopeIsActive: envelopeIsActive,
768
+ envelopeIsComplete: envelopeIsComplete,
769
+ getNextRecipient: getNextRecipient,
770
+ getRecipientsWithActions: getRecipientsWithActions,
771
+ recipientCanAct: recipientCanAct,
772
+ recipientHasAction: recipientHasAction,
773
+ userCanAct: userCanAct,
774
+ userCanCancelEnvelope: userCanCancelEnvelope,
775
+ userCanFinishEnvelope: userCanFinishEnvelope,
776
+ userCanSignNow: userCanSignNow,
777
+ userIsEnvelopeOwner: userIsEnvelopeOwner,
778
+ userIsEnvelopeRecipient: userIsEnvelopeRecipient
779
+ });
780
+
781
+ /**
782
+ * Update a recipient's status block
783
+ */
784
+ const updateRecipient = async (endpoint, envelopeId, roleName, params) => endpoint.api //
785
+ .put(`/envelopes/${envelopeId}/recipients/${roleName}`, params)
786
+ .then((r) => r.data);
787
+ /**
788
+ * Submit an envelope (signing is finished). Note that all fields must be valid/completed for this to succeed.
789
+ */
790
+ const envelopeRecipientSubmit = (endpoint, envelopeId, roleName) => updateRecipient(endpoint, envelopeId, roleName, { action: 'submit' });
791
+ /**
792
+ * Decline to complete an envelope (signing will not terminated).
793
+ */
794
+ const envelopeRecipientDecline = (endpoint, envelopeId, roleName) => updateRecipient(endpoint, envelopeId, roleName, { action: 'decline' });
795
+ /**
796
+ * Claim / change ownership of an envelope. This is a special-case operation only available in certain workflows.
797
+ */
798
+ const envelopeRecipientChangeOwner = (endpoint, envelopeId, roleName, email, fullName) => updateRecipient(endpoint, envelopeId, roleName, { action: 'owner_update', email, full_name: fullName });
799
+ /**
800
+ * Agree to electronic signing.
801
+ */
802
+ const envelopeRecipientAgree = (endpoint, envelopeId, roleName, agreed) => updateRecipient(endpoint, envelopeId, roleName, { action: 'update', agreed });
803
+ /**
804
+ * Change a recipient's name.
805
+ */
806
+ const envelopeRecipientUpdateName = (endpoint, envelopeId, roleName, fullName) => updateRecipient(endpoint, envelopeId, roleName, { action: 'update', new_full_name: fullName });
807
+ /**
808
+ * Change a recipient's name.
809
+ */
810
+ const envelopeRecipientPrepare = (endpoint, envelopeId, roleName, recipients) => updateRecipient(endpoint, envelopeId, roleName, { action: 'prepare', recipients });
811
+ /**
812
+ * Get a signing token.
813
+ */
814
+ const getSignerToken = (endpoint, envelopeId, roleName) => endpoint.api //
815
+ .get(`/envelopes/${envelopeId}/recipients/${encodeURIComponent(roleName)}/signer-token`)
816
+ .then((r) => r.data);
817
+ /**
818
+ * Get an in-person signing link.
819
+ */
820
+ const getInPersonLink = (endpoint, envelopeId, roleName) => endpoint.api //
821
+ .get(`/envelopes/${envelopeId}/recipients/${encodeURIComponent(roleName)}?in_person_link=true`)
822
+ .then((r) => r.data);
823
+ /**
824
+ * Send a delegation request.
825
+ */
826
+ const sendDelegate = (endpoint, envelopeId, roleName) => endpoint.api //
827
+ .post(`/envelopes/${envelopeId}/recipients/${encodeURIComponent(roleName)}/delegate`)
828
+ .then((r) => r.data);
829
+ /**
830
+ * Resend a recipient's invitation.
831
+ */
832
+ const resendInvitation$1 = (endpoint, envelopeId, roleName) => endpoint.api //
833
+ .post(`/envelopes/${envelopeId}/recipients/${encodeURIComponent(roleName)}/resend_invitation`)
834
+ .then((r) => r.data);
835
+
836
+ var Recipients = /*#__PURE__*/Object.freeze({
837
+ __proto__: null,
838
+ envelopeRecipientAgree: envelopeRecipientAgree,
839
+ envelopeRecipientChangeOwner: envelopeRecipientChangeOwner,
840
+ envelopeRecipientDecline: envelopeRecipientDecline,
841
+ envelopeRecipientPrepare: envelopeRecipientPrepare,
842
+ envelopeRecipientSubmit: envelopeRecipientSubmit,
843
+ envelopeRecipientUpdateName: envelopeRecipientUpdateName,
844
+ getInPersonLink: getInPersonLink,
845
+ getSignerToken: getSignerToken,
846
+ resendInvitation: resendInvitation$1,
847
+ sendDelegate: sendDelegate,
848
+ updateRecipient: updateRecipient
849
+ });
850
+
851
+ /**
852
+ * Enable automatic reminders. setup_time is the number of days after the envelope is sent that the first reminder
853
+ * should be sent. interval_time is the number of days between reminders.
854
+ */
855
+ const createReminder$1 = (endpoint, envelopeId, params) => endpoint.api //
856
+ .post(`/envelopes/${envelopeId}/reminder/`, params)
857
+ .then((r) => r.data);
858
+ /**
859
+ * Get the reminder configuration for an envelope.
860
+ */
861
+ const getReminder$1 = (endpoint, envelopeId, reminderId) => endpoint.api //
862
+ .get(`/envelopes/${envelopeId}/reminder/${reminderId}`)
863
+ .then((r) => r.data);
864
+ /**
865
+ * Update the reminder configuration for an envelope.
866
+ */
867
+ const updateReminder$1 = (endpoint, envelopeId, reminderId, params) => endpoint.api //
868
+ .put(`/envelopes/${envelopeId}/reminder/${reminderId}`, params)
869
+ .then((r) => r.data);
870
+ /**
871
+ * Delete the reminder configuration for an envelope.
872
+ */
873
+ const deleteReminder$1 = (endpoint, envelopeId, reminderId) => endpoint.api //
874
+ .delete(`/envelopes/${envelopeId}/reminder/${reminderId}`)
875
+ .then((r) => r.data);
876
+
877
+ var Reminders$1 = /*#__PURE__*/Object.freeze({
878
+ __proto__: null,
879
+ createReminder: createReminder$1,
880
+ deleteReminder: deleteReminder$1,
881
+ getReminder: getReminder$1,
882
+ updateReminder: updateReminder$1
883
+ });
884
+
885
+ /**
886
+ * Create a signature block. In a typical signing workflow, the user is asked at the beginning of the process to "adopt"
887
+ * a signature block to be used for all signature fields in the document. Thus, this is typically called one time to
888
+ * create and store a signature block. Thereafter, the ID of the signature block may be re-used for each signature field
889
+ * to be "stamped" by the user.
890
+ */
891
+ const createSignature = (endpoint, name, signature) => {
892
+ const data = new FormData();
893
+ data.append('signature', signature, name);
894
+ return endpoint.api //
895
+ .post(`/signatures`, data)
896
+ .then((r) => r.data);
897
+ };
898
+ /**
899
+ * Get the availbable signatures for a user.
900
+ */
901
+ const getSignatures = (endpoint) => endpoint.api //
902
+ .get('/signatures')
903
+ .then((r) => r.data);
904
+ /**
905
+ * Get a user's signature by ID.
906
+ */
907
+ const getSignature = (endpoint, signatureId) => endpoint.api //
908
+ .get(`/signatures/${signatureId}`)
909
+ .then((r) => r.data);
910
+ /**
911
+ * Delete a user's signature.
912
+ */
913
+ const deleteSignature = (endpoint, signatureId) => endpoint.api //
914
+ .delete(`/signatures/${signatureId}`)
915
+ .then((r) => r.data);
916
+
917
+ var Signatures = /*#__PURE__*/Object.freeze({
918
+ __proto__: null,
919
+ createSignature: createSignature,
920
+ deleteSignature: deleteSignature,
921
+ getSignature: getSignature,
922
+ getSignatures: getSignatures
923
+ });
924
+
925
+ /**
926
+ * Create an initials block. In a typical signing workflow, the user is asked at the beginning of the process to "adopt"
927
+ * an initials block to be used for all initials fields in the document. Thus, this is typically called one time to
928
+ * create and store an initials block. Thereafter, the ID of the initials block may be re-used for each initials field
929
+ * to be "stamped" by the user.
930
+ */
931
+ const createInitials = (endpoint, name, initials) => {
932
+ const data = new FormData();
933
+ data.append('initial', initials, name);
934
+ return endpoint.api //
935
+ .post(`/initials`, data)
936
+ .then((r) => r.data);
937
+ };
938
+
939
+ var Initials = /*#__PURE__*/Object.freeze({
940
+ __proto__: null,
941
+ createInitials: createInitials
942
+ });
943
+
944
+ var Types$5 = /*#__PURE__*/Object.freeze({
945
+ __proto__: null
946
+ });
947
+
948
+ var index$5 = /*#__PURE__*/Object.freeze({
949
+ __proto__: null,
950
+ Envelopes: Envelopes,
951
+ Initials: Initials,
952
+ Permissions: Permissions,
953
+ Recipients: Recipients,
954
+ Reminders: Reminders$1,
955
+ Signatures: Signatures,
956
+ Types: Types$5
957
+ });
958
+
959
+ /**
960
+ * API keys are used to authenticate server-to-server calls. (API keys should **never** be used for client-to-server operations!)
961
+ * To generate a key, either use the Verdocs admin interface and make note of the client_id and client_secret generated, or call
962
+ * createKey as shown below. Then call {@link Users.Auth.authenticateApp} to obtain an access token using the provided ID and
963
+ * secret. Note that server-to-server authentication requests return shorter-lived tokens, so it is important to check the `exp`
964
+ * field and re-authenticate as needed for subsequent calls.
965
+ *
966
+ * API keys may be updated or rotated at any time. Regular rotation is recommended. Rotation will not expire or invalidate
967
+ * existing server-to-server sessions, so it may be done at any time without disrupting your application.
968
+ *
969
+ * @module
970
+ */
971
+ /**
972
+ * Get a list of keys for a given organization. The caller must have admin access to the organization.
973
+ *
974
+ * ```typescript
975
+ * import {ApiKeys} from '@verdocs/js-sdk/Organizations';
976
+ *
977
+ * const keys = await ApiKeys.getKeys(ORGID);
978
+ * ```
979
+ */
980
+ const getKeys = (endpoint, organizationId) => endpoint.api //
981
+ .get(`/organizations/${organizationId}/api_key`)
982
+ .then((r) => r.data);
983
+ /**
984
+ * Create an API key.
985
+ *
986
+ * ```typescript
987
+ * import {ApiKeys} from '@verdocs/js-sdk/Organizations';
988
+ *
989
+ * await ApiKeys.createKey(ORGID, {name: NEWNAME});
990
+ * ```
991
+ */
992
+ const createKey = (endpoint, organizationId, params) => endpoint.api //
993
+ .post(`/organizations/${organizationId}/api_key`, params)
994
+ .then((r) => r.data);
995
+ /**
996
+ * Rotate the secret for an API key. The caller must have admin access to the organization.
997
+ *
998
+ * ```typescript
999
+ * import {ApiKeys} from '@verdocs/js-sdk/Organizations';
1000
+ *
1001
+ * const {client_secret: newSecret} = await ApiKeys.rotateKey(ORGID, CLIENTID);
1002
+ * ```
1003
+ */
1004
+ const rotateKey = (endpoint, organizationId, clientId) => endpoint.api //
1005
+ .put(`/organizations/${organizationId}/api_key/${clientId}/rotate`)
1006
+ .then((r) => r.data);
1007
+ /**
1008
+ * Update an API key to change its assigned Profile ID or Name.
1009
+ *
1010
+ * ```typescript
1011
+ * import {ApiKeys} from '@verdocs/js-sdk/Organizations';
1012
+ *
1013
+ * await ApiKeys.updateKey(ORGID, CLIENTID, {name: NEWNAME});
1014
+ * ```
1015
+ */
1016
+ const updateKey = (endpoint, organizationId, clientId, params) => endpoint.api //
1017
+ .patch(`/organizations/${organizationId}/api_key/${clientId}`, params)
1018
+ .then((r) => r.data);
1019
+ /**
1020
+ * Delete an API key.
1021
+ *
1022
+ * ```typescript
1023
+ * import {ApiKeys} from '@verdocs/js-sdk/Organizations';
1024
+ *
1025
+ * await ApiKeys.deleteKey(ORGID, CLIENTID);
1026
+ * ```
1027
+ */
1028
+ const deleteKey = (endpoint, organizationId, clientId) => endpoint.api //
1029
+ .delete(`/organizations/${organizationId}/api_key/${clientId}`)
1030
+ .then((r) => r.data);
1031
+
1032
+ var ApiKeys = /*#__PURE__*/Object.freeze({
1033
+ __proto__: null,
1034
+ createKey: createKey,
1035
+ deleteKey: deleteKey,
1036
+ getKeys: getKeys,
1037
+ rotateKey: rotateKey,
1038
+ updateKey: updateKey
1039
+ });
1040
+
1041
+ /**
1042
+ * Organizations may contain "Groups" of user profiles, called Members. Groups may have permissions assigned that
1043
+ * apply to all Members, making it easy to configure role-based access control (RBAC) within an Organization. Note
1044
+ * that permissions are **additive**. A user may be a member of more than one group, and may also have permissions
1045
+ * assigned directly. In that case, the user will have the combined set of all permissions inherited from all
1046
+ * sources.
1047
+ *
1048
+ * @module
1049
+ */
1050
+ /**
1051
+ * Get a list of groups for a given organization. The caller must have admin access to the organization.
1052
+ *
1053
+ * ```typescript
1054
+ * import {Groups} from '@verdocs/js-sdk/Organizations';
1055
+ *
1056
+ * const groups = await Groups.getGroups(ORGID);
1057
+ * ```
1058
+ */
1059
+ const getGroups = (endpoint, organizationId) => endpoint.api //
1060
+ .get(`/organizations/${organizationId}/groups`)
1061
+ .then((r) => r.data);
1062
+ /**
1063
+ * Get a single group by name. Returns a detail record.
1064
+ *
1065
+ * ```typescript
1066
+ * import {Groups} from '@verdocs/js-sdk/Organizations';
1067
+ *
1068
+ * const groups = await Groups.getGroups(ORGID);
1069
+ * ```
1070
+ */
1071
+ const getGroupByName = (endpoint, organizationId, name) => endpoint.api //
1072
+ .get(`/organizations/${organizationId}/groups`, { params: { name } })
1073
+ .then((r) => r.data);
1074
+ /**
1075
+ * Get the details for a group.
1076
+ *
1077
+ * ```typescript
1078
+ * import {Groups} from '@verdocs/js-sdk/Organizations';
1079
+ *
1080
+ * const groups = await Groups.getGroups(ORGID);
1081
+ * ```
1082
+ */
1083
+ const getGroup = (endpoint, organizationId, groupId) => endpoint.api //
1084
+ .get(`/organizations/${organizationId}/groups/${groupId}`)
1085
+ .then((r) => r.data);
1086
+ const getMembers$1 = (endpoint, organizationId, groupId) => endpoint.api //
1087
+ .get(`/organizations/${organizationId}/groups/${groupId}/members`)
1088
+ .then((r) => r.data);
1089
+ const addMembers = (endpoint, organizationId, groupId, params) => endpoint.api //
1090
+ .post(`/organizations/${organizationId}/groups/${groupId}/members`, params)
1091
+ .then((r) => r.data);
1092
+ const deleteMembers = (endpoint, organizationId, groupId, params) => endpoint.api //
1093
+ .put(`/organizations/${organizationId}/groups/${groupId}/delete_members`, params)
1094
+ .then((r) => r.data);
1095
+ const addPermission = (endpoint, organizationId, groupId, permissionId) => endpoint.api //
1096
+ .post(`/organizations/${organizationId}/groups/${groupId}/permissions/${permissionId}`, {})
1097
+ .then((r) => r.data);
1098
+ const deletePermission = (endpoint, organizationId, groupId, permissionId) => endpoint.api //
1099
+ .delete(`/organizations/${organizationId}/groups/${groupId}/permissions/${permissionId}`)
1100
+ .then((r) => r.data);
1101
+
1102
+ var Groups = /*#__PURE__*/Object.freeze({
1103
+ __proto__: null,
1104
+ addMembers: addMembers,
1105
+ addPermission: addPermission,
1106
+ deleteMembers: deleteMembers,
1107
+ deletePermission: deletePermission,
1108
+ getGroup: getGroup,
1109
+ getGroupByName: getGroupByName,
1110
+ getGroups: getGroups,
1111
+ getMembers: getMembers$1
1112
+ });
1113
+
1114
+ /**
1115
+ * An invitation represents an opportunity for a Member to join an Organization.
1116
+ *
1117
+ * @module
1118
+ */
1119
+ const getInvitations = (endpoint, organizationId) => endpoint.api //
1120
+ .get(`/organizations/${organizationId}/invitation`)
1121
+ .then((r) => r.data);
1122
+ const createInvitation = (endpoint, organizationId, params) => endpoint.api //
1123
+ .post(`/organizations/${organizationId}/invitation`, params)
1124
+ .then((r) => r.data);
1125
+ const deleteInvitation = (endpoint, organizationId, email) => endpoint.api //
1126
+ .delete(`/organizations/${organizationId}/invitation/${email}`)
1127
+ .then((r) => r.data);
1128
+ const updateInvitation = (endpoint, organizationId, email, params) => endpoint.api //
1129
+ .patch(`/organizations/${organizationId}/invitation/${email}`, params)
1130
+ .then((r) => r.data);
1131
+ const resendInvitation = (endpoint, organizationId, email) => endpoint.api //
1132
+ .post(`/organizations/${organizationId}/invitation/${email}/resend`)
1133
+ .then((r) => r.data);
1134
+ const getInvitation = (endpoint, organizationId, email, token) => endpoint.api //
1135
+ .get(`/organizations/${organizationId}/invitation/${email}/accept/${token}`)
1136
+ .then((r) => r.data);
1137
+ const acceptInvitation = (endpoint, organizationId, email, token) => endpoint.api //
1138
+ .post(`/organizations/${organizationId}/invitation/${email}/accept/${token}`)
1139
+ .then((r) => r.data);
1140
+ const declineInvitation = (endpoint, organizationId, email, token) => endpoint.api //
1141
+ .post(`/organizations/${organizationId}/invitation/${email}/decline/${token}`)
1142
+ .then((r) => r.data);
1143
+ const claimNewUser = (endpoint, organizationId, email, token) => endpoint.api //
1144
+ .put(`/organizations/${organizationId}/invitation/${email}/token/${token}/new_user`)
1145
+ .then((r) => r.data);
1146
+
1147
+ var Invitations = /*#__PURE__*/Object.freeze({
1148
+ __proto__: null,
1149
+ acceptInvitation: acceptInvitation,
1150
+ claimNewUser: claimNewUser,
1151
+ createInvitation: createInvitation,
1152
+ declineInvitation: declineInvitation,
1153
+ deleteInvitation: deleteInvitation,
1154
+ getInvitation: getInvitation,
1155
+ getInvitations: getInvitations,
1156
+ resendInvitation: resendInvitation,
1157
+ updateInvitation: updateInvitation
1158
+ });
1159
+
1160
+ /**
1161
+ * An Organization Member (aka Profile) is an individual user with access to an organization.
1162
+ *
1163
+ * @module
1164
+ */
1165
+ const getMembers = (endpoint, organizationId) => endpoint.api //
1166
+ .get(`/organizations/${organizationId}/profiles`)
1167
+ .then((r) => r.data);
1168
+ const deleteMember = (endpoint, organizationId, profileId) => endpoint.api //
1169
+ .delete(`/organizations/${organizationId}/profiles/${profileId}`)
1170
+ .then((r) => r.data);
1171
+ const addMemberRole = (endpoint, organizationId, profileId, roleId) => endpoint.api //
1172
+ .post(`/organizations/${organizationId}/profiles/${profileId}/role/${roleId}`)
1173
+ .then((r) => r.data);
1174
+ const deleteMemberRole = (endpoint, organizationId, profileId, roleId) => endpoint.api //
1175
+ .delete(`/organizations/${organizationId}/profiles/${profileId}/role/${roleId}`)
1176
+ .then((r) => r.data);
1177
+ const getMemberPlans = (endpoint, organizationId, profileId) => endpoint.api //
1178
+ .get(`/organizations/${organizationId}/profiles/${profileId}/plans`)
1179
+ .then((r) => r.data);
1180
+
1181
+ var Members = /*#__PURE__*/Object.freeze({
1182
+ __proto__: null,
1183
+ addMemberRole: addMemberRole,
1184
+ deleteMember: deleteMember,
1185
+ deleteMemberRole: deleteMemberRole,
1186
+ getMemberPlans: getMemberPlans,
1187
+ getMembers: getMembers
1188
+ });
1189
+
1190
+ /**
1191
+ * An Organization is the top level object for ownership for Members, Documents, and Templates.
1192
+ *
1193
+ * @module
1194
+ */
1195
+ /**
1196
+ * Get a list of organizations the user has access to.
1197
+ */
1198
+ const getOrganizations = (endpoint) => endpoint.api //
1199
+ .get('/organizations')
1200
+ .then((r) => r.data);
1201
+ /**
1202
+ * Create an organization.
1203
+ */
1204
+ const createOrganization = (endpoint) => endpoint.api //
1205
+ .post('/organizations')
1206
+ .then((r) => r.data);
1207
+ /**
1208
+ * Delete an organization.
1209
+ */
1210
+ const deleteOrganization = (endpoint, organizationId) => endpoint.api //
1211
+ .delete(`/organizations/${organizationId}`)
1212
+ .then((r) => r.data);
1213
+ /**
1214
+ * Get an organization by ID.
1215
+ */
1216
+ const getOrganization = (endpoint, organizationId) => endpoint.api //
1217
+ .get(`/organizations/${organizationId}`)
1218
+ .then((r) => r.data);
1219
+ /**
1220
+ * Update an organization.
1221
+ */
1222
+ const updateOrganization = (endpoint, organizationId, params) => endpoint.api //
1223
+ .patch(`/organizations/${organizationId}`, params)
1224
+ .then((r) => r.data);
1225
+
1226
+ var Organizations = /*#__PURE__*/Object.freeze({
1227
+ __proto__: null,
1228
+ createOrganization: createOrganization,
1229
+ deleteOrganization: deleteOrganization,
1230
+ getOrganization: getOrganization,
1231
+ getOrganizations: getOrganizations,
1232
+ updateOrganization: updateOrganization
1233
+ });
1234
+
1235
+ var Types$4 = /*#__PURE__*/Object.freeze({
1236
+ __proto__: null
1237
+ });
1238
+
1239
+ const getWebhooks = (endpoint) => endpoint.api //
1240
+ .get(`/v2/webhooks/organization`)
1241
+ .then((r) => r.data);
1242
+ const setWebhooks = (endpoint, params) => endpoint.api //
1243
+ .post(`/v2/webhooks/organization`, params)
1244
+ .then((r) => r.data);
1245
+
1246
+ var Webhooks = /*#__PURE__*/Object.freeze({
1247
+ __proto__: null,
1248
+ getWebhooks: getWebhooks,
1249
+ setWebhooks: setWebhooks
1250
+ });
1251
+
1252
+ /**
1253
+ * An Organization is a high-level container within Verdocs that groups together Templates, Documents, Profiles, Billing, and
1254
+ * other settings. A User may be a member of more than one Organization. Each membership is tracked by a Profile representing
1255
+ * that user's settings within that organization. It is important to select the correct Profile before performing operations
1256
+ * against the Verdocs API, as this also sets the Organization that will be operated on, and the user's permissions within it.
1257
+ *
1258
+ * @module
1259
+ */
1260
+
1261
+ var index$4 = /*#__PURE__*/Object.freeze({
1262
+ __proto__: null,
1263
+ ApiKeys: ApiKeys,
1264
+ Groups: Groups,
1265
+ Invitations: Invitations,
1266
+ Members: Members,
1267
+ Organizations: Organizations,
1268
+ Types: Types$4,
1269
+ Webhooks: Webhooks
1270
+ });
1271
+
1272
+ var Types$3 = /*#__PURE__*/Object.freeze({
1273
+ __proto__: null
1274
+ });
1275
+
1276
+ /**
1277
+ * Confirm whether the user has all of the specified permissions.
1278
+ */
1279
+ const userHasPermissions = (session, permissions) => permissions.every((perm) => (session?.permissions || []).includes(perm));
1280
+
1281
+ var index$3 = /*#__PURE__*/Object.freeze({
1282
+ __proto__: null,
1283
+ Types: Types$3,
1284
+ userHasPermissions: userHasPermissions
1285
+ });
1286
+
1287
+ const canPerformTemplateAction = (session, action, template) => {
1288
+ if (!template && !action.includes('create')) {
1289
+ return { canPerform: false, message: 'Missing required template object' };
1290
+ }
1291
+ // We use BOGUS here to force the option-chain in things like template?.profile_id to NOT match profile?.profile_id because if both
1292
+ // were undefined, they would actually match.
1293
+ const profile_id = session?.profile_id || 'BOGUS';
1294
+ const organization_id = session?.organization_id || 'BOGUS';
1295
+ if (!profile_id) {
1296
+ return { canPerform: false, message: 'Active session required' };
1297
+ }
1298
+ const isCreator = template?.profile_id === profile_id;
1299
+ const isSameOrg = template?.organization_id === organization_id;
1300
+ const isPersonal = template?.is_personal ?? false;
1301
+ const isPublic = template?.is_public ?? false;
1302
+ const permissionsRequired = [];
1303
+ switch (action) {
1304
+ case 'create_personal':
1305
+ permissionsRequired.push('template:creator:create:personal');
1306
+ break;
1307
+ case 'create_org':
1308
+ permissionsRequired.push('template:creator:create:org');
1309
+ break;
1310
+ case 'create_public':
1311
+ permissionsRequired.push('template:creator:create:public');
1312
+ break;
1313
+ case 'read':
1314
+ if (!isCreator) {
1315
+ if ((!isPersonal && isSameOrg) || !isPublic) {
1316
+ permissionsRequired.push('template:member:read');
1317
+ }
1318
+ }
1319
+ break;
1320
+ case 'write':
1321
+ if (!isCreator) {
1322
+ permissionsRequired.push('template:member:read');
1323
+ permissionsRequired.push('template:member:write');
1324
+ }
1325
+ break;
1326
+ case 'change_visibility_personal':
1327
+ if (isCreator) {
1328
+ permissionsRequired.push('template:creator:create:personal');
1329
+ }
1330
+ else {
1331
+ permissionsRequired.push('template:member:visibility');
1332
+ }
1333
+ break;
1334
+ case 'change_visibility_org':
1335
+ if (isCreator) {
1336
+ permissionsRequired.push('template:creator:create:org');
1337
+ }
1338
+ else {
1339
+ permissionsRequired.push('template:member:visibility');
1340
+ }
1341
+ break;
1342
+ case 'change_visibility_public':
1343
+ if (isCreator) {
1344
+ permissionsRequired.push('template:creator:create:public');
1345
+ permissionsRequired.push('template:creator:visibility');
1346
+ }
1347
+ else {
1348
+ permissionsRequired.push('template:member:visibility');
1349
+ }
1350
+ break;
1351
+ case 'delete':
1352
+ if (isCreator) {
1353
+ permissionsRequired.push('template:creator:delete');
1354
+ }
1355
+ else {
1356
+ permissionsRequired.push('template:member:delete');
1357
+ }
1358
+ break;
1359
+ default:
1360
+ return { canPerform: false, message: 'Action is not defined' };
1361
+ }
1362
+ if (hasRequiredPermissions(session, permissionsRequired)) {
1363
+ return { canPerform: true, message: '' };
1364
+ }
1365
+ return { canPerform: false, message: `Insufficient access to perform '${action}'. Needed permissions: ${permissionsRequired.toString()}` };
1366
+ };
1367
+ const hasRequiredPermissions = (session, permissions) => permissions.every((perm) => (session?.permissions || []).includes(perm));
1368
+
1369
+ var Actions = /*#__PURE__*/Object.freeze({
1370
+ __proto__: null,
1371
+ canPerformTemplateAction: canPerformTemplateAction,
1372
+ hasRequiredPermissions: hasRequiredPermissions
1373
+ });
1374
+
1375
+ /**
1376
+ * Add a field to a template.
1377
+ */
1378
+ const createField = (endpoint, templateId, params) => endpoint.api //
1379
+ .post(`/templates/${templateId}/fields`, params)
1380
+ .then((r) => r.data);
1381
+ /**
1382
+ * Update a template field.
1383
+ */
1384
+ const updateField = (endpoint, templateId, fieldName, params) => endpoint.api //
1385
+ .put(`/templates/${templateId}/fields/${fieldName}`, params)
1386
+ .then((r) => r.data);
1387
+ /**
1388
+ * REmove a field from a template.
1389
+ */
1390
+ const deleteField = (endpoint, templateId, fieldName) => endpoint.api //
1391
+ .delete(`/templates/${templateId}/fields/${fieldName}`)
1392
+ .then((r) => r.data);
1393
+
1394
+ var Fields$1 = /*#__PURE__*/Object.freeze({
1395
+ __proto__: null,
1396
+ createField: createField,
1397
+ deleteField: deleteField,
1398
+ updateField: updateField
1399
+ });
1400
+
1401
+ /**
1402
+ * Enable automatic reminders. setup_time is the number of days after the envelope is sent that the first reminder
1403
+ * should be sent. interval_time is the number of days between reminders.
1404
+ */
1405
+ const createReminder = (endpoint, templateId, params) => endpoint.api //
1406
+ .post(`/templates/${templateId}/reminder/`, params)
1407
+ .then((r) => r.data);
1408
+ /**
1409
+ * Get the reminder configuration for a template.
1410
+ */
1411
+ const getReminder = (endpoint, templateId, reminderId) => endpoint.api //
1412
+ .get(`/templates/${templateId}/reminder/${reminderId}`)
1413
+ .then((r) => r.data);
1414
+ /**
1415
+ * Update the reminder configuration for a template.
1416
+ */
1417
+ const updateReminder = (endpoint, templateId, reminderId, params) => endpoint.api //
1418
+ .put(`/templates/${templateId}/reminder/${reminderId}`, params)
1419
+ .then((r) => r.data);
1420
+ /**
1421
+ * Delete the reminder configuration for a template.
1422
+ */
1423
+ const deleteReminder = (endpoint, templateId, reminderId) => endpoint.api //
1424
+ .delete(`/templates/${templateId}/reminder/${reminderId}`)
1425
+ .then((r) => r.data);
1426
+
1427
+ var Reminders = /*#__PURE__*/Object.freeze({
1428
+ __proto__: null,
1429
+ createReminder: createReminder,
1430
+ deleteReminder: deleteReminder,
1431
+ getReminder: getReminder,
1432
+ updateReminder: updateReminder
1433
+ });
1434
+
1435
+ /**
1436
+ * A "role" is an individual participant in a signing flow, such as a signer or CC contact. Roles are identified by
1437
+ * their names, which must be unique (e.g. 'Recipient 1'). Template fields are assigned to roles for signing operations,
1438
+ * so you may have 'Recipient 1 Signature 1' and so forth.
1439
+ *
1440
+ * @module
1441
+ */
1442
+ const createRole = (endpoint, templateId, params) => endpoint.api //
1443
+ .post(`/templates/${templateId}/roles`, params)
1444
+ .then((r) => r.data);
1445
+ const getRoles$1 = (endpoint, templateId) => endpoint.api //
1446
+ .get(`/templates/${templateId}/roles`)
1447
+ .then((r) => r.data);
1448
+ const getRole = (endpoint, templateId, roleName) => endpoint.api //
1449
+ .get(`/templates/${templateId}/roles/${roleName}`)
1450
+ .then((r) => r.data);
1451
+ const updateRole = (endpoint, templateId, roleName, params) => endpoint.api //
1452
+ .put(`/templates/${templateId}/roles/${roleName}`, params)
1453
+ .then((r) => r.data);
1454
+ const deleteRole = (endpoint, templateId, roleName) => endpoint.api //
1455
+ .delete(`/templates/${templateId}/roles/${roleName}`)
1456
+ .then((r) => r.data);
1457
+ const getRoleFields = (endpoint, templateId, roleName) => endpoint.api //
1458
+ .get(`/templates/${templateId}/roles/${roleName}/fields`)
1459
+ .then((r) => r.data);
1460
+ const deleteSequence = (endpoint, templateId) => endpoint.api //
1461
+ .delete(`/templates/${templateId}/roles`)
1462
+ .then((r) => r.data);
1463
+
1464
+ var Roles = /*#__PURE__*/Object.freeze({
1465
+ __proto__: null,
1466
+ createRole: createRole,
1467
+ deleteRole: deleteRole,
1468
+ deleteSequence: deleteSequence,
1469
+ getRole: getRole,
1470
+ getRoleFields: getRoleFields,
1471
+ getRoles: getRoles$1,
1472
+ updateRole: updateRole
1473
+ });
1474
+
1475
+ /**
1476
+ * Get the template stars for a template.
1477
+ */
1478
+ const getStars = (endpoint, templateId) => endpoint.api //
1479
+ .get(`/templates/${templateId}/stars`)
1480
+ .then((r) => r.data);
1481
+ /**
1482
+ * Toggle the template star for a template.
1483
+ */
1484
+ const toggleStar = (endpoint, templateId) => endpoint.api //
1485
+ .post(`/templates/${templateId}/stars/toggle`)
1486
+ .then((r) => r.data);
1487
+
1488
+ var Stars = /*#__PURE__*/Object.freeze({
1489
+ __proto__: null,
1490
+ getStars: getStars,
1491
+ toggleStar: toggleStar
1492
+ });
1493
+
1494
+ /**
1495
+ * A Tag is a user-specified label applied to a template. Tags help users organize and find Templates.
1496
+ * recipients. Every Organization has a set of tags "owned" by that Organization and only visible inside it.
1497
+ * Verdocs also provides a set of system-wide "featured" tags available to all Organizations.
1498
+ *
1499
+ * @module
1500
+ */
1501
+ /**
1502
+ * Apply a tag to a template.
1503
+ */
1504
+ const addTemplateTag = (endpoint, templateId, params) => endpoint.api //
1505
+ .post(`/templates/${templateId}/tags/`, params)
1506
+ .then((r) => r.data);
1507
+ /**
1508
+ * Get all tags for a template.
1509
+ */
1510
+ const getTemplateTags = (endpoint, templateId) => endpoint.api //
1511
+ .get(`/templates/${templateId}/tags/`)
1512
+ .then((r) => r.data);
1513
+ /**
1514
+ * Remove a tag from a template.
1515
+ */
1516
+ const deleteTemplateTag = (endpoint, templateId, tagName) => endpoint.api //
1517
+ .post(`/templates/${templateId}/tags/${tagName}`)
1518
+ .then((r) => r.data);
1519
+ /**
1520
+ * Create an Organization-wide tag.
1521
+ */
1522
+ const createTag = (endpoint, name) => endpoint.api //
1523
+ .post('/tags', { tag_name: name })
1524
+ .then((r) => r.data);
1525
+ /**
1526
+ * Get an Organization-wide tag.
1527
+ */
1528
+ const getTag = (endpoint, name) => endpoint.api //
1529
+ .get(`/tags/${name}`)
1530
+ .then((r) => r.data);
1531
+ /**
1532
+ * Get all tags available for use by an Organization.
1533
+ */
1534
+ const getAllTags = (endpoint) => endpoint.api //
1535
+ .get('/tags')
1536
+ .then((r) => r.data);
1537
+
1538
+ var Tags = /*#__PURE__*/Object.freeze({
1539
+ __proto__: null,
1540
+ addTemplateTag: addTemplateTag,
1541
+ createTag: createTag,
1542
+ deleteTemplateTag: deleteTemplateTag,
1543
+ getAllTags: getAllTags,
1544
+ getTag: getTag,
1545
+ getTemplateTags: getTemplateTags
1546
+ });
1547
+
1548
+ /**
1549
+ * A Template defines how a Verdocs signing flow will be performed, including attachments, signing fields, and
1550
+ * recipients.
1551
+ *
1552
+ * @module
1553
+ */
1554
+ /**
1555
+ * Get all templates accessible by the caller, with optional filters.
1556
+ *
1557
+ * ```typescript
1558
+ * import {Templates} from '@verdocs/js-sdk/Templates';
1559
+ *
1560
+ * await Templates.getTemplates((VerdocsEndpoint.getDefault());
1561
+ * await Templates.getTemplates((VerdocsEndpoint.getDefault(), { is_starred: true });
1562
+ * await Templates.getTemplates((VerdocsEndpoint.getDefault(), { is_creator: true });
1563
+ * await Templates.getTemplates((VerdocsEndpoint.getDefault(), { is_organization: true });
1564
+ * ```
1565
+ */
1566
+ const getTemplates = (endpoint, params) => endpoint.api //
1567
+ .post('/templates', { params })
1568
+ .then((r) => r.data);
1569
+ // export interface IListTemplatesParams {
1570
+ // name?: string;
1571
+ // sharing?: 'all' | 'personal' | 'shared' | 'public';
1572
+ // starred?: 'all' | 'starred' | 'unstarred';
1573
+ // sort?: 'name' | 'created_at' | 'updated_at' | 'last_used_at' | 'counter' | 'star_counter';
1574
+ // direction?: 'asc' | 'desc';
1575
+ // page?: number;
1576
+ // rows?: number;
1577
+ // }
1578
+ /**
1579
+ * Lists all templates accessible by the caller, with optional filters.
1580
+ *
1581
+ * ```typescript
1582
+ * import {Templates} from '@verdocs/js-sdk/Templates';
1583
+ *
1584
+ * await Templates.listTemplates((VerdocsEndpoint.getDefault(), { sharing: 'personal', sort: 'last_used_at' });
1585
+ * ```
1586
+ */
1587
+ // export const listTemplates = (endpoint: VerdocsEndpoint, params?: IListTemplatesParams) =>
1588
+ // endpoint.api //
1589
+ // .post<ITemplateSummaries>('/templates/list', params, {baseURL: endpoint.getBaseURLv2()})
1590
+ // .then((r) => r.data);
1591
+ /**
1592
+ * Get one template by its ID.
1593
+ *
1594
+ * ```typescript
1595
+ * import {Templates} from '@verdocs/js-sdk/Templates';
1596
+ *
1597
+ * const template = await Templates.getTemplate((VerdocsEndpoint.getDefault(), '83da3d70-7857-4392-b876-c4592a304bc9');
1598
+ * ```
1599
+ */
1600
+ const getTemplate = (endpoint, templateId) => endpoint.api //
1601
+ .get(`/templates/${templateId}`)
1602
+ .then((r) => r.data);
1603
+ /**
1604
+ * Get owner information for a template.
1605
+ *
1606
+ * ```typescript
1607
+ * import {Templates} from '@verdocs/js-sdk/Templates';
1608
+ *
1609
+ * const template = await Templates.getTemplateOwnerInfo((VerdocsEndpoint.getDefault(), '83da3d70-7857-4392-b876-c4592a304bc9');
1610
+ * ```
1611
+ */
1612
+ const getTemplateOwnerInfo = (endpoint, templateId) => endpoint.api //
1613
+ .get(`/templates/${templateId}`)
1614
+ .then((r) => r.data);
1615
+ const ALLOWED_CREATE_FIELDS = [
1616
+ 'name',
1617
+ 'is_personal',
1618
+ 'is_public',
1619
+ 'sender',
1620
+ 'description',
1621
+ 'roles',
1622
+ 'fields',
1623
+ ];
1624
+ /**
1625
+ * Create a template.
1626
+ *
1627
+ * ```typescript
1628
+ * import {Templates} from '@verdocs/js-sdk/Templates';
1629
+ *
1630
+ * const newTemplate = await Templates.createTemplate((VerdocsEndpoint.getDefault(), {...});
1631
+ * ```
1632
+ */
1633
+ const createTemplate = (endpoint, params, onUploadProgress) => {
1634
+ const options = {
1635
+ timeout: 120000,
1636
+ onUploadProgress: (event) => {
1637
+ const total = event.total || 1;
1638
+ const loaded = event.loaded || 0;
1639
+ onUploadProgress?.(Math.floor((loaded * 100) / (total || 1)), loaded, total || 1);
1640
+ },
1641
+ };
1642
+ if (params.documents && params.documents[0] instanceof File) {
1643
+ if (params.documents.length > 10) {
1644
+ throw new Error('createTemplate() has a maximum of 10 documents that can be attached.');
1645
+ }
1646
+ const formData = new FormData();
1647
+ ALLOWED_CREATE_FIELDS.forEach((allowedKey) => {
1648
+ if (params[allowedKey] !== undefined) {
1649
+ formData.append(allowedKey, params[allowedKey]);
1650
+ }
1651
+ });
1652
+ params.documents.forEach((file) => {
1653
+ formData.append('documents', file, file.name);
1654
+ });
1655
+ return endpoint.api.post('/templates', formData, options).then((r) => r.data);
1656
+ }
1657
+ else {
1658
+ return endpoint.api.post('/templates', params, options).then((r) => r.data);
1659
+ }
1660
+ };
1661
+ /**
1662
+ * Create a template.
1663
+ *
1664
+ * ```typescript
1665
+ * import {Templates} from '@verdocs/js-sdk/Templates';
1666
+ *
1667
+ * const newTemplate = await Templates.createTemplatev2((VerdocsEndpoint.getDefault(), {...});
1668
+ * ```
1669
+ */
1670
+ const createTemplatev2 = (endpoint, params, onUploadProgress) => {
1671
+ const options = {
1672
+ timeout: 120000,
1673
+ onUploadProgress: (event) => {
1674
+ const total = event.total || 1;
1675
+ const loaded = event.loaded || 0;
1676
+ onUploadProgress?.(Math.floor((loaded * 100) / (total || 1)), loaded, total || 1);
1677
+ },
1678
+ };
1679
+ if (params.documents && params.documents[0] instanceof File) {
1680
+ const formData = new FormData();
1681
+ ALLOWED_CREATE_FIELDS.forEach((allowedKey) => {
1682
+ if (params[allowedKey] !== undefined) {
1683
+ formData.append(allowedKey, params[allowedKey]);
1684
+ }
1685
+ });
1686
+ params.documents.forEach((file) => {
1687
+ formData.append('documents', file, file.name);
1688
+ });
1689
+ return endpoint.api.post('/v2/templates', formData, options).then((r) => r.data);
1690
+ }
1691
+ else {
1692
+ return endpoint.api.post('/v2/templates', params, options).then((r) => r.data);
1693
+ }
1694
+ };
1695
+ /**
1696
+ * Create a template from a Sharepoint asset.
1697
+ *
1698
+ * ```typescript
1699
+ * import {Templates} from '@verdocs/js-sdk/Templates';
1700
+ *
1701
+ * const newTemplate = await Templates.createTemplateFromSharepoint((VerdocsEndpoint.getDefault(), {...});
1702
+ * ```
1703
+ */
1704
+ const createTemplateFromSharepoint = (endpoint, params) => {
1705
+ const options = {
1706
+ timeout: 120000,
1707
+ };
1708
+ return endpoint.api.post('/templates/from-sharepoint', params, options).then((r) => r.data);
1709
+ };
1710
+ /**
1711
+ * Update a template.
1712
+ *
1713
+ * ```typescript
1714
+ * import {Templates} from '@verdocs/js-sdk/Templates';
1715
+ *
1716
+ * const updatedTemplate = await Templates.updateTemplate((VerdocsEndpoint.getDefault(), '83da3d70-7857-4392-b876-c4592a304bc9', { name: 'New Name' });
1717
+ * ```
1718
+ */
1719
+ const updateTemplate = (endpoint, templateId, params) => endpoint.api //
1720
+ .put(`/templates/${templateId}`, params)
1721
+ .then((r) => r.data);
1722
+ /**
1723
+ * Delete a template.
1724
+ *
1725
+ * ```typescript
1726
+ * import {Templates} from '@verdocs/js-sdk/Templates';
1727
+ *
1728
+ * await Templates.deleteTemplate((VerdocsEndpoint.getDefault(), '83da3d70-7857-4392-b876-c4592a304bc9');
1729
+ * ```
1730
+ */
1731
+ const deleteTemplate = (endpoint, templateId) => endpoint.api //
1732
+ .delete(`/templates/${templateId}`)
1733
+ .then((r) => r.data);
1734
+ /**
1735
+ * Search for templates matching various criteria.
1736
+ *
1737
+ * ```typescript
1738
+ * import {Templates} from '@verdocs/js-sdk/Templates';
1739
+ *
1740
+ * const {result, page, total} = await Templates.search((VerdocsEndpoint.getDefault(), { ... });
1741
+ * ```
1742
+ */
1743
+ const searchTemplates = async (endpoint, params) => endpoint.api //
1744
+ .post('/templates/search', params)
1745
+ .then((r) => r.data);
1746
+ /**
1747
+ * Get a summary of template data, typically used to populate admin panel dashboard pages.
1748
+ *
1749
+ * ```typescript
1750
+ * import {Templates} from '@verdocs/js-sdk/Templates';
1751
+ *
1752
+ * const summary = await Templates.getSummary((VerdocsEndpoint.getDefault(), 0);
1753
+ * ```
1754
+ */
1755
+ const getSummary = async (endpoint, params = {}) => endpoint.api //
1756
+ .post('/templates/summary', params)
1757
+ .then((r) => r.data);
1758
+ const cachedTemplates = {};
1759
+ /**
1760
+ * Wrapper for `getTemplate()` that limits queries to one every 2 seconds per template ID.
1761
+ * This is intended for use in component hierarchies that all rely on the same template
1762
+ * to avoid unnecessary repeat server calls.
1763
+ */
1764
+ const throttledGetTemplate = (endpoint, templateId) => {
1765
+ if (cachedTemplates[templateId] && cachedTemplates[templateId].loaded + 2000 < new Date().getTime()) {
1766
+ return cachedTemplates[templateId].template;
1767
+ }
1768
+ return getTemplate(endpoint, templateId).then((template) => {
1769
+ cachedTemplates[templateId] = { loaded: new Date().getTime(), template };
1770
+ return template;
1771
+ });
1772
+ };
1773
+ /**
1774
+ * List templates.
1775
+ *
1776
+ * ```typescript
1777
+ * import {Templates} from '@verdocs/js-sdk/Templates';
1778
+ *
1779
+ * const {totals, templates} = await Templates.listTemplates((VerdocsEndpoint.getDefault(), { q: 'test', sort: 'created_at' }); * ```
1780
+ */
1781
+ const listTemplates = async (endpoint, params = {}) => endpoint.api //
1782
+ .post('/templates/list', params)
1783
+ .then((r) => r.data);
1784
+
1785
+ var Templates = /*#__PURE__*/Object.freeze({
1786
+ __proto__: null,
1787
+ createTemplate: createTemplate,
1788
+ createTemplateFromSharepoint: createTemplateFromSharepoint,
1789
+ createTemplatev2: createTemplatev2,
1790
+ deleteTemplate: deleteTemplate,
1791
+ getSummary: getSummary,
1792
+ getTemplate: getTemplate,
1793
+ getTemplateOwnerInfo: getTemplateOwnerInfo,
1794
+ getTemplates: getTemplates,
1795
+ listTemplates: listTemplates,
1796
+ searchTemplates: searchTemplates,
1797
+ throttledGetTemplate: throttledGetTemplate,
1798
+ updateTemplate: updateTemplate
1799
+ });
1800
+
1801
+ /**
1802
+ * A TemplateDocument represents a PDF or other attachment in a Template.
1803
+ *
1804
+ * @module
1805
+ */
1806
+ /**
1807
+ * Get all the Template Documents associated to a particular Template.
1808
+ *
1809
+ * ```typescript
1810
+ * import {TemplateDocument} from '@verdocs/js-sdk/Templates';
1811
+ *
1812
+ * await TemplateDocument.geTemplateDocuments((VerdocsEndpoint.getDefault(), templateId);
1813
+ * ```
1814
+ */
1815
+ const getTemplateDocuments = (endpoint, templateId) => endpoint.api //
1816
+ .get(`/templates/${templateId}/documents/`)
1817
+ .then((r) => r.data);
1818
+ /**
1819
+ * Get a specific Document.
1820
+ *
1821
+ * ```typescript
1822
+ * import {TemplateDocument} from '@verdocs/js-sdk/Templates';
1823
+ *
1824
+ * await TemplateDocument.geTemplateDocument((VerdocsEndpoint.getDefault(), templateId,documentId);
1825
+ * ```
1826
+ */
1827
+ const getTemplateDocument = (endpoint, templateId, documentId) => endpoint.api //
1828
+ .get(`/templates/${templateId}/documents/${documentId}`)
1829
+ .then((r) => r.data);
1830
+ /**
1831
+ * Create a Document for a particular Template.
1832
+ *
1833
+ * ```typescript
1834
+ * import {TemplateDocument} from '@verdocs/js-sdk/Templates';
1835
+ *
1836
+ * await TemplateDocument.createDocument((VerdocsEndpoint.getDefault(), templateID, params);
1837
+ * ```
1838
+ */
1839
+ const createTemplateDocument = (endpoint, templateId, file, onUploadProgress) => {
1840
+ const formData = new FormData();
1841
+ formData.append('document', file, file.name);
1842
+ return endpoint.api //
1843
+ .post(`/templates/${templateId}/documents`, formData, {
1844
+ timeout: 120000,
1845
+ onUploadProgress: (event) => {
1846
+ const total = event.total || 1;
1847
+ const loaded = event.loaded || 0;
1848
+ onUploadProgress?.(Math.floor((loaded * 100) / (total || 1)), loaded, total || 1);
1849
+ },
1850
+ })
1851
+ .then((r) => r.data);
1852
+ };
1853
+ /**
1854
+ * Delete a specific Document.
1855
+ *
1856
+ * ```typescript
1857
+ * import {TemplateDocument} from '@verdocs/js-sdk/Templates';
1858
+ *
1859
+ * await TemplateDocument.deleteDocument((VerdocsEndpoint.getDefault(), templateID, documentID);
1860
+ * ```
1861
+ */
1862
+ const deleteTemplateDocument = (endpoint, templateId, documentId) => endpoint.api //
1863
+ .delete(`/templates/${templateId}/documents/${documentId}`)
1864
+ .then((r) => r.data);
1865
+ /**
1866
+ * Get (binary download) a file attached to a Template. It is important to use this method
1867
+ * rather than a direct A HREF or similar link to set the authorization headers for the
1868
+ * request.
1869
+ */
1870
+ const getTemplateDocumentFile = async (endpoint, templateId, documentId) => endpoint.api //
1871
+ .get(`/templates/${templateId}/documents/${documentId}?file=true`, { responseType: 'blob' })
1872
+ .then((r) => r.data);
1873
+ /**
1874
+ * Get (binary download) a file attached to a Template. It is important to use this method
1875
+ * rather than a direct A HREF or similar link to set the authorization headers for the
1876
+ * request.
1877
+ */
1878
+ const getTemplateDocumentThumbnail = async (endpoint, templateId, documentId) => endpoint.api //
1879
+ .get(`/templates/${templateId}/documents/${documentId}?thumbnail=true`, { responseType: 'blob' })
1880
+ .then((r) => r.data);
1881
+ /**
1882
+ * Get a display URI for a given page in a file attached to a template document. These pages are rendered server-side
1883
+ * into PNG resources suitable for display in IMG tags although they may be used elsewhere. Note that these are intended
1884
+ * for DISPLAY ONLY, are not legally binding documents, and do not contain any encoded metadata from participants. The
1885
+ * original asset may be obtained by calling `getTemplateDocumentFile()` or similar.
1886
+ */
1887
+ const getTemplateDocumentPageDisplayUri = async (endpoint, templateId, documentId, page) => endpoint.api.get(`/templates/${templateId}/documents/${documentId}/pages/${page}/image`).then((r) => r.data);
1888
+
1889
+ var TemplateDocuments = /*#__PURE__*/Object.freeze({
1890
+ __proto__: null,
1891
+ createTemplateDocument: createTemplateDocument,
1892
+ deleteTemplateDocument: deleteTemplateDocument,
1893
+ getTemplateDocument: getTemplateDocument,
1894
+ getTemplateDocumentFile: getTemplateDocumentFile,
1895
+ getTemplateDocumentPageDisplayUri: getTemplateDocumentPageDisplayUri,
1896
+ getTemplateDocumentThumbnail: getTemplateDocumentThumbnail,
1897
+ getTemplateDocuments: getTemplateDocuments
1898
+ });
1899
+
1900
+ var Types$2 = /*#__PURE__*/Object.freeze({
1901
+ __proto__: null
1902
+ });
1903
+
1904
+ /**
1905
+ * Get all defined validators
1906
+ *
1907
+ * ```typescript
1908
+ * import {Documents} from '@verdocs/js-sdk/Templates';
1909
+ *
1910
+ * await Documents.getDocuments(templateID);
1911
+ * ```
1912
+ */
1913
+ const getValidators = (endpoint) => endpoint.api //
1914
+ .get('/validators')
1915
+ .then((r) => r.data);
1916
+ const getValidator = (endpoint, validatorName) => endpoint.api //
1917
+ .get(`/validators/${validatorName}`)
1918
+ .then((r) => r.data);
1919
+ const EMAIL_REGEX = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
1920
+ const isValidEmail = (email) => !!email && EMAIL_REGEX.test(email);
1921
+ // @see https://www.regextester.com/1978
1922
+ const PHONE_REGEX = /((?:\+|00)[17](?: |\-)?|(?:\+|00)[1-9]\d{0,2}(?: |\-)?|(?:\+|00)1\-\d{3}(?: |\-)?)?(0\d|\([0-9]{3}\)|[1-9]{0,3})(?:((?: |\-)[0-9]{2}){4}|((?:[0-9]{2}){4})|((?: |\-)[0-9]{3}(?: |\-)[0-9]{4})|([0-9]{7}))/;
1923
+ const isValidPhone = (phone) => !!phone && PHONE_REGEX.test(phone);
1924
+ const isValidRoleName = (value, roles) => roles.findIndex((role) => role.name === value) !== -1;
1925
+ const TagRegEx = /^[a-zA-Z0-9-]{0,32}$/;
1926
+ const isValidTag = (value, tags) => TagRegEx.test(value) || tags.findIndex((tag) => tag === value) !== -1;
1927
+
1928
+ var Validators = /*#__PURE__*/Object.freeze({
1929
+ __proto__: null,
1930
+ getValidator: getValidator,
1931
+ getValidators: getValidators,
1932
+ isValidEmail: isValidEmail,
1933
+ isValidPhone: isValidPhone,
1934
+ isValidRoleName: isValidRoleName,
1935
+ isValidTag: isValidTag
1936
+ });
1937
+
1938
+ var index$2 = /*#__PURE__*/Object.freeze({
1939
+ __proto__: null,
1940
+ Actions: Actions,
1941
+ Fields: Fields$1,
1942
+ Reminders: Reminders,
1943
+ Roles: Roles,
1944
+ Stars: Stars,
1945
+ Tags: Tags,
1946
+ TemplateDocuments: TemplateDocuments,
1947
+ Templates: Templates,
1948
+ Types: Types$2,
1949
+ Validators: Validators
1950
+ });
1951
+
1952
+ /**
1953
+ * Authenticate to Verdocs via user/password authentication
1954
+ *
1955
+ * ```typescript
1956
+ * import {Auth} from '@verdocs/js-sdk/Auth';
1957
+ * import {Transport} from '@verdocs/js-sdk/HTTP';
1958
+ *
1959
+ * const {accessToken} = await Auth.authenticateUser({ username: 'test@test.com', password: 'PASSWORD' });
1960
+ * Transport.setAuthToken(accessToken);
1961
+ * ```
1962
+ */
1963
+ const authenticateUser = (endpoint, params) => endpoint.api //
1964
+ .post('/authentication/login', params)
1965
+ .then((r) => r.data);
1966
+ /**
1967
+ * Authenticate to Verdocs via client ID / Secret authentication. **NOTE: This is only suitable for
1968
+ * NodeJS server-side applications. Never expose your Client Secret in a Web or Mobile app!** Also note
1969
+ * that access tokens may be cached by server-side apps (and this is recommended) but do expire after 2
1970
+ * hours. This expiration may change based on future security needs. Application developers are encouraged
1971
+ * to check the `exp` expiration field in the response accessToken and renew tokens after they expire.
1972
+ *
1973
+ * ```typescript
1974
+ * import {Auth} from '@verdocs/js-sdk/Auth';
1975
+ * import {Transport} from '@verdocs/js-sdk/HTTP';
1976
+ *
1977
+ * const {accessToken} = await Auth.authenticateApp({ client_id: 'CLIENTID', client_secret: 'SECRET' });
1978
+ * Transport.setAuthToken(accessToken);
1979
+ * ```
1980
+ */
1981
+ const authenticateApp = (endpoint, params) => endpoint.api //
1982
+ .post('/authentication/login_client', {}, { headers: params })
1983
+ .then((r) => r.data);
1984
+ /**
1985
+ * Validate a token. Only Verdocs tokens will be accepted. Most applications can decode tokens locally,
1986
+ * because tokens will be validated when API calls are made anyway. However, high-security applications
1987
+ * may use this endpoint to check if a token has been revoked.
1988
+ *
1989
+ * ```typescript
1990
+ * import {Auth} from '@verdocs/js-sdk/Auth';
1991
+ *
1992
+ * const {valid} = await Auth.validateToken({ token });
1993
+ * if (!valid) {
1994
+ * window.alert('Session invalid or expired. Please re-authenticate.');
1995
+ * }
1996
+ * ```
1997
+ */
1998
+ const validateToken = (endpoint, params) => endpoint.api //
1999
+ .post('/token/isValid', params)
2000
+ .then((r) => r.data);
2001
+ /**
2002
+ * If called before the session expires, this will refresh the caller's session and tokens.
2003
+ *
2004
+ * ```typescript
2005
+ * import {Auth} from '@verdocs/js-sdk/Auth';
2006
+ * import {Transport} from '@verdocs/js-sdk/HTTP';
2007
+ *
2008
+ * const {accessToken} = await Auth.refreshTokens();
2009
+ * Transport.setAuthToken(accessToken);
2010
+ * ```
2011
+ */
2012
+ const refreshTokens = (endpoint) => endpoint.api //
2013
+ .get('/token')
2014
+ .then((r) => r.data);
2015
+ /**
2016
+ * Update the caller's password. To help prevent CSRF attack vectors, the user's old password and email address are required.
2017
+ *
2018
+ * ```typescript
2019
+ * import {Auth} from '@verdocs/js-sdk/Auth';
2020
+ *
2021
+ * const {status, message} = await Auth.updatePassword({ email, oldPassword, newPassword });
2022
+ * if (status !== 'OK') {
2023
+ * window.alert(`Password reset error: ${message}`);
2024
+ * }
2025
+ * ```
2026
+ */
2027
+ const updatePassword = (endpoint, params) => endpoint.api //
2028
+ .put('/user/update_password', params)
2029
+ .then((r) => r.data);
2030
+ /**
2031
+ * Reset the caller's password.
2032
+ *
2033
+ * ```typescript
2034
+ * import {Auth} from '@verdocs/js-sdk/Auth';
2035
+ *
2036
+ * const {success} = await Auth.resetPassword({ email });
2037
+ * if (status !== 'OK') {
2038
+ * window.alert(`Please check your email for instructions on how to reset your password.`);
2039
+ * }
2040
+ * ```
2041
+ */
2042
+ const resetPassword = (endpoint, params) => endpoint.api //
2043
+ .post('/user/reset_password', params)
2044
+ .then((r) => r.data);
2045
+ /**
2046
+ * Update the caller's email address.
2047
+ *
2048
+ * ```typescript
2049
+ * import {Auth} from '@verdocs/js-sdk/Auth';
2050
+ *
2051
+ * const {profiles} = await Auth.updateEmail({ email: newEmail });
2052
+ * ```
2053
+ */
2054
+ const updateEmail = (endpoint, params) => endpoint.api //
2055
+ .put('/user/update_email', params)
2056
+ .then((r) => r.data);
2057
+ /**
2058
+ * Resend the email verification request. Note that to prevent certain forms of abuse, the email address is not
2059
+ * a parameter here. Instead, the caller must be authenticated as the (unverified) user. To simplify this process,
2060
+ * the access token to be used may be passed directly as a parameter here. This avoids the need to set it as the
2061
+ * active token on an endpoint, which may be inconvenient in workflows where it is preferable to keep the user in
2062
+ * "anonymous" mode while verification is being performed.
2063
+ *
2064
+ * ```typescript
2065
+ * import {Auth} from '@verdocs/js-sdk/Auth';
2066
+ *
2067
+ * const result = await Auth.resendVerification();
2068
+ * ```
2069
+ */
2070
+ const resendVerification = (endpoint, accessToken) => endpoint.api //
2071
+ .post('/user/email_verification', {}, accessToken ? { headers: { Authorization: `Bearer ${accessToken}` } } : {})
2072
+ .then((r) => r.data);
2073
+ const createUser = (endpoint, params) => endpoint.api //
2074
+ .post('/user', params)
2075
+ .then((r) => r.data);
2076
+
2077
+ var Auth = /*#__PURE__*/Object.freeze({
2078
+ __proto__: null,
2079
+ authenticateApp: authenticateApp,
2080
+ authenticateUser: authenticateUser,
2081
+ createUser: createUser,
2082
+ refreshTokens: refreshTokens,
2083
+ resendVerification: resendVerification,
2084
+ resetPassword: resetPassword,
2085
+ updateEmail: updateEmail,
2086
+ updatePassword: updatePassword,
2087
+ validateToken: validateToken
2088
+ });
2089
+
2090
+ // TODO
2091
+ const billingPlaceholder = {};
2092
+
2093
+ var Billing = /*#__PURE__*/Object.freeze({
2094
+ __proto__: null,
2095
+ billingPlaceholder: billingPlaceholder
2096
+ });
2097
+
2098
+ const getNotifications = async (endpoint) => endpoint.api //
2099
+ .get('/notifications')
2100
+ .then((r) => r.data);
2101
+
2102
+ var Notifications = /*#__PURE__*/Object.freeze({
2103
+ __proto__: null,
2104
+ getNotifications: getNotifications
2105
+ });
2106
+
2107
+ /**
2108
+ * Get the user's available profiles. The current profile will be marked with `current: true`.
2109
+ *
2110
+ * ```typescript
2111
+ * import {Profiles} from '@verdocs/js-sdk/Users';
2112
+ *
2113
+ * const profiles = await Profiles.getProfiles()
2114
+ * ```
2115
+ */
2116
+ const getProfiles = (endpoint) => endpoint.api //
2117
+ .get('/profiles')
2118
+ .then((r) => r.data);
2119
+ /**
2120
+ * Get the user's available profiles. The current profile will be marked with `current: true`.
2121
+ *
2122
+ * ```typescript
2123
+ * import {Profiles} from '@verdocs/js-sdk/Users';
2124
+ *
2125
+ * const profiles = await Profiles.getCurrentProfile()
2126
+ * ```
2127
+ */
2128
+ const getCurrentProfile = (endpoint) => endpoint.api //
2129
+ .get('/profiles')
2130
+ .then((r) => (r.data || []).find((profile) => profile.current));
2131
+ /**
2132
+ * Get a list of system roles.
2133
+ *
2134
+ * ```typescript
2135
+ * import {Profiles} from '@verdocs/js-sdk/Users';
2136
+ *
2137
+ * const roles = await Profiles.getRoles();
2138
+ * ```
2139
+ */
2140
+ const getRoles = (endpoint) => endpoint.api //
2141
+ .get('/roles')
2142
+ .then((r) => r.data);
2143
+ /**
2144
+ * Get a list of system roles.
2145
+ *
2146
+ * ```typescript
2147
+ * import {Profiles} from '@verdocs/js-sdk/Users';
2148
+ *
2149
+ * const permissions = await Profiles.getPermissions();
2150
+ * ```
2151
+ */
2152
+ const getPermissions = (endpoint) => endpoint.api //
2153
+ .get('/permissions')
2154
+ .then((r) => r.data);
2155
+ /**
2156
+ * Create a profile. If the caller does not have a "current" profile set, the new profile will be made current.
2157
+ *
2158
+ * ```typescript
2159
+ * import {Profiles} from '@verdocs/js-sdk/Users';
2160
+ *
2161
+ * const newProfile = await Profiles.createProfile({ first_name: 'FIRST', last_name: 'LAST', email: 'EMAIL' });
2162
+ * ```
2163
+ */
2164
+ const createProfile = (endpoint, params) => endpoint.api //
2165
+ .post('/profiles', params)
2166
+ .then((r) => r.data);
2167
+ /**
2168
+ * Get a profile. The caller must have admin access to the given profile.
2169
+ * TODO: Add a "public" profile endpoint for public pages
2170
+ *
2171
+ * ```typescript
2172
+ * import {Profiles} from '@verdocs/js-sdk/Users';
2173
+ *
2174
+ * const profile = await Profiles.getProfile('PROFILEID');
2175
+ * ```
2176
+ */
2177
+ const getProfile = (endpoint, profileId) => endpoint.api //
2178
+ .get(`/profiles/${profileId}`)
2179
+ .then((r) => r.data);
2180
+ /**
2181
+ * Get a profile's permissions. The caller must have admin access to the given profile.
2182
+ *
2183
+ * ```typescript
2184
+ * import {Profiles} from '@verdocs/js-sdk/Users';
2185
+ *
2186
+ * const permissions = await Profiles.getProfilePermissions('PROFILEID');
2187
+ * ```
2188
+ */
2189
+ const getProfilePermissions = (endpoint, profileId) => endpoint.api //
2190
+ .get(`/profiles/${profileId}/permissions`)
2191
+ .then((r) => r.data);
2192
+ /**
2193
+ * Get a profile's groups.
2194
+ *
2195
+ * ```typescript
2196
+ * import {Profiles} from '@verdocs/js-sdk/Users';
2197
+ *
2198
+ * const groups = await Profiles.getProfileGroups('PROFILEID');
2199
+ * ```
2200
+ */
2201
+ const getProfileGroups = (endpoint, profileId) => endpoint.api //
2202
+ .get(`/profiles/${profileId}/groups`)
2203
+ .then((r) => r.data);
2204
+ /**
2205
+ * Switch the caller's "current" profile. The current profile is used for permissions checking and profile_id field settings
2206
+ * for most operations in Verdocs. It is important to select the appropropriate profile before calling other API functions.
2207
+ *
2208
+ * ```typescript
2209
+ * import {Profiles} from '@verdocs/js-sdk/Users';
2210
+ *
2211
+ * const newProfile = await Profiles.switchProfile('PROFILEID');
2212
+ * ```
2213
+ */
2214
+ const switchProfile = (endpoint, profileId) => endpoint.api //
2215
+ .post(`/profiles/${profileId}/switch`)
2216
+ .then((r) => r.data);
2217
+ /**
2218
+ * Update a profile. For future expansion, the profile ID to update is required, but currently this must also be the
2219
+ * "current" profile for the caller.
2220
+ *
2221
+ * ```typescript
2222
+ * import {Profiles} from '@verdocs/js-sdk/Users';
2223
+ *
2224
+ * const newProfile = await Profiles.updateProfile('PROFILEID');
2225
+ * ```
2226
+ */
2227
+ const updateProfile = (endpoint, profileId, params) => endpoint.api //
2228
+ .put(`/profiles/${profileId}`, params)
2229
+ .then((r) => r.data);
2230
+ /**
2231
+ * Delete a profile. If the requested profile is the caller's curent profile, the next available profile will be selected.
2232
+ *
2233
+ * ```typescript
2234
+ * import {Profiles} from '@verdocs/js-sdk/Users';
2235
+ *
2236
+ * await Profiles.deleteProfile('PROFILEID');
2237
+ * ```
2238
+ */
2239
+ const deleteProfile = (endpoint, profileId) => endpoint.api //
2240
+ .delete(`/profiles/${profileId}`)
2241
+ .then((r) => r.data);
2242
+ /**
2243
+ * Create a user account and parent organization. This endpoint is for creating a new organization. Users joining an
2244
+ * existing organization should be invited, and follow their invitation links/instructions to create their accounts.
2245
+ *
2246
+ * ```typescript
2247
+ * import {Profiles} from '@verdocs/js-sdk/Users';
2248
+ *
2249
+ * const newAccount = await Profiles.createBusinessAccount({
2250
+ * orgName: 'ORG', email: 'a@b.com', password: '12345678', firstName: 'FIRST', lastName: 'LAST'
2251
+ * });
2252
+ * ```
2253
+ */
2254
+ const createBusinessAccount = (endpoint, params) => endpoint.api //
2255
+ .post('/user/business', params)
2256
+ .then((r) => r.data);
2257
+ const recordSignupSurvey = (endpoint, params) => endpoint.api //
2258
+ .post('/user/signup', params)
2259
+ .then((r) => r.data);
2260
+
2261
+ var Profiles = /*#__PURE__*/Object.freeze({
2262
+ __proto__: null,
2263
+ createBusinessAccount: createBusinessAccount,
2264
+ createProfile: createProfile,
2265
+ deleteProfile: deleteProfile,
2266
+ getCurrentProfile: getCurrentProfile,
2267
+ getPermissions: getPermissions,
2268
+ getProfile: getProfile,
2269
+ getProfileGroups: getProfileGroups,
2270
+ getProfilePermissions: getProfilePermissions,
2271
+ getProfiles: getProfiles,
2272
+ getRoles: getRoles,
2273
+ recordSignupSurvey: recordSignupSurvey,
2274
+ switchProfile: switchProfile,
2275
+ updateProfile: updateProfile
2276
+ });
2277
+
2278
+ var Types$1 = /*#__PURE__*/Object.freeze({
2279
+ __proto__: null
2280
+ });
2281
+
2282
+ var index$1 = /*#__PURE__*/Object.freeze({
2283
+ __proto__: null,
2284
+ Auth: Auth,
2285
+ Billing: Billing,
2286
+ Notifications: Notifications,
2287
+ Profiles: Profiles,
2288
+ Types: Types$1
2289
+ });
2290
+
2291
+ /* tslint:disable:no-bitwise */
2292
+ /**
2293
+ * Given a `rgba(r,g,b,a)` string value, returns the hex equivalent, dropping the alpha channel.
2294
+ */
2295
+ function getRGB(rgba) {
2296
+ const rgbNumbers = rgba.replace('rgba(', '').replace(')', '').split(',');
2297
+ const rgbObject = {
2298
+ red: +rgbNumbers[0],
2299
+ green: +rgbNumbers[1],
2300
+ blue: +rgbNumbers[2],
2301
+ alpha: +rgbNumbers[3],
2302
+ };
2303
+ const alpha = 1 - rgbObject.alpha;
2304
+ const red = Math.round((rgbObject.alpha * (rgbObject.red / 255) + alpha) * 255);
2305
+ const green = Math.round((rgbObject.alpha * (rgbObject.green / 255) + alpha) * 255);
2306
+ const blue = Math.round((rgbObject.alpha * (rgbObject.blue / 255) + alpha) * 255);
2307
+ return '#' + rgbToHex(red) + rgbToHex(green) + rgbToHex(blue);
2308
+ }
2309
+ /**
2310
+ * Given an RGB string value, returns the hex equivalent.
2311
+ */
2312
+ function rgbToHex(rgb) {
2313
+ const hex = rgb.toString(16);
2314
+ if (hex.length < 2) {
2315
+ return '0' + hex;
2316
+ }
2317
+ return hex;
2318
+ }
2319
+ /**
2320
+ * Given a signer role index, return the color code for that signer.
2321
+ */
2322
+ function getRGBA(roleIndex) {
2323
+ switch (roleIndex % 10) {
2324
+ case 0:
2325
+ return roleIndex === 0 ? 'rgba(255, 193, 7, 0.4)' : 'rgba(134, 134, 134, 0.3)'; // #FFE69C
2326
+ case 1:
2327
+ return 'rgba(156, 39, 176, .4)'; // '#E3C3E9'
2328
+ case 2:
2329
+ return 'rgba(33, 150, 243, .4)'; // '#C1E1FB'
2330
+ case 3:
2331
+ return 'rgba(220, 231, 117, 0.3)';
2332
+ case 4:
2333
+ return 'rgba(121, 134, 203, 0.3)';
2334
+ case 5:
2335
+ return 'rgba(77, 182, 172, 0.3)';
2336
+ case 6:
2337
+ return 'rgba(255, 202, 165, 0.3)';
2338
+ case 7:
2339
+ return 'rgba(2, 247, 190, 0.3)';
2340
+ case 8:
2341
+ return 'rgba(255, 138, 101, 0.3)';
2342
+ case 9:
2343
+ return 'rgba(82, 255, 79, 0.3)';
2344
+ default:
2345
+ return 'rgba(229, 115, 155, 0.3)';
2346
+ }
2347
+ }
2348
+ /**
2349
+ * Given a role name, return a color code for it. This works by computing a hash code so the specific color returned
2350
+ * is not specified explicitly, but will be the same for every call with the same input value.
2351
+ */
2352
+ function nameToRGBA(str) {
2353
+ if (!!str) {
2354
+ const validNum = parseInt(str.slice(-1), 10);
2355
+ if (!isNaN(validNum)) {
2356
+ str += (validNum * 99).toString();
2357
+ }
2358
+ let hash = 0;
2359
+ for (let i = 0; i < str.length; i++) {
2360
+ hash = str.charCodeAt(i) + ((hash << 5) - hash);
2361
+ }
2362
+ hash = Math.round(hash / 1.3);
2363
+ const c = (hash & 0x00ffff08).toString(16).toUpperCase();
2364
+ const hex = '#' + '00000'.substring(0, 6 - c.length) + c;
2365
+ const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
2366
+ const color = {
2367
+ r: parseInt(result[1], 16),
2368
+ g: parseInt(result[2], 16),
2369
+ b: parseInt(result[3], 16),
2370
+ };
2371
+ return `rgba(${color.r}, ${color.g}, ${color.b}, 0.2)`;
2372
+ }
2373
+ }
2374
+ /**
2375
+ * Helper function to obtain a color code given a role name given various possible inputs.
2376
+ */
2377
+ function getRoleColor(name, roles, index) {
2378
+ if (index) {
2379
+ return getRGBA(index);
2380
+ }
2381
+ else if (roles && roles.length > 0) {
2382
+ const roleIndex = roles.findIndex((role) => role === name);
2383
+ if (roleIndex > -1) {
2384
+ return getRGBA(roleIndex);
2385
+ }
2386
+ else {
2387
+ return nameToRGBA(name);
2388
+ }
2389
+ }
2390
+ else {
2391
+ return nameToRGBA(name);
2392
+ }
2393
+ }
2394
+
2395
+ var Colors = /*#__PURE__*/Object.freeze({
2396
+ __proto__: null,
2397
+ getRGB: getRGB,
2398
+ getRGBA: getRGBA,
2399
+ getRoleColor: getRoleColor,
2400
+ nameToRGBA: nameToRGBA
2401
+ });
2402
+
2403
+ const YEAR = 365 * 24 * 60 * 60;
2404
+ // const MONTH = 30 * 24 * 60 * 60;
2405
+ const WEEK = 7 * 24 * 60 * 60;
2406
+ const DAY = 24 * 60 * 60;
2407
+ const HOUR = 60 * 60;
2408
+ const MINUTE = 60;
2409
+ const formatShortTimeAgo = (val) => {
2410
+ if (val === undefined || val === null) {
2411
+ return '';
2412
+ }
2413
+ let dateInput;
2414
+ if (typeof val === 'string' || typeof val === 'number') {
2415
+ dateInput = new Date(val);
2416
+ }
2417
+ else if (typeof val === 'object') {
2418
+ dateInput = val;
2419
+ }
2420
+ else {
2421
+ return '';
2422
+ }
2423
+ const timeDiff = Math.floor((new Date().getTime() - dateInput.getTime()) / 1000);
2424
+ if (timeDiff >= YEAR) {
2425
+ return Math.floor(timeDiff / YEAR) + 'Y';
2426
+ }
2427
+ // if (timeDiff >= MONTH) {
2428
+ // return Math.floor(timeDiff / MONTH) + 'M';
2429
+ // }
2430
+ if (timeDiff >= WEEK) {
2431
+ return Math.floor(timeDiff / WEEK) + 'W';
2432
+ }
2433
+ if (timeDiff >= DAY) {
2434
+ return Math.floor(timeDiff / DAY) + 'D';
2435
+ }
2436
+ if (timeDiff >= HOUR) {
2437
+ return Math.floor(timeDiff / HOUR) + 'H';
2438
+ }
2439
+ if (timeDiff >= MINUTE) {
2440
+ return Math.floor(timeDiff / MINUTE) + 'M';
2441
+ }
2442
+ return `${timeDiff}S`;
2443
+ };
2444
+ function timePeriod(type) {
2445
+ let endDate = new Date().getTime();
2446
+ const today = new Date();
2447
+ const month = today.getMonth();
2448
+ const year = today.getFullYear();
2449
+ let startDate = null;
2450
+ switch (type) {
2451
+ case '30d':
2452
+ startDate = endDate - 60 * 60 * 24 * 30 * 1000;
2453
+ break;
2454
+ case '60d':
2455
+ startDate = endDate - 60 * 60 * 24 * 60 * 1000;
2456
+ break;
2457
+ case '6m':
2458
+ startDate = endDate - 60 * 60 * 24 * 30 * 6 * 1000;
2459
+ break;
2460
+ case 'this_month':
2461
+ startDate = new Date(year, month, 1).getTime();
2462
+ break;
2463
+ case 'last_month':
2464
+ startDate = new Date(year, month - 1, 1).getTime();
2465
+ endDate = new Date(year, month, 0).getTime();
2466
+ break;
2467
+ case 'this_year':
2468
+ startDate = new Date(year, 0, 1);
2469
+ break;
2470
+ case 'all_time':
2471
+ default:
2472
+ return null;
2473
+ }
2474
+ if (startDate === null && endDate === null) {
2475
+ return null;
2476
+ }
2477
+ return {
2478
+ start_time: new Date(startDate).toISOString(),
2479
+ end_time: new Date(endDate).toISOString(),
2480
+ };
2481
+ }
2482
+
2483
+ var DateTime = /*#__PURE__*/Object.freeze({
2484
+ __proto__: null,
2485
+ formatShortTimeAgo: formatShortTimeAgo,
2486
+ timePeriod: timePeriod
2487
+ });
2488
+
2489
+ function getRTop(y, fieldHeight, iTextHeight, yRatio) {
2490
+ return iTextHeight - (y + fieldHeight) * yRatio;
2491
+ }
2492
+ function getRLeft(x, ratio) {
2493
+ return x * ratio;
2494
+ }
2495
+ function getRValue(y, ratio) {
2496
+ return y * ratio;
2497
+ }
2498
+ function blobToBase64(image) {
2499
+ const fileReader = new FileReader();
2500
+ return new Promise((resolve, reject) => {
2501
+ fileReader.onerror = () => {
2502
+ reject(new DOMException('Problem reading blob.'));
2503
+ };
2504
+ fileReader.onload = () => {
2505
+ resolve(fileReader.result);
2506
+ };
2507
+ fileReader.readAsDataURL(image);
2508
+ });
2509
+ }
2510
+ function rescale(r, n) {
2511
+ return r * n;
2512
+ }
2513
+
2514
+ var Fields = /*#__PURE__*/Object.freeze({
2515
+ __proto__: null,
2516
+ blobToBase64: blobToBase64,
2517
+ getRLeft: getRLeft,
2518
+ getRTop: getRTop,
2519
+ getRValue: getRValue,
2520
+ rescale: rescale
2521
+ });
2522
+
2523
+ /**
2524
+ * Given a File, extract the file's content as a base64 encoded data URL. The response will have a prefix that
2525
+ * includes the MIME type of the file, e.g. "data:image/jpeg;base64,iVBORw0K......"
2526
+ */
2527
+ const fileToDataUrl = (file) => new Promise((resolve, reject) => {
2528
+ const reader = new FileReader();
2529
+ reader.onload = () => resolve({
2530
+ lastModified: file.lastModified,
2531
+ size: file.size,
2532
+ type: file.type,
2533
+ name: file.name,
2534
+ data: reader.result,
2535
+ });
2536
+ reader.onerror = reject;
2537
+ if (file) {
2538
+ reader.readAsDataURL(file);
2539
+ }
2540
+ else {
2541
+ reject(new Error('Invalid file'));
2542
+ }
2543
+ });
2544
+ /**
2545
+ * Trigger a download dialog to save a blob as a file on disk.
2546
+ */
2547
+ const downloadBlob = (blob, name = 'file.pdf') => {
2548
+ const blobUrl = URL.createObjectURL(blob);
2549
+ const link = document.createElement('a');
2550
+ link.href = blobUrl;
2551
+ link.download = name;
2552
+ document.body.appendChild(link);
2553
+ link.dispatchEvent(new MouseEvent('click', {
2554
+ bubbles: true,
2555
+ cancelable: true,
2556
+ view: window,
2557
+ }));
2558
+ document.body.removeChild(link);
2559
+ };
2560
+
2561
+ var Files = /*#__PURE__*/Object.freeze({
2562
+ __proto__: null,
2563
+ downloadBlob: downloadBlob,
2564
+ fileToDataUrl: fileToDataUrl
2565
+ });
2566
+
2567
+ const Countries = [
2568
+ { code: '+7 840', name: 'Abkhazia', value: '+7' },
2569
+ { code: '+93', name: 'Afghanistan', value: '+93' },
2570
+ { code: '+355', name: 'Albania', value: '+355' },
2571
+ { code: '+213', name: 'Algeria', value: '+213' },
2572
+ { code: '+1', name: 'American Samoa', value: '+1' },
2573
+ { code: '+376', name: 'Andorra', value: '+376' },
2574
+ { code: '+244', name: 'Angola', value: '+244' },
2575
+ { code: '+1', name: 'Anguilla', value: '+1' },
2576
+ { code: '+1', name: 'Antigua and Barbuda', value: '+1' },
2577
+ { code: '+54', name: 'Argentina', value: '+54' },
2578
+ { code: '+374', name: 'Armenia', value: '+374' },
2579
+ { code: '+297', name: 'Aruba', value: '+297' },
2580
+ { code: '+247', name: 'Ascension', value: '+247' },
2581
+ { code: '+61', name: 'Australia', value: '+61' },
2582
+ { code: '+672', name: 'Australian External Territories', value: '+672' },
2583
+ { code: '+43', name: 'Austria', value: '+43' },
2584
+ { code: '+994', name: 'Azerbaijan', value: '+994' },
2585
+ { code: '+1', name: 'Bahamas', value: '+1' },
2586
+ { code: '+973', name: 'Bahrain', value: '+973' },
2587
+ { code: '+880', name: 'Bangladesh', value: '+880' },
2588
+ { code: '+1', name: 'Barbados', value: '+1' },
2589
+ { code: '+1', name: 'Barbuda', value: '+1' },
2590
+ { code: '+375', name: 'Belarus', value: '+375' },
2591
+ { code: '+32', name: 'Belgium', value: '+32' },
2592
+ { code: '+501', name: 'Belize', value: '+501' },
2593
+ { code: '+229', name: 'Benin', value: '+229' },
2594
+ { code: '+1', name: 'Bermuda', value: '+1' },
2595
+ { code: '+975', name: 'Bhutan', value: '+975' },
2596
+ { code: '+591', name: 'Bolivia', value: '+591' },
2597
+ { code: '+387', name: 'Bosnia and Herzegovina', value: '+387' },
2598
+ { code: '+267', name: 'Botswana', value: '+267' },
2599
+ { code: '+55', name: 'Brazil', value: '+55' },
2600
+ { code: '+246', name: 'British Indian Ocean Territory', value: '+246' },
2601
+ { code: '+1', name: 'British Virgin Islands', value: '+1' },
2602
+ { code: '+673', name: 'Brunei', value: '+673' },
2603
+ { code: '+359', name: 'Bulgaria', value: '+359' },
2604
+ { code: '+226', name: 'Burkina Faso', value: '+226' },
2605
+ { code: '+257', name: 'Burundi', value: '+257' },
2606
+ { code: '+855', name: 'Cambodia', value: '+855' },
2607
+ { code: '+237', name: 'Cameroon', value: '+237' },
2608
+ { code: '+1', name: 'Canada', value: '+1' },
2609
+ { code: '+238', name: 'Cape Verde', value: '+238' },
2610
+ { code: '+1', name: 'Cayman Islands', value: '+1' },
2611
+ { code: '+236', name: 'Central African Republic', value: '+236' },
2612
+ { code: '+235', name: 'Chad', value: '+235' },
2613
+ { code: '+56', name: 'Chile', value: '+56' },
2614
+ { code: '+86', name: 'China', value: '+86' },
2615
+ { code: '+61', name: 'Christmas Island', value: '+61' },
2616
+ { code: '+61', name: 'Cocos-Keeling Islands', value: '+61' },
2617
+ { code: '+57', name: 'Colombia', value: '+57' },
2618
+ { code: '+269', name: 'Comoros', value: '+269' },
2619
+ { code: '+242', name: 'Congo', value: '+242' },
2620
+ { code: '+243', name: 'Congo, Dem. Rep. of (Zaire)', value: '+243' },
2621
+ { code: '+682', name: 'Cook Islands', value: '+682' },
2622
+ { code: '+506', name: 'Costa Rica', value: '+506' },
2623
+ { code: '+385', name: 'Croatia', value: '+385' },
2624
+ { code: '+53', name: 'Cuba', value: '+53' },
2625
+ { code: '+599', name: 'Curacao', value: '+599' },
2626
+ { code: '+537', name: 'Cyprus', value: '+537' },
2627
+ { code: '+420', name: 'Czech Republic', value: '+420' },
2628
+ { code: '+45', name: 'Denmark', value: '+45' },
2629
+ { code: '+246', name: 'Diego Garcia', value: '+246' },
2630
+ { code: '+253', name: 'Djibouti', value: '+253' },
2631
+ { code: '+1', name: 'Dominica', value: '+1' },
2632
+ { code: '+1', name: 'Dominican Republic', value: '+1' },
2633
+ { code: '+670', name: 'East Timor', value: '+670' },
2634
+ { code: '+56', name: 'Easter Island', value: '+56' },
2635
+ { code: '+593', name: 'Ecuador', value: '+593' },
2636
+ { code: '+20', name: 'Egypt', value: '+20' },
2637
+ { code: '+503', name: 'El Salvador', value: '+503' },
2638
+ { code: '+240', name: 'Equatorial Guinea', value: '+240' },
2639
+ { code: '+291', name: 'Eritrea', value: '+291' },
2640
+ { code: '+372', name: 'Estonia', value: '+372' },
2641
+ { code: '+251', name: 'Ethiopia', value: '+251' },
2642
+ { code: '+500', name: 'Falkland Islands', value: '+500' },
2643
+ { code: '+298', name: 'Faroe Islands', value: '+298' },
2644
+ { code: '+679', name: 'Fiji', value: '+679' },
2645
+ { code: '+358', name: 'Finland', value: '+358' },
2646
+ { code: '+33', name: 'France', value: '+33' },
2647
+ { code: '+596', name: 'Martinique', value: '+596' },
2648
+ { code: '+594', name: 'French Guiana', value: '+594' },
2649
+ { code: '+689', name: 'French Polynesia', value: '+689' },
2650
+ { code: '+241', name: 'Gabon', value: '+241' },
2651
+ { code: '+220', name: 'Gambia', value: '+220' },
2652
+ { code: '+995', name: 'Georgia', value: '+995' },
2653
+ { code: '+49', name: 'Germany', value: '+49' },
2654
+ { code: '+233', name: 'Ghana', value: '+233' },
2655
+ { code: '+350', name: 'Gibraltar', value: '+350' },
2656
+ { code: '+30', name: 'Greece', value: '+30' },
2657
+ { code: '+299', name: 'Greenland', value: '+299' },
2658
+ { code: '+1', name: 'Grenada', value: '+1' },
2659
+ { code: '+590', name: 'Guadeloupe', value: '+590' },
2660
+ { code: '+1', name: 'Guam', value: '+1' },
2661
+ { code: '+502', name: 'Guatemala', value: '+502' },
2662
+ { code: '+224', name: 'Guinea', value: '+224' },
2663
+ { code: '+245', name: 'Guinea-Bissau', value: '+245' },
2664
+ { code: '+595', name: 'Guyana', value: '+595' },
2665
+ { code: '+509', name: 'Haiti', value: '+509' },
2666
+ { code: '+504', name: 'Honduras', value: '+504' },
2667
+ { code: '+852', name: 'Hong Kong SAR China', value: '+852' },
2668
+ { code: '+36', name: 'Hungary', value: '+36' },
2669
+ { code: '+354', name: 'Iceland', value: '+354' },
2670
+ { code: '+91', name: 'India', value: '+91' },
2671
+ { code: '+62', name: 'Indonesia', value: '+62' },
2672
+ { code: '+98', name: 'Iran', value: '+98' },
2673
+ { code: '+964', name: 'Iraq', value: '+964' },
2674
+ { code: '+353', name: 'Ireland', value: '+353' },
2675
+ { code: '+972', name: 'Israel', value: '+972' },
2676
+ { code: '+39', name: 'Italy', value: '+39' },
2677
+ { code: '+225', name: 'Ivory Coast', value: '+225' },
2678
+ { code: '+1', name: 'Jamaica', value: '+1' },
2679
+ { code: '+81', name: 'Japan', value: '+81' },
2680
+ { code: '+962', name: 'Jordan', value: '+962' },
2681
+ { code: '+77', name: 'Kazakhstan', value: '+7' },
2682
+ { code: '+254', name: 'Kenya', value: '+254' },
2683
+ { code: '+686', name: 'Kiribati', value: '+686' },
2684
+ { code: '+965', name: 'Kuwait', value: '+965' },
2685
+ { code: '+996', name: 'Kyrgyzstan', value: '+996' },
2686
+ { code: '+856', name: 'Laos', value: '+856' },
2687
+ { code: '+371', name: 'Latvia', value: '+371' },
2688
+ { code: '+961', name: 'Lebanon', value: '+961' },
2689
+ { code: '+266', name: 'Lesotho', value: '+266' },
2690
+ { code: '+231', name: 'Liberia', value: '+231' },
2691
+ { code: '+218', name: 'Libya', value: '+218' },
2692
+ { code: '+423', name: 'Liechtenstein', value: '+423' },
2693
+ { code: '+370', name: 'Lithuania', value: '+370' },
2694
+ { code: '+352', name: 'Luxembourg', value: '+352' },
2695
+ { code: '+853', name: 'Macau SAR China', value: '+853' },
2696
+ { code: '+389', name: 'Macedonia', value: '+389' },
2697
+ { code: '+261', name: 'Madagascar', value: '+261' },
2698
+ { code: '+265', name: 'Malawi', value: '+265' },
2699
+ { code: '+60', name: 'Malaysia', value: '+60' },
2700
+ { code: '+960', name: 'Maldives', value: '+960' },
2701
+ { code: '+223', name: 'Mali', value: '+223' },
2702
+ { code: '+356', name: 'Malta', value: '+356' },
2703
+ { code: '+692', name: 'Marshall Islands', value: '+692' },
2704
+ { code: '+596', name: 'Martinique', value: '+596' },
2705
+ { code: '+222', name: 'Mauritania', value: '+222' },
2706
+ { code: '+230', name: 'Mauritius', value: '+230' },
2707
+ { code: '+262', name: 'Mayotte or Réunion', value: '+262' },
2708
+ { code: '+52', name: 'Mexico', value: '+52' },
2709
+ { code: '+691', name: 'Micronesia', value: '+691' },
2710
+ { code: '+1', name: 'Midway Island', value: '+1' },
2711
+ { code: '+373', name: 'Moldova', value: '+373' },
2712
+ { code: '+377', name: 'Monaco', value: '+377' },
2713
+ { code: '+976', name: 'Mongolia', value: '+976' },
2714
+ { code: '+382', name: 'Montenegro', value: '+382' },
2715
+ { code: '+1', name: 'Montserrat', value: '+1' },
2716
+ { code: '+212', name: 'Morocco', value: '+212' },
2717
+ { code: '+95', name: 'Myanmar', value: '+95' },
2718
+ { code: '+264', name: 'Namibia', value: '+264' },
2719
+ { code: '+674', name: 'Nauru', value: '+674' },
2720
+ { code: '+977', name: 'Nepal', value: '+977' },
2721
+ { code: '+31', name: 'Netherlands', value: '+31' },
2722
+ { code: '+599', name: 'Netherlands Antilles', value: '+599' },
2723
+ { code: '+1', name: 'Nevis', value: '+1' },
2724
+ { code: '+687', name: 'New Caledonia', value: '+687' },
2725
+ { code: '+64', name: 'New Zealand', value: '+64' },
2726
+ { code: '+505', name: 'Nicaragua', value: '+505' },
2727
+ { code: '+227', name: 'Niger', value: '+227' },
2728
+ { code: '+234', name: 'Nigeria', value: '+234' },
2729
+ { code: '+683', name: 'Niue', value: '+683' },
2730
+ { code: '+672', name: 'Norfolk Island', value: '+672' },
2731
+ { code: '+850', name: 'North Korea', value: '+850' },
2732
+ { code: '+1', name: 'Northern Mariana Islands', value: '+1' },
2733
+ { code: '+47', name: 'Norway', value: '+47' },
2734
+ { code: '+968', name: 'Oman', value: '+968' },
2735
+ { code: '+92', name: 'Pakistan', value: '+92' },
2736
+ { code: '+680', name: 'Palau', value: '+680' },
2737
+ { code: '+970', name: 'Palestinian Territory', value: '+970' },
2738
+ { code: '+507', name: 'Panama', value: '+507' },
2739
+ { code: '+675', name: 'Papua New Guinea', value: '+675' },
2740
+ { code: '+595', name: 'Paraguay', value: '+595' },
2741
+ { code: '+51', name: 'Peru', value: '+51' },
2742
+ { code: '+63', name: 'Philippines', value: '+63' },
2743
+ { code: '+48', name: 'Poland', value: '+48' },
2744
+ { code: '+351', name: 'Portugal', value: '+351' },
2745
+ { code: '+1', name: 'Puerto Rico', value: '+1' },
2746
+ { code: '+974', name: 'Qatar', value: '+974' },
2747
+ { code: '+40', name: 'Romania', value: '+40' },
2748
+ { code: '+7', name: 'Russia', value: '+7' },
2749
+ { code: '+250', name: 'Rwanda', value: '+250' },
2750
+ { code: '508', name: 'Saint Pierre and Miquelon', value: '508' },
2751
+ { code: '+685', name: 'Samoa', value: '+685' },
2752
+ { code: '+378', name: 'San Marino', value: '+378' },
2753
+ { code: '+966', name: 'Saudi Arabia', value: '+966' },
2754
+ { code: '+221', name: 'Senegal', value: '+221' },
2755
+ { code: '+381', name: 'Serbia', value: '+381' },
2756
+ { code: '+248', name: 'Seychelles', value: '+248' },
2757
+ { code: '+232', name: 'Sierra Leone', value: '+232' },
2758
+ { code: '+65', name: 'Singapore', value: '+65' },
2759
+ { code: '+421', name: 'Slovakia', value: '+421' },
2760
+ { code: '+386', name: 'Slovenia', value: '+386' },
2761
+ { code: '+677', name: 'Solomon Islands', value: '+677' },
2762
+ { code: '+27', name: 'South Africa', value: '+27' },
2763
+ { code: '+500', name: 'South Georgia and the South Sandwich Islands', value: '+500' },
2764
+ { code: '+82', name: 'South Korea', value: '+82' },
2765
+ { code: '+34', name: 'Spain', value: '+34' },
2766
+ { code: '+94', name: 'Sri Lanka', value: '+94' },
2767
+ { code: '+249', name: 'Sudan', value: '+249' },
2768
+ { code: '+597', name: 'Suriname', value: '+597' },
2769
+ { code: '+268', name: 'Swaziland', value: '+268' },
2770
+ { code: '+46', name: 'Sweden', value: '+46' },
2771
+ { code: '+41', name: 'Switzerland', value: '+41' },
2772
+ { code: '+963', name: 'Syria', value: '+963' },
2773
+ { code: '+886', name: 'Taiwan', value: '+886' },
2774
+ { code: '+992', name: 'Tajikistan', value: '+992' },
2775
+ { code: '+255', name: 'Tanzania', value: '+255' },
2776
+ { code: '+66', name: 'Thailand', value: '+66' },
2777
+ { code: '+670', name: 'Timor Leste', value: '+670' },
2778
+ { code: '+228', name: 'Togo', value: '+228' },
2779
+ { code: '+690', name: 'Tokelau', value: '+690' },
2780
+ { code: '+676', name: 'Tonga', value: '+676' },
2781
+ { code: '+1', name: 'Trinidad and Tobago', value: '+1' },
2782
+ { code: '+216', name: 'Tunisia', value: '+216' },
2783
+ { code: '+90', name: 'Turkey', value: '+90' },
2784
+ { code: '+993', name: 'Turkmenistan', value: '+993' },
2785
+ { code: '+1', name: 'Turks and Caicos Islands', value: '+1' },
2786
+ { code: '+688', name: 'Tuvalu', value: '+688' },
2787
+ { code: '+1', name: 'U.S. Virgin Islands', value: '+1' },
2788
+ { code: '+256', name: 'Uganda', value: '+256' },
2789
+ { code: '+380', name: 'Ukraine', value: '+380' },
2790
+ { code: '+971', name: 'United Arab Emirates', value: '+971' },
2791
+ { code: '+44', name: 'United Kingdom', value: '+44' },
2792
+ { code: '+1', name: 'United States', value: '+1' },
2793
+ { code: '+598', name: 'Uruguay', value: '+598' },
2794
+ { code: '+998', name: 'Uzbekistan', value: '+998' },
2795
+ { code: '+678', name: 'Vanuatu', value: '+678' },
2796
+ { code: '+58', name: 'Venezuela', value: '+58' },
2797
+ { code: '+84', name: 'Vietnam', value: '+84' },
2798
+ { code: '+1', name: 'Wake Island', value: '+1' },
2799
+ { code: '+681', name: 'Wallis and Futuna', value: '+681' },
2800
+ { code: '+967', name: 'Yemen', value: '+967' },
2801
+ { code: '+260', name: 'Zambia', value: '+260' },
2802
+ { code: '+255', name: 'Zanzibar', value: '+255' },
2803
+ { code: '+263', name: 'Zimbabwe', value: '+263' },
2804
+ ];
2805
+ function getCountryByCode(code) {
2806
+ const found = Countries.find((country) => country.code === code);
2807
+ if (found)
2808
+ return found;
2809
+ if (isFrenchGuiana(code)) {
2810
+ return { code: '+594', name: 'French Guiana', value: '+594' };
2811
+ }
2812
+ else if (isGuadeloupe(code)) {
2813
+ return { code: '+590', name: 'Guadeloupe', value: '+590' };
2814
+ }
2815
+ else if (isMartinique(code)) {
2816
+ return { code: '+596', name: 'Martinique', value: '+596' };
2817
+ }
2818
+ else if (isMayotte(code)) {
2819
+ return { code: '+262', name: 'Mayotte or Réunion', value: '+262' };
2820
+ }
2821
+ return null;
2822
+ }
2823
+ function isFrenchGuiana(code) {
2824
+ return '+594' === code.substring(0, 4);
2825
+ }
2826
+ function isGuadeloupe(code) {
2827
+ return '+590' === code.substring(0, 4);
2828
+ }
2829
+ function isMartinique(code) {
2830
+ return '+596' === code.substring(0, 4);
2831
+ }
2832
+ function isMayotte(code) {
2833
+ return '+262' === code.substring(0, 4);
2834
+ }
2835
+ function getPlusOneCountry(code) {
2836
+ let info = null;
2837
+ switch (code.substring(0, 5)) {
2838
+ case '+1684':
2839
+ info = { code: '+1', name: 'American Samoa', value: '+1' };
2840
+ break;
2841
+ case '+1264':
2842
+ info = { code: '+1', name: 'Anguilla', value: '+1' };
2843
+ break;
2844
+ case '+1268':
2845
+ info = { code: '+1', name: 'Antigua and Barbuda', value: '+1' };
2846
+ break;
2847
+ case '+1242':
2848
+ info = { code: '+1', name: 'Bahamas', value: '+1' };
2849
+ break;
2850
+ case '+1246':
2851
+ info = { code: '+1', name: 'Barbados', value: '+1' };
2852
+ break;
2853
+ case '+1441':
2854
+ info = { code: '+1', name: 'Bermuda', value: '+1' };
2855
+ break;
2856
+ case '+1284':
2857
+ info = { code: '+1', name: 'British Virgin Islands', value: '+1' };
2858
+ break;
2859
+ case '+1':
2860
+ info = { code: '+1', name: '', value: '+1' };
2861
+ break;
2862
+ }
2863
+ return info;
2864
+ }
2865
+ function isCanada(code) {
2866
+ const canadianAreaCodes = [
2867
+ '403',
2868
+ '587',
2869
+ '780',
2870
+ '825',
2871
+ '604',
2872
+ '250',
2873
+ '778',
2874
+ '236',
2875
+ '204',
2876
+ '431',
2877
+ '506',
2878
+ '709',
2879
+ '867',
2880
+ '782',
2881
+ '902',
2882
+ '867',
2883
+ '548',
2884
+ '705',
2885
+ '365',
2886
+ '613',
2887
+ '807',
2888
+ '226',
2889
+ '289',
2890
+ '437',
2891
+ '519',
2892
+ '647',
2893
+ '905',
2894
+ '249',
2895
+ '343',
2896
+ '416',
2897
+ '902',
2898
+ '782',
2899
+ '450',
2900
+ '418',
2901
+ '579',
2902
+ '873',
2903
+ '367',
2904
+ '514',
2905
+ '581',
2906
+ '819',
2907
+ '438',
2908
+ '639',
2909
+ '306',
2910
+ '867',
2911
+ ];
2912
+ const areaCode = code.substring(0, 5);
2913
+ return canadianAreaCodes.findIndex((x) => '+1' + x === areaCode) > -1;
2914
+ }
2915
+ function isAmericanSamoa(code) {
2916
+ return code.substring(0, 5) === '+1684';
2917
+ }
2918
+ function isDominicanRepublic(code) {
2919
+ return '+1809' === code.substring(0, 5) || '+1829' === code.substring(0, 5) || '+1849' === code.substring(0, 5);
2920
+ }
2921
+ function isPuertoRico(code) {
2922
+ return code.substring(0, 5) === '+' || code.substring(0, 5) === '+';
2923
+ }
2924
+ // need to finish
2925
+ function getMatchingCountry(code, substrings) {
2926
+ const toMatch = code.substring(0, substrings);
2927
+ return Countries.filter((c) => c.code === toMatch).length;
2928
+ }
2929
+ // const e164Regex = new RegExp(/\+[1-9]\d{6,14}/g);
2930
+ // export function simpleE164Validator(code: string) {
2931
+ // return (code !== null && code.length < 16 && code.length > 6 && e164Regex.test(code)) || code === '' || code === null;
2932
+ // }
2933
+
2934
+ var Locales = /*#__PURE__*/Object.freeze({
2935
+ __proto__: null,
2936
+ Countries: Countries,
2937
+ getCountryByCode: getCountryByCode,
2938
+ getMatchingCountry: getMatchingCountry,
2939
+ getPlusOneCountry: getPlusOneCountry,
2940
+ isAmericanSamoa: isAmericanSamoa,
2941
+ isCanada: isCanada,
2942
+ isDominicanRepublic: isDominicanRepublic,
2943
+ isFrenchGuiana: isFrenchGuiana,
2944
+ isGuadeloupe: isGuadeloupe,
2945
+ isMartinique: isMartinique,
2946
+ isMayotte: isMayotte,
2947
+ isPuertoRico: isPuertoRico
2948
+ });
2949
+
2950
+ /**
2951
+ * Capitalize the first letter of a string.
2952
+ */
2953
+ const capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1);
2954
+ /**
2955
+ * Convert a phone-number-like string to E164 format.
2956
+ * @see https://46elks.com/kb/e164
2957
+ */
2958
+ const convertToE164 = (input) => {
2959
+ // "(212) 555-1212" => +12125551212
2960
+ // "+46766861004" => "+46766861004"
2961
+ // "212-555-1212" => +12125551212
2962
+ // "212.555.1212" => +12125551212
2963
+ // "212 555 1212" => +12125551212
2964
+ let temp = (input || '').trim();
2965
+ // If we are already prefixed, assume the user did it deliberately and attempt to use what they entered. We also short-circuit blanks.
2966
+ if (!temp || temp.startsWith('+')) {
2967
+ return temp;
2968
+ }
2969
+ // Remove any spaces, parenthesis or other punctuation.
2970
+ temp = temp.replace(/[^0-9]/g, '');
2971
+ // 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
2972
+ // whether it's the actual first character e.g. `0(5)` or just the first digit e.g. `(05`.
2973
+ temp = temp.replace(/^0/g, '');
2974
+ // Prepend the country code and +. We're assuming US in this case given the target demographic. Users in other countries would/should be
2975
+ // already entering a prefix so they'd shortcut out of this routine via the + prefix check.
2976
+ return `+1${temp}`;
2977
+ };
2978
+
2979
+ var Strings = /*#__PURE__*/Object.freeze({
2980
+ __proto__: null,
2981
+ capitalize: capitalize,
2982
+ convertToE164: convertToE164
2983
+ });
2984
+
2985
+ /**
2986
+ * Create an array containing a sequence of integers, e.g. [START, START+1, START+2, ...] This is frequently useful
2987
+ * in rendering operations when there is no source array to .map() across.
2988
+ */
2989
+ const integerSequence = (start, count) => Array(count)
2990
+ .fill(1)
2991
+ .map((_, index) => index + start);
2992
+ /**
2993
+ * Format a profile's full name
2994
+ */
2995
+ const formatFullName = (profile) => profile ? `${capitalize(profile.first_name)} ${capitalize(profile.last_name)}` : 'Invalid User';
2996
+ /**
2997
+ * Format a profile's initials
2998
+ */
2999
+ const formatInitials = (profile) => profile ? `${capitalize(profile.first_name).charAt(0)} ${capitalize(profile.last_name).charAt(0)}` : '--';
3000
+ /**
3001
+ * Generate suggested initials for a full name, e.g. "John Doe" will yield "JD".
3002
+ */
3003
+ const fullNameToInitials = (name) => name
3004
+ .split(' ')
3005
+ .map((word) => word[0])
3006
+ .join('');
3007
+
3008
+ var Primitives = /*#__PURE__*/Object.freeze({
3009
+ __proto__: null,
3010
+ formatFullName: formatFullName,
3011
+ formatInitials: formatInitials,
3012
+ fullNameToInitials: fullNameToInitials,
3013
+ integerSequence: integerSequence
3014
+ });
3015
+
3016
+ var Types = /*#__PURE__*/Object.freeze({
3017
+ __proto__: null
3018
+ });
3019
+
3020
+ var index = /*#__PURE__*/Object.freeze({
3021
+ __proto__: null,
3022
+ Colors: Colors,
3023
+ DateTime: DateTime,
3024
+ Fields: Fields,
3025
+ Files: Files,
3026
+ Locales: Locales,
3027
+ Primitives: Primitives,
3028
+ Strings: Strings,
3029
+ Token: Token,
3030
+ Types: Types
3031
+ });
3032
+
3033
+ exports.Envelopes = index$5;
3034
+ exports.Organizations = index$4;
3035
+ exports.Sessions = index$3;
3036
+ exports.Templates = index$2;
3037
+ exports.Users = index$1;
3038
+ exports.Utils = index;
3039
+ exports.VerdocsEndpoint = VerdocsEndpoint;
3040
+ //# sourceMappingURL=index.js.map