Vault client + OAuth 2.1 PKCE + multi-vault switcher - #2
Merged
Conversation
Any Parachute Vault requires an OAuth-minted access token, so Lens must handle discovery (RFC 8414), dynamic client registration (RFC 7591), and the PKCE S256 flow — hardcoded credentials aren't an option when the UI targets unknown vaults. Tokens are scoped per vault URL in localStorage so users can connect to several vaults without re-auth, and the zustand store exposes the active vault to TanStack Query. Tests cover the pure PKCE helpers (RFC 7636 test vector), URL normalization, discovery metadata validation, the full begin/complete OAuth orchestration with mocked fetch, and the vault client Bearer-auth path. A memory-Storage polyfill in test setup works around Bun's broken `localStorage` global when vitest runs under `bun run`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced Apr 18, 2026
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.
Summary
client_idagainst itsoauth_clientstable) so this is the only way in.zustand) with tokens persisted per-vault URL inlocalStorageand active vault id in sessionStorage-adjacent state. Users can connect several vaults and switch without re-auth.VaultClientover HTTP API — always sendsBearer ${token}, throwsVaultAuthErroron 401 so TanStack Query skips retries./(home),/add(URL entry → OAuth),/oauth/callback(code + state → token),/vaults(manage).Test plan
bun run typecheckcleanbun run lintcleanbun run test— 33/33 passbun run buildsucceedsbun run devserves app at http://localhost:5173Notes
--localstorage-fileflag (default without a path) installs a brokenlocalStorageglobal that shadows jsdom's. Test setup polyfills with a simple in-memory Storage. Runtime storage functions are defensive (try/catch) so module init won't throw even iflocalStorageis unavailable.🤖 Generated with Claude Code