passport-bridge 0.47.0 → 0.48.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.
- package/dist/cliExec.js +2 -2
- package/dist/cliGitCredential.js +3 -9
- package/dist/cliHook.js +21 -3
- package/dist/cliHookDecide.d.ts +1 -0
- package/dist/cliHookDecide.js +21 -3
- package/dist/connectorKit/engine.generated.js +16 -6
- package/dist/connectorKit/githubCallEffects.generated.d.ts +23 -0
- package/dist/connectorKit/githubCallEffects.generated.js +99 -0
- package/dist/connectorKit/githubDecide.generated.d.ts +57 -0
- package/dist/connectorKit/githubDecide.generated.js +263 -0
- package/dist/{controlPlaneGithubCatalog.generated.d.ts → connectorKit/githubIds.generated.d.ts} +15 -12
- package/dist/{controlPlaneGithubCatalog.generated.js → connectorKit/githubIds.generated.js} +2 -33
- package/dist/connectorKit/http.generated.d.ts +33 -0
- package/dist/connectorKit/http.generated.js +399 -0
- package/dist/connectorKit/manifest.generated.d.ts +10 -1
- package/dist/connectorKit/manifests/github.generated.d.ts +1 -0
- package/dist/connectorKit/manifests/github.generated.js +39 -3
- package/dist/connectorKit/manifests/githubActionList.generated.d.ts +37 -0
- package/dist/connectorKit/manifests/githubActionList.generated.js +28 -0
- package/dist/connectorKit/manifests/githubCapture.generated.js +150 -84
- package/dist/connectorKit/manifests/githubGenerated.generated.d.ts +40 -0
- package/dist/connectorKit/manifests/githubGenerated.generated.js +143 -0
- package/dist/connectorKit/manifests/githubHooks.generated.d.ts +8 -0
- package/dist/connectorKit/manifests/githubHooks.generated.js +229 -29
- package/dist/connectorKit/manifests/githubReads.generated.js +23 -24
- package/dist/connectorKit/shadow.generated.d.ts +4 -10
- package/dist/connectorKit/shadow.generated.js +4 -40
- package/dist/connectorKit/sources/github/actions.generated.d.ts +306 -0
- package/dist/connectorKit/sources/github/actions.generated.js +2 -0
- package/dist/connectorKit/sources/github/catalog.generated.d.ts +2220 -0
- package/dist/connectorKit/sources/github/catalog.generated.js +2 -0
- package/dist/controlPlane.generated.d.ts +20 -17
- package/dist/controlPlane.generated.js +14 -27
- package/dist/controlPlaneActions.generated.d.ts +144 -0
- package/dist/controlPlaneActions.generated.js +169 -0
- package/dist/controlPlaneGuard.d.ts +7 -7
- package/dist/controlPlaneGuard.js +28 -40
- package/dist/cpCli.d.ts +2 -0
- package/dist/cpCli.js +7 -1
- package/dist/execGithubRepo.js +6 -5
- package/dist/gitPush.d.ts +11 -11
- package/dist/gitPush.js +21 -7
- package/dist/kitShadow.d.ts +2 -11
- package/dist/kitShadow.js +2 -7
- package/dist/launcherFastPath.js +2 -0
- package/dist/pluginPin.d.ts +1 -1
- package/dist/pluginPin.js +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/dist/controlPlaneGithub.generated.d.ts +0 -45
- package/dist/controlPlaneGithub.generated.js +0 -101
- package/dist/controlPlaneGithubApi.generated.d.ts +0 -17
- package/dist/controlPlaneGithubApi.generated.js +0 -172
- package/dist/controlPlaneGithubCli.generated.d.ts +0 -104
- package/dist/controlPlaneGithubCli.generated.js +0 -367
- package/dist/controlPlaneGithubWebhook.generated.d.ts +0 -30
- package/dist/controlPlaneGithubWebhook.generated.js +0 -105
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
// Generated by scripts/generate-control-plane-classifier.mjs. Do not edit.
|
|
2
|
+
/**
|
|
3
|
+
* GitHub's decision through the kit (docs/design/v23/github-kit.md, Phase 1): what one request does, by the kit's
|
|
4
|
+
* GitHub manifest (`manifests/github.ts`) and its hooks (`manifests/githubHooks.ts`), in the shape the guard, the
|
|
5
|
+
* credential helper, `passport exec` and the gateway read. Pure and synchronous; the bridge ships a copy.
|
|
6
|
+
*
|
|
7
|
+
* `context` is what the inventory knows of a repository's branches (the server). Without one (the guard on a
|
|
8
|
+
* computer) every named branch is its own node, which the server maps to its pattern node.
|
|
9
|
+
*
|
|
10
|
+
* A target is the canonical string (`githubTarget`): JSON of the named fields, the kit's `ActionTarget.key`, so a
|
|
11
|
+
* decision records the same digest whichever side classified it.
|
|
12
|
+
*/
|
|
13
|
+
import { classify } from "./engine.generated.js";
|
|
14
|
+
import { httpLineOf, urlParts } from "./http.generated.js";
|
|
15
|
+
import { GITHUB } from "./manifests/github.generated.js";
|
|
16
|
+
import { githubHooks, worstCasePush as kitWorstCase } from "./manifests/githubHooks.generated.js";
|
|
17
|
+
import { GH_COMMANDS } from "./manifests/githubReads.generated.js";
|
|
18
|
+
import { ghCallArgs, githubCallFacts } from "./githubCallEffects.generated.js";
|
|
19
|
+
/** Without branches the hooks hold nothing per call: built once. */
|
|
20
|
+
let exactHooks;
|
|
21
|
+
function asKit(request, org) {
|
|
22
|
+
if (request.interface === "mcp")
|
|
23
|
+
return { request, context: {} };
|
|
24
|
+
if (request.interface === "api")
|
|
25
|
+
return {
|
|
26
|
+
request: {
|
|
27
|
+
interface: "api",
|
|
28
|
+
method: request.method,
|
|
29
|
+
url: request.path,
|
|
30
|
+
...(request.body ? { body: request.body } : {})
|
|
31
|
+
},
|
|
32
|
+
context: {}
|
|
33
|
+
};
|
|
34
|
+
const linked = {};
|
|
35
|
+
if (request.cwdRepo)
|
|
36
|
+
Object.assign(linked, { owner: request.cwdRepo.owner, repo: request.cwdRepo.repo });
|
|
37
|
+
if (request.currentBranch)
|
|
38
|
+
linked.branch = request.currentBranch;
|
|
39
|
+
if (org)
|
|
40
|
+
linked.org = org;
|
|
41
|
+
return { request: { interface: "cli", argv: request.argv }, context: { linked } };
|
|
42
|
+
}
|
|
43
|
+
function asGithub(found) {
|
|
44
|
+
return {
|
|
45
|
+
nodeId: found.nodeId,
|
|
46
|
+
actionKey: found.actionKey,
|
|
47
|
+
summary: found.summary,
|
|
48
|
+
...(found.target ? { target: found.target.key } : {}),
|
|
49
|
+
...(found.unnamed ? { unnamed: found.unnamed } : {})
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Every consequential thing one request does, in order: one entry, except a `git push` naming several refs (one per
|
|
54
|
+
* ref, worst first). Empty when nothing is consequential. Enforcement decides each and blocks when any one is.
|
|
55
|
+
*/
|
|
56
|
+
export function classifyGithubAll(request, context) {
|
|
57
|
+
const hooks = context
|
|
58
|
+
? githubHooks(GITHUB, { known: context.knownBranches, defaultBranch: context.defaultBranch })
|
|
59
|
+
: (exactHooks ??= githubHooks(GITHUB));
|
|
60
|
+
if (request.interface === "cli") {
|
|
61
|
+
const line = httpLineOf(request.argv, request.stdin === true);
|
|
62
|
+
if (line)
|
|
63
|
+
return githubHttp(line, request.argv, [...(request.apiHosts ?? []), ...(context?.apiHosts ?? [])], hooks);
|
|
64
|
+
}
|
|
65
|
+
const kit = asKit(request, context?.org);
|
|
66
|
+
const found = classify(GITHUB, kit.request, kit.context, hooks);
|
|
67
|
+
const list = (found === null ? [] : Array.isArray(found) ? found : [found]).map(asGithub);
|
|
68
|
+
const args = request.interface === "mcp"
|
|
69
|
+
? { fields: request.args }
|
|
70
|
+
: request.interface === "api"
|
|
71
|
+
? request.body
|
|
72
|
+
? { fields: request.body }
|
|
73
|
+
: {}
|
|
74
|
+
: ghCallArgs(request.argv);
|
|
75
|
+
// MCP and API bodies are read whole; a gh command line is read by its flags and `-f` fields.
|
|
76
|
+
return list.map((entry) => withFacts(entry, args, request.interface !== "api" || Boolean(request.body)));
|
|
77
|
+
}
|
|
78
|
+
/** A classification with what its call's arguments say (effects, environment, an elevated grant). */
|
|
79
|
+
function withFacts(found, args, bodyRead) {
|
|
80
|
+
return { ...found, ...githubCallFacts(found.actionKey, args, bodyRead) };
|
|
81
|
+
}
|
|
82
|
+
/* ------------------------------------------------------------------ */
|
|
83
|
+
/* Raw HTTP to GitHub's API (Phase 3): curl, wget, httpie */
|
|
84
|
+
/* ------------------------------------------------------------------ */
|
|
85
|
+
/** GitHub.com's API hosts (release assets upload to their own); an Enterprise Server's come from the connection
|
|
86
|
+
* (`GithubContext.apiHosts`). */
|
|
87
|
+
const API_HOST = "api.github.com";
|
|
88
|
+
const DOTCOM_HOSTS = [API_HOST, "uploads.github.com"];
|
|
89
|
+
/** A word that says a line is about GitHub even when its URL can't be read: `github` anywhere (`$GITHUB_TOKEN`, an
|
|
90
|
+
* Accept header, a host) or a `GH_*` variable (`$GH_TOKEN`, `$GH_ENTERPRISE_TOKEN`). Without one, it isn't claimed. */
|
|
91
|
+
const GITHUB_SIGNAL = /github|\bGH_[A-Z0-9_]+/i;
|
|
92
|
+
/** A request Passport can't place: Unclassified on GitHub's own node, naming only the tool. */
|
|
93
|
+
function targetUnknown(line) {
|
|
94
|
+
const command = line.tool === "httpie" ? "http" : line.tool;
|
|
95
|
+
return {
|
|
96
|
+
nodeId: "github",
|
|
97
|
+
actionKey: "github.unclassified",
|
|
98
|
+
summary: `Unclassified action: ${command} (target unknown)`,
|
|
99
|
+
unnamed: { via: "cli", command }
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/** The API path a URL names on one of GitHub's API hosts (`/api/v3` and `/api/graphql` on an Enterprise Server). */
|
|
103
|
+
function apiPath(url, hosts) {
|
|
104
|
+
const parts = urlParts(url);
|
|
105
|
+
if (!parts || !hosts.includes(parts.host))
|
|
106
|
+
return null;
|
|
107
|
+
if (DOTCOM_HOSTS.includes(parts.host))
|
|
108
|
+
return parts.path;
|
|
109
|
+
if (parts.path === "/api/graphql")
|
|
110
|
+
return "/graphql";
|
|
111
|
+
return parts.path.startsWith("/api/v3/") ? parts.path.slice("/api/v3".length) : null;
|
|
112
|
+
}
|
|
113
|
+
/** API rules whose condition reads the body (`body` and a `when`): a body that can't be read may decide which action
|
|
114
|
+
* it is. A condition on the path (a workflow file) is read either way. */
|
|
115
|
+
const bodyRules = GITHUB.capture.api.rules
|
|
116
|
+
.filter((rule) => rule.body?.length && rule.when && Object.keys(rule.when).some((name) => name !== "path"))
|
|
117
|
+
.map((rule) => {
|
|
118
|
+
const [method, template] = rule.match.split(" ");
|
|
119
|
+
return { method, re: new RegExp(`^${template.replace(/\{\w+\}/g, "[^/]+")}$`) };
|
|
120
|
+
});
|
|
121
|
+
const bodyDecides = (method, path) => bodyRules.some((rule) => rule.method === method && rule.re.test(path.replace(/\/+$/, "")));
|
|
122
|
+
/**
|
|
123
|
+
* A curl, wget or httpie line: decided as the API request it sends, by the same rules and generated catalog as every
|
|
124
|
+
* route, so one rule covers `gh`, MCP and raw HTTP. Headers, cookies and query strings are never read. A line whose
|
|
125
|
+
* URL can't be read (a variable, several URLs) fails closed when it is about GitHub; a body that can't be read names
|
|
126
|
+
* no exact target, and fails closed where the body decides the action.
|
|
127
|
+
*/
|
|
128
|
+
function githubHttp(line, argv, enterprise, hooks) {
|
|
129
|
+
const hosts = [...DOTCOM_HOSTS, ...enterprise.map((host) => host.toLowerCase().replace(/\.$/, ""))];
|
|
130
|
+
const about = argv.some((word) => GITHUB_SIGNAL.test(word) || hosts.some((host) => word.toLowerCase().includes(host)));
|
|
131
|
+
// A line about GitHub whose target can't be read (no URL, a variable, several, a config file) fails closed.
|
|
132
|
+
if (line.problem)
|
|
133
|
+
return about ? [targetUnknown(line)] : [];
|
|
134
|
+
if (!urlParts(line.url))
|
|
135
|
+
return about ? [targetUnknown(line)] : [];
|
|
136
|
+
const path = apiPath(line.url, hosts);
|
|
137
|
+
// A GitHub API host, but a path outside its API (an Enterprise Server's web pages): Passport can't place it.
|
|
138
|
+
if (path === null)
|
|
139
|
+
return hosts.includes(urlParts(line.url).host) ? [targetUnknown(line)] : [];
|
|
140
|
+
if ((line.method === "GET" || line.method === "HEAD") && !line.opaque)
|
|
141
|
+
return [];
|
|
142
|
+
if (line.opaque && (path === "/graphql" || bodyDecides(line.method, path)))
|
|
143
|
+
return [targetUnknown(line)];
|
|
144
|
+
const found = classify(GITHUB, {
|
|
145
|
+
interface: "api",
|
|
146
|
+
method: line.method,
|
|
147
|
+
url: path,
|
|
148
|
+
...(line.opaque ? { body: { force: true } } : line.body ? { body: line.body } : {})
|
|
149
|
+
}, {}, hooks);
|
|
150
|
+
const list = (found === null ? [] : [found].flat()).map(asGithub);
|
|
151
|
+
const args = !line.opaque && line.body ? { fields: line.body } : {};
|
|
152
|
+
const decided = list.map((entry) => withFacts(entry, args, Boolean(args.fields)));
|
|
153
|
+
// A body that can't be read names no exact target.
|
|
154
|
+
return line.opaque ? decided.map(({ target: _target, ...rest }) => rest) : decided;
|
|
155
|
+
}
|
|
156
|
+
const PUSH_ORDER = ["github.branch.delete", "github.branch.force", "github.repo.tag", "github.branch.push"];
|
|
157
|
+
/** A push's order: a delete, then a force-push, a tag, a push (anything else ranks before them). */
|
|
158
|
+
export const pushRank = (found) => PUSH_ORDER.indexOf(found.actionKey);
|
|
159
|
+
/** The single most consequential thing a request does, or null. For a command line, use `classifyGithubAll`. */
|
|
160
|
+
export function classifyGithub(request, context) {
|
|
161
|
+
return [...classifyGithubAll(request, context)].sort((a, b) => pushRank(a) - pushRank(b))[0] ?? null;
|
|
162
|
+
}
|
|
163
|
+
const programOf = (word) => (word ?? "").replace(/^.*\//, "").replace(/\.exe$/i, "");
|
|
164
|
+
const GIT_GLOBAL_VALUES = new Set(["-C", "-c", "--git-dir", "--work-tree", "--namespace"]);
|
|
165
|
+
/** Whether a command line is `git push` (git's own options before it don't count). */
|
|
166
|
+
export function isGitPush(argv) {
|
|
167
|
+
if (programOf(argv[0]) !== "git")
|
|
168
|
+
return false;
|
|
169
|
+
let index = 1;
|
|
170
|
+
while ((argv[index] ?? "").startsWith("-"))
|
|
171
|
+
index += GIT_GLOBAL_VALUES.has(argv[index]) ? 2 : 1;
|
|
172
|
+
return argv[index] === "push";
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Every ref a `git push` moves, one classification each, worst first, with the worst case for what it can't name;
|
|
176
|
+
* null when it isn't a push to GitHub (or is a dry run).
|
|
177
|
+
*/
|
|
178
|
+
export function classifyGitPushRefs(args, context) {
|
|
179
|
+
if (!isGitPush(args.argv))
|
|
180
|
+
return null;
|
|
181
|
+
const found = classifyGithubAll({ interface: "cli", ...args }, context);
|
|
182
|
+
return found.length ? found : null;
|
|
183
|
+
}
|
|
184
|
+
/** The worst a push to branches it doesn't name can do: force-push and delete, on the repository. */
|
|
185
|
+
export function worstCasePush(r, why) {
|
|
186
|
+
return kitWorstCase(r, why).map(asGithub);
|
|
187
|
+
}
|
|
188
|
+
/** The options of a gh command that take a value, as `-x` and `--long`, from the kit's flag table. */
|
|
189
|
+
export function ghValueFlags(command) {
|
|
190
|
+
const flags = Object.hasOwn(GH_COMMANDS, command) ? GH_COMMANDS[command] : [];
|
|
191
|
+
const out = new Set(["-R", "--repo"]);
|
|
192
|
+
for (const flag of flags) {
|
|
193
|
+
if (flag.value !== "required")
|
|
194
|
+
continue;
|
|
195
|
+
out.add(`--${flag.long}`);
|
|
196
|
+
if (flag.short)
|
|
197
|
+
out.add(`-${flag.short}`);
|
|
198
|
+
}
|
|
199
|
+
return out;
|
|
200
|
+
}
|
|
201
|
+
/** Words and options of one command. `valueFlags` are the options that take the next word as their value. */
|
|
202
|
+
export function parseArgs(args, valueFlags) {
|
|
203
|
+
const parsed = { pos: [], opts: [] };
|
|
204
|
+
for (let index = 0; index < args.length; index++) {
|
|
205
|
+
const arg = args[index];
|
|
206
|
+
if (arg === "--") {
|
|
207
|
+
parsed.pos.push(...args.slice(index + 1));
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
210
|
+
if (arg.startsWith("--")) {
|
|
211
|
+
const eq = arg.indexOf("=");
|
|
212
|
+
const name = eq === -1 ? arg : arg.slice(0, eq);
|
|
213
|
+
if (eq !== -1)
|
|
214
|
+
parsed.opts.push([name, arg.slice(eq + 1)]);
|
|
215
|
+
else if (valueFlags.has(name))
|
|
216
|
+
parsed.opts.push([name, args[++index] ?? ""]);
|
|
217
|
+
else
|
|
218
|
+
parsed.opts.push([name, true]);
|
|
219
|
+
}
|
|
220
|
+
else if (arg.length > 1 && arg.startsWith("-")) {
|
|
221
|
+
const short = arg.slice(0, 2);
|
|
222
|
+
if (valueFlags.has(short))
|
|
223
|
+
parsed.opts.push([short, arg.length > 2 ? arg.slice(2).replace(/^=/, "") : (args[++index] ?? "")]);
|
|
224
|
+
else
|
|
225
|
+
for (const letter of arg.slice(1))
|
|
226
|
+
parsed.opts.push([`-${letter}`, true]);
|
|
227
|
+
}
|
|
228
|
+
else
|
|
229
|
+
parsed.pos.push(arg);
|
|
230
|
+
}
|
|
231
|
+
return parsed;
|
|
232
|
+
}
|
|
233
|
+
export const values = (parsed, ...names) => parsed.opts.flatMap(([name, value]) => (names.includes(name) && value !== true ? [value] : []));
|
|
234
|
+
export const lastValue = (parsed, ...names) => values(parsed, ...names).pop();
|
|
235
|
+
export const hasFlag = (parsed, ...names) => parsed.opts.some(([name]) => names.includes(name));
|
|
236
|
+
/**
|
|
237
|
+
* How `gh api` is read when only its method matters: GET or HEAD (no method, or one of those, and with no method no
|
|
238
|
+
* fields, as gh then sends a POST) is a read; any other method, or a body from `--input`, is a write.
|
|
239
|
+
*/
|
|
240
|
+
export function ghApiMethod(parsed) {
|
|
241
|
+
const explicit = lastValue(parsed, "-X", "--method")?.toUpperCase();
|
|
242
|
+
const fields = hasFlag(parsed, "-f", "--raw-field", "-F", "--field");
|
|
243
|
+
const input = hasFlag(parsed, "--input");
|
|
244
|
+
const method = explicit ?? (fields || input ? "POST" : "GET");
|
|
245
|
+
return { method, read: (method === "GET" || method === "HEAD") && !input };
|
|
246
|
+
}
|
|
247
|
+
/** A REST path's segments, decoded, without the host, query or fragment. */
|
|
248
|
+
export function apiSegments(path) {
|
|
249
|
+
return path
|
|
250
|
+
.trim()
|
|
251
|
+
.replace(/^https?:\/\/api\.github\.com/i, "")
|
|
252
|
+
.replace(/[?#].*$/, "")
|
|
253
|
+
.split("/")
|
|
254
|
+
.filter(Boolean)
|
|
255
|
+
.map((segment) => {
|
|
256
|
+
try {
|
|
257
|
+
return decodeURIComponent(segment);
|
|
258
|
+
}
|
|
259
|
+
catch {
|
|
260
|
+
return segment;
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
}
|
package/dist/{controlPlaneGithubCatalog.generated.d.ts → connectorKit/githubIds.generated.d.ts}
RENAMED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
import type {
|
|
1
|
+
/** GitHub node ids, branch matching, and the builders the webhook mapping writes summaries with (`manifests/githubEvents.ts`). Requests are classified by the kit (`githubDecide.ts`). */
|
|
2
|
+
import type { Effect } from "../controlPlaneActions.generated.js";
|
|
3
|
+
import type { UnnamedHit } from "../controlPlaneUnnamed.generated.js";
|
|
3
4
|
export declare const lower: (value: string) => string;
|
|
4
5
|
export declare const githubNodeIds: {
|
|
5
6
|
platform: string;
|
|
@@ -42,6 +43,10 @@ export type GithubRequest = {
|
|
|
42
43
|
repo: string;
|
|
43
44
|
};
|
|
44
45
|
currentBranch?: string;
|
|
46
|
+
/** The command reads standard input (a pipe into it, `<`, a heredoc): httpie sends it as the body. */
|
|
47
|
+
stdin?: true;
|
|
48
|
+
/** A GitHub Enterprise Server's API hosts (the connection's), beside api.github.com, for raw HTTP lines. */
|
|
49
|
+
apiHosts?: readonly string[];
|
|
45
50
|
} | {
|
|
46
51
|
interface: "api";
|
|
47
52
|
method: string;
|
|
@@ -52,6 +57,8 @@ export type GithubContext = {
|
|
|
52
57
|
knownBranches: (owner: string, repo: string) => readonly string[];
|
|
53
58
|
defaultBranch: (owner: string, repo: string) => string | null;
|
|
54
59
|
org?: string;
|
|
60
|
+
/** A GitHub Enterprise Server's hosts (the connection's), beside api.github.com, for raw HTTP lines. */
|
|
61
|
+
apiHosts?: readonly string[];
|
|
55
62
|
};
|
|
56
63
|
export type GithubClassification = {
|
|
57
64
|
nodeId: string;
|
|
@@ -61,6 +68,12 @@ export type GithubClassification = {
|
|
|
61
68
|
target?: string;
|
|
62
69
|
/** On `github.unclassified`: the endpoint or command it hit, coarse (`controlPlaneUnnamed.ts`). */
|
|
63
70
|
unnamed?: UnnamedHit;
|
|
71
|
+
/** This call's effects from its arguments (`githubCallEffects.ts`); absent: the action's defaults. */
|
|
72
|
+
effects?: Effect[];
|
|
73
|
+
/** The deployment environment it names ("production"), for production. */
|
|
74
|
+
environment?: string;
|
|
75
|
+
/** It grants admin or owner, so it counts as production wherever it lands. */
|
|
76
|
+
elevated?: true;
|
|
64
77
|
};
|
|
65
78
|
export type GithubRepo = {
|
|
66
79
|
owner: string;
|
|
@@ -77,14 +90,10 @@ export type TargetFields = Record<string, string | number | null | undefined>;
|
|
|
77
90
|
*/
|
|
78
91
|
export declare function githubTarget(fields: TargetFields, primary: string): string | undefined;
|
|
79
92
|
export declare const withTarget: (found: GithubClassification, target: string | undefined) => GithubClassification;
|
|
80
|
-
export declare function withoutTarget(found: GithubClassification): GithubClassification;
|
|
81
93
|
export declare const onRepo: (r: Repo, actionKey: string, summary: string, target?: string) => GithubClassification;
|
|
82
94
|
/** A `gh` command Passport can't name: the Unclassified action (its own kind, 2026-11-17) on its repository (on
|
|
83
95
|
* Repositories when none is known), with what it hit. No target narrower than the node. */
|
|
84
96
|
export declare const unclassifiedGh: (r: Repo | null, unnamed?: UnnamedHit) => GithubClassification;
|
|
85
|
-
/** The repository writes named since 2026-11-17 (workflows, runs, pull requests, issues, comments, labels): on the
|
|
86
|
-
* repository, no exact target. `what` is the summary's verb phrase ("Run a workflow"). */
|
|
87
|
-
export declare const repoWrite: (r: Repo, actionKey: string, what: string) => GithubClassification;
|
|
88
97
|
/** The branch's own node, its most specific pattern node, or the repository when no node matches. */
|
|
89
98
|
export declare function branchTarget(r: Repo, branch: string, context: BranchContext): string;
|
|
90
99
|
export type BranchVerb = "push" | "force" | "delete";
|
|
@@ -115,8 +124,6 @@ export declare const collaborator: (r: Repo, login: string, permission?: string
|
|
|
115
124
|
/** A branch (or pattern) names its own target; a repository ruleset is targeted by its id when the path has one. */
|
|
116
125
|
export declare function protection(r: Repo, branch: string | null, context: BranchContext, ruleset?: string | null): GithubClassification;
|
|
117
126
|
export declare const orgProtection: (org: string, ruleset?: string | null) => GithubClassification;
|
|
118
|
-
/** GitHub stores secret names upper case. An environment's secret names its environment too. */
|
|
119
|
-
export declare const changeSecret: (name: string | null, owner: string, repo: string | null, environment?: string | null) => GithubClassification;
|
|
120
127
|
/** The invitee is a user id or an email address (hashed, never kept), with the role GitHub defaults to. */
|
|
121
128
|
export declare const invite: (org: string, login: string | null, invitee?: string | null, role?: string | null) => GithubClassification;
|
|
122
129
|
export type Bag = Record<string, unknown>;
|
|
@@ -124,11 +131,7 @@ export declare const isBag: (value: unknown) => value is Bag;
|
|
|
124
131
|
export declare const bagAt: (value: unknown, key: string) => Bag | undefined;
|
|
125
132
|
export declare const text: (value: unknown) => string | null;
|
|
126
133
|
export declare const textAt: (value: unknown, key: string) => string | null;
|
|
127
|
-
export declare const isTrue: (value: unknown) => value is true | "true";
|
|
128
|
-
export declare const isFalse: (value: unknown) => value is false | "false";
|
|
129
134
|
export declare function numberOf(value: unknown): number | null;
|
|
130
|
-
export declare function firstNumber(args: Bag, ...keys: string[]): number | null;
|
|
131
|
-
export declare function firstText(args: Bag, ...keys: string[]): string | null;
|
|
132
135
|
/** "owner/repo", a github.com URL (with or without .git), or a bare name under the context's organization. */
|
|
133
136
|
export declare function parseRepoRef(ref: string, org?: string): Repo | null;
|
|
134
137
|
export declare const NO_BRANCHES: BranchContext;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Generated by scripts/generate-control-plane-classifier.mjs. Do not edit.
|
|
2
|
-
/**
|
|
3
|
-
import { nodeId } from "
|
|
2
|
+
/** GitHub node ids, branch matching, and the builders the webhook mapping writes summaries with (`manifests/githubEvents.ts`). Requests are classified by the kit (`githubDecide.ts`). */
|
|
3
|
+
import { nodeId } from "../controlPlane.generated.js";
|
|
4
4
|
/* ------------------------------------------------------------------ */
|
|
5
5
|
/* Node ids */
|
|
6
6
|
/* ------------------------------------------------------------------ */
|
|
@@ -124,10 +124,6 @@ export function githubTarget(fields, primary) {
|
|
|
124
124
|
return JSON.stringify(entries.map(([key, entry]) => [key, String(entry)]));
|
|
125
125
|
}
|
|
126
126
|
export const withTarget = (found, target) => target === undefined ? found : { ...found, target };
|
|
127
|
-
export function withoutTarget(found) {
|
|
128
|
-
const { target: _target, ...rest } = found;
|
|
129
|
-
return rest;
|
|
130
|
-
}
|
|
131
127
|
export const onRepo = (r, actionKey, summary, target) => withTarget({ nodeId: repoNode(r.owner, r.repo), actionKey, summary }, target);
|
|
132
128
|
/** A `gh` command Passport can't name: the Unclassified action (its own kind, 2026-11-17) on its repository (on
|
|
133
129
|
* Repositories when none is known), with what it hit. No target narrower than the node. */
|
|
@@ -145,9 +141,6 @@ export const unclassifiedGh = (r, unnamed) => ({
|
|
|
145
141
|
}),
|
|
146
142
|
...(unnamed ? { unnamed } : {})
|
|
147
143
|
});
|
|
148
|
-
/** The repository writes named since 2026-11-17 (workflows, runs, pull requests, issues, comments, labels): on the
|
|
149
|
-
* repository, no exact target. `what` is the summary's verb phrase ("Run a workflow"). */
|
|
150
|
-
export const repoWrite = (r, actionKey, what) => onRepo(r, actionKey, `${what} in ${slug(r)}`);
|
|
151
144
|
/** The branch's own node, its most specific pattern node, or the repository when no node matches. */
|
|
152
145
|
export function branchTarget(r, branch, context) {
|
|
153
146
|
const known = [...context.knownBranches(r.owner, r.repo)];
|
|
@@ -214,12 +207,6 @@ export function protection(r, branch, context, ruleset) {
|
|
|
214
207
|
}, githubTarget({ branch }, "branch"));
|
|
215
208
|
}
|
|
216
209
|
export const orgProtection = (org, ruleset) => withTarget({ nodeId: orgNode(org), actionKey: "github.branch.protection", summary: `Change protection on ${lower(org)}` }, githubTarget({ ruleset }, "ruleset"));
|
|
217
|
-
/** GitHub stores secret names upper case. An environment's secret names its environment too. */
|
|
218
|
-
export const changeSecret = (name, owner, repo, environment) => withTarget({
|
|
219
|
-
nodeId: secretsNode(owner, repo ?? undefined),
|
|
220
|
-
actionKey: "github.secret.change",
|
|
221
|
-
summary: name === null ? "Change secrets" : `Change secret ${name}`
|
|
222
|
-
}, githubTarget({ name: name === null ? null : name.toUpperCase(), environment }, "name"));
|
|
223
210
|
/** The invitee is a user id or an email address (hashed, never kept), with the role GitHub defaults to. */
|
|
224
211
|
export const invite = (org, login, invitee, role) => withTarget({
|
|
225
212
|
nodeId: orgNode(org),
|
|
@@ -230,29 +217,11 @@ export const isBag = (value) => typeof value === "object" && value !== null && !
|
|
|
230
217
|
export const bagAt = (value, key) => isBag(value) && isBag(value[key]) ? value[key] : undefined;
|
|
231
218
|
export const text = (value) => (typeof value === "string" && value !== "" ? value : null);
|
|
232
219
|
export const textAt = (value, key) => text(isBag(value) ? value[key] : undefined);
|
|
233
|
-
export const isTrue = (value) => value === true || value === "true";
|
|
234
|
-
export const isFalse = (value) => value === false || value === "false";
|
|
235
220
|
export function numberOf(value) {
|
|
236
221
|
if (typeof value === "number" && Number.isInteger(value) && value > 0)
|
|
237
222
|
return value;
|
|
238
223
|
return typeof value === "string" && /^\d+$/.test(value) ? Number(value) : null;
|
|
239
224
|
}
|
|
240
|
-
export function firstNumber(args, ...keys) {
|
|
241
|
-
for (const key of keys) {
|
|
242
|
-
const found = numberOf(args[key]);
|
|
243
|
-
if (found !== null)
|
|
244
|
-
return found;
|
|
245
|
-
}
|
|
246
|
-
return null;
|
|
247
|
-
}
|
|
248
|
-
export function firstText(args, ...keys) {
|
|
249
|
-
for (const key of keys) {
|
|
250
|
-
const found = text(args[key]);
|
|
251
|
-
if (found !== null)
|
|
252
|
-
return found;
|
|
253
|
-
}
|
|
254
|
-
return null;
|
|
255
|
-
}
|
|
256
225
|
/** "owner/repo", a github.com URL (with or without .git), or a bare name under the context's organization. */
|
|
257
226
|
export function parseRepoRef(ref, org) {
|
|
258
227
|
const parts = ref
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Raw HTTP command lines (docs/design/v23/github-kit.md, Phase 3): `curl`, `wget` and httpie (`http`, `https`), read
|
|
3
|
+
* the way each tool reads its arguments, into one request: method, URL and, only to decide, a body. Generic: no app
|
|
4
|
+
* names; an app's hooks say which hosts are its own. Headers, cookies, credentials and query strings are never
|
|
5
|
+
* returned: only what decides the action (the method, the URL's path, and a body's fields).
|
|
6
|
+
*/
|
|
7
|
+
export type HttpTool = "curl" | "wget" | "httpie";
|
|
8
|
+
export type HttpLine = {
|
|
9
|
+
tool: HttpTool;
|
|
10
|
+
method: string;
|
|
11
|
+
/** The one URL the line sends to; absent when it names none it can read (`problem` says why). */
|
|
12
|
+
url?: string;
|
|
13
|
+
/** The body's fields when the line spells them out (inline JSON, `name=value`), to decide only; never kept. */
|
|
14
|
+
body?: Record<string, unknown>;
|
|
15
|
+
/** The line sends a body it can't read (a file, standard input, a binary): it may decide the action. */
|
|
16
|
+
opaque?: true;
|
|
17
|
+
/** Why the line's target can't be read: a URL the shell expands (a variable, a substitution, curl's globs), several
|
|
18
|
+
* URLs, none, or a line Passport can't read (a config file, a positional that isn't a URL). */
|
|
19
|
+
problem?: "variable" | "several" | "none" | "unreadable";
|
|
20
|
+
};
|
|
21
|
+
/** The tool a line runs, by its program's name ("/usr/bin/curl", "curl.exe"), or null. */
|
|
22
|
+
export declare function httpToolOf(program: string | undefined): HttpTool | null;
|
|
23
|
+
/** What a command line sends, when its program is curl, wget or httpie; null for any other program. `stdin`: the
|
|
24
|
+
* line reads standard input (a pipe into it, `<`, a heredoc), which httpie sends as the body. */
|
|
25
|
+
export declare function httpLineOf(argv: readonly string[], stdin?: boolean): HttpLine | null;
|
|
26
|
+
/**
|
|
27
|
+
* A URL's host and path (no query string, no fragment, no credentials), or null when it isn't an http(s) URL.
|
|
28
|
+
* httpie's shorthand (`:3000/x`, `example.com/x`) and a bare host get `https://`.
|
|
29
|
+
*/
|
|
30
|
+
export declare function urlParts(url: string): {
|
|
31
|
+
host: string;
|
|
32
|
+
path: string;
|
|
33
|
+
} | null;
|