@cocreate/socket-server 1.24.0 → 1.24.2
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 +14 -0
- package/package.json +1 -1
- package/src/index.js +8 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.24.2](https://github.com/CoCreate-app/CoCreate-socket-server/compare/v1.24.1...v1.24.2) (2023-12-09)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* emit first part of method which is module name ([d5d2f2d](https://github.com/CoCreate-app/CoCreate-socket-server/commit/d5d2f2d70f1effece7e77c95cb409b82609ee228))
|
|
7
|
+
|
|
8
|
+
## [1.24.1](https://github.com/CoCreate-app/CoCreate-socket-server/compare/v1.24.0...v1.24.1) (2023-12-05)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* async await upgrade to handle authenticate ([e6416f5](https://github.com/CoCreate-app/CoCreate-socket-server/commit/e6416f5725ece424b69a142b70de4a0ca6687869))
|
|
14
|
+
|
|
1
15
|
# [1.24.0](https://github.com/CoCreate-app/CoCreate-socket-server/compare/v1.23.0...v1.24.0) (2023-11-25)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -30,7 +30,7 @@ class SocketServer extends EventEmitter {
|
|
|
30
30
|
let organization_id = request.url.split('/')
|
|
31
31
|
organization_id = organization_id[organization_id.length - 1]
|
|
32
32
|
|
|
33
|
-
this.wss.handleUpgrade(request, socket, head, function (socket) {
|
|
33
|
+
this.wss.handleUpgrade(request, socket, head, async function (socket) {
|
|
34
34
|
if (organization_id) {
|
|
35
35
|
let organization = self.organizations.get(organization_id)
|
|
36
36
|
if (organization && organization.status === false) {
|
|
@@ -87,7 +87,7 @@ class SocketServer extends EventEmitter {
|
|
|
87
87
|
self.emit('object.read', data);
|
|
88
88
|
|
|
89
89
|
if (self.authenticate) {
|
|
90
|
-
const { user_id, expires } = self.authenticate.decodeToken(options.token)
|
|
90
|
+
const { user_id, expires } = await self.authenticate.decodeToken(options.token, organization_id, options.clientId)
|
|
91
91
|
const userStatus = { socket, method: 'userStatus', user_id: options.user_id, clientId: options.clientId, userStatus: 'off', organization_id }
|
|
92
92
|
if (user_id) {
|
|
93
93
|
options.user_id = user_id
|
|
@@ -403,8 +403,11 @@ class SocketServer extends EventEmitter {
|
|
|
403
403
|
if (authorized.authorized)
|
|
404
404
|
data = authorized.authorized
|
|
405
405
|
|
|
406
|
-
|
|
407
|
-
|
|
406
|
+
let mod = data.method.split('.')[0]
|
|
407
|
+
if (['storage', 'database', 'array', 'index', 'object'].includes(mod))
|
|
408
|
+
this.emit(data.method, data);
|
|
409
|
+
else
|
|
410
|
+
this.emit(mod, data);
|
|
408
411
|
}
|
|
409
412
|
}
|
|
410
413
|
} catch (e) {
|
|
@@ -414,6 +417,7 @@ class SocketServer extends EventEmitter {
|
|
|
414
417
|
|
|
415
418
|
async send(data) {
|
|
416
419
|
// const socket = this.sockets.get(data.socketId)
|
|
420
|
+
delete data.wsManager
|
|
417
421
|
const socket = data.socket
|
|
418
422
|
|
|
419
423
|
if (data.sync) {
|