@verdocs/js-sdk 1.0.25 → 1.1.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.
- package/Documents/Documents.d.ts +12 -3
- package/Documents/Documents.js +27 -2
- package/Documents/Signatures.js +4 -4
- package/Documents/Stars.js +1 -1
- package/Documents/Types.d.ts +19 -0
- package/HTTP/Transport.d.ts +16 -41
- package/HTTP/Transport.js +21 -83
- package/HTTP/VerdocsEndpoint.d.ts +71 -0
- package/HTTP/VerdocsEndpoint.js +99 -0
- package/HTTP/index.d.ts +1 -0
- package/HTTP/index.js +1 -0
- package/Organizations/ApiKeys.js +5 -5
- package/Organizations/Groups.js +7 -7
- package/Organizations/Invitations.js +7 -7
- package/Organizations/Members.js +5 -5
- package/Organizations/Organizations.js +6 -6
- package/Organizations/Webhooks.js +2 -2
- package/Organizations/Whitelabel.js +2 -2
- package/Search/Content.js +3 -3
- package/Templates/Documents.js +4 -4
- package/Templates/Fields.js +3 -3
- package/Templates/Pages.js +4 -4
- package/Templates/Reminders.js +4 -4
- package/Templates/Roles.js +7 -7
- package/Templates/Stars.js +2 -2
- package/Templates/Tags.js +6 -6
- package/Templates/Templates.js +6 -6
- package/Templates/Validators.js +2 -2
- package/Users/Auth.js +6 -6
- package/Users/Notifications.js +1 -1
- package/Users/Profiles.js +10 -10
- package/Utils/AtoB.d.ts +1 -0
- package/Utils/AtoB.js +33 -0
- package/Utils/index.d.ts +1 -0
- package/Utils/index.js +1 -0
- package/package.json +4 -2
package/Documents/Documents.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ISigningSession, ISigningSessionRequest } from './Types';
|
|
1
2
|
export declare type TDocumentStatus = 'complete' | 'pending' | 'in progress' | 'declined' | 'canceled';
|
|
2
3
|
export declare type TRecipientStatus = 'invited' | 'opened' | 'signed' | 'submitted' | 'canceled' | 'pending' | 'declined';
|
|
3
4
|
export declare type TRecipientType = 'signer' | 'cc' | 'approver';
|
|
@@ -51,10 +52,10 @@ export interface IRecipient {
|
|
|
51
52
|
email: string;
|
|
52
53
|
envelope_id: string;
|
|
53
54
|
full_name: string;
|
|
54
|
-
in_app_access_key
|
|
55
|
-
key_used_to_conclude
|
|
55
|
+
in_app_access_key?: string;
|
|
56
|
+
key_used_to_conclude?: string;
|
|
56
57
|
message: string | null;
|
|
57
|
-
phone: string;
|
|
58
|
+
phone: string | null;
|
|
58
59
|
profile_id: string;
|
|
59
60
|
role_name: string;
|
|
60
61
|
sequence: number;
|
|
@@ -137,3 +138,11 @@ export declare const getSummary: (page: number) => Promise<IDocumentsSummary>;
|
|
|
137
138
|
* ```
|
|
138
139
|
*/
|
|
139
140
|
export declare const searchDocuments: (params: any) => Promise<IDocumentsSearchResult>;
|
|
141
|
+
/**
|
|
142
|
+
* Get a signing session for a document.
|
|
143
|
+
*/
|
|
144
|
+
export declare const getSigningSession: (params: ISigningSessionRequest) => Promise<{
|
|
145
|
+
recipient: IRecipient;
|
|
146
|
+
session: ISigningSession;
|
|
147
|
+
}>;
|
|
148
|
+
export declare const getDocumentRecipients: (documentId: string) => Promise<IRecipient[]>;
|
package/Documents/Documents.js
CHANGED
|
@@ -35,6 +35,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
import { getEndpoint } from '../HTTP/Transport';
|
|
38
|
+
import { AtoB } from '../Utils';
|
|
38
39
|
/**
|
|
39
40
|
* Get a summary of currently active documents.
|
|
40
41
|
*
|
|
@@ -47,7 +48,7 @@ import { getEndpoint } from '../HTTP/Transport';
|
|
|
47
48
|
export var getSummary = function (page) { return __awaiter(void 0, void 0, void 0, function () {
|
|
48
49
|
return __generator(this, function (_a) {
|
|
49
50
|
return [2 /*return*/, getEndpoint()
|
|
50
|
-
.post('/documents/summary', { page: page })
|
|
51
|
+
.api.post('/documents/summary', { page: page })
|
|
51
52
|
.then(function (r) { return r.data; })];
|
|
52
53
|
});
|
|
53
54
|
}); };
|
|
@@ -63,7 +64,31 @@ export var getSummary = function (page) { return __awaiter(void 0, void 0, void
|
|
|
63
64
|
export var searchDocuments = function (params) { return __awaiter(void 0, void 0, void 0, function () {
|
|
64
65
|
return __generator(this, function (_a) {
|
|
65
66
|
return [2 /*return*/, getEndpoint()
|
|
66
|
-
.post('/documents/search', params)
|
|
67
|
+
.api.post('/documents/search', params)
|
|
68
|
+
.then(function (r) { return r.data; })];
|
|
69
|
+
});
|
|
70
|
+
}); };
|
|
71
|
+
/**
|
|
72
|
+
* Get a signing session for a document.
|
|
73
|
+
*/
|
|
74
|
+
export var getSigningSession = function (params) { return __awaiter(void 0, void 0, void 0, function () {
|
|
75
|
+
return __generator(this, function (_a) {
|
|
76
|
+
return [2 /*return*/, getEndpoint()
|
|
77
|
+
.api.get("/documents/".concat(params.documentId, "/recipients/").concat(encodeURIComponent(params.roleId), "/invitation/").concat(params.inviteCode))
|
|
78
|
+
.then(function (r) {
|
|
79
|
+
var _a, _b;
|
|
80
|
+
// Avoiding a jsonwebtoken dependency here - we don't actually need the whole library
|
|
81
|
+
var signerToken = ((_a = r.headers) === null || _a === void 0 ? void 0 : _a.signer_token) || '';
|
|
82
|
+
var session = JSON.parse(AtoB(signerToken.split('.')[1]));
|
|
83
|
+
getEndpoint().setAuthorization((_b = r.headers) === null || _b === void 0 ? void 0 : _b.signer_token);
|
|
84
|
+
return { recipient: r.data, session: session, signerToken: signerToken };
|
|
85
|
+
})];
|
|
86
|
+
});
|
|
87
|
+
}); };
|
|
88
|
+
export var getDocumentRecipients = function (documentId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
89
|
+
return __generator(this, function (_a) {
|
|
90
|
+
return [2 /*return*/, getEndpoint()
|
|
91
|
+
.api.get("/documents/".concat(documentId, "/recipients"))
|
|
67
92
|
.then(function (r) { return r.data; })];
|
|
68
93
|
});
|
|
69
94
|
}); };
|
package/Documents/Signatures.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { getEndpoint } from '../HTTP/Transport';
|
|
2
2
|
export var createSignature = function (params) {
|
|
3
3
|
return getEndpoint()
|
|
4
|
-
.post('/signatures', params)
|
|
4
|
+
.api.post('/signatures', params)
|
|
5
5
|
.then(function (r) { return r.data; });
|
|
6
6
|
};
|
|
7
7
|
export var getSignatures = function () {
|
|
8
8
|
return getEndpoint()
|
|
9
|
-
.get('/signatures')
|
|
9
|
+
.api.get('/signatures')
|
|
10
10
|
.then(function (r) { return r.data; });
|
|
11
11
|
};
|
|
12
12
|
export var getSignature = function (signatureId) {
|
|
13
13
|
return getEndpoint()
|
|
14
|
-
.get("/signatures/".concat(signatureId))
|
|
14
|
+
.api.get("/signatures/".concat(signatureId))
|
|
15
15
|
.then(function (r) { return r.data; });
|
|
16
16
|
};
|
|
17
17
|
export var deleteSignature = function (signatureId) {
|
|
18
18
|
return getEndpoint()
|
|
19
|
-
.delete("/signatures/".concat(signatureId))
|
|
19
|
+
.api.delete("/signatures/".concat(signatureId))
|
|
20
20
|
.then(function (r) { return r.data; });
|
|
21
21
|
};
|
package/Documents/Stars.js
CHANGED
|
@@ -36,5 +36,5 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
};
|
|
37
37
|
import { getEndpoint } from '../HTTP/Transport';
|
|
38
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().post("/templates/".concat(templateId, "/stars/toggle")).then(function (r) { return r.data; })];
|
|
39
|
+
return [2 /*return*/, getEndpoint().api.post("/templates/".concat(templateId, "/stars/toggle")).then(function (r) { return r.data; })];
|
|
40
40
|
}); }); };
|
package/Documents/Types.d.ts
CHANGED
|
@@ -21,3 +21,22 @@ export interface ITemplatesSummary {
|
|
|
21
21
|
total: number;
|
|
22
22
|
result: ITemplateSummaryEntry[];
|
|
23
23
|
}
|
|
24
|
+
export interface ISigningSessionRequest {
|
|
25
|
+
documentId: string;
|
|
26
|
+
roleId: string;
|
|
27
|
+
inviteCode: string;
|
|
28
|
+
}
|
|
29
|
+
export interface ISigningSession {
|
|
30
|
+
profile_id: 'guest|515c9dc1-4c5c-4255-9f75-44b6870fc0eb';
|
|
31
|
+
document_id: 'f484a296-4f4c-4783-9adf-a3302915a503';
|
|
32
|
+
role: 'Recipient 2';
|
|
33
|
+
email: 'crobinson@medialantern.com';
|
|
34
|
+
access_key: {
|
|
35
|
+
id: 'a59ceb98-3fab-44d2-af8a-13088d6c1a32';
|
|
36
|
+
type: 'email';
|
|
37
|
+
};
|
|
38
|
+
iss: 'https://stage-realster.auth0.com';
|
|
39
|
+
aud: 'QYVTceK2qtOQvH8Nl2APUJaBMRys1y95';
|
|
40
|
+
exp: 1641881182;
|
|
41
|
+
iat: 1641873982;
|
|
42
|
+
}
|
package/HTTP/Transport.d.ts
CHANGED
|
@@ -1,59 +1,34 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The Transport
|
|
3
|
-
* its configuration settings are shared for all callers.
|
|
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.
|
|
4
5
|
*
|
|
5
6
|
* @module
|
|
6
7
|
*/
|
|
7
|
-
import {
|
|
8
|
+
import { VerdocsEndpoint } from './VerdocsEndpoint';
|
|
8
9
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* ```typescript
|
|
12
|
-
* import {Transport} from '@verdocs/js-sdk/HTTP';
|
|
13
|
-
*
|
|
14
|
-
* Transport.setAuthorization(accessToken);
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
export declare const setAuthorization: (accessToken: string | null) => void;
|
|
18
|
-
/**
|
|
19
|
-
* Set the Client ID for Verdocs API calls.
|
|
20
|
-
*
|
|
21
|
-
* ```typescript
|
|
22
|
-
* import {Transport} from '@verdocs/js-sdk/HTTP';
|
|
23
|
-
*
|
|
24
|
-
* Transport.setClientID('1234);
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
export declare const setClientID: (clientID: string) => void;
|
|
28
|
-
/**
|
|
29
|
-
* Set the base URL for API calls. This defaults to https://api.verdocs.com/ and should only be changed after consultation with
|
|
30
|
-
* Verdocs Developer Support (e.g. to access a private API endpoint).
|
|
31
|
-
*
|
|
32
|
-
* ```typescript
|
|
33
|
-
* import {Transport} from '@verdocs/js-sdk/HTTP';
|
|
34
|
-
*
|
|
35
|
-
* Transport.setBaseUrl('https://my-private-api.verdocs.com');
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
export declare const setBaseUrl: (baseUrl: string) => void;
|
|
39
|
-
/**
|
|
40
|
-
* Set the timeout for API calls in milliseconds. 2000-4000ms is recommended for most purposes. 3000ms is the default.
|
|
10
|
+
* Helper to get the endpoint for direct access to HTTP functions.
|
|
41
11
|
*
|
|
42
12
|
* ```typescript
|
|
43
13
|
* import {Transport} from '@verdocs/js-sdk/HTTP';
|
|
44
14
|
*
|
|
45
|
-
* Transport.
|
|
15
|
+
* console.log('Current timeout', Transport.getEndpoint().defaults.timeout);
|
|
46
16
|
* ```
|
|
47
17
|
*/
|
|
48
|
-
export declare const
|
|
49
|
-
export declare const logRequests: (enable: boolean) => void;
|
|
18
|
+
export declare const getEndpoint: () => VerdocsEndpoint;
|
|
50
19
|
/**
|
|
51
|
-
*
|
|
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.
|
|
52
24
|
*
|
|
53
25
|
* ```typescript
|
|
54
26
|
* import {Transport} from '@verdocs/js-sdk/HTTP';
|
|
55
27
|
*
|
|
56
|
-
*
|
|
28
|
+
* const mySigningEndpoint = new VerdocsEndpoint();
|
|
29
|
+
* setActiveEndpoint(mySigningEndpoint);
|
|
30
|
+
* ... [Perform signing operations]
|
|
31
|
+
* setActiveEndpoint(null);
|
|
57
32
|
* ```
|
|
58
33
|
*/
|
|
59
|
-
export declare const
|
|
34
|
+
export declare const setActiveEndpoint: (e: VerdocsEndpoint | null) => void;
|
package/HTTP/Transport.js
CHANGED
|
@@ -1,109 +1,47 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The Transport
|
|
3
|
-
* its configuration settings are shared for all callers.
|
|
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.
|
|
4
5
|
*
|
|
5
6
|
* @module
|
|
6
7
|
*/
|
|
7
|
-
import axios from 'axios';
|
|
8
8
|
import globalThis from './globalThis';
|
|
9
|
-
|
|
10
|
-
baseURL: 'https://api.verdocs.com/',
|
|
11
|
-
timeout: 6000,
|
|
12
|
-
headers: { 'X-Client-ID': 'NONE' },
|
|
13
|
-
};
|
|
9
|
+
import { VerdocsEndpoint } from './VerdocsEndpoint';
|
|
14
10
|
// @credit https://derickbailey.com/2016/03/09/creating-a-true-singleton-in-node-js-with-es6-symbols/
|
|
15
11
|
// Also see globalThis for comments about why we're doing this in the first place.
|
|
16
12
|
var ENDPOINT_KEY = Symbol.for('verdocs-api-endpoint');
|
|
17
13
|
if (!globalThis[ENDPOINT_KEY]) {
|
|
18
|
-
globalThis[ENDPOINT_KEY] =
|
|
14
|
+
globalThis[ENDPOINT_KEY] = new VerdocsEndpoint({ baseURL: 'https://api.verdocs.com/' });
|
|
19
15
|
}
|
|
20
|
-
var
|
|
21
|
-
var
|
|
22
|
-
// tslint:disable-next-line
|
|
23
|
-
console.log("[JS-SDK] ".concat(r.method.toUpperCase(), " ").concat(r.baseURL).concat(r.url), r.data ? JSON.stringify(r.data) : '');
|
|
24
|
-
return r;
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* Set the auth token that will be used for Verdocs API calls.
|
|
28
|
-
*
|
|
29
|
-
* ```typescript
|
|
30
|
-
* import {Transport} from '@verdocs/js-sdk/HTTP';
|
|
31
|
-
*
|
|
32
|
-
* Transport.setAuthorization(accessToken);
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
export var setAuthorization = function (accessToken) {
|
|
36
|
-
if (accessToken) {
|
|
37
|
-
endpoint.defaults.headers.Authorization = "Bearer ".concat(accessToken);
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
delete endpoint.defaults.headers.Authorization;
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* Set the Client ID for Verdocs API calls.
|
|
45
|
-
*
|
|
46
|
-
* ```typescript
|
|
47
|
-
* import {Transport} from '@verdocs/js-sdk/HTTP';
|
|
48
|
-
*
|
|
49
|
-
* Transport.setClientID('1234);
|
|
50
|
-
* ```
|
|
51
|
-
*/
|
|
52
|
-
export var setClientID = function (clientID) {
|
|
53
|
-
endpoint.defaults.headers['X-Client-ID'] = clientID;
|
|
54
|
-
};
|
|
55
|
-
/**
|
|
56
|
-
* Set the base URL for API calls. This defaults to https://api.verdocs.com/ and should only be changed after consultation with
|
|
57
|
-
* Verdocs Developer Support (e.g. to access a private API endpoint).
|
|
58
|
-
*
|
|
59
|
-
* ```typescript
|
|
60
|
-
* import {Transport} from '@verdocs/js-sdk/HTTP';
|
|
61
|
-
*
|
|
62
|
-
* Transport.setBaseUrl('https://my-private-api.verdocs.com');
|
|
63
|
-
* ```
|
|
64
|
-
*/
|
|
65
|
-
export var setBaseUrl = function (baseUrl) {
|
|
66
|
-
endpoint.defaults.baseURL = baseUrl;
|
|
67
|
-
};
|
|
68
|
-
/**
|
|
69
|
-
* Set the timeout for API calls in milliseconds. 2000-4000ms is recommended for most purposes. 3000ms is the default.
|
|
70
|
-
*
|
|
71
|
-
* ```typescript
|
|
72
|
-
* import {Transport} from '@verdocs/js-sdk/HTTP';
|
|
73
|
-
*
|
|
74
|
-
* Transport.setTimeout(3000);
|
|
75
|
-
* ```
|
|
76
|
-
*/
|
|
77
|
-
export var setTimeout = function (timeout) {
|
|
78
|
-
endpoint.defaults.timeout = timeout;
|
|
79
|
-
};
|
|
16
|
+
var globalEndpoint = globalThis[ENDPOINT_KEY];
|
|
17
|
+
var activeEndpoint = globalEndpoint;
|
|
80
18
|
/**
|
|
81
|
-
*
|
|
19
|
+
* Helper to get the endpoint for direct access to HTTP functions.
|
|
82
20
|
*
|
|
83
21
|
* ```typescript
|
|
84
22
|
* import {Transport} from '@verdocs/js-sdk/HTTP';
|
|
85
23
|
*
|
|
86
|
-
* Transport.
|
|
24
|
+
* console.log('Current timeout', Transport.getEndpoint().defaults.timeout);
|
|
87
25
|
* ```
|
|
88
26
|
*/
|
|
89
|
-
var
|
|
90
|
-
|
|
91
|
-
if (enable && requestLoggerId === null) {
|
|
92
|
-
requestLoggerId = endpoint.interceptors.request.use(requestLogger);
|
|
93
|
-
}
|
|
94
|
-
else if (!enable && requestLoggerId !== null) {
|
|
95
|
-
endpoint.interceptors.request.eject(requestLoggerId);
|
|
96
|
-
}
|
|
27
|
+
export var getEndpoint = function () {
|
|
28
|
+
return activeEndpoint;
|
|
97
29
|
};
|
|
98
30
|
/**
|
|
99
|
-
*
|
|
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.
|
|
100
35
|
*
|
|
101
36
|
* ```typescript
|
|
102
37
|
* import {Transport} from '@verdocs/js-sdk/HTTP';
|
|
103
38
|
*
|
|
104
|
-
*
|
|
39
|
+
* const mySigningEndpoint = new VerdocsEndpoint();
|
|
40
|
+
* setActiveEndpoint(mySigningEndpoint);
|
|
41
|
+
* ... [Perform signing operations]
|
|
42
|
+
* setActiveEndpoint(null);
|
|
105
43
|
* ```
|
|
106
44
|
*/
|
|
107
|
-
export var
|
|
108
|
-
|
|
45
|
+
export var setActiveEndpoint = function (e) {
|
|
46
|
+
activeEndpoint = e || globalEndpoint;
|
|
109
47
|
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A VerdocsEndpoint is a specific connection and authorization session for calling the Verdocs APIs. Where the global
|
|
3
|
+
* Transport is generally used to simpliy standard-user operations, Endpoints can be used for isolated session tasks.
|
|
4
|
+
* For instance, ephemeral signing sessions may be created independently of a caller's status as an authenticated user.
|
|
5
|
+
* In that case, an Endpoint can be created and authenticated, used for calls related to signing operations, then
|
|
6
|
+
* discarded once signing is complete.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import { AxiosInstance } from 'axios';
|
|
11
|
+
export declare class VerdocsEndpoint {
|
|
12
|
+
baseURL: string;
|
|
13
|
+
api: AxiosInstance;
|
|
14
|
+
requestLoggerId: number | null;
|
|
15
|
+
/**
|
|
16
|
+
* Create a new Endpoint to call Verdocs services.
|
|
17
|
+
*
|
|
18
|
+
* ```typescript
|
|
19
|
+
* import {Endpoint} from '@verdocs/js-sdk/HTTP';
|
|
20
|
+
*
|
|
21
|
+
* console.log('Current timeout', Transport.getEndpoint().defaults.timeout);
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
constructor({ baseURL }?: {
|
|
25
|
+
baseURL?: string;
|
|
26
|
+
});
|
|
27
|
+
/**
|
|
28
|
+
* Set the timeout for API calls in milliseconds. 2000-4000ms is recommended for most purposes. 3000ms is the default.
|
|
29
|
+
*
|
|
30
|
+
* ```typescript
|
|
31
|
+
* import {Endpoint} from '@verdocs/js-sdk/HTTP';
|
|
32
|
+
*
|
|
33
|
+
* const endpoint = new Endpoint();
|
|
34
|
+
* endpoint.setTimeout(3000);
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
setTimeout(timeout: number): void;
|
|
38
|
+
/**
|
|
39
|
+
* Set the Client ID for Verdocs API calls.
|
|
40
|
+
*
|
|
41
|
+
* ```typescript
|
|
42
|
+
* import {Endpoint} from '@verdocs/js-sdk/HTTP';
|
|
43
|
+
*
|
|
44
|
+
* const endpoint = new Endpoint();
|
|
45
|
+
* endpoint.setClientID('1234);
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
setClientID(clientID: string): void;
|
|
49
|
+
/**
|
|
50
|
+
* Set the auth token that will be used for Verdocs API calls.
|
|
51
|
+
*
|
|
52
|
+
* ```typescript
|
|
53
|
+
* import {Endpoint} from '@verdocs/js-sdk/HTTP';
|
|
54
|
+
*
|
|
55
|
+
* const endpoint = new Endpoint();
|
|
56
|
+
* endpoint.setAuthorization(accessToken);
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
setAuthorization(accessToken: string | null): void;
|
|
60
|
+
/**
|
|
61
|
+
* Enable or disable request logging. This may expose sensitive data in the console log, so it should only be used for debugging.
|
|
62
|
+
*
|
|
63
|
+
* ```typescript
|
|
64
|
+
* import {Endpoint} from '@verdocs/js-sdk/HTTP';
|
|
65
|
+
*
|
|
66
|
+
* const endpoint = new Endpoint();
|
|
67
|
+
* endpoint.logRequests(true);
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
logRequests(enable: boolean): void;
|
|
71
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A VerdocsEndpoint is a specific connection and authorization session for calling the Verdocs APIs. Where the global
|
|
3
|
+
* Transport is generally used to simpliy standard-user operations, Endpoints can be used for isolated session tasks.
|
|
4
|
+
* For instance, ephemeral signing sessions may be created independently of a caller's status as an authenticated user.
|
|
5
|
+
* In that case, an Endpoint can be created and authenticated, used for calls related to signing operations, then
|
|
6
|
+
* discarded once signing is complete.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import axios from 'axios';
|
|
11
|
+
var requestLogger = function (r) {
|
|
12
|
+
// tslint:disable-next-line
|
|
13
|
+
console.log("[JS-SDK] ".concat(r.method.toUpperCase(), " ").concat(r.baseURL).concat(r.url), r.data ? JSON.stringify(r.data) : '');
|
|
14
|
+
return r;
|
|
15
|
+
};
|
|
16
|
+
var VerdocsEndpoint = /** @class */ (function () {
|
|
17
|
+
/**
|
|
18
|
+
* Create a new Endpoint to call Verdocs services.
|
|
19
|
+
*
|
|
20
|
+
* ```typescript
|
|
21
|
+
* import {Endpoint} from '@verdocs/js-sdk/HTTP';
|
|
22
|
+
*
|
|
23
|
+
* console.log('Current timeout', Transport.getEndpoint().defaults.timeout);
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
function VerdocsEndpoint(_a) {
|
|
27
|
+
var _b = _a === void 0 ? {} : _a, baseURL = _b.baseURL;
|
|
28
|
+
this.requestLoggerId = null;
|
|
29
|
+
this.baseURL = baseURL || 'https://api.verdocs.com/';
|
|
30
|
+
this.api = axios.create({
|
|
31
|
+
baseURL: this.baseURL,
|
|
32
|
+
timeout: 6000,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Set the timeout for API calls in milliseconds. 2000-4000ms is recommended for most purposes. 3000ms is the default.
|
|
37
|
+
*
|
|
38
|
+
* ```typescript
|
|
39
|
+
* import {Endpoint} from '@verdocs/js-sdk/HTTP';
|
|
40
|
+
*
|
|
41
|
+
* const endpoint = new Endpoint();
|
|
42
|
+
* endpoint.setTimeout(3000);
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
VerdocsEndpoint.prototype.setTimeout = function (timeout) {
|
|
46
|
+
this.api.defaults.timeout = timeout;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Set the Client ID for Verdocs API calls.
|
|
50
|
+
*
|
|
51
|
+
* ```typescript
|
|
52
|
+
* import {Endpoint} from '@verdocs/js-sdk/HTTP';
|
|
53
|
+
*
|
|
54
|
+
* const endpoint = new Endpoint();
|
|
55
|
+
* endpoint.setClientID('1234);
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
VerdocsEndpoint.prototype.setClientID = function (clientID) {
|
|
59
|
+
this.api.defaults.headers['X-Client-ID'] = clientID;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Set the auth token that will be used for Verdocs API calls.
|
|
63
|
+
*
|
|
64
|
+
* ```typescript
|
|
65
|
+
* import {Endpoint} from '@verdocs/js-sdk/HTTP';
|
|
66
|
+
*
|
|
67
|
+
* const endpoint = new Endpoint();
|
|
68
|
+
* endpoint.setAuthorization(accessToken);
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
VerdocsEndpoint.prototype.setAuthorization = function (accessToken) {
|
|
72
|
+
if (accessToken) {
|
|
73
|
+
this.api.defaults.headers.Authorization = "Bearer ".concat(accessToken);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
delete this.api.defaults.headers.Authorization;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Enable or disable request logging. This may expose sensitive data in the console log, so it should only be used for debugging.
|
|
81
|
+
*
|
|
82
|
+
* ```typescript
|
|
83
|
+
* import {Endpoint} from '@verdocs/js-sdk/HTTP';
|
|
84
|
+
*
|
|
85
|
+
* const endpoint = new Endpoint();
|
|
86
|
+
* endpoint.logRequests(true);
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
VerdocsEndpoint.prototype.logRequests = function (enable) {
|
|
90
|
+
if (enable && this.requestLoggerId === null) {
|
|
91
|
+
this.requestLoggerId = this.api.interceptors.request.use(requestLogger);
|
|
92
|
+
}
|
|
93
|
+
else if (!enable && this.requestLoggerId !== null) {
|
|
94
|
+
this.api.interceptors.request.eject(this.requestLoggerId);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
return VerdocsEndpoint;
|
|
98
|
+
}());
|
|
99
|
+
export { VerdocsEndpoint };
|
package/HTTP/index.d.ts
CHANGED
package/HTTP/index.js
CHANGED
package/Organizations/ApiKeys.js
CHANGED
|
@@ -22,7 +22,7 @@ import { getEndpoint } from '../HTTP/Transport';
|
|
|
22
22
|
*/
|
|
23
23
|
export var getKeys = function (organizationId) {
|
|
24
24
|
return getEndpoint()
|
|
25
|
-
.get("/organizations/".concat(organizationId, "/api_key"))
|
|
25
|
+
.api.get("/organizations/".concat(organizationId, "/api_key"))
|
|
26
26
|
.then(function (r) { return r.data; });
|
|
27
27
|
};
|
|
28
28
|
/**
|
|
@@ -36,7 +36,7 @@ export var getKeys = function (organizationId) {
|
|
|
36
36
|
*/
|
|
37
37
|
export var createKey = function (organizationId, params) {
|
|
38
38
|
return getEndpoint()
|
|
39
|
-
.post("/organizations/".concat(organizationId, "/api_key"), params)
|
|
39
|
+
.api.post("/organizations/".concat(organizationId, "/api_key"), params)
|
|
40
40
|
.then(function (r) { return r.data; });
|
|
41
41
|
};
|
|
42
42
|
/**
|
|
@@ -50,7 +50,7 @@ export var createKey = function (organizationId, params) {
|
|
|
50
50
|
*/
|
|
51
51
|
export var rotateKey = function (organizationId, clientId) {
|
|
52
52
|
return getEndpoint()
|
|
53
|
-
.put("/organizations/".concat(organizationId, "/api_key/").concat(clientId, "/rotate"))
|
|
53
|
+
.api.put("/organizations/".concat(organizationId, "/api_key/").concat(clientId, "/rotate"))
|
|
54
54
|
.then(function (r) { return r.data; });
|
|
55
55
|
};
|
|
56
56
|
/**
|
|
@@ -64,7 +64,7 @@ export var rotateKey = function (organizationId, clientId) {
|
|
|
64
64
|
*/
|
|
65
65
|
export var updateKey = function (organizationId, clientId, params) {
|
|
66
66
|
return getEndpoint()
|
|
67
|
-
.patch("/organizations/".concat(organizationId, "/api_key/").concat(clientId), params)
|
|
67
|
+
.api.patch("/organizations/".concat(organizationId, "/api_key/").concat(clientId), params)
|
|
68
68
|
.then(function (r) { return r.data; });
|
|
69
69
|
};
|
|
70
70
|
/**
|
|
@@ -78,6 +78,6 @@ export var updateKey = function (organizationId, clientId, params) {
|
|
|
78
78
|
*/
|
|
79
79
|
export var deleteKey = function (organizationId, clientId) {
|
|
80
80
|
return getEndpoint()
|
|
81
|
-
.delete("/organizations/".concat(organizationId, "/api_key/").concat(clientId))
|
|
81
|
+
.api.delete("/organizations/".concat(organizationId, "/api_key/").concat(clientId))
|
|
82
82
|
.then(function (r) { return r.data; });
|
|
83
83
|
};
|
package/Organizations/Groups.js
CHANGED
|
@@ -19,7 +19,7 @@ import { getEndpoint } from '../HTTP/Transport';
|
|
|
19
19
|
*/
|
|
20
20
|
export var getGroups = function (organizationId) {
|
|
21
21
|
return getEndpoint()
|
|
22
|
-
.get("/organizations/".concat(organizationId, "/groups"))
|
|
22
|
+
.api.get("/organizations/".concat(organizationId, "/groups"))
|
|
23
23
|
.then(function (r) { return r.data; });
|
|
24
24
|
};
|
|
25
25
|
/**
|
|
@@ -33,31 +33,31 @@ export var getGroups = function (organizationId) {
|
|
|
33
33
|
*/
|
|
34
34
|
export var getGroup = function (organizationId, groupId) {
|
|
35
35
|
return getEndpoint()
|
|
36
|
-
.get("/organizations/".concat(organizationId, "/groups/").concat(groupId))
|
|
36
|
+
.api.get("/organizations/".concat(organizationId, "/groups/").concat(groupId))
|
|
37
37
|
.then(function (r) { return r.data; });
|
|
38
38
|
};
|
|
39
39
|
export var getMembers = function (organizationId, groupId) {
|
|
40
40
|
return getEndpoint()
|
|
41
|
-
.get("/organizations/".concat(organizationId, "/groups/").concat(groupId, "/members"))
|
|
41
|
+
.api.get("/organizations/".concat(organizationId, "/groups/").concat(groupId, "/members"))
|
|
42
42
|
.then(function (r) { return r.data; });
|
|
43
43
|
};
|
|
44
44
|
export var addMembers = function (organizationId, groupId, params) {
|
|
45
45
|
return getEndpoint()
|
|
46
|
-
.post("/organizations/".concat(organizationId, "/groups/").concat(groupId, "/members"), params)
|
|
46
|
+
.api.post("/organizations/".concat(organizationId, "/groups/").concat(groupId, "/members"), params)
|
|
47
47
|
.then(function (r) { return r.data; });
|
|
48
48
|
};
|
|
49
49
|
export var deleteMembers = function (organizationId, groupId, params) {
|
|
50
50
|
return getEndpoint()
|
|
51
|
-
.put("/organizations/".concat(organizationId, "/groups/").concat(groupId, "/delete_members"), params)
|
|
51
|
+
.api.put("/organizations/".concat(organizationId, "/groups/").concat(groupId, "/delete_members"), params)
|
|
52
52
|
.then(function (r) { return r.data; });
|
|
53
53
|
};
|
|
54
54
|
export var addPermission = function (organizationId, groupId, permissionId, params) {
|
|
55
55
|
return getEndpoint()
|
|
56
|
-
.post("/organizations/".concat(organizationId, "/groups/").concat(groupId, "/permissions/").concat(permissionId), params)
|
|
56
|
+
.api.post("/organizations/".concat(organizationId, "/groups/").concat(groupId, "/permissions/").concat(permissionId), params)
|
|
57
57
|
.then(function (r) { return r.data; });
|
|
58
58
|
};
|
|
59
59
|
export var deletePermission = function (organizationId, groupId, permissionId) {
|
|
60
60
|
return getEndpoint()
|
|
61
|
-
.delete("/organizations/".concat(organizationId, "/groups/").concat(groupId, "/permissions/").concat(permissionId))
|
|
61
|
+
.api.delete("/organizations/".concat(organizationId, "/groups/").concat(groupId, "/permissions/").concat(permissionId))
|
|
62
62
|
.then(function (r) { return r.data; });
|
|
63
63
|
};
|
|
@@ -6,36 +6,36 @@
|
|
|
6
6
|
import { getEndpoint } from '../HTTP/Transport';
|
|
7
7
|
export var getInvitations = function (organizationId) {
|
|
8
8
|
return getEndpoint()
|
|
9
|
-
.get("/organizations/".concat(organizationId, "/invitation"))
|
|
9
|
+
.api.get("/organizations/".concat(organizationId, "/invitation"))
|
|
10
10
|
.then(function (r) { return r.data; });
|
|
11
11
|
};
|
|
12
12
|
export var createInvitation = function (organizationId, params) {
|
|
13
13
|
return getEndpoint()
|
|
14
|
-
.post("/organizations/".concat(organizationId, "/invitation"), params)
|
|
14
|
+
.api.post("/organizations/".concat(organizationId, "/invitation"), params)
|
|
15
15
|
.then(function (r) { return r.data; });
|
|
16
16
|
};
|
|
17
17
|
export var deleteInvitation = function (organizationId, email) {
|
|
18
18
|
return getEndpoint()
|
|
19
|
-
.delete("/organizations/".concat(organizationId, "/invitation/").concat(email))
|
|
19
|
+
.api.delete("/organizations/".concat(organizationId, "/invitation/").concat(email))
|
|
20
20
|
.then(function (r) { return r.data; });
|
|
21
21
|
};
|
|
22
22
|
export var updateInvitation = function (organizationId, email, params) {
|
|
23
23
|
return getEndpoint()
|
|
24
|
-
.patch("/organizations/".concat(organizationId, "/invitation/").concat(email), params)
|
|
24
|
+
.api.patch("/organizations/".concat(organizationId, "/invitation/").concat(email), params)
|
|
25
25
|
.then(function (r) { return r.data; });
|
|
26
26
|
};
|
|
27
27
|
export var resendInvitation = function (organizationId, email) {
|
|
28
28
|
return getEndpoint()
|
|
29
|
-
.post("/organizations/".concat(organizationId, "/invitation/").concat(email, "/resend"))
|
|
29
|
+
.api.post("/organizations/".concat(organizationId, "/invitation/").concat(email, "/resend"))
|
|
30
30
|
.then(function (r) { return r.data; });
|
|
31
31
|
};
|
|
32
32
|
export var claimInvitation = function (organizationId, email, params) {
|
|
33
33
|
return getEndpoint()
|
|
34
|
-
.put("/organizations/".concat(organizationId, "/invitation/").concat(email), params)
|
|
34
|
+
.api.put("/organizations/".concat(organizationId, "/invitation/").concat(email), params)
|
|
35
35
|
.then(function (r) { return r.data; });
|
|
36
36
|
};
|
|
37
37
|
export var claimNewUser = function (organizationId, email, token) {
|
|
38
38
|
return getEndpoint()
|
|
39
|
-
.put("/organizations/".concat(organizationId, "/invitation/").concat(email, "/token/").concat(token, "/new_user"))
|
|
39
|
+
.api.put("/organizations/".concat(organizationId, "/invitation/").concat(email, "/token/").concat(token, "/new_user"))
|
|
40
40
|
.then(function (r) { return r.data; });
|
|
41
41
|
};
|