@vercel/board 0.34.0 → 0.36.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/dist/{access-CdBcYPQH.mjs → access-BsP0hvcC.mjs} +1 -1
- package/dist/access.d.mts +2 -2
- package/dist/access.mjs +4 -4
- package/dist/{actors-MrIEr9LI.mjs → actors-DFOpTw89.mjs} +2 -2
- package/dist/{auth-aaoKt5DK.d.mts → auth-C21V0EK1.d.mts} +1 -1
- package/dist/{auth-DjoJygbG.mjs → auth-CrjXLgOb.mjs} +2 -2
- package/dist/{backend-u1sVvybh.d.mts → backend-D21q8mdm.d.mts} +3 -3
- package/dist/backend-local.d.mts +1 -1
- package/dist/backend-local.mjs +1 -1
- package/dist/{chat-provider-9hCT654s.mjs → chat-provider-Bb-jeJLY.mjs} +2 -2
- package/dist/{chat-provider-De0iDnUB.d.mts → chat-provider-DmZCmBkb.d.mts} +2 -2
- package/dist/cli-commands.d.mts +1 -1
- package/dist/cli-commands.mjs +1 -1
- package/dist/cli-embedded.d.mts +2 -2
- package/dist/cli-embedded.mjs +1 -1
- package/dist/cli.mjs +5 -5
- package/dist/{commands-B8oZEByR.mjs → commands-BLtqSwha.mjs} +324 -26
- package/dist/{commands-BkVMdXP1.d.mts → commands-DGID-4Z2.d.mts} +175 -0
- package/dist/{conformance-gqYBkXFS.mjs → conformance-CKrwglzA.mjs} +480 -87
- package/dist/conformance.d.mts +20 -2
- package/dist/conformance.mjs +1 -1
- package/dist/{engine-rtOVWsiF.mjs → engine-B_prP0b8.mjs} +4 -4
- package/dist/{errors-D8ifv16L.mjs → errors-rYDxZEuN.mjs} +98 -4
- package/dist/{events-IQg0k281.mjs → events-AEKh9tJm.mjs} +1 -1
- package/dist/exports-BxljH73E.d.mts +4 -0
- package/dist/{exports-Bx2dGpzr.mjs → exports-Ck4Xu3OV.mjs} +135 -24
- package/dist/{external-CYe424fO.mjs → external-BA2aCC_3.mjs} +1 -1
- package/dist/{index-D6mK0Ial.d.mts → index-LREsSZb2.d.mts} +2 -2
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +4 -4
- package/dist/index.node.d.mts +6 -6
- package/dist/index.node.mjs +3 -3
- package/dist/inspect/app.js +32 -32
- package/dist/{local-CPz22MQ8.mjs → local-DJ_qI9q7.mjs} +10 -10
- package/dist/{main-DScDKwQN.mjs → main-Jz4nbNJi.mjs} +409 -24
- package/dist/{memory-7RRnLa4X.mjs → memory-DqwXlyK4.mjs} +2 -2
- package/dist/{middleware-BjYpk4yq.mjs → middleware-BxgizazV.mjs} +1 -1
- package/dist/{provider-hB8QNrwm.d.mts → provider-DEOfc4Ls.d.mts} +21 -3
- package/dist/{routes-De4W6lEs.d.mts → routes-BpKdMvgX.d.mts} +19 -8
- package/dist/{serve-B1noQRkn.mjs → serve-Puf3I-oI.mjs} +4 -4
- package/dist/{server-Ov6GBJ8j.mjs → server-CS-1aeTl.mjs} +6 -6
- package/dist/{serving-2s7lqSBS.mjs → serving-6_bhBNAW.mjs} +1 -1
- package/dist/{sql-BQzKUqQt.mjs → sql-aetuEBZC.mjs} +1 -1
- package/dist/{sqlite-DCtZFEVm.mjs → sqlite-DvsB8ENQ.mjs} +2 -2
- package/dist/{sqlite-db-qLTs52Ny.mjs → sqlite-db-BPwRoDI7.mjs} +1 -1
- package/dist/sync-chat-sdk.d.mts +2 -2
- package/dist/sync-chat-sdk.mjs +2 -2
- package/dist/sync-github.d.mts +2 -2
- package/dist/sync-github.mjs +2 -2
- package/dist/sync-linear.d.mts +3 -3
- package/dist/sync-linear.mjs +2 -2
- package/dist/sync-slack.d.mts +3 -3
- package/dist/sync-slack.mjs +3 -3
- package/dist/sync.d.mts +2 -2
- package/dist/sync.mjs +2 -2
- package/dist/{targets-aMdbp84G.mjs → targets-Dk_xgS9q.mjs} +10 -6
- package/dist/{tokens-LHLrnV_P.mjs → tokens-Dn4cPZIr.mjs} +2 -2
- package/docs/01-board/01-mounting.md +7 -2
- package/docs/01-board/03-identity.md +1 -1
- package/docs/01-board/09-access.md +31 -0
- package/docs/03-guides/03-ci.md +5 -3
- package/docs/04-reference/01-cli.md +98 -14
- package/docs/04-reference/02-board.md +28 -3
- package/docs/04-reference/03-http.md +1 -1
- package/docs/04-reference/05-conformance.md +31 -5
- package/package.json +1 -1
- package/dist/exports-uwRl5qIj.d.mts +0 -4
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { a as forbidden$1, c as toErrorResponse, f as duration, g as fileName, h as IMPORT_BYTES_MAX, i as duplicateId, l as unauthorized, m as DIRECT_UPLOAD_BYTES_MAX, p as ATTACHMENT_BYTES_MAX, r as badRequest, s as notFound, t as HttpError, u as BoardError, v as mediaType } from "./errors-
|
|
1
|
+
import { a as forbidden$1, c as toErrorResponse, f as duration, g as fileName, h as IMPORT_BYTES_MAX, i as duplicateId, l as unauthorized, m as DIRECT_UPLOAD_BYTES_MAX, p as ATTACHMENT_BYTES_MAX, r as badRequest, s as notFound, t as HttpError, u as BoardError, v as mediaType } from "./errors-rYDxZEuN.mjs";
|
|
2
2
|
import { _ as actorKind, a as ChannelPath, c as LabelKey, f as MessageId, g as SeenActorKind, h as SCOPE_MAX, i as Author, m as RemoteWatcherId, n as Attachment, o as Emoji, p as MessageText, s as Handle, t as ActorId, u as Labels, v as platformAvatar, y as storable } from "./schemas-BG205xds.mjs";
|
|
3
|
-
import { a as Link, i as ExternalTarget, n as ExternalEvent, o as Origin } from "./external-
|
|
4
|
-
import { a as compileWatcher, c as METHODS, h as VERSION, i as canonicalWatchers, m as SYNC, n as syncTarget, o as hasCriteria, r as withEmailMentions } from "./targets-
|
|
5
|
-
import { i as waitUntil, n as MIDDLEWARE_ACTOR, o as derivedId, s as isKeyIdOf, t as DroppedError } from "./middleware-
|
|
6
|
-
import { a as checkGrantChange, d as scopeOf, i as authorize, s as compileAccess, t as FULL_ACCESS, u as parseScope } from "./access-
|
|
7
|
-
import { C as workflowPath, c as checkGrant, f as grantIssuers, h as joined, l as checkPrincipal, m as issuerName, n as DEFAULT_CAN, o as authenticates, r as GITHUB_ISSUER, s as checkCan, t as BOARD_TOKEN_PREFIX, v as removes, w as wroteAs, y as tokenHash } from "./auth-
|
|
3
|
+
import { a as Link, i as ExternalTarget, n as ExternalEvent, o as Origin } from "./external-BA2aCC_3.mjs";
|
|
4
|
+
import { a as compileWatcher, c as METHODS, h as VERSION, i as canonicalWatchers, m as SYNC, n as syncTarget, o as hasCriteria, r as withEmailMentions } from "./targets-Dk_xgS9q.mjs";
|
|
5
|
+
import { i as waitUntil, n as MIDDLEWARE_ACTOR, o as derivedId, s as isKeyIdOf, t as DroppedError } from "./middleware-BxgizazV.mjs";
|
|
6
|
+
import { a as checkGrantChange, d as scopeOf, i as authorize, s as compileAccess, t as FULL_ACCESS, u as parseScope } from "./access-BsP0hvcC.mjs";
|
|
7
|
+
import { C as workflowPath, c as checkGrant, f as grantIssuers, h as joined, l as checkPrincipal, m as issuerName, n as DEFAULT_CAN, o as authenticates, r as GITHUB_ISSUER, s as checkCan, t as BOARD_TOKEN_PREFIX, v as removes, w as wroteAs, y as tokenHash } from "./auth-CrjXLgOb.mjs";
|
|
8
8
|
import { n as setOwn, t as own } from "./own-OwgPWdmh.mjs";
|
|
9
9
|
import { n as replaceMentions } from "./mentions-CB6ShY4R.mjs";
|
|
10
|
-
import { a as resolveMentions, n as actorSeen } from "./actors-
|
|
10
|
+
import { a as resolveMentions, n as actorSeen } from "./actors-DFOpTw89.mjs";
|
|
11
11
|
import { C as sessionClearedError, a as SOCKET_TIMINGS, c as drainSettledHooks, d as nullProtoRecord, f as runtimeConsumerFactory, g as A2Error, h as stateTailReaders, i as RESERVED_PARTICIPANT_IDS, l as failedPreviousAttempt, m as serverInternals, n as POLL_TIMINGS, o as STATE_CACHE, p as runtimeConsumers, r as PRESENCE_TIMINGS, s as STREAM_TIMINGS, t as DRAIN_TIMINGS, u as markSchedulerSendFailure, v as NonRetriableError, x as isSessionCleared, y as asStoreUnavailable } from "./internal-CvsrprnU-CEPOUpAv.mjs";
|
|
12
12
|
import { i as streamActivities, n as defaultSleep, t as createStreamActivity } from "./store-polling-BZt2Rf3D-oh3aU_An.mjs";
|
|
13
|
-
import { a as foldActors, i as concernedMessageId, o as foldMessages, s as iso, t as TABLES_CONSUMER } from "./sql-
|
|
13
|
+
import { a as foldActors, i as concernedMessageId, o as foldMessages, s as iso, t as TABLES_CONSUMER } from "./sql-aetuEBZC.mjs";
|
|
14
14
|
import { t as afterRetry } from "./attempts-HXcskN1w.mjs";
|
|
15
15
|
import { z } from "zod";
|
|
16
16
|
import { createHash, randomBytes } from "node:crypto";
|
|
@@ -9168,10 +9168,10 @@ function local(options = {}) {
|
|
|
9168
9168
|
opening ??= (async () => {
|
|
9169
9169
|
const file = localFile(bound.name);
|
|
9170
9170
|
let store;
|
|
9171
|
-
if (options.memory) store = (await import("./memory-
|
|
9171
|
+
if (options.memory) store = (await import("./memory-DqwXlyK4.mjs")).memory();
|
|
9172
9172
|
else {
|
|
9173
9173
|
const { mkdir } = await import("node:fs/promises");
|
|
9174
|
-
const { sqlite } = await import("./sqlite-
|
|
9174
|
+
const { sqlite } = await import("./sqlite-DvsB8ENQ.mjs");
|
|
9175
9175
|
const path = join(dir, `${file}.db`);
|
|
9176
9176
|
try {
|
|
9177
9177
|
await mkdir(dir, {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { _ as fileSize, m as DIRECT_UPLOAD_BYTES_MAX, u as BoardError } from "./errors-
|
|
1
|
+
import { _ as fileSize, m as DIRECT_UPLOAD_BYTES_MAX, u as BoardError } from "./errors-rYDxZEuN.mjs";
|
|
2
2
|
import { d as MESSAGE_TEXT_MAX, r as AttachmentId } from "./schemas-BG205xds.mjs";
|
|
3
|
-
import { h as VERSION, s as withMentions } from "./targets-
|
|
3
|
+
import { h as VERSION, s as withMentions } from "./targets-Dk_xgS9q.mjs";
|
|
4
4
|
import { n as displayEmoji, r as normalizeEmoji } from "./emoji-CTLpvH-A.mjs";
|
|
5
|
-
import { u as parseScope } from "./access-
|
|
6
|
-
import { i as isApiMessageId, n as isBoardName } from "./exports-
|
|
7
|
-
import { i as groups, n as filters$1, o as options, r as globalOptions, s as usage$1, t as commands } from "./commands-
|
|
8
|
-
import { a as http, c as handFetch, f as vercelProjectFile, i as vercel, l as handLogin, n as credentialSource, o as boardUrl, r as handTeam, s as connect, t as board } from "./server-
|
|
9
|
-
import { t as conformance } from "./conformance-
|
|
5
|
+
import { r as PERMISSIONS, u as parseScope } from "./access-BsP0hvcC.mjs";
|
|
6
|
+
import { i as isApiMessageId, n as isBoardName } from "./exports-Ck4Xu3OV.mjs";
|
|
7
|
+
import { i as groups, n as filters$1, o as options, r as globalOptions, s as usage$1, t as commands } from "./commands-BLtqSwha.mjs";
|
|
8
|
+
import { a as http, c as handFetch, f as vercelProjectFile, i as vercel, l as handLogin, n as credentialSource, o as boardUrl, r as handTeam, s as connect, t as board } from "./server-CS-1aeTl.mjs";
|
|
9
|
+
import { t as conformance } from "./conformance-CKrwglzA.mjs";
|
|
10
10
|
import { t as displayText } from "./bots-CGkO76qH.mjs";
|
|
11
11
|
import { spawn } from "node:child_process";
|
|
12
12
|
import { readFile, stat, writeFile } from "node:fs/promises";
|
|
@@ -14,6 +14,259 @@ import { mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "
|
|
|
14
14
|
import { homedir } from "node:os";
|
|
15
15
|
import { basename, dirname, join } from "node:path";
|
|
16
16
|
import { parseArgs } from "node:util";
|
|
17
|
+
//#region src/cli/grants.ts
|
|
18
|
+
/** What's wrong with the flags, as misuse: the headline, and its ways out when they aren't help. */
|
|
19
|
+
var GrantMisuse = class extends Error {
|
|
20
|
+
next;
|
|
21
|
+
constructor(message, next) {
|
|
22
|
+
super(message);
|
|
23
|
+
this.next = next;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
/** What starts a principal, after `--`, `--add-`, or `--remove-`. */
|
|
27
|
+
const KINDS = [
|
|
28
|
+
"user",
|
|
29
|
+
"project",
|
|
30
|
+
"github",
|
|
31
|
+
"oidc",
|
|
32
|
+
"app",
|
|
33
|
+
"all-users",
|
|
34
|
+
"all-projects",
|
|
35
|
+
"all-apps",
|
|
36
|
+
"everyone"
|
|
37
|
+
];
|
|
38
|
+
/** Each modifier, and the principals it fits. */
|
|
39
|
+
const MODIFIERS = {
|
|
40
|
+
environment: ["project", "all-projects"],
|
|
41
|
+
workflow: ["github"],
|
|
42
|
+
"git-branch": ["github"],
|
|
43
|
+
event: ["github"],
|
|
44
|
+
claim: ["oidc"]
|
|
45
|
+
};
|
|
46
|
+
const fits = (modifier) => MODIFIERS[modifier].map((kind) => `--${kind}`).join(" or ");
|
|
47
|
+
const flagOf = (started) => `--${started.prefix}${started.kind}${started.value !== void 0 ? ` ${started.value}` : ""}`;
|
|
48
|
+
/** The principals the flags name, each with the prefix its flag had, in the order they were typed. */
|
|
49
|
+
function principalsIn(tokens, prefixes, removal) {
|
|
50
|
+
const started = [];
|
|
51
|
+
for (const { name, value } of tokens) {
|
|
52
|
+
const prefix = prefixes.find((candidate) => KINDS.includes(name.slice(candidate.length)) && name.startsWith(candidate));
|
|
53
|
+
if (prefix !== void 0) {
|
|
54
|
+
const kind = name.slice(prefix.length);
|
|
55
|
+
if (kind === "github" && !/^[^/\s]+\/[^/\s]+$/.test(value ?? "")) throw new GrantMisuse(`--${name} takes owner/repo, like acme/web: got ${value}.`);
|
|
56
|
+
started.push({
|
|
57
|
+
prefix,
|
|
58
|
+
kind,
|
|
59
|
+
value
|
|
60
|
+
});
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
if (!Object.hasOwn(MODIFIERS, name)) continue;
|
|
64
|
+
const last = started.at(-1);
|
|
65
|
+
if (!last) throw new GrantMisuse(`--${name} goes after the ${fits(name)} it's for.`);
|
|
66
|
+
if (!MODIFIERS[name].includes(last.kind)) throw new GrantMisuse(`--${name} is for ${fits(name)}, not ${flagOf(last)}.`);
|
|
67
|
+
const given = value ?? "";
|
|
68
|
+
switch (name) {
|
|
69
|
+
case "environment": {
|
|
70
|
+
if (last.prefix === "remove-") throw new GrantMisuse(`${flagOf(last)} removes it whatever its environments, so it takes no --environment.`, removal?.({
|
|
71
|
+
kind: last.kind,
|
|
72
|
+
value: last.value
|
|
73
|
+
}));
|
|
74
|
+
const environments = given.split(",").map((environment) => environment.trim());
|
|
75
|
+
if (environments.some((environment) => environment === "")) throw new GrantMisuse(`--environment takes environments, comma-separated, like production,preview: got ${JSON.stringify(given)}.`);
|
|
76
|
+
last.environments = [.../* @__PURE__ */ new Set([...last.environments ?? [], ...environments])];
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
case "workflow":
|
|
80
|
+
case "git-branch":
|
|
81
|
+
case "event": {
|
|
82
|
+
const field = name === "git-branch" ? "branch" : name;
|
|
83
|
+
if (last[field] !== void 0) throw new GrantMisuse(`${flagOf(last)} takes one --${name}: name the repository again for another.`);
|
|
84
|
+
last[field] = given;
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
case "claim": {
|
|
88
|
+
const at = given.indexOf("=");
|
|
89
|
+
if (at <= 0) throw new GrantMisuse(`--claim takes name=value, like project_id=42: got ${JSON.stringify(given)}.`);
|
|
90
|
+
const claims = last.claims ??= {};
|
|
91
|
+
const [claim, one] = [given.slice(0, at), given.slice(at + 1)];
|
|
92
|
+
const had = claims[claim];
|
|
93
|
+
claims[claim] = had === void 0 ? one : [...[had].flat(), one];
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return started.map((one) => ({
|
|
99
|
+
prefix: one.prefix,
|
|
100
|
+
principal: inputOf(one)
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
103
|
+
/** A principal as the handle takes it, which makes a project's environments production when they're left out. */
|
|
104
|
+
function inputOf(started) {
|
|
105
|
+
const { environments } = started;
|
|
106
|
+
const value = started.value;
|
|
107
|
+
switch (started.kind) {
|
|
108
|
+
case "user": return value.includes("@") ? {
|
|
109
|
+
kind: "user",
|
|
110
|
+
email: value
|
|
111
|
+
} : {
|
|
112
|
+
kind: "user",
|
|
113
|
+
userId: value
|
|
114
|
+
};
|
|
115
|
+
case "project": return {
|
|
116
|
+
kind: "project",
|
|
117
|
+
project: value,
|
|
118
|
+
...environments ? { environments } : {}
|
|
119
|
+
};
|
|
120
|
+
case "github": return {
|
|
121
|
+
kind: "github",
|
|
122
|
+
repository: value,
|
|
123
|
+
...started.workflow !== void 0 ? { workflow: started.workflow } : {},
|
|
124
|
+
...started.branch !== void 0 ? { branch: started.branch } : {},
|
|
125
|
+
...started.event !== void 0 ? { event: started.event } : {}
|
|
126
|
+
};
|
|
127
|
+
case "oidc": return {
|
|
128
|
+
kind: "oidc",
|
|
129
|
+
issuer: value,
|
|
130
|
+
claims: started.claims ?? {}
|
|
131
|
+
};
|
|
132
|
+
case "app": return {
|
|
133
|
+
kind: "app",
|
|
134
|
+
app: value
|
|
135
|
+
};
|
|
136
|
+
case "all-projects": return {
|
|
137
|
+
kind: "all-projects",
|
|
138
|
+
...environments ? { environments } : {}
|
|
139
|
+
};
|
|
140
|
+
default: return { kind: started.kind };
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
const WORDS = [
|
|
144
|
+
...PERMISSIONS,
|
|
145
|
+
"all",
|
|
146
|
+
"none"
|
|
147
|
+
];
|
|
148
|
+
/**
|
|
149
|
+
* A grant's `can`, from each `--can pattern=permissions`, repeated or `;`-joined: `all` for every
|
|
150
|
+
* permission and `none` for no permissions, each alone. The board keeps it as written.
|
|
151
|
+
*/
|
|
152
|
+
function grantCanOf(values) {
|
|
153
|
+
const can = {};
|
|
154
|
+
for (const entry of values.flatMap((value) => value.split(";")).map((one) => one.trim()).filter(Boolean)) {
|
|
155
|
+
const at = entry.indexOf("=");
|
|
156
|
+
if (at <= 0) throw new GrantMisuse(`--can takes pattern=permissions, like ci/=read,post: got ${JSON.stringify(entry)}.`);
|
|
157
|
+
const pattern = entry.slice(0, at).trim();
|
|
158
|
+
if (Object.hasOwn(can, pattern)) throw new GrantMisuse(`--can names ${pattern} twice: say it once, with every permission it gives.`);
|
|
159
|
+
const words = entry.slice(at + 1).split(",").map((word) => word.trim()).filter(Boolean);
|
|
160
|
+
for (const word of words) if (!WORDS.includes(word)) throw new GrantMisuse(`--can: ${word} isn't a permission. Permissions are ${WORDS.slice(0, -1).join(", ")}, or ${WORDS.at(-1)}.`);
|
|
161
|
+
for (const alone of ["all", "none"]) if (words.includes(alone) && words.length > 1) throw new GrantMisuse(`--can: ${alone} is ${alone === "all" ? "every permission" : "no permissions"}, so it goes alone: ${pattern}=${alone}.`);
|
|
162
|
+
can[pattern] = words[0] === "all" ? "all" : words[0] === "none" ? [] : words;
|
|
163
|
+
}
|
|
164
|
+
return can;
|
|
165
|
+
}
|
|
166
|
+
/** Whom explain asks about, from the one principal its flags name, as the board takes it. */
|
|
167
|
+
function explainPrincipalOf(tokens) {
|
|
168
|
+
const named = principalsIn(tokens, [""]);
|
|
169
|
+
if (named.length === 0) return {
|
|
170
|
+
principal: {},
|
|
171
|
+
subject: null,
|
|
172
|
+
kind: null
|
|
173
|
+
};
|
|
174
|
+
if (named.length > 1) throw new GrantMisuse("explain asks about one principal at a time.");
|
|
175
|
+
const { principal } = named[0];
|
|
176
|
+
switch (principal.kind) {
|
|
177
|
+
case "user": {
|
|
178
|
+
const user = principal.email ?? principal.userId;
|
|
179
|
+
return {
|
|
180
|
+
principal: { user },
|
|
181
|
+
subject: user,
|
|
182
|
+
kind: "user"
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
case "project": {
|
|
186
|
+
const environments = principal.environments ?? [];
|
|
187
|
+
if (environments.length > 1) throw new GrantMisuse(`explain asks about one environment at a time: --environment ${environments[0]}.`);
|
|
188
|
+
const environment = environments[0] ?? "production";
|
|
189
|
+
return {
|
|
190
|
+
principal: {
|
|
191
|
+
project: principal.project,
|
|
192
|
+
environment
|
|
193
|
+
},
|
|
194
|
+
subject: `${principal.project} in ${environment}`,
|
|
195
|
+
kind: "project"
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
case "github": {
|
|
199
|
+
const { repository, workflow, branch, event } = principal;
|
|
200
|
+
return {
|
|
201
|
+
principal: {
|
|
202
|
+
github: repository,
|
|
203
|
+
...workflow ? { workflow } : {},
|
|
204
|
+
...branch ? { branch } : {},
|
|
205
|
+
...event ? { event } : {}
|
|
206
|
+
},
|
|
207
|
+
subject: repository,
|
|
208
|
+
kind: "github"
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
case "oidc": {
|
|
212
|
+
const claims = {};
|
|
213
|
+
for (const [name, value] of Object.entries(principal.claims)) {
|
|
214
|
+
if (Array.isArray(value)) throw new GrantMisuse(`explain asks about one token: give --claim ${name} once.`);
|
|
215
|
+
claims[name] = value;
|
|
216
|
+
}
|
|
217
|
+
return {
|
|
218
|
+
principal: {
|
|
219
|
+
oidc: principal.issuer,
|
|
220
|
+
claims
|
|
221
|
+
},
|
|
222
|
+
subject: principal.issuer,
|
|
223
|
+
kind: "oidc"
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
case "app": return {
|
|
227
|
+
principal: { app: principal.app },
|
|
228
|
+
subject: principal.app,
|
|
229
|
+
kind: "app"
|
|
230
|
+
};
|
|
231
|
+
default: throw new GrantMisuse(`explain asks about someone: --user, --project, --github, --oidc, or --app, not --${principal.kind}.`);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
/** Permissions as `--can` writes them: `all` for every one, `none` for none. */
|
|
235
|
+
const canWords = (can) => can.length === PERMISSIONS.length ? "all" : can.length === 0 ? "none" : can.join(",");
|
|
236
|
+
/** The principal flag a level names, for whom explain asked about: `--user`, `--all-projects`, `--everyone`. */
|
|
237
|
+
function levelFlag(level, kind, grants) {
|
|
238
|
+
if (level === "everyone") return "--everyone";
|
|
239
|
+
const kinds = [...new Set(grants.flatMap((grant) => grant.principals.map((principal) => principal.kind)))];
|
|
240
|
+
const group = level === "group";
|
|
241
|
+
const of = kinds.filter((one) => (one === "all-users" || one === "all-projects" || one === "all-apps") === group && one !== "everyone");
|
|
242
|
+
if (group) {
|
|
243
|
+
if (kind === "user") return "--all-users";
|
|
244
|
+
if (kind === "project") return "--all-projects";
|
|
245
|
+
if (kind === "app") return "--all-apps";
|
|
246
|
+
return of.length === 1 ? `--${of[0]}` : null;
|
|
247
|
+
}
|
|
248
|
+
if (kind !== null) return `--${kind}`;
|
|
249
|
+
return of.length === 1 ? `--${of[0]}` : null;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Explain's answer in a sentence or two: which pattern won, and over what; the closest grants
|
|
253
|
+
* there; and what they give.
|
|
254
|
+
* `security/ wins over *. Closest grant for bob@acme.com: g4 (--user): all.`
|
|
255
|
+
*/
|
|
256
|
+
function explanationLine(answer, subject, kind) {
|
|
257
|
+
const whom = subject ?? "you";
|
|
258
|
+
const given = `${canWords(answer.can)}${answer.capped !== null ? `, capped by the ${answer.capped} role` : ""}`;
|
|
259
|
+
if (answer.pattern === null || answer.level === null) {
|
|
260
|
+
if (answer.can.length === 0) return `Nothing lets ${whom} into ${answer.channel}.`;
|
|
261
|
+
return `The board lets ${whom} in itself, outside its grants: ${given}.`;
|
|
262
|
+
}
|
|
263
|
+
const wins = answer.over.length > 0 ? `${answer.pattern} wins over ${answer.over.join(", ")}.` : `${answer.pattern} wins.`;
|
|
264
|
+
const flag = levelFlag(answer.level, kind, answer.grants);
|
|
265
|
+
const at = flag ? ` (${flag})` : "";
|
|
266
|
+
const which = answer.grants.map((grant) => `${grant.id}${at}`);
|
|
267
|
+
return `${wins} Closest ${which.length > 0 ? `${which.length === 1 ? "grant" : "grants"} for ${whom}: ${which.join(", ")}` : `grant for ${whom}: ${flag ? `a ${flag} grant` : "one"} you can't list`}: ${given}.`;
|
|
268
|
+
}
|
|
269
|
+
//#endregion
|
|
17
270
|
//#region src/cli/format.ts
|
|
18
271
|
/** "claude via julian" for a profile, the name otherwise. */
|
|
19
272
|
/**
|
|
@@ -163,7 +416,8 @@ function formatCan(can) {
|
|
|
163
416
|
const patterns = Object.keys(can);
|
|
164
417
|
if (patterns.length === 1 && patterns[0] === "*" && can["*"].includes("manage")) return "all";
|
|
165
418
|
if (patterns.length === 0) return "nothing";
|
|
166
|
-
|
|
419
|
+
const permissions = (list) => list.includes("manage") ? "all" : list.length === 0 ? "none" : list.join(",");
|
|
420
|
+
return patterns.map((pattern) => `${pattern}=${permissions(can[pattern])}`).join(";");
|
|
167
421
|
}
|
|
168
422
|
/** Rows of cells, each column padded to its widest, two spaces apart. */
|
|
169
423
|
const table = (rows) => {
|
|
@@ -180,7 +434,7 @@ function principalFlags(principal) {
|
|
|
180
434
|
case "github": return [
|
|
181
435
|
`--github ${principal.repository}`,
|
|
182
436
|
...principal.workflow !== void 0 ? [`--workflow ${workflowName(principal.workflow)}`] : [],
|
|
183
|
-
...principal.branch !== void 0 ? [`--branch ${principal.branch}`] : [],
|
|
437
|
+
...principal.branch !== void 0 ? [`--git-branch ${principal.branch}`] : [],
|
|
184
438
|
...principal.event !== void 0 ? [`--event ${principal.event}`] : []
|
|
185
439
|
].join(" ");
|
|
186
440
|
case "oidc": return [`--oidc ${principal.issuer}`, ...Object.entries(principal.claims).flatMap(([name, value]) => [value].flat().map((one) => `--claim ${name}=${one}`))].join(" ");
|
|
@@ -204,14 +458,17 @@ function grantCan(can, capped) {
|
|
|
204
458
|
}
|
|
205
459
|
return patterns.map((pattern) => `${pattern}=${words(can[pattern])}`).join(" ");
|
|
206
460
|
}
|
|
461
|
+
const grantCells = (grant) => [
|
|
462
|
+
grant.id,
|
|
463
|
+
grant.principals.map(principalFlags).join(" "),
|
|
464
|
+
grantCan(grant.can, grant.capped)
|
|
465
|
+
];
|
|
207
466
|
/** Each grant on a row: its ID, who it names (as the flags that would), and what it lets them do. */
|
|
208
467
|
function formatGrants(grants) {
|
|
209
|
-
return table(grants.map(
|
|
210
|
-
grant.id,
|
|
211
|
-
grant.principals.map(principalFlags).join(" "),
|
|
212
|
-
grantCan(grant.can, grant.capped)
|
|
213
|
-
]));
|
|
468
|
+
return table(grants.map(grantCells));
|
|
214
469
|
}
|
|
470
|
+
/** One grant as its row: `g3 --everyone security/=none`. */
|
|
471
|
+
const grantRow = (grant) => grantCells(grant).join(" ");
|
|
215
472
|
/** Each token on a row: its ID, its name, what it may do, and when it expires. */
|
|
216
473
|
function formatTokens(tokens, now = Date.now()) {
|
|
217
474
|
return table(tokens.map((token) => [
|
|
@@ -800,6 +1057,8 @@ let app = {
|
|
|
800
1057
|
};
|
|
801
1058
|
let flags = {};
|
|
802
1059
|
let positionals = [];
|
|
1060
|
+
/** Every option as it was typed, in order: what reads principal flags and the modifiers after each. */
|
|
1061
|
+
let ordered = [];
|
|
803
1062
|
/** The command this run runs, by its own name, and what follows it: what a failure says it was doing. */
|
|
804
1063
|
let current = {
|
|
805
1064
|
command: void 0,
|
|
@@ -841,6 +1100,15 @@ function parse(argv) {
|
|
|
841
1100
|
if (removed) throw removed;
|
|
842
1101
|
try {
|
|
843
1102
|
const parsed = parseAll(markAttachmentId(args));
|
|
1103
|
+
ordered = parseArgs({
|
|
1104
|
+
args: markAttachmentId(args),
|
|
1105
|
+
allowPositionals: true,
|
|
1106
|
+
options: OPTIONS,
|
|
1107
|
+
tokens: true
|
|
1108
|
+
}).tokens.flatMap((token) => token.kind === "option" ? [{
|
|
1109
|
+
name: token.name,
|
|
1110
|
+
value: token.value
|
|
1111
|
+
}] : []);
|
|
844
1112
|
flags = parsed.values;
|
|
845
1113
|
positionals = parsed.positionals.map((arg) => arg.startsWith(MARK) ? arg.slice(1) : arg);
|
|
846
1114
|
} catch (error) {
|
|
@@ -1024,12 +1292,42 @@ function trustId(what, value) {
|
|
|
1024
1292
|
if (!/^[^\s/]+$/.test(value)) throw usage(`${value} isn't a ${what} ID like ${like}.`);
|
|
1025
1293
|
return value;
|
|
1026
1294
|
}
|
|
1027
|
-
/**
|
|
1028
|
-
|
|
1295
|
+
/**
|
|
1296
|
+
* A token's `--can`, as `x-board-scope` writes it (`dev/=read,post;ci/=read`), repeated or
|
|
1297
|
+
* `;`-joined, with `none` for no permissions, as `all` is every one: `*=all;security/=none` closes a
|
|
1298
|
+
* subtree. `security/=` means the same. The board takes an empty list, so `none` never leaves the CLI.
|
|
1299
|
+
*/
|
|
1300
|
+
function canFlag(values) {
|
|
1301
|
+
const scope = values.flatMap((value) => value.split(";")).map((entry) => {
|
|
1302
|
+
const at = entry.indexOf("=");
|
|
1303
|
+
if (at === -1) return entry;
|
|
1304
|
+
const permissions = entry.slice(at + 1).split(",").map((permission) => permission.trim());
|
|
1305
|
+
if (permissions.includes("none") && permissions.length > 1) throw usage(`--can: none is no permissions, so it goes alone: ${entry.slice(0, at).trim()}=none.`);
|
|
1306
|
+
return permissions[0] === "none" ? entry.slice(0, at + 1) : entry;
|
|
1307
|
+
}).join(";");
|
|
1308
|
+
try {
|
|
1309
|
+
return parseScope(scope);
|
|
1310
|
+
} catch (error) {
|
|
1311
|
+
throw usage(`${error.message.replace(/x-board-scope/g, "--can").replace(/, or all$/, ", all, or none")}.`);
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
/** What a grant's flags say, or the misuse in them. */
|
|
1315
|
+
function grantFlags(read) {
|
|
1029
1316
|
try {
|
|
1030
|
-
return
|
|
1317
|
+
return read();
|
|
1031
1318
|
} catch (error) {
|
|
1032
|
-
throw usage(
|
|
1319
|
+
if (error instanceof GrantMisuse) throw usage(error.message, error.next ? { next: error.next } : {});
|
|
1320
|
+
throw error;
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1323
|
+
/** Refuses the principal flags `verb` doesn't take: plain ones on update, `--add-` and `--remove-` ones elsewhere. */
|
|
1324
|
+
function onlyPrincipalFlags(verb) {
|
|
1325
|
+
for (const { name } of ordered) {
|
|
1326
|
+
const kind = name.replace(/^(add|remove)-/, "");
|
|
1327
|
+
if (!KINDS.includes(kind)) continue;
|
|
1328
|
+
const prefixed = kind !== name;
|
|
1329
|
+
if (verb === "update" && !prefixed) throw usage(`grants update adds and removes principals: --add-${kind} or --remove-${kind}, not --${kind}.`);
|
|
1330
|
+
if (verb !== "update" && prefixed) throw usage(`--${name} is for grants update: grants ${verb} names principals as --${kind}.`);
|
|
1033
1331
|
}
|
|
1034
1332
|
}
|
|
1035
1333
|
/** A time flag: anything `Date` reads, as ISO. */
|
|
@@ -1103,7 +1401,7 @@ function doing() {
|
|
|
1103
1401
|
case "channels": return a === "create" ? `create ${b ?? "the channel"}` : "list channels";
|
|
1104
1402
|
case "schedules":
|
|
1105
1403
|
case "actors": return `list ${command}`;
|
|
1106
|
-
case "grants": return a === "create" ? `grant ${b ?? "
|
|
1404
|
+
case "grants": return a === "create" ? "create the grant" : a === "update" ? `update grant ${b}` : a === "explain" ? `explain ${b ?? "the channel"}` : a === "revoke" ? `revoke grant ${b}` : "list grants";
|
|
1107
1405
|
case "tokens": return a === "create" ? `mint token ${b ?? ""}`.trimEnd() : a === "revoke" ? `revoke token ${b}` : "list tokens";
|
|
1108
1406
|
case "sources": return b === void 0 ? "list sources" : `${b} ${c ?? "it"} on ${a}`;
|
|
1109
1407
|
case "download": return `download ${a ?? "the attachment"}`;
|
|
@@ -1138,7 +1436,7 @@ function missing() {
|
|
|
1138
1436
|
"schedule"
|
|
1139
1437
|
].includes(command) && isMessageRef(a)) return `message ${ref(a)}`;
|
|
1140
1438
|
if (command === "schedule" && a === "cancel" && b !== void 0) return `schedule ${b}`;
|
|
1141
|
-
if ((command === "grants" || command === "tokens") && a === "revoke" && b !== void 0) return `${command === "grants" ? "grant" : "token"} ${b}`;
|
|
1439
|
+
if ((command === "grants" || command === "tokens") && (a === "revoke" || a === "update") && b !== void 0) return `${command === "grants" ? "grant" : "token"} ${b}`;
|
|
1142
1440
|
if (command === "download") return `attachment ${a}`;
|
|
1143
1441
|
}
|
|
1144
1442
|
/**
|
|
@@ -1194,6 +1492,8 @@ function failureOf(error) {
|
|
|
1194
1492
|
}]);
|
|
1195
1493
|
case "board_name_taken": return own("conflict", "board_name_taken");
|
|
1196
1494
|
case "board_not_granted": return own("permission", "board_not_granted");
|
|
1495
|
+
case "board_token_unsupported": return own("permission", "board_token_unsupported");
|
|
1496
|
+
case "board_token_scope": return own("permission", "board_token_scope");
|
|
1197
1497
|
case "invalid_board_name": return own("usage", "invalid_arguments", [helpRecovery()]);
|
|
1198
1498
|
case "too_many_redirects": return own("network", "network_error");
|
|
1199
1499
|
case "invalid_duration": return own("usage", "invalid_arguments", [helpRecovery()]);
|
|
@@ -1220,6 +1520,9 @@ function failureOf(error) {
|
|
|
1220
1520
|
message: `Failed to ${doing()}.`,
|
|
1221
1521
|
details: [message]
|
|
1222
1522
|
};
|
|
1523
|
+
case "channel_exists": return own("conflict", "channel_exists");
|
|
1524
|
+
case "channel_granted": return own("conflict", "channel_granted");
|
|
1525
|
+
case "no_own_principal": return own("usage", "no_own_principal");
|
|
1223
1526
|
case "port_taken": return own("conflict", "port_taken", [{
|
|
1224
1527
|
instruction: "Pick another port",
|
|
1225
1528
|
argv: [
|
|
@@ -1555,7 +1858,8 @@ async function run(command, args) {
|
|
|
1555
1858
|
argv: rerun("--url", "<URL>")
|
|
1556
1859
|
}]
|
|
1557
1860
|
});
|
|
1558
|
-
const
|
|
1861
|
+
const tokenUrl = io.board ? void 0 : connection().url === null ? (await client().discovery()).url : flags.url;
|
|
1862
|
+
const withToken = io.board ? {} : { withToken: (secret) => connection(tokenUrl, { token: secret }).board };
|
|
1559
1863
|
const report = await conformance(client(), {
|
|
1560
1864
|
...flags.channel ? { channel: flags.channel } : {},
|
|
1561
1865
|
...withToken
|
|
@@ -1570,12 +1874,16 @@ async function run(command, args) {
|
|
|
1570
1874
|
const [path, extra] = rest;
|
|
1571
1875
|
if (!path) throw usage("Missing the channel to create, such as dev/alerts.", { reason: "missing_arguments" });
|
|
1572
1876
|
if (extra !== void 0) throw usage(`channels create takes one channel: ${extra} is one too many.`);
|
|
1573
|
-
const { channel, created } = await client().createChannel(path);
|
|
1877
|
+
const { channel, created, grants } = await client().createChannel(path, flags.private ? { private: true } : {});
|
|
1574
1878
|
if (flags.json) result({
|
|
1575
1879
|
channel,
|
|
1576
|
-
outcome: created ? "created" : "unchanged"
|
|
1880
|
+
outcome: created ? "created" : "unchanged",
|
|
1881
|
+
...grants ? { grants } : {}
|
|
1577
1882
|
});
|
|
1578
|
-
else
|
|
1883
|
+
else if (grants) {
|
|
1884
|
+
out(`created channel ${channel.path}`);
|
|
1885
|
+
for (const grant of grants) out(`created ${grantRow(grant)}`);
|
|
1886
|
+
} else out(created ? `created ${channel.path}` : `${channel.path} already exists`);
|
|
1579
1887
|
return 0;
|
|
1580
1888
|
}
|
|
1581
1889
|
if (sub !== void 0 && sub !== "list") throw usage(`Unknown command ${sub} for ${named()} channels.`, { reason: "unknown_command" });
|
|
@@ -1759,6 +2067,83 @@ async function run(command, args) {
|
|
|
1759
2067
|
out(list.length === 0 ? "no grants" : formatGrants(list));
|
|
1760
2068
|
return 0;
|
|
1761
2069
|
}
|
|
2070
|
+
if (verb === "create") {
|
|
2071
|
+
if (rest.length > 0) throw usage(`grants create takes no arguments: ${rest[0]} is one too many.`);
|
|
2072
|
+
onlyPrincipalFlags("create");
|
|
2073
|
+
const principals = grantFlags(() => principalsIn(ordered, [""])).map(({ principal }) => principal);
|
|
2074
|
+
if (principals.length === 0) throw usage("A grant names whom it lets in: --user, --project, --github, --oidc, --all-users, --all-projects, or --everyone.", { reason: "missing_arguments" });
|
|
2075
|
+
const can = grantFlags(() => grantCanOf(flags.can ?? []));
|
|
2076
|
+
if (Object.keys(can).length === 0) throw usage("A grant says what it lets them do: --can pattern=permissions, like --can 'ci/=read,post'.", { reason: "missing_arguments" });
|
|
2077
|
+
const { grant } = await client().createGrant({
|
|
2078
|
+
principals,
|
|
2079
|
+
can
|
|
2080
|
+
});
|
|
2081
|
+
const unsigned = principals.some((principal) => principal.kind === "github" || principal.kind === "oidc") && vercelBoard((await client().discovery()).url) !== null;
|
|
2082
|
+
const note = "Vercel's board doesn't sign in GitHub or OIDC callers yet: this grant works once it does";
|
|
2083
|
+
if (flags.json) {
|
|
2084
|
+
if (unsigned) warnings.push({
|
|
2085
|
+
reason: "callers_not_signed_in",
|
|
2086
|
+
message: note
|
|
2087
|
+
});
|
|
2088
|
+
result({
|
|
2089
|
+
grant,
|
|
2090
|
+
outcome: "created"
|
|
2091
|
+
});
|
|
2092
|
+
} else {
|
|
2093
|
+
out(`created ${grantRow(grant)}`);
|
|
2094
|
+
if (unsigned) out(`note ${note}`);
|
|
2095
|
+
}
|
|
2096
|
+
return 0;
|
|
2097
|
+
}
|
|
2098
|
+
if (verb === "update") {
|
|
2099
|
+
const id = trustId("grant", rest[0]);
|
|
2100
|
+
if (rest.length > 1) throw usage(`grants update takes one grant: ${rest[1]} is one too many.`);
|
|
2101
|
+
onlyPrincipalFlags("update");
|
|
2102
|
+
const named = grantFlags(() => principalsIn(ordered, ["add-", "remove-"], ({ kind, value }) => {
|
|
2103
|
+
const named = value !== void 0 ? [value] : [];
|
|
2104
|
+
return [{
|
|
2105
|
+
instruction: "Remove it and add it back with the environments it keeps",
|
|
2106
|
+
argv: [
|
|
2107
|
+
...cli(),
|
|
2108
|
+
"grants",
|
|
2109
|
+
"update",
|
|
2110
|
+
id,
|
|
2111
|
+
`--remove-${kind}`,
|
|
2112
|
+
...named,
|
|
2113
|
+
`--add-${kind}`,
|
|
2114
|
+
...named,
|
|
2115
|
+
"--environment",
|
|
2116
|
+
"<ENVIRONMENTS>"
|
|
2117
|
+
]
|
|
2118
|
+
}];
|
|
2119
|
+
}));
|
|
2120
|
+
const add = named.filter(({ prefix }) => prefix === "add-").map(({ principal }) => principal);
|
|
2121
|
+
const remove = named.filter(({ prefix }) => prefix === "remove-").map(({ principal }) => principal);
|
|
2122
|
+
const can = flags.can !== void 0 ? grantFlags(() => grantCanOf(flags.can)) : void 0;
|
|
2123
|
+
if (add.length === 0 && remove.length === 0 && can === void 0) throw usage(`grants update ${id} changes nothing: add or remove a principal (--add-user, --remove-project, …), or give --can.`, { reason: "missing_arguments" });
|
|
2124
|
+
const { grant } = await client().updateGrant(id, {
|
|
2125
|
+
...add.length > 0 ? { add } : {},
|
|
2126
|
+
...remove.length > 0 ? { remove } : {},
|
|
2127
|
+
...can !== void 0 ? { can } : {}
|
|
2128
|
+
});
|
|
2129
|
+
if (flags.json) result({
|
|
2130
|
+
grant,
|
|
2131
|
+
outcome: "updated"
|
|
2132
|
+
});
|
|
2133
|
+
else out(`updated ${grantRow(grant)}`);
|
|
2134
|
+
return 0;
|
|
2135
|
+
}
|
|
2136
|
+
if (verb === "explain") {
|
|
2137
|
+
const [channel, extra] = rest;
|
|
2138
|
+
if (channel === void 0) throw usage("Missing the channel to explain, such as security/incidents.", { reason: "missing_arguments" });
|
|
2139
|
+
if (extra !== void 0) throw usage(`grants explain takes one channel: ${extra} is one too many.`);
|
|
2140
|
+
onlyPrincipalFlags("explain");
|
|
2141
|
+
const { principal, subject, kind } = grantFlags(() => explainPrincipalOf(ordered));
|
|
2142
|
+
const explanation = await client().explain(channel, principal);
|
|
2143
|
+
if (flags.json) result({ explanation });
|
|
2144
|
+
else out(explanationLine(explanation, subject, kind));
|
|
2145
|
+
return 0;
|
|
2146
|
+
}
|
|
1762
2147
|
if (verb === "revoke") {
|
|
1763
2148
|
const id = trustId("grant", rest[0]);
|
|
1764
2149
|
const { revoked } = await client().revokeGrant(id);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { r as sqlTables } from "./sql-
|
|
1
|
+
import { r as sqlTables } from "./sql-aetuEBZC.mjs";
|
|
2
2
|
import { t as memory$1 } from "./store-memory-CKQVEzXN.mjs";
|
|
3
|
-
import { t as sqliteDb } from "./sqlite-db-
|
|
3
|
+
import { t as sqliteDb } from "./sqlite-db-BPwRoDI7.mjs";
|
|
4
4
|
//#region src/store/memory.ts
|
|
5
5
|
/**
|
|
6
6
|
* A board that lives in memory, for tests: its log in A2's memory store, its
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $t as ExternalCopy, C as InboxItem, Ct as ThreadsPage, Dt as TokenInput, F as MessagesPage, J as RegistrationView, L as MessagesQueryInput, Mt as UpdateGrantInput, N as Me, Ot as TokenView, P as MessageView, Qt as Actor, S as InboxEntry, St as ThreadView, Tt as ThreadsQueryInput, an as ExternalFile, b as GrantView, bt as SyncedView, d as EventsPage, en as Attachment, et as ScheduleView, ft as SyncFindInput, g as FiltersInput, gt as SyncImportInput, h as Explanation, i as BoardEventView, in as ExternalEvent, it as SourceJoin, j as MatchView, l as Discovery, mt as SyncFindView, nt as SchedulesQueryInput, o as ChannelView, on as ExternalLink, q as RegisterInput, rn as ExternalAuthor, sn as Link, st as SourceRead, vt as SyncReceiptInput, y as GrantInput, yt as SyncThreadView } from "./routes-BpKdMvgX.mjs";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
//#region src/client/client.d.ts
|
|
4
4
|
/**
|
|
@@ -143,10 +143,28 @@ declare function createBoardClient(options: ClientOptions): {
|
|
|
143
143
|
/**
|
|
144
144
|
* Makes a channel before anything posts to it, as a first post would. Needs `read` and `post`
|
|
145
145
|
* there. `created` is false when it was there already; it's left as it is.
|
|
146
|
+
*
|
|
147
|
+
* `private` makes it closed to everyone but you, from the protocol's own methods: a grant
|
|
148
|
+
* letting you in at `<path>/`, then one closing `<path>/` to everyone else, then the channel,
|
|
149
|
+
* answering the two grants as `grants`. A failure part way leaves the channel open with a grant
|
|
150
|
+
* too many, or closed and not made yet, and never shuts you out. Before it writes anything, it
|
|
151
|
+
* refuses a caller that's neither a person nor a project's deployment (400 `no_own_principal`),
|
|
152
|
+
* one that can't list grants, a path a grant other than `*`'s reaches already (409
|
|
153
|
+
* `channel_granted`: the channel, `<path>/`, or a pattern under it, whose grants would still let
|
|
154
|
+
* in whoever they name), and a path where it or a channel under it is there already (409
|
|
155
|
+
* `channel_exists`), since closing `security/` closes `security/incidents` too. A board that
|
|
156
|
+
* keeps no grants fails on the listing, with nothing made. Once its own grant is made it lists
|
|
157
|
+
* them again, and takes its own back when another reaches the path, so of two callers making
|
|
158
|
+
* the same channel at once, at most one keeps a way in; and once the lock is made, it lists them
|
|
159
|
+
* a last time, and takes both back when a grant made in between still reaches the path, or its
|
|
160
|
+
* own two aren't as it made them (someone added themselves to its grant, or opened the lock).
|
|
146
161
|
*/
|
|
147
|
-
createChannel: (path: string
|
|
162
|
+
createChannel: (path: string, options?: {
|
|
163
|
+
private?: boolean;
|
|
164
|
+
}) => Promise<{
|
|
148
165
|
channel: ChannelView;
|
|
149
166
|
created: boolean;
|
|
167
|
+
grants?: GrantView[];
|
|
150
168
|
}>;
|
|
151
169
|
actors: () => Promise<Actor[]>;
|
|
152
170
|
messages: (query?: Filters & Omit<MessagesQueryInput, keyof FiltersInput>) => Promise<MessagesPage>;
|
|
@@ -185,7 +203,7 @@ declare function createBoardClient(options: ClientOptions): {
|
|
|
185
203
|
grant: GrantView;
|
|
186
204
|
}>;
|
|
187
205
|
/** Adds and removes principals (by who they are, environments aside), or replaces its `can`. Needs what `checkGrantChange` says, for the grant as it was and as it'd be. */
|
|
188
|
-
updateGrant: (id: string,
|
|
206
|
+
updateGrant: (id: string, { add, remove, can }: UpdateGrantInput) => Promise<{
|
|
189
207
|
grant: GrantView;
|
|
190
208
|
}>;
|
|
191
209
|
/**
|