@assinafy/sdk 2.2.0 → 2.3.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 CHANGED
@@ -7,6 +7,74 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [2.3.0] - 2026-09-20
11
+
12
+ ### Added
13
+
14
+ - **OAuth 2.1 support — `client.oauth`.** Applications that act inside *other
15
+ people's* workspaces can now run the whole authorization-code flow through
16
+ the SDK instead of assembling it by hand:
17
+ - `createAuthorizationUrl(options)` mints a fresh PKCE verifier (S256), a
18
+ `state` and, for `openid`, a `nonce`, then builds the consent URL. It
19
+ returns everything the callback and token exchange need, so nothing has to
20
+ be re-derived later.
21
+ - `readAuthorizationCallback(params, expected)` validates the redirect before
22
+ anything on it is trusted: `state` in constant time, then `iss` (RFC 9207).
23
+ A declined consent surfaces as an `OAuthError`, not a silent success. It
24
+ accepts an Express `req.query`, a `URLSearchParams`, a `URL`, a full
25
+ callback URL or a bare query string.
26
+ - `exchangeCode(options)`, `refreshToken(options)` and `revokeToken(options)`
27
+ call `POST /oauth/token` and `POST /oauth/revoke` on a credential-free
28
+ transport, so an integrator's own `X-Api-Key` is never sent to a route that
29
+ authenticates the application.
30
+ - `getUserInfo(accessToken?)` reads the OpenID Connect claims.
31
+ - `getProtectedResourceMetadata()` (RFC 9728, served at the API host root)
32
+ and `getAuthorizationServerMetadata(issuer?)` (RFC 8414) discover the
33
+ endpoints instead of hardcoding them, and the second one rejects a document
34
+ whose `issuer` disagrees with where it was fetched from.
35
+ - **`OAuthError`** — the OAuth endpoints answer with a flat
36
+ `{ error, error_description }` body rather than the `{ status, message, data }`
37
+ envelope, so the RFC 6749 code is exposed as `error` and the explanation as
38
+ `errorDescription`. It extends `ApiError`, so existing `catch` blocks keep
39
+ matching.
40
+ - **`ApiError.challenge`** — the parsed `WWW-Authenticate` header, when the API
41
+ sends one. On a `403` it names the scope the token is missing
42
+ (`insufficient_scope`), which is the only way to tell "reconnect asking for
43
+ more" apart from a permission an OAuth token can never hold. The parser is
44
+ also exported as `parseWwwAuthenticate`.
45
+ - Both READMEs document the complete OAuth flow: registering the application,
46
+ the scope catalogue, workspace binding, refresh-token rotation, revocation,
47
+ and what each failure means.
48
+
49
+ ### Changed
50
+
51
+ - **Signer verification and notification channels are now validated as a
52
+ pair.** The API couples them — the verification code travels on the
53
+ notification channel — so `Email` verification only allows `Email`
54
+ notification, `Whatsapp` only `Whatsapp`, and `DigitalCertificate` either
55
+ one. Exactly one notification method is allowed per signer. The SDK rejected
56
+ unknown channel names but let an impossible pairing (and an empty or
57
+ two-element `notification_methods`) through to a `400`. The rule now lives in
58
+ `validateAssignmentSignerOptions()` and therefore applies to assignment
59
+ creation, cost estimation and template-driven document creation alike; the
60
+ duplicate one-method check in the template path was removed.
61
+ - A payload the API would have rejected now fails locally with a
62
+ `ValidationError` naming the pairing.
63
+ - `AssignmentVerificationMethod` and `AssignmentNotificationMethod` document
64
+ the channel matrix, its costs and its prerequisites. ICP-Brasil **A1** and
65
+ **A3** are recorded explicitly as certificate media — a file in software or a
66
+ token/smartcard, chosen by the signer in the browser — both modelled by the
67
+ single `DigitalCertificate` value, with no separate field to send.
68
+ - `bun run audit:api` additionally fetches the two OAuth discovery documents
69
+ and checks the issuer, the authorization and token endpoints, PKCE `S256` and
70
+ the RFC 9207 `iss` parameter against the published contract. They are the
71
+ only part of the OAuth surface that does not live in the OpenAPI document.
72
+ - `docs/API_COVERAGE.md` maps the four new OAuth operations, bringing the
73
+ ledger to 93 of 93.
74
+ - The Portuguese README is now the complete reference rather than a summary
75
+ pointing at the English one: installation through the end-to-end signature
76
+ flow, every resource, errors, environments and development.
77
+
10
78
  ## [2.2.0] - 2026-08-27
11
79
 
12
80
  ### Security
@@ -553,7 +621,8 @@ fields (`cpf`, `whatsapp_phone_number`) with the PHP SDK and n8n node.
553
621
  - High-level `uploadAndRequestSignatures` helper on `AssinafyClient`.
554
622
  - `PaginatedResult<T>` with parsed `X-Pagination-*` header meta.
555
623
 
556
- [Unreleased]: https://github.com/assinafy/typescript-sdk/compare/v2.2.0...HEAD
624
+ [Unreleased]: https://github.com/assinafy/typescript-sdk/compare/v2.3.0...HEAD
625
+ [2.3.0]: https://github.com/assinafy/typescript-sdk/compare/v2.2.0...v2.3.0
557
626
  [2.2.0]: https://github.com/assinafy/typescript-sdk/compare/v2.1.2...v2.2.0
558
627
  [2.1.2]: https://github.com/assinafy/typescript-sdk/compare/v2.1.1...v2.1.2
559
628
  [2.1.1]: https://github.com/assinafy/typescript-sdk/compare/v2.1.0...v2.1.1