hapi-plugin-websocket
Advanced tools
Comparing version 2.3.8 to 2.4.0
@@ -135,3 +135,3 @@ /* | ||
wss = new WS.Server({ | ||
/* the underyling HTTP server */ | ||
/* the underlying HTTP server */ | ||
server: server.listener, | ||
@@ -242,3 +242,3 @@ | ||
if (response.statusCode >= 300) { | ||
const annotation = `(HAPI handler reponded with HTTP status ${response.statusCode})` | ||
const annotation = `(HAPI handler responded with HTTP status ${response.statusCode})` | ||
if (response.statusCode < 400) | ||
@@ -297,3 +297,3 @@ ws.close(1002, `Protocol Error ${annotation}`) | ||
else { | ||
/* plain WebSocket communication (uncorrelated request/reponse) */ | ||
/* plain WebSocket communication (uncorrelated request/response) */ | ||
ws.on("message", async (message) => { | ||
@@ -377,4 +377,12 @@ /* inject incoming WebSocket message as a simulated HTTP request */ | ||
if (isRequestWebSocketDriven(request)) { | ||
request.info.remoteAddress = request.plugins.websocket.req.socket.remoteAddress | ||
request.info.remotePort = request.plugins.websocket.req.socket.remotePort | ||
/* RequestInfo's remoteAddress and remotePort use getters and are not | ||
settable, so we have to replace them. */ | ||
Object.defineProperties(request.info, { | ||
remoteAddress: { | ||
value: request.plugins.websocket.req.socket.remoteAddress | ||
}, | ||
remotePort: { | ||
value: request.plugins.websocket.req.socket.remotePort | ||
} | ||
}) | ||
} | ||
@@ -381,0 +389,0 @@ return h.continue |
{ | ||
"name": "hapi-plugin-websocket", | ||
"version": "2.3.8", | ||
"version": "2.4.0", | ||
"description": "HAPI plugin for seamless WebSocket integration", | ||
"keywords": [ "hapi", "plugin", "websocket" ], | ||
"main": "./hapi-plugin-websocket.js", | ||
"types": "./hapi-plugin-websocket.d.ts", | ||
"license": "MIT", | ||
@@ -24,13 +25,15 @@ "repository": { | ||
"urijs": "1.19.11", | ||
"@hapi/hoek": "9.2.1", | ||
"@hapi/boom": "9.1.4", | ||
"ws": "8.5.0", | ||
"websocket-framed": "1.2.8" | ||
"@hapi/hoek": "11.0.2", | ||
"@hapi/boom": "10.0.0", | ||
"ws": "8.12.0", | ||
"websocket-framed": "1.2.9", | ||
"@types/node": "18.11.18", | ||
"@types/ws": "8.5.4" | ||
}, | ||
"devDependencies": { | ||
"@hapi/hapi": "20.2.2", | ||
"@hapi/basic": "6.0.0", | ||
"eslint": "8.13.0", | ||
"@hapi/hapi": "21.2.0", | ||
"@hapi/basic": "7.0.0", | ||
"eslint": "8.32.0", | ||
"eslint-config-standard": "17.0.0", | ||
"eslint-plugin-import": "2.26.0", | ||
"eslint-plugin-import": "2.27.4", | ||
"eslint-plugin-node": "11.1.0" | ||
@@ -37,0 +40,0 @@ }, |
@@ -49,3 +49,3 @@ | ||
/* register Basic authentication stategy */ | ||
/* register Basic authentication strategy */ | ||
server.auth.strategy("basic", "basic", { | ||
@@ -109,3 +109,3 @@ validate: async (request, username, password, h) => { | ||
initially: true, | ||
subprotocol: "quux", | ||
subprotocol: "quux.example.com", | ||
connect: ({ ctx, ws }) => { | ||
@@ -215,3 +215,3 @@ ctx.to = setInterval(() => { | ||
# access the full-featured exclusive WebSocket route via WebSockets | ||
$ wscat --subprotocol "quux/1.0" --auth foo:bar --connect ws://127.0.0.1:12345/quux | ||
$ wscat --subprotocol "quux.example.com" --auth foo:bar --connect ws://127.0.0.1:12345/quux | ||
< {"cmd":"HELLO",arg:"foo"} | ||
@@ -287,3 +287,3 @@ > {"cmd":"PING"} | ||
autoping: 10 * 1000, | ||
subprotocol: "foo/1.0", | ||
subprotocol: "quux.example.com", | ||
initially: true, | ||
@@ -290,0 +290,0 @@ connect: ({ ctx, wss, ws, req, peers }) => { |
@@ -16,3 +16,3 @@ | ||
/* register Basic authentication stategy */ | ||
/* register Basic authentication strategy */ | ||
server.auth.strategy("basic", "basic", { | ||
@@ -76,3 +76,3 @@ validate: async (request, username, password, h) => { | ||
initially: true, | ||
subprotocol: "quux", | ||
subprotocol: "quux.example.com", | ||
connect: ({ ctx, ws }) => { | ||
@@ -79,0 +79,0 @@ ctx.to = setInterval(() => { |
41996
6
592
8
+ Added@types/node@18.11.18
+ Added@types/ws@8.5.4
+ Added@hapi/boom@10.0.0(transitive)
+ Added@hapi/hoek@10.0.111.0.2(transitive)
+ Added@types/node@18.11.18(transitive)
+ Added@types/ws@8.5.4(transitive)
+ Addedbignumber.js@9.0.2(transitive)
+ Addedcbor@8.1.0(transitive)
+ Addedencodr@1.3.3(transitive)
+ Addednode-inspect-extracted@1.1.0(transitive)
+ Addedwebsocket-framed@1.2.9(transitive)
+ Addedws@8.12.0(transitive)
- Removed@hapi/boom@9.1.4(transitive)
- Removed@hapi/hoek@11.0.49.2.1(transitive)
- Removedbignumber.js@9.0.1(transitive)
- Removedcbor@8.0.2(transitive)
- Removedencodr@1.3.2(transitive)
- Removednode-inspect-extracted@1.0.8(transitive)
- Removedwebsocket-framed@1.2.8(transitive)
- Removedws@8.5.0(transitive)
Updated@hapi/boom@10.0.0
Updated@hapi/hoek@11.0.2
Updatedwebsocket-framed@1.2.9
Updatedws@8.12.0