Bind import recovery checkpoints to source content digests

This commit is contained in:
2026-11-08 19:34:32 +08:00
parent 627a043d92
commit a51d189b8e
9 changed files with 86 additions and 16 deletions
@@ -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('');
}