@cocreate/socket-server 1.21.5 → 1.21.7
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 +20 -0
- package/CoCreate.config.js +1 -2
- package/docs/index.html +2 -2
- package/package.json +3 -3
- package/src/index.js +17 -12
- package/src/mesh.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
## [1.21.7](https://github.com/CoCreate-app/CoCreate-socket-server/compare/v1.21.6...v1.21.7) (2023-11-09)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* meta name typo ([37b85be](https://github.com/CoCreate-app/CoCreate-socket-server/commit/37b85bee20c4ff7e73eccca039f9dbeb84c82417))
|
|
7
|
+
* update crud methods ([2853e1f](https://github.com/CoCreate-app/CoCreate-socket-server/commit/2853e1f82c76998cdf2d5de3ee05128c454bd2e8))
|
|
8
|
+
* update host ([4139426](https://github.com/CoCreate-app/CoCreate-socket-server/commit/41394268a2b0814d2373870184c7d30c60b94383))
|
|
9
|
+
* updated date to ISO format with UTC timezone ([98b5e0a](https://github.com/CoCreate-app/CoCreate-socket-server/commit/98b5e0abd9768e8297b54db9a4b86babf3fc69ca))
|
|
10
|
+
|
|
11
|
+
## [1.21.6](https://github.com/CoCreate-app/CoCreate-socket-server/compare/v1.21.5...v1.21.6) (2023-11-03)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* authorized false condition ([056e59a](https://github.com/CoCreate-app/CoCreate-socket-server/commit/056e59a41558f3a4a4450aa84ef8043ee1e5922b))
|
|
17
|
+
* $addToSet.activeHost ([d705f16](https://github.com/CoCreate-app/CoCreate-socket-server/commit/d705f16ab7bef6bf6c0fe2f5f4d9416b1d9df463))
|
|
18
|
+
* update dependencies to the lates versions ([6260248](https://github.com/CoCreate-app/CoCreate-socket-server/commit/62602485421b432ad00ca25712b3798c3a97eeef))
|
|
19
|
+
* update method to use object.update etc ([10e4530](https://github.com/CoCreate-app/CoCreate-socket-server/commit/10e4530ea792e7e71bdf79a1c965e94bf2204edf))
|
|
20
|
+
|
|
1
21
|
## [1.21.5](https://github.com/CoCreate-app/CoCreate-socket-server/compare/v1.21.4...v1.21.5) (2023-10-26)
|
|
2
22
|
|
|
3
23
|
|
package/CoCreate.config.js
CHANGED
package/docs/index.html
CHANGED
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
sizes="32x32"
|
|
12
12
|
href="https://cocreate.app/images/favicon.ico" />
|
|
13
13
|
<meta
|
|
14
|
-
|
|
14
|
+
name="description"
|
|
15
15
|
content="A simple HTML5 and pure javascript component. Easy configuration using data-attributes and highly styleable." />
|
|
16
16
|
<meta
|
|
17
|
-
|
|
17
|
+
name="keywords"
|
|
18
18
|
content="helper classes, utility classes, css framework, css library, inline style classes" />
|
|
19
19
|
<meta name="robots" content="index,follow" />
|
|
20
20
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/socket-server",
|
|
3
|
-
"version": "1.21.
|
|
3
|
+
"version": "1.21.7",
|
|
4
4
|
"description": "CoCreate-socket-server",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cocreate-socket",
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
},
|
|
41
41
|
"homepage": "https://cocreate.app/docs/CoCreate-socket-server",
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@cocreate/config": "^1.6.
|
|
43
|
+
"@cocreate/config": "^1.6.6",
|
|
44
44
|
"@cocreate/uuid": "^1.7.2",
|
|
45
|
-
"@cocreate/utils": "^1.26.
|
|
45
|
+
"@cocreate/utils": "^1.26.2",
|
|
46
46
|
"ws": "7.5.9"
|
|
47
47
|
}
|
|
48
48
|
}
|
package/src/index.js
CHANGED
|
@@ -64,7 +64,7 @@ class SocketServer extends EventEmitter {
|
|
|
64
64
|
if (!organization || organization && organization.status !== false) {
|
|
65
65
|
let data = {
|
|
66
66
|
socket,
|
|
67
|
-
method: 'read
|
|
67
|
+
method: 'object.read',
|
|
68
68
|
array: 'message_log',
|
|
69
69
|
$filter: {
|
|
70
70
|
sort: [
|
|
@@ -82,7 +82,7 @@ class SocketServer extends EventEmitter {
|
|
|
82
82
|
else
|
|
83
83
|
data.$filter.limit = 1
|
|
84
84
|
|
|
85
|
-
self.emit('read
|
|
85
|
+
self.emit('object.read', data);
|
|
86
86
|
|
|
87
87
|
if (self.authenticate) {
|
|
88
88
|
const { user_id, expires } = self.authenticate.decodeToken(options.token)
|
|
@@ -142,11 +142,11 @@ class SocketServer extends EventEmitter {
|
|
|
142
142
|
|
|
143
143
|
this.organizations.set(organization_id, organization)
|
|
144
144
|
|
|
145
|
-
this.emit('update
|
|
146
|
-
method: 'update
|
|
145
|
+
this.emit('object.update', {
|
|
146
|
+
method: 'object.update',
|
|
147
147
|
array: 'organizations',
|
|
148
148
|
object: {
|
|
149
|
-
_id: organization_id, ['$
|
|
149
|
+
_id: organization_id, ['$addToSet.activeHost']: socket.socketUrl // needs socketId
|
|
150
150
|
},
|
|
151
151
|
organization_id
|
|
152
152
|
});
|
|
@@ -234,8 +234,8 @@ class SocketServer extends EventEmitter {
|
|
|
234
234
|
|
|
235
235
|
if (!Object.keys(clients).length) {
|
|
236
236
|
this.organizations.delete(socket.organization_id);
|
|
237
|
-
this.emit('update
|
|
238
|
-
method: 'update
|
|
237
|
+
this.emit('object.update', {
|
|
238
|
+
method: 'object.update',
|
|
239
239
|
array: 'organizations',
|
|
240
240
|
object: {
|
|
241
241
|
_id: organization_id, ['$pull.activeHost']: socket.socketUrl
|
|
@@ -330,7 +330,7 @@ class SocketServer extends EventEmitter {
|
|
|
330
330
|
if (data.method === 'region.added' || data.method === 'region.removed')
|
|
331
331
|
console.log('data.method: ', data.method)
|
|
332
332
|
|
|
333
|
-
if (socket.user_id && socket.expires && new Date().getTime() >= socket.expires) {
|
|
333
|
+
if (socket.user_id && socket.expires && new Date(new Date().toISOString()).getTime() >= socket.expires) {
|
|
334
334
|
socket.user_id = socket.expires = null
|
|
335
335
|
this.send({ socket, method: 'updateUserStatus', userStatus: 'off', socketId: data.socketId, organization_id })
|
|
336
336
|
}
|
|
@@ -348,7 +348,11 @@ class SocketServer extends EventEmitter {
|
|
|
348
348
|
|
|
349
349
|
const authorized = await this.authorize.check(data, socket.user_id)
|
|
350
350
|
let errors = {}
|
|
351
|
-
if (authorized
|
|
351
|
+
if (authorized === false) {
|
|
352
|
+
delete data.socket
|
|
353
|
+
data.error = 'authorization failed'
|
|
354
|
+
return socket.send(JSON.stringify(data))
|
|
355
|
+
} else if (authorized.serverOrganization === false) {
|
|
352
356
|
organization.status = errors.status = false;
|
|
353
357
|
organization.serverOrganization = false;
|
|
354
358
|
organization.error = authorized.error
|
|
@@ -426,11 +430,12 @@ class SocketServer extends EventEmitter {
|
|
|
426
430
|
if (authorized && authorized.authorized)
|
|
427
431
|
data = authorized.authorized
|
|
428
432
|
|
|
429
|
-
if (data.log !== false && data.log !== 'false' && !data.method.
|
|
433
|
+
if (data.log !== false && data.log !== 'false' && !data.method.endsWith('.read') && data.method !== 'updateUserStatus' && data.method !== 'userStatus' && data.method !== 'signIn' && data.method !== 'signUp') {
|
|
434
|
+
// TODO: store logged messages more efficently by combing objects wherever possible
|
|
430
435
|
// let object = { url: socket.socketUrl, data }
|
|
431
436
|
// delete object.socket
|
|
432
|
-
// this.emit('create
|
|
433
|
-
// method: 'create
|
|
437
|
+
// this.emit('object.create', {
|
|
438
|
+
// method: 'object.create',
|
|
434
439
|
// array: 'message_log',
|
|
435
440
|
// object,
|
|
436
441
|
// organization_id: data.organization_id
|
package/src/mesh.js
CHANGED
|
@@ -16,7 +16,7 @@ async function addServer(data) {
|
|
|
16
16
|
|
|
17
17
|
// TODO: needs to get orgaizations activeRegions
|
|
18
18
|
let activeRegions = await crud.send({
|
|
19
|
-
method: 'read
|
|
19
|
+
method: 'object.read',
|
|
20
20
|
array: 'organizations',
|
|
21
21
|
object: { _id: data.organization_id },
|
|
22
22
|
organization_id: data.organization_id
|