diff --git a/src/lib/helpers.ts b/src/lib/helpers.ts index 898be233b..935e5c975 100644 --- a/src/lib/helpers.ts +++ b/src/lib/helpers.ts @@ -289,7 +289,9 @@ function base64urlencode(str: string) { } export async function generatePKCEChallenge(verifier: string) { - if (typeof crypto === 'undefined') { + const hasCryptoSupport = typeof crypto !== 'undefined' && typeof crypto.subtle !== 'undefined' && typeof TextEncoder !== 'undefined'; + + if (!hasCryptoSupport) { console.warn( 'WebCrypto API is not supported. Code challenge method will default to use plain instead of sha256.' )