Skip to content

Commit

Permalink
Fix secret storage not being used due to bad import (#2029)
Browse files Browse the repository at this point in the history
  • Loading branch information
t3chguy authored Dec 10, 2024
1 parent 5bef889 commit 5d688c3
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 8 deletions.
30 changes: 24 additions & 6 deletions playwright/e2e/launch/launch.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -17,24 +19,40 @@ declare global {
supportsEventIndexing(): Promise<boolean>;
}
| undefined;
createPickleKey(userId: string, deviceId: string): Promise<string | null>;
};
};
}
}

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();
});

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();
});

const supported = await page.evaluate<boolean>(async () => {
const indexManager = window.mxPlatformPeg.get()?.getEventIndexingManager();
return await indexManager?.supportsEventIndexing();
});
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");

expect(supported).toBe(true);
await expect(
page.evaluate<string | null>(async () => {
return await window.mxPlatformPeg.get().createPickleKey("@user:server", "ABCDEF");
}),
).resolves.not.toBeNull();
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
4 changes: 3 additions & 1 deletion src/ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/keytar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down

0 comments on commit 5d688c3

Please sign in to comment.