feat: plugins workspace with @green-tea/jwt #1

Merged
chrnx merged 4 commits from feature/scaffold-jwt into develop 2026-09-18 04:20:49 +00:00
Owner

Plan B1 (.specs/2026-09-16-plan-b1-plugins-repo-jwt.md in green-tea). Workspace, convention checks, Gitea CI and the first plugin, built against core 26.9.0-beta.2 on Verdaccio. Nothing publishes: packages are private until B3.

One real defect found on the way in. The extraction moves from jose 5 to jose 6, and jose 6 refuses a private CryptoKey in jwtVerify where jose 5 accepted one and derived the public half itself. The original keeps a single key per signer and verifies with the key it signed with — fine on 5, throws CryptoKey instances must be of type "public" on 6, for every asymmetric algorithm (ES*, RS*, PS*, EdDSA). Symmetric keys are unaffected, which is why a single HS256 test would have shipped it. importJWKKey now imports an asymmetric key twice — as given to sign with, stripped of private fields to verify with — and the round-trip is covered per algorithm family rather than once.

This matters beyond this repo: patitas-peludas/backend-green-tea is on jose 5.6.3 with the same pattern and three asymmetric production keys, so it loses all verification the day it upgrades.

Two smaller departures from the plan, both deliberate:

  • The contract tests get() helper is generic in its body — Response.json() is Promise<unknown>, so the version the plan carries does not typecheck.
  • .claude/ and .serena/ are gitignored, matching the change made in core.

Gates, all green locally: lint (0 errors), format, complexity, typecheck, 18 Node tests, 10 on Deno, 10 on Bun, deno publish --dry-run clean, edge correctly reporting nothing to run.

Plan B1 (`.specs/2026-09-16-plan-b1-plugins-repo-jwt.md` in green-tea). Workspace, convention checks, Gitea CI and the first plugin, built against core 26.9.0-beta.2 on Verdaccio. Nothing publishes: packages are private until B3. **One real defect found on the way in.** The extraction moves from jose 5 to jose 6, and jose 6 refuses a private `CryptoKey` in `jwtVerify` where jose 5 accepted one and derived the public half itself. The original keeps a single key per signer and verifies with the key it signed with — fine on 5, throws `CryptoKey instances must be of type "public"` on 6, for every asymmetric algorithm (ES\*, RS\*, PS\*, EdDSA). Symmetric keys are unaffected, which is why a single HS256 test would have shipped it. `importJWKKey` now imports an asymmetric key twice — as given to sign with, stripped of private fields to verify with — and the round-trip is covered per algorithm family rather than once. This matters beyond this repo: `patitas-peludas/backend-green-tea` is on jose 5.6.3 with the same pattern and three asymmetric production keys, so it loses all verification the day it upgrades. Two smaller departures from the plan, both deliberate: - The contract tests `get()` helper is generic in its body — `Response.json()` is `Promise<unknown>`, so the version the plan carries does not typecheck. - `.claude/` and `.serena/` are gitignored, matching the change made in core. Gates, all green locally: lint (0 errors), format, complexity, typecheck, 18 Node tests, 10 on Deno, 10 on Bun, `deno publish --dry-run` clean, edge correctly reporting nothing to run.
chrnx added 4 commits 2026-09-18 04:18:49 +00:00
Same lint, format and complexity gates as core, plus a lint rule that keeps
core a types-only import in plugin sources. Runtime suites are chosen from each
package's engines, so declaring a runtime is what puts a package under its test.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
Rules 8 and 9 are the two a reviewer cannot see from a diff: where core sits in
package.json, and whether engines, the README table and JSR still agree. A
static test makes a drift fail the build instead of reaching a user.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
Extracted from patitas-peludas onto the object plugin contract. Core is a type
import only, so installing the plugin never drags in a second core or a version
warning; a bad key still fails boot, which the contract tests now pin.

The extraction moves from jose 5 to jose 6, and that is not a version bump: jose
6 refuses a private CryptoKey in jwtVerify, where jose 5 accepted one and derived
the public half itself. The original keeps a single key per signer and verifies
with the key it signed with, which works on 5 and throws
"CryptoKey instances must be of type public" on 6 — for every asymmetric
algorithm, so ES*, RS*, PS* and EdDSA alike. Symmetric keys are unaffected, which
is exactly why one HS256 test would have shipped it.

importJWKKey now imports the key twice for an asymmetric pair: as given, to sign
with, and with the private fields stripped, to verify with. A symmetric key has
no public half, so it keeps one secret for both. The round-trip is covered per
algorithm family rather than once, because one algorithm is not coverage — it is
the gap the defect lived in.

The get() helper in the contract tests is generic in its body: Response.json()
is typed Promise<unknown>, so reaching into the payload did not typecheck.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
ci: gate every package on Gitea
CI / dco (pull_request) Successful in 3s
CI / build (pull_request) Successful in 11s
CI / runtimes (bun) (pull_request) Successful in 10s
CI / runtimes (deno) (pull_request) Successful in 11s
CI / runtimes (edge) (pull_request) Successful in 8s
7be37f5184
Lint, format, complexity, typecheck and the Node suite on the engines floor,
then Deno and Bun for the packages that declare them. Gitea only until core
comes from npm, because the version these packages build against lives on
Verdaccio.

The JSR dry-run is kept rather than deferred: it passes locally on Deno 2.9.6,
because `nodeModulesDir: manual` resolves core from the tree `npm ci` installed,
so JSR's checker never needs that version to exist on npm.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
chrnx merged commit d8ffb09ddc into develop 2026-09-18 04:20:49 +00:00
Sign in to join this conversation.