@assinafy/sdk 2.2.0 → 2.4.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,10 +2,11 @@
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: 67 paths, 89 HTTP operations, and 39 component
5
+ contract to the public SDK API: 71 paths, 93 HTTP operations, and 39 component
6
6
  schemas.
7
7
 
8
- All paths below include the `/v1` prefix shown by the OpenAPI document. The
8
+ All paths below include the `/v1` prefix shown by the OpenAPI document, except
9
+ the RFC 8615 `.well-known` document, which is served at the host root. The
9
10
  SDK's default `baseUrl` already ends in `/v1`, so resource implementations use
10
11
  the corresponding relative path without repeating that prefix.
11
12
 
@@ -13,7 +14,7 @@ Status meanings:
13
14
 
14
15
  - **Covered** — a public, typed SDK method sends the operation.
15
16
  - **Compatibility extension** — route retained for existing integrations but
16
- absent from the current OpenAPI path set and excluded from the 89-operation
17
+ absent from the current OpenAPI path set and excluded from the 93-operation
17
18
  total.
18
19
 
19
20
  ## Accounts — 10/10
@@ -93,6 +94,21 @@ Status meanings:
93
94
  | `POST` | `/v1/accounts/{accountId}/fields/validate-multiple` | `client.fields.validateMultiple(entries, options?)` | Covered |
94
95
  | `GET` | `/v1/field-types` | `client.fields.listTypes()` | Covered |
95
96
 
97
+ ## OAuth — 4/4
98
+
99
+ Endpoints an OAuth application calls. The token, revocation and userinfo
100
+ operations answer with flat RFC 6749 / OIDC bodies rather than the
101
+ `{ status, message, data }` envelope used everywhere else, and the SDK returns
102
+ them unwrapped. The browser-facing `/oauth/authorize` page belongs to the
103
+ authorization server (`https://auth.assinafy.com.br`), not to this API.
104
+
105
+ | Method | Path | SDK method | Status |
106
+ | --- | --- | --- | --- |
107
+ | `GET` | `/.well-known/oauth-protected-resource` | `client.oauth.getProtectedResourceMetadata()` | Covered |
108
+ | `POST` | `/v1/oauth/token` | `client.oauth.exchangeCode(options)` / `client.oauth.refreshToken(options)` | Covered |
109
+ | `POST` | `/v1/oauth/revoke` | `client.oauth.revokeToken(options)` | Covered |
110
+ | `GET` | `/v1/oauth/userinfo` | `client.oauth.getUserInfo(accessToken?)` | Covered |
111
+
96
112
  ## Signers — 5/5
97
113
 
98
114
  | Method | Path | SDK method | Status |
@@ -171,7 +187,7 @@ Five additional routes are documented separately under
171
187
  ## Template compatibility routes
172
188
 
173
189
  These routes are available to existing integrations but do not appear in the
174
- current OpenAPI path set. They are excluded from the official 89-operation
190
+ current OpenAPI path set. They are excluded from the official 93-operation
175
191
  coverage count.
176
192
 
177
193
  | Method | Path | SDK method | Status |
@@ -199,6 +215,14 @@ the endpoint count:
199
215
  - `client.webhookVerifier` parses webhook envelopes and optionally verifies a
200
216
  caller-configured HMAC contract; signature verification itself is not in the
201
217
  current OpenAPI document.
218
+ - `client.oauth.getAuthorizationServerMetadata(issuer?)` reads the RFC 8414
219
+ document published by the authorization server, and
220
+ `client.oauth.createAuthorizationUrl(options)` /
221
+ `client.oauth.readAuthorizationCallback(params, expected)` drive the
222
+ browser-facing half of the flow. Neither host runs on this API, so they add no
223
+ operations to the count.
224
+ - `ApiError.challenge` exposes the parsed `WWW-Authenticate` header, which names
225
+ the scope missing from a `403 insufficient_scope`.
202
226
 
203
227
  For request and response payload definitions, use the exported TypeScript
204
228
  interfaces and each method's JSDoc examples together with the
@@ -58,6 +58,69 @@ method counters. Notification counters are not mutually exclusive.
58
58
  are mutually exclusive and sum to `signature_requests`. Older unsuffixed email
