@tktchurch/auth 0.9.1 → 0.9.5

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
@@ -2,15 +2,62 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [0.9.5] - 2026-07-18
6
+
7
+ ### Security
8
+
9
+ - PKCE `base64UrlEncode` no longer references Node `Buffer` (Deno Deploy-safe; requires `btoa`).
10
+ - Phone OTP auth/register fallback only on client/validation HTTP failures
11
+ (4xx except 429); no fallback on 5xx or rate limits (Q-040).
12
+ - Example ROPG login routes require opt-in `ALLOW_PASSWORD_GRANT=1` or
13
+ `ENABLE_ROPG=1` (default deny in every environment) (Q-042).
14
+
15
+ ## [0.9.4] - 2026-07-18
16
+
17
+ ### Added
18
+
19
+ - `createPhoneOtpClient()` — high-level phone OTP registration / sign-in /
20
+ verify / profile helpers for microsites (Deno-friendly via npm or dist import).
21
+ - `InitRegistrationRequest.flowType` (e.g. `phone_registration`).
22
+ - Optional `debug` on in-progress flow step results (OTP debug codes).
23
+
24
+ ### Security (examples)
25
+
26
+ - Example app cookies always `Secure` unless `ALLOW_INSECURE_COOKIES=1`.
27
+ - Password-grant (ROPG) login routes hard-stop when `NODE_ENV` or `DEPLOYMENT`
28
+ is `production`.
29
+
30
+ ## [0.9.3] - 2026-07-10
31
+
32
+ ### Added
33
+
34
+ - `user.verifyRecoveryEmail()` — `POST /api/v1/users/me/recovery-email/verify`
35
+ for completing recovery-email verification from hosted account surfaces.
36
+
37
+ ### Changed
38
+
39
+ - Code style pass across the SDK sources, examples, and tests (formatting only;
40
+ no intentional API renames beyond the addition above).
41
+
42
+ ## [0.9.2] - 2026-06-28
43
+
44
+ ### Added
45
+
46
+ - `authorize.evaluateConsent()` and `evaluateConsentWithCredentials()` — call
47
+ `POST /oauth/authorize/consent/evaluate` so hosted login surfaces can skip the
48
+ consent UI when stored grants already cover the requested scopes.
49
+ - `AuthorizationConsentEvaluateBody` and `AuthorizationConsentEvaluateResponse`
50
+ types.
51
+
5
52
  ## [0.9.1] - 2026-06-25
6
53
 
7
54
  ### Changed
8
55
 
9
- - Dual-build pipeline: public npmjs publishes a **consumer** SDK (OAuth/OIDC client
10
- namespaces only); GitHub Packages publishes the **full** internal SDK with admin
11
- console modules, `request`/`fetchWithAuth`, and source maps.
12
- - Public consumer build is minified, ships without source maps, and does not export
13
- `DEFAULT_BASE_URL` or admin TypeScript types.
56
+ - Dual-build pipeline: public npmjs publishes a **consumer** SDK (OAuth/OIDC
57
+ client namespaces only); GitHub Packages publishes the **full** internal SDK
58
+ with admin console modules, `request`/`fetchWithAuth`, and source maps.
59
+ - Public consumer build is minified, ships without source maps, and does not
60
+ export `DEFAULT_BASE_URL` or admin TypeScript types.
14
61
  - `package.json` repository metadata now points at `tktchurch/auth-sdk-js`.
15
62
 
16
63
  ### Added
@@ -22,26 +69,28 @@ All notable changes to this project will be documented in this file.
22
69
 
23
70
  ### Changed
24
71
 
25
- - `accounts/` and `developers/` Nuxt server utilities now use `@tktchurch/auth` for
26
- PKCE authorization start, token exchange/refresh/revoke, user profile fetch, and
27
- `sanitizePostAuthRedirect`.
28
- - Privacy UI stub pages: accounts `/account/privacy`, developers `/admin/privacy`
29
- (hook points for upcoming `auth.privacy.*`).
72
+ - `accounts/` and `developers/` Nuxt server utilities now use `@tktchurch/auth`
73
+ for PKCE authorization start, token exchange/refresh/revoke, user profile
74
+ fetch, and `sanitizePostAuthRedirect`.
75
+ - Privacy UI stub pages: accounts `/account/privacy`, developers
76
+ `/admin/privacy` (hook points for upcoming `auth.privacy.*`).
30
77
 
