@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.js CHANGED
@@ -565,6 +565,7 @@ var import_axios3 = require("axios");
565
565
 
566
566
  // src/support/path.ts
567
567
  function encodePathSegment(value) {
568
+ if (value === "." || value === "..") throw new Error("Dot segments are not resource IDs");
568
569
  return encodeURIComponent(value).replace(
569
570
  /[!'()*]/g,
570
571
  (character) => `%${character.charCodeAt(0).toString(16).toUpperCase()}`
@@ -687,7 +688,7 @@ var import_axios2 = __toESM(require("axios"));
687
688
  // package.json
688
689
  var package_default = {
689
690
  name: "@assinafy/sdk",
690
- version: "2.7.1",
691
+ version: "2.8.0",
691
692
  packageManager: "bun@1.4.0",
692
693
  description: "TypeScript SDK for Assinafy API - Digital signature platform",
693
694
  type: "commonjs",
@@ -819,7 +820,13 @@ function applySdkTransportDefaults(http) {
819
820
  const guarded = (options, response, request) => {
820
821
  guardRedirect(options, response, request);
821
822
  if (current && typeof options["href"] === "string" && new URL(request.url).origin === new URL(options["href"]).origin) {
823
+ const destinationKeys = ["protocol", "host", "hostname", "port", "socketPath", "servername"];
824
+ const destination = destinationKeys.map((key) => options[key]);
825
+ const host = readHeader(options["headers"], "host");
822
826
  current(options, response, request);
827
+ if (destinationKeys.some((key, index) => options[key] !== destination[index]) || readHeader(options["headers"], "host") !== host) {
828
+ throw new Error("Redirect hooks must not change the destination");
829
+ }
823
830
  guardRedirect(options, response, request);
824
831
  }
825
832
  };
@@ -1027,12 +1034,13 @@ function toInt(value) {
1027
1034
 
1028
1035
  // src/resources/assignments.ts
1029
1036
  var ASSIGNMENT_METHODS = /* @__PURE__ */ new Set(["virtual", "collect"]);
1030
- var VERIFICATION_METHODS = /* @__PURE__ */ new Set(["Email", "Whatsapp", "DigitalCertificate"]);
1037
+ var VERIFICATION_METHODS = /* @__PURE__ */ new Set(["Email", "Whatsapp", "DigitalCertificate", "IdDocumentFaceMatchBasic"]);
1031
1038
  var NOTIFICATION_METHODS = /* @__PURE__ */ new Set(["Email", "Whatsapp"]);
1032
1039
  var ALLOWED_NOTIFICATION_METHODS = {
1033
1040
  Email: /* @__PURE__ */ new Set(["Email"]),
1034
1041
  Whatsapp: /* @__PURE__ */ new Set(["Whatsapp"]),
1035
- DigitalCertificate: NOTIFICATION_METHODS
1042
+ DigitalCertificate: NOTIFICATION_METHODS,
1043
+ IdDocumentFaceMatchBasic: NOTIFICATION_METHODS
1036
1044
  };
1037
1045
  function validateAssignmentSignerOptions(signer, label = "signer") {
1038
1046
  if (signer.verification_method !== void 0 && (typeof signer.verification_method !== "string" || !VERIFICATION_METHODS.has(signer.verification_method))) {
@@ -1372,8 +1380,10 @@ var AssignmentResource = class extends BaseResource {
1372
1380
  * {@link buildAssignmentPayload}. A `virtual` assignment may be created at
1373
1381
  * `uploaded`, `metadata_processing`, or `metadata_ready` and is promoted
1374
1382
  * automatically; `collect` requires rendered pages at `metadata_ready`.
1375
- * `DigitalCertificate` costs two credits, requires the feature plus a
1383
+ * `DigitalCertificate` costs 0.5 credits, requires the feature plus a
1376
1384
  * signer `government_id`, and that signer must be alone in its step.
1385
+ * `IdDocumentFaceMatchBasic` needs the ID Document + Face Match feature
1386
+ * and a valid CPF in the signer's `government_id`; estimate its fee first.
1377
1387
  *
1378
1388
  * Request body (`application/json`):
1379
1389
  * ```jsonc
@@ -1509,7 +1519,7 @@ var AssignmentResource = class extends BaseResource {
1509
1519
  * only `verification_method` / `notification_methods` (or `{}` for the
1510
1520
  * default Email channel). {@link buildAssignmentEstimatePayload} projects
1511
1521
  * exactly the fields permitted by the estimate schema.
1512
- * `DigitalCertificate` is priced at two credits per signer and remains
1522
+ * `DigitalCertificate` is priced at 0.5 credits per signer and remains
1513
1523
  * subject to the feature, identity, and one-signer-per-step requirements.
1514
1524
  * Current documented unit prices are 1 credit for an extra document, 0 for
1515
1525
  * email notification, and 0.45 for WhatsApp notification; a digital
@@ -1785,6 +1795,148 @@ var AssignmentResource = class extends BaseResource {
1785
1795
  )
1786
1796
  );
1787
1797
  }
1798
+ /**
1799
+ * Read the account's signer identity review
1800
+ * (`GET /documents/{documentId}/assignments/{assignmentId}/signers/{signerId}/identity-verification`).
1801
+ *
1802
+ * No request body. `InReview` lets the signer continue signing but holds
1803
+ * certification. Evidence is a summary without images or biometrics; a
1804
+ * directly approved verification exposes evidence on its activity instead.
1805
+ *
1806
+ * @param documentId - Document owning the assignment.
1807
+ * @param assignmentId - Assignment containing the signer.
1808
+ * @param signerId - Signer whose identity is under review.
1809
+ * @returns The complete review summary:
1810
+ * ```jsonc
1811
+ * {
1812
+ * "id": "verification_example", "status": "InReview",
1813
+ * "provider": "AssinafyVerify", "verification_method": "IdDocumentFaceMatchBasic",
1814
+ * "reason_codes": [{ "code": "NAME_MISMATCH", "description": "Name differs" }],
1815
+ * "evidence_available": true,
1816
+ * "expected": { "name": "Example Signer", "cpf": null },
1817
+ * "document": { "type": "CNH", "name": "EXAMPLE SIGNER", "cpf": null },
1818
+ * "matches": { "cpf": null, "name": 0.52, "birth_date": null },
1819
+ * "checks": [{ "name": "name", "result": "review", "score": 0.52, "reasons": ["NAME_MISMATCH"] }],
1820
+ * "images": ["document_front", "face"], // available only while InReview
1821
+ * "ruleset_version": "2026-10-12.2", "evidence_sha256": null,
1822
+ * "reviewed_by": null, "reviewed_at": null, "review_note": null, "completed_at": null
1823
+ * }
1824
+ * ```
1825
+ * @throws {ValidationError} If any ID is blank or invalid for a URL.
1826
+ * @throws {ApiError} `401` for invalid credentials; `404` for an unknown
1827
+ * assignment, signer or verification; `500` for a server failure.
1828
+ * @example
1829
+ * ```ts
1830
+ * const review = await client.assignments.getIdentityVerification('doc-1', 'asg-1', 'signer-1');
1831
+ * console.log(review.status, review.images.length);
1832
+ * ```
1833
+ */
1834
+ async getIdentityVerification(documentId, assignmentId, signerId) {
1835
+ const path2 = this.identityVerificationPath(documentId, assignmentId, signerId);
1836
+ return this.call("Failed to fetch signer identity review", () => this.http.get(path2));
1837
+ }
1838
+ /**
1839
+ * Download identity review evidence
1840
+ * (`GET /documents/{documentId}/assignments/{assignmentId}/signers/{signerId}/identity-verification/images/{name}`).
1841
+ *
1842
+ * No request body. The provider supplies the bytes on each request; Assinafy
1843
+ * never stores them. Available only while the review is open. Keep these
1844
+ * sensitive bytes out of caches and logs (`Cache-Control: no-store`).
1845
+ *
1846
+ * @param documentId - Document owning the assignment.
1847
+ * @param assignmentId - Assignment containing the signer.
1848
+ * @param signerId - Signer whose evidence to view.
1849
+ * @param name - One of the review's `images`: `document_front`,
1850
+ * `document_back`, `document_pdf`, or `face`.
1851
+ * @returns Raw JPEG, PNG or PDF bytes as a `Buffer`.
1852
+ * @throws {ValidationError} If an ID or image name is invalid.
1853
+ * @throws {ApiError} `401` for invalid credentials; `404` for absent evidence
1854
+ * or a decided review; `500` for a provider/server failure.
1855
+ * @example
1856
+ * ```ts
1857
+ * const bytes = await client.assignments.downloadIdentityVerificationImage('doc-1', 'asg-1', 'signer-1', 'face');
1858
+ * ```
1859
+ */
1860
+ async downloadIdentityVerificationImage(documentId, assignmentId, signerId, name) {
1861
+ const path2 = this.identityVerificationPath(documentId, assignmentId, signerId);
1862
+ if (!["document_front", "document_back", "document_pdf", "face"].includes(name)) {
1863
+ throw new ValidationError("Invalid identity verification image name");
1864
+ }
1865
+ return this.callBinary(
1866
+ "Failed to download identity review evidence",
1867
+ () => this.http.get(`${path2}/images/${name}`, { responseType: "arraybuffer" })
1868
+ );
1869
+ }
1870
+ /**
1871
+ * Decide a signer identity review
1872
+ * (`POST /documents/{documentId}/assignments/{assignmentId}/signers/{signerId}/identity-verification/review`).
1873
+ *
1874
+ * Requires `InReview` and a document at `pending_signature` or
1875
+ * `pending_identity_review`. Approval allows certification once all signers
1876
+ * sign and every review is approved. Rejection cancels the document as
1877
+ * `rejected_by_user` and sends cancellation notices to signers and copy
1878
+ * receivers. The note is hidden from them; the provider receives the decision.
1879
+ *
1880
+ * Request body (`application/json`):
1881
+ * ```jsonc
1882
+ * { "decision": "Approved", "note": "Verified independently." }
1883
+ * ```
1884
+ * @param documentId - Document owning the assignment.
1885
+ * @param assignmentId - Assignment containing the signer.
1886
+ * @param signerId - Signer whose review to decide.
1887
+ * @param payload - Explicit account review decision.
1888
+ * @param payload.decision - `Approved` or `Rejected`.
1889
+ * @param payload.note - Optional nullable note, at most 2000 characters.
1890
+ * @returns The updated review, in the full
1891
+ * {@link AssignmentResource.getIdentityVerification} shape:
1892
+ * ```jsonc
1893
+ * {
1894
+ * "id": "verification_example", "status": "Approved",
1895
+ * "provider": "AssinafyVerify", "verification_method": "IdDocumentFaceMatchBasic",
1896
+ * "reason_codes": [{ "code": "NAME_MISMATCH", "description": "Name differs" }],
1897
+ * "evidence_available": true,
1898
+ * "expected": { "name": "Example Signer", "cpf": null },
1899
+ * "document": { "type": "CNH", "name": "EXAMPLE SIGNER", "cpf": null },
1900
+ * "matches": { "cpf": null, "name": 0.52, "birth_date": null },
1901
+ * "checks": [{ "name": "name", "result": "review", "score": 0.52, "reasons": ["NAME_MISMATCH"] }],
1902
+ * "images": [], "ruleset_version": "2026-10-12.2", "evidence_sha256": null,
1903
+ * "reviewed_by": { "id": "user_example", "name": "Example Reviewer" },
1904
+ * "reviewed_at": "2026-10-16T12:00:00Z", "review_note": "Verified independently.",
1905
+ * "completed_at": "2026-10-16T12:00:00Z"
1906
+ * }
1907
+ * ```
1908
+ * @throws {ValidationError} If IDs, decision or note are invalid.
1909
+ * @throws {ApiError} `400` for a closed review or invalid document state;
1910
+ * `401` for invalid credentials; `404` if absent; `500` for a server failure.
1911
+ * @example
1912
+ * ```ts
1913
+ * await client.assignments.reviewIdentityVerification('doc-1', 'asg-1', 'signer-1', {
1914
+ * decision: 'Approved', note: 'Verified independently.',
1915
+ * });
1916
+ * ```
1917
+ */
1918
+ async reviewIdentityVerification(documentId, assignmentId, signerId, payload) {
1919
+ const path2 = this.identityVerificationPath(documentId, assignmentId, signerId);
1920
+ assertRecord(payload, "identity review payload");
1921
+ if (payload.decision !== "Approved" && payload.decision !== "Rejected") {
1922
+ throw new ValidationError("decision must be Approved or Rejected");
1923
+ }
1924
+ if (payload.note !== void 0 && payload.note !== null && (typeof payload.note !== "string" || [...payload.note].length > 2e3)) {
1925
+ throw new ValidationError("note must be a string of at most 2000 characters, or null");
1926
+ }
1927
+ const body = { decision: payload.decision };
1928
+ if (payload.note !== void 0) body.note = payload.note;
1929
+ return this.call(
1930
+ "Failed to decide signer identity review",
1931
+ () => this.http.post(`${path2}/review`, body)
1932
+ );
1933
+ }
1934
+ identityVerificationPath(documentId, assignmentId, signerId) {
1935
+ const docId = this.pathSegment(documentId, "Document ID");
1936
+ const asgId = this.pathSegment(assignmentId, "Assignment ID");
1937
+ const sid = this.pathSegment(signerId, "Signer ID");
1938
+ return `/documents/${docId}/assignments/${asgId}/signers/${sid}/identity-verification`;
1939
+ }
1788
1940
  };
1789
1941
 
1790
1942
  // src/resources/documents.ts
@@ -1798,6 +1950,7 @@ function validateDocumentWaitOptions(options) {
1798
1950
  var READY_STATUSES = /* @__PURE__ */ new Set([
1799
1951
  "metadata_ready",
1800
1952
  "pending_signature",
1953
+ "pending_identity_review",
1801
1954
  "certificated"
1802
1955
  ]);
1803
1956
  var FAILED_STATUSES = /* @__PURE__ */ new Set([
@@ -1824,6 +1977,9 @@ var DocumentResource = class extends BaseResource {
1824
1977
  *
1825
1978
  * @param source - The PDF to upload, as a file path or an in-memory buffer.
1826
1979
  * @param options - Display name, metadata, and account override.
1980
+ * @param options.name - Multipart filename override; the API derives the display name from it.
1981
+ * @param options.metadata - JSON metadata (compatibility multipart part).
1982
+ * @param options.accountId - Override the client's default workspace.
1827
1983
  * @returns The created document, freshly uploaded (`status: 'uploaded'`,
1828
1984
  * empty `pages` until `metadata_ready`). Response shape:
1829
1985
  * ```jsonc
@@ -1934,7 +2090,7 @@ var DocumentResource = class extends BaseResource {
1934
2090
  * method: 'virtual',
1935
2091
  * 'per-page': 50,
1936
2092
  * });
1937
- * console.log(data[0]?.pages.length, meta?.total);
2093
+ * console.log(data[0]?.pages?.length, meta?.total);
1938
2094
  * ```
1939
2095
  */
1940
2096
  async list(params = {}, accountId) {
@@ -2147,7 +2303,8 @@ var DocumentResource = class extends BaseResource {
2147
2303
  }
2148
2304
  /**
2149
2305
  * Poll {@link DocumentResource.details} until the document reaches a ready
2150
- * status (`metadata_ready`, `pending_signature`, or `certificated`),
2306
+ * status (`metadata_ready`, `pending_signature`, `pending_identity_review`,
2307
+ * or `certificated`),
2151
2308
  * throwing on a terminal failure status or timeout.
2152
2309
  *
2153
2310
  * Transient errors are tolerated — a `5xx` or `429` is retried on the next
@@ -2157,6 +2314,8 @@ var DocumentResource = class extends BaseResource {
2157
2314
  * @param documentId - The document to wait on.
2158
2315
  * @param options - `maxWaitMs` (default `30_000`) and `pollIntervalMs`
2159
2316
  * (default `2_000`).
2317
+ * @param options.maxWaitMs - Finite non-negative wait budget in milliseconds; default `30_000`.
2318
+ * @param options.pollIntervalMs - Finite positive polling interval in milliseconds; default `2_000`.
2160
2319
  * @returns The document details once it reaches a ready status (see
2161
2320
  * {@link DocumentResource.details} for the shape).
2162
2321
  * @throws {ValidationError} If `documentId` is missing, the document enters
@@ -2424,6 +2583,9 @@ var DocumentResource = class extends BaseResource {
2424
2583
  * names are not portable identifiers and should not be used here. This
2425
2584
  * overwrites the existing set — use
2426
2585
  * {@link DocumentResource.addTags} to append.
2586
+ * Older sandbox deployments interpret these strings as names and create
2587
+ * ID-named tags for ID inputs; pass existing names intentionally there.
2588
+ * Strings are sent unchanged. See `docs/COMPATIBILITY.md` for this variant.
2427
2589
  *
2428
2590
  * Request body (`application/json`):
2429
2591
  * ```jsonc
@@ -2475,6 +2637,8 @@ var DocumentResource = class extends BaseResource {
2475
2637
  * `tags` is a non-empty array of tag **IDs**. Attaching an ID already
2476
2638
  * present is a no-op. To replace the whole set instead, use
2477
2639
  * {@link DocumentResource.replaceTags}.
2640
+ * On older name-based sandbox deployments, pass existing tag names
2641
+ * intentionally; ID inputs create ID-named tags. No automatic remapping occurs.
2478
2642
  *
2479
2643
  * Request body (`application/json`):
2480
2644
  * ```jsonc
@@ -2594,10 +2758,17 @@ var DocumentResource = class extends BaseResource {
2594
2758
  * plus optional `verification_method`, `notification_methods`, `step`).
2595
2759
  * Only one notification method is allowed per signer; when only one of the
2596
2760
  * verification/notification fields is supplied, the API infers the other.
2597
- * `DigitalCertificate` costs two credits, requires the feature plus a
2761
+ * `DigitalCertificate` costs 0.5 credits, requires the feature plus a
2598
2762
  * signer `government_id`, and that signer must be alone in its step.
2763
+ * `IdDocumentFaceMatchBasic` needs the ID Document + Face Match feature
2764
+ * and a valid CPF in `government_id`; estimate the per-signer fee first.
2599
2765
  * @param options - Optional `name`, `message`, `expires_at`,
2600
2766
  * `editor_fields`, `tags`.
2767
+ * @param options.name - Generated document display name.
2768
+ * @param options.message - Signing invitation message.
2769
+ * @param options.expires_at - ISO-8601 signature deadline.
2770
+ * @param options.editor_fields - Template editor values as `{ field_id, value }` entries.
2771
+ * @param options.tags - Tag names attached to the generated document.
2601
2772
  * @param accountId - Override the client's default account ID.
2602
2773
  * @returns The created document (an {@link IDocumentDetailsResponse} with
2603
2774
  * `template_id` set and its `assignment` populated):
@@ -2669,7 +2840,7 @@ var DocumentResource = class extends BaseResource {
2669
2840
  *
2670
2841
  * A dry run: sends only `{ signers }` and consumes nothing. Use it to check
2671
2842
  * balances before calling {@link DocumentResource.createFromTemplate}.
2672
- * `DigitalCertificate` adds two credits per signer and has the same feature,
2843
+ * `DigitalCertificate` adds 0.5 credits per signer and has the same feature,
2673
2844
  * `government_id`, and signing-step prerequisites as document creation.
2674
2845
  *
2675
2846
  * Request body (`application/json`):
@@ -3008,7 +3179,6 @@ function normaliseTemplateSigners(signers) {
3008
3179
  if (signer.step !== void 0) projected.step = signer.step;
3009
3180
  return projected;
3010
3181
  });
3011
- validateSigningOrder(normalised, "template signers");
3012
3182
  return normalised;
3013
3183
  }
3014
3184
  function normaliseTemplateEditorFields(fields) {
@@ -3328,9 +3498,8 @@ var SignerResource = class extends BaseResource {
3328
3498
  * re-filtered here for an exact, case-insensitive email match.
3329
3499
  *
3330
3500
  * Page size is pinned to {@link MAX_LIST_PAGE_SIZE}, the largest page the
3331
- * server actually returns. An exact address realistically matches one
3332
- * signer, but a search term that matched more than that could in principle
3333
- * miss one — the API exposes no exact-email filter to rule that out.
3501
+ * server actually returns. Pages are searched until an exact match is found
3502
+ * or the result set ends, so substring matches cannot hide an existing signer.
3334
3503
  *
3335
3504
  * A `404` from the underlying list is treated as "no match" and mapped to
3336
3505
  * `null`; any other {@link ApiError} propagates.
@@ -3360,12 +3529,16 @@ var SignerResource = class extends BaseResource {
3360
3529
  async findByEmail(email, accountId) {
3361
3530
  this.assertEmail(email);
3362
3531
  try {
3363
- const { data } = await this.list(
3364
- { search: email, "per-page": MAX_LIST_PAGE_SIZE },
3365
- accountId
3366
- );
3367
3532
  const lower = email.toLowerCase();
3368
- return data.find((s) => (s.email ?? "").toLowerCase() === lower) ?? null;
3533
+ for (let page = 1; ; page++) {
3534
+ const { data, meta } = await this.list(
3535
+ { search: email, "per-page": MAX_LIST_PAGE_SIZE, page },
3536
+ accountId
3537
+ );
3538
+ const match = data.find((s) => (s.email ?? "").toLowerCase() === lower);
3539
+ if (match) return match;
3540
+ if (data.length === 0 || (meta?.last_page !== void 0 ? page >= meta.last_page : data.length < MAX_LIST_PAGE_SIZE)) return null;
3541
+ }
3369
3542
  } catch (err) {
3370
3543
  if (err instanceof ApiError && err.statusCode === 404) {
3371
3544
  return null;
@@ -3720,6 +3893,8 @@ var WorkspaceResource = class extends BaseResource {
3720
3893
  * @param accountId - Account to aggregate.
3721
3894
  * @param params - Omit for 12 monthly rows, or request daily rows with
3722
3895
  * `{ granularity: 'daily', month: '2026-06' }`.
3896
+ * @param params.granularity - `monthly` (default) or `daily`.
3897
+ * @param params.month - Month in `YYYY-MM` format; required for daily rows.
3723
3898
  * @returns Zero-filled KPI rows:
3724
3899
  * ```jsonc
3725
3900
  * [{
@@ -3845,6 +4020,7 @@ var WorkspaceResource = class extends BaseResource {
3845
4020
  * @param accountId - The workspace to delete.
3846
4021
  * @param options - Set `force: true` to cancel an active paid subscription
3847
4022
  * and proceed with deletion.
4023
+ * @param options.force - Cancel an active subscription and bypass deletion restrictions.
3848
4024
  * @returns Nothing on success (`200` with no meaningful body).
3849
4025
  * @throws {ValidationError} If `accountId` is missing.
3850
4026
  * @throws {ApiError} `400` (with a `restrictions` list) when the workspace
@@ -4227,6 +4403,8 @@ var WebhookResource = class extends BaseResource {
4227
4403
  * `account:read` scope.
4228
4404
  *
4229
4405
  * @param accountId - Override the client's default account ID.
4406
+ * @param params - Optional endpoint filters.
4407
+ * @param params.url - Match the exact registered endpoint URL.
4230
4408
  * @returns Every endpoint (1 on free plans, up to 3 on paid plans):
4231
4409
  * ```jsonc
4232
4410
  * [
@@ -4252,9 +4430,14 @@ var WebhookResource = class extends BaseResource {
4252
4430
  * const signed = endpoints.filter((endpoint) => endpoint.signing_enabled);
4253
4431
  * ```
4254
4432
  */
4255
- async listEndpoints(accountId) {
4433
+ async listEndpoints(accountId, params = {}) {
4434
+ assertRecord(params, "webhook endpoint filters");
4435
+ if (params.url !== void 0) validateWebhookUrl(params.url);
4256
4436
  const path2 = this.endpointsPath(accountId);
4257
- return this.call("Failed to list webhook endpoints", () => this.http.get(path2));
4437
+ return this.call(
4438
+ "Failed to list webhook endpoints",
4439
+ () => this.http.get(path2, params.url === void 0 ? void 0 : { params: { url: params.url } })
4440
+ );
4258
4441
  }
4259
4442
  /**
4260
4443
  * Register a URL to receive the account's webhook events
@@ -4262,8 +4445,9 @@ var WebhookResource = class extends BaseResource {
4262
4445
  *
4263
4446
  * An account can have 1 endpoint, or up to 3 on paid plans. Each endpoint
4264
4447
  * of a workspace needs a different `url`. With `signing_enabled: true` the
4265
- * API generates a signing secret; read it with
4266
- * {@link WebhookResource.getEndpointSecret}. When `events` is omitted or
4448
+ * API returns a signing `secret` in this creation response. Store it now:
4449
+ * OAuth applications cannot call {@link WebhookResource.getEndpointSecret}
4450
+ * or rotate it later. When `events` is omitted or
4267
4451
  * empty, {@link DEFAULT_WEBHOOK_EVENTS} is sent. OAuth tokens need the
4268
4452
  * `webhooks:write` scope.
4269
4453
  *
@@ -4293,6 +4477,7 @@ var WebhookResource = class extends BaseResource {
4293
4477
  * "events": ["document_ready", "signer_signed_document"],
4294
4478
  * "is_active": true,
4295
4479
  * "signing_enabled": true, // deliveries carry a `webhook-signature` header
4480
+ * "secret": "whsec_c2VjcmV0", // only in this response when signing is enabled
4296
4481
  * "created_at": "2026-10-01T12:00:00Z",
4297
4482
  * "updated_at": "2026-10-01T12:00:00Z"
4298
4483
  * }
@@ -4312,7 +4497,7 @@ var WebhookResource = class extends BaseResource {
4312
4497
  * events: ['document_ready', 'signer_signed_document'],
4313
4498
  * signing_enabled: true,
4314
4499
  * });
4315
- * const { secret } = await client.webhooks.getEndpointSecret(endpoint.id);
4500
+ * if (endpoint.secret) await secretStore.save(endpoint.id, endpoint.secret);
4316
4501
  * ```
4317
4502
  */
4318
4503
  async createEndpoint(payload, accountId) {
@@ -4437,6 +4622,32 @@ var WebhookResource = class extends BaseResource {
4437
4622
  this.logger.info("Deleting webhook endpoint");
4438
4623
  await this.callVoid("Failed to delete webhook endpoint", () => this.http.delete(path2));
4439
4624
  }
4625
+ /**
4626
+ * Delete a webhook endpoint using its registered URL
4627
+ * (`DELETE /accounts/{accountId}/webhooks/endpoints?url=…`).
4628
+ *
4629
+ * No request body. The query URL must match the registered value exactly.
4630
+ * Frees its plan slot; OAuth applications need `webhooks:write`.
4631
+ *
4632
+ * @param url - Exact registered HTTP(S) endpoint URL, including its query.
4633
+ * @param accountId - Override the client's default workspace.
4634
+ * @returns Resolves on acknowledgement (`{ "status": 200, "data": [] }`).
4635
+ * @throws {ValidationError} If the URL is invalid or the account is missing.
4636
+ * @throws {ApiError} `400` for a missing URL; `401` for invalid credentials;
4637
+ * `403` for missing scope; `404` if no endpoint uses the URL; `500` on failure.
4638
+ * @example
4639
+ * ```ts
4640
+ * await client.webhooks.deleteEndpointByUrl('https://example.com/webhooks/assinafy');
4641
+ * ```
4642
+ */
4643
+ async deleteEndpointByUrl(url, accountId) {
4644
+ validateWebhookUrl(url);
4645
+ const path2 = this.endpointsPath(accountId);
4646
+ return this.callVoid(
4647
+ "Failed to delete webhook endpoint",
4648
+ () => this.http.delete(path2, { params: { url } })
4649
+ );
4650
+ }
4440
4651
  /**
4441
4652
  * Return the secret that signs deliveries to an endpoint
4442
4653
  * (`GET /accounts/{accountId}/webhooks/endpoints/{endpointId}/secret`).
@@ -4559,6 +4770,8 @@ var TemplateResource = class extends BaseResource {
4559
4770
  *
4560
4771
  * @param source - The PDF to upload, as a file path or an in-memory buffer.
4561
4772
  * @param options - `name` (display name) and an optional `accountId` override.
4773
+ * @param options.name - Multipart filename override, with a `.pdf` extension.
4774
+ * @param options.accountId - Override the client's default workspace.
4562
4775
  * @returns The created template (envelope unwrapped). Response shape:
4563
4776
  * ```jsonc
4564
4777
  * {
@@ -4724,7 +4937,7 @@ var TemplateResource = class extends BaseResource {
4724
4937
  * @example
4725
4938
  * ```ts
4726
4939
  * const tmpl = await client.templates.get('103ad2171db7979468c3e97eb067');
4727
- * if (tmpl.status === 'Ready') console.log(tmpl.pages.length);
4940
+ * if (tmpl.status === 'Ready') console.log(tmpl.pages?.length ?? 0);
4728
4941
  * ```
4729
4942
  */
4730
4943
  async get(templateId, accountId) {
@@ -4886,6 +5099,7 @@ var TagResource = class extends BaseResource {
4886
5099
  *
4887
5100
  * @param params - Optional filters. `search` matches tag names
4888
5101
  * case-insensitively (substring).
5102
+ * @param params.search - Optional case-insensitive tag-name substring.
4889
5103
  * @param accountId - Override the client's default account ID.
4890
5104
  * @returns The matching tags (list items carry no `resource` field):
4891
5105
  * ```jsonc
@@ -5059,6 +5273,8 @@ var TagResource = class extends BaseResource {
5059
5273
  * @param tagId - The tag to delete.
5060
5274
  * @param options - `force` to detach-and-delete when the tag is still in
5061
5275
  * use, and `accountId` to override the client's default account ID.
5276
+ * @param options.force - Detach the tag from documents before deletion.
5277
+ * @param options.accountId - Override the client's default workspace.
5062
5278
  * @returns `{ deleted: true }` when the tag was deleted.
5063
5279
  * @throws {ValidationError} If `tagId` is missing, or no account ID is available.
5064
5280
  * @throws {ApiError} `404` if the tag does not exist; `409` if the tag is
@@ -6624,6 +6840,8 @@ var FieldsResource = class extends BaseResource {
6624
6840
  * @param value - The value to check (validated against the field's
6625
6841
  * type/regex). Sent as `{ value }` in the request body.
6626
6842
  * @param options - Account override and optional legacy `signerAccessCode`.
6843
+ * @param options.accountId - Override the client's default workspace.
6844
+ * @param options.signerAccessCode - Legacy signer code sent as a query parameter.
6627
6845
  * @returns The validation result. Response shape:
6628
6846
  * ```jsonc
6629
6847
  * {
@@ -6684,6 +6902,8 @@ var FieldsResource = class extends BaseResource {
6684
6902
  *
6685
6903
  * @param entries - Non-empty array of `{ field_id, value }` pairs.
6686
6904
  * @param options - Account override and optional legacy `signerAccessCode`.
6905
+ * @param options.accountId - Override the client's default workspace.
6906
+ * @param options.signerAccessCode - Legacy signer code sent as a query parameter.
6687
6907
  * @returns One validation result per entry. Response shape:
6688
6908
  * ```jsonc
6689
6909
  * [
@@ -7194,7 +7414,8 @@ var SignerDocumentsResource = class extends BaseResource {
7194
7414
  * "has_accepted_terms": false,
7195
7415
  * "has_signature": false,
7196
7416
  * "has_initial": false,
7197
- * "is_signature_reusable": false
7417
+ * "is_signature_reusable": false,
7418
+ * "verification_method": "IdDocumentFaceMatchBasic"
7198
7419
  * }
7199
7420
  * ```
7200
7421
  * @throws {ValidationError} If `signerAccessCode` is missing.
@@ -7215,6 +7436,92 @@ var SignerDocumentsResource = class extends BaseResource {
7215
7436
  () => this.http.get("/signers/self", { params: { "signer-access-code": code } })
7216
7437
  );
7217
7438
  }
7439
+ /**
7440
+ * Read the signer's identity verification state
7441
+ * (`GET /signers/identity-verification?signer-access-code=…`).
7442
+ *
7443
+ * No request body or workspace credentials. Reads a pending provider
7444
+ * decision when available. A new session can start before the first capture
7445
+ * or after `Expired`; `Declined` and `Abandoned` require a new document and
7446
+ * assignment. `InReview` lets the signer continue; account approval gates
7447
+ * certification, with `pending_identity_review` after everyone signs.
7448
+ *
7449
+ * @param signerAccessCode - Access code from the signer's signing link.
7450
+ * @returns Provider state, with nullable fields before a session exists:
7451
+ * ```jsonc
7452
+ * {
7453
+ * "can_start": false, "status": "Pending",
7454
+ * "url": "https://verify.example.com/c/session#t=opaque",
7455
+ * "expires_at": "2026-10-16T12:30:00Z", "completed_at": null
7456
+ * }
7457
+ * ```
7458
+ * `url` exists only while Pending. It is a bearer link: open it intact,
7459
+ * including its fragment, and keep it out of logs and browser storage.
7460
+ * @throws {ValidationError} If the access code is blank.
7461
+ * @throws {ApiError} `401` for an invalid/expired code; `500` for a server failure.
7462
+ * @example
7463
+ * ```ts
7464
+ * const state = await client.signerDocuments.getIdentityVerification(accessCode);
7465
+ * console.log(state.status, state.can_start);
7466
+ * ```
7467
+ */
7468
+ async getIdentityVerification(signerAccessCode) {
7469
+ const code = this.requireId(signerAccessCode, "signer-access-code");
7470
+ return this.call(
7471
+ "Failed to fetch signer identity verification",
7472
+ () => this.http.get("/signers/identity-verification", { params: { "signer-access-code": code } })
7473
+ );
7474
+ }
7475
+ /**
7476
+ * Record biometric consent and open an identity verification session
7477
+ * (`POST /signers/identity-verification?signer-access-code=…`).
7478
+ *
7479
+ * Send only after the signer explicitly consents. Starts a session when
7480
+ * none exists or replaces an Expired session. Other states return `400`;
7481
+ * resending a notification never replaces a live session. The account is
7482
+ * billed at assignment creation, with no new charge for a restart.
7483
+ *
7484
+ * Request body (`application/json`):
7485
+ * ```jsonc
7486
+ * { "consent": true }
7487
+ * ```
7488
+ * @param signerAccessCode - Access code from the signer's signing link.
7489
+ * @param payload - Explicit consent from the signer.
7490
+ * @param payload.consent - Must be `true`; never default or infer consent.
7491
+ * @returns The newly opened provider session:
7492
+ * ```jsonc
7493
+ * {
7494
+ * "id": "verification_example",
7495
+ * "url": "https://verify.example.com/c/session#t=opaque",
7496
+ * "expires_at": "2026-10-16T12:30:00Z"
7497
+ * }
7498
+ * ```
7499
+ * `expires_at` can be null. Open the URL as-is; it is a bearer credential
7500
+ * and its fragment must survive navigation. Do not log or persist it in
7501
+ * browser storage. No workspace credential is attached to this call.
7502
+ * @throws {ValidationError} If the code is blank or consent is not `true`.
7503
+ * @throws {ApiError} `400` when a non-expired session already exists;
7504
+ * `401` for an invalid/expired code; `500` for a provider/server failure.
7505
+ * @example
7506
+ * ```ts
7507
+ * // Inside the handler for the signer's explicit consent action:
7508
+ * const session = await client.signerDocuments.startIdentityVerification(accessCode, { consent: true });
7509
+ * response.redirect(session.url);
7510
+ * ```
7511
+ */
7512
+ async startIdentityVerification(signerAccessCode, payload) {
7513
+ const code = this.requireId(signerAccessCode, "signer-access-code");
7514
+ assertRecord(payload, "identity verification payload");
7515
+ if (payload.consent !== true) {
7516
+ throw new ValidationError("Explicit biometric-processing consent is required");
7517
+ }
7518
+ return this.call(
7519
+ "Failed to start signer identity verification",
7520
+ () => this.http.post("/signers/identity-verification", { consent: true }, {
7521
+ params: { "signer-access-code": code }
7522
+ })
7523
+ );
7524
+ }
7218
7525
  /**
7219
7526
  * Accept the platform terms of use as the signer
7220
7527
  * (`PUT /signers/accept-terms?signer-access-code=…`).
@@ -7248,10 +7555,10 @@ var SignerDocumentsResource = class extends BaseResource {
7248
7555
  );
7249
7556
  }
7250
7557
  /**
7251
- * Verify the signer's email one-time password
7558
+ * Verify the signer's email or WhatsApp one-time password
7252
7559
  * (`POST /verify?signer-access-code=…`).
7253
7560
  *
7254
- * Confirms the 6-digit OTP the platform emailed the signer. The access code
7561
+ * Confirms the 6-digit OTP sent through the selected channel. The access code
7255
7562
  * authenticates via the `signer-access-code` **query param**; the request
7256
7563
  * **body carries only `verification-code`** (putting the access code in the
7257
7564
  * body leaves the request unauthenticated → `401`).
@@ -7265,6 +7572,8 @@ var SignerDocumentsResource = class extends BaseResource {
7265
7572
  *
7266
7573
  * @param payload - `signerAccessCode` (the signing-link code) and
7267
7574
  * `verificationCode` (the OTP the signer received).
7575
+ * @param payload.signerAccessCode - Signing-link code sent only in the query.
7576
+ * @param payload.verificationCode - Email or WhatsApp OTP sent as `verification-code`.
7268
7577
  * @returns Resolves when the API acknowledges the operation. The response
7269
7578
  * envelope has no `data` field and is intentionally discarded.
7270
7579
  * @throws {ValidationError} If `signerAccessCode` or `verificationCode` is
@@ -7425,7 +7734,7 @@ var SignerDocumentsResource = class extends BaseResource {
7425
7734
  * "expires_at": null,
7426
7735
  * "signers": [
7427
7736
  * { "id": "19e6b92e7895332ed9708535d8c", "step": 1, "email": "signer@example.com",
7428
- * "full_name": "Example Signer", "notified": true, "completed": false }
7737
+ * "full_name": "Example Signer", "notified": true }
7429
7738
  * ],
7430
7739
  * "items": [
7431
7740
  * { "id": "item-1", "page": { "id": "page-1", "number": 1, "height": 1651, "width": 1275,
@@ -8038,7 +8347,8 @@ var WebhookVerifier = class {
8038
8347
  * @param toleranceSeconds - Accepted clock distance. Defaults to `300`.
8039
8348
  * @returns `true` only when a signature entry matches (constant-time) and
8040
8349
  * the timestamp is fresh; `false` when verification is disabled, a header
8041
- * is missing, or anything does not match.
8350
+ * is missing, the tolerance is not finite and non-negative, or anything
8351
+ * does not match.
8042
8352
  *
8043
8353
  * @example
8044
8354
  * ```ts
@@ -8054,7 +8364,7 @@ var WebhookVerifier = class {
8054
8364
  */
8055
8365
  verifySignature(payload, headers, toleranceSeconds = DEFAULT_TOLERANCE_SECONDS) {
8056
8366
  const key = decodeSecret(this.webhookSecret);
8057
- if (!key || typeof payload !== "string" && !Buffer.isBuffer(payload) || !headers) {
8367
+ if (!key || typeof payload !== "string" && !Buffer.isBuffer(payload) || !headers || !Number.isFinite(toleranceSeconds) || toleranceSeconds < 0) {
8058
8368
  return false;
8059
8369
  }
8060
8370
  const id = header(headers, "webhook-id");