Repository navigation
feat: session manager for any library, device signals, refresh tokens - #7
Merged
Merged
Conversation
…y / SWR helpers Access + refresh tokens with single-flight refresh (Web Locks across tabs), one retry on UNAUTHENTICATED, memory or web storage, subscribe/getSnapshot/store and a fetch wrapper for any UI or GraphQL library. Device signals (deviceId, clientSessionId, fingerprint, info) go with login and refresh. New operations: refreshSession, job, startDocumentJob. 1.2.0. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BA5Vx77ihDsLiZpyg5duJV
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.
What and why
Before: the GraphQL client kept one bearer token and left refresh and session state to the app.
After:
client.session, a framework-agnostic session manager with no dependencies.UNAUTHENTICATEDit refreshes and retries once.useMgplSession), Vue, Svelte and Solid throughsubscribe/getSnapshot/store.session.fetchplugs into Apollo, urql, graphql-request and RTK Query.mgplQuery/mgplMutation/mgplKey/mgplFetcher/clearOnSignOutcover TanStack Query and SWR without importing either.Login and refresh send device signals (
deviceId,clientSessionId,fingerprint,info) so the API can bind refresh tokens to the device. Everything collected is listed in docs/session.md, and there is no canvas, audio or font probing. The signal code is insrc/graphql/device.ts, which imports nothing, so it can move to security-kit unchanged.New operations:
refreshSession,job,startDocumentJob(documents.startJob/job/waitForJob).LoginResultnow carriesaccessTokenandrefreshToken. Version 1.2.0.How: the end-to-end checks run in mgpl-diagnostics/api's test suite against the real server. They cover login with device signals, 5 parallel calls with an expiring token causing 1 refresh, refresh and retry on
UNAUTHENTICATED,session.fetch, and logout. All 96 checks pass locally.Type
Screenshots
n/a (SDK)
Checklist
npm run typecheck && npm run build🤖 Generated with Claude Code
https://claude.ai/code/session_01BA5Vx77ihDsLiZpyg5duJV
Generated by Claude Code