31
78
  ## [0.6.0] - 2026-06-24
32
79
 
33
80
  ### Added
34
81
 
35
- - Platform modules: `families.*`, `dependents.*` (guardian consent), `clients.providers.*`.
82
+ - Platform modules: `families.*`, `dependents.*` (guardian consent),
83
+ `clients.providers.*`.
36
84
  - Client API keys: `clients.apiKeys.list/create/delete` backed by new OAuth
37
85
  `GET/POST/DELETE /api/v1/clients/:id/api-keys` routes.
38
86
  - OAuth backend admin reads: `GET /api/v1/users/:id/mfa/devices`,
39
- `GET /api/v1/users/:id/webauthn/credentials`, and `GET /api/v1/sessions?user_id=`
40
- for console user detail pages.
87
+ `GET /api/v1/users/:id/webauthn/credentials`, and
88
+ `GET /api/v1/sessions?user_id=` for console user detail pages.
41
89
 
42
90
  ### Tests
43
91
 
44
- - Unit coverage in `tests/phase051-platform.test.ts`; extended local-stack and Playwright suites.
92
+ - Unit coverage in `tests/phase051-platform.test.ts`; extended local-stack and
93
+ Playwright suites.
45
94
 
46
95
  ## [0.5.2] - 2026-06-24
47
96
 
@@ -53,10 +102,12 @@ All notable changes to this project will be documented in this file.
53
102
 
54
103
  ### Added
55
104
 
56
- - Migration parity: `oauth.discoverAuthorizationServer()`, `authorize.probeAuthorize()`,
57
- `user.uploadAvatar()`, `memberDirectory.lookup()`, `federated.*` URL builders and
58
- link finalize HTTP methods.
59
- - Admin reads: `user.admin.getMfaDevices()`, `user.admin.getWebAuthnCredentials()`.
105
+ - Migration parity: `oauth.discoverAuthorizationServer()`,
106
+ `authorize.probeAuthorize()`, `user.uploadAvatar()`,
107
+ `memberDirectory.lookup()`, `federated.*` URL builders and link finalize HTTP
108
+ methods.
109
+ - Admin reads: `user.admin.getMfaDevices()`,
110
+ `user.admin.getWebAuthnCredentials()`.
60
111
  - List filter wiring: `clients.list({ isActive })`, expanded `UserListQuery`,
61
112
  `RoleListQuery`, `SessionListQuery`, `AuditLogListQuery`.
62
113
 
@@ -88,16 +139,18 @@ All notable changes to this project will be documented in this file.
88
139
 
89
140
  ### Changed
90
141
 
91
- - `token.revoke` and `token.introspect` now include `client_id` / `client_secret`
92
- in the request body (required by the OAuth server for RFC 7009 / introspection).
142
+ - `token.revoke` and `token.introspect` now include `client_id` /
143
+ `client_secret` in the request body (required by the OAuth server for RFC 7009
144
+ / introspection).
93
145
 
94
146
  ### Added (0.5.0 continued)
95
147
 
96
148
  - Expanded local-stack integration tests: PKCE full cycle, OIDC/JWKS, flow init,
97
149
  public client metadata.
98
- - Playwright API e2e suite (`tests/e2e/`) for live backend + security invariants.
99
- - `bun run test:local:env` and `bun run test:e2e:env` scripts (source `oauth/.env`).
100
-
150
+ - Playwright API e2e suite (`tests/e2e/`) for live backend + security
151
+ invariants.
152
+ - `bun run test:local:env` and `bun run test:e2e:env` scripts (source
153
+ `oauth/.env`).
101
154
 
102
155
  ### Verified
103
156
 
@@ -107,15 +160,16 @@ All notable changes to this project will be documented in this file.
107
160
 
108
161
  ### Removed (breaking)
109
162
 
110
- - `createLocalStorageTokenStorage` and the `@tktchurch/auth/storage/localStorage`
111
- package subpath. Browser `localStorage` is an XSS sink for OAuth tokens; the
112
- SDK no longer ships a persistence adapter for it.
163
+ - `createLocalStorageTokenStorage` and the
164
+ `@tktchurch/auth/storage/localStorage` package subpath. Browser `localStorage`
165
+ is an XSS sink for OAuth tokens; the SDK no longer ships a persistence adapter
166
+ for it.
113
167
 
