From e6f47963998927094eccd7ce36dacfa6e6ff5d7d Mon Sep 17 00:00:00 2001 From: Yarmo Mackenbach Date: Thu, 3 Mar 2022 15:48:32 +0100 Subject: [PATCH] Fix crypto fallback --- static-src/utils.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/static-src/utils.js b/static-src/utils.js index a6ffd4d..c7e34c4 100644 --- a/static-src/utils.js +++ b/static-src/utils.js @@ -30,15 +30,13 @@ more information on this, and how to apply and follow the GNU AGPL, see { - return crypto.webcrypto - }) - // import { webcrypto as crypto } from 'crypto' -} // Compute local part of Web Key Directory URL export async function computeWKDLocalPart(localPart) { + if (!_crypto) { + _crypto = (await import('crypto')).webcrypto + } + const localPartEncoded = new TextEncoder().encode(localPart.toLowerCase()); const localPartHashed = new Uint8Array(await _crypto.subtle.digest('SHA-1', localPartEncoded)); return encodeZBase32(localPartHashed);