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

empower-permission

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

empower-permission

Given a permission set and a request return a permission token.

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9
increased by125%
Maintainers
1
Weekly downloads
 
Created
Source

Build Status Coverage Status

empower-permission

Given a permission set and a request return a permission token.

it will look in the PermissionMap for for a url that matches the given URL. If found, then it will return the token string associated with that path. Otherwise, it will return the GeneralAccessToken or '*'.

Paths will be parsed using the pathToRegexp module. g

PermissionToken

Example Token Strings:

'token:entity:create'
'token:entity:update'
'token:entity:sub-entity:read'

PermissionMap

This is a map of path strings to PermissionTokens

Example Map:

{
  "/url/token/entity/:entityId": "url:token:entity",
  "/url/token/:tokenId": "url:token",
  "/url/token": "url:token:list",
  "/url/token/:tokenId/action": "url:token:action"
}

Usage

Building the Map from JSON


var PermissionMap = require('empower-permission');
var map = PermissionMap.fromJson({
  "/url/token/entity/:entityId": "url:token:entity",
  "/url/token/:tokenId": "url:token",
  "/url/token": "url:token:list",
  "/url/token/:tokenId/action": "url:token:action"
}}

var token = map.getToken("/url/token/entity/1234");

console.log(token); // will output "url:token:entity"

Building the Map Programmatically


var PermissionMap = require('empower-permission');
var map = PermissionMap();

map
  .addToken("/url/token/entity/:entityId", "url:token:entity")
  .addToken("/url/token/:tokenId", "url:token")
  .addToken("/url/token", "url:token:list")
  .addToken("/url/token/:tokenId/action", "url:token:action")

var token = map.getToken("/url/token");

console.log(token); // will output "url:token:list"

Keywords

FAQs

Package last updated on 04 Nov 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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