passport-bridge 0.8.2 → 0.10.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.
- package/README.md +100 -3
- package/dist/accessClient.d.ts +128 -0
- package/dist/accessClient.js +436 -0
- package/dist/activeProfile.d.ts +21 -0
- package/dist/boundedFile.d.ts +2 -0
- package/dist/boundedMcpFetch.d.ts +6 -0
- package/dist/boundedResponse.d.ts +4 -0
- package/dist/bridge.d.ts +98 -0
- package/dist/bridge.js +49 -42
- package/dist/bridgeConfig.d.ts +1 -0
- package/dist/bridgePoller.d.ts +34 -0
- package/dist/bridgePoller.js +123 -0
- package/dist/bridgeShutdown.d.ts +20 -0
- package/dist/bridgeShutdown.js +5 -1
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +4 -0
- package/dist/cliAccess.d.ts +3 -0
- package/dist/cliAccess.js +119 -0
- package/dist/cliArgs.d.ts +16 -0
- package/dist/cliArgs.js +14 -3
- package/dist/cliClient.d.ts +62 -0
- package/dist/cliConnect.d.ts +22 -0
- package/dist/cliDeadline.d.ts +9 -0
- package/dist/cliDescribe.d.ts +8 -0
- package/dist/cliLogin.d.ts +3 -0
- package/dist/cliOffline.d.ts +6 -0
- package/dist/cliOutput.d.ts +7 -0
- package/dist/cliOutput.js +4 -0
- package/dist/cliPagination.d.ts +15 -0
- package/dist/cliProtocol.d.ts +4 -0
- package/dist/cliReady.d.ts +9 -0
- package/dist/cliResult.d.ts +7 -0
- package/dist/cliSession.d.ts +20 -0
- package/dist/cliSetup.d.ts +10 -0
- package/dist/cliSetup.js +157 -0
- package/dist/cliSupport.d.ts +102 -0
- package/dist/completion.d.ts +2 -0
- package/dist/completion.js +20 -2
- package/dist/credentialStorage.d.ts +12 -0
- package/dist/credentials.d.ts +64 -0
- package/dist/discover.d.ts +52 -0
- package/dist/doctor.d.ts +34 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/legacyCliSecurity.d.ts +10 -0
- package/dist/managedSkills.d.ts +7 -0
- package/dist/managedSkills.js +268 -0
- package/dist/managedSkillsContract.generated.d.ts +82 -0
- package/dist/managedSkillsContract.generated.js +32 -0
- package/dist/managedSkillsFiles.d.ts +23 -0
- package/dist/managedSkillsFiles.js +215 -0
- package/dist/managedSkillsIpc.d.ts +5 -0
- package/dist/managedSkillsIpc.js +44 -0
- package/dist/managedSkillsValidation.d.ts +14 -0
- package/dist/managedSkillsValidation.js +118 -0
- package/dist/passport.d.ts +7 -0
- package/dist/passport.js +4 -0
- package/dist/privateStableFile.d.ts +13 -0
- package/dist/recoveryCleanup.d.ts +5 -0
- package/dist/recoveryIdentity.d.ts +22 -0
- package/dist/tokenWorkspace.d.ts +3 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +13 -2
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ManagedSkillPackage, ManagedSkillSource, ManagedSkillsRequest } from "./managedSkillsContract.generated.js";
|
|
2
|
+
export declare const MANAGED_SKILL_INPUT_LIMIT: number;
|
|
3
|
+
export declare const MANAGED_SKILL_FILE_LIMIT: number;
|
|
4
|
+
export declare const MANAGED_SKILL_RECORD_LIMIT: number;
|
|
5
|
+
export declare const MANAGED_SKILL_JOURNAL_LIMIT: number;
|
|
6
|
+
export declare function digest(value: string): string;
|
|
7
|
+
export declare function object(value: unknown): Record<string, unknown>;
|
|
8
|
+
export declare function identifier(value: unknown): string;
|
|
9
|
+
export declare function validOrigin(value: unknown): string;
|
|
10
|
+
export declare function validateSource(value: unknown): ManagedSkillSource;
|
|
11
|
+
export declare function validatePackage(value: unknown): ManagedSkillPackage;
|
|
12
|
+
export declare function validateRequest(value: unknown): ManagedSkillsRequest;
|
|
13
|
+
export declare function skillName(source: ManagedSkillSource): string;
|
|
14
|
+
export declare function skillContents(name: string, artifact: ManagedSkillPackage): string;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
export const MANAGED_SKILL_INPUT_LIMIT = 1024 * 1024;
|
|
3
|
+
export const MANAGED_SKILL_FILE_LIMIT = 256 * 1024;
|
|
4
|
+
export const MANAGED_SKILL_RECORD_LIMIT = 1024 * 1024;
|
|
5
|
+
export const MANAGED_SKILL_JOURNAL_LIMIT = 2 * 1024 * 1024;
|
|
6
|
+
export function digest(value) {
|
|
7
|
+
return createHash("sha256").update(value).digest("hex");
|
|
8
|
+
}
|
|
9
|
+
export function object(value) {
|
|
10
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
11
|
+
throw new Error("Invalid managed workflow data.");
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
export function identifier(value) {
|
|
15
|
+
if (typeof value !== "string" || !/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/.test(value)) {
|
|
16
|
+
throw new Error("Invalid managed workflow identity.");
|
|
17
|
+
}
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
export function validOrigin(value) {
|
|
21
|
+
if (typeof value !== "string" || value.length > 1024)
|
|
22
|
+
throw new Error("Invalid Passport origin.");
|
|
23
|
+
const parsed = new URL(value);
|
|
24
|
+
const loopback = ["localhost", "127.0.0.1", "[::1]"].includes(parsed.hostname);
|
|
25
|
+
if ((parsed.protocol !== "https:" && !(parsed.protocol === "http:" && loopback)) ||
|
|
26
|
+
parsed.username ||
|
|
27
|
+
parsed.password ||
|
|
28
|
+
parsed.search ||
|
|
29
|
+
parsed.hash ||
|
|
30
|
+
parsed.pathname !== "/")
|
|
31
|
+
throw new Error("Invalid Passport origin.");
|
|
32
|
+
return parsed.origin;
|
|
33
|
+
}
|
|
34
|
+
export function validateSource(value) {
|
|
35
|
+
const source = object(value);
|
|
36
|
+
if (source.client !== "claude-code" && source.client !== "codex")
|
|
37
|
+
throw new Error("Unsupported workflow client.");
|
|
38
|
+
return {
|
|
39
|
+
serverOrigin: validOrigin(source.serverOrigin),
|
|
40
|
+
workspaceId: identifier(source.workspaceId),
|
|
41
|
+
profileId: identifier(source.profileId),
|
|
42
|
+
workflowKey: identifier(source.workflowKey),
|
|
43
|
+
client: source.client
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function text(value, max, multiline = false) {
|
|
47
|
+
if (typeof value !== "string" ||
|
|
48
|
+
!value.trim() ||
|
|
49
|
+
Buffer.byteLength(value) > max ||
|
|
50
|
+
(multiline ? /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/ : /[\u0000-\u001f\u007f]/).test(value)) {
|
|
51
|
+
throw new Error("Invalid or oversized workflow instructions.");
|
|
52
|
+
}
|
|
53
|
+
// Buffer's UTF-8 replacement must not silently change the reviewed bytes.
|
|
54
|
+
if (Buffer.from(value, "utf8").toString("utf8") !== value)
|
|
55
|
+
throw new Error("Invalid workflow text encoding.");
|
|
56
|
+
return value;
|
|
57
|
+
}
|
|
58
|
+
export function validatePackage(value) {
|
|
59
|
+
const artifact = object(value);
|
|
60
|
+
if (!Number.isSafeInteger(artifact.revisionVersion) || Number(artifact.revisionVersion) < 1) {
|
|
61
|
+
throw new Error("Invalid workflow revision.");
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
revisionId: identifier(artifact.revisionId),
|
|
65
|
+
revisionVersion: Number(artifact.revisionVersion),
|
|
66
|
+
name: text(artifact.name, 256),
|
|
67
|
+
description: text(artifact.description, 1024),
|
|
68
|
+
instructions: text(artifact.instructions, 200 * 1024, true)
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
export function validateRequest(value) {
|
|
72
|
+
const request = object(value);
|
|
73
|
+
if (request.protocol !== "passport.managed-skills" ||
|
|
74
|
+
request.version !== 1 ||
|
|
75
|
+
!["list", "status", "install", "uninstall", "rollback"].includes(String(request.operation))) {
|
|
76
|
+
throw new Error("Unsupported managed workflow protocol.");
|
|
77
|
+
}
|
|
78
|
+
const allowed = ["protocol", "version", "operation", "source", "package", "expectedState", "scope"];
|
|
79
|
+
if (Object.keys(request).some((key) => !allowed.includes(key)))
|
|
80
|
+
throw new Error("Unsupported managed workflow field.");
|
|
81
|
+
const result = {
|
|
82
|
+
protocol: "passport.managed-skills",
|
|
83
|
+
version: 1,
|
|
84
|
+
operation: request.operation
|
|
85
|
+
};
|
|
86
|
+
if (result.operation !== "list")
|
|
87
|
+
result.source = validateSource(request.source);
|
|
88
|
+
if (request.package !== undefined)
|
|
89
|
+
result.package = validatePackage(request.package);
|
|
90
|
+
if (result.operation === "install" && !result.package)
|
|
91
|
+
throw new Error("Published workflow instructions are required.");
|
|
92
|
+
if (request.expectedState !== undefined) {
|
|
93
|
+
if (typeof request.expectedState !== "string" || !/^[a-f0-9]{64}$/.test(request.expectedState)) {
|
|
94
|
+
throw new Error("Invalid workflow review evidence.");
|
|
95
|
+
}
|
|
96
|
+
result.expectedState = request.expectedState;
|
|
97
|
+
}
|
|
98
|
+
if (!["list", "status"].includes(result.operation) && !result.expectedState) {
|
|
99
|
+
throw new Error("Review the current workflow state before changing it.");
|
|
100
|
+
}
|
|
101
|
+
if (request.scope !== undefined) {
|
|
102
|
+
const scope = object(request.scope);
|
|
103
|
+
result.scope = { serverOrigin: validOrigin(scope.serverOrigin), workspaceId: identifier(scope.workspaceId) };
|
|
104
|
+
}
|
|
105
|
+
return result;
|
|
106
|
+
}
|
|
107
|
+
export function skillName(source) {
|
|
108
|
+
const label = source.workflowKey
|
|
109
|
+
.toLowerCase()
|
|
110
|
+
.replace(/[^a-z0-9-]/g, "-")
|
|
111
|
+
.slice(0, 24);
|
|
112
|
+
return `passport-${label}-${digest(JSON.stringify(source)).slice(0, 16)}`;
|
|
113
|
+
}
|
|
114
|
+
export function skillContents(name, artifact) {
|
|
115
|
+
return (`---\nname: ${name}\ndescription: ${JSON.stringify(artifact.description)}\n---\n\n` +
|
|
116
|
+
`<!-- Managed by Passport. Local edits are preserved and block automatic replacement. -->\n\n` +
|
|
117
|
+
`# ${artifact.name}\n\n${artifact.instructions.trim()}\n`);
|
|
118
|
+
}
|
|
@@ -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
|
@@ -511,8 +511,12 @@ async function dispatch(args, runtime) {
|
|
|
511
511
|
return prompts(args, runtime);
|
|
512
512
|
case "discover":
|
|
513
513
|
return discover(args, runtime);
|
|
514
|
+
case "setup":
|
|
515
|
+
return (await import("./cliSetup.js")).setup(args, runtime, withGateway);
|
|
514
516
|
case "session":
|
|
515
517
|
return runCliSession(args, runtime, dispatch);
|
|
518
|
+
case "access":
|
|
519
|
+
return (await import("./cliAccess.js")).access(args, runtime);
|
|
516
520
|
case "completion":
|
|
517
521
|
return completionResult(args);
|
|
518
522
|
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 @@
|
|
|
1
|
+
export declare const VERSION = "0.10.0";
|
package/dist/version.js
CHANGED
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "passport-bridge",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "passport-bridge",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.10.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.
|
|
3
|
+
"version": "0.10.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",
|
|
@@ -41,7 +52,7 @@
|
|
|
41
52
|
"build": "node scripts/build.mjs",
|
|
42
53
|
"typecheck": "tsc --noEmit",
|
|
43
54
|
"test": "tsx --test \"src/**/*.test.ts\" && node ../scripts/run-script-tests.mjs",
|
|
44
|
-
"test:coverage:unit": "c8 --all --include='src/**/*.ts' --exclude='src/**/*.test.ts' --check-coverage --lines 67 --branches 70 --functions 86 --reporter=text-summary --reporter=json tsx --test 'src/**/*.test.ts'",
|
|
55
|
+
"test:coverage:unit": "c8 --all --include='src/**/*.ts' --exclude='src/**/*.test.ts' --exclude='src/**/*.generated.ts' --check-coverage --lines 67 --branches 70 --functions 86 --reporter=text-summary --reporter=json tsx --test 'src/**/*.test.ts'",
|
|
45
56
|
"test:coverage:scope": "node ../scripts/verify-coverage-scope.mjs bridge",
|
|
46
57
|
"test:coverage": "npm run build && npm run test:coverage:unit && npm run test:coverage:scope && npm run test:cli && node ../scripts/run-script-tests.mjs",
|
|
47
58
|
"dev": "tsx src/cli.ts",
|