Files
DiscordClone/apps/electron/src/platform/index.js
Bryan1029384756 965048f7d2
All checks were successful
Build and Release / build-and-release (push) Successful in 12m29s
1.0.60
2026-04-14 20:03:54 -05:00

87 lines
3.6 KiB
JavaScript

/**
* Electron platform implementation.
* Delegates to the window.* APIs exposed by preload.cjs.
*/
import SearchDatabase from '@discord-clone/shared/src/utils/SearchDatabase';
const searchDB = new SearchDatabase(
window.searchStorage,
{
encryptData: (data, key) => window.cryptoAPI.encryptData(data, key),
decryptData: (ct, key, iv, tag) => window.cryptoAPI.decryptData(ct, key, iv, tag),
}
);
const electronPlatform = {
crypto: {
generateKeys: () => window.cryptoAPI.generateKeys(),
randomBytes: (size) => window.cryptoAPI.randomBytes(size),
sha256: (data) => window.cryptoAPI.sha256(data),
signMessage: (privateKey, message) => window.cryptoAPI.signMessage(privateKey, message),
verifySignature: (publicKey, message, signature) => window.cryptoAPI.verifySignature(publicKey, message, signature),
deriveAuthKeys: (password, salt) => window.cryptoAPI.deriveAuthKeys(password, salt),
encryptData: (data, key) => window.cryptoAPI.encryptData(data, key),
decryptData: (encryptedData, key, iv, tag, options) => window.cryptoAPI.decryptData(encryptedData, key, iv, tag, options),
decryptBatch: (items) => window.cryptoAPI.decryptBatch(items),
verifyBatch: (items) => window.cryptoAPI.verifyBatch(items),
publicEncrypt: (publicKey, data) => window.cryptoAPI.publicEncrypt(publicKey, data),
privateDecrypt: (privateKey, encryptedHex) => window.cryptoAPI.privateDecrypt(privateKey, encryptedHex),
},
session: {
save: (data) => window.sessionPersistence.save(data),
load: () => window.sessionPersistence.load(),
clear: () => window.sessionPersistence.clear(),
},
settings: {
get: (key) => window.appSettings.get(key),
set: (key, value) => window.appSettings.set(key, value),
},
idle: {
getSystemIdleTime: () => window.idleAPI.getSystemIdleTime(),
onIdleStateChanged: (callback) => window.idleAPI.onIdleStateChanged(callback),
removeIdleStateListener: () => window.idleAPI.removeIdleStateListener(),
},
links: {
openExternal: (url) => window.cryptoAPI.openExternal(url),
fetchMetadata: (url) => window.cryptoAPI.fetchMetadata(url),
},
screenCapture: {
getScreenSources: () => window.cryptoAPI.getScreenSources(),
},
windowControls: {
minimize: () => window.windowControls.minimize(),
maximize: () => window.windowControls.maximize(),
close: () => window.windowControls.close(),
flashFrame: () => window.windowControls.flashFrame(),
},
recording: {
getDefaultFolder: () => window.recordingAPI.getDefaultFolder(),
pickFolder: () => window.recordingAPI.pickFolder(),
validateFolder: (dir) => window.recordingAPI.validateFolder(dir),
openFolder: (dir) => window.recordingAPI.openFolder(dir),
openSessionFolder: (payload) => window.recordingAPI.openSessionFolder(payload),
startSession: (payload) => window.recordingAPI.startSession(payload),
openTrack: (payload) => window.recordingAPI.openTrack(payload),
append: (payload) => window.recordingAPI.append(payload),
closeTrack: (payload) => window.recordingAPI.closeTrack(payload),
finalize: (payload) => window.recordingAPI.finalize(payload),
listRecoverable: (payload) => window.recordingAPI.listRecoverable(payload),
recoverSession: (payload) => window.recordingAPI.recoverSession(payload),
},
updates: {
checkUpdate: () => window.updateAPI.checkFlatpakUpdate(),
},
systemBars: null,
searchDB,
features: {
hasWindowControls: true,
hasScreenCapture: true,
hasNativeUpdates: true,
hasSearch: true,
hasSystemBars: false,
hasRecording: true,
},
};
export default electronPlatform;