Skip to content

Commit

Permalink
readPassword now waits until db is ready
Browse files Browse the repository at this point in the history
  • Loading branch information
dominusmars committed Mar 1, 2024
1 parent b2e5c41 commit 09debec
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ dist
dist/*
dist/**

releases
releases/*
releases/**

misc

Expand All @@ -32,7 +35,7 @@ phonea.txt

testing.js


releases

.vscode

Expand Down
4 changes: 2 additions & 2 deletions build/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ catch {
}
tsc
try {
pkg --out-path releases/latest/x64 -t 'node16-linux-x64,node16-win-x64,node16-macos-x64' -C Gzip -c ./package.json ./dist/Tortilla.js
pkg --out-path releases/latest/x64 -t 'node16-linux-x64,node16-win-x64,node16-macos-x64' -C Gzip -c ./package.json ./dist/src/Tortilla.js
Write-Output 'Finished x64'
pkg --out-path releases/latest/latest -t 'node16-linux,node16-win,node16-macos' -C Gzip -c ./package.json ./dist/Tortilla.js
pkg --out-path releases/latest/latest -t 'node16-linux,node16-win,node16-macos' -C Gzip -c ./package.json ./dist/src/Tortilla.js
Write-Output 'Finished latest'
# pkg --out-path releases/latest/arm -t 'node16-linux-arm64,node16-macos-arm64' ./dist/src/Tortilla.js
Write-Output 'UNABLE TO CREATE ARM Binaries PLEASE RUN pkg --out-path releases/latest/arm -t "node16-linux-arm64,node16-macos-arm64" -C Gzip ./dist/Tortilla.js'
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"scripts": {
"test": "mocha -r ts-node/register --timeout 10000 test/**/*.spec.ts",
"test_integration": "mocha -r ts-node/register --timeout 30000 --exit tests/**/*.spec.ts ",
"start": "tsc && cross-env DEV=true node --inspect --trace-warnings ./dist/Tortilla.js",
"start": "tsc && cross-env DEV=true node --inspect --trace-warnings ./dist/src/Tortilla.js",
"start_linux": "tsc && cross-env DEV=true node --inspect --trace-warnings ./dist/Tortilla.js",
"build_linux": "export SALT=$(node -e \"const crypto = require('crypto'); console.log(crypto.randomBytes(256).toString('hex'));\") && export SALT_2=$(node -e \"const crypto = require('crypto'); console.log(crypto.randomBytes(256).toString('hex'));\") && node ./build/prebuild.js $SALT $SALT_2 && tsc && pkg --out-path releases/latest/arm -t \"node16-linux-arm64,node16-win-arm64,node16-macos-arm64\" -C Gzip -c package.json ./dist/Tortilla.js && node ./build/postbuild.js $SALT $SALT_2 && echo 'Binaries are located in releases/latest' ",
"build-win": "powershell ./build/build.ps1",
Expand Down
6 changes: 5 additions & 1 deletion src/db/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,11 @@ class DataBase {
*
* @returns {Promise<string | false>} A promise that resolves to the master password.
*/
async readPassword() {
async readPassword(): Promise<string | false> {
if (!this.ready) {
await delay(1000);
return await this.readPassword();
}
try {
return this.encrypt.decrypt(await this.configs.get("master_hash").catch(() => ""), this._getPKey(""));
} catch (error) {
Expand Down

0 comments on commit 09debec

Please sign in to comment.