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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user