INNER CODE UNIT · TypeScript
real
software-mansion/argent · packages/archive/src/index.ts:140
const real = entries.filter((e) => !e.startsWith("._"));
if (real.length !== 1) {
throw new ArchiveError(
`Could not identify the extracted member (expected "${expectedName}", found ${real.length} entries).`
);
}
return join(destDir, real[0]!);
}
/**
* Vet a gzipped tar (no path or symlink escaping `destDir`), extract it into
* `destDir`, and return its top-level member path. Used in both directions —
* neither the uploading client nor the serving tool-server is trusted. Throws
* {@link ArchiveError}; callers map it to their own contract (upload path → a
* 4xx, download path → null).
*/
export async function safeExtractTarGz(
tarPath: string,