forked from matrix-org/matrix-js-sdk
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Ensure we do not add relations to the wrong timeline ([\matrix-org#3427](matrix-org#3427)). Fixes element-hq/element-web#25450 and element-hq/element-web#25494. * Deprecate `QrCodeEvent`, `SasEvent` and `VerificationEvent` ([\matrix-org#3386](matrix-org#3386)). * Move crypto classes into a separate namespace ([\matrix-org#3385](matrix-org#3385)). * Mention deno support in the README ([\matrix-org#3417](matrix-org#3417)). Contributed by @sigmaSd. * Mark room version 10 as safe ([\matrix-org#3425](matrix-org#3425)). * Prioritise entirely supported flows for UIA ([\matrix-org#3402](matrix-org#3402)). * Add methods to terminate idb worker ([\matrix-org#3362](matrix-org#3362)). * Total summary count ([\matrix-org#3351](matrix-org#3351)). Contributed by @toger5. * Audio concealment ([\matrix-org#3349](matrix-org#3349)). Contributed by @toger5. * Correctly accumulate sync summaries. ([\matrix-org#3366](matrix-org#3366)). Fixes element-hq/element-web#23345. * Keep measuring a call feed's volume after a stream replacement ([\matrix-org#3361](matrix-org#3361)). Fixes element-hq/element-call#1051. * Element-R: Avoid uploading a new fallback key at every `/sync` ([\matrix-org#3338](matrix-org#3338)). Fixes element-hq/element-web#25215. * Accumulate receipts for the main thread and unthreaded separately ([\matrix-org#3339](matrix-org#3339)). Fixes element-hq/element-web#24629. * Remove spec non-compliant extended glob format ([\matrix-org#3423](matrix-org#3423)). Fixes element-hq/element-web#25474. * Fix bug where original event was inserted into timeline instead of the edit event ([\matrix-org#3398](matrix-org#3398)). Contributed by @andybalaam. * Only add a local receipt if it's after an existing receipt ([\matrix-org#3399](matrix-org#3399)). Contributed by @andybalaam. * Attempt a potential workaround for stuck notifs ([\matrix-org#3384](matrix-org#3384)). Fixes element-hq/element-web#25406. Contributed by @andybalaam. * Fix verification bug with `pendingEventOrdering: "chronological"` ([\matrix-org#3382](matrix-org#3382)).
- Loading branch information
Showing
115 changed files
with
4,732 additions
and
2,016 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,4 @@ | |
break | ||
found_first_header = True | ||
elif not re.match(r"^=+$", line) and len(line) > 0: | ||
print line | ||
print(line) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
/* | ||
Copyright 2023 The Matrix.org Foundation C.I.C. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
import fetchMock from "fetch-mock-jest"; | ||
import "fake-indexeddb/auto"; | ||
import { IDBFactory } from "fake-indexeddb"; | ||
|
||
import { CRYPTO_BACKENDS, InitCrypto } from "../test-utils/test-utils"; | ||
import { createClient, MatrixClient, UIAuthCallback } from "../../src"; | ||
|
||
afterEach(() => { | ||
// reset fake-indexeddb after each test, to make sure we don't leak connections | ||
// cf https://github.com/dumbmatter/fakeIndexedDB#wipingresetting-the-indexeddb-for-a-fresh-state | ||
// eslint-disable-next-line no-global-assign | ||
indexedDB = new IDBFactory(); | ||
}); | ||
|
||
const TEST_USER_ID = "@alice:localhost"; | ||
const TEST_DEVICE_ID = "xzcvb"; | ||
|
||
/** | ||
* Integration tests for cross-signing functionality. | ||
* | ||
* These tests work by intercepting HTTP requests via fetch-mock rather than mocking out bits of the client, so as | ||
* to provide the most effective integration tests possible. | ||
*/ | ||
describe.each(Object.entries(CRYPTO_BACKENDS))("cross-signing (%s)", (backend: string, initCrypto: InitCrypto) => { | ||
let aliceClient: MatrixClient; | ||
|
||
beforeEach(async () => { | ||
// anything that we don't have a specific matcher for silently returns a 404 | ||
fetchMock.catch(404); | ||
fetchMock.config.warnOnFallback = false; | ||
|
||
const homeserverUrl = "https://alice-server.com"; | ||
aliceClient = createClient({ | ||
baseUrl: homeserverUrl, | ||
userId: TEST_USER_ID, | ||
accessToken: "akjgkrgjs", | ||
deviceId: TEST_DEVICE_ID, | ||
}); | ||
|
||
await initCrypto(aliceClient); | ||
}); | ||
|
||
afterEach(async () => { | ||
await aliceClient.stopClient(); | ||
fetchMock.mockReset(); | ||
}); | ||
|
||
describe("bootstrapCrossSigning (before initialsync completes)", () => { | ||
it("publishes keys if none were yet published", async () => { | ||
// have account_data requests return an empty object | ||
fetchMock.get("express:/_matrix/client/r0/user/:userId/account_data/:type", {}); | ||
|
||
// we expect a request to upload signatures for our device ... | ||
fetchMock.post({ url: "path:/_matrix/client/v3/keys/signatures/upload", name: "upload-sigs" }, {}); | ||
|
||
// ... and one to upload the cross-signing keys (with UIA) | ||
fetchMock.post( | ||
// legacy crypto uses /unstable/; /v3/ is correct | ||
{ | ||
url: new RegExp("/_matrix/client/(unstable|v3)/keys/device_signing/upload"), | ||
name: "upload-keys", | ||
}, | ||
{}, | ||
); | ||
|
||
// provide a UIA callback, so that the cross-signing keys are uploaded | ||
const authDict = { type: "test" }; | ||
const uiaCallback: UIAuthCallback<void> = async (makeRequest) => { | ||
await makeRequest(authDict); | ||
}; | ||
|
||
// now bootstrap cross signing, and check it resolves successfully | ||
await aliceClient.bootstrapCrossSigning({ | ||
authUploadDeviceSigningKeys: uiaCallback, | ||
}); | ||
|
||
// check the cross-signing keys upload | ||
expect(fetchMock.called("upload-keys")).toBeTruthy(); | ||
const [, keysOpts] = fetchMock.lastCall("upload-keys")!; | ||
const keysBody = JSON.parse(keysOpts!.body as string); | ||
expect(keysBody.auth).toEqual(authDict); // check uia dict was passed | ||
// there should be a key of each type | ||
// master key is signed by the device | ||
expect(keysBody).toHaveProperty(`master_key.signatures.[${TEST_USER_ID}].[ed25519:${TEST_DEVICE_ID}]`); | ||
const masterKeyId = Object.keys(keysBody.master_key.keys)[0]; | ||
// ssk and usk are signed by the master key | ||
expect(keysBody).toHaveProperty(`self_signing_key.signatures.[${TEST_USER_ID}].[${masterKeyId}]`); | ||
expect(keysBody).toHaveProperty(`user_signing_key.signatures.[${TEST_USER_ID}].[${masterKeyId}]`); | ||
const sskId = Object.keys(keysBody.self_signing_key.keys)[0]; | ||
|
||
// check the publish call | ||
expect(fetchMock.called("upload-sigs")).toBeTruthy(); | ||
const [, sigsOpts] = fetchMock.lastCall("upload-sigs")!; | ||
const body = JSON.parse(sigsOpts!.body as string); | ||
// there should be a signature for our device, by our self-signing key. | ||
expect(body).toHaveProperty( | ||
`[${TEST_USER_ID}].[${TEST_DEVICE_ID}].signatures.[${TEST_USER_ID}].[${sskId}]`, | ||
); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.