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