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

ers-http

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ers-http - npm Package Compare versions

Comparing version 5.4.0 to 5.5.0

7

package.json
{
"name": "ers-http",
"version": "5.4.0",
"version": "5.5.0",
"description": "",

@@ -29,5 +29,6 @@ "main": "index.js",

"numeral": "^2.0.6",
"request": "^2.88.0",
"request-promise": "^4.2.4",
"socket.io": "^2.2.0",
"socket.io-redis": "^5.2.0",
"superagent": "^4.0.0"
"socket.io-redis": "^5.2.0"
},

@@ -34,0 +35,0 @@ "devDependencies": {

@@ -0,48 +1,45 @@

const request = require('request-promise')
const request = require('superagent')
module.exports = (options = {}) => {
const { baseUrl } = options
const {
baseUrl,
} = options
if (!baseUrl) throw new Error('baseUrl required in restrict middleware')
if (!baseUrl) throw new Error('baseUrl required in restrict middleware')
return () => (req, res, next) => {
const error = message => next(new Error(message))
return () => (req, res, next) => {
let query = req.query || {}
const error = (message) => next(new Error(message))
if (req.handshake) {
query = req.handshake.query
next = res
}
let query = req.query || {}
const access_token = query.access_token
if (req.handshake) {
query = req.handshake.query
next = res
}
if (!access_token) return error('access_token required')
const access_token = query.access_token
request({
url: baseUrl + '/account/me/id',
qs: { access_token },
json: true,
})
.then(body => {
const data = body || {}
if (!access_token) return error('access_token required')
req.session = {
...req.session,
userId: String(data.user_id),
groupId: String(data.group_id),
productId: String(data.product_id),
roleId: String(data.role_id),
lang: data.lang,
paid: data.paid,
accessToken: access_token,
}
request.get(baseUrl + '/account/me/id')
.query({access_token})
.then(res => {
if (res.error) return error('access_token invalid')
const data = res.body || {}
req.session = {
...req.session,
userId: String(data.user_id),
groupId: String(data.group_id),
productId: String(data.product_id),
roleId: String(data.role_id),
lang: data.lang,
accessToken: access_token
}
next()
})
.catch(e => error('access_token fetching error'))
}
next()
})
.catch(e => error('access_token invalid'))
}
}
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