Is it possible to use request-promise with httpSignature

215 Views Asked by At

According to the docs, it seems doable.

The request-promise docs says

Since request-promise wraps around request everything that works with request also works with request-promise. Also check out the request docs for more examples.

And the request docs says

httpSignature - options for the HTTP Signature Scheme using Joyent's library. The keyId and key properties must be specified. See the docs for other options.

I've tried adding a httpSignature: {key, keyId} parameter to my request options, and it works, except it sends the private key along with the request, which can't be right.

1

There are 1 best solutions below

0
On

As it turns out the httpSignature parameter wasn't sending the private key, it's just that we were logging the request opts instead of the actual request.

This works like a charm in case anybody is looking:

const rp = require('request-promise');
const fs = require('fs');

return await rp({
    uri: 'www.example.org',
    httpSignature: {
        key:   fs.readFileSync('/path/to/private.key'),
        keyId: 'private.key',
    }
 });