fix(matrix): handle missing secret storage facade · openclaw/openclaw@5c5a8a4
vincentkoc
·
2026-06-22
·
via Recent Commits to openclaw:main
File tree
extensions/matrix/src/matrix
| Original file line number | Diff line number | Diff line change |
|---|
@@ -485,11 +485,28 @@ export class MatrixClient {
|
485 | 485 | getUserId: () => this.getUserId(), |
486 | 486 | getPassword: () => this.password, |
487 | 487 | canUnlockSecretStorage: async () => { |
488 | | -const defaultKeyId = await this.client.secretStorage.getDefaultKeyId(); |
| 488 | +const secretStorage = ( |
| 489 | +this.client as { |
| 490 | +secretStorage?: Partial< |
| 491 | +Pick<MatrixJsClient["secretStorage"], "checkKey" | "getDefaultKeyId" | "getKey"> |
| 492 | +>; |
| 493 | +} |
| 494 | +).secretStorage; |
| 495 | +// Partial test/runtime facades can omit secretStorage; forced reset must fail closed |
| 496 | +// without turning missing recovery access into a noisy caught TypeError. |
| 497 | +if ( |
| 498 | +!secretStorage || |
| 499 | +typeof secretStorage.getDefaultKeyId !== "function" || |
| 500 | +typeof secretStorage.getKey !== "function" || |
| 501 | +typeof secretStorage.checkKey !== "function" |
| 502 | +) { |
| 503 | +return false; |
| 504 | +} |
| 505 | +const defaultKeyId = await secretStorage.getDefaultKeyId(); |
489 | 506 | if (!defaultKeyId) { |
490 | 507 | return false; |
491 | 508 | } |
492 | | -const keyTuple = await this.client.secretStorage.getKey(defaultKeyId); |
| 509 | +const keyTuple = await secretStorage.getKey(defaultKeyId); |
493 | 510 | const key = this.recoveryKeyStore.getSecretStorageKeyCandidate(defaultKeyId); |
494 | 511 | if (!keyTuple || !key) { |
495 | 512 | return false; |
@@ -498,7 +515,7 @@ export class MatrixClient {
|
498 | 515 | if (!keyInfo.iv?.trim() || !keyInfo.mac?.trim()) { |
499 | 516 | return false; |
500 | 517 | } |
501 | | -return await this.client.secretStorage.checkKey(key, keyInfo); |
| 518 | +return await secretStorage.checkKey(key, keyInfo); |
502 | 519 | }, |
503 | 520 | getDeviceId: () => this.client.getDeviceId(), |
504 | 521 | verificationManager: this.verificationManager, |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。