@assinafy/cli 2.7.1 → 2.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +2 -0
- package/README.en.md +75 -67
- package/README.md +39 -25
- package/THIRD_PARTY_NOTICES.md +8 -8
- package/dist/api.cjs +701 -93
- package/dist/api.cjs.map +1 -1
- package/dist/api.js +696 -93
- package/dist/api.js.map +1 -1
- package/dist/cli.cjs +2390 -694
- package/dist/types/api/client.d.ts +7 -0
- package/dist/types/api/client.d.ts.map +1 -1
- package/dist/types/api/envelope-types.d.ts +73 -0
- package/dist/types/api/envelope-types.d.ts.map +1 -0
- package/dist/types/api/index.d.ts +4 -0
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/resources/assignments.d.ts +7 -1
- package/dist/types/api/resources/assignments.d.ts.map +1 -1
- package/dist/types/api/resources/contracts.d.ts +3 -1
- package/dist/types/api/resources/contracts.d.ts.map +1 -1
- package/dist/types/api/resources/documents.d.ts +25 -6
- package/dist/types/api/resources/documents.d.ts.map +1 -1
- package/dist/types/api/resources/embed.d.ts +14 -0
- package/dist/types/api/resources/embed.d.ts.map +1 -0
- package/dist/types/api/resources/envelopes.d.ts +37 -0
- package/dist/types/api/resources/envelopes.d.ts.map +1 -0
- package/dist/types/api/resources/scheduled-sends.d.ts +11 -0
- package/dist/types/api/resources/scheduled-sends.d.ts.map +1 -0
- package/dist/types/api/resources/signer-documents.d.ts +23 -11
- package/dist/types/api/resources/signer-documents.d.ts.map +1 -1
- package/dist/types/api/resources/signers.d.ts +1 -1
- package/dist/types/api/resources/signers.d.ts.map +1 -1
- package/dist/types/api/resources/users.d.ts +3 -1
- package/dist/types/api/resources/users.d.ts.map +1 -1
- package/dist/types/api/resources/webhooks.d.ts +6 -2
- package/dist/types/api/resources/webhooks.d.ts.map +1 -1
- package/dist/types/api/resources/workspaces.d.ts +9 -2
- package/dist/types/api/resources/workspaces.d.ts.map +1 -1
- package/dist/types/api/types.d.ts +138 -8
- package/dist/types/api/types.d.ts.map +1 -1
- package/dist/types/api/utils.d.ts +9 -0
- package/dist/types/api/utils.d.ts.map +1 -1
- package/docs/README.md +5 -1
- package/docs/api-operations-staging.json +1262 -0
- package/docs/api-operations.json +234 -2
- package/docs/api-reference-staging.md +18466 -0
- package/docs/api-reference.md +11562 -3718
- package/docs/assignments.md +62 -14
- package/docs/contracts.md +4 -3
- package/docs/documents.md +75 -27
- package/docs/embed.md +119 -0
- package/docs/envelopes.md +239 -0
- package/docs/scheduled-sends.md +63 -0
- package/docs/sdk-reference.md +278 -30
- package/docs/send.md +15 -11
- package/docs/signer.md +84 -3
- package/docs/users.md +41 -0
- package/docs/webhooks.md +22 -6
- package/docs/workspaces.md +66 -3
- package/install.ps1 +1 -1
- package/install.sh +1 -1
- package/package.json +4 -4
package/dist/api.js
CHANGED
|
@@ -86,7 +86,62 @@ var PartialWorkflowError = class extends AssinafyError {
|
|
|
86
86
|
};
|
|
87
87
|
|
|
88
88
|
// src/api/utils.ts
|
|
89
|
+
import { validateHeaderValue } from "http";
|
|
89
90
|
import axios from "axios";
|
|
91
|
+
|
|
92
|
+
// src/api/types.ts
|
|
93
|
+
var SIGNER_CAPACITIES = [
|
|
94
|
+
"Sign",
|
|
95
|
+
"Approve",
|
|
96
|
+
"Acknowledge",
|
|
97
|
+
"Party",
|
|
98
|
+
"Witness",
|
|
99
|
+
"Intervening",
|
|
100
|
+
"Receipt",
|
|
101
|
+
"IssuerEndorserGuarantor",
|
|
102
|
+
"IssuerEndorserGuarantorSurety",
|
|
103
|
+
"Surety",
|
|
104
|
+
"PartySurety",
|
|
105
|
+
"JointDebtor",
|
|
106
|
+
"PartyJointDebtor",
|
|
107
|
+
"ContractingParty",
|
|
108
|
+
"ContractedParty",
|
|
109
|
+
"Landlord",
|
|
110
|
+
"Tenant",
|
|
111
|
+
"Buyer",
|
|
112
|
+
"Seller",
|
|
113
|
+
"AttorneyInFact",
|
|
114
|
+
"LegalRepresentative",
|
|
115
|
+
"Employer",
|
|
116
|
+
"Employee"
|
|
117
|
+
];
|
|
118
|
+
var PUSH_PREFERENCE_CODES = [
|
|
119
|
+
"SignerViewed",
|
|
120
|
+
"SignerSigned",
|
|
121
|
+
"DocumentCompleted",
|
|
122
|
+
"SignerDeclined",
|
|
123
|
+
"DocumentAboutToExpire",
|
|
124
|
+
"DocumentExpired",
|
|
125
|
+
"SignerIdentityReviewRequired",
|
|
126
|
+
"SignerWhatsappFailed"
|
|
127
|
+
];
|
|
128
|
+
var NOTIFICATION_PREFERENCE_CODES = [
|
|
129
|
+
"DocumentCompleted",
|
|
130
|
+
"SignerDeclined",
|
|
131
|
+
"DocumentCancelled",
|
|
132
|
+
"DocumentAboutToExpire",
|
|
133
|
+
"DocumentExpired",
|
|
134
|
+
"DocumentExpirationReset",
|
|
135
|
+
"DocumentProcessingFailed",
|
|
136
|
+
"TemplateProcessingFailed",
|
|
137
|
+
"SignerWhatsappFailed",
|
|
138
|
+
"ContractRenewalNotice",
|
|
139
|
+
"ContractExpiring",
|
|
140
|
+
"ContractExpired",
|
|
141
|
+
"ContractRenewed"
|
|
142
|
+
];
|
|
143
|
+
|
|
144
|
+
// src/api/utils.ts
|
|
90
145
|
var DOCUMENT_ARTIFACT_NAMES = [
|
|
91
146
|
"original",
|
|
92
147
|
"certificated",
|
|
@@ -197,6 +252,16 @@ function requireExpiration(value, name = "expires_at") {
|
|
|
197
252
|
requireIso8601(timestamp, name);
|
|
198
253
|
return value;
|
|
199
254
|
}
|
|
255
|
+
function requireScheduledTime(value, name = "send_at") {
|
|
256
|
+
if (typeof value === "number") {
|
|
257
|
+
if (!Number.isSafeInteger(value))
|
|
258
|
+
throw new ValidationError(`${name} must be an integer Unix time`);
|
|
259
|
+
} else if (typeof value === "string") {
|
|
260
|
+
requireExpiration(value, name);
|
|
261
|
+
} else {
|
|
262
|
+
throw new ValidationError(`${name} must be an ISO 8601 time or integer Unix time`);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
200
265
|
function requireEmail(value) {
|
|
201
266
|
if (!value || !EMAIL_RE.test(value)) {
|
|
202
267
|
throw new ValidationError("Invalid email address", { email: value });
|
|
@@ -204,6 +269,15 @@ function requireEmail(value) {
|
|
|
204
269
|
return value;
|
|
205
270
|
}
|
|
206
271
|
function validateSignerOptions(input) {
|
|
272
|
+
if (input.sign_as != null && !SIGNER_CAPACITIES.includes(input.sign_as)) {
|
|
273
|
+
throw new ValidationError("sign_as must be a published signer capacity or null");
|
|
274
|
+
}
|
|
275
|
+
if (input.embedded !== void 0 && typeof input.embedded !== "boolean") {
|
|
276
|
+
throw new ValidationError("embedded must be a boolean");
|
|
277
|
+
}
|
|
278
|
+
if (input.embedded === true && input.verification_method !== void 0 && !["Email", "Whatsapp"].includes(input.verification_method)) {
|
|
279
|
+
throw new ValidationError("Embedded signing requires Email or Whatsapp verification");
|
|
280
|
+
}
|
|
207
281
|
if (input.verification_method !== void 0 && !VERIFICATION_METHODS.includes(input.verification_method)) {
|
|
208
282
|
throw new ValidationError(
|
|
209
283
|
`verification_method must be one of: ${VERIFICATION_METHODS.join(", ")}`
|
|
@@ -230,6 +304,33 @@ function validateSignerOptions(input) {
|
|
|
230
304
|
throw new ValidationError("step must be an integer");
|
|
231
305
|
}
|
|
232
306
|
}
|
|
307
|
+
function validateCreditCeiling(value) {
|
|
308
|
+
if (value !== void 0 && (typeof value !== "number" || !Number.isFinite(value) || value < 0)) {
|
|
309
|
+
throw new ValidationError("max_total_credits must be a finite non-negative number");
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
function idempotencyHeaders(key) {
|
|
313
|
+
if (key === void 0) return void 0;
|
|
314
|
+
if (typeof key !== "string" || !key.trim()) {
|
|
315
|
+
throw new ValidationError("idempotencyKey must be nonblank text");
|
|
316
|
+
}
|
|
317
|
+
try {
|
|
318
|
+
validateHeaderValue("Idempotency-Key", key);
|
|
319
|
+
} catch {
|
|
320
|
+
throw new ValidationError("idempotencyKey must be a valid HTTP header value");
|
|
321
|
+
}
|
|
322
|
+
return { "Idempotency-Key": key };
|
|
323
|
+
}
|
|
324
|
+
function validateBooleanMap(payload, allowed) {
|
|
325
|
+
if (!payload || typeof payload !== "object" || Array.isArray(payload) || !Object.keys(payload).length) {
|
|
326
|
+
throw new ValidationError("At least one notification preference is required");
|
|
327
|
+
}
|
|
328
|
+
for (const [key, value] of Object.entries(payload)) {
|
|
329
|
+
if (!allowed.includes(key))
|
|
330
|
+
throw new ValidationError(`Unknown notification preference: ${key}`);
|
|
331
|
+
if (typeof value !== "boolean") throw new ValidationError(`${key} must be a boolean`);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
233
334
|
function validateDigitalCertificateMethod(method, signers) {
|
|
234
335
|
if (method !== "virtual" && signers.some((signer) => signer.verification_method === "DigitalCertificate")) {
|
|
235
336
|
throw new ValidationError("DigitalCertificate signers require method: virtual", {
|
|
@@ -369,7 +470,7 @@ var BaseResource = class {
|
|
|
369
470
|
}
|
|
370
471
|
};
|
|
371
472
|
function safeIdentifier(value, name) {
|
|
372
|
-
if (value === "." || value === ".." || /[\s/?#\\%]/.test(value)) {
|
|
473
|
+
if (typeof value !== "string" || value === "." || value === ".." || /[\s/?#\\%]/.test(value)) {
|
|
373
474
|
throw new ValidationError(`${name} contains invalid URL characters`);
|
|
374
475
|
}
|
|
375
476
|
return value;
|
|
@@ -404,10 +505,15 @@ function toInt(value) {
|
|
|
404
505
|
|
|
405
506
|
// src/api/resources/assignments.ts
|
|
406
507
|
function buildAssignmentPayload(payload, options = {}) {
|
|
508
|
+
if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
|
|
509
|
+
throw new ValidationError("Assignment payload must be an object");
|
|
510
|
+
}
|
|
407
511
|
if (payload.method !== void 0 && payload.method !== "virtual" && payload.method !== "collect") {
|
|
408
512
|
throw new ValidationError("method must be virtual or collect");
|
|
409
513
|
}
|
|
410
514
|
const signers = extractSignerRefs(payload);
|
|
515
|
+
validateCreditCeiling(payload.max_total_credits);
|
|
516
|
+
if (payload.expires_at != null) requireScheduledTime(payload.expires_at, "expires_at");
|
|
411
517
|
if (signers.length === 0) {
|
|
412
518
|
throw new ValidationError("At least one signer is required", {
|
|
413
519
|
signers: payload.signers ?? payload.signer_ids ?? payload.signerIds
|
|
@@ -422,14 +528,17 @@ function buildAssignmentPayload(payload, options = {}) {
|
|
|
422
528
|
if (!options.skipDigitalCertificateStepValidation) {
|
|
423
529
|
validateSigningSteps(normalisedSigners);
|
|
424
530
|
}
|
|
425
|
-
return
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
531
|
+
return Object.fromEntries(
|
|
532
|
+
Object.entries({
|
|
533
|
+
method,
|
|
534
|
+
signers: normalisedSigners,
|
|
535
|
+
message: payload.message,
|
|
536
|
+
expires_at: payload.expires_at,
|
|
537
|
+
copy_receivers: payload.copy_receivers,
|
|
538
|
+
entries: payload.entries,
|
|
539
|
+
max_total_credits: payload.max_total_credits
|
|
540
|
+
}).filter(([, value]) => value !== void 0)
|
|
541
|
+
);
|
|
433
542
|
}
|
|
434
543
|
function extractSignerRefs(payload) {
|
|
435
544
|
const populatedAliases = [payload.signers, payload.signer_ids, payload.signerIds].filter(
|
|
@@ -446,20 +555,24 @@ function extractSignerRefs(payload) {
|
|
|
446
555
|
}
|
|
447
556
|
function normaliseSignerRef(ref, options) {
|
|
448
557
|
if (typeof ref === "string") {
|
|
449
|
-
if (!ref) throw new ValidationError("Signer ID cannot be empty");
|
|
558
|
+
if (!ref.trim()) throw new ValidationError("Signer ID cannot be empty");
|
|
450
559
|
return { id: ref };
|
|
451
560
|
}
|
|
452
561
|
if (ref && typeof ref === "object") {
|
|
453
562
|
const input = ref;
|
|
454
563
|
const id = input.id ?? input.signer_id;
|
|
455
564
|
validateSignerOptions(input);
|
|
456
|
-
const normalised =
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
565
|
+
const normalised = Object.fromEntries(
|
|
566
|
+
Object.entries({
|
|
567
|
+
id,
|
|
568
|
+
sign_as: input.sign_as,
|
|
569
|
+
verification_method: input.verification_method,
|
|
570
|
+
notification_methods: input.notification_methods,
|
|
571
|
+
step: input.step,
|
|
572
|
+
embedded: input.embedded
|
|
573
|
+
}).filter(([, value]) => value !== void 0)
|
|
574
|
+
);
|
|
575
|
+
if (typeof id === "string" && id.trim().length > 0) {
|
|
463
576
|
return normalised;
|
|
464
577
|
}
|
|
465
578
|
if (options.allowSignersWithoutId && Object.keys(normalised).length > 0) {
|
|
@@ -472,6 +585,30 @@ function normaliseSignerRef(ref, options) {
|
|
|
472
585
|
throw new ValidationError("Invalid signer reference", { ref });
|
|
473
586
|
}
|
|
474
587
|
var AssignmentResource = class extends BaseResource {
|
|
588
|
+
/** Keep a request for later; no invitation or charge until the server sends it (staging). */
|
|
589
|
+
async schedule(documentId, payload) {
|
|
590
|
+
const id = this.requireId(documentId, "Document ID");
|
|
591
|
+
requireScheduledTime(payload?.send_at);
|
|
592
|
+
const body = { ...buildAssignmentPayload(payload), send_at: payload.send_at };
|
|
593
|
+
return this.call(
|
|
594
|
+
"Failed to schedule assignment",
|
|
595
|
+
() => this.http.post(`/documents/${id}/scheduled-sends`, body)
|
|
596
|
+
);
|
|
597
|
+
}
|
|
598
|
+
async signerCapacities(documentId) {
|
|
599
|
+
const id = this.requireId(documentId, "Document ID");
|
|
600
|
+
return this.call(
|
|
601
|
+
"Failed to fetch signer capacities",
|
|
602
|
+
() => this.http.get(`/documents/${id}/signer-capacities`)
|
|
603
|
+
);
|
|
604
|
+
}
|
|
605
|
+
async notificationHistory(documentId) {
|
|
606
|
+
const id = this.requireId(documentId, "Document ID");
|
|
607
|
+
return this.call(
|
|
608
|
+
"Failed to fetch notification history",
|
|
609
|
+
() => this.http.get(`/documents/${id}/notification-history`)
|
|
610
|
+
);
|
|
611
|
+
}
|
|
475
612
|
/** Fetch an account review and available evidence for a signer's identity verification. */
|
|
476
613
|
async getIdentityVerification(documentId, assignmentId, signerId) {
|
|
477
614
|
const docId = this.requireId(documentId, "Document ID");
|
|
@@ -809,12 +946,14 @@ var ContractResource = class extends BaseResource {
|
|
|
809
946
|
);
|
|
810
947
|
}
|
|
811
948
|
/** Read the root contract and its amendments from any document in that family. */
|
|
812
|
-
async related(documentId, accountId) {
|
|
949
|
+
async related(documentId, accountId, params = {}) {
|
|
813
950
|
const id = this.accountId(accountId);
|
|
814
951
|
const did = this.requireId(documentId, "Document ID");
|
|
815
952
|
return this.call(
|
|
816
953
|
"Failed to get related contracts",
|
|
817
|
-
() => this.http.get(`/accounts/${id}/documents/${did}/contract/related
|
|
954
|
+
() => this.http.get(`/accounts/${id}/documents/${did}/contract/related`, {
|
|
955
|
+
params: cleanParams(params)
|
|
956
|
+
})
|
|
818
957
|
);
|
|
819
958
|
}
|
|
820
959
|
/** Advance from the supplied current term or to a later end date. No automatic retry. */
|
|
@@ -933,6 +1072,25 @@ var FAILED_STATUSES = /* @__PURE__ */ new Set([
|
|
|
933
1072
|
"expired"
|
|
934
1073
|
]);
|
|
935
1074
|
var DocumentResource = class extends BaseResource {
|
|
1075
|
+
/** Read contacts who receive a completion email without document access (staging). */
|
|
1076
|
+
async listWatchers(documentId) {
|
|
1077
|
+
const id = this.requireId(documentId, "Document ID");
|
|
1078
|
+
return this.call(
|
|
1079
|
+
"Failed to list document watchers",
|
|
1080
|
+
() => this.http.get(`/documents/${id}/watchers`)
|
|
1081
|
+
);
|
|
1082
|
+
}
|
|
1083
|
+
/** Replace all watchers; an empty list clears them. Owner credentials required (staging). */
|
|
1084
|
+
async setWatchers(documentId, watcherIds) {
|
|
1085
|
+
const id = this.requireId(documentId, "Document ID");
|
|
1086
|
+
if (!Array.isArray(watcherIds) || new Set(watcherIds).size > 10 || watcherIds.some((value) => typeof value !== "string" || !value.trim())) {
|
|
1087
|
+
throw new ValidationError("watcher_ids must contain at most 10 nonblank contact IDs");
|
|
1088
|
+
}
|
|
1089
|
+
return this.call(
|
|
1090
|
+
"Failed to set document watchers",
|
|
1091
|
+
() => this.http.put(`/documents/${id}/watchers`, { watcher_ids: watcherIds })
|
|
1092
|
+
);
|
|
1093
|
+
}
|
|
936
1094
|
/**
|
|
937
1095
|
* Upload a PDF to the workspace.
|
|
938
1096
|
*
|
|
@@ -995,9 +1153,9 @@ var DocumentResource = class extends BaseResource {
|
|
|
995
1153
|
);
|
|
996
1154
|
}
|
|
997
1155
|
/** Get document details. */
|
|
998
|
-
async details(documentId) {
|
|
1156
|
+
async details(documentId, params = {}) {
|
|
999
1157
|
const id = this.requireId(documentId, "Document ID");
|
|
1000
|
-
return this.fetchDetails(id);
|
|
1158
|
+
return this.fetchDetails(id, void 0, params);
|
|
1001
1159
|
}
|
|
1002
1160
|
/**
|
|
1003
1161
|
* Rename a document (`PATCH /documents/{id}`).
|
|
@@ -1014,8 +1172,17 @@ var DocumentResource = class extends BaseResource {
|
|
|
1014
1172
|
);
|
|
1015
1173
|
}
|
|
1016
1174
|
/** Alias for {@link details}. */
|
|
1017
|
-
async get(documentId) {
|
|
1018
|
-
return this.details(documentId);
|
|
1175
|
+
async get(documentId, params = {}) {
|
|
1176
|
+
return this.details(documentId, params);
|
|
1177
|
+
}
|
|
1178
|
+
/** Read only the assignment items visible to this signer. */
|
|
1179
|
+
async getAsSigner(documentId, signerAccessCode) {
|
|
1180
|
+
const id = this.requireId(documentId, "Document ID");
|
|
1181
|
+
const code = this.requireId(signerAccessCode, "signer-access-code");
|
|
1182
|
+
return this.call(
|
|
1183
|
+
"Failed to fetch signer document",
|
|
1184
|
+
() => this.http.get(`/documents/${id}`, signerAccessConfig(code))
|
|
1185
|
+
);
|
|
1019
1186
|
}
|
|
1020
1187
|
/** Poll document status until ready (or a terminal status / timeout). */
|
|
1021
1188
|
async waitUntilReady(documentId, options = {}) {
|
|
@@ -1062,42 +1229,57 @@ var DocumentResource = class extends BaseResource {
|
|
|
1062
1229
|
attempts
|
|
1063
1230
|
});
|
|
1064
1231
|
}
|
|
1065
|
-
fetchDetails(documentId, timeout) {
|
|
1232
|
+
fetchDetails(documentId, timeout, params) {
|
|
1066
1233
|
return this.call(
|
|
1067
1234
|
"Failed to fetch document details",
|
|
1068
|
-
() => this.http.get(`/documents/${documentId}`, timeout
|
|
1235
|
+
() => this.http.get(`/documents/${documentId}`, { timeout, ...params?.expand ? { params } : {} })
|
|
1069
1236
|
);
|
|
1070
1237
|
}
|
|
1071
1238
|
/** Download a document artifact. Defaults to the certificated (signed) PDF. */
|
|
1072
|
-
async download(documentId, artifactName = "certificated") {
|
|
1239
|
+
async download(documentId, artifactName = "certificated", options = {}) {
|
|
1073
1240
|
const id = this.requireId(documentId, "Document ID");
|
|
1074
1241
|
const artifact = requireDocumentArtifactName(artifactName);
|
|
1242
|
+
const config = this.artifactConfig(options);
|
|
1075
1243
|
return this.callBinary(
|
|
1076
1244
|
"Failed to download document",
|
|
1077
1245
|
() => this.http.get(`/documents/${id}/download/${artifact}`, {
|
|
1246
|
+
...config,
|
|
1078
1247
|
responseType: "arraybuffer"
|
|
1079
1248
|
})
|
|
1080
1249
|
);
|
|
1081
1250
|
}
|
|
1082
1251
|
/** Download the document thumbnail. */
|
|
1083
|
-
async thumbnail(documentId) {
|
|
1252
|
+
async thumbnail(documentId, options = {}) {
|
|
1253
|
+
const config = this.artifactConfig(options);
|
|
1084
1254
|
const id = this.requireId(documentId, "Document ID");
|
|
1085
1255
|
return this.callBinary(
|
|
1086
1256
|
"Failed to download document thumbnail",
|
|
1087
|
-
() => this.http.get(`/documents/${id}/thumbnail`, {
|
|
1257
|
+
() => this.http.get(`/documents/${id}/thumbnail`, {
|
|
1258
|
+
...config,
|
|
1259
|
+
responseType: "arraybuffer"
|
|
1260
|
+
})
|
|
1088
1261
|
);
|
|
1089
1262
|
}
|
|
1090
1263
|
/** Download a single page as a JPEG. */
|
|
1091
|
-
async downloadPage(documentId, pageId) {
|
|
1264
|
+
async downloadPage(documentId, pageId, options = {}) {
|
|
1265
|
+
const config = this.artifactConfig(options);
|
|
1092
1266
|
const docId = this.requireId(documentId, "Document ID");
|
|
1093
1267
|
const pid = this.requireId(pageId, "Page ID");
|
|
1094
1268
|
return this.callBinary(
|
|
1095
1269
|
"Failed to download page",
|
|
1096
1270
|
() => this.http.get(`/documents/${docId}/pages/${pid}/download`, {
|
|
1271
|
+
...config,
|
|
1097
1272
|
responseType: "arraybuffer"
|
|
1098
1273
|
})
|
|
1099
1274
|
);
|
|
1100
1275
|
}
|
|
1276
|
+
artifactConfig(options) {
|
|
1277
|
+
if (options.artifact !== void 0 && options.artifact !== "certificated") {
|
|
1278
|
+
throw new ValidationError("artifact must be certificated");
|
|
1279
|
+
}
|
|
1280
|
+
const params = options.artifact === void 0 ? {} : { artifact: options.artifact };
|
|
1281
|
+
return options.signerAccessCode === void 0 ? { params } : signerAccessConfig(this.requireId(options.signerAccessCode, "signer-access-code"), params);
|
|
1282
|
+
}
|
|
1101
1283
|
/** Fetch one page of the document activity log (20 entries by default). */
|
|
1102
1284
|
async activities(documentId, params = {}) {
|
|
1103
1285
|
const id = this.requireId(documentId, "Document ID");
|
|
@@ -1171,6 +1353,9 @@ var DocumentResource = class extends BaseResource {
|
|
|
1171
1353
|
const tmplId = this.requireId(templateId, "Template ID");
|
|
1172
1354
|
const accId = this.accountId(accountId);
|
|
1173
1355
|
validateTemplateSigners(signers, { requireIdentity: true });
|
|
1356
|
+
validateCreditCeiling(options.max_total_credits);
|
|
1357
|
+
const { idempotencyKey, ...bodyOptions } = options;
|
|
1358
|
+
const headers = idempotencyHeaders(idempotencyKey);
|
|
1174
1359
|
if (options.expires_at !== void 0) requireExpiration(options.expires_at);
|
|
1175
1360
|
if (options.editor_fields !== void 0 && (!Array.isArray(options.editor_fields) || options.editor_fields.some((field) => !field?.field_id || typeof field.value !== "string"))) {
|
|
1176
1361
|
throw new ValidationError("editor_fields must contain field_id and value");
|
|
@@ -1179,11 +1364,11 @@ var DocumentResource = class extends BaseResource {
|
|
|
1179
1364
|
throw new ValidationError("tags must contain non-empty tag names");
|
|
1180
1365
|
}
|
|
1181
1366
|
await this.validateCertificateTemplateMethod(tmplId, accId, signers);
|
|
1182
|
-
const body = { ...
|
|
1367
|
+
const body = { ...bodyOptions, signers };
|
|
1183
1368
|
this.logger.info("Creating document from template", { templateId: tmplId, accountId: accId });
|
|
1184
1369
|
return this.call(
|
|
1185
1370
|
"Failed to create document from template",
|
|
1186
|
-
() => this.http.post(`/accounts/${accId}/templates/${tmplId}/documents`, body)
|
|
1371
|
+
() => this.http.post(`/accounts/${accId}/templates/${tmplId}/documents`, body, { headers })
|
|
1187
1372
|
);
|
|
1188
1373
|
}
|
|
1189
1374
|
/** Estimate the credit cost of creating a document from a template. */
|
|
@@ -1362,6 +1547,285 @@ function sleep(ms) {
|
|
|
1362
1547
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
1363
1548
|
}
|
|
1364
1549
|
|
|
1550
|
+
// src/api/resources/embed.ts
|
|
1551
|
+
var EmbedResource = class extends BaseResource {
|
|
1552
|
+
async listOrigins(accountId) {
|
|
1553
|
+
const id = this.accountId(accountId);
|
|
1554
|
+
return this.call(
|
|
1555
|
+
"Failed to list embed origins",
|
|
1556
|
+
() => this.http.get(`/accounts/${id}/embed-origins`)
|
|
1557
|
+
);
|
|
1558
|
+
}
|
|
1559
|
+
async createOrigin(origin, accountId) {
|
|
1560
|
+
const id = this.accountId(accountId);
|
|
1561
|
+
validateOrigin(origin);
|
|
1562
|
+
return this.call(
|
|
1563
|
+
"Failed to add embed origin",
|
|
1564
|
+
() => this.http.post(`/accounts/${id}/embed-origins`, { origin })
|
|
1565
|
+
);
|
|
1566
|
+
}
|
|
1567
|
+
async updateOrigin(originId, origin, accountId) {
|
|
1568
|
+
const id = this.accountId(accountId);
|
|
1569
|
+
const oid = this.requireId(originId, "Origin ID");
|
|
1570
|
+
validateOrigin(origin);
|
|
1571
|
+
return this.call(
|
|
1572
|
+
"Failed to update embed origin",
|
|
1573
|
+
() => this.http.put(`/accounts/${id}/embed-origins/${oid}`, { origin })
|
|
1574
|
+
);
|
|
1575
|
+
}
|
|
1576
|
+
async deleteOrigin(originId, accountId) {
|
|
1577
|
+
const id = this.accountId(accountId);
|
|
1578
|
+
const oid = this.requireId(originId, "Origin ID");
|
|
1579
|
+
return this.call(
|
|
1580
|
+
"Failed to delete embed origin",
|
|
1581
|
+
() => this.http.delete(`/accounts/${id}/embed-origins/${oid}`)
|
|
1582
|
+
);
|
|
1583
|
+
}
|
|
1584
|
+
/** Load the returned private URL in the iframe within five minutes. */
|
|
1585
|
+
async createSession(documentId, assignmentId, signerId) {
|
|
1586
|
+
const did = this.requireId(documentId, "Document ID");
|
|
1587
|
+
const aid = this.requireId(assignmentId, "Assignment ID");
|
|
1588
|
+
const sid = this.requireId(signerId, "Signer ID");
|
|
1589
|
+
return this.call(
|
|
1590
|
+
"Failed to create embed session",
|
|
1591
|
+
() => this.http.post(`/documents/${did}/assignments/${aid}/signers/${sid}/embed-sessions`)
|
|
1592
|
+
);
|
|
1593
|
+
}
|
|
1594
|
+
/** Used by Assinafy's embed page; consumes the token even on a 409. Never retry automatically. */
|
|
1595
|
+
async exchangeSession(token, parentOrigin) {
|
|
1596
|
+
const value = this.requireId(token, "Embed session token");
|
|
1597
|
+
if (parentOrigin !== void 0) validateOrigin(parentOrigin);
|
|
1598
|
+
return this.call(
|
|
1599
|
+
"Failed to exchange embed session",
|
|
1600
|
+
() => this.http.post(
|
|
1601
|
+
`/embed/sessions/${value}/exchange`,
|
|
1602
|
+
parentOrigin === void 0 ? void 0 : { parent_origin: parentOrigin },
|
|
1603
|
+
publicRequestConfig()
|
|
1604
|
+
)
|
|
1605
|
+
);
|
|
1606
|
+
}
|
|
1607
|
+
};
|
|
1608
|
+
function validateOrigin(value) {
|
|
1609
|
+
let url;
|
|
1610
|
+
try {
|
|
1611
|
+
url = new URL(value);
|
|
1612
|
+
} catch {
|
|
1613
|
+
throw new ValidationError("origin must be an absolute origin");
|
|
1614
|
+
}
|
|
1615
|
+
if (typeof value !== "string" || /[\s\\?#*]/.test(value) || !/^[a-z][a-z\d+.-]*:\/\/[^/]+\/?$/i.test(value) || url.username || url.password || url.pathname !== "/" || url.protocol !== "https:" && !(url.protocol === "http:" && ["localhost", "127.0.0.1"].includes(url.hostname))) {
|
|
1616
|
+
throw new ValidationError(
|
|
1617
|
+
"origin must use HTTPS (HTTP only for localhost or 127.0.0.1) without path, credentials, query, fragment or wildcard"
|
|
1618
|
+
);
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
|
|
1622
|
+
// src/api/resources/envelopes.ts
|
|
1623
|
+
var EnvelopeResource = class extends BaseResource {
|
|
1624
|
+
/** Schedule one envelope request; idempotency headers are not supported here (staging). */
|
|
1625
|
+
async schedule(payload, accountId) {
|
|
1626
|
+
const id = this.accountId(accountId);
|
|
1627
|
+
validateCreate(payload);
|
|
1628
|
+
requireScheduledTime(payload.send_at);
|
|
1629
|
+
return this.call(
|
|
1630
|
+
"Failed to schedule envelope",
|
|
1631
|
+
() => this.http.post(`/accounts/${id}/scheduled-sends`, payload)
|
|
1632
|
+
);
|
|
1633
|
+
}
|
|
1634
|
+
/** Estimate one reminder for the whole envelope without sending or charging (staging). */
|
|
1635
|
+
async estimateResendCost(envelopeId, signerId, accountId) {
|
|
1636
|
+
const id = this.accountId(accountId);
|
|
1637
|
+
const eid = this.requireId(envelopeId, "Envelope ID");
|
|
1638
|
+
const sid = this.requireId(signerId, "Signer ID");
|
|
1639
|
+
return this.call(
|
|
1640
|
+
"Failed to estimate envelope reminder cost",
|
|
1641
|
+
() => this.http.post(`/accounts/${id}/envelopes/${eid}/signers/${sid}/estimate-resend-cost`)
|
|
1642
|
+
);
|
|
1643
|
+
}
|
|
1644
|
+
async list(params = {}, accountId) {
|
|
1645
|
+
const id = this.accountId(accountId);
|
|
1646
|
+
if (params.status !== void 0 && !["open", "closed"].includes(params.status))
|
|
1647
|
+
throw new ValidationError("status must be open or closed");
|
|
1648
|
+
return this.callList(
|
|
1649
|
+
"Failed to list envelopes",
|
|
1650
|
+
() => this.http.get(`/accounts/${id}/envelopes`, { params: cleanParams({ ...params }) })
|
|
1651
|
+
);
|
|
1652
|
+
}
|
|
1653
|
+
/** Creates assignments and sends invitations; persist the result before checking delivery. */
|
|
1654
|
+
async create(payload, options = {}) {
|
|
1655
|
+
const id = this.accountId(options.accountId);
|
|
1656
|
+
validateCreate(payload);
|
|
1657
|
+
const headers = idempotencyHeaders(options.idempotencyKey);
|
|
1658
|
+
return this.call(
|
|
1659
|
+
"Failed to create envelope",
|
|
1660
|
+
() => this.http.post(`/accounts/${id}/envelopes`, payload, { headers })
|
|
1661
|
+
);
|
|
1662
|
+
}
|
|
1663
|
+
async estimateCost(payload, accountId) {
|
|
1664
|
+
const id = this.accountId(accountId);
|
|
1665
|
+
validateCreate(payload);
|
|
1666
|
+
return this.call(
|
|
1667
|
+
"Failed to estimate envelope cost",
|
|
1668
|
+
() => this.http.post(`/accounts/${id}/envelopes/estimate-cost`, payload)
|
|
1669
|
+
);
|
|
1670
|
+
}
|
|
1671
|
+
async get(envelopeId, accountId) {
|
|
1672
|
+
const id = this.accountId(accountId);
|
|
1673
|
+
const eid = this.requireId(envelopeId, "Envelope ID");
|
|
1674
|
+
return this.call(
|
|
1675
|
+
"Failed to fetch envelope",
|
|
1676
|
+
() => this.http.get(`/accounts/${id}/envelopes/${eid}`)
|
|
1677
|
+
);
|
|
1678
|
+
}
|
|
1679
|
+
/** Renames, changes the message (null clears), or reorders every current document. */
|
|
1680
|
+
async update(envelopeId, payload, accountId) {
|
|
1681
|
+
const id = this.accountId(accountId);
|
|
1682
|
+
const eid = this.requireId(envelopeId, "Envelope ID");
|
|
1683
|
+
if (!payload || !["name", "message", "document_ids"].some(
|
|
1684
|
+
(key) => payload[key] !== void 0
|
|
1685
|
+
))
|
|
1686
|
+
throw new ValidationError("At least one envelope field is required");
|
|
1687
|
+
if (payload.name !== void 0) validateName(payload.name);
|
|
1688
|
+
validateMessage(payload.message);
|
|
1689
|
+
if (payload.document_ids !== void 0) validateIds(payload.document_ids, "document_ids");
|
|
1690
|
+
return this.call(
|
|
1691
|
+
"Failed to update envelope",
|
|
1692
|
+
() => this.http.patch(`/accounts/${id}/envelopes/${eid}`, payload)
|
|
1693
|
+
);
|
|
1694
|
+
}
|
|
1695
|
+
/** Requires a closed envelope; its documents are retained by the server. */
|
|
1696
|
+
async delete(envelopeId, accountId) {
|
|
1697
|
+
const id = this.accountId(accountId);
|
|
1698
|
+
const eid = this.requireId(envelopeId, "Envelope ID");
|
|
1699
|
+
return this.call(
|
|
1700
|
+
"Failed to delete envelope",
|
|
1701
|
+
() => this.http.delete(`/accounts/${id}/envelopes/${eid}`)
|
|
1702
|
+
);
|
|
1703
|
+
}
|
|
1704
|
+
async activities(envelopeId, params = {}, accountId) {
|
|
1705
|
+
const id = this.accountId(accountId);
|
|
1706
|
+
const eid = this.requireId(envelopeId, "Envelope ID");
|
|
1707
|
+
requireSort(params.sort, ["id", "-id"]);
|
|
1708
|
+
return this.callList(
|
|
1709
|
+
"Failed to fetch envelope activities",
|
|
1710
|
+
() => this.http.get(`/accounts/${id}/envelopes/${eid}/activities`, {
|
|
1711
|
+
params: cleanParams({ ...params })
|
|
1712
|
+
})
|
|
1713
|
+
);
|
|
1714
|
+
}
|
|
1715
|
+
/** ZIP containing the requested artifact of each eligible document. */
|
|
1716
|
+
async download(envelopeId, artifactName = "certificated", accountId) {
|
|
1717
|
+
const id = this.accountId(accountId);
|
|
1718
|
+
const eid = this.requireId(envelopeId, "Envelope ID");
|
|
1719
|
+
const artifact = requireDocumentArtifactName(artifactName);
|
|
1720
|
+
return this.callBinary(
|
|
1721
|
+
"Failed to download envelope",
|
|
1722
|
+
() => this.http.get(`/accounts/${id}/envelopes/${eid}/download/${artifact}`, {
|
|
1723
|
+
responseType: "arraybuffer"
|
|
1724
|
+
})
|
|
1725
|
+
);
|
|
1726
|
+
}
|
|
1727
|
+
/** Cancels only cancellable documents and notifies their recipients. */
|
|
1728
|
+
async cancel(envelopeId, accountId) {
|
|
1729
|
+
const id = this.accountId(accountId);
|
|
1730
|
+
const eid = this.requireId(envelopeId, "Envelope ID");
|
|
1731
|
+
return this.call(
|
|
1732
|
+
"Failed to cancel envelope",
|
|
1733
|
+
() => this.http.put(`/accounts/${id}/envelopes/${eid}/cancel`)
|
|
1734
|
+
);
|
|
1735
|
+
}
|
|
1736
|
+
async resendNotification(envelopeId, signerId, accountId) {
|
|
1737
|
+
const id = this.accountId(accountId);
|
|
1738
|
+
const eid = this.requireId(envelopeId, "Envelope ID");
|
|
1739
|
+
const sid = this.requireId(signerId, "Signer ID");
|
|
1740
|
+
return this.call(
|
|
1741
|
+
"Failed to resend envelope notification",
|
|
1742
|
+
() => this.http.put(`/accounts/${id}/envelopes/${eid}/signers/${sid}/resend`)
|
|
1743
|
+
);
|
|
1744
|
+
}
|
|
1745
|
+
/** Adds a processed document for existing envelope signers and sends updated invitations. */
|
|
1746
|
+
async addDocument(envelopeId, payload, accountId) {
|
|
1747
|
+
const id = this.accountId(accountId);
|
|
1748
|
+
const eid = this.requireId(envelopeId, "Envelope ID");
|
|
1749
|
+
validateDocument(payload);
|
|
1750
|
+
validateCreditCeiling(payload.max_total_credits);
|
|
1751
|
+
return this.call(
|
|
1752
|
+
"Failed to add envelope document",
|
|
1753
|
+
() => this.http.post(`/accounts/${id}/envelopes/${eid}/documents`, payload)
|
|
1754
|
+
);
|
|
1755
|
+
}
|
|
1756
|
+
/** Cancels an open document, notifies its recipients, and removes it from the envelope. */
|
|
1757
|
+
async removeDocument(envelopeId, documentId, accountId) {
|
|
1758
|
+
const id = this.accountId(accountId);
|
|
1759
|
+
const eid = this.requireId(envelopeId, "Envelope ID");
|
|
1760
|
+
const did = this.requireId(documentId, "Document ID");
|
|
1761
|
+
return this.call(
|
|
1762
|
+
"Failed to remove envelope document",
|
|
1763
|
+
() => this.http.delete(`/accounts/${id}/envelopes/${eid}/documents/${did}`)
|
|
1764
|
+
);
|
|
1765
|
+
}
|
|
1766
|
+
};
|
|
1767
|
+
function validateName(value) {
|
|
1768
|
+
if (typeof value !== "string" || !value.trim() || [...value].length > 255 || value.includes("<"))
|
|
1769
|
+
throw new ValidationError("name must contain 1\u2013255 characters without <");
|
|
1770
|
+
}
|
|
1771
|
+
function validateMessage(value) {
|
|
1772
|
+
if (value != null && typeof value !== "string")
|
|
1773
|
+
throw new ValidationError("message must be text or null");
|
|
1774
|
+
}
|
|
1775
|
+
function validateIds(values, name) {
|
|
1776
|
+
if (!Array.isArray(values) || !values.length || values.some((id) => typeof id !== "string" || !id.trim()) || new Set(values).size !== values.length)
|
|
1777
|
+
throw new ValidationError(`${name} must contain distinct nonblank IDs`);
|
|
1778
|
+
}
|
|
1779
|
+
function validateDocument(payload) {
|
|
1780
|
+
if (!payload || typeof payload.id !== "string" || !payload.id.trim())
|
|
1781
|
+
throw new ValidationError("Document ID is required");
|
|
1782
|
+
validateIds(payload.signer_ids, "signer_ids");
|
|
1783
|
+
if (payload.method !== void 0 && !["virtual", "collect"].includes(payload.method))
|
|
1784
|
+
throw new ValidationError("method must be virtual or collect");
|
|
1785
|
+
if (payload.method === "collect" && (!Array.isArray(payload.entries) || !payload.entries.length))
|
|
1786
|
+
throw new ValidationError("entries are required for collect documents");
|
|
1787
|
+
if (payload.expires_at != null && typeof payload.expires_at !== "string" && (typeof payload.expires_at !== "number" || !Number.isFinite(payload.expires_at)))
|
|
1788
|
+
throw new ValidationError("expires_at must be a date string, Unix time or null");
|
|
1789
|
+
if (payload.copy_receiver_ids !== void 0 && (!Array.isArray(payload.copy_receiver_ids) || payload.copy_receiver_ids.some((id) => typeof id !== "string" || !id.trim())))
|
|
1790
|
+
throw new ValidationError("copy_receiver_ids must contain nonblank IDs");
|
|
1791
|
+
}
|
|
1792
|
+
function validateCreate(payload) {
|
|
1793
|
+
if (!payload) throw new ValidationError("Envelope payload is required");
|
|
1794
|
+
validateName(payload.name);
|
|
1795
|
+
validateMessage(payload.message);
|
|
1796
|
+
validateCreditCeiling(payload.max_total_credits);
|
|
1797
|
+
if (!Array.isArray(payload.signers) || !payload.signers.length || payload.signers.length > 20 || payload.signers.some((s) => !s || typeof s !== "object"))
|
|
1798
|
+
throw new ValidationError("signers must contain 1\u201320 signers");
|
|
1799
|
+
validateIds(
|
|
1800
|
+
payload.signers.map((s) => s.id),
|
|
1801
|
+
"signers"
|
|
1802
|
+
);
|
|
1803
|
+
for (const signer of payload.signers) {
|
|
1804
|
+
if ("step" in signer) throw new ValidationError("Envelope signers do not accept step");
|
|
1805
|
+
validateSignerOptions(signer);
|
|
1806
|
+
}
|
|
1807
|
+
if (!Array.isArray(payload.documents) || !payload.documents.length || payload.documents.length > 20)
|
|
1808
|
+
throw new ValidationError("documents must contain 1\u201320 documents");
|
|
1809
|
+
for (const document of payload.documents) {
|
|
1810
|
+
validateDocument(document);
|
|
1811
|
+
const signers = document.signer_ids.map((id) => payload.signers.find((s) => s.id === id));
|
|
1812
|
+
if (signers.some((s) => !s))
|
|
1813
|
+
throw new ValidationError("Every document signer must be listed in signers");
|
|
1814
|
+
const assigned = signers.filter((s) => s !== void 0);
|
|
1815
|
+
validateDigitalCertificateMethod(document.method ?? "virtual", assigned);
|
|
1816
|
+
if (assigned.length > 1 && assigned.some((s) => s.verification_method === "DigitalCertificate"))
|
|
1817
|
+
throw new ValidationError(
|
|
1818
|
+
"A DigitalCertificate signer must be alone on each envelope document"
|
|
1819
|
+
);
|
|
1820
|
+
}
|
|
1821
|
+
validateIds(
|
|
1822
|
+
payload.documents.map((d) => d.id),
|
|
1823
|
+
"documents"
|
|
1824
|
+
);
|
|
1825
|
+
if (payload.signers.some((s) => !payload.documents.some((d) => d.signer_ids.includes(s.id))))
|
|
1826
|
+
throw new ValidationError("Every signer must belong to at least one document");
|
|
1827
|
+
}
|
|
1828
|
+
|
|
1365
1829
|
// src/api/resources/fields.ts
|
|
1366
1830
|
var FieldsResource = class extends BaseResource {
|
|
1367
1831
|
/** Create a field definition. */
|
|
@@ -1676,15 +2140,44 @@ function httpsUrl(value, name) {
|
|
|
1676
2140
|
return url;
|
|
1677
2141
|
}
|
|
1678
2142
|
|
|
2143
|
+
// src/api/resources/scheduled-sends.ts
|
|
2144
|
+
var ScheduledSendResource = class extends BaseResource {
|
|
2145
|
+
async list(params = {}, accountId) {
|
|
2146
|
+
const id = this.accountId(accountId);
|
|
2147
|
+
return this.callList(
|
|
2148
|
+
"Failed to list scheduled sends",
|
|
2149
|
+
() => this.http.get(`/accounts/${id}/scheduled-sends`, { params: cleanParams({ ...params }) })
|
|
2150
|
+
);
|
|
2151
|
+
}
|
|
2152
|
+
/** Cancel only a pending request; nothing is sent or charged. */
|
|
2153
|
+
async cancel(scheduledSendId, accountId) {
|
|
2154
|
+
const id = this.accountId(accountId);
|
|
2155
|
+
const sid = this.requireId(scheduledSendId, "Scheduled send ID");
|
|
2156
|
+
return this.call(
|
|
2157
|
+
"Failed to cancel scheduled send",
|
|
2158
|
+
() => this.http.put(`/accounts/${id}/scheduled-sends/${sid}/cancel`)
|
|
2159
|
+
);
|
|
2160
|
+
}
|
|
2161
|
+
/** Execute a pending request now, sending invitations and charging its current cost. */
|
|
2162
|
+
async send(scheduledSendId, accountId) {
|
|
2163
|
+
const id = this.accountId(accountId);
|
|
2164
|
+
const sid = this.requireId(scheduledSendId, "Scheduled send ID");
|
|
2165
|
+
return this.call(
|
|
2166
|
+
"Failed to send scheduled request",
|
|
2167
|
+
() => this.http.put(`/accounts/${id}/scheduled-sends/${sid}/send`)
|
|
2168
|
+
);
|
|
2169
|
+
}
|
|
2170
|
+
};
|
|
2171
|
+
|
|
1679
2172
|
// src/api/resources/signer-documents.ts
|
|
1680
2173
|
var SignerDocumentsResource = class extends BaseResource {
|
|
1681
2174
|
/** `GET /signers/{signer_id}/document?signer-access-code=…` */
|
|
1682
|
-
async getCurrent(signerId, signerAccessCode) {
|
|
2175
|
+
async getCurrent(signerId, signerAccessCode, params = {}) {
|
|
1683
2176
|
const sid = this.requireId(signerId, "Signer ID");
|
|
1684
2177
|
const code = this.requireId(signerAccessCode, "signer-access-code");
|
|
1685
2178
|
return this.call(
|
|
1686
2179
|
"Failed to fetch current signer document",
|
|
1687
|
-
() => this.http.get(`/signers/${sid}/document`, signerAccessConfig(code))
|
|
2180
|
+
() => this.http.get(`/signers/${sid}/document`, signerAccessConfig(code, params))
|
|
1688
2181
|
);
|
|
1689
2182
|
}
|
|
1690
2183
|
/** `GET /signers/{signer_id}/documents?signer-access-code=…` */
|
|
@@ -1701,17 +2194,17 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
1701
2194
|
return this.listDocuments(signerId, { params: cleanParams({ ...params }) });
|
|
1702
2195
|
}
|
|
1703
2196
|
/** `GET /signers/{signer_id}/documents/search?search=…&signer-access-code=…` */
|
|
1704
|
-
async search(signerId, search, signerAccessCode) {
|
|
2197
|
+
async search(signerId, search, signerAccessCode, params = {}) {
|
|
1705
2198
|
const code = this.requireId(signerAccessCode, "signer-access-code");
|
|
1706
|
-
return this.searchDocuments(signerId, signerAccessConfig(code, { search }));
|
|
2199
|
+
return this.searchDocuments(signerId, signerAccessConfig(code, { ...params, search }));
|
|
1707
2200
|
}
|
|
1708
2201
|
/**
|
|
1709
2202
|
* `GET /signers/{signer_id}/documents/search?search=…` with the client's owner
|
|
1710
2203
|
* credentials instead of a signer access code. The signer must belong to that
|
|
1711
2204
|
* workspace.
|
|
1712
2205
|
*/
|
|
1713
|
-
async searchAsOwner(signerId, search) {
|
|
1714
|
-
return this.searchDocuments(signerId, { params: cleanParams({ search }) });
|
|
2206
|
+
async searchAsOwner(signerId, search, params = {}) {
|
|
2207
|
+
return this.searchDocuments(signerId, { params: cleanParams({ ...params, search }) });
|
|
1715
2208
|
}
|
|
1716
2209
|
listDocuments(signerId, config) {
|
|
1717
2210
|
const sid = this.requireId(signerId, "Signer ID");
|
|
@@ -1728,9 +2221,9 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
1728
2221
|
);
|
|
1729
2222
|
}
|
|
1730
2223
|
/**
|
|
1731
|
-
*
|
|
1732
|
-
*
|
|
1733
|
-
*
|
|
2224
|
+
* `GET /signers/{signer_id}/documents/{document_id}/download/{artifact}`.
|
|
2225
|
+
* The current API permits only originals with a signer code. Other forms are
|
|
2226
|
+
* retained for compatibility; use downloadCertifiedCopy for completed PDFs.
|
|
1734
2227
|
*/
|
|
1735
2228
|
async download(signerId, documentId, artifactName, signerAccessCode) {
|
|
1736
2229
|
const sid = this.requireId(signerId, "Signer ID");
|
|
@@ -1844,13 +2337,16 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
1844
2337
|
* Returns `{ token }` for the signer's Web PKI client. This production route
|
|
1845
2338
|
* is used by Assinafy's signing frontend but is absent from OpenAPI paths.
|
|
1846
2339
|
*/
|
|
1847
|
-
async startCertificate(signerAccessCode) {
|
|
2340
|
+
async startCertificate(signerAccessCode, documentId) {
|
|
1848
2341
|
const code = this.requireId(signerAccessCode, "signer-access-code");
|
|
1849
2342
|
return this.call(
|
|
1850
2343
|
"Failed to start certificate signature",
|
|
1851
2344
|
() => this.http.post(
|
|
1852
2345
|
"/signers/certificate/start",
|
|
1853
|
-
{
|
|
2346
|
+
{
|
|
2347
|
+
"signer-access-code": code,
|
|
2348
|
+
...documentId === void 0 ? {} : { document_id: this.requireId(documentId, "Document ID") }
|
|
2349
|
+
},
|
|
1854
2350
|
signerAccessConfig(code)
|
|
1855
2351
|
)
|
|
1856
2352
|
);
|
|
@@ -1861,7 +2357,7 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
1861
2357
|
* successfully signs it. Returns `{ signerName }`; private keys stay local.
|
|
1862
2358
|
* This production route is absent from OpenAPI paths.
|
|
1863
2359
|
*/
|
|
1864
|
-
async completeCertificate(signerAccessCode, token) {
|
|
2360
|
+
async completeCertificate(signerAccessCode, token, documentId) {
|
|
1865
2361
|
const code = this.requireId(signerAccessCode, "signer-access-code");
|
|
1866
2362
|
if (typeof token !== "string" || !token.trim()) {
|
|
1867
2363
|
throw new ValidationError("Certificate token is required");
|
|
@@ -1870,7 +2366,11 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
1870
2366
|
"Failed to complete certificate signature",
|
|
1871
2367
|
() => this.http.post(
|
|
1872
2368
|
"/signers/certificate/complete",
|
|
1873
|
-
{
|
|
2369
|
+
{
|
|
2370
|
+
"signer-access-code": code,
|
|
2371
|
+
token,
|
|
2372
|
+
...documentId === void 0 ? {} : { document_id: this.requireId(documentId, "Document ID") }
|
|
2373
|
+
},
|
|
1874
2374
|
signerAccessConfig(code)
|
|
1875
2375
|
)
|
|
1876
2376
|
);
|
|
@@ -1935,11 +2435,15 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
1935
2435
|
);
|
|
1936
2436
|
}
|
|
1937
2437
|
/** `GET /sign?signer-access-code=…` — fetch the assignment as the signer sees it. */
|
|
1938
|
-
async getAssignment(signerAccessCode, hasAcceptedTerms) {
|
|
2438
|
+
async getAssignment(signerAccessCode, hasAcceptedTerms, params = {}) {
|
|
1939
2439
|
const code = this.requireId(signerAccessCode, "signer-access-code");
|
|
2440
|
+
if (params.document_id !== void 0) this.requireId(params.document_id, "Document ID");
|
|
1940
2441
|
return this.call(
|
|
1941
2442
|
"Failed to fetch signer assignment",
|
|
1942
|
-
() => this.http.get(
|
|
2443
|
+
() => this.http.get(
|
|
2444
|
+
"/sign",
|
|
2445
|
+
signerAccessConfig(code, { ...params, has_accepted_terms: hasAcceptedTerms })
|
|
2446
|
+
)
|
|
1943
2447
|
);
|
|
1944
2448
|
}
|
|
1945
2449
|
/**
|
|
@@ -1982,12 +2486,59 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
1982
2486
|
);
|
|
1983
2487
|
}
|
|
1984
2488
|
async requireDocumentAccess(documentId, signerAccessCode, assignmentId) {
|
|
1985
|
-
const document = await this.
|
|
2489
|
+
const document = assignmentId === void 0 ? await this.call(
|
|
2490
|
+
"Failed to fetch signer document",
|
|
2491
|
+
() => this.http.get(`/documents/${documentId}`, signerAccessConfig(signerAccessCode))
|
|
2492
|
+
) : await this.getAssignment(signerAccessCode, void 0, { document_id: documentId });
|
|
1986
2493
|
if (document.id !== documentId || assignmentId !== void 0 && document.assignment?.id !== assignmentId) {
|
|
1987
2494
|
throw new ValidationError("Signer access code does not match the document or assignment");
|
|
1988
2495
|
}
|
|
1989
2496
|
return document;
|
|
1990
2497
|
}
|
|
2498
|
+
async getTheme(signerAccessCode) {
|
|
2499
|
+
const code = this.requireId(signerAccessCode, "signer-access-code");
|
|
2500
|
+
return this.call(
|
|
2501
|
+
"Failed to fetch signing theme",
|
|
2502
|
+
() => this.http.get("/sign/theme", signerAccessConfig(code))
|
|
2503
|
+
);
|
|
2504
|
+
}
|
|
2505
|
+
async downloadLogo(signerAccessCode) {
|
|
2506
|
+
const code = this.requireId(signerAccessCode, "signer-access-code");
|
|
2507
|
+
return this.callBinary(
|
|
2508
|
+
"Failed to download signing logo",
|
|
2509
|
+
() => this.http.get("/sign/logo", {
|
|
2510
|
+
...signerAccessConfig(code),
|
|
2511
|
+
responseType: "arraybuffer"
|
|
2512
|
+
})
|
|
2513
|
+
);
|
|
2514
|
+
}
|
|
2515
|
+
/** Sends a time-limited download link to the original signing contact. */
|
|
2516
|
+
async resendCertifiedCopy(signerAccessCode, documentId) {
|
|
2517
|
+
const code = this.requireId(signerAccessCode, "signer-access-code");
|
|
2518
|
+
const body = documentId === void 0 ? void 0 : { document_id: this.requireId(documentId, "Document ID") };
|
|
2519
|
+
return this.call(
|
|
2520
|
+
"Failed to send certified copy",
|
|
2521
|
+
() => this.http.post("/sign/certified-copy", body, signerAccessConfig(code))
|
|
2522
|
+
);
|
|
2523
|
+
}
|
|
2524
|
+
/** Expired tokens return an ApiError (302); redirects remain disabled. */
|
|
2525
|
+
async downloadCertifiedCopy(token, artifact = "certificated") {
|
|
2526
|
+
const value = this.requireId(token, "Download token");
|
|
2527
|
+
if (!["certificated", "pades"].includes(artifact))
|
|
2528
|
+
throw new ValidationError("artifact must be certificated or pades");
|
|
2529
|
+
const config = { ...publicRequestConfig(), responseType: "arraybuffer" };
|
|
2530
|
+
return this.callBinary(
|
|
2531
|
+
"Failed to download certified copy",
|
|
2532
|
+
() => artifact === "pades" ? this.http.get(`/signers/downloads/${value}/pades`, config) : this.http.get(`/signers/downloads/${value}`, config)
|
|
2533
|
+
);
|
|
2534
|
+
}
|
|
2535
|
+
async resendDownloadLink(token) {
|
|
2536
|
+
const value = this.requireId(token, "Download token");
|
|
2537
|
+
return this.call(
|
|
2538
|
+
"Failed to resend download link",
|
|
2539
|
+
() => this.http.post(`/signers/downloads/${value}/resend`, void 0, publicRequestConfig())
|
|
2540
|
+
);
|
|
2541
|
+
}
|
|
1991
2542
|
};
|
|
1992
2543
|
function validateDeclineReason(value) {
|
|
1993
2544
|
if (typeof value !== "string" || !value.trim()) {
|
|
@@ -2060,14 +2611,14 @@ var SignerResource = class extends BaseResource {
|
|
|
2060
2611
|
})
|
|
2061
2612
|
);
|
|
2062
2613
|
}
|
|
2063
|
-
/** Update
|
|
2614
|
+
/** Update supplied fields; verified channels on in-flight documents cannot change. */
|
|
2064
2615
|
async update(signerId, payload, accountId) {
|
|
2065
2616
|
const id = this.accountId(accountId);
|
|
2066
2617
|
const sid = this.requireId(signerId, "Signer ID");
|
|
2067
2618
|
if (payload.full_name !== void 0 && !payload.full_name.trim()) {
|
|
2068
2619
|
throw new ValidationError("Signer full name cannot be blank");
|
|
2069
2620
|
}
|
|
2070
|
-
if (payload.email !==
|
|
2621
|
+
if (payload.email != null && payload.email !== "") requireEmail(payload.email);
|
|
2071
2622
|
return this.call(
|
|
2072
2623
|
"Failed to update signer",
|
|
2073
2624
|
() => this.http.put(`/accounts/${id}/signers/${sid}`, normaliseSignerPayload(payload, true))
|
|
@@ -2088,13 +2639,13 @@ var SignerResource = class extends BaseResource {
|
|
|
2088
2639
|
try {
|
|
2089
2640
|
const lower = email.toLowerCase();
|
|
2090
2641
|
for (let page = 1; page <= MAX_SEARCH_PAGES; page++) {
|
|
2091
|
-
const { data, meta } = await this.list({ search: email, per_page:
|
|
2642
|
+
const { data, meta } = await this.list({ search: email, per_page: 50, page }, accountId);
|
|
2092
2643
|
const match = data.find((s) => (s.email ?? "").toLowerCase() === lower);
|
|
2093
2644
|
if (match) return match;
|
|
2094
2645
|
if (!data.length) return null;
|
|
2095
2646
|
if (meta?.last_page !== void 0) {
|
|
2096
2647
|
if (page >= meta.last_page) return null;
|
|
2097
|
-
} else if (data.length <
|
|
2648
|
+
} else if (data.length < 50) {
|
|
2098
2649
|
return null;
|
|
2099
2650
|
}
|
|
2100
2651
|
}
|
|
@@ -2112,7 +2663,7 @@ function normaliseSignerPayload(payload, useGovernmentId = false) {
|
|
|
2112
2663
|
const normalised = {
|
|
2113
2664
|
full_name: payload.full_name,
|
|
2114
2665
|
email: payload.email,
|
|
2115
|
-
whatsapp_phone_number: payload.whatsapp_phone_number
|
|
2666
|
+
whatsapp_phone_number: payload.whatsapp_phone_number !== void 0 ? payload.whatsapp_phone_number : payload.phone
|
|
2116
2667
|
};
|
|
2117
2668
|
if (payload.government_id !== void 0) {
|
|
2118
2669
|
normalised.government_id = payload.government_id;
|
|
@@ -2123,7 +2674,7 @@ function normaliseSignerPayload(payload, useGovernmentId = false) {
|
|
|
2123
2674
|
if ("metadata" in payload && payload.metadata !== void 0) {
|
|
2124
2675
|
normalised.metadata = payload.metadata;
|
|
2125
2676
|
}
|
|
2126
|
-
return stripEmpty(normalised);
|
|
2677
|
+
return useGovernmentId ? Object.fromEntries(Object.entries(normalised).filter(([, value]) => value !== void 0)) : stripEmpty(normalised);
|
|
2127
2678
|
}
|
|
2128
2679
|
|
|
2129
2680
|
// src/api/resources/tags.ts
|
|
@@ -2224,25 +2775,7 @@ var TemplateResource = class extends BaseResource {
|
|
|
2224
2775
|
}
|
|
2225
2776
|
};
|
|
2226
2777
|
|
|
2227
|
-
// src/api/types.ts
|
|
2228
|
-
var NOTIFICATION_PREFERENCE_CODES = [
|
|
2229
|
-
"DocumentCompleted",
|
|
2230
|
-
"SignerDeclined",
|
|
2231
|
-
"DocumentCancelled",
|
|
2232
|
-
"DocumentAboutToExpire",
|
|
2233
|
-
"DocumentExpired",
|
|
2234
|
-
"DocumentExpirationReset",
|
|
2235
|
-
"DocumentProcessingFailed",
|
|
2236
|
-
"TemplateProcessingFailed",
|
|
2237
|
-
"SignerWhatsappFailed",
|
|
2238
|
-
"ContractRenewalNotice",
|
|
2239
|
-
"ContractExpiring",
|
|
2240
|
-
"ContractExpired",
|
|
2241
|
-
"ContractRenewed"
|
|
2242
|
-
];
|
|
2243
|
-
|
|
2244
2778
|
// src/api/resources/users.ts
|
|
2245
|
-
var NOTIFICATION_PREFERENCES = new Set(NOTIFICATION_PREFERENCE_CODES);
|
|
2246
2779
|
var UsersResource = class extends BaseResource {
|
|
2247
2780
|
/** Fetch the authenticated user's profile. */
|
|
2248
2781
|
async self() {
|
|
@@ -2264,26 +2797,25 @@ var UsersResource = class extends BaseResource {
|
|
|
2264
2797
|
}
|
|
2265
2798
|
/** Merge one or more owner-facing email notification preferences. */
|
|
2266
2799
|
async updateNotificationPreferences(payload) {
|
|
2267
|
-
|
|
2268
|
-
throw new ValidationError("Notification preferences must be an object");
|
|
2269
|
-
}
|
|
2270
|
-
const entries = Object.entries(payload);
|
|
2271
|
-
if (entries.length === 0) {
|
|
2272
|
-
throw new ValidationError("At least one notification preference is required");
|
|
2273
|
-
}
|
|
2274
|
-
for (const [key, value] of entries) {
|
|
2275
|
-
if (!NOTIFICATION_PREFERENCES.has(key)) {
|
|
2276
|
-
throw new ValidationError(`Unknown notification preference: ${key}`);
|
|
2277
|
-
}
|
|
2278
|
-
if (typeof value !== "boolean") {
|
|
2279
|
-
throw new ValidationError(`${key} must be a boolean`);
|
|
2280
|
-
}
|
|
2281
|
-
}
|
|
2800
|
+
validateBooleanMap(payload, NOTIFICATION_PREFERENCE_CODES);
|
|
2282
2801
|
return this.call(
|
|
2283
2802
|
"Failed to update notification preferences",
|
|
2284
2803
|
() => this.http.put("/users/self/notification-preferences", payload)
|
|
2285
2804
|
);
|
|
2286
2805
|
}
|
|
2806
|
+
async getPushPreferences() {
|
|
2807
|
+
return this.call(
|
|
2808
|
+
"Failed to fetch push preferences",
|
|
2809
|
+
() => this.http.get("/users/self/push-preferences")
|
|
2810
|
+
);
|
|
2811
|
+
}
|
|
2812
|
+
async updatePushPreferences(payload) {
|
|
2813
|
+
validateBooleanMap(payload, PUSH_PREFERENCE_CODES);
|
|
2814
|
+
return this.call(
|
|
2815
|
+
"Failed to update push preferences",
|
|
2816
|
+
() => this.http.put("/users/self/push-preferences", payload)
|
|
2817
|
+
);
|
|
2818
|
+
}
|
|
2287
2819
|
};
|
|
2288
2820
|
|
|
2289
2821
|
// src/api/resources/webhooks.ts
|
|
@@ -2323,6 +2855,15 @@ function validateWebhookFields(payload, requireHttps = false) {
|
|
|
2323
2855
|
}
|
|
2324
2856
|
}
|
|
2325
2857
|
var WebhookResource = class extends BaseResource {
|
|
2858
|
+
/** Sends a webhook_test even to an inactive/held endpoint; does not change its state. */
|
|
2859
|
+
async testEndpoint(endpointId, accountId) {
|
|
2860
|
+
const id = this.accountId(accountId);
|
|
2861
|
+
const eid = this.requireId(endpointId, "Endpoint ID");
|
|
2862
|
+
return this.call(
|
|
2863
|
+
"Failed to send webhook test",
|
|
2864
|
+
() => this.http.post(`/accounts/${id}/webhooks/endpoints/${eid}/test`)
|
|
2865
|
+
);
|
|
2866
|
+
}
|
|
2326
2867
|
/**
|
|
2327
2868
|
* `PUT /accounts/{accountId}/webhooks/subscriptions` — create or replace the
|
|
2328
2869
|
* account's oldest webhook endpoint. Use the endpoint methods for accounts
|
|
@@ -2450,15 +2991,21 @@ var WebhookResource = class extends BaseResource {
|
|
|
2450
2991
|
}
|
|
2451
2992
|
/**
|
|
2452
2993
|
* `POST …/endpoints/{endpointId}/secret/rotate` — replace the signing secret.
|
|
2453
|
-
*
|
|
2994
|
+
* Set keep_previous to retain the replaced secret for 24 hours. Requires webhooks:write.
|
|
2454
2995
|
*/
|
|
2455
|
-
async rotateEndpointSecret(endpointId, accountId) {
|
|
2996
|
+
async rotateEndpointSecret(endpointId, accountId, options = {}) {
|
|
2456
2997
|
const id = this.accountId(accountId);
|
|
2457
2998
|
const eid = this.requireId(endpointId, "Endpoint ID");
|
|
2999
|
+
if (options.keep_previous !== void 0 && typeof options.keep_previous !== "boolean") {
|
|
3000
|
+
throw new ValidationError("keep_previous must be a boolean");
|
|
3001
|
+
}
|
|
2458
3002
|
this.logger.info("Rotating webhook endpoint secret");
|
|
2459
3003
|
return this.call(
|
|
2460
3004
|
"Failed to rotate webhook endpoint secret",
|
|
2461
|
-
() => this.http.post(
|
|
3005
|
+
() => this.http.post(
|
|
3006
|
+
`/accounts/${id}/webhooks/endpoints/${eid}/secret/rotate`,
|
|
3007
|
+
options.keep_previous === void 0 ? void 0 : { keep_previous: options.keep_previous }
|
|
3008
|
+
)
|
|
2462
3009
|
);
|
|
2463
3010
|
}
|
|
2464
3011
|
/** List currently supported webhook event types. */
|
|
@@ -2509,9 +3056,46 @@ var WorkspaceResource = class extends BaseResource {
|
|
|
2509
3056
|
);
|
|
2510
3057
|
}
|
|
2511
3058
|
/** Fetch a single workspace. */
|
|
2512
|
-
async get(accountId) {
|
|
3059
|
+
async get(accountId, params = {}) {
|
|
3060
|
+
const id = this.requireId(accountId, "Account ID");
|
|
3061
|
+
return this.call(
|
|
3062
|
+
"Failed to fetch workspace",
|
|
3063
|
+
() => this.http.get(`/accounts/${id}`, { params })
|
|
3064
|
+
);
|
|
3065
|
+
}
|
|
3066
|
+
/** Plan allowance and balances; unavailable to third-party OAuth applications. */
|
|
3067
|
+
async usage(accountId) {
|
|
3068
|
+
const id = this.requireId(accountId, "Account ID");
|
|
3069
|
+
return this.call(
|
|
3070
|
+
"Failed to fetch workspace usage",
|
|
3071
|
+
() => this.http.get(`/accounts/${id}/usage`)
|
|
3072
|
+
);
|
|
3073
|
+
}
|
|
3074
|
+
async getNotificationPolicy(accountId) {
|
|
2513
3075
|
const id = this.requireId(accountId, "Account ID");
|
|
2514
|
-
return this.call(
|
|
3076
|
+
return this.call(
|
|
3077
|
+
"Failed to fetch notification policy",
|
|
3078
|
+
() => this.http.get(`/accounts/${id}/notification-policy`)
|
|
3079
|
+
);
|
|
3080
|
+
}
|
|
3081
|
+
/** Owner-only partial merge; false disables the alert workspace-wide. */
|
|
3082
|
+
async updateNotificationPolicy(accountId, payload) {
|
|
3083
|
+
const id = this.requireId(accountId, "Account ID");
|
|
3084
|
+
if (!payload || typeof payload !== "object" || Array.isArray(payload) || !Object.keys(payload).length || Object.keys(payload).some((key) => !["events", "owners_receive_all"].includes(key)))
|
|
3085
|
+
throw new ValidationError("Provide events and/or owners_receive_all");
|
|
3086
|
+
if (payload.owners_receive_all !== void 0 && typeof payload.owners_receive_all !== "boolean")
|
|
3087
|
+
throw new ValidationError("owners_receive_all must be a boolean");
|
|
3088
|
+
if (payload.events !== void 0)
|
|
3089
|
+
validateBooleanMap(payload.events, [
|
|
3090
|
+
...NOTIFICATION_PREFERENCE_CODES,
|
|
3091
|
+
...PUSH_PREFERENCE_CODES
|
|
3092
|
+
]);
|
|
3093
|
+
if (payload.events === void 0 && payload.owners_receive_all === void 0)
|
|
3094
|
+
throw new ValidationError("At least one notification policy field is required");
|
|
3095
|
+
return this.call(
|
|
3096
|
+
"Failed to update notification policy",
|
|
3097
|
+
() => this.http.put(`/accounts/${id}/notification-policy`, payload)
|
|
3098
|
+
);
|
|
2515
3099
|
}
|
|
2516
3100
|
/** Fetch the workspace's public branding theme. */
|
|
2517
3101
|
async getTheme(accountId) {
|
|
@@ -2705,6 +3289,7 @@ var AssinafyClient = class _AssinafyClient {
|
|
|
2705
3289
|
contracts;
|
|
2706
3290
|
signers;
|
|
2707
3291
|
workspaces;
|
|
3292
|
+
scheduledSends;
|
|
2708
3293
|
assignments;
|
|
2709
3294
|
webhooks;
|
|
2710
3295
|
templates;
|
|
@@ -2712,6 +3297,8 @@ var AssinafyClient = class _AssinafyClient {
|
|
|
2712
3297
|
auth;
|
|
2713
3298
|
oauth;
|
|
2714
3299
|
fields;
|
|
3300
|
+
envelopes;
|
|
3301
|
+
embed;
|
|
2715
3302
|
users;
|
|
2716
3303
|
signerDocuments;
|
|
2717
3304
|
webhookVerifier;
|
|
@@ -2777,12 +3364,19 @@ var AssinafyClient = class _AssinafyClient {
|
|
|
2777
3364
|
this.defaultAccountId,
|
|
2778
3365
|
this.logger
|
|
2779
3366
|
);
|
|
3367
|
+
this.scheduledSends = new ScheduledSendResource(
|
|
3368
|
+
this.axiosInstance,
|
|
3369
|
+
this.defaultAccountId,
|
|
3370
|
+
this.logger
|
|
3371
|
+
);
|
|
2780
3372
|
this.webhooks = new WebhookResource(this.axiosInstance, this.defaultAccountId, this.logger);
|
|
2781
3373
|
this.templates = new TemplateResource(this.axiosInstance, this.defaultAccountId, this.logger);
|
|
2782
3374
|
this.tags = new TagResource(this.axiosInstance, this.defaultAccountId, this.logger);
|
|
2783
3375
|
this.auth = new AuthenticationResource(this.axiosInstance, void 0, this.logger);
|
|
2784
3376
|
this.oauth = new OAuthResource(this.axiosInstance, void 0, this.logger);
|
|
2785
3377
|
this.fields = new FieldsResource(this.axiosInstance, this.defaultAccountId, this.logger);
|
|
3378
|
+
this.envelopes = new EnvelopeResource(this.axiosInstance, this.defaultAccountId, this.logger);
|
|
3379
|
+
this.embed = new EmbedResource(this.axiosInstance, this.defaultAccountId, this.logger);
|
|
2786
3380
|
this.users = new UsersResource(this.axiosInstance, void 0, this.logger);
|
|
2787
3381
|
this.signerDocuments = new SignerDocumentsResource(
|
|
2788
3382
|
this.axiosInstance,
|
|
@@ -2828,6 +3422,7 @@ var AssinafyClient = class _AssinafyClient {
|
|
|
2828
3422
|
throw new ValidationError("At least one signer is required");
|
|
2829
3423
|
}
|
|
2830
3424
|
if (options.expiresAt !== void 0) requireExpiration(options.expiresAt, "expiresAt");
|
|
3425
|
+
validateCreditCeiling(options.maxTotalCredits);
|
|
2831
3426
|
const preparedSigners = options.signers.map((signer) => {
|
|
2832
3427
|
if (!signer || typeof signer !== "object") {
|
|
2833
3428
|
throw new ValidationError("Each signer must be an object");
|
|
@@ -2844,7 +3439,9 @@ var AssinafyClient = class _AssinafyClient {
|
|
|
2844
3439
|
const reference = {
|
|
2845
3440
|
verification_method: signer.verification_method ?? (useWhatsapp ? "Whatsapp" : void 0),
|
|
2846
3441
|
notification_methods: signer.notification_methods ?? (useWhatsapp ? ["Whatsapp"] : void 0),
|
|
2847
|
-
step: signer.step
|
|
3442
|
+
step: signer.step,
|
|
3443
|
+
embedded: signer.embedded,
|
|
3444
|
+
sign_as: signer.sign_as
|
|
2848
3445
|
};
|
|
2849
3446
|
validateSignerOptions(reference);
|
|
2850
3447
|
return { reference, payload };
|
|
@@ -2873,7 +3470,8 @@ var AssinafyClient = class _AssinafyClient {
|
|
|
2873
3470
|
}
|
|
2874
3471
|
const assignmentPayload = {
|
|
2875
3472
|
method: "virtual",
|
|
2876
|
-
signers: assignmentSigners
|
|
3473
|
+
signers: assignmentSigners,
|
|
3474
|
+
max_total_credits: options.maxTotalCredits
|
|
2877
3475
|
};
|
|
2878
3476
|
if (options.message !== void 0) assignmentPayload.message = options.message;
|
|
2879
3477
|
if (options.expiresAt !== void 0) assignmentPayload.expires_at = options.expiresAt;
|
|
@@ -2908,11 +3506,16 @@ export {
|
|
|
2908
3506
|
AuthenticationResource,
|
|
2909
3507
|
ContractResource,
|
|
2910
3508
|
DocumentResource,
|
|
3509
|
+
EmbedResource,
|
|
3510
|
+
EnvelopeResource,
|
|
2911
3511
|
FieldsResource,
|
|
2912
3512
|
NOTIFICATION_PREFERENCE_CODES,
|
|
2913
3513
|
NetworkError,
|
|
2914
3514
|
OAuthResource,
|
|
3515
|
+
PUSH_PREFERENCE_CODES,
|
|
2915
3516
|
PartialWorkflowError,
|
|
3517
|
+
SIGNER_CAPACITIES,
|
|
3518
|
+
ScheduledSendResource,
|
|
2916
3519
|
SignerDocumentsResource,
|
|
2917
3520
|
SignerResource,
|
|
2918
3521
|
TagResource,
|