New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

scope-map

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scope-map

define a tree of scopes, creating scope strings to provide access without redundancy, and matching agains required scopes

latest
Source
npmnpm
Version
1.5.0
Version published
Maintainers
1
Created
Source

scope-map

MIT license minified size 20kb

define trees of scopes, create scope strings to provide access without redundancy, and matching agains required scopes

NPM

usage

creating a scope layout

const scope = require('scope-map');

let layout = scope`
    root {
        scope1
        scope2
    }
`;

creating permissions to target route(s)

let allow_root = layout.allow('root');
let allow_0 = layout.allow('scope1');
let allow_1 = layout.allow('scope1 scope2');
let allow_2 = layout.allow('scope1', 'scope2');
let allow_3 = layout.allow`scope1 scope2`;

/* NOTE:
 * scope map doesnt extrapolate all sub scopes to mean
 * a common parent scope so that parent scopes can later
 * be expanded without giving scopes to unauthorized clients
 */ 
// true
console.log(allow_root != allow_1);

scope modifiers

let allow_read_0 = layout.allow('scope1');
let allow_read_1 = layout.allow('scope1:r');
let allow_write = layout.allow('scope1:w');
let allow_read_write_0 = layout.allow('scope1:rw');
let allow_read_write_1 = layout.allow('scope1:wr');
let allow_exclude = layout.allow('scope1:x');

creating requiremnts

let require_0 = layout.require('scope1');
let require_1 = layout.require('scope1 scope2');
let require_2 = layout.require('scope1', 'scope2');
let require_3 = layout.require`scope1 scope2`;

let require_read_0 = layout.require('scope1');
let require_read_1 = layout.require('scope1:r');
let require_write = layout.require('scope1:w');
let require_read_write_0 = layout.require('scope1:rw');
let require_read_write_1 = layout.require('scope1:wr');

using requiremnts on a scope

// true
console.log(require_0(allow_0));

requirements will remember scopes that are passed to them so that subsequent calls for the same scope run faster

you can also pre prime all requirments so that common scopes run faster. this effects all existing requirments and all future requirements

layout.prime(allow_0);

Keywords

scope

FAQs

Package last updated on 04 Mar 2022

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