@pipobscure/bundle 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/HISTORY.md +1924 -0
  2. package/README.md +623 -0
  3. package/bundle.run +0 -0
  4. package/dist/api.d.ts +147 -0
  5. package/dist/api.d.ts.map +1 -0
  6. package/dist/api.js +174 -0
  7. package/dist/api.js.map +1 -0
  8. package/dist/archive.d.ts +115 -0
  9. package/dist/archive.d.ts.map +1 -0
  10. package/dist/archive.js +188 -0
  11. package/dist/archive.js.map +1 -0
  12. package/dist/audit.d.ts +78 -0
  13. package/dist/audit.d.ts.map +1 -0
  14. package/dist/audit.js +119 -0
  15. package/dist/audit.js.map +1 -0
  16. package/dist/cli.d.ts +23 -0
  17. package/dist/cli.d.ts.map +1 -0
  18. package/dist/cli.js +555 -0
  19. package/dist/cli.js.map +1 -0
  20. package/dist/files.d.ts +53 -0
  21. package/dist/files.d.ts.map +1 -0
  22. package/dist/files.js +118 -0
  23. package/dist/files.js.map +1 -0
  24. package/dist/index.d.ts +10 -0
  25. package/dist/index.d.ts.map +1 -0
  26. package/dist/index.js +35 -0
  27. package/dist/index.js.map +1 -0
  28. package/dist/launch.d.ts +97 -0
  29. package/dist/launch.d.ts.map +1 -0
  30. package/dist/launch.js +267 -0
  31. package/dist/launch.js.map +1 -0
  32. package/dist/main.d.ts +3 -0
  33. package/dist/main.d.ts.map +1 -0
  34. package/dist/main.js +19 -0
  35. package/dist/main.js.map +1 -0
  36. package/dist/manifest.d.ts +139 -0
  37. package/dist/manifest.d.ts.map +1 -0
  38. package/dist/manifest.js +504 -0
  39. package/dist/manifest.js.map +1 -0
  40. package/dist/oidc.d.ts +40 -0
  41. package/dist/oidc.d.ts.map +1 -0
  42. package/dist/oidc.js +320 -0
  43. package/dist/oidc.js.map +1 -0
  44. package/dist/preload.d.ts +14 -0
  45. package/dist/preload.d.ts.map +1 -0
  46. package/dist/preload.js +38 -0
  47. package/dist/preload.js.map +1 -0
  48. package/dist/provider.d.ts +83 -0
  49. package/dist/provider.d.ts.map +1 -0
  50. package/dist/provider.js +206 -0
  51. package/dist/provider.js.map +1 -0
  52. package/dist/record.d.ts +2 -0
  53. package/dist/record.d.ts.map +1 -0
  54. package/dist/record.js +23 -0
  55. package/dist/record.js.map +1 -0
  56. package/dist/recorder.d.ts +64 -0
  57. package/dist/recorder.d.ts.map +1 -0
  58. package/dist/recorder.js +111 -0
  59. package/dist/recorder.js.map +1 -0
  60. package/dist/register.d.ts +2 -0
  61. package/dist/register.d.ts.map +1 -0
  62. package/dist/register.js +28 -0
  63. package/dist/register.js.map +1 -0
  64. package/dist/sea.d.ts +97 -0
  65. package/dist/sea.d.ts.map +1 -0
  66. package/dist/sea.js +220 -0
  67. package/dist/sea.js.map +1 -0
  68. package/dist/sigstore.d.ts +112 -0
  69. package/dist/sigstore.d.ts.map +1 -0
  70. package/dist/sigstore.js +385 -0
  71. package/dist/sigstore.js.map +1 -0
  72. package/dist/skill.d.ts +36 -0
  73. package/dist/skill.d.ts.map +1 -0
  74. package/dist/skill.js +108 -0
  75. package/dist/skill.js.map +1 -0
  76. package/package.json +84 -0
  77. package/shell-base +2 -0
  78. package/skills/audit-bundle/SKILL.md +271 -0
  79. package/src/api.ts +293 -0
  80. package/src/archive.ts +312 -0
  81. package/src/audit.ts +206 -0
  82. package/src/cli.ts +575 -0
  83. package/src/files.ts +156 -0
  84. package/src/index.ts +114 -0
  85. package/src/launch.ts +336 -0
  86. package/src/main.ts +20 -0
  87. package/src/manifest.ts +615 -0
  88. package/src/oidc.ts +372 -0
  89. package/src/preload.ts +40 -0
  90. package/src/provider.ts +270 -0
  91. package/src/record.ts +25 -0
  92. package/src/recorder.ts +166 -0
  93. package/src/register.ts +30 -0
  94. package/src/sea.ts +341 -0
  95. package/src/sigstore.ts +492 -0
  96. package/src/skill.ts +132 -0
  97. package/src/types/node-vfs.d.ts +90 -0
  98. package/src/types/node-zip.d.ts +85 -0
