Add platform secret functions to ElectronPlatform
Signed-off-by: Nils Hanff <nils.hanff@giz.berlin>pull/26405/head
parent
5b1b7acc62
commit
8fe19b6492
|
@ -403,6 +403,24 @@ export default class ElectronPlatform extends VectorBasePlatform {
|
||||||
return true;
|
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> {
|
public async getPickleKey(userId: string, deviceId: string): Promise<string | null> {
|
||||||
try {
|
try {
|
||||||
return await this.ipc.call("getPickleKey", userId, deviceId);
|
return await this.ipc.call("getPickleKey", userId, deviceId);
|
||||||
|
|
|
@ -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", () => {
|
describe("versions", () => {
|
||||||
it("calls install update", () => {
|
it("calls install update", () => {
|
||||||
const platform = new ElectronPlatform();
|
const platform = new ElectronPlatform();
|
||||||
|
|
Loading…
Reference in New Issue