114
168
  ### Added
115
169
 
116
- - Token storage validation exports: `assertValidAuthTokens`, `parseStoredAuthTokens`,
117
- `serializeAuthTokens`, `validateStorageKey`, `safeParseStoredJson`,
118
- `DEFAULT_TOKEN_STORAGE_KEY`, `MAX_STORED_TOKEN_BYTES`.
170
+ - Token storage validation exports: `assertValidAuthTokens`,
171
+ `parseStoredAuthTokens`, `serializeAuthTokens`, `validateStorageKey`,
172
+ `safeParseStoredJson`, `DEFAULT_TOKEN_STORAGE_KEY`, `MAX_STORED_TOKEN_BYTES`.
119
173
  - `allowInsecureTransport` config flag (default `false`) — rejects non-HTTPS
120
174
  `baseUrl` outside loopback hosts.
121
175
  - [`SECURITY.md`](./SECURITY.md) threat model and integrator checklist.
@@ -131,8 +185,8 @@ All notable changes to this project will be documented in this file.
131
185
 
132
186
  1. Remove `createLocalStorageTokenStorage()` — not replaced.
133
187
  2. Use HttpOnly cookies for refresh tokens via server routes (see examples).
134
- 3. Implement custom `TokenStorage` with exported validators for platform-specific
135
- secure backends (Keychain, Keystore).
188
+ 3. Implement custom `TokenStorage` with exported validators for
189
+ platform-specific secure backends (Keychain, Keystore).
136
190
 
137
191
  ### Verified
138
192
 
@@ -154,14 +208,15 @@ All notable changes to this project will be documented in this file.
154
208
  - `authorize.handleCallback()` — one call that verifies `state`
155
209
  (constant-time), surfaces server errors, and exchanges the code for tokens.
156
210
  - Standalone PKCE/CSRF primitives: `generatePkce`, `generateCodeVerifier`,
157
- `deriveCodeChallenge`, `generateState`, `generateNonce`, `randomUrlSafeString`,
158
- `timingSafeEqual` — all backed by the platform Web Crypto CSPRNG.
211
+ `deriveCodeChallenge`, `generateState`, `generateNonce`,
212
+ `randomUrlSafeString`, `timingSafeEqual` — all backed by the platform Web
213
+ Crypto CSPRNG.
159
214
  - `sanitizePostAuthRedirect()` open-redirect guard (rejects protocol-relative,
160
215
  backslash-smuggled, scheme-bearing, and CRLF targets).
161
216
  - `oidc.discover()` — fetches and maps `/.well-known/openid-configuration`.
162
- - Broader public type exports (`AuthorizationUrlOptions`, `AuthorizationRequest`,
163
- `CallbackParams`, `HandleCallbackOptions`, `OidcDiscoveryDocument`, endpoint
164
- interfaces, `AuthErrorCode`).
217
+ - Broader public type exports (`AuthorizationUrlOptions`,
218
+ `AuthorizationRequest`, `CallbackParams`, `HandleCallbackOptions`,
219
+ `OidcDiscoveryDocument`, endpoint interfaces, `AuthErrorCode`).
165
220
 
166
221
  ### Security
167
222
 
@@ -181,15 +236,18 @@ All notable changes to this project will be documented in this file.
181
236
 
182
237
  ### Added
183
238
 
184
- - Framework-agnostic `@tktchurch/auth` SDK core with typed OAuth, OIDC, AuthFlow, sessions, user, and WebAuthn endpoint wrappers.
185
- - Token lifecycle support with pluggable storage and `fetchWithAuth` one-retry refresh flow.
239
+ - Framework-agnostic `@tktchurch/auth` SDK core with typed OAuth, OIDC,
240
+ AuthFlow, sessions, user, and WebAuthn endpoint wrappers.
241
+ - Token lifecycle support with pluggable storage and `fetchWithAuth` one-retry
242
+ refresh flow.
186
243
  - Nuxt module export `@tktchurch/auth/nuxt` with:
187
244
  - `tktAuth` module configuration.
188
245
  - injected `$tktAuth` client via `useTktAuth()`.
189
246
  - server factory `createTktServerAuthClient()`.
190
247
  - cookie helper `useTktRefreshCookieName()`.
191
248
  - Next.js and Nuxt3 production examples in `examples/`.
192
- - Production-gated Nuxt3 integration tests (`tests/nuxt3.production.test.ts`) for login/me/logout patterns.
249
+ - Production-gated Nuxt3 integration tests (`tests/nuxt3.production.test.ts`)
250
+ for login/me/logout patterns.
193
251
  - Release metadata and publish hardening:
194
252
  - GitHub Packages publish configuration.
195
253
  - npmjs public publish workflow and scripts.
@@ -200,11 +258,13 @@ All notable changes to this project will be documented in this file.
200
258
  - Default SDK endpoint remains `https://prod-auth.tktchurch.com`.
201
259
  - Package version bumped to `0.2.0`.
202
260
  - Build output now includes the Nuxt module entry (`./nuxt`).
203
- - Improved strict TypeScript coverage (no implicit `any` in SDK/Nuxt example handlers).
261
+ - Improved strict TypeScript coverage (no implicit `any` in SDK/Nuxt example
262
+ handlers).
204
263
 
205
264
  ### Verified
206
265
 
207
266
  - `bun run typecheck`
208
267
  - `bun run test`
209
268
  - `bun run build`
210
- - `bun run test:nuxt3:prod` (passes when target auth server is reachable and seeded credentials are valid)
269
+ - `bun run test:nuxt3:prod` (passes when target auth server is reachable and
270
+ seeded credentials are valid)
package/PUBLISHING.md CHANGED
@@ -1,13 +1,16 @@
1
1
  # Publishing Guide (`@tktchurch/auth`)
2
2
 
3
- This package uses a **dual-build** pipeline. The artifact published to each registry differs:
3
+ This package uses a **dual-build** pipeline. The artifact published to each
4
+ registry differs:
4
5
 
5
- | Registry | Build profile | Contents |
6
- | --- | --- | --- |
7
- | **npmjs** (public) | `consumer` | OAuth/OIDC client SDK only — no admin console modules, no `request`/`fetchWithAuth`, no source maps |
8
- | **GitHub Packages** (private) | `full` | Complete internal SDK (admin CRUD, privacy admin, generic passthrough, source maps) |
6
+ | Registry | Build profile | Contents |
7
+ | ----------------------------- | ------------- | --------------------------------------------------------------------------------------------------- |
8
+ | **npmjs** (public) | `consumer` | OAuth/OIDC client SDK only — no admin console modules, no `request`/`fetchWithAuth`, no source maps |
9
+ | **GitHub Packages** (private) | `full` | Complete internal SDK (admin CRUD, privacy admin, generic passthrough, source maps) |
9
10
 
10
- Registry selection is command/workflow specific. The repo intentionally does not pin `publishConfig.registry` or a scoped `.npmrc` to avoid cross-registry auth conflicts.
11
+ Registry selection is command/workflow specific. The repo intentionally does not
12
+ pin `publishConfig.registry` or a scoped `.npmrc` to avoid cross-registry auth
13
+ conflicts.
11
14
 
12
15
  ## 1. Prerequisites
13
16
 
@@ -15,13 +18,16 @@ Registry selection is command/workflow specific. The repo intentionally does not
15
18
  - Package scope is `@tktchurch`.
16
19
  - You have permission to publish packages in the `tktchurch` organization.
17
20
  - npm scope access for `@tktchurch` (or delegated publish rights).
18
- - A GitHub token with `write:packages` and `repo` scope (for local GitHub publish).
21
+ - A GitHub token with `write:packages` and `repo` scope (for local GitHub
22
+ publish).
19
23
  - An npm token with publish rights (for local npmjs publish).
20
- - npm trusted publishing configured for this package/repository (for GitHub Actions npmjs publish).
24
+ - npm trusted publishing configured for this package/repository (for GitHub
25
+ Actions npmjs publish).
21
26
 
22
27
  ## 2. Local Release Validation
23
28
 
