@assinafy/sdk 2.5.2 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +68 -1
- package/README.en.md +154 -70
- package/README.md +129 -61
- package/SECURITY.md +9 -4
- package/dist/index.d.mts +647 -79
- package/dist/index.d.ts +647 -79
- package/dist/index.js +665 -74
- package/dist/index.mjs +665 -74
- package/docs/API_COVERAGE.md +23 -10
- package/docs/COMPATIBILITY.md +45 -32
- package/package.json +1 -1
package/docs/API_COVERAGE.md
CHANGED
|
@@ -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:
|
|
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
|
|
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 —
|
|
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 —
|
|
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 —
|
|
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
|
|
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
|
-
|
|
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`
|
|
229
|
-
|
|
230
|
-
|
|
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)` /
|
package/docs/COMPATIBILITY.md
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
{ "
|
|
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
|
-
|
|
208
|
-
|
|
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, '
|
|
215
|
+
await client.documents.sendToken(documentId, 'signer@example.com');
|
|
212
216
|
```
|
|
213
217
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
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
|
|
267
|
-
`
|
|
268
|
-
|
|
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
|
|
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
|
|
344
|
-
|
|
345
|
-
|
|
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
|
|
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`.
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
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
|
|