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

Commit 067b4ca

Browse files
authored
Merge pull request #5397 from matrix-org/bwindels/customise-dehydration-key
Add customisation point for dehydration key
2 parents 971ade5 + 41cb51e commit 067b4ca

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-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;
@@ -291,7 +292,10 @@ class _MatrixClientPeg implements IMatrixClientPeg {
291292
// These are always installed regardless of the labs flag so that
292293
// cross-signing features can toggle on without reloading and also be
293294
// accessed immediately after login.
294-
Object.assign(opts.cryptoCallbacks, crossSigningCallbacks);
295+
const customisedCallbacks = {
296+
getDehydrationKey: SecurityCustomisations.getDehydrationKey,
297+
};
298+
Object.assign(opts.cryptoCallbacks, crossSigningCallbacks, customisedCallbacks);
295299

296300
this.matrixClient = createMatrixClient(opts);
297301

src/customisations/Security.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ limitations under the License.
1616

1717
import { IMatrixClientCreds } from "../MatrixClientPeg";
1818
import { Kind as SetupEncryptionKind } from "../toasts/SetupEncryptionToast";
19+
import { ISecretStorageKeyInfo } from 'matrix-js-sdk/src/matrix';
1920

2021
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
2122
function examineLoginResponse(
@@ -44,6 +45,13 @@ function getSecretStorageKey(): Uint8Array {
4445
return null;
4546
}
4647

48+
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
49+
function getDehydrationKey(
50+
keyInfo: ISecretStorageKeyInfo,
51+
): Promise<Uint8Array> {
52+
return Promise.resolve(null);
53+
}
54+
4755
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
4856
function catchAccessSecretStorageError(e: Error): void {
4957
// E.g. notify the user in some way
@@ -74,6 +82,9 @@ export interface ISecurityCustomisations {
7482
setupEncryptionNeeded?: (
7583
kind: SetupEncryptionKind,
7684
) => boolean,
85+
getDehydrationKey?: (
86+
keyInfo: ISecretStorageKeyInfo,
87+
) => Promise<Uint8Array>,
7788
}
7889

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

0 commit comments

Comments
 (0)