@live-change/access-control-service 0.8.82 → 0.8.84

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/access.js CHANGED
@@ -108,13 +108,7 @@ export default (definition) => {
108
108
  return roles
109
109
  }
110
110
 
111
- async function checkRoles(client, { objectType, object, objects }, callback, ignorePublic) {
112
- const allObjects = ((objectType && object) ? [{ objectType, object }] : []).concat(objects || [])
113
- const roles = await getClientObjectsRoles(client, allObjects, ignorePublic)
114
- //console.log('checkRoles', allObjects, roles)
115
- //console.trace("CHECK ROLES!")
116
- return await callback(roles, client, { objectType, object })
117
- }
111
+
118
112
 
119
113
  /// QUERIES:
120
114
 
@@ -309,19 +303,15 @@ export default (definition) => {
309
303
  }]
310
304
  }
311
305
 
312
- /*
313
- function accessLimitedGet(client, objects, requiredRoles, path) {
314
- const roles = getClientObjectsRoles(client, objects)
315
- for(const requiredRole of requiredRoles) {
316
-
317
- }
318
- }
319
-
320
- function accessLimitedObservable(client, objects, path) {
321
- if(path[0] !== 'database') throw new Error("non database path "+ JSON.stringify(path))
322
- const isObject = path[1] === 'queryObject' || path[1] === ''
306
+ async function checkRoles(client, { objectType, object, objects }, callback, ignorePublic) {
307
+ const allObjects = ((objectType && object) ? [{ objectType, object }] : []).concat(objects || [])
308
+ //const roles = await getClientObjectsRoles(client, allObjects, ignorePublic)
309
+ const access = await app.dao.get(accessPath(client, allObjects))
310
+ const roles = access.roles
311
+ //console.log('checkRoles', allObjects, roles)
312
+ //console.trace("CHECK ROLES!")
313
+ return await callback(roles, client, { objectType, object })
323
314
  }
324
- */
325
315
 
326
316
  return {
327
317
  testRoles,
package/invite.js CHANGED
@@ -136,7 +136,9 @@ definition.trigger({
136
136
  console.error("INVITE WITH MESSAGE AUTHENTICATED", { contactType, contact, session, objectType, object })
137
137
  const contactTypeUpperCase = contactType[0].toUpperCase() + contactType.slice(1)
138
138
  /// Load invitation
139
- const invitation = App.encodeIdentifier([ contactType + '_' + contactTypeUpperCase, contact, objectType, object ])
139
+ const invitation = App.encodeIdentifier([
140
+ contactType + '_' + contactTypeUpperCase, contact, objectType, object
141
+ ])
140
142
  console.log("INVITATION", invitation)
141
143
  const invitationData = await AccessInvitation.get(invitation)
142
144
  if(!invitationData) throw 'not_found'
package/model.js CHANGED
@@ -116,7 +116,10 @@ const AccessInvitation = definition.model({
116
116
  }
117
117
  },
118
118
  indexes: {
119
-
119
+ byOwnerRoleAndObject: {
120
+ property: ['contactOrUserType', 'contactOrUser', 'roles', 'objectType', 'object'],
121
+ multi: true
122
+ }
120
123
  }
121
124
  })
122
125
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/access-control-service",
3
- "version": "0.8.82",
3
+ "version": "0.8.84",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -21,8 +21,8 @@
21
21
  "url": "https://www.viamage.com/"
22
22
  },
23
23
  "dependencies": {
24
- "@live-change/framework": "^0.8.82"
24
+ "@live-change/framework": "^0.8.84"
25
25
  },
26
- "gitHead": "72f303118f6bb5e324c5d77473b456fc10f7ed04",
26
+ "gitHead": "53f9ddc7529c28f12cb77c4a2758b553461e46b6",
27
27
  "type": "module"
28
28
  }
package/view.js CHANGED
@@ -5,7 +5,7 @@ const app = App.app()
5
5
  import accessModule from './access.js'
6
6
  const access = accessModule(definition)
7
7
 
8
- import { Access } from './model.js'
8
+ import { Access, AccessInvitation } from './model.js'
9
9
 
10
10
  definition.view({
11
11
  name: "myAccessTo",
@@ -121,3 +121,51 @@ definition.view({
121
121
  [sessionOrUserType, sessionOrUser, role, objectType], App.extractRange(properties))
122
122
  }
123
123
  })
124
+
125
+ definition.view({
126
+ name: 'myAccessInvitationsByObjectType',
127
+ properties: {
128
+ objectType: {
129
+ type: String
130
+ },
131
+ ...App.rangeProperties
132
+ },
133
+ returns: {
134
+ type: Array,
135
+ of: {
136
+ type: Access
137
+ }
138
+ },
139
+ async daoPath(properties, { client, service }, method) {
140
+ const [ sessionOrUserType, sessionOrUser ] =
141
+ client.user ? ['user_User', client.user] : ['session_Session', client.session]
142
+ const { objectType } = properties
143
+ return AccessInvitation.rangePath([sessionOrUserType, sessionOrUser, objectType], App.extractRange(properties))
144
+ }
145
+ })
146
+
147
+ definition.view({
148
+ name: 'myAccessInvitationsByObjectTypeAndRole',
149
+ properties: {
150
+ objectType: {
151
+ type: String
152
+ },
153
+ role: {
154
+ type: String
155
+ },
156
+ ...App.rangeProperties
157
+ },
158
+ returns: {
159
+ type: Array,
160
+ of: {
161
+ type: Access
162
+ }
163
+ },
164
+ async daoPath(properties, { client, service }, method) {
165
+ const [ sessionOrUserType, sessionOrUser ] =
166
+ client.user ? ['user_User', client.user] : ['session_Session', client.session]
167
+ const { objectType, role } = properties
168
+ return AccessInvitation.indexRangePath('byOwnerRoleAndObject',
169
+ [sessionOrUserType, sessionOrUser, role, objectType], App.extractRange(properties))
170
+ }
171
+ })