Files
piik/scripts/package-files.mjs
AAA f6b611978b fix(app): restore approved connections and refine shared playback
Preserve explicit App approval, expose playback and transfer progress, and keep shared identity and native window presentation coherent. Retain terminal fallback, cancel external input safely, and reject withdrawn UDP preparation before adoption.

Reuse exact Web artifacts across matched targets and extend the existing text participant with typed history, replies and reactions. Verified Rust/WASM/protocol checks, 1614 Web tests, Windows capture compilation and five external input lifecycle tests.
2026-11-16 07:03:38 -04:00

68 lines
2.1 KiB
JavaScript

import { createHash } from "node:crypto";
import { lstatSync, readdirSync, readFileSync, statSync } from "node:fs";
import { join, relative, sep } from "node:path";
function fail(message) { throw new Error(message); }
export function sha256(path) {
return createHash("sha256").update(readFileSync(path)).digest("hex");
}
function normalizedRelative(root, path) {
const value = relative(root, path).split(sep).join("/");
if (
value.length === 0 ||
value.startsWith("../") ||
value.includes("\\") ||
value.split("/").some((part) => part === "" || part === "." || part === "..")
) {
fail(`Invalid runtime path: ${value}`);
}
return value;
}
function regularFiles(root) {
const files = [];
const pending = [root];
while (pending.length > 0) {
const directory = pending.pop();
for (const entry of readdirSync(directory, { withFileTypes: true })) {
const absolute = join(directory, entry.name);
const metadata = lstatSync(absolute);
if (metadata.isSymbolicLink()) fail(`Runtime contains a link: ${absolute}`);
if (metadata.isDirectory()) {
pending.push(absolute);
} else if (metadata.isFile()) {
files.push(absolute);
} else {
fail(`Runtime contains an unsupported file type: ${absolute}`);
}
}
}
return files.sort((left, right) => {
const a = normalizedRelative(root, left), b = normalizedRelative(root, right);
return a < b ? -1 : a > b ? 1 : 0;
});
}
export function fileRecords(root) {
return regularFiles(root).map(absolute => ({
path: normalizedRelative(root, absolute), size: statSync(absolute).size, sha256: sha256(absolute),
}));
}
export function compareFileRecords(expected, actual) {
if (expected.length !== actual.length) fail("Extracted runtime file count differs");
for (let index = 0; index < expected.length; index += 1) {
const left = expected[index];
const right = actual[index];
if (
left.path !== right.path ||
left.size !== right.size ||
left.sha256 !== right.sha256
) {
fail(`Extracted runtime differs at ${left.path}`);
}
}
}