Skip to content

Commit

Permalink
Merge pull request #168 from bratanon/main
Browse files Browse the repository at this point in the history
Throw error when SubtleCrypto is used in an insecure context
  • Loading branch information
evert authored Oct 28, 2024
2 parents ae9adb9 + 13fde66 commit bf35cc6
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/client/authorization-code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,11 @@ async function getWebCrypto(): Promise<typeof window.crypto> {

// Browsers
if ((typeof window !== 'undefined' && window.crypto)) {
if (!window.crypto.subtle?.digest) {
throw new Error(
"The context/environment is not secure, and does not support the 'crypto.subtle' module. See: https://developer.mozilla.org/en-US/docs/Web/API/Crypto/subtle for details"
);
}
return window.crypto;
}
// Web workers possibly
Expand Down

0 comments on commit bf35cc6

Please sign in to comment.