Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 625e03c

Browse files
committed
allow customising the source of dehydration key
1 parent dbf2394 commit 625e03c

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/MatrixClientPeg.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import * as StorageManager from './utils/StorageManager';
3434
import IdentityAuthClient from './IdentityAuthClient';
3535
import { crossSigningCallbacks, tryToUnlockSecretStorageWithDehydrationKey } from './SecurityManager';
3636
import {SHOW_QR_CODE_METHOD} from "matrix-js-sdk/src/crypto/verification/QRCode";
37+
import SecurityCustomisations from "./customisations/Security";
3738

3839
export interface IMatrixClientCreds {
3940
homeserverUrl: string;
@@ -273,7 +274,10 @@ class _MatrixClientPeg implements IMatrixClientPeg {
273274
// These are always installed regardless of the labs flag so that
274275
// cross-signing features can toggle on without reloading and also be
275276
// accessed immediately after login.
276-
Object.assign(opts.cryptoCallbacks, crossSigningCallbacks);
277+
const customisatedCallbacks = {
278+
getDehydrationKey: SecurityCustomisations.getDehydrationKey,
279+
};
280+
Object.assign(opts.cryptoCallbacks, crossSigningCallbacks, customisatedCallbacks);
277281

278282
this.matrixClient = createMatrixClient(opts);
279283

src/customisations/Security.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ function getSecretStorageKey(): Uint8Array {
4444
return null;
4545
}
4646

47+
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
48+
function getDehydrationKey(
49+
keyInfo: ISecretStorageKeyInfo,
50+
): Promise<Uint8Array> {
51+
return Promise.resolve(null);
52+
}
53+
4754
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
4855
function catchAccessSecretStorageError(e: Error): void {
4956
// E.g. notify the user in some way
@@ -74,6 +81,9 @@ export interface ISecurityCustomisations {
7481
setupEncryptionNeeded?: (
7582
kind: SetupEncryptionKind,
7683
) => boolean,
84+
getDehydrationKey?: (
85+
keyInfo: ISecretStorageKeyInfo,
86+
) => Promise<Uint8Array>,
7787
}
7888

7989
// A real customisation module will define and export one or more of the

0 commit comments

Comments
 (0)