passport-bridge 0.8.2 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +81 -3
  2. package/dist/accessClient.d.ts +128 -0
  3. package/dist/accessClient.js +436 -0
  4. package/dist/activeProfile.d.ts +21 -0
  5. package/dist/boundedFile.d.ts +2 -0
  6. package/dist/boundedMcpFetch.d.ts +6 -0
  7. package/dist/boundedResponse.d.ts +4 -0
  8. package/dist/bridge.d.ts +89 -0
  9. package/dist/bridgeConfig.d.ts +1 -0
  10. package/dist/bridgeShutdown.d.ts +17 -0
  11. package/dist/cli.d.ts +2 -0
  12. package/dist/cliAccess.d.ts +3 -0
  13. package/dist/cliAccess.js +119 -0
  14. package/dist/cliArgs.d.ts +16 -0
  15. package/dist/cliArgs.js +10 -2
  16. package/dist/cliClient.d.ts +62 -0
  17. package/dist/cliConnect.d.ts +22 -0
  18. package/dist/cliDeadline.d.ts +9 -0
  19. package/dist/cliDescribe.d.ts +8 -0
  20. package/dist/cliLogin.d.ts +3 -0
  21. package/dist/cliOffline.d.ts +6 -0
  22. package/dist/cliOutput.d.ts +7 -0
  23. package/dist/cliOutput.js +2 -0
  24. package/dist/cliPagination.d.ts +15 -0
  25. package/dist/cliProtocol.d.ts +4 -0
  26. package/dist/cliReady.d.ts +9 -0
  27. package/dist/cliResult.d.ts +7 -0
  28. package/dist/cliSession.d.ts +20 -0
  29. package/dist/cliSupport.d.ts +102 -0
  30. package/dist/completion.d.ts +2 -0
  31. package/dist/completion.js +18 -2
  32. package/dist/credentialStorage.d.ts +12 -0
  33. package/dist/credentials.d.ts +64 -0
  34. package/dist/discover.d.ts +52 -0
  35. package/dist/doctor.d.ts +34 -0
  36. package/dist/index.d.ts +2 -0
  37. package/dist/index.js +1 -0
  38. package/dist/legacyCliSecurity.d.ts +10 -0
  39. package/dist/passport.d.ts +7 -0
  40. package/dist/passport.js +2 -0
  41. package/dist/privateStableFile.d.ts +13 -0
  42. package/dist/recoveryCleanup.d.ts +5 -0
  43. package/dist/recoveryIdentity.d.ts +22 -0
  44. package/dist/tokenWorkspace.d.ts +3 -0
  45. package/dist/version.d.ts +1 -0
  46. package/dist/version.js +1 -1
  47. package/npm-shrinkwrap.json +2 -2
  48. package/package.json +12 -1
