Skip to content

Commit

Permalink
fix: crypto.randomUUID validation for secure context
Browse files Browse the repository at this point in the history
Signed-off-by: rare-magma <[email protected]>
  • Loading branch information
rare-magma committed Oct 19, 2024
1 parent e7cf367 commit 8892cfe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/guitos/domain/uuid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,10 @@ export class Uuid {
`<${this.constructor.name}> does not allow the value <${id}>`,
);
}
if (!window.isSecureContext) {
throw new Error(
`<${this.constructor.name}> is not available in a non-secure context`,
);
}
}
}
1 change: 1 addition & 0 deletions src/setupTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import * as AppBudgetContext from "./guitos/context/BudgetContext";
import { BudgetMother } from "./guitos/domain/budget.mother";

window.crypto.randomUUID = randomUUID;
window.isSecureContext = true;
global.URL.createObjectURL = vi.fn();

vi.mock("crypto", () => ({
Expand Down

0 comments on commit 8892cfe

Please sign in to comment.