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

auth-scope

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

auth-scope

Create authorization scope from collection of roles and/or permissions.

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

auth-scope

Create a scope from collection of roles and/or permissions.

Originally made for use with oauth2orize and the scope parameter, but could be adapted to different scenarios.

Installation

Node

npm install auth-scope

Browser

component install alexmingoia/auth-scope

Example

var Permission = require('auth-permission')
  , Role = require('auth-role')
  , Scope = require('auth-scope');

// Specify any number of roles or permissions
var roles = new Scope([
  Role('api')
    .allow(Permission('read profile'))
    .allow(Permission('read post')),
  Permission('create account'),
  Permission('update billing')
]);

// Get scope permissions
var permissions = scope.permissions();

JSON.stringify(permissions);
// => ['read profile', 'read post', 'create account']

// Create new scope by narrowing current scope.
var restricted = scope.narrow(['api', 'create account']));

API

new Scope(collection)

Create a new scope from collection of permissions and roles.

scope.find(query)

Find permissions or roles in scope.

Array|String|Scope query array of role or permission names, another scope, or a string of comma separated role or permission names.

Returns array of roles or permissions

scope.narrow(query)

Create a new scope by narrowing existing scope.

Array|String|Scope query array of role or permission names, another scope, or a string of comma separated role or permission names.

Returns new scope.

scope.match(query)

Array|String|Scope query array of role or permission names, another scope, or a string of comma separated role or permission names.

Returns boolean.

scope.has(name)

Check if scope has given role or permission.

Returns boolean.

scope.roles()

Returns array of scope roles.

scope.permissions()

Returns scope permissions, including those in scope roles.

scope.names()

scope.toJSON()

Returns array of scope role or permission names.

Tests

Tests are written with mocha and should.js using BDD-style assertions.

Run them using npm:

npm test

MIT Licensed

Keywords

FAQs

Package last updated on 10 Nov 2013

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