feat(flashnet): add @mbga/flashnet package with API-key auth#7
Merged
Quantumlyy merged 8 commits intomainfrom Mar 29, 2026
Merged
feat(flashnet): add @mbga/flashnet package with API-key auth#7Quantumlyy merged 8 commits intomainfrom
Quantumlyy merged 8 commits intomainfrom
Conversation
New package providing Flashnet authentication for MBGA apps: - createFlashnetClient() with bearer token API-key auth - FlashnetProvider React context + useFlashnetClient hook - verifyAuth action to check auth status - useFlashnetAuth hook with TanStack Query integration - Typed error classes (FlashnetAuthError, FlashnetRequestError, etc.) - Full test coverage (37 tests) Co-authored-by: Claude <noreply@anthropic.com> Signed-off-by: Claude <noreply@anthropic.com>
Co-authored-by: Claude <noreply@anthropic.com> Signed-off-by: Claude <noreply@anthropic.com>
- Move React context and hooks to @mbga/flashnet/react entrypoint so
non-React consumers importing from @mbga/flashnet don't need react
or @tanstack/react-query installed (finding 1)
- Add @mbga/flashnet to root build script so pnpm build/release
produces its artifacts (finding 2)
- Include client.baseUrl in useFlashnetAuth query key so switching
clients busts the TanStack Query cache (finding 3)
- Make FlashnetProviderProps a discriminated union: apiKey is only
required when client is absent, so <FlashnetProvider client={c} />
is type-safe without a dummy apiKey (finding 4)
- Add test for client-switching cache scenario
Co-authored-by: Claude <noreply@anthropic.com>
Signed-off-by: Claude <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
- Add packages/flashnet/README.md with vanilla and React quick start - Add root README entry for @mbga/flashnet - Add site/pages/flashnet/ with overview and authentication docs - Add Flashnet section to sidebar and vocs config - Add FlashnetAuth component + page to vite-react example - Add Flashnet snippet to playground page - Update getting-started, API index, and landing page to mention Flashnet Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…pattern Replace the incorrect API-key auth with the real Flashnet challenge-response flow (POST /v1/auth/challenge -> sign -> POST /v1/auth/verify -> access token). - Add createFlashnetExtension() factory with .plugin for MBGA config - Add FlashnetSigner interface + createSignerFromConfig() adapter - Add challengeResponse() implementing the full auth flow - Add signIntent() for intent-based operation signing - Add sha256() and toHex() crypto utilities (Web Crypto API) - Rewrite FlashnetProvider to accept an extension prop - Replace useFlashnetAuth with useSyncExternalStore-based hook - Add useFlashnetAuthenticate mutation hook - Remove old createFlashnetClient, verifyAuth, API-key types - Rewrite all tests, docs, example app, and playground snippet Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ors, wire up example auth - Clear accessToken/publicKey when re-authentication starts and on failure, preventing stale tokens from being used after a failed re-auth - Wrap fetch() calls in auth.ts with try/catch so network-level failures (offline, DNS, CORS) surface as FlashnetChallengeError/FlashnetAuthError instead of raw TypeError - Add Authenticate button to the vite-react example so the demo actually triggers the challenge-response flow when a wallet is connected - Add tests for stale token clearing and network error wrapping Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…integration Add an `extensions` field to `createConfig()` that stores typed extensions on the config object and auto-runs their plugins. This eliminates the need for separate providers and manual config passing. Core changes: - createConfig is now generic over TExtensions - Config<TExtensions> carries the extensions type through ResolvedRegister - Extension plugins are auto-invoked when registered via extensions field Flashnet changes: - Extension captures configRef in its plugin, making authenticate() callable without arguments - useFlashnetExtension falls back to config.extensions.flashnet via MbgaContext - useFlashnetAuthenticate no longer requires a config parameter - FlashnetProvider becomes optional when using the extensions pattern Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
…ons feature The extensions field on Config adds ~166 bytes brotlied to @mbga/core — this is the auto-run loop for extension plugins. Consolidated the loop to avoid duplicate evaluations and bumped the size limit from 4 kB to 4.5 kB. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
@mbga/flashnetpackage with API-key authentication for the Flashnet orchestration APIcreateFlashnetClient()factory,verifyAuth()action,FlashnetProvidercontext, anduseFlashnetAuth()hook@mbga/flashnet/reactsubpath so non-React consumers can import from the root without needing React/TanStack peersuseFlashnetAuthquery key (client.baseUrl) so switching clients properly busts the cacheFlashnetProviderPropsso eitherclientorapiKeyis required (not both)Test plan
pnpm test— all flashnet and flashnet-react vitest projects passpnpm build—@mbga/flashnetbuilds with tsup (CJS/ESM + DTS)pnpm check:types— no type errorsimport { createFlashnetClient } from '@mbga/flashnet') works without React installed🤖 Generated with Claude Code