@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.js
CHANGED
|
@@ -516,6 +516,17 @@ function assertDateTime(value, label) {
|
|
|
516
516
|
throw new ValidationError(`${label} must be an ISO-8601 date-time`);
|
|
517
517
|
}
|
|
518
518
|
}
|
|
519
|
+
function assertExpirationDate(value, label) {
|
|
520
|
+
if (typeof value !== "string") {
|
|
521
|
+
throw new ValidationError(`${label} must be an ISO-8601 date or date-time`);
|
|
522
|
+
}
|
|
523
|
+
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;
|
|
524
|
+
try {
|
|
525
|
+
assertDateTime(normalized, label);
|
|
526
|
+
} catch {
|
|
527
|
+
throw new ValidationError(`${label} must be an ISO-8601 date or date-time`);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
519
530
|
function cleanParams(params) {
|
|
520
531
|
assertRecord(params, "params");
|
|
521
532
|
const out = {};
|
|
@@ -690,7 +701,7 @@ var import_axios2 = __toESM(require("axios"));
|
|
|
690
701
|
// package.json
|
|
691
702
|
var package_default = {
|
|
692
703
|
name: "@assinafy/sdk",
|
|
693
|
-
version: "2.
|
|
704
|
+
version: "2.11.0",
|
|
694
705
|
packageManager: "bun@1.4.4",
|
|
695
706
|
description: "TypeScript SDK for Assinafy API - Digital signature platform",
|
|
696
707
|
type: "commonjs",
|
|
@@ -774,7 +785,8 @@ var package_default = {
|
|
|
774
785
|
overrides: {
|
|
775
786
|
esbuild: "0.28.2",
|
|
776
787
|
"follow-redirects": "1.16.2",
|
|
777
|
-
"brace-expansion": "5.0.12"
|
|
788
|
+
"brace-expansion": "5.0.12",
|
|
789
|
+
minimatch: "11.0.3"
|
|
778
790
|
},
|
|
779
791
|
files: [
|
|
780
792
|
"dist",
|
|
@@ -982,7 +994,7 @@ var BaseResource = class {
|
|
|
982
994
|
return result;
|
|
983
995
|
}
|
|
984
996
|
/** Execute a paginated list call and attach meta from `X-Pagination-*` headers. */
|
|
985
|
-
async callList(label, request) {
|
|
997
|
+
async callList(label, request, allowEmptyBody = false) {
|
|
986
998
|
try {
|
|
987
999
|
const response = assertSuccessful(await request());
|
|
988
1000
|
const unwrapped = handleAssinafyResponse(response.data);
|
|
@@ -991,6 +1003,8 @@ var BaseResource = class {
|
|
|
991
1003
|
data = unwrapped;
|
|
992
1004
|
} else if (Array.isArray(unwrapped?.data)) {
|
|
993
1005
|
data = unwrapped.data;
|
|
1006
|
+
} else if (allowEmptyBody && unwrapped == null) {
|
|
1007
|
+
data = [];
|
|
994
1008
|
} else {
|
|
995
1009
|
throw new AssinafyError(`${label}: API returned a malformed list payload`, {
|
|
996
1010
|
responseData: unwrapped
|
|
@@ -1126,7 +1140,7 @@ function buildAssignmentPayload(payload) {
|
|
|
1126
1140
|
if (payload.message !== void 0 && typeof payload.message !== "string") {
|
|
1127
1141
|
throw new ValidationError("message must be a string");
|
|
1128
1142
|
}
|
|
1129
|
-
if (payload.expires_at !== void 0)
|
|
1143
|
+
if (payload.expires_at !== void 0) assertExpirationDate(payload.expires_at, "expires_at");
|
|
1130
1144
|
if (payload.copy_receivers !== void 0 && (!Array.isArray(payload.copy_receivers) || payload.copy_receivers.some(
|
|
1131
1145
|
(id) => typeof id !== "string" || !id.trim()
|
|
1132
1146
|
))) {
|
|
@@ -1298,7 +1312,7 @@ var AssignmentResource = class extends BaseResource {
|
|
|
1298
1312
|
* without it. Note the camelCase spelling: `account_id` and an
|
|
1299
1313
|
* `X-Account-Id` header are both rejected.
|
|
1300
1314
|
*
|
|
1301
|
-
* @param params - `page`, `per-page`.
|
|
1315
|
+
* @param params - `page`, `per-page`, and `sort`.
|
|
1302
1316
|
* @param accountId - Override the client's default account ID.
|
|
1303
1317
|
* @returns Assignments, with pagination in `meta`. Each item is a full
|
|
1304
1318
|
* {@link IAssignment} (same shape as {@link AssignmentResource.create}
|
|
@@ -1431,6 +1445,8 @@ var AssignmentResource = class extends BaseResource {
|
|
|
1431
1445
|
* @param payload - Signers plus optional `method` (defaults to `virtual`),
|
|
1432
1446
|
* `message`, `expires_at`, `copy_receivers` (existing signer IDs, not
|
|
1433
1447
|
* addresses), and `collect`-mode `entries` with page-image geometry.
|
|
1448
|
+
* `expires_at` accepts a date (ending at 23:59 UTC), a date-time without
|
|
1449
|
+
* an offset (UTC), or an offset-aware date-time.
|
|
1434
1450
|
* @returns The created {@link IAssignment}: `signers` (rich, with `step` /
|
|
1435
1451
|
* `notified` / `verification_method`), `items` (one row per signer × field),
|
|
1436
1452
|
* a `summary` count block, and per-signer `signing_urls`. Response shape:
|
|
@@ -1618,9 +1634,10 @@ var AssignmentResource = class extends BaseResource {
|
|
|
1618
1634
|
* (`PUT /documents/{documentId}/assignments/{assignmentId}/reset-expiration`).
|
|
1619
1635
|
*
|
|
1620
1636
|
* Sends `{ expires_at }` verbatim; the key itself is required by the
|
|
1621
|
-
* contract. Use an ISO-8601 date
|
|
1622
|
-
*
|
|
1623
|
-
*
|
|
1637
|
+
* contract. Use an ISO-8601 date, a date-time with or without an offset,
|
|
1638
|
+
* or `null` to remove the expiration. Date-only values end at 23:59 UTC;
|
|
1639
|
+
* date-times without offsets are UTC. `null` is intentionally not stripped
|
|
1640
|
+
* from the body.
|
|
1624
1641
|
*
|
|
1625
1642
|
* Request body (`application/json`):
|
|
1626
1643
|
* ```jsonc
|
|
@@ -1631,8 +1648,8 @@ var AssignmentResource = class extends BaseResource {
|
|
|
1631
1648
|
*
|
|
1632
1649
|
* @param documentId - The document the assignment belongs to.
|
|
1633
1650
|
* @param assignmentId - The assignment to update.
|
|
1634
|
-
* @param expiresAt - New expiry as an ISO-8601 date
|
|
1635
|
-
* to remove the expiration.
|
|
1651
|
+
* @param expiresAt - New expiry as an ISO-8601 date or date-time string,
|
|
1652
|
+
* or `null` to remove the expiration.
|
|
1636
1653
|
* @returns The updated {@link IAssignment} — the same full shape
|
|
1637
1654
|
* {@link AssignmentResource.create} returns (`signers`, `items`, `summary`,
|
|
1638
1655
|
* `signing_urls`), with `expires_at` reflecting the new value:
|
|
@@ -1676,7 +1693,7 @@ var AssignmentResource = class extends BaseResource {
|
|
|
1676
1693
|
async resetExpiration(documentId, assignmentId, expiresAt) {
|
|
1677
1694
|
const docId = this.requireId(documentId, "Document ID");
|
|
1678
1695
|
const asgId = this.requireId(assignmentId, "Assignment ID");
|
|
1679
|
-
if (expiresAt !== null)
|
|
1696
|
+
if (expiresAt !== null) assertExpirationDate(expiresAt, "expiresAt");
|
|
1680
1697
|
return this.call(
|
|
1681
1698
|
"Failed to update assignment expiration",
|
|
1682
1699
|
() => this.http.put(
|
|
@@ -2136,7 +2153,7 @@ var DocumentResource = class extends BaseResource {
|
|
|
2136
2153
|
* a compact representation with no expanded `assignment` or `pages`, so
|
|
2137
2154
|
* prefer it for name lookups and pickers.
|
|
2138
2155
|
*
|
|
2139
|
-
* @param params - `search`, `status`, `page`, `per-page`.
|
|
2156
|
+
* @param params - `search`, `status`, `page`, `per-page`, and `sort`.
|
|
2140
2157
|
* @param accountId - Override the client's default account ID.
|
|
2141
2158
|
* @returns Matching documents, with pagination in `meta`. Each item:
|
|
2142
2159
|
* ```jsonc
|
|
@@ -2492,14 +2509,22 @@ var DocumentResource = class extends BaseResource {
|
|
|
2492
2509
|
);
|
|
2493
2510
|
}
|
|
2494
2511
|
/**
|
|
2495
|
-
* Fetch the document activity log
|
|
2512
|
+
* Fetch a page of the document activity log
|
|
2496
2513
|
* (`GET /documents/{documentId}/activities`).
|
|
2497
2514
|
*
|
|
2498
|
-
*
|
|
2499
|
-
*
|
|
2515
|
+
* Production returns 20 entries per page by default, newest first. Request
|
|
2516
|
+
* later pages explicitly; a page past the end returns `[]`. Sandbox still
|
|
2517
|
+
* returns the full, unpaged log and may ignore these parameters. This method
|
|
2518
|
+
* preserves its array return type; use {@link DocumentResource.listActivities}
|
|
2519
|
+
* for pagination metadata. Normalises an absent body to `[]`.
|
|
2500
2520
|
*
|
|
2501
2521
|
* @param documentId - The document whose activity log to fetch.
|
|
2502
|
-
* @
|
|
2522
|
+
* @param params - Optional pagination and sorting parameters.
|
|
2523
|
+
* @param params.page - Page number, starting at 1.
|
|
2524
|
+
* @param params.per-page - Entries per page (production default 20, documented max 100).
|
|
2525
|
+
* @param params.per_page - Alias for `per-page`; explicit `per-page` wins.
|
|
2526
|
+
* @param params.sort - `-id` (default, newest first) or `id` (oldest first).
|
|
2527
|
+
* @returns The requested page of activity entries, or `[]`:
|
|
2503
2528
|
* ```jsonc
|
|
2504
2529
|
* [
|
|
2505
2530
|
* {
|
|
@@ -2520,22 +2545,66 @@ var DocumentResource = class extends BaseResource {
|
|
|
2520
2545
|
* }
|
|
2521
2546
|
* ]
|
|
2522
2547
|
* ```
|
|
2523
|
-
* @throws {ValidationError} If `documentId` is missing.
|
|
2524
|
-
* @throws {ApiError} If the API rejects the request.
|
|
2548
|
+
* @throws {ValidationError} If `documentId` is missing or invalid, or `params` is not an object.
|
|
2549
|
+
* @throws {ApiError} If the API rejects the request (`401` for invalid credentials, `500` for a server error).
|
|
2525
2550
|
*
|
|
2526
2551
|
* @example
|
|
2527
2552
|
* ```ts
|
|
2528
|
-
* const events = await client.documents.activities('doc-1'
|
|
2553
|
+
* const events = await client.documents.activities('doc-1', {
|
|
2554
|
+
* page: 2, 'per-page': 100, sort: 'id',
|
|
2555
|
+
* });
|
|
2529
2556
|
* console.log(events.map((e) => e.event));
|
|
2530
2557
|
* ```
|
|
2531
2558
|
*/
|
|
2532
|
-
async activities(documentId) {
|
|
2559
|
+
async activities(documentId, params = {}) {
|
|
2560
|
+
return (await this.listActivities(documentId, params)).data;
|
|
2561
|
+
}
|
|
2562
|
+
/**
|
|
2563
|
+
* Fetch document activities with pagination metadata
|
|
2564
|
+
* (`GET /documents/{documentId}/activities`).
|
|
2565
|
+
*
|
|
2566
|
+
* Production defaults to 20 entries, newest first. `meta` comes from the
|
|
2567
|
+
* `X-Pagination-*` headers; use `last_page` to request the remaining pages.
|
|
2568
|
+
* Sandbox returns the full unpaged log without `meta`: process it once.
|
|
2569
|
+
* Normalises an absent body to an empty list. Makes exactly one request.
|
|
2570
|
+
*
|
|
2571
|
+
* @param documentId - The document whose activity log to fetch.
|
|
2572
|
+
* @param params - Optional pagination and sorting parameters.
|
|
2573
|
+
* @param params.page - Page number, starting at 1.
|
|
2574
|
+
* @param params.per-page - Entries per page (production default 20, documented max 100).
|
|
2575
|
+
* @param params.per_page - Alias for `per-page`; explicit `per-page` wins.
|
|
2576
|
+
* @param params.sort - `-id` (default, newest first) or `id` (oldest first).
|
|
2577
|
+
* @returns Activity entries and pagination metadata when the server supplies it:
|
|
2578
|
+
* ```jsonc
|
|
2579
|
+
* {
|
|
2580
|
+
* "data": [{
|
|
2581
|
+
* "id": 15271,
|
|
2582
|
+
* "event": "document_uploaded",
|
|
2583
|
+
* "message": "Documento criado.",
|
|
2584
|
+
* "payload": [],
|
|
2585
|
+
* "origin": null,
|
|
2586
|
+
* "created_at": "2026-07-19T14:56:55Z"
|
|
2587
|
+
* }],
|
|
2588
|
+
* "meta": { "current_page": 2, "per_page": 20, "total": 21, "last_page": 2 }
|
|
2589
|
+
* }
|
|
2590
|
+
* ```
|
|
2591
|
+
* @throws {ValidationError} If `documentId` is missing or invalid, or `params` is not an object.
|
|
2592
|
+
* @throws {ApiError} If the API rejects the request (`401` for invalid credentials, `500` for a server error).
|
|
2593
|
+
* @example
|
|
2594
|
+
* ```ts
|
|
2595
|
+
* const { data, meta } = await client.documents.listActivities('doc-1', { page: 2 });
|
|
2596
|
+
* console.log(data, meta?.total);
|
|
2597
|
+
* ```
|
|
2598
|
+
*/
|
|
2599
|
+
async listActivities(documentId, params = {}) {
|
|
2533
2600
|
const id = this.requireId(documentId, "Document ID");
|
|
2534
|
-
|
|
2601
|
+
return this.callList(
|
|
2535
2602
|
"Failed to fetch document activities",
|
|
2536
|
-
() => this.http.get(`/documents/${this.pathSegment(id, "Document ID")}/activities
|
|
2603
|
+
() => this.http.get(`/documents/${this.pathSegment(id, "Document ID")}/activities`, {
|
|
2604
|
+
params: cleanListParams(params)
|
|
2605
|
+
}),
|
|
2606
|
+
true
|
|
2537
2607
|
);
|
|
2538
|
-
return result ?? [];
|
|
2539
2608
|
}
|
|
2540
2609
|
/**
|
|
2541
2610
|
* Delete a document (`DELETE /documents/{documentId}`).
|
|
@@ -2746,9 +2815,11 @@ var DocumentResource = class extends BaseResource {
|
|
|
2746
2815
|
*
|
|
2747
2816
|
* Instantiates the template, binding each role to a signer, and returns the
|
|
2748
2817
|
* new document. The request body is `{ signers, ...options }` — `signers`
|
|
2749
|
-
* maps every template `role_id` to an existing
|
|
2750
|
-
*
|
|
2751
|
-
*
|
|
2818
|
+
* maps every template `role_id` to an existing signer `id` or an `email`.
|
|
2819
|
+
* An email reuses the matching account signer or creates one with `name`;
|
|
2820
|
+
* `id` wins when both are present. Options may add `name`, `message`,
|
|
2821
|
+
* `expires_at`, `editor_fields`, and tag names in `tags` (unknown names are
|
|
2822
|
+
* created automatically).
|
|
2752
2823
|
*
|
|
2753
2824
|
* Request body (`application/json`):
|
|
2754
2825
|
* ```jsonc
|
|
@@ -2756,7 +2827,9 @@ var DocumentResource = class extends BaseResource {
|
|
|
2756
2827
|
* "signers": [
|
|
2757
2828
|
* {
|
|
2758
2829
|
* "role_id": "signing_role_example",
|
|
2759
|
-
* "
|
|
2830
|
+
* "email": "signer@example.com",
|
|
2831
|
+
* "name": "Example Signer",
|
|
2832
|
+
* "whatsapp_phone_number": "+15555550100",
|
|
2760
2833
|
* "verification_method": "Email",
|
|
2761
2834
|
* "notification_methods": [
|
|
2762
2835
|
* "Email"
|
|
@@ -2780,27 +2853,33 @@ var DocumentResource = class extends BaseResource {
|
|
|
2780
2853
|
* ```
|
|
2781
2854
|
*
|
|
2782
2855
|
* @param templateId - The template to instantiate.
|
|
2783
|
-
* @param signers - Role-to-signer bindings (each with `role_id` and
|
|
2784
|
-
*
|
|
2856
|
+
* @param signers - Role-to-signer bindings (each with `role_id` and either
|
|
2857
|
+
* an existing `id` or an `email`; email creation also accepts `name` and
|
|
2858
|
+
* `whatsapp_phone_number`). `verification_method`, `notification_methods`,
|
|
2859
|
+
* and `step` are optional.
|
|
2785
2860
|
* Only one notification method is allowed per signer; when only one of the
|
|
2786
2861
|
* verification/notification fields is supplied, the API infers the other.
|
|
2787
2862
|
* `DigitalCertificate` costs 0.5 credits, requires the feature plus a
|
|
2788
2863
|
* signer `government_id`, and that signer must be alone in its step. The
|
|
2789
|
-
* server derives the assignment method from placed template fields
|
|
2790
|
-
*
|
|
2791
|
-
*
|
|
2864
|
+
* server derives the assignment method from placed template fields and
|
|
2865
|
+
* rejects certificate signers when those fields produce a `collect`
|
|
2866
|
+
* assignment. Use a template without placed signer fields for certificate
|
|
2867
|
+
* signing.
|
|
2792
2868
|
* `IdDocumentFaceMatchBasic` needs the ID Document + Face Match feature
|
|
2793
2869
|
* and a valid CPF in `government_id`; estimate the per-signer fee first.
|
|
2794
2870
|
* @param options - Optional `name`, `message`, `expires_at`,
|
|
2795
2871
|
* `editor_fields`, `tags`.
|
|
2796
2872
|
* @param options.name - Generated document display name.
|
|
2797
2873
|
* @param options.message - Signing invitation message.
|
|
2798
|
-
* @param options.expires_at - ISO-8601
|
|
2874
|
+
* @param options.expires_at - ISO-8601 deadline: date-only (ends at 23:59
|
|
2875
|
+
* UTC), date-time without an offset (treated as UTC), or an offset-aware
|
|
2876
|
+
* date-time.
|
|
2799
2877
|
* @param options.editor_fields - Template editor values as `{ field_id, value }` entries.
|
|
2800
2878
|
* @param options.tags - Tag names attached to the generated document.
|
|
2801
2879
|
* @param accountId - Override the client's default account ID.
|
|
2802
|
-
* @returns The
|
|
2803
|
-
* `
|
|
2880
|
+
* @returns The uploaded document. Assignment creation continues in the
|
|
2881
|
+
* background; follow `GET /documents/{documentId}` or webhooks until the
|
|
2882
|
+
* document becomes `pending_signature` or `failed`:
|
|
2804
2883
|
* ```jsonc
|
|
2805
2884
|
* {
|
|
2806
2885
|
* "resource": "document",
|
|
@@ -2808,22 +2887,21 @@ var DocumentResource = class extends BaseResource {
|
|
|
2808
2887
|
* "account_id": "acc_example",
|
|
2809
2888
|
* "template_id": "103a0991a5cde83518e5672aa9aa",
|
|
2810
2889
|
* "name": "Service agreement from template",
|
|
2811
|
-
* "status": "
|
|
2812
|
-
* "artifacts": { "original": "https://…/download/original"
|
|
2890
|
+
* "status": "uploaded",
|
|
2891
|
+
* "artifacts": { "original": "https://…/download/original" },
|
|
2813
2892
|
* "is_closed": false,
|
|
2814
2893
|
* "signing_url": "https://app.assinafy.com.br/sign/19f675b7…",
|
|
2815
2894
|
* "tags": [{ "id": "103a0992…", "name": "agreements", "color": null }],
|
|
2816
|
-
* "assignment":
|
|
2817
|
-
* "pages": [
|
|
2895
|
+
* "assignment": null,
|
|
2896
|
+
* "pages": [],
|
|
2818
2897
|
* "created_at": "2026-07-15T19:57:55Z",
|
|
2819
2898
|
* "updated_at": "2026-07-15T19:59:33Z"
|
|
2820
2899
|
* }
|
|
2821
2900
|
* ```
|
|
2822
|
-
* @throws {ValidationError} If `templateId
|
|
2823
|
-
*
|
|
2824
|
-
*
|
|
2825
|
-
*
|
|
2826
|
-
* is not ready.
|
|
2901
|
+
* @throws {ValidationError} If `templateId`, an account ID, signer identity,
|
|
2902
|
+
* channel, order, deadline, editor field, or tag is invalid.
|
|
2903
|
+
* @throws {ApiError} `400` if the signers/roles are invalid, the template
|
|
2904
|
+
* is not ready, or placed signer fields conflict with `DigitalCertificate`.
|
|
2827
2905
|
*
|
|
2828
2906
|
* @example
|
|
2829
2907
|
* ```ts
|
|
@@ -2840,7 +2918,7 @@ var DocumentResource = class extends BaseResource {
|
|
|
2840
2918
|
if (options.message !== void 0 && typeof options.message !== "string") {
|
|
2841
2919
|
throw new ValidationError("message must be a string");
|
|
2842
2920
|
}
|
|
2843
|
-
if (options.expires_at !== void 0)
|
|
2921
|
+
if (options.expires_at !== void 0) assertExpirationDate(options.expires_at, "expires_at");
|
|
2844
2922
|
const editorFields = options.editor_fields === void 0 ? void 0 : normaliseTemplateEditorFields(options.editor_fields);
|
|
2845
2923
|
if (options.tags !== void 0 && (!Array.isArray(options.tags) || options.tags.some((tag) => typeof tag !== "string" || !tag.trim()))) {
|
|
2846
2924
|
throw new ValidationError("tags must be an array of non-empty tag names");
|
|
@@ -2870,10 +2948,8 @@ var DocumentResource = class extends BaseResource {
|
|
|
2870
2948
|
*
|
|
2871
2949
|
* A dry run: sends only `{ signers }` and consumes nothing. Use it to check
|
|
2872
2950
|
* balances before calling {@link DocumentResource.createFromTemplate}.
|
|
2873
|
-
* `DigitalCertificate`
|
|
2874
|
-
*
|
|
2875
|
-
* refuses certificate signers instead of returning a price for an
|
|
2876
|
-
* assignment that may charge credits but cannot be completed.
|
|
2951
|
+
* `DigitalCertificate` adds 0.5 credits per signer plus notification cost;
|
|
2952
|
+
* the API returns `400` when the template has placed signer fields.
|
|
2877
2953
|
*
|
|
2878
2954
|
* Request body (`application/json`):
|
|
2879
2955
|
* ```jsonc
|
|
@@ -2915,10 +2991,10 @@ var DocumentResource = class extends BaseResource {
|
|
|
2915
2991
|
* "message": null
|
|
2916
2992
|
* }
|
|
2917
2993
|
* ```
|
|
2918
|
-
* @throws {ValidationError} If `templateId
|
|
2919
|
-
*
|
|
2920
|
-
*
|
|
2921
|
-
*
|
|
2994
|
+
* @throws {ValidationError} If `templateId`, an account ID, role, or
|
|
2995
|
+
* channel is invalid.
|
|
2996
|
+
* @throws {ApiError} `400` if the role is invalid or placed signer fields
|
|
2997
|
+
* conflict with `DigitalCertificate`; `403` when a feature is unavailable.
|
|
2922
2998
|
*
|
|
2923
2999
|
* @example
|
|
2924
3000
|
* ```ts
|
|
@@ -3198,11 +3274,33 @@ function normaliseTemplateSigners(signers) {
|
|
|
3198
3274
|
if (typeof signer.role_id !== "string" || !signer.role_id.trim()) {
|
|
3199
3275
|
throw new ValidationError(`Template signer ${index + 1} requires role_id`);
|
|
3200
3276
|
}
|
|
3201
|
-
if (typeof signer.id !== "string" || !signer.id.trim()) {
|
|
3202
|
-
throw new ValidationError(`Template signer ${index + 1} requires id`);
|
|
3203
|
-
}
|
|
3204
3277
|
validateAssignmentSignerOptions(signer, `Template signer ${index + 1}`);
|
|
3205
|
-
const projected = { role_id: signer.role_id
|
|
3278
|
+
const projected = { role_id: signer.role_id };
|
|
3279
|
+
if (signer.id !== void 0) {
|
|
3280
|
+
if (typeof signer.id !== "string" || !signer.id.trim()) {
|
|
3281
|
+
throw new ValidationError(`Template signer ${index + 1} id must be non-empty`);
|
|
3282
|
+
}
|
|
3283
|
+
projected.id = signer.id;
|
|
3284
|
+
} else {
|
|
3285
|
+
if (!isEmail(signer.email)) {
|
|
3286
|
+
throw new ValidationError(`Template signer ${index + 1} requires a valid id or email`);
|
|
3287
|
+
}
|
|
3288
|
+
projected.email = signer.email;
|
|
3289
|
+
if (signer.name !== void 0) {
|
|
3290
|
+
if (typeof signer.name !== "string" || !signer.name.trim()) {
|
|
3291
|
+
throw new ValidationError(`Template signer ${index + 1} name must be non-empty`);
|
|
3292
|
+
}
|
|
3293
|
+
projected.name = signer.name;
|
|
3294
|
+
}
|
|
3295
|
+
if (signer.whatsapp_phone_number !== void 0) {
|
|
3296
|
+
if (!isE164PhoneNumber(signer.whatsapp_phone_number)) {
|
|
3297
|
+
throw new ValidationError(
|
|
3298
|
+
`Template signer ${index + 1} whatsapp_phone_number must be E.164`
|
|
3299
|
+
);
|
|
3300
|
+
}
|
|
3301
|
+
projected.whatsapp_phone_number = signer.whatsapp_phone_number;
|
|
3302
|
+
}
|
|
3303
|
+
}
|
|
3206
3304
|
if (signer.verification_method !== void 0) {
|
|
3207
3305
|
projected.verification_method = signer.verification_method;
|
|
3208
3306
|
}
|
|
@@ -3212,7 +3310,6 @@ function normaliseTemplateSigners(signers) {
|
|
|
3212
3310
|
if (signer.step !== void 0) projected.step = signer.step;
|
|
3213
3311
|
return projected;
|
|
3214
3312
|
});
|
|
3215
|
-
validateDigitalCertificateMethod(void 0, normalised);
|
|
3216
3313
|
return normalised;
|
|
3217
3314
|
}
|
|
3218
3315
|
function normaliseTemplateEditorFields(fields) {
|
|
@@ -3253,7 +3350,6 @@ function normaliseTemplateCostSigners(signers) {
|
|
|
3253
3350
|
}
|
|
3254
3351
|
return descriptor;
|
|
3255
3352
|
});
|
|
3256
|
-
validateDigitalCertificateMethod(void 0, normalised);
|
|
3257
3353
|
return normalised;
|
|
3258
3354
|
}
|
|
3259
3355
|
function validateWaitOption(value, name) {
|
|
@@ -4154,6 +4250,8 @@ var WebhookResource = class extends BaseResource {
|
|
|
4154
4250
|
* "document_processing_failed"
|
|
4155
4251
|
* ],
|
|
4156
4252
|
* "is_active": true,
|
|
4253
|
+
* "is_held": false,
|
|
4254
|
+
* "held_since": null,
|
|
4157
4255
|
* "updated_at": "2026-07-18T02:36:02Z" // no `id` / `created_at` are returned
|
|
4158
4256
|
* }
|
|
4159
4257
|
* ```
|
|
@@ -4323,11 +4421,12 @@ var WebhookResource = class extends BaseResource {
|
|
|
4323
4421
|
* (`GET /accounts/{accountId}/webhooks`). Pagination info (if any) is
|
|
4324
4422
|
* attached in `meta`.
|
|
4325
4423
|
*
|
|
4326
|
-
* Assinafy treats any `2xx` response as success.
|
|
4327
|
-
*
|
|
4328
|
-
*
|
|
4329
|
-
*
|
|
4330
|
-
*
|
|
4424
|
+
* Assinafy treats any `2xx` response as success. Retriable failures get up
|
|
4425
|
+
* to six attempts about ten minutes apart. After ten failed deliveries in
|
|
4426
|
+
* a row, the endpoint is paused and probed after 3, 15 and 60 minutes, then
|
|
4427
|
+
* every six hours. A successful delivery or probe resumes the endpoint and
|
|
4428
|
+
* replays missed events oldest first. Response bodies are truncated to
|
|
4429
|
+
* 2,000 characters and delivery entries are retained for seven days.
|
|
4331
4430
|
*
|
|
4332
4431
|
* @param params - Optional filters and pagination:
|
|
4333
4432
|
* - `endpoint_id` — only deliveries to this webhook endpoint.
|
|
@@ -4354,6 +4453,10 @@ var WebhookResource = class extends BaseResource {
|
|
|
4354
4453
|
* // subject: <User>, account_id, created_at }
|
|
4355
4454
|
* },
|
|
4356
4455
|
* "delivered": true,
|
|
4456
|
+
* "webhook_id": "9f86d081884c7d659a2feaa0c55ad015",
|
|
4457
|
+
* "attempt": 1,
|
|
4458
|
+
* "kind": "scheduled",
|
|
4459
|
+
* "will_retry": false,
|
|
4357
4460
|
* "http_status": 200,
|
|
4358
4461
|
* "response_body": "{ ... }", // receiving endpoint body, max 2,000 chars
|
|
4359
4462
|
* "error": null,
|
|
@@ -4446,11 +4549,14 @@ var WebhookResource = class extends BaseResource {
|
|
|
4446
4549
|
* [
|
|
4447
4550
|
* {
|
|
4448
4551
|
* "id": "65f1c2a9b3e4d5f60718293a4b5c6d7e",
|
|
4552
|
+
* "resource": "activity_event_subscription",
|
|
4449
4553
|
* "name": "ERP",
|
|
4450
4554
|
* "url": "https://example.com/webhooks/assinafy",
|
|
4451
4555
|
* "email": "ops@example.com",
|
|
4452
4556
|
* "events": ["document_ready", "signer_signed_document"],
|
|
4453
4557
|
* "is_active": true,
|
|
4558
|
+
* "is_held": false,
|
|
4559
|
+
* "held_since": null,
|
|
4454
4560
|
* "signing_enabled": true, // deliveries carry a `webhook-signature` header
|
|
4455
4561
|
* "created_at": "2026-10-01T12:00:00Z",
|
|
4456
4562
|
* "updated_at": "2026-10-01T12:00:00Z"
|
|
@@ -4468,7 +4574,7 @@ var WebhookResource = class extends BaseResource {
|
|
|
4468
4574
|
*/
|
|
4469
4575
|
async listEndpoints(accountId, params = {}) {
|
|
4470
4576
|
assertRecord(params, "webhook endpoint filters");
|
|
4471
|
-
if (params.url !== void 0) validateWebhookUrl(params.url);
|
|
4577
|
+
if (params.url !== void 0) validateWebhookUrl(params.url, true);
|
|
4472
4578
|
const path2 = this.endpointsPath(accountId);
|
|
4473
4579
|
return this.call(
|
|
4474
4580
|
"Failed to list webhook endpoints",
|
|
@@ -4482,8 +4588,8 @@ var WebhookResource = class extends BaseResource {
|
|
|
4482
4588
|
* An account can have 1 endpoint, or up to 3 on paid plans. Each endpoint
|
|
4483
4589
|
* of a workspace needs a different `url`. With `signing_enabled: true` the
|
|
4484
4590
|
* API returns a signing `secret` in this creation response. Store it now:
|
|
4485
|
-
* OAuth applications cannot call {@link WebhookResource.getEndpointSecret}
|
|
4486
|
-
*
|
|
4591
|
+
* OAuth applications cannot call {@link WebhookResource.getEndpointSecret},
|
|
4592
|
+
* but they can rotate a lost secret. When `events` is omitted or
|
|
4487
4593
|
* empty, {@link DEFAULT_WEBHOOK_EVENTS} is sent. OAuth tokens need the
|
|
4488
4594
|
* `webhooks:write` scope.
|
|
4489
4595
|
*
|
|
@@ -4499,19 +4605,22 @@ var WebhookResource = class extends BaseResource {
|
|
|
4499
4605
|
* }
|
|
4500
4606
|
* ```
|
|
4501
4607
|
*
|
|
4502
|
-
* @param payload - Endpoint details. `url` (absolute
|
|
4608
|
+
* @param payload - Endpoint details. `url` (absolute HTTPS) and `email`
|
|
4503
4609
|
* are required; `events`, `name`, `is_active` and `signing_enabled` are
|
|
4504
4610
|
* optional.
|
|
4505
4611
|
* @param accountId - Override the client's default account ID.
|
|
4506
4612
|
* @returns The created endpoint:
|
|
4507
4613
|
* ```jsonc
|
|
4508
4614
|
* {
|
|
4615
|
+
* "resource": "activity_event_subscription",
|
|
4509
4616
|
* "id": "65f1c2a9b3e4d5f60718293a4b5c6d7e",
|
|
4510
4617
|
* "name": "ERP",
|
|
4511
4618
|
* "url": "https://example.com/webhooks/assinafy",
|
|
4512
4619
|
* "email": "ops@example.com",
|
|
4513
4620
|
* "events": ["document_ready", "signer_signed_document"],
|
|
4514
4621
|
* "is_active": true,
|
|
4622
|
+
* "is_held": false,
|
|
4623
|
+
* "held_since": null,
|
|
4515
4624
|
* "signing_enabled": true, // deliveries carry a `webhook-signature` header
|
|
4516
4625
|
* "secret": "whsec_c2VjcmV0", // only in this response when signing is enabled
|
|
4517
4626
|
* "created_at": "2026-10-01T12:00:00Z",
|
|
@@ -4555,12 +4664,15 @@ var WebhookResource = class extends BaseResource {
|
|
|
4555
4664
|
* @returns The endpoint:
|
|
4556
4665
|
* ```jsonc
|
|
4557
4666
|
* {
|
|
4667
|
+
* "resource": "activity_event_subscription",
|
|
4558
4668
|
* "id": "65f1c2a9b3e4d5f60718293a4b5c6d7e",
|
|
4559
4669
|
* "name": "ERP",
|
|
4560
4670
|
* "url": "https://example.com/webhooks/assinafy",
|
|
4561
4671
|
* "email": "ops@example.com",
|
|
4562
4672
|
* "events": ["document_ready", "signer_signed_document"],
|
|
4563
4673
|
* "is_active": true,
|
|
4674
|
+
* "is_held": false,
|
|
4675
|
+
* "held_since": null,
|
|
4564
4676
|
* "signing_enabled": true, // deliveries carry a `webhook-signature` header
|
|
4565
4677
|
* "created_at": "2026-10-01T12:00:00Z",
|
|
4566
4678
|
* "updated_at": "2026-10-01T12:00:00Z"
|
|
@@ -4582,12 +4694,13 @@ var WebhookResource = class extends BaseResource {
|
|
|
4582
4694
|
/**
|
|
4583
4695
|
* Change a webhook endpoint
|
|
4584
4696
|
* (`PUT /accounts/{accountId}/webhooks/endpoints/{endpointId}`). Only the
|
|
4585
|
-
* fields sent are updated; `url`
|
|
4586
|
-
*
|
|
4697
|
+
* fields sent are updated; a changed `url` must be HTTPS, publicly
|
|
4698
|
+
* routable, and different from every other endpoint in the workspace.
|
|
4587
4699
|
*
|
|
4588
4700
|
* `signing_enabled: true` generates a secret if the endpoint has none and
|
|
4589
|
-
* keeps the current one otherwise; `false` discards the secret.
|
|
4590
|
-
*
|
|
4701
|
+
* keeps the current one otherwise; `false` discards the secret. When this
|
|
4702
|
+
* request turns signing on, the response includes the new `secret` once.
|
|
4703
|
+
* OAuth tokens need the `webhooks:write` scope.
|
|
4591
4704
|
*
|
|
4592
4705
|
* Request body (`application/json`, every field optional):
|
|
4593
4706
|
* ```jsonc
|
|
@@ -4607,13 +4720,17 @@ var WebhookResource = class extends BaseResource {
|
|
|
4607
4720
|
* @returns The updated endpoint:
|
|
4608
4721
|
* ```jsonc
|
|
4609
4722
|
* {
|
|
4723
|
+
* "resource": "activity_event_subscription",
|
|
4610
4724
|
* "id": "65f1c2a9b3e4d5f60718293a4b5c6d7e",
|
|
4611
4725
|
* "name": "ERP",
|
|
4612
4726
|
* "url": "https://example.com/webhooks/assinafy",
|
|
4613
4727
|
* "email": "ops@example.com",
|
|
4614
4728
|
* "events": ["document_ready", "signer_signed_document"],
|
|
4615
4729
|
* "is_active": true,
|
|
4730
|
+
* "is_held": false,
|
|
4731
|
+
* "held_since": null,
|
|
4616
4732
|
* "signing_enabled": true, // deliveries carry a `webhook-signature` header
|
|
4733
|
+
* "secret": "whsec_c2VjcmV0", // only when this request turned signing on
|
|
4617
4734
|
* "created_at": "2026-10-01T12:00:00Z",
|
|
4618
4735
|
* "updated_at": "2026-10-01T12:00:00Z"
|
|
4619
4736
|
* }
|
|
@@ -4677,7 +4794,7 @@ var WebhookResource = class extends BaseResource {
|
|
|
4677
4794
|
* ```
|
|
4678
4795
|
*/
|
|
4679
4796
|
async deleteEndpointByUrl(url, accountId) {
|
|
4680
|
-
validateWebhookUrl(url);
|
|
4797
|
+
validateWebhookUrl(url, true);
|
|
4681
4798
|
const path2 = this.endpointsPath(accountId);
|
|
4682
4799
|
return this.callVoid(
|
|
4683
4800
|
"Failed to delete webhook endpoint",
|
|
@@ -4717,7 +4834,7 @@ var WebhookResource = class extends BaseResource {
|
|
|
4717
4834
|
* (`POST /accounts/{accountId}/webhooks/endpoints/{endpointId}/secret/rotate`).
|
|
4718
4835
|
* The old secret stops working immediately: deliveries sent after the
|
|
4719
4836
|
* rotation are signed only with the new secret, so update the receiver at
|
|
4720
|
-
* once.
|
|
4837
|
+
* once. OAuth tokens need the `webhooks:write` scope.
|
|
4721
4838
|
*
|
|
4722
4839
|
* @param endpointId - The endpoint ID.
|
|
4723
4840
|
* @param accountId - Override the client's default account ID.
|
|
@@ -4778,15 +4895,15 @@ function validateWebhookFields(payload, required) {
|
|
|
4778
4895
|
throw new ValidationError("Webhook name must be a string");
|
|
4779
4896
|
}
|
|
4780
4897
|
}
|
|
4781
|
-
function validateWebhookUrl(value) {
|
|
4898
|
+
function validateWebhookUrl(value, allowStoredHttp = false) {
|
|
4782
4899
|
let url;
|
|
4783
4900
|
try {
|
|
4784
4901
|
url = new URL(value ?? "");
|
|
4785
4902
|
} catch {
|
|
4786
|
-
throw new ValidationError("Webhook URL must be an absolute
|
|
4903
|
+
throw new ValidationError("Webhook URL must be an absolute HTTPS URL", { url: value });
|
|
4787
4904
|
}
|
|
4788
|
-
if (url.protocol !== "https:" && url.protocol
|
|
4789
|
-
throw new ValidationError("Webhook URL must be an absolute
|
|
4905
|
+
if (url.protocol !== "https:" && !(allowStoredHttp && url.protocol === "http:") || !url.hostname) {
|
|
4906
|
+
throw new ValidationError("Webhook URL must be an absolute HTTPS URL", { url: value });
|
|
4790
4907
|
}
|
|
4791
4908
|
}
|
|
4792
4909
|
|
|
@@ -7947,7 +8064,7 @@ function assertDeclineReason(declineReason) {
|
|
|
7947
8064
|
if (typeof declineReason !== "string" || !declineReason.trim()) {
|
|
7948
8065
|
throw new ValidationError("declineReason is required");
|
|
7949
8066
|
}
|
|
7950
|
-
if (declineReason.length > 2e3) {
|
|
8067
|
+
if ([...declineReason].length > 2e3) {
|
|
7951
8068
|
throw new ValidationError("declineReason must be at most 2000 characters");
|
|
7952
8069
|
}
|
|
7953
8070
|
}
|
|
@@ -9378,8 +9495,9 @@ var AssinafyClient = class _AssinafyClient {
|
|
|
9378
9495
|
* the API; only `collect` assignments require pre-rendered pages.
|
|
9379
9496
|
* @param options.waitOptions - Optional `maxWaitMs` / `pollIntervalMs`
|
|
9380
9497
|
* forwarded to {@link DocumentResource.waitUntilReady}.
|
|
9381
|
-
* @param options.expiresAt - Optional ISO-8601 assignment expiry
|
|
9382
|
-
*
|
|
9498
|
+
* @param options.expiresAt - Optional ISO-8601 assignment expiry. A date
|
|
9499
|
+
* ends at 23:59 UTC; a date-time without an offset is interpreted as UTC;
|
|
9500
|
+
* an explicit offset is honored.
|
|
9383
9501
|
* @param options.copyReceivers - Optional existing signer IDs (not email
|
|
9384
9502
|
* addresses) that receive a copy. See the caveat on
|
|
9385
9503
|
* {@link ICreateAssignmentPayload.copy_receivers}; some plans silently drop
|
|
@@ -9465,7 +9583,7 @@ var AssinafyClient = class _AssinafyClient {
|
|
|
9465
9583
|
if (options.metadata !== void 0) {
|
|
9466
9584
|
assertRecord(options.metadata, "metadata");
|
|
9467
9585
|
}
|
|
9468
|
-
if (options.expiresAt !== void 0)
|
|
9586
|
+
if (options.expiresAt !== void 0) assertExpirationDate(options.expiresAt, "expiresAt");
|
|
9469
9587
|
if (options.copyReceivers !== void 0 && (!Array.isArray(options.copyReceivers) || options.copyReceivers.some(
|
|
9470
9588
|
(id) => typeof id !== "string" || id.trim().length === 0
|
|
9471
9589
|
))) {
|