@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.
Files changed (59) hide show
  1. package/dist/{access-N3XmkKXg.mjs → access-CdBcYPQH.mjs} +169 -12
  2. package/dist/access.d.mts +3 -3
  3. package/dist/access.mjs +5 -5
  4. package/dist/{actors-ihyN47OV.mjs → actors-MrIEr9LI.mjs} +2 -2
  5. package/dist/auth-DjoJygbG.mjs +599 -0
  6. package/dist/{auth-D6z3rMNj.d.mts → auth-aaoKt5DK.d.mts} +128 -9
  7. package/dist/backend-local.d.mts +1 -1
  8. package/dist/backend-local.mjs +1 -1
  9. package/dist/{backend-CWpyR1A7.d.mts → backend-u1sVvybh.d.mts} +30 -7
  10. package/dist/{chat-provider-DJpFUaFv.d.mts → chat-provider-De0iDnUB.d.mts} +2 -2
  11. package/dist/cli-commands.d.mts +1 -1
  12. package/dist/cli-commands.mjs +1 -1
  13. package/dist/cli-embedded.d.mts +2 -2
  14. package/dist/cli-embedded.mjs +1 -1
  15. package/dist/cli.mjs +5 -5
  16. package/dist/{commands-CHoMl06v.mjs → commands-B8oZEByR.mjs} +25 -51
  17. package/dist/{commands-BOBQHVqM.d.mts → commands-BkVMdXP1.d.mts} +0 -6
  18. package/dist/{conformance-qKmGLTAT.mjs → conformance-gqYBkXFS.mjs} +76 -83
  19. package/dist/conformance.d.mts +1 -1
  20. package/dist/conformance.mjs +1 -1
  21. package/dist/{engine-JxgZiikU.mjs → engine-rtOVWsiF.mjs} +2 -2
  22. package/dist/{errors-Pk0XV1hK.mjs → errors-D8ifv16L.mjs} +19 -4
  23. package/dist/{exports-gHDHlg0i.mjs → exports-Bx2dGpzr.mjs} +55 -10
  24. package/dist/exports-uwRl5qIj.d.mts +4 -0
  25. package/dist/{index-CXvvYNYj.d.mts → index-D6mK0Ial.d.mts} +2 -2
  26. package/dist/index.d.mts +6 -6
  27. package/dist/index.mjs +4 -4
  28. package/dist/index.node.d.mts +6 -6
  29. package/dist/index.node.mjs +3 -3
  30. package/dist/inspect/app.js +31 -31
  31. package/dist/{local-BbLjA5vI.mjs → local-CPz22MQ8.mjs} +1981 -1574
  32. package/dist/{main-CQpCZJFw.mjs → main-DScDKwQN.mjs} +45 -38
  33. package/dist/{middleware-BU7rVi9F.mjs → middleware-BjYpk4yq.mjs} +1 -1
  34. package/dist/provider-hB8QNrwm.d.mts +1031 -0
  35. package/dist/{provider-BlzUvcM9.d.mts → routes-De4W6lEs.d.mts} +2439 -2469
  36. package/dist/{serve-D8_W4UN6.mjs → serve-B1noQRkn.mjs} +4 -4
  37. package/dist/{server-BiIUXWbU.mjs → server-Ov6GBJ8j.mjs} +7 -7
  38. package/dist/{serving-D7rcUtSC.mjs → serving-2s7lqSBS.mjs} +1 -1
  39. package/dist/sync-chat-sdk.d.mts +2 -2
  40. package/dist/sync-github.d.mts +2 -2
  41. package/dist/sync-linear.d.mts +3 -2
  42. package/dist/sync-slack.d.mts +3 -3
  43. package/dist/sync.d.mts +2 -2
  44. package/dist/{targets-CknPGGVi.mjs → targets-aMdbp84G.mjs} +98 -10
  45. package/dist/{tokens-DPKjl3jf.mjs → tokens-LHLrnV_P.mjs} +2 -2
  46. package/docs/01-board/01-mounting.md +5 -3
  47. package/docs/01-board/03-identity.md +14 -13
  48. package/docs/01-board/07-schedules.md +1 -1
  49. package/docs/01-board/09-access.md +140 -59
  50. package/docs/03-guides/03-ci.md +15 -15
  51. package/docs/03-guides/05-agent-factory.md +5 -6
  52. package/docs/04-reference/01-cli.md +9 -16
  53. package/docs/04-reference/02-board.md +19 -8
  54. package/docs/04-reference/03-http.md +20 -13
  55. package/docs/04-reference/05-conformance.md +1 -1
  56. package/package.json +1 -1
  57. package/dist/auth-r-_PeZyw.mjs +0 -277
  58. package/dist/exports-BuKjVq2t.d.mts +0 -4
  59. package/dist/folds-DjFTiqIM.d.mts +0 -552
@@ -1,7 +1,7 @@
1
- import { u as BoardError } from "./errors-Pk0XV1hK.mjs";
2
- import { t as board, u as localTokenFile } from "./server-BiIUXWbU.mjs";
3
- import { t as oidcTokens } from "./tokens-DPKjl3jf.mjs";
4
- import { t as local } from "./local-BbLjA5vI.mjs";
1
+ import { u as BoardError } from "./errors-D8ifv16L.mjs";
2
+ import { t as board, u as localTokenFile } from "./server-Ov6GBJ8j.mjs";
3
+ import { t as oidcTokens } from "./tokens-LHLrnV_P.mjs";
4
+ import { t as local } from "./local-CPz22MQ8.mjs";
5
5
  import { mkdir, rename, rm, stat, writeFile } from "node:fs/promises";
6
6
  import { userInfo } from "node:os";
7
7
  import { dirname, join, resolve } from "node:path";
@@ -1,8 +1,8 @@
1
- import { d as createBoardClient, o as json, t as HttpError, u as BoardError } from "./errors-Pk0XV1hK.mjs";
1
+ import { d as createBoardClient, o as json, t as HttpError, u as BoardError } from "./errors-D8ifv16L.mjs";
2
2
  import "./schemas-BG205xds.mjs";
