Skip to content

Commit

Permalink
Merge pull request #1300 from authts/fix-1299
Browse files Browse the repository at this point in the history
explicitly throw an error when crypto.subtle is undefined
  • Loading branch information
pamapa authored Dec 14, 2023
2 parents 9380b18 + 287a433 commit 7ba6b72
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/utils/CryptoUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ export class CryptoUtils {
* PKCE: Generate a code challenge
*/
public static async generateCodeChallenge(code_verifier: string): Promise<string> {
if (!crypto.subtle) {
throw new Error("Crypto.subtle is available only in secure contexts (HTTPS).");
}

try {
const encoder = new TextEncoder();
const data = encoder.encode(code_verifier);
Expand Down

0 comments on commit 7ba6b72

Please sign in to comment.