Files
e8c7f8040e bcrypt -> argon2id (#7829)
* bcrypt -> argon2id

* coderabbit feedback

* copilot review

* switch hashing settings

* [AI] Add unit tests for sync-server password hashing

Cover password.js, focused on the bcrypt -> argon2id migration:
- loginWithPassword upgrades a legacy bcrypt hash to argon2id on a
  successful login, leaves it untouched on a failed login, and does not
  needlessly rehash an existing argon2id hash
- hashPassword/verifyPassword round-trip, bcrypt backward-compat, and
  graceful handling of non-string/malformed hashes
- bootstrapPassword/changePassword/checkPassword behaviour

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* dedupe minimatch

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-03 00:04:07 +00:00

49 lines
1.6 KiB
TypeScript

import { rebuild } from '@electron/rebuild';
import copyFiles from 'copyfiles';
import { Arch } from 'electron-builder';
import type { AfterPackContext } from 'electron-builder';
/* The beforePackHook runs before packing the Electron app for an architecture
We hook in here to build anything architecture dependent - such as beter-sqlite3
To build, we call @electron/rebuild on the better-sqlite3 module */
const beforePackHook = async (context: AfterPackContext) => {
const arch: string = Arch[context.arch];
const buildPath = context.packager.projectDir;
const projectRootPath = buildPath + '/../../';
const electronVersion = context.packager.config.electronVersion;
if (!electronVersion) {
console.error('beforePackHook: Unable to find electron version.');
process.exit(); // End the process - electron version is required
}
try {
await rebuild({
arch,
buildPath,
electronVersion,
force: true,
projectRootPath,
onlyModules: ['better-sqlite3', 'bcrypt', 'argon2'],
});
console.info(`Rebuilt better-sqlite3, bcrypt, and argon2 with ${arch}!`);
if (context.packager.platform.name === 'windows') {
console.info(`Windows build - copying appx files...`);
await new Promise(resolve =>
copyFiles(['./appx/**/*', './build'], { error: true }, resolve),
);
console.info(`Copied appx files!`);
}
} catch (err) {
console.error('beforePackHook:', err);
process.exit(); // End the process - unsuccessful build
}
};
// oxlint-disable-next-line import/no-default-export
export default beforePackHook;