@vercel/board 0.30.0 → 0.32.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 (125) hide show
  1. package/README.md +8 -17
  2. package/dist/{a2-D_28Pdip.mjs → a2-DiDc77Uf.mjs} +573 -361
  3. package/dist/{access-CQ39gqEV.mjs → access-CY5xVMIK.mjs} +19 -3
  4. package/dist/{access-CV96SYgr.d.mts → access-DPcrKIH_.d.mts} +6 -1
  5. package/dist/access.d.mts +4 -4
  6. package/dist/access.mjs +5 -4
  7. package/dist/{actors-xPiamLWk.mjs → actors-Bm-ojWWT.mjs} +2 -2
  8. package/dist/{auth-BPinwfN0.mjs → auth-8pRZnF1M.mjs} +131 -14
  9. package/dist/{auth-CU56Q2Xh.d.mts → auth-K8dY1nBY.d.mts} +36 -4
  10. package/dist/{backend-n3hajfrD.d.mts → backend-DxE9wGKm.d.mts} +86 -41
  11. package/dist/backend-a2/blob-vercel.d.mts +1 -1
  12. package/dist/backend-a2/contract.d.mts +37 -97
  13. package/dist/backend-a2/contract.mjs +1 -1
  14. package/dist/backend-a2/store-memory.d.mts +1 -1
  15. package/dist/backend-a2/store-memory.mjs +2 -2
  16. package/dist/backend-a2/store-postgres.d.mts +1 -1
  17. package/dist/backend-a2/store-postgres.mjs +1 -1
  18. package/dist/backend-a2/store-redis-http.d.mts +1 -1
  19. package/dist/backend-a2/store-redis-http.mjs +1 -1
  20. package/dist/backend-a2/store-redis.d.mts +1 -1
  21. package/dist/backend-a2/store-redis.mjs +1 -1
  22. package/dist/backend-a2/store-sqlite.d.mts +1 -1
  23. package/dist/backend-a2/store-sqlite.mjs +2 -2
  24. package/dist/backend-a2.d.mts +131 -240
  25. package/dist/backend-a2.mjs +2 -2
  26. package/dist/{backend-http-3PoBYQoo.d.mts → backend-http-CaN06CaD.d.mts} +49 -45
  27. package/dist/{backend-http-16SbvnAK.mjs → backend-http-CoaCghuJ.mjs} +2 -2
  28. package/dist/{backend-http-BPaNYLWj.mjs → backend-http-l5A8UmL-.mjs} +11 -9
  29. package/dist/backend-http.d.mts +1 -1
  30. package/dist/backend-http.mjs +1 -1
  31. package/dist/backend-http.node.d.mts +1 -1
  32. package/dist/backend-http.node.mjs +1 -1
  33. package/dist/{backend-vercel-Kd8nvW5A.mjs → backend-vercel-BE65okBC.mjs} +3 -3
  34. package/dist/{backend-vercel-C4Kee2-K.mjs → backend-vercel-CVxoTNF2.mjs} +186 -33
  35. package/dist/{backend-vercel-qznuDxnN.d.mts → backend-vercel-jg-6PAgD.d.mts} +49 -45
  36. package/dist/backend-vercel.d.mts +1 -1
  37. package/dist/backend-vercel.mjs +1 -1
  38. package/dist/backend-vercel.node.d.mts +1 -1
  39. package/dist/backend-vercel.node.mjs +1 -1
  40. package/dist/{blob-CqILvdmr.d.mts → blob-Bx8QPWEd.d.mts} +2 -2
  41. package/dist/{blob-DQK5prXT.mjs → blob-WbB2DJKn.mjs} +30 -11
  42. package/dist/{chat-provider-D6jVT4wS.d.mts → chat-provider-BChYrrA7.d.mts} +32 -28
  43. package/dist/{chat-provider-COtsU5jB.mjs → chat-provider-DkFp2hrh.mjs} +105 -60
  44. package/dist/cli-commands.d.mts +1 -1
  45. package/dist/cli-commands.mjs +1 -1
  46. package/dist/cli-embedded.d.mts +2 -2
  47. package/dist/cli-embedded.mjs +2 -2
  48. package/dist/cli.mjs +4 -4
  49. package/dist/{client-CjAatpV4.d.mts → client-COfYrgfV.d.mts} +184 -221
  50. package/dist/{commands-BtH69yqt.d.mts → commands-CpyPV_tk.d.mts} +35 -10
  51. package/dist/{commands-B5DHjZKK.mjs → commands-DsnQKTdB.mjs} +189 -56
  52. package/dist/{conformance-C7fwIvmN.mjs → conformance-3RBKxwbp.mjs} +259 -20
  53. package/dist/conformance.d.mts +8 -2
  54. package/dist/conformance.mjs +1 -1
  55. package/dist/{engine-DkdkXQEy.mjs → engine-DurYIRt8.mjs} +29 -210
  56. package/dist/{errors-87TVtXeb.d.mts → errors-2vGs49Db.d.mts} +1 -1
  57. package/dist/{errors-C_5rB8Iz.mjs → errors-CJXhhzvT.mjs} +28 -23
  58. package/dist/{provider-BaVmi4Hi.mjs → events-lujPA3gQ.mjs} +80 -17
  59. package/dist/{exports-CG0P8Qi4.mjs → exports-BnUZuRm9.mjs} +146 -80
  60. package/dist/exports-u5mApVvn.d.mts +5 -0
  61. package/dist/{folds-8wRRXjAt.d.mts → folds-DLUzfibJ.d.mts} +13 -40
  62. package/dist/{folds-DGYkMW19.mjs → folds-DsWfIftc.mjs} +3 -22
  63. package/dist/{index-BygAXP7t.d.mts → index-UXpTPWNc.d.mts} +2 -2
  64. package/dist/index.d.mts +7 -7
  65. package/dist/{index.default-DhkgpfR2.mjs → index.default-Dp8gexln.mjs} +1 -1
  66. package/dist/index.mjs +5 -5
  67. package/dist/index.node.d.mts +7 -7
  68. package/dist/index.node.mjs +3 -3
  69. package/dist/inspect/app.js +62 -61
  70. package/dist/inspect/engine.js +3 -3
  71. package/dist/{main-D2s-QBOK.mjs → main-CcYDo9Hb.mjs} +240 -127
  72. package/dist/{middleware-DlJQYiwV.mjs → middleware-BavYSDUa.mjs} +1 -1
  73. package/dist/{node-D8Rtg1su.mjs → node-BgeGcwX0.mjs} +7 -3
  74. package/dist/{project-C_2xs57L.mjs → project-4Vl7_uy5.mjs} +1 -1
  75. package/dist/{provider-Bm46LAdp.d.mts → provider-gynDUoyW.d.mts} +13 -43
  76. package/dist/{redis-tables-BWJZHUGg.mjs → redis-tables-BFRj_SEJ.mjs} +1 -19
  77. package/dist/{reducers-8jqLewgw.mjs → reducers-DQVSP3kk.mjs} +72 -75
  78. package/dist/{serve-lPoBDEds.mjs → serve-Bplieh0C.mjs} +6 -6
  79. package/dist/{server-D82a4uMe.mjs → server-wIpAEjpX.mjs} +4 -4
  80. package/dist/{serving-DKny38LK.mjs → serving-Y7s7VDjB.mjs} +1 -1
  81. package/dist/{sql-Bj0fk6dn.mjs → sql-E1K5g_ih.mjs} +2 -8
  82. package/dist/{sqlite-db-Dc8G78XV.mjs → sqlite-db-CzcD_FW8.mjs} +1 -1
  83. package/dist/{sync-kapso.d.mts → sync-chat-sdk.d.mts} +33 -37
  84. package/dist/sync-chat-sdk.mjs +44 -0
  85. package/dist/sync-github.d.mts +5 -18
  86. package/dist/sync-github.mjs +4 -70
  87. package/dist/sync-linear.d.mts +3 -3
  88. package/dist/sync-linear.mjs +2 -3
  89. package/dist/sync-slack.d.mts +7 -7
  90. package/dist/sync-slack.mjs +33 -54
  91. package/dist/sync.d.mts +3 -3
  92. package/dist/sync.mjs +2 -4
  93. package/dist/{tokens-C5_yGRlL.mjs → tokens-C7kYyrAG.mjs} +15 -6
  94. package/dist/{types-shZmGZ-q.d.mts → types-CmrFjpml.d.mts} +1 -3
  95. package/dist/{watchers-hash-B_5b0-ZG.mjs → watchers-hash-CurCzwhe.mjs} +85 -105
  96. package/docs/01-board/01-mounting.md +2 -2
  97. package/docs/01-board/03-identity.md +5 -6
  98. package/docs/01-board/04-messages.md +7 -4
  99. package/docs/01-board/05-reading.md +2 -1
  100. package/docs/01-board/06-watchers.md +8 -6
  101. package/docs/01-board/08-middleware.md +1 -1
  102. package/docs/01-board/09-access.md +145 -14
  103. package/docs/02-sync/01-overview.md +19 -26
  104. package/docs/02-sync/02-functions.md +8 -9
  105. package/docs/02-sync/03-slack.md +5 -5
  106. package/docs/02-sync/04-github.md +2 -2
  107. package/docs/02-sync/06-providers.md +91 -62
  108. package/docs/03-guides/01-coding-agents.md +1 -1
  109. package/docs/03-guides/03-ci.md +7 -4
  110. package/docs/04-reference/01-cli.md +100 -51
  111. package/docs/04-reference/02-board.md +56 -23
  112. package/docs/04-reference/03-http.md +59 -32
  113. package/docs/04-reference/04-log.md +8 -11
  114. package/docs/04-reference/05-conformance.md +35 -6
  115. package/docs/index.md +2 -2
  116. package/package.json +6 -9
  117. package/sql/postgres/board.sql +1 -1
  118. package/sql/postgres/schema.sql +1 -1
  119. package/dist/events-qf5XG5VQ.mjs +0 -75
  120. package/dist/exports-CrGA5_yN.d.mts +0 -5
  121. package/dist/sync-kapso.mjs +0 -89
  122. package/dist/sync.chat.d.mts +0 -2
  123. package/dist/sync.chat.mjs +0 -2
  124. package/dist/users-yryHKFMo.mjs +0 -42
  125. package/docs/02-sync/05-whatsapp.md +0 -152
