@assinafy/sdk 2.5.1 → 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 +62 -45
- package/README.en.md +120 -78
- package/README.md +107 -70
- package/dist/index.d.mts +1064 -60
- package/dist/index.d.ts +1064 -60
- package/dist/index.js +1040 -67
- package/dist/index.mjs +1036 -63
- package/docs/API_COVERAGE.md +23 -10
- package/docs/COMPATIBILITY.md +47 -41
- package/package.json +2 -2
package/dist/index.d.ts
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;
|
|
@@ -1529,6 +1630,13 @@ declare class DocumentResource extends BaseResource {
|
|
|
1529
1630
|
* {@link DocumentResource.upload} — that avoids the extra round-trip and
|
|
1530
1631
|
* the processing race entirely.
|
|
1531
1632
|
*
|
|
1633
|
+
* Request body (`application/json`):
|
|
1634
|
+
* ```jsonc
|
|
1635
|
+
* {
|
|
1636
|
+
* "name": "Service agreement.pdf"
|
|
1637
|
+
* }
|
|
1638
|
+
* ```
|
|
1639
|
+
*
|
|
1532
1640
|
* @param documentId - The document to rename.
|
|
1533
1641
|
* @param name - The new display name (max 255 chars), e.g.
|
|
1534
1642
|
* `'Service agreement.pdf'`. The API removes diacritics and replaces
|
|
@@ -1826,6 +1934,15 @@ declare class DocumentResource extends BaseResource {
|
|
|
1826
1934
|
* overwrites the existing set — use
|
|
1827
1935
|
* {@link DocumentResource.addTags} to append.
|
|
1828
1936
|
*
|
|
1937
|
+
* Request body (`application/json`):
|
|
1938
|
+
* ```jsonc
|
|
1939
|
+
* {
|
|
1940
|
+
* "tags": [
|
|
1941
|
+
* "tag_example"
|
|
1942
|
+
* ]
|
|
1943
|
+
* }
|
|
1944
|
+
* ```
|
|
1945
|
+
*
|
|
1829
1946
|
* @param documentId - The document to retag.
|
|
1830
1947
|
* @param tags - The complete desired set of tag IDs (`[]` clears all).
|
|
1831
1948
|
* @param accountId - Override the client's default account ID.
|
|
@@ -1855,6 +1972,15 @@ declare class DocumentResource extends BaseResource {
|
|
|
1855
1972
|
* present is a no-op. To replace the whole set instead, use
|
|
1856
1973
|
* {@link DocumentResource.replaceTags}.
|
|
1857
1974
|
*
|
|
1975
|
+
* Request body (`application/json`):
|
|
1976
|
+
* ```jsonc
|
|
1977
|
+
* {
|
|
1978
|
+
* "tags": [
|
|
1979
|
+
* "tag_example"
|
|
1980
|
+
* ]
|
|
1981
|
+
* }
|
|
1982
|
+
* ```
|
|
1983
|
+
*
|
|
1858
1984
|
* @param documentId - The document to tag.
|
|
1859
1985
|
* @param tags - Tag IDs to attach (must be non-empty).
|
|
1860
1986
|
* @param accountId - Override the client's default account ID.
|
|
@@ -1907,6 +2033,35 @@ declare class DocumentResource extends BaseResource {
|
|
|
1907
2033
|
* `options` may add `name`, `message`, `expires_at`, `editor_fields`, and
|
|
1908
2034
|
* tag names in `tags` (unknown names are created automatically).
|
|
1909
2035
|
*
|
|
2036
|
+
* Request body (`application/json`):
|
|
2037
|
+
* ```jsonc
|
|
2038
|
+
* {
|
|
2039
|
+
* "signers": [
|
|
2040
|
+
* {
|
|
2041
|
+
* "role_id": "signing_role_example",
|
|
2042
|
+
* "id": "signer_example",
|
|
2043
|
+
* "verification_method": "Email",
|
|
2044
|
+
* "notification_methods": [
|
|
2045
|
+
* "Email"
|
|
2046
|
+
* ],
|
|
2047
|
+
* "step": 1
|
|
2048
|
+
* }
|
|
2049
|
+
* ],
|
|
2050
|
+
* "name": "Service agreement.pdf",
|
|
2051
|
+
* "message": "Please sign this document.",
|
|
2052
|
+
* "expires_at": "2027-12-31T23:59:59Z",
|
|
2053
|
+
* "editor_fields": [
|
|
2054
|
+
* {
|
|
2055
|
+
* "field_id": "editor_field_example",
|
|
2056
|
+
* "value": "Example Company"
|
|
2057
|
+
* }
|
|
2058
|
+
* ],
|
|
2059
|
+
* "tags": [
|
|
2060
|
+
* "Contracts"
|
|
2061
|
+
* ]
|
|
2062
|
+
* }
|
|
2063
|
+
* ```
|
|
2064
|
+
*
|
|
1910
2065
|
* @param templateId - The template to instantiate.
|
|
1911
2066
|
* @param signers - Role-to-signer bindings (each with `role_id` and `id`,
|
|
1912
2067
|
* plus optional `verification_method`, `notification_methods`, `step`).
|
|
@@ -1959,6 +2114,21 @@ declare class DocumentResource extends BaseResource {
|
|
|
1959
2114
|
* `DigitalCertificate` adds two credits per signer and has the same feature,
|
|
1960
2115
|
* `government_id`, and signing-step prerequisites as document creation.
|
|
1961
2116
|
*
|
|
2117
|
+
* Request body (`application/json`):
|
|
2118
|
+
* ```jsonc
|
|
2119
|
+
* {
|
|
2120
|
+
* "signers": [
|
|
2121
|
+
* {
|
|
2122
|
+
* "role_id": "signing_role_example",
|
|
2123
|
+
* "verification_method": "Email",
|
|
2124
|
+
* "notification_methods": [
|
|
2125
|
+
* "Email"
|
|
2126
|
+
* ]
|
|
2127
|
+
* }
|
|
2128
|
+
* ]
|
|
2129
|
+
* }
|
|
2130
|
+
* ```
|
|
2131
|
+
*
|
|
1962
2132
|
* @param templateId - The template that would be instantiated.
|
|
1963
2133
|
* @param signers - One channel descriptor per template role. Cost requests
|
|
1964
2134
|
* use only `role_id`, `verification_method`, and `notification_methods`;
|
|
@@ -2115,6 +2285,15 @@ declare class DocumentResource extends BaseResource {
|
|
|
2115
2285
|
* that legacy shape only when the server explicitly reports that
|
|
2116
2286
|
* `channel`/`recipient` is required.
|
|
2117
2287
|
*
|
|
2288
|
+
* Request body (`application/json`):
|
|
2289
|
+
* ```jsonc
|
|
2290
|
+
* { "email": "signer@example.com" }
|
|
2291
|
+
* ```
|
|
2292
|
+
* Compatibility fallback or explicit-channel body:
|
|
2293
|
+
* ```jsonc
|
|
2294
|
+
* { "recipient": "signer@example.com", "channel": "email" }
|
|
2295
|
+
* ```
|
|
2296
|
+
*
|
|
2118
2297
|
* @param documentId - The document to send the token for.
|
|
2119
2298
|
* @param recipient - The signer's email address (or WhatsApp number when an
|
|
2120
2299
|
* explicit channel is supplied).
|
|
@@ -2132,6 +2311,21 @@ declare class DocumentResource extends BaseResource {
|
|
|
2132
2311
|
* ```
|
|
2133
2312
|
*/
|
|
2134
2313
|
sendToken(documentId: string, email: string): Promise<void>;
|
|
2314
|
+
/**
|
|
2315
|
+
* Send a signing token through an explicit channel
|
|
2316
|
+
* (`PUT /public/documents/{documentId}/send-token`).
|
|
2317
|
+
* Sends JSON `{ "recipient": "+5511999998888", "channel": "whatsapp" }`.
|
|
2318
|
+
* @param documentId - Document identifier.
|
|
2319
|
+
* @param recipient - Controlled email address or WhatsApp number.
|
|
2320
|
+
* @param channel - Delivery channel, `email` or `whatsapp`.
|
|
2321
|
+
* @returns Nothing; the acknowledgement body is discarded.
|
|
2322
|
+
* @throws {ValidationError} If an argument is empty.
|
|
2323
|
+
* @throws {ApiError} If delivery is rejected.
|
|
2324
|
+
* @example
|
|
2325
|
+
* ```ts
|
|
2326
|
+
* await client.documents.sendToken('doc-1', 'signer@example.com', 'email');
|
|
2327
|
+
* ```
|
|
2328
|
+
*/
|
|
2135
2329
|
sendToken(documentId: string, recipient: string, channel: SendTokenChannel): Promise<void>;
|
|
2136
2330
|
/**
|
|
2137
2331
|
* Quick boolean check (`GET /documents/{documentId}`): has every signer
|
|
@@ -2197,13 +2391,27 @@ declare class SignerResource extends BaseResource {
|
|
|
2197
2391
|
* A reused signer is returned unchanged; this method does not overwrite its
|
|
2198
2392
|
* existing name, phone, CPF, or metadata with the create payload.
|
|
2199
2393
|
*
|
|
2394
|
+
* Request body (`application/json`):
|
|
2395
|
+
* ```jsonc
|
|
2396
|
+
* {
|
|
2397
|
+
* "full_name": "Example Signer",
|
|
2398
|
+
* "email": "signer@example.com",
|
|
2399
|
+
* "whatsapp_phone_number": "+5548999990000",
|
|
2400
|
+
* "government_id": "390.533.447-05",
|
|
2401
|
+
* "metadata": {
|
|
2402
|
+
* "reference": "customer_example"
|
|
2403
|
+
* }
|
|
2404
|
+
* }
|
|
2405
|
+
* ```
|
|
2406
|
+
*
|
|
2200
2407
|
* @param payload - The signer to create. The official fields are required
|
|
2201
|
-
* `full_name` plus optional `email
|
|
2202
|
-
* `
|
|
2203
|
-
*
|
|
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.
|
|
2204
2412
|
* @param accountId - Override the client's default account ID.
|
|
2205
|
-
* @returns The created (or reused) signer.
|
|
2206
|
-
* `cpf`
|
|
2413
|
+
* @returns The created (or reused) signer. `government_id` comes back
|
|
2414
|
+
* normalized; `cpf` is **never echoed back**:
|
|
2207
2415
|
* ```jsonc
|
|
2208
2416
|
* {
|
|
2209
2417
|
* "resource": "signer",
|
|
@@ -2211,6 +2419,7 @@ declare class SignerResource extends BaseResource {
|
|
|
2211
2419
|
* "full_name": "Ana Souza",
|
|
2212
2420
|
* "email": "ana@example.com",
|
|
2213
2421
|
* "whatsapp_phone_number": null,
|
|
2422
|
+
* "government_id": "39053344705",
|
|
2214
2423
|
* "has_accepted_terms": false
|
|
2215
2424
|
* }
|
|
2216
2425
|
* ```
|
|
@@ -2224,7 +2433,7 @@ declare class SignerResource extends BaseResource {
|
|
|
2224
2433
|
* const signer = await client.signers.create({
|
|
2225
2434
|
* full_name: 'Ana Souza',
|
|
2226
2435
|
* email: 'ana@example.com',
|
|
2227
|
-
*
|
|
2436
|
+
* government_id: '390.533.447-05', // returned as '39053344705'
|
|
2228
2437
|
* });
|
|
2229
2438
|
*
|
|
2230
2439
|
* // A whatsapp-only signer (no email):
|
|
@@ -2251,6 +2460,7 @@ declare class SignerResource extends BaseResource {
|
|
|
2251
2460
|
* "full_name": "Example Signer",
|
|
2252
2461
|
* "email": "signer@example.com",
|
|
2253
2462
|
* "whatsapp_phone_number": null,
|
|
2463
|
+
* "government_id": "12ABC34501DE35",
|
|
2254
2464
|
* "has_accepted_terms": false
|
|
2255
2465
|
* }
|
|
2256
2466
|
* ```
|
|
@@ -2299,9 +2509,20 @@ declare class SignerResource extends BaseResource {
|
|
|
2299
2509
|
* while it belongs to an in-flight document; changing an unverified channel
|
|
2300
2510
|
* rotates its access/verification codes, so resend the notification.
|
|
2301
2511
|
*
|
|
2512
|
+
* Request body (`application/json`):
|
|
2513
|
+
* ```jsonc
|
|
2514
|
+
* {
|
|
2515
|
+
* "full_name": "Example Signer",
|
|
2516
|
+
* "email": "signer@example.com",
|
|
2517
|
+
* "whatsapp_phone_number": "+5548999990000",
|
|
2518
|
+
* "government_id": "12.ABC.345/01DE-35"
|
|
2519
|
+
* }
|
|
2520
|
+
* ```
|
|
2521
|
+
*
|
|
2302
2522
|
* @param signerId - The signer to update.
|
|
2303
|
-
* @param payload - Fields to change.
|
|
2304
|
-
* 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.
|
|
2305
2526
|
* @param accountId - Override the client's default account ID.
|
|
2306
2527
|
* @returns The updated signer (as with create, `cpf` is never echoed back):
|
|
2307
2528
|
* ```jsonc
|
|
@@ -2311,6 +2532,7 @@ declare class SignerResource extends BaseResource {
|
|
|
2311
2532
|
* "full_name": "Ana Souza Lima",
|
|
2312
2533
|
* "email": "ana@example.com",
|
|
2313
2534
|
* "whatsapp_phone_number": null,
|
|
2535
|
+
* "government_id": "12ABC34501DE35",
|
|
2314
2536
|
* "has_accepted_terms": false
|
|
2315
2537
|
* }
|
|
2316
2538
|
* ```
|
|
@@ -2414,6 +2636,16 @@ declare class WorkspaceResource extends BaseResource {
|
|
|
2414
2636
|
/**
|
|
2415
2637
|
* Create a new workspace (`POST /accounts`).
|
|
2416
2638
|
*
|
|
2639
|
+
* Request body (`application/json`):
|
|
2640
|
+
* ```jsonc
|
|
2641
|
+
* {
|
|
2642
|
+
* "name": "Example Workspace",
|
|
2643
|
+
* "notification_sender_type": "Account",
|
|
2644
|
+
* "primary_color": "336699",
|
|
2645
|
+
* "secondary_color": "ffffff"
|
|
2646
|
+
* }
|
|
2647
|
+
* ```
|
|
2648
|
+
*
|
|
2417
2649
|
* @param payload - Official fields are workspace `name` (required) and
|
|
2418
2650
|
* optional `notification_sender_type` (`User` or `Account`). Optional brand
|
|
2419
2651
|
* colours use six hex characters without
|
|
@@ -2630,6 +2862,16 @@ declare class WorkspaceResource extends BaseResource {
|
|
|
2630
2862
|
/**
|
|
2631
2863
|
* Update a workspace (`PUT /accounts/{accountId}`).
|
|
2632
2864
|
*
|
|
2865
|
+
* Request body (`application/json`):
|
|
2866
|
+
* ```jsonc
|
|
2867
|
+
* {
|
|
2868
|
+
* "name": "Example Workspace",
|
|
2869
|
+
* "notification_sender_type": "Account",
|
|
2870
|
+
* "primary_color": "336699",
|
|
2871
|
+
* "secondary_color": null
|
|
2872
|
+
* }
|
|
2873
|
+
* ```
|
|
2874
|
+
*
|
|
2633
2875
|
* @param accountId - The workspace to update.
|
|
2634
2876
|
* @param payload - Official fields are `name` and
|
|
2635
2877
|
* `notification_sender_type` (`User` or `Account`). Brand colours use six
|
|
@@ -2672,6 +2914,13 @@ declare class WorkspaceResource extends BaseResource {
|
|
|
2672
2914
|
* proceeds with deletion; it is not documented as a blanket override for
|
|
2673
2915
|
* unrelated restrictions. The flag is sent in the request body.
|
|
2674
2916
|
*
|
|
2917
|
+
* Request body (`application/json`):
|
|
2918
|
+
* ```jsonc
|
|
2919
|
+
* {
|
|
2920
|
+
* "force": true
|
|
2921
|
+
* }
|
|
2922
|
+
* ```
|
|
2923
|
+
*
|
|
2675
2924
|
* @param accountId - The workspace to delete.
|
|
2676
2925
|
* @param options - Set `force: true` to cancel an active paid subscription
|
|
2677
2926
|
* and proceed with deletion.
|
|
@@ -2819,6 +3068,28 @@ declare class AssignmentResource extends BaseResource {
|
|
|
2819
3068
|
* `DigitalCertificate` costs two credits, requires the feature plus a
|
|
2820
3069
|
* signer `government_id`, and that signer must be alone in its step.
|
|
2821
3070
|
*
|
|
3071
|
+
* Request body (`application/json`):
|
|
3072
|
+
* ```jsonc
|
|
3073
|
+
* {
|
|
3074
|
+
* "method": "virtual",
|
|
3075
|
+
* "signers": [
|
|
3076
|
+
* {
|
|
3077
|
+
* "id": "signer_example",
|
|
3078
|
+
* "verification_method": "Email",
|
|
3079
|
+
* "notification_methods": [
|
|
3080
|
+
* "Email"
|
|
3081
|
+
* ],
|
|
3082
|
+
* "step": 1
|
|
3083
|
+
* }
|
|
3084
|
+
* ],
|
|
3085
|
+
* "message": "Please sign this document.",
|
|
3086
|
+
* "expires_at": "2027-12-31T23:59:59Z",
|
|
3087
|
+
* "copy_receivers": [
|
|
3088
|
+
* "copy_signer_example"
|
|
3089
|
+
* ]
|
|
3090
|
+
* }
|
|
3091
|
+
* ```
|
|
3092
|
+
*
|
|
2822
3093
|
* @param documentId - The document to request signatures on.
|
|
2823
3094
|
* @param payload - Signers plus optional `method` (defaults to `virtual`),
|
|
2824
3095
|
* `message`, `expires_at`, `copy_receivers` (existing signer IDs, not
|
|
@@ -2922,6 +3193,21 @@ declare class AssignmentResource extends BaseResource {
|
|
|
2922
3193
|
* email notification, and 0.45 for WhatsApp notification; a digital
|
|
2923
3194
|
* certificate charge is added on top of its notification cost.
|
|
2924
3195
|
*
|
|
3196
|
+
* Request body (`application/json`):
|
|
3197
|
+
* ```jsonc
|
|
3198
|
+
* {
|
|
3199
|
+
* "method": "virtual",
|
|
3200
|
+
* "signers": [
|
|
3201
|
+
* {
|
|
3202
|
+
* "verification_method": "Email",
|
|
3203
|
+
* "notification_methods": [
|
|
3204
|
+
* "Email"
|
|
3205
|
+
* ]
|
|
3206
|
+
* }
|
|
3207
|
+
* ]
|
|
3208
|
+
* }
|
|
3209
|
+
* ```
|
|
3210
|
+
*
|
|
2925
3211
|
* @param documentId - The document the assignment would be created on.
|
|
2926
3212
|
* @param payload - `method` plus channel-only signer descriptors and/or
|
|
2927
3213
|
* `collect`-mode `entries`. Create-only fields and signer IDs are not part
|
|
@@ -2968,6 +3254,13 @@ declare class AssignmentResource extends BaseResource {
|
|
|
2968
3254
|
* is retained as a compatibility value and, unlike ordinary nullable
|
|
2969
3255
|
* inputs, is intentionally not stripped from the body.
|
|
2970
3256
|
*
|
|
3257
|
+
* Request body (`application/json`):
|
|
3258
|
+
* ```jsonc
|
|
3259
|
+
* {
|
|
3260
|
+
* "expires_at": "2027-12-31T23:59:59Z"
|
|
3261
|
+
* }
|
|
3262
|
+
* ```
|
|
3263
|
+
*
|
|
2971
3264
|
* @param documentId - The document the assignment belongs to.
|
|
2972
3265
|
* @param assignmentId - The assignment to update.
|
|
2973
3266
|
* @param expiresAt - New expiry as an ISO-8601 date/time string. `null` is
|
|
@@ -3123,21 +3416,35 @@ declare class AssignmentResource extends BaseResource {
|
|
|
3123
3416
|
}
|
|
3124
3417
|
|
|
3125
3418
|
/**
|
|
3126
|
-
* Default webhook events applied by {@link WebhookResource.register}
|
|
3127
|
-
* 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).
|
|
3128
3422
|
*/
|
|
3129
3423
|
declare const DEFAULT_WEBHOOK_EVENTS: readonly WebhookEventType[];
|
|
3130
3424
|
declare class WebhookResource extends BaseResource {
|
|
3131
3425
|
/**
|
|
3132
|
-
*
|
|
3133
|
-
* (`PUT /accounts/{accountId}/webhooks/subscriptions`).
|
|
3134
|
-
*
|
|
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}.
|
|
3135
3429
|
*
|
|
3136
3430
|
* When `events` is omitted or empty, {@link DEFAULT_WEBHOOK_EVENTS} is used
|
|
3137
3431
|
* (`document_ready`, `document_prepared`, `signer_signed_document`,
|
|
3138
3432
|
* `signer_rejected_document`, `document_processing_failed`).
|
|
3139
3433
|
* OAuth tokens need the `webhooks:write` scope.
|
|
3140
3434
|
*
|
|
3435
|
+
* Request body (`application/json`):
|
|
3436
|
+
* ```jsonc
|
|
3437
|
+
* {
|
|
3438
|
+
* "events": [
|
|
3439
|
+
* "document_ready",
|
|
3440
|
+
* "document_prepared"
|
|
3441
|
+
* ],
|
|
3442
|
+
* "is_active": true,
|
|
3443
|
+
* "url": "https://myapp.example.com/webhooks/assinafy",
|
|
3444
|
+
* "email": "operations@example.com"
|
|
3445
|
+
* }
|
|
3446
|
+
* ```
|
|
3447
|
+
*
|
|
3141
3448
|
* @param payload - Subscription details. `url` and `email` are required;
|
|
3142
3449
|
* `events` defaults to {@link DEFAULT_WEBHOOK_EVENTS} and `is_active`
|
|
3143
3450
|
* defaults to `true`.
|
|
@@ -3178,8 +3485,9 @@ declare class WebhookResource extends BaseResource {
|
|
|
3178
3485
|
*/
|
|
3179
3486
|
register(payload: IWebhookRegisterPayload, accountId?: string): Promise<IWebhookSubscription>;
|
|
3180
3487
|
/**
|
|
3181
|
-
* Fetch the
|
|
3182
|
-
* (`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}.
|
|
3183
3491
|
*
|
|
3184
3492
|
* @param accountId - Override the client's default account ID.
|
|
3185
3493
|
* @returns The subscription, or `null` when the workspace has none (the API
|
|
@@ -3213,13 +3521,14 @@ declare class WebhookResource extends BaseResource {
|
|
|
3213
3521
|
*/
|
|
3214
3522
|
get(accountId?: string): Promise<IWebhookSubscription | null>;
|
|
3215
3523
|
/**
|
|
3216
|
-
*
|
|
3217
|
-
* (`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.
|
|
3218
3528
|
*
|
|
3219
|
-
*
|
|
3220
|
-
*
|
|
3221
|
-
*
|
|
3222
|
-
* {@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`.
|
|
3223
3532
|
* OAuth tokens need the `webhooks:write` scope.
|
|
3224
3533
|
*
|
|
3225
3534
|
* @param accountId - Override the client's default account ID.
|
|
@@ -3292,6 +3601,7 @@ declare class WebhookResource extends BaseResource {
|
|
|
3292
3601
|
* truncated to 2,000 characters.
|
|
3293
3602
|
*
|
|
3294
3603
|
* @param params - Optional filters and pagination:
|
|
3604
|
+
* - `endpoint_id` — only deliveries to this webhook endpoint.
|
|
3295
3605
|
* - `event` — restrict to a single {@link WebhookEventType}
|
|
3296
3606
|
* (e.g. `'signer_signed_document'`).
|
|
3297
3607
|
* - `delivered` — `true`/`false` to filter by delivery success.
|
|
@@ -3306,6 +3616,7 @@ declare class WebhookResource extends BaseResource {
|
|
|
3306
3616
|
* "id": "103a09cfce51319dd3b3f72ffcdf",
|
|
3307
3617
|
* "event": "signature_requested",
|
|
3308
3618
|
* "activity_id": 8629,
|
|
3619
|
+
* "endpoint_id": "65f1c2a9b3e4d5f60718293a4b5c6d7e", // null once the endpoint is deleted
|
|
3309
3620
|
* "endpoint": "https://example.com/hook",
|
|
3310
3621
|
* "payload": {
|
|
3311
3622
|
* // the full event body that was POSTed to `endpoint`:
|
|
@@ -3340,7 +3651,7 @@ declare class WebhookResource extends BaseResource {
|
|
|
3340
3651
|
/**
|
|
3341
3652
|
* Retry delivery of a specific webhook dispatch
|
|
3342
3653
|
* (`POST /accounts/{accountId}/webhooks/{historyId}/retry`). Re-sends the
|
|
3343
|
-
* original payload to the
|
|
3654
|
+
* original payload to the endpoint that received it.
|
|
3344
3655
|
*
|
|
3345
3656
|
* @param dispatchId - The dispatch (delivery history) ID to re-send, as
|
|
3346
3657
|
* returned by {@link WebhookResource.listDispatches}.
|
|
@@ -3354,6 +3665,7 @@ declare class WebhookResource extends BaseResource {
|
|
|
3354
3665
|
* "id": "103a09cfce51319dd3b3f72ffcdf",
|
|
3355
3666
|
* "event": "signature_requested",
|
|
3356
3667
|
* "activity_id": 8629,
|
|
3668
|
+
* "endpoint_id": "65f1c2a9b3e4d5f60718293a4b5c6d7e", // null once the endpoint is deleted
|
|
3357
3669
|
* "endpoint": "https://example.com/hook",
|
|
3358
3670
|
* "payload": { }, // the original event body that was re-POSTed
|
|
3359
3671
|
* "delivered": true,
|
|
@@ -3375,6 +3687,251 @@ declare class WebhookResource extends BaseResource {
|
|
|
3375
3687
|
* ```
|
|
3376
3688
|
*/
|
|
3377
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;
|
|
3378
3935
|
}
|
|
3379
3936
|
|
|
3380
3937
|
/**
|
|
@@ -3557,6 +4114,14 @@ declare class TemplateResource extends BaseResource {
|
|
|
3557
4114
|
* `undefined` keys before sending. Unlike uploads, `name` here is a plain
|
|
3558
4115
|
* display name and is **not** forced to end in `.pdf`.
|
|
3559
4116
|
*
|
|
4117
|
+
* Request body (`application/json`):
|
|
4118
|
+
* ```jsonc
|
|
4119
|
+
* {
|
|
4120
|
+
* "name": "Service agreement.pdf",
|
|
4121
|
+
* "message": "Please sign this document."
|
|
4122
|
+
* }
|
|
4123
|
+
* ```
|
|
4124
|
+
*
|
|
3560
4125
|
* @param templateId - The template to update.
|
|
3561
4126
|
* @param payload - `name` and/or `message`; both optional.
|
|
3562
4127
|
* @param accountId - Override the client's default account ID.
|
|
@@ -3699,6 +4264,14 @@ declare class TagResource extends BaseResource {
|
|
|
3699
4264
|
* and `'ff8800'` both persist as `'ff8800'`. Omit `color`
|
|
3700
4265
|
* (or pass `null`) for no color.
|
|
3701
4266
|
*
|
|
4267
|
+
* Request body (`application/json`):
|
|
4268
|
+
* ```jsonc
|
|
4269
|
+
* {
|
|
4270
|
+
* "name": "Contracts",
|
|
4271
|
+
* "color": "ff8800"
|
|
4272
|
+
* }
|
|
4273
|
+
* ```
|
|
4274
|
+
*
|
|
3702
4275
|
* @param payload - `name` (required, max 64 characters; trimmed with
|
|
3703
4276
|
* internal whitespace collapsed) and optional `color`.
|
|
3704
4277
|
* @param accountId - Override the client's default account ID.
|
|
@@ -3734,6 +4307,14 @@ declare class TagResource extends BaseResource {
|
|
|
3734
4307
|
* leading `#` on `color` is accepted and stripped by the API
|
|
3735
4308
|
* (`'#112233'` → `'112233'`).
|
|
3736
4309
|
*
|
|
4310
|
+
* Request body (`application/json`):
|
|
4311
|
+
* ```jsonc
|
|
4312
|
+
* {
|
|
4313
|
+
* "name": "Signed contracts",
|
|
4314
|
+
* "color": null
|
|
4315
|
+
* }
|
|
4316
|
+
* ```
|
|
4317
|
+
*
|
|
3737
4318
|
* @param tagId - The tag to update.
|
|
3738
4319
|
* @param payload - `name` and/or `color`. `color: null` clears the color;
|
|
3739
4320
|
* omit a field to leave it unchanged.
|
|
@@ -3854,6 +4435,14 @@ declare class AuthenticationResource extends BaseResource {
|
|
|
3854
4435
|
* `X-Api-Key` (see {@link AuthenticationResource.createApiKey}) instead of
|
|
3855
4436
|
* storing a password.
|
|
3856
4437
|
*
|
|
4438
|
+
* Request body (`application/json`):
|
|
4439
|
+
* ```jsonc
|
|
4440
|
+
* {
|
|
4441
|
+
* "email": "user@example.com",
|
|
4442
|
+
* "password": "example-password"
|
|
4443
|
+
* }
|
|
4444
|
+
* ```
|
|
4445
|
+
*
|
|
3857
4446
|
* @param email - The user's email address, e.g. `'user@example.com'`.
|
|
3858
4447
|
* @param password - The user's password.
|
|
3859
4448
|
* @returns An {@link ILoginResponse} with the access token, user, and
|
|
@@ -3884,6 +4473,9 @@ declare class AuthenticationResource extends BaseResource {
|
|
|
3884
4473
|
* }
|
|
3885
4474
|
* ```
|
|
3886
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}.
|
|
3887
4479
|
* @throws {ApiError} `400` if the credentials are rejected.
|
|
3888
4480
|
*
|
|
3889
4481
|
* @example
|
|
@@ -3895,6 +4487,45 @@ declare class AuthenticationResource extends BaseResource {
|
|
|
3895
4487
|
* ```
|
|
3896
4488
|
*/
|
|
3897
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>;
|
|
3898
4529
|
/**
|
|
3899
4530
|
* Log in with a social provider (`POST /authentication/social-login`).
|
|
3900
4531
|
*
|
|
@@ -3902,6 +4533,15 @@ declare class AuthenticationResource extends BaseResource {
|
|
|
3902
4533
|
* Assinafy JWT. Returns the same {@link ILoginResponse} shape as
|
|
3903
4534
|
* {@link AuthenticationResource.login}.
|
|
3904
4535
|
*
|
|
4536
|
+
* Request body (`application/json`):
|
|
4537
|
+
* ```jsonc
|
|
4538
|
+
* {
|
|
4539
|
+
* "provider": "google",
|
|
4540
|
+
* "token": "provider_token_example",
|
|
4541
|
+
* "has_accepted_terms": true
|
|
4542
|
+
* }
|
|
4543
|
+
* ```
|
|
4544
|
+
*
|
|
3905
4545
|
* @param payload - The social-login body.
|
|
3906
4546
|
* @param payload.provider - OAuth provider; currently exactly `'google'`.
|
|
3907
4547
|
* @param payload.token - The provider-issued OAuth/ID token.
|
|
@@ -3964,6 +4604,14 @@ declare class AuthenticationResource extends BaseResource {
|
|
|
3964
4604
|
* The response is the standard status/message acknowledgement with no data,
|
|
3965
4605
|
* so this method resolves to `void`.
|
|
3966
4606
|
*
|
|
4607
|
+
* Request body (`application/json`):
|
|
4608
|
+
* ```jsonc
|
|
4609
|
+
* {
|
|
4610
|
+
* "provider": "google",
|
|
4611
|
+
* "token": "provider_token_example"
|
|
4612
|
+
* }
|
|
4613
|
+
* ```
|
|
4614
|
+
*
|
|
3967
4615
|
* @param payload - Social provider and provider-issued access/ID token.
|
|
3968
4616
|
* @returns Resolves when the API acknowledges that the identity was linked.
|
|
3969
4617
|
* @throws {ValidationError} If `provider` is not `google` or `token` is empty.
|
|
@@ -3990,6 +4638,13 @@ declare class AuthenticationResource extends BaseResource {
|
|
|
3990
4638
|
* a masked value. Calling this again rotates the key, invalidating the
|
|
3991
4639
|
* previous one.
|
|
3992
4640
|
*
|
|
4641
|
+
* Request body (`application/json`):
|
|
4642
|
+
* ```jsonc
|
|
4643
|
+
* {
|
|
4644
|
+
* "password": "example-password"
|
|
4645
|
+
* }
|
|
4646
|
+
* ```
|
|
4647
|
+
*
|
|
3993
4648
|
* @param password - The current user's password, required to authorize
|
|
3994
4649
|
* key generation.
|
|
3995
4650
|
* @returns An {@link IApiKeyResponse} containing the new key. Response
|
|
@@ -4060,6 +4715,15 @@ declare class AuthenticationResource extends BaseResource {
|
|
|
4060
4715
|
* Requires the current password as a confirmation. On success the API
|
|
4061
4716
|
* echoes back the affected `email`.
|
|
4062
4717
|
*
|
|
4718
|
+
* Request body (`application/json`):
|
|
4719
|
+
* ```jsonc
|
|
4720
|
+
* {
|
|
4721
|
+
* "email": "user@example.com",
|
|
4722
|
+
* "password": "example-password",
|
|
4723
|
+
* "new_password": "new-example-password"
|
|
4724
|
+
* }
|
|
4725
|
+
* ```
|
|
4726
|
+
*
|
|
4063
4727
|
* @param payload - The change-password body.
|
|
4064
4728
|
* @param payload.email - The user's email address.
|
|
4065
4729
|
* @param payload.password - The current password.
|
|
@@ -4099,6 +4763,13 @@ declare class AuthenticationResource extends BaseResource {
|
|
|
4099
4763
|
* Triggers Assinafy to email a reset link/token to the given address.
|
|
4100
4764
|
* Complete the flow with {@link AuthenticationResource.resetPassword}.
|
|
4101
4765
|
*
|
|
4766
|
+
* Request body (`application/json`):
|
|
4767
|
+
* ```jsonc
|
|
4768
|
+
* {
|
|
4769
|
+
* "email": "user@example.com"
|
|
4770
|
+
* }
|
|
4771
|
+
* ```
|
|
4772
|
+
*
|
|
4102
4773
|
* @param email - The email address to send the reset link to.
|
|
4103
4774
|
* @returns `{ email }` — the address the reset link was sent to. Response
|
|
4104
4775
|
* shape:
|
|
@@ -4126,6 +4797,15 @@ declare class AuthenticationResource extends BaseResource {
|
|
|
4126
4797
|
* {@link AuthenticationResource.requestPasswordReset} and sets the new
|
|
4127
4798
|
* password. On success the API echoes back the affected `email`.
|
|
4128
4799
|
*
|
|
4800
|
+
* Request body (`application/json`):
|
|
4801
|
+
* ```jsonc
|
|
4802
|
+
* {
|
|
4803
|
+
* "email": "user@example.com",
|
|
4804
|
+
* "token": "reset_token_example",
|
|
4805
|
+
* "new_password": "new-example-password"
|
|
4806
|
+
* }
|
|
4807
|
+
* ```
|
|
4808
|
+
*
|
|
4129
4809
|
* @param payload - The reset-password body.
|
|
4130
4810
|
* @param payload.email - The user's email address.
|
|
4131
4811
|
* @param payload.token - The reset token from the emailed link. The current
|
|
@@ -4218,20 +4898,20 @@ type TokenEndpointAuthOptions = {
|
|
|
4218
4898
|
* // Step 1 — before redirecting the user
|
|
4219
4899
|
* const request = await client.oauth.createAuthorizationUrl({
|
|
4220
4900
|
* clientId: process.env.ASSINAFY_CLIENT_ID!,
|
|
4221
|
-
* redirectUri: 'https://myapp.com/oauth/callback',
|
|
4222
|
-
* scopes: ['documents:read', 'documents:write', 'offline_access'],
|
|
4901
|
+
* redirectUri: 'https://myapp.example.com/oauth/callback',
|
|
4902
|
+
* scopes: ['documents:read', 'documents:write', 'account:read', 'offline_access'],
|
|
4223
4903
|
* });
|
|
4224
4904
|
* session.oauth = request; // state + codeVerifier + issuer
|
|
4225
4905
|
* response.redirect(request.url);
|
|
4226
4906
|
*
|
|
4227
|
-
* // Step 3/4 — on https://myapp.com/oauth/callback
|
|
4907
|
+
* // Step 3/4 — on https://myapp.example.com/oauth/callback
|
|
4228
4908
|
* const { code } = client.oauth.readAuthorizationCallback(query, session.oauth);
|
|
4229
4909
|
* const tokens = await client.oauth.exchangeCode({
|
|
4230
4910
|
* code,
|
|
4231
4911
|
* codeVerifier: session.oauth.codeVerifier,
|
|
4232
|
-
* redirectUri: 'https://myapp.com/oauth/callback',
|
|
4912
|
+
* redirectUri: 'https://myapp.example.com/oauth/callback',
|
|
4233
4913
|
* clientId: process.env.ASSINAFY_CLIENT_ID!,
|
|
4234
|
-
* clientSecret: process.env.ASSINAFY_CLIENT_SECRET
|
|
4914
|
+
* clientSecret: process.env.ASSINAFY_CLIENT_SECRET!,
|
|
4235
4915
|
* });
|
|
4236
4916
|
* ```
|
|
4237
4917
|
*/
|
|
@@ -4377,8 +5057,8 @@ declare class OAuthResource extends BaseResource {
|
|
|
4377
5057
|
* ```ts
|
|
4378
5058
|
* const request = await client.oauth.createAuthorizationUrl({
|
|
4379
5059
|
* clientId: process.env.ASSINAFY_CLIENT_ID!,
|
|
4380
|
-
* redirectUri: 'https://myapp.com/oauth/callback',
|
|
4381
|
-
* scopes: ['documents:read', 'documents:write', 'offline_access'],
|
|
5060
|
+
* redirectUri: 'https://myapp.example.com/oauth/callback',
|
|
5061
|
+
* scopes: ['documents:read', 'documents:write', 'account:read', 'offline_access'],
|
|
4382
5062
|
* });
|
|
4383
5063
|
* session.oauth = request;
|
|
4384
5064
|
* response.redirect(request.url);
|
|
@@ -4429,8 +5109,8 @@ declare class OAuthResource extends BaseResource {
|
|
|
4429
5109
|
* ```
|
|
4430
5110
|
* @throws {ValidationError} If `state` is missing or does not match, `iss`
|
|
4431
5111
|
* is absent or disagrees with the expected issuer, or a successful response
|
|
4432
|
-
* carries no `code
|
|
4433
|
-
*
|
|
5112
|
+
* carries no `code`, or a protocol parameter appears more than once.
|
|
5113
|
+
* Reject such responses without exchanging the code.
|
|
4434
5114
|
* @throws {OAuthError} If the server returned `error` (e.g.
|
|
4435
5115
|
* `access_denied`, `invalid_scope`, `invalid_request`,
|
|
4436
5116
|
* `unsupported_response_type`, `invalid_target`).
|
|
@@ -4443,9 +5123,9 @@ declare class OAuthResource extends BaseResource {
|
|
|
4443
5123
|
* const tokens = await client.oauth.exchangeCode({
|
|
4444
5124
|
* code,
|
|
4445
5125
|
* codeVerifier: stored.codeVerifier,
|
|
4446
|
-
* redirectUri: 'https://myapp.com/oauth/callback',
|
|
5126
|
+
* redirectUri: 'https://myapp.example.com/oauth/callback',
|
|
4447
5127
|
* clientId: process.env.ASSINAFY_CLIENT_ID!,
|
|
4448
|
-
* clientSecret: process.env.ASSINAFY_CLIENT_SECRET
|
|
5128
|
+
* clientSecret: process.env.ASSINAFY_CLIENT_SECRET!,
|
|
4449
5129
|
* });
|
|
4450
5130
|
* });
|
|
4451
5131
|
* ```
|
|
@@ -4463,6 +5143,12 @@ declare class OAuthResource extends BaseResource {
|
|
|
4463
5143
|
* a browser. Every value must match the authorization request exactly, or
|
|
4464
5144
|
* the API answers `invalid_grant`.
|
|
4465
5145
|
*
|
|
5146
|
+
* Request body (`application/x-www-form-urlencoded`; omit `client_secret`
|
|
5147
|
+
* for public applications):
|
|
5148
|
+
* ```text
|
|
5149
|
+
* grant_type=authorization_code&code=code_example&redirect_uri=https%3A%2F%2Fmyapp.example.com%2Foauth%2Fcallback&client_id=client_example&client_secret=secret_example&code_verifier=dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk&resource=https%3A%2F%2Fapi.assinafy.com.br
|
|
5150
|
+
* ```
|
|
5151
|
+
*
|
|
4466
5152
|
* @param options - Exchange options.
|
|
4467
5153
|
* @param options.code - The code from
|
|
4468
5154
|
* {@link OAuthResource.readAuthorizationCallback}.
|
|
@@ -4498,9 +5184,9 @@ declare class OAuthResource extends BaseResource {
|
|
|
4498
5184
|
* const tokens = await client.oauth.exchangeCode({
|
|
4499
5185
|
* code,
|
|
4500
5186
|
* codeVerifier: session.oauth.codeVerifier,
|
|
4501
|
-
* redirectUri: 'https://myapp.com/oauth/callback',
|
|
5187
|
+
* redirectUri: 'https://myapp.example.com/oauth/callback',
|
|
4502
5188
|
* clientId: process.env.ASSINAFY_CLIENT_ID!,
|
|
4503
|
-
* clientSecret: process.env.ASSINAFY_CLIENT_SECRET
|
|
5189
|
+
* clientSecret: process.env.ASSINAFY_CLIENT_SECRET!,
|
|
4504
5190
|
* });
|
|
4505
5191
|
* ```
|
|
4506
5192
|
*/
|
|
@@ -4528,6 +5214,12 @@ declare class OAuthResource extends BaseResource {
|
|
|
4528
5214
|
* only expires if it goes 30 days without a refresh; after that the user
|
|
4529
5215
|
* has to reconnect.
|
|
4530
5216
|
*
|
|
5217
|
+
* Request body (`application/x-www-form-urlencoded`; omit `client_secret`
|
|
5218
|
+
* for public applications):
|
|
5219
|
+
* ```text
|
|
5220
|
+
* grant_type=refresh_token&refresh_token=refresh_token_example&client_id=client_example&client_secret=secret_example&resource=https%3A%2F%2Fapi.assinafy.com.br
|
|
5221
|
+
* ```
|
|
5222
|
+
*
|
|
4531
5223
|
* @param options - Refresh options.
|
|
4532
5224
|
* @param options.refreshToken - The current refresh token.
|
|
4533
5225
|
* @param options.clientId - The application's `client_id`.
|
|
@@ -4558,7 +5250,7 @@ declare class OAuthResource extends BaseResource {
|
|
|
4558
5250
|
* const tokens = await client.oauth.refreshToken({
|
|
4559
5251
|
* refreshToken: connection.refreshToken,
|
|
4560
5252
|
* clientId: process.env.ASSINAFY_CLIENT_ID!,
|
|
4561
|
-
* clientSecret: process.env.ASSINAFY_CLIENT_SECRET
|
|
5253
|
+
* clientSecret: process.env.ASSINAFY_CLIENT_SECRET!,
|
|
4562
5254
|
* });
|
|
4563
5255
|
* await connection.save({ refreshToken: tokens.refresh_token });
|
|
4564
5256
|
* ```
|
|
@@ -4599,7 +5291,7 @@ declare class OAuthResource extends BaseResource {
|
|
|
4599
5291
|
* token: connection.refreshToken,
|
|
4600
5292
|
* tokenTypeHint: 'refresh_token',
|
|
4601
5293
|
* clientId: process.env.ASSINAFY_CLIENT_ID!,
|
|
4602
|
-
* clientSecret: process.env.ASSINAFY_CLIENT_SECRET
|
|
5294
|
+
* clientSecret: process.env.ASSINAFY_CLIENT_SECRET!,
|
|
4603
5295
|
* });
|
|
4604
5296
|
* ```
|
|
4605
5297
|
*/
|
|
@@ -4626,8 +5318,8 @@ declare class OAuthResource extends BaseResource {
|
|
|
4626
5318
|
* "email_verified": true
|
|
4627
5319
|
* }
|
|
4628
5320
|
* ```
|
|
4629
|
-
* `sub` is the stable user identifier;
|
|
4630
|
-
* was not granted.
|
|
5321
|
+
* `sub` is the stable user identifier; other claims may be omitted or
|
|
5322
|
+
* `null` when their scope was not granted.
|
|
4631
5323
|
* @throws {ValidationError} If `accessToken` is supplied but empty.
|
|
4632
5324
|
* @throws {ApiError} `401` when the token is missing, expired or revoked;
|
|
4633
5325
|
* `403` when the `openid` scope was not granted — its `WWW-Authenticate`
|
|
@@ -4687,6 +5379,17 @@ declare class FieldsResource extends BaseResource {
|
|
|
4687
5379
|
/**
|
|
4688
5380
|
* Create a field definition (`POST /accounts/{accountId}/fields`).
|
|
4689
5381
|
*
|
|
5382
|
+
* Request body (`application/json`):
|
|
5383
|
+
* ```jsonc
|
|
5384
|
+
* {
|
|
5385
|
+
* "type": "text",
|
|
5386
|
+
* "name": "Reference",
|
|
5387
|
+
* "regex": null,
|
|
5388
|
+
* "is_required": true,
|
|
5389
|
+
* "is_active": true
|
|
5390
|
+
* }
|
|
5391
|
+
* ```
|
|
5392
|
+
*
|
|
4690
5393
|
* @param payload - The field to create. `type` and `name` are required;
|
|
4691
5394
|
* `type` must be one of the platform field types (see
|
|
4692
5395
|
* {@link FieldsResource.listTypes}); `regex` may be a string or `null`,
|
|
@@ -4794,6 +5497,15 @@ declare class FieldsResource extends BaseResource {
|
|
|
4794
5497
|
* Update a field definition
|
|
4795
5498
|
* (`PUT /accounts/{accountId}/fields/{fieldId}`).
|
|
4796
5499
|
*
|
|
5500
|
+
* Request body (`application/json`):
|
|
5501
|
+
* ```jsonc
|
|
5502
|
+
* {
|
|
5503
|
+
* "name": "Customer reference",
|
|
5504
|
+
* "regex": null,
|
|
5505
|
+
* "is_active": true
|
|
5506
|
+
* }
|
|
5507
|
+
* ```
|
|
5508
|
+
*
|
|
4797
5509
|
* @param fieldId - The field definition to update.
|
|
4798
5510
|
* @param payload - Fields are `name`, nullable `regex`, and `is_active`;
|
|
4799
5511
|
* `type` and `is_required` are compatibility extensions.
|
|
@@ -4853,6 +5565,13 @@ declare class FieldsResource extends BaseResource {
|
|
|
4853
5565
|
* `signerAccessCode` is a compatibility query and is sent as
|
|
4854
5566
|
* `signer-access-code` when supplied.
|
|
4855
5567
|
*
|
|
5568
|
+
* Request body (`application/json`):
|
|
5569
|
+
* ```jsonc
|
|
5570
|
+
* {
|
|
5571
|
+
* "value": "Example value"
|
|
5572
|
+
* }
|
|
5573
|
+
* ```
|
|
5574
|
+
*
|
|
4856
5575
|
* @param fieldId - The field definition to validate against.
|
|
4857
5576
|
* @param value - The value to check (validated against the field's
|
|
4858
5577
|
* type/regex). Sent as `{ value }` in the request body.
|
|
@@ -4891,6 +5610,16 @@ declare class FieldsResource extends BaseResource {
|
|
|
4891
5610
|
* same compatibility extension described on
|
|
4892
5611
|
* {@link FieldsResource.validate}.
|
|
4893
5612
|
*
|
|
5613
|
+
* Request body (`application/json`):
|
|
5614
|
+
* ```jsonc
|
|
5615
|
+
* [
|
|
5616
|
+
* {
|
|
5617
|
+
* "field_id": "field_example",
|
|
5618
|
+
* "value": "Example value"
|
|
5619
|
+
* }
|
|
5620
|
+
* ]
|
|
5621
|
+
* ```
|
|
5622
|
+
*
|
|
4894
5623
|
* @param entries - Non-empty array of `{ field_id, value }` pairs.
|
|
4895
5624
|
* @param options - Account override and optional legacy `signerAccessCode`.
|
|
4896
5625
|
* @returns One validation result per entry. Response shape:
|
|
@@ -5142,6 +5871,15 @@ declare class SignerDocumentsResource extends BaseResource {
|
|
|
5142
5871
|
* The `document_ids` array goes in the request body; the access code
|
|
5143
5872
|
* authenticates via the `signer-access-code` query param.
|
|
5144
5873
|
*
|
|
5874
|
+
* Request body (`application/json`):
|
|
5875
|
+
* ```jsonc
|
|
5876
|
+
* {
|
|
5877
|
+
* "document_ids": [
|
|
5878
|
+
* "document_example"
|
|
5879
|
+
* ]
|
|
5880
|
+
* }
|
|
5881
|
+
* ```
|
|
5882
|
+
*
|
|
5145
5883
|
* @param documentIds - Non-empty array of document IDs to sign.
|
|
5146
5884
|
* @param signerAccessCode - The signer's access code, from their signing link.
|
|
5147
5885
|
* @returns Resolves when the API acknowledges the operation. The documented
|
|
@@ -5170,6 +5908,16 @@ declare class SignerDocumentsResource extends BaseResource {
|
|
|
5170
5908
|
* Both `document_ids` and `decline_reason` go in the request body; the access
|
|
5171
5909
|
* code authenticates via the `signer-access-code` query param.
|
|
5172
5910
|
*
|
|
5911
|
+
* Request body (`application/json`):
|
|
5912
|
+
* ```jsonc
|
|
5913
|
+
* {
|
|
5914
|
+
* "document_ids": [
|
|
5915
|
+
* "document_example"
|
|
5916
|
+
* ],
|
|
5917
|
+
* "decline_reason": "The document needs a correction."
|
|
5918
|
+
* }
|
|
5919
|
+
* ```
|
|
5920
|
+
*
|
|
5173
5921
|
* @param documentIds - Non-empty array of document IDs to decline.
|
|
5174
5922
|
* @param declineReason - Free-text reason shown to the sender (required).
|
|
5175
5923
|
* @param signerAccessCode - The signer's access code, from their signing link.
|
|
@@ -5259,6 +6007,13 @@ declare class SignerDocumentsResource extends BaseResource {
|
|
|
5259
6007
|
* **body carries only `verification-code`** (putting the access code in the
|
|
5260
6008
|
* body leaves the request unauthenticated → `401`).
|
|
5261
6009
|
*
|
|
6010
|
+
* Request body (`application/json`):
|
|
6011
|
+
* ```jsonc
|
|
6012
|
+
* {
|
|
6013
|
+
* "verification-code": "123456"
|
|
6014
|
+
* }
|
|
6015
|
+
* ```
|
|
6016
|
+
*
|
|
5262
6017
|
* @param payload - `signerAccessCode` (the signing-link code) and
|
|
5263
6018
|
* `verificationCode` (the OTP the signer received).
|
|
5264
6019
|
* @returns Resolves when the API acknowledges the operation. The response
|
|
@@ -5293,6 +6048,16 @@ declare class SignerDocumentsResource extends BaseResource {
|
|
|
5293
6048
|
* `has_accepted_terms: true` here or call
|
|
5294
6049
|
* {@link SignerDocumentsResource.acceptTerms} before fetching the assignment.
|
|
5295
6050
|
*
|
|
6051
|
+
* Request body (`application/json`):
|
|
6052
|
+
* ```jsonc
|
|
6053
|
+
* {
|
|
6054
|
+
* "full_name": "Example Signer",
|
|
6055
|
+
* "email": "signer@example.com",
|
|
6056
|
+
* "government_id": "39053344705",
|
|
6057
|
+
* "has_accepted_terms": true
|
|
6058
|
+
* }
|
|
6059
|
+
* ```
|
|
6060
|
+
*
|
|
5296
6061
|
* @param documentId - The document the signer is confirming data for.
|
|
5297
6062
|
* @param signerAccessCode - The signer's access code, from their signing link.
|
|
5298
6063
|
* @param payload - Any of the official `full_name`, `email`, or
|
|
@@ -5326,8 +6091,23 @@ declare class SignerDocumentsResource extends BaseResource {
|
|
|
5326
6091
|
*/
|
|
5327
6092
|
confirmData(documentId: string, signerAccessCode: string, payload: IConfirmSignerDataPayload): Promise<ISigner>;
|
|
5328
6093
|
/**
|
|
6094
|
+
* Confirm signer data with the compatibility phone field
|
|
6095
|
+
* (`PUT /documents/{documentId}/signers/confirm-data`).
|
|
5329
6096
|
* @deprecated Compatibility overload preserving the previous wire shape.
|
|
5330
6097
|
* `whatsapp_phone_number` is a compatibility pass-through field.
|
|
6098
|
+
* @param documentId - Document identifier.
|
|
6099
|
+
* @param signerAccessCode - Access code sent in the query string.
|
|
6100
|
+
* @param payload - Identity fields, including `whatsapp_phone_number`.
|
|
6101
|
+
* @returns The signer; see the primary overload for its response payload.
|
|
6102
|
+
* @throws {ValidationError} If identity fields or identifiers are invalid.
|
|
6103
|
+
* @throws {ApiError} If the API rejects the confirmation.
|
|
6104
|
+
* @example
|
|
6105
|
+
* ```ts
|
|
6106
|
+
* // JSON body: { "whatsapp_phone_number": "+5511999998888" }
|
|
6107
|
+
* await client.signerDocuments.confirmData(documentId, accessCode, {
|
|
6108
|
+
* whatsapp_phone_number: '+5511999998888',
|
|
6109
|
+
* });
|
|
6110
|
+
* ```
|
|
5331
6111
|
*/
|
|
5332
6112
|
confirmData(documentId: string, signerAccessCode: string, payload: ILegacyConfirmSignerDataPayload): Promise<ISigner>;
|
|
5333
6113
|
/**
|
|
@@ -5362,8 +6142,22 @@ declare class SignerDocumentsResource extends BaseResource {
|
|
|
5362
6142
|
*/
|
|
5363
6143
|
uploadSignature(signerAccessCode: string, image: Buffer, options?: IUploadSignatureOptions): Promise<void>;
|
|
5364
6144
|
/**
|
|
6145
|
+
* Upload a signature image using a compatibility content type
|
|
6146
|
+
* (`POST /signature?signer-access-code=…&type=…`).
|
|
5365
6147
|
* @deprecated Compatibility overload for non-PNG media types. The current
|
|
5366
6148
|
* OpenAPI contract specifies only `image/png`; other values are not certified.
|
|
6149
|
+
* @param signerAccessCode - Access code sent in the query string.
|
|
6150
|
+
* @param image - Non-empty raw image bytes, without a JSON envelope.
|
|
6151
|
+
* @param options - Image type, reuse preference and compatibility content type.
|
|
6152
|
+
* @returns Nothing; the acknowledgement body is discarded.
|
|
6153
|
+
* @throws {ValidationError} If the code, image or options are invalid.
|
|
6154
|
+
* @throws {ApiError} If the API rejects the upload.
|
|
6155
|
+
* @example
|
|
6156
|
+
* ```ts
|
|
6157
|
+
* await client.signerDocuments.uploadSignature(accessCode, image, {
|
|
6158
|
+
* imageType: 'signature', reuse: false, contentType: 'image/jpeg',
|
|
6159
|
+
* });
|
|
6160
|
+
* ```
|
|
5367
6161
|
*/
|
|
5368
6162
|
uploadSignature(signerAccessCode: string, image: Buffer, options: ILegacyUploadSignatureOptions): Promise<void>;
|
|
5369
6163
|
/**
|
|
@@ -5480,6 +6274,18 @@ declare class SignerDocumentsResource extends BaseResource {
|
|
|
5480
6274
|
* first. Digital Certificate signers cannot use this endpoint; use the
|
|
5481
6275
|
* certificate start/complete API flow instead.
|
|
5482
6276
|
*
|
|
6277
|
+
* Request body (`application/json`):
|
|
6278
|
+
* ```jsonc
|
|
6279
|
+
* [
|
|
6280
|
+
* {
|
|
6281
|
+
* "itemId": "item_example",
|
|
6282
|
+
* "fieldId": "field_example",
|
|
6283
|
+
* "pageId": "page_example",
|
|
6284
|
+
* "value": "Example Signer"
|
|
6285
|
+
* }
|
|
6286
|
+
* ]
|
|
6287
|
+
* ```
|
|
6288
|
+
*
|
|
5483
6289
|
* @param documentId - The document being signed.
|
|
5484
6290
|
* @param assignmentId - The assignment within that document.
|
|
5485
6291
|
* @param signerAccessCode - The signer's access code, from their signing link.
|
|
@@ -5512,6 +6318,13 @@ declare class SignerDocumentsResource extends BaseResource {
|
|
|
5512
6318
|
* delete the document via `documents.delete`; there is no workspace "cancel"
|
|
5513
6319
|
* endpoint.)
|
|
5514
6320
|
*
|
|
6321
|
+
* Request body (`application/json`):
|
|
6322
|
+
* ```jsonc
|
|
6323
|
+
* {
|
|
6324
|
+
* "decline_reason": "The document needs a correction."
|
|
6325
|
+
* }
|
|
6326
|
+
* ```
|
|
6327
|
+
*
|
|
5515
6328
|
* @param documentId - The document being declined.
|
|
5516
6329
|
* @param assignmentId - The assignment within that document.
|
|
5517
6330
|
* @param signerAccessCode - The signer's access code, from their signing link.
|
|
@@ -5640,6 +6453,21 @@ declare class UserResource extends BaseResource {
|
|
|
5640
6453
|
* (`PUT /users/self/notification-preferences`). Omitted keys retain their
|
|
5641
6454
|
* current values; account/security e-mails are not configurable here.
|
|
5642
6455
|
*
|
|
6456
|
+
* Request body (`application/json`):
|
|
6457
|
+
* ```jsonc
|
|
6458
|
+
* {
|
|
6459
|
+
* "DocumentCompleted": true,
|
|
6460
|
+
* "SignerDeclined": true,
|
|
6461
|
+
* "DocumentCancelled": true,
|
|
6462
|
+
* "DocumentAboutToExpire": true,
|
|
6463
|
+
* "DocumentExpired": true,
|
|
6464
|
+
* "DocumentExpirationReset": true,
|
|
6465
|
+
* "DocumentProcessingFailed": true,
|
|
6466
|
+
* "TemplateProcessingFailed": true,
|
|
6467
|
+
* "SignerWhatsappFailed": true
|
|
6468
|
+
* }
|
|
6469
|
+
* ```
|
|
6470
|
+
*
|
|
5643
6471
|
* @param preferences - One or more of the nine documented keys, each with
|
|
5644
6472
|
* a boolean value. Request example:
|
|
5645
6473
|
* ```json
|
|
@@ -5673,33 +6501,209 @@ declare class UserResource extends BaseResource {
|
|
|
5673
6501
|
* ```
|
|
5674
6502
|
*/
|
|
5675
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
|
+
}>;
|
|
5676
6645
|
}
|
|
5677
6646
|
|
|
6647
|
+
/** Headers read by {@link WebhookVerifier.verifySignature}. */
|
|
6648
|
+
type WebhookHeaders = {
|
|
6649
|
+
get(name: string): string | null;
|
|
6650
|
+
} | Record<string, string | string[] | undefined>;
|
|
5678
6651
|
/**
|
|
5679
|
-
*
|
|
5680
|
-
* HMAC-SHA256 convention of their own.
|
|
6652
|
+
* Verifies and parses Assinafy webhook deliveries.
|
|
5681
6653
|
*
|
|
5682
|
-
*
|
|
5683
|
-
*
|
|
5684
|
-
*
|
|
5685
|
-
*
|
|
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.
|
|
5686
6659
|
*/
|
|
5687
6660
|
declare class WebhookVerifier {
|
|
5688
6661
|
private readonly webhookSecret;
|
|
5689
6662
|
/**
|
|
5690
|
-
*
|
|
5691
|
-
*
|
|
5692
|
-
*
|
|
5693
|
-
* 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`).
|
|
5694
6666
|
*
|
|
5695
6667
|
* @example
|
|
5696
6668
|
* ```ts
|
|
5697
|
-
* const verifier = new WebhookVerifier(process.env.
|
|
6669
|
+
* const verifier = new WebhookVerifier(process.env.ASSINAFY_WEBHOOK_SECRET);
|
|
5698
6670
|
* ```
|
|
5699
6671
|
*/
|
|
5700
6672
|
constructor(webhookSecret?: string);
|
|
5701
6673
|
/**
|
|
5702
|
-
*
|
|
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}.
|
|
5703
6707
|
*
|
|
5704
6708
|
* @param payload - Exact, unparsed request bytes (or their UTF-8 string).
|
|
5705
6709
|
* @param signature - 64-character hexadecimal SHA-256 digest supplied by
|
|
@@ -5784,7 +6788,7 @@ interface ClientConfigInput {
|
|
|
5784
6788
|
* const client = new AssinafyClient({
|
|
5785
6789
|
* apiKey: process.env.ASSINAFY_API_KEY!,
|
|
5786
6790
|
* accountId: process.env.ASSINAFY_ACCOUNT_ID!,
|
|
5787
|
-
* webhookSecret: process.env.ASSINAFY_WEBHOOK_SECRET
|
|
6791
|
+
* webhookSecret: process.env.ASSINAFY_WEBHOOK_SECRET!,
|
|
5788
6792
|
* });
|
|
5789
6793
|
*
|
|
5790
6794
|
* const document = await client.documents.upload({ filePath: './contract.pdf' });
|
|
@@ -6250,4 +7254,4 @@ declare const MAX_LIST_PAGE_SIZE = 50;
|
|
|
6250
7254
|
|
|
6251
7255
|
declare const SDK_USER_AGENT: string;
|
|
6252
7256
|
|
|
6253
|
-
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 };
|