@assinafy/cli 2.7.1 → 2.8.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.
Files changed (52) hide show
  1. package/.env.example +2 -0
  2. package/README.en.md +14 -8
  3. package/README.md +11 -3
  4. package/dist/api.cjs +517 -61
  5. package/dist/api.cjs.map +1 -1
  6. package/dist/api.js +514 -61
  7. package/dist/api.js.map +1 -1
  8. package/dist/cli.cjs +1009 -169
  9. package/dist/types/api/client.d.ts +5 -0
  10. package/dist/types/api/client.d.ts.map +1 -1
  11. package/dist/types/api/envelope-types.d.ts +73 -0
  12. package/dist/types/api/envelope-types.d.ts.map +1 -0
  13. package/dist/types/api/index.d.ts +3 -0
  14. package/dist/types/api/index.d.ts.map +1 -1
  15. package/dist/types/api/resources/assignments.d.ts.map +1 -1
  16. package/dist/types/api/resources/contracts.d.ts +3 -1
  17. package/dist/types/api/resources/contracts.d.ts.map +1 -1
  18. package/dist/types/api/resources/documents.d.ts +21 -6
  19. package/dist/types/api/resources/documents.d.ts.map +1 -1
  20. package/dist/types/api/resources/embed.d.ts +14 -0
  21. package/dist/types/api/resources/embed.d.ts.map +1 -0
  22. package/dist/types/api/resources/envelopes.d.ts +31 -0
  23. package/dist/types/api/resources/envelopes.d.ts.map +1 -0
  24. package/dist/types/api/resources/signer-documents.d.ts +23 -11
  25. package/dist/types/api/resources/signer-documents.d.ts.map +1 -1
  26. package/dist/types/api/resources/signers.d.ts +1 -1
  27. package/dist/types/api/resources/signers.d.ts.map +1 -1
  28. package/dist/types/api/resources/users.d.ts +3 -1
  29. package/dist/types/api/resources/users.d.ts.map +1 -1
  30. package/dist/types/api/resources/webhooks.d.ts +6 -2
  31. package/dist/types/api/resources/webhooks.d.ts.map +1 -1
  32. package/dist/types/api/resources/workspaces.d.ts +9 -2
  33. package/dist/types/api/resources/workspaces.d.ts.map +1 -1
  34. package/dist/types/api/types.d.ts +103 -7
  35. package/dist/types/api/types.d.ts.map +1 -1
  36. package/dist/types/api/utils.d.ts +6 -0
  37. package/dist/types/api/utils.d.ts.map +1 -1
  38. package/docs/README.md +3 -1
  39. package/docs/api-operations.json +234 -2
  40. package/docs/api-reference.md +11533 -3716
  41. package/docs/assignments.md +16 -14
  42. package/docs/contracts.md +4 -3
  43. package/docs/documents.md +44 -27
  44. package/docs/embed.md +119 -0
  45. package/docs/envelopes.md +210 -0
  46. package/docs/sdk-reference.md +215 -29
  47. package/docs/send.md +15 -11
  48. package/docs/signer.md +84 -3
  49. package/docs/users.md +41 -0
  50. package/docs/webhooks.md +22 -6
  51. package/docs/workspaces.md +66 -3
  52. package/package.json +1 -1
