@assinafy/sdk 2.5.2 → 2.7.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/dist/index.d.ts CHANGED
@@ -82,9 +82,9 @@ interface AssinafyClientOptions {
82
82
  */
83
83
  baseUrl?: string;
84
84
  /**
85
- * Secret for an opt-in HMAC-SHA256 convention implemented by your own
86
- * gateway. The public Assinafy contract does not currently define a
87
- * platform webhook-signature header or shared-secret exchange.
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
- /** Official CPF/CNPJ field; non-digits are stripped before sending. */
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
- * Webhook subscription as returned by the API. There is exactly one
741
- * subscription per workspace, keyed by URL — the API returns
742
- * `{ events, is_active, url, email, updated_at }` (no `id` / `created_at`).
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;
@@ -2173,40 +2274,36 @@ declare class DocumentResource extends BaseResource {
2173
2274
  */
2174
2275
  getPublic(documentId: string): Promise<IPublicDocumentInfo>;
2175
2276
  /**
2176
- * Send the signer's access token to their email / WhatsApp
2277
+ * Send the signer's access token to their email
2177
2278
  * (`PUT /public/documents/{documentId}/send-token`).
2178
2279
  *
2179
2280
  * Part of the public signing flow: dispatches the 6-digit verification
2180
2281
  * token the signer enters to view the document. The documented request body
2181
- * is `{ email }`. For compatibility with Assinafy environments that still
2182
- * require the older contract, passing an explicit `channel` sends
2183
- * `{ recipient, channel }`; the two-argument documented call also retries
2184
- * that legacy shape only when the server explicitly reports that
2185
- * `channel`/`recipient` is required.
2282
+ * is `{ recipient, channel }` with `channel` set to `email`. This
2283
+ * two-argument form sends the legacy `{ email }` shape, which current
2284
+ * deployments still accept, and retries the documented shape only when the
2285
+ * server explicitly reports that `channel`/`recipient` is required. Use the
2286
+ * three-argument overload to send the documented shape directly.
2186
2287
  *
2187
2288
  * Request body (`application/json`):
2188
2289
  * ```jsonc
2189
2290
  * { "email": "signer@example.com" }
2190
2291
  * ```
2191
- * Compatibility fallback or explicit-channel body:
2292
+ * Documented body, sent on the explicit-channel overload or on retry:
2192
2293
  * ```jsonc
2193
2294
  * { "recipient": "signer@example.com", "channel": "email" }
2194
2295
  * ```
2195
2296
  *
2196
2297
  * @param documentId - The document to send the token for.
2197
- * @param recipient - The signer's email address (or WhatsApp number when an
2198
- * explicit channel is supplied).
2199
- * @param channel - Optional legacy delivery channel.
2298
+ * @param email - The signer's email address.
2200
2299
  * @returns Nothing after the API's empty acknowledgement.
2201
- * @throws {ValidationError} If `documentId` or `recipient` is missing, the
2202
- * official two-argument form does not receive a valid email address, or a
2203
- * supplied `channel` is not a non-empty string.
2300
+ * @throws {ValidationError} If `documentId` is missing or `email` is not a
2301
+ * valid email address.
2204
2302
  * @throws {ApiError} If the API rejects the request.
2205
2303
  *
2206
2304
  * @example
2207
2305
  * ```ts
2208
2306
  * await client.documents.sendToken('doc-1', 'signer@example.com');
2209
- * await client.documents.sendToken('doc-1', '+5511999998888', 'whatsapp');
2210
2307
  * ```
2211
2308
  */
2212
2309
  sendToken(documentId: string, email: string): Promise<void>;
@@ -2296,7 +2393,7 @@ declare class SignerResource extends BaseResource {
2296
2393
  * "full_name": "Example Signer",
2297
2394
  * "email": "signer@example.com",
2298
2395
  * "whatsapp_phone_number": "+5548999990000",
2299
- * "cpf": "39053344705",
2396
+ * "government_id": "390.533.447-05",
2300
2397
  * "metadata": {
2301
2398
  * "reference": "customer_example"
2302
2399
  * }
@@ -2304,12 +2401,13 @@ declare class SignerResource extends BaseResource {
2304
2401
  * ```
2305
2402
  *
2306
2403
  * @param payload - The signer to create. The official fields are required
2307
- * `full_name` plus optional `email` and E.164 `whatsapp_phone_number`.
2308
- * `phone`, `cpf`, and `metadata` are compatibility extensions; the SDK
2309
- * normalizes the phone alias and strips non-digits from CPF before sending.
2404
+ * `full_name` plus optional `email`, E.164 `whatsapp_phone_number` and
2405
+ * `government_id` (CPF, or a CNPJ that may contain letters; the API strips
2406
+ * formatting). `phone`, `cpf`, and `metadata` are compatibility extensions;
2407
+ * the SDK normalizes the phone alias and strips non-digits from CPF.
2310
2408
  * @param accountId - Override the client's default account ID.
2311
- * @returns The created (or reused) signer. Note the response **never echoes
2312
- * `cpf` back**, even when one was sent:
2409
+ * @returns The created (or reused) signer. `government_id` comes back
2410
+ * normalized; `cpf` is **never echoed back**:
2313
2411
  * ```jsonc
2314
2412
  * {
2315
2413
  * "resource": "signer",
@@ -2317,6 +2415,7 @@ declare class SignerResource extends BaseResource {
2317
2415
  * "full_name": "Ana Souza",
2318
2416
  * "email": "ana@example.com",
2319
2417
  * "whatsapp_phone_number": null,
2418
+ * "government_id": "39053344705",
2320
2419
  * "has_accepted_terms": false
2321
2420
  * }
2322
2421
  * ```
@@ -2330,7 +2429,7 @@ declare class SignerResource extends BaseResource {
2330
2429
  * const signer = await client.signers.create({
2331
2430
  * full_name: 'Ana Souza',
2332
2431
  * email: 'ana@example.com',
2333
- * cpf: '390.533.447-05', // sent as '39053344705', never echoed back
2432
+ * government_id: '390.533.447-05', // returned as '39053344705'
2334
2433
  * });
2335
2434
  *
2336
2435
  * // A whatsapp-only signer (no email):
@@ -2357,6 +2456,7 @@ declare class SignerResource extends BaseResource {
2357
2456
  * "full_name": "Example Signer",
2358
2457
  * "email": "signer@example.com",
2359
2458
  * "whatsapp_phone_number": null,
2459
+ * "government_id": "12ABC34501DE35",
2360
2460
  * "has_accepted_terms": false
2361
2461
  * }
2362
2462
  * ```
@@ -2411,13 +2511,14 @@ declare class SignerResource extends BaseResource {
2411
2511
  * "full_name": "Example Signer",
2412
2512
  * "email": "signer@example.com",
2413
2513
  * "whatsapp_phone_number": "+5548999990000",
2414
- * "government_id": "39053344705"
2514
+ * "government_id": "12.ABC.345/01DE-35"
2415
2515
  * }
2416
2516
  * ```
2417
2517
  *
2418
2518
  * @param signerId - The signer to update.
2419
- * @param payload - Fields to change. The official `government_id` field and
2420
- * legacy `cpf` extension are stripped to digits before sending.
2519
+ * @param payload - Fields to change. `government_id` is sent as given (the
2520
+ * API normalizes it and keeps CNPJ letters); the legacy `cpf` extension is
2521
+ * stripped to digits.
2421
2522
  * @param accountId - Override the client's default account ID.
2422
2523
  * @returns The updated signer (as with create, `cpf` is never echoed back):
2423
2524
  * ```jsonc
@@ -2427,6 +2528,7 @@ declare class SignerResource extends BaseResource {
2427
2528
  * "full_name": "Ana Souza Lima",
2428
2529
  * "email": "ana@example.com",
2429
2530
  * "whatsapp_phone_number": null,
2531
+ * "government_id": "12ABC34501DE35",
2430
2532
  * "has_accepted_terms": false
2431
2533
  * }
2432
2534
  * ```
@@ -2851,10 +2953,10 @@ declare class WorkspaceResource extends BaseResource {
2851
2953
  * ```ts
2852
2954
  * const body = buildAssignmentPayload({
2853
2955
  * method: 'virtual',
2854
- * signers: ['signer-1', { signer_id: 'signer-2', step: 2 }],
2956
+ * signers: [{ signer_id: 'signer-1', step: 1 }, { signer_id: 'signer-2', step: 2 }],
2855
2957
  * message: 'Please sign',
2856
2958
  * });
2857
- * // body.signers → [{ id: 'signer-1' }, { id: 'signer-2', step: 2 }]
2959
+ * // body.signers → [{ id: 'signer-1', step: 1 }, { id: 'signer-2', step: 2 }]
2858
2960
  * ```
2859
2961
  */
2860
2962
  declare function buildAssignmentPayload(payload: ICreateAssignmentPayload): Record<string, unknown>;
@@ -3144,9 +3246,10 @@ declare class AssignmentResource extends BaseResource {
3144
3246
  * Update the expiration date of an existing assignment
3145
3247
  * (`PUT /documents/{documentId}/assignments/{assignmentId}/reset-expiration`).
3146
3248
  *
3147
- * Sends `{ expires_at }` verbatim. Use an ISO-8601 date/time string; `null`
3148
- * is retained as a compatibility value and, unlike ordinary nullable
3149
- * inputs, is intentionally not stripped from the body.
3249
+ * Sends `{ expires_at }` verbatim; the key itself is required by the
3250
+ * contract. Use an ISO-8601 date/time string, or `null` to remove the
3251
+ * expiration — `null` is the documented clear mechanism and, unlike
3252
+ * ordinary nullable inputs, is intentionally not stripped from the body.
3150
3253
  *
3151
3254
  * Request body (`application/json`):
3152
3255
  * ```jsonc
@@ -3157,8 +3260,8 @@ declare class AssignmentResource extends BaseResource {
3157
3260
  *
3158
3261
  * @param documentId - The document the assignment belongs to.
3159
3262
  * @param assignmentId - The assignment to update.
3160
- * @param expiresAt - New expiry as an ISO-8601 date/time string. `null` is
3161
- * a compatibility value intended to clear it.
3263
+ * @param expiresAt - New expiry as an ISO-8601 date/time string, or `null`
3264
+ * to remove the expiration.
3162
3265
  * @returns The updated {@link IAssignment} — the same full shape
3163
3266
  * {@link AssignmentResource.create} returns (`signers`, `items`, `summary`,
3164
3267
  * `signing_urls`), with `expires_at` reflecting the new value:
@@ -3310,15 +3413,16 @@ declare class AssignmentResource extends BaseResource {
3310
3413
  }
3311
3414
 
3312
3415
  /**
3313
- * Default webhook events applied by {@link WebhookResource.register} when the
3314
- * caller omits `events` (or passes an empty array).
3416
+ * Default webhook events applied by {@link WebhookResource.register} and
3417
+ * {@link WebhookResource.createEndpoint} when the caller omits `events` (or
3418
+ * passes an empty array).
3315
3419
  */
3316
3420
  declare const DEFAULT_WEBHOOK_EVENTS: readonly WebhookEventType[];
3317
3421
  declare class WebhookResource extends BaseResource {
3318
3422
  /**
3319
- * Register (or replace) the workspace's single webhook subscription
3320
- * (`PUT /accounts/{accountId}/webhooks/subscriptions`). There is exactly one
3321
- * subscription per workspace, keyed by URL.
3423
+ * Update the account's oldest webhook endpoint, creating it if the account
3424
+ * has none (`PUT /accounts/{accountId}/webhooks/subscriptions`). Accounts
3425
+ * with several endpoints should use {@link WebhookResource.updateEndpoint}.
3322
3426
  *
3323
3427
  * When `events` is omitted or empty, {@link DEFAULT_WEBHOOK_EVENTS} is used
3324
3428
  * (`document_ready`, `document_prepared`, `signer_signed_document`,
@@ -3378,8 +3482,9 @@ declare class WebhookResource extends BaseResource {
3378
3482
  */
3379
3483
  register(payload: IWebhookRegisterPayload, accountId?: string): Promise<IWebhookSubscription>;
3380
3484
  /**
3381
- * Fetch the current webhook subscription
3382
- * (`GET /accounts/{accountId}/webhooks/subscriptions`).
3485
+ * Fetch the account's oldest webhook endpoint in the legacy subscription
3486
+ * shape (`GET /accounts/{accountId}/webhooks/subscriptions`). Accounts with
3487
+ * several endpoints should use {@link WebhookResource.listEndpoints}.
3383
3488
  *
3384
3489
  * @param accountId - Override the client's default account ID.
3385
3490
  * @returns The subscription, or `null` when the workspace has none (the API
@@ -3413,13 +3518,14 @@ declare class WebhookResource extends BaseResource {
3413
3518
  */
3414
3519
  get(accountId?: string): Promise<IWebhookSubscription | null>;
3415
3520
  /**
3416
- * Inactivate the current webhook subscription
3417
- * (`PUT /accounts/{accountId}/webhooks/inactivate`).
3521
+ * Deactivate the account's oldest webhook endpoint
3522
+ * (`PUT /accounts/{accountId}/webhooks/inactivate`). Other endpoints are
3523
+ * unaffected; use {@link WebhookResource.updateEndpoint} with
3524
+ * `is_active: false` to target a specific one.
3418
3525
  *
3419
- * This is the only supported way to stop deliveries — the API has no
3420
- * subscription-delete route. The subscription is retained (with its `url`
3421
- * and `events`) and simply stops firing; re-enable it by calling
3422
- * {@link WebhookResource.register} again with `is_active: true`.
3526
+ * The endpoint is retained (with its `url` and `events`) and simply stops
3527
+ * firing; re-enable it by calling {@link WebhookResource.register} again
3528
+ * with `is_active: true`.
3423
3529
  * OAuth tokens need the `webhooks:write` scope.
3424
3530
  *
3425
3531
  * @param accountId - Override the client's default account ID.
@@ -3492,6 +3598,7 @@ declare class WebhookResource extends BaseResource {
3492
3598
  * truncated to 2,000 characters.
3493
3599
  *
3494
3600
  * @param params - Optional filters and pagination:
3601
+ * - `endpoint_id` — only deliveries to this webhook endpoint.
3495
3602
  * - `event` — restrict to a single {@link WebhookEventType}
3496
3603
  * (e.g. `'signer_signed_document'`).
3497
3604
  * - `delivered` — `true`/`false` to filter by delivery success.
@@ -3506,6 +3613,7 @@ declare class WebhookResource extends BaseResource {
3506
3613
  * "id": "103a09cfce51319dd3b3f72ffcdf",
3507
3614
  * "event": "signature_requested",
3508
3615
  * "activity_id": 8629,
3616
+ * "endpoint_id": "65f1c2a9b3e4d5f60718293a4b5c6d7e", // null once the endpoint is deleted
3509
3617
  * "endpoint": "https://example.com/hook",
3510
3618
  * "payload": {
3511
3619
  * // the full event body that was POSTed to `endpoint`:
@@ -3540,7 +3648,7 @@ declare class WebhookResource extends BaseResource {
3540
3648
  /**
3541
3649
  * Retry delivery of a specific webhook dispatch
3542
3650
  * (`POST /accounts/{accountId}/webhooks/{historyId}/retry`). Re-sends the
3543
- * original payload to the subscription's endpoint.
3651
+ * original payload to the endpoint that received it.
3544
3652
  *
3545
3653
  * @param dispatchId - The dispatch (delivery history) ID to re-send, as
3546
3654
  * returned by {@link WebhookResource.listDispatches}.
@@ -3554,6 +3662,7 @@ declare class WebhookResource extends BaseResource {
3554
3662
  * "id": "103a09cfce51319dd3b3f72ffcdf",
3555
3663
  * "event": "signature_requested",
3556
3664
  * "activity_id": 8629,
3665
+ * "endpoint_id": "65f1c2a9b3e4d5f60718293a4b5c6d7e", // null once the endpoint is deleted
3557
3666
  * "endpoint": "https://example.com/hook",
3558
3667
  * "payload": { }, // the original event body that was re-POSTed
3559
3668
  * "delivered": true,
@@ -3575,6 +3684,251 @@ declare class WebhookResource extends BaseResource {
3575
3684
  * ```
3576
3685
  */
3577
3686
  retryDispatch(dispatchId: string, accountId?: string): Promise<IWebhookDispatch>;
3687
+ /**
3688
+ * List the account's webhook endpoints, oldest first
3689
+ * (`GET /accounts/{accountId}/webhooks/endpoints`). OAuth tokens need the
3690
+ * `account:read` scope.
3691
+ *
3692
+ * @param accountId - Override the client's default account ID.
3693
+ * @returns Every endpoint (1 on free plans, up to 3 on paid plans):
3694
+ * ```jsonc
3695
+ * [
3696
+ * {
3697
+ * "id": "65f1c2a9b3e4d5f60718293a4b5c6d7e",
3698
+ * "name": "ERP",
3699
+ * "url": "https://example.com/webhooks/assinafy",
3700
+ * "email": "ops@example.com",
3701
+ * "events": ["document_ready", "signer_signed_document"],
3702
+ * "is_active": true,
3703
+ * "signing_enabled": true, // deliveries carry a `webhook-signature` header
3704
+ * "created_at": "2026-10-01T12:00:00Z",
3705
+ * "updated_at": "2026-10-01T12:00:00Z"
3706
+ * }
3707
+ * ]
3708
+ * ```
3709
+ * @throws {ValidationError} If no account ID is available.
3710
+ * @throws {ApiError} If the API rejects the request.
3711
+ *
3712
+ * @example
3713
+ * ```ts
3714
+ * const endpoints = await client.webhooks.listEndpoints();
3715
+ * const signed = endpoints.filter((endpoint) => endpoint.signing_enabled);
3716
+ * ```
3717
+ */
3718
+ listEndpoints(accountId?: string): Promise<IWebhookEndpoint[]>;
3719
+ /**
3720
+ * Register a URL to receive the account's webhook events
3721
+ * (`POST /accounts/{accountId}/webhooks/endpoints`).
3722
+ *
3723
+ * An account can have 1 endpoint, or up to 3 on paid plans. Each endpoint
3724
+ * of a workspace needs a different `url`. With `signing_enabled: true` the
3725
+ * API generates a signing secret; read it with
3726
+ * {@link WebhookResource.getEndpointSecret}. When `events` is omitted or
3727
+ * empty, {@link DEFAULT_WEBHOOK_EVENTS} is sent. OAuth tokens need the
3728
+ * `webhooks:write` scope.
3729
+ *
3730
+ * Request body (`application/json`):
3731
+ * ```jsonc
3732
+ * {
3733
+ * "url": "https://example.com/webhooks/assinafy",
3734
+ * "email": "ops@example.com",
3735
+ * "events": ["document_ready", "signer_signed_document"],
3736
+ * "name": "ERP", // optional label
3737
+ * "is_active": true, // defaults to true
3738
+ * "signing_enabled": true // defaults to false
3739
+ * }
3740
+ * ```
3741
+ *
3742
+ * @param payload - Endpoint details. `url` (absolute HTTP(S)) and `email`
3743
+ * are required; `events`, `name`, `is_active` and `signing_enabled` are
3744
+ * optional.
3745
+ * @param accountId - Override the client's default account ID.
3746
+ * @returns The created endpoint:
3747
+ * ```jsonc
3748
+ * {
3749
+ * "id": "65f1c2a9b3e4d5f60718293a4b5c6d7e",
3750
+ * "name": "ERP",
3751
+ * "url": "https://example.com/webhooks/assinafy",
3752
+ * "email": "ops@example.com",
3753
+ * "events": ["document_ready", "signer_signed_document"],
3754
+ * "is_active": true,
3755
+ * "signing_enabled": true, // deliveries carry a `webhook-signature` header
3756
+ * "created_at": "2026-10-01T12:00:00Z",
3757
+ * "updated_at": "2026-10-01T12:00:00Z"
3758
+ * }
3759
+ * ```
3760
+ * @throws {ValidationError} If a field is malformed or no account ID is
3761
+ * available.
3762
+ * @throws {ApiError} `400` if another endpoint already uses `url`; `403`
3763
+ * when the plan's endpoint limit is reached or an OAuth token lacks
3764
+ * `webhooks:write`.
3765
+ *
3766
+ * @example
3767
+ * ```ts
3768
+ * const endpoint = await client.webhooks.createEndpoint({
3769
+ * name: 'ERP',
3770
+ * url: 'https://example.com/webhooks/assinafy',
3771
+ * email: 'ops@example.com',
3772
+ * events: ['document_ready', 'signer_signed_document'],
3773
+ * signing_enabled: true,
3774
+ * });
3775
+ * const { secret } = await client.webhooks.getEndpointSecret(endpoint.id);
3776
+ * ```
3777
+ */
3778
+ createEndpoint(payload: IWebhookEndpointCreatePayload, accountId?: string): Promise<IWebhookEndpoint>;
3779
+ /**
3780
+ * Retrieve one webhook endpoint
3781
+ * (`GET /accounts/{accountId}/webhooks/endpoints/{endpointId}`). OAuth
3782
+ * tokens need the `account:read` scope.
3783
+ *
3784
+ * @param endpointId - The endpoint ID.
3785
+ * @param accountId - Override the client's default account ID.
3786
+ * @returns The endpoint:
3787
+ * ```jsonc
3788
+ * {
3789
+ * "id": "65f1c2a9b3e4d5f60718293a4b5c6d7e",
3790
+ * "name": "ERP",
3791
+ * "url": "https://example.com/webhooks/assinafy",
3792
+ * "email": "ops@example.com",
3793
+ * "events": ["document_ready", "signer_signed_document"],
3794
+ * "is_active": true,
3795
+ * "signing_enabled": true, // deliveries carry a `webhook-signature` header
3796
+ * "created_at": "2026-10-01T12:00:00Z",
3797
+ * "updated_at": "2026-10-01T12:00:00Z"
3798
+ * }
3799
+ * ```
3800
+ * @throws {ValidationError} If `endpointId` is empty or no account ID is
3801
+ * available.
3802
+ * @throws {ApiError} `404` if the endpoint does not exist.
3803
+ *
3804
+ * @example
3805
+ * ```ts
3806
+ * const endpoint = await client.webhooks.getEndpoint('65f1c2a9b3e4d5f60718293a4b5c6d7e');
3807
+ * ```
3808
+ */
3809
+ getEndpoint(endpointId: string, accountId?: string): Promise<IWebhookEndpoint>;
3810
+ /**
3811
+ * Change a webhook endpoint
3812
+ * (`PUT /accounts/{accountId}/webhooks/endpoints/{endpointId}`). Only the
3813
+ * fields sent are updated; `url` cannot be one another endpoint of the
3814
+ * workspace already uses.
3815
+ *
3816
+ * `signing_enabled: true` generates a secret if the endpoint has none and
3817
+ * keeps the current one otherwise; `false` discards the secret. OAuth
3818
+ * tokens need the `webhooks:write` scope.
3819
+ *
3820
+ * Request body (`application/json`, every field optional):
3821
+ * ```jsonc
3822
+ * {
3823
+ * "url": "https://example.com/webhooks/assinafy",
3824
+ * "email": "ops@example.com",
3825
+ * "events": ["document_ready"],
3826
+ * "name": "ERP",
3827
+ * "is_active": false,
3828
+ * "signing_enabled": true
3829
+ * }
3830
+ * ```
3831
+ *
3832
+ * @param endpointId - The endpoint ID.
3833
+ * @param payload - Fields to change; at least one is required.
3834
+ * @param accountId - Override the client's default account ID.
3835
+ * @returns The updated endpoint:
3836
+ * ```jsonc
3837
+ * {
3838
+ * "id": "65f1c2a9b3e4d5f60718293a4b5c6d7e",
3839
+ * "name": "ERP",
3840
+ * "url": "https://example.com/webhooks/assinafy",
3841
+ * "email": "ops@example.com",
3842
+ * "events": ["document_ready", "signer_signed_document"],
3843
+ * "is_active": true,
3844
+ * "signing_enabled": true, // deliveries carry a `webhook-signature` header
3845
+ * "created_at": "2026-10-01T12:00:00Z",
3846
+ * "updated_at": "2026-10-01T12:00:00Z"
3847
+ * }
3848
+ * ```
3849
+ * @throws {ValidationError} If `endpointId` is empty, the payload is empty
3850
+ * or malformed, or no account ID is available.
3851
+ * @throws {ApiError} `400` if another endpoint already uses `url`; `404` if
3852
+ * the endpoint does not exist.
3853
+ *
3854
+ * @example
3855
+ * ```ts
3856
+ * // Pause one endpoint without touching the others:
3857
+ * await client.webhooks.updateEndpoint(endpoint.id, { is_active: false });
3858
+ * ```
3859
+ */
3860
+ updateEndpoint(endpointId: string, payload: IWebhookEndpointUpdatePayload, accountId?: string): Promise<IWebhookEndpoint>;
3861
+ /**
3862
+ * Stop delivering events to an endpoint and free its plan slot
3863
+ * (`DELETE /accounts/{accountId}/webhooks/endpoints/{endpointId}`). Its
3864
+ * delivery history is kept with `endpoint_id: null`. OAuth tokens need the
3865
+ * `webhooks:write` scope.
3866
+ *
3867
+ * @param endpointId - The endpoint ID.
3868
+ * @param accountId - Override the client's default account ID.
3869
+ * @returns Resolves once deleted (the API answers `{ "data": [] }`).
3870
+ * @throws {ValidationError} If `endpointId` is empty or no account ID is
3871
+ * available.
3872
+ * @throws {ApiError} `404` if the endpoint does not exist.
3873
+ *
3874
+ * @example
3875
+ * ```ts
3876
+ * await client.webhooks.deleteEndpoint('65f1c2a9b3e4d5f60718293a4b5c6d7e');
3877
+ * ```
3878
+ */
3879
+ deleteEndpoint(endpointId: string, accountId?: string): Promise<void>;
3880
+ /**
3881
+ * Return the secret that signs deliveries to an endpoint
3882
+ * (`GET /accounts/{accountId}/webhooks/endpoints/{endpointId}/secret`).
3883
+ * Pass it to {@link AssinafyClient} as `webhookSecret` to verify deliveries
3884
+ * with `webhookVerifier.verifySignature()`. Not available to OAuth
3885
+ * applications; use an API key.
3886
+ *
3887
+ * @param endpointId - The endpoint ID.
3888
+ * @param accountId - Override the client's default account ID.
3889
+ * @returns The Standard Webhooks secret:
3890
+ * ```jsonc
3891
+ * { "secret": "whsec_MfKQ9r8GKYqrTwjUPD8ILPZIo2LaLaSw" }
3892
+ * ```
3893
+ * @throws {ValidationError} If `endpointId` is empty or no account ID is
3894
+ * available.
3895
+ * @throws {ApiError} `400` when signing is disabled on the endpoint; `404`
3896
+ * if it does not exist.
3897
+ *
3898
+ * @example
3899
+ * ```ts
3900
+ * const { secret } = await client.webhooks.getEndpointSecret(endpoint.id);
3901
+ * // store `secret` with your other credentials, never in source control
3902
+ * ```
3903
+ */
3904
+ getEndpointSecret(endpointId: string, accountId?: string): Promise<IWebhookEndpointSecret>;
3905
+ /**
3906
+ * Replace an endpoint's signing secret and return the new one
3907
+ * (`POST /accounts/{accountId}/webhooks/endpoints/{endpointId}/secret/rotate`).
3908
+ * The old secret stops working immediately: deliveries sent after the
3909
+ * rotation are signed only with the new secret, so update the receiver at
3910
+ * once. Not available to OAuth applications; use an API key.
3911
+ *
3912
+ * @param endpointId - The endpoint ID.
3913
+ * @param accountId - Override the client's default account ID.
3914
+ * @returns The new secret:
3915
+ * ```jsonc
3916
+ * { "secret": "whsec_bmV3LWtleS1iYXNlNjQtZW5jb2RlZA==" }
3917
+ * ```
3918
+ * @throws {ValidationError} If `endpointId` is empty or no account ID is
3919
+ * available.
3920
+ * @throws {ApiError} `400` when signing is disabled on the endpoint; `404`
3921
+ * if it does not exist.
3922
+ *
3923
+ * @example
3924
+ * ```ts
3925
+ * const { secret } = await client.webhooks.rotateEndpointSecret(endpoint.id);
3926
+ * await secretStore.put('assinafy-webhook-secret', secret);
3927
+ * ```
3928
+ */
3929
+ rotateEndpointSecret(endpointId: string, accountId?: string): Promise<IWebhookEndpointSecret>;
3930
+ private endpointsPath;
3931
+ private endpointPath;
3578
3932
  }
3579
3933
 
3580
3934
  /**
@@ -3840,7 +4194,7 @@ declare class TemplateResource extends BaseResource {
3840
4194
  * ```ts
3841
4195
  * const tmpl = await client.templates.get('103ad2171db7979468c3e97eb067');
3842
4196
  * const jpeg = await client.templates.downloadPage(tmpl.id, tmpl.pages[0].id);
3843
- * await fs.writeFile('page-1.jpg', jpeg);
4197
+ * await fs.promises.writeFile('page-1.jpg', jpeg);
3844
4198
  * ```
3845
4199
  */
3846
4200
  downloadPage(templateId: string, pageId: string, accountId?: string): Promise<Buffer>;
@@ -4115,6 +4469,9 @@ declare class AuthenticationResource extends BaseResource {
4115
4469
  * ]
4116
4470
  * }
4117
4471
  * ```
4472
+ * When the user has two-factor authentication enabled the response carries
4473
+ * an `mfa_token` instead of a usable session; finish with
4474
+ * {@link AuthenticationResource.verifyMfa}.
4118
4475
  * @throws {ValidationError} If `email` or `password` is missing.
4119
4476
  * @throws {ApiError} `400` if the credentials are rejected.
4120
4477
  *
@@ -4127,6 +4484,45 @@ declare class AuthenticationResource extends BaseResource {
4127
4484
  * ```
4128
4485
  */
4129
4486
  login(email: string, password: string): Promise<ILoginResponse>;
4487
+ /**
4488
+ * Complete a two-factor login (`POST /authentication/mfa/verify`). Sent
4489
+ * without credentials.
4490
+ *
4491
+ * When the user has two-factor authentication enabled, `login()` returns
4492
+ * an `mfa_token`; exchange it here, within 5 minutes, for the session. The
4493
+ * challenge is single-use.
4494
+ *
4495
+ * Request body (`application/json`):
4496
+ * ```jsonc
4497
+ * {
4498
+ * "mfa_token": "<token from login>",
4499
+ * "code": "123456" // authenticator code, or a recovery code such as "ABCD-EFGH-JKMN"
4500
+ * }
4501
+ * ```
4502
+ *
4503
+ * @param mfaToken - The `mfa_token` returned by {@link AuthenticationResource.login}.
4504
+ * @param code - A 6-digit authenticator code or an unused recovery code.
4505
+ * @returns The same session as a password-only login:
4506
+ * ```jsonc
4507
+ * {
4508
+ * "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9…",
4509
+ * "user": { "id": "md3j6p9w8b7y6qvqaoy5er42", "email": "user@example.com" },
4510
+ * "accounts": [{ "id": "acc_example", "name": "Empresa Exemplo", "roles": ["Owner"] }]
4511
+ * }
4512
+ * ```
4513
+ * @throws {ValidationError} If either argument is empty.
4514
+ * @throws {ApiError} `400` for an invalid or used code; `401` when the
4515
+ * challenge expired, was used, or too many codes were tried.
4516
+ *
4517
+ * @example
4518
+ * ```ts
4519
+ * let session = await client.auth.login('user@example.com', password);
4520
+ * if (session.mfa_token) {
4521
+ * session = await client.auth.verifyMfa(session.mfa_token, await promptForCode());
4522
+ * }
4523
+ * ```
4524
+ */
4525
+ verifyMfa(mfaToken: string, code: string): Promise<ILoginResponse>;
4130
4526
  /**
4131
4527
  * Log in with a social provider (`POST /authentication/social-login`).
4132
4528
  *
@@ -4198,13 +4594,6 @@ declare class AuthenticationResource extends BaseResource {
4198
4594
  * Link a Google identity to the authenticated user
4199
4595
  * (`POST /auth/link-social-login`).
4200
4596
  *
4201
- * Request body:
4202
- * ```jsonc
4203
- * { "provider": "google", "token": "provider-issued-token" }
4204
- * ```
4205
- * The response is the standard status/message acknowledgement with no data,
4206
- * so this method resolves to `void`.
4207
- *
4208
4597
  * Request body (`application/json`):
4209
4598
  * ```jsonc
4210
4599
  * {
@@ -4212,6 +4601,8 @@ declare class AuthenticationResource extends BaseResource {
4212
4601
  * "token": "provider_token_example"
4213
4602
  * }
4214
4603
  * ```
4604
+ * The response is the standard status/message acknowledgement with no data,
4605
+ * so this method resolves to `void`.
4215
4606
  *
4216
4607
  * @param payload - Social provider and provider-issued access/ID token.
4217
4608
  * @returns Resolves when the API acknowledges that the identity was linked.
@@ -4870,6 +5261,11 @@ declare class OAuthResource extends BaseResource {
4870
5261
  * already-revoked included — so the endpoint cannot be used to probe
4871
5262
  * whether a token exists. Only failed client authentication returns `401`.
4872
5263
  *
5264
+ * Request body (`application/x-www-form-urlencoded`):
5265
+ * ```text
5266
+ * token=def50200f1e2…&token_type_hint=refresh_token&client_id=cli_1a2b3c&client_secret=…
5267
+ * ```
5268
+ *
4873
5269
  * @param options - Revocation options.
4874
5270
  * @param options.token - The access or refresh token to revoke.
4875
5271
  * @param options.clientId - The application's `client_id`.
@@ -4878,10 +5274,6 @@ declare class OAuthResource extends BaseResource {
4878
5274
  * @param options.tokenTypeHint - Optional `access_token` or
4879
5275
  * `refresh_token` hint that lets the server skip a lookup.
4880
5276
  * @returns Nothing; resolves once the API acknowledges the request.
4881
- * Request body (`application/x-www-form-urlencoded`):
4882
- * ```text
4883
- * token=def50200f1e2…&token_type_hint=refresh_token&client_id=cli_1a2b3c&client_secret=…
4884
- * ```
4885
5277
  * @throws {ValidationError} If `token` or `clientId` is missing, or
4886
5278
  * `tokenTypeHint` is not one of the two documented values.
4887
5279
  * @throws {OAuthError} `invalid_client` when client authentication fails.
@@ -5457,7 +5849,7 @@ declare class SignerDocumentsResource extends BaseResource {
5457
5849
  * documentId,
5458
5850
  * 'original',
5459
5851
  * );
5460
- * await fs.writeFile('to-sign.pdf', pdf);
5852
+ * await fs.promises.writeFile('to-sign.pdf', pdf);
5461
5853
  * ```
5462
5854
  */
5463
5855
  download(signerId: string, documentId: string, artifactName: DocumentArtifactName, signerAccessCode?: string): Promise<Buffer>;
@@ -5780,7 +6172,7 @@ declare class SignerDocumentsResource extends BaseResource {
5780
6172
  * @example
5781
6173
  * ```ts
5782
6174
  * const png = await client.signerDocuments.downloadSignature(accessCode, 'signature');
5783
- * await fs.writeFile('signature.png', png);
6175
+ * await fs.promises.writeFile('signature.png', png);
5784
6176
  * ```
5785
6177
  */
5786
6178
  downloadSignature(signerAccessCode: string, imageType?: SignatureImageType): Promise<Buffer>;
@@ -6102,33 +6494,209 @@ declare class UserResource extends BaseResource {
6102
6494
  * ```
6103
6495
  */
6104
6496
  updateNotificationPreferences(preferences: IUpdateNotificationPreferences): Promise<INotificationPreferences>;
6497
+ /**
6498
+ * List the user's enrolled two-factor methods (`GET /users/self/mfa`).
6499
+ *
6500
+ * @returns Methods and unused recovery-code count:
6501
+ * ```jsonc
6502
+ * {
6503
+ * "methods": [
6504
+ * {
6505
+ * "id": "a1b2c3d4e5f60718293a4b5c6d7e8f90",
6506
+ * "type": "Totp",
6507
+ * "label": "My phone",
6508
+ * "confirmed_at": "2026-09-09T14:21:03Z",
6509
+ * "last_used_at": "2026-09-09T18:02:44Z"
6510
+ * }
6511
+ * ],
6512
+ * "recovery_codes_remaining": 8
6513
+ * }
6514
+ * ```
6515
+ * @throws {ApiError} `401` when credentials are missing or invalid.
6516
+ *
6517
+ * @example
6518
+ * ```ts
6519
+ * const { methods } = await client.users.getMfa();
6520
+ * const enabled = methods.some((method) => method.confirmed_at !== null);
6521
+ * ```
6522
+ */
6523
+ getMfa(): Promise<IMfaStatus>;
6524
+ /**
6525
+ * Start authenticator-app enrollment (`POST /users/self/mfa/totp`).
6526
+ * Two-factor authentication is not active until
6527
+ * {@link UserResource.confirmTotpEnrollment} succeeds.
6528
+ *
6529
+ * Request body (`application/json`): `{ "label": "My phone" }` (optional).
6530
+ *
6531
+ * @param label - Optional name for the device.
6532
+ * @returns The pending enrollment. `secret` is returned only here:
6533
+ * ```jsonc
6534
+ * {
6535
+ * "id": "a1b2c3d4e5f60718293a4b5c6d7e8f90",
6536
+ * "secret": "GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ",
6537
+ * "provisioning_uri": "otpauth://totp/user%40example.com?issuer=Assinafy&secret=GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ"
6538
+ * }
6539
+ * ```
6540
+ * @throws {ValidationError} If `label` is not a string.
6541
+ * @throws {ApiError} `401` when credentials are missing or invalid.
6542
+ *
6543
+ * @example
6544
+ * ```ts
6545
+ * const enrollment = await client.users.startTotpEnrollment('My phone');
6546
+ * showQrCode(enrollment.provisioning_uri);
6547
+ * ```
6548
+ */
6549
+ startTotpEnrollment(label?: string): Promise<ITotpEnrollment>;
6550
+ /**
6551
+ * Activate an authenticator with a live code from the new device
6552
+ * (`PUT /users/self/mfa/totp/confirm`). From then on every login needs a
6553
+ * second factor.
6554
+ *
6555
+ * Replacing an already confirmed authenticator soft-deletes the old one,
6556
+ * reissues recovery codes, and additionally requires `password` or
6557
+ * `reauth_code`. First-time enrollment needs neither.
6558
+ *
6559
+ * Request body (`application/json`):
6560
+ * ```jsonc
6561
+ * {
6562
+ * "id": "a1b2c3d4e5f60718293a4b5c6d7e8f90",
6563
+ * "code": "123456", // from the NEW device
6564
+ * "password": "example-pass", // only when replacing; or:
6565
+ * "reauth_code": "654321" // code from the CURRENT device, or a recovery code
6566
+ * }
6567
+ * ```
6568
+ *
6569
+ * @param payload - Enrollment `id`, new-device `code`, and re-authentication
6570
+ * when replacing a method.
6571
+ * @returns The recovery codes, shown only once:
6572
+ * ```jsonc
6573
+ * {
6574
+ * "recovery_codes": ["ABCD-EFGH-JKMN", "PQRS-TUVW-XYZ2"] // ten in total
6575
+ * }
6576
+ * ```
6577
+ * @throws {ValidationError} If `id` or `code` is empty.
6578
+ * @throws {ApiError} `400` for a wrong code or missing re-authentication;
6579
+ * `404` for an unknown enrollment.
6580
+ *
6581
+ * @example
6582
+ * ```ts
6583
+ * const { recovery_codes } = await client.users.confirmTotpEnrollment({
6584
+ * id: enrollment.id,
6585
+ * code: '123456',
6586
+ * });
6587
+ * ```
6588
+ */
6589
+ confirmTotpEnrollment(payload: IConfirmTotpPayload): Promise<IMfaRecoveryCodes>;
6590
+ /**
6591
+ * Issue ten fresh recovery codes and invalidate the previous set
6592
+ * (`POST /users/self/mfa/recovery-codes`).
6593
+ *
6594
+ * Request body (`application/json`): `{ "password": "…" }` or
6595
+ * `{ "code": "123456" }`.
6596
+ *
6597
+ * @param proof - Current password, or a live authenticator / recovery code.
6598
+ * @returns The new codes, shown only once:
6599
+ * ```jsonc
6600
+ * {
6601
+ * "recovery_codes": ["ABCD-EFGH-JKMN", "PQRS-TUVW-XYZ2"] // ten in total
6602
+ * }
6603
+ * ```
6604
+ * @throws {ValidationError} If neither `password` nor `code` is given.
6605
+ * @throws {ApiError} `400` when the proof is rejected.
6606
+ *
6607
+ * @example
6608
+ * ```ts
6609
+ * const { recovery_codes } = await client.users.regenerateRecoveryCodes({ code: '123456' });
6610
+ * ```
6611
+ */
6612
+ regenerateRecoveryCodes(proof: IMfaReauth): Promise<IMfaRecoveryCodes>;
6613
+ /**
6614
+ * Remove an enrolled two-factor method (`DELETE /users/self/mfa/{id}`).
6615
+ * Removing the last method also discards the recovery codes.
6616
+ *
6617
+ * Request body (`application/json`): `{ "password": "…" }` or
6618
+ * `{ "code": "123456" }`.
6619
+ *
6620
+ * @param methodId - The method ID from {@link UserResource.getMfa}.
6621
+ * @param proof - Current password, or a live authenticator / recovery code.
6622
+ * @returns Whether two-factor authentication is still on:
6623
+ * ```jsonc
6624
+ * { "is_mfa_enabled": false }
6625
+ * ```
6626
+ * @throws {ValidationError} If `methodId` is empty or no proof is given.
6627
+ * @throws {ApiError} `400` when the proof is rejected; `404` for an unknown
6628
+ * method.
6629
+ *
6630
+ * @example
6631
+ * ```ts
6632
+ * await client.users.deleteMfaMethod(method.id, { password });
6633
+ * ```
6634
+ */
6635
+ deleteMfaMethod(methodId: string, proof: IMfaReauth): Promise<{
6636
+ is_mfa_enabled: boolean;
6637
+ }>;
6105
6638
  }
6106
6639
 
6640
+ /** Headers read by {@link WebhookVerifier.verifySignature}. */
6641
+ type WebhookHeaders = {
6642
+ get(name: string): string | null;
6643
+ } | Record<string, string | string[] | undefined>;
6107
6644
  /**
6108
- * Opt-in verifier for deployments that wrap Assinafy webhook bodies in an
6109
- * HMAC-SHA256 convention of their own.
6645
+ * Verifies and parses Assinafy webhook deliveries.
6110
6646
  *
6111
- * The current public Assinafy API contract does not specify a webhook-signature
6112
- * header or shared-secret exchange. This helper therefore makes no claim about
6113
- * a platform-provided header: callers must explicitly supply the raw lowercase
6114
- * or uppercase hexadecimal HMAC digest produced by their own trusted gateway.
6647
+ * Endpoints created with `signing_enabled: true` sign every delivery following
6648
+ * the Standard Webhooks specification: `webhook-signature` carries
6649
+ * space-separated `v1,<base64 HMAC-SHA256>` entries over
6650
+ * `{webhook-id}.{webhook-timestamp}.{raw body}`, keyed with the base64-decoded
6651
+ * part of the endpoint's `whsec_` secret.
6115
6652
  */
6116
6653
  declare class WebhookVerifier {
6117
6654
  private readonly webhookSecret;
6118
6655
  /**
6119
- * Create an opt-in verifier for a gateway-defined HMAC convention.
6120
- *
6121
- * @param webhookSecret - Shared secret configured in both the trusted
6122
- * gateway and this process. Omit it to keep verification disabled.
6656
+ * @param webhookSecret - The endpoint's `whsec_…` secret from
6657
+ * `webhooks.getEndpointSecret()`. Omit it to keep verification disabled
6658
+ * (every check returns `false`).
6123
6659
  *
6124
6660
  * @example
6125
6661
  * ```ts
6126
- * const verifier = new WebhookVerifier(process.env.WEBHOOK_SHARED_SECRET);
6662
+ * const verifier = new WebhookVerifier(process.env.ASSINAFY_WEBHOOK_SECRET);
6127
6663
  * ```
6128
6664
  */
6129
6665
  constructor(webhookSecret?: string);
6130
6666
  /**
6131
- * Compare a hexadecimal HMAC-SHA256 digest with the raw request body.
6667
+ * Verify a signed delivery: the Standard Webhooks signature over the raw
6668
+ * body, and a `webhook-timestamp` within `toleranceSeconds` of this
6669
+ * machine's clock (replay protection).
6670
+ *
6671
+ * @param payload - Exact, unparsed request bytes (or their UTF-8 string).
6672
+ * Re-serialized JSON will not match.
6673
+ * @param headers - Request headers: a Node/Express header object
6674
+ * (lowercase keys) or a Fetch `Headers`. Reads `webhook-id`,
6675
+ * `webhook-timestamp` and `webhook-signature`.
6676
+ * @param toleranceSeconds - Accepted clock distance. Defaults to `300`.
6677
+ * @returns `true` only when a signature entry matches (constant-time) and
6678
+ * the timestamp is fresh; `false` when verification is disabled, a header
6679
+ * is missing, or anything does not match.
6680
+ *
6681
+ * @example
6682
+ * ```ts
6683
+ * app.post('/webhooks/assinafy', express.raw({ type: 'application/json' }), (req, res) => {
6684
+ * if (!client.webhookVerifier.verifySignature(req.body, req.headers)) {
6685
+ * return res.status(401).end();
6686
+ * }
6687
+ * const event = client.webhookVerifier.extractEvent(req.body);
6688
+ * // deduplicate on req.headers['webhook-id'], then process
6689
+ * res.status(204).end();
6690
+ * });
6691
+ * ```
6692
+ */
6693
+ verifySignature(payload: string | Buffer, headers: WebhookHeaders, toleranceSeconds?: number): boolean;
6694
+ /**
6695
+ * Compare a hexadecimal HMAC-SHA256 digest of the raw body, keyed with the
6696
+ * secret string as-is.
6697
+ *
6698
+ * @deprecated For gateways that apply their own HMAC convention. Assinafy's
6699
+ * own signatures are verified with {@link WebhookVerifier.verifySignature}.
6132
6700
  *
6133
6701
  * @param payload - Exact, unparsed request bytes (or their UTF-8 string).
6134
6702
  * @param signature - 64-character hexadecimal SHA-256 digest supplied by
@@ -6679,4 +7247,4 @@ declare const MAX_LIST_PAGE_SIZE = 50;
6679
7247
 
6680
7248
  declare const SDK_USER_AGENT: string;
6681
7249
 
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 };
7250
+ 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 };