Skip to content

refactor(auth): absorb api-key package into @reloop/auth (expand) (#46)#55

Merged
pranavp10 merged 1 commit into
mainfrom
auth-refactor-46-absorb-apikey
Jul 13, 2026
Merged

refactor(auth): absorb api-key package into @reloop/auth (expand) (#46)#55
pranavp10 merged 1 commit into
mainfrom
auth-refactor-46-absorb-apikey

Conversation

@pranavp10

@pranavp10 pranavp10 commented Jul 13, 2026

Copy link
Copy Markdown
Member

Summary

  • Absorbs standalone @reloop/apikey into the shared auth package (expand step).
  • @reloop/auth/apikey — pure generate / hash / key-start / prefix helpers (no Redis/DB/Elysia).
  • @reloop/auth/apikey/validate — hashed lookup + cache for the middleware plugin to consume next.
  • @reloop/apikey becomes a thin re-export shim; no importer changes in this PR.

Stacked on #54 (#45). Closes #46.

Test plan

  • bun test in packages/auth (helpers + isolation — 8 pass)
  • bun run test in apps/backend/auth (tripwire via shim — 6 pass)
  • tsc --noEmit for @reloop/auth, @reloop/apikey, be-api-key
  • CI green once stacked base merges

Greptile Summary

This PR folds API-key code into the shared auth package. The main changes are:

  • New @reloop/auth/apikey helper entrypoint.
  • New @reloop/auth/apikey/validate Redis and DB validation entrypoint.
  • @reloop/apikey changed into a compatibility re-export shim.
  • Auth export-isolation and helper tests added.

Confidence Score: 4/5

The changed shim is mostly safe, but its new runtime package hop can break stricter service installs.

  • The helper behavior appears preserved.
  • The validation query shape matches existing repository usage.
  • The re-export shim changes dependency resolution for existing @reloop/apikey consumers.

packages/apikey/src/index.ts

Important Files Changed

Filename Overview
packages/apikey/src/index.ts Replaces the standalone implementation with re-exports from @reloop/auth subpaths.
packages/auth/src/apikey/helpers.ts Adds dependency-light API-key generation, hashing, key-start, and cache-key helpers.
packages/auth/src/apikey/validate.ts Adds the Redis and database-backed API-key validation implementation under auth.
packages/auth/package.json Adds subpath exports for API-key helpers and validation.
packages/auth/test/export-isolation.test.ts Adds coverage that the helper entrypoint does not pull heavy server dependencies.

Reviews (1): Last reviewed commit: "refactor(auth): absorb api-key package i..." | Re-trigger Greptile

Greptile also left 1 inline comment on this PR.

Move generation/hashing helpers to dependency-light @reloop/auth/apikey
and validation to @reloop/auth/apikey/validate for the upcoming middleware
plugin. Leave @reloop/apikey as a thin re-export shim so existing
importers keep working; deletion lands in the contract ticket.

Adds unit tests for generate/hash/key-start helpers and isolation
coverage that the helpers graph excludes Redis/DB/Elysia. Characterization
tripwire still passes via the shim.
Comment on lines +14 to +17
export {
type ApiKeyValidationResult,
validateApiKey,
} from "@reloop/auth/apikey/validate";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Shim Pulls New Runtime Package

When an existing service imports validateApiKey from @reloop/apikey, this shim now resolves through @reloop/auth/apikey/validate. Services that only declare @reloop/apikey can fail under isolated or production dependency resolution because the runtime import now requires the new @reloop/auth package path instead of the old standalone implementation.

Base automatically changed from auth-refactor-45-single-source-config to main July 13, 2026 05:12
@pranavp10 pranavp10 merged commit 291a737 into main Jul 13, 2026
1 check passed
@pranavp10 pranavp10 deleted the auth-refactor-46-absorb-apikey branch July 13, 2026 05:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auth refactor 3/10 — Absorb the api-key package (expand)

1 participant