passport-bridge 0.45.0 → 0.46.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/dist/cliArgs.d.ts +1 -1
  2. package/dist/cliArgs.js +3 -0
  3. package/dist/cliConnect.d.ts +3 -1
  4. package/dist/cliConnect.js +58 -6
  5. package/dist/cliConnections.d.ts +3 -3
  6. package/dist/cliConnections.js +13 -5
  7. package/dist/cliExec.js +1 -5
  8. package/dist/cliGitCredential.d.ts +2 -0
  9. package/dist/cliGitCredential.js +15 -7
  10. package/dist/cliGuardHealth.js +2 -1
  11. package/dist/cliHook.js +5 -1
  12. package/dist/cliHookAfter.js +2 -2
  13. package/dist/cliHookNotices.d.ts +7 -0
  14. package/dist/cliHookNotices.js +14 -0
  15. package/dist/cliMain.js +33 -3
  16. package/dist/cliOutput.js +4 -6
  17. package/dist/cliRequest.d.ts +65 -0
  18. package/dist/cliRequest.js +135 -0
  19. package/dist/cliScan.js +1 -1
  20. package/dist/cliSession.d.ts +0 -1
  21. package/dist/cliSession.js +0 -2
  22. package/dist/cliStatus.d.ts +4 -2
  23. package/dist/cliStatus.js +21 -4
  24. package/dist/cliSupport.d.ts +0 -8
  25. package/dist/completion.js +1 -0
  26. package/dist/connectorKit/engine.generated.d.ts +2 -2
  27. package/dist/connectorKit/engine.generated.js +23 -3
  28. package/dist/connectorKit/manifest.generated.d.ts +1 -1
  29. package/dist/connectorKit/manifests/github.generated.js +26 -3
  30. package/dist/connectorKit/manifests/githubCapture.generated.js +41 -10
  31. package/dist/connectorKit/manifests/githubHooks.generated.js +21 -1
  32. package/dist/connectorKit/manifests/githubReads.generated.d.ts +2 -0
  33. package/dist/connectorKit/manifests/githubReads.generated.js +30 -5
  34. package/dist/connectorKit/manifests/railway.generated.js +3 -3
  35. package/dist/connectorKit/manifests/supabase.generated.js +1 -1
  36. package/dist/connectorKit/manifests/supabaseCatalog.generated.js +3 -3
  37. package/dist/controlPlane.generated.d.ts +19 -18
  38. package/dist/controlPlane.generated.js +12 -17
  39. package/dist/controlPlaneGithub.generated.d.ts +2 -2
  40. package/dist/controlPlaneGithub.generated.js +12 -2
  41. package/dist/controlPlaneGithubApi.generated.d.ts +2 -0
  42. package/dist/controlPlaneGithubApi.generated.js +56 -1
  43. package/dist/controlPlaneGithubCatalog.generated.d.ts +9 -3
  44. package/dist/controlPlaneGithubCatalog.generated.js +19 -13
  45. package/dist/controlPlaneGithubCli.generated.d.ts +2 -0
  46. package/dist/controlPlaneGithubCli.generated.js +65 -12
  47. package/dist/controlPlaneGuard.js +2 -0
  48. package/dist/controlPlanePeople.generated.d.ts +117 -0
  49. package/dist/controlPlanePeople.generated.js +6 -0
  50. package/dist/controlPlaneRoutes.generated.d.ts +63 -0
  51. package/dist/controlPlaneRoutes.generated.js +111 -0
  52. package/dist/controlPlaneSupabase.js +3 -1
  53. package/dist/controlPlaneUnnamed.generated.d.ts +58 -0
  54. package/dist/controlPlaneUnnamed.generated.js +225 -0
  55. package/dist/cpCli.js +5 -1
  56. package/dist/gitCredentialRetire.d.ts +25 -0
  57. package/dist/gitCredentialRetire.js +143 -0
  58. package/dist/initAppsStep.d.ts +1 -1
  59. package/dist/initAppsStep.js +7 -5
  60. package/dist/initOutro.js +13 -10
  61. package/dist/initState.d.ts +3 -2
  62. package/dist/initState.js +7 -18
  63. package/dist/localNotices.d.ts +22 -0
  64. package/dist/localNotices.js +100 -0
  65. package/dist/pluginPin.d.ts +1 -1
  66. package/dist/pluginPin.js +1 -1
  67. package/dist/version.d.ts +1 -1
  68. package/dist/version.js +1 -1
  69. package/dist/webLinks.d.ts +23 -6
  70. package/dist/webLinks.js +21 -22
  71. package/npm-shrinkwrap.json +8 -8
  72. package/package.json +1 -1
  73. package/dist/cliApprovalLink.d.ts +0 -5
  74. package/dist/cliApprovalLink.js +0 -21
