@verdocs/js-sdk 2.1.0 → 3.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.
@@ -0,0 +1,113 @@
1
+ import { IEnvelope, IEnvelopesSummary, IRecipient, ISigningSession, TEnvelopeUpdateResult, IDocumentFieldSettings } from './Types';
2
+ import { ICreateEnvelopeRole, IEnvelopesSearchResult, ISigningSessionRequest } from './Types';
3
+ import { VerdocsEndpoint } from '../VerdocsEndpoint';
4
+ export interface ICreateEnvelopeRequest {
5
+ template_id: string;
6
+ roles: ICreateEnvelopeRole[];
7
+ name: string;
8
+ }
9
+ /**
10
+ * Create an envelope
11
+ *
12
+ * ```typescript
13
+ * import {Envelopes, ICreateEnvelopeRole, ICreateEnvelopeRequest} from '@verdocs/js-sdk/Envelopes';
14
+ *
15
+ * const role1: ICreateEnvelopeRole = {
16
+ * type: 'signer',
17
+ * name: 'Seller',
18
+ * full_name: 'Paige Turner',
19
+ * email: 'paige.turner@nomail.com',
20
+ * phone: '',
21
+ * sequence: 1,
22
+ * delegator: false,
23
+ * message: '',
24
+ * };
25
+ *
26
+ * const role2: ICreateEnvelopeRole = {
27
+ * type: 'signer',
28
+ * name: 'Buyer',
29
+ * full_name: 'Will Power',
30
+ * email: 'will.power@nomail.com',
31
+ * phone: '',
32
+ * sequence: 2,
33
+ * delegator: false,
34
+ * message: '',
35
+ * };
36
+ *
37
+ * const request: ICreateEnvelopeRequest = {template_id: 'd2338742-f3a1-465b-8592-806587413cc1', name: 'Bill of Sale', roles: [role1, role2]};
38
+ * const {id, recipients} = await Envelopes.createEnvelope(VerdocsEndpoint.getDefault(), request);
39
+ * ```
40
+ */
41
+ export declare const createEnvelope: (endpoint: VerdocsEndpoint, request: ICreateEnvelopeRequest) => Promise<IEnvelope>;
42
+ /**
43
+ * Get a summary of currently active envelopes.
44
+ *
45
+ * ```typescript
46
+ * import {Envelopes} from '@verdocs/js-sdk/Envelopes';
47
+ *
48
+ * const {action_required, completed, waiting_on_others} = await Envelopes.getSummary(VerdocsEndpoint.getDefault());
49
+ * ```
50
+ */
51
+ export declare const getSummary: (endpoint: VerdocsEndpoint, page: number) => Promise<IEnvelopesSummary>;
52
+ /**
53
+ * Search for envelopes matching various criteria.
54
+ *
55
+ * ```typescript
56
+ * import {Envelopes} from '@verdocs/js-sdk/Envelopes';
57
+ *
58
+ * const {result, page, total} = await Envelopes.search(VerdocsEndpoint.getDefault(), { ... });
59
+ * ```
60
+ */
61
+ export declare const searchEnvelopes: (endpoint: VerdocsEndpoint, params: any) => Promise<IEnvelopesSearchResult>;
62
+ export interface ISigningSessionResult {
63
+ recipient: IRecipient;
64
+ session: ISigningSession;
65
+ signerToken: string;
66
+ }
67
+ /**
68
+ * Get a signing session for an Envelope.
69
+ */
70
+ export declare const getSigningSession: (endpoint: VerdocsEndpoint, params: ISigningSessionRequest) => Promise<ISigningSessionResult>;
71
+ /**
72
+ * Get the list of recipients for an Envelope.
73
+ */
74
+ export declare const getEnvelopeRecipients: (endpoint: VerdocsEndpoint, envelopeId: string) => Promise<IRecipient[]>;
75
+ /**
76
+ * Get all metadata for an Envelope.
77
+ */
78
+ export declare const getEnvelope: (endpoint: VerdocsEndpoint, envelopeId: string) => Promise<IEnvelope>;
79
+ /**
80
+ * Cancel an Envelope.
81
+ */
82
+ export declare const cancelEnvelope: (endpoint: VerdocsEndpoint, envelopeId: string) => Promise<TEnvelopeUpdateResult>;
83
+ /**
84
+ * Returns true if the recipient has a pending action. Note that this does not necessarily mean the recipient can act (yet).
85
+ */
86
+ export declare const recipientHasAction: (recipient: IRecipient) => boolean;
87
+ /**
88
+ * Returns the recipients who still have a pending action. Note that not all of these recipients may be able to act (yet).
89
+ */
90
+ export declare const getRecipientsWithActions: (envelope: IEnvelope) => IRecipient[];
91
+ /**
92
+ * Returns true if the recipient can act.
93
+ */
94
+ export declare const recipientCanAct: (recipient: IRecipient, recipientsWithActions: IRecipient[]) => boolean;
95
+ /**
96
+ * Returns true if the user can act.
97
+ */
98
+ export declare const userCanAct: (email: string, recipientsWithActions: IRecipient[]) => boolean | undefined;
99
+ /**
100
+ * Get (binary download) a file attached to an Envelope. It is important to use this method
101
+ * rather than a direct A HREF or similar link to set the authorization headers for the
102
+ * request.
103
+ */
104
+ export declare const getEnvelopeFile: (endpoint: VerdocsEndpoint, envelopeId: string, documentId: string) => Promise<string>;
105
+ /**
106
+ * Update a Document field. Typically called during the signing process as a Recipient fills in fields.
107
+ */
108
+ export declare const updateEnvelopeField: (endpoint: VerdocsEndpoint, envelopeId: string, fieldName: string, value: any) => Promise<IDocumentFieldSettings>;
109
+ /**
110
+ * Update a Document signature field. Signature fields are ID-driven. Call `Document.createSignature()` first to create a
111
+ * signature for a Recipient, then call `Documents.updateDocumentFieldSignature()` to attach it to a field.
112
+ */
113
+ export declare const updateEnvelopeFieldSignature: (endpoint: VerdocsEndpoint, envelopeId: string, fieldName: string, signatureId: string) => Promise<IDocumentFieldSettings>;
@@ -36,12 +36,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
36
36
  };
