@cocreate/socket-server 1.13.19 → 1.14.0
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 +13 -0
- package/CoCreate.config.js +2 -2
- package/docs/index.html +8 -8
- package/package.json +1 -1
- package/src/index.js +19 -22
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
# [1.14.0](https://github.com/CoCreate-app/CoCreate-socket-server/compare/v1.13.19...v1.14.0) (2023-08-16)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* crud attributes renamed ([e17e290](https://github.com/CoCreate-app/CoCreate-socket-server/commit/e17e290df4500495f070a93e69ffaafe4f1639f8))
|
|
7
|
+
* Refactored *-target to *-selector ([6716c50](https://github.com/CoCreate-app/CoCreate-socket-server/commit/6716c5011ff3b78445bac13c7337bd49f35cc71c))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* name attribute and variable renamed to key ([ac1e91e](https://github.com/CoCreate-app/CoCreate-socket-server/commit/ac1e91e595b8a52c869bb34e629843cff22fa979))
|
|
13
|
+
|
|
1
14
|
## [1.13.19](https://github.com/CoCreate-app/CoCreate-socket-server/compare/v1.13.18...v1.13.19) (2023-06-16)
|
|
2
15
|
|
|
3
16
|
|
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
|
+
key="description"
|
|
15
15
|
content="A simple HTML5 and pure javascript component. Easy configuration using data-attributes and highly styleable." />
|
|
16
16
|
<meta
|
|
17
|
-
|
|
17
|
+
key="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
|
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
</head>
|
|
29
29
|
|
|
30
30
|
<body>
|
|
31
|
-
<div
|
|
31
|
+
<div array="" object="" key="" id="cocreate-socket-server">
|
|
32
32
|
<div
|
|
33
33
|
class="display:flex flex-wrap:wrap justify-content:space-between margin:10px">
|
|
34
34
|
<div class="display:flex align-items:center">
|
|
@@ -153,9 +153,9 @@
|
|
|
153
153
|
<textarea
|
|
154
154
|
type="code"
|
|
155
155
|
lang="html"
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
156
|
+
array="demos"
|
|
157
|
+
object=""
|
|
158
|
+
key="demo"
|
|
159
159
|
save="false"
|
|
160
160
|
id="demo"
|
|
161
161
|
class="height:100% width:100% outline:none border:none resize:none padding:5px"></textarea>
|
|
@@ -178,7 +178,7 @@
|
|
|
178
178
|
show="#eye-slash"
|
|
179
179
|
hide="#eye, #demo-preview"
|
|
180
180
|
toggle="code-height"
|
|
181
|
-
toggle-
|
|
181
|
+
toggle-selector="#demo-code"
|
|
182
182
|
><i class="far fa-eye"></i
|
|
183
183
|
></a>
|
|
184
184
|
<a
|
|
@@ -188,7 +188,7 @@
|
|
|
188
188
|
show="#eye, #demo-preview"
|
|
189
189
|
hide="#eye-slash"
|
|
190
190
|
toggle="code-height"
|
|
191
|
-
toggle-
|
|
191
|
+
toggle-selector="#demo-code"
|
|
192
192
|
><i class="fas fa-eye-slash"></i
|
|
193
193
|
></a>
|
|
194
194
|
<a
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -54,7 +54,7 @@ class SocketServer extends EventEmitter {
|
|
|
54
54
|
self.removeClient(socket)
|
|
55
55
|
});
|
|
56
56
|
|
|
57
|
-
this.send(socket, 'connect', socket.config.key);
|
|
57
|
+
this.send(socket, { method: 'connect', connectedKey: socket.config.key });
|
|
58
58
|
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -119,9 +119,9 @@ class SocketServer extends EventEmitter {
|
|
|
119
119
|
async onMessage(req, socket, message) {
|
|
120
120
|
try {
|
|
121
121
|
const organization_id = socket.config.organization_id
|
|
122
|
-
let
|
|
122
|
+
let data = JSON.parse(message)
|
|
123
123
|
|
|
124
|
-
if (
|
|
124
|
+
if (data.method) {
|
|
125
125
|
this.emit("setBandwidth", {
|
|
126
126
|
type: 'in',
|
|
127
127
|
data: message,
|
|
@@ -133,23 +133,23 @@ class SocketServer extends EventEmitter {
|
|
|
133
133
|
|
|
134
134
|
if (this.authorize) {
|
|
135
135
|
data.host = this.getHost(req)
|
|
136
|
-
const permission = await this.authorize.check(
|
|
136
|
+
const permission = await this.authorize.check(data, user_id)
|
|
137
137
|
if (permission.storage === false) {
|
|
138
138
|
data.database = process.env.organization_id
|
|
139
139
|
data.organization_id = process.env.organization_id
|
|
140
140
|
|
|
141
|
-
const permission2 = await this.authorize.check(
|
|
141
|
+
const permission2 = await this.authorize.check(data, req, user_id)
|
|
142
142
|
if (!permission2 || permission2.error) {
|
|
143
|
-
return this.send(socket, 'Access Denied',
|
|
143
|
+
return this.send(socket, { method: 'Access Denied', permission2, ...data })
|
|
144
144
|
}
|
|
145
145
|
} else if (!permission || permission.error) {
|
|
146
146
|
if (!user_id)
|
|
147
|
-
this.send(socket, 'updateUserStatus',
|
|
147
|
+
this.send(socket, { method: 'updateUserStatus', userStatus: 'off', clientId: data.clientId, organization_id })
|
|
148
148
|
|
|
149
|
-
return this.send(socket, 'Access Denied',
|
|
149
|
+
return this.send(socket, { method: 'Access Denied', permission, ...data })
|
|
150
150
|
}
|
|
151
|
-
// dburl is true and db does not have 'keys'
|
|
152
|
-
// action: syncCollection data{
|
|
151
|
+
// dburl is true and db does not have 'keys' array
|
|
152
|
+
// action: syncCollection data{array: 'keys', object[]}
|
|
153
153
|
// actions: add keys as once keys are added admin user can do anything
|
|
154
154
|
|
|
155
155
|
|
|
@@ -161,13 +161,13 @@ class SocketServer extends EventEmitter {
|
|
|
161
161
|
if (user_id) {
|
|
162
162
|
if (!socket.config.user_id) {
|
|
163
163
|
socket.config.user_id = user_id
|
|
164
|
-
this.emit('userStatus', socket, { user_id, userStatus: 'on', organization_id });
|
|
164
|
+
this.emit('userStatus', socket, { method: 'userStatus', user_id, userStatus: 'on', organization_id });
|
|
165
165
|
}
|
|
166
166
|
} else {
|
|
167
|
-
this.send(socket, 'updateUserStatus',
|
|
167
|
+
this.send(socket, { method: 'updateUserStatus', userStatus: 'off', clientId: data.clientId, organization_id })
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
-
this.emit(
|
|
170
|
+
this.emit(data.method, socket, data);
|
|
171
171
|
|
|
172
172
|
}
|
|
173
173
|
}
|
|
@@ -176,7 +176,7 @@ class SocketServer extends EventEmitter {
|
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
-
broadcast(socket,
|
|
179
|
+
broadcast(socket, data) {
|
|
180
180
|
if (!data.uid)
|
|
181
181
|
data.uid = uid.generate()
|
|
182
182
|
|
|
@@ -197,14 +197,14 @@ class SocketServer extends EventEmitter {
|
|
|
197
197
|
let url = url;
|
|
198
198
|
url += `/${room}`;
|
|
199
199
|
|
|
200
|
-
this.send(socket,
|
|
200
|
+
this.send(socket, data, url)
|
|
201
201
|
}
|
|
202
202
|
} else {
|
|
203
|
-
this.send(socket,
|
|
203
|
+
this.send(socket, data, url)
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
206
|
|
|
207
|
-
async send(socket,
|
|
207
|
+
async send(socket, data, url) {
|
|
208
208
|
let clients
|
|
209
209
|
if (!url)
|
|
210
210
|
clients = [socket]
|
|
@@ -214,14 +214,11 @@ class SocketServer extends EventEmitter {
|
|
|
214
214
|
if (clients) {
|
|
215
215
|
for (let client of clients) {
|
|
216
216
|
if (socket != client && data.broadcast != false || socket == client && data.broadcastSender != false) {
|
|
217
|
-
const permission = await this.authorize.check(
|
|
217
|
+
const permission = await this.authorize.check(data, socket.config.user_id)
|
|
218
218
|
if (permission && permission.authorized)
|
|
219
219
|
data = permission.authorized
|
|
220
220
|
|
|
221
|
-
let responseData = JSON.stringify(
|
|
222
|
-
action,
|
|
223
|
-
data
|
|
224
|
-
});
|
|
221
|
+
let responseData = JSON.stringify(data);
|
|
225
222
|
|
|
226
223
|
socket.send(responseData);
|
|
227
224
|
|