fix: add generateUUID fallback for crypto.randomUUID in PackGeneratorService and document the solution.
This commit is contained in:
@@ -10,6 +10,7 @@ The project has successfully migrated from a .NET backend to a Node.js Modular M
|
||||
- **[2025-12-14] Cleanup**: Removed Tournament Mode and simplified pack display as requested. [Link](./devlog/2025-12-14-211500_remove_tournament_mode.md)
|
||||
- **[2025-12-14] UI Tweak**: Auto-configured generation mode based on source selection. [Link](./devlog/2025-12-14-212000_ui_simplification.md)
|
||||
- **[2025-12-14] Multiplayer Game Plan**: Plan for Real Game & Online Multiplayer. [Link](./devlog/2025-12-14-212500_multiplayer_game_plan.md)
|
||||
- **[2025-12-14] Bug Fix**: Fixed `crypto.randomUUID` error for non-secure contexts. [Link](./devlog/2025-12-14-214400_fix_uuid_error.md)
|
||||
|
||||
## Active Modules
|
||||
1. **Cube Manager**: Fully functional (Parsing, Fetching, Pack Generation).
|
||||
|
||||
15
docs/development/devlog/2025-12-14-214400_fix_uuid_error.md
Normal file
15
docs/development/devlog/2025-12-14-214400_fix_uuid_error.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# Fix UUID Error in Insecure Contexts
|
||||
|
||||
## Problem
|
||||
The user reported a `TypeError: crypto.randomUUID is not a function` when accessing the application from a public IP. This is because `crypto.randomUUID()` is part of the Web Crypto API, which is often restricted to secure contexts (HTTPS) or localhost. When accessing via `http://PUBLIC_IP:PORT`, the browser disables this API.
|
||||
|
||||
## Solution
|
||||
We need to implement a fallback UUID generation method that works in non-secure contexts.
|
||||
|
||||
## Plan
|
||||
1. Modify `src/client/src/services/PackGeneratorService.ts`.
|
||||
2. Add a private method `generateUUID()` to the `PackGeneratorService` class (or a standalone helper function in the module) that:
|
||||
* Checks if `crypto.randomUUID` is available.
|
||||
* If yes, uses it.
|
||||
* If no, uses a fallback algorithm (e.g., `Math.random()` based v4 UUID generation).
|
||||
3. Replace the call `crypto.randomUUID()` with this new method.
|
||||
Reference in New Issue
Block a user