Skip to content

Commit

Permalink
Add a comment to argon2 loading in DesktopMain
Browse files Browse the repository at this point in the history
  • Loading branch information
charlag committed Jan 9, 2025
1 parent e2e9f49 commit eb098bf
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/common/desktop/DesktopMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,14 @@ type Components = {
}
const tfs = new TempFs(fs, electron, cryptoFns)
const desktopUtils = new DesktopUtils(process.argv, tfs, electron)
const wasmLoader = async () => {
// Argon2 is already built for the web part, we don't need to have another copy.
const loadArgon2 = async () => {
const wasmSourcePath = path.join(electron.app.getAppPath(), "wasm/argon2.wasm")
const wasmSource: Buffer = await fs.promises.readFile(wasmSourcePath)
const { exports } = (await WebAssembly.instantiate(wasmSource)).instance
return exports as unknown as Argon2IDExports
}
const desktopCrypto = new DesktopNativeCryptoFacade(fs, cryptoFns, tfs, wasmLoader())
const desktopCrypto = new DesktopNativeCryptoFacade(fs, cryptoFns, tfs, loadArgon2())
const opts = {
registerAsMailHandler: process.argv.some((arg) => arg === "-r"),
unregisterAsMailHandler: process.argv.some((arg) => arg === "-u"),
Expand Down Expand Up @@ -163,7 +164,7 @@ async function createComponents(): Promise<Components> {
const updater = new ElectronUpdater(conf, notifier, desktopCrypto, app, appIcon, new UpdaterWrapper(), fs)
const shortcutManager = new LocalShortcutManager()
const credentialsDb = new DesktopCredentialsStorage(__NODE_GYP_better_sqlite3, makeDbPath("credentials"), app)
const appPassHandler = new AppPassHandler(desktopCrypto, conf, wasmLoader(), lang, async () => {
const appPassHandler = new AppPassHandler(desktopCrypto, conf, loadArgon2(), lang, async () => {
const last = await wm.getLastFocused(true)
return last.commonNativeFacade
})
Expand Down

0 comments on commit eb098bf

Please sign in to comment.