@verdocs/js-sdk 1.1.9 → 1.1.13

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.
@@ -1,5 +1,5 @@
1
1
  import { ISigningSession, ISigningSessionRequest } from './Types';
2
- import { ISetting } from '../Templates/Types';
2
+ import { IFieldSetting } from '../Templates/Types';
3
3
  export declare type TDocumentStatus = 'complete' | 'pending' | 'in progress' | 'declined' | 'canceled';
4
4
  export declare type TRecipientStatus = 'invited' | 'opened' | 'signed' | 'submitted' | 'canceled' | 'pending' | 'declined';
5
5
  export declare type TRecipientType = 'signer' | 'cc' | 'approver';
@@ -81,8 +81,8 @@ export interface IDocumentField {
81
81
  recipient_role: string;
82
82
  type: string;
83
83
  required: boolean;
84
- settings?: ISetting;
85
- setting?: ISetting;
84
+ settings?: IFieldSetting;
85
+ setting?: IFieldSetting;
86
86
  validator: string | null;
87
87
  prepared?: boolean;
88
88
  }
@@ -176,3 +176,5 @@ export declare const getSigningSession: (params: ISigningSessionRequest) => Prom
176
176
  export declare const getDocumentRecipients: (documentId: string) => Promise<IRecipient[]>;
177
177
  export declare const getDocument: (documentId: string) => Promise<IDocument>;
