passport-bridge 0.16.12 → 0.16.13
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 +3 -1
- package/dist/cliAutopilotPolicy.d.ts +15 -0
- package/dist/cliExec.d.ts +2 -0
- package/dist/cliExec.js +5 -1
- package/dist/cliGuardState.d.ts +20 -3
- package/dist/cliGuardState.js +24 -12
- package/dist/cliHook.js +4 -2
- package/dist/cliHookDecide.d.ts +16 -4
- package/dist/cliHookDecide.js +58 -14
- package/dist/cliHookGuard.d.ts +9 -0
- package/dist/cliHookGuard.js +16 -2
- package/dist/cliPolicyV2.js +53 -2
- 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/dist/webLinks.d.ts +2 -0
- package/dist/webLinks.js +7 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -257,7 +257,9 @@ An ask becomes one Activity row. In Claude Code, with the audit hook registered,
|
|
|
257
257
|
|
|
258
258
|
**Coverage** (`src/cliSeen.ts`). The guard counts every command it saw, per agent per day, one character per command in `$PASSPORT_HOME/seen/<profile>.<agent>.<day>.log` (an app's action, not checked, or neither), and Cursor's imported copy of Claude Code's hook doesn't count twice. Counts go in their own batches, at most every five minutes, as `seen: {batch, day, count, governed, opaque}` on `POST /api/my/cli-activity`, never inside a report that can expire. `passport status` prints `Checked: 94% of commands Passport saw this week`.
|
|
259
259
|
|
|
260
|
-
**When Passport can't be reached.** When the guard needs Passport (an unattended ask, Codex, or a Production action someone else approves) and it doesn't answer within the budget, the environment's `offline` setting from cli-policy v2 decides: ask, block, or allow (
|
|
260
|
+
**When Passport can't be reached.** A local run, block, or attended ask stands as decided. When the guard needs Passport (an unattended ask, Codex, or a Production action someone else approves) and it doesn't answer within the budget, the environment's `offline` setting from cli-policy v2 decides: ask, block, or allow (ask everywhere by default). An ask nobody can answer (unattended, or Codex) blocks, a second-person action is always blocked, and allow never covers an irreversible action or an ask from a team floor, team or workspace rule, approver rule, or approved exception. A policy synced more than 7 days ago uses the default. The reason ends with one line saying why, such as `Nobody is here to approve it and Passport couldn't be reached, so it's blocked.`
|
|
261
|
+
|
|
262
|
+
**App access.** The person's pass for the app a `passport exec` CLI acts on (Railway for `railway`, GitHub for `gh`, and so on) comes with cli-policy v2 as `appAccess`. No access blocks every command of that CLI with `You don't have access to Railway in Passport. Ask an admin.` and a link to the app's Access tab; read-only blocks everything but reads. `passport exec` says the same (exit 5, cause `no_access`, with `Access: <link>`). A CLI whose app isn't in the workspace keeps working from its key.
|
|
261
263
|
|
|
262
264
|
`src/cliPolicy.ts` caches the member's CLI policy (`GET /api/my/cli-policy`) at `$PASSPORT_HOME/cli-policy/<profile>.json` (mode 600). Servers with Autopilot send version 2 (`src/cliPolicyV2.ts`: presets, floors, CLI rules, irreversible and delete verbs, environment flags, placed environments); older servers send version 1, and then the guard keeps its earlier shape: ask or deny before destructive verbs, never allow, no server call, and reports without the Autopilot fields. `passport login` and `passport status` refresh it and `passport logout` removes it. A 404 or error keeps the previous copy; with no copy the guard asks before every destructive verb. `PASSPORT_HOOK_DISABLED=1` turns both hooks off.
|
|
263
265
|
|
|
@@ -41,6 +41,9 @@ export type CliRule = {
|
|
|
41
41
|
label?: string;
|
|
42
42
|
/** Actions an approved exception lifts this rule for (this person only). */
|
|
43
43
|
except?: RuleException[];
|
|
44
|
+
/** This rule is an approved exception: the person's own, but an admin
|
|
45
|
+
* approved it, so an offline Run never loosens it. */
|
|
46
|
+
exception?: true;
|
|
44
47
|
};
|
|
45
48
|
export type RuleException = {
|
|
46
49
|
vendor?: string;
|
|
@@ -49,6 +52,14 @@ export type RuleException = {
|
|
|
49
52
|
actionClass?: ActionClass;
|
|
50
53
|
environment: ActionEnv | "any";
|
|
51
54
|
};
|
|
55
|
+
/** One vendor's app access: the server's cause and message, and the Access link. */
|
|
56
|
+
export type AppAccessEntry = {
|
|
57
|
+
pass: "full" | "readonly" | "none";
|
|
58
|
+
app: string;
|
|
59
|
+
cause: string;
|
|
60
|
+
message: string;
|
|
61
|
+
link?: string;
|
|
62
|
+
};
|
|
52
63
|
/** The second-person rule's cause lines, as the server words them. */
|
|
53
64
|
export declare const SECOND_PERSON_LABEL: {
|
|
54
65
|
readonly change: "Production changes need someone else to approve";
|
|
@@ -98,6 +109,10 @@ export type AutopilotPolicy = {
|
|
|
98
109
|
/** What the guard does per environment when Passport can't be reached
|
|
99
110
|
* (Batch A). Absent from older servers: built-in defaults apply. */
|
|
100
111
|
offline?: Record<ActionEnv, "ask" | "block" | "allow">;
|
|
112
|
+
/** The person's pass for the app each vendor CLI acts on (cli-policy v2
|
|
113
|
+
* `appAccess`), by vendor: No access blocks every command, Read-only runs
|
|
114
|
+
* only reads. A vendor without an entry has no app in the workspace. */
|
|
115
|
+
appAccess?: Record<string, AppAccessEntry>;
|
|
101
116
|
/** Resources the workspace placed, by id (Phase 4.5). Present only when the
|
|
102
117
|
* server reads where a finding lands, so findings may carry it. */
|
|
103
118
|
resources?: Array<{
|
package/dist/cliExec.d.ts
CHANGED
|
@@ -56,6 +56,8 @@ type Authorized = {
|
|
|
56
56
|
/** Phase 4: a backup was taken right before, or couldn't be (with the reason). */
|
|
57
57
|
backup?: unknown;
|
|
58
58
|
backupNote?: unknown;
|
|
59
|
+
/** A block's fix, as a web hash (`#apps/railway/access`). */
|
|
60
|
+
link?: unknown;
|
|
59
61
|
/** A recent decline answered this command: who, the note, and when. */
|
|
60
62
|
declined?: {
|
|
61
63
|
by?: unknown;
|
package/dist/cliExec.js
CHANGED
|
@@ -37,7 +37,7 @@ import { EXEC_ENV_NAMES, EXEC_PASSPORT_ENV, EXEC_SHADOWED_ENV, EXEC_VENDOR_NAMES
|
|
|
37
37
|
import { execTarget } from "./execTarget.js";
|
|
38
38
|
import { maskChildOutput, secretNeedles } from "./execMask.js";
|
|
39
39
|
import { findVendorBinary, removeShims } from "./execShims.js";
|
|
40
|
-
import { approvalLink } from "./webLinks.js";
|
|
40
|
+
import { approvalLink, hashLink } from "./webLinks.js";
|
|
41
41
|
import { workspaceOfToken } from "./tokenWorkspace.js";
|
|
42
42
|
import { declinedLine, waitingParts } from "./waitingLine.js";
|
|
43
43
|
export const EXEC_AUTHORIZE_PATH = "/api/my/exec/authorize";
|
|
@@ -488,6 +488,10 @@ export async function exec(args, runtime, deps = {}) {
|
|
|
488
488
|
hint: ASK_AGAIN_HINT
|
|
489
489
|
});
|
|
490
490
|
}
|
|
491
|
+
// Blocked by the app's access: say where an admin changes it.
|
|
492
|
+
const link = hashLink(auth.endpoint, decided.link);
|
|
493
|
+
if (link)
|
|
494
|
+
return failure(message, 5, "no_access", { hint: `Access: ${link}` });
|
|
491
495
|
return failure(message, 5, "blocked");
|
|
492
496
|
}
|
|
493
497
|
if (decided.decision !== "allow")
|
package/dist/cliGuardState.d.ts
CHANGED
|
@@ -49,12 +49,29 @@ export declare function guardStateFix(state: GuardState | null, client: GuardCli
|
|
|
49
49
|
export declare function fixLine(fix: ProblemFix): string;
|
|
50
50
|
export type OfflineDecision = "ask" | "block" | "allow";
|
|
51
51
|
export type OfflineRow = "production" | "staging" | "development" | "other";
|
|
52
|
-
|
|
52
|
+
/** Every environment asks unless the person chose otherwise (`OFFLINE_DEFAULT`
|
|
53
|
+
* in shared/guardContract.ts); used only without a fresh policy. */
|
|
54
|
+
export declare const OFFLINE_DEFAULT: OfflineDecision;
|
|
53
55
|
export declare const OFFLINE_CACHE_MAX_MS: number;
|
|
54
|
-
export declare const
|
|
56
|
+
export declare const OFFLINE_NOTES: {
|
|
57
|
+
readonly decided: "Passport couldn't be reached, so this computer decided.";
|
|
58
|
+
readonly setting: "Passport couldn't be reached, and your setting for that blocks it.";
|
|
59
|
+
readonly allowed: "Passport couldn't be reached, and your setting for that runs it.";
|
|
60
|
+
readonly unattended: "Nobody is here to approve it and Passport couldn't be reached, so it's blocked.";
|
|
61
|
+
readonly codex: "Codex can't ask and Passport couldn't be reached, so it's blocked.";
|
|
62
|
+
readonly secondPerson: "Someone else approves this and Passport couldn't be reached, so it's blocked.";
|
|
63
|
+
};
|
|
64
|
+
export type OfflineNote = keyof typeof OFFLINE_NOTES;
|
|
65
|
+
/** A local Ask that needed Passport, when Passport didn't answer in time (see
|
|
66
|
+
* shared/guardContract.ts `offlineDecision`). */
|
|
55
67
|
export declare function offlineDecision(input: {
|
|
56
68
|
setting: OfflineDecision;
|
|
57
69
|
actionClass?: string;
|
|
58
70
|
client: string;
|
|
59
71
|
secondPerson: boolean;
|
|
60
|
-
|
|
72
|
+
attended: boolean;
|
|
73
|
+
required: boolean;
|
|
74
|
+
}): {
|
|
75
|
+
decision: "allow" | "ask" | "block";
|
|
76
|
+
note: OfflineNote;
|
|
77
|
+
};
|
package/dist/cliGuardState.js
CHANGED
|
@@ -101,21 +101,33 @@ export function guardStateFix(state, client) {
|
|
|
101
101
|
export function fixLine(fix) {
|
|
102
102
|
return fix.command ? `${fix.text} Run: ${fix.command}` : fix.text;
|
|
103
103
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
development: "allow",
|
|
108
|
-
other: "allow"
|
|
109
|
-
};
|
|
104
|
+
/** Every environment asks unless the person chose otherwise (`OFFLINE_DEFAULT`
|
|
105
|
+
* in shared/guardContract.ts); used only without a fresh policy. */
|
|
106
|
+
export const OFFLINE_DEFAULT = "ask";
|
|
110
107
|
export const OFFLINE_CACHE_MAX_MS = 7 * 24 * 60 * 60_000;
|
|
111
|
-
export const
|
|
108
|
+
export const OFFLINE_NOTES = {
|
|
109
|
+
decided: "Passport couldn't be reached, so this computer decided.",
|
|
110
|
+
setting: "Passport couldn't be reached, and your setting for that blocks it.",
|
|
111
|
+
allowed: "Passport couldn't be reached, and your setting for that runs it.",
|
|
112
|
+
unattended: "Nobody is here to approve it and Passport couldn't be reached, so it's blocked.",
|
|
113
|
+
codex: "Codex can't ask and Passport couldn't be reached, so it's blocked.",
|
|
114
|
+
secondPerson: "Someone else approves this and Passport couldn't be reached, so it's blocked."
|
|
115
|
+
};
|
|
116
|
+
/** A local Ask that needed Passport, when Passport didn't answer in time (see
|
|
117
|
+
* shared/guardContract.ts `offlineDecision`). */
|
|
112
118
|
export function offlineDecision(input) {
|
|
113
119
|
if (input.secondPerson)
|
|
114
|
-
return "block";
|
|
120
|
+
return { decision: "block", note: "secondPerson" };
|
|
115
121
|
let decision = input.setting;
|
|
116
|
-
if (decision === "allow" && input.actionClass === "irreversible")
|
|
122
|
+
if (decision === "allow" && (input.actionClass === "irreversible" || input.required))
|
|
117
123
|
decision = "ask";
|
|
118
|
-
if (decision === "
|
|
119
|
-
decision
|
|
120
|
-
|
|
124
|
+
if (decision === "allow")
|
|
125
|
+
return { decision, note: "allowed" };
|
|
126
|
+
if (decision === "block")
|
|
127
|
+
return { decision, note: "setting" };
|
|
128
|
+
if (input.client === "codex")
|
|
129
|
+
return { decision: "block", note: "codex" };
|
|
130
|
+
if (!input.attended)
|
|
131
|
+
return { decision: "block", note: "unattended" };
|
|
132
|
+
return { decision, note: "decided" };
|
|
121
133
|
}
|
package/dist/cliHook.js
CHANGED
|
@@ -353,7 +353,9 @@ function outputClient(event, runtime) {
|
|
|
353
353
|
async function guardReport(base, plan, context) {
|
|
354
354
|
if (plan.server && base)
|
|
355
355
|
return serverDecidedReport(base, plan.server, context.now);
|
|
356
|
-
|
|
356
|
+
// Offline, this computer's answer replaces the local Ask on the record.
|
|
357
|
+
const decided = base && plan.offline && plan.verdict ? { ...base, decision: plan.verdict } : base;
|
|
358
|
+
const report = decided && context.v2 && decided.decision === "allow" ? null : codexAskBlocked(decided);
|
|
357
359
|
if (!report)
|
|
358
360
|
return null;
|
|
359
361
|
// Claude Code reuses its tool-use id after a command: an ask waits for the audit hook, then is one row.
|
|
@@ -390,7 +392,7 @@ function answeredWith(decision, plan) {
|
|
|
390
392
|
if (plan.server) {
|
|
391
393
|
return plan.server.decision === "block" ? "deny" : plan.server.decision === "none" ? "none" : plan.server.decision;
|
|
392
394
|
}
|
|
393
|
-
return decision?.verdict ?? "none";
|
|
395
|
+
return plan.verdict ?? decision?.verdict ?? "none";
|
|
394
396
|
}
|
|
395
397
|
/**
|
|
396
398
|
* After the answer is out, on this computer only: the speed numbers, an
|
package/dist/cliHookDecide.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ import { type EnvKind } from "./cliHookEnvironment.js";
|
|
|
20
20
|
import { type GuardClient, type GuardDecision } from "./cliHookGuard.js";
|
|
21
21
|
import type { HookMode } from "./cliHookMode.js";
|
|
22
22
|
import type { CachedCliPolicy } from "./cliPolicy.js";
|
|
23
|
+
import { type OfflineNote } from "./cliGuardState.js";
|
|
23
24
|
export declare const CLI_DECIDE_PATH = "/api/my/cli/decide";
|
|
24
25
|
export type CliDecideRequest = {
|
|
25
26
|
runtime: string;
|
|
@@ -61,20 +62,31 @@ export type GuardPlan = {
|
|
|
61
62
|
output: Record<string, unknown> | null;
|
|
62
63
|
server: ServerDecision | null;
|
|
63
64
|
offline: boolean;
|
|
65
|
+
/** Offline: what this computer decided in place of the local Ask. */
|
|
66
|
+
verdict?: GuardDecision["verdict"];
|
|
64
67
|
};
|
|
65
68
|
/** Codex can't ask from a hook, so an ask it read is recorded as the block it was. */
|
|
66
69
|
export declare function codexAskBlocked<T extends {
|
|
67
70
|
runtime: string;
|
|
68
71
|
decision?: string;
|
|
69
72
|
}>(report: T | null): T | null;
|
|
73
|
+
export type OfflineVerdict = {
|
|
74
|
+
verdict: GuardDecision["verdict"];
|
|
75
|
+
note: OfflineNote;
|
|
76
|
+
};
|
|
70
77
|
/**
|
|
71
78
|
* When Passport can't be reached (Batch A): the person's setting for the
|
|
72
79
|
* action's environment, from a policy synced in the last 7 days, else the
|
|
73
|
-
* built-in
|
|
74
|
-
*
|
|
75
|
-
*
|
|
80
|
+
* built-in default (Ask everywhere). It only ever sees a local Ask that needed
|
|
81
|
+
* Passport; anything else stands as decided. Someone else's approval is never
|
|
82
|
+
* possible offline; Run never covers an irreversible action or anything the
|
|
83
|
+
* team requires; and an Ask nobody can answer (unattended, or Codex) blocks.
|
|
76
84
|
*/
|
|
77
|
-
export declare function offlineVerdict(decision: GuardDecision, policy: CachedCliPolicy | null,
|
|
85
|
+
export declare function offlineVerdict(decision: GuardDecision, policy: CachedCliPolicy | null, context: {
|
|
86
|
+
client: GuardClient;
|
|
87
|
+
secondPerson: boolean;
|
|
88
|
+
attended: boolean;
|
|
89
|
+
}, now: number): OfflineVerdict;
|
|
78
90
|
/**
|
|
79
91
|
* Attended, or no v2 policy: the local decision, printed at once. Unattended
|
|
80
92
|
* ask: the server decides within the budget, and an approval request replaces
|
package/dist/cliHookDecide.js
CHANGED
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
import { needsSecondPerson } from "./cliAutopilotPolicy.js";
|
|
19
19
|
import { readBoundedJson } from "./boundedResponse.js";
|
|
20
20
|
import { isEnvKind } from "./cliHookEnvironment.js";
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
21
|
+
import { askMessage, guardOutput, waitingMessage } from "./cliHookGuard.js";
|
|
22
|
+
import { OFFLINE_CACHE_MAX_MS, OFFLINE_DEFAULT, OFFLINE_NOTES, offlineDecision } from "./cliGuardState.js";
|
|
23
23
|
import { redactCommand } from "./cliHookRedact.js";
|
|
24
24
|
export const CLI_DECIDE_PATH = "/api/my/cli/decide";
|
|
25
25
|
const MAX_RESPONSE_BYTES = 16 * 1024;
|
|
@@ -124,14 +124,33 @@ export async function decideOnServer(api, request, signal) {
|
|
|
124
124
|
export function codexAskBlocked(report) {
|
|
125
125
|
return report?.runtime === "codex" && report.decision === "ask" ? { ...report, decision: "deny" } : report;
|
|
126
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* Whether an Ask came from something the person can't change on their own: a
|
|
129
|
+
* team floor (or the approver rule), a team or workspace rule, an approved
|
|
130
|
+
* exception, or a built-in rule such as sudo. Only the person's own preset or
|
|
131
|
+
* own rule may be loosened by their offline Run.
|
|
132
|
+
*/
|
|
133
|
+
function requiredCause(cause, policy) {
|
|
134
|
+
if (!cause)
|
|
135
|
+
return true;
|
|
136
|
+
if (cause.kind === "preset")
|
|
137
|
+
return false;
|
|
138
|
+
if (cause.kind !== "rule")
|
|
139
|
+
return true;
|
|
140
|
+
const rule = policy?.version === 2 ? policy.autopilot.rules.find((entry) => entry.id === cause.id) : undefined;
|
|
141
|
+
return !(rule?.scope === "me" && !rule.exception);
|
|
142
|
+
}
|
|
127
143
|
/**
|
|
128
144
|
* When Passport can't be reached (Batch A): the person's setting for the
|
|
129
145
|
* action's environment, from a policy synced in the last 7 days, else the
|
|
130
|
-
* built-in
|
|
131
|
-
*
|
|
132
|
-
*
|
|
146
|
+
* built-in default (Ask everywhere). It only ever sees a local Ask that needed
|
|
147
|
+
* Passport; anything else stands as decided. Someone else's approval is never
|
|
148
|
+
* possible offline; Run never covers an irreversible action or anything the
|
|
149
|
+
* team requires; and an Ask nobody can answer (unattended, or Codex) blocks.
|
|
133
150
|
*/
|
|
134
|
-
export function offlineVerdict(decision, policy,
|
|
151
|
+
export function offlineVerdict(decision, policy, context, now) {
|
|
152
|
+
if (decision.verdict !== "ask")
|
|
153
|
+
return { verdict: decision.verdict, note: "decided" };
|
|
135
154
|
const fresh = policy?.version === 2 && now - policy.fetchedAt <= OFFLINE_CACHE_MAX_MS ? policy : null;
|
|
136
155
|
// An action Passport couldn't place counts as Production.
|
|
137
156
|
const row = decision.environment === undefined
|
|
@@ -139,14 +158,38 @@ export function offlineVerdict(decision, policy, client, secondPerson, now) {
|
|
|
139
158
|
: isEnvKind(decision.environment)
|
|
140
159
|
? decision.environment
|
|
141
160
|
: "other";
|
|
142
|
-
const setting = fresh?.autopilot.offline?.[row] ??
|
|
143
|
-
|
|
161
|
+
const setting = fresh?.autopilot.offline?.[row] ?? OFFLINE_DEFAULT;
|
|
162
|
+
// Every command in the line that asked counts, not just the one named.
|
|
163
|
+
const asks = (decision.decided ?? []).filter((entry) => entry.decision === "ask");
|
|
164
|
+
const required = requiredCause(decision.cause, policy) || asks.some((entry) => requiredCause(entry.cause, policy));
|
|
165
|
+
const irreversible = decision.actionClass === "irreversible" || asks.some((entry) => entry.actionClass === "irreversible");
|
|
166
|
+
const { decision: verdict, note } = offlineDecision({
|
|
144
167
|
setting,
|
|
145
|
-
...(
|
|
146
|
-
|
|
147
|
-
|
|
168
|
+
...(irreversible
|
|
169
|
+
? { actionClass: "irreversible" }
|
|
170
|
+
: decision.actionClass
|
|
171
|
+
? { actionClass: decision.actionClass }
|
|
172
|
+
: {}),
|
|
173
|
+
client: context.client,
|
|
174
|
+
secondPerson: context.secondPerson,
|
|
175
|
+
attended: context.attended,
|
|
176
|
+
required
|
|
148
177
|
});
|
|
149
|
-
return verdict === "block" ? "deny" : verdict;
|
|
178
|
+
return { verdict: verdict === "block" ? "deny" : verdict, note };
|
|
179
|
+
}
|
|
180
|
+
/** What the agent reads when this computer decided offline. */
|
|
181
|
+
function offlineOutput(client, decision, offline) {
|
|
182
|
+
const note = OFFLINE_NOTES[offline.note];
|
|
183
|
+
// An explicit Run says it ran because of the setting, not the rule that asked.
|
|
184
|
+
if (offline.verdict === "allow") {
|
|
185
|
+
const cause = { kind: "default", label: note.replace(/\.$/, "") };
|
|
186
|
+
return guardOutput(client, { ...decision, verdict: "allow", cause });
|
|
187
|
+
}
|
|
188
|
+
if (offline.verdict !== "deny")
|
|
189
|
+
return guardOutput(client, { ...decision, verdict: offline.verdict }, { note });
|
|
190
|
+
// An Ask that became a block: say what it was, and why it's blocked now.
|
|
191
|
+
const asked = askMessage(decision).replace(/ Approve to run it\.$/, "");
|
|
192
|
+
return guardOutput(client, { ...decision, verdict: "deny" }, { waiting: `${asked} ${note}` });
|
|
150
193
|
}
|
|
151
194
|
/** Turn the server's answer into what the agent reads. */
|
|
152
195
|
function serverOutput(client, decision, server) {
|
|
@@ -205,11 +248,12 @@ export async function planGuard(decision, policy, context) {
|
|
|
205
248
|
: null;
|
|
206
249
|
if (!server) {
|
|
207
250
|
// Passport didn't answer in time: the environment's offline setting decides.
|
|
208
|
-
const offline = offlineVerdict(decision, policy, context.client, secondPerson, context.now());
|
|
251
|
+
const offline = offlineVerdict(decision, policy, { client: context.client, secondPerson, attended: context.mode === "attended" }, context.now());
|
|
209
252
|
return {
|
|
210
|
-
output:
|
|
253
|
+
output: offlineOutput(context.client, decision, offline),
|
|
211
254
|
server: null,
|
|
212
255
|
offline: true,
|
|
256
|
+
verdict: offline.verdict,
|
|
213
257
|
...(api ? { api } : {})
|
|
214
258
|
};
|
|
215
259
|
}
|
package/dist/cliHookGuard.d.ts
CHANGED
|
@@ -35,6 +35,13 @@ export type DecidedFinding = {
|
|
|
35
35
|
target?: EnvTarget;
|
|
36
36
|
/** What the server is told about that, when it reads placements. */
|
|
37
37
|
placement?: Record<string, string>;
|
|
38
|
+
/** Blocked by the person's pass for the app this CLI acts on: what they read. */
|
|
39
|
+
access?: AppAccessBlock;
|
|
40
|
+
};
|
|
41
|
+
/** "You don't have access to Railway in Passport. Ask an admin." and the app's Access link. */
|
|
42
|
+
export type AppAccessBlock = {
|
|
43
|
+
message: string;
|
|
44
|
+
link?: string;
|
|
38
45
|
};
|
|
39
46
|
export type GuardDecision = {
|
|
40
47
|
verdict: GuardVerdict;
|
|
@@ -55,6 +62,8 @@ export type GuardDecision = {
|
|
|
55
62
|
deciding?: CliFinding;
|
|
56
63
|
/** v2: where the deciding vendor command lands, and how Passport knows. */
|
|
57
64
|
target?: EnvTarget;
|
|
65
|
+
/** The deciding command is blocked by the person's app access. */
|
|
66
|
+
access?: AppAccessBlock;
|
|
58
67
|
};
|
|
59
68
|
/** This machine, for reading folder links. Absent: flags and defaults only. */
|
|
60
69
|
export type GuardMachine = {
|
package/dist/cliHookGuard.js
CHANGED
|
@@ -231,17 +231,27 @@ export function decideFinding(finding, policy, machine) {
|
|
|
231
231
|
: target;
|
|
232
232
|
const verb = finding.verbKey ?? finding.verb;
|
|
233
233
|
const actionClass = classOf(policy, finding, verb, hint.kind);
|
|
234
|
-
const
|
|
234
|
+
const ruled = decideAction(policy.autopilot, {
|
|
235
235
|
vendor: finding.vendor,
|
|
236
236
|
verb,
|
|
237
237
|
actionClass,
|
|
238
238
|
environment: hint.kind
|
|
239
239
|
});
|
|
240
|
+
// The person's pass for the app this CLI acts on comes first: No access
|
|
241
|
+
// blocks every command, Read-only runs only reads (the same as exec).
|
|
242
|
+
const pass = Object.hasOwn(policy.autopilot.appAccess ?? {}, finding.vendor)
|
|
243
|
+
? policy.autopilot.appAccess[finding.vendor]
|
|
244
|
+
: undefined;
|
|
245
|
+
const limited = pass && (pass.pass === "none" || (pass.pass === "readonly" && actionClass !== "read"));
|
|
246
|
+
const { decision, cause } = limited
|
|
247
|
+
? { decision: "block", cause: { kind: "block", label: pass.cause } }
|
|
248
|
+
: ruled;
|
|
240
249
|
const reported = finding.pushEnvironment ?? reportedEnvironment(hint);
|
|
241
250
|
return {
|
|
242
251
|
finding,
|
|
243
252
|
decision,
|
|
244
253
|
cause,
|
|
254
|
+
...(limited ? { access: { message: pass.message, ...(pass.link ? { link: pass.link } : {}) } } : {}),
|
|
245
255
|
environment: hint.kind,
|
|
246
256
|
environmentSource: hint.source,
|
|
247
257
|
...(reported ? { reported } : {}),
|
|
@@ -308,7 +318,8 @@ function decideV2(command, findings, policy, complete, machine) {
|
|
|
308
318
|
actionClass: strictest.actionClass,
|
|
309
319
|
decided,
|
|
310
320
|
...(strictest.finding.local || strictest.finding.pushEnvironment ? { deciding: strictest.finding } : {}),
|
|
311
|
-
...(strictest.target ? { target: strictest.target } : {})
|
|
321
|
+
...(strictest.target ? { target: strictest.target } : {}),
|
|
322
|
+
...(strictest.access ? { access: strictest.access } : {})
|
|
312
323
|
};
|
|
313
324
|
}
|
|
314
325
|
/** The strictest verdict across every command in the line wins. */
|
|
@@ -394,6 +405,9 @@ export function askMessage(decision) {
|
|
|
394
405
|
: `Passport: your Autopilot rules ask before ${decision.label}. Run it only if you meant to.`;
|
|
395
406
|
}
|
|
396
407
|
export function denyMessage(decision, owner) {
|
|
408
|
+
// The app's access, in the words exec uses, with where an admin changes it.
|
|
409
|
+
if (decision.access)
|
|
410
|
+
return decision.access.link ? `${decision.access.message} ${decision.access.link}` : decision.access.message;
|
|
397
411
|
if (decision.cause) {
|
|
398
412
|
const mine = decision.cause.label.startsWith("Your rule");
|
|
399
413
|
const next = mine
|
package/dist/cliPolicyV2.js
CHANGED
|
@@ -118,7 +118,8 @@ function rule(value) {
|
|
|
118
118
|
...(scope ? { scope } : {}),
|
|
119
119
|
...(owner ? { owner } : {}),
|
|
120
120
|
...(label ? { label } : {}),
|
|
121
|
-
...(except.length ? { except } : {})
|
|
121
|
+
...(except.length ? { except } : {}),
|
|
122
|
+
...(body.exception === true ? { exception: true } : {})
|
|
122
123
|
};
|
|
123
124
|
}
|
|
124
125
|
/** Actions an approved exception lifts a rule for. */
|
|
@@ -167,6 +168,50 @@ function offline(value) {
|
|
|
167
168
|
}
|
|
168
169
|
return out;
|
|
169
170
|
}
|
|
171
|
+
const PASSES = new Set(["full", "readonly", "none"]);
|
|
172
|
+
/** An absolute http(s) link, or undefined. */
|
|
173
|
+
function webLink(value) {
|
|
174
|
+
if (typeof value !== "string" || value.length > 300 || /[\u0000- \u007f]/.test(value))
|
|
175
|
+
return undefined;
|
|
176
|
+
try {
|
|
177
|
+
const url = new URL(value);
|
|
178
|
+
return url.protocol === "https:" || url.protocol === "http:" ? value : undefined;
|
|
179
|
+
}
|
|
180
|
+
catch {
|
|
181
|
+
return undefined;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
/** `appAccess` by vendor: absent is none at all, anything malformed rejects the document. */
|
|
185
|
+
function appAccess(value) {
|
|
186
|
+
if (value === undefined)
|
|
187
|
+
return undefined;
|
|
188
|
+
const body = plainObject(value);
|
|
189
|
+
if (!body)
|
|
190
|
+
return null;
|
|
191
|
+
const entries = Object.entries(body);
|
|
192
|
+
if (entries.length > MAX_VENDORS)
|
|
193
|
+
return null;
|
|
194
|
+
const out = {};
|
|
195
|
+
for (const [vendor, raw] of entries) {
|
|
196
|
+
const entry = plainObject(raw);
|
|
197
|
+
if (!VENDOR_KEY.test(vendor) || UNSAFE_KEYS.has(vendor) || !entry || !PASSES.has(entry.pass))
|
|
198
|
+
return null;
|
|
199
|
+
const pass = entry.pass;
|
|
200
|
+
const app = printable(entry.app, 80);
|
|
201
|
+
if (!app)
|
|
202
|
+
return null;
|
|
203
|
+
const cause = printable(entry.cause, 160) || `${pass === "none" ? "No access" : "Read-only access"} to ${app} in Passport`;
|
|
204
|
+
const link = webLink(entry.link);
|
|
205
|
+
out[vendor] = {
|
|
206
|
+
pass,
|
|
207
|
+
app,
|
|
208
|
+
cause,
|
|
209
|
+
message: printable(entry.message, 240) || `${cause}.`,
|
|
210
|
+
...(link ? { link } : {})
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
return out;
|
|
214
|
+
}
|
|
170
215
|
function printable(value, max) {
|
|
171
216
|
return typeof value === "string"
|
|
172
217
|
? value
|
|
@@ -335,10 +380,12 @@ export function serializeCliPolicyV2(policy) {
|
|
|
335
380
|
environment: lift.environment
|
|
336
381
|
}))
|
|
337
382
|
}
|
|
338
|
-
: {})
|
|
383
|
+
: {}),
|
|
384
|
+
...(rule.exception ? { exception: true } : {})
|
|
339
385
|
})),
|
|
340
386
|
...(autopilot.secondPerson ? { secondPerson: autopilot.secondPerson } : {}),
|
|
341
387
|
...(autopilot.offline ? { offline: autopilot.offline } : {}),
|
|
388
|
+
...(autopilot.appAccess ? { appAccess: autopilot.appAccess } : {}),
|
|
342
389
|
irreversible: autopilot.irreversible,
|
|
343
390
|
irreversibleInProduction: autopilot.irreversibleInProduction ?? {},
|
|
344
391
|
deletes: autopilot.deletes ?? {},
|
|
@@ -392,6 +439,9 @@ export function parseCliPolicyV2(value) {
|
|
|
392
439
|
const knownProject = project(body.project);
|
|
393
440
|
if (knownProject === null)
|
|
394
441
|
return null;
|
|
442
|
+
const access = appAccess(body.appAccess);
|
|
443
|
+
if (access === null)
|
|
444
|
+
return null;
|
|
395
445
|
return {
|
|
396
446
|
version: 2,
|
|
397
447
|
updatedAt: body.updatedAt,
|
|
@@ -411,6 +461,7 @@ export function parseCliPolicyV2(value) {
|
|
|
411
461
|
...(body.speed === true ? { reportsSpeed: true } : {}),
|
|
412
462
|
...(parsedSecondPerson?.classes.length ? { secondPerson: parsedSecondPerson } : {}),
|
|
413
463
|
...(offline(body.offline) ? { offline: offline(body.offline) } : {}),
|
|
464
|
+
...(access && Object.keys(access).length ? { appAccess: access } : {}),
|
|
414
465
|
...(knownProject ? { project: knownProject } : {})
|
|
415
466
|
}
|
|
416
467
|
};
|
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.13";
|
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.13";
|
package/dist/webLinks.d.ts
CHANGED
|
@@ -2,4 +2,6 @@
|
|
|
2
2
|
export declare function webOrigin(endpointOrOrigin: string | undefined): string | null;
|
|
3
3
|
export declare function sessionLink(origin: string | undefined, sessionId: string | undefined): string | null;
|
|
4
4
|
export declare function approvalLink(origin: string | undefined, approvalId: string | undefined, workspaceId?: string): string | null;
|
|
5
|
+
/** A page the server named by its hash (`#apps/railway/access`), or null. */
|
|
6
|
+
export declare function hashLink(origin: string | undefined, hash: unknown): string | null;
|
|
5
7
|
export declare function ruleLink(origin: string | undefined, ruleId?: string): string | null;
|
package/dist/webLinks.js
CHANGED
|
@@ -39,6 +39,13 @@ export function approvalLink(origin, approvalId, workspaceId) {
|
|
|
39
39
|
params.set("workspace", workspaceId);
|
|
40
40
|
return `${base}/#approvals?${params.toString()}`;
|
|
41
41
|
}
|
|
42
|
+
/** A page the server named by its hash (`#apps/railway/access`), or null. */
|
|
43
|
+
export function hashLink(origin, hash) {
|
|
44
|
+
const base = webOrigin(origin);
|
|
45
|
+
if (!base || typeof hash !== "string" || !/^#[A-Za-z0-9_.~%/?=&-]{1,200}$/.test(hash))
|
|
46
|
+
return null;
|
|
47
|
+
return `${base}/${hash}`;
|
|
48
|
+
}
|
|
42
49
|
export function ruleLink(origin, ruleId) {
|
|
43
50
|
const base = webOrigin(origin);
|
|
44
51
|
if (!base)
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "passport-bridge",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.13",
|
|
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.13",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@modelcontextprotocol/sdk": "1.32.1"
|