@akshar5/cohall 0.12.4 → 0.12.5
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/CHANGELOG.md +7 -0
- package/bin/cohall.js +25 -20
- package/bin/cohall.js.map +7 -7
- package/docs/install.md +6 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.12.5](https://github.com/AksharP5/cohall/compare/v0.12.4...v0.12.5) (2026-10-17)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **auth:** keep owner tokens working with devices and backups ([#207](https://github.com/AksharP5/cohall/issues/207)) ([90d8e14](https://github.com/AksharP5/cohall/commit/90d8e142b4adcebfc7108a90f0500048e14c136b))
|
|
9
|
+
|
|
3
10
|
## [0.12.4](https://github.com/AksharP5/cohall/compare/v0.12.3...v0.12.4) (2026-10-17)
|
|
4
11
|
|
|
5
12
|
|
package/bin/cohall.js
CHANGED
|
@@ -17,7 +17,17 @@ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
|
17
17
|
|
|
18
18
|
// packages/protocol/src/index.ts
|
|
19
19
|
import { Effect, Schema } from "effect";
|
|
20
|
-
var version = "0.12.
|
|
20
|
+
var version = "0.12.5", maxSocketPayloadBytes, maxAuthTokenBytes = 512, maxAttachmentBytes, maxTaskAttachments = 2, maxProgressNoteBytes = 1024, bounded = (maxLength) => Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(maxLength)), optionalText = (maxLength) => Schema.String.check(Schema.isMaxLength(maxLength)), boundedArray = (schema, maxLength) => Schema.Array(schema).check(Schema.isMaxLength(maxLength)), count, assertOwnerToken = (token) => {
|
|
21
|
+
if (token.length < 32) {
|
|
22
|
+
throw new Error("The Cohall relay owner token must be at least 32 characters");
|
|
23
|
+
}
|
|
24
|
+
if (new TextEncoder().encode(token).byteLength > maxAuthTokenBytes) {
|
|
25
|
+
throw new Error(`The Cohall relay owner token must be at most ${maxAuthTokenBytes} UTF-8 bytes`);
|
|
26
|
+
}
|
|
27
|
+
if (token.trim() !== token || !/^[\t\x20-\x7e\x80-\xff]+$/.test(token)) {
|
|
28
|
+
throw new Error("The Cohall relay owner token must fit an HTTP header without leading or trailing whitespace");
|
|
29
|
+
}
|
|
30
|
+
}, uuid = (name) => Schema.String.check(Schema.isUUID(4)).pipe(Schema.brand(name)), isoTimestamp = (name) => Schema.String.check(Schema.isPattern(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?Z$/, {
|
|
21
31
|
expected: "an ISO-8601 UTC timestamp"
|
|
22
32
|
})).pipe(Schema.brand(name)), BotId, Bot, DeviceId, ThreadId, MessageId, TaskId, TaskRequestId, TaskRunId, ClarificationId, AuthSessionId, OperationId, Timestamp, TaskDeadline, taskDeadlineError = "Task deadline exceeded", taskDeadlinePassed = (task, time = Date.now()) => task.expiresAt !== undefined && Date.parse(task.expiresAt) <= time, Platform, Provider, DeviceStatus, TaskStatus, OperationStatus, TaskTraceEventKind, MessageRole, ConnectionRole, AuthSession, CreatePairingInput, PairingCredential, ExchangePairingInput, SessionCredential, PairingResult, Capability, Workspace, Device, DeviceOverview, maxDevicePageDevices = 16, maxDevicePageResponseBytes, DevicePage, minimumDeviceOperationVersion = "0.5.0", parsedVersion = (value) => {
|
|
23
33
|
const match = /^v?(\d+)\.(\d+)\.(\d+)(-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.exec(value);
|
|
@@ -377,7 +387,9 @@ var init_src = __esm(() => {
|
|
|
377
387
|
attachments: Schema.optionalKey(attachments)
|
|
378
388
|
}).check(Schema.makeFilter(validBotTarget));
|
|
379
389
|
SocketEvent = Schema.TaggedUnion({
|
|
380
|
-
Authenticate: {
|
|
390
|
+
Authenticate: {
|
|
391
|
+
token: bounded(maxAuthTokenBytes).check(Schema.makeFilter((token) => new TextEncoder().encode(token).byteLength <= maxAuthTokenBytes ? undefined : `Authentication token exceeds ${maxAuthTokenBytes} UTF-8 bytes`))
|
|
392
|
+
},
|
|
381
393
|
Connected: {
|
|
382
394
|
serverVersion: bounded(32),
|
|
383
395
|
connectedAt: Timestamp,
|
|
@@ -469,10 +481,11 @@ var RelayConfiguration, defaultDataDirectory = () => {
|
|
|
469
481
|
throw new Error(`${name} must be true or false`);
|
|
470
482
|
}, isLoopback2 = (host) => host === "127.0.0.1" || host === "localhost" || host === "::1", loadEnvironmentConfiguration;
|
|
471
483
|
var init_config = __esm(() => {
|
|
484
|
+
init_src();
|
|
472
485
|
RelayConfiguration = Schema16.Struct({
|
|
473
486
|
host: Schema16.NonEmptyString,
|
|
474
487
|
port: Schema16.Int.check(Schema16.isBetween({ minimum: 1, maximum: 65535 })),
|
|
475
|
-
token: Schema16.String.check(Schema16.isMinLength(32)),
|
|
488
|
+
token: Schema16.String.check(Schema16.isMinLength(32), Schema16.isMaxLength(maxAuthTokenBytes)),
|
|
476
489
|
dataDirectory: Schema16.NonEmptyString,
|
|
477
490
|
databasePath: Schema16.NonEmptyString,
|
|
478
491
|
allowRemote: Schema16.Boolean,
|
|
@@ -492,9 +505,7 @@ var init_config = __esm(() => {
|
|
|
492
505
|
await chmod7(dataDirectory, 448);
|
|
493
506
|
}
|
|
494
507
|
const token = process.env.COHALL_TOKEN ?? await tokenFrom(join10(dataDirectory, "owner-token"));
|
|
495
|
-
|
|
496
|
-
throw new Error("The Cohall relay owner token must be at least 32 characters");
|
|
497
|
-
}
|
|
508
|
+
assertOwnerToken(token);
|
|
498
509
|
const historyTaskLimit = Number(process.env.COHALL_HISTORY_TASK_LIMIT ?? "1000");
|
|
499
510
|
return Schema16.decodeUnknownSync(RelayConfiguration)({
|
|
500
511
|
host,
|
|
@@ -3005,7 +3016,7 @@ Content-Length: 0\r
|
|
|
3005
3016
|
socket.on("message", (message) => {
|
|
3006
3017
|
if (!hub.isAuthorized(socket)) {
|
|
3007
3018
|
const size = Buffer.byteLength(socketText(message));
|
|
3008
|
-
if (socket.data.preAuthFrameReceived || size >
|
|
3019
|
+
if (socket.data.preAuthFrameReceived || size > maxAuthTokenBytes * 6 + 64) {
|
|
3009
3020
|
socket.close(4003, "Only one authentication frame is allowed");
|
|
3010
3021
|
return;
|
|
3011
3022
|
}
|
|
@@ -4612,9 +4623,7 @@ var loadOwnerConfiguration = Effect4.tryPromise({
|
|
|
4612
4623
|
if (token === undefined || token.length === 0) {
|
|
4613
4624
|
throw new Error("No owner credential. Run this command on the relay host or set COHALL_TOKEN.");
|
|
4614
4625
|
}
|
|
4615
|
-
|
|
4616
|
-
throw new Error("The Cohall relay owner token must be at least 32 characters");
|
|
4617
|
-
}
|
|
4626
|
+
assertOwnerToken(token);
|
|
4618
4627
|
return ClientConfiguration.make({
|
|
4619
4628
|
relayUrl: normalizeRelayUrl(process.env.COHALL_RELAY_URL ?? stored.relayUrl),
|
|
4620
4629
|
token
|
|
@@ -6642,8 +6651,8 @@ var ownerToken = async (dataDirectory) => {
|
|
|
6642
6651
|
if (!await exists(path)) {
|
|
6643
6652
|
throw new Error(`Relay owner token was not found at ${path}`);
|
|
6644
6653
|
}
|
|
6645
|
-
if ((await stat3(path)).size >
|
|
6646
|
-
throw new Error("Relay owner token file exceeds
|
|
6654
|
+
if ((await stat3(path)).size > maxAuthTokenBytes + 2) {
|
|
6655
|
+
throw new Error("Relay owner token file exceeds its size limit");
|
|
6647
6656
|
}
|
|
6648
6657
|
return (await readFile3(path, "utf8")).trim();
|
|
6649
6658
|
};
|
|
@@ -6681,9 +6690,7 @@ var backupRelay = async (destinationInput) => {
|
|
|
6681
6690
|
}
|
|
6682
6691
|
verifyDatabase(databasePath);
|
|
6683
6692
|
const token = await ownerToken(sourceDirectory);
|
|
6684
|
-
|
|
6685
|
-
throw new Error("The relay owner token must contain between 32 and 512 bytes");
|
|
6686
|
-
}
|
|
6693
|
+
assertOwnerToken(token);
|
|
6687
6694
|
await writeFile5(ownerTokenPath, `${token}
|
|
6688
6695
|
`, { mode: 384 });
|
|
6689
6696
|
await Promise.all([chmod6(databasePath, 384), chmod6(ownerTokenPath, 384)]);
|
|
@@ -6722,7 +6729,7 @@ var restoreRelay = async (sourceInput) => {
|
|
|
6722
6729
|
}
|
|
6723
6730
|
await Promise.all([
|
|
6724
6731
|
verifyBackupMember(sourceDatabase),
|
|
6725
|
-
verifyBackupMember(sourceOwnerToken,
|
|
6732
|
+
verifyBackupMember(sourceOwnerToken, maxAuthTokenBytes + 2),
|
|
6726
6733
|
verifyBackupMember(sourceManifest, 16384)
|
|
6727
6734
|
]);
|
|
6728
6735
|
const target = relayDataDirectory();
|
|
@@ -6754,9 +6761,7 @@ var restoreRelay = async (sourceInput) => {
|
|
|
6754
6761
|
}
|
|
6755
6762
|
verifyDatabase(databasePath);
|
|
6756
6763
|
const token = (await readFile3(ownerTokenPath, "utf8")).trim();
|
|
6757
|
-
|
|
6758
|
-
throw new Error("Relay backup contains an invalid owner token");
|
|
6759
|
-
}
|
|
6764
|
+
assertOwnerToken(token);
|
|
6760
6765
|
backupVersion = manifest.cohallVersion;
|
|
6761
6766
|
await rename3(staging, target);
|
|
6762
6767
|
} catch (cause) {
|
|
@@ -9197,4 +9202,4 @@ await main().catch((cause) => {
|
|
|
9197
9202
|
process.exitCode = 1;
|
|
9198
9203
|
});
|
|
9199
9204
|
|
|
9200
|
-
//# debugId=
|
|
9205
|
+
//# debugId=A33BDA8325259EFC64756E2164756E21
|