@verdocs/js-sdk 1.4.1 → 2.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.
- package/Documents/Documents.d.ts +26 -9
- package/Documents/Documents.js +42 -27
- package/Documents/Initials.d.ts +2 -1
- package/Documents/Initials.js +3 -4
- package/Documents/Recipients.d.ts +5 -1
- package/Documents/Recipients.js +6 -4
- package/Documents/Signatures.d.ts +14 -4
- package/Documents/Signatures.js +21 -13
- package/Documents/index.d.ts +0 -1
- package/Documents/index.js +0 -1
- package/Organizations/ApiKeys.d.ts +6 -5
- package/Organizations/ApiKeys.js +15 -16
- package/Organizations/Groups.d.ts +8 -7
- package/Organizations/Groups.js +21 -22
- package/Organizations/Invitations.d.ts +8 -7
- package/Organizations/Invitations.js +21 -22
- package/Organizations/Members.d.ts +6 -5
- package/Organizations/Members.js +15 -16
- package/Organizations/Organizations.d.ts +7 -6
- package/Organizations/Organizations.js +18 -19
- package/Organizations/Webhooks.d.ts +3 -2
- package/Organizations/Webhooks.js +6 -7
- package/Organizations/Whitelabel.d.ts +3 -2
- package/Organizations/Whitelabel.js +6 -7
- package/Search/Content.d.ts +4 -3
- package/Search/Content.js +9 -10
- package/Templates/Fields.d.ts +4 -3
- package/Templates/Fields.js +9 -10
- package/Templates/Pages.d.ts +5 -4
- package/Templates/Pages.js +12 -13
- package/Templates/Reminders.d.ts +5 -4
- package/Templates/Reminders.js +12 -13
- package/Templates/Roles.d.ts +8 -7
- package/Templates/Roles.js +21 -22
- package/Templates/Stars.d.ts +3 -2
- package/Templates/Stars.js +6 -7
- package/Templates/Tags.d.ts +7 -6
- package/Templates/Tags.js +18 -19
- package/Templates/TemplateDocuments.d.ts +5 -4
- package/Templates/TemplateDocuments.js +12 -13
- package/Templates/Templates.d.ts +7 -6
- package/Templates/Templates.js +18 -19
- package/Templates/Validators.d.ts +3 -2
- package/Templates/Validators.js +7 -10
- package/Users/Auth.d.ts +9 -27
- package/Users/Auth.js +18 -105
- package/Users/Billing.d.ts +1 -1
- package/Users/Billing.js +1 -1
- package/Users/Notifications.d.ts +2 -1
- package/Users/Notifications.js +3 -4
- package/Users/Profiles.d.ts +11 -10
- package/Users/Profiles.js +30 -31
- package/Users/Types.d.ts +1 -1
- package/Utils/Token.d.ts +1 -1
- package/Utils/Token.js +2 -2
- package/{HTTP → Utils}/globalThis.d.ts +0 -0
- package/{HTTP → Utils}/globalThis.js +0 -0
- package/VerdocsEndpoint.d.ts +188 -0
- package/VerdocsEndpoint.js +285 -0
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/package.json +1 -1
- package/Documents/Stars.d.ts +0 -2
- package/Documents/Stars.js +0 -40
- package/HTTP/Transport.d.ts +0 -34
- package/HTTP/Transport.js +0 -47
- package/HTTP/Types.d.ts +0 -1
- package/HTTP/Types.js +0 -1
- package/HTTP/VerdocsEndpoint.d.ts +0 -106
- package/HTTP/VerdocsEndpoint.js +0 -141
- package/HTTP/index.d.ts +0 -3
- package/HTTP/index.js +0 -3
|
@@ -0,0 +1,285 @@
|
|
|
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.session = null;
|
|
47
|
+
this.token = null;
|
|
48
|
+
this.nextListenerId = 0;
|
|
49
|
+
this.sessionListeners = new Map();
|
|
50
|
+
this.requestLoggerId = null;
|
|
51
|
+
this.Documents = Documents;
|
|
52
|
+
this.baseURL = (options === null || options === void 0 ? void 0 : options.baseURL) || 'https://api.verdocs.com';
|
|
53
|
+
this.timeout = (options === null || options === void 0 ? void 0 : options.timeout) || 3000;
|
|
54
|
+
this.environment = (options === null || options === void 0 ? void 0 : options.environment) || 'verdocs';
|
|
55
|
+
this.sessionType = (options === null || options === void 0 ? void 0 : options.sessionType) || 'user';
|
|
56
|
+
this.clientID = (options === null || options === void 0 ? void 0 : options.clientID) || 'not-set';
|
|
57
|
+
this.api = axios.create({ baseURL: this.baseURL, timeout: this.timeout });
|
|
58
|
+
}
|
|
59
|
+
VerdocsEndpoint.prototype.setDefault = function () {
|
|
60
|
+
globalThis[ENDPOINT_KEY] = this;
|
|
61
|
+
};
|
|
62
|
+
VerdocsEndpoint.getDefault = function () {
|
|
63
|
+
return globalThis[ENDPOINT_KEY];
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Get the current environment.
|
|
67
|
+
*/
|
|
68
|
+
VerdocsEndpoint.prototype.getEnvironment = function () {
|
|
69
|
+
return this.environment;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Get the current session type.
|
|
73
|
+
*/
|
|
74
|
+
VerdocsEndpoint.prototype.getSessionType = function () {
|
|
75
|
+
return this.sessionType;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Get the current base URL. This should rarely be anything other than 'https://api.verdocs.com'.
|
|
79
|
+
*/
|
|
80
|
+
VerdocsEndpoint.prototype.getBaseURL = function () {
|
|
81
|
+
return this.baseURL;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Get the current client ID, if set.
|
|
85
|
+
*/
|
|
86
|
+
VerdocsEndpoint.prototype.getClientID = function () {
|
|
87
|
+
return this.clientID;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Get the current timeout.
|
|
91
|
+
*/
|
|
92
|
+
VerdocsEndpoint.prototype.getTimeout = function () {
|
|
93
|
+
return this.timeout;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Get the current session, if any.
|
|
97
|
+
*/
|
|
98
|
+
VerdocsEndpoint.prototype.getSession = function () {
|
|
99
|
+
return this.session;
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* Set the operating environment. This should rarely be anything other than 'verdocs'.
|
|
103
|
+
*
|
|
104
|
+
* ```typescript
|
|
105
|
+
* import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
|
|
106
|
+
*
|
|
107
|
+
* const endpoint = new VerdocsEndpoint();
|
|
108
|
+
* endpoint.setEnvironment('verdocs-stage');
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
VerdocsEndpoint.prototype.setEnvironment = function (environment) {
|
|
112
|
+
this.environment = environment;
|
|
113
|
+
return this;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Set the session type. In general this should be done immediately when the endpoint is created. Changing the
|
|
117
|
+
* session type may be done at any time, but may have unintended consequences if the endpoint is shared between
|
|
118
|
+
* multiple widgets.
|
|
119
|
+
*
|
|
120
|
+
* Changing the session type will clear/reload the action session. This may trigger notifications to session state
|
|
121
|
+
* observers. Apps that use observers to trigger UI updates such as logging the user out should be prepared to
|
|
122
|
+
* handle this event.
|
|
123
|
+
*
|
|
124
|
+
* ```typescript
|
|
125
|
+
* import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
|
|
126
|
+
*
|
|
127
|
+
* const endpoint = new VerdocsEndpoint();
|
|
128
|
+
* endpoint.setEnvironment('verdocs-stage');
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
VerdocsEndpoint.prototype.setSessionType = function (sessionType) {
|
|
132
|
+
this.sessionType = sessionType;
|
|
133
|
+
return this;
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* Set the base URL for API calls. Should be called only upon direction from Verdocs Customer Solutions Engineering.
|
|
137
|
+
*
|
|
138
|
+
* ```typescript
|
|
139
|
+
* import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
|
|
140
|
+
*
|
|
141
|
+
* const endpoint = new VerdocsEndpoint();
|
|
142
|
+
* endpoint.setBaseURL('https://api.verdocs.com');
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
VerdocsEndpoint.prototype.setBaseURL = function (url) {
|
|
146
|
+
this.api.defaults.baseURL = url;
|
|
147
|
+
return this;
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
* Set the Client ID for Verdocs API calls.
|
|
151
|
+
*
|
|
152
|
+
* ```typescript
|
|
153
|
+
* import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
|
|
154
|
+
*
|
|
155
|
+
* const endpoint = new VerdocsEndpoint();
|
|
156
|
+
* endpoint.setClientID('1234);
|
|
157
|
+
* ```
|
|
158
|
+
*/
|
|
159
|
+
VerdocsEndpoint.prototype.setClientID = function (clientID) {
|
|
160
|
+
this.clientID = clientID;
|
|
161
|
+
this.api.defaults.headers.common['X-Client-ID'] = clientID;
|
|
162
|
+
return this;
|
|
163
|
+
};
|
|
164
|
+
/**
|
|
165
|
+
* Set the timeout for API calls in milliseconds. 2000-4000ms is recommended for most purposes. 3000ms is the default.
|
|
166
|
+
*
|
|
167
|
+
* ```typescript
|
|
168
|
+
* import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
|
|
169
|
+
*
|
|
170
|
+
* const endpoint = new VerdocsEndpoint();
|
|
171
|
+
* endpoint.setTimeout(3000);
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
VerdocsEndpoint.prototype.setTimeout = function (timeout) {
|
|
175
|
+
this.timeout = timeout;
|
|
176
|
+
this.api.defaults.timeout = timeout;
|
|
177
|
+
return this;
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
* Enable or disable request logging. This may expose sensitive data in the console log, so it should only be used for debugging.
|
|
181
|
+
*
|
|
182
|
+
* ```typescript
|
|
183
|
+
* import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
|
|
184
|
+
*
|
|
185
|
+
* const endpoint = new VerdocsEndpoint();
|
|
186
|
+
* endpoint.logRequests(true);
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
VerdocsEndpoint.prototype.logRequests = function (enable) {
|
|
190
|
+
if (enable && this.requestLoggerId === null) {
|
|
191
|
+
this.requestLoggerId = this.api.interceptors.request.use(requestLogger);
|
|
192
|
+
}
|
|
193
|
+
else if (!enable && this.requestLoggerId !== null) {
|
|
194
|
+
this.api.interceptors.request.eject(this.requestLoggerId);
|
|
195
|
+
}
|
|
196
|
+
return this;
|
|
197
|
+
};
|
|
198
|
+
/**
|
|
199
|
+
* Set the authorization token that will be used for Verdocs API calls. This will also set the session metadata
|
|
200
|
+
* and notify any listeners of the new data.
|
|
201
|
+
*
|
|
202
|
+
* If this Endpoint will be used for non-default purposes (e.g. signing, or in an alternate environment) those
|
|
203
|
+
* settings should be made before calling this. Sessions are persisted to localStorage, and the environment and
|
|
204
|
+
* type become part of the storage key.
|
|
205
|
+
*
|
|
206
|
+
* ```typescript
|
|
207
|
+
* import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
|
|
208
|
+
*
|
|
209
|
+
* const endpoint = new VerdocsEndpoint();
|
|
210
|
+
* endpoint.setToken(accessToken);
|
|
211
|
+
* ```
|
|
212
|
+
*/
|
|
213
|
+
VerdocsEndpoint.prototype.setToken = function (token) {
|
|
214
|
+
if (!token) {
|
|
215
|
+
return this.clearSession();
|
|
216
|
+
}
|
|
217
|
+
var session = decodeAccessTokenBody(token);
|
|
218
|
+
if (session === null || (session.exp && session.exp * 1000 < new Date().getTime())) {
|
|
219
|
+
return this.clearSession();
|
|
220
|
+
}
|
|
221
|
+
this.token = token;
|
|
222
|
+
this.session = session;
|
|
223
|
+
this.api.defaults.headers.common.Authorization = "Bearer ".concat(token);
|
|
224
|
+
localStorage.setItem(this.sessionStorageKey(), token);
|
|
225
|
+
this.notifySessionListeners();
|
|
226
|
+
return this;
|
|
227
|
+
};
|
|
228
|
+
VerdocsEndpoint.prototype.sessionStorageKey = function () {
|
|
229
|
+
return "verdocs-session-".concat(this.getSessionType(), "-").concat(this.getEnvironment());
|
|
230
|
+
};
|
|
231
|
+
/**
|
|
232
|
+
* Clear the active session.
|
|
233
|
+
*/
|
|
234
|
+
VerdocsEndpoint.prototype.clearSession = function () {
|
|
235
|
+
localStorage.removeItem(this.sessionStorageKey());
|
|
236
|
+
delete this.api.defaults.headers.common.Authorization;
|
|
237
|
+
this.session = null;
|
|
238
|
+
this.token = null;
|
|
239
|
+
this.notifySessionListeners();
|
|
240
|
+
return this;
|
|
241
|
+
};
|
|
242
|
+
VerdocsEndpoint.prototype.notifySessionListeners = function () {
|
|
243
|
+
var _this = this;
|
|
244
|
+
this.sessionListeners.forEach(function (listener) {
|
|
245
|
+
try {
|
|
246
|
+
listener(_this, _this.session);
|
|
247
|
+
}
|
|
248
|
+
catch (e) {
|
|
249
|
+
// NOOP
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
};
|
|
253
|
+
/**
|
|
254
|
+
* Subscribe to session state change events.
|
|
255
|
+
*/
|
|
256
|
+
VerdocsEndpoint.prototype.onSessionChanged = function (listener) {
|
|
257
|
+
var _this = this;
|
|
258
|
+
// There's no value in randomizing this, a simple counter is fine
|
|
259
|
+
this.nextListenerId++;
|
|
260
|
+
var listenerSymbol = Symbol.for('' + this.nextListenerId);
|
|
261
|
+
this.sessionListeners.set(listenerSymbol, listener);
|
|
262
|
+
return function () {
|
|
263
|
+
_this.sessionListeners.delete(listenerSymbol);
|
|
264
|
+
};
|
|
265
|
+
};
|
|
266
|
+
/**
|
|
267
|
+
* Load a persisted session from localStorage. Typically called once after the endpoint is configured when the app
|
|
268
|
+
* or component starts.
|
|
269
|
+
*/
|
|
270
|
+
VerdocsEndpoint.prototype.loadSession = function (source) {
|
|
271
|
+
var token = localStorage.getItem(this.sessionStorageKey());
|
|
272
|
+
if (!token) {
|
|
273
|
+
return this.clearSession();
|
|
274
|
+
}
|
|
275
|
+
return this.setToken(token);
|
|
276
|
+
};
|
|
277
|
+
return VerdocsEndpoint;
|
|
278
|
+
}());
|
|
279
|
+
export { VerdocsEndpoint };
|
|
280
|
+
// @credit https://derickbailey.com/2016/03/09/creating-a-true-singleton-in-node-js-with-es6-symbols/
|
|
281
|
+
// Also see globalThis for comments about why we're doing this in the first place.
|
|
282
|
+
var ENDPOINT_KEY = Symbol.for('verdocs-default-endpoint');
|
|
283
|
+
if (!globalThis[ENDPOINT_KEY]) {
|
|
284
|
+
globalThis[ENDPOINT_KEY] = new VerdocsEndpoint();
|
|
285
|
+
}
|
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
package/Documents/Stars.d.ts
DELETED
package/Documents/Stars.js
DELETED
|
@@ -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
|
-
}); }); };
|
package/HTTP/Transport.d.ts
DELETED
|
@@ -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
|
-
}
|