diff --git a/packages/framework/store/src/persistence/blob/utils.ts b/packages/framework/store/src/persistence/blob/utils.ts index 70a16f87ba12..074e7aa1978e 100644 --- a/packages/framework/store/src/persistence/blob/utils.ts +++ b/packages/framework/store/src/persistence/blob/utils.ts @@ -1,7 +1,11 @@ import { toBase64 } from 'lib0/buffer.js'; +import { digest } from 'lib0/hash/sha256'; export async function sha(input: ArrayBuffer): Promise { - const hash = await crypto.subtle.digest('SHA-256', input); + const hash = + crypto.subtle === undefined // crypto.subtle is not available without a secure context (HTTPS) + ? digest(new Uint8Array(input)) + : await crypto.subtle.digest('SHA-256', input); // faster conversion from ArrayBuffer to base64 in browser return toBase64(new Uint8Array(hash)).replace(/\+/g, '-').replace(/\//g, '_');