Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@live-change/access-control-service

Package Overview
Dependencies
Maintainers
0
Versions
218
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@live-change/access-control-service - npm Package Compare versions

Comparing version 0.8.125 to 0.8.126

4

model.js

@@ -58,2 +58,6 @@ import App from '@live-change/framework'

type: Date
},
autoGrantRequests: {
type: Number,
default: 0
}

@@ -60,0 +64,0 @@ },

6

package.json
{
"name": "@live-change/access-control-service",
"version": "0.8.125",
"version": "0.8.126",
"description": "",

@@ -24,6 +24,6 @@ "main": "index.js",

"dependencies": {
"@live-change/framework": "^0.8.125"
"@live-change/framework": "^0.8.126"
},
"gitHead": "d7d1cdd1d9d670e3eb065bf56fcdbc67e4d97dea",
"gitHead": "2aa34c0589d115aeaa573bd2cae09bb43a66d162",
"type": "module"
}

@@ -6,3 +6,3 @@ import App from '@live-change/framework'

import { Access, AccessRequest, rolesArrayType } from './model.js'
import { PublicAccess, Access, AccessRequest, rolesArrayType } from './model.js'
import accessModule from './access.js'

@@ -24,2 +24,64 @@ const access = accessModule(definition)

definition.action({
name: 'requestAccess',
properties: {
objectType: {
type: String,
validation: ['nonEmpty']
},
object: {
type: String,
validation: ['nonEmpty']
},
roles: rolesArrayType
},
queuedBy: ['objectType', 'object'],
waitForEvents: true,
access: (params, { client, context, visibilityTest }) =>
visibilityTest || access.clientCanInvite(client, params),
async execute({ objectType, object, roles }, { client, service }, emit) {
const publicAccess = await PublicAccess.get(App.encodeIdentifier([objectType, object]))
const [sessionOrUserType, sessionOrUser] =
client.user ? ['user_User', client.user] : ['session_Session', client.session]
if(!publicAccess.availableRoles) throw 'notAuthorized'
for(const requestedRole of roles) {
if(!publicAccess.availableRoles.includes(requestedRole)) throw 'notAuthorized'
}
const request = App.encodeIdentifier([ sessionOrUserType, sessionOrUser, objectType, object ])
const requestData = await AccessRequest.get(request)
if(requestData) throw 'already_requested'
if(publicAccess.autoGrantRequests) {
emit({
type: 'accessRequestAccepted',
objectType, object, sessionOrUserType, sessionOrUser, roles,
autoAccept: true
})
emit({
type: 'objectOwnedPublicAccessUpdated',
identifiers: {
objectType, object
},
data: {
autoGrantRequests: publicAccess.autoGrantRequests - 1
},
})
} else {
emit({
type: 'sessionOrUserAndObjectOwnedAccessRequestSet',
data: {
roles
},
identifiers: {
sessionOrUserType, sessionOrUser,
objectType, object,
roles
}
})
}
}
})
definition.action({
name: 'acceptAccessRequest',

@@ -26,0 +88,0 @@ waitForEvents: true,

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc