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

@vivocha/scopes

Package Overview
Dependencies
Maintainers
12
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vivocha/scopes

Vivocha API Scopes Utilities

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
280
decreased by-5.08%
Maintainers
12
Weekly downloads
 
Created
Source

Vivocha Scopes

An utility to parse and test Vivocha OpenAPI Scopes.

How to use

Match Scopes

import { Scopes } from '@vivocha/scopes';

// Scopes can be passed as string or string[]
const s = new Scopes(["User.*", "-User.create", "Sessions.read", "*.update"]);
s.match("User.read");       // true
s.match("User.create");     // false
s.match("Session.delete");  // false
s.match("Asset.update");    // true

Character '*' means 'everything'
const s2 = new Scopes("*");
s2.match("User.delete");    // true
s2.match("Account.update"); // true

const s3 = new Scopes("*.delete");
s3.match("User.delete");    // true
s3.match("Account.update"); // false

const s4 = new Scopes("User.*");
s4.match("User.create");    // true
s4.match("User.read");      // true
s4.match("User.update");    // true
s4.match("User.delete");    // true
s4.match('Accound.read');   // false

Filter Scopes (returns all Scopes that match the filter condition)

import { Scopes } from '@vivocha/scopes';

const s5 = new Scopes(["User.*"]);
s5.filter("User.delete").toArray() // ["User.delete"]

const s6 = new Scopes(["User.*", "-User.delete", "*.read"]);
s6.filter("User.delete User.update Asset.delete Asset.update Asset.read").toArray() // ["User.update", "Asset.read"]

toArray() and toString()

If you want to retrieve the Scopes value you can use toString and toArray methods.

import { Scopes } from '@vivocha/scopes';

const s = new Scopes(["User.*", "-User.create", "Sessions.read", "*.update"]);
s.toString()  // User.* -User.create Sessions.read *.update
s.toArray()   // ['User.*', '-User.create', 'Sessions.read', '*.update']

Keywords

FAQs

Package last updated on 30 Sep 2019

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