Nils1729 2024-04-29 14:27:58 +02:00 committed by GitHub
commit d82339067d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 53 additions and 0 deletions

View File

@ -406,6 +406,24 @@ export default class ElectronPlatform extends VectorBasePlatform {
return true;
}
public async getPlatformSecret(key: string): Promise<string | null> {
return await this.ipc.call("getSecret", key).catch((error) => {
logger.info(`Failed to connect to password storage to get ${key}`, error);
});
}
public async savePlatformSecret(key: string, value: string): Promise<string | null> {
return await this.ipc.call("saveSecret", key, value).catch((error) => {
logger.info(`Failed to connect to password storage to save ${key}`, error);
});
}
public async destroyPlatformSecret(key: string): Promise<void> {
return await this.ipc.call("destroySecret", key).catch((error) => {
logger.info(`Failed to connect to password storage to destroy ${key}`, error);
});
}
public async getPickleKey(userId: string, deviceId: string): Promise<string | null> {
try {
return await this.ipc.call("getPickleKey", userId, deviceId);

View File

@ -284,6 +284,41 @@ describe("ElectronPlatform", () => {
});
});
describe("generic secrets", () => {
const secretKey = "secret-key";
const secretValue = "secret-value";
it("makes correct ipc call to get secret", () => {
const platform = new ElectronPlatform();
mockElectron.send.mockClear();
platform.getPlatformSecret(secretKey);
const [, { name, args }] = mockElectron.send.mock.calls[0];
expect(name).toEqual("getSecret");
expect(args).toEqual([secretKey]);
});
it("makes correct ipc call to save secret", () => {
const platform = new ElectronPlatform();
mockElectron.send.mockClear();
platform.savePlatformSecret(secretKey, secretValue);
const [, { name, args }] = mockElectron.send.mock.calls[0];
expect(name).toEqual("saveSecret");
expect(args).toEqual([secretKey, secretValue]);
});
it("makes correct ipc call to destroy pickle key", () => {
const platform = new ElectronPlatform();
mockElectron.send.mockClear();
platform.destroyPlatformSecret(secretKey);
const [, { name, args }] = mockElectron.send.mock.calls[0];
expect(name).toEqual("destroySecret");
expect(args).toEqual([secretKey]);
});
});
describe("versions", () => {
it("calls install update", () => {
const platform = new ElectronPlatform();