New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@tipe/roles

Package Overview
Dependencies
Maintainers
7
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tipe/roles - npm Package Compare versions

Comparing version 0.0.2 to 0.1.0

10

package.json
{
"name": "@tipe/roles",
"version": "0.0.2",
"version": "0.1.0",
"description": "",

@@ -11,11 +11,11 @@ "main": "src/index.js",

"type": "git",
"url": "git+https://github.com/onespeed-io/tipe-roles.git"
"url": "git+https://github.com/tipeio/tipe-roles.git"
},
"author": "",
"author": "Patrick <patrick@tipe.io>",
"license": "MIT",
"bugs": {
"url": "https://github.com/onespeed-io/tipe-roles/issues"
"url": "https://github.com/tipeio/tipe-roles/issues"
},
"homepage": "https://github.com/onespeed-io/tipe-roles#readme",
"homepage": "https://github.com/tipeio/tipe-roles#readme",
"dependencies": {}
}

@@ -55,3 +55,3 @@

Creator: 'Creator',
Member: 'member',
Member: 'Member',
Editor: 'Editor'

@@ -61,2 +61,5 @@ }

exports.roleToPolicies = function roleToPolicies(role) {
if (typeof role !== 'string') {
throw new Error('roleToPolicies ' + role + ' needs to be type string')
}
switch (role) {

@@ -255,1 +258,39 @@ case exports.roles.Owner: return exports.owner().policies

}
exports.isAllowed = function isAllowed(policy, id, type, roles, onError) {
// list of all policies in project plus org
return exports.getRoles(id, type, roles).indexOf(policy) !== -1
}
exports.getRoles = function getRoles(id, type, roles, onError) {
if (type === 'ORG_ROLE') {
const orgRole = roles.find(role => role.org.toString() === id.toString())
if (!orgRole) {
return onError({ type: 'ORG_ROLE', id, type, roles })
}
return roleToPolicies(orgRole.roles)
}
const orgs = {}
const projectRole = roles
.filter(function(role) {
if (role.type === 'ORG_ROLE') {
// refactor roles to role
orgs[role.org] = role.role || role.roles
}
return role.type === 'PROJECT_ROLE'
})
.find(function(role) { return role.project.toString() === id.toString() })
if (!projectRole) {
return onError({ type: 'PROJECT_ROLE', id, type, roles })
}
const roles = [].concat(
orgs[projectRole.org],
// refactor roles to role
projectRole.role || projectRole.roles
)
return roles.map(function(role) { return roleToPolicies(role) })
}
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