passport-bridge 0.48.2 → 0.49.0
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/dist/cliHookAfter.js +10 -1
- package/dist/cliHookDecide.d.ts +9 -3
- package/dist/cliHookDecide.js +182 -28
- package/dist/cliHookSessionState.d.ts +4 -1
- package/dist/cliHookSessionState.js +1 -1
- package/dist/connectorKit/callEffects.generated.d.ts +36 -0
- package/dist/connectorKit/callEffects.generated.js +73 -0
- package/dist/connectorKit/cli.generated.js +5 -2
- package/dist/connectorKit/engine.generated.d.ts +1 -1
- package/dist/connectorKit/engine.generated.js +32 -13
- package/dist/connectorKit/githubIds.generated.d.ts +1 -1
- package/dist/connectorKit/githubIds.generated.js +3 -2
- package/dist/connectorKit/manifest.generated.d.ts +34 -14
- package/dist/connectorKit/manifests/cloudflare.generated.d.ts +2 -0
- package/dist/connectorKit/manifests/cloudflare.generated.js +186 -0
- package/dist/connectorKit/manifests/cloudflareApi.generated.d.ts +4 -0
- package/dist/connectorKit/manifests/cloudflareApi.generated.js +207 -0
- package/dist/connectorKit/manifests/cloudflareCatalog.generated.d.ts +18 -0
- package/dist/connectorKit/manifests/cloudflareCatalog.generated.js +83 -0
- package/dist/connectorKit/manifests/cloudflareCli.generated.d.ts +2 -0
- package/dist/connectorKit/manifests/cloudflareCli.generated.js +441 -0
- package/dist/connectorKit/manifests/githubCapture.generated.js +19 -1
- package/dist/connectorKit/manifests/githubReads.generated.js +0 -3
- package/dist/connectorKit/manifests/kubernetes.generated.d.ts +76 -0
- package/dist/connectorKit/manifests/kubernetes.generated.js +210 -0
- package/dist/connectorKit/manifests/kubernetesArgs.generated.d.ts +21 -0
- package/dist/connectorKit/manifests/kubernetesArgs.generated.js +82 -0
- package/dist/connectorKit/manifests/kubernetesCli.generated.d.ts +30 -0
- package/dist/connectorKit/manifests/kubernetesCli.generated.js +530 -0
- package/dist/connectorKit/manifests/kubernetesEffects.generated.d.ts +15 -0
- package/dist/connectorKit/manifests/kubernetesEffects.generated.js +111 -0
- package/dist/connectorKit/manifests/kubernetesObjects.generated.d.ts +24 -0
- package/dist/connectorKit/manifests/kubernetesObjects.generated.js +154 -0
- package/dist/connectorKit/manifests/railwayHooks.generated.js +11 -5
- package/dist/connectorKit/manifests/sentry.generated.d.ts +6 -0
- package/dist/connectorKit/manifests/sentry.generated.js +27 -0
- package/dist/connectorKit/manifests/sentryApi.generated.d.ts +6 -0
- package/dist/connectorKit/manifests/sentryApi.generated.js +282 -0
- package/dist/connectorKit/manifests/sentryCapture.generated.d.ts +2 -0
- package/dist/connectorKit/manifests/sentryCapture.generated.js +165 -0
- package/dist/connectorKit/manifests/sentryCatalog.generated.d.ts +5 -0
- package/dist/connectorKit/manifests/sentryCatalog.generated.js +70 -0
- package/dist/connectorKit/manifests/sentryCli.generated.d.ts +2 -0
- package/dist/connectorKit/manifests/sentryCli.generated.js +230 -0
- package/dist/connectorKit/manifests/sentryIssues.generated.d.ts +20 -0
- package/dist/connectorKit/manifests/sentryIssues.generated.js +204 -0
- package/dist/connectorKit/manifests/supabase.generated.js +3 -2
- package/dist/connectorKit/manifests/supabaseApi.generated.js +52 -52
- package/dist/connectorKit/manifests/supabaseCapture.generated.js +22 -21
- package/dist/connectorKit/manifests/supabaseCatalog.generated.d.ts +2 -2
- package/dist/connectorKit/manifests/supabaseCatalog.generated.js +8 -7
- package/dist/connectorKit/manifests/supabaseCli.generated.js +32 -32
- package/dist/connectorKit/manifests/supabaseProbes.generated.js +29 -29
- package/dist/connectorKit/manifests/terraform.generated.d.ts +5 -0
- package/dist/connectorKit/manifests/terraform.generated.js +214 -0
- package/dist/connectorKit/manifests/terraformLink.generated.d.ts +30 -0
- package/dist/connectorKit/manifests/terraformLink.generated.js +73 -0
- package/dist/connectorKit/manifests/terraformPlan.generated.d.ts +48 -0
- package/dist/connectorKit/manifests/terraformPlan.generated.js +192 -0
- package/dist/connectorKit/params.generated.js +2 -0
- package/dist/connectorKit/shell.generated.d.ts +5 -1
- package/dist/connectorKit/shell.generated.js +121 -20
- package/dist/connectorKit/sources/cloudflare/api-operations.generated.d.ts +37 -0
- package/dist/connectorKit/sources/cloudflare/api-operations.generated.js +2 -0
- package/dist/connectorKit/sources/cloudflare/cli-flags.generated.d.ts +617 -0
- package/dist/connectorKit/sources/cloudflare/cli-flags.generated.js +2 -0
- package/dist/connectorKit/sources/cloudflare/mcp-tools.generated.d.ts +16 -0
- package/dist/connectorKit/sources/cloudflare/mcp-tools.generated.js +2 -0
- package/dist/connectorKit/sources/sentry/api-operations.generated.d.ts +121 -0
- package/dist/connectorKit/sources/sentry/api-operations.generated.js +2 -0
- package/dist/connectorKit/sources/sentry/cli-commands.generated.d.ts +530 -0
- package/dist/connectorKit/sources/sentry/cli-commands.generated.js +2 -0
- package/dist/connectorKit/sources/sentry/mcp-tools.generated.d.ts +32 -0
- package/dist/connectorKit/sources/sentry/mcp-tools.generated.js +2 -0
- package/dist/connectorKit/template.generated.d.ts +8 -4
- package/dist/connectorKit/template.generated.js +19 -6
- package/dist/controlPlane.generated.d.ts +11 -2
- package/dist/controlPlaneActions.generated.d.ts +52 -12
- package/dist/controlPlaneActions.generated.js +40 -11
- package/dist/controlPlaneCloudflare.d.ts +70 -0
- package/dist/controlPlaneCloudflare.js +188 -0
- package/dist/controlPlaneKubernetes.d.ts +72 -0
- package/dist/controlPlaneKubernetes.js +260 -0
- package/dist/controlPlaneModel.generated.d.ts +6 -0
- package/dist/controlPlaneNpm.generated.d.ts +83 -0
- package/dist/controlPlaneNpm.generated.js +307 -0
- package/dist/controlPlaneNpmCommands.generated.d.ts +35 -0
- package/dist/controlPlaneNpmCommands.generated.js +567 -0
- package/dist/controlPlaneNpmGuard.d.ts +44 -0
- package/dist/controlPlaneNpmGuard.js +210 -0
- package/dist/controlPlaneOffline.d.ts +1 -1
- package/dist/controlPlaneRailway.generated.js +2 -2
- package/dist/controlPlaneRailwayCli.generated.js +13 -2
- package/dist/controlPlaneRailwayModel.generated.d.ts +5 -0
- package/dist/controlPlaneRailwayModel.generated.js +15 -1
- package/dist/controlPlaneSentry.d.ts +68 -0
- package/dist/controlPlaneSentry.js +205 -0
- package/dist/controlPlaneTerraform.d.ts +86 -0
- package/dist/controlPlaneTerraform.js +273 -0
- package/dist/controlPlaneUnnamed.generated.d.ts +41 -2
- package/dist/controlPlaneUnnamed.generated.js +148 -2
- package/dist/cpCli.d.ts +1 -1
- package/dist/cpCli.js +1 -1
- package/dist/pluginPin.d.ts +1 -1
- package/dist/pluginPin.js +1 -1
- package/dist/terraformPlans.d.ts +45 -0
- package/dist/terraformPlans.js +96 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Classification } from "./controlPlane.generated.js";
|
|
2
|
+
import type { UnnamedHit } from "./controlPlaneUnnamed.generated.js";
|
|
3
|
+
import { type NpmFiles } from "./controlPlaneNpm.generated.js";
|
|
4
|
+
/**
|
|
5
|
+
* npm's command lines (`shared/controlPlaneNpm.ts` holds its nodes, files and catalog): each `npm`, `pnpm` and `yarn`
|
|
6
|
+
* subcommand family read into the registry action it takes. Pure; the bridge has a generated copy.
|
|
7
|
+
*/
|
|
8
|
+
export type NpmProgram = "npm" | "pnpm" | "yarn";
|
|
9
|
+
export declare const NPM_PROGRAMS: readonly NpmProgram[];
|
|
10
|
+
type Parsed = {
|
|
11
|
+
words: string[];
|
|
12
|
+
flags: Map<string, string | true>;
|
|
13
|
+
};
|
|
14
|
+
/** Words and flags, as npm reads them (`--flag value`, `--flag=value`, `--no-flag`, `--` ends flags). */
|
|
15
|
+
export declare function parseNpmArgs(args: readonly string[]): Parsed;
|
|
16
|
+
/** `name@version` (`@scope/name@1.0.0`); either may be missing. */
|
|
17
|
+
export declare function packageSpec(spec: string | undefined): {
|
|
18
|
+
name?: string;
|
|
19
|
+
version?: string;
|
|
20
|
+
};
|
|
21
|
+
/** What the guard reads of one command: the program and its words after it. */
|
|
22
|
+
export type NpmCall = {
|
|
23
|
+
program: NpmProgram;
|
|
24
|
+
args: readonly string[];
|
|
25
|
+
cwd: string | null;
|
|
26
|
+
};
|
|
27
|
+
/** A command's coarse hit, for an action Passport can't name: the program and its first subcommand word. */
|
|
28
|
+
export declare function npmUnnamed(program: NpmProgram, words: readonly string[]): UnnamedHit;
|
|
29
|
+
/**
|
|
30
|
+
* What one `npm`, `pnpm` or `yarn` command does to a registry: one classification (with its chain from the registry
|
|
31
|
+
* down), or none for a local command. A subcommand npm doesn't have is the Unclassified action, with its hit; pnpm and
|
|
32
|
+
* yarn run a project's scripts by name, so an unknown word there is local.
|
|
33
|
+
*/
|
|
34
|
+
export declare function classifyNpm(call: NpmCall, files?: NpmFiles): Classification[];
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,567 @@
|
|
|
1
|
+
import { EXACT_VERSION, isPackageName, joinPath, npmChain, npmChainOf, npmNodeIds, npmrcRegistries, packageJson, projectFolder, PUBLIC_REGISTRY, registryHost, SAFE_ID, TAG, TEAM, UNKNOWN_REGISTRY, USER, VERSION } from "./controlPlaneNpm.generated.js";
|
|
2
|
+
export const NPM_PROGRAMS = ["npm", "pnpm", "yarn"];
|
|
3
|
+
/** npm's flags that take a value (the ones an agent writes; any other `--flag` is read as a boolean). */
|
|
4
|
+
const VALUE_FLAGS = new Set([
|
|
5
|
+
"--registry",
|
|
6
|
+
"--tag",
|
|
7
|
+
"--access",
|
|
8
|
+
"--otp",
|
|
9
|
+
"--prefix",
|
|
10
|
+
"--workspace",
|
|
11
|
+
"-w",
|
|
12
|
+
"--userconfig",
|
|
13
|
+
"--globalconfig",
|
|
14
|
+
"--cache",
|
|
15
|
+
"--loglevel",
|
|
16
|
+
"--new-version",
|
|
17
|
+
"--filter",
|
|
18
|
+
"-F",
|
|
19
|
+
"--dir",
|
|
20
|
+
"-C",
|
|
21
|
+
"--cwd",
|
|
22
|
+
"--cidr",
|
|
23
|
+
"--name",
|
|
24
|
+
"--file",
|
|
25
|
+
"--repo",
|
|
26
|
+
"--packages",
|
|
27
|
+
"--scopes",
|
|
28
|
+
"--orgs",
|
|
29
|
+
"--expires",
|
|
30
|
+
"--token-description",
|
|
31
|
+
"--packages-and-scopes-permission",
|
|
32
|
+
"--orgs-permission",
|
|
33
|
+
"--auth-type",
|
|
34
|
+
"--scope",
|
|
35
|
+
"--publish-branch",
|
|
36
|
+
"--report-summary",
|
|
37
|
+
"--provenance-file",
|
|
38
|
+
"--json-file"
|
|
39
|
+
]);
|
|
40
|
+
/** Words and flags, as npm reads them (`--flag value`, `--flag=value`, `--no-flag`, `--` ends flags). */
|
|
41
|
+
export function parseNpmArgs(args) {
|
|
42
|
+
const words = [];
|
|
43
|
+
const flags = new Map();
|
|
44
|
+
for (let i = 0; i < args.length; i++) {
|
|
45
|
+
const arg = args[i];
|
|
46
|
+
if (arg === "--") {
|
|
47
|
+
words.push(...args.slice(i + 1));
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
if (arg.startsWith("-") && arg !== "-") {
|
|
51
|
+
const eq = arg.indexOf("=");
|
|
52
|
+
const name = eq > 0 ? arg.slice(0, eq) : arg;
|
|
53
|
+
if (eq > 0)
|
|
54
|
+
flags.set(name, arg.slice(eq + 1));
|
|
55
|
+
else if ((VALUE_FLAGS.has(name) || /^--@[^:]+:registry$/.test(name)) && args[i + 1] !== undefined)
|
|
56
|
+
flags.set(name, args[++i]);
|
|
57
|
+
else
|
|
58
|
+
flags.set(name, true);
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
words.push(arg);
|
|
62
|
+
}
|
|
63
|
+
return { words, flags };
|
|
64
|
+
}
|
|
65
|
+
const flagText = (parsed, ...names) => {
|
|
66
|
+
for (const name of names) {
|
|
67
|
+
const value = parsed.flags.get(name);
|
|
68
|
+
if (typeof value === "string")
|
|
69
|
+
return value;
|
|
70
|
+
}
|
|
71
|
+
return undefined;
|
|
72
|
+
};
|
|
73
|
+
const flagOn = (parsed, name) => {
|
|
74
|
+
const value = parsed.flags.get(name);
|
|
75
|
+
return value === true || value === "true";
|
|
76
|
+
};
|
|
77
|
+
/** Subcommands that never reach the registry as a write (npm's, pnpm's and yarn's own spellings). */
|
|
78
|
+
const LOCAL = new Set(`install i in ins inst insta instal isnt isnta isntal isntall add ci clean-install ic install-clean isntall-clean
|
|
79
|
+
install-test it install-ci-test cit run run-script rum urn test tst t start stop restart exec x dlx version verison
|
|
80
|
+
pack init innit create uninstall unlink remove rm r un update up upgrade udpate link ln rebuild rb prune dedupe ddp
|
|
81
|
+
find-dupes config c get set cache prefix root bin help help-search completion edit explore repo docs home bugs
|
|
82
|
+
issues pkg query sbom shrinkwrap set-script diff explain why fund licenses import patch patch-commit
|
|
83
|
+
patch-remove store env setup server recursive multi m outdated-local list-local licenses-list workspaces workspace
|
|
84
|
+
dedupe-check deploy fetch rebuild-local plugin constraints dlx-local node bun`.split(/\s+/));
|
|
85
|
+
/** Subcommands that only read the registry or this project. */
|
|
86
|
+
const READS = new Set([
|
|
87
|
+
"view",
|
|
88
|
+
"v",
|
|
89
|
+
"info",
|
|
90
|
+
"show",
|
|
91
|
+
"search",
|
|
92
|
+
"s",
|
|
93
|
+
"se",
|
|
94
|
+
"find",
|
|
95
|
+
"whoami",
|
|
96
|
+
"ls",
|
|
97
|
+
"list",
|
|
98
|
+
"la",
|
|
99
|
+
"ll",
|
|
100
|
+
"outdated",
|
|
101
|
+
"audit",
|
|
102
|
+
"ping",
|
|
103
|
+
"doctor",
|
|
104
|
+
"stars"
|
|
105
|
+
]);
|
|
106
|
+
/** pnpm hands these to npm; yarn's spellings are mapped before (`yarn npm tag add` is `dist-tag add`). */
|
|
107
|
+
const YARN_NAMES = { tag: "dist-tag", remove: "rm", list: "ls" };
|
|
108
|
+
function placeOf(files, folder, parsed, env) {
|
|
109
|
+
const project = files && folder ? projectFolder(files, folder) : null;
|
|
110
|
+
const user = files?.home ? npmrcRegistries(files.read(joinPath(files.home, ".npmrc"))) : { scopes: {} };
|
|
111
|
+
const local = files && project ? npmrcRegistries(files.read(joinPath(project.folder, ".npmrc"))) : { scopes: {} };
|
|
112
|
+
const scopes = { ...user.scopes, ...local.scopes };
|
|
113
|
+
for (const [name, value] of parsed.flags) {
|
|
114
|
+
const scope = /^--(@[a-z0-9][a-z0-9._~-]*):registry$/.exec(name)?.[1];
|
|
115
|
+
const host = typeof value === "string" ? registryHost(value) : null;
|
|
116
|
+
if (scope && host)
|
|
117
|
+
scopes[scope] = host;
|
|
118
|
+
}
|
|
119
|
+
const fromEnv = registryHost(env.npm_config_registry ?? env.NPM_CONFIG_REGISTRY);
|
|
120
|
+
const flag = flagText(parsed, "--registry");
|
|
121
|
+
const registry = (flag !== undefined ? (registryHost(flag) ?? UNKNOWN_REGISTRY) : null) ??
|
|
122
|
+
fromEnv ??
|
|
123
|
+
local.registry ??
|
|
124
|
+
user.registry ??
|
|
125
|
+
PUBLIC_REGISTRY;
|
|
126
|
+
return { folder: project?.folder ?? folder, pkg: project?.pkg ?? null, registry, scopes };
|
|
127
|
+
}
|
|
128
|
+
/** The registry a package is published to and read from: its scope's, else the command's. */
|
|
129
|
+
function hostFor(place, name, publishConfig) {
|
|
130
|
+
if (publishConfig) {
|
|
131
|
+
const host = registryHost(publishConfig);
|
|
132
|
+
if (host)
|
|
133
|
+
return host;
|
|
134
|
+
}
|
|
135
|
+
const scope = name?.startsWith("@") ? name.slice(0, name.indexOf("/")) : undefined;
|
|
136
|
+
return (scope && place.scopes[scope]) || place.registry;
|
|
137
|
+
}
|
|
138
|
+
/** `name@version` (`@scope/name@1.0.0`); either may be missing. */
|
|
139
|
+
export function packageSpec(spec) {
|
|
140
|
+
if (!spec)
|
|
141
|
+
return {};
|
|
142
|
+
const at = spec.lastIndexOf("@");
|
|
143
|
+
const name = at > 0 ? spec.slice(0, at) : spec;
|
|
144
|
+
const version = at > 0 ? spec.slice(at + 1) : undefined;
|
|
145
|
+
return {
|
|
146
|
+
...(isPackageName(name) ? { name } : {}),
|
|
147
|
+
...(version && VERSION.test(version) ? { version } : {})
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
function found(act) {
|
|
151
|
+
const nodes = act.scope ? npmChainOf(npmNodeIds.scope(act.host, act.scope)) : npmChain(act.host, act.name);
|
|
152
|
+
const leaf = nodes[nodes.length - 1];
|
|
153
|
+
return {
|
|
154
|
+
nodeId: leaf.id,
|
|
155
|
+
actionKey: act.actionKey,
|
|
156
|
+
summary: act.summary,
|
|
157
|
+
nodes,
|
|
158
|
+
...(act.target ? { target: act.target } : {})
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
const versionTarget = (host, name, version) => ({
|
|
162
|
+
type: "version",
|
|
163
|
+
key: `${host}/${name}/${version}`,
|
|
164
|
+
name: `${name}@${version}`
|
|
165
|
+
});
|
|
166
|
+
const tagTarget = (host, name, tag) => ({
|
|
167
|
+
type: "dist_tag",
|
|
168
|
+
key: `${host}/${name}/${tag}`,
|
|
169
|
+
name: tag
|
|
170
|
+
});
|
|
171
|
+
/** The command's subcommand words as npm names them: yarn's `npm` prefix and its spellings mapped. */
|
|
172
|
+
function commandWords(program, words) {
|
|
173
|
+
if (program !== "yarn")
|
|
174
|
+
return [...words];
|
|
175
|
+
const rest = words[0] === "npm" ? words.slice(1) : [...words];
|
|
176
|
+
if (rest[0] && YARN_NAMES[rest[0]] && (rest[0] === "tag" || words[0] === "npm"))
|
|
177
|
+
rest[0] = YARN_NAMES[rest[0]];
|
|
178
|
+
if (rest[0] === "dist-tag" && rest[1] && YARN_NAMES[rest[1]])
|
|
179
|
+
rest[1] = YARN_NAMES[rest[1]];
|
|
180
|
+
return rest;
|
|
181
|
+
}
|
|
182
|
+
/** The package a command names, else the one in its folder. */
|
|
183
|
+
function packageOf(place, spec) {
|
|
184
|
+
const named = packageSpec(spec);
|
|
185
|
+
if (named.name)
|
|
186
|
+
return named;
|
|
187
|
+
return {
|
|
188
|
+
...(place.pkg?.name ? { name: place.pkg.name } : {}),
|
|
189
|
+
...(place.pkg?.version ? { version: place.pkg.version } : {})
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
/** The read actions' words. */
|
|
193
|
+
function readSummary(words, name) {
|
|
194
|
+
const [first, second] = words;
|
|
195
|
+
if (first === "whoami")
|
|
196
|
+
return "Checked who is signed in";
|
|
197
|
+
if (first === "search" || first === "s" || first === "se" || first === "find")
|
|
198
|
+
return "Searched the registry";
|
|
199
|
+
if (first === "ping")
|
|
200
|
+
return "Checked the registry";
|
|
201
|
+
if (first === "doctor")
|
|
202
|
+
return "Checked the registry and this setup";
|
|
203
|
+
if (first === "audit")
|
|
204
|
+
return "Audited dependencies";
|
|
205
|
+
if (first === "outdated")
|
|
206
|
+
return "Checked for outdated dependencies";
|
|
207
|
+
if (first === "ls" || first === "list" || first === "la" || first === "ll")
|
|
208
|
+
return "Listed dependencies";
|
|
209
|
+
if (first === "dist-tag")
|
|
210
|
+
return name ? `Listed dist-tags of ${name}` : "Listed dist-tags";
|
|
211
|
+
if (first === "owner")
|
|
212
|
+
return name ? `Listed owners of ${name}` : "Listed owners";
|
|
213
|
+
if (first === "stage")
|
|
214
|
+
return second === "download" ? "Downloaded a staged release" : "Read staged releases";
|
|
215
|
+
if (first === "stars")
|
|
216
|
+
return "Listed starred packages";
|
|
217
|
+
return name ? `Viewed ${name}` : "Read the registry";
|
|
218
|
+
}
|
|
219
|
+
const pkgOf = (c, spec) => packageOf(c.place, spec);
|
|
220
|
+
/** Where a package's action lands: its registry, and its name when known. */
|
|
221
|
+
function on(c, spec) {
|
|
222
|
+
const { name } = pkgOf(c, spec);
|
|
223
|
+
return { host: hostFor(c.place, name), ...(name ? { name } : {}) };
|
|
224
|
+
}
|
|
225
|
+
const onRegistry = (c, actionKey, summary) => ({
|
|
226
|
+
actionKey,
|
|
227
|
+
summary,
|
|
228
|
+
host: c.place.registry
|
|
229
|
+
});
|
|
230
|
+
const exactTarget = (host, name, version) => name && version && EXACT_VERSION.test(version) ? { target: versionTarget(host, name, version) } : {};
|
|
231
|
+
/** The package a publish names: a folder argument, a workspace, else the folder's own; `all` for every workspace. */
|
|
232
|
+
function publishedPackage(c) {
|
|
233
|
+
const { parsed, place, files } = c;
|
|
234
|
+
const arg = c.words[1];
|
|
235
|
+
let pkg = place.pkg;
|
|
236
|
+
// `npm publish <folder>` publishes that folder; a tarball or a spec isn't read.
|
|
237
|
+
if (arg)
|
|
238
|
+
pkg =
|
|
239
|
+
files && place.folder && !/\.t(?:ar\.)?gz$/i.test(arg) && !arg.includes("@")
|
|
240
|
+
? packageJson(files, joinPath(place.folder, arg))
|
|
241
|
+
: null;
|
|
242
|
+
// `-w <name|folder>`: a workspace's folder, or its name.
|
|
243
|
+
const workspace = flagText(parsed, "--workspace", "-w");
|
|
244
|
+
if (workspace !== undefined) {
|
|
245
|
+
const inFolder = files && place.folder ? packageJson(files, joinPath(place.folder, workspace)) : null;
|
|
246
|
+
pkg = inFolder ?? (isPackageName(workspace) ? { name: workspace } : null);
|
|
247
|
+
}
|
|
248
|
+
const recursive = c.program === "pnpm" && (flagOn(parsed, "-r") || flagOn(parsed, "--recursive"));
|
|
249
|
+
return { pkg, all: flagOn(parsed, "--workspaces") || flagOn(parsed, "-ws") || recursive };
|
|
250
|
+
}
|
|
251
|
+
function whatOf(all, name, version) {
|
|
252
|
+
if (all)
|
|
253
|
+
return "every workspace package";
|
|
254
|
+
if (!name)
|
|
255
|
+
return "a package";
|
|
256
|
+
return version && EXACT_VERSION.test(version) ? `${name} ${version}` : name;
|
|
257
|
+
}
|
|
258
|
+
function publish(c) {
|
|
259
|
+
const { pkg, all } = publishedPackage(c);
|
|
260
|
+
const version = c.program === "yarn" ? (flagText(c.parsed, "--new-version") ?? pkg?.version) : pkg?.version;
|
|
261
|
+
const name = all ? undefined : pkg?.name;
|
|
262
|
+
const host = hostFor(c.place, name, pkg?.publishConfig?.registry);
|
|
263
|
+
// Every workspace package: one package's own settings say nothing of the rest.
|
|
264
|
+
const config = all ? undefined : pkg?.publishConfig;
|
|
265
|
+
const tag = flagText(c.parsed, "--tag") ?? config?.tag;
|
|
266
|
+
const access = flagText(c.parsed, "--access") ?? config?.access;
|
|
267
|
+
const what = whatOf(all, name, version);
|
|
268
|
+
if (flagOn(c.parsed, "--dry-run"))
|
|
269
|
+
return { actionKey: "npm.registry.read", summary: `Checked what publishing ${what} would do`, host };
|
|
270
|
+
const how = access === "public" ? " publicly" : access === "restricted" ? " privately" : "";
|
|
271
|
+
const as = tag && TAG.test(tag) && tag !== "latest" ? ` as ${tag}` : "";
|
|
272
|
+
return {
|
|
273
|
+
actionKey: "npm.package.publish",
|
|
274
|
+
summary: `Published ${what}${how}${as}`,
|
|
275
|
+
host,
|
|
276
|
+
...(name ? { name } : {}),
|
|
277
|
+
...exactTarget(host, name, version)
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
function unpublish(c) {
|
|
281
|
+
const spec = packageSpec(c.second);
|
|
282
|
+
// No spec: the folder's package at its version, as npm reads it.
|
|
283
|
+
const { name, version } = spec.name ? spec : pkgOf(c);
|
|
284
|
+
const where = on(c, name ?? c.second);
|
|
285
|
+
const summary = !name
|
|
286
|
+
? "Unpublished a package"
|
|
287
|
+
: version
|
|
288
|
+
? `Unpublished ${name} ${version}`
|
|
289
|
+
: `Unpublished every version of ${name}`;
|
|
290
|
+
return { actionKey: "npm.package.unpublish", summary, ...where, ...exactTarget(where.host, name, version) };
|
|
291
|
+
}
|
|
292
|
+
function deprecate(c) {
|
|
293
|
+
const { name, version } = packageSpec(c.second);
|
|
294
|
+
const what = `${name ?? "a package"}${version ? ` ${version}` : ""}`;
|
|
295
|
+
// An empty message takes the deprecation away.
|
|
296
|
+
const summary = c.third === "" ? `Removed the deprecation from ${what}` : `Deprecated ${what}`;
|
|
297
|
+
return { actionKey: "npm.package.deprecate", summary, ...on(c, name) };
|
|
298
|
+
}
|
|
299
|
+
function distTagAdd(c) {
|
|
300
|
+
const { name, version } = packageSpec(c.third);
|
|
301
|
+
const tag = c.fourth ?? flagText(c.parsed, "--tag") ?? "latest";
|
|
302
|
+
const where = on(c, name);
|
|
303
|
+
const safeTag = TAG.test(tag) ? tag : "a tag";
|
|
304
|
+
return {
|
|
305
|
+
actionKey: "npm.package.tag",
|
|
306
|
+
summary: version ? `Moved ${safeTag} to ${version}` : `Moved ${safeTag}`,
|
|
307
|
+
...where,
|
|
308
|
+
...(name && TAG.test(tag) ? { target: tagTarget(where.host, name, tag) } : {})
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
function distTagRemove(c) {
|
|
312
|
+
// `dist-tag rm <tag>` is the folder's package; `dist-tag rm <pkg> <tag>` names one.
|
|
313
|
+
const named = c.fourth !== undefined && packageSpec(c.third).name ? c.third : undefined;
|
|
314
|
+
const tag = named ? c.fourth : c.third;
|
|
315
|
+
const where = on(c, named);
|
|
316
|
+
const safeTag = tag && TAG.test(tag) ? tag : undefined;
|
|
317
|
+
return {
|
|
318
|
+
actionKey: "npm.package.tag",
|
|
319
|
+
summary: safeTag ? `Removed the ${safeTag} tag` : "Removed a dist-tag",
|
|
320
|
+
...where,
|
|
321
|
+
...(where.name && safeTag ? { target: tagTarget(where.host, where.name, safeTag) } : {})
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
function distTag(c) {
|
|
325
|
+
if (c.second === "add")
|
|
326
|
+
return distTagAdd(c);
|
|
327
|
+
if (c.second === "rm" || c.second === "remove")
|
|
328
|
+
return distTagRemove(c);
|
|
329
|
+
const where = on(c, c.second === "ls" ? c.third : undefined);
|
|
330
|
+
return { actionKey: "npm.registry.read", summary: readSummary(["dist-tag"], where.name), ...where };
|
|
331
|
+
}
|
|
332
|
+
function owner(c) {
|
|
333
|
+
if (c.second === "add" || c.second === "rm" || c.second === "remove") {
|
|
334
|
+
const user = c.third && USER.test(c.third) ? c.third : "someone";
|
|
335
|
+
return {
|
|
336
|
+
actionKey: "npm.package.owner",
|
|
337
|
+
summary: c.second === "add" ? `Added owner ${user}` : `Removed owner ${user}`,
|
|
338
|
+
...on(c, c.fourth)
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
const where = on(c, c.third);
|
|
342
|
+
return { actionKey: "npm.registry.read", summary: readSummary(["owner"], where.name), ...where };
|
|
343
|
+
}
|
|
344
|
+
const TEAM_WORDS = {
|
|
345
|
+
create: (_user, name) => `Created team ${name}`,
|
|
346
|
+
destroy: (_user, name) => `Deleted team ${name}`,
|
|
347
|
+
add: (user, name) => `Added ${user} to team ${name}`,
|
|
348
|
+
rm: (user, name) => `Removed ${user} from team ${name}`
|
|
349
|
+
};
|
|
350
|
+
function team(c) {
|
|
351
|
+
const match = c.second && c.third ? TEAM.exec(c.third) : null;
|
|
352
|
+
if (!match || c.second === "ls" || c.second === "list")
|
|
353
|
+
return onRegistry(c, "npm.registry.read", "Listed teams");
|
|
354
|
+
const words = Object.hasOwn(TEAM_WORDS, c.second) ? TEAM_WORDS[c.second] : undefined;
|
|
355
|
+
if (!words)
|
|
356
|
+
return "unknown";
|
|
357
|
+
const scope = `@${match[1].toLowerCase()}`;
|
|
358
|
+
const host = c.place.scopes[scope] ?? c.place.registry;
|
|
359
|
+
const name = `${match[1]}:${match[2]}`;
|
|
360
|
+
const user = c.fourth && USER.test(c.fourth) ? c.fourth : "someone";
|
|
361
|
+
return {
|
|
362
|
+
actionKey: "npm.scope.team",
|
|
363
|
+
summary: words(user, name),
|
|
364
|
+
host,
|
|
365
|
+
scope,
|
|
366
|
+
target: { type: "team", key: `${host}/${scope}/${match[2]}`, name }
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
function org(c) {
|
|
370
|
+
if (c.second === "ls" || c.second === "list" || !c.third)
|
|
371
|
+
return onRegistry(c, "npm.registry.read", "Listed org members");
|
|
372
|
+
const match = /^@?([a-z0-9][a-z0-9._-]{0,213})$/i.exec(c.third);
|
|
373
|
+
if (!match || !["set", "add", "rm"].includes(c.second ?? ""))
|
|
374
|
+
return "unknown";
|
|
375
|
+
const scope = `@${match[1].toLowerCase()}`;
|
|
376
|
+
const user = c.fourth && USER.test(c.fourth) ? c.fourth : "someone";
|
|
377
|
+
const role = c.words[4] && /^(developer|admin|owner)$/.test(c.words[4]) ? ` as ${c.words[4]}` : "";
|
|
378
|
+
const summary = c.second === "rm" ? `Removed ${user} from ${scope}` : `Added ${user} to ${scope}${role}`;
|
|
379
|
+
return { actionKey: "npm.scope.org", summary, host: c.place.scopes[scope] ?? c.place.registry, scope };
|
|
380
|
+
}
|
|
381
|
+
function token(c) {
|
|
382
|
+
if (c.second === "create") {
|
|
383
|
+
const readOnly = flagOn(c.parsed, "--read-only") || flagText(c.parsed, "--packages-and-scopes-permission") === "read-only";
|
|
384
|
+
return onRegistry(c, "npm.registry.token", readOnly ? "Created a read-only token" : "Created a token");
|
|
385
|
+
}
|
|
386
|
+
if (c.second === "revoke" || c.second === "rm" || c.second === "delete")
|
|
387
|
+
return onRegistry(c, "npm.registry.token", "Revoked a token");
|
|
388
|
+
return onRegistry(c, "npm.registry.read", "Listed tokens");
|
|
389
|
+
}
|
|
390
|
+
const login = (c) => onRegistry(c, "npm.registry.token", `Signed in to ${c.place.registry === UNKNOWN_REGISTRY ? "a registry" : c.place.registry}`);
|
|
391
|
+
const logout = (c) => onRegistry(c, "npm.registry.token", "Signed out of the registry");
|
|
392
|
+
function profile(c) {
|
|
393
|
+
if (c.second === "enable-2fa")
|
|
394
|
+
return onRegistry(c, "npm.registry.account", "Turned on two-factor authentication");
|
|
395
|
+
if (c.second === "disable-2fa")
|
|
396
|
+
return onRegistry(c, "npm.registry.account", "Turned off two-factor authentication");
|
|
397
|
+
if (c.second === "set") {
|
|
398
|
+
const prop = c.third && /^[a-z][a-z-]{0,31}$/.test(c.third) ? c.third : "a setting";
|
|
399
|
+
return onRegistry(c, "npm.registry.account", `Changed account ${prop}`);
|
|
400
|
+
}
|
|
401
|
+
return onRegistry(c, "npm.registry.read", "Read the account profile");
|
|
402
|
+
}
|
|
403
|
+
const PROVIDERS = { github: "a GitHub workflow", gitlab: "a GitLab pipeline" };
|
|
404
|
+
function trust(c) {
|
|
405
|
+
const where = on(c, c.third);
|
|
406
|
+
if (c.second === "list" || c.second === "ls" || !c.second)
|
|
407
|
+
return { actionKey: "npm.registry.read", summary: "Listed trusted publishers", ...where };
|
|
408
|
+
const name = where.name ?? "a package";
|
|
409
|
+
const revoke = c.second === "revoke" || c.second === "rm" || c.second === "remove";
|
|
410
|
+
const what = Object.hasOwn(PROVIDERS, c.second) ? PROVIDERS[c.second] : "a CI workflow";
|
|
411
|
+
const summary = revoke ? `Stopped trusting a CI workflow to publish ${name}` : `Trusted ${what} to publish ${name}`;
|
|
412
|
+
return { actionKey: "npm.package.trust", summary, ...where };
|
|
413
|
+
}
|
|
414
|
+
function stage(c) {
|
|
415
|
+
// A staged release is named by its id, or by `name@version`.
|
|
416
|
+
const spec = packageSpec(c.third);
|
|
417
|
+
const named = Boolean(spec.name && spec.version);
|
|
418
|
+
const where = named ? on(c, c.third) : { host: c.place.registry };
|
|
419
|
+
const stageId = c.third && SAFE_ID.test(c.third) && !spec.version ? ` ${c.third}` : "";
|
|
420
|
+
if (c.second === "approve" || c.second === "promote") {
|
|
421
|
+
const what = named ? `${spec.name} ${spec.version}` : `staged release${stageId}`;
|
|
422
|
+
return {
|
|
423
|
+
actionKey: "npm.package.publish",
|
|
424
|
+
summary: `Published ${what}`,
|
|
425
|
+
...where,
|
|
426
|
+
...exactTarget(where.host, named ? spec.name : undefined, spec.version)
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
if (c.second === "reject" || c.second === "rm" || c.second === "delete")
|
|
430
|
+
return { actionKey: "npm.package.stage", summary: `Rejected staged release${stageId}`, ...where };
|
|
431
|
+
if (c.second === "publish") {
|
|
432
|
+
// `stage publish <tarball>` names no package the guard can read; otherwise the folder's.
|
|
433
|
+
const { name, version } = c.third === undefined ? pkgOf(c) : {};
|
|
434
|
+
return {
|
|
435
|
+
actionKey: "npm.package.stage",
|
|
436
|
+
summary: `Staged ${name ? whatOf(false, name, version) : "a release"}`,
|
|
437
|
+
...on(c, name)
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
return onRegistry(c, "npm.registry.read", readSummary(["stage", c.second ?? ""], undefined));
|
|
441
|
+
}
|
|
442
|
+
const VIEWS = new Set(["view", "v", "info", "show"]);
|
|
443
|
+
function read(c) {
|
|
444
|
+
// `audit fix` installs; `outdated`, `ls` and `audit` read; `view <pkg>` names its package.
|
|
445
|
+
const first = c.words[0];
|
|
446
|
+
if (first === "audit" && c.second === "fix")
|
|
447
|
+
return "local";
|
|
448
|
+
const named = VIEWS.has(first) ? packageSpec(c.second).name : undefined;
|
|
449
|
+
return {
|
|
450
|
+
actionKey: "npm.registry.read",
|
|
451
|
+
summary: readSummary(c.words, named),
|
|
452
|
+
host: hostFor(c.place, named),
|
|
453
|
+
...(named ? { name: named } : {})
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
/** Each subcommand family's reader, by npm's spellings. */
|
|
457
|
+
const FAMILIES = {
|
|
458
|
+
publish,
|
|
459
|
+
unpublish,
|
|
460
|
+
deprecate,
|
|
461
|
+
"dist-tag": distTag,
|
|
462
|
+
"dist-tags": distTag,
|
|
463
|
+
owner,
|
|
464
|
+
author: owner,
|
|
465
|
+
access: (c) => accessAct(c.words, c.place, (spec) => on(c, spec)),
|
|
466
|
+
team,
|
|
467
|
+
org,
|
|
468
|
+
token,
|
|
469
|
+
login,
|
|
470
|
+
adduser: login,
|
|
471
|
+
"add-user": login,
|
|
472
|
+
logout,
|
|
473
|
+
profile,
|
|
474
|
+
trust,
|
|
475
|
+
stage
|
|
476
|
+
};
|
|
477
|
+
/** Each subcommand family, read into the action it takes; "local" for local work, "unknown" for anything else. */
|
|
478
|
+
function classifyWords(program, parsed, place, files) {
|
|
479
|
+
const words = commandWords(program, parsed.words);
|
|
480
|
+
const [first = "", second, third, fourth] = words;
|
|
481
|
+
const ctx = { program, parsed, place, files, words, second, third, fourth };
|
|
482
|
+
if (Object.hasOwn(FAMILIES, first))
|
|
483
|
+
return FAMILIES[first](ctx);
|
|
484
|
+
if (READS.has(first))
|
|
485
|
+
return read(ctx);
|
|
486
|
+
// `yarn` alone installs; `yarn <script>` and `pnpm <script>` run a script.
|
|
487
|
+
return !first || LOCAL.has(first) ? "local" : "unknown";
|
|
488
|
+
}
|
|
489
|
+
function accessAct(words, place, on) {
|
|
490
|
+
const [, second, third, fourth, fifth] = words;
|
|
491
|
+
const read = (name) => ({
|
|
492
|
+
actionKey: "npm.registry.read",
|
|
493
|
+
summary: name ? `Read who can access ${name}` : "Read package access",
|
|
494
|
+
...on(name)
|
|
495
|
+
});
|
|
496
|
+
// npm 9+: `access set status=public`, `set mfa=none`, `grant`, `revoke`; older: `access public`, `2fa-required`.
|
|
497
|
+
const setting = second === "set" ? third : second;
|
|
498
|
+
const pkgArg = second === "set" || second === "get" || second === "revoke"
|
|
499
|
+
? fourth
|
|
500
|
+
: second === "grant"
|
|
501
|
+
? fifth
|
|
502
|
+
: second === "list" || second === "ls-packages" || second === "ls-collaborators"
|
|
503
|
+
? undefined
|
|
504
|
+
: third;
|
|
505
|
+
const where = on(pkgArg);
|
|
506
|
+
const name = where.name ?? "a package";
|
|
507
|
+
const act = (summary) => ({ actionKey: "npm.package.access", summary, ...where });
|
|
508
|
+
if (setting === "status=public" || setting === "public")
|
|
509
|
+
return act(`Made ${name} public`);
|
|
510
|
+
if (setting === "status=private" || setting === "restricted" || setting === "status=restricted")
|
|
511
|
+
return act(`Made ${name} private`);
|
|
512
|
+
if (setting === "mfa=none" || setting === "2fa-not-required")
|
|
513
|
+
return act(`Stopped requiring 2FA to publish ${name}`);
|
|
514
|
+
if (setting === "mfa=publish" || setting === "mfa=automation" || setting === "2fa-required")
|
|
515
|
+
return act(`Required 2FA to publish ${name}`);
|
|
516
|
+
if (second === "grant") {
|
|
517
|
+
const team = fourth && TEAM.test(fourth) ? fourth.replace(/^@/, "") : "a team";
|
|
518
|
+
const level = third === "read-write" ? "read and write" : third === "read-only" ? "read" : "some";
|
|
519
|
+
return act(`Gave ${team} ${level} access to ${name}`);
|
|
520
|
+
}
|
|
521
|
+
if (second === "revoke") {
|
|
522
|
+
const team = third && TEAM.test(third) ? third.replace(/^@/, "") : "a team";
|
|
523
|
+
return act(`Took away ${team}'s access to ${name}`);
|
|
524
|
+
}
|
|
525
|
+
return read(where.name ? pkgArg : undefined);
|
|
526
|
+
}
|
|
527
|
+
/** The folder flags move a command to (`--prefix`, `pnpm -C`, `yarn --cwd`); null when the value isn't plain. */
|
|
528
|
+
function folderOf(call, parsed) {
|
|
529
|
+
const dir = flagText(parsed, "--prefix", "-C", "--dir", "--cwd");
|
|
530
|
+
if (dir === undefined)
|
|
531
|
+
return call.cwd;
|
|
532
|
+
if (call.cwd === null || /[$`*?[\]{}~]/.test(dir))
|
|
533
|
+
return null;
|
|
534
|
+
return joinPath(call.cwd, dir);
|
|
535
|
+
}
|
|
536
|
+
/** A command's coarse hit, for an action Passport can't name: the program and its first subcommand word. */
|
|
537
|
+
export function npmUnnamed(program, words) {
|
|
538
|
+
const first = words[0] && /^[a-z][a-z-]{0,30}$/.test(words[0]) ? ` ${words[0]}` : "";
|
|
539
|
+
return { via: "cli", command: `${program}${first}` };
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* What one `npm`, `pnpm` or `yarn` command does to a registry: one classification (with its chain from the registry
|
|
543
|
+
* down), or none for a local command. A subcommand npm doesn't have is the Unclassified action, with its hit; pnpm and
|
|
544
|
+
* yarn run a project's scripts by name, so an unknown word there is local.
|
|
545
|
+
*/
|
|
546
|
+
export function classifyNpm(call, files) {
|
|
547
|
+
const parsed = parseNpmArgs(call.args);
|
|
548
|
+
if (flagOn(parsed, "--help") || flagOn(parsed, "-h") || flagOn(parsed, "--version") || flagOn(parsed, "-v"))
|
|
549
|
+
return [];
|
|
550
|
+
const env = files?.env ?? {};
|
|
551
|
+
const place = placeOf(files, folderOf(call, parsed), parsed, env);
|
|
552
|
+
// `npm -g …` and `npm --global …` act on this computer's packages, as local as a project's.
|
|
553
|
+
const act = classifyWords(call.program, parsed, place, files);
|
|
554
|
+
if (act === "local")
|
|
555
|
+
return [];
|
|
556
|
+
if (act === "unknown") {
|
|
557
|
+
if (call.program !== "npm")
|
|
558
|
+
return [];
|
|
559
|
+
return [
|
|
560
|
+
{
|
|
561
|
+
...found({ actionKey: "npm.unclassified", summary: "Ran a command Passport can't name", host: place.registry }),
|
|
562
|
+
unnamed: npmUnnamed(call.program, parsed.words)
|
|
563
|
+
}
|
|
564
|
+
];
|
|
565
|
+
}
|
|
566
|
+
return [found(act)];
|
|
567
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The control plane for npm on this computer (`shared/controlPlaneNpm.ts`, copied as `controlPlaneNpm.generated.ts`):
|
|
3
|
+
* the guard reads each `npm`, `pnpm` and `yarn` command of a line in the folder it runs in (after a `cd`, `--prefix`,
|
|
4
|
+
* `-C` or `--cwd`; inside `sh -c`, `eval` and `env -S`) and asks `POST /api/cp/decide` once per command that acts on a
|
|
5
|
+
* registry. Local work (`install`, `ci`, `run`, `test`, `exec`, `version`, `pack`…) is never asked about.
|
|
6
|
+
*
|
|
7
|
+
* Only the classification leaves this computer: the registry's host, the package's name and version from its
|
|
8
|
+
* `package.json`, the classifier's fixed summaries, and the masked command (every flag value, an `--otp` among them,
|
|
9
|
+
* replaced). `.npmrc` is read for `registry` lines only: a token or password in it is never kept or sent.
|
|
10
|
+
*/
|
|
11
|
+
import type { Classification } from "./controlPlane.generated.js";
|
|
12
|
+
import { type CpAnswer } from "./controlPlaneGuard.js";
|
|
13
|
+
import type { Found } from "./controlPlaneOffline.js";
|
|
14
|
+
type ApiCall = (path: string, init: RequestInit) => Promise<Response>;
|
|
15
|
+
/** At most this many npm commands in one line are asked about; a line doing more is refused. */
|
|
16
|
+
export declare const MAX_NPM_COMMANDS = 8;
|
|
17
|
+
export declare const TOO_MANY_NPM = "Blocked by Passport: this command does more than 8 things on npm at once. Split it up so each can be checked.";
|
|
18
|
+
export type NpmWhere = {
|
|
19
|
+
cwd?: string | null;
|
|
20
|
+
env?: Record<string, string | undefined>;
|
|
21
|
+
home?: string;
|
|
22
|
+
};
|
|
23
|
+
/** One command: what it does, and its masked command line. */
|
|
24
|
+
export type NpmBundle = {
|
|
25
|
+
found: Classification[];
|
|
26
|
+
command?: string;
|
|
27
|
+
};
|
|
28
|
+
/** Every npm-family command of a line that acts on a registry, in order; one past the cap at most. */
|
|
29
|
+
export declare function readNpmLine(command: string, where?: NpmWhere): NpmBundle[];
|
|
30
|
+
/** The decide request for one command. */
|
|
31
|
+
export declare function npmDecideBody(bundle: NpmBundle, sessionId?: string): Record<string, unknown>;
|
|
32
|
+
/** Ask about one command under a new request id. A server that doesn't decide npm answers 400: undecided. */
|
|
33
|
+
export declare function askNpm(api: ApiCall, bundle: NpmBundle, sessionId: string | undefined, signal: AbortSignal): Promise<CpAnswer>;
|
|
34
|
+
export type NpmLinePlan = {
|
|
35
|
+
answer: CpAnswer;
|
|
36
|
+
label: string;
|
|
37
|
+
};
|
|
38
|
+
/** The guard's question for a line's npm commands: the worst answer, else the last. */
|
|
39
|
+
export declare function npmLinePlan(command: string, where: NpmWhere, open: () => Promise<ApiCall | null>, extra: {
|
|
40
|
+
sessionId?: string;
|
|
41
|
+
}, signal: AbortSignal): Promise<NpmLinePlan | null>;
|
|
42
|
+
/** What the line does on npm, for when Passport can't be reached (`controlPlaneOffline.ts`). */
|
|
43
|
+
export declare function npmFound(command: string, where: NpmWhere): Found[];
|
|
44
|
+
export {};
|