@cocreate/socket-server 1.8.0 → 1.8.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,11 @@
1
+ ## [1.8.1](https://github.com/CoCreate-app/CoCreate-socket-server/compare/v1.8.0...v1.8.1) (2023-05-20)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Refactor socket server code to re check permissions using platformId when organization.dbUrl is false. ([e0cae7a](https://github.com/CoCreate-app/CoCreate-socket-server/commit/e0cae7a0a2eb9c740f36a3306fc038a9c68329ab))
7
+ * updated dependencies to their latest versions ([84d2f1d](https://github.com/CoCreate-app/CoCreate-socket-server/commit/84d2f1d0a67b021682f5b9b543ededb995830231))
8
+
1
9
  # [1.8.0](https://github.com/CoCreate-app/CoCreate-socket-server/compare/v1.7.7...v1.8.0) (2023-05-19)
2
10
 
3
11
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/socket-server",
3
- "version": "1.8.0",
3
+ "version": "1.8.1",
4
4
  "description": "CoCreate-socket-server",
5
5
  "keywords": [
6
6
  "cocreate-socket",
@@ -40,8 +40,8 @@
40
40
  },
41
41
  "homepage": "https://cocreate.app/docs/CoCreate-socket-server",
42
42
  "dependencies": {
43
- "@cocreate/docs": "^1.5.13",
44
- "@cocreate/uuid": "^1.2.61"
43
+ "@cocreate/docs": "^1.7.11",
44
+ "@cocreate/uuid": "^1.4.10"
45
45
  },
46
46
  "devDependencies": {
47
47
  "express": "^4.17.1",
package/src/index.js CHANGED
@@ -153,28 +153,16 @@ class SocketServer extends EventEmitter {
153
153
  // if (action == 'syncServer')
154
154
  // this.emit('createDocument', socket, data);
155
155
  // else
156
- if (user_id && permission.dbUrl === false && action.includes('Document') && (data.collection == 'organizations' || data.collection == 'users')) {
156
+ if (permission.dbUrl === false) {
157
157
  data.database = process.env.organization_id
158
158
  data.organization_id = process.env.organization_id
159
- if (data.document) {
160
- if (Array.isArray(data.document) && data.document[0])
161
- data.document = data.document[0]
162
-
163
- if (data.collection == 'organizations' && data.document._id !== socket.config.organization_id)
164
- return this.send(socket, 'Access Denied', { action, permission, ...data })
165
- else if (data.collection == 'users' && data.document._id !== user_id)
166
- return this.send(socket, 'Access Denied', { action, permission, ...data })
159
+
160
+ const permission2 = await this.permissionInstance.check(action, data, req, user_id)
161
+ if (!permission2 || permission2.error) {
162
+ return this.send(socket, 'Access Denied', { action, permission2, ...data })
167
163
  }
168
- delete data.filter
169
- delete data.document.organization_id
170
- if (action == 'updateDocument')
171
- data.upsert = false
172
- } else if (action === 'createOrganization' || action === 'signIn') {
173
- data.database = process.env.organization_id
174
- data.organization_id = process.env.organization_id
175
- } else {
164
+ } else
176
165
  return this.send(socket, 'Access Denied', { action, permission, ...data })
177
- }
178
166
  }
179
167
  }
180
168