@@ -0,0 +1,6 @@
1
+ // Generated by scripts/generate-control-plane-classifier.mjs. Do not edit.
2
+ /**
3
+ * v21 People's part of the control-plane contract (docs/design/v21/people.md): coverage per person, setup links and
4
+ * leaving. Re-exported from `controlPlane.ts`; changed only through the orchestrating session.
5
+ */
6
+ export {};
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Coverage per route (decided 2026-11-17, `docs/design/v22/visibility.md`): how each action reached an app, so an
3
+ * app's one coverage number splits into the door that is open. Pure; part of the contract with `controlPlane.ts`,
4
+ * changed only through the orchestrating session.
5
+ */
6
+ import type { UnnamedHit } from "./controlPlaneUnnamed.generated.js";
7
+ /** `Interface` and the event fields read here, spelled out so `controlPlane.ts` can import this file. */
8
+ type Via = "mcp" | "cli" | "api" | "platform";
9
+ /**
10
+ * How an action reached the app. `gh`, `git`: the CLI the event says it came from; `cli`: any other CLI (railway,
11
+ * supabase). `platform`: seen only in the app's own log, so the route is unknown ("Outside").
12
+ */
13
+ export declare const ROUTES: readonly ["gh", "git", "cli", "mcp", "api", "platform"];
14
+ export type Route = (typeof ROUTES)[number];
15
+ /** One route of a deep app over the coverage window, counted as `managedCoverageOf` counts (app traffic and events
16
+ * on an account Passport isn't connected to left out). The routes' totals add up to the app's `coverage.total`. */
17
+ export type CpRouteCoverage = {
18
+ route: Route;
19
+ total: number;
20
+ /** Managed and Followed. */
21
+ through: number;
22
+ /** Unmanaged. */
23
+ outside: number;
24
+ /** Of `total`, actions Passport can't name yet (`*.unclassified`). */
25
+ unnamed: number;
26
+ /** Rounded percent of `total` through Passport; null when `total` is 0. */
27
+ percent: number | null;
28
+ /** Whose Unmanaged actions these were, most first, at most 3 (member ids): for Home's "To raise it", which names
29
+ * people and agents, never routes. Absent when none is known. */
30
+ people?: string[];
31
+ };
32
+ /** The actions a `git push` records: each ref moved, a tag, a workflow file in the pushed commits. */
33
+ export declare const GIT_PUSH_ACTIONS: ReadonlySet<string>;
34
+ export type RouteInput = {
35
+ platform: string;
36
+ interface: Via;
37
+ actionKey: string;
38
+ outcome?: string;
39
+ unnamed?: UnnamedHit;
40
+ };
41
+ /** The route of one event (the spec's rules, in order). */
42
+ export declare function routeOf(event: RouteInput): Route;
43
+ /** Each route's counts, in `ROUTES` order, routes with nothing left out. Pure. */
44
+ export declare function routeCoverage(rows: Iterable<{
45
+ route: Route;
46
+ cls: "managed" | "followed" | "unmanaged";
47
+ unnamed: boolean;
48
+ count: number;
49
+ personId?: string;
50
+ }>): CpRouteCoverage[];
51
+ /** Coverage per route straight from events (the web's example data; the server groups in its store): each event's
52
+ * class as `managedCoverageOf` decides it, app traffic and events on an account not connected left out. Pure. */
53
+ export declare function routesOfEvents(events: readonly (RouteInput & {
54
+ through: "passport" | "outside";
55
+ surface?: string;
56
+ cause?: {
57
+ through: string;
58
+ platform: string;
59
+ };
60
+ notConnected?: boolean;
61
+ personId?: string;
62
+ })[]): CpRouteCoverage[];
63
+ export {};
@@ -0,0 +1,111 @@
1
+ // Generated by scripts/generate-control-plane-classifier.mjs. Do not edit.
2
+ /**
3
+ * Coverage per route (decided 2026-11-17, `docs/design/v22/visibility.md`): how each action reached an app, so an
4
+ * app's one coverage number splits into the door that is open. Pure; part of the contract with `controlPlane.ts`,
5
+ * changed only through the orchestrating session.
6
+ */
7
+ /**
8
+ * How an action reached the app. `gh`, `git`: the CLI the event says it came from; `cli`: any other CLI (railway,
9
+ * supabase). `platform`: seen only in the app's own log, so the route is unknown ("Outside").
10
+ */
11
+ export const ROUTES = ["gh", "git", "cli", "mcp", "api", "platform"];
12
+ /** People a route names at most. */
13
+ const MAX_PEOPLE = 3;
14
+ /** The actions a `git push` records: each ref moved, a tag, a workflow file in the pushed commits. */
15
+ export const GIT_PUSH_ACTIONS = new Set([
16
+ "github.branch.push",
17
+ "github.branch.force",
18
+ "github.branch.delete",
19
+ "github.repo.tag",
20
+ "github.repo.workflow"
21
+ ]);
22
+ /** The CLI a command-line action came from. */
23
+ function programOf(platform, actionKey, unnamed) {
24
+ if (unnamed?.via === "cli") {
25
+ const program = unnamed.command.split(" ")[0];
26
+ return program === "gh" || program === "git" ? program : "cli";
27
+ }
28
+ if (platform !== "github")
29
+ return "cli";
30
+ // The guard asks GitHub about `gh` and `git push` lines only; an unnamed API call on a command line is `gh api`.
31
+ return GIT_PUSH_ACTIONS.has(actionKey) ? "git" : "gh";
32
+ }
33
+ /** The route of one event (the spec's rules, in order). */
34
+ export function routeOf(event) {
35
+ const via = event.interface;
36
+ if (via === "mcp" || via === "api")
37
+ return via;
38
+ if (via === "cli")
39
+ return programOf(event.platform, event.actionKey, event.unnamed);
40
+ // Passport's own credential with no decision: something used Passport's connection directly.
41
+ return event.outcome === "undecided" ? "api" : "platform";
42
+ }
43
+ /** Each route's counts, in `ROUTES` order, routes with nothing left out. Pure. */
44
+ export function routeCoverage(rows) {
45
+ const byRoute = new Map();
46
+ const peopleOf = new Map();
47
+ for (const row of rows) {
48
+ if (row.count <= 0)
49
+ continue;
50
+ const entry = byRoute.get(row.route) ?? {
51
+ route: row.route,
52
+ total: 0,
53
+ through: 0,
54
+ outside: 0,
55
+ unnamed: 0,
56
+ percent: null
57
+ };
58
+ entry.total += row.count;
59
+ if (row.cls === "unmanaged") {
60
+ entry.outside += row.count;
61
+ if (row.personId) {
62
+ const people = peopleOf.get(row.route) ?? new Map();
63
+ people.set(row.personId, (people.get(row.personId) ?? 0) + row.count);
64
+ peopleOf.set(row.route, people);
65
+ }
66
+ }
67
+ else
68
+ entry.through += row.count;
69
+ if (row.unnamed)
70
+ entry.unnamed += row.count;
71
+ byRoute.set(row.route, entry);
72
+ }
73
+ return ROUTES.flatMap((route) => {
74
+ const entry = byRoute.get(route);
75
+ if (!entry)
76
+ return [];
77
+ const people = [...(peopleOf.get(route) ?? new Map())]
78
+ .sort((a, b) => b[1] - a[1] || (a[0] < b[0] ? -1 : 1))
79
+ .slice(0, MAX_PEOPLE)
80
+ .map(([id]) => id);
81
+ return [
82
+ {
83
+ ...entry,
84
+ percent: entry.total ? Math.round((entry.through / entry.total) * 100) : null,
85
+ ...(people.length ? { people } : {})
86
+ }
87
+ ];
88
+ });
89
+ }
90
+ /** Coverage per route straight from events (the web's example data; the server groups in its store): each event's
91
+ * class as `managedCoverageOf` decides it, app traffic and events on an account not connected left out. Pure. */
92
+ export function routesOfEvents(events) {
93
+ return routeCoverage(events.flatMap((event) => {
94
+ if (event.notConnected === true || event.surface === "app")
95
+ return [];
96
+ const cls = event.through === "passport" && event.outcome !== "undecided"
97
+ ? "managed"
98
+ : event.cause?.through === "passport" && event.cause.platform === event.platform
99
+ ? "followed"
100
+ : "unmanaged";
101
+ return [
102
+ {
103
+ route: routeOf(event),
104
+ cls,
105
+ unnamed: event.actionKey.endsWith(".unclassified"),
106
+ count: 1,
107
+ ...(event.personId ? { personId: event.personId } : {})
108
+ }
109
+ ];
110
+ }));
111
+ }
@@ -194,7 +194,9 @@ const action = (found) => ({
194
194
  actionKey: found.actionKey,
195
195
  summary: found.summary.slice(0, MAX_SUMMARY),
196
196
  ...(found.target ? { target: found.target } : {}),
197
- ...(found.nodes?.length ? { nodes: found.nodes } : {})
197
+ ...(found.nodes?.length ? { nodes: found.nodes } : {}),
198
+ // What an unnamed action hit, coarse; the server makes it coarse again (`sanitizeUnnamed`).
199
+ ...(found.unnamed ? { unnamed: found.unnamed } : {})
198
200
  });
