@verdocs/js-sdk 1.1.17 → 1.2.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/HTTP/VerdocsEndpoint.d.ts +31 -19
- package/HTTP/VerdocsEndpoint.js +37 -19
- package/Templates/Fields.d.ts +9 -0
- package/Templates/Fields.js +9 -0
- package/Templates/Pages.d.ts +12 -0
- package/Templates/Pages.js +12 -0
- package/Templates/Roles.d.ts +7 -0
- package/Templates/Roles.js +7 -0
- package/package.json +2 -2
|
@@ -5,6 +5,18 @@
|
|
|
5
5
|
* In that case, an Endpoint can be created and authenticated, used for calls related to signing operations, then
|
|
6
6
|
* discarded once signing is complete.
|
|
7
7
|
*
|
|
8
|
+
* Note that endpoint configuration functions return the instance, so they can be chained, e.g.
|
|
9
|
+
*
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
|
|
12
|
+
*
|
|
13
|
+
* const endpoint = new VerdocsEndpoint();
|
|
14
|
+
* endpoint
|
|
15
|
+
* .logRequests(true)
|
|
16
|
+
* .setClientID('1234)
|
|
17
|
+
* .setTimeout(5000);
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
8
20
|
* @module
|
|
9
21
|
*/
|
|
10
22
|
import { AxiosInstance } from 'axios';
|
|
@@ -15,7 +27,7 @@ export declare class VerdocsEndpoint {
|
|
|
15
27
|
* Create a new Endpoint to call Verdocs services.
|
|
16
28
|
*
|
|
17
29
|
* ```typescript
|
|
18
|
-
* import {
|
|
30
|
+
* import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
|
|
19
31
|
*
|
|
20
32
|
* console.log('Current timeout', Transport.getEndpoint().defaults.timeout);
|
|
21
33
|
* ```
|
|
@@ -28,67 +40,67 @@ export declare class VerdocsEndpoint {
|
|
|
28
40
|
* Set the timeout for API calls in milliseconds. 2000-4000ms is recommended for most purposes. 3000ms is the default.
|
|
29
41
|
*
|
|
30
42
|
* ```typescript
|
|
31
|
-
* import {
|
|
43
|
+
* import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
|
|
32
44
|
*
|
|
33
|
-
* const endpoint = new
|
|
45
|
+
* const endpoint = new VerdocsEndpoint();
|
|
34
46
|
* endpoint.setTimeout(3000);
|
|
35
47
|
* ```
|
|
36
48
|
*/
|
|
37
|
-
setTimeout(timeout: number):
|
|
49
|
+
setTimeout(timeout: number): VerdocsEndpoint;
|
|
38
50
|
/**
|
|
39
51
|
* Set the Client ID for Verdocs API calls.
|
|
40
52
|
*
|
|
41
53
|
* ```typescript
|
|
42
|
-
* import {
|
|
54
|
+
* import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
|
|
43
55
|
*
|
|
44
|
-
* const endpoint = new
|
|
56
|
+
* const endpoint = new VerdocsEndpoint();
|
|
45
57
|
* endpoint.setClientID('1234);
|
|
46
58
|
* ```
|
|
47
59
|
*/
|
|
48
|
-
setClientID(clientID: string):
|
|
60
|
+
setClientID(clientID: string): VerdocsEndpoint;
|
|
49
61
|
/**
|
|
50
62
|
* Set the auth token that will be used for Verdocs API calls.
|
|
51
63
|
*
|
|
52
64
|
* ```typescript
|
|
53
|
-
* import {
|
|
65
|
+
* import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
|
|
54
66
|
*
|
|
55
|
-
* const endpoint = new
|
|
67
|
+
* const endpoint = new VerdocsEndpoint();
|
|
56
68
|
* endpoint.setAuthorization(accessToken);
|
|
57
69
|
* ```
|
|
58
70
|
*/
|
|
59
|
-
setAuthorization(accessToken: string | null):
|
|
71
|
+
setAuthorization(accessToken: string | null): VerdocsEndpoint;
|
|
60
72
|
/**
|
|
61
73
|
* Set the auth token used for signing sessions. Separating user from signing auth allows the same endpoint to be
|
|
62
74
|
* used for multiple operations, although it is recommended that a separate endpoint be created for each operation.
|
|
63
75
|
*
|
|
64
76
|
* ```typescript
|
|
65
|
-
* import {
|
|
77
|
+
* import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
|
|
66
78
|
*
|
|
67
|
-
* const endpoint = new
|
|
79
|
+
* const endpoint = new VerdocsEndpoint();
|
|
68
80
|
* endpoint.setSigningAuthorization(accessToken);
|
|
69
81
|
* ```
|
|
70
82
|
*/
|
|
71
|
-
setSigningAuthorization(accessToken: string | null):
|
|
83
|
+
setSigningAuthorization(accessToken: string | null): VerdocsEndpoint;
|
|
72
84
|
/**
|
|
73
85
|
* Set the base URL for API calls. May also be set via the constructor.
|
|
74
86
|
*
|
|
75
87
|
* ```typescript
|
|
76
|
-
* import {
|
|
88
|
+
* import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
|
|
77
89
|
*
|
|
78
|
-
* const endpoint = new
|
|
90
|
+
* const endpoint = new VerdocsEndpoint();
|
|
79
91
|
* endpoint.setBaseURL('https://api.verdocs.com');
|
|
80
92
|
* ```
|
|
81
93
|
*/
|
|
82
|
-
setBaseURL(url: string):
|
|
94
|
+
setBaseURL(url: string): VerdocsEndpoint;
|
|
83
95
|
/**
|
|
84
96
|
* Enable or disable request logging. This may expose sensitive data in the console log, so it should only be used for debugging.
|
|
85
97
|
*
|
|
86
98
|
* ```typescript
|
|
87
|
-
* import {
|
|
99
|
+
* import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
|
|
88
100
|
*
|
|
89
|
-
* const endpoint = new
|
|
101
|
+
* const endpoint = new VerdocsEndpoint();
|
|
90
102
|
* endpoint.logRequests(true);
|
|
91
103
|
* ```
|
|
92
104
|
*/
|
|
93
|
-
logRequests(enable: boolean):
|
|
105
|
+
logRequests(enable: boolean): VerdocsEndpoint;
|
|
94
106
|
}
|
package/HTTP/VerdocsEndpoint.js
CHANGED
|
@@ -5,12 +5,24 @@
|
|
|
5
5
|
* In that case, an Endpoint can be created and authenticated, used for calls related to signing operations, then
|
|
6
6
|
* discarded once signing is complete.
|
|
7
7
|
*
|
|
8
|
+
* Note that endpoint configuration functions return the instance, so they can be chained, e.g.
|
|
9
|
+
*
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
|
|
12
|
+
*
|
|
13
|
+
* const endpoint = new VerdocsEndpoint();
|
|
14
|
+
* endpoint
|
|
15
|
+
* .logRequests(true)
|
|
16
|
+
* .setClientID('1234)
|
|
17
|
+
* .setTimeout(5000);
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
8
20
|
* @module
|
|
9
21
|
*/
|
|
10
22
|
import axios from 'axios';
|
|
11
23
|
var requestLogger = function (r) {
|
|
12
24
|
// tslint:disable-next-line
|
|
13
|
-
console.
|
|
25
|
+
console.debug("[JS-SDK] ".concat(r.method.toUpperCase(), " ").concat(r.baseURL).concat(r.url), r.data ? JSON.stringify(r.data) : '');
|
|
14
26
|
return r;
|
|
15
27
|
};
|
|
16
28
|
var VerdocsEndpoint = /** @class */ (function () {
|
|
@@ -18,7 +30,7 @@ var VerdocsEndpoint = /** @class */ (function () {
|
|
|
18
30
|
* Create a new Endpoint to call Verdocs services.
|
|
19
31
|
*
|
|
20
32
|
* ```typescript
|
|
21
|
-
* import {
|
|
33
|
+
* import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
|
|
22
34
|
*
|
|
23
35
|
* console.log('Current timeout', Transport.getEndpoint().defaults.timeout);
|
|
24
36
|
* ```
|
|
@@ -35,85 +47,90 @@ var VerdocsEndpoint = /** @class */ (function () {
|
|
|
35
47
|
* Set the timeout for API calls in milliseconds. 2000-4000ms is recommended for most purposes. 3000ms is the default.
|
|
36
48
|
*
|
|
37
49
|
* ```typescript
|
|
38
|
-
* import {
|
|
50
|
+
* import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
|
|
39
51
|
*
|
|
40
|
-
* const endpoint = new
|
|
52
|
+
* const endpoint = new VerdocsEndpoint();
|
|
41
53
|
* endpoint.setTimeout(3000);
|
|
42
54
|
* ```
|
|
43
55
|
*/
|
|
44
56
|
VerdocsEndpoint.prototype.setTimeout = function (timeout) {
|
|
45
57
|
this.api.defaults.timeout = timeout;
|
|
58
|
+
return this;
|
|
46
59
|
};
|
|
47
60
|
/**
|
|
48
61
|
* Set the Client ID for Verdocs API calls.
|
|
49
62
|
*
|
|
50
63
|
* ```typescript
|
|
51
|
-
* import {
|
|
64
|
+
* import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
|
|
52
65
|
*
|
|
53
|
-
* const endpoint = new
|
|
66
|
+
* const endpoint = new VerdocsEndpoint();
|
|
54
67
|
* endpoint.setClientID('1234);
|
|
55
68
|
* ```
|
|
56
69
|
*/
|
|
57
70
|
VerdocsEndpoint.prototype.setClientID = function (clientID) {
|
|
58
|
-
this.api.defaults.headers['X-Client-ID'] = clientID;
|
|
71
|
+
this.api.defaults.headers.common['X-Client-ID'] = clientID;
|
|
72
|
+
return this;
|
|
59
73
|
};
|
|
60
74
|
/**
|
|
61
75
|
* Set the auth token that will be used for Verdocs API calls.
|
|
62
76
|
*
|
|
63
77
|
* ```typescript
|
|
64
|
-
* import {
|
|
78
|
+
* import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
|
|
65
79
|
*
|
|
66
|
-
* const endpoint = new
|
|
80
|
+
* const endpoint = new VerdocsEndpoint();
|
|
67
81
|
* endpoint.setAuthorization(accessToken);
|
|
68
82
|
* ```
|
|
69
83
|
*/
|
|
70
84
|
VerdocsEndpoint.prototype.setAuthorization = function (accessToken) {
|
|
71
85
|
if (accessToken) {
|
|
72
|
-
this.api.defaults.headers.Authorization = "Bearer ".concat(accessToken);
|
|
86
|
+
this.api.defaults.headers.common.Authorization = "Bearer ".concat(accessToken);
|
|
73
87
|
}
|
|
74
88
|
else {
|
|
75
|
-
delete this.api.defaults.headers.Authorization;
|
|
89
|
+
delete this.api.defaults.headers.common.Authorization;
|
|
76
90
|
}
|
|
91
|
+
return this;
|
|
77
92
|
};
|
|
78
93
|
/**
|
|
79
94
|
* Set the auth token used for signing sessions. Separating user from signing auth allows the same endpoint to be
|
|
80
95
|
* used for multiple operations, although it is recommended that a separate endpoint be created for each operation.
|
|
81
96
|
*
|
|
82
97
|
* ```typescript
|
|
83
|
-
* import {
|
|
98
|
+
* import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
|
|
84
99
|
*
|
|
85
|
-
* const endpoint = new
|
|
100
|
+
* const endpoint = new VerdocsEndpoint();
|
|
86
101
|
* endpoint.setSigningAuthorization(accessToken);
|
|
87
102
|
* ```
|
|
88
103
|
*/
|
|
89
104
|
VerdocsEndpoint.prototype.setSigningAuthorization = function (accessToken) {
|
|
90
105
|
if (accessToken) {
|
|
91
|
-
this.api.defaults.headers.signer = "Bearer ".concat(accessToken);
|
|
106
|
+
this.api.defaults.headers.common.signer = "Bearer ".concat(accessToken);
|
|
92
107
|
}
|
|
93
108
|
else {
|
|
94
|
-
delete this.api.defaults.headers.signer;
|
|
109
|
+
delete this.api.defaults.headers.common.signer;
|
|
95
110
|
}
|
|
111
|
+
return this;
|
|
96
112
|
};
|
|
97
113
|
/**
|
|
98
114
|
* Set the base URL for API calls. May also be set via the constructor.
|
|
99
115
|
*
|
|
100
116
|
* ```typescript
|
|
101
|
-
* import {
|
|
117
|
+
* import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
|
|
102
118
|
*
|
|
103
|
-
* const endpoint = new
|
|
119
|
+
* const endpoint = new VerdocsEndpoint();
|
|
104
120
|
* endpoint.setBaseURL('https://api.verdocs.com');
|
|
105
121
|
* ```
|
|
106
122
|
*/
|
|
107
123
|
VerdocsEndpoint.prototype.setBaseURL = function (url) {
|
|
108
124
|
this.api.defaults.baseURL = url;
|
|
125
|
+
return this;
|
|
109
126
|
};
|
|
110
127
|
/**
|
|
111
128
|
* Enable or disable request logging. This may expose sensitive data in the console log, so it should only be used for debugging.
|
|
112
129
|
*
|
|
113
130
|
* ```typescript
|
|
114
|
-
* import {
|
|
131
|
+
* import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
|
|
115
132
|
*
|
|
116
|
-
* const endpoint = new
|
|
133
|
+
* const endpoint = new VerdocsEndpoint();
|
|
117
134
|
* endpoint.logRequests(true);
|
|
118
135
|
* ```
|
|
119
136
|
*/
|
|
@@ -124,6 +141,7 @@ var VerdocsEndpoint = /** @class */ (function () {
|
|
|
124
141
|
else if (!enable && this.requestLoggerId !== null) {
|
|
125
142
|
this.api.interceptors.request.eject(this.requestLoggerId);
|
|
126
143
|
}
|
|
144
|
+
return this;
|
|
127
145
|
};
|
|
128
146
|
return VerdocsEndpoint;
|
|
129
147
|
}());
|
package/Templates/Fields.d.ts
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import { ITemplateField } from './Types';
|
|
2
|
+
/**
|
|
3
|
+
* Add a field to a template.
|
|
4
|
+
*/
|
|
2
5
|
export declare const createField: (templateId: string, params: ITemplateField) => Promise<ITemplateField>;
|
|
6
|
+
/**
|
|
7
|
+
* Update a template field.
|
|
8
|
+
*/
|
|
3
9
|
export declare const editField: (templateId: string, fieldName: string, params: ITemplateField) => Promise<ITemplateField>;
|
|
10
|
+
/**
|
|
11
|
+
* REmove a field from a template.
|
|
12
|
+
*/
|
|
4
13
|
export declare const deleteField: (templateId: string, fieldName: string) => Promise<any>;
|
package/Templates/Fields.js
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
import { getEndpoint } from '../HTTP/Transport';
|
|
2
|
+
/**
|
|
3
|
+
* Add a field to a template.
|
|
4
|
+
*/
|
|
2
5
|
export var createField = function (templateId, params) {
|
|
3
6
|
return getEndpoint()
|
|
4
7
|
.api.post("/templates/".concat(templateId, "/pages/"), params)
|
|
5
8
|
.then(function (r) { return r.data; });
|
|
6
9
|
};
|
|
10
|
+
/**
|
|
11
|
+
* Update a template field.
|
|
12
|
+
*/
|
|
7
13
|
export var editField = function (templateId, fieldName, params) {
|
|
8
14
|
return getEndpoint()
|
|
9
15
|
.api.put("/templates/".concat(templateId, "/pages/").concat(fieldName), params)
|
|
10
16
|
.then(function (r) { return r.data; });
|
|
11
17
|
};
|
|
18
|
+
/**
|
|
19
|
+
* REmove a field from a template.
|
|
20
|
+
*/
|
|
12
21
|
export var deleteField = function (templateId, fieldName) {
|
|
13
22
|
return getEndpoint()
|
|
14
23
|
.api.delete("/templates/".concat(templateId, "/pages/").concat(fieldName))
|
package/Templates/Pages.d.ts
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import { IPage } from './Types';
|
|
2
|
+
/**
|
|
3
|
+
* Add a page to a template
|
|
4
|
+
*/
|
|
2
5
|
export declare const createPage: (templateId: string, params: IPage) => Promise<IPage>;
|
|
6
|
+
/**
|
|
7
|
+
* Update a template page.
|
|
8
|
+
*/
|
|
3
9
|
export declare const editPage: (templateId: string, sequence: string) => Promise<any>;
|
|
10
|
+
/**
|
|
11
|
+
* Get a page from a template.
|
|
12
|
+
*/
|
|
4
13
|
export declare const getPage: (templateId: string, sequence: string) => Promise<any>;
|
|
14
|
+
/**
|
|
15
|
+
* Delete a page from a template
|
|
16
|
+
*/
|
|
5
17
|
export declare const deletePage: (templateId: string, sequence: string) => Promise<any>;
|
package/Templates/Pages.js
CHANGED
|
@@ -1,19 +1,31 @@
|
|
|
1
1
|
import { getEndpoint } from '../HTTP/Transport';
|
|
2
|
+
/**
|
|
3
|
+
* Add a page to a template
|
|
4
|
+
*/
|
|
2
5
|
export var createPage = function (templateId, params) {
|
|
3
6
|
return getEndpoint()
|
|
4
7
|
.api.post("/templates/".concat(templateId, "/pages/"), params)
|
|
5
8
|
.then(function (r) { return r.data; });
|
|
6
9
|
};
|
|
10
|
+
/**
|
|
11
|
+
* Update a template page.
|
|
12
|
+
*/
|
|
7
13
|
export var editPage = function (templateId, sequence) {
|
|
8
14
|
return getEndpoint()
|
|
9
15
|
.api.put("/templates/".concat(templateId, "/pages/").concat(sequence))
|
|
10
16
|
.then(function (r) { return r.data; });
|
|
11
17
|
};
|
|
18
|
+
/**
|
|
19
|
+
* Get a page from a template.
|
|
20
|
+
*/
|
|
12
21
|
export var getPage = function (templateId, sequence) {
|
|
13
22
|
return getEndpoint()
|
|
14
23
|
.api.get("/templates/".concat(templateId, "/pages/").concat(sequence))
|
|
15
24
|
.then(function (r) { return r.data; });
|
|
16
25
|
};
|
|
26
|
+
/**
|
|
27
|
+
* Delete a page from a template
|
|
28
|
+
*/
|
|
17
29
|
export var deletePage = function (templateId, sequence) {
|
|
18
30
|
return getEndpoint()
|
|
19
31
|
.api.delete("/templates/".concat(templateId, "/pages/").concat(sequence))
|
package/Templates/Roles.d.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { ITemplateField, IRole } from './Types';
|
|
2
|
+
/**
|
|
3
|
+
* A "role" is an individual participant in a signing flow, such as a signer or CC contact. Roles are identified by
|
|
4
|
+
* their names, which must be unique (e.g. 'Recipient 1'). Template fields are assigned to roles for signing operations,
|
|
5
|
+
* so you may have 'Recipient 1 Signature 1' and so forth.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
2
9
|
export declare const createRole: (templateId: string, params: IRole) => Promise<IRole>;
|
|
3
10
|
export declare const getRoles: (templateId: string) => Promise<IRole[]>;
|
|
4
11
|
export declare const getRole: (templateId: string, roleName: string) => Promise<IRole>;
|
package/Templates/Roles.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { getEndpoint } from '../HTTP/Transport';
|
|
2
|
+
/**
|
|
3
|
+
* A "role" is an individual participant in a signing flow, such as a signer or CC contact. Roles are identified by
|
|
4
|
+
* their names, which must be unique (e.g. 'Recipient 1'). Template fields are assigned to roles for signing operations,
|
|
5
|
+
* so you may have 'Recipient 1 Signature 1' and so forth.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
2
9
|
export var createRole = function (templateId, params) {
|
|
3
10
|
return getEndpoint()
|
|
4
11
|
.api.post("/templates/".concat(templateId, "/roles/"), params)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verdocs/js-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"homepage": "https://github.com/Verdocs/js-sdk",
|
|
6
6
|
"description": "Verdocs JS SDK",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"access": "public"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"axios": "^0.
|
|
47
|
+
"axios": "^0.25.0"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"typescript": "4.2.x || 4.3.x || 4.4.x || 4.5.x"
|