@orygn/opa-mcp 0.1.8 → 0.1.10
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.
- package/CHANGELOG.md +96 -1
- package/README.md +83 -34
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +1 -0
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +4 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +4 -0
- package/dist/config.js.map +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +1 -1
- package/dist/constants.js.map +1 -1
- package/dist/lib/conftest-cli.d.ts +144 -0
- package/dist/lib/conftest-cli.d.ts.map +1 -0
- package/dist/lib/conftest-cli.js +224 -0
- package/dist/lib/conftest-cli.js.map +1 -0
- package/dist/lib/opa-cli.d.ts +17 -17
- package/dist/lib/opa-cli.d.ts.map +1 -1
- package/dist/lib/opa-cli.js +37 -35
- package/dist/lib/opa-cli.js.map +1 -1
- package/dist/lib/opa-client.d.ts +5 -0
- package/dist/lib/opa-client.d.ts.map +1 -1
- package/dist/lib/opa-client.js +12 -1
- package/dist/lib/opa-client.js.map +1 -1
- package/dist/lib/regal-cli.d.ts +4 -4
- package/dist/lib/regal-cli.d.ts.map +1 -1
- package/dist/lib/regal-cli.js +10 -8
- package/dist/lib/regal-cli.js.map +1 -1
- package/dist/lib/subprocess.d.ts +4 -0
- package/dist/lib/subprocess.d.ts.map +1 -1
- package/dist/lib/subprocess.js +24 -3
- package/dist/lib/subprocess.js.map +1 -1
- package/dist/lib/tool-helpers.d.ts +14 -1
- package/dist/lib/tool-helpers.d.ts.map +1 -1
- package/dist/lib/tool-helpers.js +36 -2
- package/dist/lib/tool-helpers.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +15 -4
- package/dist/server.js.map +1 -1
- package/dist/tools/authoring/capabilities.d.ts.map +1 -1
- package/dist/tools/authoring/capabilities.js +8 -2
- package/dist/tools/authoring/capabilities.js.map +1 -1
- package/dist/tools/authoring/check.d.ts.map +1 -1
- package/dist/tools/authoring/check.js +16 -4
- package/dist/tools/authoring/check.js.map +1 -1
- package/dist/tools/authoring/deps.d.ts.map +1 -1
- package/dist/tools/authoring/deps.js +8 -2
- package/dist/tools/authoring/deps.js.map +1 -1
- package/dist/tools/authoring/format.d.ts.map +1 -1
- package/dist/tools/authoring/format.js +8 -2
- package/dist/tools/authoring/format.js.map +1 -1
- package/dist/tools/authoring/inspect.d.ts.map +1 -1
- package/dist/tools/authoring/inspect.js +8 -2
- package/dist/tools/authoring/inspect.js.map +1 -1
- package/dist/tools/authoring/lint.d.ts.map +1 -1
- package/dist/tools/authoring/lint.js +11 -12
- package/dist/tools/authoring/lint.js.map +1 -1
- package/dist/tools/authoring/migrate-v1.d.ts.map +1 -1
- package/dist/tools/authoring/migrate-v1.js +15 -5
- package/dist/tools/authoring/migrate-v1.js.map +1 -1
- package/dist/tools/authoring/parse.d.ts.map +1 -1
- package/dist/tools/authoring/parse.js +8 -2
- package/dist/tools/authoring/parse.js.map +1 -1
- package/dist/tools/bundles/build.d.ts.map +1 -1
- package/dist/tools/bundles/build.js +8 -2
- package/dist/tools/bundles/build.js.map +1 -1
- package/dist/tools/bundles/sign.d.ts.map +1 -1
- package/dist/tools/bundles/sign.js +8 -2
- package/dist/tools/bundles/sign.js.map +1 -1
- package/dist/tools/bundles/verify.d.ts.map +1 -1
- package/dist/tools/bundles/verify.js +8 -2
- package/dist/tools/bundles/verify.js.map +1 -1
- package/dist/tools/conftest/index.d.ts +4 -0
- package/dist/tools/conftest/index.d.ts.map +1 -0
- package/dist/tools/conftest/index.js +11 -0
- package/dist/tools/conftest/index.js.map +1 -0
- package/dist/tools/conftest/pull.d.ts +10 -0
- package/dist/tools/conftest/pull.d.ts.map +1 -0
- package/dist/tools/conftest/pull.js +83 -0
- package/dist/tools/conftest/pull.js.map +1 -0
- package/dist/tools/conftest/push.d.ts +10 -0
- package/dist/tools/conftest/push.d.ts.map +1 -0
- package/dist/tools/conftest/push.js +76 -0
- package/dist/tools/conftest/push.js.map +1 -0
- package/dist/tools/conftest/test.d.ts +21 -0
- package/dist/tools/conftest/test.d.ts.map +1 -0
- package/dist/tools/conftest/test.js +186 -0
- package/dist/tools/conftest/test.js.map +1 -0
- package/dist/tools/conftest/verify.d.ts +21 -0
- package/dist/tools/conftest/verify.d.ts.map +1 -0
- package/dist/tools/conftest/verify.js +112 -0
- package/dist/tools/conftest/verify.js.map +1 -0
- package/dist/tools/evaluation/_shared.d.ts +1 -1
- package/dist/tools/evaluation/_shared.d.ts.map +1 -1
- package/dist/tools/evaluation/_shared.js +2 -2
- package/dist/tools/evaluation/_shared.js.map +1 -1
- package/dist/tools/evaluation/bench.d.ts.map +1 -1
- package/dist/tools/evaluation/bench.js +8 -2
- package/dist/tools/evaluation/bench.js.map +1 -1
- package/dist/tools/evaluation/compile.d.ts.map +1 -1
- package/dist/tools/evaluation/compile.js +8 -2
- package/dist/tools/evaluation/compile.js.map +1 -1
- package/dist/tools/evaluation/eval.d.ts.map +1 -1
- package/dist/tools/evaluation/eval.js +32 -8
- package/dist/tools/evaluation/eval.js.map +1 -1
- package/dist/tools/evaluation/exec.d.ts.map +1 -1
- package/dist/tools/evaluation/exec.js +8 -2
- package/dist/tools/evaluation/exec.js.map +1 -1
- package/dist/tools/evaluation/test.d.ts.map +1 -1
- package/dist/tools/evaluation/test.js +8 -2
- package/dist/tools/evaluation/test.js.map +1 -1
- package/dist/tools/helpers/coverage-gaps.d.ts.map +1 -1
- package/dist/tools/helpers/coverage-gaps.js +8 -2
- package/dist/tools/helpers/coverage-gaps.js.map +1 -1
- package/dist/tools/helpers/describe-policy.d.ts.map +1 -1
- package/dist/tools/helpers/describe-policy.js +8 -2
- package/dist/tools/helpers/describe-policy.js.map +1 -1
- package/dist/tools/helpers/explain-decision.d.ts.map +1 -1
- package/dist/tools/helpers/explain-decision.js +8 -2
- package/dist/tools/helpers/explain-decision.js.map +1 -1
- package/dist/tools/helpers/fix.d.ts.map +1 -1
- package/dist/tools/helpers/fix.js +8 -2
- package/dist/tools/helpers/fix.js.map +1 -1
- package/dist/tools/helpers/format-write.d.ts.map +1 -1
- package/dist/tools/helpers/format-write.js +9 -3
- package/dist/tools/helpers/format-write.js.map +1 -1
- package/dist/tools/helpers/generate-test-skeleton.d.ts.map +1 -1
- package/dist/tools/helpers/generate-test-skeleton.js +8 -2
- package/dist/tools/helpers/generate-test-skeleton.js.map +1 -1
- package/dist/tools/helpers/infer-input-schema.d.ts.map +1 -1
- package/dist/tools/helpers/infer-input-schema.js +9 -3
- package/dist/tools/helpers/infer-input-schema.js.map +1 -1
- package/dist/tools/helpers/policy-diff.d.ts.map +1 -1
- package/dist/tools/helpers/policy-diff.js +11 -2
- package/dist/tools/helpers/policy-diff.js.map +1 -1
- package/dist/tools/helpers/security-audit.d.ts.map +1 -1
- package/dist/tools/helpers/security-audit.js +8 -2
- package/dist/tools/helpers/security-audit.js.map +1 -1
- package/dist/tools/helpers/suggest-fix.d.ts.map +1 -1
- package/dist/tools/helpers/suggest-fix.js +6 -0
- package/dist/tools/helpers/suggest-fix.js.map +1 -1
- package/dist/tools/index.d.ts +11 -9
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +2 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/meta/server-info.d.ts.map +1 -1
- package/dist/tools/meta/server-info.js +9 -3
- package/dist/tools/meta/server-info.js.map +1 -1
- package/dist/tools/server-management/_shared.d.ts.map +1 -1
- package/dist/tools/server-management/_shared.js +4 -1
- package/dist/tools/server-management/_shared.js.map +1 -1
- package/dist/tools/server-management/data.d.ts.map +1 -1
- package/dist/tools/server-management/data.js +32 -4
- package/dist/tools/server-management/data.js.map +1 -1
- package/dist/tools/server-management/decisions.d.ts.map +1 -1
- package/dist/tools/server-management/decisions.js +16 -2
- package/dist/tools/server-management/decisions.js.map +1 -1
- package/dist/tools/server-management/policies.d.ts.map +1 -1
- package/dist/tools/server-management/policies.js +32 -4
- package/dist/tools/server-management/policies.js.map +1 -1
- package/dist/tools/server-management/status.d.ts.map +1 -1
- package/dist/tools/server-management/status.js +24 -4
- package/dist/tools/server-management/status.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wrapper around the optional `conftest` binary (policy testing for
|
|
3
|
+
* configuration files using Rego).
|
|
4
|
+
*
|
|
5
|
+
* Conftest is OPTIONAL -- only the `conftest_*` tools require it. All
|
|
6
|
+
* other tools work without Conftest installed. If absent, conftest tools
|
|
7
|
+
* return a structured `CONFTEST_NOT_FOUND` error with an install hint.
|
|
8
|
+
*
|
|
9
|
+
* Conftest exit codes:
|
|
10
|
+
* 0 -- all tests pass (or no failures, only warnings)
|
|
11
|
+
* 1 -- one or more test failures
|
|
12
|
+
* 2+ -- command error (bad args, policy not found, parse error, etc.)
|
|
13
|
+
*
|
|
14
|
+
* All structured output is obtained via `--output=json`; raw text output
|
|
15
|
+
* is never parsed.
|
|
16
|
+
*/
|
|
17
|
+
import { mkdtemp, rm, writeFile } from 'node:fs/promises';
|
|
18
|
+
import { tmpdir } from 'node:os';
|
|
19
|
+
import { join } from 'node:path';
|
|
20
|
+
import { runBinary } from './subprocess.js';
|
|
21
|
+
// ─── Parser → file extension map ─────────────────────────────────────────────
|
|
22
|
+
const PARSER_TO_EXT = {
|
|
23
|
+
yaml: '.yaml',
|
|
24
|
+
json: '.json',
|
|
25
|
+
toml: '.toml',
|
|
26
|
+
hcl1: '.hcl',
|
|
27
|
+
hcl2: '.hcl',
|
|
28
|
+
ini: '.ini',
|
|
29
|
+
xml: '.xml',
|
|
30
|
+
dotenv: '.env',
|
|
31
|
+
cue: '.cue',
|
|
32
|
+
jsonnet: '.jsonnet',
|
|
33
|
+
properties: '.properties',
|
|
34
|
+
edn: '.edn',
|
|
35
|
+
hocon: '.conf',
|
|
36
|
+
// Dockerfile is a special case -- conftest detects by filename
|
|
37
|
+
dockerfile: '',
|
|
38
|
+
};
|
|
39
|
+
function parserToExt(parser) {
|
|
40
|
+
return PARSER_TO_EXT[parser.toLowerCase()] ?? `.${parser.toLowerCase()}`;
|
|
41
|
+
}
|
|
42
|
+
// ─── ConftestCli ──────────────────────────────────────────────────────────────
|
|
43
|
+
/**
|
|
44
|
+
* Wrapper around the local `conftest` binary.
|
|
45
|
+
*
|
|
46
|
+
* Methods do not throw on conftest-side errors -- the exit code on the
|
|
47
|
+
* returned `SpawnResult` is the signal. Inline source is written to temp
|
|
48
|
+
* files/directories because conftest does not read from stdin.
|
|
49
|
+
*/
|
|
50
|
+
export class ConftestCli {
|
|
51
|
+
config;
|
|
52
|
+
constructor(config) {
|
|
53
|
+
this.config = config;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Verify the binary is present and return its version string. Returns
|
|
57
|
+
* null if the binary is unreachable or the version output is malformed.
|
|
58
|
+
*/
|
|
59
|
+
async version(signal) {
|
|
60
|
+
const result = await this.run(['--version'], signal);
|
|
61
|
+
if (result.exitCode !== 0)
|
|
62
|
+
return null;
|
|
63
|
+
// conftest --version output: "conftest (version: 0.68.2)"
|
|
64
|
+
const match = /conftest\s*\(version:\s*([^)]+)\)/i.exec(result.stdout) ??
|
|
65
|
+
/v?(\d+\.\d+\.\d+\S*)/i.exec(result.stdout);
|
|
66
|
+
return match?.[1]?.trim() ?? null;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Run `conftest test` against one or more configuration files. Always
|
|
70
|
+
* uses `--output=json` so output is machine-readable.
|
|
71
|
+
*
|
|
72
|
+
* When `inlineConfig` or `inlinePolicy` are provided, temp files are
|
|
73
|
+
* created and cleaned up automatically. Temp file paths in the JSON
|
|
74
|
+
* output are replaced with `<inline>` before the result is returned so
|
|
75
|
+
* callers never see implementation-internal paths.
|
|
76
|
+
*/
|
|
77
|
+
async test(input, signal) {
|
|
78
|
+
return this.withTempAssets({
|
|
79
|
+
inlineConfig: input.inlineConfig,
|
|
80
|
+
inlineConfigParser: input.inlineConfigParser,
|
|
81
|
+
inlinePolicy: input.inlinePolicy,
|
|
82
|
+
}, async ({ configPath, policyDir }) => {
|
|
83
|
+
const args = ['test', '--output=json', '--no-color'];
|
|
84
|
+
// Policy source
|
|
85
|
+
const effectivePolicyDir = policyDir ?? input.policy;
|
|
86
|
+
if (effectivePolicyDir)
|
|
87
|
+
args.push('--policy', effectivePolicyDir);
|
|
88
|
+
// Namespace
|
|
89
|
+
if (input.allNamespaces) {
|
|
90
|
+
args.push('--all-namespaces');
|
|
91
|
+
}
|
|
92
|
+
else if (input.namespace) {
|
|
93
|
+
args.push('--namespace', input.namespace);
|
|
94
|
+
}
|
|
95
|
+
// Data directories
|
|
96
|
+
for (const d of input.data ?? [])
|
|
97
|
+
args.push('--data', d);
|
|
98
|
+
// Flags
|
|
99
|
+
if (input.combine)
|
|
100
|
+
args.push('--combine');
|
|
101
|
+
if (input.failOnWarn)
|
|
102
|
+
args.push('--fail-on-warn');
|
|
103
|
+
// Config files (positional args, must come last)
|
|
104
|
+
const effectiveFiles = configPath ? [configPath] : (input.files ?? []);
|
|
105
|
+
args.push(...effectiveFiles);
|
|
106
|
+
const result = await this.run(args, signal);
|
|
107
|
+
return this.sanitizeOutput(result, configPath, policyDir);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Run `conftest verify` -- executes the `_test.rego` tests inside the
|
|
112
|
+
* policy directory to verify the policies themselves.
|
|
113
|
+
*/
|
|
114
|
+
async verify(input, signal) {
|
|
115
|
+
const args = ['verify', '--output=json', '--no-color'];
|
|
116
|
+
if (input.policy)
|
|
117
|
+
args.push('--policy', input.policy);
|
|
118
|
+
if (input.namespace)
|
|
119
|
+
args.push('--namespace', input.namespace);
|
|
120
|
+
for (const d of input.data ?? [])
|
|
121
|
+
args.push('--data', d);
|
|
122
|
+
return this.run(args, signal);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Pull policies from a remote OCI or Git location into a local
|
|
126
|
+
* directory. Stdout is minimal; errors go to stderr.
|
|
127
|
+
*/
|
|
128
|
+
async pull(input, signal) {
|
|
129
|
+
const args = ['pull', input.url];
|
|
130
|
+
if (input.policy)
|
|
131
|
+
args.push('--policy', input.policy);
|
|
132
|
+
return this.run(args, signal);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Push the local policy bundle to a remote OCI registry. Uses
|
|
136
|
+
* credentials from the host environment (docker login, ORAS, etc.).
|
|
137
|
+
*/
|
|
138
|
+
async push(input, signal) {
|
|
139
|
+
const args = ['push', input.repository];
|
|
140
|
+
if (input.policy)
|
|
141
|
+
args.push('--policy', input.policy);
|
|
142
|
+
return this.run(args, signal);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Run `conftest` with the given argv. Tools should prefer the typed
|
|
146
|
+
* methods above; this is the escape hatch for unusual invocations.
|
|
147
|
+
*/
|
|
148
|
+
async run(args, signal) {
|
|
149
|
+
const opts = {
|
|
150
|
+
args,
|
|
151
|
+
timeoutMs: this.config.subprocessTimeoutMs,
|
|
152
|
+
};
|
|
153
|
+
if (signal !== undefined)
|
|
154
|
+
opts.signal = signal;
|
|
155
|
+
return runBinary(this.config.conftestBinary, opts);
|
|
156
|
+
}
|
|
157
|
+
// ─── Internal: temp file / directory management ──────────────────────────
|
|
158
|
+
/**
|
|
159
|
+
* Create temp assets for inline inputs, run `fn`, then clean up.
|
|
160
|
+
* Returns whatever `fn` returns.
|
|
161
|
+
*/
|
|
162
|
+
async withTempAssets(opts, fn) {
|
|
163
|
+
const temps = [];
|
|
164
|
+
const paths = {};
|
|
165
|
+
try {
|
|
166
|
+
if (opts.inlineConfig !== undefined) {
|
|
167
|
+
const ext = opts.inlineConfigParser === 'dockerfile'
|
|
168
|
+
? ''
|
|
169
|
+
: parserToExt(opts.inlineConfigParser ?? 'yaml');
|
|
170
|
+
const basename = opts.inlineConfigParser === 'dockerfile' ? 'Dockerfile' : `config${ext}`;
|
|
171
|
+
// mkdtemp creates the directory atomically (O_CREAT|O_EXCL) -- safe temp file pattern.
|
|
172
|
+
const tmpDir = await mkdtemp(join(tmpdir(), 'orygn-conftest-'));
|
|
173
|
+
temps.push(tmpDir);
|
|
174
|
+
const configPath = join(tmpDir, basename);
|
|
175
|
+
await writeFile(configPath, opts.inlineConfig, 'utf8');
|
|
176
|
+
paths.configPath = configPath;
|
|
177
|
+
}
|
|
178
|
+
if (opts.inlinePolicy !== undefined) {
|
|
179
|
+
// mkdtemp creates the directory atomically (O_CREAT|O_EXCL) -- safe temp file pattern.
|
|
180
|
+
const policyDir = await mkdtemp(join(tmpdir(), 'orygn-conftest-policy-'));
|
|
181
|
+
temps.push(policyDir);
|
|
182
|
+
const policyFile = join(policyDir, 'policy.rego');
|
|
183
|
+
await writeFile(policyFile, opts.inlinePolicy, 'utf8');
|
|
184
|
+
paths.policyDir = policyDir;
|
|
185
|
+
}
|
|
186
|
+
return await fn(paths);
|
|
187
|
+
}
|
|
188
|
+
finally {
|
|
189
|
+
await Promise.all(temps.map((p) => rm(p, { recursive: true, force: true })));
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Replace the temp inline-config path and temp inline-policy directory
|
|
194
|
+
* path in the stdout JSON with `<inline>` so callers never see
|
|
195
|
+
* implementation-internal temp paths.
|
|
196
|
+
*
|
|
197
|
+
* conftest emits paths inside a JSON array, so each backslash in the
|
|
198
|
+
* path is JSON-encoded as `\\`. We match the JSON-encoded form of the
|
|
199
|
+
* path to handle Windows paths correctly (forward slashes need no
|
|
200
|
+
* special treatment).
|
|
201
|
+
*/
|
|
202
|
+
sanitizeOutput(result, configPath, policyDir) {
|
|
203
|
+
if (!configPath && !policyDir)
|
|
204
|
+
return result;
|
|
205
|
+
if (!result.stdout)
|
|
206
|
+
return result;
|
|
207
|
+
let stdout = result.stdout;
|
|
208
|
+
if (configPath) {
|
|
209
|
+
// JSON.stringify encodes backslashes as \\, so match the encoded form.
|
|
210
|
+
const jsonEncoded = JSON.stringify(configPath).slice(1, -1);
|
|
211
|
+
const escaped = jsonEncoded.replace(/[\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
212
|
+
stdout = stdout.replace(new RegExp(escaped, 'g'), '<inline>');
|
|
213
|
+
}
|
|
214
|
+
if (policyDir) {
|
|
215
|
+
const jsonEncoded = JSON.stringify(policyDir).slice(1, -1);
|
|
216
|
+
const escaped = jsonEncoded.replace(/[\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
217
|
+
// Policy dir appears in conftest output as part of file paths.
|
|
218
|
+
// Replace the full dir prefix so the policy filename is preserved.
|
|
219
|
+
stdout = stdout.replace(new RegExp(escaped, 'g'), '<inline-policy>');
|
|
220
|
+
}
|
|
221
|
+
return { ...result, stdout };
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
//# sourceMappingURL=conftest-cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conftest-cli.js","sourceRoot":"","sources":["../../src/lib/conftest-cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,OAAO,EAAE,SAAS,EAAoB,MAAM,iBAAiB,CAAC;AA2F9D,gFAAgF;AAEhF,MAAM,aAAa,GAA2B;IAC5C,IAAI,EAAE,OAAO;IACb,IAAI,EAAE,OAAO;IACb,IAAI,EAAE,OAAO;IACb,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,MAAM;IACX,GAAG,EAAE,MAAM;IACX,MAAM,EAAE,MAAM;IACd,GAAG,EAAE,MAAM;IACX,OAAO,EAAE,UAAU;I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AAC;YAC3D,MAAM,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;YACnE,+DAA+D;YAC/D,mEAAmE;YACnE,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,iBAAiB,CAAC,CAAC;QACvE,CAAC;QAED,OAAO,EAAE,GAAG,MAAM,EAAE,MAAM,EAAE,CAAC;IAC/B,CAAC;CACF"}
|
package/dist/lib/opa-cli.d.ts
CHANGED
|
@@ -201,13 +201,13 @@ export declare class OpaCli {
|
|
|
201
201
|
* Verify the binary is present and report its version.
|
|
202
202
|
* Returns null if the binary is unreachable or output is malformed.
|
|
203
203
|
*/
|
|
204
|
-
version(): Promise<string | null>;
|
|
204
|
+
version(signal?: AbortSignal): Promise<string | null>;
|
|
205
205
|
/**
|
|
206
206
|
* Format Rego source. Stdout contains the formatted output. Reports
|
|
207
207
|
* `exitCode: 0` even when no changes are needed -- callers compare
|
|
208
208
|
* input vs output to detect a no-op.
|
|
209
209
|
*/
|
|
210
|
-
fmt(input: FmtInput): Promise<SpawnResult>;
|
|
210
|
+
fmt(input: FmtInput, signal?: AbortSignal): Promise<SpawnResult>;
|
|
211
211
|
/**
|
|
212
212
|
* List files that would be reformatted. Stdout is one absolute path per
|
|
213
213
|
* line for each file that is not already canonical. Exit 0 on success,
|
|
@@ -216,12 +216,12 @@ export declare class OpaCli {
|
|
|
216
216
|
* NOTE: --list and --write are mutually exclusive in OPA: passing both
|
|
217
217
|
* suppresses the write. Always use separate fmtList + fmtWrite calls.
|
|
218
218
|
*/
|
|
219
|
-
fmtList(input: FmtWriteInput): Promise<SpawnResult>;
|
|
219
|
+
fmtList(input: FmtWriteInput, signal?: AbortSignal): Promise<SpawnResult>;
|
|
220
220
|
/**
|
|
221
221
|
* Overwrite each file with its canonically formatted version. Exit 0 on
|
|
222
222
|
* success, non-zero (exit 2) if any file cannot be parsed.
|
|
223
223
|
*/
|
|
224
|
-
fmtWrite(input: FmtWriteInput): Promise<SpawnResult>;
|
|
224
|
+
fmtWrite(input: FmtWriteInput, signal?: AbortSignal): Promise<SpawnResult>;
|
|
225
225
|
/**
|
|
226
226
|
* Type-check Rego. Returns `exitCode: 0` and empty `stdout` when the
|
|
227
227
|
* policy is valid. On failure, `exitCode` is non-zero and the JSON
|
|
@@ -230,49 +230,49 @@ export declare class OpaCli {
|
|
|
230
230
|
* diagnostics). Either inline `source` or one or more `paths` must be
|
|
231
231
|
* provided.
|
|
232
232
|
*/
|
|
233
|
-
check(input: CheckInput): Promise<SpawnResult>;
|
|
233
|
+
check(input: CheckInput, signal?: AbortSignal): Promise<SpawnResult>;
|
|
234
234
|
/**
|
|
235
235
|
* Parse Rego source to a JSON AST. Stdout is the AST as JSON.
|
|
236
236
|
*/
|
|
237
|
-
parse(input: ParseInput): Promise<SpawnResult>;
|
|
237
|
+
parse(input: ParseInput, signal?: AbortSignal): Promise<SpawnResult>;
|
|
238
238
|
/**
|
|
239
239
|
* Inspect a bundle, directory, or single Rego file. Returns its
|
|
240
240
|
* packages, namespaces, manifest, and annotations as JSON on stdout.
|
|
241
241
|
*/
|
|
242
|
-
inspect(input: InspectInput): Promise<SpawnResult>;
|
|
242
|
+
inspect(input: InspectInput, signal?: AbortSignal): Promise<SpawnResult>;
|
|
243
243
|
/**
|
|
244
244
|
* Print available capabilities. With `current=true`, prints the
|
|
245
245
|
* capabilities of the running OPA. With a `version`, prints those of
|
|
246
246
|
* a specific named version. Without either, lists available named
|
|
247
247
|
* versions.
|
|
248
248
|
*/
|
|
249
|
-
capabilities(input?: CapabilitiesInput): Promise<SpawnResult>;
|
|
249
|
+
capabilities(input?: CapabilitiesInput, signal?: AbortSignal): Promise<SpawnResult>;
|
|
250
250
|
/**
|
|
251
251
|
* Static dependency analysis for a Rego ref. Stdout is JSON with the
|
|
252
252
|
* `base` and `virtual` document references the ref depends on.
|
|
253
253
|
*/
|
|
254
|
-
deps(input: DepsInput): Promise<SpawnResult>;
|
|
254
|
+
deps(input: DepsInput, signal?: AbortSignal): Promise<SpawnResult>;
|
|
255
255
|
/**
|
|
256
256
|
* Evaluate a query against a policy + input. Stdout is JSON with the
|
|
257
257
|
* standard `{result: [...]}` shape (plus optional explain, profile,
|
|
258
258
|
* coverage, and metrics sections).
|
|
259
259
|
*/
|
|
260
|
-
eval(input: EvalInput): Promise<SpawnResult>;
|
|
260
|
+
eval(input: EvalInput, signal?: AbortSignal): Promise<SpawnResult>;
|
|
261
261
|
/**
|
|
262
262
|
* Run Rego unit tests. Stdout is JSON with per-test pass/fail.
|
|
263
263
|
*/
|
|
264
|
-
test(input: TestInput): Promise<SpawnResult>;
|
|
264
|
+
test(input: TestInput, signal?: AbortSignal): Promise<SpawnResult>;
|
|
265
265
|
/**
|
|
266
266
|
* Benchmark a query. Stdout is JSON with iteration timing statistics.
|
|
267
267
|
*/
|
|
268
|
-
bench(input: BenchInput): Promise<SpawnResult>;
|
|
268
|
+
bench(input: BenchInput, signal?: AbortSignal): Promise<SpawnResult>;
|
|
269
269
|
/** Build a deployable bundle from policy + data paths. */
|
|
270
|
-
build(input: BuildInput): Promise<SpawnResult>;
|
|
270
|
+
build(input: BuildInput, signal?: AbortSignal): Promise<SpawnResult>;
|
|
271
271
|
/**
|
|
272
272
|
* Sign a bundle. Writes a `.signatures.json` next to the bundle
|
|
273
273
|
* directory.
|
|
274
274
|
*/
|
|
275
|
-
sign(input: SignInput): Promise<SpawnResult>;
|
|
275
|
+
sign(input: SignInput, signal?: AbortSignal): Promise<SpawnResult>;
|
|
276
276
|
/**
|
|
277
277
|
* Verify a signed bundle using `opa eval --bundle --verification-key`.
|
|
278
278
|
* OPA verifies the bundle signature before loading any policies; a
|
|
@@ -280,19 +280,19 @@ export declare class OpaCli {
|
|
|
280
280
|
* stderr. The trivial query `true` is used so the process exits
|
|
281
281
|
* immediately after verification without entering a REPL.
|
|
282
282
|
*/
|
|
283
|
-
bundleVerify(input: BundleVerifyInput): Promise<SpawnResult>;
|
|
283
|
+
bundleVerify(input: BundleVerifyInput, signal?: AbortSignal): Promise<SpawnResult>;
|
|
284
284
|
/**
|
|
285
285
|
* Batch-evaluate a policy decision against one or more input files using
|
|
286
286
|
* `opa exec`. Each input file is evaluated independently; results are
|
|
287
287
|
* returned as a JSON array with one entry per file.
|
|
288
288
|
*/
|
|
289
|
-
exec(input: ExecInput): Promise<SpawnResult>;
|
|
289
|
+
exec(input: ExecInput, signal?: AbortSignal): Promise<SpawnResult>;
|
|
290
290
|
/**
|
|
291
291
|
* Run `opa` with the given argv and optional stdin. Tools should
|
|
292
292
|
* prefer the typed methods above, but this exists for the rare cases
|
|
293
293
|
* the typed surface does not yet cover.
|
|
294
294
|
*/
|
|
295
|
-
run(args: string[], stdin?: string): Promise<SpawnResult>;
|
|
295
|
+
run(args: string[], stdin?: string, signal?: AbortSignal): Promise<SpawnResult>;
|
|
296
296
|
/**
|
|
297
297
|
* Write `source` to a uniquely named `.rego` file in the OS tmp dir,
|
|
298
298
|
* pass its path to `fn`, and remove it on completion (success or
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opa-cli.d.ts","sourceRoot":"","sources":["../../src/lib/opa-cli.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9D,+BAA+B;AAC/B,MAAM,WAAW,QAAQ;IACvB,kCAAkC;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,oGAAoG;IACpG,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,8EAA8E;AAC9E,MAAM,WAAW,aAAa;IAC5B,6CAA6C;IAC7C,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,uFAAuF;IACvF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,yDAAyD;IACzD,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,+CAA+C;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EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IASxF;;;;OAIG;IACG,IAAI,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IAaxE;;;;OAIG;IACG,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IAYrF;;;;;OAKG;YACW,cAAc;CAS7B"}
|
package/dist/lib/opa-cli.js
CHANGED
|
@@ -38,8 +38,8 @@ export class OpaCli {
|
|
|
38
38
|
* Verify the binary is present and report its version.
|
|
39
39
|
* Returns null if the binary is unreachable or output is malformed.
|
|
40
40
|
*/
|
|
41
|
-
async version() {
|
|
42
|
-
const result = await this.run(['version']);
|
|
41
|
+
async version(signal) {
|
|
42
|
+
const result = await this.run(['version'], undefined, signal);
|
|
43
43
|
if (result.exitCode !== 0)
|
|
44
44
|
return null;
|
|
45
45
|
const match = /Version:\s*(\S+)/i.exec(result.stdout);
|
|
@@ -51,11 +51,11 @@ export class OpaCli {
|
|
|
51
51
|
* `exitCode: 0` even when no changes are needed -- callers compare
|
|
52
52
|
* input vs output to detect a no-op.
|
|
53
53
|
*/
|
|
54
|
-
async fmt(input) {
|
|
54
|
+
async fmt(input, signal) {
|
|
55
55
|
const args = ['fmt'];
|
|
56
56
|
if (input.regoV1)
|
|
57
57
|
args.push('--rego-v1');
|
|
58
|
-
return this.withTempSource(input.source, (path) => this.run([...args, path]));
|
|
58
|
+
return this.withTempSource(input.source, (path) => this.run([...args, path], undefined, signal));
|
|
59
59
|
}
|
|
60
60
|
/**
|
|
61
61
|
* List files that would be reformatted. Stdout is one absolute path per
|
|
@@ -65,7 +65,7 @@ export class OpaCli {
|
|
|
65
65
|
* NOTE: --list and --write are mutually exclusive in OPA: passing both
|
|
66
66
|
* suppresses the write. Always use separate fmtList + fmtWrite calls.
|
|
67
67
|
*/
|
|
68
|
-
async fmtList(input) {
|
|
68
|
+
async fmtList(input, signal) {
|
|
69
69
|
if (input.paths.length === 0) {
|
|
70
70
|
throw new Error('opa fmt requires at least one path');
|
|
71
71
|
}
|
|
@@ -77,13 +77,13 @@ export class OpaCli {
|
|
|
77
77
|
if (input.v1Compatible)
|
|
78
78
|
args.push('--v1-compatible');
|
|
79
79
|
args.push(...input.paths);
|
|
80
|
-
return this.run(args);
|
|
80
|
+
return this.run(args, undefined, signal);
|
|
81
81
|
}
|
|
82
82
|
/**
|
|
83
83
|
* Overwrite each file with its canonically formatted version. Exit 0 on
|
|
84
84
|
* success, non-zero (exit 2) if any file cannot be parsed.
|
|
85
85
|
*/
|
|
86
|
-
async fmtWrite(input) {
|
|
86
|
+
async fmtWrite(input, signal) {
|
|
87
87
|
if (input.paths.length === 0) {
|
|
88
88
|
throw new Error('opa fmt requires at least one path');
|
|
89
89
|
}
|
|
@@ -95,7 +95,7 @@ export class OpaCli {
|
|
|
95
95
|
if (input.v1Compatible)
|
|
96
96
|
args.push('--v1-compatible');
|
|
97
97
|
args.push(...input.paths);
|
|
98
|
-
return this.run(args);
|
|
98
|
+
return this.run(args, undefined, signal);
|
|
99
99
|
}
|
|
100
100
|
/**
|
|
101
101
|
* Type-check Rego. Returns `exitCode: 0` and empty `stdout` when the
|
|
@@ -105,7 +105,7 @@ export class OpaCli {
|
|
|
105
105
|
* diagnostics). Either inline `source` or one or more `paths` must be
|
|
106
106
|
* provided.
|
|
107
107
|
*/
|
|
108
|
-
async check(input) {
|
|
108
|
+
async check(input, signal) {
|
|
109
109
|
if (!input.source && !input.paths?.length) {
|
|
110
110
|
throw new Error('opa check requires either source or at least one path');
|
|
111
111
|
}
|
|
@@ -121,23 +121,23 @@ export class OpaCli {
|
|
|
121
121
|
if (input.schemaDir)
|
|
122
122
|
args.push('--schema', input.schemaDir);
|
|
123
123
|
if (input.source !== undefined) {
|
|
124
|
-
return this.withTempSource(input.source, (path) => this.run([...args, path]));
|
|
124
|
+
return this.withTempSource(input.source, (path) => this.run([...args, path], undefined, signal));
|
|
125
125
|
}
|
|
126
126
|
args.push(...(input.paths ?? []));
|
|
127
|
-
return this.run(args);
|
|
127
|
+
return this.run(args, undefined, signal);
|
|
128
128
|
}
|
|
129
129
|
/**
|
|
130
130
|
* Parse Rego source to a JSON AST. Stdout is the AST as JSON.
|
|
131
131
|
*/
|
|
132
|
-
async parse(input) {
|
|
133
|
-
return this.withTempSource(input.source, (path) => this.run(['parse', '--format=json', path]));
|
|
132
|
+
async parse(input, signal) {
|
|
133
|
+
return this.withTempSource(input.source, (path) => this.run(['parse', '--format=json', path], undefined, signal));
|
|
134
134
|
}
|
|
135
135
|
/**
|
|
136
136
|
* Inspect a bundle, directory, or single Rego file. Returns its
|
|
137
137
|
* packages, namespaces, manifest, and annotations as JSON on stdout.
|
|
138
138
|
*/
|
|
139
|
-
async inspect(input) {
|
|
140
|
-
return this.run(['inspect', '--format=json', '--annotations', input.target]);
|
|
139
|
+
async inspect(input, signal) {
|
|
140
|
+
return this.run(['inspect', '--format=json', '--annotations', input.target], undefined, signal);
|
|
141
141
|
}
|
|
142
142
|
/**
|
|
143
143
|
* Print available capabilities. With `current=true`, prints the
|
|
@@ -145,19 +145,19 @@ export class OpaCli {
|
|
|
145
145
|
* a specific named version. Without either, lists available named
|
|
146
146
|
* versions.
|
|
147
147
|
*/
|
|
148
|
-
async capabilities(input = {}) {
|
|
148
|
+
async capabilities(input = {}, signal) {
|
|
149
149
|
const args = ['capabilities'];
|
|
150
150
|
if (input.current)
|
|
151
151
|
args.push('--current');
|
|
152
152
|
if (input.version)
|
|
153
153
|
args.push('--version', input.version);
|
|
154
|
-
return this.run(args);
|
|
154
|
+
return this.run(args, undefined, signal);
|
|
155
155
|
}
|
|
156
156
|
/**
|
|
157
157
|
* Static dependency analysis for a Rego ref. Stdout is JSON with the
|
|
158
158
|
* `base` and `virtual` document references the ref depends on.
|
|
159
159
|
*/
|
|
160
|
-
async deps(input) {
|
|
160
|
+
async deps(input, signal) {
|
|
161
161
|
if (input.paths.length === 0) {
|
|
162
162
|
throw new Error('opa deps requires at least one path');
|
|
163
163
|
}
|
|
@@ -166,7 +166,7 @@ export class OpaCli {
|
|
|
166
166
|
args.push('--data', path);
|
|
167
167
|
}
|
|
168
168
|
args.push(input.ref);
|
|
169
|
-
return this.run(args);
|
|
169
|
+
return this.run(args, undefined, signal);
|
|
170
170
|
}
|
|
171
171
|
// ─── Evaluation ──────────────────────────────────────────────────────
|
|
172
172
|
/**
|
|
@@ -174,7 +174,7 @@ export class OpaCli {
|
|
|
174
174
|
* standard `{result: [...]}` shape (plus optional explain, profile,
|
|
175
175
|
* coverage, and metrics sections).
|
|
176
176
|
*/
|
|
177
|
-
async eval(input) {
|
|
177
|
+
async eval(input, signal) {
|
|
178
178
|
// Inline source becomes a temp file added to --data.
|
|
179
179
|
if (input.source !== undefined) {
|
|
180
180
|
const { source, ...rest } = input;
|
|
@@ -182,7 +182,7 @@ export class OpaCli {
|
|
|
182
182
|
return this.withTempSource(input.source, (sourcePath) => this.eval({
|
|
183
183
|
...rest,
|
|
184
184
|
paths: [...(input.paths ?? []), sourcePath],
|
|
185
|
-
}));
|
|
185
|
+
}, signal));
|
|
186
186
|
}
|
|
187
187
|
const args = ['eval', '--format=json'];
|
|
188
188
|
for (const path of input.paths ?? [])
|
|
@@ -215,12 +215,12 @@ export class OpaCli {
|
|
|
215
215
|
stdin = JSON.stringify(input.input);
|
|
216
216
|
}
|
|
217
217
|
args.push(input.query);
|
|
218
|
-
return this.run(args, stdin);
|
|
218
|
+
return this.run(args, stdin, signal);
|
|
219
219
|
}
|
|
220
220
|
/**
|
|
221
221
|
* Run Rego unit tests. Stdout is JSON with per-test pass/fail.
|
|
222
222
|
*/
|
|
223
|
-
async test(input) {
|
|
223
|
+
async test(input, signal) {
|
|
224
224
|
if (input.paths.length === 0) {
|
|
225
225
|
throw new Error('opa test requires at least one path');
|
|
226
226
|
}
|
|
@@ -234,12 +234,12 @@ export class OpaCli {
|
|
|
234
234
|
if (input.runPattern)
|
|
235
235
|
args.push('--run', input.runPattern);
|
|
236
236
|
args.push(...input.paths);
|
|
237
|
-
return this.run(args);
|
|
237
|
+
return this.run(args, undefined, signal);
|
|
238
238
|
}
|
|
239
239
|
/**
|
|
240
240
|
* Benchmark a query. Stdout is JSON with iteration timing statistics.
|
|
241
241
|
*/
|
|
242
|
-
async bench(input) {
|
|
242
|
+
async bench(input, signal) {
|
|
243
243
|
const args = ['bench', '--format=json'];
|
|
244
244
|
for (const path of input.paths ?? [])
|
|
245
245
|
args.push('--data', path);
|
|
@@ -253,11 +253,11 @@ export class OpaCli {
|
|
|
253
253
|
stdin = JSON.stringify(input.input);
|
|
254
254
|
}
|
|
255
255
|
args.push(input.query);
|
|
256
|
-
return this.run(args, stdin);
|
|
256
|
+
return this.run(args, stdin, signal);
|
|
257
257
|
}
|
|
258
258
|
// ─── Bundles ─────────────────────────────────────────────────────────
|
|
259
259
|
/** Build a deployable bundle from policy + data paths. */
|
|
260
|
-
async build(input) {
|
|
260
|
+
async build(input, signal) {
|
|
261
261
|
if (input.paths.length === 0) {
|
|
262
262
|
throw new Error('opa build requires at least one input path');
|
|
263
263
|
}
|
|
@@ -279,20 +279,20 @@ export class OpaCli {
|
|
|
279
279
|
if (input.capabilities)
|
|
280
280
|
args.push('--capabilities', input.capabilities);
|
|
281
281
|
args.push(...input.paths);
|
|
282
|
-
return this.run(args);
|
|
282
|
+
return this.run(args, undefined, signal);
|
|
283
283
|
}
|
|
284
284
|
/**
|
|
285
285
|
* Sign a bundle. Writes a `.signatures.json` next to the bundle
|
|
286
286
|
* directory.
|
|
287
287
|
*/
|
|
288
|
-
async sign(input) {
|
|
288
|
+
async sign(input, signal) {
|
|
289
289
|
const args = ['sign', '--signing-key', input.signingKey];
|
|
290
290
|
if (input.signingAlg)
|
|
291
291
|
args.push('--signing-alg', input.signingAlg);
|
|
292
292
|
if (input.claimsFile)
|
|
293
293
|
args.push('--claims-file', input.claimsFile);
|
|
294
294
|
args.push('--bundle', input.bundle);
|
|
295
|
-
return this.run(args);
|
|
295
|
+
return this.run(args, undefined, signal);
|
|
296
296
|
}
|
|
297
297
|
/**
|
|
298
298
|
* Verify a signed bundle using `opa eval --bundle --verification-key`.
|
|
@@ -301,7 +301,7 @@ export class OpaCli {
|
|
|
301
301
|
* stderr. The trivial query `true` is used so the process exits
|
|
302
302
|
* immediately after verification without entering a REPL.
|
|
303
303
|
*/
|
|
304
|
-
async bundleVerify(input) {
|
|
304
|
+
async bundleVerify(input, signal) {
|
|
305
305
|
const args = ['eval', '--bundle', input.bundle, '--verification-key', input.verificationKey];
|
|
306
306
|
if (input.verificationKeyId)
|
|
307
307
|
args.push('--verification-key-id', input.verificationKeyId);
|
|
@@ -310,14 +310,14 @@ export class OpaCli {
|
|
|
310
310
|
if (input.scope)
|
|
311
311
|
args.push('--scope', input.scope);
|
|
312
312
|
args.push('true');
|
|
313
|
-
return this.run(args);
|
|
313
|
+
return this.run(args, undefined, signal);
|
|
314
314
|
}
|
|
315
315
|
/**
|
|
316
316
|
* Batch-evaluate a policy decision against one or more input files using
|
|
317
317
|
* `opa exec`. Each input file is evaluated independently; results are
|
|
318
318
|
* returned as a JSON array with one entry per file.
|
|
319
319
|
*/
|
|
320
|
-
async exec(input) {
|
|
320
|
+
async exec(input, signal) {
|
|
321
321
|
if (input.inputPaths.length === 0) {
|
|
322
322
|
throw new Error('opa exec requires at least one input path');
|
|
323
323
|
}
|
|
@@ -327,7 +327,7 @@ export class OpaCli {
|
|
|
327
327
|
for (const p of input.dataPaths ?? [])
|
|
328
328
|
args.push('--data', p);
|
|
329
329
|
args.push(...input.inputPaths);
|
|
330
|
-
return this.run(args);
|
|
330
|
+
return this.run(args, undefined, signal);
|
|
331
331
|
}
|
|
332
332
|
// ─── Low-level escape hatch ──────────────────────────────────────────
|
|
333
333
|
/**
|
|
@@ -335,13 +335,15 @@ export class OpaCli {
|
|
|
335
335
|
* prefer the typed methods above, but this exists for the rare cases
|
|
336
336
|
* the typed surface does not yet cover.
|
|
337
337
|
*/
|
|
338
|
-
async run(args, stdin) {
|
|
338
|
+
async run(args, stdin, signal) {
|
|
339
339
|
const opts = {
|
|
340
340
|
args,
|
|
341
341
|
timeoutMs: this.config.subprocessTimeoutMs,
|
|
342
342
|
};
|
|
343
343
|
if (stdin !== undefined)
|
|
344
344
|
opts.stdin = stdin;
|
|
345
|
+
if (signal !== undefined)
|
|
346
|
+
opts.signal = signal;
|
|
345
347
|
return runBinary(this.config.opaBinary, opts);
|
|
346
348
|
}
|
|
347
349
|
// ─── Internal: temp file management ──────────────────────────────────
|