Skip to content

Commit

Permalink
fix: check secure context before generating randomUUID
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 d2baf6f commit 0faed10
Showing 1 changed file with 5 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 @@ -14,6 +14,11 @@ export class Uuid {
}

static random(): Uuid {
if (!window.isSecureContext) {
throw new Error(
"<crypto.randomUUID()> is not available in a non-secure context",
);
}
return new Uuid(crypto.randomUUID());
}

Expand Down

0 comments on commit 0faed10

Please sign in to comment.