Bind import recovery checkpoints to source content digests
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
import { fault } from '../canvas-core/values.ts';
|
||||
/** Bind durable preparation/parse checkpoints to the complete immutable byte source. */
|
||||
export async function importSourceDigest(bytes:Blob,signal?:AbortSignal):Promise<string>{
|
||||
if(signal?.aborted)throw fault('import_aborted');
|
||||
const buffer=await bytes.arrayBuffer();if(signal?.aborted)throw fault('import_aborted');
|
||||
const digest=await crypto.subtle.digest('SHA-256',buffer);if(signal?.aborted)throw fault('import_aborted');
|
||||
return [...new Uint8Array(digest)].map(byte=>byte.toString(16).padStart(2,'0')).join('');
|
||||
}
|
||||
Reference in New Issue
Block a user