24
- Full internal build (used by `accounts` / `developers` via `file:../auth-sdk-js`):
29
+ Full internal build (used by `accounts` / `developers` via
30
+ `file:../auth-sdk-js`):
25
31
 
26
32
  ```bash
27
33
  bun run release:check
@@ -35,10 +41,10 @@ bun run release:check:consumer
35
41
 
36
42
  Both run typecheck + tests, then build with the matching profile:
37
43
 
38
- | Script | Build |
39
- | --- | --- |
40
- | `bun run build` / `build:full` | `BUILD_PROFILE=full` |
41
- | `bun run build:consumer` | `BUILD_PROFILE=consumer` |
44
+ | Script | Build |
45
+ | ------------------------------ | ------------------------ |
46
+ | `bun run build` / `build:full` | `BUILD_PROFILE=full` |
47
+ | `bun run build:consumer` | `BUILD_PROFILE=consumer` |
42
48
 
43
49
  ## 3. Local Publish (Manual)
44
50
 
@@ -70,13 +76,15 @@ Publish:
70
76
  bun run publish:npmjs
71
77
  ```
72
78
 
73
- Both publish scripts run the matching `release:check*` pipeline and pass `--ignore-scripts` so `prepublishOnly` does not rebuild with the wrong profile.
79
+ Both publish scripts run the matching `release:check*` pipeline and pass
80
+ `--ignore-scripts` so `prepublishOnly` does not rebuild with the wrong profile.
74
81
 
75
82
  ## 4. GitHub Actions Publish
76
83
 
77
84
  Workflow files:
78
85
 
79
- 1. `.github/workflows/publish-github-packages.yml` — `build:full` → GitHub Packages
86
+ 1. `.github/workflows/publish-github-packages.yml` — `build:full` → GitHub
87
+ Packages
80
88
  2. `.github/workflows/publish-npmjs.yml` — `build:consumer` → npmjs
81
89
 
82
90
  Triggers:
@@ -84,9 +92,12 @@ Triggers:
84
92
  1. Tag push matching `v*` (for example `v0.9.1`)
85
93
  2. Manual dispatch
86
94
 
87
- The GitHub Packages workflow installs dependencies, typechecks, tests, builds the **full** bundle, and publishes with `GITHUB_TOKEN`.
95
+ The GitHub Packages workflow installs dependencies, typechecks, tests, builds
96
+ the **full** bundle, and publishes with `GITHUB_TOKEN`.
88
97
 
89
- The npmjs workflow installs dependencies, typechecks, tests, builds the **consumer** bundle, and publishes using trusted publishing (GitHub OIDC) when configured.
98
+ The npmjs workflow installs dependencies, typechecks, tests, builds the
99
+ **consumer** bundle, and publishes using trusted publishing (GitHub OIDC) when
100
+ configured.
90
101
 
91
102
  ## 5. Tagging and Changelog
92
103
 
@@ -101,14 +112,16 @@ git push origin v0.9.1
101
112
 
102
113
  ## 6. Required Repository Secrets
103
114
 
104
- 1. No npmjs token secret is required for npmjs workflow when OIDC trusted publishing is configured.
115
+ 1. No npmjs token secret is required for npmjs workflow when OIDC trusted
116
+ publishing is configured.
105
117
  2. GitHub Packages workflow uses `GITHUB_TOKEN` automatically.
106
118
 
107
119
  ## 7. Consumer vs full SDK
108
120
 
109
121
  **Public npm (`consumer`)** ships:
110
122
 
111
- - `authorize`, `token`, `oidc`, `flow`, `user` (self-service), `sessions`, `webauthn`, `passwordReset`, `mfa`, `maintenance.status`, `oauth` meta
123
+ - `authorize`, `token`, `oidc`, `flow`, `user` (self-service), `sessions`,
124
+ `webauthn`, `passwordReset`, `mfa`, `maintenance.status`, `oauth` meta
112
125
  - PKCE, redirect sanitization, token storage helpers
113
126
  - Nuxt module entry
114
127
 
@@ -118,4 +131,5 @@ git push origin v0.9.1
118
131
  - `request()` and `fetchWithAuth()` passthrough helpers
119
132
  - `DEFAULT_BASE_URL` export and full TypeScript admin types
120
133
 
