1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-08-07 23:02:56 +03:00

Bump wasm bindings version to 2.1.0 (#3811)

This commit is contained in:
Valere
2023-10-20 18:44:55 +02:00
committed by GitHub
parent 7a52dba86c
commit 30a9119e31
4 changed files with 44 additions and 20 deletions

View File

@@ -51,7 +51,7 @@
], ],
"dependencies": { "dependencies": {
"@babel/runtime": "^7.12.5", "@babel/runtime": "^7.12.5",
"@matrix-org/matrix-sdk-crypto-wasm": "^2.0.0", "@matrix-org/matrix-sdk-crypto-wasm": "^2.1.0",
"another-json": "^0.2.0", "another-json": "^0.2.0",
"bs58": "^5.0.0", "bs58": "^5.0.0",
"content-type": "^1.0.4", "content-type": "^1.0.4",

View File

@@ -82,12 +82,6 @@ describe("OutgoingRequestProcessor", () => {
"https://example.com/_matrix/client/v3/keys/signatures/upload", "https://example.com/_matrix/client/v3/keys/signatures/upload",
], ],
["KeysBackupRequest", KeysBackupRequest, "PUT", "https://example.com/_matrix/client/v3/room_keys/keys"], ["KeysBackupRequest", KeysBackupRequest, "PUT", "https://example.com/_matrix/client/v3/room_keys/keys"],
[
"SigningKeysUploadRequest",
SigningKeysUploadRequest,
"POST",
"https://example.com/_matrix/client/v3/keys/device_signing/upload",
],
]; ];
test.each(tests)(`should handle %ss`, async (_, RequestClass, expectedMethod, expectedPath) => { test.each(tests)(`should handle %ss`, async (_, RequestClass, expectedMethod, expectedPath) => {
@@ -179,10 +173,37 @@ describe("OutgoingRequestProcessor", () => {
httpBackend.verifyNoOutstandingRequests(); httpBackend.verifyNoOutstandingRequests();
}); });
it("should handle SigningKeysUploadRequests 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));
// ... then poke the request into the OutgoingRequestProcessor under test
const reqProm = processor.makeOutgoingRequest(outgoingRequest);
// Now: check that it makes a matching HTTP request.
const testResponse = '{"result":1}';
httpBackend
.when("POST", "/_matrix")
.check((req) => {
expect(req.path).toEqual("https://example.com/_matrix/client/v3/keys/device_signing/upload");
expect(JSON.parse(req.rawData)).toEqual(testReq);
expect(req.headers["Accept"]).toEqual("application/json");
expect(req.headers["Content-Type"]).toEqual("application/json");
})
.respond(200, testResponse, true);
// SigningKeysUploadRequest does not need to be marked as sent, so no call to OlmMachine.markAsSent is expected.
await httpBackend.flushAllExpected();
await reqProm;
httpBackend.verifyNoOutstandingRequests();
});
it("should handle SigningKeysUploadRequests with UIA", async () => { it("should handle SigningKeysUploadRequests with UIA", async () => {
// first, mock up a request as we might expect to receive it from the Rust layer ... // first, mock up a request as we might expect to receive it from the Rust layer ...
const testReq = { foo: "bar" }; const testReq = { foo: "bar" };
const outgoingRequest = new SigningKeysUploadRequest("1234", JSON.stringify(testReq)); const outgoingRequest = new SigningKeysUploadRequest(JSON.stringify(testReq));
// also create a UIA callback // also create a UIA callback
const authCallback: UIAuthCallback<Object> = async (makeRequest) => { const authCallback: UIAuthCallback<Object> = async (makeRequest) => {
@@ -192,7 +213,7 @@ describe("OutgoingRequestProcessor", () => {
// ... then poke the request into the OutgoingRequestProcessor under test // ... then poke the request into the OutgoingRequestProcessor under test
const reqProm = processor.makeOutgoingRequest(outgoingRequest, authCallback); const reqProm = processor.makeOutgoingRequest(outgoingRequest, authCallback);
// Now: check that it makes a matching HTTP request ... // Now: check that it makes a matching HTTP request.
const testResponse = '{"result":1}'; const testResponse = '{"result":1}';
httpBackend httpBackend
.when("POST", "/_matrix") .when("POST", "/_matrix")
@@ -204,12 +225,10 @@ describe("OutgoingRequestProcessor", () => {
}) })
.respond(200, testResponse, true); .respond(200, testResponse, true);
// ... and that it calls OlmMachine.markAsSent. // SigningKeysUploadRequest does not need to be marked as sent, so no call to OlmMachine.markAsSent is expected.
const markSentCallPromise = awaitCallToMarkAsSent();
await httpBackend.flushAllExpected();
await Promise.all([reqProm, markSentCallPromise]); await httpBackend.flushAllExpected();
expect(olmMachine.markRequestAsSent).toHaveBeenCalledWith("1234", outgoingRequest.type, testResponse); await reqProm;
httpBackend.verifyNoOutstandingRequests(); httpBackend.verifyNoOutstandingRequests();
}); });

View File

@@ -61,7 +61,10 @@ export class OutgoingRequestProcessor {
private readonly http: MatrixHttpApi<IHttpOpts & { onlyData: true }>, private readonly http: MatrixHttpApi<IHttpOpts & { onlyData: true }>,
) {} ) {}
public async makeOutgoingRequest<T>(msg: OutgoingRequest, uiaCallback?: UIAuthCallback<T>): Promise<void> { public async makeOutgoingRequest<T>(
msg: OutgoingRequest | SigningKeysUploadRequest,
uiaCallback?: UIAuthCallback<T>,
): Promise<void> {
let resp: string; let resp: string;
/* refer https://docs.rs/matrix-sdk-crypto/0.6.0/matrix_sdk_crypto/requests/enum.OutgoingRequests.html /* refer https://docs.rs/matrix-sdk-crypto/0.6.0/matrix_sdk_crypto/requests/enum.OutgoingRequests.html
@@ -90,13 +93,15 @@ export class OutgoingRequestProcessor {
`${encodeURIComponent(msg.event_type)}/${encodeURIComponent(msg.txn_id)}`; `${encodeURIComponent(msg.event_type)}/${encodeURIComponent(msg.txn_id)}`;
resp = await this.rawJsonRequest(Method.Put, path, {}, msg.body); resp = await this.rawJsonRequest(Method.Put, path, {}, msg.body);
} else if (msg instanceof SigningKeysUploadRequest) { } else if (msg instanceof SigningKeysUploadRequest) {
resp = await this.makeRequestWithUIA( await this.makeRequestWithUIA(
Method.Post, Method.Post,
"/_matrix/client/v3/keys/device_signing/upload", "/_matrix/client/v3/keys/device_signing/upload",
{}, {},
msg.body, msg.body,
uiaCallback, uiaCallback,
); );
// SigningKeysUploadRequest does not implement OutgoingRequest and does not need to be marked as sent.
return;
} else { } else {
logger.warn("Unsupported outgoing message", Object.getPrototypeOf(msg)); logger.warn("Unsupported outgoing message", Object.getPrototypeOf(msg));
resp = ""; resp = "";

View File

@@ -1582,10 +1582,10 @@
"@jridgewell/resolve-uri" "^3.1.0" "@jridgewell/resolve-uri" "^3.1.0"
"@jridgewell/sourcemap-codec" "^1.4.14" "@jridgewell/sourcemap-codec" "^1.4.14"
"@matrix-org/matrix-sdk-crypto-wasm@^2.0.0": "@matrix-org/matrix-sdk-crypto-wasm@^2.1.0":
version "2.0.0" version "2.1.0"
resolved "https://registry.yarnpkg.com/@matrix-org/matrix-sdk-crypto-wasm/-/matrix-sdk-crypto-wasm-2.0.0.tgz#a4e9682705f090c94a58f6b851054f7598de9e83" resolved "https://registry.yarnpkg.com/@matrix-org/matrix-sdk-crypto-wasm/-/matrix-sdk-crypto-wasm-2.1.0.tgz#72b85e3843307e32ae78e1d603c748e82779ef90"
integrity sha512-8tKmI9u35URvtAr6zcfNGphImWt1y458iKq2PSPOSARlsmVk2lkrhsBFihBnWJY1oJC2EMsyfI8XTRuVYv00TQ== integrity sha512-ti0/N4nAMJ7sWY84Hs26/i/C6SXM/wizfamjCp3SH1TYEnpZNc9lTBQBG5jhrCR6CwQwYlWG3U+tg5yjuq/VkA==
"@matrix-org/olm@https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.14.tgz": "@matrix-org/olm@https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.14.tgz":
version "3.2.14" version "3.2.14"