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
1
Versions
219
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.2.26 to 0.2.27

invite.js

16

access.js

@@ -7,3 +7,3 @@

function clientHasAnyAccess(client, toType, toId) {
function clientHasAnyAccess(client, { objectType, object }) {
/// TODO: access control

@@ -13,3 +13,3 @@ return true

function clientHasAdminAccess(client, toType, toId) {
function clientHasAdminAccess(client, { objectType, object }) {
/// TODO: access control

@@ -19,4 +19,14 @@ return true

return {clientHasAnyAccess, clientHasAdminAccess }
function clientCanInvite(client, { roles, objectType, object }) {
/// TODO: access control
return true
}
function clientCanRequest(client, { roles, objectType, object }) {
/// TODO: access control
return true
}
return { clientHasAnyAccess, clientHasAdminAccess, clientCanInvite, clientCanRequest }
}

@@ -6,3 +6,4 @@ const app = require("@live-change/framework").app()

require('./model.js')
require('./invite.js')
module.exports = definition

106

model.js

@@ -0,1 +1,3 @@

const App = require("@live-change/framework")
const app = App.app()
const definition = require('./definition.js')

@@ -11,7 +13,7 @@ const config = definition.config

readAccess: (params, { client, context, visibilityTest }) =>
visibilityTest || access.clientHasAnyAccess(client, params.objectType, params.object),
visibilityTest || access.clientHasAnyAccess(client, params),
updateAccess: (params, { client, context, visibilityTest }) =>
visibilityTest || access.clientHasAdminAccess(client, params.objectType, params.object),
visibilityTest || access.clientHasAdminAccess(client, params),
resetAccess: (params, { client, context, visibilityTest }) =>
visibilityTest || access.clientHasAdminAccess(client, params.objectType, params.object)
visibilityTest || access.clientHasAdminAccess(client, params)
},

@@ -38,5 +40,5 @@ properties: {

readAccess: (params, { client, context, visibilityTest }) =>
visibilityTest || access.clientHasAnyAccess(client, params.objectType, params.object),
visibilityTest || access.clientHasAnyAccess(client, params),
writeAccess: (params, { client, context, visibilityTest }) =>
visibilityTest || access.clientHasAdminAccess(client, params.objectType, params.object)
visibilityTest || access.clientHasAdminAccess(client, params)
},

@@ -60,2 +62,10 @@ properties: {

},
availableRoles: {
type: Array,
of: {
type: String,
validation: ['nonEmpty']
},
validation: ['elementsNonEmpty']
},
lastUpdate: {

@@ -71,8 +81,12 @@ type: Date

name: 'AccessRequest',
sessionOrUserItem: {
},
relatedToAny: {
to: 'object',
sessionOrUserProperty: {
extendedWith: ['object'],
ownerReadAccess: () => true,
ownerResetAccess: () => true,
readAccess: (params, { client, context, visibilityTest }) =>
visibilityTest || access.clientHasAdminAccess(client, params.objectType, params.object)
visibilityTest || access.clientHasAnyAccess(client, params),
updateAccess: (params, { client, context, visibilityTest }) =>
visibilityTest || access.clientHasAdminAccess(client, params),
resetAccess: (params, { client, context, visibilityTest }) =>
visibilityTest || access.clientHasAdminAccess(client, params)
},

@@ -97,24 +111,32 @@ properties: {

const invitationProperties = {
roles: {
type: Array,
of: {
type: String,
validation: ['nonEmpty']
},
validation: ['elementsNonEmpty']
},
message: {
type: String,
validation: []
}
}
const AccessInvite = definition.model({
name: 'AccessInvite',
contactOrUserItem: {},
relatedToAny: {
to: 'object',
readAccess: (params, {client, context, visibilityTest}) =>
visibilityTest || access.clientHasAdminAccess(client, params.objectType, params.object)
const AccessInvitation = definition.model({
name: 'AccessInvitation',
contactOrUserProperty: {
extendedWith: ['object'],
ownerReadAccess: () => true,
ownerResetAccess: () => true,
readAccess: (params, { client, context, visibilityTest }) =>
visibilityTest || access.clientHasAnyAccess(client, params),
updateAccess: (params, { client, context, visibilityTest }) =>
visibilityTest || access.clientHasAdminAccess(client, params),
resetAccess: (params, { client, context, visibilityTest }) =>
visibilityTest || access.clientHasAdminAccess(client, params)
},
properties: {
roles: {
type: Array,
of: {
type: String,
validation: ['nonEmpty']
},
validation: ['elementsNonEmpty']
},
message: {
type: String,
validation: []
}
...invitationProperties
},

@@ -126,2 +148,26 @@ indexes: {

module.exports = { Access, PublicAccess, AccessRequest, AccessInvite }
definition.event({
name: 'userInvited',
async execute({ user, objectType, object, roles, message }) {
await AccessInvitation.create({
id: App.encodeIdentifier(['user_User', user, objectType, object]),
contactOrUserType: 'user_User', contactOrUser: user,
objectType, object,
roles, message
})
}
})
definition.event({
name: 'contactInvited',
async execute({ contactType, contact, objectType, object, roles, message }) {
await AccessInvitation.create({
id: App.encodeIdentifier([contactType, contact, objectType, object]),
contactOrUserType: contactType, contactOrUser: contact,
objectType, object,
roles, message
})
}
})
module.exports = { Access, PublicAccess, AccessRequest, AccessInvitation, invitationProperties }
{
"name": "@live-change/access-control-service",
"version": "0.2.26",
"version": "0.2.27",
"description": "",

@@ -26,3 +26,3 @@ "main": "index.js",

},
"gitHead": "f3d7b9b6c689b9d87df3cb7f64cd75fc72339b7a"
"gitHead": "9a82ff0e7a7003d5b4e34ef9aef1ad4d7d8605dd"
}
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