37
37
  import { decodeAccessTokenBody } from '../Utils/Token';
38
38
  /**
39
- * Create a document
39
+ * Create an envelope
40
40
  *
41
41
  * ```typescript
42
- * import {Documents, ICreateDocumentRole, ICreateDocumentRequest} from '@verdocs/js-sdk/Documents';
42
+ * import {Envelopes, ICreateEnvelopeRole, ICreateEnvelopeRequest} from '@verdocs/js-sdk/Envelopes';
43
43
  *
44
- * const role1: ICreateDocumentRole = {
44
+ * const role1: ICreateEnvelopeRole = {
45
45
  * type: 'signer',
46
46
  * name: 'Seller',
47
47
  * full_name: 'Paige Turner',
@@ -52,7 +52,7 @@ import { decodeAccessTokenBody } from '../Utils/Token';
52
52
  * message: '',
53
53
  * };
54
54
  *
55
- * const role2: ICreateDocumentRole = {
55
+ * const role2: ICreateEnvelopeRole = {
56
56
  * type: 'signer',
57
57
  * name: 'Buyer',
58
58
  * full_name: 'Will Power',
@@ -63,56 +63,56 @@ import { decodeAccessTokenBody } from '../Utils/Token';
63
63
  * message: '',
64
64
  * };
65
65
  *
66
- * const request: ICreateDocumentRequest = {template_id: 'd2338742-f3a1-465b-8592-806587413cc1', name: 'Bill of Sale', roles: [role1, role2]};
67
- * const {id, recipients} = await Documents.createDocument(VerdocsEndpoint.getDefault(), request);
66
+ * const request: ICreateEnvelopeRequest = {template_id: 'd2338742-f3a1-465b-8592-806587413cc1', name: 'Bill of Sale', roles: [role1, role2]};
67
+ * const {id, recipients} = await Envelopes.createEnvelope(VerdocsEndpoint.getDefault(), request);
68
68
  * ```
69
69
  */
