mirror of
https://github.com/kmc7468/arkvault.git
synced 2026-02-04 16:16:55 +00:00
업로드할 때에도 스트리밍 방식으로 처리하도록 변경
This commit is contained in:
@@ -77,7 +77,7 @@ export const unwrapHmacSecret = async (hmacSecretWrapped: string, masterKey: Cry
|
||||
name: "HMAC",
|
||||
hash: "SHA-256",
|
||||
} satisfies HmacImportParams,
|
||||
false, // Nonextractable
|
||||
true, // Extractable
|
||||
["sign", "verify"],
|
||||
),
|
||||
};
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -9,8 +9,8 @@ export const decodeString = (data: ArrayBuffer) => {
|
||||
return textDecoder.decode(data);
|
||||
};
|
||||
|
||||
export const encodeToBase64 = (data: ArrayBuffer) => {
|
||||
return btoa(String.fromCharCode(...new Uint8Array(data)));
|
||||
export const encodeToBase64 = (data: ArrayBuffer | Uint8Array) => {
|
||||
return btoa(String.fromCharCode(...(data instanceof ArrayBuffer ? new Uint8Array(data) : data)));
|
||||
};
|
||||
|
||||
export const decodeFromBase64 = (data: string) => {
|
||||
|
||||
Reference in New Issue
Block a user