@assinafy/sdk 2.5.2 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +37 -1
- package/README.en.md +92 -51
- package/README.md +82 -45
- package/dist/index.d.mts +619 -44
- package/dist/index.d.ts +619 -44
- package/dist/index.js +641 -48
- package/dist/index.mjs +641 -48
- package/docs/API_COVERAGE.md +23 -10
- package/docs/COMPATIBILITY.md +32 -20
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -82,9 +82,9 @@ interface AssinafyClientOptions {
|
|
|
82
82
|
*/
|
|
83
83
|
baseUrl?: string;
|
|
84
84
|
/**
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
85
|
+
* Webhook endpoint signing secret (`whsec_…`, from
|
|
86
|
+
* `webhooks.getEndpointSecret()`). Enables
|
|
87
|
+
* `webhookVerifier.verifySignature()`.
|
|
88
88
|
*/
|
|
89
89
|
webhookSecret?: string;
|
|
90
90
|
/** Request timeout in milliseconds. Defaults to 30_000. */
|
|
@@ -115,6 +115,11 @@ interface ICreateSignerPayload {
|
|
|
115
115
|
phone?: string;
|
|
116
116
|
/** Compatibility extension. Brazilian CPF; non-digits are stripped. */
|
|
117
117
|
cpf?: string;
|
|
118
|
+
/**
|
|
119
|
+
* CPF (11 digits) or CNPJ (14 characters, letters allowed). Sent as given;
|
|
120
|
+
* the API strips formatting and returns the normalized value.
|
|
121
|
+
*/
|
|
122
|
+
government_id?: string;
|
|
118
123
|
/** Compatibility extension retained for existing integrations. */
|
|
119
124
|
metadata?: Record<string, unknown>;
|
|
120
125
|
}
|
|
@@ -127,7 +132,10 @@ interface IUpdateSignerPayload {
|
|
|
127
132
|
phone?: string;
|
|
128
133
|
/** Compatibility extension. Brazilian CPF; non-digits are stripped. */
|
|
129
134
|
cpf?: string;
|
|
130
|
-
/**
|
|
135
|
+
/**
|
|
136
|
+
* CPF (11 digits) or CNPJ (14 characters, letters allowed). Sent as given;
|
|
137
|
+
* the API strips formatting and returns the normalized value.
|
|
138
|
+
*/
|
|
131
139
|
government_id?: string;
|
|
132
140
|
}
|
|
133
141
|
/** Signer object as returned by the API. */
|
|
@@ -142,6 +150,8 @@ interface ISigner {
|
|
|
142
150
|
* response — present here only so response objects stay assignable from inputs.
|
|
143
151
|
*/
|
|
144
152
|
cpf?: string | null;
|
|
153
|
+
/** Normalized CPF or CNPJ, e.g. `'39053344705'` or `'12ABC34501DE35'`. */
|
|
154
|
+
government_id?: string | null;
|
|
145
155
|
has_accepted_terms?: boolean;
|
|
146
156
|
/** Only returned by `GET /signers/self`. */
|
|
147
157
|
has_signature?: boolean;
|
|
@@ -737,9 +747,10 @@ interface IWebhookRegisterPayload {
|
|
|
737
747
|
is_active?: boolean;
|
|
738
748
|
}
|
|
739
749
|
/**
|
|
740
|
-
*
|
|
741
|
-
* subscription
|
|
742
|
-
*
|
|
750
|
+
* The account's oldest webhook endpoint, as returned by the legacy
|
|
751
|
+
* subscription routes: `{ events, is_active, url, email, updated_at }`
|
|
752
|
+
* (no `id` / `created_at`). Use {@link IWebhookEndpoint} for multi-endpoint
|
|
753
|
+
* accounts.
|
|
743
754
|
*/
|
|
744
755
|
interface IWebhookSubscription {
|
|
745
756
|
url: string | null;
|
|
@@ -748,6 +759,38 @@ interface IWebhookSubscription {
|
|
|
748
759
|
is_active: boolean;
|
|
749
760
|
updated_at?: string | null;
|
|
750
761
|
}
|
|
762
|
+
/** Body for `webhooks.createEndpoint()`. */
|
|
763
|
+
interface IWebhookEndpointCreatePayload extends IWebhookRegisterPayload {
|
|
764
|
+
/** Label to tell endpoints apart. */
|
|
765
|
+
name?: string;
|
|
766
|
+
/** Sign deliveries with a Standard Webhooks signature. Defaults to `false`. */
|
|
767
|
+
signing_enabled?: boolean;
|
|
768
|
+
}
|
|
769
|
+
/** Body for `webhooks.updateEndpoint()`; only the fields sent are changed. */
|
|
770
|
+
type IWebhookEndpointUpdatePayload = Partial<IWebhookEndpointCreatePayload>;
|
|
771
|
+
/**
|
|
772
|
+
* One of the account's webhook endpoints. Accounts have 1 endpoint, or up to
|
|
773
|
+
* 3 on paid plans; every active endpoint subscribed to an event receives it.
|
|
774
|
+
*/
|
|
775
|
+
interface IWebhookEndpoint {
|
|
776
|
+
id: string;
|
|
777
|
+
name: string | null;
|
|
778
|
+
url: string;
|
|
779
|
+
email: string;
|
|
780
|
+
events: (WebhookEventType | AnyString)[];
|
|
781
|
+
is_active: boolean;
|
|
782
|
+
/** Whether deliveries carry a `webhook-signature` header. */
|
|
783
|
+
signing_enabled: boolean;
|
|
784
|
+
/** ISO-8601 UTC timestamp. */
|
|
785
|
+
created_at: string;
|
|
786
|
+
/** ISO-8601 UTC timestamp. */
|
|
787
|
+
updated_at: string;
|
|
788
|
+
}
|
|
789
|
+
/** An endpoint's Standard Webhooks signing secret. */
|
|
790
|
+
interface IWebhookEndpointSecret {
|
|
791
|
+
/** `whsec_` followed by the base64-encoded key. */
|
|
792
|
+
secret: string;
|
|
793
|
+
}
|
|
751
794
|
/** Event code and human-readable description from the webhook event catalog. */
|
|
752
795
|
interface IWebhookEventTypeInfo {
|
|
753
796
|
id: WebhookEventType | AnyString;
|
|
@@ -759,6 +802,9 @@ interface IWebhookDispatch {
|
|
|
759
802
|
id: string;
|
|
760
803
|
event: WebhookEventType | AnyString;
|
|
761
804
|
activity_id: number;
|
|
805
|
+
/** Endpoint the delivery went to; `null` once that endpoint is deleted. */
|
|
806
|
+
endpoint_id?: string | null;
|
|
807
|
+
/** URL that received the request. */
|
|
762
808
|
endpoint: string | null;
|
|
763
809
|
payload: IWebhookPayload | Record<string, unknown> | null;
|
|
764
810
|
delivered: boolean;
|
|
@@ -773,6 +819,8 @@ interface IWebhookDispatch {
|
|
|
773
819
|
}
|
|
774
820
|
/** Filters accepted by `webhooks.listDispatches()`. */
|
|
775
821
|
interface IWebhookDispatchListParams extends IListParams {
|
|
822
|
+
/** Only deliveries to this webhook endpoint. */
|
|
823
|
+
endpoint_id?: string;
|
|
776
824
|
event?: WebhookEventType | AnyString;
|
|
777
825
|
delivered?: boolean | 'true' | 'false';
|
|
778
826
|
from?: number;
|
|
@@ -1013,6 +1061,11 @@ type IUpdateNotificationPreferences = Partial<INotificationPreferences>;
|
|
|
1013
1061
|
/** Login/social-login response containing the bearer token, user, and accounts. */
|
|
1014
1062
|
interface ILoginResponse {
|
|
1015
1063
|
access_token: string;
|
|
1064
|
+
/**
|
|
1065
|
+
* Returned by `auth.login()` when the user has two-factor authentication
|
|
1066
|
+
* enabled: exchange it with `auth.verifyMfa()` within 5 minutes.
|
|
1067
|
+
*/
|
|
1068
|
+
mfa_token?: string;
|
|
1016
1069
|
user: IAuthenticatedUser;
|
|
1017
1070
|
accounts: Array<{
|
|
1018
1071
|
id: string;
|
|
@@ -1022,6 +1075,54 @@ interface ILoginResponse {
|
|
|
1022
1075
|
created_at: string;
|
|
1023
1076
|
}>;
|
|
1024
1077
|
}
|
|
1078
|
+
/** An enrolled two-factor method. */
|
|
1079
|
+
interface IMfaMethod {
|
|
1080
|
+
id: string;
|
|
1081
|
+
/** `'Totp'` for authenticator apps. */
|
|
1082
|
+
type: 'Totp' | AnyString;
|
|
1083
|
+
label: string | null;
|
|
1084
|
+
/** ISO-8601 UTC timestamp. */
|
|
1085
|
+
confirmed_at: string | null;
|
|
1086
|
+
/** ISO-8601 UTC timestamp. */
|
|
1087
|
+
last_used_at: string | null;
|
|
1088
|
+
}
|
|
1089
|
+
/** Result of `users.getMfa()`. */
|
|
1090
|
+
interface IMfaStatus {
|
|
1091
|
+
methods: IMfaMethod[];
|
|
1092
|
+
recovery_codes_remaining: number;
|
|
1093
|
+
}
|
|
1094
|
+
/** Unconfirmed authenticator enrollment from `users.startTotpEnrollment()`. */
|
|
1095
|
+
interface ITotpEnrollment {
|
|
1096
|
+
id: string;
|
|
1097
|
+
/** Base32 shared secret; returned only by this call. */
|
|
1098
|
+
secret: string;
|
|
1099
|
+
/** `otpauth://` URI to render as a QR code. */
|
|
1100
|
+
provisioning_uri: string;
|
|
1101
|
+
}
|
|
1102
|
+
/** Recovery codes; shown only once. */
|
|
1103
|
+
interface IMfaRecoveryCodes {
|
|
1104
|
+
recovery_codes: string[];
|
|
1105
|
+
}
|
|
1106
|
+
/**
|
|
1107
|
+
* Re-authentication proof for sensitive two-factor changes: the current
|
|
1108
|
+
* `password`, or `code` — a live authenticator code or an unused recovery
|
|
1109
|
+
* code (which is then consumed).
|
|
1110
|
+
*/
|
|
1111
|
+
interface IMfaReauth {
|
|
1112
|
+
password?: string;
|
|
1113
|
+
code?: string;
|
|
1114
|
+
}
|
|
1115
|
+
/** Body for `users.confirmTotpEnrollment()`. */
|
|
1116
|
+
interface IConfirmTotpPayload {
|
|
1117
|
+
/** Enrollment ID from `startTotpEnrollment()`. */
|
|
1118
|
+
id: string;
|
|
1119
|
+
/** Live code from the new device. */
|
|
1120
|
+
code: string;
|
|
1121
|
+
/** Current password; needed (or `reauth_code`) only when replacing a confirmed method. */
|
|
1122
|
+
password?: string;
|
|
1123
|
+
/** Alternative to `password`: a code from the current device, or a recovery code. */
|
|
1124
|
+
reauth_code?: string;
|
|
1125
|
+
}
|
|
1025
1126
|
/** Authentication: API key payload returned by `POST /users/api-keys`. */
|
|
1026
1127
|
interface IApiKeyResponse {
|
|
1027
1128
|
api_key: string | null;
|
|
@@ -2296,7 +2397,7 @@ declare class SignerResource extends BaseResource {
|
|
|
2296
2397
|
* "full_name": "Example Signer",
|
|
2297
2398
|
* "email": "signer@example.com",
|
|
2298
2399
|
* "whatsapp_phone_number": "+5548999990000",
|
|
2299
|
-
* "
|
|
2400
|
+
* "government_id": "390.533.447-05",
|
|
2300
2401
|
* "metadata": {
|
|
2301
2402
|
* "reference": "customer_example"
|
|
2302
2403
|
* }
|
|
@@ -2304,12 +2405,13 @@ declare class SignerResource extends BaseResource {
|
|
|
2304
2405
|
* ```
|
|
2305
2406
|
*
|
|
2306
2407
|
* @param payload - The signer to create. The official fields are required
|
|
2307
|
-
* `full_name` plus optional `email
|
|
2308
|
-
* `
|
|
2309
|
-
*
|
|
2408
|
+
* `full_name` plus optional `email`, E.164 `whatsapp_phone_number` and
|
|
2409
|
+
* `government_id` (CPF, or a CNPJ that may contain letters; the API strips
|
|
2410
|
+
* formatting). `phone`, `cpf`, and `metadata` are compatibility extensions;
|
|
2411
|
+
* the SDK normalizes the phone alias and strips non-digits from CPF.
|
|
2310
2412
|
* @param accountId - Override the client's default account ID.
|
|
2311
|
-
* @returns The created (or reused) signer.
|
|
2312
|
-
* `cpf`
|
|
2413
|
+
* @returns The created (or reused) signer. `government_id` comes back
|
|
2414
|
+
* normalized; `cpf` is **never echoed back**:
|
|
2313
2415
|
* ```jsonc
|
|
2314
2416
|
* {
|
|
2315
2417
|
* "resource": "signer",
|
|
@@ -2317,6 +2419,7 @@ declare class SignerResource extends BaseResource {
|
|
|
2317
2419
|
* "full_name": "Ana Souza",
|
|
2318
2420
|
* "email": "ana@example.com",
|
|
2319
2421
|
* "whatsapp_phone_number": null,
|
|
2422
|
+
* "government_id": "39053344705",
|
|
2320
2423
|
* "has_accepted_terms": false
|
|
2321
2424
|
* }
|
|
2322
2425
|
* ```
|
|
@@ -2330,7 +2433,7 @@ declare class SignerResource extends BaseResource {
|
|
|
2330
2433
|
* const signer = await client.signers.create({
|
|
2331
2434
|
* full_name: 'Ana Souza',
|
|
2332
2435
|
* email: 'ana@example.com',
|
|
2333
|
-
*
|
|
2436
|
+
* government_id: '390.533.447-05', // returned as '39053344705'
|
|
2334
2437
|
* });
|
|
2335
2438
|
*
|
|
2336
2439
|
* // A whatsapp-only signer (no email):
|
|
@@ -2357,6 +2460,7 @@ declare class SignerResource extends BaseResource {
|
|
|
2357
2460
|
* "full_name": "Example Signer",
|
|
2358
2461
|
* "email": "signer@example.com",
|
|
2359
2462
|
* "whatsapp_phone_number": null,
|
|
2463
|
+
* "government_id": "12ABC34501DE35",
|
|
2360
2464
|
* "has_accepted_terms": false
|
|
2361
2465
|
* }
|
|
2362
2466
|
* ```
|
|
@@ -2411,13 +2515,14 @@ declare class SignerResource extends BaseResource {
|
|
|
2411
2515
|
* "full_name": "Example Signer",
|
|
2412
2516
|
* "email": "signer@example.com",
|
|
2413
2517
|
* "whatsapp_phone_number": "+5548999990000",
|
|
2414
|
-
* "government_id": "
|
|
2518
|
+
* "government_id": "12.ABC.345/01DE-35"
|
|
2415
2519
|
* }
|
|
2416
2520
|
* ```
|
|
2417
2521
|
*
|
|
2418
2522
|
* @param signerId - The signer to update.
|
|
2419
|
-
* @param payload - Fields to change.
|
|
2420
|
-
* legacy `cpf` extension
|
|
2523
|
+
* @param payload - Fields to change. `government_id` is sent as given (the
|
|
2524
|
+
* API normalizes it and keeps CNPJ letters); the legacy `cpf` extension is
|
|
2525
|
+
* stripped to digits.
|
|
2421
2526
|
* @param accountId - Override the client's default account ID.
|
|
2422
2527
|
* @returns The updated signer (as with create, `cpf` is never echoed back):
|
|
2423
2528
|
* ```jsonc
|
|
@@ -2427,6 +2532,7 @@ declare class SignerResource extends BaseResource {
|
|
|
2427
2532
|
* "full_name": "Ana Souza Lima",
|
|
2428
2533
|
* "email": "ana@example.com",
|
|
2429
2534
|
* "whatsapp_phone_number": null,
|
|
2535
|
+
* "government_id": "12ABC34501DE35",
|
|
2430
2536
|
* "has_accepted_terms": false
|
|
2431
2537
|
* }
|
|
2432
2538
|
* ```
|
|
@@ -3310,15 +3416,16 @@ declare class AssignmentResource extends BaseResource {
|
|
|
3310
3416
|
}
|
|
3311
3417
|
|
|
3312
3418
|
/**
|
|
3313
|
-
* Default webhook events applied by {@link WebhookResource.register}
|
|
3314
|
-
* caller omits `events` (or
|
|
3419
|
+
* Default webhook events applied by {@link WebhookResource.register} and
|
|
3420
|
+
* {@link WebhookResource.createEndpoint} when the caller omits `events` (or
|
|
3421
|
+
* passes an empty array).
|
|
3315
3422
|
*/
|
|
3316
3423
|
declare const DEFAULT_WEBHOOK_EVENTS: readonly WebhookEventType[];
|
|
3317
3424
|
declare class WebhookResource extends BaseResource {
|
|
3318
3425
|
/**
|
|
3319
|
-
*
|
|
3320
|
-
* (`PUT /accounts/{accountId}/webhooks/subscriptions`).
|
|
3321
|
-
*
|
|
3426
|
+
* Update the account's oldest webhook endpoint, creating it if the account
|
|
3427
|
+
* has none (`PUT /accounts/{accountId}/webhooks/subscriptions`). Accounts
|
|
3428
|
+
* with several endpoints should use {@link WebhookResource.updateEndpoint}.
|
|
3322
3429
|
*
|
|
3323
3430
|
* When `events` is omitted or empty, {@link DEFAULT_WEBHOOK_EVENTS} is used
|
|
3324
3431
|
* (`document_ready`, `document_prepared`, `signer_signed_document`,
|
|
@@ -3378,8 +3485,9 @@ declare class WebhookResource extends BaseResource {
|
|
|
3378
3485
|
*/
|
|
3379
3486
|
register(payload: IWebhookRegisterPayload, accountId?: string): Promise<IWebhookSubscription>;
|
|
3380
3487
|
/**
|
|
3381
|
-
* Fetch the
|
|
3382
|
-
* (`GET /accounts/{accountId}/webhooks/subscriptions`).
|
|
3488
|
+
* Fetch the account's oldest webhook endpoint in the legacy subscription
|
|
3489
|
+
* shape (`GET /accounts/{accountId}/webhooks/subscriptions`). Accounts with
|
|
3490
|
+
* several endpoints should use {@link WebhookResource.listEndpoints}.
|
|
3383
3491
|
*
|
|
3384
3492
|
* @param accountId - Override the client's default account ID.
|
|
3385
3493
|
* @returns The subscription, or `null` when the workspace has none (the API
|
|
@@ -3413,13 +3521,14 @@ declare class WebhookResource extends BaseResource {
|
|
|
3413
3521
|
*/
|
|
3414
3522
|
get(accountId?: string): Promise<IWebhookSubscription | null>;
|
|
3415
3523
|
/**
|
|
3416
|
-
*
|
|
3417
|
-
* (`PUT /accounts/{accountId}/webhooks/inactivate`).
|
|
3524
|
+
* Deactivate the account's oldest webhook endpoint
|
|
3525
|
+
* (`PUT /accounts/{accountId}/webhooks/inactivate`). Other endpoints are
|
|
3526
|
+
* unaffected; use {@link WebhookResource.updateEndpoint} with
|
|
3527
|
+
* `is_active: false` to target a specific one.
|
|
3418
3528
|
*
|
|
3419
|
-
*
|
|
3420
|
-
*
|
|
3421
|
-
*
|
|
3422
|
-
* {@link WebhookResource.register} again with `is_active: true`.
|
|
3529
|
+
* The endpoint is retained (with its `url` and `events`) and simply stops
|
|
3530
|
+
* firing; re-enable it by calling {@link WebhookResource.register} again
|
|
3531
|
+
* with `is_active: true`.
|
|
3423
3532
|
* OAuth tokens need the `webhooks:write` scope.
|
|
3424
3533
|
*
|
|
3425
3534
|
* @param accountId - Override the client's default account ID.
|
|
@@ -3492,6 +3601,7 @@ declare class WebhookResource extends BaseResource {
|
|
|
3492
3601
|
* truncated to 2,000 characters.
|
|
3493
3602
|
*
|
|
3494
3603
|
* @param params - Optional filters and pagination:
|
|
3604
|
+
* - `endpoint_id` — only deliveries to this webhook endpoint.
|
|
3495
3605
|
* - `event` — restrict to a single {@link WebhookEventType}
|
|
3496
3606
|
* (e.g. `'signer_signed_document'`).
|
|
3497
3607
|
* - `delivered` — `true`/`false` to filter by delivery success.
|
|
@@ -3506,6 +3616,7 @@ declare class WebhookResource extends BaseResource {
|
|
|
3506
3616
|
* "id": "103a09cfce51319dd3b3f72ffcdf",
|
|
3507
3617
|
* "event": "signature_requested",
|
|
3508
3618
|
* "activity_id": 8629,
|
|
3619
|
+
* "endpoint_id": "65f1c2a9b3e4d5f60718293a4b5c6d7e", // null once the endpoint is deleted
|
|
3509
3620
|
* "endpoint": "https://example.com/hook",
|
|
3510
3621
|
* "payload": {
|
|
3511
3622
|
* // the full event body that was POSTed to `endpoint`:
|
|
@@ -3540,7 +3651,7 @@ declare class WebhookResource extends BaseResource {
|
|
|
3540
3651
|
/**
|
|
3541
3652
|
* Retry delivery of a specific webhook dispatch
|
|
3542
3653
|
* (`POST /accounts/{accountId}/webhooks/{historyId}/retry`). Re-sends the
|
|
3543
|
-
* original payload to the
|
|
3654
|
+
* original payload to the endpoint that received it.
|
|
3544
3655
|
*
|
|
3545
3656
|
* @param dispatchId - The dispatch (delivery history) ID to re-send, as
|
|
3546
3657
|
* returned by {@link WebhookResource.listDispatches}.
|
|
@@ -3554,6 +3665,7 @@ declare class WebhookResource extends BaseResource {
|
|
|
3554
3665
|
* "id": "103a09cfce51319dd3b3f72ffcdf",
|
|
3555
3666
|
* "event": "signature_requested",
|
|
3556
3667
|
* "activity_id": 8629,
|
|
3668
|
+
* "endpoint_id": "65f1c2a9b3e4d5f60718293a4b5c6d7e", // null once the endpoint is deleted
|
|
3557
3669
|
* "endpoint": "https://example.com/hook",
|
|
3558
3670
|
* "payload": { }, // the original event body that was re-POSTed
|
|
3559
3671
|
* "delivered": true,
|
|
@@ -3575,6 +3687,251 @@ declare class WebhookResource extends BaseResource {
|
|
|
3575
3687
|
* ```
|
|
3576
3688
|
*/
|
|
3577
3689
|
retryDispatch(dispatchId: string, accountId?: string): Promise<IWebhookDispatch>;
|
|
3690
|
+
/**
|
|
3691
|
+
* List the account's webhook endpoints, oldest first
|
|
3692
|
+
* (`GET /accounts/{accountId}/webhooks/endpoints`). OAuth tokens need the
|
|
3693
|
+
* `account:read` scope.
|
|
3694
|
+
*
|
|
3695
|
+
* @param accountId - Override the client's default account ID.
|
|
3696
|
+
* @returns Every endpoint (1 on free plans, up to 3 on paid plans):
|
|
3697
|
+
* ```jsonc
|
|
3698
|
+
* [
|
|
3699
|
+
* {
|
|
3700
|
+
* "id": "65f1c2a9b3e4d5f60718293a4b5c6d7e",
|
|
3701
|
+
* "name": "ERP",
|
|
3702
|
+
* "url": "https://example.com/webhooks/assinafy",
|
|
3703
|
+
* "email": "ops@example.com",
|
|
3704
|
+
* "events": ["document_ready", "signer_signed_document"],
|
|
3705
|
+
* "is_active": true,
|
|
3706
|
+
* "signing_enabled": true, // deliveries carry a `webhook-signature` header
|
|
3707
|
+
* "created_at": "2026-10-01T12:00:00Z",
|
|
3708
|
+
* "updated_at": "2026-10-01T12:00:00Z"
|
|
3709
|
+
* }
|
|
3710
|
+
* ]
|
|
3711
|
+
* ```
|
|
3712
|
+
* @throws {ValidationError} If no account ID is available.
|
|
3713
|
+
* @throws {ApiError} If the API rejects the request.
|
|
3714
|
+
*
|
|
3715
|
+
* @example
|
|
3716
|
+
* ```ts
|
|
3717
|
+
* const endpoints = await client.webhooks.listEndpoints();
|
|
3718
|
+
* const signed = endpoints.filter((endpoint) => endpoint.signing_enabled);
|
|
3719
|
+
* ```
|
|
3720
|
+
*/
|
|
3721
|
+
listEndpoints(accountId?: string): Promise<IWebhookEndpoint[]>;
|
|
3722
|
+
/**
|
|
3723
|
+
* Register a URL to receive the account's webhook events
|
|
3724
|
+
* (`POST /accounts/{accountId}/webhooks/endpoints`).
|
|
3725
|
+
*
|
|
3726
|
+
* An account can have 1 endpoint, or up to 3 on paid plans. Each endpoint
|
|
3727
|
+
* of a workspace needs a different `url`. With `signing_enabled: true` the
|
|
3728
|
+
* API generates a signing secret; read it with
|
|
3729
|
+
* {@link WebhookResource.getEndpointSecret}. When `events` is omitted or
|
|
3730
|
+
* empty, {@link DEFAULT_WEBHOOK_EVENTS} is sent. OAuth tokens need the
|
|
3731
|
+
* `webhooks:write` scope.
|
|
3732
|
+
*
|
|
3733
|
+
* Request body (`application/json`):
|
|
3734
|
+
* ```jsonc
|
|
3735
|
+
* {
|
|
3736
|
+
* "url": "https://example.com/webhooks/assinafy",
|
|
3737
|
+
* "email": "ops@example.com",
|
|
3738
|
+
* "events": ["document_ready", "signer_signed_document"],
|
|
3739
|
+
* "name": "ERP", // optional label
|
|
3740
|
+
* "is_active": true, // defaults to true
|
|
3741
|
+
* "signing_enabled": true // defaults to false
|
|
3742
|
+
* }
|
|
3743
|
+
* ```
|
|
3744
|
+
*
|
|
3745
|
+
* @param payload - Endpoint details. `url` (absolute HTTP(S)) and `email`
|
|
3746
|
+
* are required; `events`, `name`, `is_active` and `signing_enabled` are
|
|
3747
|
+
* optional.
|
|
3748
|
+
* @param accountId - Override the client's default account ID.
|
|
3749
|
+
* @returns The created endpoint:
|
|
3750
|
+
* ```jsonc
|
|
3751
|
+
* {
|
|
3752
|
+
* "id": "65f1c2a9b3e4d5f60718293a4b5c6d7e",
|
|
3753
|
+
* "name": "ERP",
|
|
3754
|
+
* "url": "https://example.com/webhooks/assinafy",
|
|
3755
|
+
* "email": "ops@example.com",
|
|
3756
|
+
* "events": ["document_ready", "signer_signed_document"],
|
|
3757
|
+
* "is_active": true,
|
|
3758
|
+
* "signing_enabled": true, // deliveries carry a `webhook-signature` header
|
|
3759
|
+
* "created_at": "2026-10-01T12:00:00Z",
|
|
3760
|
+
* "updated_at": "2026-10-01T12:00:00Z"
|
|
3761
|
+
* }
|
|
3762
|
+
* ```
|
|
3763
|
+
* @throws {ValidationError} If a field is malformed or no account ID is
|
|
3764
|
+
* available.
|
|
3765
|
+
* @throws {ApiError} `400` if another endpoint already uses `url`; `403`
|
|
3766
|
+
* when the plan's endpoint limit is reached or an OAuth token lacks
|
|
3767
|
+
* `webhooks:write`.
|
|
3768
|
+
*
|
|
3769
|
+
* @example
|
|
3770
|
+
* ```ts
|
|
3771
|
+
* const endpoint = await client.webhooks.createEndpoint({
|
|
3772
|
+
* name: 'ERP',
|
|
3773
|
+
* url: 'https://example.com/webhooks/assinafy',
|
|
3774
|
+
* email: 'ops@example.com',
|
|
3775
|
+
* events: ['document_ready', 'signer_signed_document'],
|
|
3776
|
+
* signing_enabled: true,
|
|
3777
|
+
* });
|
|
3778
|
+
* const { secret } = await client.webhooks.getEndpointSecret(endpoint.id);
|
|
3779
|
+
* ```
|
|
3780
|
+
*/
|
|
3781
|
+
createEndpoint(payload: IWebhookEndpointCreatePayload, accountId?: string): Promise<IWebhookEndpoint>;
|
|
3782
|
+
/**
|
|
3783
|
+
* Retrieve one webhook endpoint
|
|
3784
|
+
* (`GET /accounts/{accountId}/webhooks/endpoints/{endpointId}`). OAuth
|
|
3785
|
+
* tokens need the `account:read` scope.
|
|
3786
|
+
*
|
|
3787
|
+
* @param endpointId - The endpoint ID.
|
|
3788
|
+
* @param accountId - Override the client's default account ID.
|
|
3789
|
+
* @returns The endpoint:
|
|
3790
|
+
* ```jsonc
|
|
3791
|
+
* {
|
|
3792
|
+
* "id": "65f1c2a9b3e4d5f60718293a4b5c6d7e",
|
|
3793
|
+
* "name": "ERP",
|
|
3794
|
+
* "url": "https://example.com/webhooks/assinafy",
|
|
3795
|
+
* "email": "ops@example.com",
|
|
3796
|
+
* "events": ["document_ready", "signer_signed_document"],
|
|
3797
|
+
* "is_active": true,
|
|
3798
|
+
* "signing_enabled": true, // deliveries carry a `webhook-signature` header
|
|
3799
|
+
* "created_at": "2026-10-01T12:00:00Z",
|
|
3800
|
+
* "updated_at": "2026-10-01T12:00:00Z"
|
|
3801
|
+
* }
|
|
3802
|
+
* ```
|
|
3803
|
+
* @throws {ValidationError} If `endpointId` is empty or no account ID is
|
|
3804
|
+
* available.
|
|
3805
|
+
* @throws {ApiError} `404` if the endpoint does not exist.
|
|
3806
|
+
*
|
|
3807
|
+
* @example
|
|
3808
|
+
* ```ts
|
|
3809
|
+
* const endpoint = await client.webhooks.getEndpoint('65f1c2a9b3e4d5f60718293a4b5c6d7e');
|
|
3810
|
+
* ```
|
|
3811
|
+
*/
|
|
3812
|
+
getEndpoint(endpointId: string, accountId?: string): Promise<IWebhookEndpoint>;
|
|
3813
|
+
/**
|
|
3814
|
+
* Change a webhook endpoint
|
|
3815
|
+
* (`PUT /accounts/{accountId}/webhooks/endpoints/{endpointId}`). Only the
|
|
3816
|
+
* fields sent are updated; `url` cannot be one another endpoint of the
|
|
3817
|
+
* workspace already uses.
|
|
3818
|
+
*
|
|
3819
|
+
* `signing_enabled: true` generates a secret if the endpoint has none and
|
|
3820
|
+
* keeps the current one otherwise; `false` discards the secret. OAuth
|
|
3821
|
+
* tokens need the `webhooks:write` scope.
|
|
3822
|
+
*
|
|
3823
|
+
* Request body (`application/json`, every field optional):
|
|
3824
|
+
* ```jsonc
|
|
3825
|
+
* {
|
|
3826
|
+
* "url": "https://example.com/webhooks/assinafy",
|
|
3827
|
+
* "email": "ops@example.com",
|
|
3828
|
+
* "events": ["document_ready"],
|
|
3829
|
+
* "name": "ERP",
|
|
3830
|
+
* "is_active": false,
|
|
3831
|
+
* "signing_enabled": true
|
|
3832
|
+
* }
|
|
3833
|
+
* ```
|
|
3834
|
+
*
|
|
3835
|
+
* @param endpointId - The endpoint ID.
|
|
3836
|
+
* @param payload - Fields to change; at least one is required.
|
|
3837
|
+
* @param accountId - Override the client's default account ID.
|
|
3838
|
+
* @returns The updated endpoint:
|
|
3839
|
+
* ```jsonc
|
|
3840
|
+
* {
|
|
3841
|
+
* "id": "65f1c2a9b3e4d5f60718293a4b5c6d7e",
|
|
3842
|
+
* "name": "ERP",
|
|
3843
|
+
* "url": "https://example.com/webhooks/assinafy",
|
|
3844
|
+
* "email": "ops@example.com",
|
|
3845
|
+
* "events": ["document_ready", "signer_signed_document"],
|
|
3846
|
+
* "is_active": true,
|
|
3847
|
+
* "signing_enabled": true, // deliveries carry a `webhook-signature` header
|
|
3848
|
+
* "created_at": "2026-10-01T12:00:00Z",
|
|
3849
|
+
* "updated_at": "2026-10-01T12:00:00Z"
|
|
3850
|
+
* }
|
|
3851
|
+
* ```
|
|
3852
|
+
* @throws {ValidationError} If `endpointId` is empty, the payload is empty
|
|
3853
|
+
* or malformed, or no account ID is available.
|
|
3854
|
+
* @throws {ApiError} `400` if another endpoint already uses `url`; `404` if
|
|
3855
|
+
* the endpoint does not exist.
|
|
3856
|
+
*
|
|
3857
|
+
* @example
|
|
3858
|
+
* ```ts
|
|
3859
|
+
* // Pause one endpoint without touching the others:
|
|
3860
|
+
* await client.webhooks.updateEndpoint(endpoint.id, { is_active: false });
|
|
3861
|
+
* ```
|
|
3862
|
+
*/
|
|
3863
|
+
updateEndpoint(endpointId: string, payload: IWebhookEndpointUpdatePayload, accountId?: string): Promise<IWebhookEndpoint>;
|
|
3864
|
+
/**
|
|
3865
|
+
* Stop delivering events to an endpoint and free its plan slot
|
|
3866
|
+
* (`DELETE /accounts/{accountId}/webhooks/endpoints/{endpointId}`). Its
|
|
3867
|
+
* delivery history is kept with `endpoint_id: null`. OAuth tokens need the
|
|
3868
|
+
* `webhooks:write` scope.
|
|
3869
|
+
*
|
|
3870
|
+
* @param endpointId - The endpoint ID.
|
|
3871
|
+
* @param accountId - Override the client's default account ID.
|
|
3872
|
+
* @returns Resolves once deleted (the API answers `{ "data": [] }`).
|
|
3873
|
+
* @throws {ValidationError} If `endpointId` is empty or no account ID is
|
|
3874
|
+
* available.
|
|
3875
|
+
* @throws {ApiError} `404` if the endpoint does not exist.
|
|
3876
|
+
*
|
|
3877
|
+
* @example
|
|
3878
|
+
* ```ts
|
|
3879
|
+
* await client.webhooks.deleteEndpoint('65f1c2a9b3e4d5f60718293a4b5c6d7e');
|
|
3880
|
+
* ```
|
|
3881
|
+
*/
|
|
3882
|
+
deleteEndpoint(endpointId: string, accountId?: string): Promise<void>;
|
|
3883
|
+
/**
|
|
3884
|
+
* Return the secret that signs deliveries to an endpoint
|
|
3885
|
+
* (`GET /accounts/{accountId}/webhooks/endpoints/{endpointId}/secret`).
|
|
3886
|
+
* Pass it to {@link AssinafyClient} as `webhookSecret` to verify deliveries
|
|
3887
|
+
* with `webhookVerifier.verifySignature()`. Not available to OAuth
|
|
3888
|
+
* applications; use an API key.
|
|
3889
|
+
*
|
|
3890
|
+
* @param endpointId - The endpoint ID.
|
|
3891
|
+
* @param accountId - Override the client's default account ID.
|
|
3892
|
+
* @returns The Standard Webhooks secret:
|
|
3893
|
+
* ```jsonc
|
|
3894
|
+
* { "secret": "whsec_MfKQ9r8GKYqrTwjUPD8ILPZIo2LaLaSw" }
|
|
3895
|
+
* ```
|
|
3896
|
+
* @throws {ValidationError} If `endpointId` is empty or no account ID is
|
|
3897
|
+
* available.
|
|
3898
|
+
* @throws {ApiError} `400` when signing is disabled on the endpoint; `404`
|
|
3899
|
+
* if it does not exist.
|
|
3900
|
+
*
|
|
3901
|
+
* @example
|
|
3902
|
+
* ```ts
|
|
3903
|
+
* const { secret } = await client.webhooks.getEndpointSecret(endpoint.id);
|
|
3904
|
+
* // store `secret` with your other credentials, never in source control
|
|
3905
|
+
* ```
|
|
3906
|
+
*/
|
|
3907
|
+
getEndpointSecret(endpointId: string, accountId?: string): Promise<IWebhookEndpointSecret>;
|
|
3908
|
+
/**
|
|
3909
|
+
* Replace an endpoint's signing secret and return the new one
|
|
3910
|
+
* (`POST /accounts/{accountId}/webhooks/endpoints/{endpointId}/secret/rotate`).
|
|
3911
|
+
* The old secret stops working immediately: deliveries sent after the
|
|
3912
|
+
* rotation are signed only with the new secret, so update the receiver at
|
|
3913
|
+
* once. Not available to OAuth applications; use an API key.
|
|
3914
|
+
*
|
|
3915
|
+
* @param endpointId - The endpoint ID.
|
|
3916
|
+
* @param accountId - Override the client's default account ID.
|
|
3917
|
+
* @returns The new secret:
|
|
3918
|
+
* ```jsonc
|
|
3919
|
+
* { "secret": "whsec_bmV3LWtleS1iYXNlNjQtZW5jb2RlZA==" }
|
|
3920
|
+
* ```
|
|
3921
|
+
* @throws {ValidationError} If `endpointId` is empty or no account ID is
|
|
3922
|
+
* available.
|
|
3923
|
+
* @throws {ApiError} `400` when signing is disabled on the endpoint; `404`
|
|
3924
|
+
* if it does not exist.
|
|
3925
|
+
*
|
|
3926
|
+
* @example
|
|
3927
|
+
* ```ts
|
|
3928
|
+
* const { secret } = await client.webhooks.rotateEndpointSecret(endpoint.id);
|
|
3929
|
+
* await secretStore.put('assinafy-webhook-secret', secret);
|
|
3930
|
+
* ```
|
|
3931
|
+
*/
|
|
3932
|
+
rotateEndpointSecret(endpointId: string, accountId?: string): Promise<IWebhookEndpointSecret>;
|
|
3933
|
+
private endpointsPath;
|
|
3934
|
+
private endpointPath;
|
|
3578
3935
|
}
|
|
3579
3936
|
|
|
3580
3937
|
/**
|
|
@@ -4116,6 +4473,9 @@ declare class AuthenticationResource extends BaseResource {
|
|
|
4116
4473
|
* }
|
|
4117
4474
|
* ```
|
|
4118
4475
|
* @throws {ValidationError} If `email` or `password` is missing.
|
|
4476
|
+
* When the user has two-factor authentication enabled the response carries
|
|
4477
|
+
* an `mfa_token` instead of a usable session; finish with
|
|
4478
|
+
* {@link AuthenticationResource.verifyMfa}.
|
|
4119
4479
|
* @throws {ApiError} `400` if the credentials are rejected.
|
|
4120
4480
|
*
|
|
4121
4481
|
* @example
|
|
@@ -4127,6 +4487,45 @@ declare class AuthenticationResource extends BaseResource {
|
|
|
4127
4487
|
* ```
|
|
4128
4488
|
*/
|
|
4129
4489
|
login(email: string, password: string): Promise<ILoginResponse>;
|
|
4490
|
+
/**
|
|
4491
|
+
* Complete a two-factor login (`POST /authentication/mfa/verify`). Sent
|
|
4492
|
+
* without credentials.
|
|
4493
|
+
*
|
|
4494
|
+
* When the user has two-factor authentication enabled, `login()` returns
|
|
4495
|
+
* an `mfa_token`; exchange it here, within 5 minutes, for the session. The
|
|
4496
|
+
* challenge is single-use.
|
|
4497
|
+
*
|
|
4498
|
+
* Request body (`application/json`):
|
|
4499
|
+
* ```jsonc
|
|
4500
|
+
* {
|
|
4501
|
+
* "mfa_token": "<token from login>",
|
|
4502
|
+
* "code": "123456" // authenticator code, or a recovery code such as "ABCD-EFGH-JKMN"
|
|
4503
|
+
* }
|
|
4504
|
+
* ```
|
|
4505
|
+
*
|
|
4506
|
+
* @param mfaToken - The `mfa_token` returned by {@link AuthenticationResource.login}.
|
|
4507
|
+
* @param code - A 6-digit authenticator code or an unused recovery code.
|
|
4508
|
+
* @returns The same session as a password-only login:
|
|
4509
|
+
* ```jsonc
|
|
4510
|
+
* {
|
|
4511
|
+
* "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9…",
|
|
4512
|
+
* "user": { "id": "md3j6p9w8b7y6qvqaoy5er42", "email": "user@example.com" },
|
|
4513
|
+
* "accounts": [{ "id": "acc_example", "name": "Empresa Exemplo", "roles": ["Owner"] }]
|
|
4514
|
+
* }
|
|
4515
|
+
* ```
|
|
4516
|
+
* @throws {ValidationError} If either argument is empty.
|
|
4517
|
+
* @throws {ApiError} `400` for an invalid or used code; `401` when the
|
|
4518
|
+
* challenge expired, was used, or too many codes were tried.
|
|
4519
|
+
*
|
|
4520
|
+
* @example
|
|
4521
|
+
* ```ts
|
|
4522
|
+
* let session = await client.auth.login('user@example.com', password);
|
|
4523
|
+
* if (session.mfa_token) {
|
|
4524
|
+
* session = await client.auth.verifyMfa(session.mfa_token, await promptForCode());
|
|
4525
|
+
* }
|
|
4526
|
+
* ```
|
|
4527
|
+
*/
|
|
4528
|
+
verifyMfa(mfaToken: string, code: string): Promise<ILoginResponse>;
|
|
4130
4529
|
/**
|
|
4131
4530
|
* Log in with a social provider (`POST /authentication/social-login`).
|
|
4132
4531
|
*
|
|
@@ -6102,33 +6501,209 @@ declare class UserResource extends BaseResource {
|
|
|
6102
6501
|
* ```
|
|
6103
6502
|
*/
|
|
6104
6503
|
updateNotificationPreferences(preferences: IUpdateNotificationPreferences): Promise<INotificationPreferences>;
|
|
6504
|
+
/**
|
|
6505
|
+
* List the user's enrolled two-factor methods (`GET /users/self/mfa`).
|
|
6506
|
+
*
|
|
6507
|
+
* @returns Methods and unused recovery-code count:
|
|
6508
|
+
* ```jsonc
|
|
6509
|
+
* {
|
|
6510
|
+
* "methods": [
|
|
6511
|
+
* {
|
|
6512
|
+
* "id": "a1b2c3d4e5f60718293a4b5c6d7e8f90",
|
|
6513
|
+
* "type": "Totp",
|
|
6514
|
+
* "label": "My phone",
|
|
6515
|
+
* "confirmed_at": "2026-09-09T14:21:03Z",
|
|
6516
|
+
* "last_used_at": "2026-09-09T18:02:44Z"
|
|
6517
|
+
* }
|
|
6518
|
+
* ],
|
|
6519
|
+
* "recovery_codes_remaining": 8
|
|
6520
|
+
* }
|
|
6521
|
+
* ```
|
|
6522
|
+
* @throws {ApiError} `401` when credentials are missing or invalid.
|
|
6523
|
+
*
|
|
6524
|
+
* @example
|
|
6525
|
+
* ```ts
|
|
6526
|
+
* const { methods } = await client.users.getMfa();
|
|
6527
|
+
* const enabled = methods.some((method) => method.confirmed_at !== null);
|
|
6528
|
+
* ```
|
|
6529
|
+
*/
|
|
6530
|
+
getMfa(): Promise<IMfaStatus>;
|
|
6531
|
+
/**
|
|
6532
|
+
* Start authenticator-app enrollment (`POST /users/self/mfa/totp`).
|
|
6533
|
+
* Two-factor authentication is not active until
|
|
6534
|
+
* {@link UserResource.confirmTotpEnrollment} succeeds.
|
|
6535
|
+
*
|
|
6536
|
+
* Request body (`application/json`): `{ "label": "My phone" }` (optional).
|
|
6537
|
+
*
|
|
6538
|
+
* @param label - Optional name for the device.
|
|
6539
|
+
* @returns The pending enrollment. `secret` is returned only here:
|
|
6540
|
+
* ```jsonc
|
|
6541
|
+
* {
|
|
6542
|
+
* "id": "a1b2c3d4e5f60718293a4b5c6d7e8f90",
|
|
6543
|
+
* "secret": "GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ",
|
|
6544
|
+
* "provisioning_uri": "otpauth://totp/user%40example.com?issuer=Assinafy&secret=GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ"
|
|
6545
|
+
* }
|
|
6546
|
+
* ```
|
|
6547
|
+
* @throws {ValidationError} If `label` is not a string.
|
|
6548
|
+
* @throws {ApiError} `401` when credentials are missing or invalid.
|
|
6549
|
+
*
|
|
6550
|
+
* @example
|
|
6551
|
+
* ```ts
|
|
6552
|
+
* const enrollment = await client.users.startTotpEnrollment('My phone');
|
|
6553
|
+
* showQrCode(enrollment.provisioning_uri);
|
|
6554
|
+
* ```
|
|
6555
|
+
*/
|
|
6556
|
+
startTotpEnrollment(label?: string): Promise<ITotpEnrollment>;
|
|
6557
|
+
/**
|
|
6558
|
+
* Activate an authenticator with a live code from the new device
|
|
6559
|
+
* (`PUT /users/self/mfa/totp/confirm`). From then on every login needs a
|
|
6560
|
+
* second factor.
|
|
6561
|
+
*
|
|
6562
|
+
* Replacing an already confirmed authenticator soft-deletes the old one,
|
|
6563
|
+
* reissues recovery codes, and additionally requires `password` or
|
|
6564
|
+
* `reauth_code`. First-time enrollment needs neither.
|
|
6565
|
+
*
|
|
6566
|
+
* Request body (`application/json`):
|
|
6567
|
+
* ```jsonc
|
|
6568
|
+
* {
|
|
6569
|
+
* "id": "a1b2c3d4e5f60718293a4b5c6d7e8f90",
|
|
6570
|
+
* "code": "123456", // from the NEW device
|
|
6571
|
+
* "password": "example-pass", // only when replacing; or:
|
|
6572
|
+
* "reauth_code": "654321" // code from the CURRENT device, or a recovery code
|
|
6573
|
+
* }
|
|
6574
|
+
* ```
|
|
6575
|
+
*
|
|
6576
|
+
* @param payload - Enrollment `id`, new-device `code`, and re-authentication
|
|
6577
|
+
* when replacing a method.
|
|
6578
|
+
* @returns The recovery codes, shown only once:
|
|
6579
|
+
* ```jsonc
|
|
6580
|
+
* {
|
|
6581
|
+
* "recovery_codes": ["ABCD-EFGH-JKMN", "PQRS-TUVW-XYZ2"] // ten in total
|
|
6582
|
+
* }
|
|
6583
|
+
* ```
|
|
6584
|
+
* @throws {ValidationError} If `id` or `code` is empty.
|
|
6585
|
+
* @throws {ApiError} `400` for a wrong code or missing re-authentication;
|
|
6586
|
+
* `404` for an unknown enrollment.
|
|
6587
|
+
*
|
|
6588
|
+
* @example
|
|
6589
|
+
* ```ts
|
|
6590
|
+
* const { recovery_codes } = await client.users.confirmTotpEnrollment({
|
|
6591
|
+
* id: enrollment.id,
|
|
6592
|
+
* code: '123456',
|
|
6593
|
+
* });
|
|
6594
|
+
* ```
|
|
6595
|
+
*/
|
|
6596
|
+
confirmTotpEnrollment(payload: IConfirmTotpPayload): Promise<IMfaRecoveryCodes>;
|
|
6597
|
+
/**
|
|
6598
|
+
* Issue ten fresh recovery codes and invalidate the previous set
|
|
6599
|
+
* (`POST /users/self/mfa/recovery-codes`).
|
|
6600
|
+
*
|
|
6601
|
+
* Request body (`application/json`): `{ "password": "…" }` or
|
|
6602
|
+
* `{ "code": "123456" }`.
|
|
6603
|
+
*
|
|
6604
|
+
* @param proof - Current password, or a live authenticator / recovery code.
|
|
6605
|
+
* @returns The new codes, shown only once:
|
|
6606
|
+
* ```jsonc
|
|
6607
|
+
* {
|
|
6608
|
+
* "recovery_codes": ["ABCD-EFGH-JKMN", "PQRS-TUVW-XYZ2"] // ten in total
|
|
6609
|
+
* }
|
|
6610
|
+
* ```
|
|
6611
|
+
* @throws {ValidationError} If neither `password` nor `code` is given.
|
|
6612
|
+
* @throws {ApiError} `400` when the proof is rejected.
|
|
6613
|
+
*
|
|
6614
|
+
* @example
|
|
6615
|
+
* ```ts
|
|
6616
|
+
* const { recovery_codes } = await client.users.regenerateRecoveryCodes({ code: '123456' });
|
|
6617
|
+
* ```
|
|
6618
|
+
*/
|
|
6619
|
+
regenerateRecoveryCodes(proof: IMfaReauth): Promise<IMfaRecoveryCodes>;
|
|
6620
|
+
/**
|
|
6621
|
+
* Remove an enrolled two-factor method (`DELETE /users/self/mfa/{id}`).
|
|
6622
|
+
* Removing the last method also discards the recovery codes.
|
|
6623
|
+
*
|
|
6624
|
+
* Request body (`application/json`): `{ "password": "…" }` or
|
|
6625
|
+
* `{ "code": "123456" }`.
|
|
6626
|
+
*
|
|
6627
|
+
* @param methodId - The method ID from {@link UserResource.getMfa}.
|
|
6628
|
+
* @param proof - Current password, or a live authenticator / recovery code.
|
|
6629
|
+
* @returns Whether two-factor authentication is still on:
|
|
6630
|
+
* ```jsonc
|
|
6631
|
+
* { "is_mfa_enabled": false }
|
|
6632
|
+
* ```
|
|
6633
|
+
* @throws {ValidationError} If `methodId` is empty or no proof is given.
|
|
6634
|
+
* @throws {ApiError} `400` when the proof is rejected; `404` for an unknown
|
|
6635
|
+
* method.
|
|
6636
|
+
*
|
|
6637
|
+
* @example
|
|
6638
|
+
* ```ts
|
|
6639
|
+
* await client.users.deleteMfaMethod(method.id, { password });
|
|
6640
|
+
* ```
|
|
6641
|
+
*/
|
|
6642
|
+
deleteMfaMethod(methodId: string, proof: IMfaReauth): Promise<{
|
|
6643
|
+
is_mfa_enabled: boolean;
|
|
6644
|
+
}>;
|
|
6105
6645
|
}
|
|
6106
6646
|
|
|
6647
|
+
/** Headers read by {@link WebhookVerifier.verifySignature}. */
|
|
6648
|
+
type WebhookHeaders = {
|
|
6649
|
+
get(name: string): string | null;
|
|
6650
|
+
} | Record<string, string | string[] | undefined>;
|
|
6107
6651
|
/**
|
|
6108
|
-
*
|
|
6109
|
-
* HMAC-SHA256 convention of their own.
|
|
6652
|
+
* Verifies and parses Assinafy webhook deliveries.
|
|
6110
6653
|
*
|
|
6111
|
-
*
|
|
6112
|
-
*
|
|
6113
|
-
*
|
|
6114
|
-
*
|
|
6654
|
+
* Endpoints created with `signing_enabled: true` sign every delivery following
|
|
6655
|
+
* the Standard Webhooks specification: `webhook-signature` carries
|
|
6656
|
+
* space-separated `v1,<base64 HMAC-SHA256>` entries over
|
|
6657
|
+
* `{webhook-id}.{webhook-timestamp}.{raw body}`, keyed with the base64-decoded
|
|
6658
|
+
* part of the endpoint's `whsec_` secret.
|
|
6115
6659
|
*/
|
|
6116
6660
|
declare class WebhookVerifier {
|
|
6117
6661
|
private readonly webhookSecret;
|
|
6118
6662
|
/**
|
|
6119
|
-
*
|
|
6120
|
-
*
|
|
6121
|
-
*
|
|
6122
|
-
* gateway and this process. Omit it to keep verification disabled.
|
|
6663
|
+
* @param webhookSecret - The endpoint's `whsec_…` secret from
|
|
6664
|
+
* `webhooks.getEndpointSecret()`. Omit it to keep verification disabled
|
|
6665
|
+
* (every check returns `false`).
|
|
6123
6666
|
*
|
|
6124
6667
|
* @example
|
|
6125
6668
|
* ```ts
|
|
6126
|
-
* const verifier = new WebhookVerifier(process.env.
|
|
6669
|
+
* const verifier = new WebhookVerifier(process.env.ASSINAFY_WEBHOOK_SECRET);
|
|
6127
6670
|
* ```
|
|
6128
6671
|
*/
|
|
6129
6672
|
constructor(webhookSecret?: string);
|
|
6130
6673
|
/**
|
|
6131
|
-
*
|
|
6674
|
+
* Verify a signed delivery: the Standard Webhooks signature over the raw
|
|
6675
|
+
* body, and a `webhook-timestamp` within `toleranceSeconds` of this
|
|
6676
|
+
* machine's clock (replay protection).
|
|
6677
|
+
*
|
|
6678
|
+
* @param payload - Exact, unparsed request bytes (or their UTF-8 string).
|
|
6679
|
+
* Re-serialized JSON will not match.
|
|
6680
|
+
* @param headers - Request headers: a Node/Express header object
|
|
6681
|
+
* (lowercase keys) or a Fetch `Headers`. Reads `webhook-id`,
|
|
6682
|
+
* `webhook-timestamp` and `webhook-signature`.
|
|
6683
|
+
* @param toleranceSeconds - Accepted clock distance. Defaults to `300`.
|
|
6684
|
+
* @returns `true` only when a signature entry matches (constant-time) and
|
|
6685
|
+
* the timestamp is fresh; `false` when verification is disabled, a header
|
|
6686
|
+
* is missing, or anything does not match.
|
|
6687
|
+
*
|
|
6688
|
+
* @example
|
|
6689
|
+
* ```ts
|
|
6690
|
+
* app.post('/webhooks/assinafy', express.raw({ type: 'application/json' }), (req, res) => {
|
|
6691
|
+
* if (!client.webhookVerifier.verifySignature(req.body, req.headers)) {
|
|
6692
|
+
* return res.status(401).end();
|
|
6693
|
+
* }
|
|
6694
|
+
* const event = client.webhookVerifier.extractEvent(req.body);
|
|
6695
|
+
* // deduplicate on req.headers['webhook-id'], then process
|
|
6696
|
+
* res.status(204).end();
|
|
6697
|
+
* });
|
|
6698
|
+
* ```
|
|
6699
|
+
*/
|
|
6700
|
+
verifySignature(payload: string | Buffer, headers: WebhookHeaders, toleranceSeconds?: number): boolean;
|
|
6701
|
+
/**
|
|
6702
|
+
* Compare a hexadecimal HMAC-SHA256 digest of the raw body, keyed with the
|
|
6703
|
+
* secret string as-is.
|
|
6704
|
+
*
|
|
6705
|
+
* @deprecated For gateways that apply their own HMAC convention. Assinafy's
|
|
6706
|
+
* own signatures are verified with {@link WebhookVerifier.verifySignature}.
|
|
6132
6707
|
*
|
|
6133
6708
|
* @param payload - Exact, unparsed request bytes (or their UTF-8 string).
|
|
6134
6709
|
* @param signature - 64-character hexadecimal SHA-256 digest supplied by
|
|
@@ -6679,4 +7254,4 @@ declare const MAX_LIST_PAGE_SIZE = 50;
|
|
|
6679
7254
|
|
|
6680
7255
|
declare const SDK_USER_AGENT: string;
|
|
6681
7256
|
|
|
6682
|
-
export { type AccountLogoUploadSource, type AnyString, ApiError, type AssignmentDisplaySettings, type AssignmentMethod, type AssignmentNotificationMethod, AssignmentResource, type AssignmentVerificationMethod, AssinafyClient, type AssinafyClientOptions, AssinafyError, AuthenticationResource, type ClientConfigInput, DEFAULT_WEBHOOK_EVENTS, type DocumentArtifactName, DocumentResource, type DocumentStatsGranularity, type DocumentStatus, type DocumentUploadSource, FieldsResource, type IAccountTheme, type IApiKeyResponse, type IAssignment, type IAssignmentCostSigner, type IAssignmentEntry, type IAssignmentItem, type IAssignmentListParams, type IAssignmentListResponse, type IAssignmentSigner, type IAuthenticateChallenge, type IAuthenticatedUser, type IConfirmSignerDataPayload, type ICostEstimate, type ICreateAssignmentPayload, type ICreateAssignmentResponse, type ICreateDocumentFromTemplateOptions, type ICreateFieldPayload, type ICreateSignerPayload, type ICreateSignerResponse, type ICreateTagPayload, type ICreateWorkspacePayload, type IDeleteTagResponse, type IDetachDocumentTagResponse, type IDisplaySettings, type IDocumentActivity, type IDocumentDetailsResponse, type IDocumentListItem, type IDocumentListParams, type IDocumentListResponse, type IDocumentSearchParams, type IDocumentStatsParams, type IDocumentStatsRow, type IDocumentStatusInfo, type IDocumentUploadOptions, type IDocumentUploadResponse, type IDocumentVerification, type IEstimateAssignmentCostPayload, type IFieldDefinition, type IFieldType, type IFieldValidateMultipleEntry, type IFieldValidationMultipleResult, type IFieldValidationResponse, type IFieldValidationResult, type IInlineTag, type ILegacyConfirmSignerDataPayload, type ILegacyResendCostEstimate, type ILegacyUploadSignatureOptions, type IListParams, type ILoginResponse, type IMaskedApiKeyResponse, type INotificationHistoryEntry, type INotificationPreferences, type IOAuthAuthorizationCallback, type IOAuthAuthorizationRequest, type IOAuthAuthorizationServerMetadata, type IOAuthProtectedResourceMetadata, type IOAuthTokenResponse, type IOAuthUserInfo, type IPage, type IPaginatedResponse, type IPublicDocumentInfo, type IRenameDocumentResponse, type IResendCostEstimate, type IResendEmailResponse, type ISignFieldEntry, type ISigner, type ISignerListParams, type ISignerListResponse, type ISignerSelf, type ISigningProgress, type ITag, type ITemplateCostSigner, type ITemplateDetailsResponse, type ITemplateFieldPlacement, type ITemplateListItem, type ITemplateListParams, type ITemplateListResponse, type ITemplateRole, type ITemplateSigner, type IUpdateFieldPayload, type IUpdateNotificationPreferences, type IUpdateSignerPayload, type IUpdateTagPayload, type IUpdateTemplatePayload, type IUpdateWorkspacePayload, type IUploadAndRequestSignaturesResult, type IUploadAndRequestSignaturesSigner, type IUploadSignatureOptions, type IWebhookDispatch, type IWebhookDispatchListParams, type IWebhookEventTypeInfo, type IWebhookPayload, type IWebhookRegisterPayload, type IWebhookSubscription, type IWhatsAppNotification, type IWorkspaceListItem, type IWorkspaceListResponse, type IWorkspaceResponse, type Logger, MAX_LIST_PAGE_SIZE, MAX_UPLOAD_BYTES, NetworkError, type NotificationSenderType, OAuthError, OAuthResource, type OAuthScope, type PaginatedResult, type PaginationMeta, SDK_USER_AGENT, type SendTokenChannel, type SignatureImageType, SignerDocumentsResource, type SignerReference, SignerResource, TagResource, TemplateResource, UserResource, ValidationError, type WebhookEventType, WebhookResource, WebhookVerifier, WorkspaceResource, buildAssignmentPayload, parseWwwAuthenticate };
|
|
7257
|
+
export { type AccountLogoUploadSource, type AnyString, ApiError, type AssignmentDisplaySettings, type AssignmentMethod, type AssignmentNotificationMethod, AssignmentResource, type AssignmentVerificationMethod, AssinafyClient, type AssinafyClientOptions, AssinafyError, AuthenticationResource, type ClientConfigInput, DEFAULT_WEBHOOK_EVENTS, type DocumentArtifactName, DocumentResource, type DocumentStatsGranularity, type DocumentStatus, type DocumentUploadSource, FieldsResource, type IAccountTheme, type IApiKeyResponse, type IAssignment, type IAssignmentCostSigner, type IAssignmentEntry, type IAssignmentItem, type IAssignmentListParams, type IAssignmentListResponse, type IAssignmentSigner, type IAuthenticateChallenge, type IAuthenticatedUser, type IConfirmSignerDataPayload, type IConfirmTotpPayload, type ICostEstimate, type ICreateAssignmentPayload, type ICreateAssignmentResponse, type ICreateDocumentFromTemplateOptions, type ICreateFieldPayload, type ICreateSignerPayload, type ICreateSignerResponse, type ICreateTagPayload, type ICreateWorkspacePayload, type IDeleteTagResponse, type IDetachDocumentTagResponse, type IDisplaySettings, type IDocumentActivity, type IDocumentDetailsResponse, type IDocumentListItem, type IDocumentListParams, type IDocumentListResponse, type IDocumentSearchParams, type IDocumentStatsParams, type IDocumentStatsRow, type IDocumentStatusInfo, type IDocumentUploadOptions, type IDocumentUploadResponse, type IDocumentVerification, type IEstimateAssignmentCostPayload, type IFieldDefinition, type IFieldType, type IFieldValidateMultipleEntry, type IFieldValidationMultipleResult, type IFieldValidationResponse, type IFieldValidationResult, type IInlineTag, type ILegacyConfirmSignerDataPayload, type ILegacyResendCostEstimate, type ILegacyUploadSignatureOptions, type IListParams, type ILoginResponse, type IMaskedApiKeyResponse, type IMfaMethod, type IMfaReauth, type IMfaRecoveryCodes, type IMfaStatus, type INotificationHistoryEntry, type INotificationPreferences, type IOAuthAuthorizationCallback, type IOAuthAuthorizationRequest, type IOAuthAuthorizationServerMetadata, type IOAuthProtectedResourceMetadata, type IOAuthTokenResponse, type IOAuthUserInfo, type IPage, type IPaginatedResponse, type IPublicDocumentInfo, type IRenameDocumentResponse, type IResendCostEstimate, type IResendEmailResponse, type ISignFieldEntry, type ISigner, type ISignerListParams, type ISignerListResponse, type ISignerSelf, type ISigningProgress, type ITag, type ITemplateCostSigner, type ITemplateDetailsResponse, type ITemplateFieldPlacement, type ITemplateListItem, type ITemplateListParams, type ITemplateListResponse, type ITemplateRole, type ITemplateSigner, type ITotpEnrollment, type IUpdateFieldPayload, type IUpdateNotificationPreferences, type IUpdateSignerPayload, type IUpdateTagPayload, type IUpdateTemplatePayload, type IUpdateWorkspacePayload, type IUploadAndRequestSignaturesResult, type IUploadAndRequestSignaturesSigner, type IUploadSignatureOptions, type IWebhookDispatch, type IWebhookDispatchListParams, type IWebhookEndpoint, type IWebhookEndpointCreatePayload, type IWebhookEndpointSecret, type IWebhookEndpointUpdatePayload, type IWebhookEventTypeInfo, type IWebhookPayload, type IWebhookRegisterPayload, type IWebhookSubscription, type IWhatsAppNotification, type IWorkspaceListItem, type IWorkspaceListResponse, type IWorkspaceResponse, type Logger, MAX_LIST_PAGE_SIZE, MAX_UPLOAD_BYTES, NetworkError, type NotificationSenderType, OAuthError, OAuthResource, type OAuthScope, type PaginatedResult, type PaginationMeta, SDK_USER_AGENT, type SendTokenChannel, type SignatureImageType, SignerDocumentsResource, type SignerReference, SignerResource, TagResource, TemplateResource, UserResource, ValidationError, type WebhookEventType, type WebhookHeaders, WebhookResource, WebhookVerifier, WorkspaceResource, buildAssignmentPayload, parseWwwAuthenticate };
|