This package has been deprecated

Author message:

package no longer maintained

@hacdias/indieauth-middleware

1.0.1 • Public • Published

@hacdias/indieauth-middleware

This is a simple IndieAuth middleware that can be used in conjunction with Express.js or any other framework that uses a similar API.

Install

$ npm i --save @hacdias/indieauth-middleware

Usage

This example uses express.js as the middleware framework but you can use anything as long as you provide an object with the JSON or the form encoded data.

const indieauth = require('@hacdias/indieauth-middleware')
const express = require('express')

const app = express()

app.use(indieauth({
  me: 'https://hacdias.com/',                       // Your domain
  endpoint: 'https://tokens.indieauth.com/token'    // The endpoint used to check the tokens
}))

app.post('/', (req, res) => {
 if (!req.hasScope(['updates'])) {
   // req.hasScope already returns a 401 unauthorized if the user does not
   // have the required scopes.
   return
 }

 // Do your job...
})

Contributing

PRs accepted.

License

MIT © Henrique Dias

Dependents (0)

Package Sidebar

Install

npm i @hacdias/indieauth-middleware

Weekly Downloads

2

Version

1.0.1

License

MIT

Unpacked Size

4.03 kB

Total Files

3

Last publish

Collaborators

  • hacdias