@verdocs/js-sdk 1.4.0 → 2.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 (72) hide show
  1. package/Documents/Documents.d.ts +26 -9
  2. package/Documents/Documents.js +42 -27
  3. package/Documents/Initials.d.ts +2 -1
  4. package/Documents/Initials.js +3 -4
  5. package/Documents/Recipients.d.ts +5 -1
  6. package/Documents/Recipients.js +6 -4
  7. package/Documents/Signatures.d.ts +14 -4
  8. package/Documents/Signatures.js +21 -13
  9. package/Documents/index.d.ts +0 -1
  10. package/Documents/index.js +0 -1
  11. package/Organizations/ApiKeys.d.ts +6 -5
  12. package/Organizations/ApiKeys.js +15 -16
  13. package/Organizations/Groups.d.ts +8 -7
  14. package/Organizations/Groups.js +21 -22
  15. package/Organizations/Invitations.d.ts +8 -7
  16. package/Organizations/Invitations.js +21 -22
  17. package/Organizations/Members.d.ts +6 -5
  18. package/Organizations/Members.js +15 -16
  19. package/Organizations/Organizations.d.ts +7 -6
  20. package/Organizations/Organizations.js +18 -19
  21. package/Organizations/Webhooks.d.ts +3 -2
  22. package/Organizations/Webhooks.js +6 -7
  23. package/Organizations/Whitelabel.d.ts +3 -2
  24. package/Organizations/Whitelabel.js +6 -7
  25. package/Search/Content.d.ts +4 -3
  26. package/Search/Content.js +9 -10
  27. package/Templates/Fields.d.ts +4 -3
  28. package/Templates/Fields.js +9 -10
  29. package/Templates/Pages.d.ts +5 -4
  30. package/Templates/Pages.js +12 -13
  31. package/Templates/Reminders.d.ts +5 -4
  32. package/Templates/Reminders.js +12 -13
  33. package/Templates/Roles.d.ts +8 -7
  34. package/Templates/Roles.js +21 -22
  35. package/Templates/Stars.d.ts +3 -2
  36. package/Templates/Stars.js +6 -7
  37. package/Templates/Tags.d.ts +7 -6
  38. package/Templates/Tags.js +18 -19
  39. package/Templates/TemplateDocuments.d.ts +5 -4
  40. package/Templates/TemplateDocuments.js +12 -13
  41. package/Templates/Templates.d.ts +7 -6
  42. package/Templates/Templates.js +18 -19
  43. package/Templates/Validators.d.ts +3 -2
  44. package/Templates/Validators.js +7 -10
  45. package/Users/Auth.d.ts +9 -27
  46. package/Users/Auth.js +18 -98
  47. package/Users/Billing.d.ts +1 -1
  48. package/Users/Billing.js +1 -1
  49. package/Users/Notifications.d.ts +2 -1
  50. package/Users/Notifications.js +3 -4
  51. package/Users/Profiles.d.ts +11 -10
  52. package/Users/Profiles.js +30 -31
  53. package/Users/Types.d.ts +1 -1
  54. package/Utils/Token.d.ts +1 -1
  55. package/Utils/Token.js +2 -2
  56. package/{HTTP → Utils}/globalThis.d.ts +0 -0
  57. package/{HTTP → Utils}/globalThis.js +0 -0
  58. package/VerdocsEndpoint.d.ts +193 -0
  59. package/VerdocsEndpoint.js +290 -0
  60. package/index.d.ts +1 -1
  61. package/index.js +1 -1
  62. package/package.json +1 -1
  63. package/Documents/Stars.d.ts +0 -2
  64. package/Documents/Stars.js +0 -40
  65. package/HTTP/Transport.d.ts +0 -34
  66. package/HTTP/Transport.js +0 -47
  67. package/HTTP/Types.d.ts +0 -1
  68. package/HTTP/Types.js +0 -1
  69. package/HTTP/VerdocsEndpoint.d.ts +0 -106
  70. package/HTTP/VerdocsEndpoint.js +0 -141
  71. package/HTTP/index.d.ts +0 -3
  72. package/HTTP/index.js +0 -3
