-
-
Notifications
You must be signed in to change notification settings - Fork 606
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
Constructor for OwnUserIdentity no longer accessible #4634
Comments
Right, yes; this looks like rustwasm/wasm-bindgen#4282, which landed in wasm-bindgen 0.2.96; in other words, this happened in matrix-org/matrix-rust-sdk-crypto-wasm#179. I'll take a look at whether we can update the test. |
I poked at this a bit since I already had some relevant context loaded. If we mock enough that we can bootstrap cross-signing, then we can use a real olm machine in the test. So we don't need to create an diff --git a/spec/unit/rust-crypto/rust-crypto.spec.ts b/spec/unit/rust-crypto/rust-crypto.spec.ts
index 85757678e..8d8e8163f 100644
--- a/spec/unit/rust-crypto/rust-crypto.spec.ts
+++ b/spec/unit/rust-crypto/rust-crypto.spec.ts
@@ -1534,9 +1534,44 @@ describe("RustCrypto", () => {
describe("pinCurrentIdentity", () => {
let rustCrypto: RustCrypto;
- let olmMachine: Mocked<RustSdkCryptoJs.OlmMachine>;
+ //let olmMachine: Mocked<RustSdkCryptoJs.OlmMachine>;
- beforeEach(() => {
+ beforeEach(async () => {
+ const secretStorageCallbacks = {
+ getSecretStorageKey: async (keys: any, name: string) => {
+ return [[...Object.keys(keys.keys)][0], new Uint8Array(32)];
+ },
+ } as SecretStorageCallbacks;
+ const secretStorage = new ServerSideSecretStorageImpl(new DummyAccountDataClient(), secretStorageCallbacks);
+ rustCrypto = await makeTestRustCrypto(
+ new MatrixHttpApi(new TypedEventEmitter<HttpApiEvent, HttpApiEventHandlerMap>(), {
+ baseUrl: "http://server/",
+ prefix: "",
+ onlyData: true,
+ }),
+ TEST_USER,
+ TEST_DEVICE_ID,
+ secretStorage,
+ );
+ const e2eKeyReceiver = new E2EKeyReceiver("http://server");
+ const e2eKeyResponder = new E2EKeyResponder("http://server");
+ e2eKeyResponder.addKeyReceiver(TEST_USER, e2eKeyReceiver);
+ fetchMock.get("path:/_matrix/client/v3/room_keys/version", {
+ status: 404,
+ body: {
+ errcode: "M_NOT_FOUND",
+ error: "Not found",
+ },
+ });
+ fetchMock.post("path:/_matrix/client/v3/keys/device_signing/upload", {
+ status: 200,
+ body: {},
+ });
+ fetchMock.post("path:/_matrix/client/v3/keys/signatures/upload", {
+ status: 200,
+ body: {},
+ });
+ /*
olmMachine = {
getIdentity: jest.fn(),
} as unknown as Mocked<RustSdkCryptoJs.OlmMachine>;
@@ -1548,20 +1583,22 @@ describe("RustCrypto", () => {
TEST_DEVICE_ID,
{} as ServerSideSecretStorage,
{} as CryptoCallbacks,
- );
+ );
+ */
});
it("throws an error for an unknown user", async () => {
- await expect(rustCrypto.pinCurrentUserIdentity("@alice:example.com")).rejects.toThrow(
+ await expect(rustCrypto.pinCurrentUserIdentity("@other_user:example.com")).rejects.toThrow(
"Cannot pin identity of unknown user",
);
});
it("throws an error for our own user", async () => {
- const ownIdentity = new RustSdkCryptoJs.OwnUserIdentity();
- olmMachine.getIdentity.mockResolvedValue(ownIdentity);
+ //const ownIdentity = new RustSdkCryptoJs.OwnUserIdentity();
+ //olmMachine.getIdentity.mockResolvedValue(ownIdentity);
- await expect(rustCrypto.pinCurrentUserIdentity("@alice:example.com")).rejects.toThrow(
+ await rustCrypto.bootstrapCrossSigning({ setupNewCrossSigning: true });
+ await expect(rustCrypto.pinCurrentUserIdentity(TEST_USER)).rejects.toThrow(
"Cannot pin identity of own user",
);
}); It may also require my changes to @richvdh if this looks sane-ish (modulo cleaning it up), then I can create a new PR to bump the wasm binding in the JS SDK and fix the test, and then base #4599 off of that. |
sure, that sounds great, thank you |
Since I'm changing the test, I've moved the issue to js-sdk |
Something changed between v12.1.0 and v13 which caused
OwnUserIdentity
's constructor to become private. I don't see any code changes that would cause that, and as far as I can tell,OwnUserIdentity
never should have had a constructor. However, the test at https://github.com/matrix-org/matrix-js-sdk/blob/develop/spec/unit/rust-crypto/rust-crypto.spec.ts#L1558-L1565 tries to use it. This means that when we bump js-sdk to depend on v13, we get an error: https://github.com/matrix-org/matrix-js-sdk/actions/runs/12764224352/job/35575962385?pr=4599Since it seems like that test is the only place where the constructor is used, we may just want to change the test, rather try to re-add the constructor. @richvdh since you wrote that test, do you have any opinion on this?
The text was updated successfully, but these errors were encountered: