khala-cli 0.4.9 → 0.4.10
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/THIRD_PARTY_NOTICES.txt +28 -0
- package/dist/{chunk-NIX5F4LT.mjs → chunk-2AMWQ7RB.mjs} +330 -66
- package/dist/{chunk-PAJ4JJPV.mjs → chunk-3E5DH3Y6.mjs} +43 -6
- package/dist/{chunk-NGSYOVQ4.mjs → chunk-4BP7V3OP.mjs} +2 -2
- package/dist/{chunk-TEFOQXBK.mjs → chunk-4BZQ4GVW.mjs} +3 -3
- package/dist/{chunk-ITFD3JZS.mjs → chunk-5JSGA6OB.mjs} +424 -78
- package/dist/{chunk-QKWEZXR3.mjs → chunk-6AQVW5W7.mjs} +12 -4
- package/dist/{chunk-UK5GJO4Y.mjs → chunk-6J2PUM7L.mjs} +6 -5
- package/dist/{chunk-P3YIN7G7.mjs → chunk-6SUV3EW6.mjs} +11 -10
- package/dist/{chunk-GSZADJMW.mjs → chunk-ARIDZOTI.mjs} +309 -81
- package/dist/chunk-C2WEDMAF.mjs +15 -0
- package/dist/{chunk-DJM23SIU.mjs → chunk-CHC4VZF5.mjs} +7 -8
- package/dist/{chunk-BLCRVRIK.mjs → chunk-CKLCR5G4.mjs} +456 -87
- package/dist/{chunk-7R3EIDGR.mjs → chunk-EVT2DWNZ.mjs} +1 -1
- package/dist/{chunk-KMLXOPBQ.mjs → chunk-FJVVSKZ3.mjs} +4 -2
- package/dist/{chunk-3KDOTR54.mjs → chunk-G3NMB4PY.mjs} +1 -1
- package/dist/{chunk-SSO5RFOX.mjs → chunk-HHEZVPRR.mjs} +1 -1
- package/dist/{chunk-BV45NK7K.mjs → chunk-JKOJQTFT.mjs} +100 -6
- package/dist/{chunk-T7IL7V7Q.mjs → chunk-NDMFD5IM.mjs} +13 -10
- package/dist/{chunk-TANCKTDK.mjs → chunk-OEV5DFLW.mjs} +70 -5
- package/dist/{chunk-BEO7WIIM.mjs → chunk-OIZ4R5H7.mjs} +28 -8
- package/dist/{chunk-FZEH2IXZ.mjs → chunk-PJKI7SRI.mjs} +176 -26
- package/dist/{chunk-NPSQNCOY.mjs → chunk-PN25BUQ4.mjs} +13 -4
- package/dist/{chunk-3R6HFSLL.mjs → chunk-QDPJ4VT2.mjs} +92 -38
- package/dist/{chunk-FO5GXCST.mjs → chunk-SRZTHCXP.mjs} +5 -5
- package/dist/{chunk-LBT47HLZ.mjs → chunk-TSK3HJEG.mjs} +10 -9
- package/dist/{chunk-6BO3JSUP.mjs → chunk-UX34IVN5.mjs} +2 -2
- package/dist/{chunk-V4F3SYKW.mjs → chunk-VAC3JTAV.mjs} +25 -17
- package/dist/{chunk-PDZ5Z5ZE.mjs → chunk-VDZK4LW3.mjs} +24 -9
- package/dist/chunk-W6HM6F2U.mjs +901 -0
- package/dist/{chunk-WDOHRV3D.mjs → chunk-WPNMWNCL.mjs} +14 -14
- package/dist/chunk-WUDXHF2Q.mjs +14 -0
- package/dist/{chunk-XBQDIKB5.mjs → chunk-WZJ6DQJV.mjs} +9 -8
- package/dist/{chunk-ANSR4IAW.mjs → chunk-XR625T3I.mjs} +2 -2
- package/dist/{chunk-K7V7X6WU.mjs → chunk-ZSKLNZWZ.mjs} +21 -4
- package/dist/iterm2_send.py +56 -0
- package/dist/khala.mjs +11 -11
- package/dist/web/assets/local-CSPuGnH2.css +1 -0
- package/dist/web/assets/local-Dtyxaacx.js +9 -0
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/chunk-47XNLAJG.mjs +0 -38
- package/dist/chunk-XUCWSYVS.mjs +0 -148
- package/dist/web/assets/local-CFzRHZpB.js +0 -9
- package/dist/web/assets/local-ciypUFoK.css +0 -1
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { createRequire as __khalaCreateRequire } from 'node:module'; const require = __khalaCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
retryUnexpired
|
|
4
|
+
} from "./chunk-C2WEDMAF.mjs";
|
|
2
5
|
import {
|
|
3
6
|
StateError,
|
|
4
7
|
ensureStateDir,
|
|
5
8
|
writeJsonAtomic
|
|
6
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-PN25BUQ4.mjs";
|
|
7
10
|
import {
|
|
8
11
|
__commonJS,
|
|
9
12
|
__export,
|
|
10
13
|
__toESM,
|
|
11
14
|
init_define_KHALA_BUNDLE
|
|
12
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-EVT2DWNZ.mjs";
|
|
13
16
|
|
|
14
17
|
// ../../node_modules/.pnpm/immediate@3.3.0/node_modules/immediate/lib/nextTick.js
|
|
15
18
|
var require_nextTick = __commonJS({
|
|
@@ -9623,7 +9626,8 @@ async function readIdentity(file) {
|
|
|
9623
9626
|
const stat = await handle.stat();
|
|
9624
9627
|
if (!stat.isFile() || process.platform !== "win32" && (stat.mode & 63) !== 0 || typeof process.getuid === "function" && stat.uid !== process.getuid()) throw new StateError("unsafe_state_dir");
|
|
9625
9628
|
const value = JSON.parse(await handle.readFile("utf8"));
|
|
9626
|
-
if (!value || typeof value.homeserver !== "string" || typeof value.userId !== "string" || typeof value.deviceId !== "string" || value.accessToken !== void 0 && typeof value.accessToken !== "string" || value.joinedAt !== void 0 && !Number.isFinite(value.joinedAt)) throw new CryptoStoreCorruptError();
|
|
9629
|
+
if (!value || typeof value.homeserver !== "string" || typeof value.userId !== "string" || typeof value.deviceId !== "string" || value.accessToken !== void 0 && typeof value.accessToken !== "string" || value.joinedAt !== void 0 && !Number.isFinite(value.joinedAt) || value.undecryptableEventIds !== void 0 && (!Array.isArray(value.undecryptableEventIds) || value.undecryptableEventIds.length > 100 || value.undecryptableEventIds.some((entry) => typeof entry !== "string" && (!entry || typeof entry !== "object" || typeof entry.id !== "string" || typeof entry.firstSeen !== "number" || !Number.isFinite(entry.firstSeen) || entry.firstSeen < 0 || entry.firstSeen > Number.MAX_SAFE_INTEGER)))) throw new CryptoStoreCorruptError();
|
|
9630
|
+
if (value.undecryptableEventIds) value.undecryptableEventIds = value.undecryptableEventIds.filter((entry) => typeof entry !== "string" && retryUnexpired(entry));
|
|
9627
9631
|
return value;
|
|
9628
9632
|
} catch (error) {
|
|
9629
9633
|
if (error instanceof StateError) throw error;
|
|
@@ -9735,18 +9739,32 @@ async function openCryptoStore(dir, root, creds) {
|
|
|
9735
9739
|
if (!restored) {
|
|
9736
9740
|
await deleteStores(prefix, dir);
|
|
9737
9741
|
}
|
|
9738
|
-
|
|
9742
|
+
const saved = { ...identity, ...restored && previous?.joinedAt !== void 0 ? { joinedAt: previous.joinedAt } : {}, ...restored && previous?.undecryptableEventIds ? { undecryptableEventIds: previous.undecryptableEventIds } : {} };
|
|
9743
|
+
await writeJsonAtomic(identityFile, saved);
|
|
9739
9744
|
const sync = new DurableSyncStore({ indexedDB: globalThis.indexedDB, dbName: prefix });
|
|
9740
9745
|
let closed;
|
|
9746
|
+
let identitySave = Promise.resolve();
|
|
9747
|
+
const saveIdentity = () => {
|
|
9748
|
+
const saving = identitySave.then(() => writeJsonAtomic(identityFile, saved));
|
|
9749
|
+
identitySave = saving.catch(() => {
|
|
9750
|
+
});
|
|
9751
|
+
return saving;
|
|
9752
|
+
};
|
|
9741
9753
|
return {
|
|
9742
9754
|
prefix,
|
|
9743
9755
|
sync,
|
|
9744
9756
|
restored,
|
|
9745
9757
|
...recovered ? { recovered } : {},
|
|
9746
9758
|
...restored && previous?.joinedAt !== void 0 ? { joinedAt: previous?.joinedAt } : {},
|
|
9759
|
+
undecryptableEventIds: saved.undecryptableEventIds ?? [],
|
|
9760
|
+
async rememberUndecryptable(ids) {
|
|
9761
|
+
saved.undecryptableEventIds = ids.filter((entry) => retryUnexpired(entry)).slice(-100);
|
|
9762
|
+
await saveIdentity();
|
|
9763
|
+
},
|
|
9747
9764
|
async rememberJoin(ts) {
|
|
9748
9765
|
if (this.joinedAt === void 0) {
|
|
9749
|
-
|
|
9766
|
+
saved.joinedAt = ts;
|
|
9767
|
+
await saveIdentity();
|
|
9750
9768
|
this.joinedAt = ts;
|
|
9751
9769
|
}
|
|
9752
9770
|
},
|
|
@@ -9767,7 +9785,7 @@ async function openCryptoStore(dir, root, creds) {
|
|
|
9767
9785
|
throw error;
|
|
9768
9786
|
}
|
|
9769
9787
|
}
|
|
9770
|
-
async function wipeCryptoStore(dir, root) {
|
|
9788
|
+
async function wipeCryptoStore(dir, root, fetcher = fetch) {
|
|
9771
9789
|
try {
|
|
9772
9790
|
const names = await fs3.readdir(dir);
|
|
9773
9791
|
if (!["crypto.json", "crypto.sqlite", "sync.sqlite"].some((name) => names.includes(name))) return;
|
|
@@ -9784,6 +9802,25 @@ async function wipeCryptoStore(dir, root) {
|
|
|
9784
9802
|
retries: { retries: 12, minTimeout: 1e3, maxTimeout: 1e3 }
|
|
9785
9803
|
});
|
|
9786
9804
|
try {
|
|
9805
|
+
let identity;
|
|
9806
|
+
try {
|
|
9807
|
+
identity = await readIdentity(path.join(dir, "crypto.json"));
|
|
9808
|
+
} catch {
|
|
9809
|
+
identity = null;
|
|
9810
|
+
}
|
|
9811
|
+
if (identity?.accessToken) {
|
|
9812
|
+
try {
|
|
9813
|
+
const response = await fetcher(`${identity.homeserver}/_matrix/client/v3/logout`, {
|
|
9814
|
+
method: "POST",
|
|
9815
|
+
headers: { authorization: `Bearer ${identity.accessToken}`, "content-type": "application/json" },
|
|
9816
|
+
body: "{}",
|
|
9817
|
+
signal: AbortSignal.timeout(5e3)
|
|
9818
|
+
});
|
|
9819
|
+
if (!response.ok && response.status !== 401) console.error("khala: discarded_device_logout_failed");
|
|
9820
|
+
} catch {
|
|
9821
|
+
console.error("khala: discarded_device_logout_failed");
|
|
9822
|
+
}
|
|
9823
|
+
}
|
|
9787
9824
|
await unlink2(path.join(dir, "crypto.json"));
|
|
9788
9825
|
await deleteStores(prefix, dir);
|
|
9789
9826
|
} finally {
|
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
object,
|
|
6
6
|
readMatrixUserId,
|
|
7
7
|
version
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-PN25BUQ4.mjs";
|
|
9
9
|
import {
|
|
10
10
|
init_define_KHALA_BUNDLE
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-EVT2DWNZ.mjs";
|
|
12
12
|
|
|
13
13
|
// ../contracts/src/m1/listening-mode.ts
|
|
14
14
|
init_define_KHALA_BUNDLE();
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { createRequire as __khalaCreateRequire } from 'node:module'; const require = __khalaCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
listChannels
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-OEV5DFLW.mjs";
|
|
5
5
|
import {
|
|
6
6
|
TERMINAL_SESSION_DETAILS,
|
|
7
7
|
cachedProcessReader,
|
|
8
8
|
readStateFile,
|
|
9
9
|
readStatus,
|
|
10
10
|
validAgentRejoinSecret
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-PN25BUQ4.mjs";
|
|
12
12
|
import {
|
|
13
13
|
init_define_KHALA_BUNDLE
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-EVT2DWNZ.mjs";
|
|
15
15
|
|
|
16
16
|
// src/session-start-wake.ts
|
|
17
17
|
init_define_KHALA_BUNDLE();
|