Fix clientId usage to follow LiveStore best practices#209
Merged
Conversation
- Generate clientId using userId prefix + unique identifier instead of using userId directly - Add userId to sync payload for proper authorization - Update authentication pattern to separate client identification from user identification - clientId now identifies device/app instances, userId identifies users for auth - Update all tests and schema documentation to reflect new pattern Fixes the issue where clientId was incorrectly set to userId, which goes against LiveStore's design where clientId should identify unique client instances.
- Update Logger class default from ERROR to INFO - Update pyodide runtime agent log level parsing defaults - Ensure INFO is used when RUNT_LOG_LEVEL environment variable is not set - Matches documented behavior that default is INFO - Tests continue to explicitly set ERROR level so remain unaffected
- Remove anonymous user clientId pattern from schema documentation - Change default notebook ownerId fallback from 'anonymous' to 'unknown' - Runt system is designed for authenticated users only, no anonymous access
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.
This PR fixes the incorrect usage of
clientIdin the runt runtime agent system.Problem
Previously, the system was setting
clientId = userId, which goes against LiveStore's design principles. According to the LiveStore docs and guidance from the maintainer @schickling:Solution
Modified
discoverUserIdentity()to return both user info and generate a proper clientId using the patternuserId-{uniqueId}Updated authentication flow to:
Updated schema documentation to reflect correct LiveStore patterns
Fixed all tests to include the required userId parameter
Changes
packages/pyodide-runtime-agent/src/auth.ts: Enhanced to return both userId and generated clientIdpackages/lib/src/types.ts: Added userId to RuntimeAgentOptionspackages/lib/src/config.ts: Added userId to RuntimeConfigpackages/lib/src/runtime-agent.ts: Added userId to sync payloadpackages/schema/mod.ts: Updated authentication pattern documentation