@hapi/nes 12.0.2 → 12.0.5

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/lib/client.js CHANGED
@@ -392,6 +392,10 @@
392
392
  return;
393
393
  }
394
394
 
395
+ if (this._reconnectionTimer) {
396
+ return;
397
+ }
398
+
395
399
  if (reconnection.retries < 1) {
396
400
  return this._disconnect(ignore, true); // Clear _reconnection state
397
401
  }
package/lib/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  const Cryptiles = require('@hapi/cryptiles');
4
4
  const Hoek = require('@hapi/hoek');
5
5
  const Iron = require('@hapi/iron');
6
- const Joi = require('@hapi/joi');
6
+ const Validate = require('@hapi/validate');
7
7
  const Ws = require('ws');
8
8
 
9
9
  const Client = require('./client');
@@ -38,53 +38,53 @@ const internals = {
38
38
  };
39
39
 
40
40
 
41
- internals.schema = Joi.object({
42
- onConnection: Joi.function(), // async function (socket) {}
43
- onDisconnection: Joi.function(), // function (socket) {}
44
- onMessage: Joi.function(), // async function (socket, message) { return data; } // Or throw errors
45
- auth: Joi.object({
46
- endpoint: Joi.string().required(),
47
- id: Joi.string(),
48
- type: Joi.valid('cookie', 'token', 'direct').required(),
41
+ internals.schema = Validate.object({
42
+ onConnection: Validate.function(), // async function (socket) {}
43
+ onDisconnection: Validate.function(), // function (socket) {}
44
+ onMessage: Validate.function(), // async function (socket, message) { return data; } // Or throw errors
45
+ auth: Validate.object({
46
+ endpoint: Validate.string().required(),
47
+ id: Validate.string(),
48
+ type: Validate.valid('cookie', 'token', 'direct').required(),
49
49
  route: [
50
- Joi.object(),
51
- Joi.string()
50
+ Validate.object(),
51
+ Validate.string()
52
52
  ],
53
- cookie: Joi.string().required(),
54
- isSecure: Joi.boolean(),
55
- isHttpOnly: Joi.boolean(),
56
- isSameSite: Joi.valid('Strict', 'Lax').allow(false),
57
- path: Joi.string().allow(null),
58
- domain: Joi.string().allow(null),
59
- ttl: Joi.number().allow(null),
60
- iron: Joi.object(),
61
- password: Joi.alternatives([
62
- Joi.string(),
63
- Joi.binary(),
64
- Joi.object()
53
+ cookie: Validate.string().required(),
54
+ isSecure: Validate.boolean(),
55
+ isHttpOnly: Validate.boolean(),
56
+ isSameSite: Validate.valid('Strict', 'Lax').allow(false),
57
+ path: Validate.string().allow(null),
58
+ domain: Validate.string().allow(null),
59
+ ttl: Validate.number().allow(null),
60
+ iron: Validate.object(),
61
+ password: Validate.alternatives([
62
+ Validate.string(),
63
+ Validate.binary(),
64
+ Validate.object()
65
65
  ]),
66
- index: Joi.boolean(),
67
- timeout: Joi.number().integer().min(1).allow(false),
68
- maxConnectionsPerUser: Joi.number().integer().min(1).allow(false).when('index', { is: true, otherwise: Joi.valid(false) }),
69
- minAuthVerifyInterval: Joi.number().integer().allow(false).when('...heartbeat', {
66
+ index: Validate.boolean(),
67
+ timeout: Validate.number().integer().min(1).allow(false),
68
+ maxConnectionsPerUser: Validate.number().integer().min(1).allow(false).when('index', { is: true, otherwise: Validate.valid(false) }),
69
+ minAuthVerifyInterval: Validate.number().integer().allow(false).when('...heartbeat', {
70
70
  is: false,
71
- then: Joi.number().min(1),
72
- otherwise: Joi.number().min(Joi.ref('...heartbeat.interval'))
71
+ then: Validate.number().min(1),
72
+ otherwise: Validate.number().min(Validate.ref('...heartbeat.interval'))
73
73
  })
74
74
  })
75
75
  .allow(false)
76
76
  .required(),
77
- headers: Joi.array().items(Joi.string().lowercase()).min(1).allow('*', null),
77
+ headers: Validate.array().items(Validate.string().lowercase()).min(1).allow('*', null),
78
78
  payload: {
79
- maxChunkChars: Joi.number().integer().min(1).allow(false)
79
+ maxChunkChars: Validate.number().integer().min(1).allow(false)
80
80
  },
81
- heartbeat: Joi.object({
82
- interval: Joi.number().integer().min(1).required(),
83
- timeout: Joi.number().integer().min(1).less(Joi.ref('interval')).required()
81
+ heartbeat: Validate.object({
82
+ interval: Validate.number().integer().min(1).required(),
83
+ timeout: Validate.number().integer().min(1).less(Validate.ref('interval')).required()
84
84
  })
85
85
  .allow(false),
86
- maxConnections: Joi.number().integer().min(1).allow(false),
87
- origin: Joi.array().items(Joi.string()).single().min(1)
86
+ maxConnections: Validate.number().integer().min(1).allow(false),
87
+ origin: Validate.array().items(Validate.string()).single().min(1)
88
88
  });
89
89
 
90
90
 
@@ -107,7 +107,7 @@ exports.plugin = {
107
107
  settings.auth.minAuthVerifyInterval = (settings.heartbeat ? settings.heartbeat.interval : internals.defaults.heartbeat.interval);
108
108
  }
109
109
 
110
- Joi.assert(settings, internals.schema, 'Invalid nes configuration');
110
+ Validate.assert(settings, internals.schema, 'Invalid nes configuration');
111
111
 
112
112
  // Authentication endpoint
113
113
 
package/lib/listener.js CHANGED
@@ -4,7 +4,7 @@ const Boom = require('@hapi/boom');
4
4
  const Bounce = require('@hapi/bounce');
5
5
  const Call = require('@hapi/call');
6
6
  const Hoek = require('@hapi/hoek');
7
- const Joi = require('@hapi/joi');
7
+ const Validate = require('@hapi/validate');
8
8
  const Ws = require('ws');
9
9
 
10
10
  const Socket = require('./socket');
@@ -199,15 +199,15 @@ internals.Listener.prototype._broadcast = function (update, options) {
199
199
  };
200
200
 
201
201
 
202
- internals.subSchema = Joi.object({
203
- filter: Joi.func(), // async function (path, update, options), where options: { credentials, params }, returns true, false, { override }, or throws an error
204
- onSubscribe: Joi.func(), // async function (socket, path, params)
205
- onUnsubscribe: Joi.func(), // async function (socket, path, params)
206
- auth: Joi.object({
207
- mode: Joi.string().valid('required', 'optional'),
208
- scope: Joi.array().items(Joi.string()).single().min(1),
209
- entity: Joi.valid('user', 'app', 'any'),
210
- index: Joi.boolean()
202
+ internals.subSchema = Validate.object({
203
+ filter: Validate.func(), // async function (path, update, options), where options: { credentials, params }, returns true, false, { override }, or throws an error
204
+ onSubscribe: Validate.func(), // async function (socket, path, params)
205
+ onUnsubscribe: Validate.func(), // async function (socket, path, params)
206
+ auth: Validate.object({
207
+ mode: Validate.string().valid('required', 'optional'),
208
+ scope: Validate.array().items(Validate.string()).single().min(1),
209
+ entity: Validate.valid('user', 'app', 'any'),
210
+ index: Validate.boolean()
211
211
  })
212
212
  .allow(false)
213
213
  });
@@ -216,7 +216,7 @@ internals.subSchema = Joi.object({
216
216
  internals.Listener.subscription = function (path, options) {
217
217
 
218
218
  Hoek.assert(path, 'Subscription missing path');
219
- Joi.assert(options, internals.subSchema, 'Invalid subscription options: ' + path);
219
+ Validate.assert(options, internals.subSchema, 'Invalid subscription options: ' + path);
220
220
 
221
221
  const settings = Hoek.clone(options || {});
222
222
 
package/lib/socket.js CHANGED
@@ -437,7 +437,8 @@ internals.Socket.prototype._processRequest = async function (request) {
437
437
  nes: {
438
438
  socket: this
439
439
  }
440
- }
440
+ },
441
+ remoteAddress: this.info.remoteAddress
441
442
  };
442
443
 
443
444
  const res = await this.server.inject(shot);
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "@hapi/nes",
3
3
  "description": "WebSocket adapter plugin for hapi routes",
4
- "version": "12.0.2",
4
+ "version": "12.0.5",
5
5
  "repository": "git://github.com/hapijs/nes",
6
+ "engines": {
7
+ "node": ">=12.0.0"
8
+ },
6
9
  "main": "lib/index.js",
7
10
  "files": [
8
11
  "lib"
@@ -12,21 +15,27 @@
12
15
  "plugin",
13
16
  "websocket"
14
17
  ],
18
+ "eslintConfig": {
19
+ "extends": [
20
+ "plugin:@hapi/module"
21
+ ]
22
+ },
15
23
  "dependencies": {
16
24
  "@hapi/boom": "9.x.x",
17
25
  "@hapi/bounce": "2.x.x",
18
- "@hapi/call": "6.x.x",
26
+ "@hapi/call": "8.x.x",
19
27
  "@hapi/cryptiles": "5.x.x",
20
28
  "@hapi/hoek": "9.x.x",
21
29
  "@hapi/iron": "6.x.x",
22
- "@hapi/joi": "17.x.x",
23
- "@hapi/teamwork": "4.x.x",
24
- "ws": "6.x.x"
30
+ "@hapi/teamwork": "5.x.x",
31
+ "@hapi/validate": "1.x.x",
32
+ "ws": "^7.3.1"
25
33
  },
26
34
  "devDependencies": {
27
35
  "@hapi/code": "8.x.x",
28
- "@hapi/hapi": "19.x.x",
29
- "@hapi/lab": "22.x.x"
36
+ "@hapi/eslint-plugin": "^5.0.0",
37
+ "@hapi/hapi": "20.x.x",
38
+ "@hapi/lab": "24.x.x"
30
39
  },
31
40
  "scripts": {
32
41
  "test": "lab -a @hapi/code -t 100 -L -m 10000",