@atol-sh/js 0.4.3 → 0.5.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
@@ -6,6 +6,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ### Changed
10
+
11
+ - Core SDK 0.5 requires Node 22.12 or newer. The package uses JOSE 6 for
12
+ ML-DSA-87 JWT and proof handling.
13
+ - Browser and standalone token verification now require ML-DSA-87 by
14
+ default. Enabled browser DPoP and the standalone key manager use
15
+ ML-DSA-87 by default. Explicit legacy compatibility preserves the prior
16
+ issuer verification policy and ES256 proofs.
17
+ - New ordinary browser authorization records use SHA-384 callback Web Locks.
18
+ Existing records retain their original lock and settlement behavior.
19
+ - Ordinary browser PAR accepts the full SHA-384 request URI profile and
20
+ preserves canonical retained URIs during navigation and settlement.
21
+
9
22
  ## [0.4.3] - 2026-11-24
10
23
 
11
24
  ### Fixed
package/README.md CHANGED
@@ -76,6 +76,25 @@ if (result) {
76
76
  await auth.logout()
77
77
  ```
78
78
 
79
+ ### Ordinary callback custody upgrades
80
+
81
+ Treat the ordinary browser `request_uri` as opaque. Current issuers can
82
+ return a 64-character unpadded base64url suffix derived from the full SHA-384
83
+ root identifier. The SDK also preserves canonical 43-character suffixes
84
+ from retained requests and earlier issuers throughout navigation, retry,
85
+ and terminal settlement.
86
+
87
+ New ordinary OIDC callbacks use a purpose-bound SHA-384 code commitment in
88
+ browser-local custody. After an issuer upgrade, the SDK retires a saved
89
+ predecessor proof only after an authenticated terminal response from its
90
+ original issuer. A pending or ambiguous response preserves the exact local
91
+ record for retry. If a lost authorization response leaves the old tab's
92
+ history indeterminate, start a fresh sign-in in a new tab opened independently
93
+ of the old tab. The fresh tab has separate ownership and leaves the earlier
94
+ record in place. It stays signed out until an explicit sign-in. Old and new
95
+ SDK versions use the same Web Lock coordination ID. PKCE and DPoP protocol
96
+ hashes keep their standard algorithms.
97
+
79
98
  ### Response-vault v1
80
99
 
81
100
  Registered clients can opt into the public response-vault protocol when their
@@ -133,8 +152,8 @@ starts one fresh login; `canRestartLogin()` reports whether this runtime holds
133
152
  the hidden exact authority required for that operation;
134
153
  `signDPoPProof(method, url)` signs a
135
154
  standalone RFC 9449 proof for a request to your own protected resource;
136
- `isDPoPActive()` reports whether DPoP is actually in effect (it can be
137
- `false` even when `dpop: true` was requested, if WebCrypto is unavailable);
155
+ `isDPoPActive()` reports whether DPoP is in effect. In the default signature
156
+ policy, an enabled DPoP configuration requires native ML-DSA-87 support.
138
157
  `destroy()` tears down timers and subscriptions. If a browser resource close
139
158
  throws, the client stays destroyed, retains only that cleanup ownership, and
140
159
  throws `AtolBrowserAuthCleanupError`; calling `destroy()` again retries the
@@ -145,7 +164,7 @@ incomplete step.
145
164
  The core also exports the building blocks for consumers who assemble their
146
165
  own flows:
147
166
 
148
- - **DPoP** - `createDPoPKeyManager` (per-tab non-exportable ES256 key,
167
+ - **DPoP** - `createDPoPKeyManager` (per-tab non-exportable ML-DSA-87 key,
149
168
  RFC 9449 proofs).
150
169
  - **Verification** - `verifyIdToken` (JWKS signature + issuer + audience +
151
170
  required OIDC claims and callback nonce).
@@ -169,6 +188,12 @@ signatures; every export carries a doc comment.
169
188
 
170
189
  ## Security
171
190
 
191
+ For browser deployments, TLS negotiation and certificate trust belong to
192
+ the browser and the endpoint. The SDK's fetch and navigation calls inherit
193
+ those settings. Qualify supported browsers and the deployed endpoint before
194
+ routing them to a private CNSA 2.0 listener. Transport settings are separate
195
+ from OIDC signature and browser DPoP key support.
196
+
172
197
  This is a security library first. Key properties:
173
198
 
174
199
  - **Memory-only tokens.** Access, ID, and (when opted in) refresh tokens
@@ -248,14 +273,14 @@ This is a security library first. Key properties:
248
273
  on). Same-site apps (a console on a subdomain of the IdP) reach the
249
274
  first-party session cookie in the iframe and leave it `false`.
250
275
  - **DPoP sender-constraint (RFC 9449).** When `dpop: true`, a per-tab,
251
- non-exportable ES256 keypair is generated on `init()` and a proof JWT is
276
+ non-exportable ML-DSA-87 keypair is generated and a proof JWT is
252
277
  attached to every token-endpoint call and to `getAccessToken({ dpop })`
253
278
  results. A stolen access token cannot be replayed from another client
254
279
  without the private key, which never leaves the browser's WebCrypto
255
280
  keystore. Every token response is rejected unless `token_type=DPoP` and
256
- the access token's `cnf.jkt` matches that tab key. Use
257
- `dpop: { required: true }` to fail initialization when key creation is
258
- unavailable instead of permitting the boolean option's Bearer fallback.
281
+ the access token's `cnf.jkt` matches that tab key. Key creation failure
282
+ stops authentication under the default policy. In explicit legacy mode,
283
+ `dpop: { required: true }` requires the ES256 key to be available.
259
284
  - **PKCE + nonce + ID token verification.** Login uses OIDC Authorization
260
285
  Code with PKCE (no implicit flow, no client secret in the browser).
261
286
  Callback state and PKCE are consumed through oidc-client-ts, while the SDK
@@ -361,6 +386,54 @@ generation immediately fences late responses from every older request. Call
361
386
  `collector.invalidate()` on logout before releasing the collector; future
362
387
  credentials must continue with a higher generation.
363
388
 
389
+ ### Application data-key wrapping
390
+
391
+ The core JS SDK unwraps the issuer's v2 AES-256-GCM envelope and reads
392
+ historical unversioned wrappers. The v2 envelope adds a `v2.` prefix and
393
+ authenticates the wrapping version. A password sign-in can rewrap an
394
+ existing application key with the new KEK while preserving the DEK. If
395
+ a browser vault holds an old KEK, sign in again with the password to
396
+ refresh its custody.
397
+
398
+ ## CNSA 2.0 token and proof signatures
399
+
400
+ `createAtolBrowserAuth`, `verifyIdToken` and `verifyAccessToken` require
401
+ RFC 9964 ML-DSA-87 JWT signatures by default. The core uses native WebCrypto
402
+ and the issuer's advertised AKP verification keys.
403
+ Auth still checks audience, expiry, token type, and nonce as applicable.
404
+
405
+ With DPoP enabled, the default policy also requires an ML-DSA-87 proof key.
406
+ The private key stays non-exportable when a redirect needs to stage its
407
+ opaque key handle. An unsupported runtime stops before issuer discovery
408
+ or authorization. `dpop: false` disables proofs on ordinary browser flows
409
+ and keeps the ML-DSA-87 JWT requirement. Manual DPoP callers get ML-DSA-87
410
+ from `createDPoPKeyManager()` and must handle a null result as unsupported.
411
+ RFC 9449 `ath` and RFC 7638 thumbprints keep SHA-256 as required by their
412
+ wire formats.
413
+
414
+ For an explicitly supported legacy issuer, set `requireMLDSA87: false` to
415
+ use its existing JWKS verification policy and ES256 DPoP keys. Manual
416
+ proof clients can use `createDPoPKeyManager('ES256')` for that compatibility
417
+ path. Synthetic sessions require both the existing test-only opt-in and
418
+ `requireMLDSA87: false`.
419
+
420
+ New ordinary browser authorization records use SHA-384 to identify the
421
+ callback Web Lock. Existing records keep their original lock so a refreshed
422
+ tab still coordinates with a predecessor tab. Existing attempts are
423
+ settled before starting a fresh sign-in. If cancellation is ambiguous, the
424
+ SDK retains that custody and retries settlement. Tabs on the predecessor
425
+ SDK must refresh before they can open a new-format record.
426
+
427
+ Use a browser with native ML-DSA-87 generation, JWK export and
428
+ verification, and qualify structured cloning for redirect flows. Compatible
429
+ Node runtimes can verify server-side.
430
+ Node 24.23.0 is exercised in CI for ML-DSA-87. The package requires
431
+ Node 22.12.0 or later for the ESM dependency used by its CommonJS
432
+ entry point. The strict proof and token paths cap each compact JWT at
433
+ 24 KiB. Confirm the issuer, resource server, and intermediaries permit
434
+ the combined header size. Settle existing authorization transactions
435
+ before upgrading browsers or issuers to the new default.
436
+
364
437
  ## Browser support
365
438
 
366
439
  Requires a browser with WebCrypto (`crypto.subtle`): all evergreen
@@ -383,9 +456,9 @@ back: missing WebCrypto is a fatal authorization error.
383
456
  - **"invalid redirect_uri".** The `redirectUri` you pass must be allow-listed
384
457
  for your publishable key in [console.atol.sh](https://console.atol.sh).
385
458
  Add the exact URI (scheme, host, port, path) there.
386
- - **DPoP silently falls back to Bearer.** `dpop: true` only takes effect
387
- when WebCrypto is available; call `isDPoPActive()` to check whether it
388
- actually did. A server-issued `DPoP-Nonce` challenge is retried
459
+ - **Authentication reports unavailable ML-DSA-87 support.** Use a browser
460
+ with native support for the required signature operations. A server-issued
461
+ `DPoP-Nonce` challenge is retried
389
462
  automatically with the nonce attached -- no consumer action needed.
390
463
  - **Permission checks return `false` unexpectedly.** `loadPermissions`
391
464
  denies by default: a `false` means either the server-side permission
@@ -30,6 +30,12 @@ Enabling the SDK option does not add server support. The issuer and the
30
30
  client-origin service MUST implement the same v1 contract for the registered
31
31
  client.
32
32
 
33
+ The CNSA wire generation uses opaque terminal proofs and attempt capabilities
34
+ with a version-2 byte, a 48-byte HMAC-SHA384 tag, and 99 unpadded base64url
35
+ characters. Drain active browser authorization transactions and update issuers
36
+ and SDK consumers together. Outer response-vault endpoint envelopes retain
37
+ their protocol version.
38
+
33
39
  The registration and SDK configuration have these requirements:
34
40
 
35
41
  - `issuer` is an HTTPS origin. HTTP is accepted only for loopback development,
@@ -41,8 +47,9 @@ The registration and SDK configuration have these requirements:
41
47
  - `clientId` and `audience` are non-empty registered values.
42
48
  - `scopes` is a canonical, space-delimited list with no duplicates and MUST
43
49
  contain `openid`.
44
- - DPoP is mandatory. Every authorization uses a fresh, non-extractable P-256
45
- key.
50
+ - DPoP is mandatory. Every authorization uses a fresh, non-extractable
51
+ ML-DSA-87 key by default. For a legacy issuer, the client can explicitly
52
+ select the compatibility policy with `requireMLDSA87: false` and ES256.
46
53
  - `deriveEncryptionKey` is unsupported because fragment delivery is
47
54
  incompatible with a parameter-free callback.
48
55