@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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  This ledger maps the official
4
4
  [`GET /v1/docs/openapi.json`](https://api.assinafy.com.br/v1/docs/openapi.json)
5
- contract to the public SDK API: 71 paths, 93 HTTP operations, and 41 component
5
+ contract to the public SDK API: 81 paths, 106 HTTP operations, and 44 component
6
6
  schemas.
7
7
 
8
8
  All paths below include the `/v1` prefix shown by the OpenAPI document, except
@@ -14,7 +14,7 @@ Status meanings:
14
14
 
15
15
  - **Covered** — a public, typed SDK method sends the operation.
16
16
  - **Compatibility extension** — route retained for existing integrations but
17
- absent from the current OpenAPI path set and excluded from the 93-operation
17
+ absent from the current OpenAPI path set and excluded from the 106-operation
18
18
  total.
19
19
 
20
20
  ## Accounts — 10/10
@@ -44,11 +44,12 @@ Status meanings:
44
44
  | `PUT` | `/v1/documents/{documentId}/assignments/{assignmentId}/reset-expiration` | `client.assignments.resetExpiration(documentId, assignmentId, expiresAt)` | Covered |
45
45
  | `GET` | `/v1/documents/{documentId}/assignments/{assignmentId}/whatsapp-notifications` | `client.assignments.listWhatsAppNotifications(documentId, assignmentId)` | Covered |
46
46
 
47
- ## Authentication — 9/9
47
+ ## Authentication — 10/10
48
48
 
49
49
  | Method | Path | SDK method | Status |
50
50
  | --- | --- | --- | --- |
51
51
  | `POST` | `/v1/login` | `client.auth.login(email, password)` | Covered |
52
+ | `POST` | `/v1/authentication/mfa/verify` | `client.auth.verifyMfa(mfaToken, code)` | Covered |
52
53
  | `PUT` | `/v1/authentication/request-password-reset` | `client.auth.requestPasswordReset(email)` | Covered |
53
54
  | `PUT` | `/v1/authentication/reset-password` | `client.auth.resetPassword(payload)` | Covered |
54
55
  | `PUT` | `/v1/authentication/change-password` | `client.auth.changePassword(payload)` | Covered |
@@ -166,7 +167,7 @@ an optional fourth access-code argument only for legacy compatibility.
166
167
  Five additional routes are documented separately under
167
168
  [Template compatibility routes](#template-compatibility-routes).
168
169
 
169
- ## Users — 4/4
170
+ ## Users — 9/9
170
171
 
171
172
  | Method | Path | SDK method | Status |
172
173
  | --- | --- | --- | --- |
@@ -174,8 +175,13 @@ Five additional routes are documented separately under
174
175
  | `GET` | `/v1/users/self/stats` | `client.users.getStats(params?)` | Covered |
175
176
  | `GET` | `/v1/users/self/notification-preferences` | `client.users.getNotificationPreferences()` | Covered |
176
177
  | `PUT` | `/v1/users/self/notification-preferences` | `client.users.updateNotificationPreferences(preferences)` | Covered |
178
+ | `GET` | `/v1/users/self/mfa` | `client.users.getMfa()` | Covered |
179
+ | `POST` | `/v1/users/self/mfa/totp` | `client.users.startTotpEnrollment(label?)` | Covered |
180
+ | `PUT` | `/v1/users/self/mfa/totp/confirm` | `client.users.confirmTotpEnrollment(payload)` | Covered |
181
+ | `POST` | `/v1/users/self/mfa/recovery-codes` | `client.users.regenerateRecoveryCodes(proof)` | Covered |
182
+ | `DELETE` | `/v1/users/self/mfa/{customId}` | `client.users.deleteMfaMethod(methodId, proof)` | Covered |
177
183
 
178
- ## Webhooks — 6/6
184
+ ## Webhooks — 13/13
179
185
 
180
186
  | Method | Path | SDK method | Status |
181
187
  | --- | --- | --- | --- |
@@ -185,11 +191,18 @@ Five additional routes are documented separately under
185
191
  | `GET` | `/v1/webhooks/event-types` | `client.webhooks.listEventTypes()` | Covered |
186
192
  | `GET` | `/v1/accounts/{accountId}/webhooks` | `client.webhooks.listDispatches(params?, accountId?)` | Covered |
187
193
  | `POST` | `/v1/accounts/{accountId}/webhooks/{historyId}/retry` | `client.webhooks.retryDispatch(historyId, accountId?)` | Covered |
194
+ | `GET` | `/v1/accounts/{accountId}/webhooks/endpoints` | `client.webhooks.listEndpoints(accountId?)` | Covered |
195
+ | `POST` | `/v1/accounts/{accountId}/webhooks/endpoints` | `client.webhooks.createEndpoint(payload, accountId?)` | Covered |
196
+ | `GET` | `/v1/accounts/{accountId}/webhooks/endpoints/{endpointId}` | `client.webhooks.getEndpoint(endpointId, accountId?)` | Covered |
197
+ | `PUT` | `/v1/accounts/{accountId}/webhooks/endpoints/{endpointId}` | `client.webhooks.updateEndpoint(endpointId, payload, accountId?)` | Covered |
198
+ | `DELETE` | `/v1/accounts/{accountId}/webhooks/endpoints/{endpointId}` | `client.webhooks.deleteEndpoint(endpointId, accountId?)` | Covered |
199
+ | `GET` | `/v1/accounts/{accountId}/webhooks/endpoints/{endpointId}/secret` | `client.webhooks.getEndpointSecret(endpointId, accountId?)` | Covered |
200
+ | `POST` | `/v1/accounts/{accountId}/webhooks/endpoints/{endpointId}/secret/rotate` | `client.webhooks.rotateEndpointSecret(endpointId, accountId?)` | Covered |
188
201
 
189
202
  ## Template compatibility routes
190
203
 
191
204
  These routes are available to existing integrations but do not appear in the
192
- current OpenAPI path set. They are excluded from the official 93-operation
205
+ current OpenAPI path set. They are excluded from the official 106-operation
193
206
  coverage count.
194
207
 
195
208
  | Method | Path | SDK method | Status |
@@ -204,7 +217,7 @@ coverage count.
204
217
 
205
218
  Two browser URL helpers used by older deployments are live but absent from the
206
219
  current OpenAPI path set, so they are likewise excluded from the official
207
- 93-operation coverage count.
220
+ 106-operation coverage count.
208
221
 
209
222
  | Method | Path | SDK method | Status |
210
223
  | --- | --- | --- | --- |
@@ -225,9 +238,9 @@ the endpoint count:
225
238
  - `client.documents.isFullySigned(documentId)` and
226
239
  `getSigningProgress(documentId)` derive state from document details.
227
240
  - `client.signers.findByEmail(email, accountId?)` uses the official signer list.
228
- - `client.webhookVerifier` parses webhook envelopes and optionally verifies a
229
- caller-configured HMAC contract; signature verification itself is not in the
230
- current OpenAPI document.
241
+ - `client.webhookVerifier.verifySignature(rawBody, headers)` verifies the
242
+ Standard Webhooks signature that signing-enabled endpoints send, including
243
+ the `webhook-timestamp` replay window; `extractEvent()` parses the body.
231
244
  - `client.oauth.getAuthorizationServerMetadata(issuer?)` reads the RFC 8414
232
245
  document published by the authorization server, and
233
246
  `client.oauth.createAuthorizationUrl(options)` /
@@ -19,10 +19,13 @@ GET /v1/accounts/{accountId}/stats
19
19
  GET /v1/users/self
20
20
  GET, PUT /v1/users/self/notification-preferences
21
21
  GET /v1/users/self/stats
22
+ GET /v1/users/self/mfa (and the two-factor management routes)
23
+ POST /v1/authentication/mfa/verify
24
+ GET, POST /v1/accounts/{accountId}/webhooks/endpoints (and per-endpoint routes)
22
25
  ```
23
26
 
24
27
  Sandbox deployments can return `404` for user statistics, account statistics,
25
- or notification preferences while still accepting the production methods on
28
+ notification preferences, two-factor routes, or webhook endpoint routes while still accepting the production methods on
26
29
  the production host. The SDK keeps the official paths and response types. A
27
30
  sandbox `404` does not cause the client to route a request elsewhere.
28
31
 
@@ -35,7 +38,7 @@ GET /v1/login-callback
35
38
 
36
39
  They map to `auth.getSocialLoginUrl()` and
37
40
  `auth.getSocialLoginCallbackUrl()` and are not part of the official
38
- 93-operation total.
41
+ 106-operation total.
39
42
 
40
43
  The SDK also includes the production contract additions for:
41
44
 
@@ -191,29 +194,30 @@ and returns the JPEG bytes as a `Buffer`.
191
194
 
192
195
  ## Public send-token request
193
196
 
194
- The official operation sends an email body:
197
+ The official operation requires a recipient and a channel (`email` is the only
198
+ documented channel):
195
199
 
196
200
  ```http
197
201
  PUT /v1/public/documents/{documentId}/send-token
198
202
  Content-Type: application/json
199
203
 
200
- { "email": "signer@example.com" }
204
+ { "recipient": "signer@example.com", "channel": "email" }
201
205
  ```
202
206
 
203
207
  ```ts
204
- await client.documents.sendToken(documentId, 'signer@example.com');
208
+ await client.documents.sendToken(documentId, 'signer@example.com', 'email');
205
209
  ```
206
210
 
207
- Older environments can require `{ recipient, channel }`. The explicit
208
- three-argument overload sends that shape:
211
+ The two-argument overload sends the legacy `{ email }` shape, which current
212
+ deployments still accept:
209
213
 
210
214
  ```ts
211
- await client.documents.sendToken(documentId, '+5511999990000', 'whatsapp');
215
+ await client.documents.sendToken(documentId, 'signer@example.com');
212
216
  ```
213
217
 
214
- For a two-argument call, the SDK starts with `{ email }` and retries the older
215
- email shape only when the validation response names `recipient` or `channel` as
216
- required. Other errors are returned unchanged.
218
+ When a deployment rejects `{ email }` with a validation response naming
219
+ `recipient` or `channel` as required, the SDK retries the documented shape
220
+ automatically. Other errors are returned unchanged.
217
221
 
218
222
  ## Document tags
219
223
 
@@ -263,16 +267,17 @@ typed `signerAccessCode` option for those environments.
263
267
 
264
268
  ## Signer request extensions
265
269
 
266
- The official signer-create schema uses `full_name`, `email`, and
267
- `whatsapp_phone_number`. Signer update adds `government_id`, which the SDK
268
- normalizes to digits. Three older integration inputs remain accepted:
270
+ The official signer schemas use `full_name`, `email`, `whatsapp_phone_number`,
271
+ and `government_id` on both create and update. `government_id` is sent as given:
272
+ the API strips formatting itself and keeps the letters of an alphanumeric CNPJ
273
+ (`12.ABC.345/01DE-35` is stored as `12ABC34501DE35`). Three older integration
274
+ inputs remain accepted:
269
275
 
270
276
  - `phone` is normalized to `whatsapp_phone_number` before transmission;
271
277
  - `cpf` is normalized to digits and forwarded; and
272
278
  - create-time `metadata` is forwarded unchanged.
273
279
 
274
- New integrations should use the official create fields and `government_id` on
275
- update. `cpf` is not an alias for the official update field, and signer
280
+ New integrations should use the official fields, including `government_id`. `cpf` is not an alias for the official update field, and signer
276
281
  responses do not return it.
277
282
 
278
283
  ## Digital certificate and collect placement
@@ -340,9 +345,9 @@ Document upload accepts a PDF of at most 25 MB and 2,000 pages. The multipart
340
345
  schema documents the file; the SDK's optional `metadata` JSON part is retained
341
346
  for deployments that accept application-owned opaque metadata.
342
347
 
343
- The reset-expiration schema requires an ISO-8601 date-time string. The SDK also
344
- accepts `null` for older integrations that clear an expiration this way. Confirm
345
- support in the target deployment before sending `null`.
348
+ The reset-expiration schema requires the `expires_at` key itself: send an
349
+ ISO-8601 date-time string, or `null` to remove the expiration. The SDK's
350
+ `resetExpiration` always sends the key and accepts `null` for clearing.
346
351
 
347
352
  ## Resend-cost response variants
348
353
 
@@ -400,7 +405,9 @@ signer access or verification value; treat it as a credential and never log it.
400
405
  ## Webhook delivery
401
406
 
402
407
  Assinafy sends webhook events as HTTP `POST` JSON requests with
403
- `Connection: close`. Any `2xx` is successful. There are at most two automatic
408
+ `Connection: close`, `webhook-id` and `webhook-timestamp` headers, and a
409
+ `webhook-signature` header on signing-enabled endpoints. Every active endpoint
410
+ subscribed to an event receives it independently. Any `2xx` is successful. There are at most two automatic
404
411
  attempts per event with a three-second wait. After ten consecutive failed
405
412
  events, ordinary delivery pauses and about 5% of later events are attempted
406
413
  until one succeeds. `webhooks.retryDispatch()` requests immediate redelivery.
@@ -409,18 +416,24 @@ dispatch history.
409
416
 
410
417
  The common body contains `id`, `event`, nullable `message`, nullable `payload`,
411
418
  nullable `origin`, Unix-second `created_at`, polymorphic `subject` and `object`,
412
- and `account_id`. Use `id` for idempotent handling and accept unknown fields.
413
-
414
- ## Webhook signature verification is not in the OpenAPI contract
415
-
416
- The official webhook operations define subscription management, event types,
417
- delivery history, and retry. They do not define a shared-secret field,
418
- signature algorithm, digest encoding, or signature header for incoming events.
419
-
420
- `client.webhookVerifier` is an opt-in HMAC-SHA256 utility for environments whose
421
- separate Assinafy agreement provides a shared secret and hex digest. Confirm the
422
- header name and signing procedure for the target environment before enforcing
423
- it. Do not assume an `X-Assinafy-Signature` header solely from this SDK.
419
+ and `account_id`. Deduplicate on the `webhook-id` header, which also tells
420
+ deliveries of the same event to different endpoints apart, and accept unknown
421
+ fields.
422
+
423
+ ## Webhook endpoints and signatures
424
+
425
+ An account has 1 webhook endpoint, or up to 3 on paid plans. The subscription
426
+ routes (`webhooks.register()`, `get()`, `inactivate()`) act on the account's
427
+ oldest endpoint; the endpoint routes address each one by ID.
428
+
429
+ Signing-enabled endpoints follow Standard Webhooks:
430
+ `webhook-signature` holds space-separated `v1,<base64>` entries, each an
431
+ HMAC-SHA256 of `{webhook-id}.{webhook-timestamp}.{raw body}` keyed with the
432
+ base64-decoded part of the `whsec_` secret.
433
+ `webhookVerifier.verifySignature()` implements this, with a 300-second
434
+ timestamp tolerance by default. The signing-secret routes are not available to
435
+ OAuth applications. The earlier `webhookVerifier.verify()` (hex HMAC over the
436
+ body alone) is deprecated; it never matched an Assinafy signature.
424
437
 
425
438
  ## Authentication isolation
426
439
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@assinafy/sdk",
3
- "version": "2.5.2",
3
+ "version": "2.7.0",
4
4
  "packageManager": "bun@1.4.0",
5
5
  "description": "TypeScript SDK for Assinafy API - Digital signature platform",
6
6
  "type": "commonjs",