59
59
  and WhatsApp counters remain optional.
60
60
 
61
+ ## OAuth spans two hosts, and sandbox discovery is unreachable
62
+
63
+ The flow deliberately spans two hosts, which no other part of this SDK does:
64
+
65
+ ```text
66
+ GET https://api.assinafy.com.br/.well-known/oauth-protected-resource # host root, NOT /v1
67
+ GET https://auth.assinafy.com.br/.well-known/oauth-authorization-server
68
+ GET https://auth.assinafy.com.br/oauth/authorize # browser only
69
+ POST https://api.assinafy.com.br/v1/oauth/token
70
+ POST https://api.assinafy.com.br/v1/oauth/revoke
71
+ GET https://api.assinafy.com.br/v1/oauth/userinfo
72
+ ```
73
+
74
+ `getProtectedResourceMetadata()` therefore builds its URL from the configured
75
+ base URL's **origin**, not from `baseUrl` itself, and
76
+ `getAuthorizationServerMetadata()` issues a cross-host request on the
77
+ credential-free transport.
78
+
79
+ The sandbox has its own authorization server at
80
+ `https://auth-sandbox.assinafy.com.br`, whose `/oauth/authorize` consent screen
81
+ is live. Its discovery documents, however, cannot be fetched: nginx on the
82
+ sandbox hosts rejects **any** path beginning with a dot — `/.anything` answers
83
+ `403` while `/anything` answers `404` — so `/.well-known/…` never reaches the
84
+ application. Skip discovery there by naming the endpoints explicitly; both
85
+ `createAuthorizationUrl` options exist for exactly this case:
86
+
87
+ ```ts
88
+ const client = new AssinafyClient({ baseUrl: 'https://sandbox.assinafy.com.br/v1' });
89
+
90
+ const request = await client.oauth.createAuthorizationUrl({
91
+ clientId: process.env.ASSINAFY_CLIENT_ID!,
92
+ 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',
96
+ });
97
+ ```
98
+
99
+ The token, revocation and userinfo endpoints are resolved against the
100
+ configured `baseUrl`, so they follow whichever host the client points at.
101
+ Confirm the sandbox deployment exposes them before running the exchange leg
102
+ there: at the time of writing its OpenAPI document publishes 67 paths and does
103
+ not list `/v1/oauth/…`, while production publishes 71 and does. A `404` from
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.
106
+
107
+ Response shapes diverge from the rest of the API on purpose:
108
+
109
+ | Operation | Success body | Error body |
110
+ | --- | --- | --- |
111
+ | Discovery documents | bare metadata object (RFC 8615) | — |
112
+ | `POST /oauth/token`, `POST /oauth/revoke` | flat, no envelope (RFC 6749 §5.1) | flat `{ error, error_description }` (§5.2) |
113
+ | `GET /oauth/userinfo` | flat claims object (OIDC Core §5.3.2) | the usual `{ status, message, data }` envelope |
114
+
115
+ Both JSON and `application/x-www-form-urlencoded` bodies are accepted by the
116
+ token and revocation endpoints; the SDK sends JSON because that is what the
117
+ published `requestBody` documents.
118
+
119
+ The RFC 8707 `resource` indicator defaults to the configured API origin, and is
120
+ omitted when that origin is a loopback `http://` host — the shape used by mock
121
+ servers and the packed-consumer smoke test, which has no valid resource
122
+ identifier.
123
+
61
124
  ## List pagination
62
125
 
63
126
  Two behaviours of the list endpoints are silent rather than loud, so neither
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@assinafy/sdk",
3
- "version": "2.2.0",
3
+ "version": "2.4.0",
4
4
  "packageManager": "bun@1.4.0",
5
5
  "description": "TypeScript SDK for Assinafy API - Digital signature platform",
6
6
  "type": "commonjs",
@@ -87,6 +87,7 @@
87
87
  "dist",
88
88
  "docs",
89
89
  "README.md",
90
+ "README.en.md",
90
91
  "CHANGELOG.md",
91
92
  "SECURITY.md",
92
93
  "LICENSE"