Repository navigation
feat!: injectable HTTP client, contract-first IClient & authup-owned oauth2 layer - #3114
Conversation
- @authup/core-http-kit: new `./testing` subpath export with an in-memory, route-matching fake Client for tests. - @authup/client-web-kit: store & http-client install accept a pre-built client (httpClient option) instead of always constructing one from baseURL. - apps/server-core: optional HTTPInjectionKey.UIHttpClient container binding flows per-request through renderUIPage into the embedded SSR app (UI_HTTP_CLIENT_STORE_KEY handoff, same mechanism as VITE_SERVER_STORE_KEY); production registers nothing. Unblocks HTTP-level tests for the SSR'd workflow pages (ui-pages.spec.ts).
|
Note Reviews pausedUse the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds request-scoped UI HTTP client injection and fake HTTP client utilities; wires injected client into SSR rendering and client-web-kit; refactors core-http-kit to use a structural ApiTransport/IClient contract and explicit per-entity API interfaces; adds tests and docs for SSR testing and fake client usage. ChangesCombined Change Cohort
Estimated code review effort 🎯 4 (Complex) | ⏱️ ~75 minutes Possibly related PRs
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
|
authup
@authup/client-web
@authup/server-core
@authup/access
@authup/client-web-kit
@authup/client-web-kit-theme
@authup/client-web-nuxt
@authup/client-web-theme
@authup/core-http-kit
@authup/core-kit
@authup/core-realtime-kit
@authup/errors
@authup/i18n
@authup/kit
@authup/server-adapter-kit
@authup/server-adapter-node
@authup/server-adapter-socket-io
@authup/server-adapter-web
@authup/server-kit
@authup/server-test-kit
@authup/specs
commit: |
… override A shared Client instance across concurrent SSR renders would be a cross-request hazard: client-web-kit's authentication hook writes per-user Authorization state onto the client it attaches to, so two parallel renders could leak tokens between sessions. The DI token is now a factory (() => Client) that renderUIPage invokes per render — per-request isolation is structural instead of conventional.
…uth2 layer Interfaces & types convention (also recorded in .agents/conventions.md): every interface is I-prefixed, the interface keyword is reserved for contracts a class implements, and contracts are written explicitly — never inferred from implementations. - Every domain API gets an explicit interface in its types.ts (IRealmAPI, IUserAPI, IPolicyAPI, ...) with precise payload types; classes declare `implements I*API`. EntityAPI/EntityAPISlim are renamed to IEntityAPI/IEntityAPISlim and payload-parameterized (IEntityAPI<T, TCreate, TUpdate>) so interfaces no longer advertise Partial<T> while implementations expect narrower payloads. - New aggregate IClient contract implemented by Client; consumers (client-web-kit http-client/store/auth-hook, server-core SSR client factory, ui app) are typed against IClient instead of the class. The hapic base surface is mirrored structurally (ClientBase) — the one sanctioned implementation-derived type, at the third-party boundary. - Transport port: BaseAPI now depends on a minimal ApiTransport type (get/post/put/delete/getBaseURL) instead of hapic's Client class and holds it readonly (mutable setClient removed) — the domain layer is http-library-agnostic. - OAuth2 layer is authup-owned: OAuth2TokenAPI / OAuth2AuthorizeAPI / OAuth2UserInfoAPI no longer extend @hapic/oauth2 classes; grant, revoke, introspect and userinfo logic is implemented in-package (faithful port: urlencoded bodies, client-credential headers, parameter extension) against IOAuth2*API interfaces with authup-owned parameter types; responses are typed by @authup/specs (OAuth2TokenGrantResponse — now also carrying refresh_token_expires_in). @hapic/oauth2 dependency dropped. BREAKING CHANGE: @authup/core-http-kit no longer re-exports @hapic/oauth2 types; EntityAPI/EntityAPISlim are renamed to IEntityAPI/IEntityAPISlim; BaseAPI.setClient removed; OAuth2 parameter types are now authup-owned (OAuth2Token*GrantParameters, OAuth2TokenRequestOptions, OAuth2AuthorizeParameters).
- 13 entity APIs declared getOne(id, record?) via IEntityAPISlim but ignored the query argument — callers' BuildInput was silently dropped. The implementations now append buildQuery(record). - client-web-kit plugin Options.httpClient is typed IClient (was the concrete Client class, blocking test doubles at the top-level install seam the sub-installers already accept). - FakeClient normalizes URLSearchParams bodies to plain objects in recorded requests so token-endpoint handler assertions stay ergonomic. - Refresh stale HTTPInjectionKey.UIHttpClient references in .agents docs (token is UIHttpClientFactory).
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
packages/core-http-kit/src/client/module.ts (1)
104-110: ⚡ Quick winConsider refactoring to avoid type-safety escape hatch.
The cast
(options as Record<string, any>)[key]at line 108 bypasses TypeScript's type checking to mutate theoptionsobject. This pattern is fragile because:
- It assumes all
OAuth2APIOptionsproperties are URL strings that need normalization- Future non-URL properties added to
OAuth2APIOptionswould incorrectly pass through this loop- The cast undermines the type safety benefits of the interface refactoring
♻️ Recommended refactor to preserve type safety
Create a new object instead of mutating:
const baseURL = this.getBaseURL(); if (typeof baseURL === 'string') { - const keys = Object.keys(options) as (keyof OAuth2APIOptions)[]; - for (const key of keys) { - const value = options[key]; - if (typeof value === 'string') { - (options as Record<string, any>)[key] = new URL(value, baseURL).href; - } - } + const normalizedOptions: OAuth2APIOptions = { + authorizationEndpoint: typeof options.authorizationEndpoint === 'string' + ? new URL(options.authorizationEndpoint, baseURL).href + : options.authorizationEndpoint, + introspectionEndpoint: typeof options.introspectionEndpoint === 'string' + ? new URL(options.introspectionEndpoint, baseURL).href + : options.introspectionEndpoint, + tokenEndpoint: typeof options.tokenEndpoint === 'string' + ? new URL(options.tokenEndpoint, baseURL).href + : options.tokenEndpoint, + userinfoEndpoint: typeof options.userinfoEndpoint === 'string' + ? new URL(options.userinfoEndpoint, baseURL).href + : options.userinfoEndpoint, + }; + + this.authorize = new OAuth2AuthorizeAPI({ + client: this, + options: normalizedOptions, + }); + // ... use normalizedOptions in subsequent API constructors } - -this.authorize = new OAuth2AuthorizeAPI({ - client: this, - options, -});Alternatively, if OAuth2APIOptions is guaranteed to only contain URL-string properties, document this invariant explicitly in the type definition and add a comment explaining the cast.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/core-http-kit/src/client/module.ts` around lines 104 - 110, The current loop mutates options using a type-escape cast at the line with (options as Record<string, any>)[key], which bypasses TypeScript safety and assumes every OAuth2APIOptions property is a URL string; instead create a new object (e.g., normalizedOptions: OAuth2APIOptions) and populate it without casting: copy non-string fields directly and only normalize known URL-string fields (use an explicit whitelist of keys or narrow the key type) by doing new URL(value, baseURL).href for those keys, then use normalizedOptions in place of options; update the code around the existing keys/for loop and remove the unsafe cast.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.agents/testing.md:
- Around line 146-148: The registered value currently constructs a singleton
Fake HTTP client by calling createFakeHTTPClient(...) directly; change the
registration to provide a per-request factory function instead (i.e., set
useValue to a function that returns createFakeHTTPClient({ handlers: { 'GET
/identity-providers': () => ({ data: [], meta: { total: 0 } }) } })). Update the
code where useValue is assigned so it returns a new createFakeHTTPClient
instance on each invocation to prevent cross-request token leakage.
In `@packages/client-web-kit/src/types.ts`:
- Line 8: The public Options type incorrectly uses the concrete Client type;
update the Options definition to accept the interface IClient instead of Client
so it matches downstream contracts; locate the exported Options/type in
packages/client-web-kit/src/types.ts (the httpClient property) and change its
type from Client to IClient (importing IClient from '`@authup/core-http-kit`' if
necessary) so injectable test/fake implementations conform to the public API.
In `@packages/core-http-kit/src/domains/base.ts`:
- Around line 12-16: The type guard isApiTransport is incomplete and only checks
get/post; update it to verify all ApiTransport members by ensuring
isObject(input) and that getBaseURL, get, post, put, and delete exist and are
functions so BaseAPI (and callers like RobotAPI and IdentityProviderAPI) won't
crash at runtime when they call any of those methods.
---
Nitpick comments:
In `@packages/core-http-kit/src/client/module.ts`:
- Around line 104-110: The current loop mutates options using a type-escape cast
at the line with (options as Record<string, any>)[key], which bypasses
TypeScript safety and assumes every OAuth2APIOptions property is a URL string;
instead create a new object (e.g., normalizedOptions: OAuth2APIOptions) and
populate it without casting: copy non-string fields directly and only normalize
known URL-string fields (use an explicit whitelist of keys or narrow the key
type) by doing new URL(value, baseURL).href for those keys, then use
normalizedOptions in place of options; update the code around the existing
keys/for loop and remove the unsafe cast.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: d4df67ae-6f1f-41c6-9492-9edd06afae08
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (91)
.agents/architecture.md.agents/conventions.md.agents/testing.mdapps/server-core/src/adapters/http/middleware/built-in/index.tsapps/server-core/src/adapters/http/middleware/built-in/ui-http-client.tsapps/server-core/src/adapters/http/ui/render.tsapps/server-core/src/app/modules/http/constants.tsapps/server-core/src/app/modules/http/modules/middleware.tsapps/server-core/test/unit/http/controllers/workflows/ui-pages.spec.tsapps/server-core/ui/src/app.tsapps/server-core/ui/src/server.tsdocs/src/.vitepress/config.mjsdocs/src/sdks/javascript/core-http-kit/testing.mdpackages/client-web-kit/src/components/utility/entity/AEntityDelete.tspackages/client-web-kit/src/components/utility/entity/collection/module.tspackages/client-web-kit/src/components/utility/entity/record/module.tspackages/client-web-kit/src/core/http-client/authentication-hook/install.tspackages/client-web-kit/src/core/http-client/authentication-hook/types.tspackages/client-web-kit/src/core/http-client/install.tspackages/client-web-kit/src/core/http-client/singleton.tspackages/client-web-kit/src/core/http-client/types.tspackages/client-web-kit/src/core/store/create.tspackages/client-web-kit/src/core/store/install.tspackages/client-web-kit/src/core/store/types.tspackages/client-web-kit/src/module.tspackages/client-web-kit/src/types.tspackages/core-http-kit/package.jsonpackages/core-http-kit/src/client/module.tspackages/core-http-kit/src/client/type.tspackages/core-http-kit/src/domains/base.tspackages/core-http-kit/src/domains/entities/client-permission/module.tspackages/core-http-kit/src/domains/entities/client-permission/types.tspackages/core-http-kit/src/domains/entities/client-role/module.tspackages/core-http-kit/src/domains/entities/client-role/types.tspackages/core-http-kit/src/domains/entities/client-scope/module.tspackages/core-http-kit/src/domains/entities/client-scope/types.tspackages/core-http-kit/src/domains/entities/client/module.tspackages/core-http-kit/src/domains/entities/client/types.tspackages/core-http-kit/src/domains/entities/identity-provider-role-mapping/module.tspackages/core-http-kit/src/domains/entities/identity-provider-role-mapping/types.tspackages/core-http-kit/src/domains/entities/identity-provider/module.tspackages/core-http-kit/src/domains/entities/identity-provider/types.tspackages/core-http-kit/src/domains/entities/permission-policy/module.tspackages/core-http-kit/src/domains/entities/permission-policy/types.tspackages/core-http-kit/src/domains/entities/permission/module.tspackages/core-http-kit/src/domains/entities/permission/types.tspackages/core-http-kit/src/domains/entities/policy/module.tspackages/core-http-kit/src/domains/entities/policy/types.tspackages/core-http-kit/src/domains/entities/realm/module.tspackages/core-http-kit/src/domains/entities/realm/types.tspackages/core-http-kit/src/domains/entities/robot-permission/module.tspackages/core-http-kit/src/domains/entities/robot-permission/types.tspackages/core-http-kit/src/domains/entities/robot-role/module.tspackages/core-http-kit/src/domains/entities/robot-role/types.tspackages/core-http-kit/src/domains/entities/robot/module.tspackages/core-http-kit/src/domains/entities/robot/types.tspackages/core-http-kit/src/domains/entities/role-attribute/module.tspackages/core-http-kit/src/domains/entities/role-attribute/types.tspackages/core-http-kit/src/domains/entities/role-permission/module.tspackages/core-http-kit/src/domains/entities/role-permission/types.tspackages/core-http-kit/src/domains/entities/role/module.tspackages/core-http-kit/src/domains/entities/role/types.tspackages/core-http-kit/src/domains/entities/scope/module.tspackages/core-http-kit/src/domains/entities/scope/types.tspackages/core-http-kit/src/domains/entities/user-attribute/module.tspackages/core-http-kit/src/domains/entities/user-attribute/types.tspackages/core-http-kit/src/domains/entities/user-permission/module.tspackages/core-http-kit/src/domains/entities/user-permission/types.tspackages/core-http-kit/src/domains/entities/user-role/module.tspackages/core-http-kit/src/domains/entities/user-role/types.tspackages/core-http-kit/src/domains/entities/user/module.tspackages/core-http-kit/src/domains/entities/user/types.tspackages/core-http-kit/src/domains/types-base.tspackages/core-http-kit/src/domains/workflows/oauth2/authorize/module.tspackages/core-http-kit/src/domains/workflows/oauth2/base.tspackages/core-http-kit/src/domains/workflows/oauth2/index.tspackages/core-http-kit/src/domains/workflows/oauth2/token/module.tspackages/core-http-kit/src/domains/workflows/oauth2/types.tspackages/core-http-kit/src/domains/workflows/oauth2/user-info/module.tspackages/core-http-kit/src/domains/workflows/status/module.tspackages/core-http-kit/src/domains/workflows/status/types.tspackages/core-http-kit/src/hook/module.tspackages/core-http-kit/src/hook/types.tspackages/core-http-kit/src/testing/index.tspackages/core-http-kit/src/testing/matcher.tspackages/core-http-kit/src/testing/module.tspackages/core-http-kit/src/testing/types.tspackages/core-http-kit/src/token-creator/type.tspackages/core-http-kit/test/unit/creator.spec.tspackages/core-http-kit/test/unit/fake-client.spec.tspackages/core-http-kit/tsdown.config.ts
…lementation
Keep the authup-owned IOAuth2{Token,Authorize,UserInfo}API contracts
and parameter/response types, but drop the in-package protocol
reimplementation: the OAuth2 classes extend @hapic/oauth2 again and
declare `implements I*API`, so hapic (same author) stays the single
implementation while the compiler verifies it satisfies authup's
contract on every build. Removes ~300 duplicated lines of
security-sensitive grant/header/encoding logic.
Also: convert CookieOptions & LoggerLevelFn to type aliases per the
interface convention (not class-implemented), and annotate the
httpClient-fallback sites as IClient so the Client/IClient union stays
callable.
|
@coderabbitai pause |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/client-web-kit/src/types.ts (1)
105-124:⚠️ Potential issue | 🟠 Major | ⚡ Quick winMake
baseURLconditional whenhttpClientis provided.
Optionsstill requiresbaseURL, butinstallHTTPClient()only uses it whenhttpClientis absent. That leaves the new injectable-client path type-incorrect for consumers unless they pass a fake URL. Model this as a union so callers provide either a prebuilthttpClientor abaseURL.Suggested shape
-export type Options = { - baseURL: string, +export type Options = ({ + baseURL: string, + httpClient?: undefined, +} | { + baseURL?: string, + httpClient: IClient, +}) & { /** * Pre-built HTTP client used instead of constructing one from baseURL. * Covers the store, the authentication hook and the provided client. */ - httpClient?: IClient, - realtime?: boolean, realtimeURL?: string, components?: boolean | string[], translatorLocale?: string, @@ cookieGet?: CookieGetFn, pinia?: Pinia, isServer?: boolean -}; +};🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/client-web-kit/src/types.ts` around lines 105 - 124, The Options type currently requires baseURL even when a prebuilt httpClient is provided; update the Options definition to be a discriminated union so callers must provide either a prebuilt httpClient or a baseURL (not both). Specifically, refactor the exported type Options into two variants (one with httpClient: IClient and no baseURL, and one with baseURL: string and no httpClient) while keeping the shared fields (realtime, components, translatorLocale, cookieSet/unset/get, pinia, isServer) common to both; adjust installs that reference installHTTPClient() to accept the new union type if necessary. Ensure unique symbols referenced: Options and installHTTPClient so type-checks now prevent passing a fake baseURL when using a prebuilt httpClient.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@packages/client-web-kit/src/types.ts`:
- Around line 105-124: The Options type currently requires baseURL even when a
prebuilt httpClient is provided; update the Options definition to be a
discriminated union so callers must provide either a prebuilt httpClient or a
baseURL (not both). Specifically, refactor the exported type Options into two
variants (one with httpClient: IClient and no baseURL, and one with baseURL:
string and no httpClient) while keeping the shared fields (realtime, components,
translatorLocale, cookieSet/unset/get, pinia, isServer) common to both; adjust
installs that reference installHTTPClient() to accept the new union type if
necessary. Ensure unique symbols referenced: Options and installHTTPClient so
type-checks now prevent passing a fake baseURL when using a prebuilt httpClient.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 61289a4c-9643-462a-97b3-5b9c29725628
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (25)
.agents/testing.mdpackages/client-web-kit/src/core/http-client/authentication-hook/install.tspackages/client-web-kit/src/core/http-client/install.tspackages/client-web-kit/src/core/store/create.tspackages/client-web-kit/src/types.tspackages/core-http-kit/package.jsonpackages/core-http-kit/src/domains/entities/client-role/module.tspackages/core-http-kit/src/domains/entities/client-scope/module.tspackages/core-http-kit/src/domains/entities/identity-provider-role-mapping/module.tspackages/core-http-kit/src/domains/entities/permission-policy/module.tspackages/core-http-kit/src/domains/entities/realm/module.tspackages/core-http-kit/src/domains/entities/robot-role/module.tspackages/core-http-kit/src/domains/entities/role-attribute/module.tspackages/core-http-kit/src/domains/entities/role-permission/module.tspackages/core-http-kit/src/domains/entities/role/module.tspackages/core-http-kit/src/domains/entities/scope/module.tspackages/core-http-kit/src/domains/entities/user-attribute/module.tspackages/core-http-kit/src/domains/entities/user-permission/module.tspackages/core-http-kit/src/domains/entities/user-role/module.tspackages/core-http-kit/src/domains/workflows/oauth2/authorize/module.tspackages/core-http-kit/src/domains/workflows/oauth2/index.tspackages/core-http-kit/src/domains/workflows/oauth2/token/module.tspackages/core-http-kit/src/domains/workflows/oauth2/user-info/module.tspackages/core-http-kit/src/testing/module.tspackages/server-kit/src/logger/types.ts
💤 Files with no reviewable changes (1)
- packages/core-http-kit/src/domains/workflows/oauth2/index.ts
✅ Files skipped from review due to trivial changes (2)
- packages/server-kit/src/logger/types.ts
- .agents/testing.md
🚧 Files skipped from review as they are similar to previous changes (5)
- packages/client-web-kit/src/core/store/create.ts
- packages/client-web-kit/src/core/http-client/authentication-hook/install.ts
- packages/core-http-kit/package.json
- packages/core-http-kit/src/domains/entities/scope/module.ts
- packages/core-http-kit/src/testing/module.ts
✅ Action performedReviews paused. |
- @hapic/oauth2 was re-added under devDependencies, so tsdown bundled a private copy of TokenAPI into the dist — prototype spies in server-adapter-kit's verifier spec no longer intercepted introspect and a real fetch escaped (CI 'Test Packages' failure). Moved to dependencies so the import stays external and class identity is shared. - isApiTransport now checks all five ApiTransport members (getBaseURL/get/post/put/delete) instead of get/post only, so an incomplete transport is rejected at construction rather than crashing on first put/delete call (review feedback).
The grant/revoke/introspect/authorize parameter shapes were still re-declared verbatim after the implementation went back to hapic. They are now type aliases over @hapic/oauth2's exports — single source of truth for the shapes, authup keeps only its naming convention and the IOAuth2*API contracts (whose responses stay typed by @authup/specs).
…p-client-ssr-tests
…client override The hand-rolled TypedToken<() => IClient> duplicated what the DI container already provides: HTTPInjectionKey.UIHttpClient is typed IClient again and registered with a useFactory provider + lifetime: 'transient', so each resolve yields a fresh client. The wiring passes a resolve-thunk into the (DI-agnostic) middleware; renderUIPage still resolves lazily per render.
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/core-http-kit/src/domains/workflows/oauth2/types.ts (1)
29-34: 💤 Low valueConsider clarifying the dependency model in the comment.
The comment states consumers won't depend on
@hapic/oauth2directly. While this is true for imports (consumers import from@authup/core-http-kit), TypeScript still requires@hapic/oauth2as a transitive dependency for type resolution since these are type aliases, not re-declarations. Consider rephrasing to: "without consumers importing from@hapic/oauth2directly" to be more precise about the dependency model.📝 Suggested clarification
/** * The OAuth2 protocol mechanics (and their parameter shapes) are owned - * by `@hapic/oauth2` — authup only re-exposes them under its naming - * convention so the contracts below stay expressible without consumers - * depending on `@hapic/oauth2` directly. + * by `@hapic/oauth2` — authup re-exposes them under its naming convention + * so consumers can use these contracts without importing from + * `@hapic/oauth2` directly (though it remains a transitive dependency). */🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/core-http-kit/src/domains/workflows/oauth2/types.ts` around lines 29 - 34, Update the top comment in packages/core-http-kit/src/domains/workflows/oauth2/types.ts to clarify the dependency model by changing "consumers won't depend on `@hapic/oauth2` directly" to something like "without consumers importing from `@hapic/oauth2` directly" so it accurately distinguishes import usage from TypeScript's transitive type resolution; keep the surrounding explanation about re-exposing parameter shapes intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/core-http-kit/src/domains/workflows/oauth2/types.ts`:
- Around line 29-34: Update the top comment in
packages/core-http-kit/src/domains/workflows/oauth2/types.ts to clarify the
dependency model by changing "consumers won't depend on `@hapic/oauth2`
directly" to something like "without consumers importing from `@hapic/oauth2`
directly" so it accurately distinguishes import usage from TypeScript's
transitive type resolution; keep the surrounding explanation about re-exposing
parameter shapes intact.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 87cdc360-8c9b-4024-b074-fce7bf523755
📒 Files selected for processing (9)
.agents/conventions.md.agents/testing.mdapps/server-core/src/adapters/http/middleware/built-in/ui-http-client.tsapps/server-core/src/app/modules/http/constants.tsapps/server-core/src/app/modules/http/modules/middleware.tsapps/server-core/test/unit/http/controllers/workflows/ui-pages.spec.tspackages/core-http-kit/package.jsonpackages/core-http-kit/src/domains/base.tspackages/core-http-kit/src/domains/workflows/oauth2/types.ts
✅ Files skipped from review due to trivial changes (2)
- .agents/conventions.md
- .agents/testing.md
🚧 Files skipped from review as they are similar to previous changes (4)
- apps/server-core/src/app/modules/http/modules/middleware.ts
- packages/core-http-kit/src/domains/base.ts
- apps/server-core/test/unit/http/controllers/workflows/ui-pages.spec.ts
- apps/server-core/src/adapters/http/middleware/built-in/ui-http-client.ts
Summary
Three layered changes (one commit each):
1. Injectable HTTP client for the SSR'd auth workflow UI (+ testing kit)
@authup/core-http-kit/testing: in-memory route-matchingFakeClientfor tests.apps/server-core:HTTPInjectionKey.UIHttpClientFactory— a per-request factory handed throughrenderUIPageinto the embedded SSR app. A factory, not an instance: the auth hook writes per-user Authorization state onto attached clients, so a shared instance across concurrent renders would leak tokens between sessions. Production registers nothing.ui-pages.spec.ts).2. Contract-first interfaces (new codebase convention, recorded in
.agents/conventions.md)I-prefixed;interfaceis reserved for class-implemented contracts; contracts are written explicitly, never inferred from implementations.I*APIinterface per domain (IRealmAPI,IUserAPI, …), implemented by the API classes;EntityAPI/EntityAPISlim→IEntityAPI/IEntityAPISlim, payload-parameterized (IEntityAPI<T, TCreate, TUpdate>) so contracts no longer advertisePartial<T>while implementations expect narrower payloads.IClientimplemented byClient; all consumers (client-web-kit http-client/store/auth-hook, SSR client factory, ui app) are typed against it — any conforming test double substitutes.3. HTTP-client redesign (transport port + OAuth2 contracts)
BaseAPIdepends on a minimalApiTransporttype (readonly,setClientremoved) — the domain layer is http-library-agnostic; hapic remains the default implementation at a documented structural boundary (ClientBase).OAuth2TokenAPI extends TokenAPI implements IOAuth2TokenAPI(same for authorize/user-info). Parameter/response types are authup-owned (@authup/specs), and theimplementscheck verifies on every build that@hapic/oauth2(same author) still satisfies the contract — no duplicated protocol code, drift caught at compile time.Breaking changes
@authup/core-http-kitno longer re-exports@hapic/oauth2types (it stays as the implementation dependency);EntityAPI/EntityAPISlimrenamed;BaseAPI.setClientremoved; OAuth2 parameter types are authup-owned (OAuth2Token*GrantParameters/OAuth2TokenRequestOptions/OAuth2AuthorizeParameters).Test plan
apps/server-core— 89 files / 868 tests pass (all OAuth2 grants — password, client_credentials, robot_credentials, authorization_code+PKCE, refresh — run through the new authup-owned token layer against Docker services)packages/core-http-kit— 19 tests pass (creator spec migrated to spy onOAuth2TokenAPI)singagone earlier,@hapic/oauth2removed from core-http-kit)🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Documentation
Tests
Refactor
Post-review hardening: 13
getOne()implementations now honor therecord?query param their interface advertises; pluginOptions.httpClienttypedIClient; FakeClient normalizes urlencoded bodies; stale doc refs fixed; OAuth2 parameter types are now one-line aliases over@hapic/oauth2's exports (single source for the shapes);@hapic/oauth2correctly sits independencies(devDeps get bundled by tsdown, which broke prototype spies and would have broken the published package);isApiTransportchecks all five transport members; branch merged with master after #3113 landed.