업로드할 때에도 스트리밍 방식으로 처리하도록 변경

This commit is contained in:
static
2026-01-11 13:19:54 +09:00
parent 1efcdd68f1
commit 3628e6d21a
9 changed files with 308 additions and 62 deletions

View File

@@ -1,7 +1,20 @@
import { hmac } from "@noble/hashes/hmac.js";
import { sha256 } from "@noble/hashes/sha2.js";
export const digestMessage = async (message: BufferSource) => {
return await crypto.subtle.digest("SHA-256", message);
};
export const createStreamingHmac = async (hmacSecret: CryptoKey) => {
const keyBytes = new Uint8Array(await crypto.subtle.exportKey("raw", hmacSecret));
const h = hmac.create(sha256, keyBytes);
return {
update: (data: Uint8Array) => h.update(data),
digest: () => h.digest(),
};
};
export const generateHmacSecret = async () => {
return {
hmacSecret: await crypto.subtle.generateKey(