@assinafy/sdk 2.5.0 → 2.5.2
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 +57 -49
- package/README.en.md +77 -25
- package/README.md +29 -29
- package/dist/index.d.mts +580 -40
- package/dist/index.d.ts +580 -40
- package/dist/index.js +527 -55
- package/dist/index.mjs +523 -51
- package/docs/API_COVERAGE.md +12 -1
- package/docs/COMPATIBILITY.md +16 -22
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -59,7 +59,7 @@ __export(index_exports, {
|
|
|
59
59
|
module.exports = __toCommonJS(index_exports);
|
|
60
60
|
|
|
61
61
|
// src/client.ts
|
|
62
|
-
var
|
|
62
|
+
var import_axios4 = __toESM(require("axios"));
|
|
63
63
|
var import_promises = require("timers/promises");
|
|
64
64
|
|
|
65
65
|
// src/errors.ts
|
|
@@ -140,7 +140,9 @@ var ApiError = class _ApiError extends AssinafyError {
|
|
|
140
140
|
* ones with no structured body to explain them. Anything else falls back to
|
|
141
141
|
* the stable message.
|
|
142
142
|
* @returns An `ApiError` retaining the original response body in
|
|
143
|
-
* {@link ApiError.responseData}
|
|
143
|
+
* {@link ApiError.responseData}. A JSON `message` is used verbatim; only an
|
|
144
|
+
* unstructured text body is whitespace-collapsed and truncated for
|
|
145
|
+
* legibility.
|
|
144
146
|
*
|
|
145
147
|
* @example
|
|
146
148
|
* ```ts
|
|
@@ -193,6 +195,16 @@ var OAuthError = class _OAuthError extends ApiError {
|
|
|
193
195
|
* @param error - Any thrown value.
|
|
194
196
|
* @returns An `OAuthError` when the body carries a non-empty string
|
|
195
197
|
* `error`, else the original value.
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* ```ts
|
|
201
|
+
* const apiError = ApiError.fromResponse(400, {
|
|
202
|
+
* error: 'invalid_grant',
|
|
203
|
+
* error_description: 'The provided authorization grant is invalid.',
|
|
204
|
+
* });
|
|
205
|
+
* const upgraded = OAuthError.upgrade(apiError);
|
|
206
|
+
* // upgraded instanceof OAuthError → true, .error → 'invalid_grant'
|
|
207
|
+
* ```
|
|
196
208
|
*/
|
|
197
209
|
static upgrade(error) {
|
|
198
210
|
if (!(error instanceof ApiError) || error instanceof _OAuthError) return error;
|
|
@@ -201,12 +213,14 @@ var OAuthError = class _OAuthError extends ApiError {
|
|
|
201
213
|
const code = body["error"];
|
|
202
214
|
if (typeof code !== "string" || code.length === 0) return error;
|
|
203
215
|
const description = body["error_description"];
|
|
204
|
-
|
|
216
|
+
const upgraded = new _OAuthError(
|
|
205
217
|
code,
|
|
206
218
|
typeof description === "string" && description.length > 0 ? description : null,
|
|
207
219
|
error.statusCode,
|
|
208
220
|
body
|
|
209
221
|
);
|
|
222
|
+
if (error.challenge !== void 0) upgraded.challenge = error.challenge;
|
|
223
|
+
return upgraded;
|
|
210
224
|
}
|
|
211
225
|
};
|
|
212
226
|
var ValidationError = class extends AssinafyError {
|
|
@@ -510,6 +524,9 @@ function nextRetryDelayMs(headers, attempt, maxDelayMs = 3e4) {
|
|
|
510
524
|
return Math.min(backoffMs(attempt), maxDelayMs);
|
|
511
525
|
}
|
|
512
526
|
|
|
527
|
+
// src/resources/base.ts
|
|
528
|
+
var import_axios3 = require("axios");
|
|
529
|
+
|
|
513
530
|
// src/support/path.ts
|
|
514
531
|
function encodePathSegment(value) {
|
|
515
532
|
return encodeURIComponent(value).replace(
|
|
@@ -634,7 +651,7 @@ var import_axios2 = __toESM(require("axios"));
|
|
|
634
651
|
// package.json
|
|
635
652
|
var package_default = {
|
|
636
653
|
name: "@assinafy/sdk",
|
|
637
|
-
version: "2.5.
|
|
654
|
+
version: "2.5.2",
|
|
638
655
|
packageManager: "bun@1.4.0",
|
|
639
656
|
description: "TypeScript SDK for Assinafy API - Digital signature platform",
|
|
640
657
|
type: "commonjs",
|
|
@@ -715,7 +732,7 @@ var package_default = {
|
|
|
715
732
|
},
|
|
716
733
|
overrides: {
|
|
717
734
|
esbuild: "0.28.2",
|
|
718
|
-
"brace-expansion": "5.0.
|
|
735
|
+
"brace-expansion": "5.0.12"
|
|
719
736
|
},
|
|
720
737
|
files: [
|
|
721
738
|
"dist",
|
|
@@ -940,7 +957,10 @@ var BaseResource = class {
|
|
|
940
957
|
};
|
|
941
958
|
function assertSuccessful(response) {
|
|
942
959
|
if (response.status < 200 || response.status >= 300) {
|
|
943
|
-
throw
|
|
960
|
+
throw toSdkError(
|
|
961
|
+
new import_axios3.AxiosError("Request failed", void 0, response.config, void 0, response),
|
|
962
|
+
"API request failed"
|
|
963
|
+
);
|
|
944
964
|
}
|
|
945
965
|
return response;
|
|
946
966
|
}
|
|
@@ -1319,6 +1339,28 @@ var AssignmentResource = class extends BaseResource {
|
|
|
1319
1339
|
* `DigitalCertificate` costs two credits, requires the feature plus a
|
|
1320
1340
|
* signer `government_id`, and that signer must be alone in its step.
|
|
1321
1341
|
*
|
|
1342
|
+
* Request body (`application/json`):
|
|
1343
|
+
* ```jsonc
|
|
1344
|
+
* {
|
|
1345
|
+
* "method": "virtual",
|
|
1346
|
+
* "signers": [
|
|
1347
|
+
* {
|
|
1348
|
+
* "id": "signer_example",
|
|
1349
|
+
* "verification_method": "Email",
|
|
1350
|
+
* "notification_methods": [
|
|
1351
|
+
* "Email"
|
|
1352
|
+
* ],
|
|
1353
|
+
* "step": 1
|
|
1354
|
+
* }
|
|
1355
|
+
* ],
|
|
1356
|
+
* "message": "Please sign this document.",
|
|
1357
|
+
* "expires_at": "2027-12-31T23:59:59Z",
|
|
1358
|
+
* "copy_receivers": [
|
|
1359
|
+
* "copy_signer_example"
|
|
1360
|
+
* ]
|
|
1361
|
+
* }
|
|
1362
|
+
* ```
|
|
1363
|
+
*
|
|
1322
1364
|
* @param documentId - The document to request signatures on.
|
|
1323
1365
|
* @param payload - Signers plus optional `method` (defaults to `virtual`),
|
|
1324
1366
|
* `message`, `expires_at`, `copy_receivers` (existing signer IDs, not
|
|
@@ -1437,14 +1479,29 @@ var AssignmentResource = class extends BaseResource {
|
|
|
1437
1479
|
* email notification, and 0.45 for WhatsApp notification; a digital
|
|
1438
1480
|
* certificate charge is added on top of its notification cost.
|
|
1439
1481
|
*
|
|
1482
|
+
* Request body (`application/json`):
|
|
1483
|
+
* ```jsonc
|
|
1484
|
+
* {
|
|
1485
|
+
* "method": "virtual",
|
|
1486
|
+
* "signers": [
|
|
1487
|
+
* {
|
|
1488
|
+
* "verification_method": "Email",
|
|
1489
|
+
* "notification_methods": [
|
|
1490
|
+
* "Email"
|
|
1491
|
+
* ]
|
|
1492
|
+
* }
|
|
1493
|
+
* ]
|
|
1494
|
+
* }
|
|
1495
|
+
* ```
|
|
1496
|
+
*
|
|
1440
1497
|
* @param documentId - The document the assignment would be created on.
|
|
1441
1498
|
* @param payload - `method` plus channel-only signer descriptors and/or
|
|
1442
1499
|
* `collect`-mode `entries`. Create-only fields and signer IDs are not part
|
|
1443
|
-
* of this request schema.
|
|
1444
|
-
* `InsufficientDocuments`, or `InsufficientCredits`.
|
|
1500
|
+
* of this request schema.
|
|
1445
1501
|
* @returns an {@link ICostEstimate} with `total_credits`, balances, a
|
|
1446
|
-
* line-item `breakdown`, and a `has_sufficient_resources` gate.
|
|
1447
|
-
*
|
|
1502
|
+
* line-item `breakdown`, and a `has_sufficient_resources` gate.
|
|
1503
|
+
* `blocking_reason` may be `PendingPayment`, `InsufficientDocuments`, or
|
|
1504
|
+
* `InsufficientCredits`. Response shape:
|
|
1448
1505
|
* ```jsonc
|
|
1449
1506
|
* {
|
|
1450
1507
|
* "documents": 1,
|
|
@@ -1492,6 +1549,13 @@ var AssignmentResource = class extends BaseResource {
|
|
|
1492
1549
|
* is retained as a compatibility value and, unlike ordinary nullable
|
|
1493
1550
|
* inputs, is intentionally not stripped from the body.
|
|
1494
1551
|
*
|
|
1552
|
+
* Request body (`application/json`):
|
|
1553
|
+
* ```jsonc
|
|
1554
|
+
* {
|
|
1555
|
+
* "expires_at": "2027-12-31T23:59:59Z"
|
|
1556
|
+
* }
|
|
1557
|
+
* ```
|
|
1558
|
+
*
|
|
1495
1559
|
* @param documentId - The document the assignment belongs to.
|
|
1496
1560
|
* @param assignmentId - The assignment to update.
|
|
1497
1561
|
* @param expiresAt - New expiry as an ISO-8601 date/time string. `null` is
|
|
@@ -1907,6 +1971,13 @@ var DocumentResource = class extends BaseResource {
|
|
|
1907
1971
|
* {@link DocumentResource.upload} — that avoids the extra round-trip and
|
|
1908
1972
|
* the processing race entirely.
|
|
1909
1973
|
*
|
|
1974
|
+
* Request body (`application/json`):
|
|
1975
|
+
* ```jsonc
|
|
1976
|
+
* {
|
|
1977
|
+
* "name": "Service agreement.pdf"
|
|
1978
|
+
* }
|
|
1979
|
+
* ```
|
|
1980
|
+
*
|
|
1910
1981
|
* @param documentId - The document to rename.
|
|
1911
1982
|
* @param name - The new display name (max 255 chars), e.g.
|
|
1912
1983
|
* `'Service agreement.pdf'`. The API removes diacritics and replaces
|
|
@@ -1997,8 +2068,7 @@ var DocumentResource = class extends BaseResource {
|
|
|
1997
2068
|
* "updated_at": "2026-07-19T17:24:46Z"
|
|
1998
2069
|
* }
|
|
1999
2070
|
* ```
|
|
2000
|
-
* @throws {ValidationError} If `documentId` is missing
|
|
2001
|
-
* not one of the five documented artifact names.
|
|
2071
|
+
* @throws {ValidationError} If `documentId` is missing.
|
|
2002
2072
|
* @throws {ApiError} `404` if the document does not exist.
|
|
2003
2073
|
*
|
|
2004
2074
|
* @example
|
|
@@ -2318,6 +2388,15 @@ var DocumentResource = class extends BaseResource {
|
|
|
2318
2388
|
* overwrites the existing set — use
|
|
2319
2389
|
* {@link DocumentResource.addTags} to append.
|
|
2320
2390
|
*
|
|
2391
|
+
* Request body (`application/json`):
|
|
2392
|
+
* ```jsonc
|
|
2393
|
+
* {
|
|
2394
|
+
* "tags": [
|
|
2395
|
+
* "tag_example"
|
|
2396
|
+
* ]
|
|
2397
|
+
* }
|
|
2398
|
+
* ```
|
|
2399
|
+
*
|
|
2321
2400
|
* @param documentId - The document to retag.
|
|
2322
2401
|
* @param tags - The complete desired set of tag IDs (`[]` clears all).
|
|
2323
2402
|
* @param accountId - Override the client's default account ID.
|
|
@@ -2360,6 +2439,15 @@ var DocumentResource = class extends BaseResource {
|
|
|
2360
2439
|
* present is a no-op. To replace the whole set instead, use
|
|
2361
2440
|
* {@link DocumentResource.replaceTags}.
|
|
2362
2441
|
*
|
|
2442
|
+
* Request body (`application/json`):
|
|
2443
|
+
* ```jsonc
|
|
2444
|
+
* {
|
|
2445
|
+
* "tags": [
|
|
2446
|
+
* "tag_example"
|
|
2447
|
+
* ]
|
|
2448
|
+
* }
|
|
2449
|
+
* ```
|
|
2450
|
+
*
|
|
2363
2451
|
* @param documentId - The document to tag.
|
|
2364
2452
|
* @param tags - Tag IDs to attach (must be non-empty).
|
|
2365
2453
|
* @param accountId - Override the client's default account ID.
|
|
@@ -2435,6 +2523,35 @@ var DocumentResource = class extends BaseResource {
|
|
|
2435
2523
|
* `options` may add `name`, `message`, `expires_at`, `editor_fields`, and
|
|
2436
2524
|
* tag names in `tags` (unknown names are created automatically).
|
|
2437
2525
|
*
|
|
2526
|
+
* Request body (`application/json`):
|
|
2527
|
+
* ```jsonc
|
|
2528
|
+
* {
|
|
2529
|
+
* "signers": [
|
|
2530
|
+
* {
|
|
2531
|
+
* "role_id": "signing_role_example",
|
|
2532
|
+
* "id": "signer_example",
|
|
2533
|
+
* "verification_method": "Email",
|
|
2534
|
+
* "notification_methods": [
|
|
2535
|
+
* "Email"
|
|
2536
|
+
* ],
|
|
2537
|
+
* "step": 1
|
|
2538
|
+
* }
|
|
2539
|
+
* ],
|
|
2540
|
+
* "name": "Service agreement.pdf",
|
|
2541
|
+
* "message": "Please sign this document.",
|
|
2542
|
+
* "expires_at": "2027-12-31T23:59:59Z",
|
|
2543
|
+
* "editor_fields": [
|
|
2544
|
+
* {
|
|
2545
|
+
* "field_id": "editor_field_example",
|
|
2546
|
+
* "value": "Example Company"
|
|
2547
|
+
* }
|
|
2548
|
+
* ],
|
|
2549
|
+
* "tags": [
|
|
2550
|
+
* "Contracts"
|
|
2551
|
+
* ]
|
|
2552
|
+
* }
|
|
2553
|
+
* ```
|
|
2554
|
+
*
|
|
2438
2555
|
* @param templateId - The template to instantiate.
|
|
2439
2556
|
* @param signers - Role-to-signer bindings (each with `role_id` and `id`,
|
|
2440
2557
|
* plus optional `verification_method`, `notification_methods`, `step`).
|
|
@@ -2518,6 +2635,21 @@ var DocumentResource = class extends BaseResource {
|
|
|
2518
2635
|
* `DigitalCertificate` adds two credits per signer and has the same feature,
|
|
2519
2636
|
* `government_id`, and signing-step prerequisites as document creation.
|
|
2520
2637
|
*
|
|
2638
|
+
* Request body (`application/json`):
|
|
2639
|
+
* ```jsonc
|
|
2640
|
+
* {
|
|
2641
|
+
* "signers": [
|
|
2642
|
+
* {
|
|
2643
|
+
* "role_id": "signing_role_example",
|
|
2644
|
+
* "verification_method": "Email",
|
|
2645
|
+
* "notification_methods": [
|
|
2646
|
+
* "Email"
|
|
2647
|
+
* ]
|
|
2648
|
+
* }
|
|
2649
|
+
* ]
|
|
2650
|
+
* }
|
|
2651
|
+
* ```
|
|
2652
|
+
*
|
|
2521
2653
|
* @param templateId - The template that would be instantiated.
|
|
2522
2654
|
* @param signers - One channel descriptor per template role. Cost requests
|
|
2523
2655
|
* use only `role_id`, `verification_method`, and `notification_methods`;
|
|
@@ -2718,7 +2850,8 @@ var DocumentResource = class extends BaseResource {
|
|
|
2718
2850
|
}
|
|
2719
2851
|
}
|
|
2720
2852
|
/**
|
|
2721
|
-
* Quick boolean check: has every signer
|
|
2853
|
+
* Quick boolean check (`GET /documents/{documentId}`): has every signer
|
|
2854
|
+
* completed their assignment?
|
|
2722
2855
|
*
|
|
2723
2856
|
* A computed convenience over {@link DocumentResource.details} (one `GET
|
|
2724
2857
|
* /documents/{documentId}`). Returns `true` when the document status is
|
|
@@ -2748,7 +2881,8 @@ var DocumentResource = class extends BaseResource {
|
|
|
2748
2881
|
return false;
|
|
2749
2882
|
}
|
|
2750
2883
|
/**
|
|
2751
|
-
* Summarise signing progress for UI display
|
|
2884
|
+
* Summarise signing progress for UI display
|
|
2885
|
+
* (`GET /documents/{documentId}`).
|
|
2752
2886
|
*
|
|
2753
2887
|
* A computed convenience over {@link DocumentResource.details} (one `GET
|
|
2754
2888
|
* /documents/{documentId}`). `total` and `signed` come from the assignment
|
|
@@ -2891,6 +3025,19 @@ var SignerResource = class extends BaseResource {
|
|
|
2891
3025
|
* A reused signer is returned unchanged; this method does not overwrite its
|
|
2892
3026
|
* existing name, phone, CPF, or metadata with the create payload.
|
|
2893
3027
|
*
|
|
3028
|
+
* Request body (`application/json`):
|
|
3029
|
+
* ```jsonc
|
|
3030
|
+
* {
|
|
3031
|
+
* "full_name": "Example Signer",
|
|
3032
|
+
* "email": "signer@example.com",
|
|
3033
|
+
* "whatsapp_phone_number": "+5548999990000",
|
|
3034
|
+
* "cpf": "39053344705",
|
|
3035
|
+
* "metadata": {
|
|
3036
|
+
* "reference": "customer_example"
|
|
3037
|
+
* }
|
|
3038
|
+
* }
|
|
3039
|
+
* ```
|
|
3040
|
+
*
|
|
2894
3041
|
* @param payload - The signer to create. The official fields are required
|
|
2895
3042
|
* `full_name` plus optional `email` and E.164 `whatsapp_phone_number`.
|
|
2896
3043
|
* `phone`, `cpf`, and `metadata` are compatibility extensions; the SDK
|
|
@@ -3042,6 +3189,16 @@ var SignerResource = class extends BaseResource {
|
|
|
3042
3189
|
* while it belongs to an in-flight document; changing an unverified channel
|
|
3043
3190
|
* rotates its access/verification codes, so resend the notification.
|
|
3044
3191
|
*
|
|
3192
|
+
* Request body (`application/json`):
|
|
3193
|
+
* ```jsonc
|
|
3194
|
+
* {
|
|
3195
|
+
* "full_name": "Example Signer",
|
|
3196
|
+
* "email": "signer@example.com",
|
|
3197
|
+
* "whatsapp_phone_number": "+5548999990000",
|
|
3198
|
+
* "government_id": "39053344705"
|
|
3199
|
+
* }
|
|
3200
|
+
* ```
|
|
3201
|
+
*
|
|
3045
3202
|
* @param signerId - The signer to update.
|
|
3046
3203
|
* @param payload - Fields to change. The official `government_id` field and
|
|
3047
3204
|
* legacy `cpf` extension are stripped to digits before sending.
|
|
@@ -3261,6 +3418,16 @@ var WorkspaceResource = class extends BaseResource {
|
|
|
3261
3418
|
/**
|
|
3262
3419
|
* Create a new workspace (`POST /accounts`).
|
|
3263
3420
|
*
|
|
3421
|
+
* Request body (`application/json`):
|
|
3422
|
+
* ```jsonc
|
|
3423
|
+
* {
|
|
3424
|
+
* "name": "Example Workspace",
|
|
3425
|
+
* "notification_sender_type": "Account",
|
|
3426
|
+
* "primary_color": "336699",
|
|
3427
|
+
* "secondary_color": "ffffff"
|
|
3428
|
+
* }
|
|
3429
|
+
* ```
|
|
3430
|
+
*
|
|
3264
3431
|
* @param payload - Official fields are workspace `name` (required) and
|
|
3265
3432
|
* optional `notification_sender_type` (`User` or `Account`). Optional brand
|
|
3266
3433
|
* colours use six hex characters without
|
|
@@ -3541,6 +3708,16 @@ var WorkspaceResource = class extends BaseResource {
|
|
|
3541
3708
|
/**
|
|
3542
3709
|
* Update a workspace (`PUT /accounts/{accountId}`).
|
|
3543
3710
|
*
|
|
3711
|
+
* Request body (`application/json`):
|
|
3712
|
+
* ```jsonc
|
|
3713
|
+
* {
|
|
3714
|
+
* "name": "Example Workspace",
|
|
3715
|
+
* "notification_sender_type": "Account",
|
|
3716
|
+
* "primary_color": "336699",
|
|
3717
|
+
* "secondary_color": null
|
|
3718
|
+
* }
|
|
3719
|
+
* ```
|
|
3720
|
+
*
|
|
3544
3721
|
* @param accountId - The workspace to update.
|
|
3545
3722
|
* @param payload - Official fields are `name` and
|
|
3546
3723
|
* `notification_sender_type` (`User` or `Account`). Brand colours use six
|
|
@@ -3601,6 +3778,13 @@ var WorkspaceResource = class extends BaseResource {
|
|
|
3601
3778
|
* proceeds with deletion; it is not documented as a blanket override for
|
|
3602
3779
|
* unrelated restrictions. The flag is sent in the request body.
|
|
3603
3780
|
*
|
|
3781
|
+
* Request body (`application/json`):
|
|
3782
|
+
* ```jsonc
|
|
3783
|
+
* {
|
|
3784
|
+
* "force": true
|
|
3785
|
+
* }
|
|
3786
|
+
* ```
|
|
3787
|
+
*
|
|
3604
3788
|
* @param accountId - The workspace to delete.
|
|
3605
3789
|
* @param options - Set `force: true` to cancel an active paid subscription
|
|
3606
3790
|
* and proceed with deletion.
|
|
@@ -3671,6 +3855,19 @@ var WebhookResource = class extends BaseResource {
|
|
|
3671
3855
|
* `signer_rejected_document`, `document_processing_failed`).
|
|
3672
3856
|
* OAuth tokens need the `webhooks:write` scope.
|
|
3673
3857
|
*
|
|
3858
|
+
* Request body (`application/json`):
|
|
3859
|
+
* ```jsonc
|
|
3860
|
+
* {
|
|
3861
|
+
* "events": [
|
|
3862
|
+
* "document_ready",
|
|
3863
|
+
* "document_prepared"
|
|
3864
|
+
* ],
|
|
3865
|
+
* "is_active": true,
|
|
3866
|
+
* "url": "https://myapp.example.com/webhooks/assinafy",
|
|
3867
|
+
* "email": "operations@example.com"
|
|
3868
|
+
* }
|
|
3869
|
+
* ```
|
|
3870
|
+
*
|
|
3674
3871
|
* @param payload - Subscription details. `url` and `email` are required;
|
|
3675
3872
|
* `events` defaults to {@link DEFAULT_WEBHOOK_EVENTS} and `is_active`
|
|
3676
3873
|
* defaults to `true`.
|
|
@@ -3732,7 +3929,7 @@ var WebhookResource = class extends BaseResource {
|
|
|
3732
3929
|
events: [...payload.events && payload.events.length > 0 ? payload.events : DEFAULT_WEBHOOK_EVENTS],
|
|
3733
3930
|
is_active: payload.is_active ?? true
|
|
3734
3931
|
};
|
|
3735
|
-
this.logger.info("Registering webhook"
|
|
3932
|
+
this.logger.info("Registering webhook");
|
|
3736
3933
|
return this.call(
|
|
3737
3934
|
"Failed to register webhook",
|
|
3738
3935
|
() => this.http.put(
|
|
@@ -4194,6 +4391,14 @@ var TemplateResource = class extends BaseResource {
|
|
|
4194
4391
|
* `undefined` keys before sending. Unlike uploads, `name` here is a plain
|
|
4195
4392
|
* display name and is **not** forced to end in `.pdf`.
|
|
4196
4393
|
*
|
|
4394
|
+
* Request body (`application/json`):
|
|
4395
|
+
* ```jsonc
|
|
4396
|
+
* {
|
|
4397
|
+
* "name": "Service agreement.pdf",
|
|
4398
|
+
* "message": "Please sign this document."
|
|
4399
|
+
* }
|
|
4400
|
+
* ```
|
|
4401
|
+
*
|
|
4197
4402
|
* @param templateId - The template to update.
|
|
4198
4403
|
* @param payload - `name` and/or `message`; both optional.
|
|
4199
4404
|
* @param accountId - Override the client's default account ID.
|
|
@@ -4374,6 +4579,14 @@ var TagResource = class extends BaseResource {
|
|
|
4374
4579
|
* and `'ff8800'` both persist as `'ff8800'`. Omit `color`
|
|
4375
4580
|
* (or pass `null`) for no color.
|
|
4376
4581
|
*
|
|
4582
|
+
* Request body (`application/json`):
|
|
4583
|
+
* ```jsonc
|
|
4584
|
+
* {
|
|
4585
|
+
* "name": "Contracts",
|
|
4586
|
+
* "color": "ff8800"
|
|
4587
|
+
* }
|
|
4588
|
+
* ```
|
|
4589
|
+
*
|
|
4377
4590
|
* @param payload - `name` (required, max 64 characters; trimmed with
|
|
4378
4591
|
* internal whitespace collapsed) and optional `color`.
|
|
4379
4592
|
* @param accountId - Override the client's default account ID.
|
|
@@ -4423,6 +4636,14 @@ var TagResource = class extends BaseResource {
|
|
|
4423
4636
|
* leading `#` on `color` is accepted and stripped by the API
|
|
4424
4637
|
* (`'#112233'` → `'112233'`).
|
|
4425
4638
|
*
|
|
4639
|
+
* Request body (`application/json`):
|
|
4640
|
+
* ```jsonc
|
|
4641
|
+
* {
|
|
4642
|
+
* "name": "Signed contracts",
|
|
4643
|
+
* "color": null
|
|
4644
|
+
* }
|
|
4645
|
+
* ```
|
|
4646
|
+
*
|
|
4426
4647
|
* @param tagId - The tag to update.
|
|
4427
4648
|
* @param payload - `name` and/or `color`. `color: null` clears the color;
|
|
4428
4649
|
* omit a field to leave it unchanged.
|
|
@@ -4581,6 +4802,14 @@ var AuthenticationResource = class extends BaseResource {
|
|
|
4581
4802
|
* `X-Api-Key` (see {@link AuthenticationResource.createApiKey}) instead of
|
|
4582
4803
|
* storing a password.
|
|
4583
4804
|
*
|
|
4805
|
+
* Request body (`application/json`):
|
|
4806
|
+
* ```jsonc
|
|
4807
|
+
* {
|
|
4808
|
+
* "email": "user@example.com",
|
|
4809
|
+
* "password": "example-password"
|
|
4810
|
+
* }
|
|
4811
|
+
* ```
|
|
4812
|
+
*
|
|
4584
4813
|
* @param email - The user's email address, e.g. `'user@example.com'`.
|
|
4585
4814
|
* @param password - The user's password.
|
|
4586
4815
|
* @returns An {@link ILoginResponse} with the access token, user, and
|
|
@@ -4590,7 +4819,7 @@ var AuthenticationResource = class extends BaseResource {
|
|
|
4590
4819
|
* "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9…",
|
|
4591
4820
|
* "user": {
|
|
4592
4821
|
* "id": "md3j6p9w8b7y6qvqaoy5er42",
|
|
4593
|
-
* "name": "
|
|
4822
|
+
* "name": "Empresa Exemplo",
|
|
4594
4823
|
* "email": "user@example.com",
|
|
4595
4824
|
* "telephone": null,
|
|
4596
4825
|
* "government_id": "",
|
|
@@ -4602,7 +4831,7 @@ var AuthenticationResource = class extends BaseResource {
|
|
|
4602
4831
|
* "accounts": [
|
|
4603
4832
|
* {
|
|
4604
4833
|
* "id": "acc_example",
|
|
4605
|
-
* "name": "
|
|
4834
|
+
* "name": "Empresa Exemplo",
|
|
4606
4835
|
* "roles": ["Owner"],
|
|
4607
4836
|
* "is_delete_allowed": true,
|
|
4608
4837
|
* "created_at": "2026-05-12T13:45:11Z"
|
|
@@ -4636,6 +4865,15 @@ var AuthenticationResource = class extends BaseResource {
|
|
|
4636
4865
|
* Assinafy JWT. Returns the same {@link ILoginResponse} shape as
|
|
4637
4866
|
* {@link AuthenticationResource.login}.
|
|
4638
4867
|
*
|
|
4868
|
+
* Request body (`application/json`):
|
|
4869
|
+
* ```jsonc
|
|
4870
|
+
* {
|
|
4871
|
+
* "provider": "google",
|
|
4872
|
+
* "token": "provider_token_example",
|
|
4873
|
+
* "has_accepted_terms": true
|
|
4874
|
+
* }
|
|
4875
|
+
* ```
|
|
4876
|
+
*
|
|
4639
4877
|
* @param payload - The social-login body.
|
|
4640
4878
|
* @param payload.provider - OAuth provider; currently exactly `'google'`.
|
|
4641
4879
|
* @param payload.token - The provider-issued OAuth/ID token.
|
|
@@ -4648,7 +4886,7 @@ var AuthenticationResource = class extends BaseResource {
|
|
|
4648
4886
|
* "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9…",
|
|
4649
4887
|
* "user": {
|
|
4650
4888
|
* "id": "md3j6p9w8b7y6qvqaoy5er42",
|
|
4651
|
-
* "name": "
|
|
4889
|
+
* "name": "Empresa Exemplo",
|
|
4652
4890
|
* "email": "user@example.com",
|
|
4653
4891
|
* "telephone": null,
|
|
4654
4892
|
* "government_id": "",
|
|
@@ -4660,7 +4898,7 @@ var AuthenticationResource = class extends BaseResource {
|
|
|
4660
4898
|
* "accounts": [
|
|
4661
4899
|
* {
|
|
4662
4900
|
* "id": "acc_example",
|
|
4663
|
-
* "name": "
|
|
4901
|
+
* "name": "Empresa Exemplo",
|
|
4664
4902
|
* "roles": ["Owner"],
|
|
4665
4903
|
* "is_delete_allowed": true,
|
|
4666
4904
|
* "created_at": "2026-05-12T13:45:11Z"
|
|
@@ -4710,6 +4948,14 @@ var AuthenticationResource = class extends BaseResource {
|
|
|
4710
4948
|
* The response is the standard status/message acknowledgement with no data,
|
|
4711
4949
|
* so this method resolves to `void`.
|
|
4712
4950
|
*
|
|
4951
|
+
* Request body (`application/json`):
|
|
4952
|
+
* ```jsonc
|
|
4953
|
+
* {
|
|
4954
|
+
* "provider": "google",
|
|
4955
|
+
* "token": "provider_token_example"
|
|
4956
|
+
* }
|
|
4957
|
+
* ```
|
|
4958
|
+
*
|
|
4713
4959
|
* @param payload - Social provider and provider-issued access/ID token.
|
|
4714
4960
|
* @returns Resolves when the API acknowledges that the identity was linked.
|
|
4715
4961
|
* @throws {ValidationError} If `provider` is not `google` or `token` is empty.
|
|
@@ -4746,6 +4992,13 @@ var AuthenticationResource = class extends BaseResource {
|
|
|
4746
4992
|
* a masked value. Calling this again rotates the key, invalidating the
|
|
4747
4993
|
* previous one.
|
|
4748
4994
|
*
|
|
4995
|
+
* Request body (`application/json`):
|
|
4996
|
+
* ```jsonc
|
|
4997
|
+
* {
|
|
4998
|
+
* "password": "example-password"
|
|
4999
|
+
* }
|
|
5000
|
+
* ```
|
|
5001
|
+
*
|
|
4749
5002
|
* @param password - The current user's password, required to authorize
|
|
4750
5003
|
* key generation.
|
|
4751
5004
|
* @returns An {@link IApiKeyResponse} containing the new key. Response
|
|
@@ -4833,6 +5086,15 @@ var AuthenticationResource = class extends BaseResource {
|
|
|
4833
5086
|
* Requires the current password as a confirmation. On success the API
|
|
4834
5087
|
* echoes back the affected `email`.
|
|
4835
5088
|
*
|
|
5089
|
+
* Request body (`application/json`):
|
|
5090
|
+
* ```jsonc
|
|
5091
|
+
* {
|
|
5092
|
+
* "email": "user@example.com",
|
|
5093
|
+
* "password": "example-password",
|
|
5094
|
+
* "new_password": "new-example-password"
|
|
5095
|
+
* }
|
|
5096
|
+
* ```
|
|
5097
|
+
*
|
|
4836
5098
|
* @param payload - The change-password body.
|
|
4837
5099
|
* @param payload.email - The user's email address.
|
|
4838
5100
|
* @param payload.password - The current password.
|
|
@@ -4879,6 +5141,13 @@ var AuthenticationResource = class extends BaseResource {
|
|
|
4879
5141
|
* Triggers Assinafy to email a reset link/token to the given address.
|
|
4880
5142
|
* Complete the flow with {@link AuthenticationResource.resetPassword}.
|
|
4881
5143
|
*
|
|
5144
|
+
* Request body (`application/json`):
|
|
5145
|
+
* ```jsonc
|
|
5146
|
+
* {
|
|
5147
|
+
* "email": "user@example.com"
|
|
5148
|
+
* }
|
|
5149
|
+
* ```
|
|
5150
|
+
*
|
|
4882
5151
|
* @param email - The email address to send the reset link to.
|
|
4883
5152
|
* @returns `{ email }` — the address the reset link was sent to. Response
|
|
4884
5153
|
* shape:
|
|
@@ -4910,6 +5179,15 @@ var AuthenticationResource = class extends BaseResource {
|
|
|
4910
5179
|
* {@link AuthenticationResource.requestPasswordReset} and sets the new
|
|
4911
5180
|
* password. On success the API echoes back the affected `email`.
|
|
4912
5181
|
*
|
|
5182
|
+
* Request body (`application/json`):
|
|
5183
|
+
* ```jsonc
|
|
5184
|
+
* {
|
|
5185
|
+
* "email": "user@example.com",
|
|
5186
|
+
* "token": "reset_token_example",
|
|
5187
|
+
* "new_password": "new-example-password"
|
|
5188
|
+
* }
|
|
5189
|
+
* ```
|
|
5190
|
+
*
|
|
4913
5191
|
* @param payload - The reset-password body.
|
|
4914
5192
|
* @param payload.email - The user's email address.
|
|
4915
5193
|
* @param payload.token - The reset token from the emailed link. The current
|
|
@@ -5132,8 +5410,8 @@ var OAuthResource = class extends BaseResource {
|
|
|
5132
5410
|
* ```ts
|
|
5133
5411
|
* const request = await client.oauth.createAuthorizationUrl({
|
|
5134
5412
|
* clientId: process.env.ASSINAFY_CLIENT_ID!,
|
|
5135
|
-
* redirectUri: 'https://myapp.com/oauth/callback',
|
|
5136
|
-
* scopes: ['documents:read', 'documents:write', 'offline_access'],
|
|
5413
|
+
* redirectUri: 'https://myapp.example.com/oauth/callback',
|
|
5414
|
+
* scopes: ['documents:read', 'documents:write', 'account:read', 'offline_access'],
|
|
5137
5415
|
* });
|
|
5138
5416
|
* session.oauth = request;
|
|
5139
5417
|
* response.redirect(request.url);
|
|
@@ -5220,8 +5498,8 @@ var OAuthResource = class extends BaseResource {
|
|
|
5220
5498
|
* ```
|
|
5221
5499
|
* @throws {ValidationError} If `state` is missing or does not match, `iss`
|
|
5222
5500
|
* is absent or disagrees with the expected issuer, or a successful response
|
|
5223
|
-
* carries no `code
|
|
5224
|
-
*
|
|
5501
|
+
* carries no `code`, or a protocol parameter appears more than once.
|
|
5502
|
+
* Reject such responses without exchanging the code.
|
|
5225
5503
|
* @throws {OAuthError} If the server returned `error` (e.g.
|
|
5226
5504
|
* `access_denied`, `invalid_scope`, `invalid_request`,
|
|
5227
5505
|
* `unsupported_response_type`, `invalid_target`).
|
|
@@ -5234,9 +5512,9 @@ var OAuthResource = class extends BaseResource {
|
|
|
5234
5512
|
* const tokens = await client.oauth.exchangeCode({
|
|
5235
5513
|
* code,
|
|
5236
5514
|
* codeVerifier: stored.codeVerifier,
|
|
5237
|
-
* redirectUri: 'https://myapp.com/oauth/callback',
|
|
5515
|
+
* redirectUri: 'https://myapp.example.com/oauth/callback',
|
|
5238
5516
|
* clientId: process.env.ASSINAFY_CLIENT_ID!,
|
|
5239
|
-
* clientSecret: process.env.ASSINAFY_CLIENT_SECRET
|
|
5517
|
+
* clientSecret: process.env.ASSINAFY_CLIENT_SECRET!,
|
|
5240
5518
|
* });
|
|
5241
5519
|
* });
|
|
5242
5520
|
* ```
|
|
@@ -5245,6 +5523,11 @@ var OAuthResource = class extends BaseResource {
|
|
|
5245
5523
|
assertRecord(expected, "expected authorization request");
|
|
5246
5524
|
assertNonEmptyString(expected.state, "expected.state");
|
|
5247
5525
|
const query = toSearchParams(params);
|
|
5526
|
+
for (const key of ["state", "iss", "code", "error", "error_description"]) {
|
|
5527
|
+
if (query.getAll(key).length > 1) {
|
|
5528
|
+
throw new ValidationError(`OAuth callback must not repeat ${key}`);
|
|
5529
|
+
}
|
|
5530
|
+
}
|
|
5248
5531
|
const state = query.get("state");
|
|
5249
5532
|
if (state === null || !constantTimeEquals(state, expected.state)) {
|
|
5250
5533
|
throw new ValidationError(
|
|
@@ -5281,6 +5564,12 @@ var OAuthResource = class extends BaseResource {
|
|
|
5281
5564
|
* a browser. Every value must match the authorization request exactly, or
|
|
5282
5565
|
* the API answers `invalid_grant`.
|
|
5283
5566
|
*
|
|
5567
|
+
* Request body (`application/x-www-form-urlencoded`; omit `client_secret`
|
|
5568
|
+
* for public applications):
|
|
5569
|
+
* ```text
|
|
5570
|
+
* grant_type=authorization_code&code=code_example&redirect_uri=https%3A%2F%2Fmyapp.example.com%2Foauth%2Fcallback&client_id=client_example&client_secret=secret_example&code_verifier=dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk&resource=https%3A%2F%2Fapi.assinafy.com.br
|
|
5571
|
+
* ```
|
|
5572
|
+
*
|
|
5284
5573
|
* @param options - Exchange options.
|
|
5285
5574
|
* @param options.code - The code from
|
|
5286
5575
|
* {@link OAuthResource.readAuthorizationCallback}.
|
|
@@ -5316,9 +5605,9 @@ var OAuthResource = class extends BaseResource {
|
|
|
5316
5605
|
* const tokens = await client.oauth.exchangeCode({
|
|
5317
5606
|
* code,
|
|
5318
5607
|
* codeVerifier: session.oauth.codeVerifier,
|
|
5319
|
-
* redirectUri: 'https://myapp.com/oauth/callback',
|
|
5608
|
+
* redirectUri: 'https://myapp.example.com/oauth/callback',
|
|
5320
5609
|
* clientId: process.env.ASSINAFY_CLIENT_ID!,
|
|
5321
|
-
* clientSecret: process.env.ASSINAFY_CLIENT_SECRET
|
|
5610
|
+
* clientSecret: process.env.ASSINAFY_CLIENT_SECRET!,
|
|
5322
5611
|
* });
|
|
5323
5612
|
* ```
|
|
5324
5613
|
*/
|
|
@@ -5354,6 +5643,12 @@ var OAuthResource = class extends BaseResource {
|
|
|
5354
5643
|
* only expires if it goes 30 days without a refresh; after that the user
|
|
5355
5644
|
* has to reconnect.
|
|
5356
5645
|
*
|
|
5646
|
+
* Request body (`application/x-www-form-urlencoded`; omit `client_secret`
|
|
5647
|
+
* for public applications):
|
|
5648
|
+
* ```text
|
|
5649
|
+
* grant_type=refresh_token&refresh_token=refresh_token_example&client_id=client_example&client_secret=secret_example&resource=https%3A%2F%2Fapi.assinafy.com.br
|
|
5650
|
+
* ```
|
|
5651
|
+
*
|
|
5357
5652
|
* @param options - Refresh options.
|
|
5358
5653
|
* @param options.refreshToken - The current refresh token.
|
|
5359
5654
|
* @param options.clientId - The application's `client_id`.
|
|
@@ -5384,7 +5679,7 @@ var OAuthResource = class extends BaseResource {
|
|
|
5384
5679
|
* const tokens = await client.oauth.refreshToken({
|
|
5385
5680
|
* refreshToken: connection.refreshToken,
|
|
5386
5681
|
* clientId: process.env.ASSINAFY_CLIENT_ID!,
|
|
5387
|
-
* clientSecret: process.env.ASSINAFY_CLIENT_SECRET
|
|
5682
|
+
* clientSecret: process.env.ASSINAFY_CLIENT_SECRET!,
|
|
5388
5683
|
* });
|
|
5389
5684
|
* await connection.save({ refreshToken: tokens.refresh_token });
|
|
5390
5685
|
* ```
|
|
@@ -5438,7 +5733,7 @@ var OAuthResource = class extends BaseResource {
|
|
|
5438
5733
|
* token: connection.refreshToken,
|
|
5439
5734
|
* tokenTypeHint: 'refresh_token',
|
|
5440
5735
|
* clientId: process.env.ASSINAFY_CLIENT_ID!,
|
|
5441
|
-
* clientSecret: process.env.ASSINAFY_CLIENT_SECRET
|
|
5736
|
+
* clientSecret: process.env.ASSINAFY_CLIENT_SECRET!,
|
|
5442
5737
|
* });
|
|
5443
5738
|
* ```
|
|
5444
5739
|
*/
|
|
@@ -5481,8 +5776,8 @@ var OAuthResource = class extends BaseResource {
|
|
|
5481
5776
|
* "email_verified": true
|
|
5482
5777
|
* }
|
|
5483
5778
|
* ```
|
|
5484
|
-
* `sub` is the stable user identifier;
|
|
5485
|
-
* was not granted.
|
|
5779
|
+
* `sub` is the stable user identifier; other claims may be omitted or
|
|
5780
|
+
* `null` when their scope was not granted.
|
|
5486
5781
|
* @throws {ValidationError} If `accessToken` is supplied but empty.
|
|
5487
5782
|
* @throws {ApiError} `401` when the token is missing, expired or revoked;
|
|
5488
5783
|
* `403` when the `openid` scope was not granted — its `WWW-Authenticate`
|
|
@@ -5652,8 +5947,9 @@ function toSearchParams(params) {
|
|
|
5652
5947
|
assertRecord(params, "callback parameters");
|
|
5653
5948
|
const search = new URLSearchParams();
|
|
5654
5949
|
for (const [key, value] of Object.entries(params)) {
|
|
5655
|
-
const
|
|
5656
|
-
|
|
5950
|
+
for (const item of Array.isArray(value) ? value : [value]) {
|
|
5951
|
+
if (typeof item === "string") search.append(key, item);
|
|
5952
|
+
}
|
|
5657
5953
|
}
|
|
5658
5954
|
return search;
|
|
5659
5955
|
}
|
|
@@ -5663,6 +5959,17 @@ var FieldsResource = class extends BaseResource {
|
|
|
5663
5959
|
/**
|
|
5664
5960
|
* Create a field definition (`POST /accounts/{accountId}/fields`).
|
|
5665
5961
|
*
|
|
5962
|
+
* Request body (`application/json`):
|
|
5963
|
+
* ```jsonc
|
|
5964
|
+
* {
|
|
5965
|
+
* "type": "text",
|
|
5966
|
+
* "name": "Reference",
|
|
5967
|
+
* "regex": null,
|
|
5968
|
+
* "is_required": true,
|
|
5969
|
+
* "is_active": true
|
|
5970
|
+
* }
|
|
5971
|
+
* ```
|
|
5972
|
+
*
|
|
5666
5973
|
* @param payload - The field to create. `type` and `name` are required;
|
|
5667
5974
|
* `type` must be one of the platform field types (see
|
|
5668
5975
|
* {@link FieldsResource.listTypes}); `regex` may be a string or `null`,
|
|
@@ -5807,6 +6114,15 @@ var FieldsResource = class extends BaseResource {
|
|
|
5807
6114
|
* Update a field definition
|
|
5808
6115
|
* (`PUT /accounts/{accountId}/fields/{fieldId}`).
|
|
5809
6116
|
*
|
|
6117
|
+
* Request body (`application/json`):
|
|
6118
|
+
* ```jsonc
|
|
6119
|
+
* {
|
|
6120
|
+
* "name": "Customer reference",
|
|
6121
|
+
* "regex": null,
|
|
6122
|
+
* "is_active": true
|
|
6123
|
+
* }
|
|
6124
|
+
* ```
|
|
6125
|
+
*
|
|
5810
6126
|
* @param fieldId - The field definition to update.
|
|
5811
6127
|
* @param payload - Fields are `name`, nullable `regex`, and `is_active`;
|
|
5812
6128
|
* `type` and `is_required` are compatibility extensions.
|
|
@@ -5895,6 +6211,13 @@ var FieldsResource = class extends BaseResource {
|
|
|
5895
6211
|
* `signerAccessCode` is a compatibility query and is sent as
|
|
5896
6212
|
* `signer-access-code` when supplied.
|
|
5897
6213
|
*
|
|
6214
|
+
* Request body (`application/json`):
|
|
6215
|
+
* ```jsonc
|
|
6216
|
+
* {
|
|
6217
|
+
* "value": "Example value"
|
|
6218
|
+
* }
|
|
6219
|
+
* ```
|
|
6220
|
+
*
|
|
5898
6221
|
* @param fieldId - The field definition to validate against.
|
|
5899
6222
|
* @param value - The value to check (validated against the field's
|
|
5900
6223
|
* type/regex). Sent as `{ value }` in the request body.
|
|
@@ -5947,6 +6270,16 @@ var FieldsResource = class extends BaseResource {
|
|
|
5947
6270
|
* same compatibility extension described on
|
|
5948
6271
|
* {@link FieldsResource.validate}.
|
|
5949
6272
|
*
|
|
6273
|
+
* Request body (`application/json`):
|
|
6274
|
+
* ```jsonc
|
|
6275
|
+
* [
|
|
6276
|
+
* {
|
|
6277
|
+
* "field_id": "field_example",
|
|
6278
|
+
* "value": "Example value"
|
|
6279
|
+
* }
|
|
6280
|
+
* ]
|
|
6281
|
+
* ```
|
|
6282
|
+
*
|
|
5950
6283
|
* @param entries - Non-empty array of `{ field_id, value }` pairs.
|
|
5951
6284
|
* @param options - Account override and optional legacy `signerAccessCode`.
|
|
5952
6285
|
* @returns One validation result per entry. Response shape:
|
|
@@ -6075,8 +6408,7 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
6075
6408
|
* "updated_at": "2026-07-19T14:56:56Z"
|
|
6076
6409
|
* }
|
|
6077
6410
|
* ```
|
|
6078
|
-
* @throws {ValidationError} If `signerId` or `signerAccessCode` is missing
|
|
6079
|
-
* or a supplied `search` value is not a string.
|
|
6411
|
+
* @throws {ValidationError} If `signerId` or `signerAccessCode` is missing.
|
|
6080
6412
|
* @throws {ApiError} If the access code is invalid or expired.
|
|
6081
6413
|
*
|
|
6082
6414
|
* @example
|
|
@@ -6164,7 +6496,29 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
6164
6496
|
* @param signerAccessCode - The signer's access code, from their signing link.
|
|
6165
6497
|
* @param search - Free-text term matched against the document name.
|
|
6166
6498
|
* @returns Matching documents for that signer, in the compact
|
|
6167
|
-
* {@link IDocumentListItem} shape, with pagination in `meta
|
|
6499
|
+
* {@link IDocumentListItem} shape, with pagination in `meta`:
|
|
6500
|
+
* ```jsonc
|
|
6501
|
+
* {
|
|
6502
|
+
* "data": [
|
|
6503
|
+
* {
|
|
6504
|
+
* "id": "103acccd24234c07858ffddf6d84",
|
|
6505
|
+
* "account_id": "acc_example",
|
|
6506
|
+
* "template_id": null,
|
|
6507
|
+
* "name": "Service agreement.pdf",
|
|
6508
|
+
* "status": "pending_signature",
|
|
6509
|
+
* "artifacts": { "original": "https://...", "thumbnail": "https://..." },
|
|
6510
|
+
* "is_closed": false,
|
|
6511
|
+
* "signing_url": "https://app.assinafy.com.br/sign/103acccd...",
|
|
6512
|
+
* "decline_reason": null,
|
|
6513
|
+
* "declined_by": null,
|
|
6514
|
+
* "tags": [],
|
|
6515
|
+
* "created_at": "2026-07-19T14:56:54Z",
|
|
6516
|
+
* "updated_at": "2026-07-19T14:56:56Z"
|
|
6517
|
+
* }
|
|
6518
|
+
* ],
|
|
6519
|
+
* "meta": { "current_page": 1, "per_page": 20, "total": 1, "last_page": 1 }
|
|
6520
|
+
* }
|
|
6521
|
+
* ```
|
|
6168
6522
|
* @throws {ValidationError} If `signerId` or `signerAccessCode` is missing.
|
|
6169
6523
|
* @throws {ApiError} If the access code is invalid or expired.
|
|
6170
6524
|
*
|
|
@@ -6253,6 +6607,15 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
6253
6607
|
* The `document_ids` array goes in the request body; the access code
|
|
6254
6608
|
* authenticates via the `signer-access-code` query param.
|
|
6255
6609
|
*
|
|
6610
|
+
* Request body (`application/json`):
|
|
6611
|
+
* ```jsonc
|
|
6612
|
+
* {
|
|
6613
|
+
* "document_ids": [
|
|
6614
|
+
* "document_example"
|
|
6615
|
+
* ]
|
|
6616
|
+
* }
|
|
6617
|
+
* ```
|
|
6618
|
+
*
|
|
6256
6619
|
* @param documentIds - Non-empty array of document IDs to sign.
|
|
6257
6620
|
* @param signerAccessCode - The signer's access code, from their signing link.
|
|
6258
6621
|
* @returns Resolves when the API acknowledges the operation. The documented
|
|
@@ -6272,9 +6635,7 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
6272
6635
|
* ```
|
|
6273
6636
|
*/
|
|
6274
6637
|
async signMultiple(documentIds, signerAccessCode) {
|
|
6275
|
-
|
|
6276
|
-
throw new ValidationError("documentIds must be a non-empty array of non-empty IDs");
|
|
6277
|
-
}
|
|
6638
|
+
assertDocumentIds(documentIds);
|
|
6278
6639
|
const code = this.requireId(signerAccessCode, "signer-access-code");
|
|
6279
6640
|
return this.callVoid(
|
|
6280
6641
|
"Failed to sign multiple documents",
|
|
@@ -6294,6 +6655,16 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
6294
6655
|
* Both `document_ids` and `decline_reason` go in the request body; the access
|
|
6295
6656
|
* code authenticates via the `signer-access-code` query param.
|
|
6296
6657
|
*
|
|
6658
|
+
* Request body (`application/json`):
|
|
6659
|
+
* ```jsonc
|
|
6660
|
+
* {
|
|
6661
|
+
* "document_ids": [
|
|
6662
|
+
* "document_example"
|
|
6663
|
+
* ],
|
|
6664
|
+
* "decline_reason": "The document needs a correction."
|
|
6665
|
+
* }
|
|
6666
|
+
* ```
|
|
6667
|
+
*
|
|
6297
6668
|
* @param documentIds - Non-empty array of document IDs to decline.
|
|
6298
6669
|
* @param declineReason - Free-text reason shown to the sender (required).
|
|
6299
6670
|
* @param signerAccessCode - The signer's access code, from their signing link.
|
|
@@ -6314,12 +6685,8 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
6314
6685
|
* ```
|
|
6315
6686
|
*/
|
|
6316
6687
|
async declineMultiple(documentIds, declineReason, signerAccessCode) {
|
|
6317
|
-
|
|
6318
|
-
|
|
6319
|
-
}
|
|
6320
|
-
if (typeof declineReason !== "string" || !declineReason.trim()) {
|
|
6321
|
-
throw new ValidationError("declineReason is required");
|
|
6322
|
-
}
|
|
6688
|
+
assertDocumentIds(documentIds);
|
|
6689
|
+
assertDeclineReason(declineReason);
|
|
6323
6690
|
const code = this.requireId(signerAccessCode, "signer-access-code");
|
|
6324
6691
|
return this.callVoid(
|
|
6325
6692
|
"Failed to decline multiple documents",
|
|
@@ -6413,6 +6780,13 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
6413
6780
|
* **body carries only `verification-code`** (putting the access code in the
|
|
6414
6781
|
* body leaves the request unauthenticated → `401`).
|
|
6415
6782
|
*
|
|
6783
|
+
* Request body (`application/json`):
|
|
6784
|
+
* ```jsonc
|
|
6785
|
+
* {
|
|
6786
|
+
* "verification-code": "123456"
|
|
6787
|
+
* }
|
|
6788
|
+
* ```
|
|
6789
|
+
*
|
|
6416
6790
|
* @param payload - `signerAccessCode` (the signing-link code) and
|
|
6417
6791
|
* `verificationCode` (the OTP the signer received).
|
|
6418
6792
|
* @returns Resolves when the API acknowledges the operation. The response
|
|
@@ -6550,7 +6924,48 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
6550
6924
|
* @returns The document to sign, including its `assignment` (the
|
|
6551
6925
|
* {@link IAssignment} shape: `signers`, `items`, `summary`, `signing_urls`)
|
|
6552
6926
|
* from which the `itemId` / `fieldId` / `pageId` values for
|
|
6553
|
-
* {@link SignerDocumentsResource.sign} are read
|
|
6927
|
+
* {@link SignerDocumentsResource.sign} are read:
|
|
6928
|
+
* ```jsonc
|
|
6929
|
+
* {
|
|
6930
|
+
* "resource": "document",
|
|
6931
|
+
* "id": "103acccd24234c07858ffddf6d84",
|
|
6932
|
+
* "account_id": "acc_example",
|
|
6933
|
+
* "template_id": null,
|
|
6934
|
+
* "name": "Service agreement.pdf",
|
|
6935
|
+
* "status": "pending_signature",
|
|
6936
|
+
* "artifacts": {
|
|
6937
|
+
* "original": "https://api.assinafy.com.br/v1/documents/103acccd.../download/original",
|
|
6938
|
+
* "thumbnail": "https://api.assinafy.com.br/v1/documents/103acccd.../thumbnail"
|
|
6939
|
+
* },
|
|
6940
|
+
* "is_closed": false,
|
|
6941
|
+
* "signing_url": "https://app.assinafy.com.br/sign/103acccd...",
|
|
6942
|
+
* "decline_reason": null,
|
|
6943
|
+
* "declined_by": null,
|
|
6944
|
+
* "tags": [],
|
|
6945
|
+
* "assignment": {
|
|
6946
|
+
* "id": "1032c55c58bb00a8dc35db916751",
|
|
6947
|
+
* "method": "virtual",
|
|
6948
|
+
* "sender_email": "sender@example.com",
|
|
6949
|
+
* "expires_at": null,
|
|
6950
|
+
* "signers": [
|
|
6951
|
+
* { "id": "19e6b92e7895332ed9708535d8c", "step": 1, "email": "signer@example.com",
|
|
6952
|
+
* "full_name": "Example Signer", "notified": true, "completed": false }
|
|
6953
|
+
* ],
|
|
6954
|
+
* "items": [
|
|
6955
|
+
* { "id": "item-1", "page": { "id": "page-1", "number": 1, "height": 1651, "width": 1275,
|
|
6956
|
+
* "download_url": "https://..." }, "signer": { "id": "19e6b92e..." },
|
|
6957
|
+
* "field": { "id": "field-1", "type": "signature" }, "value": null, "completed": false }
|
|
6958
|
+
* ],
|
|
6959
|
+
* "summary": { "signer_count": 1, "completed_count": 0, "signers": [] }
|
|
6960
|
+
* },
|
|
6961
|
+
* "pages": [
|
|
6962
|
+
* { "id": "103acccd5c73...", "number": 1, "height": 1651, "width": 1275,
|
|
6963
|
+
* "download_url": "https://api.assinafy.com.br/v1/documents/103acccd.../pages/103acccd5c73.../download" }
|
|
6964
|
+
* ],
|
|
6965
|
+
* "created_at": "2026-07-19T14:56:54Z",
|
|
6966
|
+
* "updated_at": "2026-07-19T14:56:56Z"
|
|
6967
|
+
* }
|
|
6968
|
+
* ```
|
|
6554
6969
|
* @throws {ValidationError} If `signerAccessCode` is missing.
|
|
6555
6970
|
* @throws {ApiError} `400` when DigitalCertificate identity/terms are not
|
|
6556
6971
|
* confirmed; `401`/`403` if the access code is invalid or expired; `409`
|
|
@@ -6590,6 +7005,18 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
6590
7005
|
* first. Digital Certificate signers cannot use this endpoint; use the
|
|
6591
7006
|
* certificate start/complete API flow instead.
|
|
6592
7007
|
*
|
|
7008
|
+
* Request body (`application/json`):
|
|
7009
|
+
* ```jsonc
|
|
7010
|
+
* [
|
|
7011
|
+
* {
|
|
7012
|
+
* "itemId": "item_example",
|
|
7013
|
+
* "fieldId": "field_example",
|
|
7014
|
+
* "pageId": "page_example",
|
|
7015
|
+
* "value": "Example Signer"
|
|
7016
|
+
* }
|
|
7017
|
+
* ]
|
|
7018
|
+
* ```
|
|
7019
|
+
*
|
|
6593
7020
|
* @param documentId - The document being signed.
|
|
6594
7021
|
* @param assignmentId - The assignment within that document.
|
|
6595
7022
|
* @param signerAccessCode - The signer's access code, from their signing link.
|
|
@@ -6647,6 +7074,13 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
6647
7074
|
* delete the document via `documents.delete`; there is no workspace "cancel"
|
|
6648
7075
|
* endpoint.)
|
|
6649
7076
|
*
|
|
7077
|
+
* Request body (`application/json`):
|
|
7078
|
+
* ```jsonc
|
|
7079
|
+
* {
|
|
7080
|
+
* "decline_reason": "The document needs a correction."
|
|
7081
|
+
* }
|
|
7082
|
+
* ```
|
|
7083
|
+
*
|
|
6650
7084
|
* @param documentId - The document being declined.
|
|
6651
7085
|
* @param assignmentId - The assignment within that document.
|
|
6652
7086
|
* @param signerAccessCode - The signer's access code, from their signing link.
|
|
@@ -6672,9 +7106,7 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
6672
7106
|
const did = this.requireId(documentId, "Document ID");
|
|
6673
7107
|
const aid = this.requireId(assignmentId, "Assignment ID");
|
|
6674
7108
|
const code = this.requireId(signerAccessCode, "signer-access-code");
|
|
6675
|
-
|
|
6676
|
-
throw new ValidationError("declineReason is required");
|
|
6677
|
-
}
|
|
7109
|
+
assertDeclineReason(declineReason);
|
|
6678
7110
|
return this.callVoid(
|
|
6679
7111
|
"Failed to decline assignment",
|
|
6680
7112
|
() => this.http.put(
|
|
@@ -6685,6 +7117,16 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
6685
7117
|
);
|
|
6686
7118
|
}
|
|
6687
7119
|
};
|
|
7120
|
+
function assertDocumentIds(documentIds) {
|
|
7121
|
+
if (!Array.isArray(documentIds) || documentIds.length === 0 || documentIds.some((id) => typeof id !== "string" || !id.trim())) {
|
|
7122
|
+
throw new ValidationError("documentIds must be a non-empty array of non-empty IDs");
|
|
7123
|
+
}
|
|
7124
|
+
}
|
|
7125
|
+
function assertDeclineReason(declineReason) {
|
|
7126
|
+
if (typeof declineReason !== "string" || !declineReason.trim()) {
|
|
7127
|
+
throw new ValidationError("declineReason is required");
|
|
7128
|
+
}
|
|
7129
|
+
}
|
|
6688
7130
|
function validateConfirmDataPayload(payload) {
|
|
6689
7131
|
for (const key of ["full_name", "government_id"]) {
|
|
6690
7132
|
if (payload[key] !== void 0 && typeof payload[key] !== "string") {
|
|
@@ -6825,13 +7267,40 @@ var UserResource = class extends BaseResource {
|
|
|
6825
7267
|
* (`PUT /users/self/notification-preferences`). Omitted keys retain their
|
|
6826
7268
|
* current values; account/security e-mails are not configurable here.
|
|
6827
7269
|
*
|
|
7270
|
+
* Request body (`application/json`):
|
|
7271
|
+
* ```jsonc
|
|
7272
|
+
* {
|
|
7273
|
+
* "DocumentCompleted": true,
|
|
7274
|
+
* "SignerDeclined": true,
|
|
7275
|
+
* "DocumentCancelled": true,
|
|
7276
|
+
* "DocumentAboutToExpire": true,
|
|
7277
|
+
* "DocumentExpired": true,
|
|
7278
|
+
* "DocumentExpirationReset": true,
|
|
7279
|
+
* "DocumentProcessingFailed": true,
|
|
7280
|
+
* "TemplateProcessingFailed": true,
|
|
7281
|
+
* "SignerWhatsappFailed": true
|
|
7282
|
+
* }
|
|
7283
|
+
* ```
|
|
7284
|
+
*
|
|
6828
7285
|
* @param preferences - One or more of the nine documented keys, each with
|
|
6829
7286
|
* a boolean value. Request example:
|
|
6830
7287
|
* ```json
|
|
6831
7288
|
* { "DocumentCompleted": true, "SignerDeclined": false }
|
|
6832
7289
|
* ```
|
|
6833
|
-
* @returns The complete updated
|
|
6834
|
-
*
|
|
7290
|
+
* @returns The complete updated nine-key preference map:
|
|
7291
|
+
* ```json
|
|
7292
|
+
* {
|
|
7293
|
+
* "DocumentCompleted": true,
|
|
7294
|
+
* "SignerDeclined": false,
|
|
7295
|
+
* "DocumentCancelled": true,
|
|
7296
|
+
* "DocumentAboutToExpire": true,
|
|
7297
|
+
* "DocumentExpired": false,
|
|
7298
|
+
* "DocumentExpirationReset": true,
|
|
7299
|
+
* "DocumentProcessingFailed": true,
|
|
7300
|
+
* "TemplateProcessingFailed": true,
|
|
7301
|
+
* "SignerWhatsappFailed": true
|
|
7302
|
+
* }
|
|
7303
|
+
* ```
|
|
6835
7304
|
* @throws {ValidationError} Before requesting when the map is empty, has an
|
|
6836
7305
|
* unknown key, or contains a non-boolean value.
|
|
6837
7306
|
* @throws {ApiError} `400` if the API rejects the map, `401` for invalid
|
|
@@ -7075,7 +7544,7 @@ var AssinafyClient = class _AssinafyClient {
|
|
|
7075
7544
|
baseURL,
|
|
7076
7545
|
timeout
|
|
7077
7546
|
};
|
|
7078
|
-
this.axiosInstance =
|
|
7547
|
+
this.axiosInstance = import_axios4.default.create({
|
|
7079
7548
|
...transportOptions,
|
|
7080
7549
|
headers,
|
|
7081
7550
|
// Authorization is stripped by the redirect stack already;
|
|
@@ -7084,7 +7553,7 @@ var AssinafyClient = class _AssinafyClient {
|
|
|
7084
7553
|
});
|
|
7085
7554
|
installCredentialOriginGuard(this.axiosInstance, baseURL);
|
|
7086
7555
|
this.publicAxiosInstance = withoutCredentials(
|
|
7087
|
-
|
|
7556
|
+
import_axios4.default.create({
|
|
7088
7557
|
...transportOptions,
|
|
7089
7558
|
headers: { "User-Agent": SDK_USER_AGENT }
|
|
7090
7559
|
})
|
|
@@ -7283,7 +7752,10 @@ var AssinafyClient = class _AssinafyClient {
|
|
|
7283
7752
|
* the upload is empty / non-PDF / larger than 25 MB, or `waitForReady` is
|
|
7284
7753
|
* enabled and processing exceeds the {@link DocumentResource.waitUntilReady}
|
|
7285
7754
|
* timeout.
|
|
7286
|
-
* @throws {ApiError} If any underlying API call is rejected
|
|
7755
|
+
* @throws {ApiError} If any underlying API call is rejected — see the
|
|
7756
|
+
* `@throws` of {@link DocumentResource.upload}, {@link SignerResource.create},
|
|
7757
|
+
* {@link AssignmentResource.create}, and
|
|
7758
|
+
* {@link DocumentResource.waitUntilReady} for the per-step statuses.
|
|
7287
7759
|
*
|
|
7288
7760
|
* @example
|
|
7289
7761
|
* ```ts
|
|
@@ -7501,7 +7973,7 @@ function installRateLimitRetry(http, maxRetries, logger) {
|
|
|
7501
7973
|
http.interceptors.response.use(
|
|
7502
7974
|
(response) => response,
|
|
7503
7975
|
async (error) => {
|
|
7504
|
-
if (!
|
|
7976
|
+
if (!import_axios4.default.isAxiosError(error) || error.response?.status !== 429 || !error.config) {
|
|
7505
7977
|
throw error;
|
|
7506
7978
|
}
|
|
7507
7979
|
const config = error.config;
|