@landstrip/landstrip-api
v0.22.9
Published
TypeScript APIs for the Landstrip sandbox
Readme
@landstrip/landstrip-api
TypeScript APIs for Landstrip. Requires Node.js ≥18 and depends on
@landstrip/landstrip to install the executable
for Linux, macOS, and Windows (x64/arm64).
Install
npm install --save-dev @landstrip/landstrip-apiUsage
npx landstrip run -p policy.json -- cargo test
npx landstrip check -p policy.json
npx landstrip doctorSee usage for a policy example and landstrip(1) for policy rules and platform limits.
Node.js API
const { execFileSync } = require('node:child_process');
const { binaryPath } = require('@landstrip/landstrip-api');
execFileSync(
binaryPath(),
['run', '-p', 'policy.json', '--', 'cargo', 'test'],
{ stdio: 'inherit' },
);| Subpath | Declarations | Highlights |
| ---------- | ------------------------------------ | ------------------------------------------------------------------------------------------- |
| . | lib/index.d.ts | binaryPath, packageName, LandstripPolicy, LandstripTrap, LandstripControlResponse |
| ./proxy | lib/proxy.d.ts | startFilterProxy, createProxyCredentials, createProxyUrl, createProxyEnvironment |
| ./shared | lib/shared.d.ts | Policy builders, config parser/merger, path/domain evaluators, trap and Seatbelt codecs |
binaryPath(platform?, arch?)resolves an official installed binary or throws;packageName(platform?, arch?)returns its package name.startFilterProxygates proxied domains and supportsallowedMethods, host-scopedheaderRules(replaceTokens,upgradeHttps), and loopbackupstreamsgateways so guests never need raw upstream credentials.writeLandstripPolicyFile(policy, prefix?)writes a temporary policy file and returns{ dir, path }. RemovedirwithrmSync(dir, { recursive: true, force: true })after use; failed cleanup reports both errors anddirin anAggregateError.parseSandboxConfiganddeepMergeSandboxConfigvalidate and mergeSandboxConfigFilelayers, includingmacos.logTag(forwarded bybuildLandstripPolicy) andlinux.backend('auto' | 'container' | 'machine', passed as--backendtolandstrip run).decodeLandstripTrap,parseTrapStanza,serializeTrapStanza,isQueryTrap, andcontrolResponseStanza(queryId, action)handle--trapstanzas; missing or unknown denial states normalize to'info'.
See landstrip(1) for --trap transport,
macos.logTag constraints, and platform enforcement details.
Development
Run make ci from the repository root.
License
Apache-2.0; native binaries installed through @landstrip/landstrip
are LGPL-2.1-or-later.
