Skip to content

feat: Added auth header to API transport#5

Draft
Chriztiaan wants to merge 1 commit into
feat/initfrom
feat/auth
Draft

feat: Added auth header to API transport#5
Chriztiaan wants to merge 1 commit into
feat/initfrom
feat/auth

Conversation

@Chriztiaan

@Chriztiaan Chriztiaan commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

POST /api/data previously accepted any request. This PR gates it behind a bearer JWT: the backend verifies the token on every write, and the frontend attaches one to every upload. The verification logic sits behind a single pluggable interface so adopters can swap the demo verifier for a real identity provider (Supabase, Clerk, etc.) by editing one file.

How it works

The demo keeps its one-token shape: the client already fetches a PowerSync JWT from /api/auth/token in fetchCredentials() for sync. Writes now reuse that same token as the bearer credential, and the backend verifies it against its own public key (the same key it signs with, exposed via a new getPublicJwk() helper).

Docs

  • auth-verifiers.md — adopter guide for swapping the verifier to Supabase or Clerk: worked verifier snippets, env vars, frontend getToken() wiring, sync-token options, and a verification checklist.

AI disclosure

This PR was created with the help of Claude Code. Help constitutes assistance in research, planning, and rough outline of implementation. Beyond having a hand in the implementation, I have also manually tested this work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant