@cocreate/socket-server 1.16.2 → 1.16.3
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 +7 -0
- package/package.json +1 -1
- package/src/index.js +13 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [1.16.3](https://github.com/CoCreate-app/CoCreate-socket-server/compare/v1.16.2...v1.16.3) (2023-08-21)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* update permission functions and variable to authorize for improved clarity and readability ([19c7415](https://github.com/CoCreate-app/CoCreate-socket-server/commit/19c74155e696886f3daab672489febf6009c2e1a))
|
|
7
|
+
|
|
1
8
|
## [1.16.2](https://github.com/CoCreate-app/CoCreate-socket-server/compare/v1.16.1...v1.16.2) (2023-08-21)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -96,7 +96,7 @@ class SocketServer extends EventEmitter {
|
|
|
96
96
|
|
|
97
97
|
// TODO: remove if no one else connected to organization
|
|
98
98
|
this.emit("deleteMetrics", { organization_id });
|
|
99
|
-
this.emit("
|
|
99
|
+
this.emit("deleteAuthorized", organization_id);
|
|
100
100
|
this.emit('disconnect', organization_id)
|
|
101
101
|
} else {
|
|
102
102
|
this.emit("updateMetrics", {
|
|
@@ -124,20 +124,20 @@ class SocketServer extends EventEmitter {
|
|
|
124
124
|
|
|
125
125
|
if (this.authorize) {
|
|
126
126
|
data.host = this.getHost(req)
|
|
127
|
-
const
|
|
128
|
-
if (
|
|
127
|
+
const authorized = await this.authorize.check(data, user_id)
|
|
128
|
+
if (authorized.storage === false) {
|
|
129
129
|
data.database = process.env.organization_id
|
|
130
130
|
data.organization_id = process.env.organization_id
|
|
131
131
|
|
|
132
|
-
const
|
|
133
|
-
if (!
|
|
134
|
-
return this.send(socket, { method: 'Access Denied',
|
|
132
|
+
const authorized2 = await this.authorize.check(data, req, user_id)
|
|
133
|
+
if (!authorized2 || authorized2.error) {
|
|
134
|
+
return this.send(socket, { method: 'Access Denied', authorized2, ...data })
|
|
135
135
|
}
|
|
136
|
-
} else if (!
|
|
136
|
+
} else if (!authorized || authorized.error) {
|
|
137
137
|
if (!user_id)
|
|
138
138
|
this.send(socket, { method: 'updateUserStatus', userStatus: 'off', clientId: data.clientId, organization_id })
|
|
139
139
|
|
|
140
|
-
return this.send(socket, { method: 'Access Denied',
|
|
140
|
+
return this.send(socket, { method: 'Access Denied', authorized, ...data })
|
|
141
141
|
}
|
|
142
142
|
// dburl is true and db does not have 'keys' array
|
|
143
143
|
// action: syncCollection data{array: 'keys', object[]}
|
|
@@ -146,8 +146,8 @@ class SocketServer extends EventEmitter {
|
|
|
146
146
|
|
|
147
147
|
// }
|
|
148
148
|
|
|
149
|
-
if (
|
|
150
|
-
data =
|
|
149
|
+
if (authorized.authorized)
|
|
150
|
+
data = authorized.authorized
|
|
151
151
|
|
|
152
152
|
if (user_id) {
|
|
153
153
|
if (!socket.config.user_id) {
|
|
@@ -205,9 +205,9 @@ class SocketServer extends EventEmitter {
|
|
|
205
205
|
if (clients) {
|
|
206
206
|
for (let client of clients) {
|
|
207
207
|
if (socket != client && data.broadcast != false || socket == client && data.broadcastSender != false) {
|
|
208
|
-
const
|
|
209
|
-
if (
|
|
210
|
-
data =
|
|
208
|
+
const authorized = await this.authorize.check(data, socket.config.user_id)
|
|
209
|
+
if (authorized && authorized.authorized)
|
|
210
|
+
data = authorized.authorized
|
|
211
211
|
|
|
212
212
|
let responseData = JSON.stringify(data);
|
|
213
213
|
|