From 90cce1a47c1bcad9d24de07320333dd247f9cd30 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Fri, 6 Jan 2023 17:28:44 +0100 Subject: [PATCH] chore(crypto-js): Improve documentation, and do a little clean up. --- bindings/matrix-sdk-crypto-js/src/requests.rs | 23 +++++++++++-------- .../tests/machine.test.js | 6 ++--- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/bindings/matrix-sdk-crypto-js/src/requests.rs b/bindings/matrix-sdk-crypto-js/src/requests.rs index f0e46a68e..ce0904195 100644 --- a/bindings/matrix-sdk-crypto-js/src/requests.rs +++ b/bindings/matrix-sdk-crypto-js/src/requests.rs @@ -38,6 +38,8 @@ pub struct KeysUploadRequest { /// A JSON-encoded string containing the rest of the payload: `device_keys`, /// `one_time_keys`, `fallback_keys`. + /// + /// It represents the body of the HTTP request. #[wasm_bindgen(readonly)] pub body: JsString, } @@ -72,6 +74,8 @@ pub struct KeysQueryRequest { /// A JSON-encoded string containing the rest of the payload: `timeout`, /// `device_keys`, `token`. + /// + /// It represents the body of the HTTP request. #[wasm_bindgen(readonly)] pub body: JsString, } @@ -107,6 +111,8 @@ pub struct KeysClaimRequest { /// A JSON-encoded string containing the rest of the payload: `timeout`, /// `one_time_keys`. + /// + /// It represents the body of the HTTP request. #[wasm_bindgen(readonly)] pub body: JsString, } @@ -149,6 +155,8 @@ pub struct ToDeviceRequest { pub txn_id: JsString, /// A JSON-encoded string containing the rest of the payload: `messages`. + /// + /// It represents the body of the HTTP request. #[wasm_bindgen(readonly)] pub body: JsString, } @@ -187,6 +195,8 @@ pub struct SignatureUploadRequest { pub id: Option, /// A JSON-encoded string containing the rest of the payload: `signed_keys`. + /// + /// It represents the body of the HTTP request. #[wasm_bindgen(readonly)] pub body: JsString, } @@ -271,6 +281,8 @@ pub struct KeysBackupRequest { pub id: Option, /// A JSON-encoded string containing the rest of the payload: `rooms`. + /// + /// It represents the body of the HTTP request. #[wasm_bindgen(readonly)] pub body: JsString, } @@ -304,6 +316,8 @@ pub struct SigningKeysUploadRequest { /// A JSON-encoded string containing the rest of the payload: `master_key`, /// `self_signing_key`, `user_signing_key`. + /// + /// It represents the body of the HTTP request. #[wasm_bindgen(readonly)] pub body: JsString, } @@ -376,15 +390,6 @@ macro_rules! request { request!(@__field_type as $field_type ; request = $request, field_name = $field_name) }; - /* - ( @__field $field_name:ident : $field_mapper:block ; request = $request:expr ) => { - { - let mapper = $field_mapper; - mapper($request) - } - }; - */ - ( @__field_type as string ; request = $request:expr, field_name = $field_name:ident ) => { $request.$field_name.to_string().into() }; diff --git a/bindings/matrix-sdk-crypto-js/tests/machine.test.js b/bindings/matrix-sdk-crypto-js/tests/machine.test.js index dbbd7f723..82e39c3f9 100644 --- a/bindings/matrix-sdk-crypto-js/tests/machine.test.js +++ b/bindings/matrix-sdk-crypto-js/tests/machine.test.js @@ -99,7 +99,7 @@ describe(OlmMachine.name, () => { test('can drop/close', async () => { m = await machine(); m.close(); - }) + }); test('can drop/close with a store', async () => { let store_name = 'temporary'; @@ -133,7 +133,7 @@ describe(OlmMachine.name, () => { deleting.onerror = () => { throw new Error('failed to remove the database (error)') }; deleting.onblocked = () => { throw new Error('failed to remove the database (blocked)') }; } - }) + }); test('can read user ID', async () => { expect((await machine()).userId.toString()).toStrictEqual(user.toString()); @@ -200,7 +200,7 @@ describe(OlmMachine.name, () => { expect(outgoingRequests[0].type).toStrictEqual(RequestType.KeysUpload); expect(outgoingRequests[0].body).toBeDefined(); - const body = JSON.parse(outgoingRequests[0].body) + const body = JSON.parse(outgoingRequests[0].body); expect(body.device_keys).toBeDefined(); expect(body.one_time_keys).toBeDefined(); }