@vercel/board 0.48.1 → 0.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{access-C06pIr0M.mjs → access-BbgmsAFF.mjs} +29 -17
- package/dist/access.d.mts +2 -2
- package/dist/access.mjs +5 -5
- package/dist/{actors-Dkyg-oo0.mjs → actors-CX2D22hL.mjs} +4 -3
- package/dist/{auth-B9-wXQ-x.mjs → auth-DJDTfgAL.mjs} +2 -2
- package/dist/{auth-li3lKwJG.d.mts → auth-Z9-Khvvw.d.mts} +1 -1
- package/dist/{backend-UBP6HimX.d.mts → backend-CcaaS9Xl.d.mts} +31 -8
- package/dist/backend-local.d.mts +1 -1
- package/dist/backend-local.mjs +1 -1
- package/dist/{chat-provider-iN0DFsSE.d.mts → chat-provider-DQ1GHm4o.d.mts} +2 -2
- package/dist/{chat-provider-kNWd6MQC.mjs → chat-provider-HJ7y_ipp.mjs} +2 -2
- package/dist/cli-commands.d.mts +1 -1
- package/dist/cli-commands.mjs +1 -1
- package/dist/cli-embedded.d.mts +8 -2
- package/dist/cli-embedded.mjs +10 -4
- package/dist/cli.mjs +6 -6
- package/dist/client-C2T4eaXd.d.mts +544 -0
- package/dist/{commands-CJsOA-hf.d.mts → commands-Cm4sODIu.d.mts} +12 -8
- package/dist/{commands-Dk6_cHLS.mjs → commands-nN8WpvCe.mjs} +75 -58
- package/dist/{conformance-CDP8y2Zm.mjs → conformance-Cr-umDl0.mjs} +102 -20
- package/dist/conformance.d.mts +1 -1
- package/dist/conformance.mjs +1 -1
- package/dist/{engine-BQ0hJw2w.mjs → engine-DJZ8Xy_g.mjs} +10 -7
- package/dist/{errors-QhkdzI-o.mjs → errors-DYF4hhIc.mjs} +53 -174
- package/dist/{events-B-qyxNsJ.mjs → events-BdOCmnZh.mjs} +3 -3
- package/dist/{exports-BzSG0_wL.mjs → exports-CuD-Mxkw.mjs} +389 -118
- package/dist/{exports-inhbjAWi.d.mts → exports-lmr6UHHc.d.mts} +4 -4
- package/dist/{external-BuVTXT1R.mjs → external-D2jq_DEQ.mjs} +1 -1
- package/dist/{index-B0Fnhvk7.d.mts → index-_KxJu15n.d.mts} +2 -2
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +4 -4
- package/dist/index.node.d.mts +7 -7
- package/dist/index.node.mjs +4 -4
- package/dist/inspect/app.js +39 -39
- package/dist/inspect/engine.js +3 -3
- package/dist/inspect-CZeoSm7E.mjs +272 -0
- package/dist/inspect-UCcPViyA.mjs +2 -0
- package/dist/inspect.d.mts +17 -0
- package/dist/inspect.mjs +196 -0
- package/dist/{local-BdKxz-Dn.mjs → local-BVSFSSYf.mjs} +165 -61
- package/dist/{main-BgiViRZ8.mjs → main-B016auoG.mjs} +227 -49
- package/dist/{memory-CMm-Fk_A.mjs → memory-C2lzMV_t.mjs} +2 -2
- package/dist/{middleware-CT6vMNUc.mjs → middleware-DUKIITFZ.mjs} +3 -3
- package/dist/{page-D-OzDOAX.mjs → page-7KWSGxyC.mjs} +12 -2
- package/dist/page-CN77B014.mjs +2 -0
- package/dist/profile-header-Cj0Cb1cf.mjs +163 -0
- package/dist/{provider-DC3WHUXo.d.mts → provider-Dwb_9mnu.d.mts} +3 -529
- package/dist/{routes-CjA6Mp4D.d.mts → routes-B6SEA9yw.d.mts} +130 -4
- package/dist/{routes-ABXf3CKq.mjs → routes-BE0y6wCk.mjs} +40 -14
- package/dist/{schemas-7VFdomFB.mjs → schemas-CUSTEFIy.mjs} +11 -3
- package/dist/{serve-C2Jbr7pR.mjs → serve-B10e7QaY.mjs} +5 -5
- package/dist/{server-EOQC5Gtq.mjs → server-ViWNvg5q.mjs} +61 -29
- package/dist/{serving-BNdiReQT.mjs → serving-SbqeWqlA.mjs} +1 -1
- package/dist/{inspect-n9brh-TT.mjs → shell-DmpmgOPC.mjs} +25 -274
- package/dist/{sql-IEbO5vXs.mjs → sql-iABdyCiz.mjs} +18 -5
- package/dist/{sqlite-CVG8XKHm.mjs → sqlite-28EMrmk7.mjs} +2 -2
- package/dist/{sqlite-db-BJjPQYx4.mjs → sqlite-db-Ckd-ceNe.mjs} +1 -1
- 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 +3 -3
- package/dist/sync-linear.d.mts +3 -3
- package/dist/sync-linear.mjs +3 -3
- package/dist/sync-slack.d.mts +3 -3
- package/dist/sync-slack.mjs +11 -7
- package/dist/sync.d.mts +2 -2
- package/dist/sync.mjs +2 -2
- package/dist/{tags-BpFo6q0_.mjs → tags-D0qra0Qy.mjs} +1 -1
- package/dist/{task-batch-D4p9N8lN.mjs → task-batch-9lVDG3d-.mjs} +10 -11
- package/dist/{tokens-BCp4EWTQ.mjs → tokens-C-iK0Cku.mjs} +2 -2
- package/dist/version-C70RLVEK.mjs +5 -0
- package/docs/01-board/01-mounting.md +8 -0
- package/docs/01-board/03-identity.md +3 -2
- package/docs/01-board/04-messages.md +6 -2
- package/docs/01-board/05-reading.md +17 -2
- package/docs/01-board/09-access.md +40 -6
- package/docs/01-board/11-tasks.md +3 -3
- package/docs/02-sync/01-overview.md +2 -1
- package/docs/03-guides/02-inspector.md +31 -0
- package/docs/03-guides/06-sandboxed-agents.md +22 -21
- package/docs/04-reference/01-cli.md +91 -33
- package/docs/04-reference/02-board.md +20 -7
- package/docs/04-reference/03-http.md +9 -6
- package/docs/04-reference/05-conformance.md +7 -0
- package/package.json +5 -1
- package/dist/inspect-BB-XUPuz.mjs +0 -2
- package/dist/page-Dr9Aqlej.mjs +0 -2
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { A as
|
|
3
|
-
import { a as Link, i as ExternalTarget, n as ExternalEvent, o as Origin } from "./external-
|
|
4
|
-
import "./routes-
|
|
5
|
-
import { a as
|
|
1
|
+
import { a as DIRECT_UPLOAD_BYTES_MAX, i as ATTACHMENT_BYTES_MAX, l as mediaType, o as IMPORT_BYTES_MAX, s as fileName } from "./profile-header-Cj0Cb1cf.mjs";
|
|
2
|
+
import { A as actorKind, D as TaskHoldKind, E as TASK_NOTE_MAX, M as platformAvatar, N as storable, O as TaskNote, T as TASK_LABEL, a as CAN_MAX, b as RemoteWatcherId, c as EDITED_HOLD, d as LabelKey, g as MessageText, h as MessageId, i as Author, j as authorView, l as Emoji, n as Attachment, o as CHANNEL_PATTERN_MAX, p as Labels, s as ChannelPath, t as ActorId, u as Handle, v as OPEN_TASK_STATES, x as SeenActorKind } from "./schemas-CUSTEFIy.mjs";
|
|
3
|
+
import { a as Link, i as ExternalTarget, n as ExternalEvent, o as Origin } from "./external-D2jq_DEQ.mjs";
|
|
4
|
+
import "./routes-BE0y6wCk.mjs";
|
|
5
|
+
import { a as duplicateId, c as notFound, f as BoardError, i as batchTooLarge, l as textTooLong, m as duration, o as forbidden$1, r as badRequest, t as HttpError, u as toErrorResponse } from "./errors-DYF4hhIc.mjs";
|
|
6
|
+
import { a as waitUntil, c as platformProfile, d as userIdOf, h as isKeyIdOf, l as shownName, m as derivedId, n as MIDDLEWARE_ACTOR, o as actorParts, s as importedHandle, t as DroppedError } from "./middleware-DUKIITFZ.mjs";
|
|
6
7
|
import { a as SCHEMA_DESCRIPTION_MAX, c as canonical, d as parseSchemaId, f as schemaId, i as BUILT_IN_SCHEMAS, l as checkDefinition, n as blocksIn, o as SCHEMA_NAME, s as SCHEMA_VERSION_MAX, u as isBuiltInName } from "./blocks-CVoBC7ur.mjs";
|
|
7
8
|
import { a as replaceMentions, i as mentionTerms, n as isEmail, r as mentionTerm, t as extractMentions } from "./mentions-CnWt9Z5b.mjs";
|
|
8
|
-
import {
|
|
9
|
-
import { c as compileAccess, i as authorize, o as checkGrantChange, t as FULL_ACCESS, u as parseCan } from "./access-
|
|
10
|
-
import {
|
|
9
|
+
import { t as VERSION } from "./version-C70RLVEK.mjs";
|
|
10
|
+
import { c as compileAccess, i as authorize, o as checkGrantChange, t as FULL_ACCESS, u as parseCan } from "./access-BbgmsAFF.mjs";
|
|
11
|
+
import { a as runMatch, h as SYNC, i as canonicalWatchers, l as METHODS, n as SYNC_ACTOR, o as compileWatcher, r as syncTarget, s as hasCriteria, t as batchPlan } from "./task-batch-9lVDG3d-.mjs";
|
|
12
|
+
import { T as wroteAs, b as removes, c as checkCan, g as joined, h as issuerName, l as checkGrant, n as GITHUB_ISSUER, p as grantIssuers, s as authenticates, u as checkPrincipal, w as workflowPath } from "./auth-DJDTfgAL.mjs";
|
|
11
13
|
import { n as setOwn, t as own } from "./own-OwgPWdmh.mjs";
|
|
12
|
-
import { i as ownedActor, n as actorSeen, o as viaOf } from "./actors-
|
|
14
|
+
import { i as ownedActor, n as actorSeen, o as viaOf } from "./actors-CX2D22hL.mjs";
|
|
13
15
|
import { C as sessionClearedError, a as SOCKET_TIMINGS, c as drainSettledHooks, d as nullProtoRecord, f as runtimeConsumerFactory, g as A2Error, h as stateTailReaders, i as RESERVED_PARTICIPANT_IDS, l as failedPreviousAttempt, m as serverInternals, n as POLL_TIMINGS, o as STATE_CACHE, p as runtimeConsumers, r as PRESENCE_TIMINGS, s as STREAM_TIMINGS, t as DRAIN_TIMINGS, u as markSchedulerSendFailure, v as NonRetriableError, x as isSessionCleared, y as asStoreUnavailable } from "./internal-CvsrprnU-CEPOUpAv.mjs";
|
|
14
16
|
import { i as streamActivities, n as defaultSleep, t as createStreamActivity } from "./store-polling-BZt2Rf3D-oh3aU_An.mjs";
|
|
15
|
-
import { a as foldActors, i as concernedMessageId, o as foldMessages, s as iso, t as TABLES_CONSUMER } from "./sql-
|
|
17
|
+
import { a as foldActors, i as concernedMessageId, o as foldMessages, s as iso, t as TABLES_CONSUMER } from "./sql-iABdyCiz.mjs";
|
|
16
18
|
import { z } from "zod";
|
|
17
19
|
import { createHash, randomBytes, timingSafeEqual } from "node:crypto";
|
|
18
20
|
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
@@ -5195,6 +5197,7 @@ async function writePost(ctx, input) {
|
|
|
5195
5197
|
if (input.sync?.length) throw badRequest("sync attaches whole threads: use `board sync <id> <target>`");
|
|
5196
5198
|
} else {
|
|
5197
5199
|
if (!channel) throw badRequest("a post needs a channel");
|
|
5200
|
+
if (input.noSync && input.sync?.length) throw badRequest("`noSync` and `sync` contradict each other");
|
|
5198
5201
|
if (input.after !== void 0) throw badRequest("`after` is for replies", "invalid_after");
|
|
5199
5202
|
thread = id;
|
|
5200
5203
|
}
|
|
@@ -5271,7 +5274,6 @@ async function commitPost(ctx, input, placed) {
|
|
|
5271
5274
|
const targets = [];
|
|
5272
5275
|
if (re === null) for (const requested of input.sync ?? []) {
|
|
5273
5276
|
const target = syncTarget(requested);
|
|
5274
|
-
await unclaimed(ctx, target, thread, identity.principal.access);
|
|
5275
5277
|
if (!targets.some((t) => t.target === target.target)) targets.push({
|
|
5276
5278
|
...target,
|
|
5277
5279
|
cause: "request"
|
|
@@ -5322,6 +5324,7 @@ async function commitPost(ctx, input, placed) {
|
|
|
5322
5324
|
const before = events.findIndex((event) => event.type === "message.posted");
|
|
5323
5325
|
rows = await appendFrom(ctx, async () => {
|
|
5324
5326
|
const { position, events: more } = await along();
|
|
5327
|
+
for (const target of targets) await unclaimed(ctx, target, thread, identity.principal.access);
|
|
5325
5328
|
const came = more({
|
|
5326
5329
|
id: position + 1 + before,
|
|
5327
5330
|
thread
|
|
@@ -5337,7 +5340,8 @@ async function commitPost(ctx, input, placed) {
|
|
|
5337
5340
|
} : event), ...came]
|
|
5338
5341
|
};
|
|
5339
5342
|
});
|
|
5340
|
-
} else
|
|
5343
|
+
} else if (targets.some((target) => target.kind === "thread")) rows = await appendWhile(ctx, unclaimedAt(ctx, targets, thread, identity.principal.access), events);
|
|
5344
|
+
else rows = input.after === void 0 || re === null ? await ctx.session.append(...events) : await appendWhile(ctx, nothingAfter(ctx, re, input.after), events);
|
|
5341
5345
|
} catch (error) {
|
|
5342
5346
|
const replayed = error instanceof HttpError && error.code === "newer_message" || input.with !== void 0 && duplicateEvent(error) ? await replayOf(ctx, input, {
|
|
5343
5347
|
channel,
|
|
@@ -5488,12 +5492,12 @@ const readerFor = (ctx, access, message) => ctx.reads.reader(access, [message]);
|
|
|
5488
5492
|
* Refuses an external thread another board thread is synced with: taking it
|
|
5489
5493
|
* over would send its replies away from that thread, to a caller who may not
|
|
5490
5494
|
* read it. A reader of that thread's channel learns which thread it is. It
|
|
5491
|
-
* reads the tables
|
|
5492
|
-
*
|
|
5495
|
+
* reads the tables as they are: it runs inside an append's look, whose
|
|
5496
|
+
* `appendFrom` has them apply the log first, and whose append lands only if
|
|
5497
|
+
* nothing, another claim included, landed since.
|
|
5493
5498
|
*/
|
|
5494
5499
|
async function unclaimed(ctx, target, thread, access) {
|
|
5495
5500
|
if (target.kind !== "thread") return;
|
|
5496
|
-
await ctx.reads.ensure();
|
|
5497
5501
|
const owner = await ctx.reads.tables.threadOf(target.target);
|
|
5498
5502
|
if (owner === null || owner === thread) return;
|
|
5499
5503
|
const synced = await ctx.reads.tables.syncOf(owner);
|
|
@@ -5501,6 +5505,16 @@ async function unclaimed(ctx, target, thread, access) {
|
|
|
5501
5505
|
throw new HttpError(409, "already_synced", `${target.target} is already synced with ${which}`);
|
|
5502
5506
|
}
|
|
5503
5507
|
/**
|
|
5508
|
+
* An append's condition that none of `targets` is another thread's, as `unclaimed` refuses: it
|
|
5509
|
+
* returns the index its reads reflect at least, so the append lands only if nothing, another
|
|
5510
|
+
* claim included, landed since.
|
|
5511
|
+
*/
|
|
5512
|
+
const unclaimedAt = (ctx, targets, thread, access) => async () => {
|
|
5513
|
+
const position = await ctx.reads.tables.position();
|
|
5514
|
+
for (const target of targets) await unclaimed(ctx, target, thread, access);
|
|
5515
|
+
return position;
|
|
5516
|
+
};
|
|
5517
|
+
/**
|
|
5504
5518
|
* Waits until the tables hold a write, so any read after it includes it. Most often
|
|
5505
5519
|
* nothing was written in between, and the writer applies its own events itself; else
|
|
5506
5520
|
* it waits for the tables' consumer. The write landed either way: if the tables are
|
|
@@ -5772,10 +5786,7 @@ const labelsAre = (ctx, id, expected) => async () => {
|
|
|
5772
5786
|
async function writeAttach(ctx, input) {
|
|
5773
5787
|
const message = spent(input.authorized, "sync");
|
|
5774
5788
|
const { target, kind } = input.target;
|
|
5775
|
-
|
|
5776
|
-
if ((await ctx.reads.tables.syncOf(message.thread))?.targets.includes(target)) return { attached: false };
|
|
5777
|
-
await unclaimed(ctx, input.target, message.thread, input.identity.principal.access);
|
|
5778
|
-
await untilApplied(ctx, await ctx.session.append({
|
|
5789
|
+
const event = {
|
|
5779
5790
|
type: "thread.synced",
|
|
5780
5791
|
id: await derivedId("board", message.thread, "sync", target),
|
|
5781
5792
|
payload: {
|
|
@@ -5785,8 +5796,21 @@ async function writeAttach(ctx, input) {
|
|
|
5785
5796
|
cause: input.cause,
|
|
5786
5797
|
by: input.identity.author
|
|
5787
5798
|
}
|
|
5788
|
-
}
|
|
5789
|
-
|
|
5799
|
+
};
|
|
5800
|
+
const rows = await appendFrom(ctx, async () => {
|
|
5801
|
+
const position = await ctx.reads.tables.position();
|
|
5802
|
+
if ((await ctx.reads.tables.syncOf(message.thread))?.targets.includes(target)) return {
|
|
5803
|
+
position,
|
|
5804
|
+
events: []
|
|
5805
|
+
};
|
|
5806
|
+
await unclaimed(ctx, input.target, message.thread, input.identity.principal.access);
|
|
5807
|
+
return {
|
|
5808
|
+
position,
|
|
5809
|
+
events: [event]
|
|
5810
|
+
};
|
|
5811
|
+
});
|
|
5812
|
+
await untilApplied(ctx, rows);
|
|
5813
|
+
return { attached: rows.length > 0 };
|
|
5790
5814
|
}
|
|
5791
5815
|
/**
|
|
5792
5816
|
* A channel made before anything posts to it, or the one that's there, made by a post or another
|
|
@@ -6117,17 +6141,44 @@ async function changerAccess({ principal }, grants, accessIn) {
|
|
|
6117
6141
|
own
|
|
6118
6142
|
};
|
|
6119
6143
|
}
|
|
6144
|
+
const NO_ACCESS = compileAccess([]);
|
|
6120
6145
|
/**
|
|
6121
|
-
*
|
|
6122
|
-
* `
|
|
6123
|
-
*
|
|
6124
|
-
* involves a stored grant names its patterns only to whoever may list the grants.
|
|
6146
|
+
* What `identity`'s grant write is judged by on `before`, the grants it appends to: null for an
|
|
6147
|
+
* owner no `x-board-can` narrows. With `left`, the grants as the write would leave them, a lockout
|
|
6148
|
+
* is judged too: a caller that says `lockMeOut` passes none.
|
|
6125
6149
|
*/
|
|
6126
|
-
async function
|
|
6150
|
+
async function standingOf(identity, before, accessIn, left) {
|
|
6127
6151
|
const access = await changerAccess(identity, before, accessIn);
|
|
6128
|
-
if (access === null) return;
|
|
6129
|
-
const
|
|
6152
|
+
if (access === null || left === void 0) return access;
|
|
6153
|
+
const { principal } = identity;
|
|
6154
|
+
if (isOwner(principal)) return {
|
|
6155
|
+
...access,
|
|
6156
|
+
then: access
|
|
6157
|
+
};
|
|
6158
|
+
const [caller, own] = await Promise.all([accessIn(principal, left), accessIn(principal, withoutEveryone(left))]);
|
|
6159
|
+
return {
|
|
6130
6160
|
...access,
|
|
6161
|
+
then: {
|
|
6162
|
+
caller: caller ?? NO_ACCESS,
|
|
6163
|
+
own: own ?? NO_ACCESS
|
|
6164
|
+
}
|
|
6165
|
+
};
|
|
6166
|
+
}
|
|
6167
|
+
const THIS_GRANT = {
|
|
6168
|
+
what: "this grant",
|
|
6169
|
+
doing: "this grant"
|
|
6170
|
+
};
|
|
6171
|
+
/**
|
|
6172
|
+
* A refusal unless `standing` may change grants so, with `after` as they'd be:
|
|
6173
|
+
* `checkGrantChange`'s rule, which Vercel's API runs too. `changed` is a grant made or widened,
|
|
6174
|
+
* `revoked` one revoked, removed from, or updated, as it was. What the caller may not do is a 403;
|
|
6175
|
+
* what it may, and couldn't take back, a 409 `grant_lockout`. A refusal that involves a stored
|
|
6176
|
+
* grant names its patterns only to whoever may list the grants.
|
|
6177
|
+
*/
|
|
6178
|
+
function judge(identity, standing, change, after, { what, doing } = THIS_GRANT) {
|
|
6179
|
+
if (standing === null) return;
|
|
6180
|
+
const refused = checkGrantChange({
|
|
6181
|
+
...standing,
|
|
6131
6182
|
after,
|
|
6132
6183
|
...change
|
|
6133
6184
|
});
|
|
@@ -6135,17 +6186,29 @@ async function mayGrant(identity, change, before, after, accessIn, what = "this
|
|
|
6135
6186
|
if (change.revoked && !lists(identity)) throw unreachable(what);
|
|
6136
6187
|
throw forbidden$1(`${change.revoked ? `this token can't ${what}: it` : what} reaches ${refused.pattern}, where you can't manage grants`);
|
|
6137
6188
|
}
|
|
6189
|
+
if (refused?.reason === "lockout") {
|
|
6190
|
+
const where = change.revoked && !lists(identity) ? "where it reaches" : `in ${refused.pattern}`;
|
|
6191
|
+
throw new HttpError(409, "grant_lockout", `${doing} would leave you unable to manage grants ${where}`, { hint: "Name yourself with manage there, in a grant made before it or in the same write. Or send lockMeOut to go ahead: only someone who still manages grants there could change it then." });
|
|
6192
|
+
}
|
|
6138
6193
|
if (refused) throw forbidden$1(`you can't let anyone in: everyone gets ${refused.permission} in ${refused.pattern}, which you can't`);
|
|
6139
6194
|
}
|
|
6195
|
+
/** `judge`, for a write that asks once: on `before`, the grants it appends to, and for a lockout, on `left`. */
|
|
6196
|
+
async function mayGrant(identity, change, before, after, accessIn, named = THIS_GRANT, left) {
|
|
6197
|
+
judge(identity, await standingOf(identity, before, accessIn, left), change, after, named);
|
|
6198
|
+
}
|
|
6140
6199
|
/** An oidc principal: naming one makes the board fetch its issuer's keys, so it takes manage everywhere. */
|
|
6141
6200
|
const namesIssuer = (principals) => principals.some((principal) => principal.kind === "oidc");
|
|
6201
|
+
const ISSUER = {
|
|
6202
|
+
what: "naming an oidc issuer",
|
|
6203
|
+
doing: "naming an oidc issuer"
|
|
6204
|
+
};
|
|
6142
6205
|
/**
|
|
6143
6206
|
* The event that makes `input`'s change to a grant in `state`, or why it can't: manage at its
|
|
6144
6207
|
* patterns, and to add principals or set `can`, what making it would take, and manage everywhere to
|
|
6145
6208
|
* name an oidc issuer. A removal goes by who a principal is; an add joins one the grant names
|
|
6146
6209
|
* already. `issuers` are the ones the board's rules trust.
|
|
6147
6210
|
*/
|
|
6148
|
-
async function updated(identity, state, { id, add, remove, can }, issuers, accessIn, team, logins) {
|
|
6211
|
+
async function updated(identity, state, { id, add, remove, can, lockMeOut }, issuers, accessIn, team, logins) {
|
|
6149
6212
|
const index = indexOf(id);
|
|
6150
6213
|
const row = index === null ? void 0 : state.grants[index];
|
|
6151
6214
|
if (!row) {
|
|
@@ -6153,7 +6216,11 @@ async function updated(identity, state, { id, add, remove, can }, issuers, acces
|
|
|
6153
6216
|
throw notFound(`grant not found: ${id}`, "grant_not_found");
|
|
6154
6217
|
}
|
|
6155
6218
|
const before = Object.values(state.grants).map(storedGrant);
|
|
6156
|
-
|
|
6219
|
+
const named = {
|
|
6220
|
+
what: `update ${id}`,
|
|
6221
|
+
doing: `updating ${id}`
|
|
6222
|
+
};
|
|
6223
|
+
await mayGrant(identity, { revoked: row }, before, before.filter((other) => other.id !== storedGrant(row).id), accessIn, named);
|
|
6157
6224
|
const others = grantIssuers(Object.values(state.grants).filter((other) => other.id !== row.id).map(storedGrant));
|
|
6158
6225
|
let principals = [...row.principals];
|
|
6159
6226
|
for (const input of remove ?? []) {
|
|
@@ -6175,15 +6242,16 @@ async function updated(identity, state, { id, add, remove, can }, issuers, acces
|
|
|
6175
6242
|
if (principals.length === 0) throw badRequest(`that leaves ${id} naming no one: revoke it instead`, "grant_empty");
|
|
6176
6243
|
if (principals.length > 32) throw badRequest("a grant names at most 32 principals", "invalid_grant");
|
|
6177
6244
|
const next = can === void 0 ? row.can : checkCan(can);
|
|
6178
|
-
const after = [...
|
|
6245
|
+
const after = [...before.filter((other) => other.id !== storedGrant(row).id), {
|
|
6246
|
+
id: storedGrant(row).id,
|
|
6179
6247
|
principals,
|
|
6180
6248
|
can: next
|
|
6181
6249
|
}];
|
|
6182
6250
|
await mayGrant(identity, {
|
|
6183
6251
|
revoked: row,
|
|
6184
6252
|
...add !== void 0 || can !== void 0 ? { changed: { can: next } } : {}
|
|
6185
|
-
}, before, after, accessIn,
|
|
6186
|
-
if (namesIssuer(principals.filter((principal) => !row.principals.includes(principal)))) await mayGrant(identity, { changed: { can: { "*": "all" } } }, before, after, accessIn,
|
|
6253
|
+
}, before, after, accessIn, named, lockMeOut ? void 0 : after);
|
|
6254
|
+
if (namesIssuer(principals.filter((principal) => !row.principals.includes(principal)))) await mayGrant(identity, { changed: { can: { "*": "all" } } }, before, after, accessIn, ISSUER);
|
|
6187
6255
|
return {
|
|
6188
6256
|
type: "grant.updated",
|
|
6189
6257
|
payload: {
|
|
@@ -6209,35 +6277,66 @@ function createTrust(options) {
|
|
|
6209
6277
|
const read = async () => (await session.state(accessReducer)).state;
|
|
6210
6278
|
/** The grants as they are now, and the index a conditional write holds them at. */
|
|
6211
6279
|
const latest = () => session.state(accessReducer, { through: "latest" });
|
|
6280
|
+
const trust = { async grants() {
|
|
6281
|
+
return Object.values((await read()).grants).map(storedGrant);
|
|
6282
|
+
} };
|
|
6283
|
+
/**
|
|
6284
|
+
* Makes `bodies`' grants in one append, all or none, in the order given. Each is judged on the
|
|
6285
|
+
* grants as they are when it lands (another write in between makes it look again), admission and
|
|
6286
|
+
* a lockout with all of them made: so a lock and the grant that keeps its maker in pass
|
|
6287
|
+
* together, whichever comes first.
|
|
6288
|
+
*/
|
|
6289
|
+
async function create(identity, bodies, lockMeOut) {
|
|
6290
|
+
const team = await options.team();
|
|
6291
|
+
const rows = await whileHeadMoves(async () => {
|
|
6292
|
+
const { state, index } = await latest();
|
|
6293
|
+
const before = Object.values(state.grants).map(storedGrant);
|
|
6294
|
+
const made = [];
|
|
6295
|
+
for (const body of bodies) made.push({
|
|
6296
|
+
id: grantId(state.nextGrant + made.length),
|
|
6297
|
+
...checkGrant(body, grantIssuers([...before, ...made]), team, logins())
|
|
6298
|
+
});
|
|
6299
|
+
const after = [...before, ...made];
|
|
6300
|
+
const standing = await standingOf(identity, before, accessIn, lockMeOut ? void 0 : after);
|
|
6301
|
+
made.forEach((grant, at) => {
|
|
6302
|
+
const named = made.length === 1 ? THIS_GRANT : {
|
|
6303
|
+
what: `grant ${at + 1} of ${made.length}`,
|
|
6304
|
+
doing: `grant ${at + 1} of ${made.length}`
|
|
6305
|
+
};
|
|
6306
|
+
judge(identity, standing, { changed: grant }, after, named);
|
|
6307
|
+
if (namesIssuer(grant.principals)) judge(identity, standing && {
|
|
6308
|
+
caller: standing.caller,
|
|
6309
|
+
own: standing.own
|
|
6310
|
+
}, { changed: { can: { "*": "all" } } }, after, ISSUER);
|
|
6311
|
+
});
|
|
6312
|
+
return session.append.ifLastIndex(index, ...made.map((grant) => ({
|
|
6313
|
+
type: "grant.created",
|
|
6314
|
+
payload: {
|
|
6315
|
+
principals: grant.principals,
|
|
6316
|
+
can: grant.can,
|
|
6317
|
+
by: identity.actor.id
|
|
6318
|
+
}
|
|
6319
|
+
})));
|
|
6320
|
+
});
|
|
6321
|
+
const { grants } = await read();
|
|
6322
|
+
return rows.map((row) => {
|
|
6323
|
+
const made = Object.values(grants).find((grant) => grant.event === row.index);
|
|
6324
|
+
if (!made) throw new Error("a grant was made but its log has no record of it");
|
|
6325
|
+
return grantView(made);
|
|
6326
|
+
});
|
|
6327
|
+
}
|
|
6212
6328
|
return {
|
|
6213
|
-
trust
|
|
6214
|
-
return Object.values((await read()).grants).map(storedGrant);
|
|
6215
|
-
} },
|
|
6329
|
+
trust,
|
|
6216
6330
|
async grants(identity) {
|
|
6217
6331
|
mayList(identity, "list grants");
|
|
6218
6332
|
return { grants: Object.values((await read()).grants).sort((a, b) => a.id - b.id).map(grantView) };
|
|
6219
6333
|
},
|
|
6220
|
-
async createGrant(identity, body) {
|
|
6221
|
-
const
|
|
6222
|
-
|
|
6223
|
-
|
|
6224
|
-
|
|
6225
|
-
|
|
6226
|
-
const after = [...before, checked];
|
|
6227
|
-
await mayGrant(identity, { changed: checked }, before, after, accessIn);
|
|
6228
|
-
if (namesIssuer(checked.principals)) await mayGrant(identity, { changed: { can: { "*": "all" } } }, before, after, accessIn, "naming an oidc issuer");
|
|
6229
|
-
return session.append.ifLastIndex(index, {
|
|
6230
|
-
type: "grant.created",
|
|
6231
|
-
payload: {
|
|
6232
|
-
principals: checked.principals,
|
|
6233
|
-
can: checked.can,
|
|
6234
|
-
by: identity.actor.id
|
|
6235
|
-
}
|
|
6236
|
-
});
|
|
6237
|
-
});
|
|
6238
|
-
const made = row && Object.values((await read()).grants).find((grant) => grant.event === row.index);
|
|
6239
|
-
if (!made) throw new Error("a grant was made but its log has no record of it");
|
|
6240
|
-
return { grant: grantView(made) };
|
|
6334
|
+
async createGrant(identity, { lockMeOut, ...body }) {
|
|
6335
|
+
const [grant] = await create(identity, [body], lockMeOut);
|
|
6336
|
+
return { grant };
|
|
6337
|
+
},
|
|
6338
|
+
async createGrants(identity, { grants, lockMeOut }) {
|
|
6339
|
+
return { grants: await create(identity, grants, lockMeOut) };
|
|
6241
6340
|
},
|
|
6242
6341
|
async updateGrant(identity, input) {
|
|
6243
6342
|
const team = await options.team();
|
|
@@ -6285,7 +6384,7 @@ function createTrust(options) {
|
|
|
6285
6384
|
can: decided.permissions
|
|
6286
6385
|
};
|
|
6287
6386
|
},
|
|
6288
|
-
async revokeGrant(identity, { id }) {
|
|
6387
|
+
async revokeGrant(identity, { id, lockMeOut }) {
|
|
6289
6388
|
return whileHeadMoves(async () => {
|
|
6290
6389
|
const { state, index } = await latest();
|
|
6291
6390
|
const at = indexOf(id);
|
|
@@ -6295,7 +6394,11 @@ function createTrust(options) {
|
|
|
6295
6394
|
return { revoked: false };
|
|
6296
6395
|
}
|
|
6297
6396
|
const before = Object.values(state.grants).map(storedGrant);
|
|
6298
|
-
|
|
6397
|
+
const after = before.filter((other) => other.id !== storedGrant(row).id);
|
|
6398
|
+
await mayGrant(identity, { revoked: row }, before, after, accessIn, {
|
|
6399
|
+
what: `revoke ${id}`,
|
|
6400
|
+
doing: `revoking ${id}`
|
|
6401
|
+
}, lockMeOut ? void 0 : after);
|
|
6299
6402
|
await session.append.ifLastIndex(index, {
|
|
6300
6403
|
type: "grant.deleted",
|
|
6301
6404
|
payload: {
|
|
@@ -9490,6 +9593,7 @@ function build(options, binding) {
|
|
|
9490
9593
|
},
|
|
9491
9594
|
grants: async (caller) => access.grants(await identityOf(caller)),
|
|
9492
9595
|
createGrant: async (caller, body) => access.createGrant(await identityOf(caller), body),
|
|
9596
|
+
createGrants: async (caller, body) => access.createGrants(await identityOf(caller), body),
|
|
9493
9597
|
updateGrant: async (caller, input) => access.updateGrant(await identityOf(caller), input),
|
|
9494
9598
|
explain: async (caller, query) => access.explain(await identityOf(caller), query),
|
|
9495
9599
|
revokeGrant: async (caller, input) => access.revokeGrant(await identityOf(caller), input),
|
|
@@ -10388,10 +10492,10 @@ function local(options = {}) {
|
|
|
10388
10492
|
opening ??= (async () => {
|
|
10389
10493
|
const file = localFile(bound.name);
|
|
10390
10494
|
let store;
|
|
10391
|
-
if (options.memory) store = (await import("./memory-
|
|
10495
|
+
if (options.memory) store = (await import("./memory-C2lzMV_t.mjs")).memory();
|
|
10392
10496
|
else {
|
|
10393
10497
|
const { mkdir } = await import("node:fs/promises");
|
|
10394
|
-
const { sqlite } = await import("./sqlite-
|
|
10498
|
+
const { sqlite } = await import("./sqlite-28EMrmk7.mjs");
|
|
10395
10499
|
const path = join(dir, `${file}.db`);
|
|
10396
10500
|
try {
|
|
10397
10501
|
await mkdir(dir, {
|