Repository navigation
feat: extract the core from apps/interlock - #3
Merged
Merged
Conversation
Move the framework-agnostic half of the Interlock prototype into the root entry: createKeycloakAuthOptions, the session-grant store, hooks and refresher, the exposure allow-list, the back-channel receiver and RP-initiated logout, the cookie-name policy, the session_grant migration and the account token invariant, and a normalizeClaims stub until 6.2. The logger is required and passed explicitly everywhere the core logs. better-auth is an exact peer (1.7.7) and kysely a ^0.29.0 peer; jose is a dependency. The core's specs move here as vitest in a node project, and CI also type-checks a consumer of the root entry under NodeNext. Refs DevalexLLC/interlock#26
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs DevalexLLC/interlock#26 (work item 3.5). The item stays open until
apps/interlockruns on the published0.1.0and passes its gate rows.What moves
The framework-agnostic half of the Interlock prototype becomes the root entry (
src/core, re-exported bysrc/index.ts), with the file names kept:createKeycloakAuthOptions(config, { database, grants, logger, cookiePrefix? }), pluscreatePostgresStore,cookieSettings,receiverRouteOfandKEYCLOAK_SCOPESKyselyGrantStore), its hooks and the refresher (createGrantRefresher(grants, { keycloak, refresh }, { logger, transport?, inFlight? })), with the refresh responses and events0001_session_grantmigration (appMigrations, same key) and the account token invariantKeycloakAuthConfig, the refresh bounds, the eight timing and path constants, and anormalizeClaimsstub until 6.2Decisions
better-authis an exact peer (1.7.7) andkyselya^0.29.0peer. The hooks throw Better Auth'sAPIError, so there must be one copy.joseis a dependency.Strict-mode rewrites
The prototype compiled with
strict: false. The behavior-adjacent changes:holderis passed explicitly to the dispatch and end paths.msLeftreplaces a null subtraction. The read race's timer may be undefined.scrubProviderTokens: usesReflect.deletePropertyand throws when a field can't be deleted. Without the check, a frozen or non-configurable token field would be serialized; there is a regression test for that.subject_missing) if a validated token ever carries neithersidnorsub. The validator already refuses that case.encryptToken: narrowssetTokenUtil's result.asyncforpromise-function-async.InFlightWork.tracknow returns a promise that settles as the tracked work does, rather than the same promise.Tests and tooling
coreproject (Node environment, 30 s timeout), with the logger injected instead of spied. Counts match the originals file for file, 303 tests, plus 19 new: logger and cookie-prefix cases, the delete regression, andclaims.tls.setDefaultCACertificatesarrives in 22.19.env.node, andno-await-in-loopoff forsrc/core/**only. Those loops (lease rounds, polling wait, hook composition, drain) are sequential by design. No disable comments.skipLibCheckas the app has it), the wayapps/interlockimports it.__tests__directory. Postgres-only code (KyselyGrantStore, the account-token trigger, the migration) is covered by the app's e2e suites, not here, so Sonar's figures forcore/databaseandcore/grantswill read low.Verification
npm run fmt:check && npm run lint && npm test && npm run build: clean. 322 tests pass on Node 24; on Node 22.18, 321 pass and 1 is skipped.file:spec, not committed): unit 744/21 (1047/33 before, minus the 303 tests in 12 moved specs), e2e 178/15 against a throwaway Postgres, repo lint clean.npm ls better-auth kysely jose -w apps/interlockshows onebetter-auth1.7.7 and onekysely0.29.6.The changeset is
minor, so merging this opens the version PR for0.1.0. The two critical Dependabot alerts onmainpredate this PR (tinypoolthrough theoxfmtdev dependency).