@assinafy/sdk 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.
package/dist/index.mjs CHANGED
@@ -505,6 +505,7 @@ import { AxiosError } from "axios";
505
505
 
506
506
  // src/support/path.ts
507
507
  function encodePathSegment(value) {
508
+ if (value === "." || value === "..") throw new Error("Dot segments are not resource IDs");
508
509
  return encodeURIComponent(value).replace(
509
510
  /[!'()*]/g,
510
511
  (character) => `%${character.charCodeAt(0).toString(16).toUpperCase()}`
@@ -627,7 +628,7 @@ import axios2 from "axios";
627
628
  // package.json
628
629
  var package_default = {
629
630
  name: "@assinafy/sdk",
630
- version: "2.7.1",
631
+ version: "2.8.0",
631
632
  packageManager: "bun@1.4.0",
632
633
  description: "TypeScript SDK for Assinafy API - Digital signature platform",
633
634
  type: "commonjs",
@@ -759,7 +760,13 @@ function applySdkTransportDefaults(http) {
759
760
  const guarded = (options, response, request) => {
760
761
  guardRedirect(options, response, request);
761
762
  if (current && typeof options["href"] === "string" && new URL(request.url).origin === new URL(options["href"]).origin) {
763
+ const destinationKeys = ["protocol", "host", "hostname", "port", "socketPath", "servername"];
764
+ const destination = destinationKeys.map((key) => options[key]);
765
+ const host = readHeader(options["headers"], "host");
762
766
  current(options, response, request);
767
+ if (destinationKeys.some((key, index) => options[key] !== destination[index]) || readHeader(options["headers"], "host") !== host) {
768
+ throw new Error("Redirect hooks must not change the destination");
769
+ }
763
770
  guardRedirect(options, response, request);
764
771
  }
765
772
  };
@@ -967,12 +974,13 @@ function toInt(value) {
967
974
 
968
975
  // src/resources/assignments.ts
969
976
  var ASSIGNMENT_METHODS = /* @__PURE__ */ new Set(["virtual", "collect"]);
970
- var VERIFICATION_METHODS = /* @__PURE__ */ new Set(["Email", "Whatsapp", "DigitalCertificate"]);
977
+ var VERIFICATION_METHODS = /* @__PURE__ */ new Set(["Email", "Whatsapp", "DigitalCertificate", "IdDocumentFaceMatchBasic"]);
971
978
  var NOTIFICATION_METHODS = /* @__PURE__ */ new Set(["Email", "Whatsapp"]);
972
979
  var ALLOWED_NOTIFICATION_METHODS = {
973
980
  Email: /* @__PURE__ */ new Set(["Email"]),
974
981
  Whatsapp: /* @__PURE__ */ new Set(["Whatsapp"]),
975
- DigitalCertificate: NOTIFICATION_METHODS
982
+ DigitalCertificate: NOTIFICATION_METHODS,
983
+ IdDocumentFaceMatchBasic: NOTIFICATION_METHODS
976
984
  };
977
985
  function validateAssignmentSignerOptions(signer, label = "signer") {
978
986
  if (signer.verification_method !== void 0 && (typeof signer.verification_method !== "string" || !VERIFICATION_METHODS.has(signer.verification_method))) {
@@ -1312,8 +1320,10 @@ var AssignmentResource = class extends BaseResource {
1312
1320
  * {@link buildAssignmentPayload}. A `virtual` assignment may be created at
1313
1321
  * `uploaded`, `metadata_processing`, or `metadata_ready` and is promoted
1314
1322
  * automatically; `collect` requires rendered pages at `metadata_ready`.
1315
- * `DigitalCertificate` costs two credits, requires the feature plus a
1323
+ * `DigitalCertificate` costs 0.5 credits, requires the feature plus a
1316
1324
  * signer `government_id`, and that signer must be alone in its step.
1325
+ * `IdDocumentFaceMatchBasic` needs the ID Document + Face Match feature
1326
+ * and a valid CPF in the signer's `government_id`; estimate its fee first.
1317
1327
  *
1318
1328
  * Request body (`application/json`):
1319
1329
  * ```jsonc
@@ -1449,7 +1459,7 @@ var AssignmentResource = class extends BaseResource {
1449
1459
  * only `verification_method` / `notification_methods` (or `{}` for the
1450
1460
  * default Email channel). {@link buildAssignmentEstimatePayload} projects
1451
1461
  * exactly the fields permitted by the estimate schema.
1452
- * `DigitalCertificate` is priced at two credits per signer and remains
1462
+ * `DigitalCertificate` is priced at 0.5 credits per signer and remains
1453
1463
  * subject to the feature, identity, and one-signer-per-step requirements.
1454
1464
  * Current documented unit prices are 1 credit for an extra document, 0 for
1455
1465
  * email notification, and 0.45 for WhatsApp notification; a digital
@@ -1725,6 +1735,148 @@ var AssignmentResource = class extends BaseResource {
1725
1735
  )
1726
1736
  );
1727
1737
  }
1738
+ /**
1739
+ * Read the account's signer identity review
1740
+ * (`GET /documents/{documentId}/assignments/{assignmentId}/signers/{signerId}/identity-verification`).
1741
+ *
1742
+ * No request body. `InReview` lets the signer continue signing but holds
1743
+ * certification. Evidence is a summary without images or biometrics; a
1744
+ * directly approved verification exposes evidence on its activity instead.
1745
+ *
1746
+ * @param documentId - Document owning the assignment.
1747
+ * @param assignmentId - Assignment containing the signer.
1748
+ * @param signerId - Signer whose identity is under review.
1749
+ * @returns The complete review summary:
1750
+ * ```jsonc
1751
+ * {
1752
+ * "id": "verification_example", "status": "InReview",
1753
+ * "provider": "AssinafyVerify", "verification_method": "IdDocumentFaceMatchBasic",
1754
+ * "reason_codes": [{ "code": "NAME_MISMATCH", "description": "Name differs" }],
1755
+ * "evidence_available": true,
1756
+ * "expected": { "name": "Example Signer", "cpf": null },
1757
+ * "document": { "type": "CNH", "name": "EXAMPLE SIGNER", "cpf": null },
1758
+ * "matches": { "cpf": null, "name": 0.52, "birth_date": null },
1759
+ * "checks": [{ "name": "name", "result": "review", "score": 0.52, "reasons": ["NAME_MISMATCH"] }],
1760
+ * "images": ["document_front", "face"], // available only while InReview
1761
+ * "ruleset_version": "2026-10-12.2", "evidence_sha256": null,
1762
+ * "reviewed_by": null, "reviewed_at": null, "review_note": null, "completed_at": null
1763
+ * }
1764
+ * ```
1765
+ * @throws {ValidationError} If any ID is blank or invalid for a URL.
1766
+ * @throws {ApiError} `401` for invalid credentials; `404` for an unknown
1767
+ * assignment, signer or verification; `500` for a server failure.
1768
+ * @example
1769
+ * ```ts
1770
+ * const review = await client.assignments.getIdentityVerification('doc-1', 'asg-1', 'signer-1');
1771
+ * console.log(review.status, review.images.length);
1772
+ * ```
1773
+ */
1774
+ async getIdentityVerification(documentId, assignmentId, signerId) {
1775
+ const path2 = this.identityVerificationPath(documentId, assignmentId, signerId);
1776
+ return this.call("Failed to fetch signer identity review", () => this.http.get(path2));
1777
+ }
1778
+ /**
1779
+ * Download identity review evidence
1780
+ * (`GET /documents/{documentId}/assignments/{assignmentId}/signers/{signerId}/identity-verification/images/{name}`).
1781
+ *
1782
+ * No request body. The provider supplies the bytes on each request; Assinafy
1783
+ * never stores them. Available only while the review is open. Keep these
1784
+ * sensitive bytes out of caches and logs (`Cache-Control: no-store`).
1785
+ *
1786
+ * @param documentId - Document owning the assignment.
1787
+ * @param assignmentId - Assignment containing the signer.
1788
+ * @param signerId - Signer whose evidence to view.
1789
+ * @param name - One of the review's `images`: `document_front`,
1790
+ * `document_back`, `document_pdf`, or `face`.
1791
+ * @returns Raw JPEG, PNG or PDF bytes as a `Buffer`.
1792
+ * @throws {ValidationError} If an ID or image name is invalid.
1793
+ * @throws {ApiError} `401` for invalid credentials; `404` for absent evidence
1794
+ * or a decided review; `500` for a provider/server failure.
1795
+ * @example
1796
+ * ```ts
1797
+ * const bytes = await client.assignments.downloadIdentityVerificationImage('doc-1', 'asg-1', 'signer-1', 'face');
1798
+ * ```
1799
+ */
1800
+ async downloadIdentityVerificationImage(documentId, assignmentId, signerId, name) {
1801
+ const path2 = this.identityVerificationPath(documentId, assignmentId, signerId);
1802
+ if (!["document_front", "document_back", "document_pdf", "face"].includes(name)) {
1803
+ throw new ValidationError("Invalid identity verification image name");
1804
+ }
1805
+ return this.callBinary(
1806
+ "Failed to download identity review evidence",
1807
+ () => this.http.get(`${path2}/images/${name}`, { responseType: "arraybuffer" })
1808
+ );
1809
+ }
1810
+ /**
1811
+ * Decide a signer identity review
1812
+ * (`POST /documents/{documentId}/assignments/{assignmentId}/signers/{signerId}/identity-verification/review`).
1813
+ *
1814
+ * Requires `InReview` and a document at `pending_signature` or
1815
+ * `pending_identity_review`. Approval allows certification once all signers
1816
+ * sign and every review is approved. Rejection cancels the document as
1817
+ * `rejected_by_user` and sends cancellation notices to signers and copy
1818
+ * receivers. The note is hidden from them; the provider receives the decision.
1819
+ *
1820
+ * Request body (`application/json`):
1821
+ * ```jsonc
1822
+ * { "decision": "Approved", "note": "Verified independently." }
1823
+ * ```
1824
+ * @param documentId - Document owning the assignment.
1825
+ * @param assignmentId - Assignment containing the signer.
1826
+ * @param signerId - Signer whose review to decide.
1827
+ * @param payload - Explicit account review decision.
1828
+ * @param payload.decision - `Approved` or `Rejected`.
1829
+ * @param payload.note - Optional nullable note, at most 2000 characters.
1830
+ * @returns The updated review, in the full
1831
+ * {@link AssignmentResource.getIdentityVerification} shape:
1832
+ * ```jsonc
1833
+ * {
1834
+ * "id": "verification_example", "status": "Approved",
1835
+ * "provider": "AssinafyVerify", "verification_method": "IdDocumentFaceMatchBasic",
1836
+ * "reason_codes": [{ "code": "NAME_MISMATCH", "description": "Name differs" }],
1837
+ * "evidence_available": true,
1838
+ * "expected": { "name": "Example Signer", "cpf": null },
1839
+ * "document": { "type": "CNH", "name": "EXAMPLE SIGNER", "cpf": null },
1840
+ * "matches": { "cpf": null, "name": 0.52, "birth_date": null },
1841
+ * "checks": [{ "name": "name", "result": "review", "score": 0.52, "reasons": ["NAME_MISMATCH"] }],
1842
+ * "images": [], "ruleset_version": "2026-10-12.2", "evidence_sha256": null,
1843
+ * "reviewed_by": { "id": "user_example", "name": "Example Reviewer" },
1844
+ * "reviewed_at": "2026-10-16T12:00:00Z", "review_note": "Verified independently.",
1845
+ * "completed_at": "2026-10-16T12:00:00Z"
1846
+ * }
1847
+ * ```
1848
+ * @throws {ValidationError} If IDs, decision or note are invalid.
1849
+ * @throws {ApiError} `400` for a closed review or invalid document state;
1850
+ * `401` for invalid credentials; `404` if absent; `500` for a server failure.
1851
+ * @example
1852
+ * ```ts
1853
+ * await client.assignments.reviewIdentityVerification('doc-1', 'asg-1', 'signer-1', {
1854
+ * decision: 'Approved', note: 'Verified independently.',
1855
+ * });
1856
+ * ```
1857
+ */
1858
+ async reviewIdentityVerification(documentId, assignmentId, signerId, payload) {
1859
+ const path2 = this.identityVerificationPath(documentId, assignmentId, signerId);
1860
+ assertRecord(payload, "identity review payload");
1861
+ if (payload.decision !== "Approved" && payload.decision !== "Rejected") {
1862
+ throw new ValidationError("decision must be Approved or Rejected");
1863
+ }
1864
+ if (payload.note !== void 0 && payload.note !== null && (typeof payload.note !== "string" || [...payload.note].length > 2e3)) {
1865
+ throw new ValidationError("note must be a string of at most 2000 characters, or null");
1866
+ }
1867
+ const body = { decision: payload.decision };
1868
+ if (payload.note !== void 0) body.note = payload.note;
1869
+ return this.call(
1870
+ "Failed to decide signer identity review",
1871
+ () => this.http.post(`${path2}/review`, body)
1872
+ );
1873
+ }
1874
+ identityVerificationPath(documentId, assignmentId, signerId) {
1875
+ const docId = this.pathSegment(documentId, "Document ID");
1876
+ const asgId = this.pathSegment(assignmentId, "Assignment ID");
1877
+ const sid = this.pathSegment(signerId, "Signer ID");
1878
+ return `/documents/${docId}/assignments/${asgId}/signers/${sid}/identity-verification`;
1879
+ }
1728
1880
  };
1729
1881
 
1730
1882
  // src/resources/documents.ts
@@ -1738,6 +1890,7 @@ function validateDocumentWaitOptions(options) {
1738
1890
  var READY_STATUSES = /* @__PURE__ */ new Set([
1739
1891
  "metadata_ready",
1740
1892
  "pending_signature",
1893
+ "pending_identity_review",
1741
1894
  "certificated"
1742
1895
  ]);
1743
1896
  var FAILED_STATUSES = /* @__PURE__ */ new Set([
@@ -1764,6 +1917,9 @@ var DocumentResource = class extends BaseResource {
1764
1917
  *
1765
1918
  * @param source - The PDF to upload, as a file path or an in-memory buffer.
1766
1919
  * @param options - Display name, metadata, and account override.
1920
+ * @param options.name - Multipart filename override; the API derives the display name from it.
1921
+ * @param options.metadata - JSON metadata (compatibility multipart part).
1922
+ * @param options.accountId - Override the client's default workspace.
1767
1923
  * @returns The created document, freshly uploaded (`status: 'uploaded'`,
1768
1924
  * empty `pages` until `metadata_ready`). Response shape:
1769
1925
  * ```jsonc
@@ -1874,7 +2030,7 @@ var DocumentResource = class extends BaseResource {
1874
2030
  * method: 'virtual',
1875
2031
  * 'per-page': 50,
1876
2032
  * });
1877
- * console.log(data[0]?.pages.length, meta?.total);
2033
+ * console.log(data[0]?.pages?.length, meta?.total);
1878
2034
  * ```
1879
2035
  */
1880
2036
  async list(params = {}, accountId) {
@@ -2087,7 +2243,8 @@ var DocumentResource = class extends BaseResource {
2087
2243
  }
2088
2244
  /**
2089
2245
  * Poll {@link DocumentResource.details} until the document reaches a ready
2090
- * status (`metadata_ready`, `pending_signature`, or `certificated`),
2246
+ * status (`metadata_ready`, `pending_signature`, `pending_identity_review`,
2247
+ * or `certificated`),
2091
2248
  * throwing on a terminal failure status or timeout.
2092
2249
  *
2093
2250
  * Transient errors are tolerated — a `5xx` or `429` is retried on the next
@@ -2097,6 +2254,8 @@ var DocumentResource = class extends BaseResource {
2097
2254
  * @param documentId - The document to wait on.
2098
2255
  * @param options - `maxWaitMs` (default `30_000`) and `pollIntervalMs`
2099
2256
  * (default `2_000`).
2257
+ * @param options.maxWaitMs - Finite non-negative wait budget in milliseconds; default `30_000`.
2258
+ * @param options.pollIntervalMs - Finite positive polling interval in milliseconds; default `2_000`.
2100
2259
  * @returns The document details once it reaches a ready status (see
2101
2260
  * {@link DocumentResource.details} for the shape).
2102
2261
  * @throws {ValidationError} If `documentId` is missing, the document enters
@@ -2364,6 +2523,9 @@ var DocumentResource = class extends BaseResource {
2364
2523
  * names are not portable identifiers and should not be used here. This
2365
2524
  * overwrites the existing set — use
2366
2525
  * {@link DocumentResource.addTags} to append.
2526
+ * Older sandbox deployments interpret these strings as names and create
2527
+ * ID-named tags for ID inputs; pass existing names intentionally there.
2528
+ * Strings are sent unchanged. See `docs/COMPATIBILITY.md` for this variant.
2367
2529
  *
2368
2530
  * Request body (`application/json`):
2369
2531
  * ```jsonc
@@ -2415,6 +2577,8 @@ var DocumentResource = class extends BaseResource {
2415
2577
  * `tags` is a non-empty array of tag **IDs**. Attaching an ID already
2416
2578
  * present is a no-op. To replace the whole set instead, use
2417
2579
  * {@link DocumentResource.replaceTags}.
2580
+ * On older name-based sandbox deployments, pass existing tag names
2581
+ * intentionally; ID inputs create ID-named tags. No automatic remapping occurs.
2418
2582
  *
2419
2583
  * Request body (`application/json`):
2420
2584
  * ```jsonc
@@ -2534,10 +2698,17 @@ var DocumentResource = class extends BaseResource {
2534
2698
  * plus optional `verification_method`, `notification_methods`, `step`).
2535
2699
  * Only one notification method is allowed per signer; when only one of the
2536
2700
  * verification/notification fields is supplied, the API infers the other.
2537
- * `DigitalCertificate` costs two credits, requires the feature plus a
2701
+ * `DigitalCertificate` costs 0.5 credits, requires the feature plus a
2538
2702
  * signer `government_id`, and that signer must be alone in its step.
2703
+ * `IdDocumentFaceMatchBasic` needs the ID Document + Face Match feature
2704
+ * and a valid CPF in `government_id`; estimate the per-signer fee first.
2539
2705
  * @param options - Optional `name`, `message`, `expires_at`,
2540
2706
  * `editor_fields`, `tags`.
2707
+ * @param options.name - Generated document display name.
2708
+ * @param options.message - Signing invitation message.
2709
+ * @param options.expires_at - ISO-8601 signature deadline.
2710
+ * @param options.editor_fields - Template editor values as `{ field_id, value }` entries.
2711
+ * @param options.tags - Tag names attached to the generated document.
2541
2712
  * @param accountId - Override the client's default account ID.
2542
2713
  * @returns The created document (an {@link IDocumentDetailsResponse} with
2543
2714
  * `template_id` set and its `assignment` populated):
@@ -2609,7 +2780,7 @@ var DocumentResource = class extends BaseResource {
2609
2780
  *
2610
2781
  * A dry run: sends only `{ signers }` and consumes nothing. Use it to check
2611
2782
  * balances before calling {@link DocumentResource.createFromTemplate}.
2612
- * `DigitalCertificate` adds two credits per signer and has the same feature,
2783
+ * `DigitalCertificate` adds 0.5 credits per signer and has the same feature,
2613
2784
  * `government_id`, and signing-step prerequisites as document creation.
2614
2785
  *
2615
2786
  * Request body (`application/json`):
@@ -2948,7 +3119,6 @@ function normaliseTemplateSigners(signers) {
2948
3119
  if (signer.step !== void 0) projected.step = signer.step;
2949
3120
  return projected;
2950
3121
  });
2951
- validateSigningOrder(normalised, "template signers");
2952
3122
  return normalised;
2953
3123
  }
2954
3124
  function normaliseTemplateEditorFields(fields) {
@@ -3268,9 +3438,8 @@ var SignerResource = class extends BaseResource {
3268
3438
  * re-filtered here for an exact, case-insensitive email match.
3269
3439
  *
3270
3440
  * Page size is pinned to {@link MAX_LIST_PAGE_SIZE}, the largest page the
3271
- * server actually returns. An exact address realistically matches one
3272
- * signer, but a search term that matched more than that could in principle
3273
- * miss one — the API exposes no exact-email filter to rule that out.
3441
+ * server actually returns. Pages are searched until an exact match is found
3442
+ * or the result set ends, so substring matches cannot hide an existing signer.
3274
3443
  *
3275
3444
  * A `404` from the underlying list is treated as "no match" and mapped to
3276
3445
  * `null`; any other {@link ApiError} propagates.
@@ -3300,12 +3469,16 @@ var SignerResource = class extends BaseResource {
3300
3469
  async findByEmail(email, accountId) {
3301
3470
  this.assertEmail(email);
3302
3471
  try {
3303
- const { data } = await this.list(
3304
- { search: email, "per-page": MAX_LIST_PAGE_SIZE },
3305
- accountId
3306
- );
3307
3472
  const lower = email.toLowerCase();
3308
- return data.find((s) => (s.email ?? "").toLowerCase() === lower) ?? null;
3473
+ for (let page = 1; ; page++) {
3474
+ const { data, meta } = await this.list(
3475
+ { search: email, "per-page": MAX_LIST_PAGE_SIZE, page },
3476
+ accountId
3477
+ );
3478
+ const match = data.find((s) => (s.email ?? "").toLowerCase() === lower);
3479
+ if (match) return match;
3480
+ if (data.length === 0 || (meta?.last_page !== void 0 ? page >= meta.last_page : data.length < MAX_LIST_PAGE_SIZE)) return null;
3481
+ }
3309
3482
  } catch (err) {
3310
3483
  if (err instanceof ApiError && err.statusCode === 404) {
3311
3484
  return null;
@@ -3660,6 +3833,8 @@ var WorkspaceResource = class extends BaseResource {
3660
3833
  * @param accountId - Account to aggregate.
3661
3834
  * @param params - Omit for 12 monthly rows, or request daily rows with
3662
3835
  * `{ granularity: 'daily', month: '2026-06' }`.
3836
+ * @param params.granularity - `monthly` (default) or `daily`.
3837
+ * @param params.month - Month in `YYYY-MM` format; required for daily rows.
3663
3838
  * @returns Zero-filled KPI rows:
3664
3839
  * ```jsonc
3665
3840
  * [{
@@ -3785,6 +3960,7 @@ var WorkspaceResource = class extends BaseResource {
3785
3960
  * @param accountId - The workspace to delete.
3786
3961
  * @param options - Set `force: true` to cancel an active paid subscription
3787
3962
  * and proceed with deletion.
3963
+ * @param options.force - Cancel an active subscription and bypass deletion restrictions.
3788
3964
  * @returns Nothing on success (`200` with no meaningful body).
3789
3965
  * @throws {ValidationError} If `accountId` is missing.
3790
3966
  * @throws {ApiError} `400` (with a `restrictions` list) when the workspace
@@ -4167,6 +4343,8 @@ var WebhookResource = class extends BaseResource {
4167
4343
  * `account:read` scope.
4168
4344
  *
4169
4345
  * @param accountId - Override the client's default account ID.
4346
+ * @param params - Optional endpoint filters.
4347
+ * @param params.url - Match the exact registered endpoint URL.
4170
4348
  * @returns Every endpoint (1 on free plans, up to 3 on paid plans):
4171
4349
  * ```jsonc
4172
4350
  * [
@@ -4192,9 +4370,14 @@ var WebhookResource = class extends BaseResource {
4192
4370
  * const signed = endpoints.filter((endpoint) => endpoint.signing_enabled);
4193
4371
  * ```
4194
4372
  */
4195
- async listEndpoints(accountId) {
4373
+ async listEndpoints(accountId, params = {}) {
4374
+ assertRecord(params, "webhook endpoint filters");
4375
+ if (params.url !== void 0) validateWebhookUrl(params.url);
4196
4376
  const path2 = this.endpointsPath(accountId);
4197
- return this.call("Failed to list webhook endpoints", () => this.http.get(path2));
4377
+ return this.call(
4378
+ "Failed to list webhook endpoints",
4379
+ () => this.http.get(path2, params.url === void 0 ? void 0 : { params: { url: params.url } })
4380
+ );
4198
4381
  }
4199
4382
  /**
4200
4383
  * Register a URL to receive the account's webhook events
@@ -4202,8 +4385,9 @@ var WebhookResource = class extends BaseResource {
4202
4385
  *
4203
4386
  * An account can have 1 endpoint, or up to 3 on paid plans. Each endpoint
4204
4387
  * of a workspace needs a different `url`. With `signing_enabled: true` the
4205
- * API generates a signing secret; read it with
4206
- * {@link WebhookResource.getEndpointSecret}. When `events` is omitted or
4388
+ * API returns a signing `secret` in this creation response. Store it now:
4389
+ * OAuth applications cannot call {@link WebhookResource.getEndpointSecret}
4390
+ * or rotate it later. When `events` is omitted or
4207
4391
  * empty, {@link DEFAULT_WEBHOOK_EVENTS} is sent. OAuth tokens need the
4208
4392
  * `webhooks:write` scope.
4209
4393
  *
@@ -4233,6 +4417,7 @@ var WebhookResource = class extends BaseResource {
4233
4417
  * "events": ["document_ready", "signer_signed_document"],
4234
4418
  * "is_active": true,
4235
4419
  * "signing_enabled": true, // deliveries carry a `webhook-signature` header
4420
+ * "secret": "whsec_c2VjcmV0", // only in this response when signing is enabled
4236
4421
  * "created_at": "2026-10-01T12:00:00Z",
4237
4422
  * "updated_at": "2026-10-01T12:00:00Z"
4238
4423
  * }
@@ -4252,7 +4437,7 @@ var WebhookResource = class extends BaseResource {
4252
4437
  * events: ['document_ready', 'signer_signed_document'],
4253
4438
  * signing_enabled: true,
4254
4439
  * });
4255
- * const { secret } = await client.webhooks.getEndpointSecret(endpoint.id);
4440
+ * if (endpoint.secret) await secretStore.save(endpoint.id, endpoint.secret);
4256
4441
  * ```
4257
4442
  */
4258
4443
  async createEndpoint(payload, accountId) {
@@ -4377,6 +4562,32 @@ var WebhookResource = class extends BaseResource {
4377
4562
  this.logger.info("Deleting webhook endpoint");
4378
4563
  await this.callVoid("Failed to delete webhook endpoint", () => this.http.delete(path2));
4379
4564
  }
4565
+ /**
4566
+ * Delete a webhook endpoint using its registered URL
4567
+ * (`DELETE /accounts/{accountId}/webhooks/endpoints?url=…`).
4568
+ *
4569
+ * No request body. The query URL must match the registered value exactly.
4570
+ * Frees its plan slot; OAuth applications need `webhooks:write`.
4571
+ *
4572
+ * @param url - Exact registered HTTP(S) endpoint URL, including its query.
4573
+ * @param accountId - Override the client's default workspace.
4574
+ * @returns Resolves on acknowledgement (`{ "status": 200, "data": [] }`).
4575
+ * @throws {ValidationError} If the URL is invalid or the account is missing.
4576
+ * @throws {ApiError} `400` for a missing URL; `401` for invalid credentials;
4577
+ * `403` for missing scope; `404` if no endpoint uses the URL; `500` on failure.
4578
+ * @example
4579
+ * ```ts
4580
+ * await client.webhooks.deleteEndpointByUrl('https://example.com/webhooks/assinafy');
4581
+ * ```
4582
+ */
4583
+ async deleteEndpointByUrl(url, accountId) {
4584
+ validateWebhookUrl(url);
4585
+ const path2 = this.endpointsPath(accountId);
4586
+ return this.callVoid(
4587
+ "Failed to delete webhook endpoint",
4588
+ () => this.http.delete(path2, { params: { url } })
4589
+ );
4590
+ }
4380
4591
  /**
4381
4592
  * Return the secret that signs deliveries to an endpoint
4382
4593
  * (`GET /accounts/{accountId}/webhooks/endpoints/{endpointId}/secret`).
@@ -4499,6 +4710,8 @@ var TemplateResource = class extends BaseResource {
4499
4710
  *
4500
4711
  * @param source - The PDF to upload, as a file path or an in-memory buffer.
4501
4712
  * @param options - `name` (display name) and an optional `accountId` override.
4713
+ * @param options.name - Multipart filename override, with a `.pdf` extension.
4714
+ * @param options.accountId - Override the client's default workspace.
4502
4715
  * @returns The created template (envelope unwrapped). Response shape:
4503
4716
  * ```jsonc
4504
4717
  * {
@@ -4664,7 +4877,7 @@ var TemplateResource = class extends BaseResource {
4664
4877
  * @example
4665
4878
  * ```ts
4666
4879
  * const tmpl = await client.templates.get('103ad2171db7979468c3e97eb067');
4667
- * if (tmpl.status === 'Ready') console.log(tmpl.pages.length);
4880
+ * if (tmpl.status === 'Ready') console.log(tmpl.pages?.length ?? 0);
4668
4881
  * ```
4669
4882
  */
4670
4883
  async get(templateId, accountId) {
@@ -4826,6 +5039,7 @@ var TagResource = class extends BaseResource {
4826
5039
  *
4827
5040
  * @param params - Optional filters. `search` matches tag names
4828
5041
  * case-insensitively (substring).
5042
+ * @param params.search - Optional case-insensitive tag-name substring.
4829
5043
  * @param accountId - Override the client's default account ID.
4830
5044
  * @returns The matching tags (list items carry no `resource` field):
4831
5045
  * ```jsonc
@@ -4999,6 +5213,8 @@ var TagResource = class extends BaseResource {
4999
5213
  * @param tagId - The tag to delete.
5000
5214
  * @param options - `force` to detach-and-delete when the tag is still in
5001
5215
  * use, and `accountId` to override the client's default account ID.
5216
+ * @param options.force - Detach the tag from documents before deletion.
5217
+ * @param options.accountId - Override the client's default workspace.
5002
5218
  * @returns `{ deleted: true }` when the tag was deleted.
5003
5219
  * @throws {ValidationError} If `tagId` is missing, or no account ID is available.
5004
5220
  * @throws {ApiError} `404` if the tag does not exist; `409` if the tag is
@@ -6564,6 +6780,8 @@ var FieldsResource = class extends BaseResource {
6564
6780
  * @param value - The value to check (validated against the field's
6565
6781
  * type/regex). Sent as `{ value }` in the request body.
6566
6782
  * @param options - Account override and optional legacy `signerAccessCode`.
6783
+ * @param options.accountId - Override the client's default workspace.
6784
+ * @param options.signerAccessCode - Legacy signer code sent as a query parameter.
6567
6785
  * @returns The validation result. Response shape:
6568
6786
  * ```jsonc
6569
6787
  * {
@@ -6624,6 +6842,8 @@ var FieldsResource = class extends BaseResource {
6624
6842
  *
6625
6843
  * @param entries - Non-empty array of `{ field_id, value }` pairs.
6626
6844
  * @param options - Account override and optional legacy `signerAccessCode`.
6845
+ * @param options.accountId - Override the client's default workspace.
6846
+ * @param options.signerAccessCode - Legacy signer code sent as a query parameter.
6627
6847
  * @returns One validation result per entry. Response shape:
6628
6848
  * ```jsonc
6629
6849
  * [
@@ -7134,7 +7354,8 @@ var SignerDocumentsResource = class extends BaseResource {
7134
7354
  * "has_accepted_terms": false,
7135
7355
  * "has_signature": false,
7136
7356
  * "has_initial": false,
7137
- * "is_signature_reusable": false
7357
+ * "is_signature_reusable": false,
7358
+ * "verification_method": "IdDocumentFaceMatchBasic"
7138
7359
  * }
7139
7360
  * ```
7140
7361
  * @throws {ValidationError} If `signerAccessCode` is missing.
@@ -7155,6 +7376,92 @@ var SignerDocumentsResource = class extends BaseResource {
7155
7376
  () => this.http.get("/signers/self", { params: { "signer-access-code": code } })
7156
7377
  );
7157
7378
  }
7379
+ /**
7380
+ * Read the signer's identity verification state
7381
+ * (`GET /signers/identity-verification?signer-access-code=…`).
7382
+ *
7383
+ * No request body or workspace credentials. Reads a pending provider
7384
+ * decision when available. A new session can start before the first capture
7385
+ * or after `Expired`; `Declined` and `Abandoned` require a new document and
7386
+ * assignment. `InReview` lets the signer continue; account approval gates
7387
+ * certification, with `pending_identity_review` after everyone signs.
7388
+ *
7389
+ * @param signerAccessCode - Access code from the signer's signing link.
7390
+ * @returns Provider state, with nullable fields before a session exists:
7391
+ * ```jsonc
7392
+ * {
7393
+ * "can_start": false, "status": "Pending",
7394
+ * "url": "https://verify.example.com/c/session#t=opaque",
7395
+ * "expires_at": "2026-10-16T12:30:00Z", "completed_at": null
7396
+ * }
7397
+ * ```
7398
+ * `url` exists only while Pending. It is a bearer link: open it intact,
7399
+ * including its fragment, and keep it out of logs and browser storage.
7400
+ * @throws {ValidationError} If the access code is blank.
7401
+ * @throws {ApiError} `401` for an invalid/expired code; `500` for a server failure.
7402
+ * @example
7403
+ * ```ts
7404
+ * const state = await client.signerDocuments.getIdentityVerification(accessCode);
7405
+ * console.log(state.status, state.can_start);
7406
+ * ```
7407
+ */
7408
+ async getIdentityVerification(signerAccessCode) {
7409
+ const code = this.requireId(signerAccessCode, "signer-access-code");
7410
+ return this.call(
7411
+ "Failed to fetch signer identity verification",
7412
+ () => this.http.get("/signers/identity-verification", { params: { "signer-access-code": code } })
7413
+ );
7414
+ }
7415
+ /**
7416
+ * Record biometric consent and open an identity verification session
7417
+ * (`POST /signers/identity-verification?signer-access-code=…`).
7418
+ *
7419
+ * Send only after the signer explicitly consents. Starts a session when
7420
+ * none exists or replaces an Expired session. Other states return `400`;
7421
+ * resending a notification never replaces a live session. The account is
7422
+ * billed at assignment creation, with no new charge for a restart.
7423
+ *
7424
+ * Request body (`application/json`):
7425
+ * ```jsonc
7426
+ * { "consent": true }
7427
+ * ```
7428
+ * @param signerAccessCode - Access code from the signer's signing link.
7429
+ * @param payload - Explicit consent from the signer.
7430
+ * @param payload.consent - Must be `true`; never default or infer consent.
7431
+ * @returns The newly opened provider session:
7432
+ * ```jsonc
7433
+ * {
7434
+ * "id": "verification_example",
7435
+ * "url": "https://verify.example.com/c/session#t=opaque",
7436
+ * "expires_at": "2026-10-16T12:30:00Z"
7437
+ * }
7438
+ * ```
7439
+ * `expires_at` can be null. Open the URL as-is; it is a bearer credential
7440
+ * and its fragment must survive navigation. Do not log or persist it in
7441
+ * browser storage. No workspace credential is attached to this call.
7442
+ * @throws {ValidationError} If the code is blank or consent is not `true`.
7443
+ * @throws {ApiError} `400` when a non-expired session already exists;
7444
+ * `401` for an invalid/expired code; `500` for a provider/server failure.
7445
+ * @example
7446
+ * ```ts
7447
+ * // Inside the handler for the signer's explicit consent action:
7448
+ * const session = await client.signerDocuments.startIdentityVerification(accessCode, { consent: true });
7449
+ * response.redirect(session.url);
7450
+ * ```
7451
+ */
7452
+ async startIdentityVerification(signerAccessCode, payload) {
7453
+ const code = this.requireId(signerAccessCode, "signer-access-code");
7454
+ assertRecord(payload, "identity verification payload");
7455
+ if (payload.consent !== true) {
7456
+ throw new ValidationError("Explicit biometric-processing consent is required");
7457
+ }
7458
+ return this.call(
7459
+ "Failed to start signer identity verification",
7460
+ () => this.http.post("/signers/identity-verification", { consent: true }, {
7461
+ params: { "signer-access-code": code }
7462
+ })
7463
+ );
7464
+ }
7158
7465
  /**
7159
7466
  * Accept the platform terms of use as the signer
7160
7467
  * (`PUT /signers/accept-terms?signer-access-code=…`).
@@ -7188,10 +7495,10 @@ var SignerDocumentsResource = class extends BaseResource {
7188
7495
  );
7189
7496
  }
7190
7497
  /**
7191
- * Verify the signer's email one-time password
7498
+ * Verify the signer's email or WhatsApp one-time password
7192
7499
  * (`POST /verify?signer-access-code=…`).
7193
7500
  *
7194
- * Confirms the 6-digit OTP the platform emailed the signer. The access code
7501
+ * Confirms the 6-digit OTP sent through the selected channel. The access code
7195
7502
  * authenticates via the `signer-access-code` **query param**; the request
7196
7503
  * **body carries only `verification-code`** (putting the access code in the
7197
7504
  * body leaves the request unauthenticated → `401`).
@@ -7205,6 +7512,8 @@ var SignerDocumentsResource = class extends BaseResource {
7205
7512
  *
7206
7513
  * @param payload - `signerAccessCode` (the signing-link code) and
7207
7514
  * `verificationCode` (the OTP the signer received).
7515
+ * @param payload.signerAccessCode - Signing-link code sent only in the query.
7516
+ * @param payload.verificationCode - Email or WhatsApp OTP sent as `verification-code`.
7208
7517
  * @returns Resolves when the API acknowledges the operation. The response
7209
7518
  * envelope has no `data` field and is intentionally discarded.
7210
7519
  * @throws {ValidationError} If `signerAccessCode` or `verificationCode` is
@@ -7365,7 +7674,7 @@ var SignerDocumentsResource = class extends BaseResource {
7365
7674
  * "expires_at": null,
7366
7675
  * "signers": [
7367
7676
  * { "id": "19e6b92e7895332ed9708535d8c", "step": 1, "email": "signer@example.com",
7368
- * "full_name": "Example Signer", "notified": true, "completed": false }
7677
+ * "full_name": "Example Signer", "notified": true }
7369
7678
  * ],
7370
7679
  * "items": [
7371
7680
  * { "id": "item-1", "page": { "id": "page-1", "number": 1, "height": 1651, "width": 1275,
@@ -7978,7 +8287,8 @@ var WebhookVerifier = class {
7978
8287
  * @param toleranceSeconds - Accepted clock distance. Defaults to `300`.
7979
8288
  * @returns `true` only when a signature entry matches (constant-time) and
7980
8289
  * the timestamp is fresh; `false` when verification is disabled, a header
7981
- * is missing, or anything does not match.
8290
+ * is missing, the tolerance is not finite and non-negative, or anything
8291
+ * does not match.
7982
8292
  *
7983
8293
  * @example
7984
8294
  * ```ts
@@ -7994,7 +8304,7 @@ var WebhookVerifier = class {
7994
8304
  */
7995
8305
  verifySignature(payload, headers, toleranceSeconds = DEFAULT_TOLERANCE_SECONDS) {
7996
8306
  const key = decodeSecret(this.webhookSecret);
7997
- if (!key || typeof payload !== "string" && !Buffer.isBuffer(payload) || !headers) {
8307
+ if (!key || typeof payload !== "string" && !Buffer.isBuffer(payload) || !headers || !Number.isFinite(toleranceSeconds) || toleranceSeconds < 0) {
7998
8308
  return false;
7999
8309
  }
8000
8310
  const id = header(headers, "webhook-id");