@live-change/access-control-service 0.9.194 → 0.9.196

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/accessControl.js CHANGED
@@ -37,7 +37,7 @@ definition.processor({
37
37
  /* console.log("ACTION", service.name, action.name, "ACCESS CONTROL TO",
38
38
  objects, 'CLIENT', client, 'CONFIG', config, "ACCESSIBLE", accessible) */
39
39
 
40
- if(!accessible) throw 'notAuthorized'
40
+ if(!accessible) throw app.logicError("notAuthorized")
41
41
 
42
42
  return oldExec.apply(action, args)
43
43
  }
@@ -69,7 +69,7 @@ definition.processor({
69
69
  console.log("ROLES", config.roles) */
70
70
  const accessible = await access.clientHasAccessRoles(client, { objects }, config.roles)
71
71
  //console.log("ACCESSIBLE", accessible)
72
- if(!accessible) throw 'notAuthorized'
72
+ if(!accessible) throw app.logicError("notAuthorized")
73
73
  return oldGet.apply(view, args)
74
74
  }
75
75
  view.observable = (...args) => {
package/invite.js CHANGED
@@ -144,7 +144,7 @@ definition.trigger({
144
144
  ])
145
145
  console.log("INVITATION", invitation)
146
146
  const invitationData = await AccessInvitation.get(invitation)
147
- if(!invitationData) throw 'not_found'
147
+ if(!invitationData) throw app.logicError("not_found")
148
148
  const { roles } = invitationData
149
149
  /// Create account and sign-in:
150
150
  const user = app.generateUid()
@@ -177,12 +177,12 @@ definition.action({
177
177
  }
178
178
  },
179
179
  async execute({ objectType, object }, {client, service}, emit) {
180
- if(!client.user) throw 'not_authorized'
180
+ if(!client.user) throw app.logicError("not_authorized")
181
181
  const user = client.user
182
182
  const invitation = App.encodeIdentifier(['user_User', user, objectType, object])
183
183
  const invitationData = await AccessInvitation.get(invitation)
184
184
  console.log("INVITATION", invitation, invitationData)
185
- if(!invitationData) throw 'not_found'
185
+ if(!invitationData) throw app.logicError("not_found")
186
186
  const { roles } = invitationData
187
187
  emit({
188
188
  type: 'userInvitationAccepted',
@@ -280,7 +280,7 @@ for(const contactType of config.contactTypes) {
280
280
  const myRoles = await access.getClientObjectRoles(client, { objectType, object }, true)
281
281
  if(!myRoles.includes('admin')) {
282
282
  for(const requestedRole of roles) {
283
- if(!myRoles.includes(requestedRole)) throw 'notAuthorized'
283
+ if(!myRoles.includes(requestedRole)) throw app.logicError("notAuthorized")
284
284
  }
285
285
  }
286
286
 
@@ -401,7 +401,7 @@ for(const contactType of config.contactTypes) {
401
401
  const myRoles = await access.getClientObjectRoles(client, { objectType, object }, true)
402
402
  if(!myRoles.includes('admin')) {
403
403
  for(const requestedRole of roles) {
404
- if(!myRoles.includes(requestedRole)) throw 'notAuthorized'
404
+ if(!myRoles.includes(requestedRole)) throw app.logicError("notAuthorized")
405
405
  }
406
406
  }
407
407
 
@@ -463,7 +463,7 @@ for(const contactType of config.contactTypes) {
463
463
  )
464
464
  if(!myRoles.includes('admin')) {
465
465
  for(const requestedRole of roles) {
466
- if(!myRoles.includes(requestedRole)) throw 'notAuthorized'
466
+ if(!myRoles.includes(requestedRole)) throw app.logicError("notAuthorized")
467
467
  }
468
468
  }
469
469
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/access-control-service",
3
- "version": "0.9.194",
3
+ "version": "0.9.196",
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.9.194"
24
+ "@live-change/framework": "^0.9.196"
25
25
  },
26
- "gitHead": "40d47cf397b45ca1f1fa888d4d85727376b2b0c0",
26
+ "gitHead": "7f358a1cc16fb35069f6ce3f897412232f766843",
27
27
  "type": "module"
28
28
  }
package/request.js CHANGED
@@ -40,14 +40,14 @@ definition.action({
40
40
  const [sessionOrUserType, sessionOrUser] =
41
41
  client.user ? ['user_User', client.user] : ['session_Session', client.session]
42
42
 
43
- if(!publicAccess.availableRoles) throw 'notAuthorized'
43
+ if(!publicAccess.availableRoles) throw app.logicError("notAuthorized")
44
44
  for(const requestedRole of roles) {
45
- if(!publicAccess.availableRoles.includes(requestedRole)) throw 'notAuthorized'
45
+ if(!publicAccess.availableRoles.includes(requestedRole)) throw app.logicError("notAuthorized")
46
46
  }
47
47
 
48
48
  const request = App.encodeIdentifier([ sessionOrUserType, sessionOrUser, objectType, object ])
49
49
  const requestData = await AccessRequest.get(request)
50
- if(requestData) throw 'already_requested'
50
+ if(requestData) throw app.logicError("already_requested")
51
51
 
52
52
  if(publicAccess.autoGrantRequests) {
53
53
  emit({
@@ -108,12 +108,12 @@ definition.action({
108
108
  const myRoles = await access.getClientObjectRoles(client, { objectType, object }, true)
109
109
  if(!myRoles.includes('admin')) {
110
110
  for(const requestedRole of roles) {
111
- if(!myRoles.includes(requestedRole)) throw 'notAuthorized'
111
+ if(!myRoles.includes(requestedRole)) throw app.logicError("notAuthorized")
112
112
  }
113
113
  }
114
114
  const request = App.encodeIdentifier([ sessionOrUserType, sessionOrUser, objectType, object ])
115
115
  const requestData = await AccessRequest.get(request)
116
- if(!requestData) throw 'not_found'
116
+ if(!requestData) throw app.logicError("not_found")
117
117
  emit({
118
118
  type: 'accessRequestAccepted',
119
119
  objectType, object, sessionOrUserType, sessionOrUser, roles
package/view.js CHANGED
@@ -39,7 +39,7 @@ definition.view({
39
39
  },
40
40
  async daoPath({ objectType, object, objects }, { client, service }, method) {
41
41
  const allObjects = ((objectType && object) ? [{ objectType, object }] : []).concat(objects || [])
42
- if(allObjects.length === 0) throw 'empty_objects_list'
42
+ if(allObjects.length === 0) throw app.logicError("empty_objects_list")
43
43
  return access.accessPath(client, allObjects)
44
44
  }
45
45
  })
@@ -69,7 +69,7 @@ definition.view({
69
69
  }
70
70
  },
71
71
  async daoPath({ objects }, { client, service }, method) {
72
- if(objects.length === 0) throw 'empty_objects_list'
72
+ if(objects.length === 0) throw app.logicError("empty_objects_list")
73
73
  return access.accessesPath(client, objects)
74
74
  }
75
75
  })