npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@policyval/attacher

v0.1.2

Published

Javascript library for attaching policies in groups, resources and principal scopes

Downloads

2

Readme

policyval attacher

This utility helps you attach Global policies, policies to Principals, Principal groups and Resources. It's possible to attach Permission Boundaries also as a second layer of protection. This is similar to the basic AWS IAM concepts.

Usage example

  • npm install --save @policyval/attacher
import { newAttacher } from '@policyval/attacher';
import { PolicyDocument, compilePolicies } from '@policyval/core';

const attacher = newAttacher();

// policies and boundaries that applies to all request contexts
const pol1:PolicyDocument = {...};
const pol2:PolicyDocument = {...};
attacher.setGlobalPolicies('anthony123', [pol1]);
attacher.setGlobalBoundaries('anthony123', pol2);

// policies and boundaries that applies only to a specific principal
const pol3:PolicyDocument = {...};
const pol4:PolicyDocument = {...};
attacher.setPrincipalPolicies('anthony123', [pol3]);
attacher.setPrincipalBoundaries('anthony123', pol4);

// policies that applies to all principals that are part of a certain group
// if a principal is part of multiple groups, the policies for multiple groups
// will apply to this principal
const pol5:PolicyDocument = {...};
const pol6:PolicyDocument = {...};
attacher.setGroupPolicies('group1', [pol5]);
attacher.setGroupPolicies('group2', [pol6]);
attacher.setPrincipalGroups('anthony123', ['group1','group2']);

// policies that applies only to a specific resource
const pol7:PolicyDocument = {...};
attacher.setResourcePolicies('tasks:123456', [pol7]);

// compute complete policies and evaluate permission
const allowed = attacher.evaluate({
  Principal: 'anthony123',
  Action: 'tasks:delete',
  Resource: 'tasks:123456',
});

// evaluate calls: computePolicies(), compilePolicies() and evaluate()

Reference

Global

Policies and boundaries applied to all cases.

Principal Group

A Principal identification can be part of one or more groups. The group can have attached policies, so when computing the policies for a certain Principal, the groups it belongs will be part of its policy along with policies attached directly to the Principal.

Functions

  • attacher.compute(requestContext):{policies,boundaries}

    • Returns a list of computed policies after adding global policies, expanding principal policies regarding to the groups it belongs, filtering related resource policies.

    • Returns a list of computed boundaries related to Global and Principal attachments.