@openclaw/matrix 2026.7.2-beta.1 → 2026.7.2-beta.3
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/{account-selection-Bz00QTmQ.js → account-selection-kqquRzCf.js} +5 -5
- package/dist/api.js +6 -6
- package/dist/{approval-handler.runtime--Ei44Vo2.js → approval-handler.runtime-BEa98wwG.js} +5 -5
- package/dist/{approval-ids-C_2kSMdJ.js → approval-ids-Dfn7oQAm.js} +1 -1
- package/dist/{approval-reaction-auth-TdVPcgxP.js → approval-reaction-auth-kXkCJBGi.js} +2 -2
- package/dist/{approval-reactions-BgU51JGd.js → approval-reactions-D-BxBK_L.js} +1 -1
- package/dist/auth-presence.js +13 -21
- package/dist/{channel-CxqDh7mS.js → channel-j331Xd7b.js} +14 -13
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{channel.runtime-wNfJc57I.js → channel.runtime-BIwlVfQw.js} +15 -16
- package/dist/{cli-o00oTJhx.js → cli-0EcKfqFw.js} +25 -15
- package/dist/{cli-metadata-Gf3HSJ2c.js → cli-metadata-Xq1Xb15R.js} +1 -1
- package/dist/cli-metadata.js +1 -1
- package/dist/{client-ClHisZbf.js → client-BtG4quUl.js} +2 -2
- package/dist/{client-DP0nmFxK.js → client-CA0PULls.js} +2 -2
- package/dist/{client-bootstrap-PqYOS-mO.js → client-bootstrap-Dk5EAn3n.js} +1 -1
- package/dist/{config-schema-CG9goLWp.js → config-schema-B5GRV8wL.js} +8 -10
- package/dist/contract-api.js +2 -2
- package/dist/{create-client-D9z9RjCM.js → create-client-WQExaby_.js} +4 -4
- package/dist/credentials-W2EmwRhu.js +65 -0
- package/dist/credentials-read-DVmFCm7X.js +77 -0
- package/dist/{credentials-write.runtime-J_EUt5WP.js → credentials-write.runtime-Be9zNSUw.js} +1 -1
- package/dist/{crypto-runtime-BHcxauC4.js → crypto-runtime-CAff-n15.js} +4 -4
- package/dist/{directory-live-DPy2aaPF.js → directory-live-DiC-0XBC.js} +3 -3
- package/dist/{doctor-BGTs609f.js → doctor-DwUVm5Lw.js} +1 -1
- package/dist/{doctor-contract-D2qTLe-C.js → doctor-contract-BA2Y6Crx.js} +1 -1
- package/dist/doctor-contract-api.js +117 -11
- package/dist/{draft-stream-De7uikGn.js → draft-stream-CTLKtJJ0.js} +1 -1
- package/dist/{encryption-guidance-BFfgq7c7.js → encryption-guidance-CbEFe38F.js} +1 -1
- package/dist/{file-sync-store-Cxb0ckyX.js → file-sync-store-CPkgnSXp.js} +23 -6
- package/dist/helper-api.js +2 -2
- package/dist/{http-client-W4TJQM6r.js → http-client-BmrgOZTL.js} +2 -2
- package/dist/{idb-persistence-iUZoHZkp.js → idb-persistence-Dyy6ipgU.js} +3 -3
- package/dist/{inbound-dedupe-DcMs0YXL.js → inbound-dedupe-CaBLblef.js} +19 -38
- package/dist/index.js +1 -1
- package/dist/{logger-BMClpI5b.js → logger-D0GCSDQq.js} +1 -1
- package/dist/{logging-CFJrbDAN.js → logging-QH-48Gr6.js} +1 -1
- package/dist/{media-text-DWaotsZB.js → media-text-BMXEXb1j.js} +1 -1
- package/dist/{messages-Dm3K4ZvM.js → messages-3UBHfZrN.js} +3 -3
- package/dist/{monitor-C_kgPPeV.js → monitor-BtUIds8T.js} +135 -136
- package/dist/plugin-entry.handlers.runtime.js +1 -1
- package/dist/probe.runtime-sBV-Govx.js +3 -0
- package/dist/{profile-update-iUHCoks3.js → profile-update-Bh2XtJwN.js} +3 -3
- package/dist/{reaction-events-0tubdHRM.js → reaction-events-BwAKtUyQ.js} +3 -3
- package/dist/record-shared-CWWx6fvI.js +2 -0
- package/dist/{recovery-key-store-Bx0zTJcB.js → recovery-key-store-CW6eePfp.js} +2 -2
- package/dist/{resolve-targets-DlLrfWDy.js → resolve-targets-DVoj-YxB.js} +1 -1
- package/dist/{resolver.runtime-MeaT1zXx.js → resolver.runtime-CC0VVsAt.js} +1 -1
- package/dist/{runtime-CveSqMOP.js → runtime-6S3DNFNv.js} +1 -1
- package/dist/runtime-api.js +6 -6
- package/dist/runtime-setter-api.js +1 -1
- package/dist/{sdk-CI8E2TKg.js → sdk-CIDZXWpZ.js} +7 -7
- package/dist/{secret-contract-OZoQf0kI.js → secret-contract-M3hRmGO-.js} +21 -5
- package/dist/secret-contract-api.js +1 -1
- package/dist/{send-C7xuGWpv.js → send-BJbrdmNm.js} +4 -3
- package/dist/session-binding-contract-api.js +2 -2
- package/dist/{setup-bootstrap-CCsexWTZ.js → setup-bootstrap-DGPOOdz-.js} +2 -2
- package/dist/{setup-core-DlmTyIP0.js → setup-core-XCdAx1nY.js} +3 -3
- package/dist/setup-plugin-api.js +3 -3
- package/dist/{setup-surface-2SS94JV0.js → setup-surface-CzUiTe_k.js} +6 -6
- package/dist/{shared-DgvN5rBx.js → shared-DquM1oz6.js} +7 -7
- package/dist/{startup-verification-CbIyF7z1.js → startup-verification-CA00kebL.js} +3 -3
- package/dist/{storage-BtSOar8T.js → storage-CzHxeF5E.js} +9 -9
- package/dist/{thread-bindings-BI8MHWp9.js → thread-bindings-Cw194yEn.js} +4 -4
- package/dist/{tool-actions.runtime-CnyhVPoY.js → tool-actions.runtime-C0jgWYhX.js} +19 -15
- package/dist/{verification-DLSe3sP7.js → verification-DjxyWTNP.js} +2 -2
- package/npm-shrinkwrap.json +3 -3
- package/openclaw.plugin.json +70 -70
- package/package.json +4 -4
- package/dist/async-lock-BcLS4KOc.js +0 -19
- package/dist/credentials-DnhsLAuR.js +0 -56
- package/dist/credentials-read-BtS-HRT5.js +0 -112
- package/dist/probe.runtime-Dry8PTWC.js +0 -3
- package/dist/record-shared-CvzjvHRn.js +0 -2
- package/dist/{deps-DDbghaZH.js → deps-CcVJfvRM.js} +1 -1
- package/dist/{storage-paths-B4_I9iqO.js → storage-paths-gUmSydsW.js} +1 -1
package/openclaw.plugin.json
CHANGED
|
@@ -669,14 +669,47 @@
|
|
|
669
669
|
"additionalProperties": {
|
|
670
670
|
"type": "object",
|
|
671
671
|
"properties": {
|
|
672
|
-
"
|
|
673
|
-
"type": "
|
|
672
|
+
"requireMention": {
|
|
673
|
+
"type": "boolean"
|
|
674
|
+
},
|
|
675
|
+
"tools": {
|
|
676
|
+
"type": "object",
|
|
677
|
+
"properties": {
|
|
678
|
+
"allow": {
|
|
679
|
+
"type": "array",
|
|
680
|
+
"items": {
|
|
681
|
+
"type": "string"
|
|
682
|
+
}
|
|
683
|
+
},
|
|
684
|
+
"alsoAllow": {
|
|
685
|
+
"type": "array",
|
|
686
|
+
"items": {
|
|
687
|
+
"type": "string"
|
|
688
|
+
}
|
|
689
|
+
},
|
|
690
|
+
"deny": {
|
|
691
|
+
"type": "array",
|
|
692
|
+
"items": {
|
|
693
|
+
"type": "string"
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
},
|
|
697
|
+
"additionalProperties": false
|
|
698
|
+
},
|
|
699
|
+
"skills": {
|
|
700
|
+
"type": "array",
|
|
701
|
+
"items": {
|
|
702
|
+
"type": "string"
|
|
703
|
+
}
|
|
674
704
|
},
|
|
675
705
|
"enabled": {
|
|
676
706
|
"type": "boolean"
|
|
677
707
|
},
|
|
678
|
-
"
|
|
679
|
-
"type": "
|
|
708
|
+
"systemPrompt": {
|
|
709
|
+
"type": "string"
|
|
710
|
+
},
|
|
711
|
+
"account": {
|
|
712
|
+
"type": "string"
|
|
680
713
|
},
|
|
681
714
|
"allowBots": {
|
|
682
715
|
"anyOf": [
|
|
@@ -713,6 +746,35 @@
|
|
|
713
746
|
},
|
|
714
747
|
"additionalProperties": false
|
|
715
748
|
},
|
|
749
|
+
"autoReply": {
|
|
750
|
+
"type": "boolean"
|
|
751
|
+
},
|
|
752
|
+
"users": {
|
|
753
|
+
"type": "array",
|
|
754
|
+
"items": {
|
|
755
|
+
"anyOf": [
|
|
756
|
+
{
|
|
757
|
+
"type": "string"
|
|
758
|
+
},
|
|
759
|
+
{
|
|
760
|
+
"type": "number"
|
|
761
|
+
}
|
|
762
|
+
]
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
},
|
|
766
|
+
"additionalProperties": false
|
|
767
|
+
}
|
|
768
|
+
},
|
|
769
|
+
"rooms": {
|
|
770
|
+
"type": "object",
|
|
771
|
+
"properties": {},
|
|
772
|
+
"additionalProperties": {
|
|
773
|
+
"type": "object",
|
|
774
|
+
"properties": {
|
|
775
|
+
"requireMention": {
|
|
776
|
+
"type": "boolean"
|
|
777
|
+
},
|
|
716
778
|
"tools": {
|
|
717
779
|
"type": "object",
|
|
718
780
|
"properties": {
|
|
@@ -737,50 +799,21 @@
|
|
|
737
799
|
},
|
|
738
800
|
"additionalProperties": false
|
|
739
801
|
},
|
|
740
|
-
"autoReply": {
|
|
741
|
-
"type": "boolean"
|
|
742
|
-
},
|
|
743
|
-
"users": {
|
|
744
|
-
"type": "array",
|
|
745
|
-
"items": {
|
|
746
|
-
"anyOf": [
|
|
747
|
-
{
|
|
748
|
-
"type": "string"
|
|
749
|
-
},
|
|
750
|
-
{
|
|
751
|
-
"type": "number"
|
|
752
|
-
}
|
|
753
|
-
]
|
|
754
|
-
}
|
|
755
|
-
},
|
|
756
802
|
"skills": {
|
|
757
803
|
"type": "array",
|
|
758
804
|
"items": {
|
|
759
805
|
"type": "string"
|
|
760
806
|
}
|
|
761
807
|
},
|
|
808
|
+
"enabled": {
|
|
809
|
+
"type": "boolean"
|
|
810
|
+
},
|
|
762
811
|
"systemPrompt": {
|
|
763
812
|
"type": "string"
|
|
764
|
-
}
|
|
765
|
-
},
|
|
766
|
-
"additionalProperties": false
|
|
767
|
-
}
|
|
768
|
-
},
|
|
769
|
-
"rooms": {
|
|
770
|
-
"type": "object",
|
|
771
|
-
"properties": {},
|
|
772
|
-
"additionalProperties": {
|
|
773
|
-
"type": "object",
|
|
774
|
-
"properties": {
|
|
813
|
+
},
|
|
775
814
|
"account": {
|
|
776
815
|
"type": "string"
|
|
777
816
|
},
|
|
778
|
-
"enabled": {
|
|
779
|
-
"type": "boolean"
|
|
780
|
-
},
|
|
781
|
-
"requireMention": {
|
|
782
|
-
"type": "boolean"
|
|
783
|
-
},
|
|
784
817
|
"allowBots": {
|
|
785
818
|
"anyOf": [
|
|
786
819
|
{
|
|
@@ -816,30 +849,6 @@
|
|
|
816
849
|
},
|
|
817
850
|
"additionalProperties": false
|
|
818
851
|
},
|
|
819
|
-
"tools": {
|
|
820
|
-
"type": "object",
|
|
821
|
-
"properties": {
|
|
822
|
-
"allow": {
|
|
823
|
-
"type": "array",
|
|
824
|
-
"items": {
|
|
825
|
-
"type": "string"
|
|
826
|
-
}
|
|
827
|
-
},
|
|
828
|
-
"alsoAllow": {
|
|
829
|
-
"type": "array",
|
|
830
|
-
"items": {
|
|
831
|
-
"type": "string"
|
|
832
|
-
}
|
|
833
|
-
},
|
|
834
|
-
"deny": {
|
|
835
|
-
"type": "array",
|
|
836
|
-
"items": {
|
|
837
|
-
"type": "string"
|
|
838
|
-
}
|
|
839
|
-
}
|
|
840
|
-
},
|
|
841
|
-
"additionalProperties": false
|
|
842
|
-
},
|
|
843
852
|
"autoReply": {
|
|
844
853
|
"type": "boolean"
|
|
845
854
|
},
|
|
@@ -855,15 +864,6 @@
|
|
|
855
864
|
}
|
|
856
865
|
]
|
|
857
866
|
}
|
|
858
|
-
},
|
|
859
|
-
"skills": {
|
|
860
|
-
"type": "array",
|
|
861
|
-
"items": {
|
|
862
|
-
"type": "string"
|
|
863
|
-
}
|
|
864
|
-
},
|
|
865
|
-
"systemPrompt": {
|
|
866
|
-
"type": "string"
|
|
867
867
|
}
|
|
868
868
|
},
|
|
869
869
|
"additionalProperties": false
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/matrix",
|
|
3
|
-
"version": "2026.7.2-beta.
|
|
3
|
+
"version": "2026.7.2-beta.3",
|
|
4
4
|
"description": "OpenClaw Matrix channel plugin for rooms and direct messages.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"zod": "4.4.3"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
|
-
"openclaw": ">=2026.7.2-beta.
|
|
21
|
+
"openclaw": ">=2026.7.2-beta.3"
|
|
22
22
|
},
|
|
23
23
|
"peerDependenciesMeta": {
|
|
24
24
|
"openclaw": {
|
|
@@ -84,10 +84,10 @@
|
|
|
84
84
|
"allowInvalidConfigRecovery": true
|
|
85
85
|
},
|
|
86
86
|
"compat": {
|
|
87
|
-
"pluginApi": ">=2026.7.2-beta.
|
|
87
|
+
"pluginApi": ">=2026.7.2-beta.3"
|
|
88
88
|
},
|
|
89
89
|
"build": {
|
|
90
|
-
"openclawVersion": "2026.7.2-beta.
|
|
90
|
+
"openclawVersion": "2026.7.2-beta.3"
|
|
91
91
|
},
|
|
92
92
|
"release": {
|
|
93
93
|
"publishToClawHub": true,
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
//#region extensions/matrix/src/matrix/async-lock.ts
|
|
2
|
-
function createAsyncLock() {
|
|
3
|
-
let lock = Promise.resolve();
|
|
4
|
-
return async function withLock(fn) {
|
|
5
|
-
const previous = lock;
|
|
6
|
-
let release;
|
|
7
|
-
lock = new Promise((resolve) => {
|
|
8
|
-
release = resolve;
|
|
9
|
-
});
|
|
10
|
-
await previous;
|
|
11
|
-
try {
|
|
12
|
-
return await fn();
|
|
13
|
-
} finally {
|
|
14
|
-
release?.();
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
//#endregion
|
|
19
|
-
export { createAsyncLock as t };
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { a as resolveMatrixCredentialsDir, i as loadMatrixCredentials, n as credentialsMatchConfig, o as resolveMatrixCredentialsPath, t as clearMatrixCredentials } from "./credentials-read-BtS-HRT5.js";
|
|
2
|
-
import { t as createAsyncLock } from "./async-lock-BcLS4KOc.js";
|
|
3
|
-
import { writeJsonFileAtomically } from "openclaw/plugin-sdk/json-store";
|
|
4
|
-
//#region extensions/matrix/src/matrix/credentials.ts
|
|
5
|
-
const credentialWriteLocks = /* @__PURE__ */ new Map();
|
|
6
|
-
function withCredentialWriteLock(credPath, fn) {
|
|
7
|
-
let withLock = credentialWriteLocks.get(credPath);
|
|
8
|
-
if (!withLock) {
|
|
9
|
-
withLock = createAsyncLock();
|
|
10
|
-
credentialWriteLocks.set(credPath, withLock);
|
|
11
|
-
}
|
|
12
|
-
return withLock(fn);
|
|
13
|
-
}
|
|
14
|
-
async function writeMatrixCredentialsUnlocked(params) {
|
|
15
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
16
|
-
const toSave = {
|
|
17
|
-
...params.credentials,
|
|
18
|
-
createdAt: params.existing?.createdAt ?? now,
|
|
19
|
-
lastUsedAt: now
|
|
20
|
-
};
|
|
21
|
-
await writeJsonFileAtomically(params.credPath, toSave);
|
|
22
|
-
}
|
|
23
|
-
async function saveMatrixCredentials(credentials, env = process.env, accountId) {
|
|
24
|
-
const credPath = resolveMatrixCredentialsPath(env, accountId);
|
|
25
|
-
await withCredentialWriteLock(credPath, async () => {
|
|
26
|
-
await writeMatrixCredentialsUnlocked({
|
|
27
|
-
credPath,
|
|
28
|
-
credentials,
|
|
29
|
-
existing: loadMatrixCredentials(env, accountId)
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
async function saveBackfilledMatrixDeviceId(credentials, env = process.env, accountId) {
|
|
34
|
-
const credPath = resolveMatrixCredentialsPath(env, accountId);
|
|
35
|
-
return await withCredentialWriteLock(credPath, async () => {
|
|
36
|
-
const existing = loadMatrixCredentials(env, accountId);
|
|
37
|
-
if (existing && (existing.homeserver !== credentials.homeserver || existing.userId !== credentials.userId || existing.accessToken !== credentials.accessToken)) return "skipped";
|
|
38
|
-
await writeMatrixCredentialsUnlocked({
|
|
39
|
-
credPath,
|
|
40
|
-
credentials,
|
|
41
|
-
existing
|
|
42
|
-
});
|
|
43
|
-
return "saved";
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
async function touchMatrixCredentials(env = process.env, accountId) {
|
|
47
|
-
const credPath = resolveMatrixCredentialsPath(env, accountId);
|
|
48
|
-
await withCredentialWriteLock(credPath, async () => {
|
|
49
|
-
const existing = loadMatrixCredentials(env, accountId);
|
|
50
|
-
if (!existing) return;
|
|
51
|
-
existing.lastUsedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
52
|
-
await writeJsonFileAtomically(credPath, existing);
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
//#endregion
|
|
56
|
-
export { clearMatrixCredentials, credentialsMatchConfig, loadMatrixCredentials, resolveMatrixCredentialsDir, resolveMatrixCredentialsPath, saveBackfilledMatrixDeviceId, saveMatrixCredentials, touchMatrixCredentials };
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
|
|
2
|
-
import { a as resolveMatrixDefaultOrOnlyAccountId, n as requiresExplicitMatrixDefaultAccount } from "./account-selection-Bz00QTmQ.js";
|
|
3
|
-
import { t as getMatrixRuntime } from "./runtime-CveSqMOP.js";
|
|
4
|
-
import { a as resolveMatrixCredentialsPath$1, r as resolveMatrixCredentialsDir$1 } from "./storage-paths-B4_I9iqO.js";
|
|
5
|
-
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/account-id";
|
|
6
|
-
import fs from "node:fs";
|
|
7
|
-
import os from "node:os";
|
|
8
|
-
import path from "node:path";
|
|
9
|
-
//#region extensions/matrix/src/matrix/credentials-read.ts
|
|
10
|
-
var credentials_read_exports = /* @__PURE__ */ __exportAll({
|
|
11
|
-
clearMatrixCredentials: () => clearMatrixCredentials,
|
|
12
|
-
credentialsMatchConfig: () => credentialsMatchConfig,
|
|
13
|
-
loadMatrixCredentials: () => loadMatrixCredentials,
|
|
14
|
-
resolveMatrixCredentialsDir: () => resolveMatrixCredentialsDir,
|
|
15
|
-
resolveMatrixCredentialsPath: () => resolveMatrixCredentialsPath
|
|
16
|
-
});
|
|
17
|
-
function resolveStateDir(env) {
|
|
18
|
-
try {
|
|
19
|
-
return getMatrixRuntime().state.resolveStateDir(env, os.homedir);
|
|
20
|
-
} catch {
|
|
21
|
-
const override = env.OPENCLAW_STATE_DIR?.trim();
|
|
22
|
-
if (override) return path.resolve(override);
|
|
23
|
-
const homeDir = env.OPENCLAW_HOME?.trim() || env.HOME?.trim() || os.homedir();
|
|
24
|
-
return path.join(homeDir, ".openclaw");
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
function resolveLegacyMatrixCredentialsPath(env) {
|
|
28
|
-
return path.join(resolveMatrixCredentialsDir(env), "credentials.json");
|
|
29
|
-
}
|
|
30
|
-
function shouldReadLegacyCredentialsForAccount(accountId) {
|
|
31
|
-
const normalizedAccountId = normalizeAccountId(accountId);
|
|
32
|
-
const cfg = getMatrixRuntime().config.current();
|
|
33
|
-
if (!cfg.channels?.matrix || typeof cfg.channels.matrix !== "object") return normalizedAccountId === DEFAULT_ACCOUNT_ID;
|
|
34
|
-
if (requiresExplicitMatrixDefaultAccount(cfg)) return false;
|
|
35
|
-
return normalizeAccountId(resolveMatrixDefaultOrOnlyAccountId(cfg)) === normalizedAccountId;
|
|
36
|
-
}
|
|
37
|
-
function resolveLegacyMigrationSourcePath(env, accountId) {
|
|
38
|
-
if (!shouldReadLegacyCredentialsForAccount(accountId)) return null;
|
|
39
|
-
const legacyPath = resolveLegacyMatrixCredentialsPath(env);
|
|
40
|
-
return legacyPath === resolveMatrixCredentialsPath(env, accountId) ? null : legacyPath;
|
|
41
|
-
}
|
|
42
|
-
function parseMatrixCredentialsFile(filePath) {
|
|
43
|
-
const raw = fs.readFileSync(filePath, "utf-8");
|
|
44
|
-
const parsed = JSON.parse(raw);
|
|
45
|
-
if (typeof parsed.homeserver !== "string" || typeof parsed.userId !== "string" || typeof parsed.accessToken !== "string") return null;
|
|
46
|
-
return parsed;
|
|
47
|
-
}
|
|
48
|
-
function loadMatrixCredentialsFile(filePath, source) {
|
|
49
|
-
try {
|
|
50
|
-
return {
|
|
51
|
-
kind: "loaded",
|
|
52
|
-
source,
|
|
53
|
-
credentials: parseMatrixCredentialsFile(filePath)
|
|
54
|
-
};
|
|
55
|
-
} catch (error) {
|
|
56
|
-
if (error?.code === "ENOENT") return { kind: "missing" };
|
|
57
|
-
throw error;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
function loadLegacyMatrixCredentialsWithCurrentFallback(params) {
|
|
61
|
-
const legacy = loadMatrixCredentialsFile(params.legacyPath, "legacy");
|
|
62
|
-
if (legacy.kind === "loaded") return legacy;
|
|
63
|
-
return loadMatrixCredentialsFile(params.currentPath, "current");
|
|
64
|
-
}
|
|
65
|
-
function resolveMatrixCredentialsDir(env = process.env, stateDir) {
|
|
66
|
-
return resolveMatrixCredentialsDir$1(stateDir ?? resolveStateDir(env));
|
|
67
|
-
}
|
|
68
|
-
function resolveMatrixCredentialsPath(env = process.env, accountId) {
|
|
69
|
-
return resolveMatrixCredentialsPath$1({
|
|
70
|
-
stateDir: resolveStateDir(env),
|
|
71
|
-
accountId
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
function loadMatrixCredentials(env = process.env, accountId) {
|
|
75
|
-
const currentPath = resolveMatrixCredentialsPath(env, accountId);
|
|
76
|
-
try {
|
|
77
|
-
const current = loadMatrixCredentialsFile(currentPath, "current");
|
|
78
|
-
if (current.kind === "loaded") return current.credentials;
|
|
79
|
-
const legacyPath = resolveLegacyMigrationSourcePath(env, accountId);
|
|
80
|
-
if (!legacyPath) return null;
|
|
81
|
-
const loaded = loadLegacyMatrixCredentialsWithCurrentFallback({
|
|
82
|
-
legacyPath,
|
|
83
|
-
currentPath
|
|
84
|
-
});
|
|
85
|
-
if (loaded.kind !== "loaded" || !loaded.credentials) return null;
|
|
86
|
-
if (loaded.source === "legacy") try {
|
|
87
|
-
fs.mkdirSync(path.dirname(currentPath), { recursive: true });
|
|
88
|
-
fs.renameSync(legacyPath, currentPath);
|
|
89
|
-
} catch {}
|
|
90
|
-
return loaded.credentials;
|
|
91
|
-
} catch {
|
|
92
|
-
return null;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
function clearMatrixCredentials(env = process.env, accountId) {
|
|
96
|
-
const paths = [resolveMatrixCredentialsPath(env, accountId), resolveLegacyMigrationSourcePath(env, accountId)];
|
|
97
|
-
for (const filePath of paths) {
|
|
98
|
-
if (!filePath) continue;
|
|
99
|
-
try {
|
|
100
|
-
fs.unlinkSync(filePath);
|
|
101
|
-
} catch {}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
function credentialsMatchConfig(stored, config) {
|
|
105
|
-
if (!config.userId) {
|
|
106
|
-
if (!config.accessToken) return false;
|
|
107
|
-
return stored.homeserver === config.homeserver && stored.accessToken === config.accessToken;
|
|
108
|
-
}
|
|
109
|
-
return stored.homeserver === config.homeserver && stored.userId === config.userId;
|
|
110
|
-
}
|
|
111
|
-
//#endregion
|
|
112
|
-
export { resolveMatrixCredentialsDir as a, loadMatrixCredentials as i, credentialsMatchConfig as n, resolveMatrixCredentialsPath as o, credentials_read_exports as r, clearMatrixCredentials as t };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
-
import fs from "node:fs";
|
|
3
2
|
import path from "node:path";
|
|
4
3
|
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
4
|
+
import fs from "node:fs";
|
|
5
5
|
import { runCommandWithTimeout } from "openclaw/plugin-sdk/process-runtime";
|
|
6
6
|
//#region extensions/matrix/src/matrix/deps.ts
|
|
7
7
|
const REQUIRED_MATRIX_PACKAGES = [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
2
2
|
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/account-id";
|
|
3
|
-
import path from "node:path";
|
|
4
3
|
import crypto from "node:crypto";
|
|
4
|
+
import path from "node:path";
|
|
5
5
|
//#region extensions/matrix/src/storage-paths.ts
|
|
6
6
|
function sanitizeMatrixPathSegment(value) {
|
|
7
7
|
return normalizeLowercaseStringOrEmpty(value).replace(/[^a-z0-9._-]+/g, "_").replace(/^_+|_+$/g, "") || "unknown";
|