@ours.network/messenger-server 2.0.1 → 2.0.2
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.
|
@@ -38,7 +38,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
38
38
|
var define_MESSENGER_BUILD_INFO_default;
|
|
39
39
|
var init_define_MESSENGER_BUILD_INFO = __esm({
|
|
40
40
|
"<define:__MESSENGER_BUILD_INFO__>"() {
|
|
41
|
-
define_MESSENGER_BUILD_INFO_default = { name: "@ours.network/messenger-server", version: "2.0.
|
|
41
|
+
define_MESSENGER_BUILD_INFO_default = { name: "@ours.network/messenger-server", version: "2.0.2", sha: "5849c383fd52ef895b0012ba494f59414a1a6397", dirty: false };
|
|
42
42
|
}
|
|
43
43
|
});
|
|
44
44
|
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
publicEngineError,
|
|
11
11
|
publicInternalError,
|
|
12
12
|
reportFailure
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-DILYQTFT.js";
|
|
14
14
|
|
|
15
15
|
// node_modules/bn.js/lib/bn.js
|
|
16
16
|
var require_bn = __commonJS({
|
|
@@ -12309,6 +12309,7 @@ function projectHistoryPage(contact, history, summary, opts = {}) {
|
|
|
12309
12309
|
total: summary.total,
|
|
12310
12310
|
unread: summary.unread,
|
|
12311
12311
|
hasMore: history.next_cursor !== null,
|
|
12312
|
+
oldestSequence: history.items.at(-1)?.seq ?? null,
|
|
12312
12313
|
nextBefore: history.next_cursor === null ? null : String(history.next_cursor),
|
|
12313
12314
|
preview: opts.preview === false ? "" : previewOf(opts.announcedContact ?? contact, messages.at(-1))
|
|
12314
12315
|
};
|
|
@@ -12405,109 +12406,13 @@ function canonicalResourceDescriptor(value) {
|
|
|
12405
12406
|
...window2 ? { window: window2 } : {}
|
|
12406
12407
|
};
|
|
12407
12408
|
}
|
|
12408
|
-
var ACTIVITY_READERS = 4;
|
|
12409
12409
|
var ACTIVITY_DEADLINE_MS = 5e3;
|
|
12410
|
-
|
|
12411
|
-
function slots(client) {
|
|
12412
|
-
let pool = activitySlots.get(client);
|
|
12413
|
-
if (!pool) activitySlots.set(client, pool = { active: 0, waiters: [] });
|
|
12414
|
-
const owned = pool, mine = /* @__PURE__ */ new Set();
|
|
12415
|
-
return {
|
|
12416
|
-
/** False once withdrawn: the projection ended while this reader still waited. */
|
|
12417
|
-
acquire: async () => {
|
|
12418
|
-
while (owned.active >= ACTIVITY_READERS) {
|
|
12419
|
-
const granted = await new Promise((resolve4) => {
|
|
12420
|
-
mine.add(resolve4);
|
|
12421
|
-
owned.waiters.push(resolve4);
|
|
12422
|
-
});
|
|
12423
|
-
if (!granted) return false;
|
|
12424
|
-
}
|
|
12425
|
-
owned.active++;
|
|
12426
|
-
return true;
|
|
12427
|
-
},
|
|
12428
|
-
release: () => {
|
|
12429
|
-
owned.active--;
|
|
12430
|
-
const next = owned.waiters.shift();
|
|
12431
|
-
if (next) {
|
|
12432
|
-
mine.delete(next);
|
|
12433
|
-
next(true);
|
|
12434
|
-
}
|
|
12435
|
-
},
|
|
12436
|
-
withdraw: () => {
|
|
12437
|
-
owned.waiters = owned.waiters.filter((waiter) => !mine.has(waiter));
|
|
12438
|
-
for (const waiter of mine) waiter(false);
|
|
12439
|
-
mine.clear();
|
|
12440
|
-
}
|
|
12441
|
-
};
|
|
12442
|
-
}
|
|
12443
|
-
var contactLists = /* @__PURE__ */ new WeakMap();
|
|
12444
|
-
var listingEpoch = 0;
|
|
12445
|
-
async function contactList(client, since, ended, live) {
|
|
12446
|
-
for (; ; ) {
|
|
12447
|
-
if (!live()) return void 0;
|
|
12448
|
-
const current = contactLists.get(client);
|
|
12449
|
-
if (current && current.epoch > since) return current.read;
|
|
12450
|
-
if (!current) {
|
|
12451
|
-
const listing = { epoch: ++listingEpoch, read: client.listContacts() };
|
|
12452
|
-
contactLists.set(client, listing);
|
|
12453
|
-
const settled = () => {
|
|
12454
|
-
if (contactLists.get(client) === listing) contactLists.delete(client);
|
|
12455
|
-
};
|
|
12456
|
-
listing.read.then(settled, settled);
|
|
12457
|
-
return listing.read;
|
|
12458
|
-
}
|
|
12459
|
-
const waited = await Promise.race([current.read.then(() => true, () => true), ended.then(() => false)]);
|
|
12460
|
-
if (!waited) return void 0;
|
|
12461
|
-
}
|
|
12462
|
-
}
|
|
12463
|
-
async function projectActivity(client, signal, deadlineMs = ACTIVITY_DEADLINE_MS) {
|
|
12410
|
+
async function projectActivity(client, signal, expectedSource) {
|
|
12464
12411
|
signal?.throwIfAborted();
|
|
12465
|
-
const
|
|
12466
|
-
let timer, stop = () => {
|
|
12467
|
-
}, expired = false;
|
|
12468
|
-
const ended = new Promise((resolve4) => {
|
|
12469
|
-
timer = setTimeout(() => {
|
|
12470
|
-
expired = true;
|
|
12471
|
-
resolve4();
|
|
12472
|
-
}, deadlineMs);
|
|
12473
|
-
stop = () => resolve4();
|
|
12474
|
-
signal?.addEventListener("abort", stop, { once: true });
|
|
12475
|
-
});
|
|
12476
|
-
const pool = slots(client);
|
|
12477
|
-
const activity = {};
|
|
12478
|
-
let open = true;
|
|
12479
|
-
let contacts = [];
|
|
12480
|
-
try {
|
|
12481
|
-
const listing = contactList(client, since, ended, () => !expired && !signal?.aborted);
|
|
12482
|
-
const listed = await Promise.race([listing, ended.then(() => void 0)]);
|
|
12483
|
-
signal?.throwIfAborted();
|
|
12484
|
-
if (!listed) throw new Error("activity contact list unavailable");
|
|
12485
|
-
contacts = listed.contacts;
|
|
12486
|
-
const queue = contacts.map((contact) => contact.container_id);
|
|
12487
|
-
const reader = async () => {
|
|
12488
|
-
for (; ; ) {
|
|
12489
|
-
if (!await pool.acquire()) return;
|
|
12490
|
-
const cid = open && !expired && !signal?.aborted ? queue.shift() : void 0;
|
|
12491
|
-
if (cid === void 0) return pool.release();
|
|
12492
|
-
try {
|
|
12493
|
-
const newest = (await client.listHistory({ peer_cid: cid, limit: 1 })).items[0];
|
|
12494
|
-
activity[cid] = { at: typeof newest?.date === "string" ? newest.date : "" };
|
|
12495
|
-
} catch {
|
|
12496
|
-
activity[cid] = { unavailable: true };
|
|
12497
|
-
} finally {
|
|
12498
|
-
pool.release();
|
|
12499
|
-
}
|
|
12500
|
-
}
|
|
12501
|
-
};
|
|
12502
|
-
await Promise.race([Promise.all(Array.from({ length: Math.min(ACTIVITY_READERS, queue.length) }, reader)), ended]);
|
|
12503
|
-
} finally {
|
|
12504
|
-
open = false;
|
|
12505
|
-
pool.withdraw();
|
|
12506
|
-
clearTimeout(timer);
|
|
12507
|
-
signal?.removeEventListener("abort", stop);
|
|
12508
|
-
}
|
|
12412
|
+
const snapshot = await client.getContactActivity();
|
|
12509
12413
|
signal?.throwIfAborted();
|
|
12510
|
-
|
|
12414
|
+
if (expectedSource && (snapshot.source.producerGeneration !== expectedSource.producerGeneration || snapshot.source.position !== expectedSource.position)) throw new Error("activity source changed");
|
|
12415
|
+
return { activity: snapshot.activity };
|
|
12511
12416
|
}
|
|
12512
12417
|
async function projectMessageWindow(client, contact, announcedContact, window2, signal, options = {}) {
|
|
12513
12418
|
let before;
|
|
@@ -12654,6 +12559,7 @@ data: ${JSON.stringify(frame.data)}
|
|
|
12654
12559
|
});
|
|
12655
12560
|
}
|
|
12656
12561
|
};
|
|
12562
|
+
var sameSource = (a, b2) => a.producerGeneration === b2.producerGeneration && a.position === b2.position;
|
|
12657
12563
|
var ResourceBindingError = class extends Error {
|
|
12658
12564
|
constructor(status, message) {
|
|
12659
12565
|
super(message);
|
|
@@ -12665,7 +12571,68 @@ var ResourceConnections = class {
|
|
|
12665
12571
|
this.deps = deps;
|
|
12666
12572
|
}
|
|
12667
12573
|
#connections = /* @__PURE__ */ new Map();
|
|
12574
|
+
#activityRead;
|
|
12668
12575
|
producerGeneration = randomUUID2();
|
|
12576
|
+
/** Ordinary and bound demands share only pending work in this service scope.
|
|
12577
|
+
* Every new demand crosses the bound SDK API; source position is not a lease. */
|
|
12578
|
+
async activity(signal, bound, deadlineMs = ACTIVITY_DEADLINE_MS) {
|
|
12579
|
+
signal.throwIfAborted();
|
|
12580
|
+
const deadline = new AbortController();
|
|
12581
|
+
const timer = setTimeout(() => deadline.abort(new Error("activity metadata unavailable")), deadlineMs);
|
|
12582
|
+
try {
|
|
12583
|
+
return await this.#readActivity(AbortSignal.any([signal, deadline.signal]), bound);
|
|
12584
|
+
} finally {
|
|
12585
|
+
clearTimeout(timer);
|
|
12586
|
+
}
|
|
12587
|
+
}
|
|
12588
|
+
async #readActivity(signal, bound) {
|
|
12589
|
+
signal.throwIfAborted();
|
|
12590
|
+
const source = await abortableProjection(this.deps.client.resourcePosition(this.deps.identity, { signal }), signal);
|
|
12591
|
+
signal.throwIfAborted();
|
|
12592
|
+
if (bound?.source && !sameSource(bound.source, source)) throw new Error("activity baseline changed");
|
|
12593
|
+
let read = this.#activityRead;
|
|
12594
|
+
if (read && (read.settled || read.controller.signal.aborted || !sameSource(read.source, source))) {
|
|
12595
|
+
throw new Error("activity prior source still draining");
|
|
12596
|
+
}
|
|
12597
|
+
if (!read) {
|
|
12598
|
+
read = {
|
|
12599
|
+
source,
|
|
12600
|
+
controller: new AbortController(),
|
|
12601
|
+
users: /* @__PURE__ */ new Set(),
|
|
12602
|
+
promise: void 0,
|
|
12603
|
+
settled: false
|
|
12604
|
+
};
|
|
12605
|
+
const owned2 = read;
|
|
12606
|
+
this.#activityRead = owned2;
|
|
12607
|
+
owned2.promise = Promise.resolve().then(() => {
|
|
12608
|
+
owned2.controller.signal.throwIfAborted();
|
|
12609
|
+
return this.deps.project({ viewId: "activity", resource: "activity" }, owned2.controller.signal, source);
|
|
12610
|
+
}).finally(() => {
|
|
12611
|
+
owned2.settled = true;
|
|
12612
|
+
if (this.#activityRead === owned2 && !owned2.users.size) this.#activityRead = void 0;
|
|
12613
|
+
});
|
|
12614
|
+
void owned2.promise.catch(() => {
|
|
12615
|
+
});
|
|
12616
|
+
}
|
|
12617
|
+
const owned = read, user = Symbol("activity reader");
|
|
12618
|
+
owned.users.add(user);
|
|
12619
|
+
try {
|
|
12620
|
+
const payload = await abortableProjection(owned.promise, signal);
|
|
12621
|
+
const after = await abortableProjection(this.deps.client.resourcePosition(this.deps.identity, { signal }), signal);
|
|
12622
|
+
signal.throwIfAborted();
|
|
12623
|
+
if (!sameSource(source, after)) throw new Error("activity source changed");
|
|
12624
|
+
if (bound) {
|
|
12625
|
+
if (!this.#current(bound.connection, bound.view)) throw new Error("activity owner retired");
|
|
12626
|
+
}
|
|
12627
|
+
return payload;
|
|
12628
|
+
} finally {
|
|
12629
|
+
owned.users.delete(user);
|
|
12630
|
+
if (!owned.users.size) {
|
|
12631
|
+
owned.controller.abort();
|
|
12632
|
+
if (owned.settled && this.#activityRead === owned) this.#activityRead = void 0;
|
|
12633
|
+
}
|
|
12634
|
+
}
|
|
12635
|
+
}
|
|
12669
12636
|
open(response) {
|
|
12670
12637
|
const id = randomUUID2(), controller = new AbortController();
|
|
12671
12638
|
let resolveClosed;
|
|
@@ -12807,6 +12774,18 @@ data: ${JSON.stringify({
|
|
|
12807
12774
|
if (!view || view.epoch !== epoch || view.baselineId !== baselineId) throw new ResourceBindingError(409, "resource binding mismatch");
|
|
12808
12775
|
const baseline = await view.initial;
|
|
12809
12776
|
if (!this.#current(connection, view) || view.failed || !connection.observer.healthy) throw new ResourceBindingError(409, "resource binding retired");
|
|
12777
|
+
if (view.descriptor.resource === "activity") {
|
|
12778
|
+
try {
|
|
12779
|
+
const payload = await this.activity(view.controller.signal, { connection, view, source: baseline.source });
|
|
12780
|
+
if (!this.#current(connection, view) || view.failed || !connection.observer.healthy || !view.covered || !sameSource(baseline.source, view.covered))
|
|
12781
|
+
throw new Error("activity baseline changed");
|
|
12782
|
+
return { ...baseline, payload };
|
|
12783
|
+
} catch {
|
|
12784
|
+
view.failed = true;
|
|
12785
|
+
this.#retire(view);
|
|
12786
|
+
throw new ResourceBindingError(409, "resource activity binding retired");
|
|
12787
|
+
}
|
|
12788
|
+
}
|
|
12810
12789
|
return baseline;
|
|
12811
12790
|
}
|
|
12812
12791
|
#get(id) {
|
|
@@ -12897,7 +12876,7 @@ data: ${JSON.stringify({
|
|
|
12897
12876
|
if (view.dirty && this.#current(connection, view)) {
|
|
12898
12877
|
view.dirty = false;
|
|
12899
12878
|
const captured = await captureResourceProjection(this.deps.client, this.deps.identity, async () => {
|
|
12900
|
-
const payload = await this.deps.project(view.descriptor, view.controller.signal);
|
|
12879
|
+
const payload = view.descriptor.resource === "activity" ? await this.activity(view.controller.signal, { connection, view }) : await this.deps.project(view.descriptor, view.controller.signal);
|
|
12901
12880
|
const delta = view.descriptor.resource === "messages" && view.payload !== void 0 ? await messageProjectionDelta(
|
|
12902
12881
|
this.deps.client,
|
|
12903
12882
|
view.payload,
|
|
@@ -21443,7 +21422,7 @@ function resourceService(deps) {
|
|
|
21443
21422
|
identity: deps.config.identity,
|
|
21444
21423
|
identityCid: deps.identityCid,
|
|
21445
21424
|
stateDir: deps.config.stateDir,
|
|
21446
|
-
project: (descriptor, signal) => projectResourceView(deps, descriptor, signal)
|
|
21425
|
+
project: (descriptor, signal, source) => projectResourceView(deps, descriptor, signal, source)
|
|
21447
21426
|
});
|
|
21448
21427
|
resourceConnections.set(deps, service);
|
|
21449
21428
|
}
|
|
@@ -21879,7 +21858,7 @@ async function projectFilesResource(client, deps, params, signal, pin) {
|
|
|
21879
21858
|
})
|
|
21880
21859
|
};
|
|
21881
21860
|
}
|
|
21882
|
-
async function projectResourceView(deps, input, signal) {
|
|
21861
|
+
async function projectResourceView(deps, input, signal, source) {
|
|
21883
21862
|
const descriptor = canonicalResourceDescriptor(input), client = deps.runtime.client;
|
|
21884
21863
|
signal.throwIfAborted();
|
|
21885
21864
|
switch (descriptor.resource) {
|
|
@@ -21898,7 +21877,7 @@ async function projectResourceView(deps, input, signal) {
|
|
|
21898
21877
|
case "commands":
|
|
21899
21878
|
return projectCommandResource(client, deps, { contact: descriptor.entityId });
|
|
21900
21879
|
case "activity":
|
|
21901
|
-
return projectActivity(client, signal);
|
|
21880
|
+
return projectActivity(client, signal, source);
|
|
21902
21881
|
case "messages": {
|
|
21903
21882
|
const pin = descriptor.addressing === "cid" ? canonicalPeer(descriptor.entityId) : void 0;
|
|
21904
21883
|
const peer = pin ? { cid: pin.cid, announcedName: "" } : await resolveContact(client, descriptor.entityId);
|
|
@@ -22125,10 +22104,10 @@ var ROUTES = {
|
|
|
22125
22104
|
// ---- contacts ------------------------------------------------------------
|
|
22126
22105
|
"GET /api/contacts": async ({ client }) => presentContacts(await client.listContacts()),
|
|
22127
22106
|
// Last activity per contact for chat-list ordering; no message or file content.
|
|
22128
|
-
"GET /api/activity": async ({
|
|
22107
|
+
"GET /api/activity": async ({ deps, res }) => {
|
|
22129
22108
|
const lifetime = new AbortController();
|
|
22130
22109
|
res.once("close", () => lifetime.abort());
|
|
22131
|
-
return
|
|
22110
|
+
return resourceService(deps).activity(lifetime.signal);
|
|
22132
22111
|
},
|
|
22133
22112
|
// The old browser surface called this `listContactRoots`. It is not a separate
|
|
22134
22113
|
// operation: roots ride along on the contacts view.
|
|
@@ -22529,7 +22508,7 @@ import { randomBytes as randomBytes2 } from "node:crypto";
|
|
|
22529
22508
|
// node_modules/@ours.network/sdk/dist/index.js
|
|
22530
22509
|
init_define_MESSENGER_BUILD_INFO();
|
|
22531
22510
|
|
|
22532
|
-
// node_modules/@ours.network/sdk/dist/chunk-
|
|
22511
|
+
// node_modules/@ours.network/sdk/dist/chunk-HQL2UEEU.js
|
|
22533
22512
|
init_define_MESSENGER_BUILD_INFO();
|
|
22534
22513
|
|
|
22535
22514
|
// node_modules/@ours.network/sdk/dist/chunk-GPUVPRIY.js
|
|
@@ -22637,7 +22616,7 @@ var L = 100 * 1024 * 1024;
|
|
|
22637
22616
|
var K = { brokerUrl: "wss://broker1.ours.network", port: 3050, stateDir: E(T(), ".ours"), gcIntervalMs: 36e5, historyMaxBytes: L, apiVisibility: "owner", apiAuthMode: "legacy" };
|
|
22638
22617
|
var $2 = "daemon-token";
|
|
22639
22618
|
|
|
22640
|
-
// node_modules/@ours.network/sdk/dist/chunk-
|
|
22619
|
+
// node_modules/@ours.network/sdk/dist/chunk-HQL2UEEU.js
|
|
22641
22620
|
import { homedir as Te } from "node:os";
|
|
22642
22621
|
import { isAbsolute as Oe, join as Se, resolve as ue } from "node:path";
|
|
22643
22622
|
import { randomBytes as W } from "node:crypto";
|
|
@@ -22816,7 +22795,7 @@ var F = class {
|
|
|
22816
22795
|
if (!h.ok) throw new U(h.status);
|
|
22817
22796
|
if (!h.body || !h.headers.get("content-type")?.startsWith("text/event-stream")) throw new Error("Invalid resource stream response");
|
|
22818
22797
|
l = h.body.getReader(), i.addEventListener("abort", g, { once: true }), i.aborted && g();
|
|
22819
|
-
let T2 = new TextDecoder("utf-8", { fatal: true }), v2 = "", b2 = 0, _ = false,
|
|
22798
|
+
let T2 = new TextDecoder("utf-8", { fatal: true }), v2 = "", b2 = 0, _ = false, A2, O2 = -1;
|
|
22820
22799
|
for (; ; ) {
|
|
22821
22800
|
let { value: ie, done: be } = await l.read();
|
|
22822
22801
|
if (c(), be) throw new Error("Resource stream ended before disposal");
|
|
@@ -22830,16 +22809,16 @@ var F = class {
|
|
|
22830
22809
|
let oe = j.split(/\r?\n/).filter((k) => k.startsWith("data:")).map((k) => k.slice(5).trimStart()).join(`
|
|
22831
22810
|
`);
|
|
22832
22811
|
if (!oe) continue;
|
|
22833
|
-
let
|
|
22812
|
+
let R2 = JSON.parse(oe);
|
|
22834
22813
|
if (c(), j.split(/\r?\n/).some((k) => k === "event: auth_required")) throw new U(401);
|
|
22835
|
-
le(
|
|
22836
|
-
let K2 =
|
|
22814
|
+
le(R2);
|
|
22815
|
+
let K2 = R2.kind;
|
|
22837
22816
|
if (!["ready", "committed", "coverage", "resync"].includes(K2)) throw new Error("Invalid resource frame kind");
|
|
22838
|
-
if (
|
|
22839
|
-
if (
|
|
22817
|
+
if (A2 !== void 0 && (R2.producerGeneration !== A2 || R2.position < O2)) throw new Error("Resource stream continuity changed");
|
|
22818
|
+
if (A2 = R2.producerGeneration, O2 = R2.position, K2 === "ready") _ = true, a(45e3);
|
|
22840
22819
|
else if (_) a(45e3);
|
|
22841
22820
|
else if (K2 !== "resync") throw new Error("Resource mutation before ready");
|
|
22842
|
-
yield
|
|
22821
|
+
yield R2, c();
|
|
22843
22822
|
}
|
|
22844
22823
|
if (Buffer.byteLength(v2) > 512 * 1024) throw new Error("Resource frame exceeds limit");
|
|
22845
22824
|
}
|
|
@@ -22993,6 +22972,9 @@ var F = class {
|
|
|
22993
22972
|
getHistorySummary(t) {
|
|
22994
22973
|
return this.post("getHistorySummary", t);
|
|
22995
22974
|
}
|
|
22975
|
+
getContactActivity() {
|
|
22976
|
+
return this.post("getContactActivity", {});
|
|
22977
|
+
}
|
|
22996
22978
|
listFiles(t = {}) {
|
|
22997
22979
|
return this.post("listFiles", t);
|
|
22998
22980
|
}
|
|
@@ -23116,14 +23098,14 @@ var x = class extends Error {
|
|
|
23116
23098
|
super(`Invalid gateway client profile: ${t}. Configure ~/.ours-client/profile.json with ours-install client; no local service fallback is permitted.`), this.name = "ClientProfileError";
|
|
23117
23099
|
}
|
|
23118
23100
|
};
|
|
23119
|
-
function
|
|
23101
|
+
function Ae(e2 = process.env) {
|
|
23120
23102
|
if (e2.OURS_CONFIG !== void 0) {
|
|
23121
23103
|
if (!e2.OURS_CONFIG.trim()) throw new x("OURS_CONFIG must name a client profile");
|
|
23122
23104
|
return ue(e2.OURS_CONFIG);
|
|
23123
23105
|
}
|
|
23124
23106
|
return Se(e2.HOME || Te(), ".ours-client", "profile.json");
|
|
23125
23107
|
}
|
|
23126
|
-
function
|
|
23108
|
+
function Re(e2) {
|
|
23127
23109
|
let t = (o) => {
|
|
23128
23110
|
throw new x(o);
|
|
23129
23111
|
};
|
|
@@ -23146,13 +23128,13 @@ function Ae(e2) {
|
|
|
23146
23128
|
return typeof n.expectedInstanceId != "string" || !/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(n.expectedInstanceId) ? t("expectedInstanceId must be a lowercase UUID") : typeof n.credentialPath != "string" || !Oe(n.credentialPath) || ue(n.credentialPath) !== n.credentialPath ? t("credentialPath must be an absolute normalized path") : Object.freeze({ serverUrl: r, endpoint: i, expectedInstanceId: n.expectedInstanceId, credentialPath: n.credentialPath });
|
|
23147
23129
|
}
|
|
23148
23130
|
function pe(e2 = process.env) {
|
|
23149
|
-
let t =
|
|
23131
|
+
let t = Ae(e2), n;
|
|
23150
23132
|
try {
|
|
23151
23133
|
n = JSON.parse(m(t).toString("utf8"));
|
|
23152
23134
|
} catch {
|
|
23153
23135
|
throw new x("selected profile is missing, invalid JSON or unsafe; require a 0700 directory and a 0600 regular file");
|
|
23154
23136
|
}
|
|
23155
|
-
let r =
|
|
23137
|
+
let r = Re(n);
|
|
23156
23138
|
if (["OURS_PORT", "OURS_STATE_DIR", "OURS_API_TOKEN", "OURS_DAEMON_ID", "OURS_DAEMON_URL", "OURS_DAEMON_CREDENTIAL_PATH"].some((o) => e2[o]?.trim())) throw new x("remove legacy OURS_PORT/STATE_DIR/API_TOKEN/DAEMON_ID/DAEMON_URL/DAEMON_CREDENTIAL_PATH environment selectors");
|
|
23157
23139
|
return Object.freeze({ ...r, configPath: t });
|
|
23158
23140
|
}
|
|
@@ -23316,8 +23298,8 @@ async function Q(e2 = {}) {
|
|
|
23316
23298
|
{
|
|
23317
23299
|
let b2 = await globalThis.fetch(p(h, "/selection"), { signal: s ? AbortSignal.any([s, AbortSignal.timeout(5e3)]) : AbortSignal.timeout(5e3), redirect: "error" }), _ = await C(b2);
|
|
23318
23300
|
if (!b2.ok || !_ || Object.keys(_).length !== 3 || Object.keys(_).some((O2) => !["schema", "instanceId", "capabilities"].includes(O2)) || _.schema !== 1 || _.instanceId !== a) throw new Error("Daemon instance selection metadata is absent, incompatible or mismatched");
|
|
23319
|
-
let
|
|
23320
|
-
if (!Array.isArray(
|
|
23301
|
+
let A2 = _.capabilities;
|
|
23302
|
+
if (!Array.isArray(A2) || A2.some((O2) => typeof O2 != "string") || T2.some((O2) => !A2.includes(O2))) throw new Error("Daemon does not support the required capabilities; refusing local-mode fallback");
|
|
23321
23303
|
}
|
|
23322
23304
|
let v2 = l === void 0 ? y2 : S(l);
|
|
23323
23305
|
if (typeof v2 != "string" || !v2.trim()) throw new Error("Instance selection requires an explicit API token after daemon verification");
|
package/dist/cli.js
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
normalizeBasePath,
|
|
8
8
|
operatorError,
|
|
9
9
|
reportFailure
|
|
10
|
-
} from "./chunks/chunk-
|
|
10
|
+
} from "./chunks/chunk-DILYQTFT.js";
|
|
11
11
|
|
|
12
12
|
// src/cli.ts
|
|
13
13
|
init_define_MESSENGER_BUILD_INFO();
|
|
@@ -131,7 +131,7 @@ async function main() {
|
|
|
131
131
|
}
|
|
132
132
|
if (process.argv.length !== 3) throw new ConfigurationError("serve does not accept command-line options");
|
|
133
133
|
const cfg = loadConfig();
|
|
134
|
-
const { start } = await import("./chunks/server-
|
|
134
|
+
const { start } = await import("./chunks/server-U75YZIHR.js");
|
|
135
135
|
const handle = await start(cfg, BUILD_INFO);
|
|
136
136
|
let closing = false;
|
|
137
137
|
const shutdown = (signal) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ours.network/messenger-server",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "Self-hosted Messenger REST/SSE backend for one identity on a shared Ours daemon.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "FSL-1.1-Apache-2.0",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@eslint-community/regexpp": "4.12.2",
|
|
44
|
-
"@ours.network/sdk": "5.0
|
|
44
|
+
"@ours.network/sdk": "5.1.0",
|
|
45
45
|
"parse5": "^8.0.1",
|
|
46
46
|
"web-push": "^3.6.7",
|
|
47
47
|
"ws": "^8.21.0"
|