@devries-cameron20 / composio Mirror · read-only
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 21, 04:45 UTC

next
ts 29 lines 1012 Bytes
Raw
1 /**
2 * Parse a sha256sum-compatible `checksums.txt` ("<hash> <filename>" per line)
3 * into a filename -> expected-hash map. Blank lines are skipped.
4 */
5 export const parseChecksumsText = (text: string): Map<string, string> => {
6 const checksums = new Map<string, string>();
7 for (const line of text.split('\n')) {
8 const trimmed = line.trim();
9 if (!trimmed) continue;
10 const parts = trimmed.split(/\s+/);
11 if (parts.length >= 2) {
12 checksums.set(parts[1]!, parts[0]!);
13 }
14 }
15 return checksums;
16 };
17
18 /**
19 * SHA-256 digest of `data` as a lowercase hex string. Copies into a fresh
20 * ArrayBuffer so views over a SharedArrayBuffer are accepted too.
21 */
22 export const sha256Hex = async (data: Uint8Array): Promise<string> => {
23 const buffer = new ArrayBuffer(data.byteLength);
24 new Uint8Array(buffer).set(data);
25 const digest = await crypto.subtle.digest('SHA-256', buffer);
26 return Array.from(new Uint8Array(digest))
27 .map(byte => byte.toString(16).padStart(2, '0'))
28 .join('');
29 };