@openclaw/matrix 2026.5.14-beta.1 → 2026.5.16-beta.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/api.js +4 -4
- package/dist/{approval-handler.runtime-DcgDdi8L.js → approval-handler.runtime--UYE3D2j.js} +5 -6
- package/dist/{approval-ids-DoC2z7tR.js → approval-ids-D6IQvvRE.js} +1 -1
- package/dist/{approval-reaction-auth-BY5VFY-q.js → approval-reaction-auth-99PRu7rF.js} +2 -2
- package/dist/{channel-eRrwLDE9.js → channel-CwN56Pko.js} +285 -26
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{channel.runtime-CsQesLGI.js → channel.runtime-9qwvlUwp.js} +8 -8
- package/dist/{cli-DAMPUa3J.js → cli-BeWdjXLV.js} +15 -17
- package/dist/{cli-metadata-Bt5SrlLo.js → cli-metadata-B2_76YSe.js} +1 -1
- package/dist/cli-metadata.js +1 -1
- package/dist/{client-DrmLRQnw.js → client-D6fFVbNM.js} +2 -2
- package/dist/{client-bootstrap-Ba68NvZB.js → client-bootstrap-DBwUKgC3.js} +3 -3
- package/dist/{client-DBDvsx0D.js → client-oci1tD6-.js} +4 -5
- package/dist/{account-config-LVxGiX7e.js → config-paths-msaDGRh6.js} +18 -1
- package/dist/{config-schema-DOKrNEs_.js → config-schema-BPCzSyjT.js} +70 -4
- package/dist/contract-api.js +5 -6
- package/dist/{create-client-ChlpNpAA.js → create-client-BahCtURn.js} +4 -4
- package/dist/{credentials-DV6fWXhC.js → credentials-DK0lK9cZ.js} +1 -1
- package/dist/{credentials-write.runtime-zniTq-Gr.js → credentials-write.runtime-DhPvBU-C.js} +1 -1
- package/dist/{crypto-runtime-BevaUxax.js → crypto-runtime-B-SPS5mv.js} +5 -5
- package/dist/{directory-live-Btsr0yok.js → directory-live-BCfx1C0G.js} +3 -3
- package/dist/{doctor-qL-bgDwE.js → doctor-KuNYX5N3.js} +3 -3
- package/dist/doctor-contract-api.js +1 -1
- package/dist/{draft-stream-B-hyLmMw.js → draft-stream-BayHVmtO.js} +1 -2
- package/dist/{encryption-guidance-BPi3A_m3.js → encryption-guidance-1QoIvd-g.js} +1 -1
- package/dist/{http-client-C7AeVJay.js → http-client-DS3UoC_p.js} +1 -1
- package/dist/index.js +2 -2
- package/dist/{legacy-crypto-inspector-C4VpBdDV.js → legacy-crypto-inspector-_gWJGVQ_.js} +1 -1
- package/dist/{legacy-crypto-restore-Biw-w2ng.js → legacy-crypto-restore-B9eF1gob.js} +1 -1
- package/dist/{logging-DZHSPP5N.js → logging-bJ8EEe1G.js} +1 -1
- package/dist/{matrix-migration.runtime-CDasos7a.js → matrix-migration.runtime-Cf_wX9mk.js} +3 -3
- package/dist/{media-text-BLL8-Dr3.js → media-text-4h4YwCGC.js} +1 -1
- package/dist/{messages-BJi_jdEA.js → messages-BKTEUSwJ.js} +5 -5
- package/dist/{migration-snapshot.runtime-CKHE3xF9.js → migration-snapshot.runtime-C7yiKWS7.js} +1 -1
- package/dist/{monitor-COvHRaUQ.js → monitor-DPJO3wS1.js} +35 -35
- package/dist/plugin-entry.handlers.runtime.js +2 -2
- package/dist/probe.runtime-zExLz3Ek.js +3 -0
- package/dist/{profile-update-DK5rfmA-.js → profile-update-BAAflurI.js} +2 -3
- package/dist/{reaction-events-Cfvkp-A-.js → reaction-events-Dimh8FUE.js} +6 -6
- package/dist/{resolve-targets-ZSM4KKln.js → resolve-targets-DPqngj4V.js} +1 -1
- package/dist/{resolver.runtime-m_D8JSm3.js → resolver.runtime-C0RDK0VW.js} +1 -1
- package/dist/{route-D6rg-iXN.js → route-R-ajT21_.js} +1 -1
- package/dist/{runtime-api-DTKcXOhp.js → runtime-api-C-QeChQj.js} +1 -1
- package/dist/runtime-api.js +1 -1
- package/dist/runtime-heavy-api.js +2 -2
- package/dist/{sdk-BLBGvKEe.js → sdk-BwfNtBhM.js} +301 -13
- package/dist/secret-contract-api.js +1 -1
- package/dist/{send-D651usmb.js → send-CdoJ1pZY.js} +323 -6
- package/dist/{setup-bootstrap-DT2Gj9hX.js → setup-bootstrap-krQU60Az.js} +4 -4
- package/dist/setup-core-CgOV8zmh.js +675 -0
- package/dist/setup-plugin-api.js +3 -4
- package/dist/{setup-surface-KzA9__US.js → setup-surface-BgUaEySF.js} +7 -10
- package/dist/{config-xD5Y8nFT.js → shared-BlXw87Kp.js} +199 -9
- package/dist/{logger-CnZRVrux.js → startup-abort-br7BZHJQ.js} +32 -1
- package/dist/{startup-verification-Demyp0bP.js → startup-verification-CTfhD7V_.js} +2 -2
- package/dist/{storage-tC3ujLiW.js → storage-HI1nL3im.js} +1 -1
- package/dist/{subagent-hooks-DQbyqq9V.js → subagent-hooks-api-BgQgDwAS.js} +22 -1
- package/dist/subagent-hooks-api.js +1 -22
- package/dist/test-api.js +2 -2
- package/dist/thread-binding-api.js +1 -1
- package/dist/{thread-bindings-DHUszTA0.js → thread-bindings-8AyQOYDT.js} +2 -2
- package/dist/{tool-actions.runtime-Bn8bvkQN.js → tool-actions.runtime-BuCnleVD.js} +9 -9
- package/dist/{verification-BJT2k9TI.js → verification-DvC37Z_y.js} +2 -2
- package/package.json +6 -6
- package/dist/accounts--0L_EuMK.js +0 -130
- package/dist/allowlist-sTzpCn5d.js +0 -68
- package/dist/config-paths-nsVaysCu.js +0 -19
- package/dist/config-update-BBkpLB9o.js +0 -143
- package/dist/direct-management--Y8ypgLv.js +0 -251
- package/dist/direct-room-XkutHjES.js +0 -76
- package/dist/exec-approvals-to3d_jMv.js +0 -196
- package/dist/probe.runtime-sh9piX22.js +0 -3
- package/dist/profile-BlHu0wDX.js +0 -111
- package/dist/recovery-key-store-BTJ6jz5v.js +0 -294
- package/dist/session-store-metadata-DQXjgNLt.js +0 -77
- package/dist/setup-core-C-uKN68n.js +0 -116
- package/dist/setup-dm-policy-0_kFUfW4.js +0 -195
- package/dist/shared-DarXfhzC.js +0 -195
- package/dist/startup-abort-56edvmbM.js +0 -32
- /package/dist/{active-client-uhlxdhEy.js → active-client-DUi-lumi.js} +0 -0
- /package/dist/{approval-reactions-o2_tuH8D.js → approval-reactions-Cwd1PMCC.js} +0 -0
- /package/dist/{async-lock-uQfhfQIY.js → async-lock-SsmtFXtt.js} +0 -0
- /package/dist/{backup-health-Cabu_WQC.js → backup-health-3BHbHxyd.js} +0 -0
- /package/dist/{config-secret-input.runtime-DiKFehsE.js → config-secret-input.runtime-nbLCnJq7.js} +0 -0
- /package/dist/{crypto-node.runtime-pihzdpY7.js → crypto-node.runtime-D9qxgRPa.js} +0 -0
- /package/dist/{deps-DR0MIYrW.js → deps-LqqGWPWt.js} +0 -0
- /package/dist/{device-health-UVYpbA_W.js → device-health-Di9MUzFj.js} +0 -0
- /package/dist/{doctor-contract-D4-64QuJ.js → doctor-contract-s4gUPmRN.js} +0 -0
- /package/dist/{errors-CTcpEDq-.js → errors-BpHgvm2o.js} +0 -0
- /package/dist/{exec-approval-resolver-Bza9Dhlm.js → exec-approval-resolver-C8faS0XB.js} +0 -0
- /package/dist/{migration-snapshot-backup-DaCHTp8C.js → migration-snapshot-backup-BWTIFXgQ.js} +0 -0
- /package/dist/{reaction-common-ejrL19w-.js → reaction-common-B-QgNfEs.js} +0 -0
- /package/dist/{runtime-C6X4h_SJ.js → runtime-lwTSy9Yt.js} +0 -0
- /package/dist/{secret-contract-DcrJWCQI.js → secret-contract-e4SdhUtT.js} +0 -0
- /package/dist/{sync-state-C_beeevA.js → sync-state-Bx0gPaGA.js} +0 -0
- /package/dist/{thread-binding-api-Cq_E-E1K.js → thread-binding-api-Bx55B6hm.js} +0 -0
- /package/dist/{timeout-abort-signal-CtaIaP1v.js → timeout-abort-signal-sT0wAxVn.js} +0 -0
- /package/dist/{url-validation-DiK9j7jz.js → url-validation-CBZBxN3F.js} +0 -0
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
import { i as resolveMatrixAccount, t as listMatrixAccountIds } from "./accounts--0L_EuMK.js";
|
|
2
|
-
import { t as normalizeMatrixApproverId } from "./approval-ids-DoC2z7tR.js";
|
|
3
|
-
import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
4
|
-
import { resolveApprovalRequestChannelAccountId } from "openclaw/plugin-sdk/approval-native-runtime";
|
|
5
|
-
import { createResolvedApproverActionAuthAdapter, resolveApprovalApprovers } from "openclaw/plugin-sdk/approval-auth-runtime";
|
|
6
|
-
import { createChannelExecApprovalProfile, getExecApprovalReplyMetadata, isChannelExecApprovalClientEnabledFromConfig, isChannelExecApprovalTargetRecipient, matchesApprovalRequestFilters } from "openclaw/plugin-sdk/approval-client-runtime";
|
|
7
|
-
import { normalizeAccountId } from "openclaw/plugin-sdk/routing";
|
|
8
|
-
//#region extensions/matrix/src/approval-auth.ts
|
|
9
|
-
function getMatrixApprovalAuthApprovers(params) {
|
|
10
|
-
return resolveApprovalApprovers({
|
|
11
|
-
allowFrom: resolveMatrixAccount(params).config.dm?.allowFrom,
|
|
12
|
-
normalizeApprover: normalizeMatrixApproverId
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
const matrixApprovalAuth = createResolvedApproverActionAuthAdapter({
|
|
16
|
-
channelLabel: "Matrix",
|
|
17
|
-
resolveApprovers: ({ cfg, accountId }) => getMatrixApprovalAuthApprovers({
|
|
18
|
-
cfg,
|
|
19
|
-
accountId
|
|
20
|
-
}),
|
|
21
|
-
normalizeSenderId: (value) => normalizeMatrixApproverId(value)
|
|
22
|
-
});
|
|
23
|
-
//#endregion
|
|
24
|
-
//#region extensions/matrix/src/exec-approvals.ts
|
|
25
|
-
function normalizeMatrixExecApproverId(value) {
|
|
26
|
-
const normalized = normalizeMatrixApproverId(value);
|
|
27
|
-
return normalized === "*" ? void 0 : normalized;
|
|
28
|
-
}
|
|
29
|
-
function resolveMatrixExecApprovalConfig(params) {
|
|
30
|
-
const account = resolveMatrixAccount(params);
|
|
31
|
-
const config = account.config.execApprovals;
|
|
32
|
-
if (!config) return;
|
|
33
|
-
return {
|
|
34
|
-
...config,
|
|
35
|
-
enabled: account.enabled && account.configured ? config.enabled : false
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
function countMatrixExecApprovalEligibleAccounts(params) {
|
|
39
|
-
return listMatrixAccountIds(params.cfg).filter((accountId) => {
|
|
40
|
-
const account = resolveMatrixAccount({
|
|
41
|
-
cfg: params.cfg,
|
|
42
|
-
accountId
|
|
43
|
-
});
|
|
44
|
-
if (!account.enabled || !account.configured) return false;
|
|
45
|
-
const config = resolveMatrixExecApprovalConfig({
|
|
46
|
-
cfg: params.cfg,
|
|
47
|
-
accountId
|
|
48
|
-
});
|
|
49
|
-
const filters = config?.enabled ? {
|
|
50
|
-
agentFilter: config.agentFilter,
|
|
51
|
-
sessionFilter: config.sessionFilter
|
|
52
|
-
} : {
|
|
53
|
-
agentFilter: void 0,
|
|
54
|
-
sessionFilter: void 0
|
|
55
|
-
};
|
|
56
|
-
return isChannelExecApprovalClientEnabledFromConfig({
|
|
57
|
-
enabled: config?.enabled,
|
|
58
|
-
approverCount: getMatrixApprovalApprovers({
|
|
59
|
-
cfg: params.cfg,
|
|
60
|
-
accountId,
|
|
61
|
-
approvalKind: params.approvalKind
|
|
62
|
-
}).length
|
|
63
|
-
}) && matchesApprovalRequestFilters({
|
|
64
|
-
request: params.request.request,
|
|
65
|
-
agentFilter: filters.agentFilter,
|
|
66
|
-
sessionFilter: filters.sessionFilter
|
|
67
|
-
});
|
|
68
|
-
}).length;
|
|
69
|
-
}
|
|
70
|
-
function matchesMatrixRequestAccount(params) {
|
|
71
|
-
const turnSourceChannel = normalizeLowercaseStringOrEmpty(params.request.request.turnSourceChannel);
|
|
72
|
-
const boundAccountId = resolveApprovalRequestChannelAccountId({
|
|
73
|
-
cfg: params.cfg,
|
|
74
|
-
request: params.request,
|
|
75
|
-
channel: "matrix"
|
|
76
|
-
});
|
|
77
|
-
if (turnSourceChannel && turnSourceChannel !== "matrix" && !boundAccountId) return countMatrixExecApprovalEligibleAccounts({
|
|
78
|
-
cfg: params.cfg,
|
|
79
|
-
request: params.request,
|
|
80
|
-
approvalKind: params.approvalKind
|
|
81
|
-
}) <= 1;
|
|
82
|
-
return !boundAccountId || !params.accountId || normalizeAccountId(boundAccountId) === normalizeAccountId(params.accountId);
|
|
83
|
-
}
|
|
84
|
-
function getMatrixExecApprovalApprovers(params) {
|
|
85
|
-
const account = resolveMatrixAccount(params).config;
|
|
86
|
-
return resolveApprovalApprovers({
|
|
87
|
-
explicit: account.execApprovals?.approvers,
|
|
88
|
-
allowFrom: account.dm?.allowFrom,
|
|
89
|
-
normalizeApprover: normalizeMatrixExecApproverId
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
function resolveMatrixApprovalKind(request) {
|
|
93
|
-
return request.id.startsWith("plugin:") ? "plugin" : "exec";
|
|
94
|
-
}
|
|
95
|
-
function getMatrixApprovalApprovers(params) {
|
|
96
|
-
if (params.approvalKind === "plugin") return getMatrixApprovalAuthApprovers({
|
|
97
|
-
cfg: params.cfg,
|
|
98
|
-
accountId: params.accountId
|
|
99
|
-
});
|
|
100
|
-
return getMatrixExecApprovalApprovers(params);
|
|
101
|
-
}
|
|
102
|
-
function isMatrixExecApprovalTargetRecipient(params) {
|
|
103
|
-
return isChannelExecApprovalTargetRecipient({
|
|
104
|
-
...params,
|
|
105
|
-
channel: "matrix",
|
|
106
|
-
normalizeSenderId: normalizeMatrixApproverId,
|
|
107
|
-
matchTarget: ({ target, normalizedSenderId }) => normalizeMatrixApproverId(target.to) === normalizedSenderId
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
const matrixExecApprovalProfile = createChannelExecApprovalProfile({
|
|
111
|
-
resolveConfig: resolveMatrixExecApprovalConfig,
|
|
112
|
-
resolveApprovers: getMatrixExecApprovalApprovers,
|
|
113
|
-
normalizeSenderId: normalizeMatrixApproverId,
|
|
114
|
-
isTargetRecipient: isMatrixExecApprovalTargetRecipient,
|
|
115
|
-
matchesRequestAccount: (params) => matchesMatrixRequestAccount({
|
|
116
|
-
...params,
|
|
117
|
-
approvalKind: "exec"
|
|
118
|
-
})
|
|
119
|
-
});
|
|
120
|
-
const isMatrixExecApprovalClientEnabled = matrixExecApprovalProfile.isClientEnabled;
|
|
121
|
-
matrixExecApprovalProfile.isApprover;
|
|
122
|
-
const isMatrixExecApprovalAuthorizedSender = matrixExecApprovalProfile.isAuthorizedSender;
|
|
123
|
-
const resolveMatrixExecApprovalTarget = matrixExecApprovalProfile.resolveTarget;
|
|
124
|
-
matrixExecApprovalProfile.shouldHandleRequest;
|
|
125
|
-
function isMatrixApprovalClientEnabled(params) {
|
|
126
|
-
if (params.approvalKind === "exec") return isMatrixExecApprovalClientEnabled(params);
|
|
127
|
-
return isChannelExecApprovalClientEnabledFromConfig({
|
|
128
|
-
enabled: resolveMatrixExecApprovalConfig(params)?.enabled,
|
|
129
|
-
approverCount: getMatrixApprovalApprovers(params).length
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
function isMatrixAnyApprovalClientEnabled(params) {
|
|
133
|
-
return isMatrixApprovalClientEnabled({
|
|
134
|
-
...params,
|
|
135
|
-
approvalKind: "exec"
|
|
136
|
-
}) || isMatrixApprovalClientEnabled({
|
|
137
|
-
...params,
|
|
138
|
-
approvalKind: "plugin"
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
function shouldHandleMatrixApprovalRequest(params) {
|
|
142
|
-
const approvalKind = resolveMatrixApprovalKind(params.request);
|
|
143
|
-
if (!matchesMatrixRequestAccount({
|
|
144
|
-
...params,
|
|
145
|
-
approvalKind
|
|
146
|
-
})) return false;
|
|
147
|
-
const config = resolveMatrixExecApprovalConfig(params);
|
|
148
|
-
if (!isChannelExecApprovalClientEnabledFromConfig({
|
|
149
|
-
enabled: config?.enabled,
|
|
150
|
-
approverCount: getMatrixApprovalApprovers({
|
|
151
|
-
...params,
|
|
152
|
-
approvalKind
|
|
153
|
-
}).length
|
|
154
|
-
})) return false;
|
|
155
|
-
return matchesApprovalRequestFilters({
|
|
156
|
-
request: params.request.request,
|
|
157
|
-
agentFilter: config?.agentFilter,
|
|
158
|
-
sessionFilter: config?.sessionFilter
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
function buildFilterCheckRequest(params) {
|
|
162
|
-
if (params.metadata.approvalKind === "plugin") return {
|
|
163
|
-
id: params.metadata.approvalId,
|
|
164
|
-
request: {
|
|
165
|
-
title: "Plugin Approval Required",
|
|
166
|
-
description: "",
|
|
167
|
-
agentId: params.metadata.agentId ?? null,
|
|
168
|
-
sessionKey: params.metadata.sessionKey ?? null
|
|
169
|
-
},
|
|
170
|
-
createdAtMs: 0,
|
|
171
|
-
expiresAtMs: 0
|
|
172
|
-
};
|
|
173
|
-
return {
|
|
174
|
-
id: params.metadata.approvalId,
|
|
175
|
-
request: {
|
|
176
|
-
command: "",
|
|
177
|
-
agentId: params.metadata.agentId ?? null,
|
|
178
|
-
sessionKey: params.metadata.sessionKey ?? null
|
|
179
|
-
},
|
|
180
|
-
createdAtMs: 0,
|
|
181
|
-
expiresAtMs: 0
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
function shouldSuppressLocalMatrixExecApprovalPrompt(params) {
|
|
185
|
-
if (!matrixExecApprovalProfile.shouldSuppressLocalPrompt(params)) return false;
|
|
186
|
-
const metadata = getExecApprovalReplyMetadata(params.payload);
|
|
187
|
-
if (!metadata) return false;
|
|
188
|
-
const request = buildFilterCheckRequest({ metadata });
|
|
189
|
-
return shouldHandleMatrixApprovalRequest({
|
|
190
|
-
cfg: params.cfg,
|
|
191
|
-
accountId: params.accountId,
|
|
192
|
-
request
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
//#endregion
|
|
196
|
-
export { isMatrixExecApprovalAuthorizedSender as a, shouldHandleMatrixApprovalRequest as c, matrixApprovalAuth as d, isMatrixApprovalClientEnabled as i, shouldSuppressLocalMatrixExecApprovalPrompt as l, getMatrixExecApprovalApprovers as n, isMatrixExecApprovalClientEnabled as o, isMatrixAnyApprovalClientEnabled as r, resolveMatrixExecApprovalTarget as s, getMatrixApprovalApprovers as t, getMatrixApprovalAuthApprovers as u };
|
package/dist/profile-BlHu0wDX.js
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-DUslC3ob.js";
|
|
2
|
-
import { normalizeLowercaseStringOrEmpty, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
3
|
-
//#region extensions/matrix/src/matrix/profile.ts
|
|
4
|
-
var profile_exports = /* @__PURE__ */ __exportAll({
|
|
5
|
-
MATRIX_PROFILE_AVATAR_MAX_BYTES: () => MATRIX_PROFILE_AVATAR_MAX_BYTES,
|
|
6
|
-
isMatrixHttpAvatarUri: () => isMatrixHttpAvatarUri,
|
|
7
|
-
isMatrixMxcUri: () => isMatrixMxcUri,
|
|
8
|
-
isSupportedMatrixAvatarSource: () => isSupportedMatrixAvatarSource,
|
|
9
|
-
syncMatrixOwnProfile: () => syncMatrixOwnProfile
|
|
10
|
-
});
|
|
11
|
-
const MATRIX_PROFILE_AVATAR_MAX_BYTES = 10 * 1024 * 1024;
|
|
12
|
-
function isMatrixMxcUri(value) {
|
|
13
|
-
return normalizeLowercaseStringOrEmpty(normalizeOptionalString(value)).startsWith("mxc://");
|
|
14
|
-
}
|
|
15
|
-
function isMatrixHttpAvatarUri(value) {
|
|
16
|
-
const normalized = normalizeLowercaseStringOrEmpty(normalizeOptionalString(value));
|
|
17
|
-
return normalized.startsWith("https://") || normalized.startsWith("http://");
|
|
18
|
-
}
|
|
19
|
-
function isSupportedMatrixAvatarSource(value) {
|
|
20
|
-
return isMatrixMxcUri(value) || isMatrixHttpAvatarUri(value);
|
|
21
|
-
}
|
|
22
|
-
async function uploadAvatarMedia(params) {
|
|
23
|
-
const media = await params.loadAvatar(params.avatarSource, params.avatarMaxBytes);
|
|
24
|
-
return await params.client.uploadContent(media.buffer, media.contentType, media.fileName || "avatar");
|
|
25
|
-
}
|
|
26
|
-
async function resolveAvatarUrl(params) {
|
|
27
|
-
const avatarPath = normalizeOptionalString(params.avatarPath) ?? null;
|
|
28
|
-
if (avatarPath) {
|
|
29
|
-
if (!params.loadAvatarFromPath) throw new Error("Matrix avatar path upload requires a media loader.");
|
|
30
|
-
return {
|
|
31
|
-
resolvedAvatarUrl: await uploadAvatarMedia({
|
|
32
|
-
client: params.client,
|
|
33
|
-
avatarSource: avatarPath,
|
|
34
|
-
avatarMaxBytes: params.avatarMaxBytes,
|
|
35
|
-
loadAvatar: params.loadAvatarFromPath
|
|
36
|
-
}),
|
|
37
|
-
uploadedAvatarSource: "path",
|
|
38
|
-
convertedAvatarFromHttp: false
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
const avatarUrl = normalizeOptionalString(params.avatarUrl) ?? null;
|
|
42
|
-
if (!avatarUrl) return {
|
|
43
|
-
resolvedAvatarUrl: null,
|
|
44
|
-
uploadedAvatarSource: null,
|
|
45
|
-
convertedAvatarFromHttp: false
|
|
46
|
-
};
|
|
47
|
-
if (isMatrixMxcUri(avatarUrl)) return {
|
|
48
|
-
resolvedAvatarUrl: avatarUrl,
|
|
49
|
-
uploadedAvatarSource: null,
|
|
50
|
-
convertedAvatarFromHttp: false
|
|
51
|
-
};
|
|
52
|
-
if (!isMatrixHttpAvatarUri(avatarUrl)) throw new Error("Matrix avatar URL must be an mxc:// URI or an http(s) URL.");
|
|
53
|
-
if (!params.loadAvatarFromUrl) throw new Error("Matrix avatar URL conversion requires a media loader.");
|
|
54
|
-
return {
|
|
55
|
-
resolvedAvatarUrl: await uploadAvatarMedia({
|
|
56
|
-
client: params.client,
|
|
57
|
-
avatarSource: avatarUrl,
|
|
58
|
-
avatarMaxBytes: params.avatarMaxBytes,
|
|
59
|
-
loadAvatar: params.loadAvatarFromUrl
|
|
60
|
-
}),
|
|
61
|
-
uploadedAvatarSource: "http",
|
|
62
|
-
convertedAvatarFromHttp: true
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
async function syncMatrixOwnProfile(params) {
|
|
66
|
-
const desiredDisplayName = normalizeOptionalString(params.displayName) ?? null;
|
|
67
|
-
const avatar = await resolveAvatarUrl({
|
|
68
|
-
client: params.client,
|
|
69
|
-
avatarUrl: params.avatarUrl ?? null,
|
|
70
|
-
avatarPath: params.avatarPath ?? null,
|
|
71
|
-
avatarMaxBytes: params.avatarMaxBytes ?? 10485760,
|
|
72
|
-
loadAvatarFromUrl: params.loadAvatarFromUrl,
|
|
73
|
-
loadAvatarFromPath: params.loadAvatarFromPath
|
|
74
|
-
});
|
|
75
|
-
const desiredAvatarUrl = avatar.resolvedAvatarUrl;
|
|
76
|
-
if (!desiredDisplayName && !desiredAvatarUrl) return {
|
|
77
|
-
skipped: true,
|
|
78
|
-
displayNameUpdated: false,
|
|
79
|
-
avatarUpdated: false,
|
|
80
|
-
resolvedAvatarUrl: null,
|
|
81
|
-
uploadedAvatarSource: avatar.uploadedAvatarSource,
|
|
82
|
-
convertedAvatarFromHttp: avatar.convertedAvatarFromHttp
|
|
83
|
-
};
|
|
84
|
-
let currentDisplayName;
|
|
85
|
-
let currentAvatarUrl;
|
|
86
|
-
try {
|
|
87
|
-
const currentProfile = await params.client.getUserProfile(params.userId);
|
|
88
|
-
currentDisplayName = normalizeOptionalString(currentProfile.displayname);
|
|
89
|
-
currentAvatarUrl = normalizeOptionalString(currentProfile.avatar_url);
|
|
90
|
-
} catch {}
|
|
91
|
-
let displayNameUpdated = false;
|
|
92
|
-
let avatarUpdated = false;
|
|
93
|
-
if (desiredDisplayName && currentDisplayName !== desiredDisplayName) {
|
|
94
|
-
await params.client.setDisplayName(desiredDisplayName);
|
|
95
|
-
displayNameUpdated = true;
|
|
96
|
-
}
|
|
97
|
-
if (desiredAvatarUrl && currentAvatarUrl !== desiredAvatarUrl) {
|
|
98
|
-
await params.client.setAvatarUrl(desiredAvatarUrl);
|
|
99
|
-
avatarUpdated = true;
|
|
100
|
-
}
|
|
101
|
-
return {
|
|
102
|
-
skipped: false,
|
|
103
|
-
displayNameUpdated,
|
|
104
|
-
avatarUpdated,
|
|
105
|
-
resolvedAvatarUrl: desiredAvatarUrl,
|
|
106
|
-
uploadedAvatarSource: avatar.uploadedAvatarSource,
|
|
107
|
-
convertedAvatarFromHttp: avatar.convertedAvatarFromHttp
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
//#endregion
|
|
111
|
-
export { profile_exports as n, syncMatrixOwnProfile as r, isSupportedMatrixAvatarSource as t };
|
|
@@ -1,294 +0,0 @@
|
|
|
1
|
-
import { n as formatMatrixErrorReason, t as formatMatrixErrorMessage } from "./errors-CTcpEDq-.js";
|
|
2
|
-
import { n as LogService } from "./logger-CnZRVrux.js";
|
|
3
|
-
import { loadJsonFile, saveJsonFile } from "openclaw/plugin-sdk/json-store";
|
|
4
|
-
import { decodeRecoveryKey } from "matrix-js-sdk/lib/crypto-api/recovery-key.js";
|
|
5
|
-
//#region extensions/matrix/src/matrix/sdk/idb-persistence-lock.ts
|
|
6
|
-
const MATRIX_IDB_PERSIST_INTERVAL_MS = 6e4;
|
|
7
|
-
const IDB_SNAPSHOT_LOCK_STALE_MS = 5 * 6e4;
|
|
8
|
-
const IDB_SNAPSHOT_LOCK_RETRY_BASE = {
|
|
9
|
-
factor: 2,
|
|
10
|
-
minTimeout: 50,
|
|
11
|
-
maxTimeout: 5e3,
|
|
12
|
-
randomize: true
|
|
13
|
-
};
|
|
14
|
-
function computeRetryDelayMs(retries, attempt) {
|
|
15
|
-
return Math.min(retries.maxTimeout, Math.max(retries.minTimeout, retries.minTimeout * retries.factor ** attempt));
|
|
16
|
-
}
|
|
17
|
-
function computeMinimumRetryWindowMs(retries) {
|
|
18
|
-
let total = 0;
|
|
19
|
-
const attempts = Math.max(1, retries.retries + 1);
|
|
20
|
-
for (let attempt = 0; attempt < attempts - 1; attempt += 1) total += computeRetryDelayMs(retries, attempt);
|
|
21
|
-
return total;
|
|
22
|
-
}
|
|
23
|
-
function resolveRetriesForMinimumWindowMs(retries, minimumWindowMs) {
|
|
24
|
-
const resolved = {
|
|
25
|
-
...retries,
|
|
26
|
-
retries: 0
|
|
27
|
-
};
|
|
28
|
-
while (computeMinimumRetryWindowMs(resolved) < minimumWindowMs) resolved.retries += 1;
|
|
29
|
-
return resolved;
|
|
30
|
-
}
|
|
31
|
-
const MATRIX_IDB_SNAPSHOT_LOCK_OPTIONS = {
|
|
32
|
-
retries: resolveRetriesForMinimumWindowMs(IDB_SNAPSHOT_LOCK_RETRY_BASE, MATRIX_IDB_PERSIST_INTERVAL_MS),
|
|
33
|
-
stale: IDB_SNAPSHOT_LOCK_STALE_MS
|
|
34
|
-
};
|
|
35
|
-
//#endregion
|
|
36
|
-
//#region extensions/matrix/src/matrix/sdk/recovery-key-store.ts
|
|
37
|
-
function isRepairableSecretStorageAccessError(err) {
|
|
38
|
-
const message = formatMatrixErrorReason(err);
|
|
39
|
-
if (!message) return false;
|
|
40
|
-
if (message.includes("getsecretstoragekey callback returned falsey")) return true;
|
|
41
|
-
if (message.includes("decrypting secret") && message.includes("bad mac")) return true;
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
var MatrixRecoveryKeyStore = class {
|
|
45
|
-
constructor(recoveryKeyPath) {
|
|
46
|
-
this.recoveryKeyPath = recoveryKeyPath;
|
|
47
|
-
this.secretStorageKeyCache = /* @__PURE__ */ new Map();
|
|
48
|
-
this.stagedRecoveryKey = null;
|
|
49
|
-
this.stagedRecoveryKeyUsed = false;
|
|
50
|
-
this.stagedCacheKeyIds = /* @__PURE__ */ new Set();
|
|
51
|
-
}
|
|
52
|
-
buildCryptoCallbacks() {
|
|
53
|
-
return {
|
|
54
|
-
getSecretStorageKey: async ({ keys }) => {
|
|
55
|
-
const requestedKeyIds = Object.keys(keys ?? {});
|
|
56
|
-
if (requestedKeyIds.length === 0) return null;
|
|
57
|
-
const staged = this.resolveStagedSecretStorageKey(requestedKeyIds);
|
|
58
|
-
if (staged) return staged;
|
|
59
|
-
for (const keyId of requestedKeyIds) {
|
|
60
|
-
const cached = this.secretStorageKeyCache.get(keyId);
|
|
61
|
-
if (cached) return [keyId, new Uint8Array(cached.key)];
|
|
62
|
-
}
|
|
63
|
-
const stored = this.loadStoredRecoveryKey();
|
|
64
|
-
if (!stored?.privateKeyBase64) return null;
|
|
65
|
-
const privateKey = new Uint8Array(Buffer.from(stored.privateKeyBase64, "base64"));
|
|
66
|
-
if (privateKey.length === 0) return null;
|
|
67
|
-
if (stored.keyId && requestedKeyIds.includes(stored.keyId)) {
|
|
68
|
-
this.rememberSecretStorageKey(stored.keyId, privateKey, stored.keyInfo);
|
|
69
|
-
return [stored.keyId, privateKey];
|
|
70
|
-
}
|
|
71
|
-
const firstRequestedKeyId = requestedKeyIds[0];
|
|
72
|
-
if (!firstRequestedKeyId) return null;
|
|
73
|
-
this.rememberSecretStorageKey(firstRequestedKeyId, privateKey, stored.keyInfo);
|
|
74
|
-
return [firstRequestedKeyId, privateKey];
|
|
75
|
-
},
|
|
76
|
-
cacheSecretStorageKey: (keyId, keyInfo, key) => {
|
|
77
|
-
const privateKey = new Uint8Array(key);
|
|
78
|
-
const normalizedKeyInfo = {
|
|
79
|
-
passphrase: keyInfo?.passphrase,
|
|
80
|
-
name: typeof keyInfo?.name === "string" ? keyInfo.name : void 0
|
|
81
|
-
};
|
|
82
|
-
this.rememberSecretStorageKey(keyId, privateKey, normalizedKeyInfo);
|
|
83
|
-
const stored = this.loadStoredRecoveryKey();
|
|
84
|
-
this.saveRecoveryKeyToDisk({
|
|
85
|
-
keyId,
|
|
86
|
-
keyInfo: normalizedKeyInfo,
|
|
87
|
-
privateKey,
|
|
88
|
-
encodedPrivateKey: stored?.encodedPrivateKey
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
getRecoveryKeySummary() {
|
|
94
|
-
const stored = this.loadStoredRecoveryKey();
|
|
95
|
-
if (!stored) return null;
|
|
96
|
-
return {
|
|
97
|
-
encodedPrivateKey: stored.encodedPrivateKey,
|
|
98
|
-
keyId: stored.keyId,
|
|
99
|
-
createdAt: stored.createdAt
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
resolveEncodedRecoveryKeyInput(params) {
|
|
103
|
-
const encodedPrivateKey = params.encodedPrivateKey.trim();
|
|
104
|
-
if (!encodedPrivateKey) throw new Error("Matrix recovery key is required");
|
|
105
|
-
let privateKey;
|
|
106
|
-
try {
|
|
107
|
-
privateKey = decodeRecoveryKey(encodedPrivateKey);
|
|
108
|
-
} catch (err) {
|
|
109
|
-
throw new Error(`Invalid Matrix recovery key: ${formatMatrixErrorMessage(err)}`, { cause: err });
|
|
110
|
-
}
|
|
111
|
-
const keyId = typeof params.keyId === "string" && params.keyId.trim() ? params.keyId.trim() : null;
|
|
112
|
-
return {
|
|
113
|
-
encodedPrivateKey,
|
|
114
|
-
privateKey,
|
|
115
|
-
keyId,
|
|
116
|
-
keyInfo: params.keyInfo ?? this.loadStoredRecoveryKey()?.keyInfo
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
storeEncodedRecoveryKey(params) {
|
|
120
|
-
const prepared = this.resolveEncodedRecoveryKeyInput(params);
|
|
121
|
-
this.saveRecoveryKeyToDisk({
|
|
122
|
-
keyId: prepared.keyId,
|
|
123
|
-
keyInfo: prepared.keyInfo,
|
|
124
|
-
privateKey: prepared.privateKey,
|
|
125
|
-
encodedPrivateKey: prepared.encodedPrivateKey
|
|
126
|
-
});
|
|
127
|
-
if (prepared.keyId) this.rememberSecretStorageKey(prepared.keyId, prepared.privateKey, prepared.keyInfo);
|
|
128
|
-
return this.getRecoveryKeySummary() ?? {};
|
|
129
|
-
}
|
|
130
|
-
stageEncodedRecoveryKey(params) {
|
|
131
|
-
const prepared = this.resolveEncodedRecoveryKeyInput(params);
|
|
132
|
-
this.discardStagedRecoveryKey();
|
|
133
|
-
this.stagedRecoveryKey = {
|
|
134
|
-
version: 1,
|
|
135
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
136
|
-
keyId: prepared.keyId,
|
|
137
|
-
encodedPrivateKey: prepared.encodedPrivateKey,
|
|
138
|
-
privateKeyBase64: Buffer.from(prepared.privateKey).toString("base64"),
|
|
139
|
-
keyInfo: prepared.keyInfo
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
hasStagedRecoveryKeyBeenUsed() {
|
|
143
|
-
return this.stagedRecoveryKeyUsed;
|
|
144
|
-
}
|
|
145
|
-
commitStagedRecoveryKey(params) {
|
|
146
|
-
if (!this.stagedRecoveryKey) return this.getRecoveryKeySummary();
|
|
147
|
-
const staged = this.stagedRecoveryKey;
|
|
148
|
-
const privateKey = new Uint8Array(Buffer.from(staged.privateKeyBase64, "base64"));
|
|
149
|
-
const keyId = typeof params?.keyId === "string" && params.keyId.trim() ? params.keyId.trim() : staged.keyId;
|
|
150
|
-
this.saveRecoveryKeyToDisk({
|
|
151
|
-
keyId,
|
|
152
|
-
keyInfo: params?.keyInfo ?? staged.keyInfo,
|
|
153
|
-
privateKey,
|
|
154
|
-
encodedPrivateKey: staged.encodedPrivateKey
|
|
155
|
-
});
|
|
156
|
-
this.clearStagedRecoveryKeyTracking();
|
|
157
|
-
return this.getRecoveryKeySummary();
|
|
158
|
-
}
|
|
159
|
-
discardStagedRecoveryKey() {
|
|
160
|
-
for (const keyId of this.stagedCacheKeyIds) this.secretStorageKeyCache.delete(keyId);
|
|
161
|
-
this.clearStagedRecoveryKeyTracking();
|
|
162
|
-
}
|
|
163
|
-
async bootstrapSecretStorageWithRecoveryKey(crypto, options = {}) {
|
|
164
|
-
let status = null;
|
|
165
|
-
const getSecretStorageStatus = crypto.getSecretStorageStatus;
|
|
166
|
-
if (typeof getSecretStorageStatus === "function") try {
|
|
167
|
-
status = await getSecretStorageStatus.call(crypto);
|
|
168
|
-
} catch (err) {
|
|
169
|
-
LogService.warn("MatrixClientLite", "Failed to read secret storage status:", err);
|
|
170
|
-
}
|
|
171
|
-
const hasDefaultSecretStorageKey = Boolean(status?.defaultKeyId);
|
|
172
|
-
const hasKnownInvalidSecrets = Object.values(status?.secretStorageKeyValidityMap ?? {}).some((valid) => !valid);
|
|
173
|
-
let generatedRecoveryKey = false;
|
|
174
|
-
const storedRecovery = this.loadStoredRecoveryKey();
|
|
175
|
-
const stagedRecovery = this.stagedRecoveryKey;
|
|
176
|
-
const sourceRecovery = options.forceNewRecoveryKey === true ? null : stagedRecovery ?? storedRecovery;
|
|
177
|
-
let recoveryKey = sourceRecovery ? {
|
|
178
|
-
keyInfo: sourceRecovery.keyInfo,
|
|
179
|
-
privateKey: new Uint8Array(Buffer.from(sourceRecovery.privateKeyBase64, "base64")),
|
|
180
|
-
encodedPrivateKey: sourceRecovery.encodedPrivateKey
|
|
181
|
-
} : null;
|
|
182
|
-
if (recoveryKey && status?.defaultKeyId) {
|
|
183
|
-
const defaultKeyId = status.defaultKeyId;
|
|
184
|
-
if (!stagedRecovery) {
|
|
185
|
-
this.rememberSecretStorageKey(defaultKeyId, recoveryKey.privateKey, recoveryKey.keyInfo);
|
|
186
|
-
if (storedRecovery && storedRecovery.keyId !== defaultKeyId) this.saveRecoveryKeyToDisk({
|
|
187
|
-
keyId: defaultKeyId,
|
|
188
|
-
keyInfo: recoveryKey.keyInfo,
|
|
189
|
-
privateKey: recoveryKey.privateKey,
|
|
190
|
-
encodedPrivateKey: recoveryKey.encodedPrivateKey
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
const ensureRecoveryKey = async () => {
|
|
195
|
-
if (recoveryKey) {
|
|
196
|
-
if (stagedRecovery) this.stagedRecoveryKeyUsed = true;
|
|
197
|
-
return recoveryKey;
|
|
198
|
-
}
|
|
199
|
-
if (typeof crypto.createRecoveryKeyFromPassphrase !== "function") throw new Error("Matrix crypto backend does not support recovery key generation (createRecoveryKeyFromPassphrase missing)");
|
|
200
|
-
recoveryKey = await crypto.createRecoveryKeyFromPassphrase();
|
|
201
|
-
this.saveRecoveryKeyToDisk(recoveryKey);
|
|
202
|
-
generatedRecoveryKey = true;
|
|
203
|
-
return recoveryKey;
|
|
204
|
-
};
|
|
205
|
-
const shouldRecreateSecretStorage = options.forceNewSecretStorage === true || !hasDefaultSecretStorageKey || !recoveryKey && status?.ready === false || hasKnownInvalidSecrets;
|
|
206
|
-
if (hasKnownInvalidSecrets) recoveryKey = null;
|
|
207
|
-
const secretStorageOptions = { setupNewKeyBackup: options.setupNewKeyBackup === true };
|
|
208
|
-
if (shouldRecreateSecretStorage) {
|
|
209
|
-
secretStorageOptions.setupNewSecretStorage = true;
|
|
210
|
-
secretStorageOptions.createSecretStorageKey = ensureRecoveryKey;
|
|
211
|
-
}
|
|
212
|
-
try {
|
|
213
|
-
await crypto.bootstrapSecretStorage(secretStorageOptions);
|
|
214
|
-
} catch (err) {
|
|
215
|
-
if (!(options.allowSecretStorageRecreateWithoutRecoveryKey === true && hasDefaultSecretStorageKey && isRepairableSecretStorageAccessError(err))) throw err;
|
|
216
|
-
recoveryKey = null;
|
|
217
|
-
LogService.warn("MatrixClientLite", "Secret storage exists on the server but local recovery material cannot unlock it; recreating secret storage during explicit bootstrap.");
|
|
218
|
-
await crypto.bootstrapSecretStorage({
|
|
219
|
-
setupNewSecretStorage: true,
|
|
220
|
-
setupNewKeyBackup: options.setupNewKeyBackup === true,
|
|
221
|
-
createSecretStorageKey: ensureRecoveryKey
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
if (generatedRecoveryKey && this.recoveryKeyPath) LogService.warn("MatrixClientLite", `Generated Matrix recovery key and saved it to ${this.recoveryKeyPath}. Keep this file secure.`);
|
|
225
|
-
}
|
|
226
|
-
clearStagedRecoveryKeyTracking() {
|
|
227
|
-
this.stagedRecoveryKey = null;
|
|
228
|
-
this.stagedRecoveryKeyUsed = false;
|
|
229
|
-
this.stagedCacheKeyIds.clear();
|
|
230
|
-
}
|
|
231
|
-
resolveStagedSecretStorageKey(requestedKeyIds) {
|
|
232
|
-
const staged = this.stagedRecoveryKey;
|
|
233
|
-
if (!staged?.privateKeyBase64) return null;
|
|
234
|
-
const privateKey = new Uint8Array(Buffer.from(staged.privateKeyBase64, "base64"));
|
|
235
|
-
if (privateKey.length === 0) return null;
|
|
236
|
-
const keyId = staged.keyId && requestedKeyIds.includes(staged.keyId) ? staged.keyId : requestedKeyIds[0];
|
|
237
|
-
if (!keyId) return null;
|
|
238
|
-
this.rememberStagedSecretStorageKey(keyId, privateKey, staged.keyInfo);
|
|
239
|
-
this.stagedCacheKeyIds.add(keyId);
|
|
240
|
-
return [keyId, privateKey];
|
|
241
|
-
}
|
|
242
|
-
rememberStagedSecretStorageKey(keyId, key, keyInfo) {
|
|
243
|
-
this.stagedRecoveryKeyUsed = true;
|
|
244
|
-
this.rememberSecretStorageKey(keyId, key, keyInfo);
|
|
245
|
-
}
|
|
246
|
-
rememberSecretStorageKey(keyId, key, keyInfo) {
|
|
247
|
-
if (!keyId.trim()) return;
|
|
248
|
-
this.secretStorageKeyCache.set(keyId, {
|
|
249
|
-
key: new Uint8Array(key),
|
|
250
|
-
keyInfo
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
loadStoredRecoveryKey() {
|
|
254
|
-
if (!this.recoveryKeyPath) return null;
|
|
255
|
-
try {
|
|
256
|
-
const parsed = loadJsonFile(this.recoveryKeyPath);
|
|
257
|
-
if (parsed?.version !== 1 || typeof parsed.createdAt !== "string" || typeof parsed.privateKeyBase64 !== "string" || !parsed.privateKeyBase64.trim()) return null;
|
|
258
|
-
return {
|
|
259
|
-
version: 1,
|
|
260
|
-
createdAt: parsed.createdAt,
|
|
261
|
-
keyId: typeof parsed.keyId === "string" ? parsed.keyId : null,
|
|
262
|
-
encodedPrivateKey: typeof parsed.encodedPrivateKey === "string" ? parsed.encodedPrivateKey : void 0,
|
|
263
|
-
privateKeyBase64: parsed.privateKeyBase64,
|
|
264
|
-
keyInfo: parsed.keyInfo && typeof parsed.keyInfo === "object" ? {
|
|
265
|
-
passphrase: parsed.keyInfo.passphrase,
|
|
266
|
-
name: typeof parsed.keyInfo.name === "string" ? parsed.keyInfo.name : void 0
|
|
267
|
-
} : void 0
|
|
268
|
-
};
|
|
269
|
-
} catch {
|
|
270
|
-
return null;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
saveRecoveryKeyToDisk(params) {
|
|
274
|
-
if (!this.recoveryKeyPath) return;
|
|
275
|
-
try {
|
|
276
|
-
const payload = {
|
|
277
|
-
version: 1,
|
|
278
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
279
|
-
keyId: typeof params.keyId === "string" ? params.keyId : null,
|
|
280
|
-
encodedPrivateKey: params.encodedPrivateKey,
|
|
281
|
-
privateKeyBase64: Buffer.from(params.privateKey).toString("base64"),
|
|
282
|
-
keyInfo: params.keyInfo ? {
|
|
283
|
-
passphrase: params.keyInfo.passphrase,
|
|
284
|
-
name: params.keyInfo.name
|
|
285
|
-
} : void 0
|
|
286
|
-
};
|
|
287
|
-
saveJsonFile(this.recoveryKeyPath, payload);
|
|
288
|
-
} catch (err) {
|
|
289
|
-
LogService.warn("MatrixClientLite", "Failed to persist recovery key:", err);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
};
|
|
293
|
-
//#endregion
|
|
294
|
-
export { MATRIX_IDB_SNAPSHOT_LOCK_OPTIONS as i, isRepairableSecretStorageAccessError as n, MATRIX_IDB_PERSIST_INTERVAL_MS as r, MatrixRecoveryKeyStore as t };
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { a as resolveMatrixTargetIdentity, i as resolveMatrixDirectUserId } from "./target-ids-80nQ2gql.js";
|
|
2
|
-
import { normalizeAccountId } from "openclaw/plugin-sdk/account-id";
|
|
3
|
-
import { addAllowlistUserEntriesFromConfigEntry, buildAllowlistResolutionSummary, canonicalizeAllowlistWithResolvedIds, patchAllowlistUsersInConfigEntries, summarizeMapping } from "openclaw/plugin-sdk/allow-from";
|
|
4
|
-
import { createReplyPrefixOptions, createTypingCallbacks } from "openclaw/plugin-sdk/channel-reply-options-runtime";
|
|
5
|
-
import { formatLocationText, toLocationContext } from "openclaw/plugin-sdk/channel-location";
|
|
6
|
-
import { getAgentScopedMediaLocalRoots } from "openclaw/plugin-sdk/agent-media-payload";
|
|
7
|
-
import { logInboundDrop, logTypingFailure } from "openclaw/plugin-sdk/channel-logging";
|
|
8
|
-
import { buildChannelKeyCandidates, resolveChannelEntryMatch } from "openclaw/plugin-sdk/channel-targets";
|
|
9
|
-
//#region extensions/matrix/src/matrix/monitor/rooms.ts
|
|
10
|
-
function readLegacyRoomAllowAlias(room) {
|
|
11
|
-
const rawRoom = room;
|
|
12
|
-
return typeof rawRoom?.allow === "boolean" ? rawRoom.allow : void 0;
|
|
13
|
-
}
|
|
14
|
-
function resolveMatrixRoomConfig(params) {
|
|
15
|
-
const rooms = params.rooms ?? {};
|
|
16
|
-
const allowlistConfigured = Object.keys(rooms).length > 0;
|
|
17
|
-
const { entry: matched, key: matchedKey, wildcardEntry, wildcardKey } = resolveChannelEntryMatch({
|
|
18
|
-
entries: rooms,
|
|
19
|
-
keys: buildChannelKeyCandidates(params.roomId, `room:${params.roomId}`, ...params.aliases),
|
|
20
|
-
wildcardKey: "*"
|
|
21
|
-
});
|
|
22
|
-
const resolved = matched ?? wildcardEntry;
|
|
23
|
-
const legacyAllow = readLegacyRoomAllowAlias(resolved);
|
|
24
|
-
return {
|
|
25
|
-
allowed: resolved ? resolved.enabled !== false && legacyAllow !== false : false,
|
|
26
|
-
allowlistConfigured,
|
|
27
|
-
config: resolved,
|
|
28
|
-
matchKey: matchedKey ?? wildcardKey,
|
|
29
|
-
matchSource: matched ? "direct" : wildcardEntry ? "wildcard" : void 0
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
//#endregion
|
|
33
|
-
//#region extensions/matrix/src/matrix/session-store-metadata.ts
|
|
34
|
-
function trimMaybeString(value) {
|
|
35
|
-
if (typeof value !== "string") return;
|
|
36
|
-
const trimmed = value.trim();
|
|
37
|
-
return trimmed.length > 0 ? trimmed : void 0;
|
|
38
|
-
}
|
|
39
|
-
function resolveMatrixRoomTargetId(value) {
|
|
40
|
-
const trimmed = trimMaybeString(value);
|
|
41
|
-
if (!trimmed) return;
|
|
42
|
-
const target = resolveMatrixTargetIdentity(trimmed);
|
|
43
|
-
return target?.kind === "room" && target.id.startsWith("!") ? target.id : void 0;
|
|
44
|
-
}
|
|
45
|
-
function resolveMatrixSessionAccountId(value) {
|
|
46
|
-
const trimmed = trimMaybeString(value);
|
|
47
|
-
return trimmed ? normalizeAccountId(trimmed) : void 0;
|
|
48
|
-
}
|
|
49
|
-
function resolveMatrixStoredRoomId(params) {
|
|
50
|
-
return resolveMatrixRoomTargetId(params.deliveryTo) ?? resolveMatrixRoomTargetId(params.lastTo) ?? resolveMatrixRoomTargetId(params.originNativeChannelId) ?? resolveMatrixRoomTargetId(params.originTo);
|
|
51
|
-
}
|
|
52
|
-
function resolveMatrixStoredSessionMeta(entry) {
|
|
53
|
-
if (!entry) return null;
|
|
54
|
-
const channel = trimMaybeString(entry.deliveryContext?.channel) ?? trimMaybeString(entry.lastChannel) ?? trimMaybeString(entry.origin?.provider);
|
|
55
|
-
const accountId = resolveMatrixSessionAccountId(entry.deliveryContext?.accountId ?? entry.lastAccountId ?? entry.origin?.accountId) ?? void 0;
|
|
56
|
-
const roomId = resolveMatrixStoredRoomId({
|
|
57
|
-
deliveryTo: entry.deliveryContext?.to,
|
|
58
|
-
lastTo: entry.lastTo,
|
|
59
|
-
originNativeChannelId: entry.origin?.nativeChannelId,
|
|
60
|
-
originTo: entry.origin?.to
|
|
61
|
-
});
|
|
62
|
-
const chatType = trimMaybeString(entry.origin?.chatType) ?? trimMaybeString(entry.chatType) ?? void 0;
|
|
63
|
-
const directUserId = chatType === "direct" ? trimMaybeString(entry.origin?.nativeDirectUserId) ?? resolveMatrixDirectUserId({
|
|
64
|
-
from: trimMaybeString(entry.origin?.from),
|
|
65
|
-
to: (roomId ? `room:${roomId}` : void 0) ?? trimMaybeString(entry.deliveryContext?.to) ?? trimMaybeString(entry.lastTo) ?? trimMaybeString(entry.origin?.to),
|
|
66
|
-
chatType
|
|
67
|
-
}) : void 0;
|
|
68
|
-
if (!channel && !accountId && !roomId && !directUserId) return null;
|
|
69
|
-
return {
|
|
70
|
-
...channel ? { channel } : {},
|
|
71
|
-
...accountId ? { accountId } : {},
|
|
72
|
-
...roomId ? { roomId } : {},
|
|
73
|
-
...directUserId ? { directUserId } : {}
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
//#endregion
|
|
77
|
-
export { canonicalizeAllowlistWithResolvedIds as a, formatLocationText as c, logTypingFailure as d, patchAllowlistUsersInConfigEntries as f, buildAllowlistResolutionSummary as i, getAgentScopedMediaLocalRoots as l, toLocationContext as m, resolveMatrixRoomConfig as n, createReplyPrefixOptions as o, summarizeMapping as p, addAllowlistUserEntriesFromConfigEntry as r, createTypingCallbacks as s, resolveMatrixStoredSessionMeta as t, logInboundDrop as u };
|