70
- export var createDocument = function (endpoint, request) { return __awaiter(void 0, void 0, void 0, function () {
70
+ export var createEnvelope = function (endpoint, request) { return __awaiter(void 0, void 0, void 0, function () {
71
71
  return __generator(this, function (_a) {
72
72
  return [2 /*return*/, endpoint.api //
73
- .post('/documents', request)
73
+ .post('/envelopes', request)
74
74
  .then(function (r) { return r.data; })];
75
75
  });
76
76
  }); };
77
77
  /**
78
- * Get a summary of currently active documents.
78
+ * Get a summary of currently active envelopes.
79
79
  *
80
80
  * ```typescript
81
- * import {Documents} from '@verdocs/js-sdk/Documents';
81
+ * import {Envelopes} from '@verdocs/js-sdk/Envelopes';
82
82
  *
83
- * const {action_required, completed, waiting_on_others} = await Documents.getSummary(VerdocsEndpoint.getDefault());
83
+ * const {action_required, completed, waiting_on_others} = await Envelopes.getSummary(VerdocsEndpoint.getDefault());
84
84
  * ```
85
85
  */
86
86
  export var getSummary = function (endpoint, page) { return __awaiter(void 0, void 0, void 0, function () {
87
87
  return __generator(this, function (_a) {
88
88
  return [2 /*return*/, endpoint.api //
89
- .post('/documents/summary', { page: page })
89
+ .post('/envelopes/summary', { page: page })
90
90
  .then(function (r) { return r.data; })];
91
91
  });
92
92
  }); };
93
93
  /**
94
- * Search for documents matching various criteria.
94
+ * Search for envelopes matching various criteria.
95
95
  *
96
96
  * ```typescript
97
- * import {Documents} from '@verdocs/js-sdk/Documents';
97
+ * import {Envelopes} from '@verdocs/js-sdk/Envelopes';
98
98
  *
99
- * const {result, page, total} = await Documents.search(VerdocsEndpoint.getDefault(), { ... });
99
+ * const {result, page, total} = await Envelopes.search(VerdocsEndpoint.getDefault(), { ... });
100
100
  * ```
101
101
  */
102
- export var searchDocuments = function (endpoint, params) { return __awaiter(void 0, void 0, void 0, function () {
102
+ export var searchEnvelopes = function (endpoint, params) { return __awaiter(void 0, void 0, void 0, function () {
103
103
  return __generator(this, function (_a) {
104
104
  return [2 /*return*/, endpoint.api //
105
- .post('/documents/search', params)
105
+ .post('/envelopes/search', params)
106
106
  .then(function (r) { return r.data; })];
107
107
  });
108
108
  }); };
109
109
  /**
110
- * Get a signing session for a Document.
110
+ * Get a signing session for an Envelope.
111
111
  */
112
112
  export var getSigningSession = function (endpoint, params) { return __awaiter(void 0, void 0, void 0, function () {
113
113
  return __generator(this, function (_a) {
114
114
  return [2 /*return*/, endpoint.api //
115
- .get("/documents/".concat(params.documentId, "/recipients/").concat(encodeURIComponent(params.roleId), "/invitation/").concat(params.inviteCode))
115
+ .get("/envelopes/".concat(params.envelopeId, "/recipients/").concat(encodeURIComponent(params.roleId), "/invitation/").concat(params.inviteCode))
116
116
  .then(function (r) {
117
117
  var _a, _b;
118
118
  // Avoiding a jsonwebtoken dependency here - we don't actually need the whole library
@@ -124,32 +124,32 @@ export var getSigningSession = function (endpoint, params) { return __awaiter(vo
124
124
  });
125
125
  }); };
126
126
  /**
127
- * Get the list of recipients for a Document.
127
+ * Get the list of recipients for an Envelope.
128
128
  */
129
- export var getDocumentRecipients = function (endpoint, documentId) { return __awaiter(void 0, void 0, void 0, function () {
129
+ export var getEnvelopeRecipients = function (endpoint, envelopeId) { return __awaiter(void 0, void 0, void 0, function () {
130
130
  return __generator(this, function (_a) {
131
131
  return [2 /*return*/, endpoint.api //
132
- .get("/documents/".concat(documentId, "/recipients"))
132
+ .get("/envelopes/".concat(envelopeId, "/recipients"))
133
133
  .then(function (r) { return r.data; })];
134
134
  });
135
135
  }); };
136
136
  /**
137
- * Get all metadata for a Document.
137
+ * Get all metadata for an Envelope.
138
138
  */
139
- export var getDocument = function (endpoint, documentId) { return __awaiter(void 0, void 0, void 0, function () {
139
+ export var getEnvelope = function (endpoint, envelopeId) { return __awaiter(void 0, void 0, void 0, function () {
140
140
  return __generator(this, function (_a) {
141
141
  return [2 /*return*/, endpoint.api //
142
- .get("/documents/".concat(documentId))
142
+ .get("/envelopes/".concat(envelopeId))
143
143
  .then(function (r) { return r.data; })];
144
144
  });
145
145
  }); };
146
146
  /**
147
- * Cancel a Document.
147
+ * Cancel an Envelope.
148
148
  */
149
- export var cancelDocument = function (endpoint, documentId) { return __awaiter(void 0, void 0, void 0, function () {
149
+ export var cancelEnvelope = function (endpoint, envelopeId) { return __awaiter(void 0, void 0, void 0, function () {
150
150
  return __generator(this, function (_a) {
151
151
  return [2 /*return*/, endpoint.api //
152
- .put("/documents/".concat(documentId), { action: 'cancel' })
152
+ .put("/envelopes/".concat(envelopeId), { action: 'cancel' })
153
153
  .then(function (r) { return r.data; })];
154
154
  });
155
155
  }); };
@@ -160,7 +160,7 @@ export var recipientHasAction = function (recipient) { return !['submitted', 'ca
160
160
  /**
161
161
  * Returns the recipients who still have a pending action. Note that not all of these recipients may be able to act (yet).
162
162
  */
163
- export var getRecipientsWithActions = function (document) { return ((document === null || document === void 0 ? void 0 : document.recipients) || []).filter(recipientHasAction); };
163
+ export var getRecipientsWithActions = function (envelope) { return ((envelope === null || envelope === void 0 ? void 0 : envelope.recipients) || []).filter(recipientHasAction); };
164
164
  /**
165
165
  * Returns true if the recipient can act.
166
166
  */
@@ -174,14 +174,14 @@ export var userCanAct = function (email, recipientsWithActions) {
174
174
  return recipient && recipient.sequence === ((_a = recipientsWithActions === null || recipientsWithActions === void 0 ? void 0 : recipientsWithActions[0]) === null || _a === void 0 ? void 0 : _a.sequence);
175
175
  };
176
176
  /**
177
- * Get (binary download) a file attached to a Document. It is important to use this method
177
+ * Get (binary download) a file attached to an Envelope. It is important to use this method
178
178
  * rather than a direct A HREF or similar link to set the authorization headers for the
179
179
  * request.
180
180
  */
181
- export var getDocumentFile = function (endpoint, documentId, envelopeDocumentId) { return __awaiter(void 0, void 0, void 0, function () {
181
+ export var getEnvelopeFile = function (endpoint, envelopeId, documentId) { return __awaiter(void 0, void 0, void 0, function () {
182
182
  return __generator(this, function (_a) {
183
183
  return [2 /*return*/, endpoint.api //
184
- .get("/documents/".concat(documentId, "/envelope_documents/").concat(envelopeDocumentId, "?file=true"), {
184
+ .get("/envelopes/".concat(envelopeId, "/envelope_documents/").concat(documentId, "?file=true"), {
185
185
  responseType: 'arraybuffer',
186
186
  })
187
187
  .then(function (r) { return Buffer.from(r.data, 'binary').toString('base64'); })];
@@ -190,10 +190,10 @@ export var getDocumentFile = function (endpoint, documentId, envelopeDocumentId)
190
190
  /**
191
191
  * Update a Document field. Typically called during the signing process as a Recipient fills in fields.
192
192
  */
193
- export var updateDocumentField = function (endpoint, documentId, fieldName, value) { return __awaiter(void 0, void 0, void 0, function () {
193
+ export var updateEnvelopeField = function (endpoint, envelopeId, fieldName, value) { return __awaiter(void 0, void 0, void 0, function () {
194
194
  return __generator(this, function (_a) {
195
195
  return [2 /*return*/, endpoint.api //
196
- .put("/documents/".concat(documentId, "/fields/").concat(fieldName), value)
196
+ .put("/envelopes/".concat(envelopeId, "/fields/").concat(fieldName), value)
197
197
  .then(function (r) { return r.data; })];
198
198
  });
199
199
  }); };
@@ -201,10 +201,10 @@ export var updateDocumentField = function (endpoint, documentId, fieldName, valu
201
201
  * Update a Document signature field. Signature fields are ID-driven. Call `Document.createSignature()` first to create a
202
202
  * signature for a Recipient, then call `Documents.updateDocumentFieldSignature()` to attach it to a field.
203
203
  */
204
- export var updateDocumentFieldSignature = function (endpoint, documentId, fieldName, signatureId) { return __awaiter(void 0, void 0, void 0, function () {
204
+ export var updateEnvelopeFieldSignature = function (endpoint, envelopeId, fieldName, signatureId) { return __awaiter(void 0, void 0, void 0, function () {
205
205
  return __generator(this, function (_a) {
206
206
  return [2 /*return*/, endpoint.api //
207
- .put("/documents/".concat(documentId, "/fields/").concat(fieldName, "/signature/").concat(signatureId))
207
+ .put("/envelopes/".concat(envelopeId, "/fields/").concat(fieldName, "/signature/").concat(signatureId))
208
208
  .then(function (r) { return r.data; })];
209
209
  });
210
210
  }); };
File without changes
File without changes
@@ -1,6 +1,6 @@
1
1
  import { IInPersonAccessKey, TRecipientAction } from './Types';
2
2
  import { VerdocsEndpoint } from '../VerdocsEndpoint';
3
- import { IDocument, IRecipient } from './Types';
3
+ import { IEnvelope, IRecipient } from './Types';
4
4
  export interface IUpdateRecipientParams {
5
5
  new_full_name?: string;
6
6
  agreed?: boolean;
@@ -8,12 +8,12 @@ export interface IUpdateRecipientParams {
8
8
  /**
9
9
  * Update a recipient's status block
10
10
  */
11
- export declare const updateRecipientStatus: (endpoint: VerdocsEndpoint, documentId: string, roleName: string, action: TRecipientAction, params?: IUpdateRecipientParams) => Promise<IRecipient>;
11
+ export declare const updateRecipientStatus: (endpoint: VerdocsEndpoint, envelopeId: string, roleName: string, action: TRecipientAction, params?: IUpdateRecipientParams) => Promise<IRecipient>;
12
12
  export interface ISignerTokenResponse {
13
13
  recipient: IRecipient;
14
- envelope: IDocument;
14
+ envelope: IEnvelope;
15
15
  signerToken: string;
16
16
  inPersonAccessKey: IInPersonAccessKey;
17
17
  }
18
- export declare const getSignerToken: (endpoint: VerdocsEndpoint, documentId: string, roleName: string) => Promise<ISignerTokenResponse>;
19
- export declare const getInPersonLink: (endpoint: VerdocsEndpoint, documentId: string, roleName: string) => Promise<ISignerTokenResponse>;
18
+ export declare const getSignerToken: (endpoint: VerdocsEndpoint, envelopeId: string, roleName: string) => Promise<ISignerTokenResponse>;
19
+ export declare const getInPersonLink: (endpoint: VerdocsEndpoint, envelopeId: string, roleName: string) => Promise<ISignerTokenResponse>;
@@ -48,20 +48,20 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
48
48
  /**
49
49
  * Update a recipient's status block
50
50
  */
51
- export var updateRecipientStatus = function (endpoint, documentId, roleName, action, params) { return __awaiter(void 0, void 0, void 0, function () {
51
+ export var updateRecipientStatus = function (endpoint, envelopeId, roleName, action, params) { return __awaiter(void 0, void 0, void 0, function () {
52
52
  return __generator(this, function (_a) {
53
53
  return [2 /*return*/, endpoint.api //
54
- .put("/documents/".concat(documentId, "/recipients/").concat(roleName), __assign({ role_name: roleName, action: action }, (params || {})))
54
+ .put("/envelopes/".concat(envelopeId, "/recipients/").concat(roleName), __assign({ role_name: roleName, action: action }, (params || {})))
55
55
  .then(function (r) { return r.data; })];
56
56
  });
57
57
  }); };
58
- export var getSignerToken = function (endpoint, documentId, roleName) {
58
+ export var getSignerToken = function (endpoint, envelopeId, roleName) {
59
59
  return endpoint.api //
60
- .get("/documents/".concat(documentId, "/recipients/").concat(encodeURIComponent(roleName), "/signer-token"))
60
+ .get("/envelopes/".concat(envelopeId, "/recipients/").concat(encodeURIComponent(roleName), "/signer-token"))
61
61
  .then(function (r) { return r.data; });
62
62
  };
63
- export var getInPersonLink = function (endpoint, documentId, roleName) {
63
+ export var getInPersonLink = function (endpoint, envelopeId, roleName) {
64
64
  return endpoint.api //
65
- .get("/documents/".concat(documentId, "/recipients/").concat(encodeURIComponent(roleName), "?in_person_link=true"))
65
+ .get("/envelopes/".concat(envelopeId, "/recipients/").concat(encodeURIComponent(roleName), "?in_person_link=true"))
66
66
  .then(function (r) { return r.data; });
67
67
  };
File without changes
File without changes
@@ -1,36 +1,13 @@
1
1
  import { IProfile } from '../Users/Types';
2
2
  export declare type TRecipientAction = 'submit' | 'decline' | 'prepare' | 'update';
3
- export interface ITemplateSummaryEntry {
4
- id: string;
5
- name: string;
6
- sender: string;
7
- counter: number;
8
- description: string | null;
9
- created_at: string;
10
- updated_at: string;
11
- is_personal: boolean;
12
- is_public: boolean;
13
- profile_id: string;
14
- organization_id: string;
15
- last_used_at: string | null;
16
- document_name: string | null;
17
- star_counter: number;
18
- tag_name: string | null;
19
- is_starred: boolean;
20
- }
21
- export interface ITemplatesSummary {
22
- page: number;
23
- total: number;
24
- result: ITemplateSummaryEntry[];
25
- }
26
3
  export interface ISigningSessionRequest {
27
- documentId: string;
4
+ envelopeId: string;
28
5
  roleId: string;
29
6
  inviteCode: string;
30
7
  }
31
8
  export interface ISigningSession {
32
9
  profile_id: string;
33
- document_id: string;
10
+ envelope_id: string;
34
11
  role: string;
35
12
  email: string;
36
13
  access_key: {
@@ -54,15 +31,15 @@ export interface IInPersonAccessKey {
54
31
  first_used: string | null;
55
32
  last_used: string | null;
56
33
  }
57
- export declare type TDocumentStatus = 'complete' | 'pending' | 'in progress' | 'declined' | 'canceled';
34
+ export declare type TEnvelopeStatus = 'complete' | 'pending' | 'in progress' | 'declined' | 'canceled';
58
35
  export declare type TRecipientStatus = 'invited' | 'opened' | 'signed' | 'submitted' | 'canceled' | 'pending' | 'declined';
59
36
  export declare type TRecipientType = 'signer' | 'cc' | 'approver';
60
- export interface IDocumentsSearchResultEntry {
37
+ export interface IEnvelopesSearchResultEntry {
61
38
  id: string;
62
39
  canceled_at: string;
63
40
  certificate_document_id: string;
64
- created_at: string;
65
41
  envelope_document_id: string;
42
+ created_at: string;
66
43
  histories: IHistory[];
67
44
  indexed_at: string;
68
45
  name: string;
@@ -71,7 +48,7 @@ export interface IDocumentsSearchResultEntry {
71
48
  profile_id: string;
72
49
  recipients: IRecipient[];
73
50
  reminder_id: string | null;
74
- status: TDocumentStatus;
51
+ status: TEnvelopeStatus;
75
52
  next_recipient: {
76
53
  claimed: boolean;
77
54
  email: string;
@@ -84,12 +61,12 @@ export interface IDocumentsSearchResultEntry {
84
61
  total_count: number;
85
62
  updated_at: string;
86
63
  }
87
- export interface IDocumentsSearchResult {
64
+ export interface IEnvelopesSearchResult {
88
65
  page: number;
89
66
  total: number;
90
- result: IDocumentsSearchResultEntry[];
67
+ result: IEnvelopesSearchResultEntry[];
91
68
  }
92
- export interface IDocumentsSummary {
69
+ export interface IEnvelopesSummary {
93
70
  action_required: {
94
71
  page: number;
95
72
  total: number;
@@ -127,7 +104,7 @@ export interface IRecipient {
127
104
  updated_at: string;
128
105
  fields?: IDocumentField[];
129
106
  }
130
- export interface IDocumentAsset {
107
+ export interface IEnvelopeDocument {
131
108
  created_at: string;
132
109
  id: string;
133
110
  mime: string;
@@ -178,28 +155,33 @@ export interface IDocumentField {
178
155
  validator: string | null;
179
156
  prepared?: boolean;
180
157
  }
181
- export interface IDocument {
158
+ /**
159
+ * An Envelope is a workflow wrapper that shepherds one or more Documents through the various recipients in a signing
160
+ * process.
161
+ */
162
+ export interface IEnvelope {
182
163
  id: string;
164
+ template_id: string;
165
+ name: string;
166
+ status: TEnvelopeStatus;
167
+ profile_id: string;
168
+ organization_id: string | null;
169
+ no_contact: boolean;
183
170
  created_at: string;
171
+ updated_at: string;
184
172
  canceled_at: string;
173
+ reminder_id: string | null;
185
174
  envelope_document_id: string;
186
175
  certificate_document_id: string | null;
187
176
  histories: IHistory[];
188
177
  recipients: IRecipient[];
189
- name: string;
190
- no_contact: boolean;
191
- profile_id: string;
192
- reminder_id: string | null;
193
- status: TDocumentStatus;
194
- template_id: string;
195
- updated_at: string;
196
- organization_id: string | null;
197
- certificate?: IDocumentAsset | null;
198
- document?: IDocumentAsset | null;
199
- fields?: IDocumentField[];
200
178
  profile?: IProfile | null;
179
+ certificate?: IEnvelopeDocument | null;
180
+ document?: IEnvelopeDocument | null;
181
+ documents?: IEnvelopeDocument[] | null;
182
+ fields?: IDocumentField[];
201
183
  }
202
- export declare type TDocumentUpdateResult = Omit<IDocument, 'histories' | 'recipients' | 'certificate' | 'document' | 'fields' | 'profile'>;
184
+ export declare type TEnvelopeUpdateResult = Omit<IEnvelope, 'histories' | 'recipients' | 'certificate' | 'document' | 'fields' | 'profile'>;
203
185
  export interface IActivityEntry {
204
186
  id: string;
205
187
  name: string;
@@ -207,7 +189,7 @@ export interface IActivityEntry {
207
189
  created_at: string;
208
190
  updated_at: string;
209
191
  profile_id: string;
210
- status: TDocumentStatus;
192
+ status: TEnvelopeStatus;
211
193
  template_id: string;
212
194
  recipient: {
213
195
  claimed: boolean;
@@ -233,12 +215,12 @@ export interface IDocumentSearchOptions {
233
215
  ascending?: boolean;
234
216
  is_owner?: boolean;
235
217
  is_recipient?: boolean;
236
- envelope_status: TDocumentStatus[];
237
- recipient_status: TDocumentStatus[];
218
+ envelope_status?: TEnvelopeStatus[];
219
+ recipient_status?: TEnvelopeStatus[];
238
220
  }
239
221
  export declare type THistoryEvent = 'recipient:invited' | 'recipient:opened' | 'recipient:agreed' | 'recipient:signed' | 'recipient:submitted';
240
222
  export declare type TEventDetail = 'in_app' | 'mail' | 'signer' | '';
241
- export interface ICreateDocumentRole {
223
+ export interface ICreateEnvelopeRole {
242
224
  type: TRecipientType;
243
225
  name: string;
244
226
  full_name: string;
@@ -248,8 +230,3 @@ export interface ICreateDocumentRole {
248
230
  delegator: boolean;
249
231
  message: string;
250
232
  }
251
- export interface ICreateDocumentRequest {
252
- template_id: string;
253
- roles: ICreateDocumentRole[];
254
- name: string;
255
- }
File without changes
@@ -1,4 +1,4 @@
1
- export * as Documents from './Documents';
1
+ export * as Envelopes from './Envelopes';
2
2
  export * as Recipients from './Recipients';
3
3
  export * as Signatures from './Signatures';
4
4
  export * as Initials from './Initials';
@@ -1,4 +1,4 @@
1
- export * as Documents from './Documents';
1
+ export * as Envelopes from './Envelopes';
2
2
  export * as Recipients from './Recipients';
3
3
  export * as Signatures from './Signatures';
4
4
  export * as Initials from './Initials';
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Verdocs provides a range of search functions to help find and retrieve content. This module provides generic functions intended
3
3
  * to locate items across all content types. More specific retrievals may be performed using the various "list" endpoints within
4
- * each collection (e.g. {@link Documents.Documents.searchDocuments} or {@link Templates.Templates.searchTemplates}).
4
+ * each collection (e.g. {@link Envelopes.Envelopes.searchEnvelopes} or {@link Templates.Templates.searchTemplates}).
5
5
  *
6
6
  * @module
7
7
  */
package/Search/Content.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Verdocs provides a range of search functions to help find and retrieve content. This module provides generic functions intended
3
3
  * to locate items across all content types. More specific retrievals may be performed using the various "list" endpoints within
4
- * each collection (e.g. {@link Documents.Documents.searchDocuments} or {@link Templates.Templates.searchTemplates}).
4
+ * each collection (e.g. {@link Envelopes.Envelopes.searchEnvelopes} or {@link Templates.Templates.searchTemplates}).
5
5
  *
6
6
  * @module
7
7
  */
package/Search/Types.d.ts CHANGED
@@ -1,19 +1,19 @@
1
1
  import { TTemplateSender } from '../Templates/Types';
2
- import { TDocumentStatus } from '../Documents/Types';
2
+ import { TEnvelopeStatus } from '../Envelopes/Types';
3
3
  export declare type TMimeType = 'application/pdf' | string;
4
4
  /**
5
5
  * An individual hit in a document search result. Note that this schema does not precisely match IDocument because fields
6
6
  * are optimized for search performance.
7
7
  */
8
- export interface IDocumentHit {
9
- type: 'document';
8
+ export interface IEnvelopeHit {
9
+ type: 'envelope';
10
10
  id: string;
11
11
  template_id: string;
12
12
  name: string;
13
13
  profile_id: string;
14
14
  organization_id: string;
15
15
  organization_name: string;
16
- status: TDocumentStatus;
16
+ status: TEnvelopeStatus;
17
17
  recipient_emails: string[];
18
18
  recipient_names: string[];
19
19
  updated_at: string;
@@ -93,7 +93,7 @@ export interface ISearchResultCollection<T> {
93
93
  search_time_ms: number;
94
94
  }
95
95
  export interface ISearchResult {
96
- documents: ISearchResultCollection<IDocumentHit>;
96
+ documents: ISearchResultCollection<IEnvelopeHit>;
97
97
  myTemplates: ISearchResultCollection<ITemplateHit>;
98
98
  publicTemplates: ISearchResultCollection<ITemplateHit>;
99
99
  organizations: ISearchResultCollection<IOrganizationHit>;
@@ -0,0 +1,37 @@
1
+ import { IProfile, TPermission, TPlan, TRole } from '../Users/Types';
2
+ export interface ISigningSessionRequest {
3
+ envelopeId: string;
4
+ roleId: string;
5
+ inviteCode: string;
6
+ }
7
+ export interface ISigningSession {
8
+ profile_id: string;
9
+ envelope_id: string;
10
+ role: string;
11
+ email: string;
12
+ access_key: {
13
+ id: string;
14
+ type: string;
15
+ };
16
+ iss: string;
17
+ aud: string;
18
+ exp: number;
19
+ iat: number;
20
+ [key: string]: any;
21
+ }
22
+ export interface IUserSession {
23
+ sub: string;
24
+ email: string;
25
+ email_verified: boolean;
26
+ iat: number;
27
+ exp: number;
28
+ permissions: TPermission[];
29
+ roles: TRole[];
30
+ profile: IProfile;
31
+ profile_id: string;
32
+ organization_id: string;
33
+ plans?: TPlan[];
34
+ [key: string]: any;
35
+ }
36
+ export declare type TSessionType = 'user' | 'signing';
37
+ export declare type TSession = IUserSession | ISigningSession | null;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export * as Types from './Types';
@@ -0,0 +1 @@
1
+ export * as Types from './Types';
@@ -1,26 +1,35 @@
1
1
  import { IOrganization } from '../Organizations/Types';
2
+ /**
3
+ * A reusable template for creating signable instruments. Templates are used to create Envelopes which contain
4
+ * Documents to sign.
5
+ */
2
6
  export interface ITemplate {
3
- template_document?: ITemplateDocument;
4
- pages?: IPage[];
5
- roles?: IRole[];
6
- counter?: number;
7
- star_counter?: number;
8
- name: string;
9
7
  id: string;
10
- profile_id?: string;
11
- created_at?: string;
12
- updated_at?: string;
13
- last_used_at?: string;
8
+ name: string;
9
+ description?: string;
10
+ sender: TTemplateSender;
11
+ profile_id: string;
12
+ organization_id: string;
13
+ counter: number;
14
+ star_counter: number;
15
+ is_personal: boolean;
16
+ is_public: boolean;
17
+ created_at: string;
18
+ updated_at: string;
19
+ last_used_at: string;
14
20
  token?: string;
15
21
  reminder_id?: string;
16
22
  reminder?: IReminder;
17
- organization_id?: string;
18
- is_personal?: boolean;
19
- is_public?: boolean;
20
- sender?: TTemplateSender;
21
- description?: string;
23
+ processed?: boolean;
22
24
  organization?: IOrganization;
25
+ roles?: IRole[];
26
+ pages?: IPage[];
27
+ template_document?: ITemplateDocument;
28
+ template_documents?: ITemplateDocument[];
23
29
  }
30
+ /**
31
+ * Some template search and list endpoints return only a partial set of fields for each entry via this structure.
32
+ */
24
33
  export interface ITemplateSummaryEntry {
25
34
  id: string;
26
35
  name: string;
@@ -124,6 +133,9 @@ export interface IStar {
124
133
  template_id: string;
125
134
  profile_id: string;
126
135
  }
136
+ /**
137
+ * An individual recipient, CC, or other party in a signing flow.
138
+ */
127
139
  export interface IRole {
128
140
  template_id: string;
129
141
  name: string;
@@ -137,6 +149,9 @@ export interface IRole {
137
149
  phone?: string;
138
150
  rgba?: string;
139
151
  }
152
+ /**
153
+ * A file attached to the template for display/signing.
154
+ */
140
155
  export interface ITemplateDocument {
141
156
  url: string;
142
157
  name: string;
@@ -178,6 +193,7 @@ export interface IPage {
178
193
  page_number: number;
179
194
  thumbnail_url: string;
180
195
  image_uri?: string | null;
196
+ display_uri?: string | null;
181
197
  template_document?: ITemplateDocument;
182
198
  fields?: ITemplateField[];
183
199
  }
package/Users/Types.d.ts CHANGED
@@ -40,20 +40,6 @@ export interface IProfile {
40
40
  /** The plans assigned to the profilel _NOTE: Only present in the "current" profile._ */
41
41
  groups?: IGroup[];
42
42
  }
43
- export interface IActiveSession {
44
- sub: string;
45
- email: string;
46
- email_verified: boolean;
47
- iat: number;
48
- exp: number;
49
- permissions: TPermission[];
50
- roles: TRole[];
51
- profile: IProfile;
52
- profile_id: string;
53
- organization_id: string;
54
- plans?: TPlan[];
55
- [key: string]: any;
56
- }
57
43
  export interface IRole {
58
44
  /** Unique identifier for the role. */
59
45
  id: string;
package/Utils/Token.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { ISigningSession } from '../Documents/Types';
2
- import { IActiveSession } from '../Users/Types';
1
+ import { ISigningSession } from '../Envelopes/Types';
2
+ import { IUserSession } from '../Sessions/Types';
3
3
  /**
4
4
  * Simplified, Node/Browser-safe alternative to atob() for base64 decoding.
5
5
  * Modified from https://github.com/MaxArt2501/base64-js/blob/master/base64.js
@@ -17,4 +17,4 @@ export declare const decodeJWTBody: (token: string) => any;
17
17
  * application should distinguish between the two based on the context of the authenticated session, or by
18
18
  * the presence of the `document_id` field, which will only be present for signing sessions.
19
19
  */
20
- export declare const decodeAccessTokenBody: (token: string) => IActiveSession | ISigningSession | null;
20
+ export declare const decodeAccessTokenBody: (token: string) => IUserSession | ISigningSession | null;
@@ -1,10 +1,6 @@
1
1
  import { AxiosInstance } from 'axios';
2
- import { ISigningSession } from './Documents/Types';
3
- import { IActiveSession } from './Users/Types';
4
- import * as Documents from './Documents';
2
+ import { TSession, TSessionType } from './Sessions/Types';
5
3
  export declare type TEnvironment = 'verdocs' | 'verdocs-stage';
6
- export declare type TSessionType = 'user' | 'signing';
7
- export declare type TSession = IActiveSession | ISigningSession | null;
8
4
  export declare type TSessionChangedListener = (endpoint: VerdocsEndpoint, session: TSession) => void;
9
5
  export interface VerdocsEndpointOptions {
10
6
  baseURL?: string;
@@ -51,7 +47,6 @@ export declare class VerdocsEndpoint {
51
47
  */
52
48
  session: TSession;
53
49
  api: AxiosInstance;
54
- Documents: typeof Documents;
55
50
  /**
56
51
  * Create a new VerdocsEndpoint to call Verdocs platform services.
57
52
  *
@@ -1,7 +1,6 @@
1
1
  import axios from 'axios';
2
2
  import { decodeAccessTokenBody } from './Utils/Token';
3
3
  import globalThis from './Utils/globalThis';
4
- import * as Documents from './Documents';
5
4
  // @credit https://derickbailey.com/2016/03/09/creating-a-true-singleton-in-node-js-with-es6-symbols/
6
5
  // Also see globalThis for comments about why we're doing this in the first place.
7
6
  var ENDPOINT_KEY = Symbol.for('verdocs-default-endpoint');
@@ -56,7 +55,6 @@ var VerdocsEndpoint = /** @class */ (function () {
56
55
  * with Documents.
57
56
  */
58
57
  this.session = null;
59
- this.Documents = Documents;
60
58
  this.baseURL = (options === null || options === void 0 ? void 0 : options.baseURL) || 'https://api.verdocs.com';
61
59
  this.timeout = (options === null || options === void 0 ? void 0 : options.timeout) || 3000;
62
60
  this.environment = (options === null || options === void 0 ? void 0 : options.environment) || 'verdocs';
package/index.d.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  /**
2
2
  * Verdocs functions are organized into high-level modules that represent the main objects within Verdocs:
3
3
  *
4
- * - Documents - An individual document to be signed. Documents are created from templates.
5
- * - HTTP - General support functionality for Verdocs' REST endpoints. Typically not used directly.
4
+ * - Envelopes - An individual document to be signed. Documents are created from templates.
6
5
  * - Organizations - An Organization is a container for user profiles, templates, documents, billing, and other related objects.
7
6
  * - Search - Various methods used to retrieve lists of documents and templtes.
8
7
  * - Templates - A template for a document containing a PDF file, metadata for signature fields, and other information.
@@ -11,10 +10,11 @@
11
10
  *
12
11
  * @module
13
12
  */
14
- export * as Documents from './Documents';
15
- export * as Templates from './Templates';
13
+ export * as Envelopes from './Envelopes';
16
14
  export * as Organizations from './Organizations';
17
15
  export * as Search from './Search';
16
+ export * as Sessions from './Sessions';
17
+ export * as Templates from './Templates';
18
18
  export * as Users from './Users';
19
19
  export * as Utils from './Utils';
20
20
  export * from './VerdocsEndpoint';
package/index.js CHANGED
@@ -1,8 +1,7 @@
1
1
  /**
2
2
  * Verdocs functions are organized into high-level modules that represent the main objects within Verdocs:
3
3
  *
4
- * - Documents - An individual document to be signed. Documents are created from templates.
5
- * - HTTP - General support functionality for Verdocs' REST endpoints. Typically not used directly.
4
+ * - Envelopes - An individual document to be signed. Documents are created from templates.
6
5
  * - Organizations - An Organization is a container for user profiles, templates, documents, billing, and other related objects.
7
6
  * - Search - Various methods used to retrieve lists of documents and templtes.
8
7
  * - Templates - A template for a document containing a PDF file, metadata for signature fields, and other information.
@@ -11,10 +10,11 @@
11
10
  *
12
11
  * @module
13
12
  */
14
- export * as Documents from './Documents';
15
- export * as Templates from './Templates';
13
+ export * as Envelopes from './Envelopes';
16
14
  export * as Organizations from './Organizations';
17
15
  export * as Search from './Search';
16
+ export * as Sessions from './Sessions';
17
+ export * as Templates from './Templates';
18
18
  export * as Users from './Users';
19
19
  export * as Utils from './Utils';
20
20
  export * from './VerdocsEndpoint';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdocs/js-sdk",
3
- "version": "2.1.0",
3
+ "version": "3.0.0",
4
4
  "private": false,
5
5
  "homepage": "https://github.com/Verdocs/js-sdk",
6
6
  "description": "Verdocs JS SDK",
@@ -1,109 +0,0 @@
1
- import { ICreateDocumentRequest, IDocumentsSearchResult, ISigningSessionRequest } from './Types';
2
- import { IDocument, IDocumentsSummary, IRecipient, ISigningSession } from './Types';
3
- import { TDocumentUpdateResult, IDocumentFieldSettings } from './Types';
4
- import { VerdocsEndpoint } from '../VerdocsEndpoint';
5
- /**
6
- * Create a document
7
- *
8
- * ```typescript
9
- * import {Documents, ICreateDocumentRole, ICreateDocumentRequest} from '@verdocs/js-sdk/Documents';
10
- *
11
- * const role1: ICreateDocumentRole = {
12
- * type: 'signer',
13
- * name: 'Seller',
14
- * full_name: 'Paige Turner',
15
- * email: 'paige.turner@nomail.com',
16
- * phone: '',
17
- * sequence: 1,
18
- * delegator: false,
19
- * message: '',
20
- * };
21
- *
22
- * const role2: ICreateDocumentRole = {
23
- * type: 'signer',
24
- * name: 'Buyer',
25
- * full_name: 'Will Power',
26
- * email: 'will.power@nomail.com',
27
- * phone: '',
28
- * sequence: 2,
29
- * delegator: false,
30
- * message: '',
31
- * };
32
- *
33
- * const request: ICreateDocumentRequest = {template_id: 'd2338742-f3a1-465b-8592-806587413cc1', name: 'Bill of Sale', roles: [role1, role2]};
34
- * const {id, recipients} = await Documents.createDocument(VerdocsEndpoint.getDefault(), request);
35
- * ```
36
- */
37
- export declare const createDocument: (endpoint: VerdocsEndpoint, request: ICreateDocumentRequest) => Promise<IDocument>;
38
- /**
39
- * Get a summary of currently active documents.
40
- *
41
- * ```typescript
42
- * import {Documents} from '@verdocs/js-sdk/Documents';
43
- *
44
- * const {action_required, completed, waiting_on_others} = await Documents.getSummary(VerdocsEndpoint.getDefault());
45
- * ```
46
- */
47
- export declare const getSummary: (endpoint: VerdocsEndpoint, page: number) => Promise<IDocumentsSummary>;
48
- /**
49
- * Search for documents matching various criteria.
50
- *
51
- * ```typescript
52
- * import {Documents} from '@verdocs/js-sdk/Documents';
53
- *
54
- * const {result, page, total} = await Documents.search(VerdocsEndpoint.getDefault(), { ... });
55
- * ```
56
- */
57
- export declare const searchDocuments: (endpoint: VerdocsEndpoint, params: any) => Promise<IDocumentsSearchResult>;
58
- export interface ISigningSessionResult {
59
- recipient: IRecipient;
60
- session: ISigningSession;
61
- signerToken: string;
62
- }
63
- /**
64
- * Get a signing session for a Document.
65
- */
66
- export declare const getSigningSession: (endpoint: VerdocsEndpoint, params: ISigningSessionRequest) => Promise<ISigningSessionResult>;
67
- /**
68
- * Get the list of recipients for a Document.
69
- */
70
- export declare const getDocumentRecipients: (endpoint: VerdocsEndpoint, documentId: string) => Promise<IRecipient[]>;
71
- /**
72
- * Get all metadata for a Document.
73
- */
74
- export declare const getDocument: (endpoint: VerdocsEndpoint, documentId: string) => Promise<IDocument>;
75
- /**
76
- * Cancel a Document.
77
- */
78
- export declare const cancelDocument: (endpoint: VerdocsEndpoint, documentId: string) => Promise<TDocumentUpdateResult>;
79
- /**
80
- * Returns true if the recipient has a pending action. Note that this does not necessarily mean the recipient can act (yet).
81
- */
82
- export declare const recipientHasAction: (recipient: IRecipient) => boolean;
83
- /**
84
- * Returns the recipients who still have a pending action. Note that not all of these recipients may be able to act (yet).
85
- */
86
- export declare const getRecipientsWithActions: (document: IDocument) => IRecipient[];
87
- /**
88
- * Returns true if the recipient can act.
89
- */
90
- export declare const recipientCanAct: (recipient: IRecipient, recipientsWithActions: IRecipient[]) => boolean;
91
- /**
92
- * Returns true if the user can act.
93
- */
94
- export declare const userCanAct: (email: string, recipientsWithActions: IRecipient[]) => boolean | undefined;
95
- /**
96
- * Get (binary download) a file attached to a Document. It is important to use this method
97
- * rather than a direct A HREF or similar link to set the authorization headers for the
98
- * request.
99
- */
100
- export declare const getDocumentFile: (endpoint: VerdocsEndpoint, documentId: string, envelopeDocumentId: string) => Promise<string>;
101
- /**
102
- * Update a Document field. Typically called during the signing process as a Recipient fills in fields.
103
- */
104
- export declare const updateDocumentField: (endpoint: VerdocsEndpoint, documentId: string, fieldName: string, value: any) => Promise<IDocumentFieldSettings>;
105
- /**
106
- * Update a Document signature field. Signature fields are ID-driven. Call `Document.createSignature()` first to create a
107
- * signature for a Recipient, then call `Documents.updateDocumentFieldSignature()` to attach it to a field.
108
- */
109
- export declare const updateDocumentFieldSignature: (endpoint: VerdocsEndpoint, documentId: string, fieldName: string, signatureId: string) => Promise<IDocumentFieldSettings>;