/* global Uint8Array */ import { _base64URLEncode } from "@authgear/core"; import { randomBytes, sha256String } from "./nativemodule"; export async function generateCodeVerifier(): Promise { const arr = await randomBytes(32); const base64 = _base64URLEncode(new Uint8Array(arr)); return base64; } export async function computeCodeChallenge( codeVerifier: string ): Promise { const hash = await sha256String(codeVerifier); const base64 = _base64URLEncode(new Uint8Array(hash)); return base64; }