diff --git a/.env b/.env
index 9c94a29..2a09a9c 100644
--- a/.env
+++ b/.env
@@ -7,4 +7,6 @@ DB_PASSWORD=RLR+2DHmZ6XJGotT2F7Ylrpdptc
DB_NAME=dok
OFFLINE_SERVER_1=Test Server Alpha
-OFFLINE_SERVER_2=Test Server Beta
\ No newline at end of file
+OFFLINE_SERVER_2=Test Server Beta
+
+APP_URL=https://spiel.dynastyofknights.com
\ No newline at end of file
diff --git a/app.js b/app.js
index de2a14f..f29490f 100644
--- a/app.js
+++ b/app.js
@@ -6,6 +6,8 @@ const helmet = require("helmet");
const rateLimit = require("express-rate-limit");
const serverRoutes = require("./routes/servers");
+const registerRoutes = require("./routes/register");
+const verifyRoutes = require("./routes/verify");
const app = express();
const PORT = process.env.PORT || 3000;
@@ -48,6 +50,8 @@ app.use(express.static(path.join(__dirname, "public")));
======================== */
app.use("/", serverRoutes);
+app.use("/register", registerRoutes);
+app.use("/verify", verifyRoutes);
/* ========================
404 Handler
diff --git a/node_modules/.bin/node-gyp-build b/node_modules/.bin/node-gyp-build
new file mode 100644
index 0000000..b804ba9
--- /dev/null
+++ b/node_modules/.bin/node-gyp-build
@@ -0,0 +1,16 @@
+#!/bin/sh
+basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
+
+case `uname` in
+ *CYGWIN*|*MINGW*|*MSYS*)
+ if command -v cygpath > /dev/null 2>&1; then
+ basedir=`cygpath -w "$basedir"`
+ fi
+ ;;
+esac
+
+if [ -x "$basedir/node" ]; then
+ exec "$basedir/node" "$basedir/../node-gyp-build/bin.js" "$@"
+else
+ exec node "$basedir/../node-gyp-build/bin.js" "$@"
+fi
diff --git a/node_modules/.bin/node-gyp-build-optional b/node_modules/.bin/node-gyp-build-optional
new file mode 100644
index 0000000..cb670aa
--- /dev/null
+++ b/node_modules/.bin/node-gyp-build-optional
@@ -0,0 +1,16 @@
+#!/bin/sh
+basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
+
+case `uname` in
+ *CYGWIN*|*MINGW*|*MSYS*)
+ if command -v cygpath > /dev/null 2>&1; then
+ basedir=`cygpath -w "$basedir"`
+ fi
+ ;;
+esac
+
+if [ -x "$basedir/node" ]; then
+ exec "$basedir/node" "$basedir/../node-gyp-build/optional.js" "$@"
+else
+ exec node "$basedir/../node-gyp-build/optional.js" "$@"
+fi
diff --git a/node_modules/.bin/node-gyp-build-optional.cmd b/node_modules/.bin/node-gyp-build-optional.cmd
new file mode 100644
index 0000000..74d85f2
--- /dev/null
+++ b/node_modules/.bin/node-gyp-build-optional.cmd
@@ -0,0 +1,17 @@
+@ECHO off
+GOTO start
+:find_dp0
+SET dp0=%~dp0
+EXIT /b
+:start
+SETLOCAL
+CALL :find_dp0
+
+IF EXIST "%dp0%\node.exe" (
+ SET "_prog=%dp0%\node.exe"
+) ELSE (
+ SET "_prog=node"
+ SET PATHEXT=%PATHEXT:;.JS;=;%
+)
+
+endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\node-gyp-build\optional.js" %*
diff --git a/node_modules/.bin/node-gyp-build-optional.ps1 b/node_modules/.bin/node-gyp-build-optional.ps1
new file mode 100644
index 0000000..45995c3
--- /dev/null
+++ b/node_modules/.bin/node-gyp-build-optional.ps1
@@ -0,0 +1,28 @@
+#!/usr/bin/env pwsh
+$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
+
+$exe=""
+if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
+ # Fix case when both the Windows and Linux builds of Node
+ # are installed in the same directory
+ $exe=".exe"
+}
+$ret=0
+if (Test-Path "$basedir/node$exe") {
+ # Support pipeline input
+ if ($MyInvocation.ExpectingInput) {
+ $input | & "$basedir/node$exe" "$basedir/../node-gyp-build/optional.js" $args
+ } else {
+ & "$basedir/node$exe" "$basedir/../node-gyp-build/optional.js" $args
+ }
+ $ret=$LASTEXITCODE
+} else {
+ # Support pipeline input
+ if ($MyInvocation.ExpectingInput) {
+ $input | & "node$exe" "$basedir/../node-gyp-build/optional.js" $args
+ } else {
+ & "node$exe" "$basedir/../node-gyp-build/optional.js" $args
+ }
+ $ret=$LASTEXITCODE
+}
+exit $ret
diff --git a/node_modules/.bin/node-gyp-build-test b/node_modules/.bin/node-gyp-build-test
new file mode 100644
index 0000000..bdf6dca
--- /dev/null
+++ b/node_modules/.bin/node-gyp-build-test
@@ -0,0 +1,16 @@
+#!/bin/sh
+basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
+
+case `uname` in
+ *CYGWIN*|*MINGW*|*MSYS*)
+ if command -v cygpath > /dev/null 2>&1; then
+ basedir=`cygpath -w "$basedir"`
+ fi
+ ;;
+esac
+
+if [ -x "$basedir/node" ]; then
+ exec "$basedir/node" "$basedir/../node-gyp-build/build-test.js" "$@"
+else
+ exec node "$basedir/../node-gyp-build/build-test.js" "$@"
+fi
diff --git a/node_modules/.bin/node-gyp-build-test.cmd b/node_modules/.bin/node-gyp-build-test.cmd
new file mode 100644
index 0000000..182a757
--- /dev/null
+++ b/node_modules/.bin/node-gyp-build-test.cmd
@@ -0,0 +1,17 @@
+@ECHO off
+GOTO start
+:find_dp0
+SET dp0=%~dp0
+EXIT /b
+:start
+SETLOCAL
+CALL :find_dp0
+
+IF EXIST "%dp0%\node.exe" (
+ SET "_prog=%dp0%\node.exe"
+) ELSE (
+ SET "_prog=node"
+ SET PATHEXT=%PATHEXT:;.JS;=;%
+)
+
+endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\node-gyp-build\build-test.js" %*
diff --git a/node_modules/.bin/node-gyp-build-test.ps1 b/node_modules/.bin/node-gyp-build-test.ps1
new file mode 100644
index 0000000..6cb0b9b
--- /dev/null
+++ b/node_modules/.bin/node-gyp-build-test.ps1
@@ -0,0 +1,28 @@
+#!/usr/bin/env pwsh
+$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
+
+$exe=""
+if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
+ # Fix case when both the Windows and Linux builds of Node
+ # are installed in the same directory
+ $exe=".exe"
+}
+$ret=0
+if (Test-Path "$basedir/node$exe") {
+ # Support pipeline input
+ if ($MyInvocation.ExpectingInput) {
+ $input | & "$basedir/node$exe" "$basedir/../node-gyp-build/build-test.js" $args
+ } else {
+ & "$basedir/node$exe" "$basedir/../node-gyp-build/build-test.js" $args
+ }
+ $ret=$LASTEXITCODE
+} else {
+ # Support pipeline input
+ if ($MyInvocation.ExpectingInput) {
+ $input | & "node$exe" "$basedir/../node-gyp-build/build-test.js" $args
+ } else {
+ & "node$exe" "$basedir/../node-gyp-build/build-test.js" $args
+ }
+ $ret=$LASTEXITCODE
+}
+exit $ret
diff --git a/node_modules/.bin/node-gyp-build.cmd b/node_modules/.bin/node-gyp-build.cmd
new file mode 100644
index 0000000..ac854a6
--- /dev/null
+++ b/node_modules/.bin/node-gyp-build.cmd
@@ -0,0 +1,17 @@
+@ECHO off
+GOTO start
+:find_dp0
+SET dp0=%~dp0
+EXIT /b
+:start
+SETLOCAL
+CALL :find_dp0
+
+IF EXIST "%dp0%\node.exe" (
+ SET "_prog=%dp0%\node.exe"
+) ELSE (
+ SET "_prog=node"
+ SET PATHEXT=%PATHEXT:;.JS;=;%
+)
+
+endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\node-gyp-build\bin.js" %*
diff --git a/node_modules/.bin/node-gyp-build.ps1 b/node_modules/.bin/node-gyp-build.ps1
new file mode 100644
index 0000000..c1f9a9a
--- /dev/null
+++ b/node_modules/.bin/node-gyp-build.ps1
@@ -0,0 +1,28 @@
+#!/usr/bin/env pwsh
+$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
+
+$exe=""
+if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
+ # Fix case when both the Windows and Linux builds of Node
+ # are installed in the same directory
+ $exe=".exe"
+}
+$ret=0
+if (Test-Path "$basedir/node$exe") {
+ # Support pipeline input
+ if ($MyInvocation.ExpectingInput) {
+ $input | & "$basedir/node$exe" "$basedir/../node-gyp-build/bin.js" $args
+ } else {
+ & "$basedir/node$exe" "$basedir/../node-gyp-build/bin.js" $args
+ }
+ $ret=$LASTEXITCODE
+} else {
+ # Support pipeline input
+ if ($MyInvocation.ExpectingInput) {
+ $input | & "node$exe" "$basedir/../node-gyp-build/bin.js" $args
+ } else {
+ & "node$exe" "$basedir/../node-gyp-build/bin.js" $args
+ }
+ $ret=$LASTEXITCODE
+}
+exit $ret
diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json
index 6b1d52f..60baeac 100644
--- a/node_modules/.package-lock.json
+++ b/node_modules/.package-lock.json
@@ -185,6 +185,29 @@
],
"license": "MIT"
},
+ "node_modules/bcrypt": {
+ "version": "6.0.0",
+ "resolved": "https://registry.npmjs.org/bcrypt/-/bcrypt-6.0.0.tgz",
+ "integrity": "sha512-cU8v/EGSrnH+HnxV2z0J7/blxH8gq7Xh2JFT6Aroax7UohdmiJJlxApMxtKfuI7z68NvvVcmR78k2LbT6efhRg==",
+ "hasInstallScript": true,
+ "license": "MIT",
+ "dependencies": {
+ "node-addon-api": "^8.3.0",
+ "node-gyp-build": "^4.8.4"
+ },
+ "engines": {
+ "node": ">= 18"
+ }
+ },
+ "node_modules/bcrypt/node_modules/node-addon-api": {
+ "version": "8.6.0",
+ "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-8.6.0.tgz",
+ "integrity": "sha512-gBVjCaqDlRUk0EwoPNKzIr9KkS9041G/q31IBShPs1Xz6UTA+EXdZADbzqAJQrpDRq71CIMnOP5VMut3SL0z5Q==",
+ "license": "MIT",
+ "engines": {
+ "node": "^18 || ^20 || >= 21"
+ }
+ },
"node_modules/better-sqlite3": {
"version": "12.6.2",
"resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-12.6.2.tgz",
@@ -483,6 +506,13 @@
"node": ">=6.6.0"
}
},
+ "node_modules/crypto": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/crypto/-/crypto-1.0.1.tgz",
+ "integrity": "sha512-VxBKmeNcqQdiUQUW2Tzq0t377b54N2bMtXO/qiLa+6eRRmmC4qT3D4OnTGoT/U6O9aklQ/jTwbOtRMTTY8G0Ig==",
+ "deprecated": "This package is no longer supported. It's now a built-in Node module. If you've depended on crypto, you should switch to the one that's built-in.",
+ "license": "ISC"
+ },
"node_modules/csrf": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/csrf/-/csrf-3.1.0.tgz",
@@ -1732,6 +1762,26 @@
"node": ">= 10.12.0"
}
},
+ "node_modules/node-gyp-build": {
+ "version": "4.8.4",
+ "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.8.4.tgz",
+ "integrity": "sha512-LA4ZjwlnUblHVgq0oBF3Jl/6h/Nvs5fzBLwdEF4nuxnFdsfajde4WfxtJr3CaiH+F6ewcIB/q4jQ4UzPyid+CQ==",
+ "license": "MIT",
+ "bin": {
+ "node-gyp-build": "bin.js",
+ "node-gyp-build-optional": "optional.js",
+ "node-gyp-build-test": "build-test.js"
+ }
+ },
+ "node_modules/nodemailer": {
+ "version": "8.0.2",
+ "resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-8.0.2.tgz",
+ "integrity": "sha512-zbj002pZAIkWQFxyAaqoxvn+zoIwRnS40hgjqTXudKOOJkiFFgBeNqjgD3/YCR12sZnrghWYBY+yP1ZucdDRpw==",
+ "license": "MIT-0",
+ "engines": {
+ "node": ">=6.0.0"
+ }
+ },
"node_modules/nopt": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/nopt/-/nopt-5.0.0.tgz",
diff --git a/node_modules/bcrypt/.dockerignore b/node_modules/bcrypt/.dockerignore
new file mode 100644
index 0000000..01f4eb7
--- /dev/null
+++ b/node_modules/bcrypt/.dockerignore
@@ -0,0 +1,6 @@
+.git/
+.vscode/
+Dockerfile*
+prebuilds/
+node_modules/
+build*/
diff --git a/node_modules/bcrypt/.editorconfig b/node_modules/bcrypt/.editorconfig
new file mode 100644
index 0000000..4e12f93
--- /dev/null
+++ b/node_modules/bcrypt/.editorconfig
@@ -0,0 +1,19 @@
+root = true
+
+[*]
+indent_style = space
+indent_size = 4
+end_of_line = lf
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+
+[{package.json,*.yml}]
+indent_style = space
+indent_size = 2
+
+[appveyor.yml]
+end_of_line = crlf
+
+[*.md]
+trim_trailing_whitespace = false
diff --git a/node_modules/bcrypt/.github/workflows/build-pack-publish.yml b/node_modules/bcrypt/.github/workflows/build-pack-publish.yml
new file mode 100644
index 0000000..9b14ee1
--- /dev/null
+++ b/node_modules/bcrypt/.github/workflows/build-pack-publish.yml
@@ -0,0 +1,110 @@
+name: Prebuildify, package, publish
+
+on:
+ push:
+ branches: [ master ]
+ pull_request:
+ branches: [ master ]
+ release:
+ types: [ prereleased, released ]
+
+jobs:
+ build-linux:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ # This is unsafe, but we really don't use any other native dependencies
+ - run: npm ci
+ - run: docker run -u $(id -u):$(id -g) -v `pwd`:/input -w /input ghcr.io/prebuild/almalinux-devtoolset11 npx prebuildify --napi --tag-libc --strip --target=node@18.0.0
+ - run: docker run -u $(id -u):$(id -g) -v `pwd`:/input -w /input ghcr.io/prebuild/alpine npx prebuildify --napi --tag-libc --strip --target=node@18.0.0
+ - run: docker run -u $(id -u):$(id -g) -v `pwd`:/input -w /input ghcr.io/prebuild/linux-armv7 npx prebuildify --napi --tag-libc --strip --target=node@18.0.0
+ - run: docker run -u $(id -u):$(id -g) -v `pwd`:/input -w /input ghcr.io/prebuild/linux-armv7l-musl npx prebuildify --napi --tag-libc --strip --target=node@18.0.0
+ - run: docker run -u $(id -u):$(id -g) -v `pwd`:/input -w /input ghcr.io/prebuild/linux-arm64 npx prebuildify --napi --tag-libc --strip --target=node@18.0.0
+ - run: docker run -u $(id -u):$(id -g) -v `pwd`:/input -w /input ghcr.io/prebuild/linux-arm64-musl npx prebuildify --napi --tag-libc --strip --target=node@18.0.0
+ - run: find prebuilds
+ - uses: actions/upload-artifact@v4
+ with:
+ name: prebuild-linux
+ path: ./prebuilds/
+
+ build-windows:
+ runs-on: windows-latest
+ steps:
+ - uses: actions/checkout@v4
+ - uses: actions/setup-node@v4
+ with:
+ node-version: 20
+ registry-url: 'https://registry.npmjs.org'
+ - run: npm ci
+ - run: npx prebuildify --napi --strip --arch=x64 --target=node@18.0.0
+ - run: npx prebuildify --napi --strip --arch=arm64 --target=node@20.0.0
+ - run: dir prebuilds
+ - uses: actions/upload-artifact@v4
+ with:
+ name: prebuild-windows
+ path: ./prebuilds/
+
+ build-macos:
+ runs-on: macos-latest
+ steps:
+ - uses: actions/checkout@v4
+ - uses: actions/setup-node@v4
+ with:
+ node-version: 18
+ registry-url: 'https://registry.npmjs.org'
+ - run: npm ci
+ - run: npx prebuildify --napi --strip --arch=arm64 --target=node@18.0.0
+ - run: npx prebuildify --napi --strip --arch=x64 --target=node@18.0.0
+ - run: find prebuilds
+ - uses: actions/upload-artifact@v4
+ with:
+ name: prebuild-macos
+ path: ./prebuilds/
+
+ pack:
+ needs:
+ - build-linux
+ - build-windows
+ - build-macos
+ runs-on: ubuntu-latest
+ outputs:
+ PACK_FILE: ${{ steps.pack.outputs.PACK_FILE }}
+ steps:
+ - uses: actions/checkout@v4
+ - uses: actions/download-artifact@v4
+ with:
+ path: /tmp/prebuilds/
+ - name: Coalesce prebuilds from build matrix
+ run: |
+ mkdir prebuilds
+ for d in /tmp/prebuilds/*; do
+ cp -Rav $d/* prebuilds/
+ done
+ - run: chmod a+x prebuilds/*/*.node && find prebuilds -executable -type f
+ - id: pack
+ name: Prepare NPM package
+ run: |
+ echo "PACK_FILE=$(npm pack)" >> "$GITHUB_OUTPUT"
+ - uses: actions/upload-artifact@v4
+ with:
+ name: package-tgz
+ path: ${{ steps.pack.outputs.PACK_FILE }}
+ if-no-files-found: 'error'
+
+ test-package:
+ needs: pack
+ strategy:
+ matrix:
+ node-version: [ 18, 20, 22, 23 ]
+ os: [ ubuntu-latest, windows-latest, macos-latest ]
+ runs-on: ${{ matrix.os }}
+ steps:
+ - uses: actions/setup-node@v4
+ with:
+ node-version: ${{ matrix.node-version }}
+ registry-url: 'https://registry.npmjs.org'
+ - uses: actions/download-artifact@v4
+ with:
+ name: package-tgz
+ - run: npm install ${{ needs.pack.outputs.PACK_FILE }}
+ - run: node -e "const b = require('bcrypt'); const h = b.hashSync('hello', 10); console.log(h, b.compareSync('hello', h))"
diff --git a/node_modules/bcrypt/.github/workflows/ci.yaml b/node_modules/bcrypt/.github/workflows/ci.yaml
new file mode 100644
index 0000000..77c4e5a
--- /dev/null
+++ b/node_modules/bcrypt/.github/workflows/ci.yaml
@@ -0,0 +1,42 @@
+name: ci
+
+on:
+ push:
+ branches:
+ - master
+ pull_request:
+ branches:
+ - master
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ node-version: [18, 20, 22]
+ steps:
+ - uses: actions/checkout@v4
+ - name: Use Node.js ${{ matrix.node-version }}
+ uses: actions/setup-node@v4
+ with:
+ node-version: ${{ matrix.node-version }}
+ - run: npm ci
+ - name: Test
+ run: npm test
+
+ build-alpine:
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ node-version: [18, 20, 22]
+ container:
+ image: node:${{ matrix.node-version }}-alpine
+ steps:
+ - uses: actions/checkout@v4
+ - name: Install dependencies
+ run: |
+ apk add make g++ python3
+ - run: npm ci
+ - name: Test
+ run: |
+ npm test --unsafe-perm
diff --git a/node_modules/bcrypt/CHANGELOG.md b/node_modules/bcrypt/CHANGELOG.md
new file mode 100644
index 0000000..eab713b
--- /dev/null
+++ b/node_modules/bcrypt/CHANGELOG.md
@@ -0,0 +1,184 @@
+# 6.0.0 (2025-02-28)
+ * Drop support for NodeJS <= 16
+ * Remove `node-pre-gyp` in favor of `prebuildify`, prebuilt binaries are now shipped with the package
+ * Update `node-addon-api` to 8.3.0
+ * Update JS code to newer ES syntax
+
+# 5.1.0 (2022-10-06)
+ * Update `node-pre-gyp` to 1.0.11
+
+# 5.1.0 (2022-10-06)
+ * Update `node-pre-gyp` to 1.0.10
+ * Replace `nodeunit` with `jest` as the testing library
+
+# 5.0.1 (2021-02-22)
+
+ * Update `node-pre-gyp` to 1.0.0
+
+# 5.0.0 (2020-06-02)
+
+ * Fix the bcrypt "wrap-around" bug. It affects passwords with lengths >= 255.
+ It is uncommon but it's a bug nevertheless. Previous attempts to fix the bug
+ was unsuccessful.
+ * Experimental support for z/OS
+ * Fix a bug related to NUL in password input
+ * Update `node-pre-gyp` to 0.15.0
+
+# 4.0.1 (2020-02-27)
+
+ * Fix compilation errors in Alpine linux
+
+# 4.0.0 (2020-02-17)
+
+ * Switch to NAPI bcrypt
+ * Drop support for NodeJS 8
+
+# 3.0.8 (2019-12-31)
+
+ * Update `node-pre-gyp` to 0.14
+ * Pre-built binaries for NodeJS 13
+
+# 3.0.7 (2019-10-18)
+
+ * Update `nan` to 2.14.0
+ * Update `node-pre-gyp` to 0.13
+
+# 3.0.6 (2019-04-11)
+
+ * Update `nan` to 2.13.2
+
+# 3.0.5 (2019-03-19)
+
+ * Update `nan` to 2.13.1
+ * NodeJS 12 compatibility
+ * Remove `node-pre-gyp` from bundled dependencies
+
+# 3.0.4-napi (2019-03-08)
+
+ * Sync N-API bcrypt with NAN bcrypt
+
+# 3.0.4 (2019-02-07)
+
+ * Fix GCC, NAN and V8 deprecation warnings
+
+# 3.0.3 (2018-12-19)
+
+ * Update `nan` to 2.12.1
+
+# 3.0.2 (2018-10-18)
+
+ * Update `nan` to 2.11.1
+
+# 3.0.1 (2018-09-20)
+
+ * Update `nan` to 2.11.0
+
+# 3.0.0 (2018-07-06)
+
+ * Drop support for NodeJS <= 4
+
+# 2.0.1 (2018-04-20)
+
+ * Update `node-pre-gyp` to allow downloading prebuilt modules
+
+# 2.0.0 (2018-04-07)
+
+ * Make `2b` the default bcrypt version
+
+# 1.1.0-napi (2018-01-21)
+
+ * Initial support for [N-API](https://nodejs.org/api/n-api.html)
+
+# 1.0.3 (2016-08-23)
+
+ * update to nan v2.6.2 for NodeJS 8 support
+ * Fix: use npm scripts instead of node-gyp directly.
+
+# 1.0.2 (2016-12-31)
+
+ * Fix `compare` promise rejection with invalid arguments
+
+# 1.0.1 (2016-12-07)
+
+ * Fix destructuring imports with promises
+
+# 1.0.0 (2016-12-04)
+
+ * add Promise support (commit 2488473)
+
+# 0.8.7 (2016-06-09)
+
+ * update nan to 2.3.5 for improved node v6 support
+
+# 0.8.6 (2016-04-20)
+
+ * update nan for node v6 support
+
+# 0.8.5 (2015-08-12)
+
+ * update to nan v2 (adds support for iojs 3)
+
+# 0.8.4 (2015-07-24)
+
+ * fix deprecation warning for the Encode API
+
+# 0.8.3 (2015-05-06)
+
+ * update nan to 1.8.4 for iojs 2.x support
+
+# 0.8.2 (2015-03-28)
+
+ * always use callback for generating random bytes to avoid blocking
+
+# 0.8.1 (2015-01-18)
+ * update NaN to 1.5.0 for iojs support
+
+# 0.8.0 (2014-08-03)
+ * migrate to NAN for bindings
+
+# v0.5.0
+ * Fix for issue around empty string params throwing Errors.
+ * Method deprecation.
+ * Upgrade from libeio/ev to libuv. (shtylman)
+ ** --- NOTE --- Breaks 0.4.x compatability
+ * EV_MULTIPLICITY compile flag.
+
+# v0.4.1
+ * Thread safety fix around OpenSSL (GH-32). (bnoordhuis - through node)
+ * C++ code changes using delete and new instead of malloc and free. (shtylman)
+ * Compile options for speed, zoom. (shtylman)
+ * Move much of the type and variable checking to the JS. (shtylman)
+
+# v0.4.0
+ * Added getRounds function that will tell you the number of rounds within a hash/salt
+
+# v0.3.2
+ * Fix api issue with async salt gen first param
+
+# v0.3.1
+ * Compile under node 0.5.x
+
+# v0.3.0
+ * Internal Refactoring
+ * Remove pthread dependencies and locking
+ * Fix compiler warnings and a memory bug
+
+# v0.2.4
+ * Use threadsafe functions instead of pthread mutexes
+ * salt validation to make sure the salt is of the correct size and format
+
+# v0.2.3
+ * cygwin support
+
+# v0.2.2
+ * Remove dependency on libbsd, use libssl instead
+
+# v0.2.0
+ * Added async functionality
+ * API changes
+ * hashpw -> encrypt
+ * all old sync methods now end with _sync
+ * Removed libbsd(arc4random) dependency...now uses openssl which is more widely spread
+
+# v0.1.2
+ * Security fix. Wasn't reading rounds in properly and was always only using 4 rounds
diff --git a/node_modules/bcrypt/Dockerfile b/node_modules/bcrypt/Dockerfile
new file mode 100644
index 0000000..2802baf
--- /dev/null
+++ b/node_modules/bcrypt/Dockerfile
@@ -0,0 +1,57 @@
+# Usage:
+#
+# docker build -t bcryptjs-builder .
+# CONTAINER=$(docker create bcryptjs-builder)
+# # Then copy the artifact to your host:
+# docker cp "$CONTAINER:/usr/local/opt/bcrypt-js/prebuilds" .
+# docker rm "$CONTAINER"
+#
+# Use --platform to build cross-platform i.e. for ARM:
+#
+# docker build -t bcryptjs-builder --platform "linux/arm64/v8" .
+# CONTAINER=$docker create --platform "linux/arm64/v8" bcryptjs-builder)
+# # this copies the prebuilds/linux-arm artifacts
+# docker cp "$CONTAINER:/usr/local/opt/bcrypt-js/prebuilds" .
+# docker rm "$CONTAINER"
+
+
+ARG FROM_IMAGE=node:18-bullseye
+#ARG FROM_IMAGE=arm32v7/node:16-bullseye
+#ARG FROM_IMAGE=arm64v8/node:16-bullseye
+FROM ${FROM_IMAGE}
+
+ENV project bcrypt-js
+ENV DEBIAN_FRONTEND noninteractive
+ENV LC_ALL en_US.UTF-8
+ENV LANG ${LC_ALL}
+
+RUN echo "#log: ${project}: Setup system" \
+ && set -x \
+ && apt-get update -y \
+ && apt-get install -y \
+ build-essential \
+ python3 \
+ && apt-get clean \
+ && update-alternatives --install /usr/local/bin/python python /usr/bin/python3 20 \
+ && npm i -g prebuildify@5 node-gyp@9 \
+ && sync
+
+ADD . /usr/local/opt/${project}
+WORKDIR /usr/local/opt/${project}
+
+RUN echo "#log: ${project}: Running build" \
+ && set -x \
+ && npm ci \
+ && npm run build
+
+ARG RUN_TESTS=true
+ARG TEST_TIMEOUT_SECONDS=
+
+RUN if "${RUN_TESTS}"; then \
+ echo "#log ${project}: Running tests" \
+ && npm test; \
+ else \
+ echo "#log ${project}: Tests were skipped!"; \
+ fi
+
+CMD /bin/bash -l
diff --git a/node_modules/bcrypt/Dockerfile-alpine b/node_modules/bcrypt/Dockerfile-alpine
new file mode 100644
index 0000000..7570cfe
--- /dev/null
+++ b/node_modules/bcrypt/Dockerfile-alpine
@@ -0,0 +1,41 @@
+# Usage:
+#
+# docker build -t bcryptjs-linux-alpine-builder -f Dockerfile-alpine .
+# CONTAINER=$(docker create bcryptjs-linux-alpine-builder)
+# # Then copy the artifact to your host:
+# docker cp "$CONTAINER:/usr/local/opt/bcrypt-js/prebuilds" .
+# docker rm "$CONTAINER"
+
+ARG FROM_IMAGE=node:18-alpine
+FROM ${FROM_IMAGE}
+
+ENV project bcrypt-js
+ENV DEBIAN_FRONTEND noninteractive
+ENV LC_ALL en_US.UTF-8
+ENV LANG ${LC_ALL}
+
+RUN echo "#log: ${project}: Setup system" \
+ && set -x \
+ && apk add --update build-base python3 \
+ && npm i -g prebuildify@5 node-gyp@9 \
+ && sync
+
+ADD . /usr/local/opt/${project}
+WORKDIR /usr/local/opt/${project}
+
+RUN echo "#log: ${project}: Running build" \
+ && set -x \
+ && npm ci \
+ && npm run build
+
+ARG RUN_TESTS=true
+ARG TEST_TIMEOUT_SECONDS=
+
+RUN if "${RUN_TESTS}"; then \
+ echo "#log ${project}: Running tests" \
+ && npm test; \
+ else \
+ echo "#log ${project}: Tests were skipped!"; \
+ fi
+
+CMD /bin/bash -l
diff --git a/node_modules/bcrypt/ISSUE_TEMPLATE.md b/node_modules/bcrypt/ISSUE_TEMPLATE.md
new file mode 100644
index 0000000..b4baa00
--- /dev/null
+++ b/node_modules/bcrypt/ISSUE_TEMPLATE.md
@@ -0,0 +1,18 @@
+Thanks for reporting a new issue with the node bcrypt module!
+
+To help you resolve your issue faster please make sure you have done the following:
+
+* Searched existing issues (even closed ones) for your same problem
+* Make sure you have installed the required dependencies listed on the readme
+* Read your npm error log for lines telling you what failed, usually it is a problem with not having the correct dependencies installed to build the native module
+
+Once you have done the above and are still confident that the issue is with the module, please describe it below. Some things that really help get your issue resolved faster are:
+
+* What went wrong?
+* What did you expect to happen?
+* Which version of nodejs and OS?
+* If you find a bug, please write a failing test.
+
+Thanks!
+
+P.S. If it doesn't look like you read the above then your issue will likely be closed without further explanation. Sorry, but there are just too many issues opened with no useful information or questions which have been previously addressed.
diff --git a/node_modules/bcrypt/LICENSE b/node_modules/bcrypt/LICENSE
new file mode 100644
index 0000000..94e2ba5
--- /dev/null
+++ b/node_modules/bcrypt/LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2010 Nicholas Campbell
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
\ No newline at end of file
diff --git a/node_modules/bcrypt/Makefile b/node_modules/bcrypt/Makefile
new file mode 100644
index 0000000..cb22252
--- /dev/null
+++ b/node_modules/bcrypt/Makefile
@@ -0,0 +1,19 @@
+TESTS = test/*.js
+
+all: test
+
+build: clean compile
+
+compile:
+ npm install .
+ npm run install
+
+test: build
+ @./node_modules/.bin/jest \
+ $(TESTS)
+
+clean:
+ rm -Rf lib/bindings/
+
+
+.PHONY: clean test build
diff --git a/node_modules/bcrypt/README.md b/node_modules/bcrypt/README.md
new file mode 100644
index 0000000..e923108
--- /dev/null
+++ b/node_modules/bcrypt/README.md
@@ -0,0 +1,388 @@
+# node.bcrypt.js
+
+[](https://github.com/kelektiv/node.bcrypt.js/actions/workflows/ci.yaml)
+
+[](https://ci.appveyor.com/project/defunctzombie/node-bcrypt-js-pgo26/branch/master)
+
+A library to help you hash passwords.
+
+You can read about [bcrypt in Wikipedia][bcryptwiki] as well as in the following article:
+[How To Safely Store A Password][codahale]
+
+## If You Are Submitting Bugs or Issues
+
+Please verify that the NodeJS version you are using is a _stable_ version; Unstable versions are currently not supported and issues created while using an unstable version will be closed.
+
+If you are on a stable version of NodeJS, please provide a sufficient code snippet or log files for installation issues. The code snippet does not require you to include confidential information. However, it must provide enough information so the problem can be replicable, or it may be closed without an explanation.
+
+
+## Version Compatibility
+
+_Please upgrade to atleast v5.0.0 to avoid security issues mentioned below._
+
+| Node Version | Bcrypt Version |
+| -------------- | ------------------|
+| 0.4 | <= 0.4 |
+| 0.6, 0.8, 0.10 | >= 0.5 |
+| 0.11 | >= 0.8 |
+| 4 | <= 2.1.0 |
+| 8 | >= 1.0.3 < 4.0.0 |
+| 10, 11 | >= 3 |
+| 12 onwards | >= 3.0.6 |
+
+`node-gyp` only works with stable/released versions of node. Since the `bcrypt` module uses `node-gyp` to build and install, you'll need a stable version of node to use bcrypt. If you do not, you'll likely see an error that starts with:
+
+```
+gyp ERR! stack Error: "pre" versions of node cannot be installed, use the --nodedir flag instead
+```
+
+## Security Issues And Concerns
+
+> Per bcrypt implementation, only the first 72 bytes of a string are used. Any extra bytes are ignored when matching passwords. Note that this is not the first 72 *characters*. It is possible for a string to contain less than 72 characters, while taking up more than 72 bytes (e.g. a UTF-8 encoded string containing emojis). If a string is provided, it will be encoded using UTF-8.
+
+As should be the case with any security tool, anyone using this library should scrutinise it. If you find or suspect an issue with the code, please bring it to the maintainers' attention. We will spend some time ensuring that this library is as secure as possible.
+
+Here is a list of BCrypt-related security issues/concerns that have come up over the years.
+
+* An [issue with passwords][jtr] was found with a version of the Blowfish algorithm developed for John the Ripper. This is not present in the OpenBSD version and is thus not a problem for this module. HT [zooko][zooko].
+* Versions `< 5.0.0` suffer from bcrypt wrap-around bug and _will truncate passwords >= 255 characters leading to severely weakened passwords_. Please upgrade at earliest. See [this wiki page][wrap-around-bug] for more details.
+* Versions `< 5.0.0` _do not handle NUL characters inside passwords properly leading to all subsequent characters being dropped and thus resulting in severely weakened passwords_. Please upgrade at earliest. See [this wiki page][improper-nuls] for more details.
+
+## Compatibility Note
+
+This library supports `$2a$` and `$2b$` prefix bcrypt hashes. `$2x$` and `$2y$` hashes are specific to bcrypt implementation developed for John the Ripper. In theory, they should be compatible with `$2b$` prefix.
+
+Compatibility with hashes generated by other languages is not 100% guaranteed due to difference in character encodings. However, it should not be an issue for most cases.
+
+### Migrating from v1.0.x
+
+Hashes generated in earlier version of `bcrypt` remain 100% supported in `v2.x.x` and later versions. In most cases, the migration should be a bump in the `package.json`.
+
+Hashes generated in `v2.x.x` using the defaults parameters will not work in earlier versions.
+
+## Dependencies
+
+* NodeJS
+* `node-gyp`
+ * Please check the dependencies for this tool at: https://github.com/nodejs/node-gyp
+ * Windows users will need the options for c# and c++ installed with their visual studio instance.
+ * Python 2.x/3.x
+* `OpenSSL` - This is only required to build the `bcrypt` project if you are using versions <= 0.7.7. Otherwise, we're using the builtin node crypto bindings for seed data (which use the same OpenSSL code paths we were, but don't have the external dependency).
+
+## Install via NPM
+
+```
+npm install bcrypt
+```
+***Note:*** OS X users using Xcode 4.3.1 or above may need to run the following command in their terminal prior to installing if errors occur regarding xcodebuild: ```sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer```
+
+_Pre-built binaries for various NodeJS versions are made available on a best-effort basis._
+
+Only the current stable and supported LTS releases are actively tested against.
+
+_There may be an interval between the release of the module and the availabilty of the compiled modules._
+
+Currently, we have pre-built binaries that support the following platforms:
+
+1. Windows x32 and x64
+2. Linux x64 (GlibC and musl)
+3. macOS
+
+If you face an error like this:
+
+```
+node-pre-gyp ERR! Tried to download(404): https://github.com/kelektiv/node.bcrypt.js/releases/download/v1.0.2/bcrypt_lib-v1.0.2-node-v48-linux-x64.tar.gz
+```
+
+make sure you have the appropriate dependencies installed and configured for your platform. You can find installation instructions for the dependencies for some common platforms [in this page][depsinstall].
+
+## Usage
+
+### async (recommended)
+
+```javascript
+const bcrypt = require('bcrypt');
+const saltRounds = 10;
+const myPlaintextPassword = 's0/\/\P4$$w0rD';
+const someOtherPlaintextPassword = 'not_bacon';
+```
+
+#### To hash a password:
+
+Technique 1 (generate a salt and hash on separate function calls):
+
+```javascript
+bcrypt.genSalt(saltRounds, function(err, salt) {
+ bcrypt.hash(myPlaintextPassword, salt, function(err, hash) {
+ // Store hash in your password DB.
+ });
+});
+```
+
+Technique 2 (auto-gen a salt and hash):
+
+```javascript
+bcrypt.hash(myPlaintextPassword, saltRounds, function(err, hash) {
+ // Store hash in your password DB.
+});
+```
+
+Note that both techniques achieve the same end-result.
+
+#### To check a password:
+
+```javascript
+// Load hash from your password DB.
+bcrypt.compare(myPlaintextPassword, hash, function(err, result) {
+ // result == true
+});
+bcrypt.compare(someOtherPlaintextPassword, hash, function(err, result) {
+ // result == false
+});
+```
+
+[A Note on Timing Attacks](#a-note-on-timing-attacks)
+
+### with promises
+
+bcrypt uses whatever `Promise` implementation is available in `global.Promise`. NodeJS >= 0.12 has a native `Promise` implementation built in. However, this should work in any Promises/A+ compliant implementation.
+
+Async methods that accept a callback, return a `Promise` when callback is not specified if Promise support is available.
+
+```javascript
+bcrypt.hash(myPlaintextPassword, saltRounds).then(function(hash) {
+ // Store hash in your password DB.
+});
+```
+```javascript
+// Load hash from your password DB.
+bcrypt.compare(myPlaintextPassword, hash).then(function(result) {
+ // result == true
+});
+bcrypt.compare(someOtherPlaintextPassword, hash).then(function(result) {
+ // result == false
+});
+```
+
+This is also compatible with `async/await`
+
+```javascript
+async function checkUser(username, password) {
+ //... fetch user from a db etc.
+
+ const match = await bcrypt.compare(password, user.passwordHash);
+
+ if(match) {
+ //login
+ }
+
+ //...
+}
+```
+
+### ESM import
+```javascript
+import bcrypt from "bcrypt";
+
+// later
+await bcrypt.compare(password, hash);
+```
+
+### sync
+
+```javascript
+const bcrypt = require('bcrypt');
+const saltRounds = 10;
+const myPlaintextPassword = 's0/\/\P4$$w0rD';
+const someOtherPlaintextPassword = 'not_bacon';
+```
+
+#### To hash a password:
+
+Technique 1 (generate a salt and hash on separate function calls):
+
+```javascript
+const salt = bcrypt.genSaltSync(saltRounds);
+const hash = bcrypt.hashSync(myPlaintextPassword, salt);
+// Store hash in your password DB.
+```
+
+Technique 2 (auto-gen a salt and hash):
+
+```javascript
+const hash = bcrypt.hashSync(myPlaintextPassword, saltRounds);
+// Store hash in your password DB.
+```
+
+As with async, both techniques achieve the same end-result.
+
+#### To check a password:
+
+```javascript
+// Load hash from your password DB.
+bcrypt.compareSync(myPlaintextPassword, hash); // true
+bcrypt.compareSync(someOtherPlaintextPassword, hash); // false
+```
+
+[A Note on Timing Attacks](#a-note-on-timing-attacks)
+
+### Why is async mode recommended over sync mode?
+We recommend using async API if you use `bcrypt` on a server. Bcrypt hashing is CPU intensive which will cause the sync APIs to block the event loop and prevent your application from servicing any inbound requests or events. The async version uses a thread pool which does not block the main event loop.
+
+## API
+
+`BCrypt.`
+
+ * `genSaltSync(rounds, minor)`
+ * `rounds` - [OPTIONAL] - the cost of processing the data. (default - 10)
+ * `minor` - [OPTIONAL] - minor version of bcrypt to use. (default - b)
+ * `genSalt(rounds, minor, cb)`
+ * `rounds` - [OPTIONAL] - the cost of processing the data. (default - 10)
+ * `minor` - [OPTIONAL] - minor version of bcrypt to use. (default - b)
+ * `cb` - [OPTIONAL] - a callback to be fired once the salt has been generated. uses eio making it asynchronous. If `cb` is not specified, a `Promise` is returned if Promise support is available.
+ * `err` - First parameter to the callback detailing any errors.
+ * `salt` - Second parameter to the callback providing the generated salt.
+ * `hashSync(data, salt)`
+ * `data` - [REQUIRED] - the data to be encrypted.
+ * `salt` - [REQUIRED] - the salt to be used to hash the password. if specified as a number then a salt will be generated with the specified number of rounds and used (see example under **Usage**).
+ * `hash(data, salt, cb)`
+ * `data` - [REQUIRED] - the data to be encrypted.
+ * `salt` - [REQUIRED] - the salt to be used to hash the password. if specified as a number then a salt will be generated with the specified number of rounds and used (see example under **Usage**).
+ * `cb` - [OPTIONAL] - a callback to be fired once the data has been encrypted. uses eio making it asynchronous. If `cb` is not specified, a `Promise` is returned if Promise support is available.
+ * `err` - First parameter to the callback detailing any errors.
+ * `encrypted` - Second parameter to the callback providing the encrypted form.
+ * `compareSync(data, encrypted)`
+ * `data` - [REQUIRED] - data to compare.
+ * `encrypted` - [REQUIRED] - data to be compared to.
+ * `compare(data, encrypted, cb)`
+ * `data` - [REQUIRED] - data to compare.
+ * `encrypted` - [REQUIRED] - data to be compared to.
+ * `cb` - [OPTIONAL] - a callback to be fired once the data has been compared. uses eio making it asynchronous. If `cb` is not specified, a `Promise` is returned if Promise support is available.
+ * `err` - First parameter to the callback detailing any errors.
+ * `same` - Second parameter to the callback providing whether the data and encrypted forms match [true | false].
+ * `getRounds(encrypted)` - return the number of rounds used to encrypt a given hash
+ * `encrypted` - [REQUIRED] - hash from which the number of rounds used should be extracted.
+
+## A Note on Rounds
+
+A note about the cost: when you are hashing your data, the module will go through a series of rounds to give you a secure hash. The value you submit is not just the number of rounds the module will go through to hash your data. The module will use the value you enter and go through `2^rounds` hashing iterations.
+
+From @garthk, on a 2GHz core you can roughly expect:
+
+ rounds=8 : ~40 hashes/sec
+ rounds=9 : ~20 hashes/sec
+ rounds=10: ~10 hashes/sec
+ rounds=11: ~5 hashes/sec
+ rounds=12: 2-3 hashes/sec
+ rounds=13: ~1 sec/hash
+ rounds=14: ~1.5 sec/hash
+ rounds=15: ~3 sec/hash
+ rounds=25: ~1 hour/hash
+ rounds=31: 2-3 days/hash
+
+
+## A Note on Timing Attacks
+
+Because it's come up multiple times in this project and other bcrypt projects, it needs to be said. The `bcrypt` library is not susceptible to timing attacks. From codahale/bcrypt-ruby#42:
+
+> One of the desired properties of a cryptographic hash function is preimage attack resistance, which means there is no shortcut for generating a message which, when hashed, produces a specific digest.
+
+A great thread on this, in much more detail can be found @ codahale/bcrypt-ruby#43
+
+If you're unfamiliar with timing attacks and want to learn more you can find a great writeup @ [A Lesson In Timing Attacks][timingatk]
+
+However, timing attacks are real. And the comparison function is _not_ time safe. That means that it may exit the function early in the comparison process. Timing attacks happen because of the above. We don't need to be careful that an attacker will learn anything, and our comparison function provides a comparison of hashes. It is a utility to the overall purpose of the library. If you end up using it for something else, we cannot guarantee the security of the comparator. Keep that in mind as you use the library.
+
+## Hash Info
+
+The characters that comprise the resultant hash are `./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789$`.
+
+Resultant hashes will be 60 characters long and they will include the salt among other parameters, as follows:
+
+`$[algorithm]$[cost]$[salt][hash]`
+
+- 2 chars hash algorithm identifier prefix. `"$2a$" or "$2b$"` indicates BCrypt
+- Cost-factor (n). Represents the exponent used to determine how many iterations 2^n
+- 16-byte (128-bit) salt, base64 encoded to 22 characters
+- 24-byte (192-bit) hash, base64 encoded to 31 characters
+
+Example:
+```
+$2b$10$nOUIs5kJ7naTuTFkBy1veuK0kSxUFXfuaOKdOKf9xYT0KKIGSJwFa
+ | | | |
+ | | | hash-value = K0kSxUFXfuaOKdOKf9xYT0KKIGSJwFa
+ | | |
+ | | salt = nOUIs5kJ7naTuTFkBy1veu
+ | |
+ | cost-factor => 10 = 2^10 rounds
+ |
+ hash-algorithm identifier => 2b = BCrypt
+```
+
+## Testing
+
+If you create a pull request, tests better pass :)
+
+```
+npm install
+npm test
+```
+
+## Credits
+
+The code for this comes from a few sources:
+
+* blowfish.cc - OpenBSD
+* bcrypt.cc - OpenBSD
+* bcrypt::gen_salt - [gen_salt inclusion to bcrypt][bcryptgs]
+* bcrypt_node.cc - me
+
+## Contributors
+
+* [Antonio Salazar Cardozo][shadowfiend] - Early MacOS X support (when we used libbsd)
+* [Ben Glow][pixelglow] - Fixes for thread safety with async calls
+* [Van Nguyen][thegoleffect] - Found a timing attack in the comparator
+* [NewITFarmer][newitfarmer] - Initial Cygwin support
+* [David Trejo][dtrejo] - packaging fixes
+* [Alfred Westerveld][alfredwesterveld] - packaging fixes
+* [Vincent Côté-Roy][vincentr] - Testing around concurrency issues
+* [Lloyd Hilaiel][lloyd] - Documentation fixes
+* [Roman Shtylman][shtylman] - Code refactoring, general rot reduction, compile options, better memory management with delete and new, and an upgrade to libuv over eio/ev.
+* [Vadim Graboys][vadimg] - Code changes to support 0.5.5+
+* [Ben Noordhuis][bnoordhuis] - Fixed a thread safety issue in nodejs that was perfectly mappable to this module.
+* [Nate Rajlich][tootallnate] - Bindings and build process.
+* [Sean McArthur][seanmonstar] - Windows Support
+* [Fanie Oosthuysen][weareu] - Windows Support
+* [Amitosh Swain Mahapatra][recrsn] - $2b$ hash support, ES6 Promise support
+* [Nicola Del Gobbo][NickNaso] - Initial implementation with N-API
+
+## License
+Unless stated elsewhere, file headers or otherwise, the license as stated in the LICENSE file.
+
+[bcryptwiki]: https://en.wikipedia.org/wiki/Bcrypt
+[bcryptgs]: http://mail-index.netbsd.org/tech-crypto/2002/05/24/msg000204.html
+[codahale]: http://codahale.com/how-to-safely-store-a-password/
+[gh13]: https://github.com/ncb000gt/node.bcrypt.js/issues/13
+[jtr]: http://www.openwall.com/lists/oss-security/2011/06/20/2
+[depsinstall]: https://github.com/kelektiv/node.bcrypt.js/wiki/Installation-Instructions
+[timingatk]: https://codahale.com/a-lesson-in-timing-attacks/
+[wrap-around-bug]: https://github.com/kelektiv/node.bcrypt.js/wiki/Security-Issues-and-Concerns#bcrypt-wrap-around-bug-medium-severity
+[improper-nuls]: https://github.com/kelektiv/node.bcrypt.js/wiki/Security-Issues-and-Concerns#improper-nul-handling-medium-severity
+
+[shadowfiend]:https://github.com/Shadowfiend
+[thegoleffect]:https://github.com/thegoleffect
+[pixelglow]:https://github.com/pixelglow
+[dtrejo]:https://github.com/dtrejo
+[alfredwesterveld]:https://github.com/alfredwesterveld
+[newitfarmer]:https://github.com/newitfarmer
+[zooko]:https://twitter.com/zooko
+[vincentr]:https://twitter.com/vincentcr
+[lloyd]:https://github.com/lloyd
+[shtylman]:https://github.com/shtylman
+[vadimg]:https://github.com/vadimg
+[bnoordhuis]:https://github.com/bnoordhuis
+[tootallnate]:https://github.com/tootallnate
+[seanmonstar]:https://github.com/seanmonstar
+[weareu]:https://github.com/weareu
+[recrsn]:https://github.com/recrsn
+[NickNaso]: https://github.com/NickNaso
diff --git a/node_modules/bcrypt/SECURITY.md b/node_modules/bcrypt/SECURITY.md
new file mode 100644
index 0000000..c132dc8
--- /dev/null
+++ b/node_modules/bcrypt/SECURITY.md
@@ -0,0 +1,15 @@
+# Security Policy
+
+As with any software, `bcrypt` is likely to have bugs. Please report any security vulnerabilities responsibly
+
+## Supported Versions
+
+| Version | Supported |
+| ------- | ------------------ |
+| 5.0.x | :white_check_mark: |
+| < 5.0 | :x: |
+
+## Reporting a Vulnerability
+
+If you are reporting a security vulnerability, please refrain from opening a GitHub issue and instead mail it to
+one of the maintainers listed in the README.
diff --git a/node_modules/bcrypt/bcrypt.js b/node_modules/bcrypt/bcrypt.js
new file mode 100644
index 0000000..62da525
--- /dev/null
+++ b/node_modules/bcrypt/bcrypt.js
@@ -0,0 +1,242 @@
+const path = require('path');
+const bindings = require('node-gyp-build')(path.resolve(__dirname));
+
+const crypto = require('crypto');
+
+const promises = require('./promises');
+
+/// generate a salt (sync)
+/// @param {Number} [rounds] number of rounds (default 10)
+/// @return {String} salt
+function genSaltSync(rounds, minor) {
+ // default 10 rounds
+ if (!rounds) {
+ rounds = 10;
+ } else if (typeof rounds !== 'number') {
+ throw new Error('rounds must be a number');
+ }
+
+ if (!minor) {
+ minor = 'b';
+ } else if (minor !== 'b' && minor !== 'a') {
+ throw new Error('minor must be either "a" or "b"');
+ }
+
+ return bindings.gen_salt_sync(minor, rounds, crypto.randomBytes(16));
+}
+
+/// generate a salt
+/// @param {Number} [rounds] number of rounds (default 10)
+/// @param {Function} cb callback(err, salt)
+function genSalt(rounds, minor, cb) {
+ let error;
+
+ // if callback is first argument, then use defaults for others
+ if (typeof arguments[0] === 'function') {
+ // have to set callback first otherwise arguments are overridden
+ cb = arguments[0];
+ rounds = 10;
+ minor = 'b';
+ // callback is second argument
+ } else if (typeof arguments[1] === 'function') {
+ // have to set callback first otherwise arguments are overridden
+ cb = arguments[1];
+ minor = 'b';
+ }
+
+ if (!cb) {
+ return promises.promise(genSalt, this, [rounds, minor]);
+ }
+
+ // default 10 rounds
+ if (!rounds) {
+ rounds = 10;
+ } else if (typeof rounds !== 'number') {
+ // callback error asynchronously
+ error = new Error('rounds must be a number');
+ return process.nextTick(function () {
+ cb(error);
+ });
+ }
+
+ if (!minor) {
+ minor = 'b'
+ } else if (minor !== 'b' && minor !== 'a') {
+ error = new Error('minor must be either "a" or "b"');
+ return process.nextTick(function () {
+ cb(error);
+ });
+ }
+
+ crypto.randomBytes(16, function (error, randomBytes) {
+ if (error) {
+ cb(error);
+ return;
+ }
+
+ bindings.gen_salt(minor, rounds, randomBytes, cb);
+ });
+}
+
+/// hash data using a salt
+/// @param {String|Buffer} data the data to encrypt
+/// @param {String} salt the salt to use when hashing
+/// @return {String} hash
+function hashSync(data, salt) {
+ if (data == null || salt == null) {
+ throw new Error('data and salt arguments required');
+ }
+
+ if (!(typeof data === 'string' || data instanceof Buffer) || (typeof salt !== 'string' && typeof salt !== 'number')) {
+ throw new Error('data must be a string or Buffer and salt must either be a salt string or a number of rounds');
+ }
+
+ if (typeof salt === 'number') {
+ salt = module.exports.genSaltSync(salt);
+ }
+
+ return bindings.encrypt_sync(data, salt);
+}
+
+/// hash data using a salt
+/// @param {String|Buffer} data the data to encrypt
+/// @param {String} salt the salt to use when hashing
+/// @param {Function} cb callback(err, hash)
+function hash(data, salt, cb) {
+ let error;
+
+ if (typeof data === 'function') {
+ error = new Error('data must be a string or Buffer and salt must either be a salt string or a number of rounds');
+ return process.nextTick(function () {
+ data(error);
+ });
+ }
+
+ if (typeof salt === 'function') {
+ error = new Error('data must be a string or Buffer and salt must either be a salt string or a number of rounds');
+ return process.nextTick(function () {
+ salt(error);
+ });
+ }
+
+ // cb exists but is not a function
+ // return a rejecting promise
+ if (cb && typeof cb !== 'function') {
+ return promises.reject(new Error('cb must be a function or null to return a Promise'));
+ }
+
+ if (!cb) {
+ return promises.promise(hash, this, [data, salt]);
+ }
+
+ if (data == null || salt == null) {
+ error = new Error('data and salt arguments required');
+ return process.nextTick(function () {
+ cb(error);
+ });
+ }
+
+ if (!(typeof data === 'string' || data instanceof Buffer) || (typeof salt !== 'string' && typeof salt !== 'number')) {
+ error = new Error('data must be a string or Buffer and salt must either be a salt string or a number of rounds');
+ return process.nextTick(function () {
+ cb(error);
+ });
+ }
+
+
+ if (typeof salt === 'number') {
+ return module.exports.genSalt(salt, function (err, salt) {
+ return bindings.encrypt(data, salt, cb);
+ });
+ }
+
+ return bindings.encrypt(data, salt, cb);
+}
+
+/// compare raw data to hash
+/// @param {String|Buffer} data the data to hash and compare
+/// @param {String} hash expected hash
+/// @return {bool} true if hashed data matches hash
+function compareSync(data, hash) {
+ if (data == null || hash == null) {
+ throw new Error('data and hash arguments required');
+ }
+
+ if (!(typeof data === 'string' || data instanceof Buffer) || typeof hash !== 'string') {
+ throw new Error('data must be a string or Buffer and hash must be a string');
+ }
+
+ return bindings.compare_sync(data, hash);
+}
+
+/// compare raw data to hash
+/// @param {String|Buffer} data the data to hash and compare
+/// @param {String} hash expected hash
+/// @param {Function} cb callback(err, matched) - matched is true if hashed data matches hash
+function compare(data, hash, cb) {
+ let error;
+
+ if (typeof data === 'function') {
+ error = new Error('data and hash arguments required');
+ return process.nextTick(function () {
+ data(error);
+ });
+ }
+
+ if (typeof hash === 'function') {
+ error = new Error('data and hash arguments required');
+ return process.nextTick(function () {
+ hash(error);
+ });
+ }
+
+ // cb exists but is not a function
+ // return a rejecting promise
+ if (cb && typeof cb !== 'function') {
+ return promises.reject(new Error('cb must be a function or null to return a Promise'));
+ }
+
+ if (!cb) {
+ return promises.promise(compare, this, [data, hash]);
+ }
+
+ if (data == null || hash == null) {
+ error = new Error('data and hash arguments required');
+ return process.nextTick(function () {
+ cb(error);
+ });
+ }
+
+ if (!(typeof data === 'string' || data instanceof Buffer) || typeof hash !== 'string') {
+ error = new Error('data and hash must be strings');
+ return process.nextTick(function () {
+ cb(error);
+ });
+ }
+
+ return bindings.compare(data, hash, cb);
+}
+
+/// @param {String} hash extract rounds from this hash
+/// @return {Number} the number of rounds used to encrypt a given hash
+function getRounds(hash) {
+ if (hash == null) {
+ throw new Error('hash argument required');
+ }
+
+ if (typeof hash !== 'string') {
+ throw new Error('hash must be a string');
+ }
+
+ return bindings.get_rounds(hash);
+}
+
+module.exports = {
+ genSaltSync,
+ genSalt,
+ hashSync,
+ hash,
+ compareSync,
+ compare,
+ getRounds,
+}
diff --git a/node_modules/bcrypt/binding.gyp b/node_modules/bcrypt/binding.gyp
new file mode 100644
index 0000000..46428be
--- /dev/null
+++ b/node_modules/bcrypt/binding.gyp
@@ -0,0 +1,49 @@
+{
+ "variables": {
+ "NODE_VERSION%":" {
+ const start = Date.now();
+
+ // genSalt
+ const salt = await bcrypt.genSalt(10)
+ console.log('salt: ' + salt);
+ console.log('salt cb end: ' + (Date.now() - start) + 'ms');
+
+ // hash
+ const crypted = await bcrypt.hash('test', salt)
+ console.log('crypted: ' + crypted);
+ console.log('crypted cb end: ' + (Date.now() - start) + 'ms');
+ console.log('rounds used from hash:', bcrypt.getRounds(crypted));
+
+ // compare
+ const res = await bcrypt.compare('test', crypted)
+ console.log('compared true: ' + res);
+ console.log('compared true cb end: ' + (Date.now() - start) + 'ms');
+
+ // compare
+ const res2 = await bcrypt.compare('bacon', crypted)
+ console.log('compared false: ' + res2);
+ console.log('compared false cb end: ' + (Date.now() - start) + 'ms');
+
+ console.log('end: ' + (Date.now() - start) + 'ms');
+})();
diff --git a/node_modules/bcrypt/examples/forever_gen_salt.js b/node_modules/bcrypt/examples/forever_gen_salt.js
new file mode 100644
index 0000000..3f2ff2f
--- /dev/null
+++ b/node_modules/bcrypt/examples/forever_gen_salt.js
@@ -0,0 +1,8 @@
+const bcrypt = require('../bcrypt');
+
+(function printSalt() {
+ bcrypt.genSalt(10, (err, salt) => {
+ console.log('salt: ' + salt);
+ printSalt();
+ });
+})()
diff --git a/node_modules/bcrypt/node_modules/node-addon-api/LICENSE.md b/node_modules/bcrypt/node_modules/node-addon-api/LICENSE.md
new file mode 100644
index 0000000..819d91a
--- /dev/null
+++ b/node_modules/bcrypt/node_modules/node-addon-api/LICENSE.md
@@ -0,0 +1,9 @@
+The MIT License (MIT)
+
+Copyright (c) 2017 [Node.js API collaborators](https://github.com/nodejs/node-addon-api#collaborators)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/node_modules/bcrypt/node_modules/node-addon-api/README.md b/node_modules/bcrypt/node_modules/node-addon-api/README.md
new file mode 100644
index 0000000..39df5a9
--- /dev/null
+++ b/node_modules/bcrypt/node_modules/node-addon-api/README.md
@@ -0,0 +1,95 @@
+# **node-addon-api module**
+
+[](https://app.codecov.io/gh/nodejs/node-addon-api/tree/main)
+
+[](https://nodei.co/npm/node-addon-api/) [](https://nodei.co/npm/node-addon-api/)
+
+This module contains **header-only C++ wrapper classes** which simplify
+the use of the C based [Node-API](https://nodejs.org/dist/latest/docs/api/n-api.html)
+provided by Node.js when using C++. It provides a C++ object model
+and exception handling semantics with low overhead.
+
+- [API References](doc/README.md)
+- [Badges](#badges)
+- [Contributing](#contributing)
+- [License](#license)
+
+## API References
+
+API references are available in the [doc](doc/README.md) directory.
+
+
+## Current version: 8.6.0
+
+
+(See [CHANGELOG.md](CHANGELOG.md) for complete Changelog)
+
+node-addon-api is based on [Node-API](https://nodejs.org/api/n-api.html) and supports using different Node-API versions.
+This allows addons built with it to run with Node.js versions which support the targeted Node-API version.
+**However** the node-addon-api support model is to support only the active LTS Node.js versions. This means that
+every year there will be a new major which drops support for the Node.js LTS version which has gone out of service.
+
+The oldest Node.js version supported by the current version of node-addon-api is Node.js 18.x.
+
+## Badges
+
+The use of badges is recommended to indicate the minimum version of Node-API
+required for the module. This helps to determine which Node.js major versions are
+supported. Addon maintainers can consult the [Node-API support matrix][] to determine
+which Node.js versions provide a given Node-API version. The following badges are
+available:
+
+
+
+
+
+
+
+
+
+
+
+
+## Contributing
+
+We love contributions from the community to **node-addon-api**!
+See [CONTRIBUTING.md](CONTRIBUTING.md) for more details on our philosophy around extending this module.
+
+## Team members
+
+### Active
+
+| Name | GitHub Link |
+| ------------------- | ----------------------------------------------------- |
+| Anna Henningsen | [addaleax](https://github.com/addaleax) |
+| Chengzhong Wu | [legendecas](https://github.com/legendecas) |
+| Jack Xia | [JckXia](https://github.com/JckXia) |
+| Kevin Eady | [KevinEady](https://github.com/KevinEady) |
+| Michael Dawson | [mhdawson](https://github.com/mhdawson) |
+| Nicola Del Gobbo | [NickNaso](https://github.com/NickNaso) |
+| Vladimir Morozov | [vmoroz](https://github.com/vmoroz) |
+
+
+
+Emeritus
+
+### Emeritus
+
+| Name | GitHub Link |
+| ------------------- | ----------------------------------------------------- |
+| Arunesh Chandra | [aruneshchandra](https://github.com/aruneshchandra) |
+| Benjamin Byholm | [kkoopa](https://github.com/kkoopa) |
+| Gabriel Schulhof | [gabrielschulhof](https://github.com/gabrielschulhof) |
+| Hitesh Kanwathirtha | [digitalinfinity](https://github.com/digitalinfinity) |
+| Jason Ginchereau | [jasongin](https://github.com/jasongin) |
+| Jim Schlight | [jschlight](https://github.com/jschlight) |
+| Sampson Gao | [sampsongao](https://github.com/sampsongao) |
+| Taylor Woll | [boingoing](https://github.com/boingoing) |
+
+
+
+## License
+
+Licensed under [MIT](./LICENSE.md)
+
+[Node-API support matrix]: https://nodejs.org/dist/latest/docs/api/n-api.html#node-api-version-matrix
diff --git a/node_modules/bcrypt/node_modules/node-addon-api/common.gypi b/node_modules/bcrypt/node_modules/node-addon-api/common.gypi
new file mode 100644
index 0000000..5fda7e7
--- /dev/null
+++ b/node_modules/bcrypt/node_modules/node-addon-api/common.gypi
@@ -0,0 +1,21 @@
+{
+ 'variables': {
+ 'NAPI_VERSION%': "
+inline PropertyDescriptor PropertyDescriptor::Accessor(
+ const char* utf8name,
+ Getter getter,
+ napi_property_attributes attributes,
+ void* /*data*/) {
+ using CbData = details::CallbackData;
+ // TODO: Delete when the function is destroyed
+ auto callbackData = new CbData({getter, nullptr});
+
+ return PropertyDescriptor({utf8name,
+ nullptr,
+ nullptr,
+ CbData::Wrapper,
+ nullptr,
+ nullptr,
+ attributes,
+ callbackData});
+}
+
+template
+inline PropertyDescriptor PropertyDescriptor::Accessor(
+ const std::string& utf8name,
+ Getter getter,
+ napi_property_attributes attributes,
+ void* data) {
+ return Accessor(utf8name.c_str(), getter, attributes, data);
+}
+
+template
+inline PropertyDescriptor PropertyDescriptor::Accessor(
+ napi_value name,
+ Getter getter,
+ napi_property_attributes attributes,
+ void* /*data*/) {
+ using CbData = details::CallbackData;
+ // TODO: Delete when the function is destroyed
+ auto callbackData = new CbData({getter, nullptr});
+
+ return PropertyDescriptor({nullptr,
+ name,
+ nullptr,
+ CbData::Wrapper,
+ nullptr,
+ nullptr,
+ attributes,
+ callbackData});
+}
+
+template
+inline PropertyDescriptor PropertyDescriptor::Accessor(
+ Name name, Getter getter, napi_property_attributes attributes, void* data) {
+ napi_value nameValue = name;
+ return PropertyDescriptor::Accessor(nameValue, getter, attributes, data);
+}
+
+template
+inline PropertyDescriptor PropertyDescriptor::Accessor(
+ const char* utf8name,
+ Getter getter,
+ Setter setter,
+ napi_property_attributes attributes,
+ void* /*data*/) {
+ using CbData = details::AccessorCallbackData;
+ // TODO: Delete when the function is destroyed
+ auto callbackData = new CbData({getter, setter, nullptr});
+
+ return PropertyDescriptor({utf8name,
+ nullptr,
+ nullptr,
+ CbData::GetterWrapper,
+ CbData::SetterWrapper,
+ nullptr,
+ attributes,
+ callbackData});
+}
+
+template
+inline PropertyDescriptor PropertyDescriptor::Accessor(
+ const std::string& utf8name,
+ Getter getter,
+ Setter setter,
+ napi_property_attributes attributes,
+ void* data) {
+ return Accessor(utf8name.c_str(), getter, setter, attributes, data);
+}
+
+template
+inline PropertyDescriptor PropertyDescriptor::Accessor(
+ napi_value name,
+ Getter getter,
+ Setter setter,
+ napi_property_attributes attributes,
+ void* /*data*/) {
+ using CbData = details::AccessorCallbackData;
+ // TODO: Delete when the function is destroyed
+ auto callbackData = new CbData({getter, setter, nullptr});
+
+ return PropertyDescriptor({nullptr,
+ name,
+ nullptr,
+ CbData::GetterWrapper,
+ CbData::SetterWrapper,
+ nullptr,
+ attributes,
+ callbackData});
+}
+
+template
+inline PropertyDescriptor PropertyDescriptor::Accessor(
+ Name name,
+ Getter getter,
+ Setter setter,
+ napi_property_attributes attributes,
+ void* data) {
+ napi_value nameValue = name;
+ return PropertyDescriptor::Accessor(
+ nameValue, getter, setter, attributes, data);
+}
+
+template
+inline PropertyDescriptor PropertyDescriptor::Function(
+ const char* utf8name,
+ Callable cb,
+ napi_property_attributes attributes,
+ void* /*data*/) {
+ using ReturnType = decltype(cb(CallbackInfo(nullptr, nullptr)));
+ using CbData = details::CallbackData;
+ // TODO: Delete when the function is destroyed
+ auto callbackData = new CbData({cb, nullptr});
+
+ return PropertyDescriptor({utf8name,
+ nullptr,
+ CbData::Wrapper,
+ nullptr,
+ nullptr,
+ nullptr,
+ attributes,
+ callbackData});
+}
+
+template
+inline PropertyDescriptor PropertyDescriptor::Function(
+ const std::string& utf8name,
+ Callable cb,
+ napi_property_attributes attributes,
+ void* data) {
+ return Function(utf8name.c_str(), cb, attributes, data);
+}
+
+template
+inline PropertyDescriptor PropertyDescriptor::Function(
+ napi_value name,
+ Callable cb,
+ napi_property_attributes attributes,
+ void* /*data*/) {
+ using ReturnType = decltype(cb(CallbackInfo(nullptr, nullptr)));
+ using CbData = details::CallbackData;
+ // TODO: Delete when the function is destroyed
+ auto callbackData = new CbData({cb, nullptr});
+
+ return PropertyDescriptor({nullptr,
+ name,
+ CbData::Wrapper,
+ nullptr,
+ nullptr,
+ nullptr,
+ attributes,
+ callbackData});
+}
+
+template
+inline PropertyDescriptor PropertyDescriptor::Function(
+ Name name, Callable cb, napi_property_attributes attributes, void* data) {
+ napi_value nameValue = name;
+ return PropertyDescriptor::Function(nameValue, cb, attributes, data);
+}
+
+#endif // !SRC_NAPI_INL_DEPRECATED_H_
diff --git a/node_modules/bcrypt/node_modules/node-addon-api/napi-inl.h b/node_modules/bcrypt/node_modules/node-addon-api/napi-inl.h
new file mode 100644
index 0000000..0f1717e
--- /dev/null
+++ b/node_modules/bcrypt/node_modules/node-addon-api/napi-inl.h
@@ -0,0 +1,7108 @@
+#ifndef SRC_NAPI_INL_H_
+#define SRC_NAPI_INL_H_
+
+////////////////////////////////////////////////////////////////////////////////
+// Node-API C++ Wrapper Classes
+//
+// Inline header-only implementations for "Node-API" ABI-stable C APIs for
+// Node.js.
+////////////////////////////////////////////////////////////////////////////////
+
+// Note: Do not include this file directly! Include "napi.h" instead.
+// This should be a no-op and is intended for better IDE integration.
+#include "napi.h"
+
+#include
+#include
+#include
+#if NAPI_HAS_THREADS
+#include
+#endif // NAPI_HAS_THREADS
+#include
+#include
+
+#if defined(__clang__) || defined(__GNUC__)
+#define NAPI_NO_SANITIZE_VPTR __attribute__((no_sanitize("vptr")))
+#else
+#define NAPI_NO_SANITIZE_VPTR
+#endif
+
+namespace Napi {
+
+#ifdef NAPI_CPP_CUSTOM_NAMESPACE
+namespace NAPI_CPP_CUSTOM_NAMESPACE {
+#endif
+
+// Helpers to handle functions exposed from C++ and internal constants.
+namespace details {
+
+// New napi_status constants not yet available in all supported versions of
+// Node.js releases. Only necessary when they are used in napi.h and napi-inl.h.
+constexpr int napi_no_external_buffers_allowed = 22;
+
+template
+inline void default_basic_finalizer(node_addon_api_basic_env /*env*/,
+ void* data,
+ void* /*hint*/) {
+ delete static_cast(data);
+}
+
+// Attach a data item to an object and delete it when the object gets
+// garbage-collected.
+// TODO: Replace this code with `napi_add_finalizer()` whenever it becomes
+// available on all supported versions of Node.js.
+template <
+ typename FreeType,
+ node_addon_api_basic_finalize finalizer = default_basic_finalizer>
+inline napi_status AttachData(napi_env env,
+ napi_value obj,
+ FreeType* data,
+ void* hint = nullptr) {
+ napi_status status;
+#if (NAPI_VERSION < 5)
+ napi_value symbol, external;
+ status = napi_create_symbol(env, nullptr, &symbol);
+ if (status == napi_ok) {
+ status = napi_create_external(env, data, finalizer, hint, &external);
+ if (status == napi_ok) {
+ napi_property_descriptor desc = {nullptr,
+ symbol,
+ nullptr,
+ nullptr,
+ nullptr,
+ external,
+ napi_default,
+ nullptr};
+ status = napi_define_properties(env, obj, 1, &desc);
+ }
+ }
+#else // NAPI_VERSION >= 5
+ status = napi_add_finalizer(env, obj, data, finalizer, hint, nullptr);
+#endif
+ return status;
+}
+
+// For use in JS to C++ callback wrappers to catch any Napi::Error exceptions
+// and rethrow them as JavaScript exceptions before returning from the callback.
+template
+#ifdef NODE_ADDON_API_CPP_EXCEPTIONS_ALL
+inline napi_value WrapCallback(napi_env env, Callable callback) {
+#else
+inline napi_value WrapCallback(napi_env, Callable callback) {
+#endif
+#ifdef NODE_ADDON_API_CPP_EXCEPTIONS
+ try {
+ return callback();
+ } catch (const Error& e) {
+ e.ThrowAsJavaScriptException();
+ return nullptr;
+ }
+#ifdef NODE_ADDON_API_CPP_EXCEPTIONS_ALL
+ catch (const std::exception& e) {
+ Napi::Error::New(env, e.what()).ThrowAsJavaScriptException();
+ return nullptr;
+ } catch (...) {
+ Napi::Error::New(env, "A native exception was thrown")
+ .ThrowAsJavaScriptException();
+ return nullptr;
+ }
+#endif // NODE_ADDON_API_CPP_EXCEPTIONS_ALL
+#else // NODE_ADDON_API_CPP_EXCEPTIONS
+ // When C++ exceptions are disabled, errors are immediately thrown as JS
+ // exceptions, so there is no need to catch and rethrow them here.
+ return callback();
+#endif // NODE_ADDON_API_CPP_EXCEPTIONS
+}
+
+// For use in JS to C++ void callback wrappers to catch any Napi::Error
+// exceptions and rethrow them as JavaScript exceptions before returning from
+// the callback.
+template
+inline void WrapVoidCallback(Callable callback) {
+#ifdef NODE_ADDON_API_CPP_EXCEPTIONS
+ try {
+ callback();
+ } catch (const Error& e) {
+ e.ThrowAsJavaScriptException();
+ }
+#else // NAPI_CPP_EXCEPTIONS
+ // When C++ exceptions are disabled, errors are immediately thrown as JS
+ // exceptions, so there is no need to catch and rethrow them here.
+ callback();
+#endif // NAPI_CPP_EXCEPTIONS
+}
+
+// For use in JS to C++ void callback wrappers to catch _any_ thrown exception
+// and rethrow them as JavaScript exceptions before returning from the callback,
+// wrapping in an Napi::Error as needed.
+template
+#ifdef NODE_ADDON_API_CPP_EXCEPTIONS_ALL
+inline void WrapVoidCallback(napi_env env, Callable callback) {
+#else
+inline void WrapVoidCallback(napi_env, Callable callback) {
+#endif
+#ifdef NODE_ADDON_API_CPP_EXCEPTIONS
+ try {
+ callback();
+ } catch (const Error& e) {
+ e.ThrowAsJavaScriptException();
+ }
+#ifdef NODE_ADDON_API_CPP_EXCEPTIONS_ALL
+ catch (const std::exception& e) {
+ Napi::Error::New(env, e.what()).ThrowAsJavaScriptException();
+ } catch (...) {
+ Napi::Error::New(env, "A native exception was thrown")
+ .ThrowAsJavaScriptException();
+ }
+#endif // NODE_ADDON_API_CPP_EXCEPTIONS_ALL
+#else
+ // When C++ exceptions are disabled, there is no need to catch and rethrow C++
+ // exceptions. JS errors should be thrown with
+ // `Error::ThrowAsJavaScriptException`.
+ callback();
+#endif // NODE_ADDON_API_CPP_EXCEPTIONS
+}
+
+template
+struct CallbackData {
+ static inline napi_value Wrapper(napi_env env, napi_callback_info info) {
+ return details::WrapCallback(env, [&] {
+ CallbackInfo callbackInfo(env, info);
+ CallbackData* callbackData =
+ static_cast(callbackInfo.Data());
+ callbackInfo.SetData(callbackData->data);
+ return callbackData->callback(callbackInfo);
+ });
+ }
+
+ Callable callback;
+ void* data;
+};
+
+template
+struct CallbackData {
+ static inline napi_value Wrapper(napi_env env, napi_callback_info info) {
+ return details::WrapCallback(env, [&] {
+ CallbackInfo callbackInfo(env, info);
+ CallbackData* callbackData =
+ static_cast(callbackInfo.Data());
+ callbackInfo.SetData(callbackData->data);
+ callbackData->callback(callbackInfo);
+ return nullptr;
+ });
+ }
+
+ Callable callback;
+ void* data;
+};
+
+template
+napi_value TemplatedVoidCallback(napi_env env,
+ napi_callback_info info) NAPI_NOEXCEPT {
+ return details::WrapCallback(env, [&] {
+ CallbackInfo cbInfo(env, info);
+ Callback(cbInfo);
+ return nullptr;
+ });
+}
+
+template
+napi_value TemplatedCallback(napi_env env,
+ napi_callback_info info) NAPI_NOEXCEPT {
+ return details::WrapCallback(env, [&] {
+ CallbackInfo cbInfo(env, info);
+ // MSVC requires to copy 'Callback' function pointer to a local variable
+ // before invoking it.
+ auto callback = Callback;
+ return callback(cbInfo);
+ });
+}
+
+template
+napi_value TemplatedInstanceCallback(napi_env env,
+ napi_callback_info info) NAPI_NOEXCEPT {
+ return details::WrapCallback(env, [&] {
+ CallbackInfo cbInfo(env, info);
+ T* instance = T::Unwrap(cbInfo.This().As