diff --git a/package.json b/package.json index a26a0c0ebc7..3b5f4f741e6 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ ], "dependencies": { "@babel/runtime": "^7.12.5", - "@matrix-org/matrix-sdk-crypto-wasm": "^2.2.0", + "@matrix-org/matrix-sdk-crypto-wasm": "^3.0.1", "another-json": "^0.2.0", "bs58": "^5.0.0", "content-type": "^1.0.4", diff --git a/spec/unit/rust-crypto/OutgoingRequestProcessor.spec.ts b/spec/unit/rust-crypto/OutgoingRequestProcessor.spec.ts index da8dc37a6ee..3501ec8faed 100644 --- a/spec/unit/rust-crypto/OutgoingRequestProcessor.spec.ts +++ b/spec/unit/rust-crypto/OutgoingRequestProcessor.spec.ts @@ -24,7 +24,7 @@ import { KeysUploadRequest, RoomMessageRequest, SignatureUploadRequest, - SigningKeysUploadRequest, + UploadSigningKeysRequest, ToDeviceRequest, } from "@matrix-org/matrix-sdk-crypto-wasm"; @@ -173,10 +173,10 @@ describe("OutgoingRequestProcessor", () => { httpBackend.verifyNoOutstandingRequests(); }); - it("should handle SigningKeysUploadRequests without UIA", async () => { + it("should handle UploadSigningKeysRequest without UIA", async () => { // first, mock up a request as we might expect to receive it from the Rust layer ... const testReq = { foo: "bar" }; - const outgoingRequest = new SigningKeysUploadRequest(JSON.stringify(testReq)); + const outgoingRequest = new UploadSigningKeysRequest(JSON.stringify(testReq)); // ... then poke the request into the OutgoingRequestProcessor under test const reqProm = processor.makeOutgoingRequest(outgoingRequest); @@ -200,10 +200,10 @@ describe("OutgoingRequestProcessor", () => { httpBackend.verifyNoOutstandingRequests(); }); - it("should handle SigningKeysUploadRequests with UIA", async () => { + it("should handle UploadSigningKeysRequest with UIA", async () => { // first, mock up a request as we might expect to receive it from the Rust layer ... const testReq = { foo: "bar" }; - const outgoingRequest = new SigningKeysUploadRequest(JSON.stringify(testReq)); + const outgoingRequest = new UploadSigningKeysRequest(JSON.stringify(testReq)); // also create a UIA callback const authCallback: UIAuthCallback = async (makeRequest) => { diff --git a/src/rust-crypto/CrossSigningIdentity.ts b/src/rust-crypto/CrossSigningIdentity.ts index 981fe8ec672..8598dab6152 100644 --- a/src/rust-crypto/CrossSigningIdentity.ts +++ b/src/rust-crypto/CrossSigningIdentity.ts @@ -14,12 +14,12 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { OlmMachine, CrossSigningStatus } from "@matrix-org/matrix-sdk-crypto-wasm"; +import { OlmMachine, CrossSigningStatus, CrossSigningBootstrapRequests } from "@matrix-org/matrix-sdk-crypto-wasm"; import * as RustSdkCryptoJs from "@matrix-org/matrix-sdk-crypto-wasm"; import { BootstrapCrossSigningOpts } from "../crypto-api"; import { logger } from "../logger"; -import { OutgoingRequest, OutgoingRequestProcessor } from "./OutgoingRequestProcessor"; +import { OutgoingRequestProcessor } from "./OutgoingRequestProcessor"; import { UIAuthCallback } from "../interactive-auth"; import { ServerSideSecretStorage } from "../secret-storage"; @@ -118,7 +118,7 @@ export class CrossSigningIdentity { private async resetCrossSigning(authUploadDeviceSigningKeys?: UIAuthCallback): Promise { // XXX: We must find a way to make this atomic, currently if the user does not remember his account password // or 4S passphrase/key the process will fail in a bad state, with keys rotated but not uploaded or saved in 4S. - const outgoingRequests: Array = await this.olmMachine.bootstrapCrossSigning(true); + const outgoingRequests: CrossSigningBootstrapRequests = await this.olmMachine.bootstrapCrossSigning(true); // If 4S is configured we need to udpate it. if (await this.secretStorage.hasKey()) { @@ -128,8 +128,14 @@ export class CrossSigningIdentity { await this.exportCrossSigningKeysToStorage(); } logger.log("bootStrapCrossSigning: publishing keys to server"); - for (const req of outgoingRequests) { - await this.outgoingRequestProcessor.makeOutgoingRequest(req, authUploadDeviceSigningKeys); + for (const req of [ + outgoingRequests.uploadKeysRequest, + outgoingRequests.uploadSigningKeysRequest, + outgoingRequests.uploadSignaturesRequest, + ]) { + if (req) { + await this.outgoingRequestProcessor.makeOutgoingRequest(req, authUploadDeviceSigningKeys); + } } } diff --git a/src/rust-crypto/OutgoingRequestProcessor.ts b/src/rust-crypto/OutgoingRequestProcessor.ts index 335e11a2638..1fbd2d643c6 100644 --- a/src/rust-crypto/OutgoingRequestProcessor.ts +++ b/src/rust-crypto/OutgoingRequestProcessor.ts @@ -23,7 +23,7 @@ import { RoomMessageRequest, SignatureUploadRequest, ToDeviceRequest, - SigningKeysUploadRequest, + UploadSigningKeysRequest, } from "@matrix-org/matrix-sdk-crypto-wasm"; import { logger } from "../logger"; @@ -62,7 +62,7 @@ export class OutgoingRequestProcessor { ) {} public async makeOutgoingRequest( - msg: OutgoingRequest | SigningKeysUploadRequest, + msg: OutgoingRequest | UploadSigningKeysRequest, uiaCallback?: UIAuthCallback, ): Promise { let resp: string; @@ -92,7 +92,7 @@ export class OutgoingRequestProcessor { `/_matrix/client/v3/rooms/${encodeURIComponent(msg.room_id)}/send/` + `${encodeURIComponent(msg.event_type)}/${encodeURIComponent(msg.txn_id)}`; resp = await this.rawJsonRequest(Method.Put, path, {}, msg.body); - } else if (msg instanceof SigningKeysUploadRequest) { + } else if (msg instanceof UploadSigningKeysRequest) { await this.makeRequestWithUIA( Method.Post, "/_matrix/client/v3/keys/device_signing/upload", diff --git a/yarn.lock b/yarn.lock index afef1640151..6e6ea3a0dfc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1590,10 +1590,10 @@ "@jridgewell/resolve-uri" "^3.1.0" "@jridgewell/sourcemap-codec" "^1.4.14" -"@matrix-org/matrix-sdk-crypto-wasm@^2.2.0": - version "2.2.0" - resolved "https://registry.yarnpkg.com/@matrix-org/matrix-sdk-crypto-wasm/-/matrix-sdk-crypto-wasm-2.2.0.tgz#7c60afe01915281a6b71502821bc8e01afbfa70d" - integrity sha512-txmvaTiZpVV0/kWCRcE7tZvRESCEc1ynLJDVh9OUsFlaXfl13c7qdD3E6IJEJ8YiPMIn+PHogdfBZsO84reaMg== +"@matrix-org/matrix-sdk-crypto-wasm@^3.0.1": + version "3.0.1" + resolved "https://registry.yarnpkg.com/@matrix-org/matrix-sdk-crypto-wasm/-/matrix-sdk-crypto-wasm-3.0.1.tgz#56a0376f8a389264bcf4d5325b378a71f18b7664" + integrity sha512-r0PBfUKlLHm67+fpIV21netX5+DujbY2XjJy7JUGJ55oW4XWBNbSf9vElfaQkrdt/iDscL/8I5PoD5lCuVW6zA== "@matrix-org/olm@3.2.15": version "3.2.15"