package/dist/api.js CHANGED
@@ -86,6 +86,7 @@ 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";
90
91
  var DOCUMENT_ARTIFACT_NAMES = [
91
92
  "original",
@@ -204,6 +205,12 @@ function requireEmail(value) {
204
205
  return value;
205
206
  }
206
207
  function validateSignerOptions(input) {
208
+ if (input.embedded !== void 0 && typeof input.embedded !== "boolean") {
209
+ throw new ValidationError("embedded must be a boolean");
210
+ }
211
+ if (input.embedded === true && input.verification_method !== void 0 && !["Email", "Whatsapp"].includes(input.verification_method)) {
212
+ throw new ValidationError("Embedded signing requires Email or Whatsapp verification");
213
+ }
207
214
  if (input.verification_method !== void 0 && !VERIFICATION_METHODS.includes(input.verification_method)) {
208
215
  throw new ValidationError(
209
216
  `verification_method must be one of: ${VERIFICATION_METHODS.join(", ")}`
@@ -230,6 +237,33 @@ function validateSignerOptions(input) {
230
237
  throw new ValidationError("step must be an integer");
231
238
  }
232
239
  }
240
+ function validateCreditCeiling(value) {
241
+ if (value !== void 0 && (typeof value !== "number" || !Number.isFinite(value) || value < 0)) {
242
+ throw new ValidationError("max_total_credits must be a finite non-negative number");
243
+ }
244
+ }
245
+ function idempotencyHeaders(key) {
246
+ if (key === void 0) return void 0;
247
+ if (typeof key !== "string" || !key.trim()) {
248
+ throw new ValidationError("idempotencyKey must be nonblank text");
249
+ }
250
+ try {
251
+ validateHeaderValue("Idempotency-Key", key);
252
+ } catch {
253
+ throw new ValidationError("idempotencyKey must be a valid HTTP header value");
254
+ }
255
+ return { "Idempotency-Key": key };
256
+ }
257
+ function validateBooleanMap(payload, allowed) {
258
+ if (!payload || typeof payload !== "object" || Array.isArray(payload) || !Object.keys(payload).length) {
259
+ throw new ValidationError("At least one notification preference is required");
260
+ }
261
+ for (const [key, value] of Object.entries(payload)) {
262
+ if (!allowed.includes(key))
263
+ throw new ValidationError(`Unknown notification preference: ${key}`);
264
+ if (typeof value !== "boolean") throw new ValidationError(`${key} must be a boolean`);
265
+ }
266
+ }
233
267
  function validateDigitalCertificateMethod(method, signers) {
234
268
  if (method !== "virtual" && signers.some((signer) => signer.verification_method === "DigitalCertificate")) {
235
269
  throw new ValidationError("DigitalCertificate signers require method: virtual", {
@@ -408,6 +442,7 @@ function buildAssignmentPayload(payload, options = {}) {
408
442
  throw new ValidationError("method must be virtual or collect");
409
443
  }
410
444
  const signers = extractSignerRefs(payload);
445
+ validateCreditCeiling(payload.max_total_credits);
411
446
  if (signers.length === 0) {
412
447
  throw new ValidationError("At least one signer is required", {
413
448
  signers: payload.signers ?? payload.signer_ids ?? payload.signerIds
@@ -428,7 +463,8 @@ function buildAssignmentPayload(payload, options = {}) {
428
463
  message: payload.message,
429
464
  expires_at: payload.expires_at === void 0 ? void 0 : requireExpiration(payload.expires_at),
430
465
  copy_receivers: payload.copy_receivers,
431
- entries: payload.entries
466
+ entries: payload.entries,
467
+ max_total_credits: payload.max_total_credits
432
468
  });
433
469
  }
434
470
  function extractSignerRefs(payload) {
@@ -457,7 +493,8 @@ function normaliseSignerRef(ref, options) {
457
493
  id,
458
494
  verification_method: input.verification_method,
459
495
  notification_methods: input.notification_methods,
460
- step: input.step
496
+ step: input.step,
497
+ embedded: input.embedded
461
498
  });
462
499
  if (typeof id === "string" && id.length > 0) {
463
500
  return normalised;
@@ -809,12 +846,14 @@ var ContractResource = class extends BaseResource {
809
846
  );
810
847
  }
811
848
  /** Read the root contract and its amendments from any document in that family. */
812
- async related(documentId, accountId) {
849
+ async related(documentId, accountId, params = {}) {
813
850
  const id = this.accountId(accountId);
814
851
  const did = this.requireId(documentId, "Document ID");
815
852
  return this.call(
816
853
  "Failed to get related contracts",
817
- () => this.http.get(`/accounts/${id}/documents/${did}/contract/related`)
854
+ () => this.http.get(`/accounts/${id}/documents/${did}/contract/related`, {
855
+ params: cleanParams(params)
856
+ })
818
857
  );
819
858
  }
820
859
  /** Advance from the supplied current term or to a later end date. No automatic retry. */
@@ -995,9 +1034,9 @@ var DocumentResource = class extends BaseResource {
995
1034
  );
996
1035
  }
997
1036
  /** Get document details. */
998
- async details(documentId) {
1037
+ async details(documentId, params = {}) {
999
1038
  const id = this.requireId(documentId, "Document ID");
1000
- return this.fetchDetails(id);
1039
+ return this.fetchDetails(id, void 0, params);
1001
1040
  }
1002
1041
  /**
1003
1042
  * Rename a document (`PATCH /documents/{id}`).
@@ -1014,8 +1053,17 @@ var DocumentResource = class extends BaseResource {
1014
1053
  );
1015
1054
  }
1016
1055
  /** Alias for {@link details}. */
1017
- async get(documentId) {
1018
- return this.details(documentId);
1056
+ async get(documentId, params = {}) {
1057
+ return this.details(documentId, params);
1058
+ }
1059
+ /** Read only the assignment items visible to this signer. */
1060
+ async getAsSigner(documentId, signerAccessCode) {
1061
+ const id = this.requireId(documentId, "Document ID");
1062
+ const code = this.requireId(signerAccessCode, "signer-access-code");
1063
+ return this.call(
1064
+ "Failed to fetch signer document",
1065
+ () => this.http.get(`/documents/${id}`, signerAccessConfig(code))
1066
+ );
1019
1067
  }
1020
1068
  /** Poll document status until ready (or a terminal status / timeout). */
1021
1069
  async waitUntilReady(documentId, options = {}) {
@@ -1062,42 +1110,57 @@ var DocumentResource = class extends BaseResource {
1062
1110
  attempts
1063
1111
  });
1064
1112
  }
1065
- fetchDetails(documentId, timeout) {
1113
+ fetchDetails(documentId, timeout, params) {
1066
1114
  return this.call(
1067
1115
  "Failed to fetch document details",
1068
- () => this.http.get(`/documents/${documentId}`, timeout === void 0 ? void 0 : { timeout })
1116
+ () => this.http.get(`/documents/${documentId}`, { timeout, ...params?.expand ? { params } : {} })
1069
1117
  );
1070
1118
  }
1071
1119
  /** Download a document artifact. Defaults to the certificated (signed) PDF. */
1072
- async download(documentId, artifactName = "certificated") {
1120
+ async download(documentId, artifactName = "certificated", options = {}) {
1073
1121
  const id = this.requireId(documentId, "Document ID");
1074
1122
  const artifact = requireDocumentArtifactName(artifactName);
1123
+ const config = this.artifactConfig(options);
1075
1124
  return this.callBinary(
1076
1125
  "Failed to download document",
1077
1126
  () => this.http.get(`/documents/${id}/download/${artifact}`, {
1127
+ ...config,
1078
1128
  responseType: "arraybuffer"
1079
1129
  })
1080
1130
  );
1081
1131
  }
1082
1132
  /** Download the document thumbnail. */
1083
- async thumbnail(documentId) {
1133
+ async thumbnail(documentId, options = {}) {
1134
+ const config = this.artifactConfig(options);
1084
1135
  const id = this.requireId(documentId, "Document ID");
1085
1136
  return this.callBinary(
1086
1137
  "Failed to download document thumbnail",
1087
- () => this.http.get(`/documents/${id}/thumbnail`, { responseType: "arraybuffer" })
1138
+ () => this.http.get(`/documents/${id}/thumbnail`, {
1139
+ ...config,
1140
+ responseType: "arraybuffer"
1141
+ })
1088
1142
  );
1089
1143
  }
1090
1144
  /** Download a single page as a JPEG. */
1091
- async downloadPage(documentId, pageId) {
1145
+ async downloadPage(documentId, pageId, options = {}) {
1146
+ const config = this.artifactConfig(options);
1092
1147
  const docId = this.requireId(documentId, "Document ID");
1093
1148
  const pid = this.requireId(pageId, "Page ID");
1094
1149
  return this.callBinary(
1095
1150
  "Failed to download page",
1096
1151
  () => this.http.get(`/documents/${docId}/pages/${pid}/download`, {
1152
+ ...config,
1097
1153
  responseType: "arraybuffer"
1098
1154
  })
1099
1155
  );
1100
1156
  }
1157
+ artifactConfig(options) {
1158
+ if (options.artifact !== void 0 && options.artifact !== "certificated") {
1159
+ throw new ValidationError("artifact must be certificated");
1160
+ }
1161
+ const params = options.artifact === void 0 ? {} : { artifact: options.artifact };
1162
+ return options.signerAccessCode === void 0 ? { params } : signerAccessConfig(this.requireId(options.signerAccessCode, "signer-access-code"), params);
1163
+ }
1101
1164
  /** Fetch one page of the document activity log (20 entries by default). */
1102
1165
  async activities(documentId, params = {}) {
1103
1166
  const id = this.requireId(documentId, "Document ID");
@@ -1171,6 +1234,9 @@ var DocumentResource = class extends BaseResource {
1171
1234
  const tmplId = this.requireId(templateId, "Template ID");
1172
1235
  const accId = this.accountId(accountId);
1173
1236
  validateTemplateSigners(signers, { requireIdentity: true });
1237
+ validateCreditCeiling(options.max_total_credits);
1238
+ const { idempotencyKey, ...bodyOptions } = options;
1239
+ const headers = idempotencyHeaders(idempotencyKey);
1174
1240
  if (options.expires_at !== void 0) requireExpiration(options.expires_at);
1175
1241
  if (options.editor_fields !== void 0 && (!Array.isArray(options.editor_fields) || options.editor_fields.some((field) => !field?.field_id || typeof field.value !== "string"))) {
1176
1242
  throw new ValidationError("editor_fields must contain field_id and value");
@@ -1179,11 +1245,11 @@ var DocumentResource = class extends BaseResource {
1179
1245
  throw new ValidationError("tags must contain non-empty tag names");
1180
1246
  }
1181
1247
  await this.validateCertificateTemplateMethod(tmplId, accId, signers);
1182
- const body = { ...options, signers };
1248
+ const body = { ...bodyOptions, signers };
1183
1249
  this.logger.info("Creating document from template", { templateId: tmplId, accountId: accId });
1184
1250
  return this.call(
1185
1251
  "Failed to create document from template",
1186
- () => this.http.post(`/accounts/${accId}/templates/${tmplId}/documents`, body)
1252
+ () => this.http.post(`/accounts/${accId}/templates/${tmplId}/documents`, body, { headers })
1187
1253
  );
1188
1254
  }
1189
1255
  /** Estimate the credit cost of creating a document from a template. */
@@ -1362,6 +1428,265 @@ function sleep(ms) {
1362
1428
  return new Promise((resolve) => setTimeout(resolve, ms));
1363
1429
  }
1364
1430
 
1431
+ // src/api/resources/embed.ts
1432
+ var EmbedResource = class extends BaseResource {
1433
+ async listOrigins(accountId) {
1434
+ const id = this.accountId(accountId);
1435
+ return this.call(
1436
+ "Failed to list embed origins",
1437
+ () => this.http.get(`/accounts/${id}/embed-origins`)
1438
+ );
1439
+ }
1440
+ async createOrigin(origin, accountId) {
1441
+ const id = this.accountId(accountId);
1442
+ validateOrigin(origin);
1443
+ return this.call(
1444
+ "Failed to add embed origin",
1445
+ () => this.http.post(`/accounts/${id}/embed-origins`, { origin })
1446
+ );
1447
+ }
1448
+ async updateOrigin(originId, origin, accountId) {
1449
+ const id = this.accountId(accountId);
1450
+ const oid = this.requireId(originId, "Origin ID");
1451
+ validateOrigin(origin);
1452
+ return this.call(
1453
+ "Failed to update embed origin",
1454
+ () => this.http.put(`/accounts/${id}/embed-origins/${oid}`, { origin })
1455
+ );
1456
+ }
1457
+ async deleteOrigin(originId, accountId) {
1458
+ const id = this.accountId(accountId);
1459
+ const oid = this.requireId(originId, "Origin ID");
1460
+ return this.call(
1461
+ "Failed to delete embed origin",
1462
+ () => this.http.delete(`/accounts/${id}/embed-origins/${oid}`)
1463
+ );
1464
+ }
1465
+ /** Load the returned private URL in the iframe within five minutes. */
1466
+ async createSession(documentId, assignmentId, signerId) {
1467
+ const did = this.requireId(documentId, "Document ID");
1468
+ const aid = this.requireId(assignmentId, "Assignment ID");
1469
+ const sid = this.requireId(signerId, "Signer ID");
1470
+ return this.call(
1471
+ "Failed to create embed session",
1472
+ () => this.http.post(`/documents/${did}/assignments/${aid}/signers/${sid}/embed-sessions`)
1473
+ );
1474
+ }
1475
+ /** Used by Assinafy's embed page; consumes the token even on a 409. Never retry automatically. */
1476
+ async exchangeSession(token, parentOrigin) {
1477
+ const value = this.requireId(token, "Embed session token");
1478
+ if (parentOrigin !== void 0) validateOrigin(parentOrigin);
1479
+ return this.call(
1480
+ "Failed to exchange embed session",
1481
+ () => this.http.post(
1482
+ `/embed/sessions/${value}/exchange`,
1483
+ parentOrigin === void 0 ? void 0 : { parent_origin: parentOrigin },
1484
+ publicRequestConfig()
1485
+ )
1486
+ );
1487
+ }
1488
+ };
1489
+ function validateOrigin(value) {
1490
+ let url;
1491
+ try {
1492
+ url = new URL(value);
1493
+ } catch {
1494
+ throw new ValidationError("origin must be an absolute origin");
1495
+ }
1496
+ 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))) {
1497
+ throw new ValidationError(
1498
+ "origin must use HTTPS (HTTP only for localhost or 127.0.0.1) without path, credentials, query, fragment or wildcard"
1499
+ );
1500
+ }
1501
+ }
1502
+
1503
+ // src/api/resources/envelopes.ts
1504
+ var EnvelopeResource = class extends BaseResource {
1505
+ async list(params = {}, accountId) {
1506
+ const id = this.accountId(accountId);
1507
+ if (params.status !== void 0 && !["open", "closed"].includes(params.status))
1508
+ throw new ValidationError("status must be open or closed");
1509
+ return this.callList(
1510
+ "Failed to list envelopes",
1511
+ () => this.http.get(`/accounts/${id}/envelopes`, { params: cleanParams({ ...params }) })
1512
+ );
1513
+ }
1514
+ /** Creates assignments and sends invitations; persist the result before checking delivery. */
1515
+ async create(payload, options = {}) {
1516
+ const id = this.accountId(options.accountId);
1517
+ validateCreate(payload);
1518
+ const headers = idempotencyHeaders(options.idempotencyKey);
1519
+ return this.call(
1520
+ "Failed to create envelope",
1521
+ () => this.http.post(`/accounts/${id}/envelopes`, payload, { headers })
1522
+ );
1523
+ }
1524
+ async estimateCost(payload, accountId) {
1525
+ const id = this.accountId(accountId);
1526
+ validateCreate(payload);
1527
+ return this.call(
1528
+ "Failed to estimate envelope cost",
1529
+ () => this.http.post(`/accounts/${id}/envelopes/estimate-cost`, payload)
1530
+ );
1531
+ }
1532
+ async get(envelopeId, accountId) {
1533
+ const id = this.accountId(accountId);
1534
+ const eid = this.requireId(envelopeId, "Envelope ID");
1535
+ return this.call(
1536
+ "Failed to fetch envelope",
1537
+ () => this.http.get(`/accounts/${id}/envelopes/${eid}`)
1538
+ );
1539
+ }
1540
+ /** Renames, changes the message (null clears), or reorders every current document. */
1541
+ async update(envelopeId, payload, accountId) {
1542
+ const id = this.accountId(accountId);
1543
+ const eid = this.requireId(envelopeId, "Envelope ID");
1544
+ if (!payload || !["name", "message", "document_ids"].some(
1545
+ (key) => payload[key] !== void 0
1546
+ ))
1547
+ throw new ValidationError("At least one envelope field is required");
1548
+ if (payload.name !== void 0) validateName(payload.name);
1549
+ validateMessage(payload.message);
1550
+ if (payload.document_ids !== void 0) validateIds(payload.document_ids, "document_ids");
1551
+ return this.call(
1552
+ "Failed to update envelope",
1553
+ () => this.http.patch(`/accounts/${id}/envelopes/${eid}`, payload)
1554
+ );
1555
+ }
1556
+ /** Requires a closed envelope; its documents are retained by the server. */
1557
+ async delete(envelopeId, accountId) {
1558
+ const id = this.accountId(accountId);
1559
+ const eid = this.requireId(envelopeId, "Envelope ID");
1560
+ return this.call(
1561
+ "Failed to delete envelope",
1562
+ () => this.http.delete(`/accounts/${id}/envelopes/${eid}`)
1563
+ );
1564
+ }
1565
+ async activities(envelopeId, params = {}, accountId) {
1566
+ const id = this.accountId(accountId);
1567
+ const eid = this.requireId(envelopeId, "Envelope ID");
1568
+ requireSort(params.sort, ["id", "-id"]);
1569
+ return this.callList(
1570
+ "Failed to fetch envelope activities",
1571
+ () => this.http.get(`/accounts/${id}/envelopes/${eid}/activities`, {
1572
+ params: cleanParams({ ...params })
1573
+ })
1574
+ );
1575
+ }
1576
+ /** ZIP containing the requested artifact of each eligible document. */
1577
+ async download(envelopeId, artifactName = "certificated", accountId) {
1578
+ const id = this.accountId(accountId);
1579
+ const eid = this.requireId(envelopeId, "Envelope ID");
1580
+ const artifact = requireDocumentArtifactName(artifactName);
1581
+ return this.callBinary(
1582
+ "Failed to download envelope",
1583
+ () => this.http.get(`/accounts/${id}/envelopes/${eid}/download/${artifact}`, {
1584
+ responseType: "arraybuffer"
1585
+ })
1586
+ );
1587
+ }
1588
+ /** Cancels only cancellable documents and notifies their recipients. */
1589
+ async cancel(envelopeId, accountId) {
1590
+ const id = this.accountId(accountId);
1591
+ const eid = this.requireId(envelopeId, "Envelope ID");
1592
+ return this.call(
1593
+ "Failed to cancel envelope",
1594
+ () => this.http.put(`/accounts/${id}/envelopes/${eid}/cancel`)
1595
+ );
1596
+ }
1597
+ async resendNotification(envelopeId, signerId, accountId) {
1598
+ const id = this.accountId(accountId);
1599
+ const eid = this.requireId(envelopeId, "Envelope ID");
1600
+ const sid = this.requireId(signerId, "Signer ID");
1601
+ return this.call(
1602
+ "Failed to resend envelope notification",
1603
+ () => this.http.put(`/accounts/${id}/envelopes/${eid}/signers/${sid}/resend`)
1604
+ );
1605
+ }
1606
+ /** Adds a processed document for existing envelope signers and sends updated invitations. */
1607
+ async addDocument(envelopeId, payload, accountId) {
1608
+ const id = this.accountId(accountId);
1609
+ const eid = this.requireId(envelopeId, "Envelope ID");
1610
+ validateDocument(payload);
1611
+ validateCreditCeiling(payload.max_total_credits);
1612
+ return this.call(
1613
+ "Failed to add envelope document",
1614
+ () => this.http.post(`/accounts/${id}/envelopes/${eid}/documents`, payload)
1615
+ );
1616
+ }
1617
+ /** Cancels an open document, notifies its recipients, and removes it from the envelope. */
1618
+ async removeDocument(envelopeId, documentId, accountId) {
1619
+ const id = this.accountId(accountId);
1620
+ const eid = this.requireId(envelopeId, "Envelope ID");
1621
+ const did = this.requireId(documentId, "Document ID");
1622
+ return this.call(
1623
+ "Failed to remove envelope document",
1624
+ () => this.http.delete(`/accounts/${id}/envelopes/${eid}/documents/${did}`)
1625
+ );
1626
+ }
1627
+ };
1628
+ function validateName(value) {
1629
+ if (typeof value !== "string" || !value.trim() || [...value].length > 255 || value.includes("<"))
1630
+ throw new ValidationError("name must contain 1\u2013255 characters without <");
1631
+ }
1632
+ function validateMessage(value) {
1633
+ if (value != null && typeof value !== "string")
1634
+ throw new ValidationError("message must be text or null");
1635
+ }
1636
+ function validateIds(values, name) {
1637
+ if (!Array.isArray(values) || !values.length || values.some((id) => typeof id !== "string" || !id.trim()) || new Set(values).size !== values.length)
1638
+ throw new ValidationError(`${name} must contain distinct nonblank IDs`);
1639
+ }
1640
+ function validateDocument(payload) {
1641
+ if (!payload || typeof payload.id !== "string" || !payload.id.trim())
1642
+ throw new ValidationError("Document ID is required");
1643
+ validateIds(payload.signer_ids, "signer_ids");
1644
+ if (payload.method !== void 0 && !["virtual", "collect"].includes(payload.method))
1645
+ throw new ValidationError("method must be virtual or collect");
1646
+ if (payload.method === "collect" && (!Array.isArray(payload.entries) || !payload.entries.length))
1647
+ throw new ValidationError("entries are required for collect documents");
1648
+ if (payload.expires_at != null && typeof payload.expires_at !== "string" && (typeof payload.expires_at !== "number" || !Number.isFinite(payload.expires_at)))
1649
+ throw new ValidationError("expires_at must be a date string, Unix time or null");
1650
+ if (payload.copy_receiver_ids !== void 0 && (!Array.isArray(payload.copy_receiver_ids) || payload.copy_receiver_ids.some((id) => typeof id !== "string" || !id.trim())))
1651
+ throw new ValidationError("copy_receiver_ids must contain nonblank IDs");
1652
+ }
1653
+ function validateCreate(payload) {
1654
+ if (!payload) throw new ValidationError("Envelope payload is required");
1655
+ validateName(payload.name);
1656
+ validateMessage(payload.message);
1657
+ validateCreditCeiling(payload.max_total_credits);
1658
+ if (!Array.isArray(payload.signers) || !payload.signers.length || payload.signers.length > 20 || payload.signers.some((s) => !s || typeof s !== "object"))
1659
+ throw new ValidationError("signers must contain 1\u201320 signers");
1660
+ validateIds(
1661
+ payload.signers.map((s) => s.id),
1662
+ "signers"
1663
+ );
1664
+ for (const signer of payload.signers) {
1665
+ if ("step" in signer) throw new ValidationError("Envelope signers do not accept step");
1666
+ validateSignerOptions(signer);
1667
+ }
1668
+ if (!Array.isArray(payload.documents) || !payload.documents.length || payload.documents.length > 20)
1669
+ throw new ValidationError("documents must contain 1\u201320 documents");
1670
+ for (const document of payload.documents) {
1671
+ validateDocument(document);
1672
+ const signers = document.signer_ids.map((id) => payload.signers.find((s) => s.id === id));
1673
+ if (signers.some((s) => !s))
1674
+ throw new ValidationError("Every document signer must be listed in signers");
1675
+ const assigned = signers.filter((s) => s !== void 0);
1676
+ validateDigitalCertificateMethod(document.method ?? "virtual", assigned);
1677
+ if (assigned.length > 1 && assigned.some((s) => s.verification_method === "DigitalCertificate"))
1678
+ throw new ValidationError(
1679
+ "A DigitalCertificate signer must be alone on each envelope document"
1680
+ );
1681
+ }
1682
+ validateIds(
1683
+ payload.documents.map((d) => d.id),
1684
+ "documents"
1685
+ );
1686
+ if (payload.signers.some((s) => !payload.documents.some((d) => d.signer_ids.includes(s.id))))
1687
+ throw new ValidationError("Every signer must belong to at least one document");
1688
+ }
1689
+
1365
1690
  // src/api/resources/fields.ts
1366
1691
  var FieldsResource = class extends BaseResource {
1367
1692
  /** Create a field definition. */
@@ -1679,12 +2004,12 @@ function httpsUrl(value, name) {
1679
2004
  // src/api/resources/signer-documents.ts
1680
2005
  var SignerDocumentsResource = class extends BaseResource {
1681
2006
  /** `GET /signers/{signer_id}/document?signer-access-code=…` */
1682
- async getCurrent(signerId, signerAccessCode) {
2007
+ async getCurrent(signerId, signerAccessCode, params = {}) {
1683
2008
  const sid = this.requireId(signerId, "Signer ID");
1684
2009
  const code = this.requireId(signerAccessCode, "signer-access-code");
1685
2010
  return this.call(
1686
2011
  "Failed to fetch current signer document",
1687
- () => this.http.get(`/signers/${sid}/document`, signerAccessConfig(code))
2012
+ () => this.http.get(`/signers/${sid}/document`, signerAccessConfig(code, params))
1688
2013
  );
1689
2014
  }
1690
2015
  /** `GET /signers/{signer_id}/documents?signer-access-code=…` */
@@ -1701,17 +2026,17 @@ var SignerDocumentsResource = class extends BaseResource {
1701
2026
  return this.listDocuments(signerId, { params: cleanParams({ ...params }) });
1702
2027
  }
1703
2028
  /** `GET /signers/{signer_id}/documents/search?search=…&signer-access-code=…` */
1704
- async search(signerId, search, signerAccessCode) {
2029
+ async search(signerId, search, signerAccessCode, params = {}) {
1705
2030
  const code = this.requireId(signerAccessCode, "signer-access-code");
1706
- return this.searchDocuments(signerId, signerAccessConfig(code, { search }));
2031
+ return this.searchDocuments(signerId, signerAccessConfig(code, { ...params, search }));
1707
2032
  }
1708
2033
  /**
1709
2034
  * `GET /signers/{signer_id}/documents/search?search=…` with the client's owner
1710
2035
  * credentials instead of a signer access code. The signer must belong to that
1711
2036
  * workspace.
1712
2037
  */
1713
- async searchAsOwner(signerId, search) {
1714
- return this.searchDocuments(signerId, { params: cleanParams({ search }) });
2038
+ async searchAsOwner(signerId, search, params = {}) {
2039
+ return this.searchDocuments(signerId, { params: cleanParams({ ...params, search }) });
1715
2040
  }
1716
2041
  listDocuments(signerId, config) {
1717
2042
  const sid = this.requireId(signerId, "Signer ID");
@@ -1728,9 +2053,9 @@ var SignerDocumentsResource = class extends BaseResource {
1728
2053
  );
1729
2054
  }
1730
2055
  /**
1731
- * Public `GET /signers/{signer_id}/documents/{document_id}/download/{artifact}`.
1732
- * When an access code is supplied, the SDK first verifies that it belongs to
1733
- * the requested signer for callers that want that additional check.
2056
+ * `GET /signers/{signer_id}/documents/{document_id}/download/{artifact}`.
2057
+ * The current API permits only originals with a signer code. Other forms are
2058
+ * retained for compatibility; use downloadCertifiedCopy for completed PDFs.
1734
2059
  */
1735
2060
  async download(signerId, documentId, artifactName, signerAccessCode) {
1736
2061
  const sid = this.requireId(signerId, "Signer ID");
@@ -1844,13 +2169,16 @@ var SignerDocumentsResource = class extends BaseResource {
1844
2169
  * Returns `{ token }` for the signer's Web PKI client. This production route
1845
2170
  * is used by Assinafy's signing frontend but is absent from OpenAPI paths.
1846
2171
  */
1847
- async startCertificate(signerAccessCode) {
2172
+ async startCertificate(signerAccessCode, documentId) {
1848
2173
  const code = this.requireId(signerAccessCode, "signer-access-code");
1849
2174
  return this.call(
1850
2175
  "Failed to start certificate signature",
1851
2176
  () => this.http.post(
1852
2177
  "/signers/certificate/start",
1853
- { "signer-access-code": code },
2178
+ {
2179
+ "signer-access-code": code,
2180
+ ...documentId === void 0 ? {} : { document_id: this.requireId(documentId, "Document ID") }
2181
+ },
1854
2182
  signerAccessConfig(code)
1855
2183
  )
1856
2184
  );
@@ -1861,7 +2189,7 @@ var SignerDocumentsResource = class extends BaseResource {
1861
2189
  * successfully signs it. Returns `{ signerName }`; private keys stay local.
1862
2190
  * This production route is absent from OpenAPI paths.
1863
2191
  */
1864
- async completeCertificate(signerAccessCode, token) {
2192
+ async completeCertificate(signerAccessCode, token, documentId) {
1865
2193
  const code = this.requireId(signerAccessCode, "signer-access-code");
1866
2194
  if (typeof token !== "string" || !token.trim()) {
1867
2195
  throw new ValidationError("Certificate token is required");
@@ -1870,7 +2198,11 @@ var SignerDocumentsResource = class extends BaseResource {
1870
2198
  "Failed to complete certificate signature",
1871
2199
  () => this.http.post(
1872
2200
  "/signers/certificate/complete",
1873
- { "signer-access-code": code, token },
2201
+ {
2202
+ "signer-access-code": code,
2203
+ token,
2204
+ ...documentId === void 0 ? {} : { document_id: this.requireId(documentId, "Document ID") }
2205
+ },
1874
2206
  signerAccessConfig(code)
1875
2207
  )
1876
2208
  );
@@ -1935,11 +2267,15 @@ var SignerDocumentsResource = class extends BaseResource {
1935
2267
  );
1936
2268
  }
1937
2269
  /** `GET /sign?signer-access-code=…` — fetch the assignment as the signer sees it. */
1938
- async getAssignment(signerAccessCode, hasAcceptedTerms) {
2270
+ async getAssignment(signerAccessCode, hasAcceptedTerms, params = {}) {
1939
2271
  const code = this.requireId(signerAccessCode, "signer-access-code");
2272
+ if (params.document_id !== void 0) this.requireId(params.document_id, "Document ID");
1940
2273
  return this.call(
1941
2274
  "Failed to fetch signer assignment",
1942
- () => this.http.get("/sign", signerAccessConfig(code, { has_accepted_terms: hasAcceptedTerms }))
2275
+ () => this.http.get(
2276
+ "/sign",
2277
+ signerAccessConfig(code, { ...params, has_accepted_terms: hasAcceptedTerms })
2278
+ )
1943
2279
  );
1944
2280
  }
1945
2281
  /**
@@ -1982,12 +2318,59 @@ var SignerDocumentsResource = class extends BaseResource {
1982
2318
  );
1983
2319
  }
1984
2320
  async requireDocumentAccess(documentId, signerAccessCode, assignmentId) {
1985
- const document = await this.getAssignment(signerAccessCode);
2321
+ const document = assignmentId === void 0 ? await this.call(
2322
+ "Failed to fetch signer document",
2323
+ () => this.http.get(`/documents/${documentId}`, signerAccessConfig(signerAccessCode))
2324
+ ) : await this.getAssignment(signerAccessCode, void 0, { document_id: documentId });
1986
2325
  if (document.id !== documentId || assignmentId !== void 0 && document.assignment?.id !== assignmentId) {
1987
2326
  throw new ValidationError("Signer access code does not match the document or assignment");
1988
2327
  }
1989
2328
  return document;
1990
2329
  }
2330
+ async getTheme(signerAccessCode) {
2331
+ const code = this.requireId(signerAccessCode, "signer-access-code");
2332
+ return this.call(
2333
+ "Failed to fetch signing theme",
2334
+ () => this.http.get("/sign/theme", signerAccessConfig(code))
2335
+ );
2336
+ }
2337
+ async downloadLogo(signerAccessCode) {
2338
+ const code = this.requireId(signerAccessCode, "signer-access-code");
2339
+ return this.callBinary(
2340
+ "Failed to download signing logo",
2341
+ () => this.http.get("/sign/logo", {
2342
+ ...signerAccessConfig(code),
2343
+ responseType: "arraybuffer"
2344
+ })
2345
+ );
2346
+ }
2347
+ /** Sends a time-limited download link to the original signing contact. */
2348
+ async resendCertifiedCopy(signerAccessCode, documentId) {
2349
+ const code = this.requireId(signerAccessCode, "signer-access-code");
2350
+ const body = documentId === void 0 ? void 0 : { document_id: this.requireId(documentId, "Document ID") };
2351
+ return this.call(
2352
+ "Failed to send certified copy",
2353
+ () => this.http.post("/sign/certified-copy", body, signerAccessConfig(code))
2354
+ );
2355
+ }
2356
+ /** Expired tokens return an ApiError (302); redirects remain disabled. */
2357
+ async downloadCertifiedCopy(token, artifact = "certificated") {
2358
+ const value = this.requireId(token, "Download token");
2359
+ if (!["certificated", "pades"].includes(artifact))
2360
+ throw new ValidationError("artifact must be certificated or pades");
2361
+ const config = { ...publicRequestConfig(), responseType: "arraybuffer" };
2362
+ return this.callBinary(
2363
+ "Failed to download certified copy",
2364
+ () => artifact === "pades" ? this.http.get(`/signers/downloads/${value}/pades`, config) : this.http.get(`/signers/downloads/${value}`, config)
2365
+ );
2366
+ }
2367
+ async resendDownloadLink(token) {
2368
+ const value = this.requireId(token, "Download token");
2369
+ return this.call(
2370
+ "Failed to resend download link",
2371
+ () => this.http.post(`/signers/downloads/${value}/resend`, void 0, publicRequestConfig())
2372
+ );
2373
+ }
1991
2374
  };
1992
2375
  function validateDeclineReason(value) {
1993
2376
  if (typeof value !== "string" || !value.trim()) {
@@ -2060,14 +2443,14 @@ var SignerResource = class extends BaseResource {
2060
2443
  })
2061
2444
  );
2062
2445
  }
2063
- /** Update a signer. Fails if the signer has active assignments. */
2446
+ /** Update supplied fields; verified channels on in-flight documents cannot change. */
2064
2447
  async update(signerId, payload, accountId) {
2065
2448
  const id = this.accountId(accountId);
2066
2449
  const sid = this.requireId(signerId, "Signer ID");
2067
2450
  if (payload.full_name !== void 0 && !payload.full_name.trim()) {
2068
2451
  throw new ValidationError("Signer full name cannot be blank");
2069
2452
  }
2070
- if (payload.email !== void 0) requireEmail(payload.email);
2453
+ if (payload.email != null && payload.email !== "") requireEmail(payload.email);
2071
2454
  return this.call(
2072
2455
  "Failed to update signer",
2073
2456
  () => this.http.put(`/accounts/${id}/signers/${sid}`, normaliseSignerPayload(payload, true))
@@ -2088,13 +2471,13 @@ var SignerResource = class extends BaseResource {
2088
2471
  try {
2089
2472
  const lower = email.toLowerCase();
2090
2473
  for (let page = 1; page <= MAX_SEARCH_PAGES; page++) {
2091
- const { data, meta } = await this.list({ search: email, per_page: 100, page }, accountId);
2474
+ const { data, meta } = await this.list({ search: email, per_page: 50, page }, accountId);
2092
2475
  const match = data.find((s) => (s.email ?? "").toLowerCase() === lower);
2093
2476
  if (match) return match;
2094
2477
  if (!data.length) return null;
2095
2478
  if (meta?.last_page !== void 0) {
2096
2479
  if (page >= meta.last_page) return null;
2097
- } else if (data.length < 100) {
2480
+ } else if (data.length < 50) {
2098
2481
  return null;
2099
2482
  }
2100
2483
  }
@@ -2112,7 +2495,7 @@ function normaliseSignerPayload(payload, useGovernmentId = false) {
2112
2495
  const normalised = {
2113
2496
  full_name: payload.full_name,
2114
2497
  email: payload.email,
2115
- whatsapp_phone_number: payload.whatsapp_phone_number ?? payload.phone
2498
+ whatsapp_phone_number: payload.whatsapp_phone_number !== void 0 ? payload.whatsapp_phone_number : payload.phone
2116
2499
  };
2117
2500
  if (payload.government_id !== void 0) {
2118
2501
  normalised.government_id = payload.government_id;
@@ -2123,7 +2506,7 @@ function normaliseSignerPayload(payload, useGovernmentId = false) {
2123
2506
  if ("metadata" in payload && payload.metadata !== void 0) {
2124
2507
  normalised.metadata = payload.metadata;
2125
2508
  }
2126
- return stripEmpty(normalised);
2509
+ return useGovernmentId ? Object.fromEntries(Object.entries(normalised).filter(([, value]) => value !== void 0)) : stripEmpty(normalised);
2127
2510
  }
2128
2511
 
2129
2512
  // src/api/resources/tags.ts
@@ -2225,6 +2608,16 @@ var TemplateResource = class extends BaseResource {
2225
2608
  };
2226
2609
 
2227
2610
  // src/api/types.ts
2611
+ var PUSH_PREFERENCE_CODES = [
2612
+ "SignerViewed",
2613
+ "SignerSigned",
2614
+ "DocumentCompleted",
2615
+ "SignerDeclined",
2616
+ "DocumentAboutToExpire",
2617
+ "DocumentExpired",
2618
+ "SignerIdentityReviewRequired",
2619
+ "SignerWhatsappFailed"
2620
+ ];
2228
2621
  var NOTIFICATION_PREFERENCE_CODES = [
2229
2622
  "DocumentCompleted",
2230
2623
  "SignerDeclined",
@@ -2242,7 +2635,6 @@ var NOTIFICATION_PREFERENCE_CODES = [
2242
2635
  ];
2243
2636
 
2244
2637
  // src/api/resources/users.ts
2245
- var NOTIFICATION_PREFERENCES = new Set(NOTIFICATION_PREFERENCE_CODES);
2246
2638
  var UsersResource = class extends BaseResource {
2247
2639
  /** Fetch the authenticated user's profile. */
2248
2640
  async self() {
@@ -2264,26 +2656,25 @@ var UsersResource = class extends BaseResource {
2264
2656
  }
2265
2657
  /** Merge one or more owner-facing email notification preferences. */
2266
2658
  async updateNotificationPreferences(payload) {
2267
- if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
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
- }
2659
+ validateBooleanMap(payload, NOTIFICATION_PREFERENCE_CODES);
2282
2660
  return this.call(
2283
2661
  "Failed to update notification preferences",
2284
2662
  () => this.http.put("/users/self/notification-preferences", payload)
2285
2663
  );
2286
2664
  }
2665
+ async getPushPreferences() {
2666
+ return this.call(
2667
+ "Failed to fetch push preferences",
2668
+ () => this.http.get("/users/self/push-preferences")
2669
+ );
2670
+ }
2671
+ async updatePushPreferences(payload) {
2672
+ validateBooleanMap(payload, PUSH_PREFERENCE_CODES);
2673
+ return this.call(
2674
+ "Failed to update push preferences",
2675
+ () => this.http.put("/users/self/push-preferences", payload)
2676
+ );
2677
+ }
2287
2678
  };
2288
2679
 
2289
2680
  // src/api/resources/webhooks.ts
@@ -2323,6 +2714,15 @@ function validateWebhookFields(payload, requireHttps = false) {
2323
2714
  }
2324
2715
  }
2325
2716
  var WebhookResource = class extends BaseResource {
2717
+ /** Sends a webhook_test even to an inactive/held endpoint; does not change its state. */
2718
+ async testEndpoint(endpointId, accountId) {
2719
+ const id = this.accountId(accountId);
2720
+ const eid = this.requireId(endpointId, "Endpoint ID");
2721
+ return this.call(
2722
+ "Failed to send webhook test",
2723
+ () => this.http.post(`/accounts/${id}/webhooks/endpoints/${eid}/test`)
2724
+ );
2725
+ }
2326
2726
  /**
2327
2727
  * `PUT /accounts/{accountId}/webhooks/subscriptions` — create or replace the
2328
2728
  * account's oldest webhook endpoint. Use the endpoint methods for accounts
@@ -2450,15 +2850,21 @@ var WebhookResource = class extends BaseResource {
2450
2850
  }
2451
2851
  /**
2452
2852
  * `POST …/endpoints/{endpointId}/secret/rotate` — replace the signing secret.
2453
- * The old secret stops working immediately. Requires `webhooks:write` for OAuth.
2853
+ * Set keep_previous to retain the replaced secret for 24 hours. Requires webhooks:write.
2454
2854
  */
2455
- async rotateEndpointSecret(endpointId, accountId) {
2855
+ async rotateEndpointSecret(endpointId, accountId, options = {}) {
2456
2856
  const id = this.accountId(accountId);
2457
2857
  const eid = this.requireId(endpointId, "Endpoint ID");
2858
+ if (options.keep_previous !== void 0 && typeof options.keep_previous !== "boolean") {
2859
+ throw new ValidationError("keep_previous must be a boolean");
2860
+ }
2458
2861
  this.logger.info("Rotating webhook endpoint secret");
2459
2862
  return this.call(
2460
2863
  "Failed to rotate webhook endpoint secret",
2461
- () => this.http.post(`/accounts/${id}/webhooks/endpoints/${eid}/secret/rotate`)
2864
+ () => this.http.post(
2865
+ `/accounts/${id}/webhooks/endpoints/${eid}/secret/rotate`,
2866
+ options.keep_previous === void 0 ? void 0 : { keep_previous: options.keep_previous }
2867
+ )
2462
2868
  );
2463
2869
  }
2464
2870
  /** List currently supported webhook event types. */
@@ -2509,9 +2915,46 @@ var WorkspaceResource = class extends BaseResource {
2509
2915
  );
2510
2916
  }
2511
2917
  /** Fetch a single workspace. */
2512
- async get(accountId) {
2918
+ async get(accountId, params = {}) {
2919
+ const id = this.requireId(accountId, "Account ID");
2920
+ return this.call(
2921
+ "Failed to fetch workspace",
2922
+ () => this.http.get(`/accounts/${id}`, { params })
2923
+ );
2924
+ }
2925
+ /** Plan allowance and balances; unavailable to third-party OAuth applications. */
2926
+ async usage(accountId) {
2927
+ const id = this.requireId(accountId, "Account ID");
2928
+ return this.call(
2929
+ "Failed to fetch workspace usage",
2930
+ () => this.http.get(`/accounts/${id}/usage`)
2931
+ );
2932
+ }
2933
+ async getNotificationPolicy(accountId) {
2934
+ const id = this.requireId(accountId, "Account ID");
2935
+ return this.call(
2936
+ "Failed to fetch notification policy",
2937
+ () => this.http.get(`/accounts/${id}/notification-policy`)
2938
+ );
2939
+ }
2940
+ /** Owner-only partial merge; false disables the alert workspace-wide. */
2941
+ async updateNotificationPolicy(accountId, payload) {
2513
2942
  const id = this.requireId(accountId, "Account ID");
2514
- return this.call("Failed to fetch workspace", () => this.http.get(`/accounts/${id}`));
2943
+ if (!payload || typeof payload !== "object" || Array.isArray(payload) || !Object.keys(payload).length || Object.keys(payload).some((key) => !["events", "owners_receive_all"].includes(key)))
2944
+ throw new ValidationError("Provide events and/or owners_receive_all");
2945
+ if (payload.owners_receive_all !== void 0 && typeof payload.owners_receive_all !== "boolean")
2946
+ throw new ValidationError("owners_receive_all must be a boolean");
2947
+ if (payload.events !== void 0)
2948
+ validateBooleanMap(payload.events, [
2949
+ ...NOTIFICATION_PREFERENCE_CODES,
2950
+ ...PUSH_PREFERENCE_CODES
2951
+ ]);
2952
+ if (payload.events === void 0 && payload.owners_receive_all === void 0)
2953
+ throw new ValidationError("At least one notification policy field is required");
2954
+ return this.call(
2955
+ "Failed to update notification policy",
2956
+ () => this.http.put(`/accounts/${id}/notification-policy`, payload)
2957
+ );
2515
2958
  }
2516
2959
  /** Fetch the workspace's public branding theme. */
2517
2960
  async getTheme(accountId) {
@@ -2712,6 +3155,8 @@ var AssinafyClient = class _AssinafyClient {
2712
3155
  auth;
2713
3156
  oauth;
2714
3157
  fields;
3158
+ envelopes;
3159
+ embed;
2715
3160
  users;
2716
3161
  signerDocuments;
2717
3162
  webhookVerifier;
@@ -2783,6 +3228,8 @@ var AssinafyClient = class _AssinafyClient {
2783
3228
  this.auth = new AuthenticationResource(this.axiosInstance, void 0, this.logger);
2784
3229
  this.oauth = new OAuthResource(this.axiosInstance, void 0, this.logger);
2785
3230
  this.fields = new FieldsResource(this.axiosInstance, this.defaultAccountId, this.logger);
3231
+ this.envelopes = new EnvelopeResource(this.axiosInstance, this.defaultAccountId, this.logger);
3232
+ this.embed = new EmbedResource(this.axiosInstance, this.defaultAccountId, this.logger);
2786
3233
  this.users = new UsersResource(this.axiosInstance, void 0, this.logger);
2787
3234
  this.signerDocuments = new SignerDocumentsResource(
2788
3235
  this.axiosInstance,
@@ -2828,6 +3275,7 @@ var AssinafyClient = class _AssinafyClient {
2828
3275
  throw new ValidationError("At least one signer is required");
2829
3276
  }
2830
3277
  if (options.expiresAt !== void 0) requireExpiration(options.expiresAt, "expiresAt");
3278
+ validateCreditCeiling(options.maxTotalCredits);
2831
3279
  const preparedSigners = options.signers.map((signer) => {
2832
3280
  if (!signer || typeof signer !== "object") {
2833
3281
  throw new ValidationError("Each signer must be an object");
@@ -2844,7 +3292,8 @@ var AssinafyClient = class _AssinafyClient {
2844
3292
  const reference = {
2845
3293
  verification_method: signer.verification_method ?? (useWhatsapp ? "Whatsapp" : void 0),
2846
3294
  notification_methods: signer.notification_methods ?? (useWhatsapp ? ["Whatsapp"] : void 0),
2847
- step: signer.step
3295
+ step: signer.step,
3296
+ embedded: signer.embedded
2848
3297
  };
2849
3298
  validateSignerOptions(reference);
2850
3299
  return { reference, payload };
@@ -2873,7 +3322,8 @@ var AssinafyClient = class _AssinafyClient {
2873
3322
  }
2874
3323
  const assignmentPayload = {
2875
3324
  method: "virtual",
2876
- signers: assignmentSigners
3325
+ signers: assignmentSigners,
3326
+ max_total_credits: options.maxTotalCredits
2877
3327
  };
2878
3328
  if (options.message !== void 0) assignmentPayload.message = options.message;
2879
3329
  if (options.expiresAt !== void 0) assignmentPayload.expires_at = options.expiresAt;
@@ -2908,10 +3358,13 @@ export {
2908
3358
  AuthenticationResource,
2909
3359
  ContractResource,
2910
3360
  DocumentResource,
3361
+ EmbedResource,
3362
+ EnvelopeResource,
2911
3363
  FieldsResource,
2912
3364
  NOTIFICATION_PREFERENCE_CODES,
2913
3365
  NetworkError,
2914
3366
  OAuthResource,
3367
+ PUSH_PREFERENCE_CODES,
2915
3368
  PartialWorkflowError,
2916
3369
  SignerDocumentsResource,
2917
3370
  SignerResource,