diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..b58752e --- /dev/null +++ b/package-lock.json @@ -0,0 +1,117 @@ +{ + "name": "wisp-server-node", + "version": "1.1.5", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "wisp-server-node", + "version": "1.1.5", + "license": "AGPL-3.0-only", + "dependencies": { + "bufferutil": "^4.0.8", + "utf-8-validate": "^6.0.4", + "ws": "^8.18.0" + }, + "devDependencies": { + "@types/ws": "^8.5.12", + "typescript": "^5.6.2" + } + }, + "node_modules/@types/node": { + "version": "20.11.16", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.16.tgz", + "integrity": "sha512-gKb0enTmRCzXSSUJDq6/sPcqrfCv2mkkG6Jt/clpn5eiCbKTY+SgZUxo+p8ZKMof5dCp9vHQUAB7wOUTod22wQ==", + "dev": true, + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "node_modules/@types/ws": { + "version": "8.5.12", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.12.tgz", + "integrity": "sha512-3tPRkv1EtkDpzlgyKyI8pGsGZAGPEaXeu0DOj5DI25Ja91bdAYddYHbADRYVrZMRbfW+1l5YwXVDKohDJNQxkQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/bufferutil": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.8.tgz", + "integrity": "sha512-4T53u4PdgsXqKaIctwF8ifXlRTTmEPJ8iEPWFdGZvcf7sbwYo6FKFEX9eNNAnzFZ7EzJAQ3CJeOtCRA4rDp7Pw==", + "hasInstallScript": true, + "dependencies": { + "node-gyp-build": "^4.3.0" + }, + "engines": { + "node": ">=6.14.2" + } + }, + "node_modules/node-gyp-build": { + "version": "4.8.0", + "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.8.0.tgz", + "integrity": "sha512-u6fs2AEUljNho3EYTJNBfImO5QTo/J/1Etd+NVdCj7qWKUSN/bSLkZwhDv7I+w/MSC6qJ4cknepkAYykDdK8og==", + "bin": { + "node-gyp-build": "bin.js", + "node-gyp-build-optional": "optional.js", + "node-gyp-build-test": "build-test.js" + } + }, + "node_modules/typescript": { + "version": "5.6.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.2.tgz", + "integrity": "sha512-NW8ByodCSNCwZeghjN3o+JX5OFH0Ojg6sadjEKY4huZ52TqbJTJnDo5+Tw98lSy63NZvi4n+ez5m2u5d4PkZyw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true + }, + "node_modules/utf-8-validate": { + "version": "6.0.4", + "resolved": "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-6.0.4.tgz", + "integrity": "sha512-xu9GQDeFp+eZ6LnCywXN/zBancWvOpUMzgjLPSjy4BRHSmTelvn2E0DG0o1sTiw5hkCKBHo8rwSKncfRfv2EEQ==", + "hasInstallScript": true, + "license": "MIT", + "dependencies": { + "node-gyp-build": "^4.3.0" + }, + "engines": { + "node": ">=6.14.2" + } + }, + "node_modules/ws": { + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz", + "integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==", + "license": "MIT", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + } + } +} diff --git a/src/ConnectionHandler.ts b/src/ConnectionHandler.ts index 66d5794..c84daaf 100644 --- a/src/ConnectionHandler.ts +++ b/src/ConnectionHandler.ts @@ -3,13 +3,13 @@ import WebSocket, { WebSocketServer } from "ws"; import net, { Socket } from "node:net"; import dns from "node:dns/promises"; import dgram from "node:dgram"; -import FrameParsers from "./Packets.ts"; -import { STREAM_TYPE, PACKET_TYPE, LOG_LEVEL, WispFrame, WispOptions } from "./Types.ts"; -import { Logger } from "./utils/Logger.ts"; -import { handleWsProxy } from "./wsproxy.ts"; -import { checkErrorCode } from "./utils/Error.ts"; +import FrameParsers from "./Packets.js"; +import { STREAM_TYPE, PACKET_TYPE, LOG_LEVEL, WispFrame, WispOptions } from "./Types.js"; +import { Logger } from "./utils/Logger.js"; +import { handleWsProxy } from "./wsproxy.js"; +import { checkErrorCode } from "./utils/Error.js"; -const wss = new WebSocket.Server({ noServer: true }); +const wss = new WebSocketServer({ noServer: true }); const defaultOptions: WispOptions = { logLevel: LOG_LEVEL.INFO, pingInterval: 30 }; // Accepts either routeRequest(ws) or routeRequest(request, socket, head) like bare export async function routeRequest( diff --git a/src/Packets.ts b/src/Packets.ts index 73638cc..fd18acd 100644 --- a/src/Packets.ts +++ b/src/Packets.ts @@ -1,4 +1,4 @@ -import { PACKET_TYPE, WispFrame } from "./Types.ts"; +import { PACKET_TYPE, WispFrame } from "./Types.js"; export function wispFrameParser(data: Buffer): WispFrame { const uint8arrayView = new Uint8Array(data); diff --git a/src/createServer.ts b/src/createServer.ts index 7096f7e..6c3f3e6 100644 --- a/src/createServer.ts +++ b/src/createServer.ts @@ -1,7 +1,6 @@ -import { WebSocketServer } from "ws"; -import wisp from "./ConnectionHandler.ts"; +import wisp from "./ConnectionHandler.js"; import http from "node:http"; -import { LOG_LEVEL } from "./Types.ts"; +import { LOG_LEVEL } from "./Types.js"; import net, { Socket } from "node:net"; const httpServer = http.createServer().listen(process.env.PORT || 3000); diff --git a/src/utils/Logger.ts b/src/utils/Logger.ts index 8f7ffc2..328c462 100644 --- a/src/utils/Logger.ts +++ b/src/utils/Logger.ts @@ -1,4 +1,4 @@ -import { LOG_LEVEL } from "../Types.ts"; +import { LOG_LEVEL } from "../Types.js"; export class Logger { logLevel: number; diff --git a/tsconfig.json b/tsconfig.json index f57b1ab..0bfe049 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -29,8 +29,7 @@ "skipLibCheck": true, "resolveJsonModule": false, - "emitDeclarationOnly": true, - "allowImportingTsExtensions": true + "emitDeclarationOnly": false }, "include": ["src"] }