fix(FN-1028): add crypto.randomUUID fallback for schedule step ID generation

- Add fallback ID generation using Math.random when crypto.randomUUID is unavailable
- Update ScheduleStepsEditor component with robust step creation
- Add unit tests for fallback ID generation behavior
- Document fallback approach in Scheduled Tasks section of README
This commit is contained in:
gsxdsm
2026-04-06 00:09:21 -07:00
parent 2eae2834f4
commit 76770e6e14
3 changed files with 56 additions and 2 deletions

View File

@@ -11,7 +11,14 @@ interface ScheduleStepsEditorProps {
}
function generateStepId(): string {
return crypto.randomUUID();
// crypto.randomUUID() may be unavailable in non-secure contexts (HTTP),
// older browsers, or some test environments. Fall back to a
// cryptographically-acceptable alternative when needed.
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
return crypto.randomUUID();
}
// Deterministic fallback: timestamp + random hex
return `step-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`;
}
function createEmptyStep(type: AutomationStepType): AutomationStep {