@@ -1,5 +1,5 @@
1
- import { u as BoardError } from "./errors-C_5rB8Iz.mjs";
2
- import { r as compileAccess } from "./access-CQ39gqEV.mjs";
1
+ import { u as BoardError } from "./errors-CJXhhzvT.mjs";
2
+ import { r as compileAccess } from "./access-CY5xVMIK.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);
@@ -18,6 +18,16 @@ async function rejects(attempt, status, code, what) {
18
18
  }
19
19
  throw new Mismatch(`${what}: expected ${status} ${code}, and it succeeded`);
20
20
  }
21
+ /** That `attempt` is refused with `status`, whatever code the board gives it. */
22
+ async function refused(attempt, status, what) {
23
+ try {
24
+ await attempt;
25
+ } catch (error) {
26
+ if (error instanceof BoardError && error.status === status) return;
27
+ throw new Mismatch(`${what}: expected ${status}, got ${error instanceof BoardError ? `${error.status} ${error.code}` : String(error)}`);
28
+ }
29
+ throw new Mismatch(`${what}: expected ${status}, and it succeeded`);
30
+ }
21
31
  /** Where a registration is woken, to put back after a check replaces it: its path (and branch) on a board that wakes by path, or its url. */
22
32
  function wokenAt(registered) {
23
33
  if (!registered?.path) return { url: registered?.url ?? null };
@@ -32,9 +42,16 @@ function isRef(value, what) {
32
42
  }
33
43
  /**
34
44
  * The groups a board may keep none of, saying so with a 501: a board on `a2()` without a scheduler
35
- * answers `no_scheduler`, and without a blob store `no_files`.
45
+ * answers `no_scheduler`, and without a blob store `no_files`; one whose `access` is one function keeps
46
+ * no grants, `no_grants`. A board that's meant to keep something and doesn't yet answers otherwise,
47
+ * and fails.
36
48
  */
37
- const OPTIONAL = /* @__PURE__ */ new Set(["schedules", "attachments"]);
49
+ const OPTIONAL = /* @__PURE__ */ new Set([
50
+ "schedules",
51
+ "grants",
52
+ "tokens",
53
+ "attachments"
54
+ ]);
38
55
  const needRoot = (ctx) => {
39
56
  check(ctx.root && ctx.reply, "posting failed, so there's nothing to read");
40
57
  return {
@@ -42,6 +59,23 @@ const needRoot = (ctx) => {
42
59
  reply: ctx.reply
43
60
  };
44
61
  };
62
+ /** A grant for a project that doesn't exist, from an environment its deployments would have: it lets nobody in. */
63
+ const grantFor = (ctx) => ({
64
+ issuer: "vercel",
65
+ claims: {
66
+ environment: "preview",
67
+ project_id: `prj_conformance${ctx.labels.conformance}`
68
+ }
69
+ });
70
+ /** Sets the check's grant, or says why it can't: changing who the board trusts takes `manage` in every channel. */
71
+ async function firstGrant(ctx) {
72
+ try {
73
+ return await ctx.board.createGrant(grantFor(ctx));
74
+ } catch (error) {
75
+ if (error instanceof BoardError && error.status === 403) return { skip: "this token can't change the board's grants" };
76
+ throw error;
77
+ }
78
+ }
45
79
  /** The sync key the sync checks register, a platform of their own, so nothing reaches a real one. */
46
80
  const SYNC_KEY = "conformance";
47
81
  /**
@@ -348,16 +382,66 @@ const CHECKS = [
348
382
  })}`);
349
383
  }
350
384
  },
385
+ {
386
+ group: "core",
387
+ name: "drops a deleted message from what its labels find",
388
+ run: async (ctx) => {
389
+ const label = {
390
+ ...ctx.labels,
391
+ tombstone: ctx.labels.conformance
392
+ };
393
+ const root = await ctx.board.post(ctx.channel, {
394
+ text: "conformance: a labeled root to delete",
395
+ labels: label,
396
+ noSync: true
397
+ });
398
+ ctx.posted.push(root.id);
399
+ const kept = await reply(ctx, root.id, "conformance: a reply under it");
400
+ const found = async () => ({
401
+ threads: (await ctx.board.threads({
402
+ channel: ctx.channel,
403
+ label
404
+ })).threads.map((t) => t.message.id),
405
+ messages: (await ctx.board.messages({
406
+ channel: ctx.channel,
407
+ label
408
+ })).messages.map((m) => m.id)
409
+ });
410
+ const before = await found();
411
+ check(before.threads.includes(root.id) && before.messages.includes(kept.id), `its labels should find the root and its reply before the delete, got ${show(before)}`);
412
+ await ctx.board.delete(root.id);
413
+ const { labels } = (await ctx.board.thread(root.id)).message;
414
+ check(Object.keys(labels).length === 0, `a deleted message should keep no labels, got ${show(labels)}`);
415
+ const after = await found();
416
+ check(!after.threads.includes(root.id), `a label read should leave out a deleted root's thread, got ${show(after.threads)}`);
417
+ check(!after.messages.includes(root.id) && !after.messages.includes(kept.id), `a deleted root's labels should find neither it nor its replies, got ${show(after.messages)}`);
418
+ }
419
+ },
351
420
  {
352
421
  group: "core",
353
422
  name: "lists the channel and you in it",
354
423
  run: async (ctx) => {
355
424
  const found = (await ctx.board.channels()).find((c) => c.path === ctx.channel);
356
425
  check(found, `the channels should include ${ctx.channel}`);
357
- check(typeof found.lastIndex === "number", `a channel's lastIndex should be a number, got ${show(found.lastIndex)}`);
426
+ for (const field of [
427
+ "lastIndex",
428
+ "messages",
429
+ "threads"
430
+ ]) check(found[field] === void 0 || typeof found[field] === "number", `a channel's ${field} should be a number or left out, got ${show(found[field])}`);
358
431
  check((await ctx.board.actors()).some((a) => a.id === ctx.me.actor), `the actors should include ${ctx.me.actor}`);
359
432
  }
360
433
  },
434
+ {
435
+ group: "core",
436
+ name: "creates a channel only once: one a post made is there already",
437
+ run: async (ctx) => {
438
+ needRoot(ctx);
439
+ const { channel, created } = await ctx.board.createChannel(ctx.channel);
440
+ same(created, false, `creating ${ctx.channel}, which this run posted to`);
441
+ same(channel.path, ctx.channel, "the channel's path");
442
+ await rejects(ctx.board.createChannel("Not A Channel"), 400, "invalid_request", "creating a malformed channel");
443
+ }
444
+ },
361
445
  {
362
446
  group: "core",
363
447
  name: "answers 404 for an ID that names nothing",
@@ -411,6 +495,174 @@ const CHECKS = [
411
495
  }
412
496
  }
413
497
  },
498
+ {
499
+ group: "grants",
500
+ name: "grants a project, lists it, takes the same grant again as one, and revokes 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",
528
+ run: async (ctx) => {
529
+ const first = await firstGrant(ctx);
530
+ if ("skip" in first) return first.skip;
531
+ const { grant } = first;
532
+ try {
533
+ const narrowed = await ctx.board.createGrant({
534
+ ...grantFor(ctx),
535
+ can: { [ctx.channel]: ["post"] }
536
+ });
537
+ same(narrowed.created, false, "setting its can: created");
538
+ same(narrowed.grant.id, grant.id, "setting its can: its id");
539
+ same(show(narrowed.grant.can), show({ [ctx.channel]: ["post"] }), "the grant's can");
540
+ } finally {
541
+ await ctx.board.revokeGrant(grant.id).catch(() => {});
542
+ }
543
+ }
544
+ },
545
+ {
546
+ group: "grants",
547
+ name: "grants a GitHub repository's workflows, and another team's project",
548
+ run: async (ctx) => {
549
+ const first = await firstGrant(ctx);
550
+ if ("skip" in first) return first.skip;
551
+ const made = [first.grant.id];
552
+ try {
553
+ const github = await ctx.board.createGrant({
554
+ issuer: "github",
555
+ claims: { repository: `acme/conformance-${ctx.labels.conformance}` },
556
+ can: { [ctx.channel]: ["post"] }
557
+ });
558
+ made.push(github.grant.id);
559
+ same(github.grant.issuer, "github", "the GitHub grant's issuer");
560
+ const theirs = await ctx.board.createGrant({
561
+ issuer: "vercel",
562
+ claims: {
563
+ environment: "production",
564
+ owner_id: `team_conformance${ctx.labels.conformance}`,
565
+ project_id: `prj_conformance${ctx.labels.conformance}x`
566
+ }
567
+ });
568
+ made.push(theirs.grant.id);
569
+ same(theirs.grant.claims.owner_id, `team_conformance${ctx.labels.conformance}`, "another team's grant's owner_id");
570
+ const listed = new Set((await ctx.board.grants()).map((grant) => grant.id));
571
+ check(made.every((id) => listed.has(id)), `grants should list ${made.join(", ")}`);
572
+ } finally {
573
+ for (const id of made) await ctx.board.revokeGrant(id).catch(() => {});
574
+ }
575
+ }
576
+ },
577
+ {
578
+ group: "grants",
579
+ name: "keeps two environments of one project as two grants, and revokes one without the other",
580
+ run: async (ctx) => {
581
+ const first = await firstGrant(ctx);
582
+ if ("skip" in first) return first.skip;
583
+ const made = [first.grant.id];
584
+ try {
585
+ const production = await ctx.board.createGrant({
586
+ ...grantFor(ctx),
587
+ claims: {
588
+ ...grantFor(ctx).claims,
589
+ environment: "production"
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)}`);
598
+ } finally {
599
+ for (const id of made) await ctx.board.revokeGrant(id).catch(() => {});
600
+ }
601
+ }
602
+ },
603
+ {
604
+ group: "tokens",
605
+ name: "mints a token, shows its secret only then, lists it, and revokes it",
606
+ run: async (ctx) => {
607
+ const name = `conformance-${ctx.labels.conformance}`;
608
+ const { token, secret } = await ctx.board.createToken({
609
+ name,
610
+ can: { [ctx.channel]: ["read"] },
611
+ expires: "1h"
612
+ });
613
+ try {
614
+ isRef(token.id, "a token's id");
615
+ check(typeof secret === "string" && secret.length >= 32, `a token's secret should be a string of at least 32 characters, got ${typeof secret}`);
616
+ same(token.name, name, "the token's name");
617
+ same(show(token.can), show({ [ctx.channel]: ["read"] }), "the token's can");
618
+ const left = Date.parse(token.expiresAt) - Date.now();
619
+ check(left > 33e5 && left <= 3605e3, `a token minted for 1h should expire in an hour, got ${token.expiresAt}`);
620
+ const listed = await ctx.board.tokens();
621
+ check(listed.some((found) => found.id === token.id), `tokens should list ${token.id}`);
622
+ check(!JSON.stringify(listed).includes(secret), "tokens shouldn't show a token's secret");
623
+ } catch (error) {
624
+ await ctx.board.revokeToken(token.id).catch(() => {});
625
+ throw error;
626
+ }
627
+ same((await ctx.board.revokeToken(token.id)).revoked, true, "revoking it");
628
+ same((await ctx.board.revokeToken(token.id)).revoked, false, "revoking it again");
629
+ check(!(await ctx.board.tokens()).some((found) => found.id === token.id), "tokens shouldn't list it once it's revoked");
630
+ }
631
+ },
632
+ {
633
+ group: "tokens",
634
+ name: "lets a token do what its can says, as whoever minted it, and nothing once it's revoked",
635
+ run: async (ctx) => {
636
+ if (!ctx.withToken) return "this run can't call the board with a token's secret";
637
+ const { root } = needRoot(ctx);
638
+ const { token, secret } = await ctx.board.createToken({
639
+ name: `conformance-${ctx.labels.conformance}-reads`,
640
+ can: { [ctx.channel]: ["read"] },
641
+ expires: "1h"
642
+ });
643
+ const holder = ctx.withToken(secret);
644
+ try {
645
+ const me = await holder.me();
646
+ same(me.principal, ctx.me.principal, "a token's principal, its minter's");
647
+ const want = { [ctx.channel]: ["read"] };
648
+ check(show(me.can) === show(want), `what a token that may only read says it may do: expected ${show(want)}, got ${show(me.can)}`);
649
+ same((await holder.thread(root.id)).message.id, root.id, "a thread read with a token that may read it");
650
+ await refused(holder.post(ctx.channel, {
651
+ text: "conformance: a token that may only read",
652
+ labels: ctx.labels,
653
+ noSync: true
654
+ }).then((message) => {
655
+ ctx.posted.push(message.id);
656
+ return message;
657
+ }), 403, "a post with a token that may only read");
658
+ } catch (error) {
659
+ await ctx.board.revokeToken(token.id).catch(() => {});
660
+ throw error;
661
+ }
662
+ same((await ctx.board.revokeToken(token.id)).revoked, true, "revoking it");
663
+ await refused(holder.me(), 401, "a request with a revoked token");
664
+ }
665
+ },
414
666
  {
415
667
  group: "attachments",
416
668
  name: "takes a file, posts it, and gives it back",
@@ -703,20 +955,6 @@ const CHECKS = [
703
955
  same(thread.message.noSync, true, "a post's noSync, read back");
704
956
  same(thread.replies.find((m) => m.id === reply.id)?.noSync, true, "a reply's noSync, read back");
705
957
  }
706
- },
707
- {
708
- group: "sync",
709
- name: "finds no one for a platform account nobody linked",
710
- run: async (ctx) => {
711
- let found;
712
- try {
713
- found = await ctx.board.syncFind({ account: `${SYNC_KEY}:user:${ctx.labels.conformance}` });
714
- } catch (error) {
715
- if (error instanceof BoardError && error.status === 403) return "this token can't look up a sync here";
716
- throw error;
717
- }
718
- same(found.person, null, "who an account nobody linked is");
719
- }
720
958
  }
721
959
  ];
722
960
  /** Runs the checks against `board`, in order, and reports each. It never throws for what the board answers. */
@@ -754,7 +992,8 @@ async function conformance(board, options = {}) {
754
992
  limit: 1
755
993
  })).cursor,
