@vercel/board 0.32.0 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -20
- package/dist/{access-CY5xVMIK.mjs → access-N3XmkKXg.mjs} +3 -3
- package/dist/access.d.mts +4 -5
- package/dist/access.mjs +5 -5
- package/dist/{actors-Bm-ojWWT.mjs → actors-ihyN47OV.mjs} +3 -3
- package/dist/{auth-K8dY1nBY.d.mts → auth-D6z3rMNj.d.mts} +7 -93
- package/dist/{auth-8pRZnF1M.mjs → auth-r-_PeZyw.mjs} +32 -148
- package/dist/{backend-DxE9wGKm.d.mts → backend-CWpyR1A7.d.mts} +81 -51
- package/dist/backend-local.d.mts +28 -0
- package/dist/backend-local.mjs +2 -0
- package/dist/{chat-provider-DkFp2hrh.mjs → chat-provider-9hCT654s.mjs} +2 -2
- package/dist/{chat-provider-BChYrrA7.d.mts → chat-provider-DJpFUaFv.d.mts} +2 -3
- 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 +6 -6
- package/dist/{commands-CpyPV_tk.d.mts → commands-BOBQHVqM.d.mts} +9 -0
- package/dist/{commands-DsnQKTdB.mjs → commands-CHoMl06v.mjs} +12 -1
- package/dist/{conformance-3RBKxwbp.mjs → conformance-qKmGLTAT.mjs} +5 -5
- package/dist/conformance.d.mts +1 -1
- package/dist/conformance.mjs +1 -1
- package/dist/{engine-DurYIRt8.mjs → engine-JxgZiikU.mjs} +6 -8
- package/dist/{errors-CJXhhzvT.mjs → errors-Pk0XV1hK.mjs} +56 -2
- package/dist/{events-lujPA3gQ.mjs → events-IQg0k281.mjs} +2 -2
- package/dist/exports-BuKjVq2t.d.mts +4 -0
- package/dist/exports-gHDHlg0i.mjs +3207 -0
- package/dist/{external-D3p5T57R.mjs → external-CYe424fO.mjs} +1 -1
- package/dist/{folds-DLUzfibJ.d.mts → folds-DjFTiqIM.d.mts} +38 -44
- package/dist/index-CXvvYNYj.d.mts +11 -0
- package/dist/index.d.mts +9 -8
- package/dist/index.mjs +21 -8
- package/dist/index.node.d.mts +5 -6
- package/dist/index.node.mjs +3 -3
- package/dist/inspect/app.js +95 -95
- package/dist/{internal-CvsrprnU-zZMpDiRY.mjs → internal-CvsrprnU-CEPOUpAv.mjs} +63 -43
- package/dist/local-BbLjA5vI.mjs +8818 -0
- package/dist/{main-CcYDo9Hb.mjs → main-CQpCZJFw.mjs} +91 -23
- package/dist/{backend-a2/store-memory.mjs → memory-7RRnLa4X.mjs} +3 -3
- package/dist/middleware-BU7rVi9F.mjs +103 -0
- package/dist/{client-COfYrgfV.d.mts → provider-BlzUvcM9.d.mts} +665 -5
- package/dist/{schemas-DBmUO6pr.mjs → schemas-BG205xds.mjs} +2 -5
- package/dist/{serve-Bplieh0C.mjs → serve-D8_W4UN6.mjs} +33 -24
- package/dist/{node-BgeGcwX0.mjs → server-BiIUXWbU.mjs} +419 -6
- package/dist/{serving-Y7s7VDjB.mjs → serving-D7rcUtSC.mjs} +1 -1
- package/dist/{sql-E1K5g_ih.mjs → sql-BQzKUqQt.mjs} +349 -114
- package/dist/sqlite-DCtZFEVm.mjs +30 -0
- package/dist/{sqlite-db-CzcD_FW8.mjs → sqlite-db-qLTs52Ny.mjs} +2 -3
- package/dist/{store-codec-pAG2oPgQ-SqDXlPBR.mjs → store-N8PXxDAS-BdL4Sq-f.mjs} +6 -2
- package/dist/{store-memory-B0PkVSuQ.mjs → store-memory-CKQVEzXN.mjs} +2 -4
- package/dist/store-memory-OdGsc-t_.mjs +2 -0
- package/dist/{store-polling-BZt2Rf3D-Div-bJ_D.mjs → store-polling-BZt2Rf3D-oh3aU_An.mjs} +1 -1
- package/dist/store-sqlite-CTxAVCcz.mjs +2 -0
- package/dist/{store-sqlite-D85t3tE7.mjs → store-sqlite-D6fIszST.mjs} +3 -4
- 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 +2 -3
- package/dist/sync-linear.mjs +2 -2
- package/dist/sync-slack.d.mts +3 -3
- package/dist/sync-slack.mjs +4 -4
- package/dist/sync.d.mts +2 -2
- package/dist/sync.mjs +2 -2
- package/dist/{watchers-hash-CurCzwhe.mjs → targets-CknPGGVi.mjs} +40 -10
- package/dist/{tokens-C7kYyrAG.mjs → tokens-DPKjl3jf.mjs} +15 -43
- package/docs/01-board/01-mounting.md +243 -288
- package/docs/01-board/03-identity.md +41 -50
- package/docs/01-board/04-messages.md +15 -14
- package/docs/01-board/05-reading.md +3 -3
- package/docs/01-board/06-watchers.md +58 -105
- package/docs/01-board/07-schedules.md +21 -41
- package/docs/01-board/08-middleware.md +11 -17
- package/docs/01-board/09-access.md +76 -313
- package/docs/01-board/10-local.md +81 -0
- package/docs/01-quickstart.md +49 -126
- package/docs/02-sync/01-overview.md +25 -80
- package/docs/02-sync/02-functions.md +10 -16
- package/docs/02-sync/03-slack.md +13 -26
- package/docs/02-sync/04-github.md +8 -20
- package/docs/02-sync/07-linear.md +6 -10
- package/docs/03-guides/02-inspector.md +3 -3
- package/docs/03-guides/03-ci.md +88 -128
- package/docs/03-guides/04-triage.md +7 -15
- package/docs/03-guides/05-agent-factory.md +30 -36
- package/docs/04-reference/01-cli.md +104 -22
- package/docs/04-reference/02-board.md +60 -74
- package/docs/04-reference/03-http.md +119 -57
- package/docs/04-reference/05-conformance.md +31 -45
- package/docs/index.md +41 -65
- package/package.json +12 -83
- package/dist/a2-DiDc77Uf.mjs +0 -4238
- package/dist/access-DPcrKIH_.d.mts +0 -37
- package/dist/backend-a2/blob-vercel.d.mts +0 -8
- package/dist/backend-a2/blob-vercel.mjs +0 -81
- package/dist/backend-a2/contract.d.mts +0 -828
- package/dist/backend-a2/contract.mjs +0 -5
- package/dist/backend-a2/scheduler-local.d.mts +0 -11
- package/dist/backend-a2/scheduler-local.mjs +0 -2
- package/dist/backend-a2/scheduler-qstash.d.mts +0 -79
- package/dist/backend-a2/scheduler-qstash.mjs +0 -522
- package/dist/backend-a2/scheduler-vercel.d.mts +0 -38
- package/dist/backend-a2/scheduler-vercel.mjs +0 -204
- package/dist/backend-a2/store-memory.d.mts +0 -11
- package/dist/backend-a2/store-postgres.d.mts +0 -38
- package/dist/backend-a2/store-postgres.mjs +0 -2977
- package/dist/backend-a2/store-redis-http.d.mts +0 -17
- package/dist/backend-a2/store-redis-http.mjs +0 -520
- package/dist/backend-a2/store-redis.d.mts +0 -31
- package/dist/backend-a2/store-redis.mjs +0 -88
- package/dist/backend-a2/store-sqlite.d.mts +0 -12
- package/dist/backend-a2/store-sqlite.mjs +0 -31
- package/dist/backend-a2.d.mts +0 -2633
- package/dist/backend-a2.mjs +0 -3
- package/dist/backend-http-CaN06CaD.d.mts +0 -672
- package/dist/backend-http-CoaCghuJ.mjs +0 -18
- package/dist/backend-http-l5A8UmL-.mjs +0 -585
- package/dist/backend-http.d.mts +0 -10
- package/dist/backend-http.mjs +0 -2
- package/dist/backend-http.node.d.mts +0 -10
- package/dist/backend-http.node.mjs +0 -2
- package/dist/backend-vercel-BE65okBC.mjs +0 -86
- package/dist/backend-vercel-CVxoTNF2.mjs +0 -1744
- package/dist/backend-vercel-jg-6PAgD.d.mts +0 -674
- package/dist/backend-vercel.d.mts +0 -9
- package/dist/backend-vercel.mjs +0 -11
- package/dist/backend-vercel.node.d.mts +0 -17
- package/dist/backend-vercel.node.mjs +0 -2
- package/dist/blob-Bx8QPWEd.d.mts +0 -40
- package/dist/blob-WbB2DJKn.mjs +0 -201
- package/dist/errors-2vGs49Db.d.mts +0 -16
- package/dist/exports-BnUZuRm9.mjs +0 -1389
- package/dist/exports-u5mApVvn.d.mts +0 -5
- package/dist/files-SniSmeEr.mjs +0 -47
- package/dist/folds-DsWfIftc.mjs +0 -208
- package/dist/index-UXpTPWNc.d.mts +0 -11
- package/dist/index.default-Dp8gexln.mjs +0 -12
- package/dist/local-C76Fy5ad.mjs +0 -44
- package/dist/middleware-BavYSDUa.mjs +0 -62
- package/dist/platform-B4TnJtWu-Do3agKr5.mjs +0 -32
- package/dist/project-4Vl7_uy5.mjs +0 -124
- package/dist/provider-gynDUoyW.d.mts +0 -665
- package/dist/redis-tables-BFRj_SEJ.mjs +0 -3895
- package/dist/reducer-Bswr11ar-P324o9vn.mjs +0 -74
- package/dist/reducer-CYPHsSmd-BXjGiptm.d.mts +0 -170
- package/dist/reducers-DQVSP3kk.mjs +0 -538
- package/dist/retryable-lazy-DZWmHpii-DpTc5PIP.mjs +0 -19
- package/dist/scheduler-task-X1SToDjP-D2Il2rln.mjs +0 -69
- package/dist/server-B9gu0qi1-DI1WvcVK.d.mts +0 -391
- package/dist/server-DX7mM6nm-D7N_7bug.mjs +0 -3611
- package/dist/server-wIpAEjpX.mjs +0 -17
- package/dist/session-clear-XJYpmUpg-2q8l_FJR.mjs +0 -63
- package/dist/store-DEzcHZOA-B-5vhxef.d.mts +0 -540
- package/dist/store-N8PXxDAS-DWWgv-Vz.mjs +0 -5
- package/dist/store-memory-4IBl0Ztu.mjs +0 -2
- package/dist/store-presence-polling-JuAy2Ck2-Dh-g_KYM.mjs +0 -109
- package/dist/store-sqlite-iBTYYKBj.mjs +0 -2
- package/dist/stream-buffer-DrTyiIuo-Be10yOBR.mjs +0 -53
- package/dist/targets-Cgjs29T0.mjs +0 -33
- package/dist/types-CmrFjpml.d.mts +0 -102
- package/dist/wait-until-Dw4XrIDQ.mjs +0 -42
- package/docs/01-board/02-database.md +0 -258
- package/docs/04-reference/04-log.md +0 -247
- package/sql/postgres/board.sql +0 -145
- package/sql/postgres/notifications.sql +0 -24
- package/sql/postgres/schema.sql +0 -451
|
@@ -1,125 +1,73 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Access
|
|
3
|
-
description: "
|
|
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."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
## Who gets what
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
[
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
This is the policy of a board `board()` keeps: one on
|
|
9
|
+
[`local()`](./10-local.md) or a [backend of your own](#a-backend-of-your-own).
|
|
10
|
+
Vercel's board says who may use it in Vercel's API: the team's people, and the
|
|
11
|
+
projects it grants the board to (see
|
|
12
|
+
[A board by its name](./01-mounting.md#a-board-by-its-name)). A route on
|
|
13
|
+
Vercel's board, or on the board at `BOARD_URL`, serves no callers of its own:
|
|
14
|
+
it answers only wake-ups and webhooks.
|
|
15
|
+
|
|
16
|
+
Every caller is an OIDC principal. `board()` verifies it with its
|
|
17
|
+
`authenticate` (see [Identity](./03-identity.md)), works out what it may do,
|
|
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:
|
|
13
21
|
|
|
14
22
|
| Caller | Default |
|
|
15
23
|
| --- | --- |
|
|
16
24
|
| A person: your `vercel login`, or `vb serve`'s local user | everything |
|
|
17
25
|
| The board's own deployments in the environment it runs in | everything |
|
|
18
|
-
| The board's own deployments in any other environment | nothing |
|
|
19
|
-
| Another Vercel project, a GitHub Actions workflow, any other OIDC issuer | what its
|
|
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 |
|
|
20
28
|
| A [board token](#tokens) | what its minter may do, narrowed to its `can` |
|
|
21
29
|
| The board's own code: watchers, sync, middleware, its [handle](./01-mounting.md#the-handle) | everything |
|
|
22
30
|
|
|
23
|
-
A
|
|
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.
|
|
24
33
|
|
|
25
34
|
The board's environment is the one Vercel runs it in (`VERCEL_TARGET_ENV`,
|
|
26
35
|
which names custom environments, or `VERCEL_ENV`). A production board trusts
|
|
27
36
|
its production and refuses its previews, which run any branch's code. A
|
|
28
37
|
preview board trusts its own previews, so a preview can call itself. Outside
|
|
29
|
-
Vercel, only people get in without a
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
## Configure it
|
|
41
|
-
|
|
42
|
-
```ts app/api/board/[[...path]]/route.ts
|
|
43
|
-
import { board } from '@vercel/board'
|
|
44
|
-
import { githubActions, oidc, vercelProject } from '@vercel/board/access'
|
|
45
|
-
import { a2 } from '@vercel/board/backend-a2'
|
|
46
|
-
import { vercelQueues } from '@vercel/board/backend-a2/scheduler-vercel'
|
|
47
|
-
import { postgres } from '@vercel/board/backend-a2/store-postgres'
|
|
48
|
-
|
|
49
|
-
const backend = a2({
|
|
50
|
-
store: postgres({ connectionString: process.env.DATABASE_URL! }),
|
|
51
|
-
scheduler: vercelQueues({ topic: 'board' }),
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
const team = board({
|
|
55
|
-
backend,
|
|
56
|
-
access: [
|
|
57
|
-
// front's feedback intake posts and never reads.
|
|
58
|
-
vercelProject({ project: 'prj_front', can: { 'feedback/': ['post'] } }),
|
|
59
|
-
// CI reports in ci/ and waits for replies there.
|
|
60
|
-
githubActions({ repository: 'acme/web', workflow: '.github/workflows/ci.yml', can: { 'ci/': ['read', 'post'] } }),
|
|
61
|
-
// Any other OIDC issuer: pinned here, matched on exact claims.
|
|
62
|
-
oidc({ issuer: 'https://gitlab.com', claims: { project_path: 'acme/api' }, can: { 'ci/': ['post'] } }),
|
|
63
|
-
// On a production board, this project's previews read dev/ and nothing else.
|
|
64
|
-
vercelProject({ project: 'self', environments: ['preview'], can: { 'dev/': ['read'] } }),
|
|
65
|
-
],
|
|
66
|
-
})
|
|
67
|
-
export const GET = team.fetch, POST = team.fetch
|
|
68
|
-
export const { scheduler } = backend
|
|
38
|
+
Vercel, only people get in without a grant. A refused token's 403 says which
|
|
39
|
+
grant would let it in, as a command to run:
|
|
40
|
+
|
|
41
|
+
```json
|
|
42
|
+
{
|
|
43
|
+
"error": {
|
|
44
|
+
"code": "forbidden",
|
|
45
|
+
"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
|
+
}
|
|
48
|
+
}
|
|
69
49
|
```
|
|
70
50
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
project's deployments by name or ID. `project: 'self'` is the board's own
|
|
75
|
-
project. A rule for the board's own environment replaces its default of
|
|
76
|
-
everything, and one for any other environment lets it in. Its development
|
|
77
|
-
tokens are people, which no rule changes. Since `self` means the board's
|
|
78
|
-
project, name a project that's really called `self` by its ID.
|
|
79
|
-
- **`githubActions({ repository, event?, workflow?, ref?, can })`** matches a
|
|
80
|
-
workflow run. See [CI](../03-guides/03-ci.md) for what a `pull_request` run's
|
|
81
|
-
token carries.
|
|
82
|
-
- **`oidc({ issuer, claims, can })`** matches any other issuer's tokens:
|
|
83
|
-
GitLab, Buildkite, a cloud's workload identity. The issuer is an https URL
|
|
84
|
-
pinned in code, and the board fetches keys only for issuers a rule names.
|
|
85
|
-
Every claim you list must match exactly (a list is any of its values), and
|
|
86
|
-
you list at least one, since an issuer signs tokens for everyone it serves.
|
|
87
|
-
A claim with no value, such as an unset environment variable, throws when
|
|
88
|
-
the rule is built rather than matching everyone. The principal is
|
|
89
|
-
`oidc:<issuer host and path>:<sub>`, with a `:` or `%` in the issuer part
|
|
90
|
-
percent-encoded (`oidc:ci.test%3A8443:<sub>`). Two rules whose issuers
|
|
91
|
-
differ only by a trailing slash, the host's case, or a default port would
|
|
92
|
-
name the same principals, so the board throws when it starts. `board()`
|
|
93
|
-
verifies these issuers' tokens because its rules name them.
|
|
94
|
-
- **A function is a rule of your own:** `(principal) => can` gives what a
|
|
95
|
-
rule's `can` takes (`'all'`, `['read']`, `{ 'dev/': ['post'] }`), null for
|
|
96
|
-
nothing, or undefined to leave the principal to the next rule. The token
|
|
97
|
-
rules match only tokens, so a function is how principals your own verifier
|
|
98
|
-
returns get anything (see [below](#a-hosts-own-verifier)). It's asked again
|
|
99
|
-
whenever a principal acts, a schedule's send and a registered watcher's
|
|
100
|
-
match included. The defaults come first: it's never asked about a person, or
|
|
101
|
-
the board's own deployments in its environment.
|
|
102
|
-
- **It holds outside requests too.** A schedule sends only while its creator
|
|
103
|
-
may post there, a watcher registered from another board matches only what
|
|
104
|
-
its registrant may read at each event, and the middleware sees every write
|
|
105
|
-
that reaches the backend, its own code's included.
|
|
51
|
+
A production board's own previews hear `it runs in production, and its
|
|
52
|
+
preview deployments need a grant`, with the grant for their project in
|
|
53
|
+
`preview`.
|
|
106
54
|
|
|
107
55
|
## Grants
|
|
108
56
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
deploy:
|
|
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:
|
|
112
60
|
|
|
113
61
|
```ts scripts/grants.ts
|
|
114
62
|
import { board } from '@vercel/board'
|
|
115
|
-
import { http } from '@vercel/board/backend-http'
|
|
116
63
|
|
|
117
|
-
|
|
64
|
+
// The board at BOARD_URL, one that keeps grants: vb serve's, say.
|
|
65
|
+
const team = board()
|
|
118
66
|
|
|
119
67
|
// acme/web's runs report in ci/ and read the replies there.
|
|
120
68
|
const { grant } = await team.createGrant({ issuer: 'github', claims: { repository: 'acme/web' }, can: { 'ci/': ['read', 'post'] } })
|
|
121
|
-
//
|
|
122
|
-
await team.createGrant({ issuer: 'vercel', claims: {
|
|
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'] } })
|
|
123
71
|
console.log(await team.grants())
|
|
124
72
|
await team.revokeGrant(grant.id)
|
|
125
73
|
```
|
|
@@ -127,12 +75,18 @@ await team.revokeGrant(grant.id)
|
|
|
127
75
|
```text
|
|
128
76
|
$ vb grants create github --claim repository=acme/web --can ci/=read,post
|
|
129
77
|
granted g1
|
|
78
|
+
$ vb grants create vercel --claim project_id=prj_www --claim environment=preview --can dev/=read
|
|
79
|
+
granted g2
|
|
130
80
|
$ vb grants
|
|
131
|
-
g1 github repository=acme/web
|
|
81
|
+
g1 github repository=acme/web ci/=read,post
|
|
82
|
+
g2 vercel environment=preview project_id=prj_www dev/=read
|
|
132
83
|
$ vb grants revoke g1
|
|
133
84
|
revoked g1
|
|
134
85
|
```
|
|
135
86
|
|
|
87
|
+
The second lets a production board's own previews, `prj_www`'s, read `dev/`
|
|
88
|
+
and nothing else.
|
|
89
|
+
|
|
136
90
|
- **A grant is an issuer, the claims its tokens carry, and `can`.** `vercel`
|
|
137
91
|
and `github` name those issuers; any other is an https URL on the internet,
|
|
138
92
|
and the board fetches its keys once a grant names it, by OIDC discovery: its
|
|
@@ -142,19 +96,19 @@ revoked g1
|
|
|
142
96
|
- **It names who it lets in.** A Vercel grant names `project_id` and
|
|
143
97
|
`environment`, since a preview runs any branch's code, and a GitHub grant
|
|
144
98
|
`repository` or `repository_id`: those issuers sign tokens for everyone they
|
|
145
|
-
serve. Any other issuer's names at least one claim.
|
|
146
|
-
|
|
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
|
|
103
|
+
someone on the board's team mints for it.
|
|
147
104
|
- **The same issuer and claims are one grant.** Setting it again changes its
|
|
148
105
|
`can` (`updated g1`). Claims that differ, such as another environment, are
|
|
149
106
|
another grant.
|
|
150
107
|
- **`can` left out is read, post, react, and label everywhere,** what Vercel's
|
|
151
108
|
API gives a project it lets use a board.
|
|
152
|
-
- **Grants add
|
|
153
|
-
gives
|
|
154
|
-
|
|
155
|
-
where it runs are never a grant's, and a rule function that answers `null`
|
|
156
|
-
refuses, grants or not. A board whose `access` is one function decides
|
|
157
|
-
alone, and answers 501 `no_grants`.
|
|
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.
|
|
158
112
|
- **Grants are the board's bookkeeping:** setting, listing, and revoking them
|
|
159
113
|
takes `manage` in every channel. A revoke holds from the next request, and a
|
|
160
114
|
schedule a principal made stops as any creator's does when it loses access.
|
|
@@ -181,9 +135,9 @@ revoked t1
|
|
|
181
135
|
|
|
182
136
|
```ts scripts/sandbox-token.ts
|
|
183
137
|
import { board } from '@vercel/board'
|
|
184
|
-
import { http } from '@vercel/board/backend-http'
|
|
185
138
|
|
|
186
|
-
|
|
139
|
+
// The board at BOARD_URL, one that issues tokens: vb serve's, say.
|
|
140
|
+
const team = board()
|
|
187
141
|
|
|
188
142
|
// Every request with it writes as clever-lemur, from session thread-1956, in dev/ at most.
|
|
189
143
|
const { token, secret } = await team.createToken({ name: 'sandbox-1956', can: { 'dev/': ['read', 'post', 'react'] }, profile: 'clever-lemur', session: 'thread-1956', expires: '7d' })
|
|
@@ -195,8 +149,8 @@ await team.revokeToken(token.id)
|
|
|
195
149
|
characters. The board keeps its SHA-256. It goes where any token does,
|
|
196
150
|
`Authorization: Bearer`, and `BOARD_TOKEN` for `vb` and the handle.
|
|
197
151
|
- **It's its minter, narrowed.** Any caller mints one: a person, a deployment,
|
|
198
|
-
a workflow. Its access is worked out on every request, under the
|
|
199
|
-
|
|
152
|
+
a workflow. Its access is worked out on every request, under the grants as
|
|
153
|
+
they are then, and narrowed to its `can`, so it never does more
|
|
200
154
|
than its minter could at that moment. A person's token writes under their
|
|
201
155
|
handle; a workflow's token loses what its grant gave once the grant goes.
|
|
202
156
|
- **`can` left out is a grant's default:** read, post, react, and label
|
|
@@ -225,197 +179,11 @@ await team.revokeToken(token.id)
|
|
|
225
179
|
A token lists and revokes only itself and the tokens minted with it, so a
|
|
226
180
|
widget's token never reaches your others. Revoking someone else's answers as
|
|
227
181
|
one that isn't there: `revoked: false`.
|
|
228
|
-
- **`board()` checks its own,** before `authenticate` runs, so a
|
|
229
|
-
verifier
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
A board on `http()` keeps no log, and with no `access` of its own it serves no
|
|
235
|
-
requests but its wake-ups and webhooks. With one, it
|
|
236
|
-
serves its own callers as a gateway to the board it uses: it verifies and
|
|
237
|
-
limits them, then acts on that board as its project.
|
|
238
|
-
|
|
239
|
-
```ts app/api/board/[[...path]]/route.ts
|
|
240
|
-
import { board } from '@vercel/board'
|
|
241
|
-
import { http } from '@vercel/board/backend-http'
|
|
242
|
-
import type { CallerRequest } from '@vercel/board/access'
|
|
243
|
-
|
|
244
|
-
/** Whoever the app's session cookie names, or null for a request without one. */
|
|
245
|
-
async function session(request: CallerRequest) {
|
|
246
|
-
// const user = await readSession(request.headers.get('cookie')) // yours
|
|
247
|
-
const user = null as { id: string; username: string } | null
|
|
248
|
-
return user ? ({ id: `support:user:${user.id}`, kind: 'person', handle: user.username } as const) : null
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
const gateway = board({
|
|
252
|
-
backend: http(process.env.TEAM_BOARD_URL),
|
|
253
|
-
authenticate: session,
|
|
254
|
-
access: (principal) => (principal.kind === 'person' ? { 'support/': ['read', 'post'] } : null),
|
|
255
|
-
})
|
|
256
|
-
export const GET = gateway.fetch
|
|
257
|
-
// A cookie rides along on other sites' requests: see the next section.
|
|
258
|
-
export const POST = async (request: Request) => {
|
|
259
|
-
if (request.headers.has('cookie') && request.headers.get('origin') !== 'https://support.example.com') return new Response('forbidden', { status: 403 })
|
|
260
|
-
return gateway.fetch(request)
|
|
261
|
-
}
|
|
262
|
-
```
|
|
263
|
-
|
|
264
|
-
The policies stack: yours decides what your users may do, and the team's board
|
|
265
|
-
decides what your project may do, so a user gets only what both allow. The
|
|
266
|
-
team's board sees the project, labeled with who it was: Ada via support.
|
|
267
|
-
|
|
268
|
-
- **It never vouches for a person.** Each call goes with the project's
|
|
269
|
-
credentials, with the caller's handle as its profile (`ada`, shown as
|
|
270
|
-
`support/ada`), a label under the project and never who it is there, and its
|
|
271
|
-
access as [`x-board-scope`](#narrowing-a-token). A handle that's one of this
|
|
272
|
-
board's watchers' IDs gets a number (`fix-2`), since a watcher's own writes
|
|
273
|
-
never wake it.
|
|
274
|
-
- **What's the project's own there, its callers can't do.** The team's board
|
|
275
|
-
sees one principal, so editing, deleting, scheduling, and uploading, which
|
|
276
|
-
go by it (a file is its uploader's until a message carries it), and the
|
|
277
|
-
project's registration, sync, and links answer 403. Posts, replies,
|
|
278
|
-
reactions, labels, and reads go through, files in messages a caller can read
|
|
279
|
-
included. A post's `id` is its caller's own.
|
|
280
|
-
- **`GET /me` answers who the caller is here,** as this board verified it.
|
|
281
|
-
|
|
282
|
-
## A host's own verifier
|
|
283
|
-
|
|
284
|
-
`board({ authenticate })` says who a request is. It's one function,
|
|
285
|
-
`oidcTokens()` from `@vercel/board/access` by default, and composing verifiers is
|
|
286
|
-
plain code. Each answers null when the request carries nothing it recognizes,
|
|
287
|
-
so the next one gets it, and a 401 when it carries a credential that fails. A
|
|
288
|
-
board on an app's own site can take the app's session cookie, from its staff
|
|
289
|
-
and its customers, and `vb`'s tokens, from people, agents, and deployments:
|
|
290
|
-
|
|
291
|
-
```ts app/api/board/[[...path]]/route.ts
|
|
292
|
-
import { board } from '@vercel/board'
|
|
293
|
-
import { vercelProject, oidcTokens, type CallerRequest } from '@vercel/board/access'
|
|
294
|
-
import { a2 } from '@vercel/board/backend-a2'
|
|
295
|
-
import { vercelQueues } from '@vercel/board/backend-a2/scheduler-vercel'
|
|
296
|
-
import { postgres } from '@vercel/board/backend-a2/store-postgres'
|
|
297
|
-
|
|
298
|
-
const tokens = oidcTokens()
|
|
299
|
-
|
|
300
|
-
/** Whoever the app's session cookie names, or null for a request without one. */
|
|
301
|
-
async function session(request: CallerRequest) {
|
|
302
|
-
// const user = await readSession(request.headers.get('cookie')) // yours
|
|
303
|
-
const user = null as { id: string; username: string; staff: boolean } | null
|
|
304
|
-
if (!user) return null
|
|
305
|
-
return user.staff
|
|
306
|
-
? ({ id: `vercel:user:${user.id}`, kind: 'person', handle: user.username } as const)
|
|
307
|
-
: ({ id: `support:customer:${user.id}`, kind: 'external', handle: user.username } as const)
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
const backend = a2({
|
|
311
|
-
store: postgres({ connectionString: process.env.DATABASE_URL! }),
|
|
312
|
-
scheduler: vercelQueues({ topic: 'board' }),
|
|
313
|
-
})
|
|
314
|
-
|
|
315
|
-
export const team = board({
|
|
316
|
-
backend,
|
|
317
|
-
authenticate: async (request) => (await session(request)) ?? (await tokens(request)),
|
|
318
|
-
access: [
|
|
319
|
-
vercelProject({ project: 'prj_front', can: { 'feedback/': ['post'] } }),
|
|
320
|
-
// Customers read and write in support/, and nowhere else.
|
|
321
|
-
(principal) => (principal.id.startsWith('support:customer:') ? { 'support/': ['read', 'post'] } : undefined),
|
|
322
|
-
],
|
|
323
|
-
})
|
|
324
|
-
export const GET = team.fetch
|
|
325
|
-
export const POST = async (request: Request) => {
|
|
326
|
-
if (request.headers.has('cookie') && request.headers.get('origin') !== 'https://support.example.com') return new Response('forbidden', { status: 403 })
|
|
327
|
-
return team.fetch(request)
|
|
328
|
-
}
|
|
329
|
-
export const { scheduler } = backend
|
|
330
|
-
```
|
|
331
|
-
|
|
332
|
-
A browser sends the cookie with requests that other sites' pages make, so the
|
|
333
|
-
route checks the `Origin` of every write that carries one. A bearer token
|
|
334
|
-
doesn't ride along like that, so `vb`, deployments, and webhooks need no such
|
|
335
|
-
check. board ships no helper for it: it's the route's to say which pages may
|
|
336
|
-
write.
|
|
337
|
-
|
|
338
|
-
- **A verifier gets what the request said:** `credential`, its bearer token or
|
|
339
|
-
null, `headers`, for a cookie, `audience`, the board's URL, `claims`, what it
|
|
340
|
-
claims for itself, and `board`, what the board knows that verifying needs
|
|
341
|
-
(its project, and the issuers its rules trust), which `oidcTokens()` reads.
|
|
342
|
-
- **A host's own returns the principal:** `id` in the board's scheme
|
|
343
|
-
(`vercel:user:<id>`, `vercel:project:<id>:<env>`, …), `kind`, `handle`, and
|
|
344
|
-
optionally `expiresAt`. Its handle stands: the one the CLI sends doesn't
|
|
345
|
-
replace it, so a verifier that wants it returns `request.claims.handle`
|
|
346
|
-
itself. The name, profile, and `x-board-scope` the caller sends still apply
|
|
347
|
-
on top of it.
|
|
348
|
-
- **`kind: 'person'` is a full member of the board:** it may do everything,
|
|
349
|
-
as the board's own people do, whatever the rules say. So your verifier
|
|
350
|
-
decides who counts as one. Staff are people here; customers are `external`.
|
|
351
|
-
- **Anyone else gets what the first rule that matches gives,** and only a
|
|
352
|
-
function matches a host's IDs, like `support:customer:99`. One that no rule
|
|
353
|
-
matches is refused with 403. One whose `expiresAt` has passed is refused,
|
|
354
|
-
and a schedule it made is canceled `revoked`.
|
|
355
|
-
- **Name your principals in a scheme no sync registers.** A sync writes as
|
|
356
|
-
the users of the platforms it registers, `support:…` for a platform named
|
|
357
|
-
`support`, and the board tells a host's principal from them only once that
|
|
358
|
-
principal has written or registered watchers. So if a sync could register
|
|
359
|
-
platform `support`, `support:customer:99` is one of its users until that
|
|
360
|
-
customer first writes. Give `sync` carefully: see
|
|
361
|
-
[what `sync` grants](../04-reference/03-http.md#what-sync-grants).
|
|
362
|
-
- **To reject, throw an `HttpError` or return or throw a `Response`.** The
|
|
363
|
-
board sends that response as is. Anything else thrown is a 500, so turn a
|
|
364
|
-
bad credential into a 401 yourself.
|
|
365
|
-
- **It's asked once per request,** however many times a stream polls, and a
|
|
366
|
-
token `oidcTokens()` verified is kept until it expires. What `access` gives
|
|
367
|
-
is worked out again for each page a stream sends.
|
|
368
|
-
|
|
369
|
-
A host that serves many teams' boards from one deployment can't use the
|
|
370
|
-
built-in verifier at all: its callers can't access the host's project, and
|
|
371
|
-
every team's board would trust the host's own deployments. Its verifier
|
|
372
|
-
replaces `oidcTokens()`, and a function as `access` says what each principal
|
|
373
|
-
may do:
|
|
374
|
-
|
|
375
|
-
```ts lib/boards.ts
|
|
376
|
-
import { board } from '@vercel/board'
|
|
377
|
-
import { a2 } from '@vercel/board/backend-a2'
|
|
378
|
-
import { vercelBlob } from '@vercel/board/backend-a2/blob-vercel'
|
|
379
|
-
import { vercelQueues } from '@vercel/board/backend-a2/scheduler-vercel'
|
|
380
|
-
import { redis } from '@vercel/board/backend-a2/store-redis'
|
|
381
|
-
|
|
382
|
-
/** One team's board. Make each once, and cache it. */
|
|
383
|
-
export function teamBoard(teamId: string) {
|
|
384
|
-
return board({
|
|
385
|
-
backend: a2({
|
|
386
|
-
store: redis({ url: process.env.REDIS_URL!, keyPrefix: `board:${teamId}:` }),
|
|
387
|
-
scheduler: vercelQueues({ topic: `board-${teamId}` }),
|
|
388
|
-
blob: vercelBlob({ prefix: teamId }),
|
|
389
|
-
}),
|
|
390
|
-
authenticate: async (request) => {
|
|
391
|
-
if (request.credential === null) return null
|
|
392
|
-
// const caller = await verifyPlatformToken(request.credential) // yours
|
|
393
|
-
const caller = null as { teamId: string; userId: string; username: string; expiresAt: Date } | null
|
|
394
|
-
if (caller?.teamId !== teamId) return new Response(null, { status: 404 })
|
|
395
|
-
return { id: `vercel:user:${caller.userId}`, kind: 'person', handle: caller.username, expiresAt: caller.expiresAt }
|
|
396
|
-
},
|
|
397
|
-
// access: async (principal) => canOf(teamId, principal.id), // yours
|
|
398
|
-
access: async (principal) => (principal.kind === 'person' ? 'all' : null),
|
|
399
|
-
})
|
|
400
|
-
}
|
|
401
|
-
```
|
|
402
|
-
|
|
403
|
-
- **A function as `access` decides for everyone** it's asked about, people
|
|
404
|
-
and the board's own deployments too, as a rule's `can` (`'all'`, `['read']`,
|
|
405
|
-
`{ 'dev/': ['post'] }`), or null for nothing. It's asked again whenever a
|
|
406
|
-
principal acts, a schedule's send included, so what it says now is what
|
|
407
|
-
holds.
|
|
408
|
-
- **Nothing else is trusted.** Without `oidcTokens()` in its verifier, no
|
|
409
|
-
people, own-project deployments, audience check, or platform token header
|
|
410
|
-
count. A board whose verifier is `oidcTokens()` alone takes no host's
|
|
411
|
-
principals: schedules one made before the board switched are revoked. The
|
|
412
|
-
board's own code's (its handle's, watchers') keep sending.
|
|
413
|
-
- **One board per team.** Create a `board()` for each team and cache them.
|
|
414
|
-
Give each its own store prefix, scheduler topic, and attachments prefix, so
|
|
415
|
-
no team's board reads another's log or files. On a scheduler like
|
|
416
|
-
`vercelQueues()`, a board holds no timers between requests, so dropping an
|
|
417
|
-
evicted one is enough once you close its store (`close()`), which ends the
|
|
418
|
-
connections it opened.
|
|
182
|
+
- **`board()` checks its own,** before `authenticate` runs, so a
|
|
183
|
+
[verifier of your own](./01-mounting.md#callers-of-your-own) never sees
|
|
184
|
+
them.
|
|
185
|
+
- **It's how another team's callers get in,** until cross-team access exists:
|
|
186
|
+
someone on the board's team mints one for them, narrowed to what they need.
|
|
419
187
|
|
|
420
188
|
## A backend of your own
|
|
421
189
|
|
|
@@ -447,11 +215,9 @@ through the binding's `handle(caller)`, so the middleware sees it.
|
|
|
447
215
|
|
|
448
216
|
| Export | What it does |
|
|
449
217
|
| --- | --- |
|
|
450
|
-
| `
|
|
451
|
-
| `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 `board.issuers` names, 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 |
|
|
218
|
+
| `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 |
|
|
452
219
|
| `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 |
|
|
453
|
-
| `
|
|
454
|
-
| `compileAccess(can)`, `union(accesses)`, `FULL_ACCESS` | What a `can` allows on its own, as the same `Access`, with `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 keeps its own copy of these rules to check itself against |
|
|
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 |
|
|
455
221
|
| `DEFAULT_CAN` | The `can` a grant or a token gets when it names none: `{ '*': ['read', 'post', 'react', 'label'] }` |
|
|
456
222
|
|
|
457
223
|
## Permissions
|
|
@@ -474,8 +240,8 @@ through the binding's `handle(caller)`, so the middleware sees it.
|
|
|
474
240
|
inbox needs `sync` in all of them, since raw events span them.
|
|
475
241
|
`{ '*': 'all', 'security/': [] }` can do neither.
|
|
476
242
|
- **`sync` speaks for platform users.** A caller with it in a channel can write
|
|
477
|
-
there as any Slack, GitHub, or Linear user it names, which is what a
|
|
478
|
-
|
|
243
|
+
there as any Slack, GitHub, or Linear user it names, which is what a
|
|
244
|
+
deployment that syncs onto this board needs. Who those users are (name,
|
|
479
245
|
handle, avatar) shows in every channel, so only the board's own sync, or one
|
|
480
246
|
with `sync` in every channel, changes that: anyone else's imports name their
|
|
481
247
|
author and leave the record be. Give it only to the deployment that runs the
|
|
@@ -536,8 +302,8 @@ Reads show only what the caller can read, everywhere:
|
|
|
536
302
|
|
|
537
303
|
## 404 or 403
|
|
538
304
|
|
|
539
|
-
- **What you can't read answers 404,** as if it didn't exist. On
|
|
540
|
-
message IDs are sequential, so a 403 would confirm a message is there.
|
|
305
|
+
- **What you can't read answers 404,** as if it didn't exist. On a local
|
|
306
|
+
board, message IDs are sequential, so a 403 would confirm a message is there.
|
|
541
307
|
- **A refused write you can read answers 403** and names what's missing:
|
|
542
308
|
`this token can't label in dev`.
|
|
543
309
|
- **A channel the request names is yours to know,** so a post to a channel you
|
|
@@ -579,7 +345,7 @@ would bring into the narrowed caller's channels.
|
|
|
579
345
|
## Schedules
|
|
580
346
|
|
|
581
347
|
A schedule sends as its creator with the creator's access when it fires, under
|
|
582
|
-
the
|
|
348
|
+
the grants as they are then, and only while the board token it was
|
|
583
349
|
made with, if any, is live. The board keeps the token's verified claims and
|
|
584
350
|
any scope, never the token. A creator that can no longer post there has the
|
|
585
351
|
schedule canceled with `revoked`. Only its creator, while it can post there, or
|
|
@@ -606,11 +372,8 @@ left out for full access. `GET /me` returns the same as `can`.
|
|
|
606
372
|
|
|
607
373
|
### How do I keep a channel from the project's own people?
|
|
608
374
|
|
|
609
|
-
|
|
610
|
-
everything.
|
|
611
|
-
as it says what everyone else may do as well (see
|
|
612
|
-
[A host's own verifier](#a-hosts-own-verifier)). Otherwise, content that needs
|
|
613
|
-
privacy from them needs a second board.
|
|
375
|
+
You can't, on one board: people who can access the board's Vercel project can
|
|
376
|
+
do everything. Content that needs privacy from them needs a second board.
|
|
614
377
|
|
|
615
378
|
### Does a mirrored channel stay private?
|
|
616
379
|
|
|
@@ -620,9 +383,9 @@ platforms it syncs with.
|
|
|
620
383
|
|
|
621
384
|
### Do message IDs leak anything?
|
|
622
385
|
|
|
623
|
-
How busy the board is. On
|
|
624
|
-
caller that can read one channel sees how many events happened in
|
|
625
|
-
They don't say where or what.
|
|
386
|
+
How busy the board is. On a local board, IDs and cursors are positions in its
|
|
387
|
+
log, so a caller that can read one channel sees how many events happened in
|
|
388
|
+
all of them. They don't say where or what.
|
|
626
389
|
|
|
627
390
|
### Is there a static token for callers without OIDC?
|
|
628
391
|
|
|
@@ -630,4 +393,4 @@ Yes: a [board token](#tokens), which you mint, list, and revoke, and which
|
|
|
630
393
|
lives 90 days at most. Callers with an OIDC token need none: a
|
|
631
394
|
[grant](#grants) lets them in by their claims, each living as long as its
|
|
632
395
|
token. A credential of your own, such as a session cookie, takes
|
|
633
|
-
[a verifier of your own](#
|
|
396
|
+
[a verifier of your own](./01-mounting.md#callers-of-your-own).
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Local boards
|
|
3
|
+
description: "`local()` keeps a board in this process: in SQLite under `.board/`, or in memory for tests. It's for development, `vb serve`, tests, and working offline."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## A board on this machine
|
|
7
|
+
|
|
8
|
+
```ts app/api/board/[[...path]]/route.ts
|
|
9
|
+
import { board } from '@vercel/board'
|
|
10
|
+
import { local } from '@vercel/board/backend-local'
|
|
11
|
+
|
|
12
|
+
// SQLite at .board/local.db, files in .board/local/, and timers in this process.
|
|
13
|
+
export const team = board({ backend: local() })
|
|
14
|
+
export const GET = team.fetch, POST = team.fetch
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
`local()` keeps everything in the process that runs it. It needs Node, and a
|
|
18
|
+
disk it can write: a serverless function can't keep one.
|
|
19
|
+
|
|
20
|
+
- **One file per board, by its name.** The default board is `.board/local.db`.
|
|
21
|
+
A board with a `name` gets a file named for it: `board({ backend: local(),
|
|
22
|
+
name: 'security' })` is `.board/security.db`, whatever the name's case. Any
|
|
23
|
+
other name, `Security Team` say, gets letters and dashes, a `.`, and a hash
|
|
24
|
+
(`security-team.83f2a9a1e050b6c257f82d1bf439cc90.db`). No plain name has
|
|
25
|
+
a `.`, so no two names share a file.
|
|
26
|
+
- **`team` is ignored.** There's one team on this machine: `board({ team:
|
|
27
|
+
'acme', name: 'security' })` is `.board/security.db` too, and
|
|
28
|
+
`board({ team: 'acme' })` is the default board.
|
|
29
|
+
- **Attachments live beside it,** in a folder named like the file:
|
|
30
|
+
`.board/local/`, `.board/security/`. The folder appears with the first file.
|
|
31
|
+
- **A scheduler runs in the process.** Scheduled messages send, and watchers
|
|
32
|
+
and sync retry, while it runs. A restart drops what's pending, a scheduled
|
|
33
|
+
message's next send included.
|
|
34
|
+
- **It opens on the first call.** `board()` binds it without touching the
|
|
35
|
+
disk. A directory it can't write fails that call with 500 `no_store`, which
|
|
36
|
+
says where.
|
|
37
|
+
- **It passes the whole [conformance](../04-reference/05-conformance.md) kit,**
|
|
38
|
+
schedules and attachments included.
|
|
39
|
+
|
|
40
|
+
Keep `.board/` out of Git:
|
|
41
|
+
|
|
42
|
+
```text .gitignore
|
|
43
|
+
.board/
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Options
|
|
47
|
+
|
|
48
|
+
| Option | What it does |
|
|
49
|
+
| --- | --- |
|
|
50
|
+
| `dir` | Where it keeps its files. Default `.board`, under the working directory |
|
|
51
|
+
| `memory` | Keeps the board, its files included, in memory: nothing is written, and it's gone with the process. For tests |
|
|
52
|
+
|
|
53
|
+
`close()` closes the board's file once nothing uses it, as a test does at its
|
|
54
|
+
end.
|
|
55
|
+
|
|
56
|
+
## In tests
|
|
57
|
+
|
|
58
|
+
```ts test/deploys.test.ts
|
|
59
|
+
import { expect, it } from 'vitest'
|
|
60
|
+
import { board } from '@vercel/board'
|
|
61
|
+
import { local } from '@vercel/board/backend-local'
|
|
62
|
+
|
|
63
|
+
it('posts the deploy', async () => {
|
|
64
|
+
const team = board({ backend: local({ memory: true }) })
|
|
65
|
+
await team.post('deploys', 'www@a1b2c3 is live')
|
|
66
|
+
// await yourDeployHook(team)
|
|
67
|
+
const { messages } = await team.messages({ channel: 'deploys' })
|
|
68
|
+
expect(messages.map((message) => message.text)).toEqual(['www@a1b2c3 is live'])
|
|
69
|
+
})
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
A handle on it is the board's own code, as on any board this process keeps:
|
|
73
|
+
it writes as `board:client`, and `team.as('deploys')` as
|
|
74
|
+
`board:client:deploys`.
|
|
75
|
+
|
|
76
|
+
## vb serve
|
|
77
|
+
|
|
78
|
+
[`vb serve`](../04-reference/01-cli.md#serve) runs `local()` under `.board/` at
|
|
79
|
+
the Git checkout's root, behind `http://127.0.0.1:4100/api/board`, and signs
|
|
80
|
+
you a token for it. Other commands, and `board()` with `BOARD_URL` set to that
|
|
81
|
+
URL, reach it.
|