178
178
  export declare const getDocumentFile: (documentId: string, envelopeDocumentId: string) => Promise<string>;
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>;
@@ -108,3 +108,17 @@ 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
+ export var updateDocumentField = function (documentId, fieldName, value) { return __awaiter(void 0, void 0, void 0, function () {
112
+ return __generator(this, function (_a) {
113
+ return [2 /*return*/, getEndpoint()
114
+ .api.put("/documents/".concat(documentId, "/fields/").concat(fieldName), value)
115
+ .then(function (r) { return r.data; })];
116
+ });
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?: string;
2
+ id: string;
3
3
  profile_id: string;
4
4
  url: string;
5
- created_at?: Date;
6
- updated_at?: Date;
5
+ deleted: boolean;
6
+ created_at: string;
7
+ updated_at: string;
7
8
  }
8
- export declare const createSignature: (params: any) => Promise<ISignature>;
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>;
@@ -1,7 +1,15 @@
1
1
  import { getEndpoint } from '../HTTP/Transport';
2
- export var createSignature = function (params) {
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('/signatures', params)
12
+ .api.post("/signatures", data)
5
13
  .then(function (r) { return r.data; });
6
14
  };
7
15
  export var getSignatures = function () {
@@ -2,4 +2,5 @@ export * as Documents from './Documents';
2
2
  export * as Recipients from './Recipients';
3
3
  export * as Stars from './Stars';
4
4
  export * as Signatures from './Signatures';
5
+ export * as Initials from './Initials';
5
6
  export * as Types from './Types';
@@ -2,4 +2,5 @@ export * as Documents from './Documents';
2
2
  export * as Recipients from './Recipients';
3
3
  export * as Stars from './Stars';
4
4
  export * as Signatures from './Signatures';
5
+ export * as Initials from './Initials';
5
6
  export * as Types from './Types';
@@ -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
  *
@@ -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
  *
@@ -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
- address2: string | null;
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;
@@ -1,3 +1,4 @@
1
+ import { IOrganization } from '../Organizations/Types';
1
2
  export interface ITemplate {
2
3
  template_document?: ITemplateAsset;
3
4
  pages?: IPage[];
@@ -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;
@@ -151,20 +153,28 @@ export interface ITemplateField {
151
153
  template_id: string;
152
154
  type: string;
153
155
  required: boolean;
154
- setting?: ISetting;
156
+ setting?: IFieldSetting;
155
157
  page_sequence: number;
156
158
  validator?: string;
157
159
  label?: string;
158
160
  }
159
- export interface ISetting {
160
- x?: number;
161
- y?: number;
161
+ export interface IFieldSetting {
162
+ x: number;
163
+ y: number;
162
164
  width?: number;
163
165
  height?: number;
164
- result?: string;
166
+ result?: any;
165
167
  type?: string;
166
- options?: any[];
167
168
  value?: string;
169
+ leading?: number;
170
+ alignment?: number;
171
+ upperCase?: boolean;
172
+ options?: any[];
173
+ base64?: string;
174
+ hash?: string;
175
+ ip_address?: string;
176
+ signature_id?: string;
177
+ signed_at?: string;
168
178
  [key: string]: any;
169
179
  }
170
180
  export interface IPage {
package/Utils/Fields.d.ts CHANGED
@@ -1,12 +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
- export declare function getStyle(field: IDocumentField): Record<string, string>;
8
4
  export declare function blobToBase64(image: Blob): Promise<unknown>;
9
- export declare function getInputStyle(field: IDocumentField, mode: string, browserType: string): Record<string, string>;
10
- export declare function getCheckboxLabelStyle(required: boolean): Record<string, any>;
11
- export declare function getLetterSpacing(browserType: string): -0.0018 | -0.23594210526315787 | -0.0019;
12
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
  }
@@ -43,44 +7,6 @@ export function getRLeft(x, ratio) {
43
7
  export function getRValue(y, ratio) {
44
8
  return y * ratio;
45
9
  }
46
- export function getStyle(field) {
47
- var settings = field.settings || field.setting || {};
48
- var height = getHeight(field);
49
- var style = {
50
- left: ((settings === null || settings === void 0 ? void 0 : settings.x) || 0) + 'px',
51
- bottom: ((settings === null || settings === void 0 ? void 0 : settings.y) || 0) + 'px',
52
- height: '100%',
53
- width: '100%',
54
- };
55
- switch (field.type) {
56
- case 'textbox':
57
- case 'date':
58
- case 'timestamp':
59
- case 'placeholder':
60
- case 'dropdown':
61
- style.maxHeight = height + 'px';
62
- style.maxWidth = ((settings === null || settings === void 0 ? void 0 : settings.width) || 0) + 'px';
63
- break;
64
- case 'checkbox':
65
- case 'checkbox_group':
66
- case 'radio_button_group':
67
- style.maxHeight = 13.5 + 'px';
68
- style.maxWidth = 13.5 + 'px';
69
- break;
70
- case 'attachment':
71
- case 'payment':
72
- style.maxHeight = 24 + 'px';
73
- style.maxWidth = 24 + 'px';
74
- break;
75
- case 'signature':
76
- case 'initial':
77
- style.maxHeight = 36 + 'px';
78
- style.maxWidth = 82.63636363636 + 'px';
79
- style['line-height'] = 36 + 'px';
80
- break;
81
- }
82
- return style;
83
- }
84
10
  export function blobToBase64(image) {
85
11
  var fileReader = new FileReader();
86
12
  return new Promise(function (resolve, reject) {
@@ -93,83 +19,6 @@ export function blobToBase64(image) {
93
19
  fileReader.readAsDataURL(image);
94
20
  });
95
21
  }
96
- export function getInputStyle(field, mode, browserType) {
97
- var settings = field.settings || field.setting || {};
98
- var fontSize = (settings === null || settings === void 0 ? void 0 : settings.font_size) || 11;
99
- var style = {
100
- height: '100%',
101
- width: '100%',
102
- background: 'none',
103
- };
104
- if (settings.font_size ||
105
- field.type === 'date' ||
106
- field.type === 'signature' ||
107
- field.type === 'initial' ||
108
- field.type === 'timestamp') {
109
- style.fontSize = fontSize + 'px';
110
- style.letterSpacing = '.3px !important';
111
- }
112
- if (field.type === 'dropdown') {
113
- style.fontSize = '10.8px';
114
- delete style.background;
115
- }
116
- if (field.type === 'textbox') {
117
- style.fontSize = fontSize + 'px';
118
- style.letterSpacing = getLetterSpacing(browserType) + 'px';
119
- }
120
- if (field.required) {
121
- style.border = '1px solid #cc0000';
122
- }
123
- if ((field === null || field === void 0 ? void 0 : field.prepared) === true && mode !== 'prepareview') {
124
- style.visibility = 'hidden';
125
- }
126
- if (settings.color) {
127
- style.color = settings.color;
128
- }
129
- if (settings.upperCase) {
130
- style.textTransform = 'uppercase';
131
- }
132
- if (settings.leading) {
133
- style.lineHeight = "".concat(rescale(1, settings.leading + 0.5), "px");
134
- }
135
- return style;
136
- }
137
- export function getCheckboxLabelStyle(required) {
138
- var labelStyle = {
139
- position: 'absolute',
140
- top: 0,
141
- left: 0,
142
- cursor: 'pointer',
143
- height: "13.5px",
144
- width: "13.5px",
145
- backgroundColor: 'transparent',
146
- border: '1px solid #777',
147
- };
148
- if (required) {
149
- labelStyle.boxShadow = '0 0 0 1px #cc0000';
150
- }
151
- return labelStyle;
152
- }
153
- export function getLetterSpacing(browserType) {
154
- switch (browserType) {
155
- case 'opera':
156
- return -0.0018;
157
- case 'firefox':
158
- return -0.23594210526315787;
159
- case 'ie':
160
- return -0.0019;
161
- case 'edge':
162
- return -0.0019;
163
- case 'chrome':
164
- return -0.0018;
165
- case 'safari':
166
- return -0.0018;
167
- case 'blink':
168
- return -0.0018;
169
- default:
170
- return -0.0018;
171
- }
172
- }
173
22
  export function rescale(r, n) {
174
23
  return r * n;
175
24
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdocs/js-sdk",
3
- "version": "1.1.9",
3
+ "version": "1.1.13",
4
4
  "private": false,
5
5
  "homepage": "https://github.com/Verdocs/js-sdk",
6
6
  "description": "Verdocs JS SDK",