Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump matrix-sdk-crypto-wasm to 3.0.1 #3849

Merged
merged 5 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.0",
"another-json": "^0.2.0",
"bs58": "^5.0.0",
"content-type": "^1.0.4",
Expand Down
19 changes: 14 additions & 5 deletions src/rust-crypto/CrossSigningIdentity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -118,7 +118,7 @@ export class CrossSigningIdentity {
private async resetCrossSigning(authUploadDeviceSigningKeys?: UIAuthCallback<void>): Promise<void> {
// 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<OutgoingRequest> = 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()) {
Expand All @@ -128,8 +128,17 @@ 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(
outgoingRequests.uploadKeysRequest,
authUploadDeviceSigningKeys,
);
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/rust-crypto/OutgoingRequestProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
RoomMessageRequest,
SignatureUploadRequest,
ToDeviceRequest,
SigningKeysUploadRequest,
UploadSigningKeysRequest,
} from "@matrix-org/matrix-sdk-crypto-wasm";

import { logger } from "../logger";
Expand Down Expand Up @@ -62,7 +62,7 @@
) {}

public async makeOutgoingRequest<T>(
msg: OutgoingRequest | SigningKeysUploadRequest,
msg: OutgoingRequest | UploadSigningKeysRequest,
uiaCallback?: UIAuthCallback<T>,
): Promise<void> {
let resp: string;
Expand Down Expand Up @@ -92,7 +92,7 @@
`/_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",
Expand All @@ -103,7 +103,7 @@
// SigningKeysUploadRequest does not implement OutgoingRequest and does not need to be marked as sent.
return;
} else {
logger.warn("Unsupported outgoing message", Object.getPrototypeOf(msg));

Check failure on line 106 in src/rust-crypto/OutgoingRequestProcessor.ts

View workflow job for this annotation

GitHub Actions / Jest [integ] (Node 18)

crypto (rust-sdk) › Secret Storage and Key Backup › bootstrapSecretStorage › should upload cross signing keys

TypeError: Cannot convert undefined or null to object at Function.getPrototypeOf (<anonymous>) at OutgoingRequestProcessor.getPrototypeOf [as makeOutgoingRequest] (src/rust-crypto/OutgoingRequestProcessor.ts:106:64) at CrossSigningIdentity.makeOutgoingRequest [as resetCrossSigning] (src/rust-crypto/CrossSigningIdentity.ts:137:53) at CrossSigningIdentity.bootstrapCrossSigning (src/rust-crypto/CrossSigningIdentity.ts:102:17) at RustCrypto.bootstrapCrossSigning (src/rust-crypto/rust-crypto.ts:667:9) at Object.<anonymous> (spec/integ/crypto/crypto.spec.ts:2714:17)

Check failure on line 106 in src/rust-crypto/OutgoingRequestProcessor.ts

View workflow job for this annotation

GitHub Actions / Jest [integ] (Node 18)

crypto (rust-sdk) › Secret Storage and Key Backup › bootstrapSecretStorage › should create a new megolm backup

TypeError: Cannot convert undefined or null to object at Function.getPrototypeOf (<anonymous>) at OutgoingRequestProcessor.getPrototypeOf [as makeOutgoingRequest] (src/rust-crypto/OutgoingRequestProcessor.ts:106:64) at CrossSigningIdentity.makeOutgoingRequest [as resetCrossSigning] (src/rust-crypto/CrossSigningIdentity.ts:137:53) at CrossSigningIdentity.bootstrapCrossSigning (src/rust-crypto/CrossSigningIdentity.ts:102:17) at RustCrypto.bootstrapCrossSigning (src/rust-crypto/rust-crypto.ts:667:9) at bootstrapSecurity (spec/integ/crypto/crypto.spec.ts:2586:13) at Object.<anonymous> (spec/integ/crypto/crypto.spec.ts:2745:17)

Check failure on line 106 in src/rust-crypto/OutgoingRequestProcessor.ts

View workflow job for this annotation

GitHub Actions / Jest [integ] (Node 18)

crypto (rust-sdk) › Secret Storage and Key Backup › Manage Key Backup › Should be able to restore from 4S after bootstrap

TypeError: Cannot convert undefined or null to object at Function.getPrototypeOf (<anonymous>) at OutgoingRequestProcessor.getPrototypeOf [as makeOutgoingRequest] (src/rust-crypto/OutgoingRequestProcessor.ts:106:64) at CrossSigningIdentity.makeOutgoingRequest [as resetCrossSigning] (src/rust-crypto/CrossSigningIdentity.ts:137:53) at CrossSigningIdentity.bootstrapCrossSigning (src/rust-crypto/CrossSigningIdentity.ts:102:17) at RustCrypto.bootstrapCrossSigning (src/rust-crypto/rust-crypto.ts:667:9) at bootstrapSecurity (spec/integ/crypto/crypto.spec.ts:2586:13) at Object.<anonymous> (spec/integ/crypto/crypto.spec.ts:2774:17)

Check failure on line 106 in src/rust-crypto/OutgoingRequestProcessor.ts

View workflow job for this annotation

GitHub Actions / Jest [integ] (Node 18)

crypto (rust-sdk) › Secret Storage and Key Backup › Manage Key Backup › Reset key backup should create a new backup and update 4S

TypeError: Cannot convert undefined or null to object at Function.getPrototypeOf (<anonymous>) at OutgoingRequestProcessor.getPrototypeOf [as makeOutgoingRequest] (src/rust-crypto/OutgoingRequestProcessor.ts:106:64) at CrossSigningIdentity.makeOutgoingRequest [as resetCrossSigning] (src/rust-crypto/CrossSigningIdentity.ts:137:53) at CrossSigningIdentity.bootstrapCrossSigning (src/rust-crypto/CrossSigningIdentity.ts:102:17) at RustCrypto.bootstrapCrossSigning (src/rust-crypto/rust-crypto.ts:667:9) at bootstrapSecurity (spec/integ/crypto/crypto.spec.ts:2586:13) at Object.<anonymous> (spec/integ/crypto/crypto.spec.ts:2820:17)

Check failure on line 106 in src/rust-crypto/OutgoingRequestProcessor.ts

View workflow job for this annotation

GitHub Actions / Jest [integ] (Node latest)

crypto (rust-sdk) › Secret Storage and Key Backup › bootstrapSecretStorage › should upload cross signing keys

TypeError: Cannot convert undefined or null to object at Function.getPrototypeOf (<anonymous>) at OutgoingRequestProcessor.getPrototypeOf [as makeOutgoingRequest] (src/rust-crypto/OutgoingRequestProcessor.ts:106:64) at CrossSigningIdentity.makeOutgoingRequest [as resetCrossSigning] (src/rust-crypto/CrossSigningIdentity.ts:137:53) at CrossSigningIdentity.bootstrapCrossSigning (src/rust-crypto/CrossSigningIdentity.ts:102:17) at RustCrypto.bootstrapCrossSigning (src/rust-crypto/rust-crypto.ts:667:9) at Object.<anonymous> (spec/integ/crypto/crypto.spec.ts:2714:17)

Check failure on line 106 in src/rust-crypto/OutgoingRequestProcessor.ts

View workflow job for this annotation

GitHub Actions / Jest [integ] (Node latest)

crypto (rust-sdk) › Secret Storage and Key Backup › bootstrapSecretStorage › should create a new megolm backup

TypeError: Cannot convert undefined or null to object at Function.getPrototypeOf (<anonymous>) at OutgoingRequestProcessor.getPrototypeOf [as makeOutgoingRequest] (src/rust-crypto/OutgoingRequestProcessor.ts:106:64) at CrossSigningIdentity.makeOutgoingRequest [as resetCrossSigning] (src/rust-crypto/CrossSigningIdentity.ts:137:53) at CrossSigningIdentity.bootstrapCrossSigning (src/rust-crypto/CrossSigningIdentity.ts:102:17) at RustCrypto.bootstrapCrossSigning (src/rust-crypto/rust-crypto.ts:667:9) at bootstrapSecurity (spec/integ/crypto/crypto.spec.ts:2586:13) at Object.<anonymous> (spec/integ/crypto/crypto.spec.ts:2745:17)

Check failure on line 106 in src/rust-crypto/OutgoingRequestProcessor.ts

View workflow job for this annotation

GitHub Actions / Jest [integ] (Node latest)

crypto (rust-sdk) › Secret Storage and Key Backup › Manage Key Backup › Should be able to restore from 4S after bootstrap

TypeError: Cannot convert undefined or null to object at Function.getPrototypeOf (<anonymous>) at OutgoingRequestProcessor.getPrototypeOf [as makeOutgoingRequest] (src/rust-crypto/OutgoingRequestProcessor.ts:106:64) at CrossSigningIdentity.makeOutgoingRequest [as resetCrossSigning] (src/rust-crypto/CrossSigningIdentity.ts:137:53) at CrossSigningIdentity.bootstrapCrossSigning (src/rust-crypto/CrossSigningIdentity.ts:102:17) at RustCrypto.bootstrapCrossSigning (src/rust-crypto/rust-crypto.ts:667:9) at bootstrapSecurity (spec/integ/crypto/crypto.spec.ts:2586:13) at Object.<anonymous> (spec/integ/crypto/crypto.spec.ts:2774:17)

Check failure on line 106 in src/rust-crypto/OutgoingRequestProcessor.ts

View workflow job for this annotation

GitHub Actions / Jest [integ] (Node latest)

crypto (rust-sdk) › Secret Storage and Key Backup › Manage Key Backup › Reset key backup should create a new backup and update 4S

TypeError: Cannot convert undefined or null to object at Function.getPrototypeOf (<anonymous>) at OutgoingRequestProcessor.getPrototypeOf [as makeOutgoingRequest] (src/rust-crypto/OutgoingRequestProcessor.ts:106:64) at CrossSigningIdentity.makeOutgoingRequest [as resetCrossSigning] (src/rust-crypto/CrossSigningIdentity.ts:137:53) at CrossSigningIdentity.bootstrapCrossSigning (src/rust-crypto/CrossSigningIdentity.ts:102:17) at RustCrypto.bootstrapCrossSigning (src/rust-crypto/rust-crypto.ts:667:9) at bootstrapSecurity (spec/integ/crypto/crypto.spec.ts:2586:13) at Object.<anonymous> (spec/integ/crypto/crypto.spec.ts:2820:17)
resp = "";
}

Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@matrix-org/matrix-sdk-crypto-wasm/-/matrix-sdk-crypto-wasm-3.0.0.tgz#d2a20c964009791d1982ed365d4d80ad029d0176"
integrity sha512-3uswyBfqmkflESmLDgoUeqUY5UkW4ZzyNWK45gZWHzpgsPs/yZNFbk5/dMMb7jw7KR2U/BeA9YHCxe6jnhl00A==

"@matrix-org/[email protected]":
version "3.2.15"
Expand Down
Loading