@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.
- package/README.md +8 -17
- package/dist/{a2-D_28Pdip.mjs → a2-DiDc77Uf.mjs} +573 -361
- package/dist/{access-CQ39gqEV.mjs → access-CY5xVMIK.mjs} +19 -3
- package/dist/{access-CV96SYgr.d.mts → access-DPcrKIH_.d.mts} +6 -1
- package/dist/access.d.mts +4 -4
- package/dist/access.mjs +5 -4
- package/dist/{actors-xPiamLWk.mjs → actors-Bm-ojWWT.mjs} +2 -2
- package/dist/{auth-BPinwfN0.mjs → auth-8pRZnF1M.mjs} +131 -14
- package/dist/{auth-CU56Q2Xh.d.mts → auth-K8dY1nBY.d.mts} +36 -4
- package/dist/{backend-n3hajfrD.d.mts → backend-DxE9wGKm.d.mts} +86 -41
- package/dist/backend-a2/blob-vercel.d.mts +1 -1
- package/dist/backend-a2/contract.d.mts +37 -97
- package/dist/backend-a2/contract.mjs +1 -1
- package/dist/backend-a2/store-memory.d.mts +1 -1
- package/dist/backend-a2/store-memory.mjs +2 -2
- package/dist/backend-a2/store-postgres.d.mts +1 -1
- package/dist/backend-a2/store-postgres.mjs +1 -1
- package/dist/backend-a2/store-redis-http.d.mts +1 -1
- package/dist/backend-a2/store-redis-http.mjs +1 -1
- package/dist/backend-a2/store-redis.d.mts +1 -1
- package/dist/backend-a2/store-redis.mjs +1 -1
- package/dist/backend-a2/store-sqlite.d.mts +1 -1
- package/dist/backend-a2/store-sqlite.mjs +2 -2
- package/dist/backend-a2.d.mts +131 -240
- package/dist/backend-a2.mjs +2 -2
- package/dist/{backend-http-3PoBYQoo.d.mts → backend-http-CaN06CaD.d.mts} +49 -45
- package/dist/{backend-http-16SbvnAK.mjs → backend-http-CoaCghuJ.mjs} +2 -2
- package/dist/{backend-http-BPaNYLWj.mjs → backend-http-l5A8UmL-.mjs} +11 -9
- package/dist/backend-http.d.mts +1 -1
- package/dist/backend-http.mjs +1 -1
- package/dist/backend-http.node.d.mts +1 -1
- package/dist/backend-http.node.mjs +1 -1
- package/dist/{backend-vercel-Kd8nvW5A.mjs → backend-vercel-BE65okBC.mjs} +3 -3
- package/dist/{backend-vercel-C4Kee2-K.mjs → backend-vercel-CVxoTNF2.mjs} +186 -33
- package/dist/{backend-vercel-qznuDxnN.d.mts → backend-vercel-jg-6PAgD.d.mts} +49 -45
- package/dist/backend-vercel.d.mts +1 -1
- package/dist/backend-vercel.mjs +1 -1
- package/dist/backend-vercel.node.d.mts +1 -1
- package/dist/backend-vercel.node.mjs +1 -1
- package/dist/{blob-CqILvdmr.d.mts → blob-Bx8QPWEd.d.mts} +2 -2
- package/dist/{blob-DQK5prXT.mjs → blob-WbB2DJKn.mjs} +30 -11
- package/dist/{chat-provider-D6jVT4wS.d.mts → chat-provider-BChYrrA7.d.mts} +32 -28
- package/dist/{chat-provider-COtsU5jB.mjs → chat-provider-DkFp2hrh.mjs} +105 -60
- 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 +2 -2
- package/dist/cli.mjs +4 -4
- package/dist/{client-CjAatpV4.d.mts → client-COfYrgfV.d.mts} +184 -221
- package/dist/{commands-BtH69yqt.d.mts → commands-CpyPV_tk.d.mts} +35 -10
- package/dist/{commands-B5DHjZKK.mjs → commands-DsnQKTdB.mjs} +189 -56
- package/dist/{conformance-C7fwIvmN.mjs → conformance-3RBKxwbp.mjs} +259 -20
- package/dist/conformance.d.mts +8 -2
- package/dist/conformance.mjs +1 -1
- package/dist/{engine-DkdkXQEy.mjs → engine-DurYIRt8.mjs} +29 -210
- package/dist/{errors-87TVtXeb.d.mts → errors-2vGs49Db.d.mts} +1 -1
- package/dist/{errors-C_5rB8Iz.mjs → errors-CJXhhzvT.mjs} +28 -23
- package/dist/{provider-BaVmi4Hi.mjs → events-lujPA3gQ.mjs} +80 -17
- package/dist/{exports-CG0P8Qi4.mjs → exports-BnUZuRm9.mjs} +146 -80
- package/dist/exports-u5mApVvn.d.mts +5 -0
- package/dist/{folds-8wRRXjAt.d.mts → folds-DLUzfibJ.d.mts} +13 -40
- package/dist/{folds-DGYkMW19.mjs → folds-DsWfIftc.mjs} +3 -22
- package/dist/{index-BygAXP7t.d.mts → index-UXpTPWNc.d.mts} +2 -2
- package/dist/index.d.mts +7 -7
- package/dist/{index.default-DhkgpfR2.mjs → index.default-Dp8gexln.mjs} +1 -1
- package/dist/index.mjs +5 -5
- package/dist/index.node.d.mts +7 -7
- package/dist/index.node.mjs +3 -3
- package/dist/inspect/app.js +62 -61
- package/dist/inspect/engine.js +3 -3
- package/dist/{main-D2s-QBOK.mjs → main-CcYDo9Hb.mjs} +240 -127
- package/dist/{middleware-DlJQYiwV.mjs → middleware-BavYSDUa.mjs} +1 -1
- package/dist/{node-D8Rtg1su.mjs → node-BgeGcwX0.mjs} +7 -3
- package/dist/{project-C_2xs57L.mjs → project-4Vl7_uy5.mjs} +1 -1
- package/dist/{provider-Bm46LAdp.d.mts → provider-gynDUoyW.d.mts} +13 -43
- package/dist/{redis-tables-BWJZHUGg.mjs → redis-tables-BFRj_SEJ.mjs} +1 -19
- package/dist/{reducers-8jqLewgw.mjs → reducers-DQVSP3kk.mjs} +72 -75
- package/dist/{serve-lPoBDEds.mjs → serve-Bplieh0C.mjs} +6 -6
- package/dist/{server-D82a4uMe.mjs → server-wIpAEjpX.mjs} +4 -4
- package/dist/{serving-DKny38LK.mjs → serving-Y7s7VDjB.mjs} +1 -1
- package/dist/{sql-Bj0fk6dn.mjs → sql-E1K5g_ih.mjs} +2 -8
- package/dist/{sqlite-db-Dc8G78XV.mjs → sqlite-db-CzcD_FW8.mjs} +1 -1
- package/dist/{sync-kapso.d.mts → sync-chat-sdk.d.mts} +33 -37
- package/dist/sync-chat-sdk.mjs +44 -0
- package/dist/sync-github.d.mts +5 -18
- package/dist/sync-github.mjs +4 -70
- package/dist/sync-linear.d.mts +3 -3
- package/dist/sync-linear.mjs +2 -3
- package/dist/sync-slack.d.mts +7 -7
- package/dist/sync-slack.mjs +33 -54
- package/dist/sync.d.mts +3 -3
- package/dist/sync.mjs +2 -4
- package/dist/{tokens-C5_yGRlL.mjs → tokens-C7kYyrAG.mjs} +15 -6
- package/dist/{types-shZmGZ-q.d.mts → types-CmrFjpml.d.mts} +1 -3
- package/dist/{watchers-hash-B_5b0-ZG.mjs → watchers-hash-CurCzwhe.mjs} +85 -105
- package/docs/01-board/01-mounting.md +2 -2
- package/docs/01-board/03-identity.md +5 -6
- package/docs/01-board/04-messages.md +7 -4
- package/docs/01-board/05-reading.md +2 -1
- package/docs/01-board/06-watchers.md +8 -6
- package/docs/01-board/08-middleware.md +1 -1
- package/docs/01-board/09-access.md +145 -14
- package/docs/02-sync/01-overview.md +19 -26
- package/docs/02-sync/02-functions.md +8 -9
- package/docs/02-sync/03-slack.md +5 -5
- package/docs/02-sync/04-github.md +2 -2
- package/docs/02-sync/06-providers.md +91 -62
- package/docs/03-guides/01-coding-agents.md +1 -1
- package/docs/03-guides/03-ci.md +7 -4
- package/docs/04-reference/01-cli.md +100 -51
- package/docs/04-reference/02-board.md +56 -23
- package/docs/04-reference/03-http.md +59 -32
- package/docs/04-reference/04-log.md +8 -11
- package/docs/04-reference/05-conformance.md +35 -6
- package/docs/index.md +2 -2
- package/package.json +6 -9
- package/sql/postgres/board.sql +1 -1
- package/sql/postgres/schema.sql +1 -1
- package/dist/events-qf5XG5VQ.mjs +0 -75
- package/dist/exports-CrGA5_yN.d.mts +0 -5
- package/dist/sync-kapso.mjs +0 -89
- package/dist/sync.chat.d.mts +0 -2
- package/dist/sync.chat.mjs +0 -2
- package/dist/users-yryHKFMo.mjs +0 -42
- package/docs/02-sync/05-whatsapp.md +0 -152
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { i as fileSize, n as DIRECT_UPLOAD_BYTES_MAX } from "./files-SniSmeEr.mjs";
|
|
2
|
-
import { a as AttachmentId } from "./schemas-DBmUO6pr.mjs";
|
|
3
|
-
import { d as VERSION, i as withMentions } from "./watchers-hash-
|
|
2
|
+
import { a as AttachmentId, m as MESSAGE_TEXT_MAX } from "./schemas-DBmUO6pr.mjs";
|
|
3
|
+
import { d as VERSION, i as withMentions } from "./watchers-hash-CurCzwhe.mjs";
|
|
4
4
|
import { n as displayEmoji, r as normalizeEmoji } from "./emoji-CTLpvH-A.mjs";
|
|
5
|
-
import { u as BoardError } from "./errors-
|
|
6
|
-
import { i as groups, n as filters$1, o as options, r as globalOptions, s as usage$1, t as commands } from "./commands-
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { t as
|
|
10
|
-
import { t as
|
|
11
|
-
import {
|
|
5
|
+
import { u as BoardError } from "./errors-CJXhhzvT.mjs";
|
|
6
|
+
import { i as groups, n as filters$1, o as options, r as globalOptions, s as usage$1, t as commands } from "./commands-DsnQKTdB.mjs";
|
|
7
|
+
import { i as parseScope } from "./access-CY5xVMIK.mjs";
|
|
8
|
+
import { a as handFetch, d as vercelProjectFile, n as boardUrl, o as handLogin, r as connect } from "./node-BgeGcwX0.mjs";
|
|
9
|
+
import { t as http } from "./backend-http-CoaCghuJ.mjs";
|
|
10
|
+
import { t as board } from "./server-wIpAEjpX.mjs";
|
|
11
|
+
import { t as conformance } from "./conformance-3RBKxwbp.mjs";
|
|
12
|
+
import { n as isApiMessageId } from "./backend-vercel-CVxoTNF2.mjs";
|
|
13
|
+
import { n as handTeam, r as vercel, t as credentialSource } from "./backend-vercel-BE65okBC.mjs";
|
|
12
14
|
import { t as displayText } from "./bots-CGkO76qH.mjs";
|
|
13
15
|
import { spawn } from "node:child_process";
|
|
14
16
|
import { readFile, stat, writeFile } from "node:fs/promises";
|
|
@@ -34,7 +36,6 @@ function authorName(message) {
|
|
|
34
36
|
if (!author) return message.by.actor;
|
|
35
37
|
const slash = author.handle.indexOf("/");
|
|
36
38
|
if (message.by.profile !== null && slash !== -1) return `${author.name} via ${author.handle.slice(0, slash)}`;
|
|
37
|
-
if (author.person && author.person.handle !== author.handle) return `${author.name} (${author.person.handle})`;
|
|
38
39
|
return author.name;
|
|
39
40
|
}
|
|
40
41
|
function ago(iso, now = Date.now()) {
|
|
@@ -161,6 +162,36 @@ function formatAccess(access) {
|
|
|
161
162
|
return `${pattern.padEnd(width)} ${permissions.includes("manage") ? "all" : permissions.length === 0 ? "nothing" : permissions.join(" ")}`;
|
|
162
163
|
});
|
|
163
164
|
}
|
|
165
|
+
/** What a grant or token may do, as `--can` takes it: `dev/=read,post;ci/=read`, or `all`. */
|
|
166
|
+
function formatCan(can) {
|
|
167
|
+
const patterns = Object.keys(can);
|
|
168
|
+
if (patterns.length === 1 && patterns[0] === "*" && can["*"].includes("manage")) return "all";
|
|
169
|
+
if (patterns.length === 0) return "nothing";
|
|
170
|
+
return patterns.map((pattern) => `${pattern}=${can[pattern].includes("manage") ? "all" : can[pattern].join(",")}`).join(";");
|
|
171
|
+
}
|
|
172
|
+
/** Rows of cells, each column padded to its widest, two spaces apart. */
|
|
173
|
+
const table = (rows) => {
|
|
174
|
+
const widths = rows[0].map((_, column) => Math.max(...rows.map((row) => row[column].length)));
|
|
175
|
+
return rows.map((row) => row.map((cell, column) => column === row.length - 1 ? cell : cell.padEnd(widths[column])).join(" ").trimEnd()).join("\n");
|
|
176
|
+
};
|
|
177
|
+
/** Each grant on a row: its ID, its issuer, the claims it matches, and what it lets do. */
|
|
178
|
+
function formatGrants(grants) {
|
|
179
|
+
return table(grants.map((grant) => [
|
|
180
|
+
grant.id,
|
|
181
|
+
grant.issuer,
|
|
182
|
+
Object.entries(grant.claims).map(([name, value]) => `${name}=${typeof value === "string" ? value : value.join("|")}`).join(" "),
|
|
183
|
+
formatCan(grant.can)
|
|
184
|
+
]));
|
|
185
|
+
}
|
|
186
|
+
/** Each token on a row: its ID, its name, what it may do, and when it expires. */
|
|
187
|
+
function formatTokens(tokens, now = Date.now()) {
|
|
188
|
+
return table(tokens.map((token) => [
|
|
189
|
+
token.id,
|
|
190
|
+
token.name,
|
|
191
|
+
formatCan(token.can),
|
|
192
|
+
`expires ${until(token.expiresAt, now)}${token.profile !== null ? ` · as ${token.profile}` : ""}${token.parent !== null ? ` · minted with ${token.parent}` : ""}`
|
|
193
|
+
]));
|
|
194
|
+
}
|
|
164
195
|
/** `90m` → `1h30m`, `1d`: milliseconds as a duration flag would say them. */
|
|
165
196
|
function span(ms) {
|
|
166
197
|
const parts = [];
|
|
@@ -448,9 +479,9 @@ function rows(entries, pad = padOf(entries)) {
|
|
|
448
479
|
/** An option as help writes it: `--limit <N>`, `-h, --help`, `--label <k[=v|w]>...`. */
|
|
449
480
|
const flag = (option) => `${option.short ? `-${option.short}, ` : ""}--${option.name}${option.value ? option.optionalValue ? ` [${option.value}]` : ` <${option.value}>` : ""}${option.multiple ? "..." : ""}`;
|
|
450
481
|
const shown = (list) => list.filter((option) => !option.hidden);
|
|
451
|
-
/** A command's rows in the list: itself, when it runs alone, and each of its subcommands. */
|
|
482
|
+
/** A command's rows in the list: itself, when it runs alone and no subcommand is what it runs, and each of its subcommands. */
|
|
452
483
|
function listed(command) {
|
|
453
|
-
return [...!command.subcommands || command.runsWithoutSubcommand ? [[usage$1([command]), command.description]] : [], ...(command.subcommands ?? []).filter((sub) => !sub.hidden).map((sub) => [usage$1([command, sub]), sub.description])];
|
|
484
|
+
return [...!command.subcommands || command.runsWithoutSubcommand && !command.subcommands.some((sub) => sub.default) ? [[usage$1([command]), command.description]] : [], ...(command.subcommands ?? []).filter((sub) => !sub.hidden).map((sub) => [usage$1([command, sub]), sub.description])];
|
|
454
485
|
}
|
|
455
486
|
/** Every command, by group, then what the app adds (`serve`, `inspect`), and the options they share. */
|
|
456
487
|
function rootHelp(app, version) {
|
|
@@ -497,7 +528,7 @@ function commandHelp(name, path) {
|
|
|
497
528
|
return lines.join("\n");
|
|
498
529
|
}
|
|
499
530
|
/**
|
|
500
|
-
* The command `words` name, and its subcommand when they name one (`
|
|
531
|
+
* The command `words` name, and its subcommand when they name one (`schedule cancel`, `sources slack
|
|
501
532
|
* read`): what `--help` shows the page of. Null when the first word names no command.
|
|
502
533
|
*/
|
|
503
534
|
function commandPath(words, all) {
|
|
@@ -735,7 +766,7 @@ let typed = [];
|
|
|
735
766
|
let warnings = [];
|
|
736
767
|
/** The board this run reached by its URL, for a failure to name. */
|
|
737
768
|
let reached = null;
|
|
738
|
-
/** The help `words` ask for: a command's page when they name one (`read`, `
|
|
769
|
+
/** The help `words` ask for: a command's page when they name one (`read`, `sources read`), or else every command. */
|
|
739
770
|
function help(words = []) {
|
|
740
771
|
const own = Object.values(app.commands).map((command) => command.spec);
|
|
741
772
|
const path = commandPath(words, [...commands, ...own]);
|
|
@@ -775,7 +806,11 @@ function parse(argv) {
|
|
|
775
806
|
function parseFailure(error, argv, word) {
|
|
776
807
|
const option = error.message.match(/--[a-z][\w-]*/)?.[0] ?? /'(-[^' ,]+)/.exec(error.message)?.[1];
|
|
777
808
|
if (error.code === "ERR_PARSE_ARGS_UNKNOWN_OPTION" && option) {
|
|
778
|
-
const
|
|
809
|
+
const token = /^Unknown option '(.*?)'\. /.exec(error.message)?.[1];
|
|
810
|
+
const dash = argv.indexOf("--");
|
|
811
|
+
const options = dash === -1 ? argv : argv.slice(0, dash);
|
|
812
|
+
const spaced = token === void 0 ? void 0 : options.find((arg) => /\s/.test(arg) && (token.startsWith("--") ? arg === token : arg.startsWith(token)));
|
|
813
|
+
const guess = !spaced && option.startsWith("--") ? closest(option.slice(2), optionsOf(word)) : void 0;
|
|
779
814
|
const next = [{
|
|
780
815
|
instruction: "See all options",
|
|
781
816
|
argv: [
|
|
@@ -784,17 +819,18 @@ function parseFailure(error, argv, word) {
|
|
|
784
819
|
"--help"
|
|
785
820
|
]
|
|
786
821
|
}];
|
|
787
|
-
const
|
|
822
|
+
const unknown = spaced ?? option;
|
|
823
|
+
const at = argv.indexOf(unknown);
|
|
788
824
|
if (word && TEXT.has(word) && at !== -1) {
|
|
789
825
|
const rest = [...argv.slice(0, at), ...argv.slice(at + 1)];
|
|
790
826
|
const dash = rest.indexOf("--");
|
|
791
827
|
const text = dash === -1 ? [
|
|
792
828
|
...rest,
|
|
793
829
|
"--",
|
|
794
|
-
|
|
830
|
+
unknown
|
|
795
831
|
] : [
|
|
796
832
|
...rest.slice(0, dash + 1),
|
|
797
|
-
|
|
833
|
+
unknown,
|
|
798
834
|
...rest.slice(dash + 1)
|
|
799
835
|
];
|
|
800
836
|
next.push({
|
|
@@ -802,7 +838,8 @@ function parseFailure(error, argv, word) {
|
|
|
802
838
|
argv: [...cli(), ...text]
|
|
803
839
|
});
|
|
804
840
|
}
|
|
805
|
-
|
|
841
|
+
const where = `${named()}${word ? ` ${word}` : ""}`;
|
|
842
|
+
return usage(`Unknown option ${spaced ? JSON.stringify(spaced) : option} for ${where}.${guess ? ` Did you mean --${guess}?` : ""}`, {
|
|
806
843
|
reason: "unknown_option",
|
|
807
844
|
next
|
|
808
845
|
});
|
|
@@ -840,7 +877,7 @@ const result = (value) => io.write(`${JSON.stringify(warnings.length ? {
|
|
|
840
877
|
...value,
|
|
841
878
|
warnings
|
|
842
879
|
} : value, null, io.tty ? 2 : void 0)}\n`);
|
|
843
|
-
/** One line of a JSON stream (`tail
|
|
880
|
+
/** One line of a JSON stream (`tail`): compact, wherever it goes. */
|
|
844
881
|
const line = (value) => io.write(`${JSON.stringify(value)}\n`);
|
|
845
882
|
/** A message's ID as you'd write it: `#812` or `812`. It's passed to the board as it is. */
|
|
846
883
|
function messageId(value, what = "message ID") {
|
|
@@ -855,10 +892,12 @@ const tooLarge = (path) => new Failed({
|
|
|
855
892
|
reason: "payload_too_large",
|
|
856
893
|
message: `Can't attach ${path}. It's over ${DIRECT_UPLOAD_BYTES_MAX / 1024 / 1024} MB, the most an attachment can be.`
|
|
857
894
|
});
|
|
858
|
-
/** Whether an
|
|
859
|
-
const
|
|
860
|
-
/**
|
|
861
|
-
const
|
|
895
|
+
/** Whether an ID goes in and out bare: a number, or one Vercel's API hands out (`msg_…`), a message even where a channel has its name. */
|
|
896
|
+
const bareId = (value) => /^\d+$/.test(value) || isApiMessageId(value);
|
|
897
|
+
/** Whether an argument names a message rather than a channel: `#<id>`, or an ID that goes bare. */
|
|
898
|
+
const isMessageRef = (value) => /^#[^\s/]+$/.test(value) || bareId(value);
|
|
899
|
+
/** A message's ID as it's passed back: bare when it goes bare, `#<id>` when it could be a channel's name. */
|
|
900
|
+
const messageRef = (id) => bareId(id) ? id : `#${id}`;
|
|
862
901
|
/** `--if-revision N`, as an edit or a delete takes it. */
|
|
863
902
|
function ifRevision() {
|
|
864
903
|
const given = flags["if-revision"];
|
|
@@ -875,8 +914,33 @@ function labelPairs(values, wrong = "Labels look like key=value, and {value} isn
|
|
|
875
914
|
}
|
|
876
915
|
return pairs;
|
|
877
916
|
}
|
|
878
|
-
|
|
879
|
-
|
|
917
|
+
/**
|
|
918
|
+
* A message's text: the argument, stdin for `-`, or the file `--text-file` names (`-` for stdin).
|
|
919
|
+
* `optional` when the message can go without, as one with `--attach` files can.
|
|
920
|
+
*/
|
|
921
|
+
async function text(value, { optional = false } = {}) {
|
|
922
|
+
const file = flags["text-file"];
|
|
923
|
+
if (file !== void 0) {
|
|
924
|
+
if (value !== void 0) throw usage("Can't use --text-file with text: pass one or the other.");
|
|
925
|
+
if (file === "-") return (await io.stdin()).replace(/\n$/, "");
|
|
926
|
+
const data = await io.readFile(file).catch((error) => {
|
|
927
|
+
if (!(error instanceof Failed) || error.failure.reason !== "payload_too_large") throw error;
|
|
928
|
+
throw new Failed({
|
|
929
|
+
class: "limit",
|
|
930
|
+
reason: "payload_too_large",
|
|
931
|
+
message: `Can't use ${file} as the text. A message's text is at most ${MESSAGE_TEXT_MAX.toLocaleString("en-US")} characters.`
|
|
932
|
+
});
|
|
933
|
+
});
|
|
934
|
+
if (!data) throw usage(`Can't read ${file}. There's no such file.`, {
|
|
935
|
+
reason: "file_not_found",
|
|
936
|
+
next: []
|
|
937
|
+
});
|
|
938
|
+
return new TextDecoder().decode(data).replace(/\n$/, "");
|
|
939
|
+
}
|
|
940
|
+
if (value === void 0) {
|
|
941
|
+
if (optional) return "";
|
|
942
|
+
throw usage("Missing the message's text: pass it, - to read it from stdin, or --text-file <path>.", { reason: "missing_arguments" });
|
|
943
|
+
}
|
|
880
944
|
if (value !== "-") return value;
|
|
881
945
|
return (await io.stdin()).replace(/\n$/, "");
|
|
882
946
|
}
|
|
@@ -908,6 +972,31 @@ function scheduleId(value) {
|
|
|
908
972
|
if (!/^[^\s/]+$/.test(value)) throw usage(`${value} isn't a schedule ID like s12.`);
|
|
909
973
|
return value;
|
|
910
974
|
}
|
|
975
|
+
/** A grant's or token's ID as the board gave it: `g3`, `t12`, or another board's own. */
|
|
976
|
+
function trustId(what, value) {
|
|
977
|
+
const like = what === "grant" ? "g3" : "t12";
|
|
978
|
+
if (value === void 0) throw usage(`Missing the ${what} ID, like ${like}.`, { reason: "missing_arguments" });
|
|
979
|
+
if (!/^[^\s/]+$/.test(value)) throw usage(`${value} isn't a ${what} ID like ${like}.`);
|
|
980
|
+
return value;
|
|
981
|
+
}
|
|
982
|
+
/** `--can`, as `x-board-scope` writes it: `dev/=read,post;ci/=read`. */
|
|
983
|
+
function canFlag(value) {
|
|
984
|
+
try {
|
|
985
|
+
return parseScope(value);
|
|
986
|
+
} catch (error) {
|
|
987
|
+
throw usage(`${error.message.replace(/x-board-scope/g, "--can")}.`);
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
/** `--claim k=v`, each again: the same name twice is any of its values. */
|
|
991
|
+
function claimPairs(values) {
|
|
992
|
+
const claims = {};
|
|
993
|
+
for (const value of values ?? []) {
|
|
994
|
+
const at = value.indexOf("=");
|
|
995
|
+
if (at <= 0 || at === value.length - 1) throw usage(`Claims look like name=value, and ${value} isn't one.`);
|
|
996
|
+
(claims[value.slice(0, at)] ??= []).push(value.slice(at + 1));
|
|
997
|
+
}
|
|
998
|
+
return Object.fromEntries(Object.entries(claims).map(([name, list]) => [name, list.length === 1 ? list[0] : list]));
|
|
999
|
+
}
|
|
911
1000
|
/** A time flag: anything `Date` reads, as ISO. */
|
|
912
1001
|
function instant(flag, value) {
|
|
913
1002
|
const time = new Date(value);
|
|
@@ -976,11 +1065,12 @@ function doing() {
|
|
|
976
1065
|
case "typing": return `show typing in ${ref(a)}`;
|
|
977
1066
|
case "sync": return b === void 0 ? `list where ${ref(a)} is synced` : `sync ${ref(a)} with ${b}`;
|
|
978
1067
|
case "schedule": return a === "cancel" ? `cancel schedule ${b}` : `schedule a message in ${message ? ref(a) : a ?? "a channel"}`;
|
|
1068
|
+
case "channels": return a === "create" ? `create ${b ?? "the channel"}` : "list channels";
|
|
979
1069
|
case "schedules":
|
|
980
|
-
case "channels":
|
|
981
1070
|
case "actors": return `list ${command}`;
|
|
1071
|
+
case "grants": return a === "create" ? `grant ${b ?? "an issuer"}` : a === "revoke" ? `revoke grant ${b}` : "list grants";
|
|
1072
|
+
case "tokens": return a === "create" ? `mint token ${b ?? ""}`.trimEnd() : a === "revoke" ? `revoke token ${b}` : "list tokens";
|
|
982
1073
|
case "sources": return b === void 0 ? "list sources" : `${b} ${c ?? "it"} on ${a}`;
|
|
983
|
-
case "identity": return a === "link" ? `link your account on ${b}` : a === "unlink" ? `unlink ${b}` : "list your linked accounts";
|
|
984
1074
|
case "download": return `download ${a ?? "the attachment"}`;
|
|
985
1075
|
case "inbox": return `read ${a}'s inbox`;
|
|
986
1076
|
case "tail": return `follow ${a ?? "the board"}`;
|
|
@@ -1013,6 +1103,7 @@ function missing() {
|
|
|
1013
1103
|
"schedule"
|
|
1014
1104
|
].includes(command) && isMessageRef(a)) return `message ${ref(a)}`;
|
|
1015
1105
|
if (command === "schedule" && a === "cancel" && b !== void 0) return `schedule ${b}`;
|
|
1106
|
+
if ((command === "grants" || command === "tokens") && a === "revoke" && b !== void 0) return `${command === "grants" ? "grant" : "token"} ${b}`;
|
|
1016
1107
|
if (command === "download") return `attachment ${a}`;
|
|
1017
1108
|
}
|
|
1018
1109
|
/**
|
|
@@ -1115,7 +1206,7 @@ function failureOf(error) {
|
|
|
1115
1206
|
});
|
|
1116
1207
|
const specific = (fallback) => /^[a-z]+(_[a-z]+)+$/.test(code) && code !== "invalid_request" && code !== "remote_error" ? code : fallback;
|
|
1117
1208
|
if (status === 400) return theirs("usage", specific("invalid_arguments"), `Can't ${doing()}.`);
|
|
1118
|
-
if (status === 401) return theirs("auth", "login_required", "The board didn't accept your credentials.", [{
|
|
1209
|
+
if (status === 401) return theirs("auth", "login_required", "The board didn't accept your credentials.", process.env.BOARD_TOKEN ? [{ instruction: "Pass a token it accepts in BOARD_TOKEN, or unset it" }] : [{
|
|
1119
1210
|
instruction: "Log in again",
|
|
1120
1211
|
argv: ["vercel", "login"]
|
|
1121
1212
|
}]);
|
|
@@ -1210,7 +1301,10 @@ function connection(url = flags.url, options = {}) {
|
|
|
1210
1301
|
const team = flags.scope ?? flags.team;
|
|
1211
1302
|
const configured = url ?? (team === void 0 ? configuredUrl() : null);
|
|
1212
1303
|
if (configured === null) {
|
|
1213
|
-
const board$1 = board({ backend: vercel(
|
|
1304
|
+
const board$1 = board({ backend: vercel({
|
|
1305
|
+
...team !== void 0 ? { team } : {},
|
|
1306
|
+
...sending(options.token)
|
|
1307
|
+
}) });
|
|
1214
1308
|
return {
|
|
1215
1309
|
url: null,
|
|
1216
1310
|
transport: { source: credentialSource },
|
|
@@ -1221,7 +1315,10 @@ function connection(url = flags.url, options = {}) {
|
|
|
1221
1315
|
reached = at;
|
|
1222
1316
|
const onVercel = vercelBoard(at);
|
|
1223
1317
|
if (onVercel) {
|
|
1224
|
-
const board$3 = board({ backend: vercel(
|
|
1318
|
+
const board$3 = board({ backend: vercel({
|
|
1319
|
+
...onVercel,
|
|
1320
|
+
...sending(options.token)
|
|
1321
|
+
}) });
|
|
1225
1322
|
return {
|
|
1226
1323
|
url: at,
|
|
1227
1324
|
transport: { source: credentialSource },
|
|
@@ -1240,6 +1337,15 @@ function connection(url = flags.url, options = {}) {
|
|
|
1240
1337
|
board: profile !== void 0 ? board$2.as(profile) : board$2
|
|
1241
1338
|
};
|
|
1242
1339
|
}
|
|
1340
|
+
/** For Vercel's API, `token` in place of your own credentials: a board token's secret. */
|
|
1341
|
+
function sending(token) {
|
|
1342
|
+
if (token === void 0) return {};
|
|
1343
|
+
return { fetch: (input, init) => {
|
|
1344
|
+
const request = new Request(input, init);
|
|
1345
|
+
request.headers.set("authorization", `Bearer ${token}`);
|
|
1346
|
+
return globalThis.fetch(request);
|
|
1347
|
+
} };
|
|
1348
|
+
}
|
|
1243
1349
|
/** A handle on the board this command talks to: `vb()`'s, as `--as` says, or the one `connection()` finds. */
|
|
1244
1350
|
function client() {
|
|
1245
1351
|
if (!io.board) return connection().board;
|
|
@@ -1291,6 +1397,7 @@ function printDone(id, outcome) {
|
|
|
1291
1397
|
message: { id },
|
|
1292
1398
|
outcome
|
|
1293
1399
|
});
|
|
1400
|
+
else out(`${outcome} ${messageRef(id)}`);
|
|
1294
1401
|
}
|
|
1295
1402
|
/** Best-effort: the URL is printed either way. */
|
|
1296
1403
|
/** `url`, when it's an http or https URL as `new URL` reads it: the only kind the CLI opens, so a board can't hand the opener a flag or another scheme. */
|
|
@@ -1323,94 +1430,6 @@ function portFlag() {
|
|
|
1323
1430
|
if (port !== void 0 && !(Number.isInteger(port) && port >= 0 && port <= 65535)) throw usage(`${flags.port} isn't a port.`, { reason: "invalid_port" });
|
|
1324
1431
|
return port;
|
|
1325
1432
|
}
|
|
1326
|
-
/** How long `identity link` waits for the sign-in or the code. */
|
|
1327
|
-
const LINK_WAIT_MS = 6e5;
|
|
1328
|
-
async function identity(args) {
|
|
1329
|
-
const board = client();
|
|
1330
|
-
const [sub, target] = args;
|
|
1331
|
-
if (sub === void 0) {
|
|
1332
|
-
const view = await board.identity();
|
|
1333
|
-
if (flags.json) return result(view), 0;
|
|
1334
|
-
if (view.links.length === 0) out("no linked accounts");
|
|
1335
|
-
for (const link of view.links) out(`${link.handle ? `@${link.handle} ` : ""}${link.actor} by ${link.method === "code" ? "code" : "sign-in"} · ${link.at}`);
|
|
1336
|
-
if (view.unlinked?.length) out(`not linked ${view.unlinked.join(", ")} (${named()} identity link <key>)`);
|
|
1337
|
-
return 0;
|
|
1338
|
-
}
|
|
1339
|
-
if (sub === "unlink") {
|
|
1340
|
-
if (!target) throw usage(`Missing the account to unlink: a handle or actor ID from \`${named()} identity\`.`, { reason: "missing_arguments" });
|
|
1341
|
-
if (args.length !== 2) throw usage("identity unlink takes one account.");
|
|
1342
|
-
const unlinked = await board.unlinkAccount(target);
|
|
1343
|
-
if (flags.json) result({
|
|
1344
|
-
...unlinked,
|
|
1345
|
-
outcome: "unlinked"
|
|
1346
|
-
});
|
|
1347
|
-
else out(`unlinked ${unlinked.actor}`);
|
|
1348
|
-
return 0;
|
|
1349
|
-
}
|
|
1350
|
-
if (sub !== "link") throw usage(`Unknown command ${sub} for ${named()} identity.`, { reason: "unknown_command" });
|
|
1351
|
-
if (!target) throw usage("Missing the sync entry to link your account on, such as slack.", { reason: "missing_arguments" });
|
|
1352
|
-
if (args.length !== 2) throw usage("identity link takes one sync entry.");
|
|
1353
|
-
const before = new Set((await board.identity()).links.map((link) => `${link.actor}|${link.at}`));
|
|
1354
|
-
const platform = (await board.discovery().catch(() => null))?.sync.find((entry) => entry.key === target)?.platform ?? target;
|
|
1355
|
-
const { code, expiresAt, signIn } = await board.syncCode(target);
|
|
1356
|
-
const consent = signIn !== void 0 && !flags.code;
|
|
1357
|
-
if (consent && browsable(signIn) === null) throw new Failed({
|
|
1358
|
-
class: "platform",
|
|
1359
|
-
reason: "invalid_sign_in",
|
|
1360
|
-
message: "The board's sign-in isn't an http or https URL.",
|
|
1361
|
-
details: [JSON.stringify(signIn)],
|
|
1362
|
-
data: { signIn }
|
|
1363
|
-
});
|
|
1364
|
-
if (flags.json) line({
|
|
1365
|
-
type: "code",
|
|
1366
|
-
sync: target,
|
|
1367
|
-
platform,
|
|
1368
|
-
code,
|
|
1369
|
-
expiresAt,
|
|
1370
|
-
...signIn !== void 0 ? { signIn } : {}
|
|
1371
|
-
});
|
|
1372
|
-
const until = Date.now() + LINK_WAIT_MS;
|
|
1373
|
-
const sleep = () => new Promise((resolve) => setTimeout(resolve, 2e3));
|
|
1374
|
-
/** An account linked on that platform since this run began: where the code or the sign-in landed. */
|
|
1375
|
-
const linkedSince = async () => (await board.identity()).links.find((link) => link.actor.startsWith(`${platform}:user:`) && !before.has(`${link.actor}|${link.at}`));
|
|
1376
|
-
if (consent) {
|
|
1377
|
-
if (!flags.json) {
|
|
1378
|
-
out(`Sign in to ${platform} as yourself to link it (and to post as you there):\n\n ${signIn}\n`);
|
|
1379
|
-
out(`Only open it yourself: whoever completes it links their account to you.`);
|
|
1380
|
-
}
|
|
1381
|
-
if (!flags["no-open"] && !flags.json) openBrowser(signIn);
|
|
1382
|
-
} else if (!flags.json) {
|
|
1383
|
-
const minutes = Math.round((Date.parse(expiresAt) - Date.now()) / 6e4);
|
|
1384
|
-
out(`From your ${platform} account, post this as a message anywhere the board syncs, within ${minutes} minutes:\n\n ${code}\n`);
|
|
1385
|
-
}
|
|
1386
|
-
if (flags["no-wait"]) return 0;
|
|
1387
|
-
while (Date.now() < Math.min(until, consent ? Infinity : Date.parse(expiresAt))) {
|
|
1388
|
-
await sleep();
|
|
1389
|
-
const linked = await linkedSince();
|
|
1390
|
-
if (linked) {
|
|
1391
|
-
if (flags.json) line({
|
|
1392
|
-
type: "linked",
|
|
1393
|
-
account: linked
|
|
1394
|
-
});
|
|
1395
|
-
else out(`linked ${linked.handle ? `@${linked.handle} ` : ""}(${linked.actor})`);
|
|
1396
|
-
return 0;
|
|
1397
|
-
}
|
|
1398
|
-
}
|
|
1399
|
-
throw new Failed({
|
|
1400
|
-
class: "timeout",
|
|
1401
|
-
reason: "timeout",
|
|
1402
|
-
message: consent ? "Nothing linked an account within 10 minutes." : "The code expired before a message carried it.",
|
|
1403
|
-
next: [{
|
|
1404
|
-
instruction: "Try again",
|
|
1405
|
-
argv: [
|
|
1406
|
-
...cli(),
|
|
1407
|
-
"identity",
|
|
1408
|
-
"link",
|
|
1409
|
-
target
|
|
1410
|
-
]
|
|
1411
|
-
}]
|
|
1412
|
-
});
|
|
1413
|
-
}
|
|
1414
1433
|
async function run(command, args) {
|
|
1415
1434
|
switch (command) {
|
|
1416
1435
|
case void 0:
|
|
@@ -1446,12 +1465,31 @@ async function run(command, args) {
|
|
|
1446
1465
|
}
|
|
1447
1466
|
case "conformance": {
|
|
1448
1467
|
if (args.length > 0) throw usage("conformance takes no arguments: pass its channel with --channel.");
|
|
1449
|
-
const
|
|
1468
|
+
const withToken = io.board ? {} : { withToken: (secret) => connection(flags.url, { token: secret }).board };
|
|
1469
|
+
const report = await conformance(client(), {
|
|
1470
|
+
...flags.channel ? { channel: flags.channel } : {},
|
|
1471
|
+
...withToken
|
|
1472
|
+
});
|
|
1450
1473
|
if (flags.json) result(report);
|
|
1451
1474
|
else out(formatConformance(report));
|
|
1452
1475
|
return report.ok ? 0 : 1;
|
|
1453
1476
|
}
|
|
1454
1477
|
case "channels": {
|
|
1478
|
+
const [sub, ...rest] = args;
|
|
1479
|
+
if (sub === "create") {
|
|
1480
|
+
const [path, extra] = rest;
|
|
1481
|
+
if (!path) throw usage("Missing the channel to create, such as dev/alerts.", { reason: "missing_arguments" });
|
|
1482
|
+
if (extra !== void 0) throw usage(`channels create takes one channel: ${extra} is one too many.`);
|
|
1483
|
+
const { channel, created } = await client().createChannel(path);
|
|
1484
|
+
if (flags.json) result({
|
|
1485
|
+
channel,
|
|
1486
|
+
outcome: created ? "created" : "unchanged"
|
|
1487
|
+
});
|
|
1488
|
+
else out(created ? `created ${channel.path}` : `${channel.path} already exists`);
|
|
1489
|
+
return 0;
|
|
1490
|
+
}
|
|
1491
|
+
if (sub !== void 0 && sub !== "list") throw usage(`Unknown command ${sub} for ${named()} channels.`, { reason: "unknown_command" });
|
|
1492
|
+
if (rest.length > 0) throw usage(`channels list takes no arguments: ${rest[0]} is one too many.`);
|
|
1455
1493
|
const channels = await client().channels();
|
|
1456
1494
|
if (flags.json) return result({ channels }), 0;
|
|
1457
1495
|
if (channels.length === 0) return out("no channels yet"), 0;
|
|
@@ -1463,17 +1501,18 @@ async function run(command, args) {
|
|
|
1463
1501
|
group = prefix;
|
|
1464
1502
|
}
|
|
1465
1503
|
const count = (n, one, many) => `${n} ${n === 1 ? one : many}`;
|
|
1466
|
-
|
|
1504
|
+
const { threads, messages, lastIndex } = channel;
|
|
1505
|
+
const counted = threads !== void 0 && messages !== void 0 ? ` ${count(threads, "thread", "threads")} · ${count(messages, "message", "messages")}${lastIndex ? ` · last #${lastIndex}` : ""}` : "";
|
|
1506
|
+
out(`${prefix ? " " : ""}${channel.path}${counted}`);
|
|
1467
1507
|
}
|
|
1468
1508
|
return 0;
|
|
1469
1509
|
}
|
|
1470
1510
|
case "actors": {
|
|
1471
1511
|
const actors = await client().actors();
|
|
1472
1512
|
if (flags.json) return result({ actors }), 0;
|
|
1473
|
-
for (const actor of actors) out(`@${actor.handle} ${actor.name} ${actor.id}
|
|
1513
|
+
for (const actor of actors) out(`@${actor.handle} ${actor.name} ${actor.id}`);
|
|
1474
1514
|
return 0;
|
|
1475
1515
|
}
|
|
1476
|
-
case "identity": return identity(args);
|
|
1477
1516
|
case "read": {
|
|
1478
1517
|
const target = args[0];
|
|
1479
1518
|
const board = client();
|
|
@@ -1544,7 +1583,7 @@ async function run(command, args) {
|
|
|
1544
1583
|
if (flags.sync?.length && flags["no-sync"]) throw usage("Can't use --sync with --no-sync.");
|
|
1545
1584
|
if (re === void 0 && flags.after !== void 0) throw usage("Can't use --after on a new thread. It's for replies: the thread's newest message.");
|
|
1546
1585
|
const board = client();
|
|
1547
|
-
const content = body
|
|
1586
|
+
const content = await text(body, { optional: !!flags.attach?.length });
|
|
1548
1587
|
const files = await attachments(board);
|
|
1549
1588
|
const options = {
|
|
1550
1589
|
text: content,
|
|
@@ -1567,11 +1606,12 @@ async function run(command, args) {
|
|
|
1567
1606
|
case "reply": {
|
|
1568
1607
|
const id = messageId(args[0]);
|
|
1569
1608
|
const board = client();
|
|
1570
|
-
const content = args[1]
|
|
1609
|
+
const content = await text(args[1], { optional: !!flags.attach?.length });
|
|
1571
1610
|
const files = await attachments(board);
|
|
1572
1611
|
const message = await board.reply(id, {
|
|
1573
1612
|
text: content,
|
|
1574
1613
|
...files.length ? { attachments: files } : {},
|
|
1614
|
+
...flags.label?.length ? { labels: labelPairs(flags.label) } : {},
|
|
1575
1615
|
...flags["idempotency-key"] ? { id: flags["idempotency-key"] } : {},
|
|
1576
1616
|
...flags["no-sync"] ? { noSync: true } : {},
|
|
1577
1617
|
...flags.after !== void 0 ? { after: messageId(flags.after) } : {}
|
|
@@ -1597,7 +1637,7 @@ async function run(command, args) {
|
|
|
1597
1637
|
const times = flags.times === void 0 ? void 0 : Number(flags.times);
|
|
1598
1638
|
if (times !== void 0 && !(Number.isInteger(times) && times > 0)) throw usage(`--times takes a count, and ${flags.times} isn't one.`);
|
|
1599
1639
|
const board = client();
|
|
1600
|
-
const content = body
|
|
1640
|
+
const content = await text(body, { optional: !!flags.attach?.length });
|
|
1601
1641
|
const files = await attachments(board);
|
|
1602
1642
|
const where = isMessageRef(target) ? { re: messageId(target) } : target;
|
|
1603
1643
|
const schedule = await board.schedule(where, {
|
|
@@ -1620,6 +1660,80 @@ async function run(command, args) {
|
|
|
1620
1660
|
else out(formatSchedule(schedule));
|
|
1621
1661
|
return 0;
|
|
1622
1662
|
}
|
|
1663
|
+
case "grants": {
|
|
1664
|
+
const [verb, ...rest] = args;
|
|
1665
|
+
if (verb === void 0 || verb === "list") {
|
|
1666
|
+
if (rest.length > 0) throw usage(`grants list takes no arguments: ${rest[0]} is one too many.`);
|
|
1667
|
+
const list = await client().grants();
|
|
1668
|
+
if (flags.json) return result({ grants: list }), 0;
|
|
1669
|
+
out(list.length === 0 ? "no grants" : formatGrants(list));
|
|
1670
|
+
return 0;
|
|
1671
|
+
}
|
|
1672
|
+
if (verb === "revoke") {
|
|
1673
|
+
const id = trustId("grant", rest[0]);
|
|
1674
|
+
const { revoked } = await client().revokeGrant(id);
|
|
1675
|
+
if (flags.json) result({
|
|
1676
|
+
grant: id,
|
|
1677
|
+
outcome: revoked ? "revoked" : "unchanged"
|
|
1678
|
+
});
|
|
1679
|
+
else out(revoked ? `revoked ${id}` : `${id} is already gone`);
|
|
1680
|
+
return 0;
|
|
1681
|
+
}
|
|
1682
|
+
if (verb !== "create") throw usage(`Unknown command ${verb} for ${named()} grants.`, { reason: "unknown_command" });
|
|
1683
|
+
const [issuer, extra] = rest;
|
|
1684
|
+
if (!issuer) throw usage("Missing the issuer to grant: vercel, github, or an https URL.", { reason: "missing_arguments" });
|
|
1685
|
+
if (extra !== void 0) throw usage(`grants create takes one issuer, and its claims as --claim name=value: ${extra} is one too many.`);
|
|
1686
|
+
const claims = claimPairs(flags.claim);
|
|
1687
|
+
if (Object.keys(claims).length === 0) throw usage(`Missing the claims ${issuer}'s tokens must carry: pass --claim name=value.`, { reason: "missing_arguments" });
|
|
1688
|
+
const { grant, created } = await client().createGrant({
|
|
1689
|
+
issuer,
|
|
1690
|
+
claims,
|
|
1691
|
+
...flags.can !== void 0 ? { can: canFlag(flags.can) } : {}
|
|
1692
|
+
});
|
|
1693
|
+
if (flags.json) result({
|
|
1694
|
+
grant,
|
|
1695
|
+
outcome: created ? "granted" : "updated"
|
|
1696
|
+
});
|
|
1697
|
+
else out(`${created ? "granted" : "updated"} ${grant.id}`);
|
|
1698
|
+
return 0;
|
|
1699
|
+
}
|
|
1700
|
+
case "tokens": {
|
|
1701
|
+
const [verb, ...rest] = args;
|
|
1702
|
+
if (verb === void 0 || verb === "list") {
|
|
1703
|
+
if (rest.length > 0) throw usage(`tokens list takes no arguments: ${rest[0]} is one too many.`);
|
|
1704
|
+
const list = await client().tokens();
|
|
1705
|
+
if (flags.json) return result({ tokens: list }), 0;
|
|
1706
|
+
out(list.length === 0 ? "no tokens" : formatTokens(list));
|
|
1707
|
+
return 0;
|
|
1708
|
+
}
|
|
1709
|
+
if (verb === "revoke") {
|
|
1710
|
+
const id = trustId("token", rest[0]);
|
|
1711
|
+
const { revoked } = await client().revokeToken(id);
|
|
1712
|
+
if (flags.json) result({
|
|
1713
|
+
token: id,
|
|
1714
|
+
outcome: revoked ? "revoked" : "unchanged"
|
|
1715
|
+
});
|
|
1716
|
+
else out(revoked ? `revoked ${id}` : `${id} isn't a live token of yours`);
|
|
1717
|
+
return 0;
|
|
1718
|
+
}
|
|
1719
|
+
if (verb !== "create") throw usage(`Unknown command ${verb} for ${named()} tokens.`, { reason: "unknown_command" });
|
|
1720
|
+
const [name, extra] = rest;
|
|
1721
|
+
if (!name) throw usage("Missing a name for the token, like feedback-widget.", { reason: "missing_arguments" });
|
|
1722
|
+
if (extra !== void 0) throw usage(`tokens create takes one name: ${extra} is one too many.`);
|
|
1723
|
+
const { token, secret } = await client().createToken({
|
|
1724
|
+
name,
|
|
1725
|
+
...flags.can !== void 0 ? { can: canFlag(flags.can) } : {},
|
|
1726
|
+
...flags.profile !== void 0 ? { profile: flags.profile } : {},
|
|
1727
|
+
...flags.session !== void 0 ? { session: flags.session } : {},
|
|
1728
|
+
...flags.expires !== void 0 ? { expires: flags.expires } : {}
|
|
1729
|
+
});
|
|
1730
|
+
if (flags.json) result({
|
|
1731
|
+
token,
|
|
1732
|
+
secret
|
|
1733
|
+
});
|
|
1734
|
+
else out(secret);
|
|
1735
|
+
return 0;
|
|
1736
|
+
}
|
|
1623
1737
|
case "schedules": {
|
|
1624
1738
|
const list = await client().schedules({
|
|
1625
1739
|
...args[0] ? { re: messageId(args[0]) } : {},
|
|
@@ -1935,7 +2049,6 @@ async function runOnce(argv, options) {
|
|
|
1935
2049
|
/** The commands about the machine the CLI runs on, not the board: none of them run in-process. */
|
|
1936
2050
|
const MACHINE = /* @__PURE__ */ new Set([
|
|
1937
2051
|
"whoami",
|
|
1938
|
-
"identity",
|
|
1939
2052
|
"hooks",
|
|
1940
2053
|
"hook",
|
|
1941
2054
|
"serve",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { m as MESSAGE_TEXT_MAX, p as Labels } from "./schemas-DBmUO6pr.mjs";
|
|
2
|
-
import { t as HttpError } from "./errors-
|
|
2
|
+
import { t as HttpError } from "./errors-CJXhhzvT.mjs";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
//#region src/server/middleware.ts
|
|
5
5
|
/** A write the middleware didn't let through: the API answers 422 with what it responded. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { u as BoardError } from "./errors-
|
|
1
|
+
import { u as BoardError } from "./errors-CJXhhzvT.mjs";
|
|
2
2
|
import { execFile } from "node:child_process";
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
4
|
import { mkdir, readFile, readdir, stat, unlink, writeFile } from "node:fs/promises";
|
|
@@ -496,12 +496,16 @@ function guarded(url, doFetch, suppliedToken) {
|
|
|
496
496
|
envRejected = true;
|
|
497
497
|
}
|
|
498
498
|
if (process.env.VERCEL === "1") {
|
|
499
|
+
let edgeless = false;
|
|
499
500
|
if (!headers.has("x-vercel-trusted-oidc-idp-token")) {
|
|
500
501
|
const token = headers.get("authorization")?.match(/^Bearer (.+)$/i)?.[1] ?? (typeof suppliedToken === "function" ? await suppliedToken() : suppliedToken) ?? (process.env.BOARD_TOKEN || await hostedToken(url));
|
|
501
|
-
|
|
502
|
+
const edge = token.startsWith("board_") ? await hostedToken(url).catch(() => null) : token;
|
|
503
|
+
if (edge === null) edgeless = true;
|
|
504
|
+
else headers.set("x-vercel-trusted-oidc-idp-token", edge);
|
|
502
505
|
}
|
|
503
506
|
return through(doFetch, input, init, null).catch((error) => {
|
|
504
|
-
|
|
507
|
+
if (!(error instanceof Wall)) throw error;
|
|
508
|
+
throw edgeless ? new BoardError("protected", `${url} is behind Vercel Deployment Protection, and this deployment has no Vercel OIDC token to get through it.`, error.status, { hint: "Enable OIDC on its project, and add it to the board project's Deployment Protection Trusted Sources." }) : new BoardError("protected", `${url} is behind Vercel Deployment Protection, and it rejected this deployment's Vercel OIDC token.`, error.status, { hint: "Add this project and environment to the board project's Deployment Protection Trusted Sources." });
|
|
505
509
|
});
|
|
506
510
|
}
|
|
507
511
|
const used = await (secret ??= readBypass(host));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as setOwn, t as own } from "./own-OwgPWdmh.mjs";
|
|
2
|
-
import { n as foldMessages, r as foldSync } from "./folds-
|
|
2
|
+
import { n as foldMessages, r as foldSync } from "./folds-DsWfIftc.mjs";
|
|
3
3
|
//#region src/store/project.ts
|
|
4
4
|
/** The message an event concerns, if any. */
|
|
5
5
|
function concernedMessageId(event) {
|