passport-bridge 0.46.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.
- package/dist/cliGitCredential.d.ts +2 -0
- package/dist/cliGitCredential.js +15 -7
- package/dist/controlPlane.generated.d.ts +3 -3
- package/dist/controlPlaneRoutes.generated.d.ts +63 -0
- package/dist/controlPlaneRoutes.generated.js +111 -0
- package/dist/gitCredentialRetire.d.ts +25 -0
- package/dist/gitCredentialRetire.js +143 -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
|
@@ -20,6 +20,8 @@ export type GitCredentialDependencies = CredentialsSwitch & {
|
|
|
20
20
|
fallback?: (helper: string, operation: string, input: string, env: Runtime["env"]) => Promise<string>;
|
|
21
21
|
run?: RunGit;
|
|
22
22
|
command?: readonly string[];
|
|
23
|
+
/** The person's own helpers' answer once Passport's entry is gone (tests). */
|
|
24
|
+
fillFromOwnHelpers?: (input: string, env: Runtime["env"]) => Promise<string>;
|
|
23
25
|
/** What a helper line answers (tests); the default runs it as git would. */
|
|
24
26
|
probe?: (line: string, env: Runtime["env"]) => string | null;
|
|
25
27
|
mintTimeoutMs?: number;
|
package/dist/cliGitCredential.js
CHANGED
|
@@ -48,6 +48,7 @@ import { beginShadowLine, shadowAfterDecision, shadowAlongside, shadowGithubLine
|
|
|
48
48
|
import { takePushDecisions } from "./gitPushDecisions.js";
|
|
49
49
|
import { helperLine, helperProgram, installGitCredential, probeHelper, readGitCredentialState, removeGitCredential } from "./gitCredentialSetup.js";
|
|
50
50
|
import { GIT_OFF, issuesCredentials, offResult } from "./offInV1.js";
|
|
51
|
+
import { fillFromOwnHelpers, retireGitCredential } from "./gitCredentialRetire.js";
|
|
51
52
|
export const GIT_CREDENTIAL_PATH = "/api/my/github/git-credential";
|
|
52
53
|
export const TOKEN_USERNAME = "x-access-token";
|
|
53
54
|
const REPO_PATH = /^([A-Za-z0-9_.-]{1,100})\/([A-Za-z0-9_.-]{1,100}?)(?:\.git)?\/?$/;
|
|
@@ -119,8 +120,7 @@ const runFallback = (helper, operation, input, env) => new Promise((resolve) =>
|
|
|
119
120
|
});
|
|
120
121
|
/** Ask the helpers git used before setup, in order, as git would; the first that answers wins. `quit`: whether
|
|
121
122
|
* a helper's quit stops there (in v1 it doesn't: the next helper is asked). */
|
|
122
|
-
async function delegate(operation, input, runtime, deps, quit = true) {
|
|
123
|
-
const helpers = readGitCredentialState()?.fallback ?? [];
|
|
123
|
+
async function delegate(operation, input, runtime, deps, quit = true, helpers = readGitCredentialState()?.fallback ?? []) {
|
|
124
124
|
const run = deps.fallback ?? runFallback;
|
|
125
125
|
// The path is there for Passport (useHttpPath); the earlier helpers stored their
|
|
126
126
|
// passwords per host, so they get the request as git sent it before setup.
|
|
@@ -476,15 +476,23 @@ export async function gitCredential(args, runtime, deps = {}) {
|
|
|
476
476
|
const input = await readInput(runtime);
|
|
477
477
|
let out = "";
|
|
478
478
|
try {
|
|
479
|
-
// Off in v1: no token from Passport
|
|
480
|
-
//
|
|
481
|
-
|
|
482
|
-
|
|
479
|
+
// Off in v1: no token from Passport, and this helper is retired: it takes its own entries out of the
|
|
480
|
+
// global config, then the helpers git used before setup answer, else the person's own helpers, so git
|
|
481
|
+
// is never left with an empty answer. Never quit=1: Passport doesn't stop git here.
|
|
482
|
+
// The recorded helpers are read before the retire step deletes the record.
|
|
483
|
+
const recorded = on ? null : readGitCredentialState();
|
|
484
|
+
if (!on)
|
|
485
|
+
retireGitCredential(runtime, recorded, deps.run);
|
|
486
|
+
if (operation === "get" && !on) {
|
|
487
|
+
out = withoutQuit(await delegate("get", input, runtime, deps, false, recorded?.fallback ?? []));
|
|
488
|
+
if (!/^password=/m.test(out))
|
|
489
|
+
out = await (deps.fillFromOwnHelpers ?? fillFromOwnHelpers)(input, runtime.env);
|
|
490
|
+
}
|
|
483
491
|
else if (operation === "get")
|
|
484
492
|
out = await get(args, runtime, deps, input);
|
|
485
493
|
// A token Passport issued is never stored: git would offer an expired one next time.
|
|
486
494
|
else if (parseCredentialRequest(input).get("username") !== TOKEN_USERNAME) {
|
|
487
|
-
out = await delegate(operation, input, runtime, deps);
|
|
495
|
+
out = await delegate(operation, input, runtime, deps, true, recorded?.fallback);
|
|
488
496
|
}
|
|
489
497
|
}
|
|
490
498
|
catch (error) {
|
|
@@ -5,8 +5,10 @@
|
|
|
5
5
|
* (decided 2026-11-13) live beside it in `controlPlaneModel.ts`; what an unnamed action hit in `controlPlaneUnnamed.ts`.
|
|
6
6
|
*/
|
|
7
7
|
import type { CpAgentV21, CpPersonV21 } from "./controlPlanePeople.generated.js";
|
|
8
|
+
import type { CpRouteCoverage } from "./controlPlaneRoutes.generated.js";
|
|
8
9
|
import type { UnnamedHit } from "./controlPlaneUnnamed.generated.js";
|
|
9
10
|
export type * from "./controlPlanePeople.generated.js";
|
|
11
|
+
export type * from "./controlPlaneRoutes.generated.js";
|
|
10
12
|
/** The kinds (2026-11-16; Unclassified 2026-11-17). A read is decided only when a Block could cover it (`readGate.ts`). */
|
|
11
13
|
export declare const KINDS: readonly ["delete", "change", "create", "read", "unclassified"];
|
|
12
14
|
export type Kind = (typeof KINDS)[number];
|
|
@@ -445,14 +447,11 @@ export type CpPlatformRow = {
|
|
|
445
447
|
observationDetail?: string;
|
|
446
448
|
/** Where Passport learns of actions on this platform, with each source's status (spec Part 2, section 2). */
|
|
447
449
|
sources?: ObservationSource[];
|
|
448
|
-
/** Credentials the platform lists that Passport didn't issue; null when it can't list them. */
|
|
449
450
|
credentialsOutside?: number | null;
|
|
450
451
|
/** v19, connected platforms: credentials outside Passport seen in 30 days, most used first; "Needs you" rows. */
|
|
451
452
|
outsideCredentials?: CpOutsideCredential[];
|
|
452
453
|
setupGaps?: CpSetupGap[];
|
|
453
|
-
/** "shared": connected as an admin, so through is matched and coverage estimated (spec Part 2, section 1). */
|
|
454
454
|
identity?: "member" | "shared";
|
|
455
|
-
/** The connection's held grant stopped working: the row says "Reconnect <Platform>". */
|
|
456
455
|
reconnect?: true;
|
|
457
456
|
readOnly?: true;
|
|
458
457
|
/** How agents reach the app ("Model"): MCP, CLI, API, Outside (`platform`), each set up or not. */
|
|
@@ -462,6 +461,7 @@ export type CpPlatformRow = {
|
|
|
462
461
|
}>;
|
|
463
462
|
gatewayCalls7d?: number;
|
|
464
463
|
blocked7d?: number;
|
|
464
|
+
routes?: CpRouteCoverage[];
|
|
465
465
|
};
|
|
466
466
|
export type CpNodeView = {
|
|
467
467
|
node: ResourceNode;
|
|
@@ -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
|
+
}
|
|
@@ -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>;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `passport git-credential` is retired (off in v1: Passport issues no git
|
|
3
|
+
* tokens). A config left from an older setup still points git at it, and the
|
|
4
|
+
* empty `helper =` reset that setup added drops the helpers git had before, so
|
|
5
|
+
* git would get an empty answer and stop at a sign-in prompt. When git asks,
|
|
6
|
+
* the CLI unsets only its own values from the global config (one stderr line),
|
|
7
|
+
* then answers from the person's own helpers so this git command works too.
|
|
8
|
+
*/
|
|
9
|
+
import { spawn } from "node:child_process";
|
|
10
|
+
import { rmSync } from "node:fs";
|
|
11
|
+
import { PASSPORT_CREDENTIAL_KEY, defaultRunGit, isPassportHelper, statePath } from "./gitCredentialSetup.js";
|
|
12
|
+
const USE_HTTP_PATH_KEY = "credential.https://github.com/.useHttpPath";
|
|
13
|
+
/** Set on the nested `git credential fill`, so a Passport entry that couldn't be removed never recurses. */
|
|
14
|
+
export const RETIRED_FILL_GUARD = "PASSPORT_GIT_CREDENTIAL_RETIRED";
|
|
15
|
+
const MAX_ANSWER_BYTES = 64 * 1024;
|
|
16
|
+
const FILL_TIMEOUT_MS = 15_000;
|
|
17
|
+
export const RETIRED_NOTICE = "passport: git-credential is retired, so Passport took itself out of your global git config; git uses your own sign-in.";
|
|
18
|
+
export 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.";
|
|
19
|
+
function globalValues(run, env, key) {
|
|
20
|
+
const got = run(["config", "--global", "--get-all", key], env);
|
|
21
|
+
return got.ok ? got.stdout.replace(/\n$/, "").split("\n") : null;
|
|
22
|
+
}
|
|
23
|
+
/** The values setup's record says the section held for `key` before Passport wrote it. */
|
|
24
|
+
function recorded(state, key) {
|
|
25
|
+
const found = Object.entries(state.restore ?? {}).find(([existing]) => existing.toLowerCase() === key.toLowerCase());
|
|
26
|
+
return found?.[1] ?? [];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Takes Passport's own entries out of the global git config and nothing else.
|
|
30
|
+
* In order, so a failure part-way is retried on the next call (Passport's
|
|
31
|
+
* helper, removed last, keeps bringing git back here):
|
|
32
|
+
* 1. what setup moved out of the section goes back (it lives only in the record);
|
|
33
|
+
* 2. the pushInsteadOf rewrites the record lists, each by its exact value;
|
|
34
|
+
* 3. useHttpPath, unless the record shows the section had it before;
|
|
35
|
+
* 4. the empty `helper =` reset: with a record, when the recorded helpers had no
|
|
36
|
+
* reset; without one, when every reset sits right before a Passport line (as
|
|
37
|
+
* setup writes them). This reset is what left git with no answer;
|
|
38
|
+
* 5. Passport's helper value(s) last.
|
|
39
|
+
* Each removal is one `--fixed-value --unset-all` of an exact value, so a
|
|
40
|
+
* concurrent writer is never undone. A failed write prints one line and stops;
|
|
41
|
+
* git is still answered through the fallback.
|
|
42
|
+
*/
|
|
43
|
+
export function retireGitCredential(runtime, state, run = defaultRunGit) {
|
|
44
|
+
const env = runtime.env;
|
|
45
|
+
const helpers = globalValues(run, env, PASSPORT_CREDENTIAL_KEY) ?? [];
|
|
46
|
+
const ours = [...new Set(helpers.filter(isPassportHelper))];
|
|
47
|
+
if (!ours.length)
|
|
48
|
+
return false;
|
|
49
|
+
const unset = (key, value) => run(["config", "--global", "--fixed-value", "--unset-all", key, value], env).ok;
|
|
50
|
+
const failed = () => (runtime.stderr.write(`${RETIRE_FAILED_NOTICE}\n`), false);
|
|
51
|
+
for (const [key, values] of Object.entries(state?.restore ?? {})) {
|
|
52
|
+
const present = globalValues(run, env, key) ?? [];
|
|
53
|
+
for (const value of values) {
|
|
54
|
+
if (!present.includes(value) && !run(["config", "--global", "--add", key, value], env).ok)
|
|
55
|
+
return failed();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
for (const { key, value } of state?.pushInsteadOf ?? []) {
|
|
59
|
+
if (globalValues(run, env, key)?.includes(value) && !unset(key, value))
|
|
60
|
+
return failed();
|
|
61
|
+
}
|
|
62
|
+
const pathOurs = state ? !recorded(state, USE_HTTP_PATH_KEY).includes("true") : true;
|
|
63
|
+
if (pathOurs && globalValues(run, env, USE_HTTP_PATH_KEY)?.includes("true") && !unset(USE_HTTP_PATH_KEY, "true")) {
|
|
64
|
+
return failed();
|
|
65
|
+
}
|
|
66
|
+
const resets = helpers.filter((value) => value === "").length;
|
|
67
|
+
const resetsBeforeOurs = helpers.filter((value, index) => value === "" && isPassportHelper(helpers[index + 1] ?? ""));
|
|
68
|
+
const resetOurs = state
|
|
69
|
+
? !recorded(state, PASSPORT_CREDENTIAL_KEY).includes("")
|
|
70
|
+
: resets > 0 && resetsBeforeOurs.length === resets;
|
|
71
|
+
if (resetOurs && resets > 0 && !unset(PASSPORT_CREDENTIAL_KEY, ""))
|
|
72
|
+
return failed();
|
|
73
|
+
if (!ours.every((value) => unset(PASSPORT_CREDENTIAL_KEY, value)))
|
|
74
|
+
return failed();
|
|
75
|
+
try {
|
|
76
|
+
rmSync(statePath(), { force: true });
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
/* the record only matters to setup */
|
|
80
|
+
}
|
|
81
|
+
runtime.stderr.write(`${RETIRED_NOTICE}\n`);
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
/** The credential git's remaining helpers give for this request, never prompting: the lines git needs from
|
|
85
|
+
* a helper (username, password, expiry), or "" when none answers in time. */
|
|
86
|
+
export function fillFromOwnHelpers(input, env, cwd = process.cwd(), timeoutMs = FILL_TIMEOUT_MS) {
|
|
87
|
+
const vars = env;
|
|
88
|
+
// git always hands a helper its HOME; without one, git would read the OS account's real config instead.
|
|
89
|
+
if (vars[RETIRED_FILL_GUARD] || !vars.HOME)
|
|
90
|
+
return Promise.resolve("");
|
|
91
|
+
const request = input
|
|
92
|
+
.split("\n")
|
|
93
|
+
.filter((line) => /^(?:protocol|host|username|path)=/.test(line))
|
|
94
|
+
.join("\n");
|
|
95
|
+
if (!/^host=/m.test(request))
|
|
96
|
+
return Promise.resolve("");
|
|
97
|
+
return new Promise((resolve) => {
|
|
98
|
+
const run = { settled: false };
|
|
99
|
+
const finish = (answer) => {
|
|
100
|
+
if (run.settled)
|
|
101
|
+
return;
|
|
102
|
+
run.settled = true;
|
|
103
|
+
clearTimeout(run.timer);
|
|
104
|
+
resolve(answer);
|
|
105
|
+
};
|
|
106
|
+
const child = spawn("git", ["-c", "credential.interactive=false", "credential", "fill"], {
|
|
107
|
+
cwd,
|
|
108
|
+
detached: true,
|
|
109
|
+
env: {
|
|
110
|
+
...env,
|
|
111
|
+
GIT_TERMINAL_PROMPT: "0",
|
|
112
|
+
GIT_ASKPASS: "",
|
|
113
|
+
SSH_ASKPASS: "",
|
|
114
|
+
GCM_INTERACTIVE: "never",
|
|
115
|
+
[RETIRED_FILL_GUARD]: "1"
|
|
116
|
+
},
|
|
117
|
+
stdio: ["pipe", "pipe", "ignore"]
|
|
118
|
+
});
|
|
119
|
+
// A helper's own child can hold stdout open: the timer answers git anyway and ends the whole group.
|
|
120
|
+
run.timer = setTimeout(() => {
|
|
121
|
+
try {
|
|
122
|
+
if (child.pid)
|
|
123
|
+
process.kill(-child.pid, "SIGKILL");
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
/* already gone */
|
|
127
|
+
}
|
|
128
|
+
finish("");
|
|
129
|
+
}, timeoutMs);
|
|
130
|
+
let out = "";
|
|
131
|
+
child.stdout.on("data", (chunk) => {
|
|
132
|
+
if (out.length < MAX_ANSWER_BYTES)
|
|
133
|
+
out += chunk.toString("utf8");
|
|
134
|
+
});
|
|
135
|
+
child.on("error", () => finish(""));
|
|
136
|
+
child.on("close", (code) => {
|
|
137
|
+
const lines = out.split("\n").filter((line) => /^(?:username|password|password_expiry_utc)=/.test(line));
|
|
138
|
+
finish(code === 0 && lines.some((line) => line.startsWith("password=")) ? `${lines.join("\n")}\n` : "");
|
|
139
|
+
});
|
|
140
|
+
child.stdin.on("error", () => undefined);
|
|
141
|
+
child.stdin.end(`${request}\n\n`);
|
|
142
|
+
});
|
|
143
|
+
}
|
package/dist/pluginPin.d.ts
CHANGED
package/dist/pluginPin.js
CHANGED
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.46.
|
|
1
|
+
export declare const VERSION = "0.46.1";
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Keep in lockstep with bridge/package.json.
|
|
2
|
-
export const VERSION = "0.46.
|
|
2
|
+
export const VERSION = "0.46.1";
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "passport-bridge",
|
|
3
|
-
"version": "0.46.
|
|
3
|
+
"version": "0.46.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "passport-bridge",
|
|
9
|
-
"version": "0.46.
|
|
9
|
+
"version": "0.46.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@modelcontextprotocol/sdk": "1.32.1"
|