@arrowood.dev/socket
Advanced tools
Comparing version 0.0.2 to 0.1.0
@@ -21,3 +21,6 @@ /// <reference types="node" /> | ||
} | ||
export declare class SocketError extends TypeError { | ||
constructor(message: string); | ||
} | ||
export type * from './types'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Socket = exports.connect = void 0; | ||
exports.SocketError = exports.Socket = exports.connect = void 0; | ||
const node_net_1 = __importDefault(require("node:net")); | ||
@@ -14,7 +14,7 @@ const node_tls_1 = __importDefault(require("node:tls")); | ||
if (typeof address === 'string') { | ||
const url = new URL(address); | ||
const url = new URL(`https://${address}`); | ||
// eslint-disable-next-line no-param-reassign -- there is no harm reassigning to this param | ||
address = { | ||
hostname: url.hostname, | ||
port: parseInt(url.port), | ||
port: parseInt(url.port === '' ? '443' : url.port), | ||
}; | ||
@@ -69,3 +69,8 @@ } | ||
this.socket.on('error', (err) => { | ||
this.closedReject(err); | ||
if (err instanceof Error) { | ||
this.closedReject(new SocketError(err.message)); | ||
} | ||
else { | ||
this.closedReject(new SocketError(err)); | ||
} | ||
}); | ||
@@ -85,6 +90,6 @@ // types are wrong. fixed based on docs https://nodejs.org/dist/latest/docs/api/stream.html#streamduplextowebstreamduplex | ||
if (this.secureTransport !== 'starttls') { | ||
throw new Error("secureTransport must be set to 'starttls'"); | ||
throw new SocketError("secureTransport must be set to 'starttls'"); | ||
} | ||
if (this.startTlsCalled) { | ||
throw new Error('can only call startTls once'); | ||
throw new SocketError('can only call startTls once'); | ||
} | ||
@@ -98,1 +103,7 @@ else { | ||
exports.Socket = Socket; | ||
class SocketError extends TypeError { | ||
constructor(message) { | ||
super(`SocketError: ${message}`); | ||
} | ||
} | ||
exports.SocketError = SocketError; |
{ | ||
"name": "@arrowood.dev/socket", | ||
"version": "0.0.2", | ||
"version": "0.1.0", | ||
"description": "A Node.js Implementation of the Cloudflare Socket API", | ||
@@ -25,3 +25,3 @@ "keywords": [], | ||
"prepare": "husky install", | ||
"test": "tap --ts test/*.test.ts", | ||
"test": "tap run test/*.test.ts", | ||
"type-check": "tsc" | ||
@@ -31,3 +31,2 @@ }, | ||
"@types/node": "18.17.5", | ||
"@types/tap": "15.0.8", | ||
"@vercel/style-guide": "5.0.1", | ||
@@ -38,7 +37,7 @@ "eslint": "8.48.0", | ||
"prettier": "3.0.3", | ||
"tap": "16.3.8", | ||
"tap": "18.2.0", | ||
"ts-node": "10.9.1", | ||
"typescript": "5.2.2" | ||
}, | ||
"packageManager": "pnpm@8.6.12", | ||
"packageManager": "pnpm@8.8.0", | ||
"engines": { | ||
@@ -45,0 +44,0 @@ "node": ">=18" |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12490
9
164