@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.mjs
CHANGED
|
@@ -153,12 +153,14 @@ var OAuthError = class _OAuthError extends ApiError {
|
|
|
153
153
|
const code = body["error"];
|
|
154
154
|
if (typeof code !== "string" || code.length === 0) return error;
|
|
155
155
|
const description = body["error_description"];
|
|
156
|
-
|
|
156
|
+
const upgraded = new _OAuthError(
|
|
157
157
|
code,
|
|
158
158
|
typeof description === "string" && description.length > 0 ? description : null,
|
|
159
159
|
error.statusCode,
|
|
160
160
|
body
|
|
161
161
|
);
|
|
162
|
+
if (error.challenge !== void 0) upgraded.challenge = error.challenge;
|
|
163
|
+
return upgraded;
|
|
162
164
|
}
|
|
163
165
|
};
|
|
164
166
|
var ValidationError = class extends AssinafyError {
|
|
@@ -462,6 +464,9 @@ function nextRetryDelayMs(headers, attempt, maxDelayMs = 3e4) {
|
|
|
462
464
|
return Math.min(backoffMs(attempt), maxDelayMs);
|
|
463
465
|
}
|
|
464
466
|
|
|
467
|
+
// src/resources/base.ts
|
|
468
|
+
import { AxiosError } from "axios";
|
|
469
|
+
|
|
465
470
|
// src/support/path.ts
|
|
466
471
|
function encodePathSegment(value) {
|
|
467
472
|
return encodeURIComponent(value).replace(
|
|
@@ -586,7 +591,7 @@ import axios2 from "axios";
|
|
|
586
591
|
// package.json
|
|
587
592
|
var package_default = {
|
|
588
593
|
name: "@assinafy/sdk",
|
|
589
|
-
version: "2.5.
|
|
594
|
+
version: "2.5.2",
|
|
590
595
|
packageManager: "bun@1.4.0",
|
|
591
596
|
description: "TypeScript SDK for Assinafy API - Digital signature platform",
|
|
592
597
|
type: "commonjs",
|
|
@@ -667,7 +672,7 @@ var package_default = {
|
|
|
667
672
|
},
|
|
668
673
|
overrides: {
|
|
669
674
|
esbuild: "0.28.2",
|
|
670
|
-
"brace-expansion": "5.0.
|
|
675
|
+
"brace-expansion": "5.0.12"
|
|
671
676
|
},
|
|
672
677
|
files: [
|
|
673
678
|
"dist",
|
|
@@ -892,7 +897,10 @@ var BaseResource = class {
|
|
|
892
897
|
};
|
|
893
898
|
function assertSuccessful(response) {
|
|
894
899
|
if (response.status < 200 || response.status >= 300) {
|
|
895
|
-
throw
|
|
900
|
+
throw toSdkError(
|
|
901
|
+
new AxiosError("Request failed", void 0, response.config, void 0, response),
|
|
902
|
+
"API request failed"
|
|
903
|
+
);
|
|
896
904
|
}
|
|
897
905
|
return response;
|
|
898
906
|
}
|
|
@@ -1271,6 +1279,28 @@ var AssignmentResource = class extends BaseResource {
|
|
|
1271
1279
|
* `DigitalCertificate` costs two credits, requires the feature plus a
|
|
1272
1280
|
* signer `government_id`, and that signer must be alone in its step.
|
|
1273
1281
|
*
|
|
1282
|
+
* Request body (`application/json`):
|
|
1283
|
+
* ```jsonc
|
|
1284
|
+
* {
|
|
1285
|
+
* "method": "virtual",
|
|
1286
|
+
* "signers": [
|
|
1287
|
+
* {
|
|
1288
|
+
* "id": "signer_example",
|
|
1289
|
+
* "verification_method": "Email",
|
|
1290
|
+
* "notification_methods": [
|
|
1291
|
+
* "Email"
|
|
1292
|
+
* ],
|
|
1293
|
+
* "step": 1
|
|
1294
|
+
* }
|
|
1295
|
+
* ],
|
|
1296
|
+
* "message": "Please sign this document.",
|
|
1297
|
+
* "expires_at": "2027-12-31T23:59:59Z",
|
|
1298
|
+
* "copy_receivers": [
|
|
1299
|
+
* "copy_signer_example"
|
|
1300
|
+
* ]
|
|
1301
|
+
* }
|
|
1302
|
+
* ```
|
|
1303
|
+
*
|
|
1274
1304
|
* @param documentId - The document to request signatures on.
|
|
1275
1305
|
* @param payload - Signers plus optional `method` (defaults to `virtual`),
|
|
1276
1306
|
* `message`, `expires_at`, `copy_receivers` (existing signer IDs, not
|
|
@@ -1389,6 +1419,21 @@ var AssignmentResource = class extends BaseResource {
|
|
|
1389
1419
|
* email notification, and 0.45 for WhatsApp notification; a digital
|
|
1390
1420
|
* certificate charge is added on top of its notification cost.
|
|
1391
1421
|
*
|
|
1422
|
+
* Request body (`application/json`):
|
|
1423
|
+
* ```jsonc
|
|
1424
|
+
* {
|
|
1425
|
+
* "method": "virtual",
|
|
1426
|
+
* "signers": [
|
|
1427
|
+
* {
|
|
1428
|
+
* "verification_method": "Email",
|
|
1429
|
+
* "notification_methods": [
|
|
1430
|
+
* "Email"
|
|
1431
|
+
* ]
|
|
1432
|
+
* }
|
|
1433
|
+
* ]
|
|
1434
|
+
* }
|
|
1435
|
+
* ```
|
|
1436
|
+
*
|
|
1392
1437
|
* @param documentId - The document the assignment would be created on.
|
|
1393
1438
|
* @param payload - `method` plus channel-only signer descriptors and/or
|
|
1394
1439
|
* `collect`-mode `entries`. Create-only fields and signer IDs are not part
|
|
@@ -1444,6 +1489,13 @@ var AssignmentResource = class extends BaseResource {
|
|
|
1444
1489
|
* is retained as a compatibility value and, unlike ordinary nullable
|
|
1445
1490
|
* inputs, is intentionally not stripped from the body.
|
|
1446
1491
|
*
|
|
1492
|
+
* Request body (`application/json`):
|
|
1493
|
+
* ```jsonc
|
|
1494
|
+
* {
|
|
1495
|
+
* "expires_at": "2027-12-31T23:59:59Z"
|
|
1496
|
+
* }
|
|
1497
|
+
* ```
|
|
1498
|
+
*
|
|
1447
1499
|
* @param documentId - The document the assignment belongs to.
|
|
1448
1500
|
* @param assignmentId - The assignment to update.
|
|
1449
1501
|
* @param expiresAt - New expiry as an ISO-8601 date/time string. `null` is
|
|
@@ -1859,6 +1911,13 @@ var DocumentResource = class extends BaseResource {
|
|
|
1859
1911
|
* {@link DocumentResource.upload} — that avoids the extra round-trip and
|
|
1860
1912
|
* the processing race entirely.
|
|
1861
1913
|
*
|
|
1914
|
+
* Request body (`application/json`):
|
|
1915
|
+
* ```jsonc
|
|
1916
|
+
* {
|
|
1917
|
+
* "name": "Service agreement.pdf"
|
|
1918
|
+
* }
|
|
1919
|
+
* ```
|
|
1920
|
+
*
|
|
1862
1921
|
* @param documentId - The document to rename.
|
|
1863
1922
|
* @param name - The new display name (max 255 chars), e.g.
|
|
1864
1923
|
* `'Service agreement.pdf'`. The API removes diacritics and replaces
|
|
@@ -2269,6 +2328,15 @@ var DocumentResource = class extends BaseResource {
|
|
|
2269
2328
|
* overwrites the existing set — use
|
|
2270
2329
|
* {@link DocumentResource.addTags} to append.
|
|
2271
2330
|
*
|
|
2331
|
+
* Request body (`application/json`):
|
|
2332
|
+
* ```jsonc
|
|
2333
|
+
* {
|
|
2334
|
+
* "tags": [
|
|
2335
|
+
* "tag_example"
|
|
2336
|
+
* ]
|
|
2337
|
+
* }
|
|
2338
|
+
* ```
|
|
2339
|
+
*
|
|
2272
2340
|
* @param documentId - The document to retag.
|
|
2273
2341
|
* @param tags - The complete desired set of tag IDs (`[]` clears all).
|
|
2274
2342
|
* @param accountId - Override the client's default account ID.
|
|
@@ -2311,6 +2379,15 @@ var DocumentResource = class extends BaseResource {
|
|
|
2311
2379
|
* present is a no-op. To replace the whole set instead, use
|
|
2312
2380
|
* {@link DocumentResource.replaceTags}.
|
|
2313
2381
|
*
|
|
2382
|
+
* Request body (`application/json`):
|
|
2383
|
+
* ```jsonc
|
|
2384
|
+
* {
|
|
2385
|
+
* "tags": [
|
|
2386
|
+
* "tag_example"
|
|
2387
|
+
* ]
|
|
2388
|
+
* }
|
|
2389
|
+
* ```
|
|
2390
|
+
*
|
|
2314
2391
|
* @param documentId - The document to tag.
|
|
2315
2392
|
* @param tags - Tag IDs to attach (must be non-empty).
|
|
2316
2393
|
* @param accountId - Override the client's default account ID.
|
|
@@ -2386,6 +2463,35 @@ var DocumentResource = class extends BaseResource {
|
|
|
2386
2463
|
* `options` may add `name`, `message`, `expires_at`, `editor_fields`, and
|
|
2387
2464
|
* tag names in `tags` (unknown names are created automatically).
|
|
2388
2465
|
*
|
|
2466
|
+
* Request body (`application/json`):
|
|
2467
|
+
* ```jsonc
|
|
2468
|
+
* {
|
|
2469
|
+
* "signers": [
|
|
2470
|
+
* {
|
|
2471
|
+
* "role_id": "signing_role_example",
|
|
2472
|
+
* "id": "signer_example",
|
|
2473
|
+
* "verification_method": "Email",
|
|
2474
|
+
* "notification_methods": [
|
|
2475
|
+
* "Email"
|
|
2476
|
+
* ],
|
|
2477
|
+
* "step": 1
|
|
2478
|
+
* }
|
|
2479
|
+
* ],
|
|
2480
|
+
* "name": "Service agreement.pdf",
|
|
2481
|
+
* "message": "Please sign this document.",
|
|
2482
|
+
* "expires_at": "2027-12-31T23:59:59Z",
|
|
2483
|
+
* "editor_fields": [
|
|
2484
|
+
* {
|
|
2485
|
+
* "field_id": "editor_field_example",
|
|
2486
|
+
* "value": "Example Company"
|
|
2487
|
+
* }
|
|
2488
|
+
* ],
|
|
2489
|
+
* "tags": [
|
|
2490
|
+
* "Contracts"
|
|
2491
|
+
* ]
|
|
2492
|
+
* }
|
|
2493
|
+
* ```
|
|
2494
|
+
*
|
|
2389
2495
|
* @param templateId - The template to instantiate.
|
|
2390
2496
|
* @param signers - Role-to-signer bindings (each with `role_id` and `id`,
|
|
2391
2497
|
* plus optional `verification_method`, `notification_methods`, `step`).
|
|
@@ -2469,6 +2575,21 @@ var DocumentResource = class extends BaseResource {
|
|
|
2469
2575
|
* `DigitalCertificate` adds two credits per signer and has the same feature,
|
|
2470
2576
|
* `government_id`, and signing-step prerequisites as document creation.
|
|
2471
2577
|
*
|
|
2578
|
+
* Request body (`application/json`):
|
|
2579
|
+
* ```jsonc
|
|
2580
|
+
* {
|
|
2581
|
+
* "signers": [
|
|
2582
|
+
* {
|
|
2583
|
+
* "role_id": "signing_role_example",
|
|
2584
|
+
* "verification_method": "Email",
|
|
2585
|
+
* "notification_methods": [
|
|
2586
|
+
* "Email"
|
|
2587
|
+
* ]
|
|
2588
|
+
* }
|
|
2589
|
+
* ]
|
|
2590
|
+
* }
|
|
2591
|
+
* ```
|
|
2592
|
+
*
|
|
2472
2593
|
* @param templateId - The template that would be instantiated.
|
|
2473
2594
|
* @param signers - One channel descriptor per template role. Cost requests
|
|
2474
2595
|
* use only `role_id`, `verification_method`, and `notification_methods`;
|
|
@@ -2844,6 +2965,19 @@ var SignerResource = class extends BaseResource {
|
|
|
2844
2965
|
* A reused signer is returned unchanged; this method does not overwrite its
|
|
2845
2966
|
* existing name, phone, CPF, or metadata with the create payload.
|
|
2846
2967
|
*
|
|
2968
|
+
* Request body (`application/json`):
|
|
2969
|
+
* ```jsonc
|
|
2970
|
+
* {
|
|
2971
|
+
* "full_name": "Example Signer",
|
|
2972
|
+
* "email": "signer@example.com",
|
|
2973
|
+
* "whatsapp_phone_number": "+5548999990000",
|
|
2974
|
+
* "cpf": "39053344705",
|
|
2975
|
+
* "metadata": {
|
|
2976
|
+
* "reference": "customer_example"
|
|
2977
|
+
* }
|
|
2978
|
+
* }
|
|
2979
|
+
* ```
|
|
2980
|
+
*
|
|
2847
2981
|
* @param payload - The signer to create. The official fields are required
|
|
2848
2982
|
* `full_name` plus optional `email` and E.164 `whatsapp_phone_number`.
|
|
2849
2983
|
* `phone`, `cpf`, and `metadata` are compatibility extensions; the SDK
|
|
@@ -2995,6 +3129,16 @@ var SignerResource = class extends BaseResource {
|
|
|
2995
3129
|
* while it belongs to an in-flight document; changing an unverified channel
|
|
2996
3130
|
* rotates its access/verification codes, so resend the notification.
|
|
2997
3131
|
*
|
|
3132
|
+
* Request body (`application/json`):
|
|
3133
|
+
* ```jsonc
|
|
3134
|
+
* {
|
|
3135
|
+
* "full_name": "Example Signer",
|
|
3136
|
+
* "email": "signer@example.com",
|
|
3137
|
+
* "whatsapp_phone_number": "+5548999990000",
|
|
3138
|
+
* "government_id": "39053344705"
|
|
3139
|
+
* }
|
|
3140
|
+
* ```
|
|
3141
|
+
*
|
|
2998
3142
|
* @param signerId - The signer to update.
|
|
2999
3143
|
* @param payload - Fields to change. The official `government_id` field and
|
|
3000
3144
|
* legacy `cpf` extension are stripped to digits before sending.
|
|
@@ -3214,6 +3358,16 @@ var WorkspaceResource = class extends BaseResource {
|
|
|
3214
3358
|
/**
|
|
3215
3359
|
* Create a new workspace (`POST /accounts`).
|
|
3216
3360
|
*
|
|
3361
|
+
* Request body (`application/json`):
|
|
3362
|
+
* ```jsonc
|
|
3363
|
+
* {
|
|
3364
|
+
* "name": "Example Workspace",
|
|
3365
|
+
* "notification_sender_type": "Account",
|
|
3366
|
+
* "primary_color": "336699",
|
|
3367
|
+
* "secondary_color": "ffffff"
|
|
3368
|
+
* }
|
|
3369
|
+
* ```
|
|
3370
|
+
*
|
|
3217
3371
|
* @param payload - Official fields are workspace `name` (required) and
|
|
3218
3372
|
* optional `notification_sender_type` (`User` or `Account`). Optional brand
|
|
3219
3373
|
* colours use six hex characters without
|
|
@@ -3494,6 +3648,16 @@ var WorkspaceResource = class extends BaseResource {
|
|
|
3494
3648
|
/**
|
|
3495
3649
|
* Update a workspace (`PUT /accounts/{accountId}`).
|
|
3496
3650
|
*
|
|
3651
|
+
* Request body (`application/json`):
|
|
3652
|
+
* ```jsonc
|
|
3653
|
+
* {
|
|
3654
|
+
* "name": "Example Workspace",
|
|
3655
|
+
* "notification_sender_type": "Account",
|
|
3656
|
+
* "primary_color": "336699",
|
|
3657
|
+
* "secondary_color": null
|
|
3658
|
+
* }
|
|
3659
|
+
* ```
|
|
3660
|
+
*
|
|
3497
3661
|
* @param accountId - The workspace to update.
|
|
3498
3662
|
* @param payload - Official fields are `name` and
|
|
3499
3663
|
* `notification_sender_type` (`User` or `Account`). Brand colours use six
|
|
@@ -3554,6 +3718,13 @@ var WorkspaceResource = class extends BaseResource {
|
|
|
3554
3718
|
* proceeds with deletion; it is not documented as a blanket override for
|
|
3555
3719
|
* unrelated restrictions. The flag is sent in the request body.
|
|
3556
3720
|
*
|
|
3721
|
+
* Request body (`application/json`):
|
|
3722
|
+
* ```jsonc
|
|
3723
|
+
* {
|
|
3724
|
+
* "force": true
|
|
3725
|
+
* }
|
|
3726
|
+
* ```
|
|
3727
|
+
*
|
|
3557
3728
|
* @param accountId - The workspace to delete.
|
|
3558
3729
|
* @param options - Set `force: true` to cancel an active paid subscription
|
|
3559
3730
|
* and proceed with deletion.
|
|
@@ -3624,6 +3795,19 @@ var WebhookResource = class extends BaseResource {
|
|
|
3624
3795
|
* `signer_rejected_document`, `document_processing_failed`).
|
|
3625
3796
|
* OAuth tokens need the `webhooks:write` scope.
|
|
3626
3797
|
*
|
|
3798
|
+
* Request body (`application/json`):
|
|
3799
|
+
* ```jsonc
|
|
3800
|
+
* {
|
|
3801
|
+
* "events": [
|
|
3802
|
+
* "document_ready",
|
|
3803
|
+
* "document_prepared"
|
|
3804
|
+
* ],
|
|
3805
|
+
* "is_active": true,
|
|
3806
|
+
* "url": "https://myapp.example.com/webhooks/assinafy",
|
|
3807
|
+
* "email": "operations@example.com"
|
|
3808
|
+
* }
|
|
3809
|
+
* ```
|
|
3810
|
+
*
|
|
3627
3811
|
* @param payload - Subscription details. `url` and `email` are required;
|
|
3628
3812
|
* `events` defaults to {@link DEFAULT_WEBHOOK_EVENTS} and `is_active`
|
|
3629
3813
|
* defaults to `true`.
|
|
@@ -4147,6 +4331,14 @@ var TemplateResource = class extends BaseResource {
|
|
|
4147
4331
|
* `undefined` keys before sending. Unlike uploads, `name` here is a plain
|
|
4148
4332
|
* display name and is **not** forced to end in `.pdf`.
|
|
4149
4333
|
*
|
|
4334
|
+
* Request body (`application/json`):
|
|
4335
|
+
* ```jsonc
|
|
4336
|
+
* {
|
|
4337
|
+
* "name": "Service agreement.pdf",
|
|
4338
|
+
* "message": "Please sign this document."
|
|
4339
|
+
* }
|
|
4340
|
+
* ```
|
|
4341
|
+
*
|
|
4150
4342
|
* @param templateId - The template to update.
|
|
4151
4343
|
* @param payload - `name` and/or `message`; both optional.
|
|
4152
4344
|
* @param accountId - Override the client's default account ID.
|
|
@@ -4327,6 +4519,14 @@ var TagResource = class extends BaseResource {
|
|
|
4327
4519
|
* and `'ff8800'` both persist as `'ff8800'`. Omit `color`
|
|
4328
4520
|
* (or pass `null`) for no color.
|
|
4329
4521
|
*
|
|
4522
|
+
* Request body (`application/json`):
|
|
4523
|
+
* ```jsonc
|
|
4524
|
+
* {
|
|
4525
|
+
* "name": "Contracts",
|
|
4526
|
+
* "color": "ff8800"
|
|
4527
|
+
* }
|
|
4528
|
+
* ```
|
|
4529
|
+
*
|
|
4330
4530
|
* @param payload - `name` (required, max 64 characters; trimmed with
|
|
4331
4531
|
* internal whitespace collapsed) and optional `color`.
|
|
4332
4532
|
* @param accountId - Override the client's default account ID.
|
|
@@ -4376,6 +4576,14 @@ var TagResource = class extends BaseResource {
|
|
|
4376
4576
|
* leading `#` on `color` is accepted and stripped by the API
|
|
4377
4577
|
* (`'#112233'` → `'112233'`).
|
|
4378
4578
|
*
|
|
4579
|
+
* Request body (`application/json`):
|
|
4580
|
+
* ```jsonc
|
|
4581
|
+
* {
|
|
4582
|
+
* "name": "Signed contracts",
|
|
4583
|
+
* "color": null
|
|
4584
|
+
* }
|
|
4585
|
+
* ```
|
|
4586
|
+
*
|
|
4379
4587
|
* @param tagId - The tag to update.
|
|
4380
4588
|
* @param payload - `name` and/or `color`. `color: null` clears the color;
|
|
4381
4589
|
* omit a field to leave it unchanged.
|
|
@@ -4534,6 +4742,14 @@ var AuthenticationResource = class extends BaseResource {
|
|
|
4534
4742
|
* `X-Api-Key` (see {@link AuthenticationResource.createApiKey}) instead of
|
|
4535
4743
|
* storing a password.
|
|
4536
4744
|
*
|
|
4745
|
+
* Request body (`application/json`):
|
|
4746
|
+
* ```jsonc
|
|
4747
|
+
* {
|
|
4748
|
+
* "email": "user@example.com",
|
|
4749
|
+
* "password": "example-password"
|
|
4750
|
+
* }
|
|
4751
|
+
* ```
|
|
4752
|
+
*
|
|
4537
4753
|
* @param email - The user's email address, e.g. `'user@example.com'`.
|
|
4538
4754
|
* @param password - The user's password.
|
|
4539
4755
|
* @returns An {@link ILoginResponse} with the access token, user, and
|
|
@@ -4589,6 +4805,15 @@ var AuthenticationResource = class extends BaseResource {
|
|
|
4589
4805
|
* Assinafy JWT. Returns the same {@link ILoginResponse} shape as
|
|
4590
4806
|
* {@link AuthenticationResource.login}.
|
|
4591
4807
|
*
|
|
4808
|
+
* Request body (`application/json`):
|
|
4809
|
+
* ```jsonc
|
|
4810
|
+
* {
|
|
4811
|
+
* "provider": "google",
|
|
4812
|
+
* "token": "provider_token_example",
|
|
4813
|
+
* "has_accepted_terms": true
|
|
4814
|
+
* }
|
|
4815
|
+
* ```
|
|
4816
|
+
*
|
|
4592
4817
|
* @param payload - The social-login body.
|
|
4593
4818
|
* @param payload.provider - OAuth provider; currently exactly `'google'`.
|
|
4594
4819
|
* @param payload.token - The provider-issued OAuth/ID token.
|
|
@@ -4663,6 +4888,14 @@ var AuthenticationResource = class extends BaseResource {
|
|
|
4663
4888
|
* The response is the standard status/message acknowledgement with no data,
|
|
4664
4889
|
* so this method resolves to `void`.
|
|
4665
4890
|
*
|
|
4891
|
+
* Request body (`application/json`):
|
|
4892
|
+
* ```jsonc
|
|
4893
|
+
* {
|
|
4894
|
+
* "provider": "google",
|
|
4895
|
+
* "token": "provider_token_example"
|
|
4896
|
+
* }
|
|
4897
|
+
* ```
|
|
4898
|
+
*
|
|
4666
4899
|
* @param payload - Social provider and provider-issued access/ID token.
|
|
4667
4900
|
* @returns Resolves when the API acknowledges that the identity was linked.
|
|
4668
4901
|
* @throws {ValidationError} If `provider` is not `google` or `token` is empty.
|
|
@@ -4699,6 +4932,13 @@ var AuthenticationResource = class extends BaseResource {
|
|
|
4699
4932
|
* a masked value. Calling this again rotates the key, invalidating the
|
|
4700
4933
|
* previous one.
|
|
4701
4934
|
*
|
|
4935
|
+
* Request body (`application/json`):
|
|
4936
|
+
* ```jsonc
|
|
4937
|
+
* {
|
|
4938
|
+
* "password": "example-password"
|
|
4939
|
+
* }
|
|
4940
|
+
* ```
|
|
4941
|
+
*
|
|
4702
4942
|
* @param password - The current user's password, required to authorize
|
|
4703
4943
|
* key generation.
|
|
4704
4944
|
* @returns An {@link IApiKeyResponse} containing the new key. Response
|
|
@@ -4786,6 +5026,15 @@ var AuthenticationResource = class extends BaseResource {
|
|
|
4786
5026
|
* Requires the current password as a confirmation. On success the API
|
|
4787
5027
|
* echoes back the affected `email`.
|
|
4788
5028
|
*
|
|
5029
|
+
* Request body (`application/json`):
|
|
5030
|
+
* ```jsonc
|
|
5031
|
+
* {
|
|
5032
|
+
* "email": "user@example.com",
|
|
5033
|
+
* "password": "example-password",
|
|
5034
|
+
* "new_password": "new-example-password"
|
|
5035
|
+
* }
|
|
5036
|
+
* ```
|
|
5037
|
+
*
|
|
4789
5038
|
* @param payload - The change-password body.
|
|
4790
5039
|
* @param payload.email - The user's email address.
|
|
4791
5040
|
* @param payload.password - The current password.
|
|
@@ -4832,6 +5081,13 @@ var AuthenticationResource = class extends BaseResource {
|
|
|
4832
5081
|
* Triggers Assinafy to email a reset link/token to the given address.
|
|
4833
5082
|
* Complete the flow with {@link AuthenticationResource.resetPassword}.
|
|
4834
5083
|
*
|
|
5084
|
+
* Request body (`application/json`):
|
|
5085
|
+
* ```jsonc
|
|
5086
|
+
* {
|
|
5087
|
+
* "email": "user@example.com"
|
|
5088
|
+
* }
|
|
5089
|
+
* ```
|
|
5090
|
+
*
|
|
4835
5091
|
* @param email - The email address to send the reset link to.
|
|
4836
5092
|
* @returns `{ email }` — the address the reset link was sent to. Response
|
|
4837
5093
|
* shape:
|
|
@@ -4863,6 +5119,15 @@ var AuthenticationResource = class extends BaseResource {
|
|
|
4863
5119
|
* {@link AuthenticationResource.requestPasswordReset} and sets the new
|
|
4864
5120
|
* password. On success the API echoes back the affected `email`.
|
|
4865
5121
|
*
|
|
5122
|
+
* Request body (`application/json`):
|
|
5123
|
+
* ```jsonc
|
|
5124
|
+
* {
|
|
5125
|
+
* "email": "user@example.com",
|
|
5126
|
+
* "token": "reset_token_example",
|
|
5127
|
+
* "new_password": "new-example-password"
|
|
5128
|
+
* }
|
|
5129
|
+
* ```
|
|
5130
|
+
*
|
|
4866
5131
|
* @param payload - The reset-password body.
|
|
4867
5132
|
* @param payload.email - The user's email address.
|
|
4868
5133
|
* @param payload.token - The reset token from the emailed link. The current
|
|
@@ -5085,8 +5350,8 @@ var OAuthResource = class extends BaseResource {
|
|
|
5085
5350
|
* ```ts
|
|
5086
5351
|
* const request = await client.oauth.createAuthorizationUrl({
|
|
5087
5352
|
* clientId: process.env.ASSINAFY_CLIENT_ID!,
|
|
5088
|
-
* redirectUri: 'https://myapp.com/oauth/callback',
|
|
5089
|
-
* scopes: ['documents:read', 'documents:write', 'offline_access'],
|
|
5353
|
+
* redirectUri: 'https://myapp.example.com/oauth/callback',
|
|
5354
|
+
* scopes: ['documents:read', 'documents:write', 'account:read', 'offline_access'],
|
|
5090
5355
|
* });
|
|
5091
5356
|
* session.oauth = request;
|
|
5092
5357
|
* response.redirect(request.url);
|
|
@@ -5173,8 +5438,8 @@ var OAuthResource = class extends BaseResource {
|
|
|
5173
5438
|
* ```
|
|
5174
5439
|
* @throws {ValidationError} If `state` is missing or does not match, `iss`
|
|
5175
5440
|
* is absent or disagrees with the expected issuer, or a successful response
|
|
5176
|
-
* carries no `code
|
|
5177
|
-
*
|
|
5441
|
+
* carries no `code`, or a protocol parameter appears more than once.
|
|
5442
|
+
* Reject such responses without exchanging the code.
|
|
5178
5443
|
* @throws {OAuthError} If the server returned `error` (e.g.
|
|
5179
5444
|
* `access_denied`, `invalid_scope`, `invalid_request`,
|
|
5180
5445
|
* `unsupported_response_type`, `invalid_target`).
|
|
@@ -5187,9 +5452,9 @@ var OAuthResource = class extends BaseResource {
|
|
|
5187
5452
|
* const tokens = await client.oauth.exchangeCode({
|
|
5188
5453
|
* code,
|
|
5189
5454
|
* codeVerifier: stored.codeVerifier,
|
|
5190
|
-
* redirectUri: 'https://myapp.com/oauth/callback',
|
|
5455
|
+
* redirectUri: 'https://myapp.example.com/oauth/callback',
|
|
5191
5456
|
* clientId: process.env.ASSINAFY_CLIENT_ID!,
|
|
5192
|
-
* clientSecret: process.env.ASSINAFY_CLIENT_SECRET
|
|
5457
|
+
* clientSecret: process.env.ASSINAFY_CLIENT_SECRET!,
|
|
5193
5458
|
* });
|
|
5194
5459
|
* });
|
|
5195
5460
|
* ```
|
|
@@ -5198,6 +5463,11 @@ var OAuthResource = class extends BaseResource {
|
|
|
5198
5463
|
assertRecord(expected, "expected authorization request");
|
|
5199
5464
|
assertNonEmptyString(expected.state, "expected.state");
|
|
5200
5465
|
const query = toSearchParams(params);
|
|
5466
|
+
for (const key of ["state", "iss", "code", "error", "error_description"]) {
|
|
5467
|
+
if (query.getAll(key).length > 1) {
|
|
5468
|
+
throw new ValidationError(`OAuth callback must not repeat ${key}`);
|
|
5469
|
+
}
|
|
5470
|
+
}
|
|
5201
5471
|
const state = query.get("state");
|
|
5202
5472
|
if (state === null || !constantTimeEquals(state, expected.state)) {
|
|
5203
5473
|
throw new ValidationError(
|
|
@@ -5234,6 +5504,12 @@ var OAuthResource = class extends BaseResource {
|
|
|
5234
5504
|
* a browser. Every value must match the authorization request exactly, or
|
|
5235
5505
|
* the API answers `invalid_grant`.
|
|
5236
5506
|
*
|
|
5507
|
+
* Request body (`application/x-www-form-urlencoded`; omit `client_secret`
|
|
5508
|
+
* for public applications):
|
|
5509
|
+
* ```text
|
|
5510
|
+
* 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
|
|
5511
|
+
* ```
|
|
5512
|
+
*
|
|
5237
5513
|
* @param options - Exchange options.
|
|
5238
5514
|
* @param options.code - The code from
|
|
5239
5515
|
* {@link OAuthResource.readAuthorizationCallback}.
|
|
@@ -5269,9 +5545,9 @@ var OAuthResource = class extends BaseResource {
|
|
|
5269
5545
|
* const tokens = await client.oauth.exchangeCode({
|
|
5270
5546
|
* code,
|
|
5271
5547
|
* codeVerifier: session.oauth.codeVerifier,
|
|
5272
|
-
* redirectUri: 'https://myapp.com/oauth/callback',
|
|
5548
|
+
* redirectUri: 'https://myapp.example.com/oauth/callback',
|
|
5273
5549
|
* clientId: process.env.ASSINAFY_CLIENT_ID!,
|
|
5274
|
-
* clientSecret: process.env.ASSINAFY_CLIENT_SECRET
|
|
5550
|
+
* clientSecret: process.env.ASSINAFY_CLIENT_SECRET!,
|
|
5275
5551
|
* });
|
|
5276
5552
|
* ```
|
|
5277
5553
|
*/
|
|
@@ -5307,6 +5583,12 @@ var OAuthResource = class extends BaseResource {
|
|
|
5307
5583
|
* only expires if it goes 30 days without a refresh; after that the user
|
|
5308
5584
|
* has to reconnect.
|
|
5309
5585
|
*
|
|
5586
|
+
* Request body (`application/x-www-form-urlencoded`; omit `client_secret`
|
|
5587
|
+
* for public applications):
|
|
5588
|
+
* ```text
|
|
5589
|
+
* 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
|
|
5590
|
+
* ```
|
|
5591
|
+
*
|
|
5310
5592
|
* @param options - Refresh options.
|
|
5311
5593
|
* @param options.refreshToken - The current refresh token.
|
|
5312
5594
|
* @param options.clientId - The application's `client_id`.
|
|
@@ -5337,7 +5619,7 @@ var OAuthResource = class extends BaseResource {
|
|
|
5337
5619
|
* const tokens = await client.oauth.refreshToken({
|
|
5338
5620
|
* refreshToken: connection.refreshToken,
|
|
5339
5621
|
* clientId: process.env.ASSINAFY_CLIENT_ID!,
|
|
5340
|
-
* clientSecret: process.env.ASSINAFY_CLIENT_SECRET
|
|
5622
|
+
* clientSecret: process.env.ASSINAFY_CLIENT_SECRET!,
|
|
5341
5623
|
* });
|
|
5342
5624
|
* await connection.save({ refreshToken: tokens.refresh_token });
|
|
5343
5625
|
* ```
|
|
@@ -5391,7 +5673,7 @@ var OAuthResource = class extends BaseResource {
|
|
|
5391
5673
|
* token: connection.refreshToken,
|
|
5392
5674
|
* tokenTypeHint: 'refresh_token',
|
|
5393
5675
|
* clientId: process.env.ASSINAFY_CLIENT_ID!,
|
|
5394
|
-
* clientSecret: process.env.ASSINAFY_CLIENT_SECRET
|
|
5676
|
+
* clientSecret: process.env.ASSINAFY_CLIENT_SECRET!,
|
|
5395
5677
|
* });
|
|
5396
5678
|
* ```
|
|
5397
5679
|
*/
|
|
@@ -5434,8 +5716,8 @@ var OAuthResource = class extends BaseResource {
|
|
|
5434
5716
|
* "email_verified": true
|
|
5435
5717
|
* }
|
|
5436
5718
|
* ```
|
|
5437
|
-
* `sub` is the stable user identifier;
|
|
5438
|
-
* was not granted.
|
|
5719
|
+
* `sub` is the stable user identifier; other claims may be omitted or
|
|
5720
|
+
* `null` when their scope was not granted.
|
|
5439
5721
|
* @throws {ValidationError} If `accessToken` is supplied but empty.
|
|
5440
5722
|
* @throws {ApiError} `401` when the token is missing, expired or revoked;
|
|
5441
5723
|
* `403` when the `openid` scope was not granted — its `WWW-Authenticate`
|
|
@@ -5605,8 +5887,9 @@ function toSearchParams(params) {
|
|
|
5605
5887
|
assertRecord(params, "callback parameters");
|
|
5606
5888
|
const search = new URLSearchParams();
|
|
5607
5889
|
for (const [key, value] of Object.entries(params)) {
|
|
5608
|
-
const
|
|
5609
|
-
|
|
5890
|
+
for (const item of Array.isArray(value) ? value : [value]) {
|
|
5891
|
+
if (typeof item === "string") search.append(key, item);
|
|
5892
|
+
}
|
|
5610
5893
|
}
|
|
5611
5894
|
return search;
|
|
5612
5895
|
}
|
|
@@ -5616,6 +5899,17 @@ var FieldsResource = class extends BaseResource {
|
|
|
5616
5899
|
/**
|
|
5617
5900
|
* Create a field definition (`POST /accounts/{accountId}/fields`).
|
|
5618
5901
|
*
|
|
5902
|
+
* Request body (`application/json`):
|
|
5903
|
+
* ```jsonc
|
|
5904
|
+
* {
|
|
5905
|
+
* "type": "text",
|
|
5906
|
+
* "name": "Reference",
|
|
5907
|
+
* "regex": null,
|
|
5908
|
+
* "is_required": true,
|
|
5909
|
+
* "is_active": true
|
|
5910
|
+
* }
|
|
5911
|
+
* ```
|
|
5912
|
+
*
|
|
5619
5913
|
* @param payload - The field to create. `type` and `name` are required;
|
|
5620
5914
|
* `type` must be one of the platform field types (see
|
|
5621
5915
|
* {@link FieldsResource.listTypes}); `regex` may be a string or `null`,
|
|
@@ -5760,6 +6054,15 @@ var FieldsResource = class extends BaseResource {
|
|
|
5760
6054
|
* Update a field definition
|
|
5761
6055
|
* (`PUT /accounts/{accountId}/fields/{fieldId}`).
|
|
5762
6056
|
*
|
|
6057
|
+
* Request body (`application/json`):
|
|
6058
|
+
* ```jsonc
|
|
6059
|
+
* {
|
|
6060
|
+
* "name": "Customer reference",
|
|
6061
|
+
* "regex": null,
|
|
6062
|
+
* "is_active": true
|
|
6063
|
+
* }
|
|
6064
|
+
* ```
|
|
6065
|
+
*
|
|
5763
6066
|
* @param fieldId - The field definition to update.
|
|
5764
6067
|
* @param payload - Fields are `name`, nullable `regex`, and `is_active`;
|
|
5765
6068
|
* `type` and `is_required` are compatibility extensions.
|
|
@@ -5848,6 +6151,13 @@ var FieldsResource = class extends BaseResource {
|
|
|
5848
6151
|
* `signerAccessCode` is a compatibility query and is sent as
|
|
5849
6152
|
* `signer-access-code` when supplied.
|
|
5850
6153
|
*
|
|
6154
|
+
* Request body (`application/json`):
|
|
6155
|
+
* ```jsonc
|
|
6156
|
+
* {
|
|
6157
|
+
* "value": "Example value"
|
|
6158
|
+
* }
|
|
6159
|
+
* ```
|
|
6160
|
+
*
|
|
5851
6161
|
* @param fieldId - The field definition to validate against.
|
|
5852
6162
|
* @param value - The value to check (validated against the field's
|
|
5853
6163
|
* type/regex). Sent as `{ value }` in the request body.
|
|
@@ -5900,6 +6210,16 @@ var FieldsResource = class extends BaseResource {
|
|
|
5900
6210
|
* same compatibility extension described on
|
|
5901
6211
|
* {@link FieldsResource.validate}.
|
|
5902
6212
|
*
|
|
6213
|
+
* Request body (`application/json`):
|
|
6214
|
+
* ```jsonc
|
|
6215
|
+
* [
|
|
6216
|
+
* {
|
|
6217
|
+
* "field_id": "field_example",
|
|
6218
|
+
* "value": "Example value"
|
|
6219
|
+
* }
|
|
6220
|
+
* ]
|
|
6221
|
+
* ```
|
|
6222
|
+
*
|
|
5903
6223
|
* @param entries - Non-empty array of `{ field_id, value }` pairs.
|
|
5904
6224
|
* @param options - Account override and optional legacy `signerAccessCode`.
|
|
5905
6225
|
* @returns One validation result per entry. Response shape:
|
|
@@ -6227,6 +6547,15 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
6227
6547
|
* The `document_ids` array goes in the request body; the access code
|
|
6228
6548
|
* authenticates via the `signer-access-code` query param.
|
|
6229
6549
|
*
|
|
6550
|
+
* Request body (`application/json`):
|
|
6551
|
+
* ```jsonc
|
|
6552
|
+
* {
|
|
6553
|
+
* "document_ids": [
|
|
6554
|
+
* "document_example"
|
|
6555
|
+
* ]
|
|
6556
|
+
* }
|
|
6557
|
+
* ```
|
|
6558
|
+
*
|
|
6230
6559
|
* @param documentIds - Non-empty array of document IDs to sign.
|
|
6231
6560
|
* @param signerAccessCode - The signer's access code, from their signing link.
|
|
6232
6561
|
* @returns Resolves when the API acknowledges the operation. The documented
|
|
@@ -6266,6 +6595,16 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
6266
6595
|
* Both `document_ids` and `decline_reason` go in the request body; the access
|
|
6267
6596
|
* code authenticates via the `signer-access-code` query param.
|
|
6268
6597
|
*
|
|
6598
|
+
* Request body (`application/json`):
|
|
6599
|
+
* ```jsonc
|
|
6600
|
+
* {
|
|
6601
|
+
* "document_ids": [
|
|
6602
|
+
* "document_example"
|
|
6603
|
+
* ],
|
|
6604
|
+
* "decline_reason": "The document needs a correction."
|
|
6605
|
+
* }
|
|
6606
|
+
* ```
|
|
6607
|
+
*
|
|
6269
6608
|
* @param documentIds - Non-empty array of document IDs to decline.
|
|
6270
6609
|
* @param declineReason - Free-text reason shown to the sender (required).
|
|
6271
6610
|
* @param signerAccessCode - The signer's access code, from their signing link.
|
|
@@ -6381,6 +6720,13 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
6381
6720
|
* **body carries only `verification-code`** (putting the access code in the
|
|
6382
6721
|
* body leaves the request unauthenticated → `401`).
|
|
6383
6722
|
*
|
|
6723
|
+
* Request body (`application/json`):
|
|
6724
|
+
* ```jsonc
|
|
6725
|
+
* {
|
|
6726
|
+
* "verification-code": "123456"
|
|
6727
|
+
* }
|
|
6728
|
+
* ```
|
|
6729
|
+
*
|
|
6384
6730
|
* @param payload - `signerAccessCode` (the signing-link code) and
|
|
6385
6731
|
* `verificationCode` (the OTP the signer received).
|
|
6386
6732
|
* @returns Resolves when the API acknowledges the operation. The response
|
|
@@ -6599,6 +6945,18 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
6599
6945
|
* first. Digital Certificate signers cannot use this endpoint; use the
|
|
6600
6946
|
* certificate start/complete API flow instead.
|
|
6601
6947
|
*
|
|
6948
|
+
* Request body (`application/json`):
|
|
6949
|
+
* ```jsonc
|
|
6950
|
+
* [
|
|
6951
|
+
* {
|
|
6952
|
+
* "itemId": "item_example",
|
|
6953
|
+
* "fieldId": "field_example",
|
|
6954
|
+
* "pageId": "page_example",
|
|
6955
|
+
* "value": "Example Signer"
|
|
6956
|
+
* }
|
|
6957
|
+
* ]
|
|
6958
|
+
* ```
|
|
6959
|
+
*
|
|
6602
6960
|
* @param documentId - The document being signed.
|
|
6603
6961
|
* @param assignmentId - The assignment within that document.
|
|
6604
6962
|
* @param signerAccessCode - The signer's access code, from their signing link.
|
|
@@ -6656,6 +7014,13 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
6656
7014
|
* delete the document via `documents.delete`; there is no workspace "cancel"
|
|
6657
7015
|
* endpoint.)
|
|
6658
7016
|
*
|
|
7017
|
+
* Request body (`application/json`):
|
|
7018
|
+
* ```jsonc
|
|
7019
|
+
* {
|
|
7020
|
+
* "decline_reason": "The document needs a correction."
|
|
7021
|
+
* }
|
|
7022
|
+
* ```
|
|
7023
|
+
*
|
|
6659
7024
|
* @param documentId - The document being declined.
|
|
6660
7025
|
* @param assignmentId - The assignment within that document.
|
|
6661
7026
|
* @param signerAccessCode - The signer's access code, from their signing link.
|
|
@@ -6842,6 +7207,21 @@ var UserResource = class extends BaseResource {
|
|
|
6842
7207
|
* (`PUT /users/self/notification-preferences`). Omitted keys retain their
|
|
6843
7208
|
* current values; account/security e-mails are not configurable here.
|
|
6844
7209
|
*
|
|
7210
|
+
* Request body (`application/json`):
|
|
7211
|
+
* ```jsonc
|
|
7212
|
+
* {
|
|
7213
|
+
* "DocumentCompleted": true,
|
|
7214
|
+
* "SignerDeclined": true,
|
|
7215
|
+
* "DocumentCancelled": true,
|
|
7216
|
+
* "DocumentAboutToExpire": true,
|
|
7217
|
+
* "DocumentExpired": true,
|
|
7218
|
+
* "DocumentExpirationReset": true,
|
|
7219
|
+
* "DocumentProcessingFailed": true,
|
|
7220
|
+
* "TemplateProcessingFailed": true,
|
|
7221
|
+
* "SignerWhatsappFailed": true
|
|
7222
|
+
* }
|
|
7223
|
+
* ```
|
|
7224
|
+
*
|
|
6845
7225
|
* @param preferences - One or more of the nine documented keys, each with
|
|
6846
7226
|
* a boolean value. Request example:
|
|
6847
7227
|
* ```json
|