index : matrix-js-sdk

My fork of matrix-js-sdk

diff options
context:
space:
mode:
authorBruno Windels <[email protected]>2020-06-18 15:06:34 +0200
committerBruno Windels <[email protected]>2020-06-18 15:06:56 +0200
commitf62049559cfa0320344c3236568f2b8c3c281751 (patch)
tree79c22e5578a26673e53d7db85495d047196fdad0
parent1fe9dd03a3f45fe5655f9a647c3205d19b9cd936 (diff)
downloadmatrix-js-sdk-f62049559cfa0320344c3236568f2b8c3c281751.tar.gz
make authUploadDeviceSigningKeys required, as default is only used by tests
and make tests pass {} instead of undefined for authDict as otherwise we'll enter in the "obtain flows" mode and not add the keys to the builder
-rw-r--r--spec/unit/crypto/cross-signing.spec.js5
-rw-r--r--spec/unit/crypto/secrets.spec.js18
-rw-r--r--src/crypto/index.js6
3 files changed, 21 insertions, 8 deletions
diff --git a/spec/unit/crypto/cross-signing.spec.js b/spec/unit/crypto/cross-signing.spec.js
index a15239a0..7f24d1c7 100644
--- a/spec/unit/crypto/cross-signing.spec.js
+++ b/spec/unit/crypto/cross-signing.spec.js
@@ -70,7 +70,10 @@ describe("Cross Signing", function() {
alice.setAccountData = async () => {};
alice.getAccountDataFromServer = async () => {};
// set Alice's cross-signing key
- await alice.bootstrapSecretStorage({createSecretStorageKey});
+ await alice.bootstrapSecretStorage({
+ createSecretStorageKey,
+ authUploadDeviceSigningKeys: async func => await func({}),
+ });
expect(alice.uploadDeviceSigningKeys).toHaveBeenCalled();
});
diff --git a/spec/unit/crypto/secrets.spec.js b/spec/unit/crypto/secrets.spec.js
index 74748667..ceb01e71 100644
--- a/spec/unit/crypto/secrets.spec.js
+++ b/spec/unit/crypto/secrets.spec.js
@@ -326,7 +326,10 @@ describe("Secrets", function() {
this.emit("accountData", event);
};
- await bob.bootstrapSecretStorage({createSecretStorageKey});
+ await bob.bootstrapSecretStorage({
+ createSecretStorageKey,
+ authUploadDeviceSigningKeys: async func => await func({}),
+ });
const crossSigning = bob._crypto._crossSigningInfo;
const secretStorage = bob._crypto._secretStorage;
@@ -382,6 +385,7 @@ describe("Secrets", function() {
keyInfo: { pubkey: storagePublicKey },
privateKey: storagePrivateKey,
}),
+ authUploadDeviceSigningKeys: async func => await func({}),
});
// Clear local cross-signing keys and read from secret storage
@@ -390,7 +394,9 @@ describe("Secrets", function() {
crossSigning.toStorage(),
);
crossSigning.keys = {};
- await bob.bootstrapSecretStorage();
+ await bob.bootstrapSecretStorage({
+ authUploadDeviceSigningKeys: async func => await func({}),
+ });
expect(crossSigning.getId()).toBeTruthy();
expect(await crossSigning.isStoredInSecretStorage(secretStorage))
@@ -511,7 +517,9 @@ describe("Secrets", function() {
this.emit("accountData", event);
};
- await alice.bootstrapSecretStorage();
+ await alice.bootstrapSecretStorage({
+ authUploadDeviceSigningKeys: async func => await func({}),
+ });
expect(alice.getAccountData("m.secret_storage.default_key").getContent())
.toEqual({key: "key_id"});
@@ -651,7 +659,9 @@ describe("Secrets", function() {
this.emit("accountData", event);
};
- await alice.bootstrapSecretStorage();
+ await alice.bootstrapSecretStorage({
+ authUploadDeviceSigningKeys: async func => await func({}),
+ });
const backupKey = alice.getAccountData("m.megolm_backup.v1")
.getContent();
diff --git a/src/crypto/index.js b/src/crypto/index.js
index f2a37260..37083302 100644
--- a/src/crypto/index.js
+++ b/src/crypto/index.js
@@ -449,11 +449,11 @@ Crypto.prototype.isCrossSigningReady = async function() {
* - migrates Secure Secret Storage to use the latest algorithm, if an outdated
* algorithm is found
*
- * @param {function} [opts.authUploadDeviceSigningKeys] Optional. Function
+ * @param {function} opts.authUploadDeviceSigningKeys Function
* called to await an interactive auth flow when uploading device signing keys.
* Args:
* {function} A function that makes the request requiring auth. Receives the
- * auth data as an object.
+ * auth data as an object. Can be called multiple times, first with an empty authDict, to obtain the flows.
* @param {function} [opts.createSecretStorageKey] Optional. Function
* called to await a secret storage key creation flow.
* Returns:
@@ -475,7 +475,7 @@ Crypto.prototype.isCrossSigningReady = async function() {
*/
Crypto.prototype.bootstrapSecretStorage = async function({
- authUploadDeviceSigningKeys = async func => await func(),
+ authUploadDeviceSigningKeys,
createSecretStorageKey = async () => ({ }),
keyBackupInfo,
setupNewKeyBackup,