@scriptdb/server 1.0.7 → 1.0.8

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.
Files changed (2) hide show
  1. package/dist/index.js +31 -6
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -4356,7 +4356,7 @@ import { spawn } from "node:child_process";
4356
4356
  import Storage from "@scriptdb/storage";
4357
4357
  var pkgData = `{
4358
4358
  "name": "scriptdb-workspace",
4359
- "version": "1.0.7",
4359
+ "version": "1.0.8",
4360
4360
  "description": "ScriptDB workspace for custom scripts, services, and databases",
4361
4361
  "private": true,
4362
4362
  "devDependencies": {
@@ -4402,6 +4402,7 @@ var tsconfigData = `
4402
4402
  var dotGitignoreData = `
4403
4403
  # Ignore all files in this directory
4404
4404
  node_modules/
4405
+ bin/
4405
4406
  `;
4406
4407
  var ecosystemData = `
4407
4408
  module.exports = {
@@ -4705,7 +4706,7 @@ class ScriptDBClient {
4705
4706
  parsed.password = "";
4706
4707
  this.uri = parsed.toString();
4707
4708
  } catch (e) {
4708
- this.uri = normalized;
4709
+ this.uri = uri;
4709
4710
  }
4710
4711
  this.host = parsed.hostname || "localhost";
4711
4712
  this.port = parsed.port ? parseInt(parsed.port, 10) : 1234;
@@ -4796,6 +4797,12 @@ class ScriptDBClient {
4796
4797
  this._connecting = null;
4797
4798
  return reject(error);
4798
4799
  }
4800
+ if (!this.client) {
4801
+ const error = new Error("Failed to create client socket");
4802
+ this.logger?.error?.("Connection failed", error.message);
4803
+ this._connecting = null;
4804
+ return reject(error);
4805
+ }
4799
4806
  const onError = (err) => {
4800
4807
  this.logger?.error?.("Client socket error:", err && err.message ? err.message : err);
4801
4808
  this._handleDisconnect(err);
@@ -4806,7 +4813,7 @@ class ScriptDBClient {
4806
4813
  };
4807
4814
  this.client.on("error", onError);
4808
4815
  this.client.on("close", onClose);
4809
- if (this.socketTimeout > 0) {
4816
+ if (this.socketTimeout > 0 && this.client) {
4810
4817
  this.client.setTimeout(this.socketTimeout);
4811
4818
  this.client.on("timeout", () => {
4812
4819
  this.logger?.warn?.("Socket timeout, destroying connection");
@@ -5663,8 +5670,23 @@ async function server() {
5663
5670
  allowed.host = parsedConfig.host;
5664
5671
  if (parsedConfig.port !== undefined)
5665
5672
  allowed.port = parsedConfig.port;
5666
- if (parsedConfig.users !== undefined)
5667
- allowed.users = parsedConfig.users;
5673
+ if (parsedConfig.users !== undefined) {
5674
+ if (Array.isArray(parsedConfig.users)) {
5675
+ if (parsedConfig.users.length === 0) {
5676
+ allowed.users = [];
5677
+ } else if (typeof parsedConfig.users[0] === "string") {
5678
+ allowed.users = parsedConfig.users.map((username) => ({
5679
+ username,
5680
+ password: "",
5681
+ hash: false
5682
+ }));
5683
+ } else {
5684
+ allowed.users = parsedConfig.users;
5685
+ }
5686
+ } else {
5687
+ allowed.users = [parsedConfig.users];
5688
+ }
5689
+ }
5668
5690
  if (typeof parsedConfig.folder === "string")
5669
5691
  allowed.folder = parsedConfig.folder;
5670
5692
  if (typeof parsedConfig.secure === "boolean")
@@ -5731,7 +5753,7 @@ async function server() {
5731
5753
  } catch (err) {
5732
5754
  exitWithError("Failed to initialize VM", err);
5733
5755
  }
5734
- let storage;
5756
+ let storage = null;
5735
5757
  try {
5736
5758
  storage = new Storage2(baseDir, basePath);
5737
5759
  await storage.initialize();
@@ -5739,6 +5761,9 @@ async function server() {
5739
5761
  } catch (err) {
5740
5762
  exitWithError("Failed to initialize Storage", err);
5741
5763
  }
5764
+ if (!storage) {
5765
+ exitWithError("Storage was not initialized");
5766
+ }
5742
5767
  let scriptDBServer;
5743
5768
  try {
5744
5769
  scriptDBServer = new Protocal({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scriptdb/server",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "server module resolver for script database",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -41,10 +41,10 @@
41
41
  "typescript": "^5.0.0"
42
42
  },
43
43
  "dependencies": {
44
- "@scriptdb/client": "^1.0.7",
45
- "@scriptdb/storage": "^1.0.7",
46
- "@scriptdb/system-modules": "^1.0.7",
47
- "@scriptdb/vm": "^1.0.7",
44
+ "@scriptdb/client": "^1.0.8",
45
+ "@scriptdb/storage": "^1.0.8",
46
+ "@scriptdb/system-modules": "^1.0.8",
47
+ "@scriptdb/vm": "^1.0.8",
48
48
  "@types/ws": "^8.18.1",
49
49
  "bcryptjs": "^3.0.3",
50
50
  "bottleneck": "^2.19.5",