From 287a433aa83ea1fce6c0863069eeb1145d553e29 Mon Sep 17 00:00:00 2001 From: pamapa Date: Wed, 13 Dec 2023 16:22:03 +0100 Subject: [PATCH] fix: #1299 explicitly throw an error when crypto.subtle is undefined --- src/utils/CryptoUtils.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/utils/CryptoUtils.ts b/src/utils/CryptoUtils.ts index 66e77782f..5f3fdd895 100644 --- a/src/utils/CryptoUtils.ts +++ b/src/utils/CryptoUtils.ts @@ -38,6 +38,10 @@ export class CryptoUtils { * PKCE: Generate a code challenge */ public static async generateCodeChallenge(code_verifier: string): Promise { + 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);