@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/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(customId, 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
|
|
|
@@ -58,7 +61,7 @@ method counters. Notification counters are not mutually exclusive.
|
|
|
58
61
|
are mutually exclusive and sum to `signature_requests`. Older unsuffixed email
|
|
59
62
|
and WhatsApp counters remain optional.
|
|
60
63
|
|
|
61
|
-
## OAuth
|
|
64
|
+
## OAuth uses separate API and authorization hosts
|
|
62
65
|
|
|
63
66
|
The flow deliberately spans two hosts, which no other part of this SDK does:
|
|
64
67
|
|
|
@@ -77,32 +80,26 @@ base URL's **origin**, not from `baseUrl` itself, and
|
|
|
77
80
|
credential-free transport.
|
|
78
81
|
|
|
79
82
|
The sandbox has its own authorization server at
|
|
80
|
-
`https://auth-sandbox.assinafy.com.br`,
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
application. Skip discovery there by naming the endpoints explicitly; both
|
|
85
|
-
`createAuthorizationUrl` options exist for exactly this case:
|
|
83
|
+
`https://auth-sandbox.assinafy.com.br`, with the consent screen at
|
|
84
|
+
`/oauth/authorize`. Both discovery documents are available, and its OpenAPI
|
|
85
|
+
contract includes the token, revocation and userinfo routes. Discover the
|
|
86
|
+
sandbox issuer from its API origin:
|
|
86
87
|
|
|
87
88
|
```ts
|
|
88
89
|
const client = new AssinafyClient({ baseUrl: 'https://sandbox.assinafy.com.br/v1' });
|
|
89
|
-
|
|
90
|
+
const metadata = await client.oauth.getAuthorizationServerMetadata();
|
|
90
91
|
const request = await client.oauth.createAuthorizationUrl({
|
|
91
92
|
clientId: process.env.ASSINAFY_CLIENT_ID!,
|
|
92
93
|
redirectUri: 'https://myapp.example.com/oauth/callback',
|
|
93
|
-
scopes: ['documents:read'],
|
|
94
|
-
issuer: 'https://auth-sandbox.assinafy.com.br',
|
|
95
|
-
authorizationEndpoint: 'https://auth-sandbox.assinafy.com.br/oauth/authorize',
|
|
94
|
+
scopes: ['documents:read', 'account:read', 'offline_access'],
|
|
96
95
|
});
|
|
97
96
|
```
|
|
98
97
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
this API is byte-identical for a bad id and for a route that does not exist, so
|
|
105
|
-
it is never on its own proof that a route is missing.
|
|
98
|
+
Register the application in the matching environment. Production and sandbox
|
|
99
|
+
use different issuers, clients, credentials and workspace IDs; keep the entire
|
|
100
|
+
connection in one environment. Token, revocation and userinfo requests use the
|
|
101
|
+
configured `baseUrl`. Use a temporary HTTPS tunnel for local callbacks and
|
|
102
|
+
register its exact callback URL before starting the connection.
|
|
106
103
|
|
|
107
104
|
Response shapes diverge from the rest of the API on purpose:
|
|
108
105
|
|
|
@@ -113,9 +110,9 @@ Response shapes diverge from the rest of the API on purpose:
|
|
|
113
110
|
| `GET /oauth/userinfo` | flat claims object (OIDC Core §5.3.2) | the usual `{ status, message, data }` envelope |
|
|
114
111
|
|
|
115
112
|
Both JSON and `application/x-www-form-urlencoded` bodies are accepted by the
|
|
116
|
-
token and revocation endpoints
|
|
117
|
-
|
|
118
|
-
|
|
113
|
+
token and revocation endpoints, and the production OpenAPI document lists both.
|
|
114
|
+
The SDK sends `application/x-www-form-urlencoded`: the encoding RFC 6749 and
|
|
115
|
+
RFC 7009 define and the OAuth Integration Guide uses.
|
|
119
116
|
|
|
120
117
|
The RFC 8707 `resource` indicator defaults to the configured API origin, and is
|
|
121
118
|
omitted when that origin is a loopback `http://` host — the shape used by mock
|
|
@@ -269,16 +266,17 @@ typed `signerAccessCode` option for those environments.
|
|
|
269
266
|
|
|
270
267
|
## Signer request extensions
|
|
271
268
|
|
|
272
|
-
The official signer
|
|
273
|
-
`
|
|
274
|
-
|
|
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:
|
|
275
274
|
|
|
276
275
|
- `phone` is normalized to `whatsapp_phone_number` before transmission;
|
|
277
276
|
- `cpf` is normalized to digits and forwarded; and
|
|
278
277
|
- create-time `metadata` is forwarded unchanged.
|
|
279
278
|
|
|
280
|
-
New integrations should use the official
|
|
281
|
-
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
|
|
282
280
|
responses do not return it.
|
|
283
281
|
|
|
284
282
|
## Digital certificate and collect placement
|
|
@@ -406,7 +404,9 @@ signer access or verification value; treat it as a credential and never log it.
|
|
|
406
404
|
## Webhook delivery
|
|
407
405
|
|
|
408
406
|
Assinafy sends webhook events as HTTP `POST` JSON requests with
|
|
409
|
-
`Connection: close
|
|
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
|
|
410
410
|
attempts per event with a three-second wait. After ten consecutive failed
|
|
411
411
|
events, ordinary delivery pauses and about 5% of later events are attempted
|
|
412
412
|
until one succeeds. `webhooks.retryDispatch()` requests immediate redelivery.
|
|
@@ -415,18 +415,24 @@ dispatch history.
|
|
|
415
415
|
|
|
416
416
|
The common body contains `id`, `event`, nullable `message`, nullable `payload`,
|
|
417
417
|
nullable `origin`, Unix-second `created_at`, polymorphic `subject` and `object`,
|
|
418
|
-
and `account_id`.
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
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.
|
|
430
436
|
|
|
431
437
|
## Authentication isolation
|
|
432
438
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@assinafy/sdk",
|
|
3
|
-
"version": "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",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
},
|
|
82
82
|
"overrides": {
|
|
83
83
|
"esbuild": "0.28.2",
|
|
84
|
-
"brace-expansion": "5.0.
|
|
84
|
+
"brace-expansion": "5.0.12"
|
|
85
85
|
},
|
|
86
86
|
"files": [
|
|
87
87
|
"dist",
|