New attachment storage system
This commit is contained in:
parent
273e1ccb15
commit
28664a606f
161 changed files with 2418 additions and 1562 deletions
|
@ -11,7 +11,10 @@ export const MAC_KEY_SIZE = 32;
|
|||
|
||||
export const MAC_SIZE = 32;
|
||||
|
||||
export function appendMacStream(macKey: Uint8Array): Duplex {
|
||||
export function appendMacStream(
|
||||
macKey: Uint8Array,
|
||||
onMac?: (mac: Uint8Array) => undefined
|
||||
): Duplex {
|
||||
if (macKey.byteLength !== MAC_KEY_SIZE) {
|
||||
throw new Error('appendMacStream: invalid macKey length');
|
||||
}
|
||||
|
@ -28,7 +31,9 @@ export function appendMacStream(macKey: Uint8Array): Duplex {
|
|||
},
|
||||
flush(callback) {
|
||||
try {
|
||||
callback(null, hmac.digest());
|
||||
const mac = hmac.digest();
|
||||
onMac?.(mac);
|
||||
callback(null, mac);
|
||||
} catch (error) {
|
||||
callback(error);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue