
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
library to work with roles, contains calculation of times for the session, validation of required roles
library to work with roles, contains calculation of times for the session, validation of required roles
This library is ideal for working with redis-jwt
Npm
npm install role-calc --save
Yarn
yarn add role-calc
Evaluate if any of the required roles are met or all
import {has} from 'role-calc';
// Roles required
let required = [
'Developer',
'Specialist',
'Technician',
'Director',
'Manager',
'Designer',
'Analyst',
'Administrator'
];
// Roles user
let candidates = [
'Developer',
'Administrator',
'Designer'
];
// if it contains one
has(required, candidates); // -> true
has(['Developer'], candidates); // -> true
has(required, ['Other', 'Fake']); // -> false
// must meet everyone '*'
has(required, candidates, '*'); // -> false
has(['Developer', 'Designer'], candidates, '*'); // -> true
has(['Director'], ['Director', 'Other'], '*'); // -> true
Gets the times of a list from an array of roles
import {time} from 'role-calc';
// Roles with time
let roles = [
{
role: 'Developer',
ttl: '15 minutes'
},
{
role: 'Specialist',
ttl: '2 hours'
},
{
role: 'Manager',
ttl: '3 days'
},
{
role: 'Administrator',
ttl: '1 years'
},
{
role: 'Director',
ttl: '90 minutes'
},
{
role: 'Designer',
ttl: '55 hours'
},
{
role: 'other'
}
];
// Roles user
let candidates = [
'Developer',
'Administrator',
'Designer'
];
time(roles, candidates);
/*
->
[
{ role: 'Developer', ttl: '15 minutes' },
{ role: 'Administrator', ttl: '1 years' },
{ role: 'Designer', ttl: '55 hours' }
]
*/
Calculate time of multiple roles assigned to a user
import {calc} from 'role-calc';
// Roles with time
let roles = [
{
role: 'Developer',
ttl: '15 minutes'
},
{
role: 'Specialist',
ttl: '2 hours'
},
{
role: 'Manager',
ttl: '3 days'
},
{
role: 'Administrator',
ttl: '1 years'
},
{
role: 'Director',
ttl: '90 minutes'
},
{
role: 'Designer',
ttl: '55 hours'
},
{
role: 'other'
}
];
/*
time(roles, option, format)
- roles: array
- option: max, min, sum, average
- format(optional): milliseconds, seconds, minutes, hours, days, weeks, months, years
*/
calc(roles, 'sum'); // -> 533805 minutes
calc(roles, 'max', 'hours'); // -> 8766 hours
calc(roles, 'min', 'minutes'); // -> 15 minutes
calc(roles, 'average', 'days'); // -> 61.782986111111114 days
npm start
npm run compile
npm test
MIT © Leonardo Rico
FAQs
library to work with roles, contains calculation of times for the session, validation of required roles
We found that role-calc demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.