@assinafy/sdk 2.9.1 → 2.11.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/CHANGELOG.md +51 -1
- package/README.en.md +57 -23
- package/README.md +57 -22
- package/dist/index.d.mts +173 -76
- package/dist/index.d.ts +173 -76
- package/dist/index.js +200 -82
- package/dist/index.mjs +200 -82
- package/docs/API_COVERAGE.md +1 -1
- package/docs/COMPATIBILITY.md +98 -30
- package/docs/RELEASING.md +13 -6
- package/package.json +3 -2
package/dist/index.mjs
CHANGED
|
@@ -454,6 +454,17 @@ function assertDateTime(value, label) {
|
|
|
454
454
|
throw new ValidationError(`${label} must be an ISO-8601 date-time`);
|
|
455
455
|
}
|
|
456
456
|
}
|
|
457
|
+
function assertExpirationDate(value, label) {
|
|
458
|
+
if (typeof value !== "string") {
|
|
459
|
+
throw new ValidationError(`${label} must be an ISO-8601 date or date-time`);
|
|
460
|
+
}
|
|
461
|
+
const normalized = /^\d{4}-\d{2}-\d{2}$/u.test(value) ? `${value}T00:00:00Z` : /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?$/u.test(value) ? `${value}Z` : value;
|
|
462
|
+
try {
|
|
463
|
+
assertDateTime(normalized, label);
|
|
464
|
+
} catch {
|
|
465
|
+
throw new ValidationError(`${label} must be an ISO-8601 date or date-time`);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
457
468
|
function cleanParams(params) {
|
|
458
469
|
assertRecord(params, "params");
|
|
459
470
|
const out = {};
|
|
@@ -628,7 +639,7 @@ import axios2 from "axios";
|
|
|
628
639
|
// package.json
|
|
629
640
|
var package_default = {
|
|
630
641
|
name: "@assinafy/sdk",
|
|
631
|
-
version: "2.
|
|
642
|
+
version: "2.11.0",
|
|
632
643
|
packageManager: "bun@1.4.4",
|
|
633
644
|
description: "TypeScript SDK for Assinafy API - Digital signature platform",
|
|
634
645
|
type: "commonjs",
|
|
@@ -712,7 +723,8 @@ var package_default = {
|
|
|
712
723
|
overrides: {
|
|
713
724
|
esbuild: "0.28.2",
|
|
714
725
|
"follow-redirects": "1.16.2",
|
|
715
|
-
"brace-expansion": "5.0.12"
|
|
726
|
+
"brace-expansion": "5.0.12",
|
|
727
|
+
minimatch: "11.0.3"
|
|
716
728
|
},
|
|
717
729
|
files: [
|
|
718
730
|
"dist",
|
|
@@ -920,7 +932,7 @@ var BaseResource = class {
|
|
|
920
932
|
return result;
|
|
921
933
|
}
|
|
922
934
|
/** Execute a paginated list call and attach meta from `X-Pagination-*` headers. */
|
|
923
|
-
async callList(label, request) {
|
|
935
|
+
async callList(label, request, allowEmptyBody = false) {
|
|
924
936
|
try {
|
|
925
937
|
const response = assertSuccessful(await request());
|
|
926
938
|
const unwrapped = handleAssinafyResponse(response.data);
|
|
@@ -929,6 +941,8 @@ var BaseResource = class {
|
|
|
929
941
|
data = unwrapped;
|
|
930
942
|
} else if (Array.isArray(unwrapped?.data)) {
|
|
931
943
|
data = unwrapped.data;
|
|
944
|
+
} else if (allowEmptyBody && unwrapped == null) {
|
|
945
|
+
data = [];
|
|
932
946
|
} else {
|
|
933
947
|
throw new AssinafyError(`${label}: API returned a malformed list payload`, {
|
|
934
948
|
responseData: unwrapped
|
|
@@ -1064,7 +1078,7 @@ function buildAssignmentPayload(payload) {
|
|
|
1064
1078
|
if (payload.message !== void 0 && typeof payload.message !== "string") {
|
|
1065
1079
|
throw new ValidationError("message must be a string");
|
|
1066
1080
|
}
|
|
1067
|
-
if (payload.expires_at !== void 0)
|
|
1081
|
+
if (payload.expires_at !== void 0) assertExpirationDate(payload.expires_at, "expires_at");
|
|
1068
1082
|
if (payload.copy_receivers !== void 0 && (!Array.isArray(payload.copy_receivers) || payload.copy_receivers.some(
|
|
1069
1083
|
(id) => typeof id !== "string" || !id.trim()
|
|
1070
1084
|
))) {
|
|
@@ -1236,7 +1250,7 @@ var AssignmentResource = class extends BaseResource {
|
|
|
1236
1250
|
* without it. Note the camelCase spelling: `account_id` and an
|
|
1237
1251
|
* `X-Account-Id` header are both rejected.
|
|
1238
1252
|
*
|
|
1239
|
-
* @param params - `page`, `per-page`.
|
|
1253
|
+
* @param params - `page`, `per-page`, and `sort`.
|
|
1240
1254
|
* @param accountId - Override the client's default account ID.
|
|
1241
1255
|
* @returns Assignments, with pagination in `meta`. Each item is a full
|
|
1242
1256
|
* {@link IAssignment} (same shape as {@link AssignmentResource.create}
|
|
@@ -1369,6 +1383,8 @@ var AssignmentResource = class extends BaseResource {
|
|
|
1369
1383
|
* @param payload - Signers plus optional `method` (defaults to `virtual`),
|
|
1370
1384
|
* `message`, `expires_at`, `copy_receivers` (existing signer IDs, not
|
|
1371
1385
|
* addresses), and `collect`-mode `entries` with page-image geometry.
|
|
1386
|
+
* `expires_at` accepts a date (ending at 23:59 UTC), a date-time without
|
|
1387
|
+
* an offset (UTC), or an offset-aware date-time.
|
|
1372
1388
|
* @returns The created {@link IAssignment}: `signers` (rich, with `step` /
|
|
1373
1389
|
* `notified` / `verification_method`), `items` (one row per signer × field),
|
|
1374
1390
|
* a `summary` count block, and per-signer `signing_urls`. Response shape:
|
|
@@ -1556,9 +1572,10 @@ var AssignmentResource = class extends BaseResource {
|
|
|
1556
1572
|
* (`PUT /documents/{documentId}/assignments/{assignmentId}/reset-expiration`).
|
|
1557
1573
|
*
|
|
1558
1574
|
* Sends `{ expires_at }` verbatim; the key itself is required by the
|
|
1559
|
-
* contract. Use an ISO-8601 date
|
|
1560
|
-
*
|
|
1561
|
-
*
|
|
1575
|
+
* contract. Use an ISO-8601 date, a date-time with or without an offset,
|
|
1576
|
+
* or `null` to remove the expiration. Date-only values end at 23:59 UTC;
|
|
1577
|
+
* date-times without offsets are UTC. `null` is intentionally not stripped
|
|
1578
|
+
* from the body.
|
|
1562
1579
|
*
|
|
1563
1580
|
* Request body (`application/json`):
|
|
1564
1581
|
* ```jsonc
|
|
@@ -1569,8 +1586,8 @@ var AssignmentResource = class extends BaseResource {
|
|
|
1569
1586
|
*
|
|
1570
1587
|
* @param documentId - The document the assignment belongs to.
|
|
1571
1588
|
* @param assignmentId - The assignment to update.
|
|
1572
|
-
* @param expiresAt - New expiry as an ISO-8601 date
|
|
1573
|
-
* to remove the expiration.
|
|
1589
|
+
* @param expiresAt - New expiry as an ISO-8601 date or date-time string,
|
|
1590
|
+
* or `null` to remove the expiration.
|
|
1574
1591
|
* @returns The updated {@link IAssignment} — the same full shape
|
|
1575
1592
|
* {@link AssignmentResource.create} returns (`signers`, `items`, `summary`,
|
|
1576
1593
|
* `signing_urls`), with `expires_at` reflecting the new value:
|
|
@@ -1614,7 +1631,7 @@ var AssignmentResource = class extends BaseResource {
|
|
|
1614
1631
|
async resetExpiration(documentId, assignmentId, expiresAt) {
|
|
1615
1632
|
const docId = this.requireId(documentId, "Document ID");
|
|
1616
1633
|
const asgId = this.requireId(assignmentId, "Assignment ID");
|
|
1617
|
-
if (expiresAt !== null)
|
|
1634
|
+
if (expiresAt !== null) assertExpirationDate(expiresAt, "expiresAt");
|
|
1618
1635
|
return this.call(
|
|
1619
1636
|
"Failed to update assignment expiration",
|
|
1620
1637
|
() => this.http.put(
|
|
@@ -2074,7 +2091,7 @@ var DocumentResource = class extends BaseResource {
|
|
|
2074
2091
|
* a compact representation with no expanded `assignment` or `pages`, so
|
|
2075
2092
|
* prefer it for name lookups and pickers.
|
|
2076
2093
|
*
|
|
2077
|
-
* @param params - `search`, `status`, `page`, `per-page`.
|
|
2094
|
+
* @param params - `search`, `status`, `page`, `per-page`, and `sort`.
|
|
2078
2095
|
* @param accountId - Override the client's default account ID.
|
|
2079
2096
|
* @returns Matching documents, with pagination in `meta`. Each item:
|
|
2080
2097
|
* ```jsonc
|
|
@@ -2430,14 +2447,22 @@ var DocumentResource = class extends BaseResource {
|
|
|
2430
2447
|
);
|
|
2431
2448
|
}
|
|
2432
2449
|
/**
|
|
2433
|
-
* Fetch the document activity log
|
|
2450
|
+
* Fetch a page of the document activity log
|
|
2434
2451
|
* (`GET /documents/{documentId}/activities`).
|
|
2435
2452
|
*
|
|
2436
|
-
*
|
|
2437
|
-
*
|
|
2453
|
+
* Production returns 20 entries per page by default, newest first. Request
|
|
2454
|
+
* later pages explicitly; a page past the end returns `[]`. Sandbox still
|
|
2455
|
+
* returns the full, unpaged log and may ignore these parameters. This method
|
|
2456
|
+
* preserves its array return type; use {@link DocumentResource.listActivities}
|
|
2457
|
+
* for pagination metadata. Normalises an absent body to `[]`.
|
|
2438
2458
|
*
|
|
2439
2459
|
* @param documentId - The document whose activity log to fetch.
|
|
2440
|
-
* @
|
|
2460
|
+
* @param params - Optional pagination and sorting parameters.
|
|
2461
|
+
* @param params.page - Page number, starting at 1.
|
|
2462
|
+
* @param params.per-page - Entries per page (production default 20, documented max 100).
|
|
2463
|
+
* @param params.per_page - Alias for `per-page`; explicit `per-page` wins.
|
|
2464
|
+
* @param params.sort - `-id` (default, newest first) or `id` (oldest first).
|
|
2465
|
+
* @returns The requested page of activity entries, or `[]`:
|
|
2441
2466
|
* ```jsonc
|
|
2442
2467
|
* [
|
|
2443
2468
|
* {
|
|
@@ -2458,22 +2483,66 @@ var DocumentResource = class extends BaseResource {
|
|
|
2458
2483
|
* }
|
|
2459
2484
|
* ]
|
|
2460
2485
|
* ```
|
|
2461
|
-
* @throws {ValidationError} If `documentId` is missing.
|
|
2462
|
-
* @throws {ApiError} If the API rejects the request.
|
|
2486
|
+
* @throws {ValidationError} If `documentId` is missing or invalid, or `params` is not an object.
|
|
2487
|
+
* @throws {ApiError} If the API rejects the request (`401` for invalid credentials, `500` for a server error).
|
|
2463
2488
|
*
|
|
2464
2489
|
* @example
|
|
2465
2490
|
* ```ts
|
|
2466
|
-
* const events = await client.documents.activities('doc-1'
|
|
2491
|
+
* const events = await client.documents.activities('doc-1', {
|
|
2492
|
+
* page: 2, 'per-page': 100, sort: 'id',
|
|
2493
|
+
* });
|
|
2467
2494
|
* console.log(events.map((e) => e.event));
|
|
2468
2495
|
* ```
|
|
2469
2496
|
*/
|
|
2470
|
-
async activities(documentId) {
|
|
2497
|
+
async activities(documentId, params = {}) {
|
|
2498
|
+
return (await this.listActivities(documentId, params)).data;
|
|
2499
|
+
}
|
|
2500
|
+
/**
|
|
2501
|
+
* Fetch document activities with pagination metadata
|
|
2502
|
+
* (`GET /documents/{documentId}/activities`).
|
|
2503
|
+
*
|
|
2504
|
+
* Production defaults to 20 entries, newest first. `meta` comes from the
|
|
2505
|
+
* `X-Pagination-*` headers; use `last_page` to request the remaining pages.
|
|
2506
|
+
* Sandbox returns the full unpaged log without `meta`: process it once.
|
|
2507
|
+
* Normalises an absent body to an empty list. Makes exactly one request.
|
|
2508
|
+
*
|
|
2509
|
+
* @param documentId - The document whose activity log to fetch.
|
|
2510
|
+
* @param params - Optional pagination and sorting parameters.
|
|
2511
|
+
* @param params.page - Page number, starting at 1.
|
|
2512
|
+
* @param params.per-page - Entries per page (production default 20, documented max 100).
|
|
2513
|
+
* @param params.per_page - Alias for `per-page`; explicit `per-page` wins.
|
|
2514
|
+
* @param params.sort - `-id` (default, newest first) or `id` (oldest first).
|
|
2515
|
+
* @returns Activity entries and pagination metadata when the server supplies it:
|
|
2516
|
+
* ```jsonc
|
|
2517
|
+
* {
|
|
2518
|
+
* "data": [{
|
|
2519
|
+
* "id": 15271,
|
|
2520
|
+
* "event": "document_uploaded",
|
|
2521
|
+
* "message": "Documento criado.",
|
|
2522
|
+
* "payload": [],
|
|
2523
|
+
* "origin": null,
|
|
2524
|
+
* "created_at": "2026-07-19T14:56:55Z"
|
|
2525
|
+
* }],
|
|
2526
|
+
* "meta": { "current_page": 2, "per_page": 20, "total": 21, "last_page": 2 }
|
|
2527
|
+
* }
|
|
2528
|
+
* ```
|
|
2529
|
+
* @throws {ValidationError} If `documentId` is missing or invalid, or `params` is not an object.
|
|
2530
|
+
* @throws {ApiError} If the API rejects the request (`401` for invalid credentials, `500` for a server error).
|
|
2531
|
+
* @example
|
|
2532
|
+
* ```ts
|
|
2533
|
+
* const { data, meta } = await client.documents.listActivities('doc-1', { page: 2 });
|
|
2534
|
+
* console.log(data, meta?.total);
|
|
2535
|
+
* ```
|
|
2536
|
+
*/
|
|
2537
|
+
async listActivities(documentId, params = {}) {
|
|
2471
2538
|
const id = this.requireId(documentId, "Document ID");
|
|
2472
|
-
|
|
2539
|
+
return this.callList(
|
|
2473
2540
|
"Failed to fetch document activities",
|
|
2474
|
-
() => this.http.get(`/documents/${this.pathSegment(id, "Document ID")}/activities
|
|
2541
|
+
() => this.http.get(`/documents/${this.pathSegment(id, "Document ID")}/activities`, {
|
|
2542
|
+
params: cleanListParams(params)
|
|
2543
|
+
}),
|
|
2544
|
+
true
|
|
2475
2545
|
);
|
|
2476
|
-
return result ?? [];
|
|
2477
2546
|
}
|
|
2478
2547
|
/**
|
|
2479
2548
|
* Delete a document (`DELETE /documents/{documentId}`).
|
|
@@ -2684,9 +2753,11 @@ var DocumentResource = class extends BaseResource {
|
|
|
2684
2753
|
*
|
|
2685
2754
|
* Instantiates the template, binding each role to a signer, and returns the
|
|
2686
2755
|
* new document. The request body is `{ signers, ...options }` — `signers`
|
|
2687
|
-
* maps every template `role_id` to an existing
|
|
2688
|
-
*
|
|
2689
|
-
*
|
|
2756
|
+
* maps every template `role_id` to an existing signer `id` or an `email`.
|
|
2757
|
+
* An email reuses the matching account signer or creates one with `name`;
|
|
2758
|
+
* `id` wins when both are present. Options may add `name`, `message`,
|
|
2759
|
+
* `expires_at`, `editor_fields`, and tag names in `tags` (unknown names are
|
|
2760
|
+
* created automatically).
|
|
2690
2761
|
*
|
|
2691
2762
|
* Request body (`application/json`):
|
|
2692
2763
|
* ```jsonc
|
|
@@ -2694,7 +2765,9 @@ var DocumentResource = class extends BaseResource {
|
|
|
2694
2765
|
* "signers": [
|
|
2695
2766
|
* {
|
|
2696
2767
|
* "role_id": "signing_role_example",
|
|
2697
|
-
* "
|
|
2768
|
+
* "email": "signer@example.com",
|
|
2769
|
+
* "name": "Example Signer",
|
|
2770
|
+
* "whatsapp_phone_number": "+15555550100",
|
|
2698
2771
|
* "verification_method": "Email",
|
|
2699
2772
|
* "notification_methods": [
|
|
2700
2773
|
* "Email"
|
|
@@ -2718,27 +2791,33 @@ var DocumentResource = class extends BaseResource {
|
|
|
2718
2791
|
* ```
|
|
2719
2792
|
*
|
|
2720
2793
|
* @param templateId - The template to instantiate.
|
|
2721
|
-
* @param signers - Role-to-signer bindings (each with `role_id` and
|
|
2722
|
-
*
|
|
2794
|
+
* @param signers - Role-to-signer bindings (each with `role_id` and either
|
|
2795
|
+
* an existing `id` or an `email`; email creation also accepts `name` and
|
|
2796
|
+
* `whatsapp_phone_number`). `verification_method`, `notification_methods`,
|
|
2797
|
+
* and `step` are optional.
|
|
2723
2798
|
* Only one notification method is allowed per signer; when only one of the
|
|
2724
2799
|
* verification/notification fields is supplied, the API infers the other.
|
|
2725
2800
|
* `DigitalCertificate` costs 0.5 credits, requires the feature plus a
|
|
2726
2801
|
* signer `government_id`, and that signer must be alone in its step. The
|
|
2727
|
-
* server derives the assignment method from placed template fields
|
|
2728
|
-
*
|
|
2729
|
-
*
|
|
2802
|
+
* server derives the assignment method from placed template fields and
|
|
2803
|
+
* rejects certificate signers when those fields produce a `collect`
|
|
2804
|
+
* assignment. Use a template without placed signer fields for certificate
|
|
2805
|
+
* signing.
|
|
2730
2806
|
* `IdDocumentFaceMatchBasic` needs the ID Document + Face Match feature
|
|
2731
2807
|
* and a valid CPF in `government_id`; estimate the per-signer fee first.
|
|
2732
2808
|
* @param options - Optional `name`, `message`, `expires_at`,
|
|
2733
2809
|
* `editor_fields`, `tags`.
|
|
2734
2810
|
* @param options.name - Generated document display name.
|
|
2735
2811
|
* @param options.message - Signing invitation message.
|
|
2736
|
-
* @param options.expires_at - ISO-8601
|
|
2812
|
+
* @param options.expires_at - ISO-8601 deadline: date-only (ends at 23:59
|
|
2813
|
+
* UTC), date-time without an offset (treated as UTC), or an offset-aware
|
|
2814
|
+
* date-time.
|
|
2737
2815
|
* @param options.editor_fields - Template editor values as `{ field_id, value }` entries.
|
|
2738
2816
|
* @param options.tags - Tag names attached to the generated document.
|
|
2739
2817
|
* @param accountId - Override the client's default account ID.
|
|
2740
|
-
* @returns The
|
|
2741
|
-
* `
|
|
2818
|
+
* @returns The uploaded document. Assignment creation continues in the
|
|
2819
|
+
* background; follow `GET /documents/{documentId}` or webhooks until the
|
|
2820
|
+
* document becomes `pending_signature` or `failed`:
|
|
2742
2821
|
* ```jsonc
|
|
2743
2822
|
* {
|
|
2744
2823
|
* "resource": "document",
|
|
@@ -2746,22 +2825,21 @@ var DocumentResource = class extends BaseResource {
|
|
|
2746
2825
|
* "account_id": "acc_example",
|
|
2747
2826
|
* "template_id": "103a0991a5cde83518e5672aa9aa",
|
|
2748
2827
|
* "name": "Service agreement from template",
|
|
2749
|
-
* "status": "
|
|
2750
|
-
* "artifacts": { "original": "https://…/download/original"
|
|
2828
|
+
* "status": "uploaded",
|
|
2829
|
+
* "artifacts": { "original": "https://…/download/original" },
|
|
2751
2830
|
* "is_closed": false,
|
|
2752
2831
|
* "signing_url": "https://app.assinafy.com.br/sign/19f675b7…",
|
|
2753
2832
|
* "tags": [{ "id": "103a0992…", "name": "agreements", "color": null }],
|
|
2754
|
-
* "assignment":
|
|
2755
|
-
* "pages": [
|
|
2833
|
+
* "assignment": null,
|
|
2834
|
+
* "pages": [],
|
|
2756
2835
|
* "created_at": "2026-07-15T19:57:55Z",
|
|
2757
2836
|
* "updated_at": "2026-07-15T19:59:33Z"
|
|
2758
2837
|
* }
|
|
2759
2838
|
* ```
|
|
2760
|
-
* @throws {ValidationError} If `templateId
|
|
2761
|
-
*
|
|
2762
|
-
*
|
|
2763
|
-
*
|
|
2764
|
-
* is not ready.
|
|
2839
|
+
* @throws {ValidationError} If `templateId`, an account ID, signer identity,
|
|
2840
|
+
* channel, order, deadline, editor field, or tag is invalid.
|
|
2841
|
+
* @throws {ApiError} `400` if the signers/roles are invalid, the template
|
|
2842
|
+
* is not ready, or placed signer fields conflict with `DigitalCertificate`.
|
|
2765
2843
|
*
|
|
2766
2844
|
* @example
|
|
2767
2845
|
* ```ts
|
|
@@ -2778,7 +2856,7 @@ var DocumentResource = class extends BaseResource {
|
|
|
2778
2856
|
if (options.message !== void 0 && typeof options.message !== "string") {
|
|
2779
2857
|
throw new ValidationError("message must be a string");
|
|
2780
2858
|
}
|
|
2781
|
-
if (options.expires_at !== void 0)
|
|
2859
|
+
if (options.expires_at !== void 0) assertExpirationDate(options.expires_at, "expires_at");
|
|
2782
2860
|
const editorFields = options.editor_fields === void 0 ? void 0 : normaliseTemplateEditorFields(options.editor_fields);
|
|
2783
2861
|
if (options.tags !== void 0 && (!Array.isArray(options.tags) || options.tags.some((tag) => typeof tag !== "string" || !tag.trim()))) {
|
|
2784
2862
|
throw new ValidationError("tags must be an array of non-empty tag names");
|
|
@@ -2808,10 +2886,8 @@ var DocumentResource = class extends BaseResource {
|
|
|
2808
2886
|
*
|
|
2809
2887
|
* A dry run: sends only `{ signers }` and consumes nothing. Use it to check
|
|
2810
2888
|
* balances before calling {@link DocumentResource.createFromTemplate}.
|
|
2811
|
-
* `DigitalCertificate`
|
|
2812
|
-
*
|
|
2813
|
-
* refuses certificate signers instead of returning a price for an
|
|
2814
|
-
* assignment that may charge credits but cannot be completed.
|
|
2889
|
+
* `DigitalCertificate` adds 0.5 credits per signer plus notification cost;
|
|
2890
|
+
* the API returns `400` when the template has placed signer fields.
|
|
2815
2891
|
*
|
|
2816
2892
|
* Request body (`application/json`):
|
|
2817
2893
|
* ```jsonc
|
|
@@ -2853,10 +2929,10 @@ var DocumentResource = class extends BaseResource {
|
|
|
2853
2929
|
* "message": null
|
|
2854
2930
|
* }
|
|
2855
2931
|
* ```
|
|
2856
|
-
* @throws {ValidationError} If `templateId
|
|
2857
|
-
*
|
|
2858
|
-
*
|
|
2859
|
-
*
|
|
2932
|
+
* @throws {ValidationError} If `templateId`, an account ID, role, or
|
|
2933
|
+
* channel is invalid.
|
|
2934
|
+
* @throws {ApiError} `400` if the role is invalid or placed signer fields
|
|
2935
|
+
* conflict with `DigitalCertificate`; `403` when a feature is unavailable.
|
|
2860
2936
|
*
|
|
2861
2937
|
* @example
|
|
2862
2938
|
* ```ts
|
|
@@ -3136,11 +3212,33 @@ function normaliseTemplateSigners(signers) {
|
|
|
3136
3212
|
if (typeof signer.role_id !== "string" || !signer.role_id.trim()) {
|
|
3137
3213
|
throw new ValidationError(`Template signer ${index + 1} requires role_id`);
|
|
3138
3214
|
}
|
|
3139
|
-
if (typeof signer.id !== "string" || !signer.id.trim()) {
|
|
3140
|
-
throw new ValidationError(`Template signer ${index + 1} requires id`);
|
|
3141
|
-
}
|
|
3142
3215
|
validateAssignmentSignerOptions(signer, `Template signer ${index + 1}`);
|
|
3143
|
-
const projected = { role_id: signer.role_id
|
|
3216
|
+
const projected = { role_id: signer.role_id };
|
|
3217
|
+
if (signer.id !== void 0) {
|
|
3218
|
+
if (typeof signer.id !== "string" || !signer.id.trim()) {
|
|
3219
|
+
throw new ValidationError(`Template signer ${index + 1} id must be non-empty`);
|
|
3220
|
+
}
|
|
3221
|
+
projected.id = signer.id;
|
|
3222
|
+
} else {
|
|
3223
|
+
if (!isEmail(signer.email)) {
|
|
3224
|
+
throw new ValidationError(`Template signer ${index + 1} requires a valid id or email`);
|
|
3225
|
+
}
|
|
3226
|
+
projected.email = signer.email;
|
|
3227
|
+
if (signer.name !== void 0) {
|
|
3228
|
+
if (typeof signer.name !== "string" || !signer.name.trim()) {
|
|
3229
|
+
throw new ValidationError(`Template signer ${index + 1} name must be non-empty`);
|
|
3230
|
+
}
|
|
3231
|
+
projected.name = signer.name;
|
|
3232
|
+
}
|
|
3233
|
+
if (signer.whatsapp_phone_number !== void 0) {
|
|
3234
|
+
if (!isE164PhoneNumber(signer.whatsapp_phone_number)) {
|
|
3235
|
+
throw new ValidationError(
|
|
3236
|
+
`Template signer ${index + 1} whatsapp_phone_number must be E.164`
|
|
3237
|
+
);
|
|
3238
|
+
}
|
|
3239
|
+
projected.whatsapp_phone_number = signer.whatsapp_phone_number;
|
|
3240
|
+
}
|
|
3241
|
+
}
|
|
3144
3242
|
if (signer.verification_method !== void 0) {
|
|
3145
3243
|
projected.verification_method = signer.verification_method;
|
|
3146
3244
|
}
|
|
@@ -3150,7 +3248,6 @@ function normaliseTemplateSigners(signers) {
|
|
|
3150
3248
|
if (signer.step !== void 0) projected.step = signer.step;
|
|
3151
3249
|
return projected;
|
|
3152
3250
|
});
|
|
3153
|
-
validateDigitalCertificateMethod(void 0, normalised);
|
|
3154
3251
|
return normalised;
|
|
3155
3252
|
}
|
|
3156
3253
|
function normaliseTemplateEditorFields(fields) {
|
|
@@ -3191,7 +3288,6 @@ function normaliseTemplateCostSigners(signers) {
|
|
|
3191
3288
|
}
|
|
3192
3289
|
return descriptor;
|
|
3193
3290
|
});
|
|
3194
|
-
validateDigitalCertificateMethod(void 0, normalised);
|
|
3195
3291
|
return normalised;
|
|
3196
3292
|
}
|
|
3197
3293
|
function validateWaitOption(value, name) {
|
|
@@ -4092,6 +4188,8 @@ var WebhookResource = class extends BaseResource {
|
|
|
4092
4188
|
* "document_processing_failed"
|
|
4093
4189
|
* ],
|
|
4094
4190
|
* "is_active": true,
|
|
4191
|
+
* "is_held": false,
|
|
4192
|
+
* "held_since": null,
|
|
4095
4193
|
* "updated_at": "2026-07-18T02:36:02Z" // no `id` / `created_at` are returned
|
|
4096
4194
|
* }
|
|
4097
4195
|
* ```
|
|
@@ -4261,11 +4359,12 @@ var WebhookResource = class extends BaseResource {
|
|
|
4261
4359
|
* (`GET /accounts/{accountId}/webhooks`). Pagination info (if any) is
|
|
4262
4360
|
* attached in `meta`.
|
|
4263
4361
|
*
|
|
4264
|
-
* Assinafy treats any `2xx` response as success.
|
|
4265
|
-
*
|
|
4266
|
-
*
|
|
4267
|
-
*
|
|
4268
|
-
*
|
|
4362
|
+
* Assinafy treats any `2xx` response as success. Retriable failures get up
|
|
4363
|
+
* to six attempts about ten minutes apart. After ten failed deliveries in
|
|
4364
|
+
* a row, the endpoint is paused and probed after 3, 15 and 60 minutes, then
|
|
4365
|
+
* every six hours. A successful delivery or probe resumes the endpoint and
|
|
4366
|
+
* replays missed events oldest first. Response bodies are truncated to
|
|
4367
|
+
* 2,000 characters and delivery entries are retained for seven days.
|
|
4269
4368
|
*
|
|
4270
4369
|
* @param params - Optional filters and pagination:
|
|
4271
4370
|
* - `endpoint_id` — only deliveries to this webhook endpoint.
|
|
@@ -4292,6 +4391,10 @@ var WebhookResource = class extends BaseResource {
|
|
|
4292
4391
|
* // subject: <User>, account_id, created_at }
|
|
4293
4392
|
* },
|
|
4294
4393
|
* "delivered": true,
|
|
4394
|
+
* "webhook_id": "9f86d081884c7d659a2feaa0c55ad015",
|
|
4395
|
+
* "attempt": 1,
|
|
4396
|
+
* "kind": "scheduled",
|
|
4397
|
+
* "will_retry": false,
|
|
4295
4398
|
* "http_status": 200,
|
|
4296
4399
|
* "response_body": "{ ... }", // receiving endpoint body, max 2,000 chars
|
|
4297
4400
|
* "error": null,
|
|
@@ -4384,11 +4487,14 @@ var WebhookResource = class extends BaseResource {
|
|
|
4384
4487
|
* [
|
|
4385
4488
|
* {
|
|
4386
4489
|
* "id": "65f1c2a9b3e4d5f60718293a4b5c6d7e",
|
|
4490
|
+
* "resource": "activity_event_subscription",
|
|
4387
4491
|
* "name": "ERP",
|
|
4388
4492
|
* "url": "https://example.com/webhooks/assinafy",
|
|
4389
4493
|
* "email": "ops@example.com",
|
|
4390
4494
|
* "events": ["document_ready", "signer_signed_document"],
|
|
4391
4495
|
* "is_active": true,
|
|
4496
|
+
* "is_held": false,
|
|
4497
|
+
* "held_since": null,
|
|
4392
4498
|
* "signing_enabled": true, // deliveries carry a `webhook-signature` header
|
|
4393
4499
|
* "created_at": "2026-10-01T12:00:00Z",
|
|
4394
4500
|
* "updated_at": "2026-10-01T12:00:00Z"
|
|
@@ -4406,7 +4512,7 @@ var WebhookResource = class extends BaseResource {
|
|
|
4406
4512
|
*/
|
|
4407
4513
|
async listEndpoints(accountId, params = {}) {
|
|
4408
4514
|
assertRecord(params, "webhook endpoint filters");
|
|
4409
|
-
if (params.url !== void 0) validateWebhookUrl(params.url);
|
|
4515
|
+
if (params.url !== void 0) validateWebhookUrl(params.url, true);
|
|
4410
4516
|
const path2 = this.endpointsPath(accountId);
|
|
4411
4517
|
return this.call(
|
|
4412
4518
|
"Failed to list webhook endpoints",
|
|
@@ -4420,8 +4526,8 @@ var WebhookResource = class extends BaseResource {
|
|
|
4420
4526
|
* An account can have 1 endpoint, or up to 3 on paid plans. Each endpoint
|
|
4421
4527
|
* of a workspace needs a different `url`. With `signing_enabled: true` the
|
|
4422
4528
|
* API returns a signing `secret` in this creation response. Store it now:
|
|
4423
|
-
* OAuth applications cannot call {@link WebhookResource.getEndpointSecret}
|
|
4424
|
-
*
|
|
4529
|
+
* OAuth applications cannot call {@link WebhookResource.getEndpointSecret},
|
|
4530
|
+
* but they can rotate a lost secret. When `events` is omitted or
|
|
4425
4531
|
* empty, {@link DEFAULT_WEBHOOK_EVENTS} is sent. OAuth tokens need the
|
|
4426
4532
|
* `webhooks:write` scope.
|
|
4427
4533
|
*
|
|
@@ -4437,19 +4543,22 @@ var WebhookResource = class extends BaseResource {
|
|
|
4437
4543
|
* }
|
|
4438
4544
|
* ```
|
|
4439
4545
|
*
|
|
4440
|
-
* @param payload - Endpoint details. `url` (absolute
|
|
4546
|
+
* @param payload - Endpoint details. `url` (absolute HTTPS) and `email`
|
|
4441
4547
|
* are required; `events`, `name`, `is_active` and `signing_enabled` are
|
|
4442
4548
|
* optional.
|
|
4443
4549
|
* @param accountId - Override the client's default account ID.
|
|
4444
4550
|
* @returns The created endpoint:
|
|
4445
4551
|
* ```jsonc
|
|
4446
4552
|
* {
|
|
4553
|
+
* "resource": "activity_event_subscription",
|
|
4447
4554
|
* "id": "65f1c2a9b3e4d5f60718293a4b5c6d7e",
|
|
4448
4555
|
* "name": "ERP",
|
|
4449
4556
|
* "url": "https://example.com/webhooks/assinafy",
|
|
4450
4557
|
* "email": "ops@example.com",
|
|
4451
4558
|
* "events": ["document_ready", "signer_signed_document"],
|
|
4452
4559
|
* "is_active": true,
|
|
4560
|
+
* "is_held": false,
|
|
4561
|
+
* "held_since": null,
|
|
4453
4562
|
* "signing_enabled": true, // deliveries carry a `webhook-signature` header
|
|
4454
4563
|
* "secret": "whsec_c2VjcmV0", // only in this response when signing is enabled
|
|
4455
4564
|
* "created_at": "2026-10-01T12:00:00Z",
|
|
@@ -4493,12 +4602,15 @@ var WebhookResource = class extends BaseResource {
|
|
|
4493
4602
|
* @returns The endpoint:
|
|
4494
4603
|
* ```jsonc
|
|
4495
4604
|
* {
|
|
4605
|
+
* "resource": "activity_event_subscription",
|
|
4496
4606
|
* "id": "65f1c2a9b3e4d5f60718293a4b5c6d7e",
|
|
4497
4607
|
* "name": "ERP",
|
|
4498
4608
|
* "url": "https://example.com/webhooks/assinafy",
|
|
4499
4609
|
* "email": "ops@example.com",
|
|
4500
4610
|
* "events": ["document_ready", "signer_signed_document"],
|
|
4501
4611
|
* "is_active": true,
|
|
4612
|
+
* "is_held": false,
|
|
4613
|
+
* "held_since": null,
|
|
4502
4614
|
* "signing_enabled": true, // deliveries carry a `webhook-signature` header
|
|
4503
4615
|
* "created_at": "2026-10-01T12:00:00Z",
|
|
4504
4616
|
* "updated_at": "2026-10-01T12:00:00Z"
|
|
@@ -4520,12 +4632,13 @@ var WebhookResource = class extends BaseResource {
|
|
|
4520
4632
|
/**
|
|
4521
4633
|
* Change a webhook endpoint
|
|
4522
4634
|
* (`PUT /accounts/{accountId}/webhooks/endpoints/{endpointId}`). Only the
|
|
4523
|
-
* fields sent are updated; `url`
|
|
4524
|
-
*
|
|
4635
|
+
* fields sent are updated; a changed `url` must be HTTPS, publicly
|
|
4636
|
+
* routable, and different from every other endpoint in the workspace.
|
|
4525
4637
|
*
|
|
4526
4638
|
* `signing_enabled: true` generates a secret if the endpoint has none and
|
|
4527
|
-
* keeps the current one otherwise; `false` discards the secret.
|
|
4528
|
-
*
|
|
4639
|
+
* keeps the current one otherwise; `false` discards the secret. When this
|
|
4640
|
+
* request turns signing on, the response includes the new `secret` once.
|
|
4641
|
+
* OAuth tokens need the `webhooks:write` scope.
|
|
4529
4642
|
*
|
|
4530
4643
|
* Request body (`application/json`, every field optional):
|
|
4531
4644
|
* ```jsonc
|
|
@@ -4545,13 +4658,17 @@ var WebhookResource = class extends BaseResource {
|
|
|
4545
4658
|
* @returns The updated endpoint:
|
|
4546
4659
|
* ```jsonc
|
|
4547
4660
|
* {
|
|
4661
|
+
* "resource": "activity_event_subscription",
|
|
4548
4662
|
* "id": "65f1c2a9b3e4d5f60718293a4b5c6d7e",
|
|
4549
4663
|
* "name": "ERP",
|
|
4550
4664
|
* "url": "https://example.com/webhooks/assinafy",
|
|
4551
4665
|
* "email": "ops@example.com",
|
|
4552
4666
|
* "events": ["document_ready", "signer_signed_document"],
|
|
4553
4667
|
* "is_active": true,
|
|
4668
|
+
* "is_held": false,
|
|
4669
|
+
* "held_since": null,
|
|
4554
4670
|
* "signing_enabled": true, // deliveries carry a `webhook-signature` header
|
|
4671
|
+
* "secret": "whsec_c2VjcmV0", // only when this request turned signing on
|
|
4555
4672
|
* "created_at": "2026-10-01T12:00:00Z",
|
|
4556
4673
|
* "updated_at": "2026-10-01T12:00:00Z"
|
|
4557
4674
|
* }
|
|
@@ -4615,7 +4732,7 @@ var WebhookResource = class extends BaseResource {
|
|
|
4615
4732
|
* ```
|
|
4616
4733
|
*/
|
|
4617
4734
|
async deleteEndpointByUrl(url, accountId) {
|
|
4618
|
-
validateWebhookUrl(url);
|
|
4735
|
+
validateWebhookUrl(url, true);
|
|
4619
4736
|
const path2 = this.endpointsPath(accountId);
|
|
4620
4737
|
return this.callVoid(
|
|
4621
4738
|
"Failed to delete webhook endpoint",
|
|
@@ -4655,7 +4772,7 @@ var WebhookResource = class extends BaseResource {
|
|
|
4655
4772
|
* (`POST /accounts/{accountId}/webhooks/endpoints/{endpointId}/secret/rotate`).
|
|
4656
4773
|
* The old secret stops working immediately: deliveries sent after the
|
|
4657
4774
|
* rotation are signed only with the new secret, so update the receiver at
|
|
4658
|
-
* once.
|
|
4775
|
+
* once. OAuth tokens need the `webhooks:write` scope.
|
|
4659
4776
|
*
|
|
4660
4777
|
* @param endpointId - The endpoint ID.
|
|
4661
4778
|
* @param accountId - Override the client's default account ID.
|
|
@@ -4716,15 +4833,15 @@ function validateWebhookFields(payload, required) {
|
|
|
4716
4833
|
throw new ValidationError("Webhook name must be a string");
|
|
4717
4834
|
}
|
|
4718
4835
|
}
|
|
4719
|
-
function validateWebhookUrl(value) {
|
|
4836
|
+
function validateWebhookUrl(value, allowStoredHttp = false) {
|
|
4720
4837
|
let url;
|
|
4721
4838
|
try {
|
|
4722
4839
|
url = new URL(value ?? "");
|
|
4723
4840
|
} catch {
|
|
4724
|
-
throw new ValidationError("Webhook URL must be an absolute
|
|
4841
|
+
throw new ValidationError("Webhook URL must be an absolute HTTPS URL", { url: value });
|
|
4725
4842
|
}
|
|
4726
|
-
if (url.protocol !== "https:" && url.protocol
|
|
4727
|
-
throw new ValidationError("Webhook URL must be an absolute
|
|
4843
|
+
if (url.protocol !== "https:" && !(allowStoredHttp && url.protocol === "http:") || !url.hostname) {
|
|
4844
|
+
throw new ValidationError("Webhook URL must be an absolute HTTPS URL", { url: value });
|
|
4728
4845
|
}
|
|
4729
4846
|
}
|
|
4730
4847
|
|
|
@@ -7885,7 +8002,7 @@ function assertDeclineReason(declineReason) {
|
|
|
7885
8002
|
if (typeof declineReason !== "string" || !declineReason.trim()) {
|
|
7886
8003
|
throw new ValidationError("declineReason is required");
|
|
7887
8004
|
}
|
|
7888
|
-
if (declineReason.length > 2e3) {
|
|
8005
|
+
if ([...declineReason].length > 2e3) {
|
|
7889
8006
|
throw new ValidationError("declineReason must be at most 2000 characters");
|
|
7890
8007
|
}
|
|
7891
8008
|
}
|
|
@@ -9316,8 +9433,9 @@ var AssinafyClient = class _AssinafyClient {
|
|
|
9316
9433
|
* the API; only `collect` assignments require pre-rendered pages.
|
|
9317
9434
|
* @param options.waitOptions - Optional `maxWaitMs` / `pollIntervalMs`
|
|
9318
9435
|
* forwarded to {@link DocumentResource.waitUntilReady}.
|
|
9319
|
-
* @param options.expiresAt - Optional ISO-8601 assignment expiry
|
|
9320
|
-
*
|
|
9436
|
+
* @param options.expiresAt - Optional ISO-8601 assignment expiry. A date
|
|
9437
|
+
* ends at 23:59 UTC; a date-time without an offset is interpreted as UTC;
|
|
9438
|
+
* an explicit offset is honored.
|
|
9321
9439
|
* @param options.copyReceivers - Optional existing signer IDs (not email
|
|
9322
9440
|
* addresses) that receive a copy. See the caveat on
|
|
9323
9441
|
* {@link ICreateAssignmentPayload.copy_receivers}; some plans silently drop
|
|
@@ -9403,7 +9521,7 @@ var AssinafyClient = class _AssinafyClient {
|
|
|
9403
9521
|
if (options.metadata !== void 0) {
|
|
9404
9522
|
assertRecord(options.metadata, "metadata");
|
|
9405
9523
|
}
|
|
9406
|
-
if (options.expiresAt !== void 0)
|
|
9524
|
+
if (options.expiresAt !== void 0) assertExpirationDate(options.expiresAt, "expiresAt");
|
|
9407
9525
|
if (options.copyReceivers !== void 0 && (!Array.isArray(options.copyReceivers) || options.copyReceivers.some(
|
|
9408
9526
|
(id) => typeof id !== "string" || id.trim().length === 0
|
|
9409
9527
|
))) {
|
package/docs/API_COVERAGE.md
CHANGED
|
@@ -84,7 +84,7 @@ Status meanings:
|
|
|
84
84
|
| `GET` | `/v1/documents/{documentId}` | `client.documents.details(documentId)` / `get(documentId)` | Covered |
|
|
85
85
|
| `DELETE` | `/v1/documents/{documentId}` | `client.documents.delete(documentId)` | Covered |
|
|
86
86
|
| `PATCH` | `/v1/documents/{documentId}` | `client.documents.rename(documentId, name)` | Covered |
|
|
87
|
-
| `GET` | `/v1/documents/{documentId}/activities` | `client.documents.activities(documentId)` | Covered |
|
|
87
|
+
| `GET` | `/v1/documents/{documentId}/activities` | `client.documents.activities(documentId, params?)` / `client.documents.listActivities(documentId, params?)` | Covered |
|
|
88
88
|
| `GET` | `/v1/documents/{documentId}/download/{artifactName}` | `client.documents.download(documentId, artifactName)` | Covered |
|
|
89
89
|
| `GET` | `/v1/documents/{documentSignatureHash}/verify` | `client.documents.verify(documentSignatureHash)` | Covered |
|
|
90
90
|
| `GET` | `/v1/documents/{documentId}/thumbnail` | `client.documents.thumbnail(documentId)` | Covered |
|