fix(app): make client ID generation resilient to UUID failures#297
Open
Jacobinwwey wants to merge 2 commits intogetpaseo:mainfrom
Open
fix(app): make client ID generation resilient to UUID failures#297Jacobinwwey wants to merge 2 commits intogetpaseo:mainfrom
Jacobinwwey wants to merge 2 commits intogetpaseo:mainfrom
Conversation
Signed-off-by: Jacobinwwey <jacob.hxx.cn@outlook.com>
Signed-off-by: Jacobinwwey <jacob.hxx.cn@outlook.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.
1. Context & Motivation (Context)
globalThis.crypto.randomUUID()is always usable when minting a client ID. On some React Native / Expo setups the UUID path can be broken or recurse through an incomplete polyfill, which turns first-run client ID creation into a hard failure instead of a recoverable fallback.randomUUID()as the preferred entropy source, but falls back togetRandomValues()when UUID generation is broken. That adds a small amount of local formatting logic in exchange for a more robust startup path without changing the persisted client ID shape.2. Implementation Details (Implementation)
client-idgeneration to catchrandomUUID()failures and derive the persisted identifier fromgetRandomValues()before falling back to the existing time/Math-based path.randomUUID()fromgetRandomValues()so environments that already expose a working random byte source do not depend on a second UUID implementation.3. Testing Strategies (Validation)
client-id(coveringrandomUUID()failure fallback)polyfillCrypto(covering non-recursive UUID generation fromgetRandomValues())npm run test --workspace=@getpaseo/app -- src/utils/client-id.test.ts src/polyfills/crypto.test.tsnpm run build:highlight && npm run typecheck --workspace=@getpaseo/appcid_<hex>storage format