121
- Internal TKTChurch apps should install from GitHub Packages or use `file:../auth-sdk-js` with `bun run build:full`.
134
+ Internal TKTChurch apps should install from GitHub Packages or use
135
+ `file:../auth-sdk-js` with `bun run build:full`.
package/README.md CHANGED
@@ -63,8 +63,8 @@ surfaces server errors, and exchanges the code for tokens:
63
63
 
64
64
  ```ts
65
65
  const tokens = await auth.authorize.handleCallback({
66
- callback: requestUrl, // full callback URL or its query string
67
- expectedState: saved.state, // the state you persisted in step 1
66
+ callback: requestUrl, // full callback URL or its query string
67
+ expectedState: saved.state, // the state you persisted in step 1
68
68
  codeVerifier: saved.codeVerifier,
69
69
  redirectUri: saved.redirectUri,
70
70
  });
@@ -93,9 +93,15 @@ return Response.redirect(sanitizePostAuthRedirect(next, "/dashboard"));
93
93
  If you need the primitives directly:
94
94
 
95
95
  ```ts
96
- import { generatePkce, generateState, generateNonce, deriveCodeChallenge } from "@tktchurch/auth";
97
-
98
- const { codeVerifier, codeChallenge, codeChallengeMethod } = await generatePkce();
96
+ import {
97
+ deriveCodeChallenge,
98
+ generateNonce,
99
+ generatePkce,
100
+ generateState,
101
+ } from "@tktchurch/auth";
102
+
103
+ const { codeVerifier, codeChallenge, codeChallengeMethod } =
104
+ await generatePkce();
99
105
  ```
100
106
 
101
107
  ### OIDC discovery
@@ -128,7 +134,8 @@ export async function GET() {
128
134
 
129
135
  > Do **not** store OAuth tokens in `localStorage` or `sessionStorage`. The SDK
130
136
  > does not ship a browser persistence adapter — use server-side cookies or a
131
- > platform secure store (Keychain, Keystore). See [`SECURITY.md`](./SECURITY.md).
137
+ > platform secure store (Keychain, Keystore). See
138
+ > [`SECURITY.md`](./SECURITY.md).
132
139
 
133
140
  ## Framework Examples (Best Practices)
134
141
 
@@ -181,6 +188,7 @@ const init = await auth.flow.initAuthentication({
181
188
  let status = await auth.flow.executeStep({
182
189
  sessionId: init.sessionId,
183
190
  stepId: init.currentStep.stepId,
191
+ continuationToken: init.continuationToken,
184
192
  credential: {
185
193
  username: "user@example.com",
186
194
  password: "secret",
@@ -192,6 +200,7 @@ while (status.status === "in_progress") {
192
200
  status = await auth.flow.executeStep({
193
201
  sessionId: status.sessionId,
194
202
  stepId: status.nextStep.stepId,
203
+ continuationToken: init.continuationToken,
195
204
  credential: {},
196
205
  });
197
206
  }
@@ -217,8 +226,8 @@ const auth = createAuthClient({
217
226
 
218
227
  For platform-specific secure backends (Keychain, Keystore, encrypted server
219
228
  session), implement `TokenStorage` using the exported validators
220
- (`assertValidAuthTokens`, `parseStoredAuthTokens`, `serializeAuthTokens`).
221
- See [`SECURITY.md`](./SECURITY.md).
229
+ (`assertValidAuthTokens`, `parseStoredAuthTokens`, `serializeAuthTokens`). See
230
+ [`SECURITY.md`](./SECURITY.md).
222
231
 
223
232
  ## Error Handling
224
233
 
@@ -243,9 +252,12 @@ try {
243
252
 
244
253
  ## Authenticated Fetch
245
254
 
246
- `fetchWithAuth` adds the bearer token automatically and retries once on `401` using refresh token when possible.
255
+ `fetchWithAuth` adds the bearer token automatically and retries once on `401`
256
+ using refresh token when possible.
247
257
 
248
- > **Note:** `fetchWithAuth` and `request()` are available only in the **full** SDK (GitHub Packages / local `file:` build). The public npmjs consumer build omits generic passthrough helpers.
258
+ > **Note:** `fetchWithAuth` and `request()` are available only in the **full**
259
+ > SDK (GitHub Packages / local `file:` build). The public npmjs consumer build
260
+ > omits generic passthrough helpers.
249
261
 
250
262
  ```ts
