@assinafy/sdk 2.5.2 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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(customId, 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
 
@@ -263,16 +266,17 @@ typed `signerAccessCode` option for those environments.
263
266
 
264
267
  ## Signer request extensions
265
268
 
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:
269
+ The official signer schemas use `full_name`, `email`, `whatsapp_phone_number`,
270
+ and `government_id` on both create and update. `government_id` is sent as given:
271
+ the API strips formatting itself and keeps the letters of an alphanumeric CNPJ
272
+ (`12.ABC.345/01DE-35` is stored as `12ABC34501DE35`). Three older integration
273
+ inputs remain accepted:
269
274
 
270
275
  - `phone` is normalized to `whatsapp_phone_number` before transmission;
271
276
  - `cpf` is normalized to digits and forwarded; and
272
277
  - create-time `metadata` is forwarded unchanged.
273
278
 
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
279
+ New integrations should use the official fields, including `government_id`. `cpf` is not an alias for the official update field, and signer
276
280
  responses do not return it.
277
281
 
278
282
  ## Digital certificate and collect placement
@@ -400,7 +404,9 @@ signer access or verification value; treat it as a credential and never log it.
400
404
  ## Webhook delivery
401
405
 
402
406
  Assinafy sends webhook events as HTTP `POST` JSON requests with
403
- `Connection: close`. Any `2xx` is successful. There are at most two automatic
407
+ `Connection: close`, `webhook-id` and `webhook-timestamp` headers, and a
408
+ `webhook-signature` header on signing-enabled endpoints. Every active endpoint
409
+ subscribed to an event receives it independently. Any `2xx` is successful. There are at most two automatic
404
410
  attempts per event with a three-second wait. After ten consecutive failed
405
411
  events, ordinary delivery pauses and about 5% of later events are attempted
406
412
  until one succeeds. `webhooks.retryDispatch()` requests immediate redelivery.
@@ -409,18 +415,24 @@ dispatch history.
409
415
 
410
416
  The common body contains `id`, `event`, nullable `message`, nullable `payload`,
411
417
  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.
418
+ and `account_id`. Deduplicate on the `webhook-id` header, which also tells
419
+ deliveries of the same event to different endpoints apart, and accept unknown
420
+ fields.
421
+
422
+ ## Webhook endpoints and signatures
423
+
424
+ An account has 1 webhook endpoint, or up to 3 on paid plans. The subscription
425
+ routes (`webhooks.register()`, `get()`, `inactivate()`) act on the account's
426
+ oldest endpoint; the endpoint routes address each one by ID.
427
+
428
+ Signing-enabled endpoints follow Standard Webhooks:
429
+ `webhook-signature` holds space-separated `v1,<base64>` entries, each an
430
+ HMAC-SHA256 of `{webhook-id}.{webhook-timestamp}.{raw body}` keyed with the
431
+ base64-decoded part of the `whsec_` secret.
432
+ `webhookVerifier.verifySignature()` implements this, with a 300-second
433
+ timestamp tolerance by default. The signing-secret routes are not available to
434
+ OAuth applications. The earlier `webhookVerifier.verify()` (hex HMAC over the
435
+ body alone) is deprecated; it never matched an Assinafy signature.
424
436
 
425
437
  ## Authentication isolation
426
438
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@assinafy/sdk",
3
- "version": "2.5.2",
3
+ "version": "2.6.0",
4
4
  "packageManager": "bun@1.4.0",
5
5
  "description": "TypeScript SDK for Assinafy API - Digital signature platform",
6
6
  "type": "commonjs",