passport-bridge 0.16.3 → 0.16.4
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/README.md +2 -2
- package/dist/accessTokenCache.d.ts +54 -0
- package/dist/accessTokenCache.js +163 -0
- package/dist/bridgeExchange.d.ts +6 -0
- package/dist/bridgeExchange.js +5 -0
- package/dist/cliHook.js +12 -12
- package/dist/credentials.d.ts +3 -1
- package/dist/credentials.js +6 -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 +6 -6
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -231,7 +231,7 @@ Codex has no field for `codex exec`; its prompt-free modes count as unattended,
|
|
|
231
231
|
|
|
232
232
|
The approval request carries a command summary with secrets removed on this computer (`src/cliHookRedact.ts`, using `passport scan`'s key formats plus secret-named flags, variables, JSON fields, URL credentials, and long opaque values; heredoc bodies are dropped). It is the only part of a command line that ever leaves the machine, and only approvers see it.
|
|
233
233
|
|
|
234
|
-
The guard decides from local data inside `HOOK_BUDGET_MS` (1.5 s) and prints first; only an unattended ask waits for the server, within the same budget. With the budget left, it reports its decision and, at most every ten minutes, refreshes a policy cache older than an hour. Any failure is silent and fails open. Neither hook sends the raw command line, output, folder path, or environment.
|
|
234
|
+
The guard decides from local data inside `HOOK_BUDGET_MS` (1.5 s) and prints first; only an unattended ask waits for the server, within the same budget. With the budget left, it reports its decision and, at most every ten minutes, refreshes a policy cache older than an hour. Any failure is silent and fails open. Neither hook sends the raw command line, output, folder path, or environment. Both hooks exchange the profile's refresh credential without rotating it and keep the short-lived access token in `$PASSPORT_HOME/.<profile>.access.json` (`src/accessTokenCache.ts`, mode 600, atomic replace), so most runs send one request instead of an exchange and then the request. A cached token is used only with more than a minute left; a 401 on it drops it, exchanges once, and retries once.
|
|
235
235
|
|
|
236
236
|
An ask becomes one Activity row. In Claude Code, with the audit hook registered, the guard parks its report in `$PASSPORT_HOME/hook-pending/` (`src/cliHookPending.ts`, mode 600, claimed by atomic rename). The audit hook for the same tool-use id sends the run with `decision: "ask", ran: true` ("asked first, then ran"). An ask nobody claims within 30 minutes (no agent fires a hook for a declined prompt) is sent by the next hook run as `ran: false` ("asked first, not run"). An allow the server gave is parked the same way, so the run's row says `Approved earlier this session`. Cursor has no tool-use id to match, so its asks are sent at once as their own "asked first" row. Denies are always sent at once; asks and blocks the server decided are recorded by the server.
|
|
237
237
|
|
|
@@ -314,7 +314,7 @@ passport completion fish > ~/.config/fish/completions/passport.fish
|
|
|
314
314
|
|
|
315
315
|
## Profiles
|
|
316
316
|
|
|
317
|
-
Credentials live in `~/.passport/credentials.json` (mode `0600`, atomic updates); `PASSPORT_HOME` changes the directory. The store is shared with `passport-bridge`, and refreshes are coordinated across processes.
|
|
317
|
+
Credentials live in `~/.passport/credentials.json` (mode `0600`, atomic updates); `PASSPORT_HOME` changes the directory. The store is shared with `passport-bridge`, and refreshes are coordinated across processes. The hooks cache each profile's current access token next to it in `.<profile>.access.json` (mode `0600`): the token, its expiry, the endpoint, and a sha256 fingerprint of the refresh credential (never the credential itself), so a re-login, rotation, or endpoint change can't reuse it. Logging out, signing in again, or rotating a profile deletes its cached token.
|
|
318
318
|
|
|
319
319
|
Resolution order:
|
|
320
320
|
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The CLI hook's access-token cache: `$PASSPORT_HOME/.<profile>.access.json`,
|
|
3
|
+
* next to the credential store.
|
|
4
|
+
*
|
|
5
|
+
* A hook process lives for one shell command under a 1.5 s budget, and a
|
|
6
|
+
* token exchange alone can take most of it. So the short-lived access token
|
|
7
|
+
* one hook run mints is kept for the next run, and the common path is one
|
|
8
|
+
* request instead of two.
|
|
9
|
+
*
|
|
10
|
+
* Each entry is bound to the profile's endpoint and to a fingerprint of its
|
|
11
|
+
* refresh token (a sha256 prefix, never the token), so a re-login, a rotation,
|
|
12
|
+
* a logout, or an endpoint change can never reuse it. The file is owner-only
|
|
13
|
+
* and replaced atomically; concurrent hook runs race harmlessly (last writer
|
|
14
|
+
* wins). Reading never throws: a missing, corrupt, foreign-owned, mismatched,
|
|
15
|
+
* or nearly expired entry is simply absent and the hook exchanges as before.
|
|
16
|
+
*/
|
|
17
|
+
/** Use a cached token only with at least this long left. */
|
|
18
|
+
export declare const ACCESS_REUSE_MARGIN_MS = 60000;
|
|
19
|
+
export type AccessBinding = {
|
|
20
|
+
endpoint: string;
|
|
21
|
+
refresh: string;
|
|
22
|
+
};
|
|
23
|
+
export type HeldAccess = {
|
|
24
|
+
token: string;
|
|
25
|
+
expiresAt: number;
|
|
26
|
+
};
|
|
27
|
+
type ApiCall = (path: string, init: RequestInit) => Promise<Response>;
|
|
28
|
+
export declare function accessCachePath(profile: string): string;
|
|
29
|
+
/** Identifies the refresh token an entry was minted from without storing it. */
|
|
30
|
+
export declare function refreshFingerprint(refreshToken: string): string;
|
|
31
|
+
/** The cached access token for this exact binding, if it has more than a
|
|
32
|
+
* minute left. */
|
|
33
|
+
export declare function readCachedAccess(profile: string, binding: AccessBinding, now: number): string | undefined;
|
|
34
|
+
/** Replace the entry atomically (temp file, then rename), mode 0600. Throws;
|
|
35
|
+
* the hook treats a failed write as nothing cached. */
|
|
36
|
+
export declare function writeCachedAccess(profile: string, binding: AccessBinding, held: HeldAccess): void;
|
|
37
|
+
/** Remove the entry. With `only`, remove it only while it still holds that
|
|
38
|
+
* token, so a run that saw a 401 does not delete a sibling's fresh entry.
|
|
39
|
+
* Never throws. */
|
|
40
|
+
export declare function dropCachedAccess(profile: string, only?: string): void;
|
|
41
|
+
/**
|
|
42
|
+
* One authenticated call surface for a hook run. A cached token goes out
|
|
43
|
+
* first with no exchange. A 401 on it drops the entry, exchanges once (shared
|
|
44
|
+
* by every call in the run), and retries once. A fresh token is cached for
|
|
45
|
+
* the next run, best effort.
|
|
46
|
+
*
|
|
47
|
+
* The exchange never rotates the refresh token: a rotation cut short by the
|
|
48
|
+
* hook's budget would lose the only copy of the new one.
|
|
49
|
+
*/
|
|
50
|
+
export declare function cachedAccessApi(profile: string, saved: {
|
|
51
|
+
endpoint: string;
|
|
52
|
+
refreshToken: string;
|
|
53
|
+
}, signal: AbortSignal, fetcher: typeof fetch, exchangeTimeoutMs: number): Promise<ApiCall>;
|
|
54
|
+
export {};
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The CLI hook's access-token cache: `$PASSPORT_HOME/.<profile>.access.json`,
|
|
3
|
+
* next to the credential store.
|
|
4
|
+
*
|
|
5
|
+
* A hook process lives for one shell command under a 1.5 s budget, and a
|
|
6
|
+
* token exchange alone can take most of it. So the short-lived access token
|
|
7
|
+
* one hook run mints is kept for the next run, and the common path is one
|
|
8
|
+
* request instead of two.
|
|
9
|
+
*
|
|
10
|
+
* Each entry is bound to the profile's endpoint and to a fingerprint of its
|
|
11
|
+
* refresh token (a sha256 prefix, never the token), so a re-login, a rotation,
|
|
12
|
+
* a logout, or an endpoint change can never reuse it. The file is owner-only
|
|
13
|
+
* and replaced atomically; concurrent hook runs race harmlessly (last writer
|
|
14
|
+
* wins). Reading never throws: a missing, corrupt, foreign-owned, mismatched,
|
|
15
|
+
* or nearly expired entry is simply absent and the hook exchanges as before.
|
|
16
|
+
*/
|
|
17
|
+
import { createHash } from "node:crypto";
|
|
18
|
+
import { lstatSync, unlinkSync } from "node:fs";
|
|
19
|
+
import { join } from "node:path";
|
|
20
|
+
import { readBoundedUtf8File } from "./boundedFile.js";
|
|
21
|
+
import { credentialDir, enforceOwner, writePrivateAtomic } from "./credentialStorage.js";
|
|
22
|
+
const VERSION = 1;
|
|
23
|
+
const MAX_BYTES = 16 * 1024;
|
|
24
|
+
const MAX_TOKEN_LENGTH = 4096;
|
|
25
|
+
/** Use a cached token only with at least this long left. */
|
|
26
|
+
export const ACCESS_REUSE_MARGIN_MS = 60_000;
|
|
27
|
+
/** Passport's access tokens last an hour. Anything claiming far longer was
|
|
28
|
+
* written under a wrong clock, so it is ignored rather than trusted. */
|
|
29
|
+
const MAX_REMAINING_MS = 24 * 60 * 60 * 1000;
|
|
30
|
+
/** Mirrors the credential store's profile-name rule. Kept local so this file
|
|
31
|
+
* does not import `credentials.ts`, which imports it. */
|
|
32
|
+
const PROFILE_NAME = /^[A-Za-z0-9][A-Za-z0-9._@-]{0,79}$/;
|
|
33
|
+
const UNSAFE_PROFILE_KEYS = new Set(["__proto__", "prototype", "constructor"]);
|
|
34
|
+
export function accessCachePath(profile) {
|
|
35
|
+
if (!PROFILE_NAME.test(profile) || UNSAFE_PROFILE_KEYS.has(profile)) {
|
|
36
|
+
throw new Error("Invalid Passport profile name.");
|
|
37
|
+
}
|
|
38
|
+
return join(credentialDir(), `.${profile}.access.json`);
|
|
39
|
+
}
|
|
40
|
+
/** Identifies the refresh token an entry was minted from without storing it. */
|
|
41
|
+
export function refreshFingerprint(refreshToken) {
|
|
42
|
+
return createHash("sha256").update(refreshToken, "utf8").digest("hex").slice(0, 32);
|
|
43
|
+
}
|
|
44
|
+
function readEntry(profile) {
|
|
45
|
+
try {
|
|
46
|
+
const path = accessCachePath(profile);
|
|
47
|
+
enforceOwner(lstatSync(path), "access-token cache");
|
|
48
|
+
const parsed = JSON.parse(readBoundedUtf8File(path, MAX_BYTES));
|
|
49
|
+
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/** The cached access token for this exact binding, if it has more than a
|
|
56
|
+
* minute left. */
|
|
57
|
+
export function readCachedAccess(profile, binding, now) {
|
|
58
|
+
const entry = readEntry(profile);
|
|
59
|
+
if (!entry || entry.version !== VERSION)
|
|
60
|
+
return undefined;
|
|
61
|
+
if (entry.endpoint !== binding.endpoint || entry.refresh !== binding.refresh)
|
|
62
|
+
return undefined;
|
|
63
|
+
const { accessToken, expiresAt } = entry;
|
|
64
|
+
if (typeof accessToken !== "string" || !accessToken || accessToken.length > MAX_TOKEN_LENGTH)
|
|
65
|
+
return undefined;
|
|
66
|
+
if (/[\u0000- \u007f]/.test(accessToken))
|
|
67
|
+
return undefined;
|
|
68
|
+
if (typeof expiresAt !== "number" || !Number.isFinite(expiresAt))
|
|
69
|
+
return undefined;
|
|
70
|
+
const remaining = expiresAt - now;
|
|
71
|
+
if (remaining <= ACCESS_REUSE_MARGIN_MS || remaining > MAX_REMAINING_MS)
|
|
72
|
+
return undefined;
|
|
73
|
+
return accessToken;
|
|
74
|
+
}
|
|
75
|
+
/** Replace the entry atomically (temp file, then rename), mode 0600. Throws;
|
|
76
|
+
* the hook treats a failed write as nothing cached. */
|
|
77
|
+
export function writeCachedAccess(profile, binding, held) {
|
|
78
|
+
const document = {
|
|
79
|
+
version: VERSION,
|
|
80
|
+
endpoint: binding.endpoint,
|
|
81
|
+
refresh: binding.refresh,
|
|
82
|
+
accessToken: held.token,
|
|
83
|
+
expiresAt: held.expiresAt
|
|
84
|
+
};
|
|
85
|
+
writePrivateAtomic(accessCachePath(profile), `.${profile}.access`, JSON.stringify(document), "access-token cache");
|
|
86
|
+
}
|
|
87
|
+
/** Remove the entry. With `only`, remove it only while it still holds that
|
|
88
|
+
* token, so a run that saw a 401 does not delete a sibling's fresh entry.
|
|
89
|
+
* Never throws. */
|
|
90
|
+
export function dropCachedAccess(profile, only) {
|
|
91
|
+
try {
|
|
92
|
+
if (only !== undefined && readEntry(profile)?.accessToken !== only)
|
|
93
|
+
return;
|
|
94
|
+
unlinkSync(accessCachePath(profile));
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
/* Missing already, or the binding check keeps a leftover from being used. */
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* One authenticated call surface for a hook run. A cached token goes out
|
|
102
|
+
* first with no exchange. A 401 on it drops the entry, exchanges once (shared
|
|
103
|
+
* by every call in the run), and retries once. A fresh token is cached for
|
|
104
|
+
* the next run, best effort.
|
|
105
|
+
*
|
|
106
|
+
* The exchange never rotates the refresh token: a rotation cut short by the
|
|
107
|
+
* hook's budget would lose the only copy of the new one.
|
|
108
|
+
*/
|
|
109
|
+
export async function cachedAccessApi(profile, saved, signal, fetcher, exchangeTimeoutMs) {
|
|
110
|
+
const origin = new URL(saved.endpoint).origin;
|
|
111
|
+
const binding = { endpoint: saved.endpoint, refresh: refreshFingerprint(saved.refreshToken) };
|
|
112
|
+
const initial = readCachedAccess(profile, binding, Date.now());
|
|
113
|
+
let cached = initial;
|
|
114
|
+
const { BridgeCredentialError, TokenManager } = await import("./bridgeExchange.js");
|
|
115
|
+
const manager = new TokenManager(saved.endpoint, saved.refreshToken, undefined, undefined, exchangeTimeoutMs, signal, fetcher);
|
|
116
|
+
let kept;
|
|
117
|
+
const keep = () => {
|
|
118
|
+
const held = manager.heldAccessToken();
|
|
119
|
+
if (!held || held.token === kept)
|
|
120
|
+
return;
|
|
121
|
+
kept = held.token;
|
|
122
|
+
try {
|
|
123
|
+
writeCachedAccess(profile, binding, held);
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
/* Best effort: the next run exchanges instead. */
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
const send = (path, init, token) => {
|
|
130
|
+
const headers = new Headers(init.headers);
|
|
131
|
+
headers.set("authorization", `Bearer ${token}`);
|
|
132
|
+
const pending = fetcher(`${origin}${path}`, { ...init, headers, redirect: "error" });
|
|
133
|
+
// Written while the request is in flight, never ahead of it.
|
|
134
|
+
if (token !== initial)
|
|
135
|
+
keep();
|
|
136
|
+
return pending;
|
|
137
|
+
};
|
|
138
|
+
// A refused token never stays cached, whether it came from disk or was
|
|
139
|
+
// just minted.
|
|
140
|
+
const refused = (token) => {
|
|
141
|
+
if (token === cached)
|
|
142
|
+
cached = undefined;
|
|
143
|
+
dropCachedAccess(profile, token);
|
|
144
|
+
};
|
|
145
|
+
return async (path, init) => {
|
|
146
|
+
const presented = cached ?? (await manager.accessToken());
|
|
147
|
+
const response = await send(path, init, presented);
|
|
148
|
+
if (response.status !== 401)
|
|
149
|
+
return response;
|
|
150
|
+
await response.body?.cancel().catch(() => undefined);
|
|
151
|
+
refused(presented);
|
|
152
|
+
// A refused cached token needs this run's one exchange (shared with any
|
|
153
|
+
// concurrent call); a refused fresh one forces another, as before.
|
|
154
|
+
const next = await manager.accessToken(presented !== initial);
|
|
155
|
+
const retried = await send(path, init, next);
|
|
156
|
+
if (retried.status === 401) {
|
|
157
|
+
await retried.body?.cancel().catch(() => undefined);
|
|
158
|
+
refused(next);
|
|
159
|
+
throw new BridgeCredentialError(401);
|
|
160
|
+
}
|
|
161
|
+
return retried;
|
|
162
|
+
};
|
|
163
|
+
}
|
package/dist/bridgeExchange.d.ts
CHANGED
|
@@ -87,6 +87,12 @@ export declare class TokenManager {
|
|
|
87
87
|
* only: never log it. Recovery correlates with it and self-heal compares
|
|
88
88
|
* the on-disk token against it. */
|
|
89
89
|
currentRefreshToken(): string;
|
|
90
|
+
/** The access token this process holds and when it expires, for the CLI
|
|
91
|
+
* hook's cross-process cache. In-process only: never log it. */
|
|
92
|
+
heldAccessToken(): {
|
|
93
|
+
token: string;
|
|
94
|
+
expiresAt: number;
|
|
95
|
+
} | undefined;
|
|
90
96
|
/** The exchange in flight, if any, so shutdown can let it persist. */
|
|
91
97
|
inflightExchange(): Promise<unknown> | undefined;
|
|
92
98
|
private assertHomeWorkspace;
|
package/dist/bridgeExchange.js
CHANGED
|
@@ -161,6 +161,11 @@ export class TokenManager {
|
|
|
161
161
|
currentRefreshToken() {
|
|
162
162
|
return this.refreshToken;
|
|
163
163
|
}
|
|
164
|
+
/** The access token this process holds and when it expires, for the CLI
|
|
165
|
+
* hook's cross-process cache. In-process only: never log it. */
|
|
166
|
+
heldAccessToken() {
|
|
167
|
+
return this.access ? { token: this.access, expiresAt: this.expiresAt } : undefined;
|
|
168
|
+
}
|
|
164
169
|
/** The exchange in flight, if any, so shutdown can let it persist. */
|
|
165
170
|
inflightExchange() {
|
|
166
171
|
return this.inflight;
|
package/dist/cliHook.js
CHANGED
|
@@ -27,7 +27,7 @@ export { opaqueKind, opaqueProgram } from "./cliHookOpaque.js";
|
|
|
27
27
|
import { hasExpired, holdAsk, takeAsk, takeExpired } from "./cliHookPending.js";
|
|
28
28
|
import { claimStaleRefresh, readCliPolicy } from "./cliPolicy.js";
|
|
29
29
|
import { readCreds } from "./credentials.js";
|
|
30
|
-
import { resolveCliAuth, selectStoredProfile } from "./cliSupport.js";
|
|
30
|
+
import { endpoint, resolveCliAuth, selectStoredProfile } from "./cliSupport.js";
|
|
31
31
|
/** Claude Code, Codex, and Cursor fail open on a slow hook, so the budget is ours. */
|
|
32
32
|
export const HOOK_BUDGET_MS = 1_500;
|
|
33
33
|
const MAX_FINDINGS = 8;
|
|
@@ -228,16 +228,16 @@ function localProfile(args, env) {
|
|
|
228
228
|
return undefined;
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
|
-
/** One authenticated call surface for everything after the decision
|
|
232
|
-
*
|
|
231
|
+
/** One authenticated call surface for everything after the decision: a
|
|
232
|
+
* still-valid access token cached by an earlier run, or one exchange that
|
|
233
|
+
* never rotates the refresh token (see `reportSender`). */
|
|
233
234
|
async function profileApi(profile, signal, fetcher) {
|
|
234
235
|
const saved = readCreds()[profile];
|
|
235
236
|
if (!saved)
|
|
236
237
|
return null;
|
|
237
|
-
const
|
|
238
|
-
const
|
|
239
|
-
|
|
240
|
-
return (path, init) => manager.authedFetch(`${origin}${path}`, init);
|
|
238
|
+
const { cachedAccessApi } = await import("./accessTokenCache.js");
|
|
239
|
+
const credential = { endpoint: endpoint(saved.endpoint), refreshToken: saved.refreshToken };
|
|
240
|
+
return cachedAccessApi(profile, credential, signal, fetcher, HOOK_BUDGET_MS);
|
|
241
241
|
}
|
|
242
242
|
/** The report an older server accepts: no Autopilot fields, ask or deny only. */
|
|
243
243
|
export function legacyReport(report) {
|
|
@@ -270,17 +270,17 @@ async function postWith(api, report, signal) {
|
|
|
270
270
|
* command under a 1.5 s budget, and a rotation cut short by that budget would
|
|
271
271
|
* lose the only copy of the new token, which later revokes the whole family.
|
|
272
272
|
* With nothing to rotate there is nothing to serialize either, so the hook
|
|
273
|
-
* never takes the profile lease or queues behind a serving bridge.
|
|
273
|
+
* never takes the profile lease or queues behind a serving bridge. The
|
|
274
|
+
* access token it gets is cached for the next run (`accessTokenCache.ts`), so
|
|
275
|
+
* most runs send one request, not an exchange and then the report. */
|
|
274
276
|
async function reportSender(args, runtime, signal, deps) {
|
|
275
277
|
if (deps.send)
|
|
276
278
|
return (report) => deps.send(report, signal, runtime, args);
|
|
277
279
|
const auth = resolveCliAuth(args, runtime.env);
|
|
278
280
|
if (auth.kind !== "profile")
|
|
279
281
|
return null;
|
|
280
|
-
const
|
|
281
|
-
|
|
282
|
-
const origin = new URL(auth.endpoint).origin;
|
|
283
|
-
return (report) => postWith((path, init) => manager.authedFetch(`${origin}${path}`, init), report, signal);
|
|
282
|
+
const api = await profileApi(auth.profile, signal, deps.fetch ?? fetch);
|
|
283
|
+
return api ? (report) => postWith(api, report, signal) : null;
|
|
284
284
|
}
|
|
285
285
|
/** Parked asks nobody claimed in time: the prompt was declined, or nothing ran. */
|
|
286
286
|
function expiredAsks(now) {
|
package/dist/credentials.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { activeProfilePath } from "./activeProfile.js";
|
|
2
2
|
/**
|
|
3
3
|
* Local credential store for the bridge: ~/.passport/credentials.json.
|
|
4
|
-
* PASSPORT_HOME overrides the directory for tests and sandboxes.
|
|
4
|
+
* PASSPORT_HOME overrides the directory for tests and sandboxes. Every write
|
|
5
|
+
* that replaces or removes a profile's credential also drops the hook's
|
|
6
|
+
* cached access token for it (`accessTokenCache.ts`).
|
|
5
7
|
*/
|
|
6
8
|
export type Profile = {
|
|
7
9
|
refreshToken: string;
|
package/dist/credentials.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { closeSync, constants, fchmodSync, fstatSync, lstatSync, openSync, readFileSync, unlinkSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
+
import { dropCachedAccess } from "./accessTokenCache.js";
|
|
3
4
|
import { credentialDir, enforceOwner, ensurePrivateDirectory, isMissing, syncDirectory, withCredentialStoreWriteLock as withStoreWriteLock, withProfileLock as withProfileLockInternal, writePrivateAtomic } from "./credentialStorage.js";
|
|
4
5
|
import { activeProfilePath, clearActiveProfileAtomic, prepareActiveProfileForSelection, readActiveProfile as readActiveProfileFile, readActiveProfileDocument, writeActiveProfileAtomic } from "./activeProfile.js";
|
|
5
6
|
/**
|
|
@@ -281,6 +282,7 @@ export function persistProfileRotation(name, previousRefreshToken, next) {
|
|
|
281
282
|
creds[name] = { ...latest, ...validatedNext };
|
|
282
283
|
writeCredsAtomic(creds);
|
|
283
284
|
clearRotationJournal(name);
|
|
285
|
+
dropCachedAccess(name);
|
|
284
286
|
});
|
|
285
287
|
}
|
|
286
288
|
/** Persist a rotating child against the endpoint currently stored for this
|
|
@@ -311,6 +313,7 @@ export function recoverProfileRotation(name) {
|
|
|
311
313
|
if (current.refreshToken === journal.previousRefreshToken) {
|
|
312
314
|
creds[name] = { ...current, ...journal.next };
|
|
313
315
|
writeCredsAtomic(creds);
|
|
316
|
+
dropCachedAccess(name);
|
|
314
317
|
}
|
|
315
318
|
else if (current.refreshToken !== journal.next.refreshToken) {
|
|
316
319
|
throw new Error("Passport profile conflicts with its credential rotation recovery journal.");
|
|
@@ -327,6 +330,7 @@ export function writeProfile(name, profile) {
|
|
|
327
330
|
creds[name] = { ...creds[name], ...profile };
|
|
328
331
|
writeCredsAtomic(creds);
|
|
329
332
|
clearRotationJournal(name);
|
|
333
|
+
dropCachedAccess(name);
|
|
330
334
|
});
|
|
331
335
|
}
|
|
332
336
|
/** Replace a profile only if the credential that started an interactive
|
|
@@ -347,6 +351,7 @@ export function replaceProfileAfterRecovery(name, previousRefreshToken, profile)
|
|
|
347
351
|
creds[name] = { ...current, ...profile };
|
|
348
352
|
writeCredsAtomic(creds);
|
|
349
353
|
clearRotationJournal(name);
|
|
354
|
+
dropCachedAccess(name);
|
|
350
355
|
});
|
|
351
356
|
}
|
|
352
357
|
export function removeProfile(name) {
|
|
@@ -358,6 +363,7 @@ export function removeProfile(name) {
|
|
|
358
363
|
delete creds[name];
|
|
359
364
|
writeCredsAtomic(creds);
|
|
360
365
|
clearRotationJournal(name);
|
|
366
|
+
dropCachedAccess(name);
|
|
361
367
|
if (active.kind === "present" && active.profile === name) {
|
|
362
368
|
const remaining = Object.keys(creds).sort();
|
|
363
369
|
if (remaining.length === 1)
|
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.16.
|
|
1
|
+
export declare const VERSION = "0.16.4";
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Keep in lockstep with bridge/package.json.
|
|
2
|
-
export const VERSION = "0.16.
|
|
2
|
+
export const VERSION = "0.16.4";
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "passport-bridge",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.4",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "passport-bridge",
|
|
9
|
-
"version": "0.16.
|
|
9
|
+
"version": "0.16.4",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@modelcontextprotocol/sdk": "1.
|
|
12
|
+
"@modelcontextprotocol/sdk": "1.32.1"
|
|
13
13
|
},
|
|
14
14
|
"bin": {
|
|
15
15
|
"passport": "dist/passport.js",
|
|
@@ -479,9 +479,9 @@
|
|
|
479
479
|
}
|
|
480
480
|
},
|
|
481
481
|
"node_modules/@modelcontextprotocol/sdk": {
|
|
482
|
-
"version": "1.
|
|
483
|
-
"resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.
|
|
484
|
-
"integrity": "sha512-
|
|
482
|
+
"version": "1.32.1",
|
|
483
|
+
"resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.32.1.tgz",
|
|
484
|
+
"integrity": "sha512-2DdE+SJDtzLEEWzY1ZjY7Q+VcPhcV1KisD3zI4u0XZyktsjHum1mwbMI+JaulUBi2OZk+KJAi2uPXzxichPkdw==",
|
|
485
485
|
"license": "MIT",
|
|
486
486
|
"dependencies": {
|
|
487
487
|
"@hono/node-server": "^1.19.9 || ^2.0.5",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "passport-bridge",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.4",
|
|
4
4
|
"description": "Passport CLI for governed terminal and CI agents, plus the local stdio-to-cloud MCP bridge.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"prepublishOnly": "npm run build"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@modelcontextprotocol/sdk": "1.
|
|
67
|
+
"@modelcontextprotocol/sdk": "1.32.1"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@types/node": "^24.13.1",
|