@verdocs/js-sdk 3.10.29 → 4.0.0

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 +41294 -0
  3. package/dist/index.d.ts +41294 -0
  4. package/dist/index.js +3045 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/index.mjs +3036 -0
  7. package/dist/index.mjs.map +1 -0
  8. package/dist/package.json +85 -0
  9. package/dist/tsconfig.json +16 -0
  10. package/package.json +31 -14
  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
@@ -1,319 +0,0 @@
1
- import axios from 'axios';
2
- import { decodeAccessTokenBody } from './Utils/Token';
3
- import globalThis from './Utils/globalThis';
4
- // @credit https://derickbailey.com/2016/03/09/creating-a-true-singleton-in-node-js-with-es6-symbols/
5
- // Also see globalThis for comments about why we're doing this in the first place.
6
- var ENDPOINT_KEY = Symbol.for('verdocs-default-endpoint');
7
- var requestLogger = function (r) {
8
- // tslint:disable-next-line
9
- console.debug("[JS-SDK] ".concat(r.method.toUpperCase(), " ").concat(r.baseURL).concat(r.url), r.data ? JSON.stringify(r.data) : '');
10
- return r;
11
- };
12
- /**
13
- * VerdocsEndpoint is a class wrapper for a specific connection and authorization context for calling the Verdocs APIs.
14
- * Endpoints can be used for isolated session tasks.
15
- *
16
- * For instance, ephemeral signing sessions may be created independently of a caller's status as an authenticated user.
17
- * In that case, an Endpoint can be created and authenticated, used for calls related to signing operations, then
18
- * discarded once signing is complete.
19
- *
20
- * Note that endpoint configuration functions return the instance, so they can be chained, e.g.
21
- *
22
- * ```typescript
23
- * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
24
- *
25
- * const endpoint = new VerdocsEndpoint();
26
- * endpoint
27
- * .setSessionType('signing')
28
- * .logRequests(true)
29
- * .setClientID('1234)
30
- * .setTimeout(30000);
31
- * ```
32
- */
33
- var VerdocsEndpoint = /** @class */ (function () {
34
- /**
35
- * Create a new VerdocsEndpoint to call Verdocs platform services.
36
- *
37
- * ```typescript
38
- * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
39
- * const endpoint = new VerdocsEndpoint();
40
- * ```
41
- */
42
- function VerdocsEndpoint(options) {
43
- this.environment = 'verdocs';
44
- this.sessionType = 'user';
45
- this.baseURL = (window.location.origin === 'https://beta.verdocs.com' || window.location.origin === 'https://stage.verdocs.com'
46
- ? 'https://stage-api.verdocs.com'
47
- : 'https://api.verdocs.com');
48
- this.clientID = 'not-set';
49
- this.timeout = 60000;
50
- this.token = null;
51
- this.nextListenerId = 0;
52
- this.sessionListeners = new Map();
53
- this.requestLoggerId = null;
54
- /**
55
- * The current user session, or null if not authenticated. May be either a User or Signing session. If set, the
56
- * presence of the `document_id` field can be used to differentiate the types. Only signing sessions are associated
57
- * with Envelopes.
58
- */
59
- this.session = null;
60
- this.baseURL = (options === null || options === void 0 ? void 0 : options.baseURL) || this.baseURL;
61
- this.timeout = (options === null || options === void 0 ? void 0 : options.timeout) || this.timeout;
62
- this.environment = (options === null || options === void 0 ? void 0 : options.environment) || this.environment;
63
- this.sessionType = (options === null || options === void 0 ? void 0 : options.sessionType) || this.sessionType;
64
- this.clientID = (options === null || options === void 0 ? void 0 : options.clientID) || this.clientID;
65
- this.api = axios.create({ baseURL: this.baseURL, timeout: this.timeout });
66
- }
67
- VerdocsEndpoint.prototype.setDefault = function () {
68
- globalThis[ENDPOINT_KEY] = this;
69
- };
70
- VerdocsEndpoint.getDefault = function () {
71
- if (!globalThis[ENDPOINT_KEY]) {
72
- globalThis[ENDPOINT_KEY] = new VerdocsEndpoint();
73
- window.console.debug('[JS_SDK] Created default endpoint', globalThis[ENDPOINT_KEY].baseURL);
74
- }
75
- return globalThis[ENDPOINT_KEY];
76
- };
77
- /**
78
- * Get the current environment.
79
- */
80
- VerdocsEndpoint.prototype.getEnvironment = function () {
81
- return this.environment;
82
- };
83
- /**
84
- * Get the current session type.
85
- */
86
- VerdocsEndpoint.prototype.getSessionType = function () {
87
- return this.sessionType;
88
- };
89
- /**
90
- * Get the current base URL. This should rarely be anything other than 'https://api.verdocs.com'.
91
- */
92
- VerdocsEndpoint.prototype.getBaseURL = function () {
93
- return this.baseURL;
94
- };
95
- /**
96
- * Get the current client ID, if set.
97
- */
98
- VerdocsEndpoint.prototype.getClientID = function () {
99
- return this.clientID;
100
- };
101
- /**
102
- * Get the current timeout.
103
- */
104
- VerdocsEndpoint.prototype.getTimeout = function () {
105
- return this.timeout;
106
- };
107
- /**
108
- * Get the current session, if any.
109
- */
110
- VerdocsEndpoint.prototype.getSession = function () {
111
- return this.session;
112
- };
113
- /**
114
- * Set the operating environment. This should rarely be anything other than 'verdocs'.
115
- *
116
- * ```typescript
117
- * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
118
- *
119
- * const endpoint = new VerdocsEndpoint();
120
- * endpoint.setEnvironment('verdocs-stage');
121
- * ```
122
- */
123
- VerdocsEndpoint.prototype.setEnvironment = function (environment) {
124
- this.environment = environment;
125
- return this;
126
- };
127
- /**
128
- * Set the session type. In general this should be done immediately when the endpoint is created. Changing the
129
- * session type may be done at any time, but may have unintended consequences if the endpoint is shared between
130
- * multiple widgets.
131
- *
132
- * Changing the session type will clear/reload the action session. This may trigger notifications to session state
133
- * observers. Apps that use observers to trigger UI updates such as logging the user out should be prepared to
134
- * handle this event.
135
- *
136
- * ```typescript
137
- * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
138
- *
139
- * const endpoint = new VerdocsEndpoint();
140
- * endpoint.setEnvironment('verdocs-stage');
141
- * ```
142
- */
143
- VerdocsEndpoint.prototype.setSessionType = function (sessionType) {
144
- this.sessionType = sessionType;
145
- return this;
146
- };
147
- /**
148
- * Set the base URL for API calls. Should be called only upon direction from Verdocs Customer Solutions Engineering.
149
- *
150
- * ```typescript
151
- * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
152
- *
153
- * const endpoint = new VerdocsEndpoint();
154
- * endpoint.setBaseURL('https://api.verdocs.com');
155
- * ```
156
- */
157
- VerdocsEndpoint.prototype.setBaseURL = function (url) {
158
- this.baseURL = url;
159
- this.api.defaults.baseURL = url;
160
- return this;
161
- };
162
- /**
163
- * Set the Client ID for Verdocs API calls.
164
- *
165
- * ```typescript
166
- * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
167
- *
168
- * const endpoint = new VerdocsEndpoint();
169
- * endpoint.setClientID('1234);
170
- * ```
171
- */
172
- VerdocsEndpoint.prototype.setClientID = function (clientID) {
173
- this.clientID = clientID;
174
- this.api.defaults.headers.common['X-Client-ID'] = clientID;
175
- return this;
176
- };
177
- /**
178
- * Set the timeout for API calls in milliseconds. 5000-20000ms is recommended for most purposes. 15000ms is the default.
179
- * Note that some calls may involve rendering operations that require some time to complete, so very short timeouts
180
- * are not recommended.
181
- *
182
- * ```typescript
183
- * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
184
- *
185
- * const endpoint = new VerdocsEndpoint();
186
- * endpoint.setTimeout(3000);
187
- * ```
188
- */
189
- VerdocsEndpoint.prototype.setTimeout = function (timeout) {
190
- this.timeout = timeout;
191
- this.api.defaults.timeout = timeout;
192
- return this;
193
- };
194
- /**
195
- * Enable or disable request logging. This may expose sensitive data in the console log, so it should only be used for debugging.
196
- *
197
- * ```typescript
198
- * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
199
- *
200
- * const endpoint = new VerdocsEndpoint();
201
- * endpoint.logRequests(true);
202
- * ```
203
- */
204
- VerdocsEndpoint.prototype.logRequests = function (enable) {
205
- if (enable && this.requestLoggerId === null) {
206
- this.requestLoggerId = this.api.interceptors.request.use(requestLogger);
207
- }
208
- else if (!enable && this.requestLoggerId !== null) {
209
- this.api.interceptors.request.eject(this.requestLoggerId);
210
- }
211
- return this;
212
- };
213
- /**
214
- * Set the authorization token that will be used for Verdocs API calls. This will also set the session metadata
215
- * and notify any listeners of the new data.
216
- *
217
- * If this Endpoint will be used for non-default purposes (e.g. signing, or in an alternate environment) those
218
- * settings should be made before calling this. Sessions are persisted to localStorage, and the environment and
219
- * type become part of the storage key.
220
- *
221
- * ```typescript
222
- * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
223
- *
224
- * const endpoint = new VerdocsEndpoint();
225
- * endpoint.setToken(accessToken);
226
- * ```
227
- */
228
- VerdocsEndpoint.prototype.setToken = function (token) {
229
- if (!token) {
230
- return this.clearSession();
231
- }
232
- var session = decodeAccessTokenBody(token);
233
- if (session === null || (session.exp && session.exp * 1000 < new Date().getTime())) {
234
- window.console.warn('[JS_SDK] Ignoring attempt to use expired session token');
235
- return this.clearSession();
236
- }
237
- this.token = token;
238
- this.session = session;
239
- if (this.sessionType === 'user') {
240
- this.api.defaults.headers.common.Authorization = "Bearer ".concat(token);
241
- }
242
- else {
243
- this.api.defaults.headers.common.signer = "Bearer ".concat(token);
244
- }
245
- localStorage.setItem(this.sessionStorageKey(), token);
246
- this.notifySessionListeners();
247
- return this;
248
- };
249
- /**
250
- * Retrieves the current session token, if any. Tokens should rarely be used for direct actions, but this is
251
- * required by the `<VerdocsView>` and other components to authorize requests to raw PDF files.
252
- */
253
- VerdocsEndpoint.prototype.getToken = function () {
254
- return this.token;
255
- };
256
- VerdocsEndpoint.prototype.sessionStorageKey = function () {
257
- return "verdocs-session-".concat(this.getSessionType(), "-").concat(this.getEnvironment());
258
- };
259
- /**
260
- * Clear the active session.
261
- */
262
- VerdocsEndpoint.prototype.clearSession = function () {
263
- localStorage.removeItem(this.sessionStorageKey());
264
- delete this.api.defaults.headers.common.Authorization;
265
- delete this.api.defaults.headers.common.signer;
266
- this.session = null;
267
- this.token = null;
268
- this.notifySessionListeners();
269
- return this;
270
- };
271
- /**
272
- * Clear the active signing session.
273
- */
274
- VerdocsEndpoint.prototype.clearSignerSession = function () {
275
- localStorage.removeItem(this.sessionStorageKey());
276
- delete this.api.defaults.headers.common.Authorization;
277
- this.session = null;
278
- this.token = null;
279
- this.notifySessionListeners();
280
- return this;
281
- };
282
- VerdocsEndpoint.prototype.notifySessionListeners = function () {
283
- var _this = this;
284
- this.sessionListeners.forEach(function (listener) {
285
- try {
286
- listener(_this, _this.session);
287
- }
288
- catch (e) {
289
- // NOOP
290
- }
291
- });
292
- };
293
- /**
294
- * Subscribe to session state change events.
295
- */
296
- VerdocsEndpoint.prototype.onSessionChanged = function (listener) {
297
- var _this = this;
298
- // There's no value in randomizing this, a simple counter is fine
299
- this.nextListenerId++;
300
- var listenerSymbol = Symbol.for('' + this.nextListenerId);
301
- this.sessionListeners.set(listenerSymbol, listener);
302
- return function () {
303
- _this.sessionListeners.delete(listenerSymbol);
304
- };
305
- };
306
- /**
307
- * Load a persisted session from localStorage. Typically called once after the endpoint is configured when the app
308
- * or component starts.
309
- */
310
- VerdocsEndpoint.prototype.loadSession = function () {
311
- var token = localStorage.getItem(this.sessionStorageKey());
312
- if (!token) {
313
- return this.clearSession();
314
- }
315
- return this.setToken(token);
316
- };
317
- return VerdocsEndpoint;
318
- }());
319
- export { VerdocsEndpoint };
package/index.d.ts DELETED
@@ -1,18 +0,0 @@
1
- /**
2
- * Verdocs functions are organized into high-level modules that represent the main objects within Verdocs:
3
- *
4
- * - Envelopes - An individual document to be signed. Documents are created from templates.
5
- * - Organizations - An Organization is a container for user profiles, templates, documents, billing, and other related objects.
6
- * - Templates - A template for a document containing a PDF file, metadata for signature fields, and other information.
7
- * - Users - All operations related to authentication and user-related operations.
8
- * - Utils - General support functions used by the other modules and exported for convenience.
9
- *
10
- * @module
11
- */
12
- export * as Envelopes from './Envelopes';
13
- export * as Organizations from './Organizations';
14
- export * as Sessions from './Sessions';
15
- export * as Templates from './Templates';
16
- export * as Users from './Users';
17
- export * as Utils from './Utils';
18
- export * from './VerdocsEndpoint';
package/index.js DELETED
@@ -1,18 +0,0 @@
1
- /**
2
- * Verdocs functions are organized into high-level modules that represent the main objects within Verdocs:
3
- *
4
- * - Envelopes - An individual document to be signed. Documents are created from templates.
5
- * - Organizations - An Organization is a container for user profiles, templates, documents, billing, and other related objects.
6
- * - Templates - A template for a document containing a PDF file, metadata for signature fields, and other information.
7
- * - Users - All operations related to authentication and user-related operations.
8
- * - Utils - General support functions used by the other modules and exported for convenience.
9
- *
10
- * @module
11
- */
12
- export * as Envelopes from './Envelopes';
13
- export * as Organizations from './Organizations';
14
- export * as Sessions from './Sessions';
15
- export * as Templates from './Templates';
16
- export * as Users from './Users';
17
- export * as Utils from './Utils';
18
- export * from './VerdocsEndpoint';
@@ -1,26 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es5",
4
- "module": "esnext",
5
- "lib": ["es2017", "es7", "es6", "dom"],
6
- "declaration": true,
7
- "allowJs": true,
8
- "outDir": "./",
9
- "strict": true,
10
- "esModuleInterop": true,
11
- "moduleResolution": "node",
12
- "jsx": "react",
13
- "jsxFactory": "JSX.createElement",
14
- "jsxFragmentFactory": "JSX.Fragment"
15
- },
16
- "include": ["src"],
17
- "exclude": ["node_modules", "dist", "**/__tests__/*"],
18
- "typedocOptions": {
19
- "entryPoints": ["src/index.ts"],
20
- "out": "docs",
21
- "includeVersion": true,
22
- "gitRevision": "main",
23
- "hideGenerator": true,
24
- "excludePrivate": true
25
- }
26
- }