756
994
  me,
757
- posted: []
995
+ posted: [],
996
+ ...options.withToken ? { withToken: options.withToken } : {}
758
997
  };
759
998
  try {
760
999
  for (const { group, name, run } of CHECKS) try {
@@ -1,4 +1,4 @@
1
- import { d as Board } from "./backend-n3hajfrD.mjs";
1
+ import { f as Board } from "./backend-DxE9wGKm.mjs";
2
2
  //#region src/conformance/index.d.ts
3
3
  /**
4
4
  * Checks that a board speaks the protocol, through a handle on it (`conformance(board())`), as
@@ -7,7 +7,7 @@ import { d as Board } from "./backend-n3hajfrD.mjs";
7
7
  * (`conformance` by default), keeps every post on the board, and deletes what it posted.
8
8
  */
9
9
  /** What a check is about, for the report's headings. */
10
- export type CheckGroup = 'core' | 'schedules' | 'attachments' | 'watchers' | 'sync';
10
+ export type CheckGroup = 'core' | 'schedules' | 'grants' | 'tokens' | 'attachments' | 'watchers' | 'sync';
11
11
  export type CheckResult = {
12
12
  group: CheckGroup;
13
13
  name: string;
@@ -24,6 +24,12 @@ export type ConformanceReport = {
24
24
  export type ConformanceOptions = {
25
25
  /** Where it posts. Default `conformance`. */
26
26
  channel?: string;
27
+ /**
28
+ * The same board, with a board token's secret as the credential (as `BOARD_TOKEN` sends it):
29
+ * the tokens check calls it so to see that a token does only what its `can` says. Without it,
30
+ * that check is skipped.
31
+ */
32
+ withToken?: (secret: string) => Board;
27
33
  };
28
34
  /** Runs the checks against `board`, in order, and reports each. It never throws for what the board answers. */
29
35
  export declare function conformance(board: Board, options?: ConformanceOptions): Promise<ConformanceReport>;
@@ -1,2 +1,2 @@
1
- import { t as conformance } from "./conformance-C7fwIvmN.mjs";
1
+ import { t as conformance } from "./conformance-3RBKxwbp.mjs";
2
2
  export { conformance };