@@ -0,0 +1,290 @@
1
+ import axios from 'axios';
2
+ import { decodeAccessTokenBody } from './Utils/Token';
3
+ import globalThis from './Utils/globalThis';
4
+ import * as Documents from './Documents';
5
+ var requestLogger = function (r) {
6
+ // tslint:disable-next-line
7
+ console.debug("[JS-SDK] ".concat(r.method.toUpperCase(), " ").concat(r.baseURL).concat(r.url), r.data ? JSON.stringify(r.data) : '');
8
+ return r;
9
+ };
10
+ /**
11
+ * VerdocsEndpoint is a class wrapper for a specific connection and authorization context for calling the Verdocs APIs.
12
+ * Endpoints can be used for isolated session tasks.
13
+ *
14
+ * For instance, ephemeral signing sessions may be created independently of a caller's status as an authenticated user.
15
+ * In that case, an Endpoint can be created and authenticated, used for calls related to signing operations, then
16
+ * discarded once signing is complete.
17
+ *
18
+ * Note that endpoint configuration functions return the instance, so they can be chained, e.g.
19
+ *
20
+ * ```typescript
21
+ * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
22
+ *
23
+ * const endpoint = new VerdocsEndpoint();
24
+ * endpoint
25
+ * .setSessionType('signing')
26
+ * .logRequests(true)
27
+ * .setClientID('1234)
28
+ * .setTimeout(5000);
29
+ * ```
30
+ */
31
+ var VerdocsEndpoint = /** @class */ (function () {
32
+ /**
33
+ * Create a new VerdocsEndpoint to call Verdocs platform services.
34
+ *
35
+ * ```typescript
36
+ * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
37
+ * const endpoint = new VerdocsEndpoint();
38
+ * ```
39
+ */
40
+ function VerdocsEndpoint(options) {
41
+ this.environment = 'verdocs';
42
+ this.sessionType = 'user';
43
+ this.baseURL = 'https://api.verdocs.com';
44
+ this.clientID = 'not-set';
45
+ this.timeout = 3000;
46
+ this.token = null;
47
+ this.nextListenerId = 0;
48
+ this.sessionListeners = new Map();
49
+ this.requestLoggerId = null;
50
+ /**
51
+ * The current user session, or null if not authenticated. May be either a User or Signing session. If set, the
52
+ * presence of the `document_id` field can be used to differentiate the types. Only signing sessions are associated
53
+ * with Documents.
54
+ */
55
+ this.session = null;
56
+ this.Documents = Documents;
57
+ this.baseURL = (options === null || options === void 0 ? void 0 : options.baseURL) || 'https://api.verdocs.com';
58
+ this.timeout = (options === null || options === void 0 ? void 0 : options.timeout) || 3000;
59
+ this.environment = (options === null || options === void 0 ? void 0 : options.environment) || 'verdocs';
60
+ this.sessionType = (options === null || options === void 0 ? void 0 : options.sessionType) || 'user';
61
+ this.clientID = (options === null || options === void 0 ? void 0 : options.clientID) || 'not-set';
62
+ this.api = axios.create({ baseURL: this.baseURL, timeout: this.timeout });
63
+ }
64
+ VerdocsEndpoint.prototype.setDefault = function () {
65
+ globalThis[ENDPOINT_KEY] = this;
66
+ };
67
+ VerdocsEndpoint.getDefault = function () {
68
+ return globalThis[ENDPOINT_KEY];
69
+ };
70
+ /**
71
+ * Get the current environment.
72
+ */
73
+ VerdocsEndpoint.prototype.getEnvironment = function () {
74
+ return this.environment;
75
+ };
76
+ /**
77
+ * Get the current session type.
78
+ */
79
+ VerdocsEndpoint.prototype.getSessionType = function () {
80
+ return this.sessionType;
81
+ };
82
+ /**
83
+ * Get the current base URL. This should rarely be anything other than 'https://api.verdocs.com'.
84
+ */
85
+ VerdocsEndpoint.prototype.getBaseURL = function () {
86
+ return this.baseURL;
87
+ };
88
+ /**
89
+ * Get the current client ID, if set.
90
+ */
91
+ VerdocsEndpoint.prototype.getClientID = function () {
92
+ return this.clientID;
93
+ };
94
+ /**
95
+ * Get the current timeout.
96
+ */
97
+ VerdocsEndpoint.prototype.getTimeout = function () {
98
+ return this.timeout;
99
+ };
100
+ /**
101
+ * Get the current session, if any.
102
+ */
103
+ VerdocsEndpoint.prototype.getSession = function () {
104
+ return this.session;
105
+ };
106
+ /**
107
+ * Set the operating environment. This should rarely be anything other than 'verdocs'.
108
+ *
109
+ * ```typescript
110
+ * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
111
+ *
112
+ * const endpoint = new VerdocsEndpoint();
113
+ * endpoint.setEnvironment('verdocs-stage');
114
+ * ```
115
+ */
116
+ VerdocsEndpoint.prototype.setEnvironment = function (environment) {
117
+ this.environment = environment;
118
+ return this;
119
+ };
120
+ /**
121
+ * Set the session type. In general this should be done immediately when the endpoint is created. Changing the
122
+ * session type may be done at any time, but may have unintended consequences if the endpoint is shared between
123
+ * multiple widgets.
124
+ *
125
+ * Changing the session type will clear/reload the action session. This may trigger notifications to session state
126
+ * observers. Apps that use observers to trigger UI updates such as logging the user out should be prepared to
127
+ * handle this event.
128
+ *
129
+ * ```typescript
130
+ * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
131
+ *
132
+ * const endpoint = new VerdocsEndpoint();
133
+ * endpoint.setEnvironment('verdocs-stage');
134
+ * ```
135
+ */
136
+ VerdocsEndpoint.prototype.setSessionType = function (sessionType) {
137
+ this.sessionType = sessionType;
138
+ return this;
139
+ };
140
+ /**
141
+ * Set the base URL for API calls. Should be called only upon direction from Verdocs Customer Solutions Engineering.
142
+ *
143
+ * ```typescript
144
+ * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
145
+ *
146
+ * const endpoint = new VerdocsEndpoint();
147
+ * endpoint.setBaseURL('https://api.verdocs.com');
148
+ * ```
149
+ */
150
+ VerdocsEndpoint.prototype.setBaseURL = function (url) {
151
+ this.api.defaults.baseURL = url;
152
+ return this;
153
+ };
154
+ /**
155
+ * Set the Client ID for Verdocs API calls.
156
+ *
157
+ * ```typescript
158
+ * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
159
+ *
160
+ * const endpoint = new VerdocsEndpoint();
161
+ * endpoint.setClientID('1234);
162
+ * ```
163
+ */
164
+ VerdocsEndpoint.prototype.setClientID = function (clientID) {
165
+ this.clientID = clientID;
166
+ this.api.defaults.headers.common['X-Client-ID'] = clientID;
167
+ return this;
168
+ };
169
+ /**
170
+ * Set the timeout for API calls in milliseconds. 2000-4000ms is recommended for most purposes. 3000ms is the default.
171
+ *
172
+ * ```typescript
173
+ * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
174
+ *
175
+ * const endpoint = new VerdocsEndpoint();
176
+ * endpoint.setTimeout(3000);
177
+ * ```
178
+ */
179
+ VerdocsEndpoint.prototype.setTimeout = function (timeout) {
180
+ this.timeout = timeout;
181
+ this.api.defaults.timeout = timeout;
182
+ return this;
183
+ };
184
+ /**
185
+ * Enable or disable request logging. This may expose sensitive data in the console log, so it should only be used for debugging.
186
+ *
187
+ * ```typescript
188
+ * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
189
+ *
190
+ * const endpoint = new VerdocsEndpoint();
191
+ * endpoint.logRequests(true);
192
+ * ```
193
+ */
194
+ VerdocsEndpoint.prototype.logRequests = function (enable) {
195
+ if (enable && this.requestLoggerId === null) {
196
+ this.requestLoggerId = this.api.interceptors.request.use(requestLogger);
197
+ }
198
+ else if (!enable && this.requestLoggerId !== null) {
199
+ this.api.interceptors.request.eject(this.requestLoggerId);
200
+ }
201
+ return this;
202
+ };
203
+ /**
204
+ * Set the authorization token that will be used for Verdocs API calls. This will also set the session metadata
205
+ * and notify any listeners of the new data.
206
+ *
207
+ * If this Endpoint will be used for non-default purposes (e.g. signing, or in an alternate environment) those
208
+ * settings should be made before calling this. Sessions are persisted to localStorage, and the environment and
209
+ * type become part of the storage key.
210
+ *
211
+ * ```typescript
212
+ * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
213
+ *
214
+ * const endpoint = new VerdocsEndpoint();
215
+ * endpoint.setToken(accessToken);
216
+ * ```
217
+ */
218
+ VerdocsEndpoint.prototype.setToken = function (token) {
219
+ if (!token) {
220
+ return this.clearSession();
221
+ }
222
+ var session = decodeAccessTokenBody(token);
223
+ if (session === null || (session.exp && session.exp * 1000 < new Date().getTime())) {
224
+ return this.clearSession();
225
+ }
226
+ this.token = token;
227
+ this.session = session;
228
+ this.api.defaults.headers.common.Authorization = "Bearer ".concat(token);
229
+ localStorage.setItem(this.sessionStorageKey(), token);
230
+ this.notifySessionListeners();
231
+ return this;
232
+ };
233
+ VerdocsEndpoint.prototype.sessionStorageKey = function () {
234
+ return "verdocs-session-".concat(this.getSessionType(), "-").concat(this.getEnvironment());
235
+ };
236
+ /**
237
+ * Clear the active session.
238
+ */
239
+ VerdocsEndpoint.prototype.clearSession = function () {
240
+ localStorage.removeItem(this.sessionStorageKey());
241
+ delete this.api.defaults.headers.common.Authorization;
242
+ this.session = null;
243
+ this.token = null;
244
+ this.notifySessionListeners();
245
+ return this;
246
+ };
247
+ VerdocsEndpoint.prototype.notifySessionListeners = function () {
248
+ var _this = this;
249
+ this.sessionListeners.forEach(function (listener) {
250
+ try {
251
+ listener(_this, _this.session);
252
+ }
253
+ catch (e) {
254
+ // NOOP
255
+ }
256
+ });
257
+ };
258
+ /**
259
+ * Subscribe to session state change events.
260
+ */
261
+ VerdocsEndpoint.prototype.onSessionChanged = function (listener) {
262
+ var _this = this;
263
+ // There's no value in randomizing this, a simple counter is fine
264
+ this.nextListenerId++;
265
+ var listenerSymbol = Symbol.for('' + this.nextListenerId);
266
+ this.sessionListeners.set(listenerSymbol, listener);
267
+ return function () {
268
+ _this.sessionListeners.delete(listenerSymbol);
269
+ };
270
+ };
271
+ /**
272
+ * Load a persisted session from localStorage. Typically called once after the endpoint is configured when the app
273
+ * or component starts.
274
+ */
275
+ VerdocsEndpoint.prototype.loadSession = function () {
276
+ var token = localStorage.getItem(this.sessionStorageKey());
277
+ if (!token) {
278
+ return this.clearSession();
279
+ }
280
+ return this.setToken(token);
281
+ };
282
+ return VerdocsEndpoint;
283
+ }());
284
+ export { VerdocsEndpoint };
285
+ // @credit https://derickbailey.com/2016/03/09/creating-a-true-singleton-in-node-js-with-es6-symbols/
286
+ // Also see globalThis for comments about why we're doing this in the first place.
287
+ var ENDPOINT_KEY = Symbol.for('verdocs-default-endpoint');
288
+ if (!globalThis[ENDPOINT_KEY]) {
289
+ globalThis[ENDPOINT_KEY] = new VerdocsEndpoint();
290
+ }
package/index.d.ts CHANGED
@@ -12,7 +12,7 @@
12
12
  */
