@vercel/board 0.33.0 → 0.34.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-N3XmkKXg.mjs → access-CdBcYPQH.mjs} +169 -12
- package/dist/access.d.mts +3 -3
- package/dist/access.mjs +5 -5
- package/dist/{actors-ihyN47OV.mjs → actors-MrIEr9LI.mjs} +2 -2
- package/dist/auth-DjoJygbG.mjs +599 -0
- package/dist/{auth-D6z3rMNj.d.mts → auth-aaoKt5DK.d.mts} +128 -9
- package/dist/backend-local.d.mts +1 -1
- package/dist/backend-local.mjs +1 -1
- package/dist/{backend-CWpyR1A7.d.mts → backend-u1sVvybh.d.mts} +30 -7
- package/dist/{chat-provider-DJpFUaFv.d.mts → chat-provider-De0iDnUB.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-CHoMl06v.mjs → commands-B8oZEByR.mjs} +25 -51
- package/dist/{commands-BOBQHVqM.d.mts → commands-BkVMdXP1.d.mts} +0 -6
- package/dist/{conformance-qKmGLTAT.mjs → conformance-gqYBkXFS.mjs} +76 -83
- package/dist/conformance.d.mts +1 -1
- package/dist/conformance.mjs +1 -1
- package/dist/{engine-JxgZiikU.mjs → engine-rtOVWsiF.mjs} +2 -2
- package/dist/{errors-Pk0XV1hK.mjs → errors-D8ifv16L.mjs} +19 -4
- package/dist/{exports-gHDHlg0i.mjs → exports-Bx2dGpzr.mjs} +55 -10
- package/dist/exports-uwRl5qIj.d.mts +4 -0
- package/dist/{index-CXvvYNYj.d.mts → index-D6mK0Ial.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 +31 -31
- package/dist/{local-BbLjA5vI.mjs → local-CPz22MQ8.mjs} +1981 -1574
- package/dist/{main-CQpCZJFw.mjs → main-DScDKwQN.mjs} +45 -38
- package/dist/{middleware-BU7rVi9F.mjs → middleware-BjYpk4yq.mjs} +1 -1
- package/dist/provider-hB8QNrwm.d.mts +1031 -0
- package/dist/{provider-BlzUvcM9.d.mts → routes-De4W6lEs.d.mts} +2439 -2469
- package/dist/{serve-D8_W4UN6.mjs → serve-B1noQRkn.mjs} +4 -4
- package/dist/{server-BiIUXWbU.mjs → server-Ov6GBJ8j.mjs} +7 -7
- package/dist/{serving-D7rcUtSC.mjs → serving-2s7lqSBS.mjs} +1 -1
- package/dist/sync-chat-sdk.d.mts +2 -2
- package/dist/sync-github.d.mts +2 -2
- package/dist/sync-linear.d.mts +3 -2
- package/dist/sync-slack.d.mts +3 -3
- package/dist/sync.d.mts +2 -2
- package/dist/{targets-CknPGGVi.mjs → targets-aMdbp84G.mjs} +98 -10
- package/dist/{tokens-DPKjl3jf.mjs → tokens-LHLrnV_P.mjs} +2 -2
- package/docs/01-board/01-mounting.md +5 -3
- package/docs/01-board/03-identity.md +14 -13
- package/docs/01-board/07-schedules.md +1 -1
- package/docs/01-board/09-access.md +140 -59
- package/docs/03-guides/03-ci.md +15 -15
- package/docs/03-guides/05-agent-factory.md +5 -6
- package/docs/04-reference/01-cli.md +9 -16
- package/docs/04-reference/02-board.md +19 -8
- package/docs/04-reference/03-http.md +20 -13
- package/docs/04-reference/05-conformance.md +1 -1
- package/package.json +1 -1
- package/dist/auth-r-_PeZyw.mjs +0 -277
- package/dist/exports-BuKjVq2t.d.mts +0 -4
- package/dist/folds-DjFTiqIM.d.mts +0 -552
|
@@ -1,5 +1,88 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Ft as Access, Gt as Level, Kt as Permission, Lt as Can, qt as WrittenCan } from "./routes-De4W6lEs.mjs";
|
|
2
2
|
import { JWTVerifyGetKey } from "jose";
|
|
3
|
+
//#region src/server/grants.d.ts
|
|
4
|
+
/** Who asks, as a verified token says, in the terms grants name them by. */
|
|
5
|
+
type Caller = {
|
|
6
|
+
kind: 'user';
|
|
7
|
+
userId: string;
|
|
8
|
+
} | {
|
|
9
|
+
kind: 'project';
|
|
10
|
+
projectId: string;
|
|
11
|
+
environment: string;
|
|
12
|
+
teamId?: string;
|
|
13
|
+
} | {
|
|
14
|
+
kind: 'github';
|
|
15
|
+
repository: string;
|
|
16
|
+
repositoryId?: string;
|
|
17
|
+
workflowRef?: string;
|
|
18
|
+
ref?: string;
|
|
19
|
+
event?: string;
|
|
20
|
+
} | {
|
|
21
|
+
kind: 'oidc';
|
|
22
|
+
issuer: string;
|
|
23
|
+
claims: Readonly<Record<string, unknown>>;
|
|
24
|
+
} | {
|
|
25
|
+
kind: 'app';
|
|
26
|
+
clientId: string;
|
|
27
|
+
};
|
|
28
|
+
/** A grant as the decision reads it: whom it names, and what it gives where. */
|
|
29
|
+
type DecidingGrant = {
|
|
30
|
+
readonly principals: readonly GrantPrincipal[];
|
|
31
|
+
readonly can: WrittenCan;
|
|
32
|
+
};
|
|
33
|
+
/** What decides a caller's access, all of it plain data or a predicate the backend answers. */
|
|
34
|
+
type GrantFacts<G extends DecidingGrant = DecidingGrant> = {
|
|
35
|
+
caller: Caller;
|
|
36
|
+
/** The board's grants, as they are, or as a write is about to leave them. */
|
|
37
|
+
grants: readonly G[];
|
|
38
|
+
/** Whether the caller, a user, is a person on the board's team: `all-users` names them, and that lets them in. */
|
|
39
|
+
member?: boolean;
|
|
40
|
+
/** Whether the caller, a project, is on the board's team: `all-projects` names it. */
|
|
41
|
+
teamProject?: boolean;
|
|
42
|
+
/** Whether the caller, an app, is installed on the board's team: `all-apps` names it. */
|
|
43
|
+
teamApp?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* The most the caller may do anywhere, whatever the grants say: what a backend makes of a
|
|
46
|
+
* person's team role (a viewer is `['read', 'react']`) or an app's scopes. Nothing caps it,
|
|
47
|
+
* without it.
|
|
48
|
+
*/
|
|
49
|
+
cap?: readonly Permission[];
|
|
50
|
+
/** A token's `can`, which narrows what the grants give. */
|
|
51
|
+
can?: Can;
|
|
52
|
+
};
|
|
53
|
+
/** Where a matched grant came from: one the board keeps. */
|
|
54
|
+
type GrantSource<G extends DecidingGrant = DecidingGrant> = {
|
|
55
|
+
grant: G;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* What the caller may do by the board's grants: `caller`, all of it, as `GET /me` says, and `own`,
|
|
59
|
+
* the same without `everyone`'s grants, what `checkGrantChange` judges reach by. At each channel the
|
|
60
|
+
* most specific pattern a grant naming it gives decides, then the closest principal there, and
|
|
61
|
+
* grants tied there add up; `cap` caps both, and a token's `can` narrows them. Null when
|
|
62
|
+
* nothing but `everyone` names it, since `everyone` lets no one in itself.
|
|
63
|
+
*/
|
|
64
|
+
declare function grantAccess<G extends DecidingGrant>(facts: GrantFacts<G>): {
|
|
65
|
+
caller: Access;
|
|
66
|
+
own: Access;
|
|
67
|
+
} | null;
|
|
68
|
+
/**
|
|
69
|
+
* Which grants decide `channel` for the caller: the `pattern` that wins there, the patterns it wins
|
|
70
|
+
* `over`, most specific first, the `level` that wins at it, the `grants` at that level, which add
|
|
71
|
+
* up, and what the caller may do there, `permissions`, after its `cap` and its token's `can`.
|
|
72
|
+
* `capped` says whether the cap took anything away. `pattern` and `level` are null for a caller
|
|
73
|
+
* nothing lets in, whose `permissions` are empty. What `grantAccess` gives, explained.
|
|
74
|
+
*/
|
|
75
|
+
type GrantExplanation<G extends DecidingGrant = DecidingGrant> = {
|
|
76
|
+
pattern: string | null;
|
|
77
|
+
over: string[];
|
|
78
|
+
level: Level | null;
|
|
79
|
+
grants: G[];
|
|
80
|
+
capped: boolean;
|
|
81
|
+
permissions: Permission[];
|
|
82
|
+
};
|
|
83
|
+
/** Which grants decide `channel` for the caller `facts` describes, from plain data, as a board explains it. */
|
|
84
|
+
declare function explainGrants<G extends DecidingGrant>(facts: GrantFacts<G>, channel: string): GrantExplanation<G>;
|
|
85
|
+
//#endregion
|
|
3
86
|
//#region src/server/auth.d.ts
|
|
4
87
|
/**
|
|
5
88
|
* What a request says about who's calling, beside its credential: labels the caller picks for
|
|
@@ -98,15 +181,51 @@ type OidcTokensOptions = {
|
|
|
98
181
|
};
|
|
99
182
|
/** A principal as the board keeps it to work its access out again: who it is, its token's facts, its scope, and the board token it came with. */
|
|
100
183
|
type Known = Pick<Principal, 'id' | 'kind' | 'handle' | 'facts' | 'scope' | 'token'>;
|
|
101
|
-
/**
|
|
102
|
-
|
|
103
|
-
|
|
184
|
+
/**
|
|
185
|
+
* Who a grant names, as the board keeps it: IDs, with the names it knows beside them. A board
|
|
186
|
+
* that verifies tokens itself knows none, so it keeps what was written: a user's ID, a project's
|
|
187
|
+
* ID, a repository's `owner/name`.
|
|
188
|
+
*/
|
|
189
|
+
type GrantPrincipal = {
|
|
190
|
+
kind: 'user';
|
|
191
|
+
userId: string;
|
|
192
|
+
email?: string;
|
|
193
|
+
} | {
|
|
194
|
+
kind: 'project';
|
|
195
|
+
projectId: string;
|
|
196
|
+
name?: string;
|
|
197
|
+
environments: readonly string[];
|
|
198
|
+
teamId?: string;
|
|
199
|
+
} | {
|
|
200
|
+
kind: 'github';
|
|
201
|
+
repository: string;
|
|
202
|
+
repositoryId?: string;
|
|
203
|
+
workflow?: string;
|
|
204
|
+
branch?: string;
|
|
205
|
+
event?: string;
|
|
206
|
+
} | {
|
|
207
|
+
kind: 'oidc';
|
|
104
208
|
issuer: string;
|
|
105
209
|
claims: Readonly<Record<string, string | readonly string[]>>;
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
210
|
+
} | {
|
|
211
|
+
kind: 'all-users';
|
|
212
|
+
} | {
|
|
213
|
+
kind: 'all-projects';
|
|
214
|
+
environments: readonly string[];
|
|
215
|
+
} | {
|
|
216
|
+
kind: 'app';
|
|
217
|
+
clientId: string;
|
|
218
|
+
name?: string;
|
|
219
|
+
} | {
|
|
220
|
+
kind: 'all-apps';
|
|
221
|
+
} | {
|
|
222
|
+
kind: 'everyone';
|
|
223
|
+
};
|
|
224
|
+
/** A grant the board keeps: who it names, and one `can` for all of them, as written. */
|
|
225
|
+
type StoredGrant = {
|
|
226
|
+
id: string;
|
|
227
|
+
principals: readonly GrantPrincipal[];
|
|
228
|
+
can: WrittenCan;
|
|
110
229
|
};
|
|
111
230
|
/**
|
|
112
231
|
* What a grant or a token left without `can` gives: what Vercel's API gives a project it lets use a
|
|
@@ -147,4 +266,4 @@ type HostPrincipal = {
|
|
|
147
266
|
expiresAt?: Date | null;
|
|
148
267
|
};
|
|
149
268
|
//#endregion
|
|
150
|
-
export { DEFAULT_CAN as a, IssuerConfig as c, Pinned as d, Principal as f, Claims as i, Known as l, StoredGrant as m, AuthenticateContext as n, Granted as o, PrincipalKind as p, CallerRequest as r, HostPrincipal as s, Authenticate as t, OidcTokensOptions as u };
|
|
269
|
+
export { GrantExplanation as _, DEFAULT_CAN as a, explainGrants as b, IssuerConfig as c, Pinned as d, Principal as f, DecidingGrant as g, Caller as h, Claims as i, Known as l, StoredGrant as m, AuthenticateContext as n, Granted as o, PrincipalKind as p, CallerRequest as r, HostPrincipal as s, Authenticate as t, OidcTokensOptions as u, GrantFacts as v, grantAccess as x, GrantSource as y };
|
package/dist/backend-local.d.mts
CHANGED
package/dist/backend-local.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as local } from "./local-
|
|
1
|
+
import { t as local } from "./local-CPz22MQ8.mjs";
|
|
2
2
|
export { local };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { d as Pinned, l as Known, m as StoredGrant, o as Granted, t as Authenticate } from "./auth-
|
|
3
|
-
import {
|
|
1
|
+
import { $ as ScheduleView, $t as Attachment, A as MatchView, At as UpdateGrantBody, C as InboxNextQuery, Ct as ThreadsQuery, D as LabelBody, Dt as TokenView, F as MessagesQuery, Ft as Access, G as RegisterBody, Gt as Level, Kt as Permission, M as Me, Mt as UploadStartBody, N as MessageView, Nt as UploadTicket, Ot as TypingBody, P as MessagesPage, R as PostBody, S as InboxItem, St as ThreadsPage, T as InboxQuery, Tt as TokenBody, U as ReactBody, X as ScheduleBody, Zt as Actor, a as ChannelView, b as InboxAckBody, c as Discovery, d as EventsQuery, en as Author, et as SchedulesQuery, ft as SyncFindQuery, g as GrantBody, gt as SyncReceiptBody, i as BoardEventView, it as SourceJoinBody, j as MatchesQuery, k as LinkedQuery, l as EditBody, lt as SyncCopiesQuery, m as Explanation, mt as SyncImportBody, o as CreateChannelBody, ot as SourceRead, p as ExplainQuery, pt as SyncFindView, q as RegistrationView, rn as ExternalEvent, rt as SourceJoin, s as DeleteBody, st as SourceReadQuery, t as AckBody, tn as Labels, u as EventsPage, ut as SyncCopiesView, vt as SyncThreadView, w as InboxPushBody, x as InboxEntry, xt as ThreadView, y as GrantView, yt as SyncedView } from "./routes-De4W6lEs.mjs";
|
|
2
|
+
import { d as Pinned, l as Known, m as StoredGrant, o as Granted, t as Authenticate } from "./auth-aaoKt5DK.mjs";
|
|
3
|
+
import { L as ProfileOption, M as BoardClient, P as ErrorOrigin, p as SyncProvider } from "./provider-hB8QNrwm.mjs";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
//#region src/api/protocol.d.ts
|
|
6
6
|
type Input<S extends z.ZodType> = NonNullable<z.output<S>>;
|
|
@@ -118,21 +118,32 @@ type Protocol = {
|
|
|
118
118
|
canceled: boolean;
|
|
119
119
|
};
|
|
120
120
|
};
|
|
121
|
-
/** The board's grants: needs `manage`
|
|
121
|
+
/** The board's grants: needs `manage` at `*`, or a team owner. 501 `no_grants` where the board keeps none. */
|
|
122
122
|
grants: {
|
|
123
123
|
input: Nothing;
|
|
124
124
|
output: {
|
|
125
125
|
grants: GrantView[];
|
|
126
126
|
};
|
|
127
127
|
};
|
|
128
|
-
/**
|
|
128
|
+
/** A new grant, always: the same principals again are another. Needs `manage` at each pattern its `can` names. */
|
|
129
129
|
createGrant: {
|
|
130
130
|
input: Input<typeof GrantBody>;
|
|
131
131
|
output: {
|
|
132
132
|
grant: GrantView;
|
|
133
|
-
created: boolean;
|
|
134
133
|
};
|
|
135
134
|
};
|
|
135
|
+
/** Adds and removes principals, or replaces its `can`: needs what `checkGrantChange` says, for the grant as it was and as it'd be. 404 `grant_not_found`. */
|
|
136
|
+
updateGrant: {
|
|
137
|
+
input: Id & Input<typeof UpdateGrantBody>;
|
|
138
|
+
output: {
|
|
139
|
+
grant: GrantView;
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
/** Which grant decides `channel` for the caller, or with `manage` at `*` (or a team owner), the principal it names. */
|
|
143
|
+
explain: {
|
|
144
|
+
input: Input<typeof ExplainQuery>;
|
|
145
|
+
output: Explanation;
|
|
146
|
+
};
|
|
136
147
|
/** `revoked` is false when it was already gone. */
|
|
137
148
|
revokeGrant: {
|
|
138
149
|
input: Id;
|
|
@@ -404,6 +415,14 @@ declare class DroppedError extends HttpError {
|
|
|
404
415
|
}
|
|
405
416
|
//#endregion
|
|
406
417
|
//#region src/server/policy.d.ts
|
|
418
|
+
/** What decides a channel for a principal: the winning pattern and level, the grants there or the rule, and what they give. */
|
|
419
|
+
type Decided = {
|
|
420
|
+
pattern: string | null;
|
|
421
|
+
over: string[];
|
|
422
|
+
level: Level | null;
|
|
423
|
+
grants: StoredGrant[];
|
|
424
|
+
permissions: Permission[];
|
|
425
|
+
};
|
|
407
426
|
/** Who may use a board, and what they may do: `board()`'s options for it. */
|
|
408
427
|
type PolicyOptions = {
|
|
409
428
|
/**
|
|
@@ -693,8 +712,12 @@ type BoardBinding = {
|
|
|
693
712
|
/**
|
|
694
713
|
* What a principal the backend stored may do now, under board()'s defaults and the board's grants:
|
|
695
714
|
* a schedule's creator at each send, a registrant at each event and pull. Null once it may do nothing.
|
|
715
|
+
* With `grants`, under those instead of the board's grants as they are: a grant write's own
|
|
716
|
+
* snapshot, so what it checks is what it appends to.
|
|
696
717
|
*/
|
|
697
|
-
accessNow(principal: Known): Promise<Access | null>;
|
|
718
|
+
accessNow(principal: Known, grants?: readonly StoredGrant[]): Promise<Access | null>;
|
|
719
|
+
/** Which grants, or which rule, decide `channel` for a principal under board()'s `access`, and what they give: what `explain` answers. */
|
|
720
|
+
explain(principal: Known, channel: string): Promise<Decided>;
|
|
698
721
|
/** The board's own Vercel project and team, as board() knows them: what discovery names, for clients to mint tokens with. */
|
|
699
722
|
project(): Promise<{
|
|
700
723
|
id: string | null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Zt as Actor, an as ExternalLink, in as ExternalFile, nn as ExternalAuthor, ot as SourceRead, rt as SourceJoin } from "./routes-De4W6lEs.mjs";
|
|
2
|
+
import { T as ProviderEvent, a as ProviderOptions, c as ReceivedEvent, d as ResolvedTarget, g as SyncFn, i as ProviderFile, k as SyncRoot, n as FileDelivery, o as ProviderPost, p as SyncProvider, r as ProviderDelivery, s as Receive, t as FetchedLink } from "./provider-hB8QNrwm.mjs";
|
|
3
3
|
import { Adapter, Author, FileUpload, Message, ReactionEvent, StateAdapter } from "chat";
|
|
4
4
|
//#region src/sync/chat-provider.d.ts
|
|
5
5
|
type ChatInput = {
|
package/dist/cli-commands.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as OptionName, c as globalOptions, d as options, f as usage, i as CliOption, l as groups, n as CliCommand, o as commands, r as CliExample, s as filters, t as CliArgument, u as option } from "./commands-
|
|
1
|
+
import { a as OptionName, c as globalOptions, d as options, f as usage, i as CliOption, l as groups, n as CliCommand, o as commands, r as CliExample, s as filters, t as CliArgument, u as option } from "./commands-BkVMdXP1.mjs";
|
|
2
2
|
export { CliArgument, CliCommand, CliExample, CliOption, OptionName, commands, filters, globalOptions, groups, option, options, usage };
|
package/dist/cli-commands.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as option, i as groups, n as filters, o as options, r as globalOptions, s as usage, t as commands } from "./commands-
|
|
1
|
+
import { a as option, i as groups, n as filters, o as options, r as globalOptions, s as usage, t as commands } from "./commands-B8oZEByR.mjs";
|
|
2
2
|
export { commands, filters, globalOptions, groups, option, options, usage };
|
package/dist/cli-embedded.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { d as Board } from "./backend-
|
|
2
|
-
import "./index-
|
|
1
|
+
import { d as Board } from "./backend-u1sVvybh.mjs";
|
|
2
|
+
import "./index-D6mK0Ial.mjs";
|
|
3
3
|
//#region src/cli/failure.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* What kind of failure it is, which fixes the exit code: 2 for `usage` and `missing_input`, 130
|
package/dist/cli-embedded.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as commandLine, c as failureLines, i as mainWith, l as formatFailure, n as commandWord, o as exitCode, r as main, s as failureDocument, t as Failed } from "./main-
|
|
1
|
+
import { a as commandLine, c as failureLines, i as mainWith, l as formatFailure, n as commandWord, o as exitCode, r as main, s as failureDocument, t as Failed } from "./main-DScDKwQN.mjs";
|
|
2
2
|
//#region src/cli/embedded.ts
|
|
3
3
|
/**
|
|
4
4
|
* Board's CLI as `appName` names it in help, usage, and errors (`vercel board`). With no board
|
package/dist/cli.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { p as ATTACHMENT_BYTES_MAX } from "./errors-
|
|
2
|
+
import { p as ATTACHMENT_BYTES_MAX } from "./errors-D8ifv16L.mjs";
|
|
3
3
|
import "./schemas-BG205xds.mjs";
|
|
4
|
-
import { a as option } from "./commands-
|
|
5
|
-
import { d as projectDir } from "./server-
|
|
6
|
-
import { r as main, u as who } from "./main-
|
|
4
|
+
import { a as option } from "./commands-B8oZEByR.mjs";
|
|
5
|
+
import { d as projectDir } from "./server-Ov6GBJ8j.mjs";
|
|
6
|
+
import { r as main, u as who } from "./main-DScDKwQN.mjs";
|
|
7
7
|
import { randomBytes, timingSafeEqual } from "node:crypto";
|
|
8
8
|
import { appendFile, readFile } from "node:fs/promises";
|
|
9
9
|
import { join } from "node:path";
|
|
@@ -661,7 +661,7 @@ const local = {
|
|
|
661
661
|
if (args.length > 0) throw usage("serve takes no arguments: pass its port with --port, and its directory with --dir.");
|
|
662
662
|
const port = portFlag();
|
|
663
663
|
const root = projectDir();
|
|
664
|
-
const { localHandle, serveLocal } = await import("./serve-
|
|
664
|
+
const { localHandle, serveLocal } = await import("./serve-B1noQRkn.mjs");
|
|
665
665
|
const handle = flags.handle ?? process.env.BOARD_HANDLE;
|
|
666
666
|
const local = await serveLocal({
|
|
667
667
|
dir: flags.dir ?? join(root, ".board"),
|
|
@@ -210,12 +210,6 @@ const options = {
|
|
|
210
210
|
value: "scope",
|
|
211
211
|
description: "what it may do (default: *=read,post,react,label)"
|
|
212
212
|
},
|
|
213
|
-
claim: {
|
|
214
|
-
type: "string",
|
|
215
|
-
multiple: true,
|
|
216
|
-
value: "k=v",
|
|
217
|
-
description: "a claim its tokens carry; the same name again is any of them"
|
|
218
|
-
},
|
|
219
213
|
profile: {
|
|
220
214
|
type: "string",
|
|
221
215
|
value: "name",
|
|
@@ -381,7 +375,7 @@ const commands = [
|
|
|
381
375
|
{
|
|
382
376
|
group: "the board",
|
|
383
377
|
name: "grants",
|
|
384
|
-
description: "who
|
|
378
|
+
description: "who may do what where: people, projects, and workflows, and what each grant lets them do",
|
|
385
379
|
arguments: [],
|
|
386
380
|
options: [],
|
|
387
381
|
runsWithoutSubcommand: true,
|
|
@@ -389,50 +383,30 @@ const commands = [
|
|
|
389
383
|
name: "list the grants",
|
|
390
384
|
value: "grants"
|
|
391
385
|
}],
|
|
392
|
-
subcommands: [
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
}, {
|
|
417
|
-
name: "let a project's production post feedback",
|
|
418
|
-
value: "grants create vercel --claim project_id=prj_123 --claim environment=production --can feedback/=post"
|
|
419
|
-
}]
|
|
420
|
-
},
|
|
421
|
-
{
|
|
422
|
-
name: "revoke",
|
|
423
|
-
description: "stop letting them in",
|
|
424
|
-
arguments: [{
|
|
425
|
-
name: "grant",
|
|
426
|
-
required: true,
|
|
427
|
-
description: "its ID, as grants shows it (g3)"
|
|
428
|
-
}],
|
|
429
|
-
options: [],
|
|
430
|
-
examples: [{
|
|
431
|
-
name: "revoke a grant",
|
|
432
|
-
value: "grants revoke g3"
|
|
433
|
-
}]
|
|
434
|
-
}
|
|
435
|
-
]
|
|
386
|
+
subcommands: [{
|
|
387
|
+
name: "list",
|
|
388
|
+
default: true,
|
|
389
|
+
description: "the board's grants",
|
|
390
|
+
arguments: [],
|
|
391
|
+
options: [],
|
|
392
|
+
examples: [{
|
|
393
|
+
name: "list the grants",
|
|
394
|
+
value: "grants list"
|
|
395
|
+
}]
|
|
396
|
+
}, {
|
|
397
|
+
name: "revoke",
|
|
398
|
+
description: "stop letting them in",
|
|
399
|
+
arguments: [{
|
|
400
|
+
name: "grant",
|
|
401
|
+
required: true,
|
|
402
|
+
description: "its ID, as grants shows it (g3)"
|
|
403
|
+
}],
|
|
404
|
+
options: [],
|
|
405
|
+
examples: [{
|
|
406
|
+
name: "revoke a grant",
|
|
407
|
+
value: "grants revoke g3"
|
|
408
|
+
}]
|
|
409
|
+
}]
|
|
436
410
|
},
|
|
437
411
|
{
|
|
438
412
|
group: "the board",
|
|
@@ -258,12 +258,6 @@ declare const options: {
|
|
|
258
258
|
readonly value: 'scope';
|
|
259
259
|
readonly description: 'what it may do (default: *=read,post,react,label)';
|
|
260
260
|
};
|
|
261
|
-
readonly claim: {
|
|
262
|
-
readonly type: 'string';
|
|
263
|
-
readonly multiple: true;
|
|
264
|
-
readonly value: 'k=v';
|
|
265
|
-
readonly description: 'a claim its tokens carry; the same name again is any of them';
|
|
266
|
-
};
|
|
267
261
|
readonly profile: {
|
|
268
262
|
readonly type: 'string';
|
|
269
263
|
readonly value: 'name';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { u as BoardError } from "./errors-
|
|
2
|
-
import {
|
|
1
|
+
import { u as BoardError } from "./errors-D8ifv16L.mjs";
|
|
2
|
+
import { s as compileAccess } from "./access-CdBcYPQH.mjs";
|
|
3
3
|
//#region src/conformance/index.ts
|
|
4
4
|
var Mismatch = class extends Error {};
|
|
5
5
|
const show = (value) => JSON.stringify(value) ?? String(value);
|
|
@@ -59,18 +59,21 @@ const needRoot = (ctx) => {
|
|
|
59
59
|
reply: ctx.reply
|
|
60
60
|
};
|
|
61
61
|
};
|
|
62
|
-
/** A
|
|
62
|
+
/** A project that doesn't exist, by ID, which every board takes: a grant naming it lets nobody in. */
|
|
63
|
+
const projectFor = (ctx, environments = ["preview"]) => ({
|
|
64
|
+
kind: "project",
|
|
65
|
+
project: `prj_conformance${ctx.labels.conformance}`,
|
|
66
|
+
environments
|
|
67
|
+
});
|
|
68
|
+
/** The check's grant: that project may post in the check's channel. */
|
|
63
69
|
const grantFor = (ctx) => ({
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
environment: "preview",
|
|
67
|
-
project_id: `prj_conformance${ctx.labels.conformance}`
|
|
68
|
-
}
|
|
70
|
+
principals: [projectFor(ctx)],
|
|
71
|
+
can: { [ctx.channel]: ["post"] }
|
|
69
72
|
});
|
|
70
|
-
/**
|
|
71
|
-
async function firstGrant(ctx) {
|
|
73
|
+
/** Makes the check's grant, or says why it can't: changing grants takes `manage` where they apply. */
|
|
74
|
+
async function firstGrant(ctx, input = grantFor(ctx)) {
|
|
72
75
|
try {
|
|
73
|
-
return await ctx.board.createGrant(
|
|
76
|
+
return await ctx.board.createGrant(input);
|
|
74
77
|
} catch (error) {
|
|
75
78
|
if (error instanceof BoardError && error.status === 403) return { skip: "this token can't change the board's grants" };
|
|
76
79
|
throw error;
|
|
@@ -497,78 +500,70 @@ const CHECKS = [
|
|
|
497
500
|
},
|
|
498
501
|
{
|
|
499
502
|
group: "grants",
|
|
500
|
-
name: "grants a project, lists it,
|
|
501
|
-
run: async (ctx) => {
|
|
502
|
-
const asked = grantFor(ctx);
|
|
503
|
-
const first = await firstGrant(ctx);
|
|
504
|
-
if ("skip" in first) return first.skip;
|
|
505
|
-
try {
|
|
506
|
-
isRef(first.grant.id, "a grant's id");
|
|
507
|
-
same(first.created, true, "a new grant: created");
|
|
508
|
-
same(first.grant.issuer, "vercel", "the grant's issuer");
|
|
509
|
-
same(first.grant.claims.project_id, asked.claims.project_id, "the grant's project_id");
|
|
510
|
-
check(first.grant.can["*"]?.includes("post"), `a grant with no can should let them post everywhere, got ${show(first.grant.can)}`);
|
|
511
|
-
same(first.grant.by, ctx.me.actor, "the grant's by");
|
|
512
|
-
const again = await ctx.board.createGrant(asked);
|
|
513
|
-
same(again.created, false, "the same issuer and claims again: created");
|
|
514
|
-
same(again.grant.id, first.grant.id, "the same issuer and claims again: its id");
|
|
515
|
-
same((await ctx.board.grants()).filter((grant) => grant.id === first.grant.id).length, 1, "grants listing it");
|
|
516
|
-
} catch (error) {
|
|
517
|
-
await ctx.board.revokeGrant(first.grant.id).catch(() => {});
|
|
518
|
-
throw error;
|
|
519
|
-
}
|
|
520
|
-
same((await ctx.board.revokeGrant(first.grant.id)).revoked, true, "revoking it");
|
|
521
|
-
same((await ctx.board.revokeGrant(first.grant.id)).revoked, false, "revoking it again");
|
|
522
|
-
check(!(await ctx.board.grants()).some((grant) => grant.id === first.grant.id), "grants shouldn't list it once it's revoked");
|
|
523
|
-
}
|
|
524
|
-
},
|
|
525
|
-
{
|
|
526
|
-
group: "grants",
|
|
527
|
-
name: "changes a grant's can when it's set again",
|
|
503
|
+
name: "grants a project, lists it, and revokes it",
|
|
528
504
|
run: async (ctx) => {
|
|
529
505
|
const first = await firstGrant(ctx);
|
|
530
506
|
if ("skip" in first) return first.skip;
|
|
531
507
|
const { grant } = first;
|
|
532
508
|
try {
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
509
|
+
isRef(grant.id, "a grant's id");
|
|
510
|
+
same(show(grant.principals.map((principal) => principal.kind === "project" ? [
|
|
511
|
+
principal.kind,
|
|
512
|
+
principal.projectId,
|
|
513
|
+
principal.environments
|
|
514
|
+
] : principal.kind)), show([[
|
|
515
|
+
"project",
|
|
516
|
+
projectFor(ctx).project,
|
|
517
|
+
["preview"]
|
|
518
|
+
]]), "the grant's principals");
|
|
519
|
+
same(show(grant.can), show({ [ctx.channel]: ["post"] }), "the grant's can");
|
|
520
|
+
same(grant.by, ctx.me.actor, "the grant's by");
|
|
521
|
+
same((await ctx.board.grants()).filter((listed) => listed.id === grant.id).length, 1, "grants listing it");
|
|
522
|
+
} catch (error) {
|
|
541
523
|
await ctx.board.revokeGrant(grant.id).catch(() => {});
|
|
524
|
+
throw error;
|
|
542
525
|
}
|
|
526
|
+
same((await ctx.board.revokeGrant(grant.id)).revoked, true, "revoking it");
|
|
527
|
+
same((await ctx.board.revokeGrant(grant.id)).revoked, false, "revoking it again");
|
|
528
|
+
check(!(await ctx.board.grants()).some((listed) => listed.id === grant.id), "grants shouldn't list it once it's revoked");
|
|
543
529
|
}
|
|
544
530
|
},
|
|
545
531
|
{
|
|
546
532
|
group: "grants",
|
|
547
|
-
name: "
|
|
533
|
+
name: "makes another grant for the same principals, and changes one by its ID",
|
|
548
534
|
run: async (ctx) => {
|
|
549
535
|
const first = await firstGrant(ctx);
|
|
550
536
|
if ("skip" in first) return first.skip;
|
|
551
537
|
const made = [first.grant.id];
|
|
552
538
|
try {
|
|
553
|
-
const
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
539
|
+
const again = await ctx.board.createGrant(grantFor(ctx));
|
|
540
|
+
made.push(again.grant.id);
|
|
541
|
+
check(again.grant.id !== first.grant.id, `the same principals again should be another grant, got ${again.grant.id} twice`);
|
|
542
|
+
const repository = `acme/conformance-${ctx.labels.conformance}`;
|
|
543
|
+
const added = await ctx.board.updateGrant(first.grant.id, {
|
|
544
|
+
add: [{
|
|
545
|
+
kind: "github",
|
|
546
|
+
repository
|
|
547
|
+
}],
|
|
548
|
+
can: { [ctx.channel]: ["read", "post"] }
|
|
557
549
|
});
|
|
558
|
-
|
|
559
|
-
same(
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
550
|
+
same(added.grant.id, first.grant.id, "the updated grant's id");
|
|
551
|
+
same(show(added.grant.principals.map((principal) => principal.kind)), show(["project", "github"]), "principals after adding a repository");
|
|
552
|
+
same(show(added.grant.can), show({ [ctx.channel]: ["read", "post"] }), "the updated grant's can");
|
|
553
|
+
const removed = await ctx.board.updateGrant(first.grant.id, { remove: [{
|
|
554
|
+
kind: "project",
|
|
555
|
+
project: projectFor(ctx).project
|
|
556
|
+
}] });
|
|
557
|
+
same(show(removed.grant.principals.map((principal) => principal.kind)), show(["github"]), "principals after removing the project");
|
|
558
|
+
await rejects(ctx.board.updateGrant(first.grant.id, { remove: [{
|
|
559
|
+
kind: "project",
|
|
560
|
+
project: projectFor(ctx).project
|
|
561
|
+
}] }), 400, "not_in_grant", "removing a principal the grant no longer names");
|
|
562
|
+
await rejects(ctx.board.updateGrant(first.grant.id, { remove: [{
|
|
563
|
+
kind: "github",
|
|
564
|
+
repository
|
|
565
|
+
}] }), 400, "grant_empty", "removing the last principal");
|
|
566
|
+
await rejects(ctx.board.updateGrant(`${first.grant.id}0`, { can: { [ctx.channel]: ["read"] } }), 404, "grant_not_found", "updating a grant that was never made");
|
|
572
567
|
} finally {
|
|
573
568
|
for (const id of made) await ctx.board.revokeGrant(id).catch(() => {});
|
|
574
569
|
}
|
|
@@ -576,27 +571,25 @@ const CHECKS = [
|
|
|
576
571
|
},
|
|
577
572
|
{
|
|
578
573
|
group: "grants",
|
|
579
|
-
name: "keeps
|
|
574
|
+
name: "keeps a grant's can as written, a pattern with no permissions included",
|
|
580
575
|
run: async (ctx) => {
|
|
581
|
-
const
|
|
576
|
+
const can = {
|
|
577
|
+
"*": ["read"],
|
|
578
|
+
[`${ctx.channel}/`]: []
|
|
579
|
+
};
|
|
580
|
+
const first = await firstGrant(ctx, {
|
|
581
|
+
principals: [projectFor(ctx, ["production", "preview"])],
|
|
582
|
+
can
|
|
583
|
+
});
|
|
582
584
|
if ("skip" in first) return first.skip;
|
|
583
|
-
const made = [first.grant.id];
|
|
584
585
|
try {
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
}
|
|
591
|
-
});
|
|
592
|
-
made.push(production.grant.id);
|
|
593
|
-
same(production.created, true, "another environment: created");
|
|
594
|
-
check(production.grant.id !== first.grant.id, "another environment should be another grant");
|
|
595
|
-
same((await ctx.board.revokeGrant(first.grant.id)).revoked, true, "revoking the preview grant");
|
|
596
|
-
const listed = (await ctx.board.grants()).map((grant) => grant.id);
|
|
597
|
-
check(listed.includes(production.grant.id) && !listed.includes(first.grant.id), `grants should list ${production.grant.id} and not ${first.grant.id}, got ${show(listed)}`);
|
|
586
|
+
same(show(first.grant.can), show(can), "the grant's can");
|
|
587
|
+
const listed = (await ctx.board.grants()).find((grant) => grant.id === first.grant.id);
|
|
588
|
+
same(show(listed?.can), show(can), "the listed grant's can");
|
|
589
|
+
const project = listed?.principals[0];
|
|
590
|
+
same(show(project?.kind === "project" ? [...project.environments].sort() : null), show(["preview", "production"]), "the project's environments");
|
|
598
591
|
} finally {
|
|
599
|
-
|
|
592
|
+
await ctx.board.revokeGrant(first.grant.id).catch(() => {});
|
|
600
593
|
}
|
|
601
594
|
}
|
|
602
595
|
},
|
package/dist/conformance.d.mts
CHANGED
package/dist/conformance.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as conformance } from "./conformance-
|
|
1
|
+
import { t as conformance } from "./conformance-gqYBkXFS.mjs";
|
|
2
2
|
export { conformance };
|