3
- import { N as RegisterBody, a as compileWatcher, c as METHODS, i as canonicalWatchers, q as routes } from "./targets-CknPGGVi.mjs";
4
- import { a as DERIVED_ID, c as keyId, l as sha256 } from "./middleware-BU7rVi9F.mjs";
5
- import { a as registrant, o as wakePath, r as createVercel, t as createBoard } from "./exports-gHDHlg0i.mjs";
3
+ import { P as RegisterBody, Y as routes, a as compileWatcher, c as METHODS, i as canonicalWatchers } from "./targets-aMdbp84G.mjs";
4
+ import { a as DERIVED_ID, c as keyId, l as sha256 } from "./middleware-BjYpk4yq.mjs";
5
+ import { a as registrant, o as wakePath, r as createVercel, t as createBoard } from "./exports-Bx2dGpzr.mjs";
6
6
  import { execFile } from "node:child_process";
7
7
  import { createHash } from "node:crypto";
8
8
  import { mkdir, readFile, readdir, stat, unlink, writeFile } from "node:fs/promises";
@@ -841,7 +841,7 @@ function createHttp(url, options, environment) {
841
841
  }).catch(rethrow);
842
842
  } else if (route.method === "GET") response = await client.request(`${path}${queryString(fields)}`, { signal }).catch(rethrow);