251
263
  const response = await auth.fetchWithAuth("/api/v1/users/me");
@@ -256,27 +268,36 @@ if (!response.ok) {
256
268
 
257
269
  ## API reference (public consumer build)
258
270
 
259
- The public npmjs package ships OAuth/OIDC client namespaces only. Admin console modules (`clients`, `roles`, `auditLogs`, …) and generic passthrough helpers are available in the **full** SDK from GitHub Packages — see [`CONTEXT.md`](./CONTEXT.md).
260
-
261
- | Namespace | Methods | Auth |
262
- | --- | --- | --- |
263
- | `token` | `password`, `refresh`, `clientCredentials`, `authorizationCode`, `tokenExchange`, `revoke`, `introspect` | client credentials / stored tokens |
264
- | `authorize` | `createRequest`, `parseCallback`, `handleCallback`, `consent`, `consentWithCredentials` | public + server session |
265
- | `oidc` | `userInfo`, `discover`, `jwks` | bearer / public |
266
- | `oauth` | `publicClient`, `discoverAuthorizationServer` | public |
267
- | `flow` | `initAuthentication`, `executeStep`, `initRegistration`, `executeRegistrationStep`, `initRecovery`, `executeRecoveryStep`, `getStatus` | public / step session |
268
- | `user` | `me`, `updateMe`, `changePassword`, `deleteAvatar`, `verifyPhone`, `securityOverview`, `recoveryContacts.*`, `identities.*`, `deleteMe` | bearer |
269
- | `sessions` | `list`, `current`, `get`, `update`, `revoke`, `revokeAll`, `revokeAllDevices` | bearer |
270
- | `webauthn` | `registerBegin/Finish`, `authenticateBegin/Finish`, `credentials`, `removeCredential`, `renameCredential`, `setPrimaryCredential` | bearer / public begin |
271
- | `passwordReset` | `request`, `validate`, `complete` | public |
272
- | `mfa` | `setup`, `verify`, `devices`, `removeDevice`, `regenerateBackupCodes`, `disable` | bearer |
273
- | `maintenance` | `status` | public |
274
-
275
- Integrators must pass an explicit `baseUrl` in `createAuthClient({ baseUrl, clientId, })`. The public consumer build does not export `DEFAULT_BASE_URL`.
271
+ The public npmjs package ships OAuth/OIDC client namespaces only. Admin console
272
+ modules (`clients`, `roles`, `auditLogs`, …) and generic passthrough helpers are
273
+ available in the **full** SDK from GitHub Packages — see
274
+ [`CONTEXT.md`](./CONTEXT.md).
275
+
276
+ | Namespace | Methods | Auth |
277
+ | --------------- | --------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------- |
278
+ | `token` | `password`, `refresh`, `clientCredentials`, `authorizationCode`, `tokenExchange`, `revoke`, `introspect` | client credentials / stored tokens |
279
+ | `authorize` | `createRequest`, `parseCallback`, `handleCallback`, `consent`, `consentWithCredentials` | public + server session |
280
+ | `oidc` | `userInfo`, `discover`, `jwks` | bearer / public |
281
+ | `oauth` | `publicClient`, `discoverAuthorizationServer` | public |
282
+ | `flow` | `initAuthentication`, `executeStep`, `initRegistration`, `executeRegistrationStep`, `initRecovery`, `executeRecoveryStep`, `getStatus` | public / step session |
283
+ | `user` | `me`, `updateMe`, `changePassword`, `deleteAvatar`, `verifyPhone`, `securityOverview`, `recoveryContacts.*`, `identities.*`, `deleteMe` | bearer |
284
+ | `sessions` | `list`, `current`, `get`, `update`, `revoke`, `revokeAll`, `revokeAllDevices` | bearer |
285
+ | `webauthn` | `registerBegin/Finish`, `authenticateBegin/Finish`, `credentials`, `removeCredential`, `renameCredential`, `setPrimaryCredential` | bearer / public begin |
286
+ | `passwordReset` | `request`, `validate`, `complete` | public |
287
+ | `mfa` | `setup`, `verify`, `devices`, `removeDevice`, `regenerateBackupCodes`, `disable` | bearer |
288
+ | `maintenance` | `status` | public |
289
+
290
+ Integrators must pass an explicit `baseUrl` in
291
+ `createAuthClient({ baseUrl, clientId, … })`. The public consumer build does not
292
+ export `DEFAULT_BASE_URL`.
276
293
 
277
294
  ### Internal admin SDK (GitHub Packages only)
278
295
 
279
- The full build adds `consents`, admin `maintenance.*`, `clients` … `comms`, `privacy`, `user.admin.*`, plus `request()` / `fetchWithAuth()`. Admin methods require a bearer access token with matching backend permissions (`client:read`, `user:write`, `*:*`, etc.). The SDK does not enforce permissions — the OAuth server does.
296
+ The full build adds `consents`, admin `maintenance.*`, `clients` … `comms`,
297
+ `privacy`, `user.admin.*`, plus `request()` / `fetchWithAuth()`. Admin methods
298
+ require a bearer access token with matching backend permissions (`client:read`,
299
+ `user:write`, `*:*`, etc.). The SDK does not enforce permissions — the OAuth
300
+ server does.
280
301
 
281
302
  ### Migrating from hand-rolled `oauth.ts`
282
303
 
@@ -287,13 +308,18 @@ Replace direct `fetch` calls with namespaced SDK methods:
287
308
  await fetch(`${baseUrl}/oauth/token`, { method: "POST", body });
288
309
 
289
310
  // After
290
- const tokens = await auth.token.authorizationCode({ code, redirectUri, codeVerifier });
311
+ const tokens = await auth.token.authorizationCode({
312
+ code,
313
+ redirectUri,
314
+ codeVerifier,
315
+ });
291
316
  ```
292
317
 
293
- For admin console CRUD (`/api/v1/clients`, etc.), use the **full** SDK from GitHub Packages — see [`CONTEXT.md`](./CONTEXT.md).
318
+ For admin console CRUD (`/api/v1/clients`, etc.), use the **full** SDK from
319
+ GitHub Packages — see [`CONTEXT.md`](./CONTEXT.md).
294
320
 
295
- Inject internal URL rewriting via `createAuthClient({ fetch })` — same pattern as
296
- `accounts` / `developers` `oauth-fetch.ts`.
321
+ Inject internal URL rewriting via `createAuthClient({ fetch })` — same pattern
322
+ as `accounts` / `developers` `oauth-fetch.ts`.
297
323
 
298
324
  ## Release and Publish
299
325
 
@@ -303,13 +329,17 @@ Inject internal URL rewriting via `createAuthClient({ fetch })` — same pattern
303
329
  GitHub Packages (private, `tktchurch` scope) is configured via:
304
330
 
305
331
  - Script: `bun run publish:github`
306
- - Workflow: [`.github/workflows/publish-github-packages.yml`](./.github/workflows/publish-github-packages.yml)
332
+ - Workflow:
333
+ [`.github/workflows/publish-github-packages.yml`](./.github/workflows/publish-github-packages.yml)
307
334
  - Auth token: `NODE_AUTH_TOKEN` (`GITHUB_TOKEN` in workflow)
308
335
 
309
336
  npmjs (public) publishing ships the **consumer** build only:
310
337
 
311
338
  - Script: `bun run publish:npmjs` (runs `release:check:consumer`)
312
- - Workflow: [`.github/workflows/publish-npmjs.yml`](./.github/workflows/publish-npmjs.yml)
313
- - Auth: npm trusted publishing (OIDC, no `NPM_TOKEN` secret) or local `NODE_AUTH_TOKEN`
339
+ - Workflow:
340
+ [`.github/workflows/publish-npmjs.yml`](./.github/workflows/publish-npmjs.yml)
341
+ - Auth: npm trusted publishing (OIDC, no `NPM_TOKEN` secret) or local
342
+ `NODE_AUTH_TOKEN`
314
343
 
315
- GitHub Packages ships the **full** internal SDK. See [`PUBLISHING.md`](./PUBLISHING.md) for the dual-build matrix.
344
+ GitHub Packages ships the **full** internal SDK. See
345
+ [`PUBLISHING.md`](./PUBLISHING.md) for the dual-build matrix.