@verdocs/js-sdk 1.1.10 → 1.1.14
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 +1 -0
- package/Documents/Documents.js +7 -3
- package/Documents/Initials.d.ts +14 -0
- package/Documents/Initials.js +14 -0
- package/Documents/Signatures.d.ts +11 -4
- package/Documents/Signatures.js +10 -2
- package/Documents/index.d.ts +1 -0
- package/Documents/index.js +1 -0
- package/HTTP/VerdocsEndpoint.d.ts +12 -0
- package/HTTP/VerdocsEndpoint.js +19 -0
- package/Organizations/Types.d.ts +3 -3
- package/Templates/Types.d.ts +12 -5
- package/Utils/Fields.d.ts +0 -6
- package/Utils/Fields.js +0 -113
- package/package.json +1 -1
package/Documents/Documents.d.ts
CHANGED
|
@@ -177,3 +177,4 @@ export declare const getDocumentRecipients: (documentId: string) => Promise<IRec
|
|
|
177
177
|
export declare const getDocument: (documentId: string) => Promise<IDocument>;
|
|
178
178
|
export declare const getDocumentFile: (documentId: string, envelopeDocumentId: string) => Promise<string>;
|
|
179
179
|
export declare const updateDocumentField: (documentId: string, fieldName: string, value: any) => Promise<IFieldSetting>;
|
|
180
|
+
export declare const updateDocumentFieldSignature: (documentId: string, fieldName: string, signatureId: string) => Promise<IFieldSetting>;
|
package/Documents/Documents.js
CHANGED
|
@@ -108,9 +108,6 @@ export var getDocumentFile = function (documentId, envelopeDocumentId) { return
|
|
|
108
108
|
.then(function (r) { return Buffer.from(r.data, 'binary').toString('base64'); })];
|
|
109
109
|
});
|
|
110
110
|
}); };
|
|
111
|
-
// {"name":"textboxP2-0","recipient_role":"Recipient 1","envelope_id":"29b99d0b-8079-4e98-827c-28c375e5ecb7","page":2,"type":"textbox",
|
|
112
|
-
// "required":true,"settings":{"x":0,"y":772.0000000000001,"width":150,"height":15,"result":"Text 1","leading":0,"alignment":0,"upperCase":false},
|
|
113
|
-
// "validator":null,"label":null,"prepared":false}
|
|
114
111
|
export var updateDocumentField = function (documentId, fieldName, value) { return __awaiter(void 0, void 0, void 0, function () {
|
|
115
112
|
return __generator(this, function (_a) {
|
|
116
113
|
return [2 /*return*/, getEndpoint()
|
|
@@ -118,3 +115,10 @@ export var updateDocumentField = function (documentId, fieldName, value) { retur
|
|
|
118
115
|
.then(function (r) { return r.data; })];
|
|
119
116
|
});
|
|
120
117
|
}); };
|
|
118
|
+
export var updateDocumentFieldSignature = function (documentId, fieldName, signatureId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
119
|
+
return __generator(this, function (_a) {
|
|
120
|
+
return [2 /*return*/, getEndpoint()
|
|
121
|
+
.api.put("/documents/".concat(documentId, "/fields/").concat(fieldName, "/signature/").concat(signatureId))
|
|
122
|
+
.then(function (r) { return r.data; })];
|
|
123
|
+
});
|
|
124
|
+
}); };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface IInitials {
|
|
2
|
+
id?: string;
|
|
3
|
+
profile_id: string;
|
|
4
|
+
url: string;
|
|
5
|
+
created_at?: Date;
|
|
6
|
+
updated_at?: Date;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Create an initials block. In a typical signing workflow, the user is asked at the beginning of the process to "adopt"
|
|
10
|
+
* an initials block to be used for all initials fields in the document. Thus, this is typically called one time to
|
|
11
|
+
* create and store an initials block. Thereafter, the ID of the initials block may be re-used for each initials field
|
|
12
|
+
* to be "stamped" by the user.
|
|
13
|
+
*/
|
|
14
|
+
export declare const createInitials: (name: string, initials: string | Blob) => Promise<IInitials>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { getEndpoint } from '../HTTP/Transport';
|
|
2
|
+
/**
|
|
3
|
+
* Create an initials block. In a typical signing workflow, the user is asked at the beginning of the process to "adopt"
|
|
4
|
+
* an initials block to be used for all initials fields in the document. Thus, this is typically called one time to
|
|
5
|
+
* create and store an initials block. Thereafter, the ID of the initials block may be re-used for each initials field
|
|
6
|
+
* to be "stamped" by the user.
|
|
7
|
+
*/
|
|
8
|
+
export var createInitials = function (name, initials) {
|
|
9
|
+
var data = new FormData();
|
|
10
|
+
data.append('initial', initials, name);
|
|
11
|
+
return getEndpoint()
|
|
12
|
+
.api.post("/initials", data)
|
|
13
|
+
.then(function (r) { return r.data; });
|
|
14
|
+
};
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
export interface ISignature {
|
|
2
|
-
id
|
|
2
|
+
id: string;
|
|
3
3
|
profile_id: string;
|
|
4
4
|
url: string;
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
deleted: boolean;
|
|
6
|
+
created_at: string;
|
|
7
|
+
updated_at: string;
|
|
7
8
|
}
|
|
8
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Create a signature block. In a typical signing workflow, the user is asked at the beginning of the process to "adopt"
|
|
11
|
+
* a signature block to be used for all signature fields in the document. Thus, this is typically called one time to
|
|
12
|
+
* create and store a signature block. Thereafter, the ID of the signature block may be re-used for each signature field
|
|
13
|
+
* to be "stamped" by the user.
|
|
14
|
+
*/
|
|
15
|
+
export declare const createSignature: (name: string, signature: string | Blob) => Promise<ISignature>;
|
|
9
16
|
export declare const getSignatures: () => Promise<ISignature[]>;
|
|
10
17
|
export declare const getSignature: (signatureId: string) => Promise<any>;
|
|
11
18
|
export declare const deleteSignature: (signatureId: string) => Promise<any>;
|
package/Documents/Signatures.js
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import { getEndpoint } from '../HTTP/Transport';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Create a signature block. In a typical signing workflow, the user is asked at the beginning of the process to "adopt"
|
|
4
|
+
* a signature block to be used for all signature fields in the document. Thus, this is typically called one time to
|
|
5
|
+
* create and store a signature block. Thereafter, the ID of the signature block may be re-used for each signature field
|
|
6
|
+
* to be "stamped" by the user.
|
|
7
|
+
*/
|
|
8
|
+
export var createSignature = function (name, signature) {
|
|
9
|
+
var data = new FormData();
|
|
10
|
+
data.append('signature', signature, name);
|
|
3
11
|
return getEndpoint()
|
|
4
|
-
.api.post(
|
|
12
|
+
.api.post("/signatures", data)
|
|
5
13
|
.then(function (r) { return r.data; });
|
|
6
14
|
};
|
|
7
15
|
export var getSignatures = function () {
|
package/Documents/index.d.ts
CHANGED
package/Documents/index.js
CHANGED
|
@@ -57,6 +57,18 @@ export declare class VerdocsEndpoint {
|
|
|
57
57
|
* ```
|
|
58
58
|
*/
|
|
59
59
|
setAuthorization(accessToken: string | null): void;
|
|
60
|
+
/**
|
|
61
|
+
* Set the auth token used for signing sessions. Separating user from signing auth allows the same endpoint to be
|
|
62
|
+
* used for multiple operations, although it is recommended that a separate endpoint be created for each operation.
|
|
63
|
+
*
|
|
64
|
+
* ```typescript
|
|
65
|
+
* import {Endpoint} from '@verdocs/js-sdk/HTTP';
|
|
66
|
+
*
|
|
67
|
+
* const endpoint = new Endpoint();
|
|
68
|
+
* endpoint.setSigningAuthorization(accessToken);
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
setSigningAuthorization(accessToken: string | null): void;
|
|
60
72
|
/**
|
|
61
73
|
* Set the base URL for API calls. May also be set via the constructor.
|
|
62
74
|
*
|
package/HTTP/VerdocsEndpoint.js
CHANGED
|
@@ -75,6 +75,25 @@ var VerdocsEndpoint = /** @class */ (function () {
|
|
|
75
75
|
delete this.api.defaults.headers.Authorization;
|
|
76
76
|
}
|
|
77
77
|
};
|
|
78
|
+
/**
|
|
79
|
+
* Set the auth token used for signing sessions. Separating user from signing auth allows the same endpoint to be
|
|
80
|
+
* used for multiple operations, although it is recommended that a separate endpoint be created for each operation.
|
|
81
|
+
*
|
|
82
|
+
* ```typescript
|
|
83
|
+
* import {Endpoint} from '@verdocs/js-sdk/HTTP';
|
|
84
|
+
*
|
|
85
|
+
* const endpoint = new Endpoint();
|
|
86
|
+
* endpoint.setSigningAuthorization(accessToken);
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
VerdocsEndpoint.prototype.setSigningAuthorization = function (accessToken) {
|
|
90
|
+
if (accessToken) {
|
|
91
|
+
this.api.defaults.headers.signer = "Bearer ".concat(accessToken);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
delete this.api.defaults.headers.signer;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
78
97
|
/**
|
|
79
98
|
* Set the base URL for API calls. May also be set via the constructor.
|
|
80
99
|
*
|
package/Organizations/Types.d.ts
CHANGED
|
@@ -5,12 +5,12 @@ export interface IOrganization {
|
|
|
5
5
|
/** The organization's name. */
|
|
6
6
|
name: string;
|
|
7
7
|
address: string | null;
|
|
8
|
+
address2: string | null;
|
|
8
9
|
phone: string | null;
|
|
9
|
-
/** If the organization is a business, its name. Note that a business name can be different from an organization name. */
|
|
10
|
-
business_name: string | null;
|
|
11
10
|
/** If true, the organization is a business */
|
|
12
11
|
is_business: boolean;
|
|
13
|
-
|
|
12
|
+
/** If the organization is a business, its name. Note that a business name can be different from an organization name. */
|
|
13
|
+
business_name: string | null;
|
|
14
14
|
contact_email: string | null;
|
|
15
15
|
timezone: string | null;
|
|
16
16
|
envelope_responsible: boolean;
|
package/Templates/Types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IOrganization } from '../Organizations/Types';
|
|
1
2
|
export interface ITemplate {
|
|
2
3
|
template_document?: ITemplateAsset;
|
|
3
4
|
pages?: IPage[];
|
|
@@ -7,9 +8,9 @@ export interface ITemplate {
|
|
|
7
8
|
name: string;
|
|
8
9
|
id?: string;
|
|
9
10
|
profile_id?: string;
|
|
10
|
-
created_at?:
|
|
11
|
-
updated_at?:
|
|
12
|
-
last_used_at?:
|
|
11
|
+
created_at?: string;
|
|
12
|
+
updated_at?: string;
|
|
13
|
+
last_used_at?: string;
|
|
13
14
|
token?: string;
|
|
14
15
|
reminder_id?: string;
|
|
15
16
|
reminder?: IReminder;
|
|
@@ -18,6 +19,7 @@ export interface ITemplate {
|
|
|
18
19
|
is_public?: boolean;
|
|
19
20
|
sender?: TTemplateSender;
|
|
20
21
|
description?: string;
|
|
22
|
+
organization?: IOrganization;
|
|
21
23
|
}
|
|
22
24
|
export interface ITemplateSummaryEntry {
|
|
23
25
|
id: string;
|
|
@@ -157,8 +159,8 @@ export interface ITemplateField {
|
|
|
157
159
|
label?: string;
|
|
158
160
|
}
|
|
159
161
|
export interface IFieldSetting {
|
|
160
|
-
x
|
|
161
|
-
y
|
|
162
|
+
x: number;
|
|
163
|
+
y: number;
|
|
162
164
|
width?: number;
|
|
163
165
|
height?: number;
|
|
164
166
|
result?: any;
|
|
@@ -168,6 +170,11 @@ export interface IFieldSetting {
|
|
|
168
170
|
alignment?: number;
|
|
169
171
|
upperCase?: boolean;
|
|
170
172
|
options?: any[];
|
|
173
|
+
base64?: string;
|
|
174
|
+
hash?: string;
|
|
175
|
+
ip_address?: string;
|
|
176
|
+
signature_id?: string;
|
|
177
|
+
signed_at?: string;
|
|
171
178
|
[key: string]: any;
|
|
172
179
|
}
|
|
173
180
|
export interface IPage {
|
package/Utils/Fields.d.ts
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import { IDocumentField } from '../Documents/Documents';
|
|
2
|
-
export declare function getHeight(field: IDocumentField): number;
|
|
3
|
-
export declare function getWidth(field: IDocumentField): number;
|
|
4
1
|
export declare function getRTop(y: number, fieldHeight: number, iTextHeight: number, yRatio: number): number;
|
|
5
2
|
export declare function getRLeft(x: number, ratio: number): number;
|
|
6
3
|
export declare function getRValue(y: number, ratio: number): number;
|
|
7
4
|
export declare function blobToBase64(image: Blob): Promise<unknown>;
|
|
8
|
-
export declare function getInputStyle(field: IDocumentField, mode: string, browserType: string): Record<string, string>;
|
|
9
|
-
export declare function getCheckboxLabelStyle(required: boolean): Record<string, any>;
|
|
10
|
-
export declare function getLetterSpacing(browserType: string): -0.0018 | -0.23594210526315787 | -0.0019;
|
|
11
5
|
export declare function rescale(r: number, n: number): number;
|
package/Utils/Fields.js
CHANGED
|
@@ -1,39 +1,3 @@
|
|
|
1
|
-
export function getHeight(field) {
|
|
2
|
-
var settings = field.settings || field.setting || {};
|
|
3
|
-
switch (field.type) {
|
|
4
|
-
case 'signature':
|
|
5
|
-
case 'initial':
|
|
6
|
-
return 36;
|
|
7
|
-
case 'checkbox':
|
|
8
|
-
case 'checkbox_group':
|
|
9
|
-
case 'radio_button_group':
|
|
10
|
-
return 13.5;
|
|
11
|
-
case 'attachment':
|
|
12
|
-
case 'payment':
|
|
13
|
-
return 24;
|
|
14
|
-
}
|
|
15
|
-
return settings.height || 0;
|
|
16
|
-
}
|
|
17
|
-
export function getWidth(field) {
|
|
18
|
-
var settings = field.settings || field.setting || {};
|
|
19
|
-
switch (field.type) {
|
|
20
|
-
case 'signature':
|
|
21
|
-
case 'initial':
|
|
22
|
-
return 82.63636363636;
|
|
23
|
-
case 'checkbox':
|
|
24
|
-
case 'checkbox_group':
|
|
25
|
-
case 'radio_button_group':
|
|
26
|
-
return 13.5;
|
|
27
|
-
case 'attachment':
|
|
28
|
-
case 'payment':
|
|
29
|
-
return 24;
|
|
30
|
-
case 'date':
|
|
31
|
-
return 64;
|
|
32
|
-
case 'dropdown':
|
|
33
|
-
return (settings === null || settings === void 0 ? void 0 : settings.width) || 64;
|
|
34
|
-
}
|
|
35
|
-
return (settings === null || settings === void 0 ? void 0 : settings.width) || 0;
|
|
36
|
-
}
|
|
37
1
|
export function getRTop(y, fieldHeight, iTextHeight, yRatio) {
|
|
38
2
|
return iTextHeight - (y + fieldHeight) * yRatio;
|
|
39
3
|
}
|
|
@@ -55,83 +19,6 @@ export function blobToBase64(image) {
|
|
|
55
19
|
fileReader.readAsDataURL(image);
|
|
56
20
|
});
|
|
57
21
|
}
|
|
58
|
-
export function getInputStyle(field, mode, browserType) {
|
|
59
|
-
var settings = field.settings || field.setting || {};
|
|
60
|
-
var fontSize = (settings === null || settings === void 0 ? void 0 : settings.font_size) || 11;
|
|
61
|
-
var style = {
|
|
62
|
-
height: '100%',
|
|
63
|
-
width: '100%',
|
|
64
|
-
background: 'none',
|
|
65
|
-
};
|
|
66
|
-
if (settings.font_size ||
|
|
67
|
-
field.type === 'date' ||
|
|
68
|
-
field.type === 'signature' ||
|
|
69
|
-
field.type === 'initial' ||
|
|
70
|
-
field.type === 'timestamp') {
|
|
71
|
-
style.fontSize = fontSize + 'px';
|
|
72
|
-
style.letterSpacing = '.3px !important';
|
|
73
|
-
}
|
|
74
|
-
if (field.type === 'dropdown') {
|
|
75
|
-
style.fontSize = '10.8px';
|
|
76
|
-
delete style.background;
|
|
77
|
-
}
|
|
78
|
-
if (field.type === 'textbox') {
|
|
79
|
-
style.fontSize = fontSize + 'px';
|
|
80
|
-
style.letterSpacing = getLetterSpacing(browserType) + 'px';
|
|
81
|
-
}
|
|
82
|
-
if (field.required) {
|
|
83
|
-
style.border = '1px solid #cc0000';
|
|
84
|
-
}
|
|
85
|
-
if ((field === null || field === void 0 ? void 0 : field.prepared) === true && mode !== 'prepareview') {
|
|
86
|
-
style.visibility = 'hidden';
|
|
87
|
-
}
|
|
88
|
-
if (settings.color) {
|
|
89
|
-
style.color = settings.color;
|
|
90
|
-
}
|
|
91
|
-
if (settings.upperCase) {
|
|
92
|
-
style.textTransform = 'uppercase';
|
|
93
|
-
}
|
|
94
|
-
if (settings.leading) {
|
|
95
|
-
style.lineHeight = "".concat(rescale(1, settings.leading + 0.5), "px");
|
|
96
|
-
}
|
|
97
|
-
return style;
|
|
98
|
-
}
|
|
99
|
-
export function getCheckboxLabelStyle(required) {
|
|
100
|
-
var labelStyle = {
|
|
101
|
-
position: 'absolute',
|
|
102
|
-
top: 0,
|
|
103
|
-
left: 0,
|
|
104
|
-
cursor: 'pointer',
|
|
105
|
-
height: "13.5px",
|
|
106
|
-
width: "13.5px",
|
|
107
|
-
backgroundColor: 'transparent',
|
|
108
|
-
border: '1px solid #777',
|
|
109
|
-
};
|
|
110
|
-
if (required) {
|
|
111
|
-
labelStyle.boxShadow = '0 0 0 1px #cc0000';
|
|
112
|
-
}
|
|
113
|
-
return labelStyle;
|
|
114
|
-
}
|
|
115
|
-
export function getLetterSpacing(browserType) {
|
|
116
|
-
switch (browserType) {
|
|
117
|
-
case 'opera':
|
|
118
|
-
return -0.0018;
|
|
119
|
-
case 'firefox':
|
|
120
|
-
return -0.23594210526315787;
|
|
121
|
-
case 'ie':
|
|
122
|
-
return -0.0019;
|
|
123
|
-
case 'edge':
|
|
124
|
-
return -0.0019;
|
|
125
|
-
case 'chrome':
|
|
126
|
-
return -0.0018;
|
|
127
|
-
case 'safari':
|
|
128
|
-
return -0.0018;
|
|
129
|
-
case 'blink':
|
|
130
|
-
return -0.0018;
|
|
131
|
-
default:
|
|
132
|
-
return -0.0018;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
22
|
export function rescale(r, n) {
|
|
136
23
|
return r * n;
|
|
137
24
|
}
|