@adonis-agora/authkit-testing 0.6.4 → 1.0.0-rc.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 ADDED
@@ -0,0 +1,235 @@
1
+ # @adonis-agora/authkit-testing
2
+
3
+ ## 1.0.0-rc.0
4
+
5
+ ### Major Changes
6
+
7
+ - [#436](https://github.com/DavideCarvalho/adonis-agora-authkit/pull/436) [`c942fe3`](https://github.com/DavideCarvalho/adonis-agora-authkit/commit/c942fe30483346217c9c89112e13db0d4a65c647) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - AuthKit 1.0. See the [Migrating to 1.0](https://github.com/DavideCarvalho/adonis-agora-authkit/blob/main/apps/docs/content/docs/migrating-to-1-0.mdx) guide.
8
+
9
+ Breaking changes (`@adonis-agora/authkit-server`):
10
+
11
+ - `withMfa` is removed. MFA state lives in the lib-owned `auth_mfa` table, so drop the mixin from your `AuthUser` model's `compose(...)`.
12
+ - `markSudo` is no longer exported. Grant sudo with `completeSudo(sudoContextFrom(ctx), methodId)`, which also writes the `sudo.confirmed` audit event, remembers the method and redirects to the validated `return_to`.
13
+ - The email-change confirmation link is sent through `mail.onEmailChangeConfirm` only. Without it, AuthKit sends its built-in email; `onEmailVerification` no longer receives email-change confirmations.
14
+ - The `clients` option of `defineConfig` is removed. Create clients in the admin console, through the Admin API or with `node ace authkit:clients:create` (new `--client-secret` flag keeps an existing secret). `buildImpersonationPanel(cfg, targetId, clients)` now requires `clients`, and the impersonation curl always shows the `<CLIENT_SECRET>` placeholder.
15
+ - `inertiaRenderer({ prefix, views })`: `views` is required. Screens not listed render with the built-in Edge view. `AuthkitScreen` is now the exact union of the screens AuthKit renders (adds `throttled`, `agents/consent`, `agents/done`; no arbitrary strings), and every screen's props are exported: `AuthkitScreenProps['<view>']` plus named types (`LoginProps`, `SessionExpiredProps`, …). The controllers are checked against them. Hosts declare screens of their own by augmenting `AuthkitScreenProps` (`declare module '@adonis-agora/authkit-server'`).
16
+ - The Admin API client body reads `grantTypes` only; the `grants` alias is gone (responses still return `grants`).
17
+ - `lucidAccountStore` always mounts password history over the model's connection (`auth_password_history`).
18
+ - `/account/orgs/json`, `/account/orgs/invitations/json` and `/account/orgs/:id/json` are removed; use `/account/api/orgs/*`.
19
+ - `GET /account/api/apps` entries gain `name` and `logoUrl`.
20
+
21
+ - The admin console reads its config from a `<script type="application/json" id="authkit-admin-config">` data block (CSP-safe) instead of an inline `window.__AUTHKIT__` script; the dev fallback is gone.
22
+ - The admin client DTO returns `grantTypes` (was `grants`), plus `clientName` and `logoUri`, which the console and the Admin API can now set (`null` removes them, as it does `backchannelLogoutUri`). `GET {admin}/api/clients/:id` exists.
23
+ - Anonymous JSON callers of the admin and account JSON APIs get `401` (and `403` without an admin role) instead of a redirect to the login page.
24
+ - Fixes: the Redis adapter's `list()` honours the connection `keyPrefix` (sessions, apps and admin lists were empty); a password login posted without a password is an invalid-credentials answer, not a 500.
25
+
26
+ Breaking changes (`@adonis-agora/authkit-core`):
27
+
28
+ - `ClientConfig` and `ResolvedAuthServerConfig.clients` are removed.
29
+
30
+ Breaking changes (`@adonis-agora/authkit-client`):
31
+
32
+ - `@adonisjs/auth` is a required peer. `ctx.auth` is `@adonisjs/auth`, backed by the AuthKit session through `authkitClientGuard`; `ctx.authkit` (from `authkit_context_middleware`) carries the AuthKit-only data (identity, `hasGlobalRole`, active org, `toSharedProps`).
33
+ - `authkit_middleware`, `auth_middleware` and `silent_auth_middleware` (and their subpaths) are removed: `ctx.auth` comes from `@adonisjs/auth`, and `middleware.auth()` / `silentAuth` are the `#middleware/auth_middleware` / `#middleware/silent_auth_middleware` files `node ace configure` publishes. `require_org_middleware` stays. `@adonis-agora/authkit-client/types` no longer declares `HttpContext.auth`; type `ctx.authkit.getUser()` through the `AuthkitUserType` interface.
34
+ - `node ace configure @adonis-agora/authkit-client` installs `@adonisjs/auth` when missing (`--no-install` prints the command), writes `config/auth.ts` with `authkitClientGuard` + `sessionUserProvider` (`--model`, default `#models/user`; an existing file is left alone and the guard to add is printed), registers `@adonisjs/auth/auth_provider`, `initialize_auth_middleware` + `authkit_context_middleware`, and publishes the named `auth` / `silentAuth` middleware.
35
+ - `authkitClientGuard` takes its user from `resolveUser` when one is configured (so `lucidMirror` provisions the row on first login, and what it loads is on `ctx.auth.user`, the same instance as `ctx.authkit.getUser()`), with the provider as the fallback.
36
+ - New `authkitIdentityProvider()`: a user provider with no database; `ctx.auth.user` is the AuthKit `Identity`.
37
+ - New `authkitClientGuard({ provider, resolver })` option: a per-guard resolver for API routes (bearer JWT, opaque, PAT).
38
+ - `resolvers.jwt({ tokenSource: 'bearer' })` accepts `Authorization: DPoP <jwt>` with a valid `DPoP` proof for `cnf.jkt`-bound tokens, and refuses DPoP-bound tokens sent as `Bearer`.
39
+ - `UnauthorizedAccessConstructor` is no longer exported, and `AuthkitClientGuard` no longer takes an exception class; it always throws `@adonisjs/auth`'s `E_UNAUTHORIZED_ACCESS`.
40
+
41
+ Breaking changes (`@adonis-agora/authkit-sdk`):
42
+
43
+ - `clients.*` return `grantTypes` (was `grants`), plus `clientName` and `logoUri`.
44
+
45
+ Breaking changes (`@adonis-agora/authkit-react`):
46
+
47
+ - `createAuthkitClient()` no longer reads `window.__AUTHKIT__`: pass `baseUrl` for `client.admin.*` and `csrfToken`.
48
+ - Admin response types match the server: `users.remove` / `clients.remove` → `{ ok, deleted }`, `users.resetPassword` → `{ ok, email }`, `users.disable` / `enable` → the user, `SettingListResult.locked`; `AdminClient.grants` → `grantTypes` (+ `clientName`, `logoUri`); `UpdateUserInput` is `{ globalRoles? }`, `CreateUserInput` takes no `null`.
49
+ - New: `client.account.agents.list()` / `revoke()`, `useAccountAgentsQueryOptions`, `useRevokeAccountAgentMutationOptions`.
50
+ - Peers: `react` / `react-dom` `^19.0.0`, `@inertiajs/react` `^2.0.0 || ^3.0.0`.
51
+
52
+ - `useProfile`, `useSessions`, `useAuthorizedApps`, `useOrganizations`, `useOrganization`, `useOrgInvitations`, `useSwitchOrganization` and their types are removed, with the `profile`, `sessions`, `apps`, `orgs` and `orgInvitations` keys of `endpoints`. Use the query options (`useMeQueryOptions`, `useAccountSessionsQueryOptions`, `useAppsQueryOptions`, `useAccountOrgsQueryOptions`, …).
53
+ - `UserProfile`, `AuthorizedApps`, `OrganizationSwitcher` and `OrganizationProfile` need `QueryClientProvider` and `AuthkitClientProvider`.
54
+
55
+ All packages:
56
+
57
+ - `@adonis-agora/*` peer ranges accept 1.x and its release candidates (`<2.0.0 || >=1.0.0-rc.0 <2.0.0`): `durable`, `media`, `telescope` (authkit-server), `resilience` (authkit-client), `authkit-server` (authkit-sdk).
58
+ - Node.js `>=24` is required (tested on 24 and 26).
59
+
60
+ ### Patch Changes
61
+
62
+ - Updated dependencies [[`c942fe3`](https://github.com/DavideCarvalho/adonis-agora-authkit/commit/c942fe30483346217c9c89112e13db0d4a65c647)]:
63
+ - @adonis-agora/authkit-core@1.0.0-rc.0
64
+
65
+ ## 0.6.4
66
+
67
+ ### Patch Changes
68
+
69
+ - fix(deps): update dependency jose to v6.2.15 ([#405](https://github.com/DavideCarvalho/adonis-agora-authkit/issues/405))
70
+
71
+ ## 0.6.3
72
+
73
+ ### Patch Changes
74
+
75
+ - fix(deps): update dependency jose to v6.2.14 ([#388](https://github.com/DavideCarvalho/adonis-agora-authkit/issues/388))
76
+
77
+ ## 0.6.2
78
+
79
+ ### Patch Changes
80
+
81
+ - Updated dependencies [[`1b9c90c`](https://github.com/DavideCarvalho/adonis-agora-authkit/commit/1b9c90ced4356d2c754e850e307954455ddeeb3a)]:
82
+ - @adonis-agora/authkit-core@0.10.1
83
+
84
+ ## 0.6.1
85
+
86
+ ### Patch Changes
87
+
88
+ - fix(deps): update dependency jose to v6.2.13 ([#323](https://github.com/DavideCarvalho/adonis-agora-authkit/issues/323))
89
+
90
+ ## 0.6.0
91
+
92
+ ### Minor Changes
93
+
94
+ - [#269](https://github.com/DavideCarvalho/adonis-agora-authkit/pull/269) [`b0ca480`](https://github.com/DavideCarvalho/adonis-agora-authkit/commit/b0ca4802419aba93a9f913775f697cc4075cff88) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Drop Node 20, which reached end-of-life on 2026-04-30, and Node 22, which AdonisJS 7 does not support (it requires Node >=24): `engines.node` is now `>=24`. The supported Node lines are 24 and 26, and CI runs the test suite on each of them.
95
+
96
+ ### Patch Changes
97
+
98
+ - Updated dependencies [[`b0ca480`](https://github.com/DavideCarvalho/adonis-agora-authkit/commit/b0ca4802419aba93a9f913775f697cc4075cff88)]:
99
+ - @adonis-agora/authkit-core@0.10.0
100
+
101
+ ## 0.5.3
102
+
103
+ ### Patch Changes
104
+
105
+ - Updated dependencies [[`94644e6`](https://github.com/DavideCarvalho/adonis-agora-authkit/commit/94644e6b1d8d10e0fd3c4b57706cce46b70412cb)]:
106
+ - @adonis-agora/authkit-core@0.9.0
107
+
108
+ ## 0.5.2
109
+
110
+ ### Patch Changes
111
+
112
+ - bc32ea4: Bump runtime dependencies to their latest releases.
113
+
114
+ - `@simplewebauthn/server` and `@simplewebauthn/browser` go to `14.x`. The committed
115
+ `src/host/assets/webauthn.js` bundle was regenerated from the new `@simplewebauthn/browser`
116
+ (the `check:webauthn-bundle` guard would have caught the drift otherwise). The `authkit-react`
117
+ peer was **widened** to `^13.3.0 || ^14.0.0` instead of moved, so apps still on 13 keep
118
+ installing cleanly.
119
+ - `oidc-provider` 9.12.0 → 9.12.2 and `jose` 6.2.10 → 6.2.12 (patch releases on the token/JWT path).
120
+
121
+ No API change on our side: typecheck, tests, packaging smoke and the WebAuthn bundle check all pass.
122
+
123
+ ## 0.5.1
124
+
125
+ ### Patch Changes
126
+
127
+ - Updated dependencies [813a321]
128
+ - @adonis-agora/authkit-core@0.8.0
129
+
130
+ ## 0.5.0
131
+
132
+ ### Minor Changes
133
+
134
+ - 1f15367: `fakeAuthenticator()` covers the whole `Authenticator` surface again.
135
+
136
+ The client's `Authenticator` grew `getUserOrFail()` and `toSharedProps()`, but
137
+ `FakeAuthenticatorLike` did not — so injecting the fake into a `ctx.auth` typed
138
+ as `Authenticator` stopped type-checking, which is the one job the fake has.
139
+ Both methods now exist on the fake, with the same fail-closed semantics as the
140
+ real one: `getUserOrFail()` throws when there is no session (or no user), and
141
+ `toSharedProps()` returns `null` when there is no session and
142
+ `{ user, globalRoles }` when there is.
143
+
144
+ A compile-time assignment against the real `Authenticator` type now guards the
145
+ surface, so the next method added to the real class fails the testing package's
146
+ typecheck instead of failing silently in host apps.
147
+
148
+ ### Patch Changes
149
+
150
+ - 1f15367: Point `homepage` and `bugs.url` at the repository's current name.
151
+
152
+ The repository was renamed to `adonis-agora-authkit`; `repository.url` followed,
153
+ `homepage` and `bugs.url` did not. Every package therefore shipped a manifest
154
+ that disagreed with itself, and the "Repository"/"Homepage" links on npm leaned
155
+ on GitHub's rename redirect — which lasts only until someone claims the old
156
+ name. All three fields now name the same repository.
157
+
158
+ - Updated dependencies [1f15367]
159
+ - @adonis-agora/authkit-core@0.7.1
160
+
161
+ ## 0.4.0
162
+
163
+ ### Minor Changes
164
+
165
+ - c12bac9: Remove `hasAppRole`/`appRoles` from the fake `Authenticator` (`fakeAuthenticator`), matching the real
166
+ `@adonis-agora/authkit-client` surface after app-role authorization moved out of AuthKit. The fake now
167
+ exposes only `hasGlobalRole` (token roles). 0.x breaking.
168
+
169
+ ## 0.3.0
170
+
171
+ ### Minor Changes
172
+
173
+ - 0542665: Re-scope to @adonis-agora/authkit-\* (join the Agora ecosystem)
174
+
175
+ ### Patch Changes
176
+
177
+ - Updated dependencies [0542665]
178
+ - @adonis-agora/authkit-core@0.7.0
179
+
180
+ ## 0.2.5
181
+
182
+ ### Patch Changes
183
+
184
+ - Updated dependencies [93eaf69]
185
+ - Updated dependencies [e2582b8]
186
+ - @adonis-agora/authkit-core@0.6.0
187
+
188
+ ## 0.2.4
189
+
190
+ ### Patch Changes
191
+
192
+ - Updated dependencies [df4b41f]
193
+ - @adonis-agora/authkit-core@0.5.0
194
+
195
+ ## 0.2.3
196
+
197
+ ### Patch Changes
198
+
199
+ - Updated dependencies
200
+ - @adonis-agora/authkit-core@0.4.0
201
+
202
+ ## 0.2.2
203
+
204
+ ### Patch Changes
205
+
206
+ - Updated dependencies
207
+ - @adonis-agora/authkit-core@0.3.1
208
+
209
+ ## 0.2.1
210
+
211
+ ### Patch Changes
212
+
213
+ - Updated dependencies
214
+ - @adonis-agora/authkit-core@0.3.0
215
+
216
+ ## 0.2.0
217
+
218
+ ### Minor Changes
219
+
220
+ - 1872a30: DX & ops infra:
221
+ - New package `@adonis-agora/authkit-testing` — test helpers for host apps:
222
+ `createTestIdentity`, `mintTestIdToken` + `serveJwks`/`testJwks`/`jwksFromKey`
223
+ (real RS256 tokens validated by a local JWKS), `fakeAuthenticator`, and a
224
+ capability-aware `fakeAccountStore`.
225
+ - `node ace authkit:doctor` — validates host config and prints ✅/⚠️/❌ findings
226
+ (issuer/mountPath, clients, accountStore capabilities, session, shield, ally,
227
+ rate-limit, admin, webauthn, jwks). Non-zero exit on errors.
228
+ - `node ace authkit:rotate-keys` — rotates managed JWKS signing keys via a new
229
+ file-backed keystore (`jwks: { source: 'managed', store }`), keeping the last
230
+ N public keys so pre-rotation tokens still verify.
231
+
232
+ ### Patch Changes
233
+
234
+ - Updated dependencies [1872a30]
235
+ - @adonis-agora/authkit-core@0.2.0
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Test helpers so **host apps** built on AuthKit can test auth flows without booting
4
4
  an IdP. Mint real signed ID tokens validated by a local JWKS, fake the
5
- `ctx.auth` authenticator, fake an account store, and build valid identities.
5
+ `ctx.authkit` authenticator, fake an account store, and build valid identities.
6
6
 
7
7
  ```sh
8
8
  pnpm add -D @adonis-agora/authkit-testing
@@ -58,16 +58,19 @@ raw public JWKS object with `jwksFromKey(key)` / `testJwks(key)`.
58
58
  ### `fakeAuthenticator({ identity?, user? })`
59
59
 
60
60
  Object satisfying the client's `Authenticator` surface, for injecting into
61
- `ctx.auth` in controller tests. O AuthKit só autentica — autorização por role é
61
+ `ctx.authkit` in controller tests. O AuthKit só autentica — autorização por role é
62
62
  do `@adonis-agora/authz`, então o fake expõe só `hasGlobalRole` (roles do token).
63
+ O `authkitClientGuard` lê o `ctx.authkit` da request, então o mesmo fake também autentica
64
+ `ctx.auth`: com `user`, `ctx.auth.user` é esse usuário; sem `user`, o guard pede ao provider pelo
65
+ `userId` da identidade.
63
66
 
64
67
  ```ts
65
68
  import { fakeAuthenticator } from '@adonis-agora/authkit-testing'
66
69
 
67
- const auth = fakeAuthenticator({
70
+ const authkit = fakeAuthenticator({
68
71
  identity: createTestIdentity({ globalRoles: ['ADMIN'] }),
69
72
  })
70
- auth.hasGlobalRole('ADMIN') // true
73
+ authkit.hasGlobalRole('ADMIN') // true
71
74
  ```
72
75
 
73
76
  Pass `identity: null` to simulate an anonymous request.
@@ -1,6 +1,6 @@
1
1
  import type { Identity } from '@adonis-agora/authkit-core';
2
2
  /**
3
- * Superfície pública do `Authenticator` do client (o que `ctx.auth` expõe).
3
+ * Superfície pública do `Authenticator` do client (o que `ctx.authkit` expõe).
4
4
  * Reproduzida aqui para não acoplar o pacote de testing ao client em runtime.
5
5
  */
6
6
  export interface FakeAuthenticatorLike {
@@ -9,6 +9,8 @@ export interface FakeAuthenticatorLike {
9
9
  authenticate(): Promise<Identity>;
10
10
  check(): Promise<boolean>;
11
11
  hasGlobalRole(role: string): boolean;
12
+ /** `true` when a `user` was given: `authkitClientGuard` then uses it for `ctx.auth.user`. */
13
+ readonly resolvesUser: boolean;
12
14
  getUser(): Promise<unknown>;
13
15
  getUserOrFail(): Promise<unknown>;
14
16
  toSharedProps(): Promise<{
@@ -24,6 +26,6 @@ export interface FakeAuthenticatorOptions {
24
26
  }
25
27
  /**
26
28
  * Cria um objeto que satisfaz a superfície do `Authenticator` do client para
27
- * injetar em `ctx.auth` em testes de controller — sem resolver tokens de verdade.
29
+ * injetar em `ctx.authkit` em testes de controller — sem resolver tokens de verdade.
28
30
  */
29
31
  export declare function fakeAuthenticator(options?: FakeAuthenticatorOptions): FakeAuthenticatorLike;
@@ -1,7 +1,7 @@
1
1
  import { createTestIdentity } from './identity.js';
2
2
  /**
3
3
  * Cria um objeto que satisfaz a superfície do `Authenticator` do client para
4
- * injetar em `ctx.auth` em testes de controller — sem resolver tokens de verdade.
4
+ * injetar em `ctx.authkit` em testes de controller — sem resolver tokens de verdade.
5
5
  */
6
6
  export function fakeAuthenticator(options = {}) {
7
7
  const identity = options.identity === undefined ? createTestIdentity() : options.identity;
@@ -24,6 +24,7 @@ export function fakeAuthenticator(options = {}) {
24
24
  hasGlobalRole(role) {
25
25
  return identity?.globalRoles.includes(role) ?? false;
26
26
  },
27
+ resolvesUser: 'user' in options,
27
28
  async getUser() {
28
29
  if (!identity)
29
30
  return null;
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@adonis-agora/authkit-testing",
3
- "version": "0.6.4",
3
+ "version": "1.0.0-rc.0",
4
4
  "description": "Test helpers for apps built on AuthKit: mint real signed ID tokens with a local JWKS, fake authenticators and account stores, and build valid identities — so host apps can test auth flows without booting an IdP.",
5
5
  "license": "MIT",
6
6
  "author": "dudousxd",
7
7
  "repository": {
8
8
  "type": "git",
9
- "url": "https://github.com/DavideCarvalho/adonis-agora-authkit.git",
9
+ "url": "git+https://github.com/DavideCarvalho/adonis-agora-authkit.git",
10
10
  "directory": "packages/authkit-testing"
11
11
  },
12
12
  "homepage": "https://davidecarvalho.github.io/agora/docs/authkit",
@@ -29,7 +29,8 @@
29
29
  "main": "./build/index.js",
30
30
  "types": "./build/index.d.ts",
31
31
  "files": [
32
- "build"
32
+ "build",
33
+ "CHANGELOG.md"
33
34
  ],
34
35
  "exports": {
35
36
  ".": "./build/index.js",
@@ -39,15 +40,15 @@
39
40
  "node": ">=24"
40
41
  },
41
42
  "dependencies": {
42
- "@adonis-agora/authkit-core": "0.10.1",
43
+ "@adonis-agora/authkit-core": "1.0.0-rc.0",
43
44
  "jose": "6.2.15"
44
45
  },
45
46
  "devDependencies": {
46
- "@adonis-agora/authkit-client": "0.20.5",
47
+ "@adonis-agora/authkit-client": "1.0.0-rc.0",
47
48
  "@adonisjs/tsconfig": "2.0.0",
48
49
  "@japa/assert": "4.2.0",
49
50
  "@japa/runner": "5.4.0",
50
- "@poppinss/ts-exec": "1.5.1",
51
+ "@poppinss/ts-exec": "1.5.2",
51
52
  "@types/node": "26.6.5",
52
53
  "typescript": "7.0.2"
53
54
  },