(feat): add cache package
(feat): improve local storage security (feat): move settings to dedicated settings package
This commit is contained in:
parent
fb095db7a6
commit
790a1db788
54 changed files with 1984 additions and 947 deletions
|
|
@ -3,12 +3,21 @@ import {
|
|||
ipcChannels,
|
||||
type DesktopCallStatus,
|
||||
type DesktopScreenShareSource,
|
||||
secureStorageLimits,
|
||||
} from "../shared/ipc.js";
|
||||
|
||||
function windowAction(channel: string) {
|
||||
return () => ipcRenderer.invoke(channel);
|
||||
}
|
||||
|
||||
function validKey(key: string) {
|
||||
return (
|
||||
typeof key === "string" &&
|
||||
key.length > 0 &&
|
||||
Buffer.byteLength(key, "utf8") <= secureStorageLimits.maxKeyBytes
|
||||
);
|
||||
}
|
||||
|
||||
const desktopApi = {
|
||||
media: {
|
||||
listScreenShareSources: () =>
|
||||
|
|
@ -46,6 +55,24 @@ const desktopApi = {
|
|||
return ipcRenderer.invoke(ipcChannels.setCallStatus, status);
|
||||
},
|
||||
},
|
||||
secureStorage: {
|
||||
getStatus: () => ipcRenderer.invoke(ipcChannels.getSecureStorageStatus),
|
||||
load: (key: string) =>
|
||||
validKey(key)
|
||||
? ipcRenderer.invoke(ipcChannels.loadSecureStorage, key)
|
||||
: Promise.reject(new Error("Invalid secure storage key.")),
|
||||
save: (key: string, value: string) =>
|
||||
validKey(key) &&
|
||||
typeof value === "string" &&
|
||||
Buffer.byteLength(value, "utf8") <= secureStorageLimits.maxValueBytes
|
||||
? ipcRenderer.invoke(ipcChannels.saveSecureStorage, key, value)
|
||||
: Promise.reject(new Error("Invalid secure storage key or value.")),
|
||||
delete: (key: string) =>
|
||||
validKey(key)
|
||||
? ipcRenderer.invoke(ipcChannels.deleteSecureStorage, key)
|
||||
: Promise.reject(new Error("Invalid secure storage key.")),
|
||||
clear: () => ipcRenderer.invoke(ipcChannels.clearSecureStorage),
|
||||
},
|
||||
window: {
|
||||
minimize: () => windowAction(ipcChannels.minimizeWindow),
|
||||
maximize: () => windowAction(ipcChannels.maximizeWindow),
|
||||
|
|
|
|||
Loading…
Reference in a new issue