@assinafy/sdk 2.7.1 → 2.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +50 -1
- package/README.en.md +89 -17
- package/README.md +86 -16
- package/dist/index.d.mts +399 -42
- package/dist/index.d.ts +399 -42
- package/dist/index.js +387 -44
- package/dist/index.mjs +386 -44
- package/docs/API_COVERAGE.md +14 -8
- package/docs/COMPATIBILITY.md +67 -8
- package/package.json +1 -1
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.
|
|
631
|
+
version: "2.8.1",
|
|
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,14 @@ 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"]);
|
|
979
|
+
var DIGITAL_CERTIFICATE_REQUIRES_VIRTUAL_METHOD = "digital_certificate_requires_virtual_method";
|
|
972
980
|
var ALLOWED_NOTIFICATION_METHODS = {
|
|
973
981
|
Email: /* @__PURE__ */ new Set(["Email"]),
|
|
974
982
|
Whatsapp: /* @__PURE__ */ new Set(["Whatsapp"]),
|
|
975
|
-
DigitalCertificate: NOTIFICATION_METHODS
|
|
983
|
+
DigitalCertificate: NOTIFICATION_METHODS,
|
|
984
|
+
IdDocumentFaceMatchBasic: NOTIFICATION_METHODS
|
|
976
985
|
};
|
|
977
986
|
function validateAssignmentSignerOptions(signer, label = "signer") {
|
|
978
987
|
if (signer.verification_method !== void 0 && (typeof signer.verification_method !== "string" || !VERIFICATION_METHODS.has(signer.verification_method))) {
|
|
@@ -1022,6 +1031,15 @@ function validateSigningOrder(signers, label = "signers") {
|
|
|
1022
1031
|
}
|
|
1023
1032
|
}
|
|
1024
1033
|
}
|
|
1034
|
+
function validateDigitalCertificateMethod(method, signers) {
|
|
1035
|
+
if (method === "virtual" || !signers.some((signer) => signer.verification_method === "DigitalCertificate")) {
|
|
1036
|
+
return;
|
|
1037
|
+
}
|
|
1038
|
+
throw new ValidationError("DigitalCertificate signers require method: virtual", {
|
|
1039
|
+
code: DIGITAL_CERTIFICATE_REQUIRES_VIRTUAL_METHOD,
|
|
1040
|
+
method: method ?? null
|
|
1041
|
+
});
|
|
1042
|
+
}
|
|
1025
1043
|
function buildAssignmentPayload(payload) {
|
|
1026
1044
|
assertRecord(payload, "assignment payload");
|
|
1027
1045
|
const method = payload.method ?? "virtual";
|
|
@@ -1050,6 +1068,7 @@ function buildAssignmentPayload(payload) {
|
|
|
1050
1068
|
throw new ValidationError("copy_receivers must be an array of non-empty signer IDs");
|
|
1051
1069
|
}
|
|
1052
1070
|
const normalisedSigners = signers.map((ref) => normaliseSignerRef(ref));
|
|
1071
|
+
validateDigitalCertificateMethod(method, normalisedSigners);
|
|
1053
1072
|
validateSigningOrder(normalisedSigners, "assignment signers");
|
|
1054
1073
|
return cleanParams({
|
|
1055
1074
|
method,
|
|
@@ -1074,9 +1093,11 @@ function buildAssignmentEstimatePayload(payload) {
|
|
|
1074
1093
|
if (method === "collect" && (!entries || entries.length === 0)) {
|
|
1075
1094
|
throw new ValidationError("At least one field-placement entry is required for a collect cost estimate");
|
|
1076
1095
|
}
|
|
1096
|
+
const normalisedSigners = signers.map((signer) => normaliseEstimateSigner(signer));
|
|
1097
|
+
validateDigitalCertificateMethod(method, normalisedSigners);
|
|
1077
1098
|
return cleanParams({
|
|
1078
1099
|
method,
|
|
1079
|
-
signers:
|
|
1100
|
+
signers: normalisedSigners,
|
|
1080
1101
|
entries
|
|
1081
1102
|
});
|
|
1082
1103
|
}
|
|
@@ -1312,8 +1333,12 @@ var AssignmentResource = class extends BaseResource {
|
|
|
1312
1333
|
* {@link buildAssignmentPayload}. A `virtual` assignment may be created at
|
|
1313
1334
|
* `uploaded`, `metadata_processing`, or `metadata_ready` and is promoted
|
|
1314
1335
|
* automatically; `collect` requires rendered pages at `metadata_ready`.
|
|
1315
|
-
* `DigitalCertificate` costs
|
|
1316
|
-
* signer `government_id`,
|
|
1336
|
+
* `DigitalCertificate` costs 0.5 credits, requires the feature plus a
|
|
1337
|
+
* signer `government_id`, that signer must be alone in its step, and the
|
|
1338
|
+
* assignment must use `method: 'virtual'`. Certificate completion marks a
|
|
1339
|
+
* virtual item complete; it cannot submit placed `collect` fields.
|
|
1340
|
+
* `IdDocumentFaceMatchBasic` needs the ID Document + Face Match feature
|
|
1341
|
+
* and a valid CPF in the signer's `government_id`; estimate its fee first.
|
|
1317
1342
|
*
|
|
1318
1343
|
* Request body (`application/json`):
|
|
1319
1344
|
* ```jsonc
|
|
@@ -1411,7 +1436,9 @@ var AssignmentResource = class extends BaseResource {
|
|
|
1411
1436
|
* }
|
|
1412
1437
|
* ```
|
|
1413
1438
|
* @throws {ValidationError} If `documentId` is missing, no signer is
|
|
1414
|
-
* supplied,
|
|
1439
|
+
* supplied, a signer reference is invalid, or `DigitalCertificate` is
|
|
1440
|
+
* combined with `collect`. The last case has `errors.code ===
|
|
1441
|
+
* 'digital_certificate_requires_virtual_method'`.
|
|
1415
1442
|
* @throws {ApiError} `400` for an invalid assignment or unmet verification
|
|
1416
1443
|
* precondition; otherwise if the API rejects the request.
|
|
1417
1444
|
*
|
|
@@ -1449,8 +1476,10 @@ var AssignmentResource = class extends BaseResource {
|
|
|
1449
1476
|
* only `verification_method` / `notification_methods` (or `{}` for the
|
|
1450
1477
|
* default Email channel). {@link buildAssignmentEstimatePayload} projects
|
|
1451
1478
|
* exactly the fields permitted by the estimate schema.
|
|
1452
|
-
* `DigitalCertificate` is priced at
|
|
1453
|
-
* subject to the feature
|
|
1479
|
+
* `DigitalCertificate` is priced at 0.5 credits per signer and remains
|
|
1480
|
+
* subject to the feature and identity requirements. It is valid only with
|
|
1481
|
+
* `method: 'virtual'`; the SDK refuses to quote a certificate/`collect`
|
|
1482
|
+
* request because that assignment cannot be completed.
|
|
1454
1483
|
* Current documented unit prices are 1 credit for an extra document, 0 for
|
|
1455
1484
|
* email notification, and 0.45 for WhatsApp notification; a digital
|
|
1456
1485
|
* certificate charge is added on top of its notification cost.
|
|
@@ -1495,7 +1524,9 @@ var AssignmentResource = class extends BaseResource {
|
|
|
1495
1524
|
* ```
|
|
1496
1525
|
* @throws {ValidationError} If `documentId` is missing, a `virtual` request
|
|
1497
1526
|
* has no signer entry, or a `collect` request has no signer entry or no
|
|
1498
|
-
* field-placement entry
|
|
1527
|
+
* field-placement entry, or combines `DigitalCertificate` with `collect`.
|
|
1528
|
+
* The last case has `errors.code ===
|
|
1529
|
+
* 'digital_certificate_requires_virtual_method'`.
|
|
1499
1530
|
* @throws {ApiError} If the API rejects the request.
|
|
1500
1531
|
*
|
|
1501
1532
|
* @example
|
|
@@ -1725,6 +1756,148 @@ var AssignmentResource = class extends BaseResource {
|
|
|
1725
1756
|
)
|
|
1726
1757
|
);
|
|
1727
1758
|
}
|
|
1759
|
+
/**
|
|
1760
|
+
* Read the account's signer identity review
|
|
1761
|
+
* (`GET /documents/{documentId}/assignments/{assignmentId}/signers/{signerId}/identity-verification`).
|
|
1762
|
+
*
|
|
1763
|
+
* No request body. `InReview` lets the signer continue signing but holds
|
|
1764
|
+
* certification. Evidence is a summary without images or biometrics; a
|
|
1765
|
+
* directly approved verification exposes evidence on its activity instead.
|
|
1766
|
+
*
|
|
1767
|
+
* @param documentId - Document owning the assignment.
|
|
1768
|
+
* @param assignmentId - Assignment containing the signer.
|
|
1769
|
+
* @param signerId - Signer whose identity is under review.
|
|
1770
|
+
* @returns The complete review summary:
|
|
1771
|
+
* ```jsonc
|
|
1772
|
+
* {
|
|
1773
|
+
* "id": "verification_example", "status": "InReview",
|
|
1774
|
+
* "provider": "AssinafyVerify", "verification_method": "IdDocumentFaceMatchBasic",
|
|
1775
|
+
* "reason_codes": [{ "code": "NAME_MISMATCH", "description": "Name differs" }],
|
|
1776
|
+
* "evidence_available": true,
|
|
1777
|
+
* "expected": { "name": "Example Signer", "cpf": null },
|
|
1778
|
+
* "document": { "type": "CNH", "name": "EXAMPLE SIGNER", "cpf": null },
|
|
1779
|
+
* "matches": { "cpf": null, "name": 0.52, "birth_date": null },
|
|
1780
|
+
* "checks": [{ "name": "name", "result": "review", "score": 0.52, "reasons": ["NAME_MISMATCH"] }],
|
|
1781
|
+
* "images": ["document_front", "face"], // available only while InReview
|
|
1782
|
+
* "ruleset_version": "2026-10-12.2", "evidence_sha256": null,
|
|
1783
|
+
* "reviewed_by": null, "reviewed_at": null, "review_note": null, "completed_at": null
|
|
1784
|
+
* }
|
|
1785
|
+
* ```
|
|
1786
|
+
* @throws {ValidationError} If any ID is blank or invalid for a URL.
|
|
1787
|
+
* @throws {ApiError} `401` for invalid credentials; `404` for an unknown
|
|
1788
|
+
* assignment, signer or verification; `500` for a server failure.
|
|
1789
|
+
* @example
|
|
1790
|
+
* ```ts
|
|
1791
|
+
* const review = await client.assignments.getIdentityVerification('doc-1', 'asg-1', 'signer-1');
|
|
1792
|
+
* console.log(review.status, review.images.length);
|
|
1793
|
+
* ```
|
|
1794
|
+
*/
|
|
1795
|
+
async getIdentityVerification(documentId, assignmentId, signerId) {
|
|
1796
|
+
const path2 = this.identityVerificationPath(documentId, assignmentId, signerId);
|
|
1797
|
+
return this.call("Failed to fetch signer identity review", () => this.http.get(path2));
|
|
1798
|
+
}
|
|
1799
|
+
/**
|
|
1800
|
+
* Download identity review evidence
|
|
1801
|
+
* (`GET /documents/{documentId}/assignments/{assignmentId}/signers/{signerId}/identity-verification/images/{name}`).
|
|
1802
|
+
*
|
|
1803
|
+
* No request body. The provider supplies the bytes on each request; Assinafy
|
|
1804
|
+
* never stores them. Available only while the review is open. Keep these
|
|
1805
|
+
* sensitive bytes out of caches and logs (`Cache-Control: no-store`).
|
|
1806
|
+
*
|
|
1807
|
+
* @param documentId - Document owning the assignment.
|
|
1808
|
+
* @param assignmentId - Assignment containing the signer.
|
|
1809
|
+
* @param signerId - Signer whose evidence to view.
|
|
1810
|
+
* @param name - One of the review's `images`: `document_front`,
|
|
1811
|
+
* `document_back`, `document_pdf`, or `face`.
|
|
1812
|
+
* @returns Raw JPEG, PNG or PDF bytes as a `Buffer`.
|
|
1813
|
+
* @throws {ValidationError} If an ID or image name is invalid.
|
|
1814
|
+
* @throws {ApiError} `401` for invalid credentials; `404` for absent evidence
|
|
1815
|
+
* or a decided review; `500` for a provider/server failure.
|
|
1816
|
+
* @example
|
|
1817
|
+
* ```ts
|
|
1818
|
+
* const bytes = await client.assignments.downloadIdentityVerificationImage('doc-1', 'asg-1', 'signer-1', 'face');
|
|
1819
|
+
* ```
|
|
1820
|
+
*/
|
|
1821
|
+
async downloadIdentityVerificationImage(documentId, assignmentId, signerId, name) {
|
|
1822
|
+
const path2 = this.identityVerificationPath(documentId, assignmentId, signerId);
|
|
1823
|
+
if (!["document_front", "document_back", "document_pdf", "face"].includes(name)) {
|
|
1824
|
+
throw new ValidationError("Invalid identity verification image name");
|
|
1825
|
+
}
|
|
1826
|
+
return this.callBinary(
|
|
1827
|
+
"Failed to download identity review evidence",
|
|
1828
|
+
() => this.http.get(`${path2}/images/${name}`, { responseType: "arraybuffer" })
|
|
1829
|
+
);
|
|
1830
|
+
}
|
|
1831
|
+
/**
|
|
1832
|
+
* Decide a signer identity review
|
|
1833
|
+
* (`POST /documents/{documentId}/assignments/{assignmentId}/signers/{signerId}/identity-verification/review`).
|
|
1834
|
+
*
|
|
1835
|
+
* Requires `InReview` and a document at `pending_signature` or
|
|
1836
|
+
* `pending_identity_review`. Approval allows certification once all signers
|
|
1837
|
+
* sign and every review is approved. Rejection cancels the document as
|
|
1838
|
+
* `rejected_by_user` and sends cancellation notices to signers and copy
|
|
1839
|
+
* receivers. The note is hidden from them; the provider receives the decision.
|
|
1840
|
+
*
|
|
1841
|
+
* Request body (`application/json`):
|
|
1842
|
+
* ```jsonc
|
|
1843
|
+
* { "decision": "Approved", "note": "Verified independently." }
|
|
1844
|
+
* ```
|
|
1845
|
+
* @param documentId - Document owning the assignment.
|
|
1846
|
+
* @param assignmentId - Assignment containing the signer.
|
|
1847
|
+
* @param signerId - Signer whose review to decide.
|
|
1848
|
+
* @param payload - Explicit account review decision.
|
|
1849
|
+
* @param payload.decision - `Approved` or `Rejected`.
|
|
1850
|
+
* @param payload.note - Optional nullable note, at most 2000 characters.
|
|
1851
|
+
* @returns The updated review, in the full
|
|
1852
|
+
* {@link AssignmentResource.getIdentityVerification} shape:
|
|
1853
|
+
* ```jsonc
|
|
1854
|
+
* {
|
|
1855
|
+
* "id": "verification_example", "status": "Approved",
|
|
1856
|
+
* "provider": "AssinafyVerify", "verification_method": "IdDocumentFaceMatchBasic",
|
|
1857
|
+
* "reason_codes": [{ "code": "NAME_MISMATCH", "description": "Name differs" }],
|
|
1858
|
+
* "evidence_available": true,
|
|
1859
|
+
* "expected": { "name": "Example Signer", "cpf": null },
|
|
1860
|
+
* "document": { "type": "CNH", "name": "EXAMPLE SIGNER", "cpf": null },
|
|
1861
|
+
* "matches": { "cpf": null, "name": 0.52, "birth_date": null },
|
|
1862
|
+
* "checks": [{ "name": "name", "result": "review", "score": 0.52, "reasons": ["NAME_MISMATCH"] }],
|
|
1863
|
+
* "images": [], "ruleset_version": "2026-10-12.2", "evidence_sha256": null,
|
|
1864
|
+
* "reviewed_by": { "id": "user_example", "name": "Example Reviewer" },
|
|
1865
|
+
* "reviewed_at": "2026-10-16T12:00:00Z", "review_note": "Verified independently.",
|
|
1866
|
+
* "completed_at": "2026-10-16T12:00:00Z"
|
|
1867
|
+
* }
|
|
1868
|
+
* ```
|
|
1869
|
+
* @throws {ValidationError} If IDs, decision or note are invalid.
|
|
1870
|
+
* @throws {ApiError} `400` for a closed review or invalid document state;
|
|
1871
|
+
* `401` for invalid credentials; `404` if absent; `500` for a server failure.
|
|
1872
|
+
* @example
|
|
1873
|
+
* ```ts
|
|
1874
|
+
* await client.assignments.reviewIdentityVerification('doc-1', 'asg-1', 'signer-1', {
|
|
1875
|
+
* decision: 'Approved', note: 'Verified independently.',
|
|
1876
|
+
* });
|
|
1877
|
+
* ```
|
|
1878
|
+
*/
|
|
1879
|
+
async reviewIdentityVerification(documentId, assignmentId, signerId, payload) {
|
|
1880
|
+
const path2 = this.identityVerificationPath(documentId, assignmentId, signerId);
|
|
1881
|
+
assertRecord(payload, "identity review payload");
|
|
1882
|
+
if (payload.decision !== "Approved" && payload.decision !== "Rejected") {
|
|
1883
|
+
throw new ValidationError("decision must be Approved or Rejected");
|
|
1884
|
+
}
|
|
1885
|
+
if (payload.note !== void 0 && payload.note !== null && (typeof payload.note !== "string" || [...payload.note].length > 2e3)) {
|
|
1886
|
+
throw new ValidationError("note must be a string of at most 2000 characters, or null");
|
|
1887
|
+
}
|
|
1888
|
+
const body = { decision: payload.decision };
|
|
1889
|
+
if (payload.note !== void 0) body.note = payload.note;
|
|
1890
|
+
return this.call(
|
|
1891
|
+
"Failed to decide signer identity review",
|
|
1892
|
+
() => this.http.post(`${path2}/review`, body)
|
|
1893
|
+
);
|
|
1894
|
+
}
|
|
1895
|
+
identityVerificationPath(documentId, assignmentId, signerId) {
|
|
1896
|
+
const docId = this.pathSegment(documentId, "Document ID");
|
|
1897
|
+
const asgId = this.pathSegment(assignmentId, "Assignment ID");
|
|
1898
|
+
const sid = this.pathSegment(signerId, "Signer ID");
|
|
1899
|
+
return `/documents/${docId}/assignments/${asgId}/signers/${sid}/identity-verification`;
|
|
1900
|
+
}
|
|
1728
1901
|
};
|
|
1729
1902
|
|
|
1730
1903
|
// src/resources/documents.ts
|
|
@@ -1738,6 +1911,7 @@ function validateDocumentWaitOptions(options) {
|
|
|
1738
1911
|
var READY_STATUSES = /* @__PURE__ */ new Set([
|
|
1739
1912
|
"metadata_ready",
|
|
1740
1913
|
"pending_signature",
|
|
1914
|
+
"pending_identity_review",
|
|
1741
1915
|
"certificated"
|
|
1742
1916
|
]);
|
|
1743
1917
|
var FAILED_STATUSES = /* @__PURE__ */ new Set([
|
|
@@ -1764,6 +1938,9 @@ var DocumentResource = class extends BaseResource {
|
|
|
1764
1938
|
*
|
|
1765
1939
|
* @param source - The PDF to upload, as a file path or an in-memory buffer.
|
|
1766
1940
|
* @param options - Display name, metadata, and account override.
|
|
1941
|
+
* @param options.name - Multipart filename override; the API derives the display name from it.
|
|
1942
|
+
* @param options.metadata - JSON metadata (compatibility multipart part).
|
|
1943
|
+
* @param options.accountId - Override the client's default workspace.
|
|
1767
1944
|
* @returns The created document, freshly uploaded (`status: 'uploaded'`,
|
|
1768
1945
|
* empty `pages` until `metadata_ready`). Response shape:
|
|
1769
1946
|
* ```jsonc
|
|
@@ -1874,7 +2051,7 @@ var DocumentResource = class extends BaseResource {
|
|
|
1874
2051
|
* method: 'virtual',
|
|
1875
2052
|
* 'per-page': 50,
|
|
1876
2053
|
* });
|
|
1877
|
-
* console.log(data[0]?.pages
|
|
2054
|
+
* console.log(data[0]?.pages?.length, meta?.total);
|
|
1878
2055
|
* ```
|
|
1879
2056
|
*/
|
|
1880
2057
|
async list(params = {}, accountId) {
|
|
@@ -2087,7 +2264,8 @@ var DocumentResource = class extends BaseResource {
|
|
|
2087
2264
|
}
|
|
2088
2265
|
/**
|
|
2089
2266
|
* Poll {@link DocumentResource.details} until the document reaches a ready
|
|
2090
|
-
* status (`metadata_ready`, `pending_signature`,
|
|
2267
|
+
* status (`metadata_ready`, `pending_signature`, `pending_identity_review`,
|
|
2268
|
+
* or `certificated`),
|
|
2091
2269
|
* throwing on a terminal failure status or timeout.
|
|
2092
2270
|
*
|
|
2093
2271
|
* Transient errors are tolerated — a `5xx` or `429` is retried on the next
|
|
@@ -2097,6 +2275,8 @@ var DocumentResource = class extends BaseResource {
|
|
|
2097
2275
|
* @param documentId - The document to wait on.
|
|
2098
2276
|
* @param options - `maxWaitMs` (default `30_000`) and `pollIntervalMs`
|
|
2099
2277
|
* (default `2_000`).
|
|
2278
|
+
* @param options.maxWaitMs - Finite non-negative wait budget in milliseconds; default `30_000`.
|
|
2279
|
+
* @param options.pollIntervalMs - Finite positive polling interval in milliseconds; default `2_000`.
|
|
2100
2280
|
* @returns The document details once it reaches a ready status (see
|
|
2101
2281
|
* {@link DocumentResource.details} for the shape).
|
|
2102
2282
|
* @throws {ValidationError} If `documentId` is missing, the document enters
|
|
@@ -2364,6 +2544,9 @@ var DocumentResource = class extends BaseResource {
|
|
|
2364
2544
|
* names are not portable identifiers and should not be used here. This
|
|
2365
2545
|
* overwrites the existing set — use
|
|
2366
2546
|
* {@link DocumentResource.addTags} to append.
|
|
2547
|
+
* Older sandbox deployments interpret these strings as names and create
|
|
2548
|
+
* ID-named tags for ID inputs; pass existing names intentionally there.
|
|
2549
|
+
* Strings are sent unchanged. See `docs/COMPATIBILITY.md` for this variant.
|
|
2367
2550
|
*
|
|
2368
2551
|
* Request body (`application/json`):
|
|
2369
2552
|
* ```jsonc
|
|
@@ -2415,6 +2598,8 @@ var DocumentResource = class extends BaseResource {
|
|
|
2415
2598
|
* `tags` is a non-empty array of tag **IDs**. Attaching an ID already
|
|
2416
2599
|
* present is a no-op. To replace the whole set instead, use
|
|
2417
2600
|
* {@link DocumentResource.replaceTags}.
|
|
2601
|
+
* On older name-based sandbox deployments, pass existing tag names
|
|
2602
|
+
* intentionally; ID inputs create ID-named tags. No automatic remapping occurs.
|
|
2418
2603
|
*
|
|
2419
2604
|
* Request body (`application/json`):
|
|
2420
2605
|
* ```jsonc
|
|
@@ -2534,10 +2719,20 @@ var DocumentResource = class extends BaseResource {
|
|
|
2534
2719
|
* plus optional `verification_method`, `notification_methods`, `step`).
|
|
2535
2720
|
* Only one notification method is allowed per signer; when only one of the
|
|
2536
2721
|
* verification/notification fields is supplied, the API infers the other.
|
|
2537
|
-
* `DigitalCertificate` costs
|
|
2538
|
-
* signer `government_id`, and that signer must be alone in its step.
|
|
2722
|
+
* `DigitalCertificate` costs 0.5 credits, requires the feature plus a
|
|
2723
|
+
* signer `government_id`, and that signer must be alone in its step. The
|
|
2724
|
+
* server derives the assignment method from placed template fields but
|
|
2725
|
+
* does not yet reject unusable certificate/`collect` combinations, so the
|
|
2726
|
+
* SDK temporarily refuses certificate signers on this template route.
|
|
2727
|
+
* `IdDocumentFaceMatchBasic` needs the ID Document + Face Match feature
|
|
2728
|
+
* and a valid CPF in `government_id`; estimate the per-signer fee first.
|
|
2539
2729
|
* @param options - Optional `name`, `message`, `expires_at`,
|
|
2540
2730
|
* `editor_fields`, `tags`.
|
|
2731
|
+
* @param options.name - Generated document display name.
|
|
2732
|
+
* @param options.message - Signing invitation message.
|
|
2733
|
+
* @param options.expires_at - ISO-8601 signature deadline.
|
|
2734
|
+
* @param options.editor_fields - Template editor values as `{ field_id, value }` entries.
|
|
2735
|
+
* @param options.tags - Tag names attached to the generated document.
|
|
2541
2736
|
* @param accountId - Override the client's default account ID.
|
|
2542
2737
|
* @returns The created document (an {@link IDocumentDetailsResponse} with
|
|
2543
2738
|
* `template_id` set and its `assignment` populated):
|
|
@@ -2559,15 +2754,16 @@ var DocumentResource = class extends BaseResource {
|
|
|
2559
2754
|
* "updated_at": "2026-07-15T19:59:33Z"
|
|
2560
2755
|
* }
|
|
2561
2756
|
* ```
|
|
2562
|
-
* @throws {ValidationError} If `templateId` is missing
|
|
2563
|
-
* available
|
|
2757
|
+
* @throws {ValidationError} If `templateId` is missing, no account ID is
|
|
2758
|
+
* available, or a signer uses `DigitalCertificate`. Certificate refusals
|
|
2759
|
+
* have `errors.code === 'digital_certificate_requires_virtual_method'`.
|
|
2564
2760
|
* @throws {ApiError} `400` if the signers/roles are invalid or the template
|
|
2565
2761
|
* is not ready.
|
|
2566
2762
|
*
|
|
2567
2763
|
* @example
|
|
2568
2764
|
* ```ts
|
|
2569
2765
|
* await client.documents.createFromTemplate('tmpl_id', [
|
|
2570
|
-
* { role_id: 'role_id', id: 'signer_id', verification_method: '
|
|
2766
|
+
* { role_id: 'role_id', id: 'signer_id', verification_method: 'Email' },
|
|
2571
2767
|
* ], { name: 'My Contract' });
|
|
2572
2768
|
* ```
|
|
2573
2769
|
*/
|
|
@@ -2609,8 +2805,10 @@ var DocumentResource = class extends BaseResource {
|
|
|
2609
2805
|
*
|
|
2610
2806
|
* A dry run: sends only `{ signers }` and consumes nothing. Use it to check
|
|
2611
2807
|
* balances before calling {@link DocumentResource.createFromTemplate}.
|
|
2612
|
-
* `DigitalCertificate`
|
|
2613
|
-
*
|
|
2808
|
+
* `DigitalCertificate` requires a provably `virtual` assignment. Because
|
|
2809
|
+
* this route leaves method detection to the server, the SDK temporarily
|
|
2810
|
+
* refuses certificate signers instead of returning a price for an
|
|
2811
|
+
* assignment that may charge credits but cannot be completed.
|
|
2614
2812
|
*
|
|
2615
2813
|
* Request body (`application/json`):
|
|
2616
2814
|
* ```jsonc
|
|
@@ -2652,14 +2850,15 @@ var DocumentResource = class extends BaseResource {
|
|
|
2652
2850
|
* "message": null
|
|
2653
2851
|
* }
|
|
2654
2852
|
* ```
|
|
2655
|
-
* @throws {ValidationError} If `templateId` is missing
|
|
2656
|
-
* available
|
|
2853
|
+
* @throws {ValidationError} If `templateId` is missing, no account ID is
|
|
2854
|
+
* available, or a signer uses `DigitalCertificate`. Certificate refusals
|
|
2855
|
+
* have `errors.code === 'digital_certificate_requires_virtual_method'`.
|
|
2657
2856
|
* @throws {ApiError} If the API rejects the request.
|
|
2658
2857
|
*
|
|
2659
2858
|
* @example
|
|
2660
2859
|
* ```ts
|
|
2661
2860
|
* const estimate = await client.documents.estimateCostFromTemplate('tmpl_id', [
|
|
2662
|
-
* { role_id: 'role_id', verification_method: '
|
|
2861
|
+
* { role_id: 'role_id', verification_method: 'Email' },
|
|
2663
2862
|
* ]);
|
|
2664
2863
|
* if (!estimate.has_sufficient_resources) throw new Error(estimate.blocking_reason ?? 'insufficient');
|
|
2665
2864
|
* ```
|
|
@@ -2948,7 +3147,7 @@ function normaliseTemplateSigners(signers) {
|
|
|
2948
3147
|
if (signer.step !== void 0) projected.step = signer.step;
|
|
2949
3148
|
return projected;
|
|
2950
3149
|
});
|
|
2951
|
-
|
|
3150
|
+
validateDigitalCertificateMethod(void 0, normalised);
|
|
2952
3151
|
return normalised;
|
|
2953
3152
|
}
|
|
2954
3153
|
function normaliseTemplateEditorFields(fields) {
|
|
@@ -2972,7 +3171,7 @@ function normaliseTemplateCostSigners(signers) {
|
|
|
2972
3171
|
if (!Array.isArray(signers) || signers.length === 0) {
|
|
2973
3172
|
throw new ValidationError("At least one template role is required for cost estimation");
|
|
2974
3173
|
}
|
|
2975
|
-
|
|
3174
|
+
const normalised = signers.map((signer, index) => {
|
|
2976
3175
|
if (!signer || typeof signer !== "object") {
|
|
2977
3176
|
throw new ValidationError(`Template cost signer ${index + 1} is invalid`);
|
|
2978
3177
|
}
|
|
@@ -2989,6 +3188,8 @@ function normaliseTemplateCostSigners(signers) {
|
|
|
2989
3188
|
}
|
|
2990
3189
|
return descriptor;
|
|
2991
3190
|
});
|
|
3191
|
+
validateDigitalCertificateMethod(void 0, normalised);
|
|
3192
|
+
return normalised;
|
|
2992
3193
|
}
|
|
2993
3194
|
function validateWaitOption(value, name) {
|
|
2994
3195
|
if (!Number.isFinite(value) || value < 0 || name === "pollIntervalMs" && value === 0) {
|
|
@@ -3268,9 +3469,8 @@ var SignerResource = class extends BaseResource {
|
|
|
3268
3469
|
* re-filtered here for an exact, case-insensitive email match.
|
|
3269
3470
|
*
|
|
3270
3471
|
* Page size is pinned to {@link MAX_LIST_PAGE_SIZE}, the largest page the
|
|
3271
|
-
* server actually returns.
|
|
3272
|
-
*
|
|
3273
|
-
* miss one — the API exposes no exact-email filter to rule that out.
|
|
3472
|
+
* server actually returns. Pages are searched until an exact match is found
|
|
3473
|
+
* or the result set ends, so substring matches cannot hide an existing signer.
|
|
3274
3474
|
*
|
|
3275
3475
|
* A `404` from the underlying list is treated as "no match" and mapped to
|
|
3276
3476
|
* `null`; any other {@link ApiError} propagates.
|
|
@@ -3300,12 +3500,16 @@ var SignerResource = class extends BaseResource {
|
|
|
3300
3500
|
async findByEmail(email, accountId) {
|
|
3301
3501
|
this.assertEmail(email);
|
|
3302
3502
|
try {
|
|
3303
|
-
const { data } = await this.list(
|
|
3304
|
-
{ search: email, "per-page": MAX_LIST_PAGE_SIZE },
|
|
3305
|
-
accountId
|
|
3306
|
-
);
|
|
3307
3503
|
const lower = email.toLowerCase();
|
|
3308
|
-
|
|
3504
|
+
for (let page = 1; ; page++) {
|
|
3505
|
+
const { data, meta } = await this.list(
|
|
3506
|
+
{ search: email, "per-page": MAX_LIST_PAGE_SIZE, page },
|
|
3507
|
+
accountId
|
|
3508
|
+
);
|
|
3509
|
+
const match = data.find((s) => (s.email ?? "").toLowerCase() === lower);
|
|
3510
|
+
if (match) return match;
|
|
3511
|
+
if (data.length === 0 || (meta?.last_page !== void 0 ? page >= meta.last_page : data.length < MAX_LIST_PAGE_SIZE)) return null;
|
|
3512
|
+
}
|
|
3309
3513
|
} catch (err) {
|
|
3310
3514
|
if (err instanceof ApiError && err.statusCode === 404) {
|
|
3311
3515
|
return null;
|
|
@@ -3660,6 +3864,8 @@ var WorkspaceResource = class extends BaseResource {
|
|
|
3660
3864
|
* @param accountId - Account to aggregate.
|
|
3661
3865
|
* @param params - Omit for 12 monthly rows, or request daily rows with
|
|
3662
3866
|
* `{ granularity: 'daily', month: '2026-06' }`.
|
|
3867
|
+
* @param params.granularity - `monthly` (default) or `daily`.
|
|
3868
|
+
* @param params.month - Month in `YYYY-MM` format; required for daily rows.
|
|
3663
3869
|
* @returns Zero-filled KPI rows:
|
|
3664
3870
|
* ```jsonc
|
|
3665
3871
|
* [{
|
|
@@ -3785,6 +3991,7 @@ var WorkspaceResource = class extends BaseResource {
|
|
|
3785
3991
|
* @param accountId - The workspace to delete.
|
|
3786
3992
|
* @param options - Set `force: true` to cancel an active paid subscription
|
|
3787
3993
|
* and proceed with deletion.
|
|
3994
|
+
* @param options.force - Cancel an active subscription and bypass deletion restrictions.
|
|
3788
3995
|
* @returns Nothing on success (`200` with no meaningful body).
|
|
3789
3996
|
* @throws {ValidationError} If `accountId` is missing.
|
|
3790
3997
|
* @throws {ApiError} `400` (with a `restrictions` list) when the workspace
|
|
@@ -4167,6 +4374,8 @@ var WebhookResource = class extends BaseResource {
|
|
|
4167
4374
|
* `account:read` scope.
|
|
4168
4375
|
*
|
|
4169
4376
|
* @param accountId - Override the client's default account ID.
|
|
4377
|
+
* @param params - Optional endpoint filters.
|
|
4378
|
+
* @param params.url - Match the exact registered endpoint URL.
|
|
4170
4379
|
* @returns Every endpoint (1 on free plans, up to 3 on paid plans):
|
|
4171
4380
|
* ```jsonc
|
|
4172
4381
|
* [
|
|
@@ -4192,9 +4401,14 @@ var WebhookResource = class extends BaseResource {
|
|
|
4192
4401
|
* const signed = endpoints.filter((endpoint) => endpoint.signing_enabled);
|
|
4193
4402
|
* ```
|
|
4194
4403
|
*/
|
|
4195
|
-
async listEndpoints(accountId) {
|
|
4404
|
+
async listEndpoints(accountId, params = {}) {
|
|
4405
|
+
assertRecord(params, "webhook endpoint filters");
|
|
4406
|
+
if (params.url !== void 0) validateWebhookUrl(params.url);
|
|
4196
4407
|
const path2 = this.endpointsPath(accountId);
|
|
4197
|
-
return this.call(
|
|
4408
|
+
return this.call(
|
|
4409
|
+
"Failed to list webhook endpoints",
|
|
4410
|
+
() => this.http.get(path2, params.url === void 0 ? void 0 : { params: { url: params.url } })
|
|
4411
|
+
);
|
|
4198
4412
|
}
|
|
4199
4413
|
/**
|
|
4200
4414
|
* Register a URL to receive the account's webhook events
|
|
@@ -4202,8 +4416,9 @@ var WebhookResource = class extends BaseResource {
|
|
|
4202
4416
|
*
|
|
4203
4417
|
* An account can have 1 endpoint, or up to 3 on paid plans. Each endpoint
|
|
4204
4418
|
* of a workspace needs a different `url`. With `signing_enabled: true` the
|
|
4205
|
-
* API
|
|
4206
|
-
* {@link WebhookResource.getEndpointSecret}
|
|
4419
|
+
* API returns a signing `secret` in this creation response. Store it now:
|
|
4420
|
+
* OAuth applications cannot call {@link WebhookResource.getEndpointSecret}
|
|
4421
|
+
* or rotate it later. When `events` is omitted or
|
|
4207
4422
|
* empty, {@link DEFAULT_WEBHOOK_EVENTS} is sent. OAuth tokens need the
|
|
4208
4423
|
* `webhooks:write` scope.
|
|
4209
4424
|
*
|
|
@@ -4233,6 +4448,7 @@ var WebhookResource = class extends BaseResource {
|
|
|
4233
4448
|
* "events": ["document_ready", "signer_signed_document"],
|
|
4234
4449
|
* "is_active": true,
|
|
4235
4450
|
* "signing_enabled": true, // deliveries carry a `webhook-signature` header
|
|
4451
|
+
* "secret": "whsec_c2VjcmV0", // only in this response when signing is enabled
|
|
4236
4452
|
* "created_at": "2026-10-01T12:00:00Z",
|
|
4237
4453
|
* "updated_at": "2026-10-01T12:00:00Z"
|
|
4238
4454
|
* }
|
|
@@ -4252,7 +4468,7 @@ var WebhookResource = class extends BaseResource {
|
|
|
4252
4468
|
* events: ['document_ready', 'signer_signed_document'],
|
|
4253
4469
|
* signing_enabled: true,
|
|
4254
4470
|
* });
|
|
4255
|
-
*
|
|
4471
|
+
* if (endpoint.secret) await secretStore.save(endpoint.id, endpoint.secret);
|
|
4256
4472
|
* ```
|
|
4257
4473
|
*/
|
|
4258
4474
|
async createEndpoint(payload, accountId) {
|
|
@@ -4377,6 +4593,32 @@ var WebhookResource = class extends BaseResource {
|
|
|
4377
4593
|
this.logger.info("Deleting webhook endpoint");
|
|
4378
4594
|
await this.callVoid("Failed to delete webhook endpoint", () => this.http.delete(path2));
|
|
4379
4595
|
}
|
|
4596
|
+
/**
|
|
4597
|
+
* Delete a webhook endpoint using its registered URL
|
|
4598
|
+
* (`DELETE /accounts/{accountId}/webhooks/endpoints?url=…`).
|
|
4599
|
+
*
|
|
4600
|
+
* No request body. The query URL must match the registered value exactly.
|
|
4601
|
+
* Frees its plan slot; OAuth applications need `webhooks:write`.
|
|
4602
|
+
*
|
|
4603
|
+
* @param url - Exact registered HTTP(S) endpoint URL, including its query.
|
|
4604
|
+
* @param accountId - Override the client's default workspace.
|
|
4605
|
+
* @returns Resolves on acknowledgement (`{ "status": 200, "data": [] }`).
|
|
4606
|
+
* @throws {ValidationError} If the URL is invalid or the account is missing.
|
|
4607
|
+
* @throws {ApiError} `400` for a missing URL; `401` for invalid credentials;
|
|
4608
|
+
* `403` for missing scope; `404` if no endpoint uses the URL; `500` on failure.
|
|
4609
|
+
* @example
|
|
4610
|
+
* ```ts
|
|
4611
|
+
* await client.webhooks.deleteEndpointByUrl('https://example.com/webhooks/assinafy');
|
|
4612
|
+
* ```
|
|
4613
|
+
*/
|
|
4614
|
+
async deleteEndpointByUrl(url, accountId) {
|
|
4615
|
+
validateWebhookUrl(url);
|
|
4616
|
+
const path2 = this.endpointsPath(accountId);
|
|
4617
|
+
return this.callVoid(
|
|
4618
|
+
"Failed to delete webhook endpoint",
|
|
4619
|
+
() => this.http.delete(path2, { params: { url } })
|
|
4620
|
+
);
|
|
4621
|
+
}
|
|
4380
4622
|
/**
|
|
4381
4623
|
* Return the secret that signs deliveries to an endpoint
|
|
4382
4624
|
* (`GET /accounts/{accountId}/webhooks/endpoints/{endpointId}/secret`).
|
|
@@ -4499,6 +4741,8 @@ var TemplateResource = class extends BaseResource {
|
|
|
4499
4741
|
*
|
|
4500
4742
|
* @param source - The PDF to upload, as a file path or an in-memory buffer.
|
|
4501
4743
|
* @param options - `name` (display name) and an optional `accountId` override.
|
|
4744
|
+
* @param options.name - Multipart filename override, with a `.pdf` extension.
|
|
4745
|
+
* @param options.accountId - Override the client's default workspace.
|
|
4502
4746
|
* @returns The created template (envelope unwrapped). Response shape:
|
|
4503
4747
|
* ```jsonc
|
|
4504
4748
|
* {
|
|
@@ -4664,7 +4908,7 @@ var TemplateResource = class extends BaseResource {
|
|
|
4664
4908
|
* @example
|
|
4665
4909
|
* ```ts
|
|
4666
4910
|
* const tmpl = await client.templates.get('103ad2171db7979468c3e97eb067');
|
|
4667
|
-
* if (tmpl.status === 'Ready') console.log(tmpl.pages
|
|
4911
|
+
* if (tmpl.status === 'Ready') console.log(tmpl.pages?.length ?? 0);
|
|
4668
4912
|
* ```
|
|
4669
4913
|
*/
|
|
4670
4914
|
async get(templateId, accountId) {
|
|
@@ -4826,6 +5070,7 @@ var TagResource = class extends BaseResource {
|
|
|
4826
5070
|
*
|
|
4827
5071
|
* @param params - Optional filters. `search` matches tag names
|
|
4828
5072
|
* case-insensitively (substring).
|
|
5073
|
+
* @param params.search - Optional case-insensitive tag-name substring.
|
|
4829
5074
|
* @param accountId - Override the client's default account ID.
|
|
4830
5075
|
* @returns The matching tags (list items carry no `resource` field):
|
|
4831
5076
|
* ```jsonc
|
|
@@ -4999,6 +5244,8 @@ var TagResource = class extends BaseResource {
|
|
|
4999
5244
|
* @param tagId - The tag to delete.
|
|
5000
5245
|
* @param options - `force` to detach-and-delete when the tag is still in
|
|
5001
5246
|
* use, and `accountId` to override the client's default account ID.
|
|
5247
|
+
* @param options.force - Detach the tag from documents before deletion.
|
|
5248
|
+
* @param options.accountId - Override the client's default workspace.
|
|
5002
5249
|
* @returns `{ deleted: true }` when the tag was deleted.
|
|
5003
5250
|
* @throws {ValidationError} If `tagId` is missing, or no account ID is available.
|
|
5004
5251
|
* @throws {ApiError} `404` if the tag does not exist; `409` if the tag is
|
|
@@ -6564,6 +6811,8 @@ var FieldsResource = class extends BaseResource {
|
|
|
6564
6811
|
* @param value - The value to check (validated against the field's
|
|
6565
6812
|
* type/regex). Sent as `{ value }` in the request body.
|
|
6566
6813
|
* @param options - Account override and optional legacy `signerAccessCode`.
|
|
6814
|
+
* @param options.accountId - Override the client's default workspace.
|
|
6815
|
+
* @param options.signerAccessCode - Legacy signer code sent as a query parameter.
|
|
6567
6816
|
* @returns The validation result. Response shape:
|
|
6568
6817
|
* ```jsonc
|
|
6569
6818
|
* {
|
|
@@ -6624,6 +6873,8 @@ var FieldsResource = class extends BaseResource {
|
|
|
6624
6873
|
*
|
|
6625
6874
|
* @param entries - Non-empty array of `{ field_id, value }` pairs.
|
|
6626
6875
|
* @param options - Account override and optional legacy `signerAccessCode`.
|
|
6876
|
+
* @param options.accountId - Override the client's default workspace.
|
|
6877
|
+
* @param options.signerAccessCode - Legacy signer code sent as a query parameter.
|
|
6627
6878
|
* @returns One validation result per entry. Response shape:
|
|
6628
6879
|
* ```jsonc
|
|
6629
6880
|
* [
|
|
@@ -7134,7 +7385,8 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
7134
7385
|
* "has_accepted_terms": false,
|
|
7135
7386
|
* "has_signature": false,
|
|
7136
7387
|
* "has_initial": false,
|
|
7137
|
-
* "is_signature_reusable": false
|
|
7388
|
+
* "is_signature_reusable": false,
|
|
7389
|
+
* "verification_method": "IdDocumentFaceMatchBasic"
|
|
7138
7390
|
* }
|
|
7139
7391
|
* ```
|
|
7140
7392
|
* @throws {ValidationError} If `signerAccessCode` is missing.
|
|
@@ -7155,6 +7407,92 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
7155
7407
|
() => this.http.get("/signers/self", { params: { "signer-access-code": code } })
|
|
7156
7408
|
);
|
|
7157
7409
|
}
|
|
7410
|
+
/**
|
|
7411
|
+
* Read the signer's identity verification state
|
|
7412
|
+
* (`GET /signers/identity-verification?signer-access-code=…`).
|
|
7413
|
+
*
|
|
7414
|
+
* No request body or workspace credentials. Reads a pending provider
|
|
7415
|
+
* decision when available. A new session can start before the first capture
|
|
7416
|
+
* or after `Expired`; `Declined` and `Abandoned` require a new document and
|
|
7417
|
+
* assignment. `InReview` lets the signer continue; account approval gates
|
|
7418
|
+
* certification, with `pending_identity_review` after everyone signs.
|
|
7419
|
+
*
|
|
7420
|
+
* @param signerAccessCode - Access code from the signer's signing link.
|
|
7421
|
+
* @returns Provider state, with nullable fields before a session exists:
|
|
7422
|
+
* ```jsonc
|
|
7423
|
+
* {
|
|
7424
|
+
* "can_start": false, "status": "Pending",
|
|
7425
|
+
* "url": "https://verify.example.com/c/session#t=opaque",
|
|
7426
|
+
* "expires_at": "2026-10-16T12:30:00Z", "completed_at": null
|
|
7427
|
+
* }
|
|
7428
|
+
* ```
|
|
7429
|
+
* `url` exists only while Pending. It is a bearer link: open it intact,
|
|
7430
|
+
* including its fragment, and keep it out of logs and browser storage.
|
|
7431
|
+
* @throws {ValidationError} If the access code is blank.
|
|
7432
|
+
* @throws {ApiError} `401` for an invalid/expired code; `500` for a server failure.
|
|
7433
|
+
* @example
|
|
7434
|
+
* ```ts
|
|
7435
|
+
* const state = await client.signerDocuments.getIdentityVerification(accessCode);
|
|
7436
|
+
* console.log(state.status, state.can_start);
|
|
7437
|
+
* ```
|
|
7438
|
+
*/
|
|
7439
|
+
async getIdentityVerification(signerAccessCode) {
|
|
7440
|
+
const code = this.requireId(signerAccessCode, "signer-access-code");
|
|
7441
|
+
return this.call(
|
|
7442
|
+
"Failed to fetch signer identity verification",
|
|
7443
|
+
() => this.http.get("/signers/identity-verification", { params: { "signer-access-code": code } })
|
|
7444
|
+
);
|
|
7445
|
+
}
|
|
7446
|
+
/**
|
|
7447
|
+
* Record biometric consent and open an identity verification session
|
|
7448
|
+
* (`POST /signers/identity-verification?signer-access-code=…`).
|
|
7449
|
+
*
|
|
7450
|
+
* Send only after the signer explicitly consents. Starts a session when
|
|
7451
|
+
* none exists or replaces an Expired session. Other states return `400`;
|
|
7452
|
+
* resending a notification never replaces a live session. The account is
|
|
7453
|
+
* billed at assignment creation, with no new charge for a restart.
|
|
7454
|
+
*
|
|
7455
|
+
* Request body (`application/json`):
|
|
7456
|
+
* ```jsonc
|
|
7457
|
+
* { "consent": true }
|
|
7458
|
+
* ```
|
|
7459
|
+
* @param signerAccessCode - Access code from the signer's signing link.
|
|
7460
|
+
* @param payload - Explicit consent from the signer.
|
|
7461
|
+
* @param payload.consent - Must be `true`; never default or infer consent.
|
|
7462
|
+
* @returns The newly opened provider session:
|
|
7463
|
+
* ```jsonc
|
|
7464
|
+
* {
|
|
7465
|
+
* "id": "verification_example",
|
|
7466
|
+
* "url": "https://verify.example.com/c/session#t=opaque",
|
|
7467
|
+
* "expires_at": "2026-10-16T12:30:00Z"
|
|
7468
|
+
* }
|
|
7469
|
+
* ```
|
|
7470
|
+
* `expires_at` can be null. Open the URL as-is; it is a bearer credential
|
|
7471
|
+
* and its fragment must survive navigation. Do not log or persist it in
|
|
7472
|
+
* browser storage. No workspace credential is attached to this call.
|
|
7473
|
+
* @throws {ValidationError} If the code is blank or consent is not `true`.
|
|
7474
|
+
* @throws {ApiError} `400` when a non-expired session already exists;
|
|
7475
|
+
* `401` for an invalid/expired code; `500` for a provider/server failure.
|
|
7476
|
+
* @example
|
|
7477
|
+
* ```ts
|
|
7478
|
+
* // Inside the handler for the signer's explicit consent action:
|
|
7479
|
+
* const session = await client.signerDocuments.startIdentityVerification(accessCode, { consent: true });
|
|
7480
|
+
* response.redirect(session.url);
|
|
7481
|
+
* ```
|
|
7482
|
+
*/
|
|
7483
|
+
async startIdentityVerification(signerAccessCode, payload) {
|
|
7484
|
+
const code = this.requireId(signerAccessCode, "signer-access-code");
|
|
7485
|
+
assertRecord(payload, "identity verification payload");
|
|
7486
|
+
if (payload.consent !== true) {
|
|
7487
|
+
throw new ValidationError("Explicit biometric-processing consent is required");
|
|
7488
|
+
}
|
|
7489
|
+
return this.call(
|
|
7490
|
+
"Failed to start signer identity verification",
|
|
7491
|
+
() => this.http.post("/signers/identity-verification", { consent: true }, {
|
|
7492
|
+
params: { "signer-access-code": code }
|
|
7493
|
+
})
|
|
7494
|
+
);
|
|
7495
|
+
}
|
|
7158
7496
|
/**
|
|
7159
7497
|
* Accept the platform terms of use as the signer
|
|
7160
7498
|
* (`PUT /signers/accept-terms?signer-access-code=…`).
|
|
@@ -7188,10 +7526,10 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
7188
7526
|
);
|
|
7189
7527
|
}
|
|
7190
7528
|
/**
|
|
7191
|
-
* Verify the signer's email one-time password
|
|
7529
|
+
* Verify the signer's email or WhatsApp one-time password
|
|
7192
7530
|
* (`POST /verify?signer-access-code=…`).
|
|
7193
7531
|
*
|
|
7194
|
-
* Confirms the 6-digit OTP
|
|
7532
|
+
* Confirms the 6-digit OTP sent through the selected channel. The access code
|
|
7195
7533
|
* authenticates via the `signer-access-code` **query param**; the request
|
|
7196
7534
|
* **body carries only `verification-code`** (putting the access code in the
|
|
7197
7535
|
* body leaves the request unauthenticated → `401`).
|
|
@@ -7205,6 +7543,8 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
7205
7543
|
*
|
|
7206
7544
|
* @param payload - `signerAccessCode` (the signing-link code) and
|
|
7207
7545
|
* `verificationCode` (the OTP the signer received).
|
|
7546
|
+
* @param payload.signerAccessCode - Signing-link code sent only in the query.
|
|
7547
|
+
* @param payload.verificationCode - Email or WhatsApp OTP sent as `verification-code`.
|
|
7208
7548
|
* @returns Resolves when the API acknowledges the operation. The response
|
|
7209
7549
|
* envelope has no `data` field and is intentionally discarded.
|
|
7210
7550
|
* @throws {ValidationError} If `signerAccessCode` or `verificationCode` is
|
|
@@ -7365,7 +7705,7 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
7365
7705
|
* "expires_at": null,
|
|
7366
7706
|
* "signers": [
|
|
7367
7707
|
* { "id": "19e6b92e7895332ed9708535d8c", "step": 1, "email": "signer@example.com",
|
|
7368
|
-
* "full_name": "Example Signer", "notified": true
|
|
7708
|
+
* "full_name": "Example Signer", "notified": true }
|
|
7369
7709
|
* ],
|
|
7370
7710
|
* "items": [
|
|
7371
7711
|
* { "id": "item-1", "page": { "id": "page-1", "number": 1, "height": 1651, "width": 1275,
|
|
@@ -7978,7 +8318,8 @@ var WebhookVerifier = class {
|
|
|
7978
8318
|
* @param toleranceSeconds - Accepted clock distance. Defaults to `300`.
|
|
7979
8319
|
* @returns `true` only when a signature entry matches (constant-time) and
|
|
7980
8320
|
* the timestamp is fresh; `false` when verification is disabled, a header
|
|
7981
|
-
* is missing,
|
|
8321
|
+
* is missing, the tolerance is not finite and non-negative, or anything
|
|
8322
|
+
* does not match.
|
|
7982
8323
|
*
|
|
7983
8324
|
* @example
|
|
7984
8325
|
* ```ts
|
|
@@ -7994,7 +8335,7 @@ var WebhookVerifier = class {
|
|
|
7994
8335
|
*/
|
|
7995
8336
|
verifySignature(payload, headers, toleranceSeconds = DEFAULT_TOLERANCE_SECONDS) {
|
|
7996
8337
|
const key = decodeSecret(this.webhookSecret);
|
|
7997
|
-
if (!key || typeof payload !== "string" && !Buffer.isBuffer(payload) || !headers) {
|
|
8338
|
+
if (!key || typeof payload !== "string" && !Buffer.isBuffer(payload) || !headers || !Number.isFinite(toleranceSeconds) || toleranceSeconds < 0) {
|
|
7998
8339
|
return false;
|
|
7999
8340
|
}
|
|
8000
8341
|
const id = header(headers, "webhook-id");
|
|
@@ -8680,6 +9021,7 @@ export {
|
|
|
8680
9021
|
AssinafyError,
|
|
8681
9022
|
AuthenticationResource,
|
|
8682
9023
|
DEFAULT_WEBHOOK_EVENTS,
|
|
9024
|
+
DIGITAL_CERTIFICATE_REQUIRES_VIRTUAL_METHOD,
|
|
8683
9025
|
DocumentResource,
|
|
8684
9026
|
FieldsResource,
|
|
8685
9027
|
MAX_LIST_PAGE_SIZE,
|