13
13
  export * as Documents from './Documents';
14
14
  export * as Templates from './Templates';
15
- export * as HTTP from './HTTP';
16
15
  export * as Organizations from './Organizations';
17
16
  export * as Users from './Users';
18
17
  export * as Utils from './Utils';
18
+ export * from './VerdocsEndpoint';
package/index.js CHANGED
@@ -12,7 +12,7 @@
12
12
  */
13
13
  export * as Documents from './Documents';
14
14
  export * as Templates from './Templates';
15
- export * as HTTP from './HTTP';
16
15
  export * as Organizations from './Organizations';
17
16
  export * as Users from './Users';
18
17
  export * as Utils from './Utils';
18
+ export * from './VerdocsEndpoint';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdocs/js-sdk",
3
- "version": "1.4.0",
3
+ "version": "2.0.1",
4
4
  "private": false,
5
5
  "homepage": "https://github.com/Verdocs/js-sdk",
6
6
  "description": "Verdocs JS SDK",
@@ -1,2 +0,0 @@
1
- import { ITemplateSummaryEntry } from './Types';
2
- export declare const toggleStar: (templateId: string) => Promise<ITemplateSummaryEntry>;
@@ -1,40 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __generator = (this && this.__generator) || function (thisArg, body) {
11
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
- function verb(n) { return function (v) { return step([n, v]); }; }
14
- function step(op) {
15
- if (f) throw new TypeError("Generator is already executing.");
16
- while (_) try {
17
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
- if (y = 0, t) op = [op[0] & 2, t.value];
19
- switch (op[0]) {
20
- case 0: case 1: t = op; break;
21
- case 4: _.label++; return { value: op[1], done: false };
22
- case 5: _.label++; y = op[1]; op = [0]; continue;
23
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
- default:
25
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
- if (t[2]) _.ops.pop();
30
- _.trys.pop(); continue;
31
- }
32
- op = body.call(thisArg, _);
33
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
- }
36
- };
37
- import { getEndpoint } from '../HTTP/Transport';
38
- export var toggleStar = function (templateId) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
39
- return [2 /*return*/, getEndpoint().api.post("/templates/".concat(templateId, "/stars/toggle")).then(function (r) { return r.data; })];
40
- }); }); };
@@ -1,34 +0,0 @@
1
- /**
2
- * The Transport is a global singleton used to call Verdocs APIs. There can only be one Transport per application, and
3
- * its configuration settings are shared for all callers. This is a simplified form of the Endpoint class where most
4
- * tasks such as general session-token-management are handled automatically for the caller.
5
- *
6
- * @module
7
- */
8
- import { VerdocsEndpoint } from './VerdocsEndpoint';
9
- /**
10
- * Helper to get the endpoint for direct access to HTTP functions.
11
- *
12
- * ```typescript
13
- * import {Transport} from '@verdocs/js-sdk/HTTP';
14
- *
15
- * console.log('Current timeout', Transport.getEndpoint().defaults.timeout);
16
- * ```
17
- */
18
- export declare const getEndpoint: () => VerdocsEndpoint;
19
- /**
20
- * Change the endpoint that will be used when making calls to Verdocs. Only one endpoint may be active at a time.
21
- * Authorization and other configuration data is specific to each endpoint, and will not be carried over when the
22
- * endpoint is changed. The typical use-case is to change to a sandboxed endpoint for signing sessions, then revert
23
- * to the global endpoint when the signing session is complete. To revert, pass `null` as the endpoint to use.
24
- *
25
- * ```typescript
26
- * import {Transport} from '@verdocs/js-sdk/HTTP';
27
- *
28
- * const mySigningEndpoint = new VerdocsEndpoint();
29
- * setActiveEndpoint(mySigningEndpoint);
30
- * ... [Perform signing operations]
31
- * setActiveEndpoint(null);
32
- * ```
33
- */
34
- export declare const setActiveEndpoint: (e: VerdocsEndpoint | null) => void;
package/HTTP/Transport.js DELETED
@@ -1,47 +0,0 @@
1
- /**
2
- * The Transport is a global singleton used to call Verdocs APIs. There can only be one Transport per application, and
3
- * its configuration settings are shared for all callers. This is a simplified form of the Endpoint class where most
4
- * tasks such as general session-token-management are handled automatically for the caller.
5
- *
6
- * @module
7
- */
8
- import { VerdocsEndpoint } from './VerdocsEndpoint';
9
- import globalThis from './globalThis';
10
- // @credit https://derickbailey.com/2016/03/09/creating-a-true-singleton-in-node-js-with-es6-symbols/
11
- // Also see globalThis for comments about why we're doing this in the first place.
12
- var ENDPOINT_KEY = Symbol.for('verdocs-api-endpoint');
13
- if (!globalThis[ENDPOINT_KEY]) {
14
- globalThis[ENDPOINT_KEY] = new VerdocsEndpoint();
15
- }
16
- var globalEndpoint = globalThis[ENDPOINT_KEY];
17
- var activeEndpoint = globalEndpoint;
18
- /**
19
- * Helper to get the endpoint for direct access to HTTP functions.
20
- *
21
- * ```typescript
22
- * import {Transport} from '@verdocs/js-sdk/HTTP';
23
- *
24
- * console.log('Current timeout', Transport.getEndpoint().defaults.timeout);
25
- * ```
26
- */
27
- export var getEndpoint = function () {
28
- return activeEndpoint;
29
- };
30
- /**
31
- * Change the endpoint that will be used when making calls to Verdocs. Only one endpoint may be active at a time.
32
- * Authorization and other configuration data is specific to each endpoint, and will not be carried over when the
33
- * endpoint is changed. The typical use-case is to change to a sandboxed endpoint for signing sessions, then revert
34
- * to the global endpoint when the signing session is complete. To revert, pass `null` as the endpoint to use.
35
- *
36
- * ```typescript
37
- * import {Transport} from '@verdocs/js-sdk/HTTP';
38
- *
39
- * const mySigningEndpoint = new VerdocsEndpoint();
40
- * setActiveEndpoint(mySigningEndpoint);
41
- * ... [Perform signing operations]
42
- * setActiveEndpoint(null);
43
- * ```
44
- */
45
- export var setActiveEndpoint = function (e) {
46
- activeEndpoint = e || globalEndpoint;
47
- };
package/HTTP/Types.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare type TRequestStatus = 'OK' | 'ERROR';
package/HTTP/Types.js DELETED
@@ -1 +0,0 @@
1
- export {};
@@ -1,106 +0,0 @@
1
- import { AxiosInstance } from 'axios';
2
- /**
3
- * VerdocsEndpoint is a class wrapper for a specific connection and authorization context for calling the Verdocs APIs.
4
- * Endpoints can be used for isolated session tasks.
5
- * For instance, ephemeral signing sessions may be created independently of a caller's status as an authenticated user.
6
- * In that case, an Endpoint can be created and authenticated, used for calls related to signing operations, then
7
- * discarded once signing is complete.
8
- *
9
- * Note that endpoint configuration functions return the instance, so they can be chained, e.g.
10
- *
11
- * ```typescript
12
- * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
13
- *
14
- * const endpoint = new VerdocsEndpoint();
15
- * endpoint
16
- * .logRequests(true)
17
- * .setClientID('1234)
18
- * .setTimeout(5000);
19
- * ```
20
- */
21
- export declare class VerdocsEndpoint {
22
- /**
23
- * Reference to the axios instance wrapped by this endpoint. This is exposed as a convenience to developers, but
24
- * developers should generally use the convenience functions such as `setTimeout` to configure the connection.
25
- * Although there are currently no plans to change from Axios to another XHR library, the less this property is
26
- * directly accessed the easier future migrations will be.
27
- */
28
- api: AxiosInstance;
29
- private requestLoggerId;
30
- /**
31
- * Create a new VerdocsEndpoint to call Verdocs platform services.
32
- *
33
- * ```typescript
34
- * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
35
- * const endpoint = new VerdocsEndpoint();
36
- * ```
37
- */
38
- constructor();
39
- /**
40
- * Set the timeout for API calls in milliseconds. 2000-4000ms is recommended for most purposes. 3000ms is the default.
41
- *
42
- * ```typescript
43
- * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
44
- *
45
- * const endpoint = new VerdocsEndpoint();
46
- * endpoint.setTimeout(3000);
47
- * ```
48
- */
49
- setTimeout(timeout: number): VerdocsEndpoint;
50
- /**
51
- * Set the Client ID for Verdocs API calls.
52
- *
53
- * ```typescript
54
- * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
55
- *
56
- * const endpoint = new VerdocsEndpoint();
57
- * endpoint.setClientID('1234);
58
- * ```
59
- */
60
- setClientID(clientID: string): VerdocsEndpoint;
61
- /**
62
- * Set the auth token that will be used for Verdocs API calls.
63
- *
64
- * ```typescript
65
- * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
66
- *
67
- * const endpoint = new VerdocsEndpoint();
68
- * endpoint.setAuthorization(accessToken);
69
- * ```
70
- */
71
- setAuthorization(accessToken: string | null): VerdocsEndpoint;
72
- /**
73
- * Set the auth token used for signing sessions. Separating user from signing auth allows the same endpoint to be
74
- * used for multiple operations, although it is recommended that a separate endpoint be created for each operation.
75
- *
76
- * ```typescript
77
- * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
78
- *
79
- * const endpoint = new VerdocsEndpoint();
80
- * endpoint.setSigningAuthorization(accessToken);
81
- * ```
82
- */
83
- setSigningAuthorization(accessToken: string | null): VerdocsEndpoint;
84
- /**
85
- * Set the base URL for API calls. May also be set via the constructor.
86
- *
87
- * ```typescript
88
- * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
89
- *
90
- * const endpoint = new VerdocsEndpoint();
91
- * endpoint.setBaseURL('https://api.verdocs.com');
92
- * ```
93
- */
94
- setBaseURL(url: string): VerdocsEndpoint;
95
- /**
96
- * Enable or disable request logging. This may expose sensitive data in the console log, so it should only be used for debugging.
97
- *
98
- * ```typescript
99
- * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
100
- *
101
- * const endpoint = new VerdocsEndpoint();
102
- * endpoint.logRequests(true);
103
- * ```
104
- */
105
- logRequests(enable: boolean): VerdocsEndpoint;
106
- }