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

byu-group-mem

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

byu-group-mem - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

43

index.js

@@ -34,3 +34,12 @@ /**

let generatewso2RequestOptions = function (method, url) {
return {url: url, method: method, json: true, resolveWithFullResponse: true, simple: false, encoding: 'utf8', headers: {Accept: 'application/json'}
return {
url: url,
method: method,
json: true,
resolveWithFullResponse: true,
simple: false,
encoding: 'utf8',
headers: {
Accept: 'application/json'
}
};

@@ -55,3 +64,3 @@ };

if (typeof config.wso2_request_instance !== 'object'
|| (typeof wso2_request_instance === 'object' && !Object.keys(config.wso2_request_instance).includes('request')))
|| (typeof wso2_request_instance === 'object' && !Object.keys(config.wso2_request_instance).includes('request')))
throw new Error('The wso2_request_instance in the byu-group-mem function must be an instance of the byu-wso2-request package.');

@@ -64,21 +73,21 @@ if (typeof config.group_name !== 'string')

Promise.race([
config.wso2_request_instance.request(generatewso2RequestOptions('GET', `https://api.byu.edu:443/byuapi/persons/v1/${req.verifiedJWTs.prioritizedClaims.byuId}/group_memberships/${config.group_name}`)),
config.wso2_request_instance.request(generatewso2RequestOptions('GET', `https://api.byu.edu:443/byuapi/persons/v2/${req.verifiedJWTs.prioritizedClaims.byuId}/group_memberships/${config.group_name}`)),
timeout()
])
.then(MembersOfResponse => {
if (MembersOfResponse === 'timed-out')
return (config.handler ? res.status(504).send(config.handler(504, new Error('MembersOf Service Timed Out.'))) :
res.status(504).send({metadata: meta(504, 'MembersOf Service Timed Out.')}));
.then(MembersOfResponse => {
if (MembersOfResponse === 'timed-out')
return (config.handler ? res.status(504).send(config.handler(504, new Error('MembersOf Service Timed Out.'))) :
res.status(504).send({metadata: meta(504, 'MembersOf Service Timed Out.')}));
if (MembersOfResponse.statusCode !== 200)
return (config.handler ? res.status(500).send(config.handler(500, new Error(`Unexpected response from MembersOf Service. Service status: ${MembersOfResponse.statusMessage}`))) :
res.status(500).send({metadata: meta(500, `Unexpected response from MembersOf Service. Service status: ${MembersOfResponse.statusMessage}`)}));
if (MembersOfResponse.body.metadata.code !== 200) {
const code = MembersOfResponse.body.metadata.validation_response.code;
const message = MembersOfResponse.body.metadata.validation_response.message;
const info = MembersOfResponse.body.metadata.validation_response.validation_information;
return (config.handler ? res.status(code).send(config.handler(MembersOfResponse.body.metadata.code, new Error(message))) :
res.status(code).send({metadata: meta(code, message)}));
}
if (!isAuthorized(req.verifiedJWTs, MembersOfResponse.body['MembersOf Service'].response.members))
return (config.handler ? res.status(401).send(config.handler(401, new Error('User does not have the necessary privileges.'))) :
res.status(401).send({metadata: meta(401, 'User does not have the necessary privileges.')}));
next();
})
};
next();
})
}
};
{
"name": "byu-group-mem",
"version": "0.1.0",
"version": "0.1.1",
"description": "Validates the group membership of a person",

@@ -5,0 +5,0 @@ "main": "index.js",

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