@cocreate/socket-server 1.27.0 → 1.27.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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [1.27.1](https://github.com/CoCreate-app/CoCreate-socket-server/compare/v1.27.0...v1.27.1) (2024-01-17)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * handling of host and origin. Updated to support new query system ([61a1c68](https://github.com/CoCreate-app/CoCreate-socket-server/commit/61a1c685a1d3466836b19867558842632c7994a4))
7
+
1
8
  # [1.27.0](https://github.com/CoCreate-app/CoCreate-socket-server/compare/v1.26.0...v1.27.0) (2024-01-08)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/socket-server",
3
- "version": "1.27.0",
3
+ "version": "1.27.1",
4
4
  "description": "CoCreate-socket-server",
5
5
  "keywords": [
6
6
  "cocreate-socket",
package/src/index.js CHANGED
@@ -25,11 +25,11 @@ class SocketServer extends EventEmitter {
25
25
  socket.destroy();
26
26
  });
27
27
 
28
- server.https.on('upgrade', (request, socket, head) => this.upgrade(request, socket, head))
29
- server.http.on('upgrade', (request, socket, head) => this.upgrade(request, socket, head))
28
+ server.https.on('upgrade', (request, socket, head) => this.upgrade(request, socket, head, 'wss'))
29
+ server.http.on('upgrade', (request, socket, head) => this.upgrade(request, socket, head, 'ws'))
30
30
  }
31
31
 
32
- upgrade(request, socket, head) {
32
+ upgrade(request, socket, head, protocol) {
33
33
  const self = this;
34
34
  let organization_id = request.url.split('/')
35
35
  organization_id = organization_id[organization_id.length - 1]
@@ -53,20 +53,19 @@ class SocketServer extends EventEmitter {
53
53
  socket.id = options.socketId;
54
54
  socket.clientId = options.clientId;
55
55
  socket.pathname = request.url
56
- socket.origin = request.headers.origin || request.headers.host
56
+ socket.origin = request.headers.origin
57
+ socket.host = request.headers.host
57
58
 
58
- if (socket.origin.startsWith('http'))
59
- socket.origin = socket.origin.replace('http', 'ws')
60
-
61
- socket.socketUrl = socket.origin + socket.pathname
62
-
63
- if (socket.origin && socket.origin !== 'null') {
59
+ if (!socket.host && socket.origin && socket.origin !== 'null') {
64
60
  if (socket.origin.includes('://'))
65
61
  socket.host = new URL(socket.origin).host
66
62
  else
67
63
  socket.host = socket.origin;
68
64
  }
69
65
 
66
+ socket.socketUrl = protocol + '://' + socket.host + socket.pathname
67
+
68
+
70
69
  // if (!await server.acme.checkCertificate(socket.host, organization_id))
71
70
  // return socket.send(JSON.stringify({ method: 'Access Denied', error: 'Host not whitelisted' }))
72
71
 
@@ -85,9 +84,10 @@ class SocketServer extends EventEmitter {
85
84
  }
86
85
 
87
86
  if (options.lastSynced)
88
- data.$filter.query = [
89
- { key: '_id', value: options.lastSynced, operator: '$gt' }
90
- ]
87
+ data.$filter.query = {
88
+ _id: { $gt: options.lastSynced }
89
+ }
90
+
91
91
  else
92
92
  data.$filter.limit = 1
93
93