Skip to content

feat(sdk): pin signing keys or verify offline from TypeScript, as in Rust - #330

Merged
PiquelChips merged 2 commits into
mainfrom
sdk/ts-fixed-keys
Nov 4, 2026
Merged

PiquelChips merged 2 commits into
mainfrom
sdk/ts-fixed-keys

Conversation

@PiquelChips

@PiquelChips PiquelChips commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

The Rust SDK can verify tokens against a pinned or offline key set (KeySet::parse + KeyCache::fixed), but the TypeScript SDK couldn't: its KeySet wasn't exported and KeyCache only took a JWKS URL. Now it can, with the same semantics:

import { KeyCache, KeySet } from '@piquel/auth';

const keys = KeyCache.fixed(KeySet.parse(await readFile('jwks.json', 'utf8')));
await keys.verify(jws, jws.requireAlgorithm(['RS256']));
  • KeySet is exported. KeySet.parse follows the existing rules: it skips keys it can't use, and rejects a document that isn't a key set or that has a duplicate kid. It now also takes the set's JSON text, the way Rust's takes bytes. A JSON string can never be a key set, so treating strings as text is unambiguous.
  • KeyCache.fixed(keys) never fetches, so a kid the set lacks is unknown_key, never network, as in Rust. The constructor overload behind it is @internal and stripped from the .d.ts, and so is KeySet.read.
  • Tests: a fixed cache verifies its own keys and fails missing ones with unknown_key. The jwks vectors also run against the JSON-text form.
  • Docs: the package README, the shared contract in docs/architecture/sdk.md, and a sentence in the Rust crate docs naming KeyCache::fixed.

just web check, lint, test and smoke (Node, Bun, workerd) pass.

Reviewed with review-loop: 1 round with 2× GPT 6.1 Sol and Claude Opus 5.5. Verdict: approved

Note

Written by Claude Opus 5.5 in Claude Code and reviewed by GPT 6.1 Sol and Claude Opus 5.5 (via T3 Code)

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 28 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b290d210-a0f8-4031-9fc4-d7133be32b4e
Commits

Reviewing files that changed from the base of the PR and between 9fdd197 and 19468c9.

Files selected for processing: 7
  • crates/auth-sdk/src/lib.rs
  • docs/architecture/sdk.md
  • packages/auth/README.md
  • packages/auth/src/index.ts
  • packages/auth/src/keys.ts
  • packages/auth/test/keys.test.ts
  • packages/auth/test/vectors.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@PiquelChips PiquelChips self-assigned this Nov 4, 2026
@PiquelChips PiquelChips added enhancement New feature or request sdk Rust and TypeScript SDKs labels Nov 4, 2026
@PiquelChips PiquelChips added this to the 0.1 milestone Nov 4, 2026
@github-project-automation github-project-automation Bot moved this to Needs Triage in sourceorigin.dev Nov 4, 2026
@PiquelChips PiquelChips moved this from Needs Triage to In Progress in sourceorigin.dev Nov 4, 2026
…Rust

KeySet is now exported from @piquel/auth, and KeyCache.fixed(keys) mirrors
the Rust SDK's KeyCache::fixed: a set that is never fetched, so a kid it
lacks fails with unknown_key. KeySet.parse also takes the set's JSON text.
@PiquelChips
PiquelChips merged commit 590d7b5 into main Nov 4, 2026
9 checks passed
@PiquelChips
PiquelChips deleted the sdk/ts-fixed-keys branch November 4, 2026 15:06
@github-project-automation github-project-automation Bot moved this from In Progress to Done in sourceorigin.dev Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request sdk Rust and TypeScript SDKs

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant