Socket
Socket
Sign inDemoInstall

@remap/authenticate-middleware

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@remap/authenticate-middleware - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

7

index.js
const { STATUS_CODES } = require('http')
const { createError } = require('micro-errors')
const { Authentication } = require('@remap/services')

@@ -9,3 +10,3 @@ const STATUS_MESSAGE_400 = STATUS_CODES[400]

module.exports = ({ authenticate }) => {
module.exports = ({ authenticate = Authentication.authenticate } = {}) => {
if (typeof authenticate !== 'function') {

@@ -28,5 +29,3 @@ throw new TypeError('`authenticate` service client must be function')

const auth = await authenticate(idToken).catch(error => {
throw createError(401, STATUS_MESSAGE_401, error, { detail: 'Invalid token' })
})
const auth = await authenticate(idToken).catch(error => { throw error })

@@ -33,0 +32,0 @@ if (!auth) {

{
"name": "@remap/authenticate-middleware",
"version": "1.0.2",
"version": "1.1.0",
"description": "ReMap Authenticate Middleware",

@@ -30,2 +30,3 @@ "main": "index.js",

"dependencies": {
"@remap/services": "^1.1.0",
"micro-errors": "^2.0.0"

@@ -35,2 +36,3 @@ },

"ava": "^1.0.0-beta.8",
"cross-fetch": "^2.2.2",
"eslint": "^5.5.0",

@@ -41,5 +43,4 @@ "eslint-plugin-ava": "^5.1.1",

"micro-compose": "^0.0.3",
"node-fetch": "^2.2.0",
"test-listen": "^1.1.0"
}
}

@@ -14,8 +14,7 @@ # authenticate-middleware

const { handleErrors } = require('micro-errors')
const auhtenticate = require('@remap/authenticate-middleware')
const authenticationService = require('./services/authentication')
const authenticateMiddleware = require('@remap/authenticate-middleware')
module.exports = compose(
handleErrors(),
authenticate({ authentication: authenticationServive })
authenticateMiddleware(),
)(

@@ -26,14 +25,10 @@ async (req, res) => {

)
```
// ./services/authentication example
### Optional custom authenticator
module.exports = async idToken => {
const res = await fetch(process.env.AUTHENTICATION_ENDPOINT, {
method: 'POST',
body: JSON.stringify({ id_token: idToken }),
mode: 'cors',
})
return await res.json()
}
```js
const middlwware = authenticateMiddleware({
authenticate: async () => await doSomething(),
})
```
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