From 09debeccb53508d89b3d22b94c661020eb036b8e Mon Sep 17 00:00:00 2001 From: mohamad khawam Date: Fri, 1 Mar 2024 16:44:22 -0500 Subject: [PATCH] readPassword now waits until db is ready --- .gitignore | 5 ++++- build/build.ps1 | 4 ++-- package.json | 2 +- src/db/db.ts | 6 +++++- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 30744fc..1622123 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,9 @@ dist dist/* dist/** +releases +releases/* +releases/** misc @@ -32,7 +35,7 @@ phonea.txt testing.js - +releases .vscode diff --git a/build/build.ps1 b/build/build.ps1 index 7a24b63..32395eb 100644 --- a/build/build.ps1 +++ b/build/build.ps1 @@ -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' diff --git a/package.json b/package.json index ecc2442..c133e9d 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/db/db.ts b/src/db/db.ts index 3bb0784..3b119e9 100644 --- a/src/db/db.ts +++ b/src/db/db.ts @@ -557,7 +557,11 @@ class DataBase { * * @returns {Promise} A promise that resolves to the master password. */ - async readPassword() { + async readPassword(): Promise { + 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) {