Updated practices for VFS - #61
Merged
Merged
Conversation
Replace the legacy Supabase anon API key with the new publishable key (sb_publishable_...) throughout the app and templates: - SupabaseConnector reads VITE_SUPABASE_PUBLISHABLE_KEY (config field renamed supabaseAnonKey -> supabaseKey) - .env.local.template / .env.cloud.template / README updated to the publishable key naming and guidance Newer Supabase (CLI and new projects) signs user tokens with asymmetric ES256 JWT signing keys, which the HS256 shared-secret config rejected (PSYNC_S2101). Point PowerSync at the Supabase Auth JWKS endpoint so it validates ES256 tokens by KID, keep the HS256 secret as a fallback, and declare the "authenticated" audience: - docker/powersync.yaml: add jwks_uri (via PS_SUPABASE_JWKS_URI) and audience: [authenticated] - env templates: add PS_SUPABASE_JWKS_URI (http://kong:8000/... on the shared Docker network) - README: note the asymmetric-key consideration for cloud instances Verified locally end to end: anonymous sign-in ES256 token is accepted by /write-checkpoint2.json and /sync/stream (HTTP 200), bogus tokens still 401. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Choose the PowerSync SQLite VFS based on the runtime environment instead of always attempting OPFS: - Add isMobile() and isSafari() detection (handles iPadOS reporting as macOS and Chromium/Firefox carrying "Safari" in their UA). - Add isOPFSUsable(): an async probe that opens a SyncAccessHandle inside a throwaway Worker to confirm OPFS actually works. Safari Private Browsing exposes the OPFS API but fails this call, so the probe catches it. Non-Safari browsers skip the probe. Falls back safely on timeout/error. - pickVFS() now falls back to IndexedDB (IDBBatchAtomicVFS) for: unusable OPFS (incl. Safari Private Browsing), mobile Safari, and desktop Safari multi-tab. - Disable multi-tab in Safari Private Browsing (isSafariPrivate); other IndexedDB cases keep multi-tab. Also drop the now-unused SyncClientImplementation import (the Rust sync client is the default in current PowerSync, so the explicit clientImplementation is no longer needed). Co-Authored-By: Claude Opus 4.8 (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.
Description
This PR adds changes that address best practices when handling VFS for different platforms and browsers, focusing on how to handle cases for Safari on desktop and mobile.
AI Disclosure
Claude Opus 4.8 was used to generate the helper functions. All changes were tested and verified by myself.