Skip to content

Commit

Permalink
Improved isSecureContext message #183
Browse files Browse the repository at this point in the history
  • Loading branch information
vlad-ignatov committed Aug 26, 2024
1 parent 8b6d825 commit 6c63e0d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/security/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ const crypto: Crypto = typeof globalThis === "object" && globalThis.crypto ?
require("isomorphic-webcrypto").default;

const subtle = () => {
if (!window.isSecureContext) {
throw new Error(
"Some of the required subtle crypto functionality is not " +
"available unless you run this app in secure context (using " +
"HTTPS or running locally). See " +
"https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts"
)
}
if (!crypto.subtle) {
if (!globalThis.isSecureContext) {
throw new Error(
"Some of the required subtle crypto functionality is not " +
"available unless you run this app in secure context (using " +
"HTTPS or running locally). See " +
"https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts"
)
}
throw new Error(
"Some of the required subtle crypto functionality is not " +
"available in the current environment (no crypto.subtle)"
Expand Down

0 comments on commit 6c63e0d

Please sign in to comment.