JSPM

oauth-simple-signature-check

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 234
  • Score
    100M100P100Q91967F
  • License MIT

A simple OAuth 1.0a signature verification package.

Package Exports

  • oauth-simple-signature-check

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (oauth-simple-signature-check) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

oauth-simple-signature-check

This package is a simple way to quickly test an OAuth 1.0a signature for validity. As it is intended to be extremely simple, there are no configuration options; however, you may use it as a base if you need different behavior. The algorithm for validating OAuth signatures was adapted from this site: http://lti.tools/oauth/

It was originally designed to simplify OAuth signature validation within the LTI (Learning Tools Interopability) spec, but it can be adapted to many other uses as well.

Assumptions

The package works out-of-the-box with Express.js.

The algorithm assumes you are using HMAC-SHA1 within the OAuth 1.0a spec. Again, you can fork this package and easily change this, if needed. It also assumes you are using UTF-8 for encoding (which you should be).

How to use

Call it in your express.js app, within a route. Here is an example:

const validateOAuthSignature = require("oauth-simple-signature-check");

app.post("/", function (req, res) => {
  const isOAuthSignatureValid = validateOAuthSignature(req, process.env.CONSUMER_SECRET); 

  if (isOAuthSignatureValid)
    res.json({ data: {str: "my secret string"} });
  else
    res.json({});
});