@@ -0,0 +1,2 @@
1
+ export type CompletionShell = "bash" | "zsh" | "fish";
2
+ export declare function completionScript(shell: CompletionShell): string;
@@ -15,6 +15,7 @@ const DESCRIPTIONS = {
15
15
  prompts: "List or get MCP prompts",
16
16
  discover: "Scan local MCP configuration for fleet governance",
17
17
  session: "Reuse one authenticated session for NDJSON commands",
18
+ access: "Use the signed managed access gateway",
18
19
  completion: "Generate shell completion",
19
20
  help: "Show command help",
20
21
  version: "Show CLI version and local context"
@@ -26,7 +27,16 @@ const COMMAND_FLAGS = {
26
27
  run: ["--args", "--set", "--set-json", "--wait"],
27
28
  connect: ["--alias", "--open", "--wait"],
28
29
  resources: ["--out"],
29
- prompts: ["--set", "--out"]
30
+ prompts: ["--set", "--out"],
31
+ access: [
32
+ "--workspace",
33
+ "--client-id",
34
+ "--private-key-file",
35
+ "--public-jwk-file",
36
+ "--algorithm",
37
+ "--input",
38
+ "--delegation-id"
39
+ ]
30
40
  };
31
41
  const VALUE_FLAGS = new Set([
32
42
  "--profile",
@@ -41,7 +51,13 @@ const VALUE_FLAGS = new Set([
41
51
  "--set-json",
42
52
  "--wait",
43
53
  "--alias",
44
- "--out"
54
+ "--out",
55
+ "--input",
56
+ "--algorithm",
57
+ "--private-key-file",
58
+ "--public-jwk-file",
59
+ "--delegation-id",
60
+ "--client-id"
45
61
  ]);
46
62
  function flagsFor(command) {
47
63
  return [...GLOBAL, ...(command ? (COMMAND_FLAGS[command] ?? []) : [])];
@@ -0,0 +1,12 @@
1
+ import { type Stats } from "node:fs";
2
+ export declare function credentialDir(): string;
3
+ export declare function isMissing(error: unknown): boolean;
4
+ export declare function enforceOwner(stat: Stats, label: string): void;
5
+ /** Create or repair the owner-only credential directory without following a
6
+ * symlink at the security boundary. */
7
+ export declare function ensurePrivateDirectory(create: boolean): boolean;
8
+ /** The JSON document and the active-profile pointer share this lock. */
9
+ export declare function withCredentialStoreWriteLock<T>(fn: () => T): T;
10
+ export declare function syncDirectory(): void;
11
+ export declare function writePrivateAtomic(target: string, temporaryPrefix: string, contents: string, label: string): void;
12
+ export declare function withProfileLock<T>(name: string, fn: () => Promise<T>): Promise<T>;
@@ -0,0 +1,64 @@
1
+ import { activeProfilePath } from "./activeProfile.js";
2
+ /**
3
+ * Local credential store for the bridge: ~/.passport/credentials.json.
4
+ * PASSPORT_HOME overrides the directory for tests and sandboxes.
5
+ */
6
+ export type Profile = {
7
+ refreshToken: string;
8
+ endpoint: string;
9
+ instanceId?: string;
10
+ /** Stable AI-client and route identity used when an expired bridge profile is recovered in place. */
11
+ client?: string;
12
+ target?: string;
13
+ };
14
+ type Creds = Record<string, Profile>;
15
+ export declare function inferredProfileClient(name: string, profile: Profile): string | undefined;
16
+ /** A deterministic CLI-owned profile is either explicitly tagged or has the
17
+ * exact legacy `cli@<workspace>` shape. */
18
+ export declare function isCliProfile(name: string, profile: Profile): boolean;
19
+ /** Profile names become both JSON keys and lock-file names. */
20
+ export declare function assertProfileName(name: string): void;
21
+ export declare function profileRotationJournalPath(name: string): string;
22
+ /** Best-effort reads preserve the historical offline UX. Mutations use the
23
+ * strict reader below and never turn corruption into an empty store. */
24
+ export declare function readCreds(): Creds;
25
+ export declare function getProfile(name: string): Profile | undefined;
26
+ /** Security-sensitive flows use the strict view before minting or rotating a
27
+ * credential. Corruption and unreadable paths must fail before a remote token
28
+ * is changed, not after it becomes impossible to persist. */
29
+ export declare function getProfileStrict(name: string): Profile | undefined;
30
+ export declare function assertCredentialStoreMutationReady(): void;
31
+ /** Persist a minted refresh-token child before acknowledging its access token.
32
+ * The journal is fsynced first, so a failed credential replace or killed process
33
+ * can recover the child without replaying its now-stale parent. */
34
+ export declare function persistProfileRotation(name: string, previousRefreshToken: string, next: Profile): void;
35
+ /** Persist a rotating child against the endpoint currently stored for this
36
+ * profile. Interactive recovery may have replaced that endpoint after the
37
+ * TokenManager was constructed, so a captured startup endpoint is only a
38
+ * fallback and must never overwrite newer durable state. */
39
+ export declare function persistCurrentProfileRotation(name: string, previousRefreshToken: string, nextRefreshToken: string, fallbackEndpoint: string): void;
40
+ /** Complete an interrupted profile rotation while the caller owns its profile
41
+ * lock. Conflicting state fails closed rather than choosing a stale parent. */
42
+ export declare function recoverProfileRotation(name: string): Profile | undefined;
43
+ export declare function writeProfile(name: string, profile: Profile): void;
44
+ /** Replace a profile only if the credential that started an interactive
45
+ * recovery is still the live slot value. A bridge may be waiting for browser
46
+ * approval while another process rotates or reconnects the same profile; in
47
+ * that race the newer durable slot wins and the recovery must not overwrite
48
+ * it. */
49
+ export declare function replaceProfileAfterRecovery(name: string, previousRefreshToken: string, profile: Profile): void;
50
+ export declare function removeProfile(name: string): Profile | undefined;
51
+ export { activeProfilePath };
52
+ /** Serialize refresh-token exchange across processes. A heartbeat keeps a live
53
+ * owner fresh; the random token makes release ownership-safe after recovery. */
54
+ export declare function withProfileLock<T>(name: string, fn: () => Promise<T>): Promise<T>;
55
+ /** Best-effort read for command resolution. A stale or damaged pointer must
56
+ * never make the CLI guess a credential; callers can fall back to the normal
57
+ * sole-profile rule or report ambiguity. */
58
+ export declare function readActiveProfile(): string | undefined;
59
+ /** Make a stored profile the local default for interactive CLI commands. The
60
+ * selected name is not a credential and is stored separately from secrets. */
61
+ export declare function setActiveProfile(name: string): void;
62
+ /** Clear the local selection, optionally only when it points at `name`. */
63
+ export declare function clearActiveProfile(name?: string): void;
64
+ export declare function credsPath(): string;
@@ -0,0 +1,52 @@
1
+ export type DiscoveryClient = "claude" | "claude-code" | "cursor" | "vscode" | "codex";
2
+ export type DiscoverySourceStatus = "ready" | "missing" | "permission_denied" | "invalid" | "unreadable";
3
+ export type DiscoveryEntry = {
4
+ client: DiscoveryClient;
5
+ name: string;
6
+ governance: "governed" | "unmanaged";
7
+ transport: "stdio" | "http" | "sse" | "unknown";
8
+ detail: string;
9
+ canImport: boolean;
10
+ protectedSettings: boolean;
11
+ };
12
+ export type DiscoverySource = {
13
+ client: DiscoveryClient;
14
+ status: DiscoverySourceStatus;
15
+ servers: DiscoveryEntry[];
16
+ };
17
+ export type DiscoverySnapshot = {
18
+ scanId: string;
19
+ scannedAt: number;
20
+ installationId: string;
21
+ installationLabel: string;
22
+ sources: DiscoverySource[];
23
+ };
24
+ export type DiscoveryComplianceReport = {
25
+ assets?: Array<{
26
+ connectionCount?: number;
27
+ decision?: {
28
+ state?: string;
29
+ } | null;
30
+ }>;
31
+ policy?: {
32
+ fleetMode?: string;
33
+ enforcement?: string;
34
+ };
35
+ };
36
+ /**
37
+ * A managed scanner is the enforcement boundary Passport can verify today.
38
+ * `require_passport` fails every active direct connection unless an admin has
39
+ * explicitly approved it or granted an exception. `block` is narrower: it
40
+ * fails entries an admin explicitly denied. Endpoint management can use the
41
+ * exit code as a compliance gate without Passport editing client config.
42
+ */
43
+ export declare function evaluateDiscoveryCompliance(report: DiscoveryComplianceReport): {
44
+ compliant: boolean;
45
+ routeRequired: number;
46
+ denied: number;
47
+ };
48
+ export declare function inspectDiscoveryEntry(client: DiscoveryClient, rawName: string, raw: unknown, passportOrigin: string): DiscoveryEntry;
49
+ export declare function fleetInstallationId(env?: NodeJS.ProcessEnv): string;
50
+ export declare function scanLocalMcpConfigs(passportOrigin: string, env?: NodeJS.ProcessEnv): DiscoverySnapshot;
51
+ /** Contract helper: no prohibited local detail may enter the wire snapshot. */
52
+ export declare function discoverySnapshotFingerprint(snapshot: DiscoverySnapshot): string;
@@ -0,0 +1,34 @@
1
+ export type DoctorStatus = "pass" | "warn" | "fail" | "skip";
2
+ export type DoctorCheck = {
3
+ id: string;
4
+ status: DoctorStatus;
5
+ summary: string;
6
+ action?: string;
7
+ };
8
+ export type DoctorReport = {
9
+ version: string;
10
+ ok: boolean;
11
+ auth: "profile" | "agent-key" | "none";
12
+ profile?: string;
13
+ profileCount: number;
14
+ endpointOrigin?: string;
15
+ server?: {
16
+ name: string;
17
+ version: string;
18
+ };
19
+ checks: DoctorCheck[];
20
+ };
21
+ type DoctorOptions = {
22
+ version: string;
23
+ profile?: string;
24
+ env: NodeJS.ProcessEnv;
25
+ timeoutMs: number;
26
+ signal: AbortSignal;
27
+ caller?: string;
28
+ normalizeEndpoint: (raw: string) => string;
29
+ redactError: (message: string) => string;
30
+ };
31
+ export declare function nodeRuntimeSupported(version: string): boolean;
32
+ export declare function runDoctor(options: DoctorOptions): Promise<DoctorReport>;
33
+ export declare function formatDoctorReport(report: DoctorReport): string;
34
+ export {};
@@ -0,0 +1,2 @@
1
+ export { AccessGatewayClient, AccessGatewayError, accessClientFromEnv, assertCallerId, defaultAccessPrivateKeyFile, defaultAccessPublicJwkFile, generateAccessKey, parseAccessInputFile, writeGeneratedAccessKey } from "./accessClient.js";
2
+ export type { AccessAction, AccessAlgorithm, AccessCapability, AccessGatewayClientOptions, AccessInvocationInput, AccessInvocationResult, AccessReceipt, AccessRun, AccessRunInput, GeneratedAccessKey } from "./accessClient.js";
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export { AccessGatewayClient, AccessGatewayError, accessClientFromEnv, assertCallerId, defaultAccessPrivateKeyFile, defaultAccessPublicJwkFile, generateAccessKey, parseAccessInputFile, writeGeneratedAccessKey } from "./accessClient.js";
@@ -0,0 +1,10 @@
1
+ /** Kept well below the profile lock's 30-second stale lease. */
2
+ export declare const LEGACY_REQUEST_TIMEOUT_MS = 10000;
3
+ export declare function legacyCloudOrigin(raw: string): string;
4
+ export declare function legacyProfileEndpoint(raw: string): string;
5
+ export declare function legacyCredentialEndpoint(raw: string, cloud: string): string;
6
+ export declare function legacyVerifyUrl(raw: string, cloud: string): string;
7
+ /** Every legacy network operation is finite and refuses redirects. In
8
+ * particular, a 307/308 can never replay a refresh token, session bearer, or
9
+ * device code to an origin selected by a response. */
10
+ export declare function legacyFetch(input: string | URL, init?: RequestInit, fetcher?: typeof fetch, timeout?: number): Promise<Response>;
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+ import { type Env, type Runtime } from "./cliSupport.js";
3
+ export { refusalOf } from "./cliResult.js";
4
+ export { callerFrom, sanitize } from "./cliSupport.js";
5
+ export declare function main(argv?: string[], env?: Env, io?: Pick<Runtime, "stdout" | "stderr"> & {
6
+ stdin?: Runtime["stdin"];
7
+ }): Promise<number>;
package/dist/passport.js CHANGED
@@ -513,6 +513,8 @@ async function dispatch(args, runtime) {
513
513
  return discover(args, runtime);
514
514
  case "session":
515
515
  return runCliSession(args, runtime, dispatch);
516
+ case "access":
517
+ return (await import("./cliAccess.js")).access(args, runtime);
516
518
  case "completion":
517
519
  return completionResult(args);
518
520
  case "help":
@@ -0,0 +1,13 @@
1
+ type StablePrivateFileOptions<T> = {
2
+ target: string;
3
+ label: string;
4
+ temporaryPrefix: string;
5
+ maxBytes: number;
6
+ create(): string;
7
+ parse(contents: string): T | undefined;
8
+ };
9
+ /** Create an owner-only stable file exactly once. Hard-link publication is an
10
+ * atomic no-replace operation, so every concurrent process rereads the same
11
+ * winner rather than overwriting it with its own candidate. */
12
+ export declare function readOrCreatePrivateStableFile<T>(options: StablePrivateFileOptions<T>): T;
13
+ export {};
@@ -0,0 +1,5 @@
1
+ /** Revoke a replacement after a local recovery failure. This intentionally
2
+ * does not accept the recovery flow's AbortSignal: cancellation must not leave
3
+ * a newly issued server credential live, and legacyFetch supplies its own
4
+ * bounded timeout. */
5
+ export declare function revokeIssuedRecoveryCredential(cloud: string, refreshToken: string, fetcher?: typeof fetch): Promise<void>;
@@ -0,0 +1,22 @@
1
+ import type { Profile } from "./credentials.js";
2
+ export type RecoveryIdentity = {
3
+ client: string;
4
+ target: string;
5
+ instanceId?: string;
6
+ };
7
+ /**
8
+ * Resolve the identity of a saved profile without inventing a new device.
9
+ *
10
+ * Desktop profiles created before recovery metadata was persisted have a
11
+ * qualified slot name (`<client>@<workspace>`), which is enough to recover
12
+ * the policy client but not the installation id. The server receives the
13
+ * previous credential as a private recovery hint and resolves that exact
14
+ * device. A metadata-free profile derives its route target from the saved
15
+ * endpoint; an unrecognized endpoint is intentionally rejected instead of
16
+ * silently falling back to the workspace.
17
+ *
18
+ * The old recovery bug could persist the whole qualified profile name as the
19
+ * client. Treat that exact shape as repairable poison; any other disagreement
20
+ * between a stored client and its slot name is unsafe to guess through.
21
+ */
22
+ export declare function recoveryIdentity(profile: string, storedProfile: Profile | undefined, expectedWorkspace?: string, endpoint?: string): RecoveryIdentity;
@@ -0,0 +1,3 @@
1
+ /** Every server-issued token is workspace-prefixed (`<wsId>~...`). Returns an
2
+ * empty string for environment-supplied or malformed tokens. */
3
+ export declare function workspaceOfToken(token: string): string;
@@ -0,0 +1 @@
1
+ export declare const VERSION = "0.9.0";
package/dist/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  // Keep in lockstep with bridge/package.json. The published bridge can run from
2
2
  // a compiled sidecar where package.json is not available at runtime.
3
- export const VERSION = "0.8.2";
3
+ export const VERSION = "0.9.0";
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "passport-bridge",
3
- "version": "0.8.2",
3
+ "version": "0.9.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "passport-bridge",
9
- "version": "0.8.2",
9
+ "version": "0.9.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@modelcontextprotocol/sdk": "1.30.0"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "passport-bridge",
3
- "version": "0.8.2",
3
+ "version": "0.9.0",
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": {
@@ -26,6 +26,17 @@
26
26
  "passport-bridge": "./dist/cli.js",
27
27
  "passport": "./dist/passport.js"
28
28
  },
29
+ "exports": {
30
+ ".": {
31
+ "types": "./dist/index.d.ts",
32
+ "import": "./dist/index.js"
33
+ },
34
+ "./access": {
35
+ "types": "./dist/accessClient.d.ts",
36
+ "import": "./dist/accessClient.js"
37
+ },
38
+ "./package.json": "./package.json"
39
+ },
29
40
  "files": [
30
41
  "dist",
31
42
  "README.md",