@hapi/nes 12.0.5 → 13.0.1
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.
- package/LICENSE.md +2 -1
- package/lib/index.js +1 -1
- package/lib/listener.js +6 -6
- package/lib/socket.js +3 -3
- package/package.json +13 -16
package/LICENSE.md
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
Copyright (c) 2016-
|
|
1
|
+
Copyright (c) 2016-2022, Project contributors
|
|
2
|
+
Copyright (c) 2016-2020, Sideway Inc
|
|
2
3
|
All rights reserved.
|
|
3
4
|
|
|
4
5
|
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
package/lib/index.js
CHANGED
|
@@ -205,7 +205,7 @@ internals.auth = function (server, settings) {
|
|
|
205
205
|
return h.response(result).state(config.cookie, credentials);
|
|
206
206
|
}
|
|
207
207
|
|
|
208
|
-
const sealed = await Iron.seal(credentials, config.password, config.iron
|
|
208
|
+
const sealed = await Iron.seal(credentials, config.password, config.iron ?? Iron.defaults);
|
|
209
209
|
result.token = sealed;
|
|
210
210
|
return result;
|
|
211
211
|
}
|
package/lib/listener.js
CHANGED
|
@@ -165,7 +165,7 @@ internals.Listener.prototype._beat = function () {
|
|
|
165
165
|
|
|
166
166
|
internals.Listener.broadcast = function (message, options) {
|
|
167
167
|
|
|
168
|
-
options = options
|
|
168
|
+
options = options ?? {};
|
|
169
169
|
|
|
170
170
|
const update = {
|
|
171
171
|
type: 'update',
|
|
@@ -218,7 +218,7 @@ internals.Listener.subscription = function (path, options) {
|
|
|
218
218
|
Hoek.assert(path, 'Subscription missing path');
|
|
219
219
|
Validate.assert(options, internals.subSchema, 'Invalid subscription options: ' + path);
|
|
220
220
|
|
|
221
|
-
const settings = Hoek.clone(options
|
|
221
|
+
const settings = Hoek.clone(options ?? {});
|
|
222
222
|
|
|
223
223
|
// Auth configuration
|
|
224
224
|
|
|
@@ -261,7 +261,7 @@ internals.Listener.publish = function (path, update, options) {
|
|
|
261
261
|
|
|
262
262
|
Hoek.assert(path && path[0] === '/', 'Missing or invalid subscription path:', path || 'empty');
|
|
263
263
|
|
|
264
|
-
options = options
|
|
264
|
+
options = options ?? {};
|
|
265
265
|
|
|
266
266
|
const message = {
|
|
267
267
|
type: 'pub',
|
|
@@ -382,7 +382,7 @@ internals.Listener.prototype._subscribe = async function (path, socket) {
|
|
|
382
382
|
|
|
383
383
|
internals.Listener.eachSocket = function (each, options) {
|
|
384
384
|
|
|
385
|
-
options = options
|
|
385
|
+
options = options ?? {};
|
|
386
386
|
|
|
387
387
|
return this.plugins.nes._listener._eachSocket(each, options);
|
|
388
388
|
};
|
|
@@ -454,7 +454,7 @@ internals.Sockets.prototype.auth = function (socket) {
|
|
|
454
454
|
throw Boom.serverUnavailable('Too many connections for the authenticated user');
|
|
455
455
|
}
|
|
456
456
|
|
|
457
|
-
this._byUser[user] = this._byUser[user]
|
|
457
|
+
this._byUser[user] = this._byUser[user] ?? [];
|
|
458
458
|
this._byUser[user].push(socket);
|
|
459
459
|
};
|
|
460
460
|
|
|
@@ -522,7 +522,7 @@ internals.Subscribers.prototype.add = async function (socket, path, match) {
|
|
|
522
522
|
socket.auth.credentials.user) {
|
|
523
523
|
|
|
524
524
|
const user = socket.auth.credentials.user;
|
|
525
|
-
this._byUser[user] = this._byUser[user]
|
|
525
|
+
this._byUser[user] = this._byUser[user] ?? [];
|
|
526
526
|
this._byUser[user].push(this._items[socket.id]);
|
|
527
527
|
}
|
|
528
528
|
}
|
package/lib/socket.js
CHANGED
|
@@ -118,7 +118,7 @@ internals.Socket.prototype.isOpen = function () {
|
|
|
118
118
|
|
|
119
119
|
internals.Socket.prototype._send = function (message, options) {
|
|
120
120
|
|
|
121
|
-
options = options
|
|
121
|
+
options = options ?? {};
|
|
122
122
|
|
|
123
123
|
if (!this.isOpen()) { // Open
|
|
124
124
|
return Promise.reject(Boom.internal('Socket not open'));
|
|
@@ -544,7 +544,7 @@ internals.Socket.prototype._authenticate = async function (request) {
|
|
|
544
544
|
const config = this._listener._settings.auth;
|
|
545
545
|
if (config.type === 'direct') {
|
|
546
546
|
const route = this.server.lookup(config.id);
|
|
547
|
-
request.auth.headers = request.auth.headers
|
|
547
|
+
request.auth.headers = request.auth.headers ?? {};
|
|
548
548
|
request.auth.headers['x-forwarded-for'] = this.info['x-forwarded-for'];
|
|
549
549
|
const res = await this.server.inject({ url: route.path, method: 'auth', headers: request.auth.headers, remoteAddress: this.info.remoteAddress, allowInternals: true, validate: false });
|
|
550
550
|
if (res.statusCode !== 200) {
|
|
@@ -560,7 +560,7 @@ internals.Socket.prototype._authenticate = async function (request) {
|
|
|
560
560
|
}
|
|
561
561
|
|
|
562
562
|
try {
|
|
563
|
-
const auth = await Iron.unseal(request.auth, config.password, config.iron
|
|
563
|
+
const auth = await Iron.unseal(request.auth, config.password, config.iron ?? Iron.defaults);
|
|
564
564
|
this._setCredentials(auth);
|
|
565
565
|
}
|
|
566
566
|
catch (err) {
|
package/package.json
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hapi/nes",
|
|
3
3
|
"description": "WebSocket adapter plugin for hapi routes",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "13.0.1",
|
|
5
5
|
"repository": "git://github.com/hapijs/nes",
|
|
6
|
-
"engines": {
|
|
7
|
-
"node": ">=12.0.0"
|
|
8
|
-
},
|
|
9
6
|
"main": "lib/index.js",
|
|
10
7
|
"files": [
|
|
11
8
|
"lib"
|
|
@@ -21,21 +18,21 @@
|
|
|
21
18
|
]
|
|
22
19
|
},
|
|
23
20
|
"dependencies": {
|
|
24
|
-
"@hapi/boom": "
|
|
25
|
-
"@hapi/bounce": "
|
|
26
|
-
"@hapi/call": "
|
|
27
|
-
"@hapi/cryptiles": "
|
|
28
|
-
"@hapi/hoek": "
|
|
29
|
-
"@hapi/iron": "
|
|
30
|
-
"@hapi/teamwork": "
|
|
31
|
-
"@hapi/validate": "
|
|
21
|
+
"@hapi/boom": "^10.0.1",
|
|
22
|
+
"@hapi/bounce": "^3.0.1",
|
|
23
|
+
"@hapi/call": "^9.0.1",
|
|
24
|
+
"@hapi/cryptiles": "^6.0.1",
|
|
25
|
+
"@hapi/hoek": "^11.0.2",
|
|
26
|
+
"@hapi/iron": "^7.0.1",
|
|
27
|
+
"@hapi/teamwork": "^6.0.0",
|
|
28
|
+
"@hapi/validate": "^2.0.1",
|
|
32
29
|
"ws": "^7.3.1"
|
|
33
30
|
},
|
|
34
31
|
"devDependencies": {
|
|
35
|
-
"@hapi/code": "
|
|
36
|
-
"@hapi/eslint-plugin": "
|
|
37
|
-
"@hapi/hapi": "
|
|
38
|
-
"@hapi/lab": "
|
|
32
|
+
"@hapi/code": "^9.0.3",
|
|
33
|
+
"@hapi/eslint-plugin": "*",
|
|
34
|
+
"@hapi/hapi": "^21.2.1",
|
|
35
|
+
"@hapi/lab": "^25.1.2"
|
|
39
36
|
},
|
|
40
37
|
"scripts": {
|
|
41
38
|
"test": "lab -a @hapi/code -t 100 -L -m 10000",
|