HTTP Request Signature

0.0.5 · abandoned · verified Wed Apr 22

This library provides tools for parsing and generating HTTP signatures in compliance with the 'Signing HTTP Messages' Internet Draft (draft-cavage-http-signatures-07.txt). Currently at version 0.0.5, it appears to be an unmaintained project, with its last update occurring approximately seven years ago. A significant limitation is its exclusive support for the `ed25519` cryptographic algorithm, restricting its use cases to environments that specifically require or permit this algorithm. Due to its status as an early-stage, potentially abandoned library based on a draft specification, users should exercise caution regarding security, long-term stability, and compatibility with evolving standards. The project does not indicate a clear release cadence, reflecting its dormant state.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to generate an HTTP request signature using a secret key and then verify the integrity and authenticity of the signed request using the corresponding public key, adhering to the ed25519 algorithm.

const { sign, verify } = require('http-request-signature');

// Example: Signing an HTTP message
const secretKey = '96aa9ec42242a9a62196281045705196a64e12b15e9160bbb630e38385b82700e7876fd5cc3a228dad634816f4ec4b80a258b2a552467e5d26f30003211bc45d';
const publicKey = 'e7876fd5cc3a228dad634816f4ec4b80a258b2a552467e5d26f30003211bc45d'; // In a real scenario, this would be derived from a different key pair

const requestToSign = {
  headers: {
    '(request-target)': 'post /foo',
    date: '2017-09-01T15:04:17.555Z',
    digest: 'SHA-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE='
  },
  keyId: 'primary',
  secretKey: secretKey
};

const signature = sign(requestToSign, { algorithm: 'ed25519' });
console.log('Generated Signature:', signature);

// Example: Verifying an HTTP message
const signedRequestHeaders = {
  '(request-target)': 'post /foo',
  date: '2017-09-01T15:04:17.555Z',
  digest: 'SHA-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=',
  signature: signature // Use the generated signature
};

const verificationResult = verify({
  headers: signedRequestHeaders,
  publicKey: publicKey
}, { algorithm: 'ed25519' });

console.log('Verification Result:', verificationResult);

view raw JSON →