Skip to content

Commit

Permalink
fix: #1299 explicitly throw an error when crypto.subtle is undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
pamapa committed Dec 13, 2023
1 parent 9380b18 commit 287a433
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).");

Check warning on line 42 in src/utils/CryptoUtils.ts

View check run for this annotation

Codecov / codecov/patch

src/utils/CryptoUtils.ts#L42

Added line #L42 was not covered by tests
}

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

0 comments on commit 287a433

Please sign in to comment.