@ovos-media/sign-helpers

2.2.1 • Public • Published

@ovos-media/sign-helpers

Helpers for signed resources.

Usage

const makeVerifyRequest = require('@ovos-media/sign-helpers').verifyRequest;

const verifyRequest = makeVerifyRequest({
  basePath: process.env.SERVICE_PATH,
  path(ctx) { return ctx.request.url; },
  parseReferer: true, // this is a default, can be overwritten optional
  refererRegex: /https?:\/\/[a-zA-Z0-9\.\:]*(.*)\// // this is a default, can be overwritten optional
});

const work = (ctx) => {
  const credentials = verifyRequest(ctx);

  if (credentials) {
    ctx.status = 200;
  } else {
    ctx.status = 401;
  }
}

router.get('/url', work);

Contributors

created at ovos with

Dependencies (1)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i @ovos-media/sign-helpers

    Weekly Downloads

    2

    Version

    2.2.1

    License

    UNLICENSED

    Unpacked Size

    3.71 kB

    Total Files

    5

    Last publish

    Collaborators

    • es-ovos
    • khaldoun1
    • marcingil
    • flipace
    • bonnevoyager
    • mhawk
    • milanorszagh
    • denis.loncaric
    • ovos_bot
    • adifuchs