843
843
  else response = await client.request(path, {
844
- method: "POST",
844
+ method: route.method,
845
845
  body: new TextEncoder().encode(JSON.stringify(fields)),
846
846
  headers: { "content-type": "application/json" },
847
847
  signal
@@ -1087,8 +1087,8 @@ function vercel(options = {}) {
1087
1087
  function board(options = {}) {
1088
1088
  return createBoard(options, {
1089
1089
  backend: (fetch) => process.env.BOARD_URL?.trim() ? http() : vercel(fetch ? { fetch } : {}),
1090
- sync: () => import("./engine-JxgZiikU.mjs"),
1091
- serving: () => import("./serving-D7rcUtSC.mjs")
1090
+ sync: () => import("./engine-rtOVWsiF.mjs"),
1091
+ serving: () => import("./serving-2s7lqSBS.mjs")
1092
1092
  });
1093
1093
  }
1094
1094
  //#endregion
@@ -1,2 +1,2 @@
1
- import { i as ownTeamId, n as discoveryIdentity, r as ownProjectId, t as oidcTokens } from "./tokens-DPKjl3jf.mjs";
1
+ import { i as ownTeamId, n as discoveryIdentity, r as ownProjectId, t as oidcTokens } from "./tokens-LHLrnV_P.mjs";
2
2
  export { discoveryIdentity, oidcTokens, ownProjectId, ownTeamId };
@@ -1,5 +1,5 @@
1
- import { b as channels, g as SyncFn, p as SyncProvider } from "./provider-BlzUvcM9.mjs";
2
- import { r as ChatTransport, t as ChatInput } from "./chat-provider-DJpFUaFv.mjs";
1
+ import { b as channels, g as SyncFn, p as SyncProvider } from "./provider-hB8QNrwm.mjs";
2
+ import { r as ChatTransport, t as ChatInput } from "./chat-provider-De0iDnUB.mjs";
3
3
  import { z } from "zod";
4
4
  import { ReactionEvent } from "chat";
5
5
  //#region src/sync/chat-sdk.d.ts
@@ -1,5 +1,5 @@
1
- import { f as SyncContext, g as SyncFn, y as SyncUnit } from "./provider-BlzUvcM9.mjs";
2
- import { n as ChatSyncProvider } from "./chat-provider-DJpFUaFv.mjs";
1
+ import { f as SyncContext, g as SyncFn, y as SyncUnit } from "./provider-hB8QNrwm.mjs";
2
+ import { n as ChatSyncProvider } from "./chat-provider-De0iDnUB.mjs";
3
3
  import { z } from "zod";
4
4
  import { Adapter } from "chat";
5
5
  //#region src/sync/github.d.ts
@@ -1,5 +1,6 @@
1
- import { Gt as SourceRead, c as ReceivedEvent, d as ResolvedTarget, f as SyncContext, g as SyncFn, o as ProviderPost, r as ProviderDelivery, y as SyncUnit } from "./provider-BlzUvcM9.mjs";
2
- import { n as ChatSyncProvider, t as ChatInput } from "./chat-provider-DJpFUaFv.mjs";
1
+ import { ot as SourceRead } from "./routes-De4W6lEs.mjs";
2
+ import { c as ReceivedEvent, d as ResolvedTarget, f as SyncContext, g as SyncFn, o as ProviderPost, r as ProviderDelivery, y as SyncUnit } from "./provider-hB8QNrwm.mjs";
3
+ import { n as ChatSyncProvider, t as ChatInput } from "./chat-provider-De0iDnUB.mjs";
3
4
  import { z } from "zod";
4
5
  import { Adapter } from "chat";
5
6
  //#region src/sync/linear.d.ts
@@ -1,6 +1,6 @@
1
- import { c as ExternalLink } from "./folds-DjFTiqIM.mjs";
2
- import { b as channels, d as ResolvedTarget, f as SyncContext, g as SyncFn, o as ProviderPost, r as ProviderDelivery } from "./provider-BlzUvcM9.mjs";
3
- import { n as ChatSyncProvider, t as ChatInput } from "./chat-provider-DJpFUaFv.mjs";
1
+ import { an as ExternalLink } from "./routes-De4W6lEs.mjs";
2
+ import { b as channels, d as ResolvedTarget, f as SyncContext, g as SyncFn, o as ProviderPost, r as ProviderDelivery } from "./provider-hB8QNrwm.mjs";
3
+ import { n as ChatSyncProvider, t as ChatInput } from "./chat-provider-De0iDnUB.mjs";
4
4
  import { z } from "zod";
5
5
  import { Adapter } from "chat";
6
6
  //#region src/sync/slack.d.ts
package/dist/sync.d.mts CHANGED
@@ -1,3 +1,3 @@
1
- import { a as ExternalAuthor, o as ExternalEvent, s as ExternalFile } from "./folds-DjFTiqIM.mjs";
2
- import { A as envelope, C as render, D as SyncOverrides, E as RootOverride, O as SyncResult, S as mirror, T as ProviderEvent, _ as SyncIn, a as ProviderOptions, b as channels, c as ReceivedEvent, d as ResolvedTarget, f as SyncContext, g as SyncFn, h as Sync, i as ProviderFile, j as eventSchema, k as SyncRoot, l as RenderInput, m as UnreadableError, n as FileDelivery, o as ProviderPost, p as SyncProvider, r as ProviderDelivery, s as Receive, u as Renderer, v as SyncOut, w as EventBase, x as into, y as SyncUnit } from "./provider-BlzUvcM9.mjs";
1
+ import { in as ExternalFile, nn as ExternalAuthor, rn as ExternalEvent } from "./routes-De4W6lEs.mjs";
2
+ import { A as envelope, C as render, D as SyncOverrides, E as RootOverride, O as SyncResult, S as mirror, T as ProviderEvent, _ as SyncIn, a as ProviderOptions, b as channels, c as ReceivedEvent, d as ResolvedTarget, f as SyncContext, g as SyncFn, h as Sync, i as ProviderFile, j as eventSchema, k as SyncRoot, l as RenderInput, m as UnreadableError, n as FileDelivery, o as ProviderPost, p as SyncProvider, r as ProviderDelivery, s as Receive, u as Renderer, v as SyncOut, w as EventBase, x as into, y as SyncUnit } from "./provider-hB8QNrwm.mjs";
3
3
  export { EventBase, type ExternalAuthor, ExternalEvent, type ExternalFile, type FileDelivery, type ProviderDelivery, type ProviderEvent, type ProviderFile, type ProviderOptions, type ProviderPost, type Receive, ReceivedEvent, type RenderInput, type Renderer, ResolvedTarget, type RootOverride, type Sync, type SyncContext, type SyncFn, type SyncIn, type SyncOut, SyncOverrides, SyncProvider, type SyncResult, type SyncRoot, type SyncUnit, UnreadableError, channels, envelope, eventSchema, into, mirror, render };
@@ -1,7 +1,7 @@
1
- import { m as DIRECT_UPLOAD_BYTES_MAX, p as ATTACHMENT_BYTES_MAX, r as badRequest, t as HttpError } from "./errors-Pk0XV1hK.mjs";
1
+ import { m as DIRECT_UPLOAD_BYTES_MAX, p as ATTACHMENT_BYTES_MAX, r as badRequest, t as HttpError } from "./errors-D8ifv16L.mjs";
2
2
  import { a as ChannelPath, c as LabelKey, d as MESSAGE_TEXT_MAX, l as LabelValue, o as Emoji, p as MessageText, r as AttachmentId, u as Labels, v as platformAvatar, y as storable } from "./schemas-BG205xds.mjs";
3
3
  import { a as Link, i as ExternalTarget, l as isThreadTarget, n as ExternalEvent, o as Origin, t as ExternalAuthor } from "./external-CYe424fO.mjs";
4
- import { o as options } from "./commands-CHoMl06v.mjs";
4
+ import { o as options } from "./commands-B8oZEByR.mjs";
5
5
  import { n as replaceMentions, t as extractMentions } from "./mentions-CB6ShY4R.mjs";
6
6
  import { z } from "zod";
7
7
  //#region src/api/routes.ts
@@ -132,12 +132,87 @@ const CanGrant = z.union([z.literal("all"), z.array(z.string().min(1).max(16)).m
132
132
  /** What a grant or token lets do: `'all'`, a list for every channel, or a map from channel pattern to one. board() checks the patterns. */
133
133
  const Can = z.union([CanGrant, z.record(z.string().min(1).max(300), CanGrant)]);
134
134
  const ClaimValue = z.string().min(1).max(1e3);
135
- /** Who a grant lets in: an issuer (`vercel`, `github`, or an https URL) and the claims its tokens carry, exactly. */
136
- const GrantBody = z.object({
137
- issuer: z.string().min(1).max(1e3),
138
- claims: z.record(z.string().min(1).max(200), z.union([ClaimValue, z.array(ClaimValue).min(1).max(32)])),
139
- can: Can.optional()
135
+ const Environments = z.array(z.string().min(1).max(100)).min(1).max(16);
136
+ /**
137
+ * Who a grant names, as people write it: a user by email (or, where the board can't look one up,
138
+ * by ID), a project by name or ID, a repository by `owner/name`. The board resolves names and keeps
139
+ * IDs; a board that verifies tokens itself takes IDs only. A `user` names `email` or `userId`.
140
+ * Nothing else: a key it doesn't know (a misspelled `workflows`, say) is a 400, never dropped,
141
+ * since dropping it would name more than was meant.
142
+ */
143
+ const PrincipalInput = z.discriminatedUnion("kind", [
144
+ z.strictObject({
145
+ kind: z.literal("user"),
146
+ email: z.string().min(3).max(320).optional(),
147
+ userId: z.string().min(1).max(200).optional()
148
+ }),
149
+ z.strictObject({
150
+ kind: z.literal("project"),
151
+ project: z.string().min(1).max(200),
152
+ environments: Environments.optional()
153
+ }),
154
+ z.strictObject({
155
+ kind: z.literal("github"),
156
+ repository: z.string().min(3).max(200),
157
+ workflow: z.string().min(1).max(300).optional(),
158
+ branch: z.string().min(1).max(255).optional(),
159
+ event: z.string().min(1).max(64).optional()
160
+ }),
161
+ z.strictObject({
162
+ kind: z.literal("oidc"),
163
+ issuer: z.string().min(1).max(1e3),
164
+ claims: z.record(z.string().min(1).max(200), z.union([ClaimValue, z.array(ClaimValue).min(1).max(32)]))
165
+ }),
166
+ z.strictObject({ kind: z.literal("all-users") }),
167
+ z.strictObject({
168
+ kind: z.literal("all-projects"),
169
+ environments: Environments.optional()
170
+ }),
171
+ z.strictObject({
172
+ kind: z.literal("app"),
173
+ app: z.string().min(1).max(200)
174
+ }),
175
+ z.strictObject({ kind: z.literal("all-apps") }),
176
+ z.strictObject({ kind: z.literal("everyone") })
177
+ ]);
178
+ /** What a grant lets its principals do: a map from channel pattern to `'all'` or a list, `[]` for none. Kept as written. */
179
+ const GrantCan = z.record(z.string().min(1).max(300), CanGrant);
180
+ /** A grant: who it names, and one `can` for all of them. The same principals again are another grant. */
181
+ const GrantBody = z.strictObject({
182
+ principals: z.array(PrincipalInput).min(1).max(32),
183
+ can: GrantCan
140
184
  });
185
+ /**
186
+ * Which grant decides a channel, and what it gives, for the caller or a principal it names: a
187
+ * `user` (by email, or by ID where the board can't look one up), a `project` in one `environment`
188
+ * (production by default), a `github` repository's run (with its `workflow`, `branch`, and
189
+ * `event`), or an `oidc` issuer's token with each `claim` as `name=value`.
190
+ */
191
+ const ExplainQuery = z.object({
192
+ channel: ChannelPath,
193
+ user: z.string().min(1).max(320).optional(),
194
+ project: z.string().min(1).max(200).optional(),
195
+ environment: z.string().min(1).max(100).optional(),
196
+ github: z.string().min(3).max(200).optional(),
197
+ workflow: z.string().min(1).max(300).optional(),
198
+ branch: z.string().min(1).max(255).optional(),
199
+ event: z.string().min(1).max(64).optional(),
200
+ oidc: z.string().min(1).max(1e3).optional(),
201
+ claim: repeated.optional(),
202
+ app: z.string().min(1).max(200).optional()
203
+ }).refine((query) => [
204
+ query.user,
205
+ query.project,
206
+ query.github,
207
+ query.oidc,
208
+ query.app
209
+ ].filter((value) => value !== void 0).length <= 1, "name one principal: user, project, github, oidc, or app").refine((query) => query.environment === void 0 || query.project !== void 0, "environment goes with project").refine((query) => query.workflow === void 0 && query.branch === void 0 && query.event === void 0 || query.github !== void 0, "workflow, branch, and event go with github").refine((query) => query.claim === void 0 || query.oidc !== void 0, "claim goes with oidc");
210
+ /** A grant's change: principals to add and to remove, and a `can` to replace its own. */
211
+ const UpdateGrantBody = z.strictObject({
212
+ add: z.array(PrincipalInput).min(1).max(32).optional(),
213
+ remove: z.array(PrincipalInput).min(1).max(32).optional(),
214
+ can: GrantCan.optional()
215
+ }).refine((body) => body.add !== void 0 || body.remove !== void 0 || body.can !== void 0, "name principals to add or remove, or a can");
141
216
  /** A token acting as the caller: what it may do, and the profile and session every request with it writes as. */
142
217
  const TokenBody = z.object({
143
218
  name: z.string().regex(/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/, "a token name is up to 64 letters, numbers, and ._-"),
@@ -509,7 +584,7 @@ const routes = {
509
584
  method: "POST",
510
585
  path: "/schedules/:id/cancel"
511
586
  },
512
- /** Grants need manage in every channel. Setting one with the same issuer and claims changes its `can`. */
587
+ /** Listing grants needs manage at `*`; changing one, manage at each pattern its `can` names. Team owners always may. */
513
588
  grants: {
514
589
  method: "GET",
515
590
  path: "/grants"
@@ -519,6 +594,17 @@ const routes = {
519
594
  path: "/grants",
520
595
  body: GrantBody
521
596
  },
597
+ updateGrant: {
598
+ method: "PATCH",
599
+ path: "/grants/:id",
600
+ body: UpdateGrantBody
601
+ },
602
+ /** Which grant decides a channel, for the caller or, with `manage` at `*`, a principal it names. */
603
+ explain: {
604
+ method: "GET",
605
+ path: "/grants/explain",
606
+ query: ExplainQuery
607
+ },
522
608
  revokeGrant: {
523
609
  method: "POST",
524
610
  path: "/grants/:id/revoke"
@@ -674,7 +760,7 @@ const routes = {
674
760
  };
675
761
  //#endregion
676
762
  //#region src/version.ts
677
- const VERSION = "0.33.0";
763
+ const VERSION = "0.34.0";
678
764
  //#endregion
679
765
  //#region src/server/backend.ts
680
766
  /** The subscription sync's outbound runs on, in `BoardBinding.subscriptions`. No watcher's ID starts with `@`. */
@@ -709,6 +795,8 @@ const METHODS = [
709
795
  "cancelSchedule",
710
796
  "grants",
711
797
  "createGrant",
798
+ "updateGrant",
799
+ "explain",
712
800
  "revokeGrant",
713
801
  "tokens",
714
802
  "createToken",
@@ -1059,4 +1147,4 @@ async function withEmailMentions(text, find) {
1059
1147
  };
1060
1148
  }
1061
1149
  //#endregion
1062
- export { PostBody as A, SyncFindQuery as B, InboxNextQuery as C, LinkedQuery as D, LabelBody as E, SchedulesQuery as F, TypingBody as G, SyncReceiptBody as H, SourceJoinBody as I, UploadStartBody as K, SourceReadQuery as L, Ref as M, RegisterBody as N, MatchesQuery as O, ScheduleBody as P, SyncBody as R, InboxAckBody as S, InboxQuery as T, ThreadsQuery as U, SyncImportBody as V, TokenBody as W, CreateChannelBody as _, compileWatcher as a, EventsQuery as b, METHODS as c, queryObject as d, readCapped as f, AckBody as g, VERSION as h, canonicalWatchers as i, ReactBody as j, MessagesQuery as k, createRouter as l, SYNC as m, syncTarget as n, hasCriteria as o, readJson as p, routes as q, withEmailMentions as r, withMentions as s, mentionsEmails as t, openapi as u, DeleteBody as v, InboxPushBody as w, GrantBody as x, EditBody as y, SyncCopiesQuery as z };
1150
+ export { MessagesQuery as A, SyncCopiesQuery as B, InboxAckBody as C, LabelBody as D, InboxQuery as E, ScheduleBody as F, TokenBody as G, SyncImportBody as H, SchedulesQuery as I, UploadStartBody as J, TypingBody as K, SourceJoinBody as L, ReactBody as M, Ref as N, LinkedQuery as O, RegisterBody as P, SourceReadQuery as R, GrantBody as S, InboxPushBody as T, SyncReceiptBody as U, SyncFindQuery as V, ThreadsQuery as W, routes as Y, CreateChannelBody as _, compileWatcher as a, EventsQuery as b, METHODS as c, queryObject as d, readCapped as f, AckBody as g, VERSION as h, canonicalWatchers as i, PostBody as j, MatchesQuery as k, createRouter as l, SYNC as m, syncTarget as n, hasCriteria as o, readJson as p, UpdateGrantBody as q, withEmailMentions as r, withMentions as s, mentionsEmails as t, openapi as u, DeleteBody as v, InboxNextQuery as w, ExplainQuery as x, EditBody as y, SyncBody as z };
@@ -1,5 +1,5 @@
1
- import { l as unauthorized } from "./errors-Pk0XV1hK.mjs";
2
- import { a as VERCEL_ISSUER, f as issuerName, g as trustedIssuers, i as TOKENS, m as privateHost, p as markVerified } from "./auth-r-_PeZyw.mjs";
1
+ import { l as unauthorized } from "./errors-D8ifv16L.mjs";
2
+ import { _ as privateHost, a as VERCEL_ISSUER, b as trustedIssuers, g as markVerified, i as TOKENS, m as issuerName } from "./auth-DjoJygbG.mjs";
3
3
  import { createRemoteJWKSet, decodeJwt, jwtVerify } from "jose";
4
4
  //#region src/server/identity.ts
5
5
  let fromDisk;
@@ -398,11 +398,13 @@ write.
398
398
  replace it, so a verifier that wants it returns `request.claims.handle`
399
399
  itself. The name, profile, and `x-board-scope` the caller sends still apply
400
400
  on top of it.
401
- - **`kind: 'person'` is a full member of the board:** it may do everything,
402
- as the board's own people do. So your verifier decides who counts as one.
401
+ - **`kind: 'person'` is a person on the team:** it gets what grants give
402
+ people, as the board's own people do (g1 gives everything), and a channel
403
+ closed to `everyone` keeps it out unless a grant names it. So your verifier
404
+ decides who counts as one.
403
405
  - **Anyone else gets what grants give its ID.** A host's principal carries no
404
406
  claims past its ID, and only a deployment's, `vercel:project:<id>:<env>`,
405
- says what a grant matches: that project's Vercel grants for that
407
+ says what a grant matches: the grants naming that project in that
406
408
  environment. Any other is refused with 403. One whose `expiresAt` has passed
407
409
  is refused, and a schedule it made is canceled `revoked`.
408
410
  - **Name your principals in a scheme no sync registers.** A sync writes as
@@ -163,26 +163,27 @@ verified principal.
163
163
 
164
164
  ## Machines outside the project
165
165
 
166
- Machines outside the board's project need a [grant](./09-access.md#grants),
167
- which says what they may do in each channel. Someone with `manage` in every
168
- channel creates it on the board, and it holds from the next request:
166
+ g2 lets every project on the board's team read, post, react, and label.
167
+ Anything else outside the board's project needs a
168
+ [grant](./09-access.md#grants), which says what it may do in each channel.
169
+ Someone with `manage` where it reaches creates it on the board, and it holds
170
+ from the next request:
169
171
 
170
172
  ```text
171
- $ vb grants create vercel --claim project_id=prj_marketing --claim environment=production --can feedback/=post
172
- granted g1
173
- $ vb grants create github --claim repository=acme/www --can deploys=read,post
174
- granted g2
173
+ $ vb grants create --project prj_marketing --environment production --can feedback/=post
174
+ created g4 --project prj_marketing --environment production feedback/=post
175
+ $ vb grants create --github acme/www --can deploys=read,post
176
+ created g5 --github acme/www deploys=read,post
175
177
  ```
176
178
 
177
- - **A Vercel grant names a project by its ID,** and the environment it calls
178
- from. A GitHub grant names a repository, by `repository` or
179
- `repository_id`; only `repository_id` survives a rename.
180
- - **Grants match claims; principals record IDs.** A workflow writes as
179
+ - **A project grant names a project,** and the environments it calls from. A
180
+ GitHub grant names a repository as `owner/name`; where the board can look
181
+ it up, it keeps the repository's ID, which survives a rename.
182
+ - **Principals record IDs.** A workflow writes as
181
183
  `github:repo:<repository_id>` whatever its grant names, so a rename doesn't
182
184
  change who wrote what.
183
185
  - **A `pull_request` run's token carries `ref: refs/pull/<n>/merge`,** so a
184
- grant pinned to `--claim ref=refs/heads/main` doesn't match it. Match on
185
- `event_name` instead.
186
+ grant pinned to `--branch main` doesn't match it. Match on `--event` instead.
186
187
 
187
188
  > [!WARNING]
188
189
  > For `pull_request`, GitHub runs the workflow file from the PR's merge commit,
@@ -81,7 +81,7 @@ post there (or read the thread, for a reply) has the schedule canceled with
81
81
  it`. A schedule from before board kept its creator's claims is worked out from
82
82
  the principal ID alone, which names a deployment's project ID and environment
83
83
  and nothing of a workflow's run. So the board's own deployments in its
84
- environment, and a project a Vercel grant names, keep sending; a workflow's is
84
+ environment, and a project a grant names, keep sending; a workflow's is
85
85
  `revoked` at its next send.
86
86
 
87
87
  ## In code
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Access
3
- description: "Who may use a board, and what each caller may do in each channel: read, post, react, label, sync, or manage. Its people and its own deployments get everything, and grants and board tokens let others in while it runs. Anything out of reach answers 404."
3
+ description: "Grants say who may do what in each channel: read, post, react, label, sync, or manage, and board tokens narrow what their minter may. Anything out of reach answers 404."
4
4
  ---
5
5
 
6
6
  ## Who gets what
@@ -16,20 +16,21 @@ it answers only wake-ups and webhooks.
16
16
  Every caller is an OIDC principal. `board()` verifies it with its
17
17
  `authenticate` (see [Identity](./03-identity.md)), works out what it may do,
18
18
  then calls its backend with the caller it verified. The policy is the board's
19
- on every backend, and the backend only stores. Some get everything without
20
- asking; the rest get what grants and board tokens give them:
19
+ on every backend, and the backend only stores. The board's own code gets
20
+ everything without asking; everyone else gets what the [grants](#grants) that
21
+ name them give:
21
22
 
22
- | Caller | Default |
23
+ | Caller | On a new board |
23
24
  | --- | --- |
24
- | A person: your `vercel login`, or `vb serve`'s local user | everything |
25
+ | A person: your `vercel login`, or `vb serve`'s local user | everything, from g1 |
26
+ | A project's deployments on the board's team, the board's own previews included | read, post, react, and label everywhere, from g2 |
25
27
  | The board's own deployments in the environment it runs in | everything |
26
- | The board's own deployments in any other environment | what its [grants](#grants) give, or nothing |
27
- | Another Vercel project, a GitHub Actions workflow, any other OIDC issuer | what its grants give, or nothing |
28
+ | Another project on the team, a GitHub Actions workflow, any other OIDC issuer | what its grants give, or nothing |
28
29
  | A [board token](#tokens) | what its minter may do, narrowed to its `can` |
29
30
  | The board's own code: watchers, sync, middleware, its [handle](./01-mounting.md#the-handle) | everything |
30
31
 
31
- A token no grant lets in is refused with 403, whatever it asks, and one from
32
- an issuer no grant names with 401.
32
+ A caller that only `everyone` names is refused with 403, whatever it asks,
33
+ and one from an issuer no grant names with 401.
33
34
 
34
35
  The board's environment is the one Vercel runs it in (`VERCEL_TARGET_ENV`,
35
36
  which names custom environments, or `VERCEL_ENV`). A production board trusts
@@ -43,7 +44,7 @@ grant would let it in, as a command to run:
43
44
  "error": {
44
45
  "code": "forbidden",
45
46
  "message": "this token can't use this board: no grant lets in acme/www",
46
- "hint": "Grant it: vb grants create github --claim repository=acme/www"
47
+ "hint": "Grant it: vb grants create --github acme/www"
47
48
  }
48
49
  }
49
50
  ```
@@ -54,9 +55,10 @@ preview deployments need a grant`, with the grant for their project in
54
55
 
55
56
  ## Grants
56
57
 
57
- A grant lets callers in by their tokens: an issuer, the claims its tokens
58
- carry, and what they may do in each channel. The board keeps it, so people let
59
- a CI run or another project in while the board runs, with no deploy:
58
+ A grant names principals and says what they may do, in one `can` for all of
59
+ them: a map from [channel pattern](#channels) to permissions, `[]` for none.
60
+ Grants live on the board, so people change who gets in while it runs, with no
61
+ deploy:
60
62
 
61
63
  ```ts scripts/grants.ts
62
64
  import { board } from '@vercel/board'
@@ -64,54 +66,119 @@ import { board } from '@vercel/board'
64
66
  // The board at BOARD_URL, one that keeps grants: vb serve's, say.
65
67
  const team = board()
66
68
 
67
- // acme/web's runs report in ci/ and read the replies there.
68
- const { grant } = await team.createGrant({ issuer: 'github', claims: { repository: 'acme/web' }, can: { 'ci/': ['read', 'post'] } })
69
- // front's production deployments post feedback, and do nothing else.
70
- await team.createGrant({ issuer: 'vercel', claims: { project_id: 'prj_front', environment: 'production' }, can: { 'feedback/': ['post'] } })
69
+ // Close security/ to everyone, then open it to two people.
70
+ await team.createGrant({ principals: [{ kind: 'everyone' }], can: { 'security/': [] } })
71
+ const { grant } = await team.createGrant({ principals: [{ kind: 'user', email: 'alice@acme.com' }, { kind: 'user', email: 'bob@acme.com' }], can: { 'security/': 'all' } })
72
+ // acme/web's CI posts in ci/ from its main branch.
73
+ await team.createGrant({ principals: [{ kind: 'github', repository: 'acme/web', workflow: 'ci.yml', branch: 'main' }], can: { 'ci/': ['post'] } })
74
+ await team.updateGrant(grant.id, { add: [{ kind: 'user', email: 'carol@acme.com' }] })
71
75
  console.log(await team.grants())
72
76
  await team.revokeGrant(grant.id)
73
77
  ```
74
78
 
75
- ```text
76
- $ vb grants create github --claim repository=acme/web --can ci/=read,post
77
- granted g1
78
- $ vb grants create vercel --claim project_id=prj_www --claim environment=preview --can dev/=read
79
- granted g2
80
- $ vb grants
81
- g1 github repository=acme/web ci/=read,post
82
- g2 vercel environment=preview project_id=prj_www dev/=read
83
- $ vb grants revoke g1
84
- revoked g1
85
- ```
86
-
87
- The second lets a production board's own previews, `prj_www`'s, read `dev/`
88
- and nothing else.
89
-
90
- - **A grant is an issuer, the claims its tokens carry, and `can`.** `vercel`
91
- and `github` name those issuers; any other is an https URL on the internet,
92
- and the board fetches its keys once a grant names it, by OIDC discovery: its
93
- `/.well-known/openid-configuration` must name it as `issuer`, with a
94
- `jwks_uri` that's an https URL on the internet, and no redirect is followed. Every claim must match
95
- exactly, and a list is any of its values (`--claim` twice with one name).
96
- - **It names who it lets in.** A Vercel grant names `project_id` and
97
- `environment`, since a preview runs any branch's code, and a GitHub grant
98
- `repository` or `repository_id`: those issuers sign tokens for everyone they
99
- serve. Any other issuer's names at least one claim. A claim is any one its
100
- tokens carry: GitHub's `event_name` or `ref`, GitLab's `project_path`.
101
- - **It's for callers on the board's team.** Until cross-team access exists, a
102
- caller on another team gets in only with a [board token](#tokens) that
79
+ | Principal | Names | Level |
80
+ | --- | --- | --- |
81
+ | `user` | a person on the team, by `email`, or by `userId` on a board that verifies tokens itself | one principal |
82
+ | `project` | a project's deployments in its `environments`, by name or ID (`prj_…`) | one principal |
83
+ | `github` | GitHub Actions runs in a `repository`, narrowed by `workflow`, `branch`, or `event` | one principal |
84
+ | `oidc` | an `issuer`'s tokens that carry every one of its `claims` | one principal |
85
+ | `all-users` | every person on the team | a group |
86
+ | `all-projects` | every project's deployments on the board's team, in its `environments` | a group |
87
+ | `app` | an app on the team, by its slug or client ID (`clientId` on a board that verifies tokens itself) | one principal |
88
+ | `all-apps` | every app installed on the board's team | a group |
89
+ | `everyone` | everyone the board lets in some other way | everyone |
90
+
91
+ ### How grants combine
92
+
93
+ For a caller and a channel, among the grants that name the caller:
94
+
95
+ 1. **The most specific pattern wins:** an exact channel, then the longest
96
+ subtree, then `*`.
97
+ 2. **Among the grants naming that pattern, the closest principal wins:** one
98
+ principal, then a group, then `everyone`.
99
+ 3. **Grants tied there add up.**
100
+ 4. **A cap limits the result:** a person's team role, so a viewer reads and
101
+ reacts, or an app's scopes. A board without team roles, such as
102
+ `vb serve`'s, caps nothing.
103
+
104
+ So `everyone` with `security/=none` beside Alice's `security/=all` lets only
105
+ Alice into `security/`. A grant naming Bob on `*` doesn't help him there: the
106
+ more specific pattern decides first.
107
+
108
+ - **`explain` says which grant decides.** `team.explain('security/incidents',
109
+ { user: 'bob@acme.com' })` (`GET /grants/explain?channel=…&user=…`) answers
110
+ the pattern that won and the ones it won `over`, the level that won there,
111
+ the grants at that level or the rule in code, and what they give:
112
+ `{ channel, pattern, over, level, grants, rule, capped, can }`. Left
113
+ without a principal, it explains you. Anyone else's takes `manage` at `*`,
114
+ and so does seeing which grants decided, since a grant names everyone else
115
+ it lets in.
116
+ - **`everyone` never lets anyone in.** It only shapes what callers something
117
+ else lets in get: a person on the team, or a project or workflow a grant
118
+ names. A caller nothing else names is refused.
119
+ - **Every board starts with three grants,** as a team's board in Vercel's API
120
+ does. g1 names `all-users` with `*` at `all`, capped by role. g2 names
121
+ `all-projects` in production, preview, and development, and g3
122
+ `all-apps`, each with read, post, react, and label everywhere. A local
123
+ board has no apps, so g3 lets no one in there. Revoke or change them like
124
+ any other.
125
+ - **A person's role, and an app's scopes, cap what grants give:** a viewer
126
+ reads and reacts, and an app with only `read:messageboard` only reads.
127
+
128
+ > [!WARNING]
129
+ > g2 lets in every project on the team, previews included, and a preview runs
130
+ > any branch's code. Revoke g2, or close the channels it shouldn't reach, when
131
+ > that's too much.
132
+
133
+ - **A grant names principals by what people type.** Vercel's API looks up an
134
+ email, a project's name, and a repository, and keeps their IDs: views show
135
+ `{ userId, email }`, `{ projectId, name }`, and `{ repositoryId,
136
+ repository }`. A board that verifies tokens itself, such as `vb serve`'s,
137
+ has nothing to look names up with, so it takes a user's ID and a project's
138
+ `prj_…`, and matches a repository by the token's `repository`.
139
+ - **A project names its environments,** and `all-projects` only production,
140
+ preview, or development, since a custom environment's ID is one project's.
141
+ - **A project is its team's.** A grant keeps the board's team on each project
142
+ it names, and lets in its tokens only while they're that team's, so a
143
+ project moved to another team keeps none of its grants. A board that
144
+ doesn't know its team, such as `vb serve`'s outside a linked project, keeps
145
+ none, and lets a project in by its ID alone. Until cross-team access exists,
146
+ a caller on another team gets in only with a [board token](#tokens) that
103
147
  someone on the board's team mints for it.
104
- - **The same issuer and claims are one grant.** Setting it again changes its
105
- `can` (`updated g1`). Claims that differ, such as another environment, are
106
- another grant.
107
- - **`can` left out is read, post, react, and label everywhere,** what Vercel's
108
- API gives a project it lets use a board.
109
- - **Grants add up.** A caller gets what every grant that matches its token
110
- gives. People and the board's own deployments where it runs are never a
111
- grant's: they have everything already.
112
- - **Grants are the board's bookkeeping:** setting, listing, and revoking them
113
- takes `manage` in every channel. A revoke holds from the next request, and a
114
- schedule a principal made stops as any creator's does when it loses access.
148
+ - **A GitHub principal matches a run's token:** `workflow` by the
149
+ token's `workflow_ref` (`ci.yml` is `.github/workflows/ci.yml`), `branch` as
150
+ `refs/heads/<branch>`, and `event` by `event_name`.
151
+ - **An `oidc` issuer is an https URL on the internet,** and the board fetches
152
+ its keys once a grant names it, by OIDC discovery: its
153
+ `/.well-known/openid-configuration` must name it as `issuer`, with a
154
+ `jwks_uri` that's an https URL on the internet, and no redirect is followed.
155
+ Every claim must match exactly, and a list is any of its values. Vercel's
156
+ and GitHub's issuers have kinds of their own.
157
+ - **The same principals again are another grant.** Change one by its ID:
158
+ `updateGrant(id, { add, remove, can })` adds principals, removes them by who
159
+ they are (a project whatever its environments), and replaces its `can`.
160
+ Adding a project it names already adds its environments; to narrow one,
161
+ remove it and add it back in the same update.
162
+ - **You can't grant what you don't have:** your token's and your own grants'
163
+ limits count, an `everyone` lock doesn't, and anyone you let in gets what
164
+ `everyone` gets. So making or widening a grant takes `manage` at each pattern
165
+ it names, and under each wherever your own limits narrow you, and you let no
166
+ one in while `everyone` gets something somewhere that you don't.
167
+ - **Revoking a grant, or removing from one, is judged the same way,** since
168
+ lifting what it held back widens whoever it named: `manage` at its patterns,
169
+ and under each wherever your own limits narrow you. It lets no one new in,
170
+ so what `everyone` gets doesn't count.
171
+ - **Naming an `oidc` principal takes `manage` everywhere,** since the board
172
+ then fetches its issuer's keys. Listing grants takes `manage` at `*`.
173
+ - **Owners always may.** On Vercel's API, the team's owners. On a local board,
174
+ its local user, the one `vb serve` mints a token for: a person on the team
175
+ is a principal like any other. Reading a closed channel still takes a
176
+ grant, an owner's too.
177
+ - **A grant takes only the keys it knows.** A misspelled one, `workflows` for
178
+ `workflow` say, is 400, never dropped, so a grant never names more than you
179
+ wrote.
180
+ - **A revoke holds from the next request,** and a schedule a principal made
181
+ stops as any creator's does when it loses access.
115
182
 
116
183
  ## Tokens
117
184
 
@@ -217,7 +284,10 @@ through the binding's `handle(caller)`, so the middleware sees it.
217
284
  | --- | --- |
218
285
  | `oidcTokens(options?)` | An `authenticate`: the OIDC tokens made out to this board. It verifies a request's bearer token for its audience, from Vercel, GitHub Actions, an issuer a grant names (`board.issuers`), or `local` (`vb serve`'s). Null with no token, a 401 for a bad one. Without `board`, the project is the environment's. `board()`'s default |
219
286
  | `resolveActor(principal, claims, audience)` | The actor a caller writes as: `vercel:user:u_123+claude` for a profile, a person's handle and name from their claims |
220
- | `compileAccess(can)`, `union(accesses)`, `FULL_ACCESS` | What a `can` allows on its own, as an `Access`: `can(permission, channel)`, `readable(channel)`, `everywhere(permission)`, `summary()` for `me`, and `narrow(scope)` to keep only what both allow. `union` adds up what several allow, as grants do: accesses from `compileAccess`, `union`, or `narrow`, and anything else counts as nothing. Each is frozen. A bad pattern or permission throws. For a backend that checks a caller against a `can` of its own |
287
+ | `compileAccess(can)`, `union(accesses)`, `FULL_ACCESS` | What a `can` allows on its own, as an `Access`: `can(permission, channel)`, `readable(channel)`, `everywhere(permission)`, `summary()` for `me`, and `narrow(scope)` to keep only what both allow. `union` adds up what several allow, as tied grants do: accesses from `compileAccess`, `union`, or `narrow`, and anything else counts as nothing. Each is frozen. A bad pattern or permission throws `InvalidCan`. For a backend that checks a caller against a `can` of its own |
288
+ | `grantAccess(facts)` | What a caller may do by a board's grants, from plain data: `caller`, all of it, and `own`, without `everyone`'s grants, or null when nothing lets it in. `facts` is the `caller` (`{ kind: 'user', userId }`, a project in an environment, a run, an issuer's token, or `{ kind: 'app', clientId }`), the `grants`, whether the caller is on the team (`member`, `teamProject`, `teamApp`, booleans), a `cap`, the most the caller may do (`['read', 'react']` for a viewer), and a token's `can` |
289
+ | `checkGrantChange({ caller, own, owner, after, changed, revoked })` | Whether a caller may change grants so, as a board checks it: null, or `{ reason, pattern, permission }`, `reach` at a spot it can't manage and `admission` at one where `everyone` gets what it doesn't have. `caller` is its access as `GET /me` says and `own` the same without `everyone`'s grants, `after` every grant as the change leaves them, `changed` a grant made or widened, and `revoked` one revoked, removed from, or updated, as it was. It does no I/O, so a backend that keeps grants runs the same rule |
290
+ | `InvalidCan` | What a `can`, a pattern, or a permission that doesn't parse throws, with `code` `invalid_can`, for a backend to answer 400 |
221
291
  | `DEFAULT_CAN` | The `can` a grant or a token gets when it names none: `{ '*': ['read', 'post', 'react', 'label'] }` |
222
292
 
223
293
  ## Permissions
@@ -370,6 +440,16 @@ left out for full access. `GET /me` returns the same as `can`.
370
440
 
371
441
  ## FAQ
372
442
 
443
+ ### Why can't I make a grant on `*`?
444
+
445
+ It would give whoever it names a channel you're kept out of. A grant on you,
446
+ your token's `can`, or an `everyone` grant that gives more than you have
447
+ somewhere keeps you from making it. A channel closed to everyone (`everyone`
448
+ at `security/` with nothing) doesn't: it stays closed to whoever you name,
449
+ and opens to them only as it opens to you, so grants on `*` stay yours to
450
+ make. A grant on `security/` itself doesn't: it would meet the lock there and
451
+ win, being closer. The board's owners always may.
452
+
373
453
  ### How do I keep a channel from the project's own people?
374
454
 
375
455
  You can't, on one board: people who can access the board's Vercel project can
@@ -391,6 +471,7 @@ all of them. They don't say where or what.
391
471
 
392
472
  Yes: a [board token](#tokens), which you mint, list, and revoke, and which
393
473
  lives 90 days at most. Callers with an OIDC token need none: a
394
- [grant](#grants) lets them in by their claims, each living as long as its
395
- token. A credential of your own, such as a session cookie, takes
474
+ [grant](#grants) names them, a project, a repository's runs, or an issuer's
475
+ claims, and each token lives as long as it does. A credential of your own,
476
+ such as a session cookie, takes
396
477
  [a verifier of your own](./01-mounting.md#callers-of-your-own).