199
201
  /** The decide request for one bundle. */
200
202
  export function supabaseDecideBody(bundle, ask) {
@@ -0,0 +1,58 @@
1
+ /**
2
+ * What an action Passport can't name hit (`UnnamedHit`, decided 2026-11-17), made coarse: an API path becomes a
3
+ * template of the platform's own path words, a command line its program and known subcommand words. Pure; the
4
+ * server, the bridge and the kit share it. Never an owner, repository, number, id, sha, branch, query string, body,
5
+ * flag or argument: a segment or word that isn't the platform's own vocabulary is a placeholder or dropped.
6
+ */
7
+ /**
8
+ * What an action Passport can't name hit, so the next one to name is known (2026-11-17): an API call's method and
9
+ * path template (`repos/{owner}/{repo}/actions/runs/{id}/cancel`), or a command line's program and subcommand words
10
+ * (`gh run watch`). Never an owner, repository, number, id, branch, query string, body, flag or argument.
11
+ */
12
+ export type UnnamedHit = {
13
+ via: "api";
14
+ method?: string;
15
+ path?: string;
16
+ } | {
17
+ via: "cli";
18
+ command: string;
19
+ };
20
+ /** An app's action Passport can't name (`github.unclassified`). */
21
+ export declare const isUnclassifiedAction: (actionKey: string) => boolean;
22
+ /** The kind an event is shown as: Unclassified for an unnamed action whatever kind it was stored with (events
23
+ * from before 2026-11-17 recorded it as a Delete), else its own. */
24
+ export declare function displayKind<K extends string>(event: {
25
+ actionKey: string;
26
+ kind: K;
27
+ }): K | "unclassified";
28
+ export declare const UNNAMED_METHODS: readonly string[];
29
+ /** GitHub REST's literal path words (api.github.com), not exhaustive: any other segment becomes a placeholder. */
30
+ export declare const GITHUB_PATH_WORDS: ReadonlySet<string>;
31
+ /** Supabase's Management API path words (api.supabase.com/v1). */
32
+ export declare const SUPABASE_PATH_WORDS: ReadonlySet<string>;
33
+ /** Railway is GraphQL: its path is one word. */
34
+ export declare const RAILWAY_PATH_WORDS: ReadonlySet<string>;
35
+ export declare function pathWordsFor(platform: string): ReadonlySet<string>;
36
+ /**
37
+ * An API path as a template of the platform's own words: scheme, host, query and fragment dropped; the names after
38
+ * `repos`, `orgs`, `users` (as the first word) are `{owner}/{repo}`, `{org}`, `{user}`; any other segment stays only
39
+ * when it is one of `known`, else it is one placeholder named by the word before it (`{number}` after `pulls`,
40
+ * `{branch}` after `branches`, `{sha}` for a commit hash, else `{id}`), a run of them collapsed into one.
41
+ */
42
+ export declare function templatePath(raw: string, known: ReadonlySet<string>): string;
43
+ /**
44
+ * A command line as its program and at most two subcommand words: each a CLI word (`^[a-z][a-z-]{0,30}$`) and, for
45
+ * `gh` and `git`, one that CLI has, so a positional argument (a branch, a remote, a repository, a number) never
46
+ * passes as a subcommand. Flags end it. Null when the program itself isn't a plain name.
47
+ */
48
+ export declare function unnamedCommand(argv: readonly string[]): string | null;
49
+ /** An API call's hit: its method (one of the HTTP methods) and its path's template; either may be unknown. */
50
+ export declare function unnamedApi(platform: string, method: string | undefined, path?: string): UnnamedHit;
51
+ /** A command line's hit; undefined when nothing of it can be kept. */
52
+ export declare function unnamedCli(argv: readonly string[]): UnnamedHit | undefined;
53
+ /**
54
+ * What a caller sent (the bridge's classification) made coarse again, so nothing it adds survives: the method from
55
+ * the list, the path re-templated with the platform's words, the command re-read word by word. Anything else is
56
+ * dropped, never refused.
57
+ */
58
+ export declare function sanitizeUnnamed(platform: string, value: unknown): UnnamedHit | undefined;
@@ -0,0 +1,225 @@
1
+ // Generated by scripts/generate-control-plane-classifier.mjs. Do not edit.
2
+ /**
3
+ * What an action Passport can't name hit (`UnnamedHit`, decided 2026-11-17), made coarse: an API path becomes a
4
+ * template of the platform's own path words, a command line its program and known subcommand words. Pure; the
5
+ * server, the bridge and the kit share it. Never an owner, repository, number, id, sha, branch, query string, body,
6
+ * flag or argument: a segment or word that isn't the platform's own vocabulary is a placeholder or dropped.
7
+ */
8
+ /** An app's action Passport can't name (`github.unclassified`). */
9
+ export const isUnclassifiedAction = (actionKey) => actionKey.endsWith(".unclassified");
10
+ /** The kind an event is shown as: Unclassified for an unnamed action whatever kind it was stored with (events
11
+ * from before 2026-11-17 recorded it as a Delete), else its own. */
12
+ export function displayKind(event) {
13
+ return isUnclassifiedAction(event.actionKey) ? "unclassified" : event.kind;
14
+ }
15
+ export const UNNAMED_METHODS = ["POST", "PUT", "PATCH", "DELETE", "GET", "HEAD"];
16
+ const MAX_SEGMENTS = 12;
17
+ const MAX_PATH = 200;
18
+ /** A subcommand word as a CLI spells one. */
19
+ const COMMAND_WORD = /^[a-z][a-z-]{0,30}$/;
20
+ const words = (text) => new Set(text.split(/\s+/).filter(Boolean));
21
+ /** GitHub REST's literal path words (api.github.com), not exhaustive: any other segment becomes a placeholder. */
22
+ export const GITHUB_PATH_WORDS = words(`
23
+ repos orgs users user enterprises graphql app installations installation
24
+ actions workflows runs jobs dispatches cancel force-cancel rerun rerun-failed-jobs approve logs timing attempts
25
+ artifacts caches secrets variables runners runner-groups permissions oidc environments deployment-protection-rules
26
+ pulls issues comments reviews requested_reviewers merge update-branch files commits labels assignees milestones
27
+ events timeline reactions lock sub_issues
28
+ releases assets latest tags git refs heads blobs trees matching-refs ref contents readme
29
+ branches protection required_status_checks required_pull_request_reviews enforce_admins restrictions rename
30
+ rulesets rules collaborators invitations members memberships teams outside_collaborators public_members
31
+ hooks tests pings deliveries config redeliver keys deployments statuses check-runs check-suites pages forks topics subscription subscribers stargazers
32
+ vulnerability-alerts automated-security-fixes code-scanning dependabot secret-scanning alerts autolinks
33
+ properties values transfer generate dispatch notifications languages contributors traffic projects codespaces
34
+ `);
35
+ /** Supabase's Management API path words (api.supabase.com/v1). */
36
+ export const SUPABASE_PATH_WORDS = words(`
37
+ v1 projects organizations branches database query migrations functions deploy body secrets api-keys config auth
38
+ postgrest pgbouncer storage buckets network-restrictions network-bans ssl-enforcement custom-hostname
39
+ vanity-subdomain restore pause unpause upgrade readonly health types typescript snippets sso providers
40
+ third-party-auth signing-keys billing addons apply push reset merge backups pitr settings members
41
+ `);
42
+ /** Railway is GraphQL: its path is one word. */
43
+ export const RAILWAY_PATH_WORDS = words("graphql v2");
44
+ export function pathWordsFor(platform) {
45
+ if (platform === "github")
46
+ return GITHUB_PATH_WORDS;
47
+ if (platform === "supabase")
48
+ return SUPABASE_PATH_WORDS;
49
+ if (platform === "railway")
50
+ return RAILWAY_PATH_WORDS;
51
+ return new Set();
52
+ }
53
+ /** A root word whose next segments are names, in order: `repos/{owner}/{repo}`. */
54
+ const POSITIONAL = {
55
+ repos: ["owner", "repo"],
56
+ orgs: ["org"],
57
+ users: ["user"],
58
+ enterprises: ["enterprise"]
59
+ };
60
+ /** The placeholder a value takes after a path word, when it isn't `{id}`. */
61
+ const AFTER = {
62
+ pulls: "number",
63
+ issues: "number",
64
+ milestones: "number",
65
+ branches: "branch",
66
+ heads: "branch",
67
+ tags: "tag",
68
+ labels: "name",
69
+ secrets: "name",
70
+ variables: "name",
71
+ environments: "name",
72
+ contents: "path",
73
+ commits: "sha",
74
+ projects: "ref",
75
+ functions: "slug"
76
+ };
77
+ function decoded(segment) {
78
+ try {
79
+ return decodeURIComponent(segment);
80
+ }
81
+ catch {
82
+ return segment;
83
+ }
84
+ }
85
+ /**
86
+ * An API path as a template of the platform's own words: scheme, host, query and fragment dropped; the names after
87
+ * `repos`, `orgs`, `users` (as the first word) are `{owner}/{repo}`, `{org}`, `{user}`; any other segment stays only
88
+ * when it is one of `known`, else it is one placeholder named by the word before it (`{number}` after `pulls`,
89
+ * `{branch}` after `branches`, `{sha}` for a commit hash, else `{id}`), a run of them collapsed into one.
90
+ */
91
+ export function templatePath(raw, known) {
92
+ const bare = raw
93
+ .trim()
94
+ .replace(/^[a-z][a-z0-9+.-]*:\/\/[^/]*/i, "")
95
+ .replace(/[?#][\s\S]*$/, "");
96
+ const segments = bare.split("/").filter(Boolean).slice(0, 64).map(decoded);
97
+ const out = [];
98
+ let index = 0;
99
+ const positional = segments[0] !== undefined && known.has(segments[0]) ? POSITIONAL[segments[0]] : undefined;
100
+ if (positional) {
101
+ out.push(segments[0]);
102
+ index = 1;
103
+ for (const name of positional) {
104
+ if (index >= segments.length)
105
+ break;
106
+ out.push(`{${name}}`);
107
+ index++;
108
+ }
109
+ }
110
+ let word;
111
+ let inRun = false;
112
+ for (; index < segments.length; index++) {
113
+ const segment = segments[index];
114
+ if (known.has(segment)) {
115
+ out.push(segment);
116
+ word = segment;
117
+ inRun = false;
118
+ continue;
119
+ }
120
+ if (inRun)
121
+ continue;
122
+ const name = /^[0-9a-f]{40}$/i.test(segment) ? "sha" : ((word && AFTER[word]) ?? "id");
123
+ out.push(`{${name}}`);
124
+ inRun = true;
125
+ }
126
+ return out.slice(0, MAX_SEGMENTS).join("/").slice(0, MAX_PATH);
127
+ }
128
+ /** `gh`'s command groups and their subcommands (gh 2.6x manual); a group with none takes no subcommand. */
129
+ const GH_COMMANDS = Object.fromEntries(Object.entries({
130
+ agent: "",
131
+ alias: "delete import list set",
132
+ api: "",
133
+ attestation: "download trusted-root verify",
134
+ auth: "login logout refresh setup-git status switch token",
135
+ browse: "",
136
+ cache: "delete list",
137
+ codespace: "code cp create delete edit jupyter list logs ports rebuild ssh stop view",
138
+ completion: "",
139
+ config: "clear-cache get list set",
140
+ extension: "browse create exec install list remove search upgrade",
141
+ gist: "clone create delete edit list rename view",
142
+ "gpg-key": "add delete list",
143
+ issue: "close comment create delete develop edit list lock pin reopen status transfer unlock unpin view", // copy-style-allow filler: gh's own subcommand names
144
+ label: "clone create delete edit list",
145
+ org: "list",
146
+ pr: "checkout checks close comment create diff edit list lock merge ready reopen review revert status unlock update-branch view", // copy-style-allow filler: gh's own subcommand names
147
+ project: "close copy create delete edit field-create field-delete field-list item-add item-archive item-create item-delete item-edit item-list link list mark-template unlink view",
148
+ release: "create delete delete-asset download edit list upload verify verify-asset view",
149
+ repo: "archive autolink clone create delete deploy-key edit fork gitignore license list rename set-default sync unarchive view",
150
+ ruleset: "check list view",
151
+ run: "cancel delete download list rerun view watch",
152
+ search: "code commits issues prs repos",
153
+ secret: "delete list set",
154
+ "ssh-key": "add delete list",
155
+ status: "",
156
+ variable: "delete get list set",
157
+ workflow: "disable enable list run view"
158
+ }).map(([group, subs]) => [group, words(subs)]));
159
+ /** Git's own commands; git takes one word. */
160
+ const GIT_COMMANDS = words(`
161
+ add am apply archive bisect blame branch bundle checkout cherry-pick clean clone commit config describe diff fetch
162
+ format-patch gc grep init log ls-files ls-remote merge mv notes pull push range-diff rebase reflog remote reset
163
+ restore revert rm shortlog show sparse-checkout stash status submodule switch tag worktree
164
+ `);
165
+ /** A program's name from its path: `/usr/bin/gh.exe` is `gh`. */
166
+ const programName = (argv0) => (argv0 ?? "").replace(/^.*[\\/]/, "").replace(/\.exe$/i, "");
167
+ /**
168
+ * A command line as its program and at most two subcommand words: each a CLI word (`^[a-z][a-z-]{0,30}$`) and, for
169
+ * `gh` and `git`, one that CLI has, so a positional argument (a branch, a remote, a repository, a number) never
170
+ * passes as a subcommand. Flags end it. Null when the program itself isn't a plain name.
171
+ */
172
+ export function unnamedCommand(argv) {
173
+ const program = programName(argv[0]);
174
+ if (!COMMAND_WORD.test(program))
175
+ return null;
176
+ const out = [program];
177
+ const rest = argv.slice(1);
178
+ for (const word of rest.slice(0, 2)) {
179
+ if (!COMMAND_WORD.test(word))
180
+ break;
181
+ if (program === "git" && (out.length > 1 || !GIT_COMMANDS.has(word)))
182
+ break;
183
+ if (program === "gh") {
184
+ const group = out.length === 1 ? GH_COMMANDS[word] : GH_COMMANDS[out[1]];
185
+ if (out.length === 1 ? !Object.prototype.hasOwnProperty.call(GH_COMMANDS, word) : !group?.has(word))
186
+ break;
187
+ }
188
+ out.push(word);
189
+ }
190
+ return out.join(" ");
191
+ }
192
+ /** An API call's hit: its method (one of the HTTP methods) and its path's template; either may be unknown. */
193
+ export function unnamedApi(platform, method, path) {
194
+ const upper = method?.toUpperCase();
195
+ const template = path === undefined ? "" : templatePath(path, pathWordsFor(platform));
196
+ return {
197
+ via: "api",
198
+ ...(upper && UNNAMED_METHODS.includes(upper) ? { method: upper } : {}),
199
+ ...(template ? { path: template } : {})
200
+ };
201
+ }
202
+ /** A command line's hit; undefined when nothing of it can be kept. */
203
+ export function unnamedCli(argv) {
204
+ const command = unnamedCommand(argv);
205
+ return command === null ? undefined : { via: "cli", command };
206
+ }
207
+ /**
208
+ * What a caller sent (the bridge's classification) made coarse again, so nothing it adds survives: the method from
209
+ * the list, the path re-templated with the platform's words, the command re-read word by word. Anything else is
210
+ * dropped, never refused.
211
+ */
212
+ export function sanitizeUnnamed(platform, value) {
213
+ if (!value || typeof value !== "object" || Array.isArray(value))
214
+ return undefined;
215
+ const hit = value;
216
+ if (hit.via === "api") {
217
+ const method = typeof hit.method === "string" ? hit.method.slice(0, 10) : undefined;
218
+ const path = typeof hit.path === "string" ? hit.path.slice(0, 2_000) : undefined;
219
+ return unnamedApi(platform, method, path);
220
+ }
221
+ if (hit.via === "cli" && typeof hit.command === "string") {
222
+ return unnamedCli(hit.command.slice(0, 200).trim().split(/\s+/));
223
+ }
224
+ return undefined;
225
+ }
package/dist/cpCli.js CHANGED
@@ -14,6 +14,7 @@ import { readBoundedJson } from "./boundedResponse.js";
14
14
  import { credentialDir, enforceOwner, ensurePrivateDirectory, writePrivateAtomic } from "./credentialStorage.js";
15
15
  import { assertProfileName, getProfile } from "./credentials.js";
16
16
  import { disarmFastPath } from "./fastPathFlag.js";
17
+ import { parseNotices, saveLocalNotices } from "./localNotices.js";
17
18
  export const CP_CLI_PATH = "/api/cp/cli";
18
19
  /** Older than this, the hooks refresh the copy after they have answered. */
19
20
  export const CP_CLI_STALE_MS = 60 * 60 * 1000;
@@ -162,7 +163,10 @@ export async function refreshCpCli(profile, signal, deps = {}) {
162
163
  await response.body?.cancel().catch(() => undefined);
163
164
  return response.status === 404 ? "unavailable" : "failed";
164
165
  }
165
- const cli = parseCpCli(await readBoundedJson(response, MAX_BYTES));
166
+ const body = await readBoundedJson(response, MAX_BYTES);
167
+ const cli = parseCpCli(body);
168
+ // Notices are handed over once by this read: keep them before anything else can fail.
169
+ saveLocalNotices(profile, parseNotices(plainObject(body)?.notices));
166
170
  if (!cli || signal.aborted)
167
171
  return "failed";
168
172
  writeCpCli(profile, cli, (deps.now ?? Date.now)());
@@ -0,0 +1,25 @@
1
+ import type { Runtime } from "./cliSupport.js";
2
+ import { type GitCredentialState, type RunGit } from "./gitCredentialSetup.js";
3
+ /** Set on the nested `git credential fill`, so a Passport entry that couldn't be removed never recurses. */
4
+ export declare const RETIRED_FILL_GUARD = "PASSPORT_GIT_CREDENTIAL_RETIRED";
5
+ export declare const RETIRED_NOTICE = "passport: git-credential is retired, so Passport took itself out of your global git config; git uses your own sign-in.";
6
+ export declare const RETIRE_FAILED_NOTICE = "passport: git-credential is retired, but your global git config couldn't be updated; git uses your own sign-in, and Passport tries again next time.";
7
+ /**
8
+ * Takes Passport's own entries out of the global git config and nothing else.
9
+ * In order, so a failure part-way is retried on the next call (Passport's
10
+ * helper, removed last, keeps bringing git back here):
11
+ * 1. what setup moved out of the section goes back (it lives only in the record);
12
+ * 2. the pushInsteadOf rewrites the record lists, each by its exact value;
13
+ * 3. useHttpPath, unless the record shows the section had it before;
14
+ * 4. the empty `helper =` reset: with a record, when the recorded helpers had no
15
+ * reset; without one, when every reset sits right before a Passport line (as
16
+ * setup writes them). This reset is what left git with no answer;
17
+ * 5. Passport's helper value(s) last.
18
+ * Each removal is one `--fixed-value --unset-all` of an exact value, so a
19
+ * concurrent writer is never undone. A failed write prints one line and stops;
20
+ * git is still answered through the fallback.
21
+ */
22
+ export declare function retireGitCredential(runtime: Pick<Runtime, "env" | "stderr">, state: GitCredentialState | null, run?: RunGit): boolean;
23
+ /** The credential git's remaining helpers give for this request, never prompting: the lines git needs from
24
+ * a helper (username, password, expiry), or "" when none answers in time. */
25
+ export declare function fillFromOwnHelpers(input: string, env: Runtime["env"], cwd?: string, timeoutMs?: number): Promise<string>;