@assinafy/sdk 2.5.1 → 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 +26 -45
- package/README.en.md +28 -27
- package/README.md +25 -25
- package/dist/index.d.mts +447 -18
- package/dist/index.d.ts +447 -18
- package/dist/index.js +402 -22
- package/dist/index.mjs +398 -18
- package/docs/API_COVERAGE.md +1 -1
- package/docs/COMPATIBILITY.md +15 -21
- 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
|
|
@@ -213,12 +213,14 @@ var OAuthError = class _OAuthError extends ApiError {
|
|
|
213
213
|
const code = body["error"];
|
|
214
214
|
if (typeof code !== "string" || code.length === 0) return error;
|
|
215
215
|
const description = body["error_description"];
|
|
216
|
-
|
|
216
|
+
const upgraded = new _OAuthError(
|
|
217
217
|
code,
|
|
218
218
|
typeof description === "string" && description.length > 0 ? description : null,
|
|
219
219
|
error.statusCode,
|
|
220
220
|
body
|
|
221
221
|
);
|
|
222
|
+
if (error.challenge !== void 0) upgraded.challenge = error.challenge;
|
|
223
|
+
return upgraded;
|
|
222
224
|
}
|
|
223
225
|
};
|
|
224
226
|
var ValidationError = class extends AssinafyError {
|
|
@@ -522,6 +524,9 @@ function nextRetryDelayMs(headers, attempt, maxDelayMs = 3e4) {
|
|
|
522
524
|
return Math.min(backoffMs(attempt), maxDelayMs);
|
|
523
525
|
}
|
|
524
526
|
|
|
527
|
+
// src/resources/base.ts
|
|
528
|
+
var import_axios3 = require("axios");
|
|
529
|
+
|
|
525
530
|
// src/support/path.ts
|
|
526
531
|
function encodePathSegment(value) {
|
|
527
532
|
return encodeURIComponent(value).replace(
|
|
@@ -646,7 +651,7 @@ var import_axios2 = __toESM(require("axios"));
|
|
|
646
651
|
// package.json
|
|
647
652
|
var package_default = {
|
|
648
653
|
name: "@assinafy/sdk",
|
|
649
|
-
version: "2.5.
|
|
654
|
+
version: "2.5.2",
|
|
650
655
|
packageManager: "bun@1.4.0",
|
|
651
656
|
description: "TypeScript SDK for Assinafy API - Digital signature platform",
|
|
652
657
|
type: "commonjs",
|
|
@@ -727,7 +732,7 @@ var package_default = {
|
|
|
727
732
|
},
|
|
728
733
|
overrides: {
|
|
729
734
|
esbuild: "0.28.2",
|
|
730
|
-
"brace-expansion": "5.0.
|
|
735
|
+
"brace-expansion": "5.0.12"
|
|
731
736
|
},
|
|
732
737
|
files: [
|
|
733
738
|
"dist",
|
|
@@ -952,7 +957,10 @@ var BaseResource = class {
|
|
|
952
957
|
};
|
|
953
958
|
function assertSuccessful(response) {
|
|
954
959
|
if (response.status < 200 || response.status >= 300) {
|
|
955
|
-
throw
|
|
960
|
+
throw toSdkError(
|
|
961
|
+
new import_axios3.AxiosError("Request failed", void 0, response.config, void 0, response),
|
|
962
|
+
"API request failed"
|
|
963
|
+
);
|
|
956
964
|
}
|
|
957
965
|
return response;
|
|
958
966
|
}
|
|
@@ -1331,6 +1339,28 @@ var AssignmentResource = class extends BaseResource {
|
|
|
1331
1339
|
* `DigitalCertificate` costs two credits, requires the feature plus a
|
|
1332
1340
|
* signer `government_id`, and that signer must be alone in its step.
|
|
1333
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
|
+
*
|
|
1334
1364
|
* @param documentId - The document to request signatures on.
|
|
1335
1365
|
* @param payload - Signers plus optional `method` (defaults to `virtual`),
|
|
1336
1366
|
* `message`, `expires_at`, `copy_receivers` (existing signer IDs, not
|
|
@@ -1449,6 +1479,21 @@ var AssignmentResource = class extends BaseResource {
|
|
|
1449
1479
|
* email notification, and 0.45 for WhatsApp notification; a digital
|
|
1450
1480
|
* certificate charge is added on top of its notification cost.
|
|
1451
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
|
+
*
|
|
1452
1497
|
* @param documentId - The document the assignment would be created on.
|
|
1453
1498
|
* @param payload - `method` plus channel-only signer descriptors and/or
|
|
1454
1499
|
* `collect`-mode `entries`. Create-only fields and signer IDs are not part
|
|
@@ -1504,6 +1549,13 @@ var AssignmentResource = class extends BaseResource {
|
|
|
1504
1549
|
* is retained as a compatibility value and, unlike ordinary nullable
|
|
1505
1550
|
* inputs, is intentionally not stripped from the body.
|
|
1506
1551
|
*
|
|
1552
|
+
* Request body (`application/json`):
|
|
1553
|
+
* ```jsonc
|
|
1554
|
+
* {
|
|
1555
|
+
* "expires_at": "2027-12-31T23:59:59Z"
|
|
1556
|
+
* }
|
|
1557
|
+
* ```
|
|
1558
|
+
*
|
|
1507
1559
|
* @param documentId - The document the assignment belongs to.
|
|
1508
1560
|
* @param assignmentId - The assignment to update.
|
|
1509
1561
|
* @param expiresAt - New expiry as an ISO-8601 date/time string. `null` is
|
|
@@ -1919,6 +1971,13 @@ var DocumentResource = class extends BaseResource {
|
|
|
1919
1971
|
* {@link DocumentResource.upload} — that avoids the extra round-trip and
|
|
1920
1972
|
* the processing race entirely.
|
|
1921
1973
|
*
|
|
1974
|
+
* Request body (`application/json`):
|
|
1975
|
+
* ```jsonc
|
|
1976
|
+
* {
|
|
1977
|
+
* "name": "Service agreement.pdf"
|
|
1978
|
+
* }
|
|
1979
|
+
* ```
|
|
1980
|
+
*
|
|
1922
1981
|
* @param documentId - The document to rename.
|
|
1923
1982
|
* @param name - The new display name (max 255 chars), e.g.
|
|
1924
1983
|
* `'Service agreement.pdf'`. The API removes diacritics and replaces
|
|
@@ -2329,6 +2388,15 @@ var DocumentResource = class extends BaseResource {
|
|
|
2329
2388
|
* overwrites the existing set — use
|
|
2330
2389
|
* {@link DocumentResource.addTags} to append.
|
|
2331
2390
|
*
|
|
2391
|
+
* Request body (`application/json`):
|
|
2392
|
+
* ```jsonc
|
|
2393
|
+
* {
|
|
2394
|
+
* "tags": [
|
|
2395
|
+
* "tag_example"
|
|
2396
|
+
* ]
|
|
2397
|
+
* }
|
|
2398
|
+
* ```
|
|
2399
|
+
*
|
|
2332
2400
|
* @param documentId - The document to retag.
|
|
2333
2401
|
* @param tags - The complete desired set of tag IDs (`[]` clears all).
|
|
2334
2402
|
* @param accountId - Override the client's default account ID.
|
|
@@ -2371,6 +2439,15 @@ var DocumentResource = class extends BaseResource {
|
|
|
2371
2439
|
* present is a no-op. To replace the whole set instead, use
|
|
2372
2440
|
* {@link DocumentResource.replaceTags}.
|
|
2373
2441
|
*
|
|
2442
|
+
* Request body (`application/json`):
|
|
2443
|
+
* ```jsonc
|
|
2444
|
+
* {
|
|
2445
|
+
* "tags": [
|
|
2446
|
+
* "tag_example"
|
|
2447
|
+
* ]
|
|
2448
|
+
* }
|
|
2449
|
+
* ```
|
|
2450
|
+
*
|
|
2374
2451
|
* @param documentId - The document to tag.
|
|
2375
2452
|
* @param tags - Tag IDs to attach (must be non-empty).
|
|
2376
2453
|
* @param accountId - Override the client's default account ID.
|
|
@@ -2446,6 +2523,35 @@ var DocumentResource = class extends BaseResource {
|
|
|
2446
2523
|
* `options` may add `name`, `message`, `expires_at`, `editor_fields`, and
|
|
2447
2524
|
* tag names in `tags` (unknown names are created automatically).
|
|
2448
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
|
+
*
|
|
2449
2555
|
* @param templateId - The template to instantiate.
|
|
2450
2556
|
* @param signers - Role-to-signer bindings (each with `role_id` and `id`,
|
|
2451
2557
|
* plus optional `verification_method`, `notification_methods`, `step`).
|
|
@@ -2529,6 +2635,21 @@ var DocumentResource = class extends BaseResource {
|
|
|
2529
2635
|
* `DigitalCertificate` adds two credits per signer and has the same feature,
|
|
2530
2636
|
* `government_id`, and signing-step prerequisites as document creation.
|
|
2531
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
|
+
*
|
|
2532
2653
|
* @param templateId - The template that would be instantiated.
|
|
2533
2654
|
* @param signers - One channel descriptor per template role. Cost requests
|
|
2534
2655
|
* use only `role_id`, `verification_method`, and `notification_methods`;
|
|
@@ -2904,6 +3025,19 @@ var SignerResource = class extends BaseResource {
|
|
|
2904
3025
|
* A reused signer is returned unchanged; this method does not overwrite its
|
|
2905
3026
|
* existing name, phone, CPF, or metadata with the create payload.
|
|
2906
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
|
+
*
|
|
2907
3041
|
* @param payload - The signer to create. The official fields are required
|
|
2908
3042
|
* `full_name` plus optional `email` and E.164 `whatsapp_phone_number`.
|
|
2909
3043
|
* `phone`, `cpf`, and `metadata` are compatibility extensions; the SDK
|
|
@@ -3055,6 +3189,16 @@ var SignerResource = class extends BaseResource {
|
|
|
3055
3189
|
* while it belongs to an in-flight document; changing an unverified channel
|
|
3056
3190
|
* rotates its access/verification codes, so resend the notification.
|
|
3057
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
|
+
*
|
|
3058
3202
|
* @param signerId - The signer to update.
|
|
3059
3203
|
* @param payload - Fields to change. The official `government_id` field and
|
|
3060
3204
|
* legacy `cpf` extension are stripped to digits before sending.
|
|
@@ -3274,6 +3418,16 @@ var WorkspaceResource = class extends BaseResource {
|
|
|
3274
3418
|
/**
|
|
3275
3419
|
* Create a new workspace (`POST /accounts`).
|
|
3276
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
|
+
*
|
|
3277
3431
|
* @param payload - Official fields are workspace `name` (required) and
|
|
3278
3432
|
* optional `notification_sender_type` (`User` or `Account`). Optional brand
|
|
3279
3433
|
* colours use six hex characters without
|
|
@@ -3554,6 +3708,16 @@ var WorkspaceResource = class extends BaseResource {
|
|
|
3554
3708
|
/**
|
|
3555
3709
|
* Update a workspace (`PUT /accounts/{accountId}`).
|
|
3556
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
|
+
*
|
|
3557
3721
|
* @param accountId - The workspace to update.
|
|
3558
3722
|
* @param payload - Official fields are `name` and
|
|
3559
3723
|
* `notification_sender_type` (`User` or `Account`). Brand colours use six
|
|
@@ -3614,6 +3778,13 @@ var WorkspaceResource = class extends BaseResource {
|
|
|
3614
3778
|
* proceeds with deletion; it is not documented as a blanket override for
|
|
3615
3779
|
* unrelated restrictions. The flag is sent in the request body.
|
|
3616
3780
|
*
|
|
3781
|
+
* Request body (`application/json`):
|
|
3782
|
+
* ```jsonc
|
|
3783
|
+
* {
|
|
3784
|
+
* "force": true
|
|
3785
|
+
* }
|
|
3786
|
+
* ```
|
|
3787
|
+
*
|
|
3617
3788
|
* @param accountId - The workspace to delete.
|
|
3618
3789
|
* @param options - Set `force: true` to cancel an active paid subscription
|
|
3619
3790
|
* and proceed with deletion.
|
|
@@ -3684,6 +3855,19 @@ var WebhookResource = class extends BaseResource {
|
|
|
3684
3855
|
* `signer_rejected_document`, `document_processing_failed`).
|
|
3685
3856
|
* OAuth tokens need the `webhooks:write` scope.
|
|
3686
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
|
+
*
|
|
3687
3871
|
* @param payload - Subscription details. `url` and `email` are required;
|
|
3688
3872
|
* `events` defaults to {@link DEFAULT_WEBHOOK_EVENTS} and `is_active`
|
|
3689
3873
|
* defaults to `true`.
|
|
@@ -4207,6 +4391,14 @@ var TemplateResource = class extends BaseResource {
|
|
|
4207
4391
|
* `undefined` keys before sending. Unlike uploads, `name` here is a plain
|
|
4208
4392
|
* display name and is **not** forced to end in `.pdf`.
|
|
4209
4393
|
*
|
|
4394
|
+
* Request body (`application/json`):
|
|
4395
|
+
* ```jsonc
|
|
4396
|
+
* {
|
|
4397
|
+
* "name": "Service agreement.pdf",
|
|
4398
|
+
* "message": "Please sign this document."
|
|
4399
|
+
* }
|
|
4400
|
+
* ```
|
|
4401
|
+
*
|
|
4210
4402
|
* @param templateId - The template to update.
|
|
4211
4403
|
* @param payload - `name` and/or `message`; both optional.
|
|
4212
4404
|
* @param accountId - Override the client's default account ID.
|
|
@@ -4387,6 +4579,14 @@ var TagResource = class extends BaseResource {
|
|
|
4387
4579
|
* and `'ff8800'` both persist as `'ff8800'`. Omit `color`
|
|
4388
4580
|
* (or pass `null`) for no color.
|
|
4389
4581
|
*
|
|
4582
|
+
* Request body (`application/json`):
|
|
4583
|
+
* ```jsonc
|
|
4584
|
+
* {
|
|
4585
|
+
* "name": "Contracts",
|
|
4586
|
+
* "color": "ff8800"
|
|
4587
|
+
* }
|
|
4588
|
+
* ```
|
|
4589
|
+
*
|
|
4390
4590
|
* @param payload - `name` (required, max 64 characters; trimmed with
|
|
4391
4591
|
* internal whitespace collapsed) and optional `color`.
|
|
4392
4592
|
* @param accountId - Override the client's default account ID.
|
|
@@ -4436,6 +4636,14 @@ var TagResource = class extends BaseResource {
|
|
|
4436
4636
|
* leading `#` on `color` is accepted and stripped by the API
|
|
4437
4637
|
* (`'#112233'` → `'112233'`).
|
|
4438
4638
|
*
|
|
4639
|
+
* Request body (`application/json`):
|
|
4640
|
+
* ```jsonc
|
|
4641
|
+
* {
|
|
4642
|
+
* "name": "Signed contracts",
|
|
4643
|
+
* "color": null
|
|
4644
|
+
* }
|
|
4645
|
+
* ```
|
|
4646
|
+
*
|
|
4439
4647
|
* @param tagId - The tag to update.
|
|
4440
4648
|
* @param payload - `name` and/or `color`. `color: null` clears the color;
|
|
4441
4649
|
* omit a field to leave it unchanged.
|
|
@@ -4594,6 +4802,14 @@ var AuthenticationResource = class extends BaseResource {
|
|
|
4594
4802
|
* `X-Api-Key` (see {@link AuthenticationResource.createApiKey}) instead of
|
|
4595
4803
|
* storing a password.
|
|
4596
4804
|
*
|
|
4805
|
+
* Request body (`application/json`):
|
|
4806
|
+
* ```jsonc
|
|
4807
|
+
* {
|
|
4808
|
+
* "email": "user@example.com",
|
|
4809
|
+
* "password": "example-password"
|
|
4810
|
+
* }
|
|
4811
|
+
* ```
|
|
4812
|
+
*
|
|
4597
4813
|
* @param email - The user's email address, e.g. `'user@example.com'`.
|
|
4598
4814
|
* @param password - The user's password.
|
|
4599
4815
|
* @returns An {@link ILoginResponse} with the access token, user, and
|
|
@@ -4649,6 +4865,15 @@ var AuthenticationResource = class extends BaseResource {
|
|
|
4649
4865
|
* Assinafy JWT. Returns the same {@link ILoginResponse} shape as
|
|
4650
4866
|
* {@link AuthenticationResource.login}.
|
|
4651
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
|
+
*
|
|
4652
4877
|
* @param payload - The social-login body.
|
|
4653
4878
|
* @param payload.provider - OAuth provider; currently exactly `'google'`.
|
|
4654
4879
|
* @param payload.token - The provider-issued OAuth/ID token.
|
|
@@ -4723,6 +4948,14 @@ var AuthenticationResource = class extends BaseResource {
|
|
|
4723
4948
|
* The response is the standard status/message acknowledgement with no data,
|
|
4724
4949
|
* so this method resolves to `void`.
|
|
4725
4950
|
*
|
|
4951
|
+
* Request body (`application/json`):
|
|
4952
|
+
* ```jsonc
|
|
4953
|
+
* {
|
|
4954
|
+
* "provider": "google",
|
|
4955
|
+
* "token": "provider_token_example"
|
|
4956
|
+
* }
|
|
4957
|
+
* ```
|
|
4958
|
+
*
|
|
4726
4959
|
* @param payload - Social provider and provider-issued access/ID token.
|
|
4727
4960
|
* @returns Resolves when the API acknowledges that the identity was linked.
|
|
4728
4961
|
* @throws {ValidationError} If `provider` is not `google` or `token` is empty.
|
|
@@ -4759,6 +4992,13 @@ var AuthenticationResource = class extends BaseResource {
|
|
|
4759
4992
|
* a masked value. Calling this again rotates the key, invalidating the
|
|
4760
4993
|
* previous one.
|
|
4761
4994
|
*
|
|
4995
|
+
* Request body (`application/json`):
|
|
4996
|
+
* ```jsonc
|
|
4997
|
+
* {
|
|
4998
|
+
* "password": "example-password"
|
|
4999
|
+
* }
|
|
5000
|
+
* ```
|
|
5001
|
+
*
|
|
4762
5002
|
* @param password - The current user's password, required to authorize
|
|
4763
5003
|
* key generation.
|
|
4764
5004
|
* @returns An {@link IApiKeyResponse} containing the new key. Response
|
|
@@ -4846,6 +5086,15 @@ var AuthenticationResource = class extends BaseResource {
|
|
|
4846
5086
|
* Requires the current password as a confirmation. On success the API
|
|
4847
5087
|
* echoes back the affected `email`.
|
|
4848
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
|
+
*
|
|
4849
5098
|
* @param payload - The change-password body.
|
|
4850
5099
|
* @param payload.email - The user's email address.
|
|
4851
5100
|
* @param payload.password - The current password.
|
|
@@ -4892,6 +5141,13 @@ var AuthenticationResource = class extends BaseResource {
|
|
|
4892
5141
|
* Triggers Assinafy to email a reset link/token to the given address.
|
|
4893
5142
|
* Complete the flow with {@link AuthenticationResource.resetPassword}.
|
|
4894
5143
|
*
|
|
5144
|
+
* Request body (`application/json`):
|
|
5145
|
+
* ```jsonc
|
|
5146
|
+
* {
|
|
5147
|
+
* "email": "user@example.com"
|
|
5148
|
+
* }
|
|
5149
|
+
* ```
|
|
5150
|
+
*
|
|
4895
5151
|
* @param email - The email address to send the reset link to.
|
|
4896
5152
|
* @returns `{ email }` — the address the reset link was sent to. Response
|
|
4897
5153
|
* shape:
|
|
@@ -4923,6 +5179,15 @@ var AuthenticationResource = class extends BaseResource {
|
|
|
4923
5179
|
* {@link AuthenticationResource.requestPasswordReset} and sets the new
|
|
4924
5180
|
* password. On success the API echoes back the affected `email`.
|
|
4925
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
|
+
*
|
|
4926
5191
|
* @param payload - The reset-password body.
|
|
4927
5192
|
* @param payload.email - The user's email address.
|
|
4928
5193
|
* @param payload.token - The reset token from the emailed link. The current
|
|
@@ -5145,8 +5410,8 @@ var OAuthResource = class extends BaseResource {
|
|
|
5145
5410
|
* ```ts
|
|
5146
5411
|
* const request = await client.oauth.createAuthorizationUrl({
|
|
5147
5412
|
* clientId: process.env.ASSINAFY_CLIENT_ID!,
|
|
5148
|
-
* redirectUri: 'https://myapp.com/oauth/callback',
|
|
5149
|
-
* 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'],
|
|
5150
5415
|
* });
|
|
5151
5416
|
* session.oauth = request;
|
|
5152
5417
|
* response.redirect(request.url);
|
|
@@ -5233,8 +5498,8 @@ var OAuthResource = class extends BaseResource {
|
|
|
5233
5498
|
* ```
|
|
5234
5499
|
* @throws {ValidationError} If `state` is missing or does not match, `iss`
|
|
5235
5500
|
* is absent or disagrees with the expected issuer, or a successful response
|
|
5236
|
-
* carries no `code
|
|
5237
|
-
*
|
|
5501
|
+
* carries no `code`, or a protocol parameter appears more than once.
|
|
5502
|
+
* Reject such responses without exchanging the code.
|
|
5238
5503
|
* @throws {OAuthError} If the server returned `error` (e.g.
|
|
5239
5504
|
* `access_denied`, `invalid_scope`, `invalid_request`,
|
|
5240
5505
|
* `unsupported_response_type`, `invalid_target`).
|
|
@@ -5247,9 +5512,9 @@ var OAuthResource = class extends BaseResource {
|
|
|
5247
5512
|
* const tokens = await client.oauth.exchangeCode({
|
|
5248
5513
|
* code,
|
|
5249
5514
|
* codeVerifier: stored.codeVerifier,
|
|
5250
|
-
* redirectUri: 'https://myapp.com/oauth/callback',
|
|
5515
|
+
* redirectUri: 'https://myapp.example.com/oauth/callback',
|
|
5251
5516
|
* clientId: process.env.ASSINAFY_CLIENT_ID!,
|
|
5252
|
-
* clientSecret: process.env.ASSINAFY_CLIENT_SECRET
|
|
5517
|
+
* clientSecret: process.env.ASSINAFY_CLIENT_SECRET!,
|
|
5253
5518
|
* });
|
|
5254
5519
|
* });
|
|
5255
5520
|
* ```
|
|
@@ -5258,6 +5523,11 @@ var OAuthResource = class extends BaseResource {
|
|
|
5258
5523
|
assertRecord(expected, "expected authorization request");
|
|
5259
5524
|
assertNonEmptyString(expected.state, "expected.state");
|
|
5260
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
|
+
}
|
|
5261
5531
|
const state = query.get("state");
|
|
5262
5532
|
if (state === null || !constantTimeEquals(state, expected.state)) {
|
|
5263
5533
|
throw new ValidationError(
|
|
@@ -5294,6 +5564,12 @@ var OAuthResource = class extends BaseResource {
|
|
|
5294
5564
|
* a browser. Every value must match the authorization request exactly, or
|
|
5295
5565
|
* the API answers `invalid_grant`.
|
|
5296
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
|
+
*
|
|
5297
5573
|
* @param options - Exchange options.
|
|
5298
5574
|
* @param options.code - The code from
|
|
5299
5575
|
* {@link OAuthResource.readAuthorizationCallback}.
|
|
@@ -5329,9 +5605,9 @@ var OAuthResource = class extends BaseResource {
|
|
|
5329
5605
|
* const tokens = await client.oauth.exchangeCode({
|
|
5330
5606
|
* code,
|
|
5331
5607
|
* codeVerifier: session.oauth.codeVerifier,
|
|
5332
|
-
* redirectUri: 'https://myapp.com/oauth/callback',
|
|
5608
|
+
* redirectUri: 'https://myapp.example.com/oauth/callback',
|
|
5333
5609
|
* clientId: process.env.ASSINAFY_CLIENT_ID!,
|
|
5334
|
-
* clientSecret: process.env.ASSINAFY_CLIENT_SECRET
|
|
5610
|
+
* clientSecret: process.env.ASSINAFY_CLIENT_SECRET!,
|
|
5335
5611
|
* });
|
|
5336
5612
|
* ```
|
|
5337
5613
|
*/
|
|
@@ -5367,6 +5643,12 @@ var OAuthResource = class extends BaseResource {
|
|
|
5367
5643
|
* only expires if it goes 30 days without a refresh; after that the user
|
|
5368
5644
|
* has to reconnect.
|
|
5369
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
|
+
*
|
|
5370
5652
|
* @param options - Refresh options.
|
|
5371
5653
|
* @param options.refreshToken - The current refresh token.
|
|
5372
5654
|
* @param options.clientId - The application's `client_id`.
|
|
@@ -5397,7 +5679,7 @@ var OAuthResource = class extends BaseResource {
|
|
|
5397
5679
|
* const tokens = await client.oauth.refreshToken({
|
|
5398
5680
|
* refreshToken: connection.refreshToken,
|
|
5399
5681
|
* clientId: process.env.ASSINAFY_CLIENT_ID!,
|
|
5400
|
-
* clientSecret: process.env.ASSINAFY_CLIENT_SECRET
|
|
5682
|
+
* clientSecret: process.env.ASSINAFY_CLIENT_SECRET!,
|
|
5401
5683
|
* });
|
|
5402
5684
|
* await connection.save({ refreshToken: tokens.refresh_token });
|
|
5403
5685
|
* ```
|
|
@@ -5451,7 +5733,7 @@ var OAuthResource = class extends BaseResource {
|
|
|
5451
5733
|
* token: connection.refreshToken,
|
|
5452
5734
|
* tokenTypeHint: 'refresh_token',
|
|
5453
5735
|
* clientId: process.env.ASSINAFY_CLIENT_ID!,
|
|
5454
|
-
* clientSecret: process.env.ASSINAFY_CLIENT_SECRET
|
|
5736
|
+
* clientSecret: process.env.ASSINAFY_CLIENT_SECRET!,
|
|
5455
5737
|
* });
|
|
5456
5738
|
* ```
|
|
5457
5739
|
*/
|
|
@@ -5494,8 +5776,8 @@ var OAuthResource = class extends BaseResource {
|
|
|
5494
5776
|
* "email_verified": true
|
|
5495
5777
|
* }
|
|
5496
5778
|
* ```
|
|
5497
|
-
* `sub` is the stable user identifier;
|
|
5498
|
-
* was not granted.
|
|
5779
|
+
* `sub` is the stable user identifier; other claims may be omitted or
|
|
5780
|
+
* `null` when their scope was not granted.
|
|
5499
5781
|
* @throws {ValidationError} If `accessToken` is supplied but empty.
|
|
5500
5782
|
* @throws {ApiError} `401` when the token is missing, expired or revoked;
|
|
5501
5783
|
* `403` when the `openid` scope was not granted — its `WWW-Authenticate`
|
|
@@ -5665,8 +5947,9 @@ function toSearchParams(params) {
|
|
|
5665
5947
|
assertRecord(params, "callback parameters");
|
|
5666
5948
|
const search = new URLSearchParams();
|
|
5667
5949
|
for (const [key, value] of Object.entries(params)) {
|
|
5668
|
-
const
|
|
5669
|
-
|
|
5950
|
+
for (const item of Array.isArray(value) ? value : [value]) {
|
|
5951
|
+
if (typeof item === "string") search.append(key, item);
|
|
5952
|
+
}
|
|
5670
5953
|
}
|
|
5671
5954
|
return search;
|
|
5672
5955
|
}
|
|
@@ -5676,6 +5959,17 @@ var FieldsResource = class extends BaseResource {
|
|
|
5676
5959
|
/**
|
|
5677
5960
|
* Create a field definition (`POST /accounts/{accountId}/fields`).
|
|
5678
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
|
+
*
|
|
5679
5973
|
* @param payload - The field to create. `type` and `name` are required;
|
|
5680
5974
|
* `type` must be one of the platform field types (see
|
|
5681
5975
|
* {@link FieldsResource.listTypes}); `regex` may be a string or `null`,
|
|
@@ -5820,6 +6114,15 @@ var FieldsResource = class extends BaseResource {
|
|
|
5820
6114
|
* Update a field definition
|
|
5821
6115
|
* (`PUT /accounts/{accountId}/fields/{fieldId}`).
|
|
5822
6116
|
*
|
|
6117
|
+
* Request body (`application/json`):
|
|
6118
|
+
* ```jsonc
|
|
6119
|
+
* {
|
|
6120
|
+
* "name": "Customer reference",
|
|
6121
|
+
* "regex": null,
|
|
6122
|
+
* "is_active": true
|
|
6123
|
+
* }
|
|
6124
|
+
* ```
|
|
6125
|
+
*
|
|
5823
6126
|
* @param fieldId - The field definition to update.
|
|
5824
6127
|
* @param payload - Fields are `name`, nullable `regex`, and `is_active`;
|
|
5825
6128
|
* `type` and `is_required` are compatibility extensions.
|
|
@@ -5908,6 +6211,13 @@ var FieldsResource = class extends BaseResource {
|
|
|
5908
6211
|
* `signerAccessCode` is a compatibility query and is sent as
|
|
5909
6212
|
* `signer-access-code` when supplied.
|
|
5910
6213
|
*
|
|
6214
|
+
* Request body (`application/json`):
|
|
6215
|
+
* ```jsonc
|
|
6216
|
+
* {
|
|
6217
|
+
* "value": "Example value"
|
|
6218
|
+
* }
|
|
6219
|
+
* ```
|
|
6220
|
+
*
|
|
5911
6221
|
* @param fieldId - The field definition to validate against.
|
|
5912
6222
|
* @param value - The value to check (validated against the field's
|
|
5913
6223
|
* type/regex). Sent as `{ value }` in the request body.
|
|
@@ -5960,6 +6270,16 @@ var FieldsResource = class extends BaseResource {
|
|
|
5960
6270
|
* same compatibility extension described on
|
|
5961
6271
|
* {@link FieldsResource.validate}.
|
|
5962
6272
|
*
|
|
6273
|
+
* Request body (`application/json`):
|
|
6274
|
+
* ```jsonc
|
|
6275
|
+
* [
|
|
6276
|
+
* {
|
|
6277
|
+
* "field_id": "field_example",
|
|
6278
|
+
* "value": "Example value"
|
|
6279
|
+
* }
|
|
6280
|
+
* ]
|
|
6281
|
+
* ```
|
|
6282
|
+
*
|
|
5963
6283
|
* @param entries - Non-empty array of `{ field_id, value }` pairs.
|
|
5964
6284
|
* @param options - Account override and optional legacy `signerAccessCode`.
|
|
5965
6285
|
* @returns One validation result per entry. Response shape:
|
|
@@ -6287,6 +6607,15 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
6287
6607
|
* The `document_ids` array goes in the request body; the access code
|
|
6288
6608
|
* authenticates via the `signer-access-code` query param.
|
|
6289
6609
|
*
|
|
6610
|
+
* Request body (`application/json`):
|
|
6611
|
+
* ```jsonc
|
|
6612
|
+
* {
|
|
6613
|
+
* "document_ids": [
|
|
6614
|
+
* "document_example"
|
|
6615
|
+
* ]
|
|
6616
|
+
* }
|
|
6617
|
+
* ```
|
|
6618
|
+
*
|
|
6290
6619
|
* @param documentIds - Non-empty array of document IDs to sign.
|
|
6291
6620
|
* @param signerAccessCode - The signer's access code, from their signing link.
|
|
6292
6621
|
* @returns Resolves when the API acknowledges the operation. The documented
|
|
@@ -6326,6 +6655,16 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
6326
6655
|
* Both `document_ids` and `decline_reason` go in the request body; the access
|
|
6327
6656
|
* code authenticates via the `signer-access-code` query param.
|
|
6328
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
|
+
*
|
|
6329
6668
|
* @param documentIds - Non-empty array of document IDs to decline.
|
|
6330
6669
|
* @param declineReason - Free-text reason shown to the sender (required).
|
|
6331
6670
|
* @param signerAccessCode - The signer's access code, from their signing link.
|
|
@@ -6441,6 +6780,13 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
6441
6780
|
* **body carries only `verification-code`** (putting the access code in the
|
|
6442
6781
|
* body leaves the request unauthenticated → `401`).
|
|
6443
6782
|
*
|
|
6783
|
+
* Request body (`application/json`):
|
|
6784
|
+
* ```jsonc
|
|
6785
|
+
* {
|
|
6786
|
+
* "verification-code": "123456"
|
|
6787
|
+
* }
|
|
6788
|
+
* ```
|
|
6789
|
+
*
|
|
6444
6790
|
* @param payload - `signerAccessCode` (the signing-link code) and
|
|
6445
6791
|
* `verificationCode` (the OTP the signer received).
|
|
6446
6792
|
* @returns Resolves when the API acknowledges the operation. The response
|
|
@@ -6659,6 +7005,18 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
6659
7005
|
* first. Digital Certificate signers cannot use this endpoint; use the
|
|
6660
7006
|
* certificate start/complete API flow instead.
|
|
6661
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
|
+
*
|
|
6662
7020
|
* @param documentId - The document being signed.
|
|
6663
7021
|
* @param assignmentId - The assignment within that document.
|
|
6664
7022
|
* @param signerAccessCode - The signer's access code, from their signing link.
|
|
@@ -6716,6 +7074,13 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
6716
7074
|
* delete the document via `documents.delete`; there is no workspace "cancel"
|
|
6717
7075
|
* endpoint.)
|
|
6718
7076
|
*
|
|
7077
|
+
* Request body (`application/json`):
|
|
7078
|
+
* ```jsonc
|
|
7079
|
+
* {
|
|
7080
|
+
* "decline_reason": "The document needs a correction."
|
|
7081
|
+
* }
|
|
7082
|
+
* ```
|
|
7083
|
+
*
|
|
6719
7084
|
* @param documentId - The document being declined.
|
|
6720
7085
|
* @param assignmentId - The assignment within that document.
|
|
6721
7086
|
* @param signerAccessCode - The signer's access code, from their signing link.
|
|
@@ -6902,6 +7267,21 @@ var UserResource = class extends BaseResource {
|
|
|
6902
7267
|
* (`PUT /users/self/notification-preferences`). Omitted keys retain their
|
|
6903
7268
|
* current values; account/security e-mails are not configurable here.
|
|
6904
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
|
+
*
|
|
6905
7285
|
* @param preferences - One or more of the nine documented keys, each with
|
|
6906
7286
|
* a boolean value. Request example:
|
|
6907
7287
|
* ```json
|
|
@@ -7164,7 +7544,7 @@ var AssinafyClient = class _AssinafyClient {
|
|
|
7164
7544
|
baseURL,
|
|
7165
7545
|
timeout
|
|
7166
7546
|
};
|
|
7167
|
-
this.axiosInstance =
|
|
7547
|
+
this.axiosInstance = import_axios4.default.create({
|
|
7168
7548
|
...transportOptions,
|
|
7169
7549
|
headers,
|
|
7170
7550
|
// Authorization is stripped by the redirect stack already;
|
|
@@ -7173,7 +7553,7 @@ var AssinafyClient = class _AssinafyClient {
|
|
|
7173
7553
|
});
|
|
7174
7554
|
installCredentialOriginGuard(this.axiosInstance, baseURL);
|
|
7175
7555
|
this.publicAxiosInstance = withoutCredentials(
|
|
7176
|
-
|
|
7556
|
+
import_axios4.default.create({
|
|
7177
7557
|
...transportOptions,
|
|
7178
7558
|
headers: { "User-Agent": SDK_USER_AGENT }
|
|
7179
7559
|
})
|
|
@@ -7593,7 +7973,7 @@ function installRateLimitRetry(http, maxRetries, logger) {
|
|
|
7593
7973
|
http.interceptors.response.use(
|
|
7594
7974
|
(response) => response,
|
|
7595
7975
|
async (error) => {
|
|
7596
|
-
if (!
|
|
7976
|
+
if (!import_axios4.default.isAxiosError(error) || error.response?.status !== 429 || !error.config) {
|
|
7597
7977
|
throw error;
|
|
7598
7978
|
}
|
|
7599
7979
|
const config = error.config;
|