Fix secret storage not being used due to bad import (#2029)

This commit is contained in:
Michael Telatynski 2024-12-10 14:39:02 +00:00 committed by GitHub
parent 5bef889f83
commit 5d688c375a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 28 additions and 8 deletions

View File

@ -6,6 +6,8 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
Please see LICENSE files in the repository root for full details.
*/
import { platform } from "node:os";
import { test, expect } from "../../element-desktop-test.js";
declare global {
@ -17,6 +19,7 @@ declare global {
supportsEventIndexing(): Promise<boolean>;
}
| undefined;
createPickleKey(userId: string, deviceId: string): Promise<string | null>;
};
};
}
@ -24,17 +27,32 @@ declare global {
test.describe("App launch", () => {
test.slow();
test("should launch and render the welcome view successfully and support seshat", async ({ page }) => {
test.beforeEach(async ({ page }) => {
await page.locator("#matrixchat").waitFor();
await page.locator(".mx_Welcome").waitFor();
});
test("should launch and render the welcome view successfully", async ({ page }) => {
await expect(page).toHaveURL("vector://vector/webapp/#/welcome");
await expect(page).toHaveScreenshot();
const supported = await page.evaluate<boolean>(async () => {
const indexManager = window.mxPlatformPeg.get()?.getEventIndexingManager();
return await indexManager?.supportsEventIndexing();
});
expect(supported).toBe(true);
test("should launch and render the welcome view successfully and support seshat", async ({ page }) => {
await expect(
page.evaluate<boolean>(async () => {
return window.mxPlatformPeg.get().getEventIndexingManager()?.supportsEventIndexing();
}),
).resolves.toBeTruthy();
});
test("should launch and render the welcome view successfully and support keytar", async ({ page }) => {
test.skip(platform() === "linux", "This test does not yet support Linux");
await expect(
page.evaluate<string | null>(async () => {
return await window.mxPlatformPeg.get().createPickleKey("@user:server", "ABCDEF");
}),
).resolves.not.toBeNull();
});
});

View File

@ -157,7 +157,9 @@ ipcMain.on("ipcCall", async function (_ev: IpcMainEvent, payload) {
case "createPickleKey":
try {
const pickleKey = await randomArray(32);
await keytar?.setPassword("element.io", `${args[0]}|${args[1]}`, pickleKey);
// We purposefully throw if keytar is not available so the caller can handle it
// rather than sending them a pickle key we did not store on their behalf.
await keytar!.setPassword("element.io", `${args[0]}|${args[1]}`, pickleKey);
ret = pickleKey;
} catch {
ret = null;

View File

@ -9,7 +9,7 @@ import type * as Keytar from "keytar"; // Hak dependency type
let keytar: typeof Keytar | undefined;
try {
keytar = await import("keytar");
({ default: keytar } = await import("keytar"));
} catch (e) {
if ((<NodeJS.ErrnoException>e).code === "MODULE_NOT_FOUND") {
console.log("Keytar isn't installed; secure key storage is disabled.");