17 lines
604 B
TypeScript
17 lines
604 B
TypeScript
// Names of the embedded files that make up the source-of-truth layer.
|
|
|
|
export const ATTACH = {
|
|
manifest: 'papure/manifest.json',
|
|
markdown: (id: string) => `papure/pages/${id}.md`,
|
|
ink: (id: string) => `papure/pages/${id}.ink.json`,
|
|
source: (id: string) => `papure/sources/${id}.pdf`
|
|
};
|
|
|
|
export const FORMAT = 'papure';
|
|
|
|
export async function sha256Hex(bytes: Uint8Array, length = 24): Promise<string> {
|
|
const digest = await crypto.subtle.digest('SHA-256', bytes as BufferSource);
|
|
return Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, '0'))
|
|
.join('')
|
|
.slice(0, length);
|
|
}
|