nano-pow 4.0.1 → 4.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,15 +2,15 @@
2
2
  # SPDX-FileCopyrightText: 2025 Chris Duncan <chris@zoso.dev>
3
3
  # SPDX-License-Identifier: GPL-3.0-or-later
4
4
 
5
- SCRIPT_LINK=$(readlink -f $0);
6
- SCRIPT_DIR=$(dirname $SCRIPT_LINK);
7
- NANO_POW_HOME=$HOME/.nano-pow;
8
- NANO_POW_LOGS=$NANO_POW_HOME/logs;
5
+ SCRIPT_LINK=$(readlink -f "$0");
6
+ SCRIPT_DIR=$(dirname "$SCRIPT_LINK");
7
+ NANO_POW_HOME="$HOME"/.nano-pow;
8
+ NANO_POW_LOGS="$NANO_POW_HOME"/logs;
9
9
 
10
- mkdir -p $NANO_POW_LOGS;
11
- if [ $1 = '--server' ]; then
10
+ mkdir -p "$NANO_POW_LOGS";
11
+ if [ "$1" = '--server' ]; then
12
12
  shift;
13
- node $SCRIPT_DIR/server.js $@ > $NANO_POW_LOGS/nano-pow-server-$(date +%s).log 2>&1 & echo $! > $NANO_POW_HOME/server.pid;
13
+ node "$SCRIPT_DIR"/server.js "$@" > "$NANO_POW_LOGS"/nano-pow-server-$(date +%s).log 2>&1 & echo "$!" > "$NANO_POW_HOME"/server.pid;
14
14
  else
15
- node $SCRIPT_DIR/cli.js $@;
15
+ node "$SCRIPT_DIR"/cli.js "$@";
16
16
  fi;
@@ -1,8 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  //! SPDX-FileCopyrightText: 2025 Chris Duncan <chris@zoso.dev>
3
3
  //! SPDX-License-Identifier: GPL-3.0-or-later
4
- import * as http from "node:http";
4
+ import * as crypto from "node:crypto";
5
+ import * as dns from "node:dns/promises";
5
6
  import * as fs from "node:fs/promises";
7
+ import * as http from "node:http";
8
+ import * as os from "node:os";
6
9
  import * as puppeteer from "puppeteer";
7
10
  import { serverHelp } from "../../docs/index.js";
8
11
  const PORT = process.env.PORT || 3e3;
@@ -87,7 +90,9 @@ async function work_validate(res, json) {
87
90
  page.on("console", (msg) => {
88
91
  log(msg.text());
89
92
  });
90
- await fs.writeFile(`${import.meta.dirname}/server.html`, "");
93
+ const path = new URL(import.meta.url).pathname;
94
+ const dir = path.slice(0, path.lastIndexOf("/"));
95
+ await fs.writeFile(`${dir}/server.html`, "");
91
96
  await page.goto(import.meta.resolve("./server.html"));
92
97
  await page.waitForFunction(async () => {
93
98
  return await navigator.gpu.requestAdapter();
@@ -103,7 +108,7 @@ async function work_validate(res, json) {
103
108
  </head>
104
109
  </html>
105
110
  `);
106
- await fs.unlink(`${import.meta.dirname}/server.html`);
111
+ await fs.unlink(`${dir}/server.html`);
107
112
  log("Puppeteer initialized");
108
113
  const server = http.createServer(async (req, res) => {
109
114
  let data = [];
@@ -152,9 +157,10 @@ async function work_validate(res, json) {
152
157
  process.exit(1);
153
158
  }
154
159
  });
155
- server.listen(PORT, () => {
160
+ server.listen(PORT, async () => {
156
161
  process.title = "NanoPow Server";
157
- log(`Server process ${process.pid} running at http://localhost:${PORT}/`);
162
+ const ip = await dns.lookup(os.hostname(), { family: 4 });
163
+ log(`Server process ${process.pid} running at ${ip.address}:${PORT}/`);
158
164
  });
159
165
  function shutdown() {
160
166
  log("Shutdown signal received");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nano-pow",
3
- "version": "4.0.1",
3
+ "version": "4.0.3",
4
4
  "description": "Proof-of-work generation and validation with WebGPU/WebGL for Nano cryptocurrency.",
5
5
  "keywords": [
6
6
  "nemo",