lody 0.111.0 → 0.111.1
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/{acp-interaction-owner-U5gmgHzv.js → acp-interaction-owner-C-E7Jj_j.js} +63 -63
- package/dist/{agent-execution-DND1xdse.js → agent-execution-DKXM8hy_.js} +2 -2
- package/dist/baguette-worker.js +3 -3
- package/dist/chunks/{vendor-@effect-platform-node-shared-C3vEQ-7m.js → vendor-@effect-platform-node-shared-GTij4Yj3.js} +2 -2
- package/dist/chunks/{vendor-@loro-dev-streams-client-B5HWGDv7.js → vendor-@loro-dev-streams-client-WbHLrl2m.js} +2 -2
- package/dist/chunks/{vendor-@loro-dev-streams-crdt-e4yhr5Ky.js → vendor-@loro-dev-streams-crdt-BsFOZws4.js} +7 -8
- package/dist/chunks/{vendor-@opencode-codemode-Bo8uQG1T.js → vendor-@opencode-codemode-DS2pDojq.js} +2 -2
- package/dist/chunks/{vendor-effect-BcqAZ7RD.js → vendor-effect-Bggm7QMO.js} +25 -25
- package/dist/chunks/{vendor-loro-repo-Bn7ZyXGt.js → vendor-loro-repo-FH5_Ccs5.js} +2 -2
- package/dist/chunks/{vendor-ws-DPfDb9HP.js → vendor-ws-DSn-BAa0.js} +6 -6
- package/dist/{client-CEfn-YWo.js → client-CCvHoqKn.js} +63 -63
- package/dist/{cloudflared-native-CDEjYrz5.js → cloudflared-native-C6cs44SH.js} +3 -3
- package/dist/cloudflared-worker.js +5 -5
- package/dist/{daemon-session-tools-DWqlzwmI.js → daemon-session-tools-5WXyyVe4.js} +63 -63
- package/dist/{diff-line-counts-7tSV8pEZ.js → diff-line-counts-CJrMXY2d.js} +2 -2
- package/dist/{diff-worker-task-BOwESZtp.js → diff-worker-task-CVilVhwP.js} +2 -2
- package/dist/diff-worker.js +5 -5
- package/dist/{directory-handle-rZKgRLvJ.js → directory-handle-C9cpH0Mn.js} +3 -3
- package/dist/{dsh-plugins-CU5NOgp8.js → dsh-plugins-DON2RlNE.js} +23 -23
- package/dist/file-index-scan-worker.js +5 -5
- package/dist/{file-lock-BDk2nHD1.js → file-lock-CnN7gNjb.js} +64 -64
- package/dist/{index-CxVpJe-t.js → index-9-5T7zY8.js} +4 -4
- package/dist/{index-CxSGZcPV.js → index-Dpq04zN3.js} +64 -64
- package/dist/{index-2FWwoHbP.js → index-DqAVXjKE.js} +221 -258
- package/dist/{index-DIx0_Tmf.js → index-p6riVneO.js} +72 -72
- package/dist/{index-CHejLb12.js → index-yZ5Xv7WP.js} +64 -64
- package/dist/index.js +69 -69
- package/dist/{machine-identity-restore-DQGAyQGr.js → machine-identity-restore-A8uLX7VW.js} +39 -39
- package/dist/{process-DJHRUC0C.js → process-CJFimK5a.js} +3 -3
- package/dist/{process-options-CwB784qP.js → process-options-D8DB-_Kg.js} +9 -9
- package/dist/{register-Ckv3mOhI.js → register-BNMQne-3.js} +431 -171
- package/dist/{remote-pairing-Betw2bE6.js → remote-pairing-BT-Kw_k3.js} +36 -36
- package/dist/{reset-identity-D_5lqUCh.js → reset-identity-7bUkXE3v.js} +67 -67
- package/dist/{review-viewer-BxgCMlmh.js → review-viewer-COX5NAkB.js} +6 -6
- package/dist/{schedule-command-client-BYBOGR_C.js → schedule-command-client-D_Ti-1Rl.js} +5 -5
- package/dist/{telemetry-3aPi8ATd.js → telemetry-DKZfKfJp.js} +18398 -18109
- package/dist/{workspace-legacy-DYv8EYIc.js → workspace-legacy-C_cxzMuh.js} +545 -322
- package/package.json +1 -1
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { w as withinAuthorityLimit, a as authorityClocksAgree, b as authorityStamp } from "./authority-clock-DKvmDgsy.js";
|
|
2
|
-
import { DatabaseSync } from "node:sqlite";
|
|
3
1
|
import { P as Point$1, v as verify, h as hashes, g as getPublicKey, s as sign } from "./chunks/vendor-@noble-ed25519-Ds7aTPMa.js";
|
|
4
|
-
import { a3 as TaggedError,
|
|
2
|
+
import { a3 as TaggedError, cG as fail$v, cH as succeed, cI as gen, cJ as nominal, cK as try_, cg as isSuccess, ci as isFailure, cL as map$1, cM as mapError, cN as flatMap, bc as acquireUseRelease, M as sync, $ as suspend, L as void_, b as fail$w, cO as fromResult, b1 as andThen, aa as uninterruptible, aG as tryPromise, h as gen$1, u as mapError$1, cP as getOrThrow, f as fnUntraced, aH as acquireRelease, v as promise, w as try_$1, K as flatMap$1, cQ as getOrUndefined, cR as get, cS as get$1, cT as of, cU as fromIterable, cV as empty, cW as fromIterable$1, cX as empty$1, cY as has, cZ as has$1, c_ as add, c$ as set, d0 as union, d1 as remove$1, d2 as remove$2, d3 as keys$3, d4 as append, F as yieldNow, a8 as catch_, d5 as some, k as isFailure$1, bi as String$1, d6 as isPattern, bt as Struct, bv as ArraySchema, d7 as Uint8Array$1, d8 as decodeUnknownResult, bw as Int, V as addFinalizer, I as doneUnsafe, a$ as make, Z as tap, _ as _await, bh as TaggedError$1, d9 as optional, bk as Defect, bJ as Literals, a4 as Service, a0 as succeed$1, da as catchTag, a1 as succeed$2, db as Tuple, bu as NullOr, bN as Literal, dc as instanceOf, bK as Number$1, b8 as make$1, bM as Boolean$1, a2 as map$2, z as makeUnsafe, H as currentTimeMillis, ad as ensuring, b4 as catchIf, c9 as scope, p as provide, dd as fn, C as Clock, cu as scoped, O as join, g as forkIn, bb as onExit, E as isSuccess$1, cf as result, de as monotonicTimeNanos, ab as orDie, df as timeout, dg as dropping, dh as take, U as catchCause, i as interrupt, di as hasInterrupts, dj as retry, dk as spaced, J as sleep, b2 as succeed$3, aV as offerUnsafe, dl as interrupt$1, cq as interrupt$2, bp as decodeUnknownSync, aj as effect, B as failCause, cv as map$3, dm as tapError, b6 as forEach, t as provideService, dn as mergeAll, bS as provideMerge, dp as map$4, aD as serviceOption, dq as isNone, cn as isSome, be as withSpan, dr as isMinLength, ds as isMaxLength, dt as declare, du as isResult, dv as Scope, ac as makeUnsafe$1, j as exit, N as close, n as done, dw as fromReasons, m as make$2, b0 as cached, dx as build, ak as provide$1, dy as get$2, S as void_$1, cz as runPromise, Q as asVoid, av as as, dz as makeUnsafe$2, bW as isDieReason, d as die, bI as isInterruptReason, dA as onError, dB as buildWithScope, cB as provide$2, bs as squash, a6 as isTimeoutError, Y as uninterruptibleMask, P as interruptible, dC as runSync, dD as match, x as never, dE as tapCause } from "./chunks/vendor-effect-Bggm7QMO.js";
|
|
5
3
|
import { e as encode$1, d as decode$2 } from "./chunks/vendor-@ipld-dag-cbor-BNII2wZN.js";
|
|
6
4
|
import { v as sha512, w as extract, x as sha256, y as expand, z as hmac, A as hkdf } from "./chunks/vendor-@noble-hashes-DpNaeH7w.js";
|
|
7
5
|
import { X as X25519, H as HkdfSha256, D as DhkemX25519HkdfSha256$1 } from "./chunks/vendor-@hpke-dhkem-x25519-BavO0sqB.js";
|
|
@@ -9,12 +7,14 @@ import { C as CipherSuite, H as HkdfSha256$1, D as DhkemX25519HkdfSha256 } from
|
|
|
9
7
|
import { C as Chacha20Poly1305 } from "./chunks/vendor-@hpke-chacha20poly1305-CUhxL4CC.js";
|
|
10
8
|
import { O as OpenError } from "./chunks/vendor-@hpke-common-CfGjdxIH.js";
|
|
11
9
|
import { x as xchacha20poly1305 } from "./chunks/vendor-@noble-ciphers-DL-K0bMl.js";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
10
|
+
import { w as withinAuthorityLimit, a as authorityClocksAgree, b as authorityStamp } from "./authority-clock-DKvmDgsy.js";
|
|
11
|
+
import { DatabaseSync } from "node:sqlite";
|
|
12
|
+
import { dr as sharingReplySchemas, ds as id$2, dt as sharingChangeSchema, du as requestId$1, dv as captureScheduleAuthorization, dw as ScheduleDefinitionSchema, dx as isCloudE2eeMemberRemoved, dy as isCloudE2eeDeviceRevoked, b4 as isE2eeReadQuery, co as decodeE2eeRpcRequestBody, dz as isE2eeFeatureMethod, cs as encodeE2eeRpcRequestBody, cp as decodeE2eeRpcResponseBody, b8 as LocalMachineRpcResponseSchema, dA as E2eeFeatureInputSchema, bc as E2EE_RPC_MAX_FRAME_BYTES, ct as encodeE2eeRpcResponseBody, dB as normalizeSessionTurnInputConfig, dC as queuedInputEvidence, a_ as getSessionRoomId, dp as getScheduleRoomId, dD as readScheduleAuthorization, dE as scheduleChangedSince, dF as scheduleDocumentFromMirrorState, dG as scheduleDefinitionFingerprint, dH as ScheduleAuthorizationRequestSchema, dI as CloudE2eeLedgerOutage, dJ as LocalE2eePrepareRequestSchema, b3 as LocalE2eePrepareResponseSchema, dK as createWorkspaceEpochTransitionLegacy, dL as encryptedWorkspaceNamespace, dM as encryptedWorkspaceResolver, ck as createLoroStreamsJsonStreamClient, dN as encryptedWorkspaceRoom, dO as isSessionDocRoomId, dP as getScheduleIdFromRoomId } from "./telemetry-DKZfKfJp.js";
|
|
13
|
+
import { e as encodeStreamsRoomAdditionalData } from "./chunks/vendor-loro-repo-FH5_Ccs5.js";
|
|
14
14
|
import { g as decodeImportBlobMeta, i as isContainer } from "./chunks/vendor-loro-crdt-CcUjyH5H.js";
|
|
15
15
|
import { o as object, c as string, j as unknown, g as _enum, e as boolean, a as literal, B as custom, A as _instanceof, n as number, C as ZodError } from "./chunks/vendor-zod-CBWGVFD-.js";
|
|
16
|
-
import { p as platformLayer, g as getLodyDataDir, a as getLogger } from "./process-options-
|
|
17
|
-
import { lazyExecutionJournal } from "./agent-execution-
|
|
16
|
+
import { p as platformLayer, g as getLodyDataDir, a as getLogger } from "./process-options-D8DB-_Kg.js";
|
|
17
|
+
import { lazyExecutionJournal } from "./agent-execution-DKXM8hy_.js";
|
|
18
18
|
import { createHash, randomUUID, timingSafeEqual, randomBytes, createDecipheriv, createCipheriv } from "node:crypto";
|
|
19
19
|
import { mkdirSync, existsSync, chmodSync, closeSync, openSync, constants } from "node:fs";
|
|
20
20
|
import { dirname, isAbsolute, join as join$1 } from "node:path";
|
|
@@ -23,8 +23,7 @@ import Database from "better-sqlite3";
|
|
|
23
23
|
import { mkdir, open as open$1, rename, lstat, readFile, readdir, unlink, link, rm } from "node:fs/promises";
|
|
24
24
|
import { createRequire } from "node:module";
|
|
25
25
|
import { pathToFileURL } from "node:url";
|
|
26
|
-
import { c as runCommandOk, d as squashProcessFailure } from "./process-
|
|
27
|
-
const withE2eeTestClock = (work) => work;
|
|
26
|
+
import { c as runCommandOk, d as squashProcessFailure } from "./process-CJFimK5a.js";
|
|
28
27
|
class ValidationError extends TaggedError("ValidationError") {
|
|
29
28
|
}
|
|
30
29
|
class ContentError extends TaggedError("ContentError") {
|
|
@@ -226,6 +225,41 @@ const bytes$2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePrope
|
|
|
226
225
|
signingPublicKey,
|
|
227
226
|
userId
|
|
228
227
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
228
|
+
const ALPHABET$1 = "0123456789abcdefghjkmnpqrstvwxyz";
|
|
229
|
+
const USER_ID_BYTES = 32;
|
|
230
|
+
const PAYLOAD_BITS = (USER_ID_BYTES - 1) * 8;
|
|
231
|
+
const MAX_CHARACTERS = Math.floor(PAYLOAD_BITS / 5);
|
|
232
|
+
const refused = () => fail$v(new ValidationError({ code: "canonical" }));
|
|
233
|
+
function accountUserId(accountId) {
|
|
234
|
+
const count = accountId.length;
|
|
235
|
+
if (count < 1 || count > MAX_CHARACTERS) return refused();
|
|
236
|
+
const bytes2 = new Uint8Array(USER_ID_BYTES);
|
|
237
|
+
bytes2[0] = count;
|
|
238
|
+
for (let index = 0; index < count; index += 1) {
|
|
239
|
+
const value = ALPHABET$1.indexOf(accountId[index]);
|
|
240
|
+
if (value < 0) return refused();
|
|
241
|
+
const bit = index * 5;
|
|
242
|
+
const byte = 1 + (bit >> 3);
|
|
243
|
+
const shifted = value << 11 - (bit & 7);
|
|
244
|
+
bytes2[byte] = bytes2[byte] | shifted >> 8;
|
|
245
|
+
if (byte + 1 < USER_ID_BYTES) bytes2[byte + 1] = shifted & 255;
|
|
246
|
+
}
|
|
247
|
+
return userId(bytes2);
|
|
248
|
+
}
|
|
249
|
+
function accountIdFromUserId(id2) {
|
|
250
|
+
const bytes2 = id2.toBytes();
|
|
251
|
+
const count = bytes2[0];
|
|
252
|
+
if (count < 1 || count > MAX_CHARACTERS) return refused();
|
|
253
|
+
let accountId = "";
|
|
254
|
+
for (let index = 0; index < count; index += 1) {
|
|
255
|
+
const bit = index * 5;
|
|
256
|
+
const byte = 1 + (bit >> 3);
|
|
257
|
+
const word = bytes2[byte] << 8 | (bytes2[byte + 1] ?? 0);
|
|
258
|
+
accountId += ALPHABET$1[word >> 11 - (bit & 7) & 31];
|
|
259
|
+
}
|
|
260
|
+
const expected = accountUserId(accountId);
|
|
261
|
+
return isSuccess(expected) && expected.success.equals(id2) ? succeed(accountId) : refused();
|
|
262
|
+
}
|
|
229
263
|
const MAX_RECORD_BYTES = 8192;
|
|
230
264
|
const MAX_DEPTH = 8;
|
|
231
265
|
const MAX_ARRAY_LENGTH = 32;
|
|
@@ -2986,7 +3020,7 @@ function openDocument(view, scope2, documentKey, frame, additionalData) {
|
|
|
2986
3020
|
}
|
|
2987
3021
|
const verified = Symbol("VerifiedMachineSharingPolicy");
|
|
2988
3022
|
const policies = /* @__PURE__ */ new WeakMap();
|
|
2989
|
-
const domain$3 = () => new TextEncoder().encode("lody-e2ee/machine-sharing/
|
|
3023
|
+
const domain$3 = () => new TextEncoder().encode("lody-e2ee/machine-sharing/v3\0");
|
|
2990
3024
|
const fail$n = (code) => fail$v(new ContentError({ code }));
|
|
2991
3025
|
const mapped = (value, code = "invalid-policy") => mapError(value, () => new ContentError({ code }));
|
|
2992
3026
|
const hexPattern = (size) => new RegExp(`^[0-9a-f]{${size * 2}}$`);
|
|
@@ -3008,10 +3042,35 @@ function projectSet(projects) {
|
|
|
3008
3042
|
return rows;
|
|
3009
3043
|
});
|
|
3010
3044
|
}
|
|
3045
|
+
function sessionSet(sessions) {
|
|
3046
|
+
return gen(function* () {
|
|
3047
|
+
if (!Array.isArray(sessions) || sessions.length > 4096) return yield* fail$n("invalid-policy");
|
|
3048
|
+
const rows = [];
|
|
3049
|
+
for (const row of sessions) {
|
|
3050
|
+
if (!row || row.level !== "read") return yield* fail$n("invalid-policy");
|
|
3051
|
+
const bytes2 = yield* identity(row.sessionId);
|
|
3052
|
+
const audience = row.audience === "team" ? 0 : row.audience && typeof row.audience === "object" && Object.keys(row.audience).length === 1 ? yield* identity(row.audience.userId) : void 0;
|
|
3053
|
+
if (audience === void 0) return yield* fail$n("invalid-policy");
|
|
3054
|
+
const sortKey = keyId(bytes2) + ":" + (audience === 0 ? "0" : "1" + keyId(audience));
|
|
3055
|
+
rows.push({ text: row.sessionId, bytes: bytes2, audience, sortKey });
|
|
3056
|
+
}
|
|
3057
|
+
rows.sort((a, b) => a.sortKey < b.sortKey ? -1 : a.sortKey > b.sortKey ? 1 : 0);
|
|
3058
|
+
if (rows.some((row, i) => i > 0 && row.sortKey === rows[i - 1].sortKey))
|
|
3059
|
+
return yield* fail$n("invalid-policy");
|
|
3060
|
+
return rows;
|
|
3061
|
+
});
|
|
3062
|
+
}
|
|
3063
|
+
const grant = (row) => Object.freeze({
|
|
3064
|
+
sessionId: row.text,
|
|
3065
|
+
audience: row.audience === 0 ? "team" : Object.freeze({ userId: getOrThrow(decodeMachineId(row.audience)) }),
|
|
3066
|
+
level: "read"
|
|
3067
|
+
});
|
|
3068
|
+
const sameAudience = (a, row) => (a.audience === void 0 ? "team" : a.audience) === "team" ? row.audience === "team" : row.audience !== "team" && row.audience.userId === a.audience.userId;
|
|
3011
3069
|
function updateMachineSharingState(state, change) {
|
|
3012
3070
|
return gen(function* () {
|
|
3013
3071
|
const current = yield* projectSet(state.projects);
|
|
3014
|
-
|
|
3072
|
+
let sessions = (yield* sessionSet(state.sessions)).map(grant);
|
|
3073
|
+
if (typeof state.sharedWithTeam !== "boolean" || change.kind !== "session" && typeof change.sharedWithTeam !== "boolean")
|
|
3015
3074
|
return yield* fail$n("invalid-policy");
|
|
3016
3075
|
let projects = current.map((row) => row.text);
|
|
3017
3076
|
let sharedWithTeam = state.sharedWithTeam;
|
|
@@ -3023,9 +3082,29 @@ function updateMachineSharingState(state, change) {
|
|
|
3023
3082
|
projects.push(change.localProjectId);
|
|
3024
3083
|
sharedWithTeam = true;
|
|
3025
3084
|
}
|
|
3085
|
+
} else if (change.kind === "session") {
|
|
3086
|
+
yield* identity(change.sessionId);
|
|
3087
|
+
if (change.level !== null && change.level !== "read") return yield* fail$n("invalid-policy");
|
|
3088
|
+
yield* sessionSet([
|
|
3089
|
+
{
|
|
3090
|
+
sessionId: change.sessionId,
|
|
3091
|
+
audience: change.audience === void 0 ? "team" : change.audience,
|
|
3092
|
+
level: "read"
|
|
3093
|
+
}
|
|
3094
|
+
]);
|
|
3095
|
+
sessions = sessions.filter(
|
|
3096
|
+
(row) => row.sessionId !== change.sessionId || !sameAudience(change, row)
|
|
3097
|
+
);
|
|
3098
|
+
if (change.level === "read")
|
|
3099
|
+
sessions.push({
|
|
3100
|
+
sessionId: change.sessionId,
|
|
3101
|
+
audience: change.audience ?? "team",
|
|
3102
|
+
level: "read"
|
|
3103
|
+
});
|
|
3026
3104
|
} else return yield* fail$n("invalid-policy");
|
|
3027
3105
|
return Object.freeze({
|
|
3028
3106
|
sharedWithTeam,
|
|
3107
|
+
sessions: Object.freeze((yield* sessionSet(sessions)).map(grant)),
|
|
3029
3108
|
projects: Object.freeze((yield* projectSet(projects)).map((row) => row.text))
|
|
3030
3109
|
});
|
|
3031
3110
|
});
|
|
@@ -3042,9 +3121,10 @@ function encodeMachineSharingPolicy(policy) {
|
|
|
3042
3121
|
return yield* fail$n("invalid-policy");
|
|
3043
3122
|
const previous = policy.previousDigest === null ? null : yield* rawHex(policy.previousDigest, 32);
|
|
3044
3123
|
const projects = yield* projectSet(policy.projects);
|
|
3124
|
+
const sessions = yield* sessionSet(policy.sessions);
|
|
3045
3125
|
return yield* mapped(
|
|
3046
3126
|
encodeMachineSharingCbor([
|
|
3047
|
-
|
|
3127
|
+
3,
|
|
3048
3128
|
1,
|
|
3049
3129
|
workspace,
|
|
3050
3130
|
genesis,
|
|
@@ -3057,7 +3137,8 @@ function encodeMachineSharingPolicy(policy) {
|
|
|
3057
3137
|
signer,
|
|
3058
3138
|
policy.issuedAt,
|
|
3059
3139
|
request,
|
|
3060
|
-
generation
|
|
3140
|
+
generation,
|
|
3141
|
+
sessions.map((row) => [row.bytes, row.audience, 1])
|
|
3061
3142
|
])
|
|
3062
3143
|
);
|
|
3063
3144
|
});
|
|
@@ -3065,8 +3146,8 @@ function encodeMachineSharingPolicy(policy) {
|
|
|
3065
3146
|
function decodeMachineSharingPolicy(bytes2) {
|
|
3066
3147
|
return gen(function* () {
|
|
3067
3148
|
const row = yield* mapped(decodeMachineSharingCbor(bytes2));
|
|
3068
|
-
if (!Array.isArray(row) || row.length !==
|
|
3069
|
-
if (row[0] !==
|
|
3149
|
+
if (!Array.isArray(row) || row.length !== 15) return yield* fail$n("invalid-policy");
|
|
3150
|
+
if (row[0] !== 3) return yield* fail$n("unsupported-policy-version");
|
|
3070
3151
|
if (row[1] !== 1) return yield* fail$n("invalid-policy-purpose");
|
|
3071
3152
|
const [
|
|
3072
3153
|
,
|
|
@@ -3082,14 +3163,28 @@ function decodeMachineSharingPolicy(bytes2) {
|
|
|
3082
3163
|
signer,
|
|
3083
3164
|
issuedAt,
|
|
3084
3165
|
request,
|
|
3085
|
-
generation
|
|
3166
|
+
generation,
|
|
3167
|
+
sessions
|
|
3086
3168
|
] = row;
|
|
3087
3169
|
const text2 = (value) => mapped(decodeMachineId(value));
|
|
3088
|
-
if (!(genesis instanceof Uint8Array) || !(owner instanceof Uint8Array) || !(signer instanceof Uint8Array) || !(request instanceof Uint8Array) || !(generation instanceof Uint8Array) || previous !== null && !(previous instanceof Uint8Array) || typeof revision !== "number" || typeof issuedAt !== "number" || typeof shared !== "boolean" || !Array.isArray(projects))
|
|
3170
|
+
if (!(genesis instanceof Uint8Array) || !(owner instanceof Uint8Array) || !(signer instanceof Uint8Array) || !(request instanceof Uint8Array) || !(generation instanceof Uint8Array) || previous !== null && !(previous instanceof Uint8Array) || typeof revision !== "number" || typeof issuedAt !== "number" || typeof shared !== "boolean" || !Array.isArray(projects) || !Array.isArray(sessions))
|
|
3089
3171
|
return yield* fail$n("invalid-policy");
|
|
3090
3172
|
const names = [];
|
|
3091
3173
|
for (const project of projects) names.push(yield* text2(project));
|
|
3174
|
+
const grants = [];
|
|
3175
|
+
for (const session of sessions) {
|
|
3176
|
+
if (!Array.isArray(session) || session.length !== 3 || session[2] !== 1)
|
|
3177
|
+
return yield* fail$n("invalid-policy");
|
|
3178
|
+
grants.push(
|
|
3179
|
+
Object.freeze({
|
|
3180
|
+
sessionId: yield* text2(session[0]),
|
|
3181
|
+
audience: session[1] === 0 ? "team" : Object.freeze({ userId: yield* text2(session[1]) }),
|
|
3182
|
+
level: "read"
|
|
3183
|
+
})
|
|
3184
|
+
);
|
|
3185
|
+
}
|
|
3092
3186
|
const policy = Object.freeze({
|
|
3187
|
+
sessions: Object.freeze(grants),
|
|
3093
3188
|
workspaceId: yield* text2(workspace),
|
|
3094
3189
|
genesisHash: keyId(genesis),
|
|
3095
3190
|
machineId: yield* text2(machine),
|
|
@@ -3139,13 +3234,18 @@ function machineSharingContentScope(binding, epoch) {
|
|
|
3139
3234
|
function machineSharingDigest(frame) {
|
|
3140
3235
|
return frame instanceof Uint8Array && frame.length >= 143 && frame.length <= 256 * 1024 + 143 ? succeed(keyId(sha256(frame))) : fail$n("invalid-policy-frame");
|
|
3141
3236
|
}
|
|
3142
|
-
function policyAuthority(ledger, policy, machineGeneration) {
|
|
3237
|
+
function policyAuthority(ledger, policy, machineGeneration, acceptRetiredPersonal = false) {
|
|
3143
3238
|
return gen(function* () {
|
|
3144
3239
|
yield* mapped(requireLedgerContinuation(ledger, ledger), "invalid-policy-ledger");
|
|
3145
3240
|
yield* requireMachineSharingGeneration(ledger, policy, machineGeneration);
|
|
3146
3241
|
if (keyId(ledger.genesis.toBytes()) !== policy.genesisHash)
|
|
3147
3242
|
return yield* fail$n("policy-binding-mismatch");
|
|
3148
|
-
const state = ledger.inspectState()
|
|
3243
|
+
const state = ledger.inspectState();
|
|
3244
|
+
const currentSigner = state.devices.get(policy.signer);
|
|
3245
|
+
const key2 = yield* mapped(signingPublicKey(yield* rawHex(policy.signer, 32)));
|
|
3246
|
+
const historical = acceptRetiredPersonal ? historicalContentIdentity(ledger, key2) : null;
|
|
3247
|
+
const historicalKind = acceptRetiredPersonal ? historicalDeviceKind(ledger, key2) : null;
|
|
3248
|
+
const signer = currentSigner ?? (historical && isSuccess(historical) && historicalKind && isSuccess(historicalKind) ? { kind: historicalKind.success, membershipId: historical.success.memberInstance } : void 0);
|
|
3149
3249
|
const owner = state.members.get(policy.ownerMembershipId);
|
|
3150
3250
|
const machine = [...state.devices.values()].find(
|
|
3151
3251
|
(d) => d.kind === "machine" && d.machineId === policy.machineId
|
|
@@ -3221,33 +3321,26 @@ function readPolicyFrame(input) {
|
|
|
3221
3321
|
return yield* fail$n("policy-binding-mismatch");
|
|
3222
3322
|
const head = Object.freeze({ revision: policy.revision, digest: digest2 });
|
|
3223
3323
|
const previous = input.previous;
|
|
3224
|
-
if (head.revision !== input.expectedHead.revision ||
|
|
3324
|
+
if (head.revision !== input.expectedHead.revision || previous !== null && (!Number.isSafeInteger(previous.revision) || previous.revision < 1 || !hexPattern(32).test(previous.digest) || head.revision < previous.revision || head.revision === previous.revision && head.digest !== previous.digest))
|
|
3225
3325
|
return yield* fail$n("policy-version-conflict");
|
|
3226
3326
|
return { policy, head, signer: opened.author.device };
|
|
3227
3327
|
});
|
|
3228
3328
|
}
|
|
3229
|
-
function readMachineSharingHistoryStep(input) {
|
|
3230
|
-
return gen(function* () {
|
|
3231
|
-
const { policy, head, signer } = yield* readPolicyFrame(input);
|
|
3232
|
-
const kind = yield* mapped(
|
|
3233
|
-
historicalDeviceKind(input.ledger, signer),
|
|
3234
|
-
"policy-signer-ineligible"
|
|
3235
|
-
);
|
|
3236
|
-
if (kind !== "personal") return yield* fail$n("policy-signer-ineligible");
|
|
3237
|
-
return Object.freeze({ _tag: "MachineSharingHistoryStep", policy, head });
|
|
3238
|
-
});
|
|
3239
|
-
}
|
|
3240
|
-
function verifyMachineSharingHistoryStep(input) {
|
|
3241
|
-
return map$1(readPolicyFrame(input), ({ head }) => head);
|
|
3242
|
-
}
|
|
3243
3329
|
function openMachineSharingPolicy(input) {
|
|
3244
3330
|
return gen(function* () {
|
|
3245
3331
|
const { policy, head } = yield* readPolicyFrame(input);
|
|
3246
|
-
yield* policyAuthority(input.ledger, policy, input.machineGeneration);
|
|
3332
|
+
yield* policyAuthority(input.ledger, policy, input.machineGeneration, true);
|
|
3247
3333
|
const evidence = Object.freeze({
|
|
3248
3334
|
[verified]: true,
|
|
3249
3335
|
head,
|
|
3250
|
-
inspect: () => ({
|
|
3336
|
+
inspect: () => ({
|
|
3337
|
+
...policy,
|
|
3338
|
+
projects: [...policy.projects],
|
|
3339
|
+
sessions: policy.sessions.map((row) => ({
|
|
3340
|
+
...row,
|
|
3341
|
+
audience: row.audience === "team" ? "team" : { ...row.audience }
|
|
3342
|
+
}))
|
|
3343
|
+
})
|
|
3251
3344
|
});
|
|
3252
3345
|
policies.set(evidence, { policy, ledger: input.ledger });
|
|
3253
3346
|
return evidence;
|
|
@@ -3284,7 +3377,7 @@ function authorizeMachineExecution(input) {
|
|
|
3284
3377
|
const policy = evidence.policy;
|
|
3285
3378
|
if (!sameBinding(policy, { ...target, ownerMembershipId: keyId(machine.membershipId.toBytes()) }))
|
|
3286
3379
|
return deny("policy-binding-mismatch");
|
|
3287
|
-
if (isFailure(policyAuthority(input.ledger, policy, input.machineGeneration)))
|
|
3380
|
+
if (isFailure(policyAuthority(input.ledger, policy, input.machineGeneration, true)))
|
|
3288
3381
|
return deny("policy-signer-ineligible");
|
|
3289
3382
|
if (!policy.sharedWithTeam) return deny("machine-not-shared");
|
|
3290
3383
|
if (input.localProjectId !== void 0 && !policy.projects.includes(input.localProjectId))
|
|
@@ -4880,13 +4973,18 @@ const makeSession = fnUntraced(function* (input) {
|
|
|
4880
4973
|
input.master.fill(0);
|
|
4881
4974
|
let closed = false;
|
|
4882
4975
|
const mutex = yield* make$1(1);
|
|
4976
|
+
let readers = 0;
|
|
4977
|
+
const readsDrained = makeUnsafe();
|
|
4883
4978
|
yield* addFinalizer(
|
|
4884
|
-
() =>
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4979
|
+
() => gen$1(function* () {
|
|
4980
|
+
yield* mutex.withPermit(
|
|
4981
|
+
sync(() => {
|
|
4982
|
+
closed = true;
|
|
4983
|
+
master.fill(0);
|
|
4984
|
+
})
|
|
4985
|
+
);
|
|
4986
|
+
if (readers > 0) yield* _await(readsDrained);
|
|
4987
|
+
})
|
|
4890
4988
|
);
|
|
4891
4989
|
const ownedOperation = (work) => mutex.withPermit(uninterruptible(work));
|
|
4892
4990
|
const guard = () => {
|
|
@@ -4939,14 +5037,14 @@ const makeSession = fnUntraced(function* (input) {
|
|
|
4939
5037
|
yield* attempt$6(guard);
|
|
4940
5038
|
return { header, value };
|
|
4941
5039
|
});
|
|
4942
|
-
const readEntry = fnUntraced(function* (ref) {
|
|
5040
|
+
const readEntry = fnUntraced(function* (ref, readMaster = master) {
|
|
4943
5041
|
yield* attempt$6(guard);
|
|
4944
5042
|
const remote = yield* store.readEntry(vaultId, ref.entryId);
|
|
4945
5043
|
if (!remote) return yield* vaultError("missing");
|
|
4946
5044
|
const header = yield* attempt$6(() => ownCiphertext(remote));
|
|
4947
5045
|
if (ciphertextDigest(header) !== ref.digest) return yield* vaultError("authentication");
|
|
4948
5046
|
return yield* acquireUseRelease(
|
|
4949
|
-
attempt$6(() => decryptVault(
|
|
5047
|
+
attempt$6(() => decryptVault(readMaster, vaultId, header, "workspace-entry")),
|
|
4950
5048
|
(plain) => attempt$6(() => {
|
|
4951
5049
|
const value = useCanonicalSecret(
|
|
4952
5050
|
plain,
|
|
@@ -5120,7 +5218,25 @@ const makeSession = fnUntraced(function* (input) {
|
|
|
5120
5218
|
vaultId,
|
|
5121
5219
|
locator,
|
|
5122
5220
|
readIndex: () => ownedOperation(index()),
|
|
5123
|
-
|
|
5221
|
+
/** Each immutable package read owns a short-lived key copy, not the index lock. */
|
|
5222
|
+
readEntry: (ref) => {
|
|
5223
|
+
const reference = { ...ref };
|
|
5224
|
+
return acquireUseRelease(
|
|
5225
|
+
mutex.withPermit(
|
|
5226
|
+
attempt$6(() => {
|
|
5227
|
+
guard();
|
|
5228
|
+
const key2 = master.slice();
|
|
5229
|
+
readers++;
|
|
5230
|
+
return key2;
|
|
5231
|
+
})
|
|
5232
|
+
),
|
|
5233
|
+
(key2) => readEntry(reference, key2),
|
|
5234
|
+
(key2) => sync(() => {
|
|
5235
|
+
key2.fill(0);
|
|
5236
|
+
if (--readers === 0 && closed) doneUnsafe(readsDrained, void_);
|
|
5237
|
+
})
|
|
5238
|
+
).pipe(uninterruptible);
|
|
5239
|
+
},
|
|
5124
5240
|
upload: (value, entryId = hex$8(random(32))) => ownedOperation(upload(value, entryId)),
|
|
5125
5241
|
reserve: (candidate) => ownedOperation(reserve(candidate)),
|
|
5126
5242
|
replace: (candidate) => ownedOperation(reserve(candidate, true)),
|
|
@@ -5906,6 +6022,17 @@ const makeWorkspaceRecovery = fnUntraced(function* (input) {
|
|
|
5906
6022
|
const epoch = opened;
|
|
5907
6023
|
if (personal.publicKey.equals(identity2.publicKey) || personal.encryptionPublicKey.equals(identity2.encryptionPublicKey))
|
|
5908
6024
|
return yield* vaultError("invalid-input");
|
|
6025
|
+
const retained2 = view.inspectState().devices.get(hex$8(personal.publicKey.toBytes()));
|
|
6026
|
+
if (retained2) {
|
|
6027
|
+
if (retained2.kind !== "personal" || !retained2.membershipId.equals(membership) || !retained2.encryptionPublicKey.equals(personal.encryptionPublicKey))
|
|
6028
|
+
return yield* vaultError("unauthorized");
|
|
6029
|
+
return {
|
|
6030
|
+
outcome: "Committed",
|
|
6031
|
+
epoch,
|
|
6032
|
+
personal: personal.publicKey,
|
|
6033
|
+
role: view.inspectState().members.get(hex$8(membership.toBytes())).role
|
|
6034
|
+
};
|
|
6035
|
+
}
|
|
5909
6036
|
const restoreKey = `${key2}/restore`, before = yield* local.read(restoreKey);
|
|
5910
6037
|
let intent;
|
|
5911
6038
|
if (before) {
|
|
@@ -6274,6 +6401,7 @@ fnUntraced(function* (local, vaultId) {
|
|
|
6274
6401
|
}
|
|
6275
6402
|
return progress;
|
|
6276
6403
|
});
|
|
6404
|
+
const withE2eeTestClock = (work) => work;
|
|
6277
6405
|
const machineSharingGenerationFromHistory = fnUntraced(function* (input) {
|
|
6278
6406
|
const admissions = /* @__PURE__ */ new Map();
|
|
6279
6407
|
const hex2 = (key2) => Buffer.from(key2.toBytes()).toString("hex");
|
|
@@ -6481,7 +6609,7 @@ const makeMachineSharingHost = fn("MachineSharingHost.make")(function* (options)
|
|
|
6481
6609
|
throw error2;
|
|
6482
6610
|
}
|
|
6483
6611
|
});
|
|
6484
|
-
const readFrame = fnUntraced(function* (binding, version, machineGeneration, previous
|
|
6612
|
+
const readFrame = fnUntraced(function* (binding, version, machineGeneration, previous) {
|
|
6485
6613
|
if (!matches(binding, version)) return yield* fail$i("sharing_invalid");
|
|
6486
6614
|
const frame = unhex$2(version.frameHex);
|
|
6487
6615
|
const epoch = new DataView(frame.buffer, frame.byteOffset, frame.byteLength).getUint32(
|
|
@@ -6505,26 +6633,8 @@ const makeMachineSharingHost = fn("MachineSharingHost.make")(function* (options)
|
|
|
6505
6633
|
expectedHead: version,
|
|
6506
6634
|
previous
|
|
6507
6635
|
};
|
|
6508
|
-
|
|
6509
|
-
|
|
6510
|
-
head: yield* fromResult(verifyMachineSharingHistoryStep(input)),
|
|
6511
|
-
policy: null,
|
|
6512
|
-
state: null
|
|
6513
|
-
};
|
|
6514
|
-
if (management) {
|
|
6515
|
-
const active = openMachineSharingPolicy(input);
|
|
6516
|
-
if (isSuccess(active)) {
|
|
6517
|
-
const body2 = active.success.inspect();
|
|
6518
|
-
if (body2.requestId !== version.requestId || body2.previousDigest !== version.previousDigest)
|
|
6519
|
-
return yield* fail$i("sharing_invalid");
|
|
6520
|
-
return { head: active.success.head, policy: active.success, state: body2 };
|
|
6521
|
-
}
|
|
6522
|
-
const historical = yield* fromResult(readMachineSharingHistoryStep(input));
|
|
6523
|
-
if (historical.policy.requestId !== version.requestId || historical.policy.previousDigest !== version.previousDigest)
|
|
6524
|
-
return yield* fail$i("sharing_invalid");
|
|
6525
|
-
return { head: historical.head, policy: null, state: historical.policy };
|
|
6526
|
-
}
|
|
6527
|
-
const policy = yield* fromResult(openMachineSharingPolicy(input));
|
|
6636
|
+
const active = openMachineSharingPolicy(input);
|
|
6637
|
+
const policy = yield* fromResult(active);
|
|
6528
6638
|
const body = policy.inspect();
|
|
6529
6639
|
if (body.requestId !== version.requestId || body.previousDigest !== version.previousDigest)
|
|
6530
6640
|
return yield* fail$i("sharing_invalid");
|
|
@@ -6532,7 +6642,7 @@ const makeMachineSharingHost = fn("MachineSharingHost.make")(function* (options)
|
|
|
6532
6642
|
})
|
|
6533
6643
|
);
|
|
6534
6644
|
});
|
|
6535
|
-
const latest = fnUntraced(function* (binding, remote, machineGeneration, force = false
|
|
6645
|
+
const latest = fnUntraced(function* (binding, remote, machineGeneration, force = false) {
|
|
6536
6646
|
const token = invalidationToken;
|
|
6537
6647
|
const resource = key$2(binding);
|
|
6538
6648
|
const cached2 = cache.get(resource);
|
|
@@ -6559,36 +6669,26 @@ const makeMachineSharingHost = fn("MachineSharingHost.make")(function* (options)
|
|
|
6559
6669
|
return { policy: null, state: null, head };
|
|
6560
6670
|
}
|
|
6561
6671
|
if (saved?.head?.status === "removed") return yield* fail$i("sharing_conflict");
|
|
6562
|
-
|
|
6563
|
-
|
|
6564
|
-
|
|
6565
|
-
|
|
6566
|
-
|
|
6567
|
-
|
|
6568
|
-
|
|
6569
|
-
|
|
6570
|
-
|
|
6571
|
-
|
|
6572
|
-
|
|
6573
|
-
|
|
6574
|
-
|
|
6575
|
-
|
|
6576
|
-
|
|
6577
|
-
|
|
6578
|
-
|
|
6579
|
-
|
|
6580
|
-
|
|
6581
|
-
|
|
6582
|
-
previous = read22.head;
|
|
6583
|
-
policy = read22.policy;
|
|
6584
|
-
fullState = read22.state;
|
|
6585
|
-
if (revision === head.revision) {
|
|
6586
|
-
if (!sameHead(read22.head, head)) return yield* fail$i("sharing_conflict");
|
|
6587
|
-
yield* guard();
|
|
6588
|
-
if (read22.policy) yield* remember(binding, head, raw2);
|
|
6589
|
-
}
|
|
6590
|
-
}
|
|
6591
|
-
if (!policy && !management || !fullState || !sharingFresh(started, yield* sharingStamp))
|
|
6672
|
+
const raw2 = saved?.original?.revision === head.revision ? saved.original : yield* parse(
|
|
6673
|
+
sharingReplySchemas.readVersion,
|
|
6674
|
+
yield* remote.readVersion({ ...access, revision: head.revision })
|
|
6675
|
+
);
|
|
6676
|
+
if (!raw2 || "status" in raw2 || raw2.revision !== head.revision)
|
|
6677
|
+
return yield* fail$i("sharing_unavailable");
|
|
6678
|
+
const read22 = yield* readFrame(
|
|
6679
|
+
binding,
|
|
6680
|
+
raw2,
|
|
6681
|
+
machineGeneration,
|
|
6682
|
+
saved?.head?.status === "active" ? saved.head : null
|
|
6683
|
+
);
|
|
6684
|
+
const policy = read22.policy;
|
|
6685
|
+
const fullState = read22.state;
|
|
6686
|
+
if (!sameHead(read22.head, head)) return yield* fail$i("sharing_conflict");
|
|
6687
|
+
yield* guard();
|
|
6688
|
+
if (token !== invalidationToken || !sharingFresh(started, yield* sharingStamp))
|
|
6689
|
+
return yield* fail$i("sharing_unavailable");
|
|
6690
|
+
if (read22.policy) yield* remember(binding, head, raw2);
|
|
6691
|
+
if (!policy || !fullState || !sharingFresh(started, yield* sharingStamp))
|
|
6592
6692
|
return yield* fail$i("sharing_unavailable");
|
|
6593
6693
|
if (policy)
|
|
6594
6694
|
yield* sql$3(() => {
|
|
@@ -6656,9 +6756,7 @@ const makeMachineSharingHost = fn("MachineSharingHost.make")(function* (options)
|
|
|
6656
6756
|
)
|
|
6657
6757
|
};
|
|
6658
6758
|
});
|
|
6659
|
-
const checked = yield* result(
|
|
6660
|
-
latest(binding, remote, machineGeneration, force, true)
|
|
6661
|
-
);
|
|
6759
|
+
const checked = yield* result(latest(binding, remote, machineGeneration, force));
|
|
6662
6760
|
if (isFailure(checked) && !unfinished) return yield* fail$w(checked.failure);
|
|
6663
6761
|
const policy = isSuccess(checked) ? checked.success.policy : null;
|
|
6664
6762
|
const saved = yield* pin(binding);
|
|
@@ -6682,22 +6780,16 @@ const makeMachineSharingHost = fn("MachineSharingHost.make")(function* (options)
|
|
|
6682
6780
|
machineId,
|
|
6683
6781
|
ownerMembershipId: binding.ownerMembershipId,
|
|
6684
6782
|
generation: binding.generation,
|
|
6685
|
-
head: isSuccess(checked) &&
|
|
6783
|
+
head: isSuccess(checked) && checked.success.head ? {
|
|
6686
6784
|
revision: checked.success.head.revision,
|
|
6687
6785
|
digest: checked.success.head.digest
|
|
6688
6786
|
} : null,
|
|
6689
6787
|
sharedWithTeam: body?.sharedWithTeam ?? false,
|
|
6690
6788
|
projects: body?.projects ?? [],
|
|
6789
|
+
sessions: body?.sessions ?? [],
|
|
6691
6790
|
canManage,
|
|
6692
6791
|
signer: body?.signer ?? null,
|
|
6693
|
-
needsResign: !!body &&
|
|
6694
|
-
const signer = current.ledger.inspectState().devices.get(body.signer);
|
|
6695
|
-
const permission = contentPermissions(
|
|
6696
|
-
current.ledger,
|
|
6697
|
-
getOrThrow(signingPublicKey(unhex$2(body.signer)))
|
|
6698
|
-
);
|
|
6699
|
-
return signer?.kind !== "personal" || hex$7(signer.membershipId.toBytes()) !== binding.ownerMembershipId || isFailure(permission) || !permission.success.mayWriteDocument;
|
|
6700
|
-
})()),
|
|
6792
|
+
needsResign: !!body && !current.ledger.inspectState().devices.has(body.signer),
|
|
6701
6793
|
...!decision.allowed ? { deniedReason: "e2ee_machine_not_shared" } : {},
|
|
6702
6794
|
removed: saved?.head?.status === "removed",
|
|
6703
6795
|
...unfinished ? { pendingRequest: unfinished } : {},
|
|
@@ -6706,30 +6798,25 @@ const makeMachineSharingHost = fn("MachineSharingHost.make")(function* (options)
|
|
|
6706
6798
|
})
|
|
6707
6799
|
);
|
|
6708
6800
|
});
|
|
6709
|
-
const pinnedDenial = (initial, decide
|
|
6801
|
+
const pinnedDenial = (initial, decide) => gen$1(function* () {
|
|
6710
6802
|
const saved = yield* pin(initial.binding);
|
|
6711
6803
|
const original = saved?.original;
|
|
6712
6804
|
if (saved?.head?.status !== "active" || !original || original.revision !== saved.head.revision || original.digest !== saved.head.digest)
|
|
6713
6805
|
return void 0;
|
|
6714
|
-
const retained2 = yield* readFrame(
|
|
6715
|
-
|
|
6716
|
-
original
|
|
6717
|
-
|
|
6718
|
-
|
|
6719
|
-
true,
|
|
6720
|
-
true
|
|
6721
|
-
);
|
|
6722
|
-
if (!retained2.policy) {
|
|
6723
|
-
if (!retained2.state) return void 0;
|
|
6724
|
-
if (!retained2.state.sharedWithTeam)
|
|
6725
|
-
return { allowed: false, reason: "machine-not-shared" };
|
|
6726
|
-
if (localProjectId !== void 0 && !retained2.state.projects.includes(localProjectId))
|
|
6727
|
-
return { allowed: false, reason: "project-not-shared" };
|
|
6728
|
-
return void 0;
|
|
6729
|
-
}
|
|
6806
|
+
const retained2 = yield* readFrame(initial.binding, original, initial.machineGeneration, {
|
|
6807
|
+
revision: original.revision,
|
|
6808
|
+
digest: original.digest
|
|
6809
|
+
});
|
|
6810
|
+
if (!retained2.policy) return void 0;
|
|
6730
6811
|
const decision = decide(yield* options.ledger(), retained2.policy);
|
|
6731
6812
|
return !decision.allowed && (decision.reason === "machine-not-shared" || decision.reason === "project-not-shared") ? decision : void 0;
|
|
6732
|
-
}).pipe(
|
|
6813
|
+
}).pipe(
|
|
6814
|
+
catch_(
|
|
6815
|
+
(error2) => succeed$2(
|
|
6816
|
+
error2 instanceof ContentError && error2.code === "policy-signer-ineligible" ? { allowed: false, reason: "machine-not-shared" } : void 0
|
|
6817
|
+
)
|
|
6818
|
+
)
|
|
6819
|
+
);
|
|
6733
6820
|
const decider = fnUntraced(function* (machineId, requester, localProjectId) {
|
|
6734
6821
|
const qualified = yield* result(target(machineId));
|
|
6735
6822
|
if (isFailure(qualified)) return void 0;
|
|
@@ -6756,7 +6843,7 @@ const makeMachineSharingHost = fn("MachineSharingHost.make")(function* (options)
|
|
|
6756
6843
|
if (yield* authorizeOwner(options, machineId, requester, localProjectId)) return void 0;
|
|
6757
6844
|
const resolved = yield* decider(machineId, requester, localProjectId);
|
|
6758
6845
|
if (!resolved || resolved.decide(resolved.initial.ledger, null).allowed) return void 0;
|
|
6759
|
-
return yield* pinnedDenial(resolved.initial, resolved.decide
|
|
6846
|
+
return yield* pinnedDenial(resolved.initial, resolved.decide);
|
|
6760
6847
|
});
|
|
6761
6848
|
const authorize = fnUntraced(function* (machineId, requester, localProjectId, remote) {
|
|
6762
6849
|
yield* guard();
|
|
@@ -6769,7 +6856,7 @@ const makeMachineSharingHost = fn("MachineSharingHost.make")(function* (options)
|
|
|
6769
6856
|
if (own2.allowed) return own2;
|
|
6770
6857
|
if (own2.reason !== "policy-unavailable") return own2;
|
|
6771
6858
|
const unknown2 = () => map$2(
|
|
6772
|
-
pinnedDenial(initial, decide
|
|
6859
|
+
pinnedDenial(initial, decide),
|
|
6773
6860
|
(denial) => denial ?? { allowed: false, reason: "policy-unavailable" }
|
|
6774
6861
|
);
|
|
6775
6862
|
return yield* admitted(
|
|
@@ -6792,7 +6879,7 @@ const makeMachineSharingHost = fn("MachineSharingHost.make")(function* (options)
|
|
|
6792
6879
|
);
|
|
6793
6880
|
}
|
|
6794
6881
|
if (isFailure(refreshed)) {
|
|
6795
|
-
const denial = yield* pinnedDenial(initial, decide
|
|
6882
|
+
const denial = yield* pinnedDenial(initial, decide);
|
|
6796
6883
|
if (denial) return denial;
|
|
6797
6884
|
return yield* fail$w(refreshed.failure);
|
|
6798
6885
|
}
|
|
@@ -6813,6 +6900,16 @@ const makeMachineSharingHost = fn("MachineSharingHost.make")(function* (options)
|
|
|
6813
6900
|
})
|
|
6814
6901
|
);
|
|
6815
6902
|
});
|
|
6903
|
+
const readSessionAccess = fnUntraced(function* (machineId, remote) {
|
|
6904
|
+
const view = yield* read2(machineId, remote, false);
|
|
6905
|
+
const { binding } = yield* target(machineId);
|
|
6906
|
+
const cached2 = cache.get(key$2(binding));
|
|
6907
|
+
const isCurrent = () => !closed && !!cached2 && !!view.head && cached2.policy.head.revision === view.head.revision && cached2.policy.head.digest === view.head.digest && binding.generation === view.generation && binding.ownerMembershipId === view.ownerMembershipId && cache.get(key$2(binding)) === cached2 && sharingFresh(cached2.stamp, {
|
|
6908
|
+
wall: clock.currentTimeMillisUnsafe(),
|
|
6909
|
+
mono: clock.monotonicTimeNanosUnsafe()
|
|
6910
|
+
});
|
|
6911
|
+
return { view, isCurrent };
|
|
6912
|
+
});
|
|
6816
6913
|
const write = fnUntraced(function* (machineId, generation, rid, change, remote) {
|
|
6817
6914
|
yield* parse(requestId$1, rid);
|
|
6818
6915
|
const normalized = yield* parse(sharingChangeSchema, change);
|
|
@@ -6835,10 +6932,10 @@ const makeMachineSharingHost = fn("MachineSharingHost.make")(function* (options)
|
|
|
6835
6932
|
() => db.prepare("SELECT value FROM sharing_requests WHERE resource=?").all(key$2(binding)).some((row) => JSON.parse(String(row.value)).state === "pending")
|
|
6836
6933
|
);
|
|
6837
6934
|
if (unfinished) return yield* fail$i("sharing_conflict");
|
|
6838
|
-
const current = yield* latest(binding, remote, machineGeneration, true
|
|
6935
|
+
const current = yield* latest(binding, remote, machineGeneration, true);
|
|
6839
6936
|
const expectedHead = current.head;
|
|
6840
6937
|
if (expectedHead?.status === "removed") return { status: "removed", requestId: rid };
|
|
6841
|
-
const state2 = current.state ?? { sharedWithTeam: false, projects: [] };
|
|
6938
|
+
const state2 = current.state ?? { sharedWithTeam: false, projects: [], sessions: [] };
|
|
6842
6939
|
const next = yield* fromResult(updateMachineSharingState(state2, normalized));
|
|
6843
6940
|
const view = yield* options.ledger();
|
|
6844
6941
|
const epoch = view.inspectState().epoch.number;
|
|
@@ -6916,7 +7013,7 @@ const makeMachineSharingHost = fn("MachineSharingHost.make")(function* (options)
|
|
|
6916
7013
|
revision: original.request.expectedHead.revision,
|
|
6917
7014
|
digest: original.request.expectedHead.digest
|
|
6918
7015
|
} : null;
|
|
6919
|
-
yield* readFrame(binding, version, machineGeneration, previous
|
|
7016
|
+
yield* readFrame(binding, version, machineGeneration, previous);
|
|
6920
7017
|
yield* remember(
|
|
6921
7018
|
binding,
|
|
6922
7019
|
{ ...binding, revision: version.revision, digest: version.digest, status: "active" },
|
|
@@ -6953,6 +7050,7 @@ const makeMachineSharingHost = fn("MachineSharingHost.make")(function* (options)
|
|
|
6953
7050
|
/** Passive counts of retained policies/team grants, never current authorization. */
|
|
6954
7051
|
inspectCache,
|
|
6955
7052
|
read: (...args) => owned(read2(...args)),
|
|
7053
|
+
readSessionAccess: (...args) => owned(readSessionAccess(...args)),
|
|
6956
7054
|
write: (...args) => owned(write(...args)),
|
|
6957
7055
|
authorize: (...args) => owned(authorize(...args)),
|
|
6958
7056
|
/** A retained verified denial, read locally; `undefined` is unknown, never permission. */
|
|
@@ -6999,6 +7097,7 @@ const makeLazyMachineSharingHost = fnUntraced(function* (options) {
|
|
|
6999
7097
|
/** Count an existing owner only; observing an unopened host never opens storage. */
|
|
7000
7098
|
inspectCache: (machineId) => owner?.inspectCache(machineId) ?? { cachedPolicies: 0, cachedExecutionGrants: 0 },
|
|
7001
7099
|
read: (...args) => flatMap$1(get2, (value) => value.read(...args)),
|
|
7100
|
+
readSessionAccess: (...args) => flatMap$1(get2, (value) => value.readSessionAccess(...args)),
|
|
7002
7101
|
write: (...args) => flatMap$1(get2, (value) => value.write(...args)),
|
|
7003
7102
|
authorize: (...args) => gen$1(function* () {
|
|
7004
7103
|
if (stopped) return yield* fail$i("closed");
|
|
@@ -7389,7 +7488,12 @@ const makeEncryptedFeatureReceiver = fnUntraced(function* (options) {
|
|
|
7389
7488
|
const active = read2 ? reads : writes;
|
|
7390
7489
|
if (active.has(envelope.id) || active.size >= 32) return true;
|
|
7391
7490
|
active.add(envelope.id);
|
|
7392
|
-
const
|
|
7491
|
+
const historyRequest = opened.input.request.method === "session/history-read" ? opened.input.request : void 0;
|
|
7492
|
+
const authorize = historyRequest ? (workspaceId, requesterDevice) => options.authorizeHistoryRead?.(
|
|
7493
|
+
workspaceId,
|
|
7494
|
+
requesterDevice,
|
|
7495
|
+
historyRequest.params.sessionId
|
|
7496
|
+
) ?? succeed$2({ _tag: "Denied", reason: "not-authorized" }) : read2 ? options.authorizeRead : options.authorize;
|
|
7393
7497
|
const invoke2 = (authority) => acquireUseRelease(
|
|
7394
7498
|
sync(() => ({
|
|
7395
7499
|
controller: new AbortController(),
|
|
@@ -7426,11 +7530,13 @@ const makeEncryptedFeatureReceiver = fnUntraced(function* (options) {
|
|
|
7426
7530
|
})
|
|
7427
7531
|
);
|
|
7428
7532
|
const task = gen$1(function* () {
|
|
7533
|
+
const clock = yield* Clock;
|
|
7429
7534
|
const authority = yield* authorize(options.workspaceId, opened.requesterDevice);
|
|
7430
7535
|
const authoritySignal = options.authoritySignal?.();
|
|
7431
|
-
if (authority._tag !== "Authorized" || opened.input.request.method === "machine/acp-interaction" && (!authority.isCurrent || !authoritySignal || authoritySignal.aborted || !authority.isCurrent()) || !options.isOpen() || (yield* currentTimeMillis) >= opened.expiresAt)
|
|
7536
|
+
if (authority._tag !== "Authorized" || (opened.input.request.method === "machine/acp-interaction" || opened.input.request.method === "session/history-read") && (!authority.isCurrent || !authoritySignal || authoritySignal.aborted || !authority.isCurrent()) || !options.isOpen() || (yield* currentTimeMillis) >= opened.expiresAt)
|
|
7432
7537
|
return yield* void_;
|
|
7433
7538
|
const admittedAuthority = authority.isCurrent && authoritySignal ? { isCurrent: authority.isCurrent, signal: authoritySignal } : void 0;
|
|
7539
|
+
const currentAdmission = () => !admittedAuthority || !admittedAuthority.signal.aborted && admittedAuthority.isCurrent();
|
|
7434
7540
|
yield* options.native.retainFeatureRequest(options.machineId, opened);
|
|
7435
7541
|
let frames;
|
|
7436
7542
|
if (read2) {
|
|
@@ -7490,23 +7596,30 @@ const makeEncryptedFeatureReceiver = fnUntraced(function* (options) {
|
|
|
7490
7596
|
}
|
|
7491
7597
|
}
|
|
7492
7598
|
const current = yield* authorize(options.workspaceId, opened.requesterDevice);
|
|
7493
|
-
if (current._tag !== "Authorized" || !options.isOpen() || (yield* currentTimeMillis) >= opened.expiresAt)
|
|
7599
|
+
if (current._tag !== "Authorized" || !currentAdmission() || !options.isOpen() || (yield* currentTimeMillis) >= opened.expiresAt)
|
|
7494
7600
|
return yield* void_;
|
|
7495
7601
|
yield* options.native.verifyFeatureRequest(opened);
|
|
7602
|
+
const stream = options.native.responseStream(opened.requesterDevice);
|
|
7496
7603
|
yield* tryPromise({
|
|
7497
|
-
try:
|
|
7498
|
-
|
|
7499
|
-
|
|
7500
|
-
|
|
7501
|
-
|
|
7502
|
-
|
|
7604
|
+
try: () => options.client.ensureJsonStream(stream, 86400),
|
|
7605
|
+
catch: (cause) => cause
|
|
7606
|
+
});
|
|
7607
|
+
for (const frame of frames) {
|
|
7608
|
+
const latest = historyRequest ? yield* authorize(options.workspaceId, opened.requesterDevice) : current;
|
|
7609
|
+
if (latest._tag !== "Authorized" || latest.isCurrent && !latest.isCurrent() || !options.isOpen() || !currentAdmission() || (yield* currentTimeMillis) >= opened.expiresAt)
|
|
7610
|
+
return yield* void_;
|
|
7611
|
+
yield* tryPromise({
|
|
7612
|
+
try: () => {
|
|
7613
|
+
if (!options.isOpen() || !currentAdmission() || latest.isCurrent && !latest.isCurrent() || clock.currentTimeMillisUnsafe() >= opened.expiresAt)
|
|
7614
|
+
throw new Error("e2ee_history_authority_withdrawn");
|
|
7615
|
+
return options.client.appendJson(
|
|
7503
7616
|
stream,
|
|
7504
7617
|
e2eeRpcEnvelope({ id: opened.requestId, frame: Buffer.from(frame).toString("hex") })
|
|
7505
7618
|
);
|
|
7506
|
-
}
|
|
7507
|
-
|
|
7508
|
-
|
|
7509
|
-
}
|
|
7619
|
+
},
|
|
7620
|
+
catch: (cause) => cause
|
|
7621
|
+
});
|
|
7622
|
+
}
|
|
7510
7623
|
return yield* void_;
|
|
7511
7624
|
}).pipe(
|
|
7512
7625
|
catch_(() => void_),
|
|
@@ -10441,8 +10554,8 @@ function makeWorkspaceOperations() {
|
|
|
10441
10554
|
try: () => {
|
|
10442
10555
|
if (controller.signal.aborted)
|
|
10443
10556
|
throw new WorkspaceOperationError({ reason: "closed" });
|
|
10444
|
-
const scope2 = makeUnsafe();
|
|
10445
|
-
const completed = makeUnsafe
|
|
10557
|
+
const scope2 = makeUnsafe$1();
|
|
10558
|
+
const completed = makeUnsafe();
|
|
10446
10559
|
let closing = false;
|
|
10447
10560
|
const child = {
|
|
10448
10561
|
scope: scope2,
|
|
@@ -15687,7 +15800,7 @@ const makeCliE2eeExecutionAuthorization = fn("CliE2eeExecutionAuthorization.make
|
|
|
15687
15800
|
})
|
|
15688
15801
|
);
|
|
15689
15802
|
const authorize = fn("CliE2eeExecutionAuthorization.authorize")(
|
|
15690
|
-
function* (workspaceId, requesterDevice, access, localProjectId) {
|
|
15803
|
+
function* (workspaceId, requesterDevice, access, localProjectId, sessionId, sessionOwnerUserId) {
|
|
15691
15804
|
if (closed) return denied("closed");
|
|
15692
15805
|
if (workspaceId !== options.workspaceId || !requesterSchema.safeParse(requesterDevice).success)
|
|
15693
15806
|
return denied("invalid-request");
|
|
@@ -15720,7 +15833,7 @@ const makeCliE2eeExecutionAuthorization = fn("CliE2eeExecutionAuthorization.make
|
|
|
15720
15833
|
const permissions = yield* fromResult(contentPermissions(view, requester.success));
|
|
15721
15834
|
const reader = state.devices.get(requesterDevice);
|
|
15722
15835
|
const mayRead = reader && reader.kind !== "recovery" && state.members.has(Buffer.from(reader.membershipId.toBytes()).toString("hex"));
|
|
15723
|
-
if (access === "read" ? !mayRead : !permissions.mayWriteDocument) {
|
|
15836
|
+
if (access === "read" || access === "session-read" ? !mayRead : !permissions.mayWriteDocument) {
|
|
15724
15837
|
grants.delete(requesterDevice);
|
|
15725
15838
|
return denied("not-authorized");
|
|
15726
15839
|
}
|
|
@@ -15741,6 +15854,26 @@ const makeCliE2eeExecutionAuthorization = fn("CliE2eeExecutionAuthorization.make
|
|
|
15741
15854
|
if (relaxed && !current(yield* stamp)) return denied("unavailable");
|
|
15742
15855
|
if (principal === "member") {
|
|
15743
15856
|
grants.delete(requesterDevice);
|
|
15857
|
+
if (access === "session-read") {
|
|
15858
|
+
if (!sessionId || !options.sessionSharing) return denied("e2ee_machine_not_shared");
|
|
15859
|
+
const generation2 = options.runtime.executionGeneration();
|
|
15860
|
+
const shared2 = yield* options.sessionSharing(
|
|
15861
|
+
requesterDevice,
|
|
15862
|
+
sessionId,
|
|
15863
|
+
sessionOwnerUserId
|
|
15864
|
+
);
|
|
15865
|
+
if (!shared2.allowed || !shared2.isCurrent() || generation2 !== options.runtime.executionGeneration())
|
|
15866
|
+
return denied("e2ee_machine_not_shared");
|
|
15867
|
+
const after2 = (yield* options.runtime.executionLedger()).inspectState();
|
|
15868
|
+
const machine2 = after2.devices.get(self), signer2 = after2.devices.get(requesterDevice);
|
|
15869
|
+
if (!machine2 || !signer2 || signer2.kind === "recovery" || !after2.members.has(Buffer.from(machine2.membershipId.toBytes()).toString("hex")) || !after2.members.has(Buffer.from(signer2.membershipId.toBytes()).toString("hex")) || !current(yield* stamp))
|
|
15870
|
+
return denied("not-authorized");
|
|
15871
|
+
const isCurrent = () => !closed && options.runtime.executionGeneration() === generation2 && shared2.isCurrent() && current({
|
|
15872
|
+
wall: clock.currentTimeMillisUnsafe(),
|
|
15873
|
+
monotonic: clock.monotonicTimeNanosUnsafe()
|
|
15874
|
+
});
|
|
15875
|
+
return isCurrent() ? { _tag: "Authorized", isCurrent } : denied("not-authorized");
|
|
15876
|
+
}
|
|
15744
15877
|
if (access !== "execute") return denied("e2ee_machine_not_owned");
|
|
15745
15878
|
if (!options.sharing) return denied("e2ee_machine_not_shared");
|
|
15746
15879
|
const shared = yield* options.sharing(requesterDevice, localProjectId).pipe(catch_(() => succeed$2({ allowed: false, isCurrent: void 0 })));
|
|
@@ -15762,7 +15895,10 @@ const makeCliE2eeExecutionAuthorization = fn("CliE2eeExecutionAuthorization.make
|
|
|
15762
15895
|
if (relaxed) {
|
|
15763
15896
|
if (!noticed) {
|
|
15764
15897
|
noticed = true;
|
|
15765
|
-
options.onWindowNotice?.(true
|
|
15898
|
+
options.onWindowNotice?.(true, {
|
|
15899
|
+
executionUntilMs: grantedFrom.wall + OUTAGE_EXECUTION_WINDOW_MS,
|
|
15900
|
+
readUntilMs: grantedFrom.wall + OUTAGE_READ_WINDOW_MS
|
|
15901
|
+
});
|
|
15766
15902
|
}
|
|
15767
15903
|
} else grants.set(requesterDevice, grantedFrom);
|
|
15768
15904
|
if (access === "read") return { _tag: "Authorized" };
|
|
@@ -15785,6 +15921,14 @@ const makeCliE2eeExecutionAuthorization = fn("CliE2eeExecutionAuthorization.make
|
|
|
15785
15921
|
refreshLedger: refreshOnce.pipe(
|
|
15786
15922
|
flatMap$1((value) => value ? void_ : fail$w("unavailable"))
|
|
15787
15923
|
),
|
|
15924
|
+
authorizeSessionRead: (workspaceId, requesterDevice, rootSessionId, sessionOwnerUserId) => authorize(
|
|
15925
|
+
workspaceId,
|
|
15926
|
+
requesterDevice,
|
|
15927
|
+
"session-read",
|
|
15928
|
+
void 0,
|
|
15929
|
+
rootSessionId,
|
|
15930
|
+
sessionOwnerUserId
|
|
15931
|
+
),
|
|
15788
15932
|
authorizeRead: (workspaceId, requesterDevice) => authorize(workspaceId, requesterDevice, "read"),
|
|
15789
15933
|
/** A reply moved the ledger back. Ordinary grants are unaffected; a later read reopens it. */
|
|
15790
15934
|
endOutageWindow: endWindow,
|
|
@@ -15804,6 +15948,37 @@ const makeCliE2eeExecutionAuthorization = fn("CliE2eeExecutionAuthorization.make
|
|
|
15804
15948
|
};
|
|
15805
15949
|
}
|
|
15806
15950
|
);
|
|
15951
|
+
const authorizeCliE2eeSessionTarget = (options, target) => gen$1(function* () {
|
|
15952
|
+
const state = (yield* options.runtime.executionLedger()).inspectState();
|
|
15953
|
+
const generation = options.runtime.executionGeneration();
|
|
15954
|
+
const source = state.devices.get(options.sourceDevice);
|
|
15955
|
+
if (!source || source.kind === "recovery") return false;
|
|
15956
|
+
const issuer = state.members.get(Buffer.from(source.membershipId.toBytes()).toString("hex"));
|
|
15957
|
+
const account = issuer && accountIdFromUserId(issuer.userId);
|
|
15958
|
+
if (!account || isFailure(account)) return false;
|
|
15959
|
+
const machine = [...state.devices.values()].find(
|
|
15960
|
+
(row) => row.kind === "machine" && row.machineId === target.machineId
|
|
15961
|
+
);
|
|
15962
|
+
if (!machine) return false;
|
|
15963
|
+
let policy;
|
|
15964
|
+
const check = fnUntraced(function* (userId2) {
|
|
15965
|
+
const member = [...state.members.entries()].find(([, row]) => {
|
|
15966
|
+
const account2 = accountIdFromUserId(row.userId);
|
|
15967
|
+
return isSuccess(account2) && account2.success === userId2;
|
|
15968
|
+
});
|
|
15969
|
+
if (!member) return false;
|
|
15970
|
+
if (Buffer.from(machine.membershipId.toBytes()).toString("hex") === member[0] || target.sessionOwnerUserId === userId2)
|
|
15971
|
+
return true;
|
|
15972
|
+
if (!options.readPolicy) return false;
|
|
15973
|
+
policy ??= yield* options.readPolicy(target.machineId);
|
|
15974
|
+
if (policy.removed || policy.unavailable) return false;
|
|
15975
|
+
return member[1].role !== "guest" && policy.sharedWithTeam && (!target.localProjectId || policy.projects.includes(target.localProjectId)) || policy.sessions.some(
|
|
15976
|
+
(row) => row.sessionId === target.rootSessionId && (row.audience === "team" || row.audience.userId === userId2)
|
|
15977
|
+
);
|
|
15978
|
+
});
|
|
15979
|
+
const allowed = (yield* check(account.success)) && (yield* check(target.requesterUserId));
|
|
15980
|
+
return allowed && generation === options.runtime.executionGeneration();
|
|
15981
|
+
});
|
|
15807
15982
|
class MachinePairingJournalError extends TaggedError("MachinePairingJournalError") {
|
|
15808
15983
|
}
|
|
15809
15984
|
const failure = (code, cause) => new MachinePairingJournalError({ code, ...cause === void 0 ? {} : { cause } });
|
|
@@ -16268,7 +16443,7 @@ async function retireRevokedMachineIdentity(options) {
|
|
|
16268
16443
|
requireOsProtection: existsSync(`${directory}.require-os`),
|
|
16269
16444
|
keyring: options.keyring
|
|
16270
16445
|
});
|
|
16271
|
-
const { Bytes } = yield* promise(() => import("./index-
|
|
16446
|
+
const { Bytes } = yield* promise(() => import("./index-DqAVXjKE.js"));
|
|
16272
16447
|
const genesis = yield* fromResult(Bytes.genesisHash(bytes(options.genesisHash)));
|
|
16273
16448
|
const current = yield* custody.openDevice(genesis);
|
|
16274
16449
|
const key2 = hex(current.publicKey.toBytes());
|
|
@@ -16337,7 +16512,7 @@ async function eraseRemovedWorkspace(options) {
|
|
|
16337
16512
|
directory: join$1(directory, "custody"),
|
|
16338
16513
|
keyring: options.keyring
|
|
16339
16514
|
});
|
|
16340
|
-
const { Bytes } = yield* promise(() => import("./index-
|
|
16515
|
+
const { Bytes } = yield* promise(() => import("./index-DqAVXjKE.js"));
|
|
16341
16516
|
const genesis = yield* fromResult(
|
|
16342
16517
|
Bytes.genesisHash(bytes(removal.genesisHash))
|
|
16343
16518
|
);
|
|
@@ -16468,7 +16643,7 @@ async function prepareCliE2eeMachineLegacy(options) {
|
|
|
16468
16643
|
);
|
|
16469
16644
|
}
|
|
16470
16645
|
async function prepareMachine(options) {
|
|
16471
|
-
const { Bytes, hashRecordBytes: hashRecordBytes2, verifyLedgerEffect: verifyLedgerEffect2 } = await import("./index-
|
|
16646
|
+
const { Bytes, hashRecordBytes: hashRecordBytes2, verifyLedgerEffect: verifyLedgerEffect2 } = await import("./index-DqAVXjKE.js");
|
|
16472
16647
|
const binding = Binding.parse({
|
|
16473
16648
|
workspaceId: options.workspaceId,
|
|
16474
16649
|
genesisHash: options.genesisHash,
|
|
@@ -16667,7 +16842,7 @@ async function openWorkspaceOwned(scope2, options, requireActivation, pairing) {
|
|
|
16667
16842
|
keyring: options.keyring
|
|
16668
16843
|
});
|
|
16669
16844
|
const { Bytes, hashRecordBytes: hashRecordBytes2 } = yield* promise(
|
|
16670
|
-
() => import("./index-
|
|
16845
|
+
() => import("./index-DqAVXjKE.js")
|
|
16671
16846
|
);
|
|
16672
16847
|
const genesis = yield* fromResult(Bytes.genesisHash(bytes(binding.genesisHash)));
|
|
16673
16848
|
if (hex(hashRecordBytes2(bytes(binding.genesisRecordHex)).toBytes()) !== binding.genesisHash)
|
|
@@ -16709,6 +16884,27 @@ async function openWorkspaceOwned(scope2, options, requireActivation, pairing) {
|
|
|
16709
16884
|
workspaceId: options.workspaceId,
|
|
16710
16885
|
credential,
|
|
16711
16886
|
cloud: options.cloud,
|
|
16887
|
+
sessionSharing: (requester, sessionId, sessionOwnerUserId) => gen$1(function* () {
|
|
16888
|
+
const state = (yield* runtime.executionLedger()).inspectState();
|
|
16889
|
+
const signer = state.devices.get(requester);
|
|
16890
|
+
const member = signer && state.members.get(hex(signer.membershipId.toBytes()));
|
|
16891
|
+
const account = member && accountIdFromUserId(member.userId);
|
|
16892
|
+
if (account && isSuccess(account) && account.success === sessionOwnerUserId)
|
|
16893
|
+
return { allowed: true, isCurrent: () => true };
|
|
16894
|
+
const machine = state.devices.get(hex(device.publicKey.toBytes()));
|
|
16895
|
+
if (!sharingRemote || !sharing || machine?.kind !== "machine" || !machine.machineId)
|
|
16896
|
+
return { allowed: false, isCurrent: () => false };
|
|
16897
|
+
const { view, isCurrent } = yield* sharing.readSessionAccess(
|
|
16898
|
+
machine.machineId,
|
|
16899
|
+
sharingRemote
|
|
16900
|
+
);
|
|
16901
|
+
return {
|
|
16902
|
+
isCurrent,
|
|
16903
|
+
allowed: !view.removed && !view.unavailable && view.sessions.some(
|
|
16904
|
+
(row) => row.sessionId === sessionId && (row.audience === "team" || account && isSuccess(account) && row.audience.userId === account.success)
|
|
16905
|
+
)
|
|
16906
|
+
};
|
|
16907
|
+
}),
|
|
16712
16908
|
onCredentialFailure: (cause) => credentialFailureHandler(cause),
|
|
16713
16909
|
runtime,
|
|
16714
16910
|
sharing: sharingRemote ? (requester, localProjectId) => gen$1(function* () {
|
|
@@ -17042,7 +17238,7 @@ async function openWorkspaceOwned(scope2, options, requireActivation, pairing) {
|
|
|
17042
17238
|
scoped(
|
|
17043
17239
|
gen$1(function* () {
|
|
17044
17240
|
yield* openMachinePairingJournal(directory);
|
|
17045
|
-
const { Bytes } = yield* promise(() => import("./index-
|
|
17241
|
+
const { Bytes } = yield* promise(() => import("./index-DqAVXjKE.js"));
|
|
17046
17242
|
const genesis = yield* fromResult(Bytes.genesisHash(bytes(options.genesisHash)));
|
|
17047
17243
|
const current = yield* opened.custody.openDevice(genesis);
|
|
17048
17244
|
if (hex(current.publicKey.toBytes()) !== opened.signingPublicKey || (yield* opened.custody.deviceCredential(genesis, current.publicKey)) !== opened.credential)
|
|
@@ -17381,6 +17577,14 @@ async function openWorkspaceOwned(scope2, options, requireActivation, pairing) {
|
|
|
17381
17577
|
})
|
|
17382
17578
|
)
|
|
17383
17579
|
},
|
|
17580
|
+
authorizeSessionTarget: (target) => authorizeCliE2eeSessionTarget(
|
|
17581
|
+
{
|
|
17582
|
+
runtime: opened.runtime,
|
|
17583
|
+
sourceDevice: opened.signingPublicKey,
|
|
17584
|
+
readPolicy: opened.sharingRemote ? (machineId) => opened.sharing.read(machineId, opened.sharingRemote) : void 0
|
|
17585
|
+
},
|
|
17586
|
+
target
|
|
17587
|
+
),
|
|
17384
17588
|
authorizeMachineTarget: (machineId, localProjectId) => gen$1(function* () {
|
|
17385
17589
|
const state = (yield* opened.runtime.executionLedger()).inspectState();
|
|
17386
17590
|
const own2 = state.devices.get(opened.signingPublicKey);
|
|
@@ -17397,7 +17601,7 @@ async function openWorkspaceOwned(scope2, options, requireActivation, pairing) {
|
|
|
17397
17601
|
return result2.allowed;
|
|
17398
17602
|
}),
|
|
17399
17603
|
retainQueuedInput: (input) => executionOrigins.retainQueuedInput(input),
|
|
17400
|
-
startRpc: (machineId, offer, trace, handleFeature) => run(
|
|
17604
|
+
startRpc: (machineId, offer, trace, handleFeature, resolveHistoryTarget) => run(
|
|
17401
17605
|
gen$1(function* () {
|
|
17402
17606
|
if (rpcFiber || closed) return;
|
|
17403
17607
|
rpcFiber = yield* forkIn(
|
|
@@ -17439,6 +17643,26 @@ async function openWorkspaceOwned(scope2, options, requireActivation, pairing) {
|
|
|
17439
17643
|
journal: rpcJournal,
|
|
17440
17644
|
authorize: opened.executionAuthorization.authorizeOwnedExecution,
|
|
17441
17645
|
authorizeRead: opened.executionAuthorization.authorizeRead,
|
|
17646
|
+
authorizeHistoryRead: (workspaceId, requester, sessionId) => gen$1(function* () {
|
|
17647
|
+
if (!resolveHistoryTarget)
|
|
17648
|
+
return { _tag: "Denied", reason: "not-authorized" };
|
|
17649
|
+
const target = yield* tryPromise({
|
|
17650
|
+
try: () => resolveHistoryTarget(sessionId),
|
|
17651
|
+
catch: (cause) => cause
|
|
17652
|
+
});
|
|
17653
|
+
const editing = yield* opened.executionAuthorization.authorizeExecution(
|
|
17654
|
+
workspaceId,
|
|
17655
|
+
requester,
|
|
17656
|
+
target.localProjectId
|
|
17657
|
+
);
|
|
17658
|
+
if (editing._tag === "Authorized") return editing;
|
|
17659
|
+
return yield* opened.executionAuthorization.authorizeSessionRead(
|
|
17660
|
+
workspaceId,
|
|
17661
|
+
requester,
|
|
17662
|
+
target.rootSessionId,
|
|
17663
|
+
target.sessionOwnerUserId
|
|
17664
|
+
);
|
|
17665
|
+
}),
|
|
17442
17666
|
authoritySignal: () => AbortSignal.any([
|
|
17443
17667
|
opened.runtime.executionAuthoritySignal(),
|
|
17444
17668
|
opened.executionAuthorization.authoritySignal
|
|
@@ -17574,7 +17798,7 @@ async function retainMachineBootstrap(input, keyring) {
|
|
|
17574
17798
|
keyring
|
|
17575
17799
|
});
|
|
17576
17800
|
const { Bytes, signVerified: signVerified2 } = yield* promise(
|
|
17577
|
-
() => import("./index-
|
|
17801
|
+
() => import("./index-DqAVXjKE.js")
|
|
17578
17802
|
);
|
|
17579
17803
|
const device = yield* custody.openDevice(
|
|
17580
17804
|
getOrThrow(Bytes.genesisHash(bytes(unsigned.genesisHash)))
|
|
@@ -17645,7 +17869,7 @@ async function loadMachineBootstrap(reference, machineId, keyring) {
|
|
|
17645
17869
|
keyring
|
|
17646
17870
|
});
|
|
17647
17871
|
const { Bytes, verifySignature: verifySignature2 } = yield* promise(
|
|
17648
|
-
() => import("./index-
|
|
17872
|
+
() => import("./index-DqAVXjKE.js")
|
|
17649
17873
|
);
|
|
17650
17874
|
const genesis = getOrThrow(Bytes.genesisHash(bytes(bootstrap.genesisHash)));
|
|
17651
17875
|
const device = yield* custody.openDevice(genesis);
|
|
@@ -17678,175 +17902,174 @@ const workspaceLegacy = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.def
|
|
|
17678
17902
|
validateCliE2eePairingIntentLegacy
|
|
17679
17903
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
17680
17904
|
export {
|
|
17681
|
-
|
|
17682
|
-
|
|
17683
|
-
|
|
17905
|
+
disposePrf as $,
|
|
17906
|
+
confirmIndependentComparison as A,
|
|
17907
|
+
contentAad as B,
|
|
17684
17908
|
ContentError as C,
|
|
17685
|
-
|
|
17909
|
+
contentHkdfSalt as D,
|
|
17686
17910
|
EpochKeyError as E,
|
|
17687
|
-
|
|
17688
|
-
|
|
17911
|
+
contentKeyInfo as F,
|
|
17912
|
+
contentPermissions as G,
|
|
17689
17913
|
HpkePrimitiveError as H,
|
|
17690
|
-
|
|
17691
|
-
|
|
17692
|
-
|
|
17914
|
+
contentSigningBytes as I,
|
|
17915
|
+
decodeCbor as J,
|
|
17916
|
+
decodeInstallationReport as K,
|
|
17693
17917
|
LedgerError as L,
|
|
17694
|
-
|
|
17695
|
-
|
|
17696
|
-
|
|
17918
|
+
decodeMachineSharingPolicy as M,
|
|
17919
|
+
decodePairingApproval as N,
|
|
17920
|
+
decodePairingRequest as O,
|
|
17697
17921
|
PAIRING_CLOCK_SKEW_MS as P,
|
|
17698
|
-
|
|
17922
|
+
decodeRecord as Q,
|
|
17699
17923
|
RecoveryVaultError as R,
|
|
17700
|
-
|
|
17701
|
-
|
|
17702
|
-
|
|
17924
|
+
deriveContentKey as S,
|
|
17925
|
+
deriveDocumentKey as T,
|
|
17926
|
+
derivePairingKeys as U,
|
|
17703
17927
|
ValidationError as V,
|
|
17704
|
-
|
|
17705
|
-
|
|
17706
|
-
|
|
17707
|
-
|
|
17708
|
-
|
|
17709
|
-
|
|
17710
|
-
|
|
17711
|
-
|
|
17712
|
-
|
|
17713
|
-
|
|
17714
|
-
|
|
17715
|
-
|
|
17716
|
-
|
|
17717
|
-
|
|
17718
|
-
|
|
17719
|
-
|
|
17720
|
-
|
|
17721
|
-
|
|
17722
|
-
|
|
17723
|
-
|
|
17724
|
-
|
|
17725
|
-
|
|
17726
|
-
|
|
17727
|
-
|
|
17728
|
-
|
|
17729
|
-
|
|
17730
|
-
|
|
17731
|
-
|
|
17732
|
-
|
|
17733
|
-
|
|
17734
|
-
|
|
17735
|
-
|
|
17736
|
-
|
|
17737
|
-
|
|
17738
|
-
|
|
17739
|
-
|
|
17740
|
-
|
|
17741
|
-
|
|
17742
|
-
|
|
17743
|
-
|
|
17744
|
-
|
|
17745
|
-
|
|
17746
|
-
|
|
17747
|
-
|
|
17748
|
-
|
|
17749
|
-
|
|
17750
|
-
|
|
17751
|
-
|
|
17752
|
-
|
|
17753
|
-
|
|
17754
|
-
|
|
17755
|
-
|
|
17756
|
-
|
|
17757
|
-
|
|
17758
|
-
|
|
17759
|
-
|
|
17760
|
-
|
|
17761
|
-
|
|
17762
|
-
|
|
17763
|
-
|
|
17764
|
-
|
|
17765
|
-
|
|
17766
|
-
|
|
17767
|
-
|
|
17768
|
-
|
|
17769
|
-
|
|
17770
|
-
|
|
17771
|
-
|
|
17772
|
-
|
|
17773
|
-
|
|
17774
|
-
|
|
17775
|
-
|
|
17776
|
-
|
|
17777
|
-
|
|
17778
|
-
|
|
17779
|
-
|
|
17780
|
-
|
|
17781
|
-
|
|
17782
|
-
|
|
17783
|
-
|
|
17784
|
-
|
|
17785
|
-
|
|
17786
|
-
|
|
17787
|
-
|
|
17788
|
-
|
|
17789
|
-
|
|
17790
|
-
|
|
17791
|
-
|
|
17792
|
-
|
|
17793
|
-
|
|
17794
|
-
|
|
17795
|
-
|
|
17796
|
-
|
|
17797
|
-
|
|
17798
|
-
|
|
17799
|
-
|
|
17800
|
-
|
|
17801
|
-
|
|
17802
|
-
|
|
17803
|
-
|
|
17804
|
-
|
|
17805
|
-
|
|
17806
|
-
|
|
17807
|
-
|
|
17808
|
-
|
|
17809
|
-
|
|
17810
|
-
|
|
17811
|
-
|
|
17812
|
-
|
|
17813
|
-
|
|
17814
|
-
|
|
17815
|
-
|
|
17816
|
-
|
|
17817
|
-
|
|
17818
|
-
|
|
17819
|
-
|
|
17820
|
-
|
|
17821
|
-
|
|
17822
|
-
|
|
17823
|
-
|
|
17824
|
-
|
|
17825
|
-
|
|
17826
|
-
|
|
17827
|
-
|
|
17828
|
-
|
|
17829
|
-
|
|
17830
|
-
|
|
17831
|
-
PAIRING_MAX_WORKSPACES as g,
|
|
17928
|
+
deriveRecoveryAccessCredential as W,
|
|
17929
|
+
deviceCredentialBindingBytes as X,
|
|
17930
|
+
disposeContentKey as Y,
|
|
17931
|
+
disposeDocumentKey as Z,
|
|
17932
|
+
disposePairingKeys as _,
|
|
17933
|
+
EpochStagingError as a,
|
|
17934
|
+
prepareLedgerCommand as a$,
|
|
17935
|
+
ed25519WasmActive as a0,
|
|
17936
|
+
encodeCbor as a1,
|
|
17937
|
+
encodeContentContext as a2,
|
|
17938
|
+
encodeContentHeader as a3,
|
|
17939
|
+
encodeDocumentContext as a4,
|
|
17940
|
+
encodeInstallationReport as a5,
|
|
17941
|
+
encodeMachineSharingPolicy as a6,
|
|
17942
|
+
encodePairingApproval as a7,
|
|
17943
|
+
encodePairingRequest as a8,
|
|
17944
|
+
encodePairingSecret as a9,
|
|
17945
|
+
machineSharingDigest as aA,
|
|
17946
|
+
mailboxDigest as aB,
|
|
17947
|
+
nativeDeviceSigner as aC,
|
|
17948
|
+
obsoleteEpochStagedGroup as aD,
|
|
17949
|
+
openContentAead as aE,
|
|
17950
|
+
openDocument as aF,
|
|
17951
|
+
openEpochEnvelope as aG,
|
|
17952
|
+
openEpochKeyHpke as aH,
|
|
17953
|
+
openHistoryPacket as aI,
|
|
17954
|
+
openMachineSharingPolicy as aJ,
|
|
17955
|
+
openPresenceContent as aK,
|
|
17956
|
+
openRpcRequestContent as aL,
|
|
17957
|
+
openRpcResponseContent as aM,
|
|
17958
|
+
ownEpochStagedGroup as aN,
|
|
17959
|
+
ownEpochStagedGroupKey as aO,
|
|
17960
|
+
ownCiphertext as aP,
|
|
17961
|
+
pairingApprovalTag as aQ,
|
|
17962
|
+
pairingQrPayload as aR,
|
|
17963
|
+
pairingRequestDigest as aS,
|
|
17964
|
+
pairingRequestTag as aT,
|
|
17965
|
+
parsePairingString as aU,
|
|
17966
|
+
parseRecoveryFile as aV,
|
|
17967
|
+
passkeyUserHandle as aW,
|
|
17968
|
+
possessionSigningBytes as aX,
|
|
17969
|
+
prepareDeviceAdmission as aY,
|
|
17970
|
+
prepareEpochEnvelope as aZ,
|
|
17971
|
+
prepareJoinRequest as a_,
|
|
17972
|
+
encodeSignedSnapshot as aa,
|
|
17973
|
+
envelopeRouting as ab,
|
|
17974
|
+
epochDeliveryId as ac,
|
|
17975
|
+
epochHistoryPacket as ad,
|
|
17976
|
+
epochHpkeAad as ae,
|
|
17977
|
+
epochPublicationRecord as af,
|
|
17978
|
+
exportDocumentKey as ag,
|
|
17979
|
+
exportVerifiedState as ah,
|
|
17980
|
+
extendLedger as ai,
|
|
17981
|
+
extendLedgerEffect as aj,
|
|
17982
|
+
formatPairingString as ak,
|
|
17983
|
+
frameLedgerRecord as al,
|
|
17984
|
+
generateRecoveryPackage as am,
|
|
17985
|
+
getCommittedEpochStagingKey as an,
|
|
17986
|
+
hasVerifiedCheckpoint as ao,
|
|
17987
|
+
hasVerifiedRecordHash as ap,
|
|
17988
|
+
headAttestationSigningBytes as aq,
|
|
17989
|
+
historicalContentIdentity as ar,
|
|
17990
|
+
importDocumentKey as as,
|
|
17991
|
+
importRecoveryIdentity as at,
|
|
17992
|
+
inspectContentFrame as au,
|
|
17993
|
+
installationBody as av,
|
|
17994
|
+
installationSigningBytes as aw,
|
|
17995
|
+
joinRequestSigningBytes as ax,
|
|
17996
|
+
ledgerStateDigest as ay,
|
|
17997
|
+
machineSharingContentScope as az,
|
|
17998
|
+
bytes$2 as b,
|
|
17999
|
+
prepareLedgerPage as b0,
|
|
18000
|
+
prepareLedgerPageEffect as b1,
|
|
18001
|
+
prepareLedgerRecord as b2,
|
|
18002
|
+
prepareLedgerSnapshot as b3,
|
|
18003
|
+
recordSigningBytes as b4,
|
|
18004
|
+
recoverLedgerHistory as b5,
|
|
18005
|
+
requireLedgerContinuation as b6,
|
|
18006
|
+
restoreVerifiedState as b7,
|
|
18007
|
+
sameEpochStagedGroup as b8,
|
|
18008
|
+
sameCiphertext as b9,
|
|
18009
|
+
verifyLedger as bA,
|
|
18010
|
+
verifyLedgerSnapshot as bB,
|
|
18011
|
+
verifyMachineSharingGeneration as bC,
|
|
18012
|
+
verifyPairingApprovalTag as bD,
|
|
18013
|
+
verifyPairingRequestTag as bE,
|
|
18014
|
+
verifySignature as bF,
|
|
18015
|
+
wipeRecoveryPackage as bG,
|
|
18016
|
+
completedE2eeIdentityReset as bH,
|
|
18017
|
+
cliE2eeIdentityDirectory as bI,
|
|
18018
|
+
leaseE2eeIdentity as bJ,
|
|
18019
|
+
archiveE2eeIdentity as bK,
|
|
18020
|
+
prepareCliE2eeMachineLegacy as bL,
|
|
18021
|
+
activateCliE2eeWorkspaceLegacy as bM,
|
|
18022
|
+
retainCliE2eeMachineBootstrapLegacy as bN,
|
|
18023
|
+
workspaceLegacy as bO,
|
|
18024
|
+
scopedDocumentKey as ba,
|
|
18025
|
+
sealContentAead as bb,
|
|
18026
|
+
sealDocument as bc,
|
|
18027
|
+
sealEpochKeyHpke as bd,
|
|
18028
|
+
sealHistoryPacket as be,
|
|
18029
|
+
sealMachineSharingPolicy as bf,
|
|
18030
|
+
sealPresenceContent as bg,
|
|
18031
|
+
sealRpcRequestContent as bh,
|
|
18032
|
+
sealRpcResponseContent as bi,
|
|
18033
|
+
signDeviceCredentialBinding as bj,
|
|
18034
|
+
signGenesisRecord as bk,
|
|
18035
|
+
signLedgerRecord as bl,
|
|
18036
|
+
signLedgerSnapshot as bm,
|
|
18037
|
+
signVerified as bn,
|
|
18038
|
+
slotId as bo,
|
|
18039
|
+
snapshotSigningBytes as bp,
|
|
18040
|
+
snapshotTrustFromView as bq,
|
|
18041
|
+
updateMachineSharingState as br,
|
|
18042
|
+
validLedgerOffset as bs,
|
|
18043
|
+
ciphertextDigest as bt,
|
|
18044
|
+
vaultIdFromPasskeyUserHandle as bu,
|
|
18045
|
+
vaultPrfInput as bv,
|
|
18046
|
+
verifiedPasskeyPrf as bw,
|
|
18047
|
+
verifiedPasskeyRegistration as bx,
|
|
18048
|
+
verifyContentSignature as by,
|
|
18049
|
+
verifyDeviceCredentialBinding as bz,
|
|
18050
|
+
LedgerFeedError as c,
|
|
18051
|
+
PAIRING_MAX_WORKSPACES as d,
|
|
18052
|
+
PAIRING_REQUEST_MAX_LIFETIME_MS as e,
|
|
18053
|
+
PAIRING_STRING_LENGTH as f,
|
|
18054
|
+
PAIRING_URL_PREFIX as g,
|
|
17832
18055
|
hashRecordBytes as h,
|
|
17833
|
-
|
|
17834
|
-
|
|
17835
|
-
|
|
17836
|
-
|
|
17837
|
-
|
|
17838
|
-
|
|
17839
|
-
|
|
17840
|
-
|
|
17841
|
-
|
|
17842
|
-
|
|
17843
|
-
|
|
17844
|
-
|
|
17845
|
-
|
|
18056
|
+
PairingError as i,
|
|
18057
|
+
accountIdFromUserId as j,
|
|
18058
|
+
accountUserId as k,
|
|
18059
|
+
admitDocument as l,
|
|
18060
|
+
authenticateDocument as m,
|
|
18061
|
+
authenticateEpochEnvelope as n,
|
|
18062
|
+
authenticateEpochEnvelopeSignature as o,
|
|
18063
|
+
authenticateEpochStagedGroup as p,
|
|
18064
|
+
authenticateInstallationReport as q,
|
|
18065
|
+
authenticateLedgerSnapshotEvidence as r,
|
|
18066
|
+
authorizeMachineExecution as s,
|
|
18067
|
+
checkInstallationContext as t,
|
|
18068
|
+
checkLocalPublication as u,
|
|
17846
18069
|
verifyLedgerEffect as v,
|
|
17847
|
-
|
|
17848
|
-
|
|
17849
|
-
|
|
17850
|
-
|
|
18070
|
+
checkPairingRequestLifetime as w,
|
|
18071
|
+
commitEpochKey as x,
|
|
18072
|
+
compareNotes as y,
|
|
18073
|
+
comparisonNote as z
|
|
17851
18074
|
};
|
|
17852
|
-
//# sourceMappingURL=workspace-legacy-
|
|
18075
|
+
//# sourceMappingURL=workspace-legacy-C_cxzMuh.js.map
|