package/dist/files.js ADDED
@@ -0,0 +1,118 @@
1
+ import * as FS from 'node:fs';
2
+ import * as PATH from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ /**
5
+ * Every file under `dir`, as `/`-separated paths relative to it, sorted.
6
+ *
7
+ * A nested `node_modules` is skipped by default: its contents belong to the
8
+ * packages inside it, which `dependencyFiles` reaches through the dependency
9
+ * graph instead — so a hoisted tree and a nested one produce the same set.
10
+ */
11
+ export function walk(dir, { exclude = ['node_modules'] } = {}, prefix = '') {
12
+ const out = [];
13
+ for (const entry of FS.readdirSync(dir, { withFileTypes: true })) {
14
+ if (exclude.includes(entry.name))
15
+ continue;
16
+ const relative = prefix ? `${prefix}/${entry.name}` : entry.name;
17
+ if (entry.isDirectory())
18
+ out.push(...walk(PATH.join(dir, entry.name), { exclude }, relative));
19
+ else if (entry.isFile())
20
+ out.push(relative);
21
+ }
22
+ return out.sort();
23
+ }
24
+ /**
25
+ * Every file of `names` and of everything they depend on, as paths relative to
26
+ * `base`, sorted. Packages are located the way node locates them, so the answer
27
+ * describes the tree that is actually installed rather than what a lock file
28
+ * says should be.
29
+ *
30
+ * A dependency that is not installed under `base` — missing, or hoisted above
31
+ * it, where no member path can name it — is an error rather than a silent
32
+ * omission, because a bundle whose closure is incomplete is a bundle that
33
+ * fails at runtime on a machine other than the one that built it. Only an
34
+ * optional dependency may be absent.
35
+ */
36
+ export function dependencyFiles(names, base) {
37
+ const root = PATH.resolve(base);
38
+ const files = [];
39
+ const seen = new Set();
40
+ // Each dependency is looked up from the package that depends on it, not from
41
+ // the root: a tree can hold several versions of one package, and which one
42
+ // a `require` gets depends on where it is asked from.
43
+ const queue = names.map((name) => ({ name, from: root, optional: false }));
44
+ while (queue.length) {
45
+ const { name, from, optional } = queue.shift();
46
+ const dir = locate(name, from, root);
47
+ if (!dir) {
48
+ if (optional)
49
+ continue; // optional, and not installed
50
+ throw new Error(`'${name}', needed by ${PATH.relative(root, from) || 'the root'}, is not installed ` +
51
+ `under ${root} — a bundle without it fails wherever the code that needs it runs`);
52
+ }
53
+ if (seen.has(dir))
54
+ continue;
55
+ seen.add(dir);
56
+ const relative = PATH.relative(root, dir);
57
+ for (const file of walk(dir))
58
+ files.push(posix(relative, file));
59
+ const manifest = JSON.parse(FS.readFileSync(PATH.join(dir, 'package.json'), 'utf-8'));
60
+ const optionals = manifest.optionalDependencies ?? {};
61
+ for (const dep of Object.keys(manifest.dependencies ?? {})) {
62
+ queue.push({ name: dep, from: dir, optional: dep in optionals });
63
+ }
64
+ for (const dep of Object.keys(optionals))
65
+ queue.push({ name: dep, from: dir, optional: true });
66
+ }
67
+ return files.sort();
68
+ }
69
+ // Where `name` is installed as seen from `from`: the nearest `node_modules/name`
70
+ // on the way up, the search node's resolver makes. It looks for the directory
71
+ // rather than resolving `name/package.json`, because a package whose `exports`
72
+ // does not list its manifest would refuse that — and be mistaken for missing.
73
+ // The search stops at `root`: a package above it cannot become a member of an
74
+ // archive rooted there, so finding one is the same as not finding one.
75
+ function locate(name, from, root) {
76
+ for (let dir = from;; dir = PATH.dirname(dir)) {
77
+ if (PATH.basename(dir) !== 'node_modules') {
78
+ const candidate = PATH.join(dir, 'node_modules', name);
79
+ if (FS.existsSync(PATH.join(candidate, 'package.json')))
80
+ return candidate;
81
+ }
82
+ if (dir === root || PATH.dirname(dir) === dir)
83
+ return null;
84
+ }
85
+ }
86
+ /** The three sources above, combined and de-duplicated. */
87
+ export function moduleFiles({ base, files = [], dirs = [], dependencies = [], filter }) {
88
+ const all = [
89
+ ...files,
90
+ ...dirs.flatMap((dir) => walk(PATH.join(base, dir)).map((name) => posix(dir, name))),
91
+ ...dependencyFiles(dependencies, base),
92
+ ];
93
+ const kept = filter ? all.filter(filter) : all;
94
+ return [...new Set(kept)].sort();
95
+ }
96
+ /**
97
+ * The shell launcher this package ships: the prefix that turns an archive into
98
+ * a file you can run by name. `bundle sign --launcher` uses it, so nobody has
99
+ * to know it lives inside `node_modules`.
100
+ */
101
+ export function launcherPath() {
102
+ return PATH.join(packageRoot(), 'shell-base');
103
+ }
104
+ /** This package's own root — the directory its `package.json` sits in. */
105
+ export function packageRoot() {
106
+ return PATH.resolve(PATH.dirname(fileURLToPath(import.meta.url)), '..');
107
+ }
108
+ /**
109
+ * The directory this package's runnable modules are in: `dist` once compiled,
110
+ * `src` when the source is being run directly under node's type stripping.
111
+ */
112
+ export function moduleDir() {
113
+ return PATH.basename(PATH.dirname(fileURLToPath(import.meta.url)));
114
+ }
115
+ function posix(dir, name) {
116
+ return `${dir.split(PATH.sep).join('/')}/${name}`;
117
+ }
118
+ //# sourceMappingURL=files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.js","sourceRoot":"","sources":["../src/files.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAuBzC;;;;;;GAMG;AACH,MAAM,UAAU,IAAI,CAAC,GAAW,EAAE,EAAE,OAAO,GAAG,CAAC,cAAc,CAAC,EAAE,GAAgB,EAAE,EAAE,MAAM,GAAG,EAAE;IAC3F,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,KAAK,MAAM,KAAK,IAAI,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;QAC/D,IAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC;YAAE,SAAS;QAC3C,MAAM,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;QACjE,IAAI,KAAK,CAAC,WAAW,EAAE;YAAE,GAAG,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC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,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;AAC5E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,SAAS;IACrB,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACvE,CAAC;AAED,SAAS,KAAK,CAAC,GAAW,EAAE,IAAY;IACpC,OAAO,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC;AACtD,CAAC"}
@@ -0,0 +1,10 @@
1
+ export { createBundle, signBundle, verifyBundle, verifyBundleSync, inspectBundle, runBundle, fileSigner, mountArgv, registerPath, type BuildResult, type CreateOptions, type SignOptions, type VerifyBundleOptions, type RunOptions, type RunResult, type Inspection, } from './api.ts';
2
+ export { bundle, rebundle, createArchive, keySigner, members, fromDirectory, fromArchive, type Member, type Signer, type Signature, type EmitResult, type BundleOptions, type RebundleOptions, } from './archive.ts';
3
+ export { AUTHORITY, buildManifest, parseManifest, parseSignature, formatSignature, signatureOf, verify, verifySync, STATES, type ArchiveSource, type ManifestFields, type SignatureMarker, type VerificationResult, type VerificationState, type VerifyOptions, } from './manifest.ts';
4
+ export { walk, moduleFiles, dependencyFiles, launcherPath, packageRoot, moduleDir, type WalkOptions, type ModuleFilesOptions, } from './files.ts';
5
+ export { prepare as prepareAudit, check as checkAudit, approve as approveAudit, verdictPath, type Verdict, type Finding, type AuditOptions, type Preparation, } from './audit.ts';
6
+ export { skills, skill, install as installSkill, DEFAULT_SKILLS_DIR, type SkillInfo, type InstallResult, } from './skill.ts';
7
+ export { main as cli, USAGE, type Console as CliConsole } from './cli.ts';
8
+ export * as sigstore from './sigstore.ts';
9
+ export * as oidc from './oidc.ts';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAeA,OAAO,EACH,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,SAAS,EACT,UAAU,EACV,SAAS,EACT,YAAY,EACZ,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACxB,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,UAAU,GAClB,MAAM,UAAU,CAAC;AAGlB,OAAO,EACH,MAAM,EACN,QAAQ,EACR,aAAa,EACb,SAAS,EACT,OAAO,EACP,aAAa,EACb,WAAW,EACX,KAAK,MAAM,EACX,KAAK,MAAM,EACX,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,eAAe,GACvB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACH,SAAS,EACT,aAAa,EACb,aAAa,EACb,cAAc,EACd,eAAe,EACf,WAAW,EACX,MAAM,EACN,UAAU,EACV,MAAM,EACN,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,aAAa,GACrB,MAAM,eAAe,CAAC;AAGvB,OAAO,EACH,IAAI,EACJ,WAAW,EACX,eAAe,EACf,YAAY,EACZ,WAAW,EACX,SAAS,EACT,KAAK,WAAW,EAChB,KAAK,kBAAkB,GAC1B,MAAM,YAAY,CAAC;AAIpB,OAAO,EACH,OAAO,IAAI,YAAY,EACvB,KAAK,IAAI,UAAU,EACnB,OAAO,IAAI,YAAY,EACvB,WAAW,EACX,KAAK,OAAO,EACZ,KAAK,OAAO,EACZ,KAAK,YAAY,EACjB,KAAK,WAAW,GACnB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACH,MAAM,EACN,KAAK,EACL,OAAO,IAAI,YAAY,EACvB,kBAAkB,EAClB,KAAK,SAAS,EACd,KAAK,aAAa,GACrB,MAAM,YAAY,CAAC;AAIpB,OAAO,EAAE,IAAI,IAAI,GAAG,EAAE,KAAK,EAAE,KAAK,OAAO,IAAI,UAAU,EAAE,MAAM,UAAU,CAAC;AAK1E,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,35 @@
1
+ // The package root: everything needed to build, sign, verify and run an archive
2
+ // from code, and nothing that needs a flag to import.
3
+ //
4
+ // The two VFS providers are deliberately *not* re-exported here. Importing
5
+ // either needs `node:vfs`, which only exists under `--experimental-vfs`, and
6
+ // creating or verifying an archive does not — so a plain `import
7
+ // '@pipobscure/bundle'` must not drag that requirement in. They have their own
8
+ // entry points:
9
+ //
10
+ // @pipobscure/bundle/provider the verifying provider, and register()
11
+ // @pipobscure/bundle/register a preload that registers it and nothing else
12
+ // @pipobscure/bundle/recorder the recording provider, and register()
13
+ // @pipobscure/bundle/record a preload that registers it and nothing else
14
+ // The high-level drive: create, sign, verify, inspect, run.
15
+ export { createBundle, signBundle, verifyBundle, verifyBundleSync, inspectBundle, runBundle, fileSigner, mountArgv, registerPath, } from './api.js';
16
+ // The archive layer, for callers assembling members themselves.
17
+ export { bundle, rebundle, createArchive, keySigner, members, fromDirectory, fromArchive, } from './archive.js';
18
+ // The format layer: the manifest, the signature marker, and verification.
19
+ export { AUTHORITY, buildManifest, parseManifest, parseSignature, formatSignature, signatureOf, verify, verifySync, STATES, } from './manifest.js';
20
+ // Working out what belongs in an archive, for what observing a run cannot see.
21
+ export { walk, moduleFiles, dependencyFiles, launcherPath, packageRoot, moduleDir, } from './files.js';
22
+ // The audit gate — step 3 of building a bundle, and the thing that makes it a
23
+ // step rather than a suggestion.
24
+ export { prepare as prepareAudit, check as checkAudit, approve as approveAudit, verdictPath, } from './audit.js';
25
+ // Installing the auditing skill into a project.
26
+ export { skills, skill, install as installSkill, DEFAULT_SKILLS_DIR, } from './skill.js';
27
+ // The CLI, as a function — so a host can offer the same commands without
28
+ // spawning anything.
29
+ export { main as cli, USAGE } from './cli.js';
30
+ // Signing through sigstore, and the OIDC flows that identity comes from. Both
31
+ // are namespaced: they are a signer implementation and its plumbing, not part
32
+ // of the archive format, and naming them that way keeps that visible.
33
+ export * as sigstore from './sigstore.js';
34
+ export * as oidc from './oidc.js';
35
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,sDAAsD;AACtD,EAAE;AACF,2EAA2E;AAC3E,6EAA6E;AAC7E,iEAAiE;AACjE,+EAA+E;AAC/E,gBAAgB;AAChB,EAAE;AACF,yEAAyE;AACzE,+EAA+E;AAC/E,yEAAyE;AACzE,+EAA+E;AAE/E,4DAA4D;AAC5D,OAAO,EACH,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,SAAS,EACT,UAAU,EACV,SAAS,EACT,YAAY,GAQf,MAAM,UAAU,CAAC;AAElB,gEAAgE;AAChE,OAAO,EACH,MAAM,EACN,QAAQ,EACR,aAAa,EACb,SAAS,EACT,OAAO,EACP,aAAa,EACb,WAAW,GAOd,MAAM,cAAc,CAAC;AAEtB,0EAA0E;AAC1E,OAAO,EACH,SAAS,EACT,aAAa,EACb,aAAa,EACb,cAAc,EACd,eAAe,EACf,WAAW,EACX,MAAM,EACN,UAAU,EACV,MAAM,GAOT,MAAM,eAAe,CAAC;AAEvB,+EAA+E;AAC/E,OAAO,EACH,IAAI,EACJ,WAAW,EACX,eAAe,EACf,YAAY,EACZ,WAAW,EACX,SAAS,GAGZ,MAAM,YAAY,CAAC;AAEpB,8EAA8E;AAC9E,iCAAiC;AACjC,OAAO,EACH,OAAO,IAAI,YAAY,EACvB,KAAK,IAAI,UAAU,EACnB,OAAO,IAAI,YAAY,EACvB,WAAW,GAKd,MAAM,YAAY,CAAC;AAEpB,gDAAgD;AAChD,OAAO,EACH,MAAM,EACN,KAAK,EACL,OAAO,IAAI,YAAY,EACvB,kBAAkB,GAGrB,MAAM,YAAY,CAAC;AAEpB,yEAAyE;AACzE,qBAAqB;AACrB,OAAO,EAAE,IAAI,IAAI,GAAG,EAAE,KAAK,EAA8B,MAAM,UAAU,CAAC;AAE1E,8EAA8E;AAC9E,8EAA8E;AAC9E,sEAAsE;AACtE,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC"}
@@ -0,0 +1,97 @@
1
+ import * as VFS from 'node:vfs';
2
+ import { type VerificationResult } from './manifest.ts';
3
+ /** What a caller can decide about a container before it is allowed to run. */
4
+ export interface LaunchOptions {
5
+ /** Extra trusted roots, as PEM text or paths to PEM files. */
6
+ roots?: string[] | undefined;
7
+ /** Require this sigstore signing identity. */
8
+ identity?: string | undefined;
9
+ /** Require this sigstore OIDC issuer. */
10
+ issuer?: string | undefined;
11
+ /** Path to the sigstore trust root to check against. */
12
+ trustedRoot?: string | undefined;
13
+ /**
14
+ * Run a container whose signature is good but whose chain is not anchored
15
+ * in the trust store (default: false).
16
+ */
17
+ allowUntrusted?: boolean | undefined;
18
+ /**
19
+ * Recompute every member digest at mount rather than on first read
20
+ * (default: false — reads check them anyway, and this is startup latency).
21
+ */
22
+ deep?: boolean | undefined;
23
+ /** Entry point inside the archive, overriding its package.json `main`. */
24
+ entry?: string | undefined;
25
+ /**
26
+ * What to do when the container does not verify. The default prints the
27
+ * reason and exits 1; nothing from the archive has run at that point.
28
+ */
29
+ onRefuse?: ((reason: string) => void) | undefined;
30
+ }
31
+ /** Where a mounted container ended up, and what it is. */
32
+ export interface Mounted {
33
+ /** The generated mount point the archive is visible at. */
34
+ root: string;
35
+ /** The mount, so a caller can unmount it. */
36
+ vfs: VFS.VirtualFileSystem;
37
+ /** The resolved entry point, as an absolute path under `root`. */
38
+ entry: string;
39
+ }
40
+ /**
41
+ * Verify `container` and mount it. Returns where it landed; nothing has been
42
+ * executed out of it yet.
43
+ */
44
+ export declare function mount(container: string, options?: LaunchOptions): Mounted;
45
+ /**
46
+ * Run what is at a mount's entry point. A CommonJS entry is `require()`d and an
47
+ * ES module is `import()`ed, chosen the way node itself chooses — the archive's
48
+ * `package.json` `type` and the entry's own extension.
49
+ */
50
+ export declare function start({ root, entry }: Mounted): Promise<void>;
51
+ /** Verify a container, mount it, and run the application inside. */
52
+ export declare function run(container: string, options?: LaunchOptions): Promise<void>;
53
+ /**
54
+ * Verify the running executable and run the archive appended to it — the
55
+ * self-validating shape, where the signature covers the runtime, the verifier
56
+ * and the application as one file.
57
+ */
58
+ export declare function runSelf(options?: LaunchOptions): Promise<void>;
59
+ /** Verify a container without mounting or running it. */
60
+ export declare function verify(container: string, options?: LaunchOptions): VerificationResult;
61
+ /**
62
+ * What, if anything, is appended to a container.
63
+ *
64
+ * This is how one binary can be both shapes: an executable with a signed
65
+ * archive behind it runs *that*, and the same executable with nothing appended
66
+ * takes an archive from its command line instead. The discriminator is the
67
+ * signature marker rather than the presence of a ZIP, because a SEA carries an
68
+ * archive of its own inside its blob — one that is not at the tail, and never
69
+ * carries a marker.
70
+ */
71
+ export declare function appended(container: string): 'signed' | 'unsigned' | 'none';
72
+ /**
73
+ * The command line of a verifying node.
74
+ *
75
+ * Options are read up to the first non-option argument, which is the archive;
76
+ * everything after it belongs to the application, untouched. That is the shape
77
+ * of every command that wraps another one — `env`, `nice`, `time` — and it is
78
+ * what lets an application have flags of its own that collide with these.
79
+ */
80
+ export declare const USAGE = "usage: <runtime> [options] <archive> [args...]\n\nVerifies an archive and runs the application inside it. Nothing from the archive\nruns until its signature, its certificate chain and its member digests check out,\nand every member is re-hashed as it is read for the life of the process.\n\noptions:\n -r, --root <file> extra trusted root certificate (PEM); repeatable\n --identity <san> require this sigstore signing identity\n --issuer <url> require this sigstore OIDC issuer\n --untrusted run an archive whose signature is good but unanchored\n --deep check every member digest at mount, not on first read\n --entry <path> entry point inside the archive, overriding its main\n --verify report the archive's trust state and stop\n -h, --help this\n --version the verifier's version, and the runtime's\n\nThe same policy can come from the environment \u2014 BUNDLE_ROOTS, BUNDLE_IDENTITY,\nBUNDLE_ISSUER, BUNDLE_SIGSTORE_ROOT, BUNDLE_ALLOW_UNTRUSTED \u2014 which is what a\ncontainer built with no policy of its own falls back to.\n";
81
+ /** Options baked into a runtime at build time, and whether they are the last word. */
82
+ export interface Baked extends LaunchOptions {
83
+ /**
84
+ * A runtime built with a policy of its own accepts no policy from its
85
+ * command line: a binary that demands a signing identity is not one whose
86
+ * user can ask it to stop. Adding a root, requiring a different identity
87
+ * and `--untrusted` are all refused. What remains — `--entry`, `--verify`,
88
+ * `--help` — cannot loosen anything.
89
+ */
90
+ sealed?: boolean | undefined;
91
+ }
92
+ /**
93
+ * Run a verifying node's command line. Returns the exit code; the application's
94
+ * own exit code is its business, set the ordinary way from inside it.
95
+ */
96
+ export declare function main(argv: string[], baked?: Baked): Promise<number>;
97
+ //# sourceMappingURL=launch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"launch.d.ts","sourceRoot":"","sources":["../src/launch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAOhC,OAAO,EAAoC,KAAK,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAuB1F,8EAA8E;AAC9E,MAAM,WAAW,aAAa;IAC1B,8DAA8D;IAC9D,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAC7B,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,yCAAyC;IACzC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,wDAAwD;IACxD,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACrC;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,GAAG,SAAS,CAAC;CAChC;AAED;;;GAGG;AACH,wBAAsB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,GAAE,KAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CA2F7E"}
package/dist/launch.js ADDED
@@ -0,0 +1,267 @@
1
+ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
2
+ if (typeof path === "string" && /^\.\.?\//.test(path)) {
3
+ return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
4
+ return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
5
+ });
6
+ }
7
+ return path;
8
+ };
9
+ import * as VFS from 'node:vfs';
10
+ import * as FS from 'node:fs';
11
+ import * as PATH from 'node:path';
12
+ import * as ZLIB from 'node:zlib';
13
+ import { createRequire } from 'node:module';
14
+ import { pathToFileURL } from 'node:url';
15
+ import { open as openBundle } from './provider.js';
16
+ import { message, signatureOf, verifySync } from './manifest.js';
17
+ /**
18
+ * Verify `container` and mount it. Returns where it landed; nothing has been
19
+ * executed out of it yet.
20
+ */
21
+ export function mount(container, options = {}) {
22
+ const settings = {
23
+ roots: options.roots,
24
+ identity: options.identity,
25
+ issuer: options.issuer,
26
+ trustedRoot: options.trustedRoot,
27
+ allowUntrusted: options.allowUntrusted,
28
+ deep: options.deep,
29
+ name: 'bundle-launch',
30
+ };
31
+ let provider;
32
+ try {
33
+ provider = openBundle(container, settings);
34
+ }
35
+ catch (err) {
36
+ refuse(options, message(err));
37
+ }
38
+ const vfs = VFS.create(provider, { emitExperimentalWarning: false });
39
+ const root = vfs.mount();
40
+ return { root, vfs, entry: entryPoint(root, options.entry) };
41
+ }
42
+ /**
43
+ * Run what is at a mount's entry point. A CommonJS entry is `require()`d and an
44
+ * ES module is `import()`ed, chosen the way node itself chooses — the archive's
45
+ * `package.json` `type` and the entry's own extension.
46
+ */
47
+ export async function start({ root, entry }) {
48
+ if (isModule(root, entry))
49
+ await import(__rewriteRelativeImportExtension(pathToFileURL(entry).href));
50
+ else
51
+ createRequire(PATH.join(root, 'package.json'))(entry);
52
+ }
53
+ /** Verify a container, mount it, and run the application inside. */
54
+ export async function run(container, options = {}) {
55
+ await start(mount(container, options));
56
+ }
57
+ /**
58
+ * Verify the running executable and run the archive appended to it — the
59
+ * self-validating shape, where the signature covers the runtime, the verifier
60
+ * and the application as one file.
61
+ */
62
+ export async function runSelf(options = {}) {
63
+ await run(process.execPath, options);
64
+ }
65
+ /** Verify a container without mounting or running it. */
66
+ export function verify(container, options = {}) {
67
+ const roots = (options.roots ?? []).map((root) => (root.includes('-----BEGIN') ? root : FS.readFileSync(root, 'utf-8')));
68
+ return verifySync(container, {
69
+ extraRoots: roots, deep: options.deep ?? false,
70
+ identity: options.identity, issuer: options.issuer, trustedRoot: options.trustedRoot,
71
+ });
72
+ }
73
+ /**
74
+ * What, if anything, is appended to a container.
75
+ *
76
+ * This is how one binary can be both shapes: an executable with a signed
77
+ * archive behind it runs *that*, and the same executable with nothing appended
78
+ * takes an archive from its command line instead. The discriminator is the
79
+ * signature marker rather than the presence of a ZIP, because a SEA carries an
80
+ * archive of its own inside its blob — one that is not at the tail, and never
81
+ * carries a marker.
82
+ */
83
+ export function appended(container) {
84
+ if (signatureOf(container) !== null)
85
+ return 'signed';
86
+ try {
87
+ // An archive at the tail with no marker is the one case worth naming:
88
+ // somebody appended an application and never signed it.
89
+ ZLIB.ZipFile.openSync(container).closeSync();
90
+ return 'unsigned';
91
+ }
92
+ catch {
93
+ return 'none';
94
+ }
95
+ }
96
+ // --------------------------------------------------------- the command line ---
97
+ /**
98
+ * The command line of a verifying node.
99
+ *
100
+ * Options are read up to the first non-option argument, which is the archive;
101
+ * everything after it belongs to the application, untouched. That is the shape
102
+ * of every command that wraps another one — `env`, `nice`, `time` — and it is
103
+ * what lets an application have flags of its own that collide with these.
104
+ */
105
+ export const USAGE = `usage: <runtime> [options] <archive> [args...]
106
+
107
+ Verifies an archive and runs the application inside it. Nothing from the archive
108
+ runs until its signature, its certificate chain and its member digests check out,
109
+ and every member is re-hashed as it is read for the life of the process.
110
+
111
+ options:
112
+ -r, --root <file> extra trusted root certificate (PEM); repeatable
113
+ --identity <san> require this sigstore signing identity
114
+ --issuer <url> require this sigstore OIDC issuer
115
+ --untrusted run an archive whose signature is good but unanchored
116
+ --deep check every member digest at mount, not on first read
117
+ --entry <path> entry point inside the archive, overriding its main
118
+ --verify report the archive's trust state and stop
119
+ -h, --help this
120
+ --version the verifier's version, and the runtime's
121
+
122
+ The same policy can come from the environment — BUNDLE_ROOTS, BUNDLE_IDENTITY,
123
+ BUNDLE_ISSUER, BUNDLE_SIGSTORE_ROOT, BUNDLE_ALLOW_UNTRUSTED — which is what a
124
+ container built with no policy of its own falls back to.
125
+ `;
126
+ /**
127
+ * Run a verifying node's command line. Returns the exit code; the application's
128
+ * own exit code is its business, set the ordinary way from inside it.
129
+ */
130
+ export async function main(argv, baked = {}) {
131
+ const flags = { roots: [...(baked.roots ?? [])] };
132
+ let verifyOnly = false;
133
+ let i = 0;
134
+ const sealedRefusal = (flag) => {
135
+ process.stderr.write(`${flag} is not accepted: this runtime was built with a policy of its own\n`);
136
+ return 64;
137
+ };
138
+ for (; i < argv.length; i++) {
139
+ const arg = argv[i];
140
+ if (arg === '--') {
141
+ i++;
142
+ break;
143
+ }
144
+ if (!arg.startsWith('-') || arg === '-')
145
+ break;
146
+ // `--flag=value` and `--flag value` both, because both are written.
147
+ const eq = arg.indexOf('=');
148
+ const name = eq === -1 ? arg : arg.slice(0, eq);
149
+ const inline = eq === -1 ? undefined : arg.slice(eq + 1);
150
+ const value = () => {
151
+ const next = inline ?? argv[++i];
152
+ if (next === undefined)
153
+ throw new Error(`${name} needs a value`);
154
+ return next;
155
+ };
156
+ switch (name) {
157
+ case '-h':
158
+ case '--help':
159
+ process.stdout.write(USAGE);
160
+ return 0;
161
+ case '--version':
162
+ process.stdout.write(`${version()} (node ${process.versions.node})\n`);
163
+ return 0;
164
+ case '--verify':
165
+ verifyOnly = true;
166
+ break;
167
+ case '--deep':
168
+ flags.deep = true;
169
+ break;
170
+ case '--entry':
171
+ flags.entry = value();
172
+ break;
173
+ case '-r':
174
+ case '--root':
175
+ if (baked.sealed)
176
+ return sealedRefusal(name);
177
+ flags.roots.push(value());
178
+ break;
179
+ case '--identity':
180
+ if (baked.sealed)
181
+ return sealedRefusal(name);
182
+ flags.identity = value();
183
+ break;
184
+ case '--issuer':
185
+ if (baked.sealed)
186
+ return sealedRefusal(name);
187
+ flags.issuer = value();
188
+ break;
189
+ case '--untrusted':
190
+ if (baked.sealed)
191
+ return sealedRefusal(name);
192
+ flags.allowUntrusted = true;
193
+ break;
194
+ default:
195
+ process.stderr.write(`unknown option ${name}\n\n${USAGE}`);
196
+ return 64;
197
+ }
198
+ }
199
+ const archive = argv[i];
200
+ if (archive === undefined) {
201
+ process.stderr.write(`no archive to run\n\n${USAGE}`);
202
+ return 64;
203
+ }
204
+ const options = {
205
+ ...baked,
206
+ ...flags,
207
+ roots: flags.roots.length > 0 ? flags.roots : undefined,
208
+ };
209
+ const container = PATH.resolve(archive);
210
+ if (verifyOnly) {
211
+ const result = verify(container, options);
212
+ process.stdout.write(`${result.state.toUpperCase()} — ${result.reason}\n`);
213
+ if (result.identity)
214
+ process.stdout.write(` identity: ${result.identity}\n`);
215
+ return result.state === 'valid' ? 0 : 1;
216
+ }
217
+ // The application sees the argv it would have had from `--vfs-load`: the
218
+ // archive's own path where a script path goes, and its arguments from
219
+ // index 2 on. The runtime's own options are gone by then — they were the
220
+ // runtime's, not the program's.
221
+ process.argv = [process.argv[0], container, ...argv.slice(i + 1)];
222
+ await run(container, options);
223
+ return 0;
224
+ }
225
+ /** This package's version, read out of the mount the verifier is running from. */
226
+ function version() {
227
+ try {
228
+ const manifest = JSON.parse(FS.readFileSync(PATH.join(import.meta.dirname, '..', 'package.json'), 'utf-8'));
229
+ return `${manifest.name ?? 'bundle'} ${manifest.version ?? '0.0.0'}`;
230
+ }
231
+ catch {
232
+ return 'bundle';
233
+ }
234
+ }
235
+ // ------------------------------------------------------------------ details ---
236
+ // The archive's entry point: an explicit override, else its package.json
237
+ // `main`, else `index.js` — node's own order for a directory.
238
+ function entryPoint(root, override) {
239
+ if (override)
240
+ return PATH.resolve(root, override);
241
+ const manifest = readPackage(root);
242
+ return PATH.resolve(root, typeof manifest['main'] === 'string' ? manifest['main'] : 'index.js');
243
+ }
244
+ function isModule(root, entry) {
245
+ if (entry.endsWith('.mjs'))
246
+ return true;
247
+ if (entry.endsWith('.cjs'))
248
+ return false;
249
+ return readPackage(root)['type'] === 'module';
250
+ }
251
+ function readPackage(root) {
252
+ try {
253
+ return JSON.parse(FS.readFileSync(PATH.join(root, 'package.json'), 'utf-8'));
254
+ }
255
+ catch {
256
+ return {};
257
+ }
258
+ }
259
+ function refuse(options, reason) {
260
+ if (options.onRefuse) {
261
+ options.onRefuse(reason);
262
+ throw new Error(reason);
263
+ }
264
+ process.stderr.write(`refusing to run: ${reason}\n`);
265
+ process.exit(1);
266
+ }
267
+ //# sourceMappingURL=launch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"launch.js","sourceRoot":"","sources":["../src/launch.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,IAAI,IAAI,UAAU,EAAwB,MAAM,eAAe,CAAC;AACzE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAA2B,MAAM,eAAe,C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M,CAAC;QAAE,OAAO,IAAI,CAAC;IACxC,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,KAAK,CAAC;IACzC,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,QAAQ,CAAC;AAClD,CAAC;AAED,SAAS,WAAW,CAAC,IAAY;IAC7B,IAAI,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,EAAE,OAAO,CAAC,CAA4B,CAAC;IAC5G,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,EAAE,CAAC;IACd,CAAC;AACL,CAAC;AAED,SAAS,MAAM,CAAC,OAAsB,EAAE,MAAc;IAClD,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QACnB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC;IACD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,oBAAoB,MAAM,IAAI,CAAC,CAAC;IACrD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC"}
package/dist/main.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=main.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":""}
package/dist/main.js ADDED
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env node
2
+ import { main } from './cli.js';
3
+ // The executable entry point, in every launch mode this tool has:
4
+ //
5
+ // * `bundle …` / `node dist/main.js …` — an ordinary CLI.
6
+ // * `--vfs-load=<archive>` — node runs the mounted package's
7
+ // `main`, which is this file, out of the archive.
8
+ // * the SEA container, whose bootstrap mounts its own tail and then requires
9
+ // the package inside it, landing here.
10
+ //
11
+ // In all three, `process.argv` is [runtime, entry, ...userArgs], so the user's
12
+ // arguments always start at index 2.
13
+ //
14
+ // Nothing but argv handling lives here. `cli.ts` returns an exit code rather
15
+ // than exiting, so it stays callable in-process — by a test, or by a host that
16
+ // wants the commands without a subprocess — and the one place that turns a code
17
+ // into an exit is this file.
18
+ process.exitCode = await main(process.argv.slice(2));
19
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,kEAAkE;AAClE,EAAE;AACF,4DAA4D;AAC5D,+DAA+D;AAC/D,sDAAsD;AACtD,+EAA+E;AAC/E,2CAA2C;AAC3C,EAAE;AACF,+EAA+E;AAC/E,qCAAqC;AACrC,EAAE;AACF,6EAA6E;AAC7E,+EAA+E;AAC/E,gFAAgF;AAChF,6BAA6B;AAE7B,OAAO,CAAC,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC"}