1.0.4 • Published 1 year ago

@redspher2021/axios-http-signing v1.0.4

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

Axios plugin: HTTP signing

This library permit to sign with axios and private rsa key

import authorizeWithDigest from '@redspher/axios-http-signing';
import axios from 'axios';

const client = axios.create();

authorizeWithDigest(client, {
    keyId: 'DEMO.myApp',
    privKey: '{the private key: put the content of a rsa private key in pem format}',
    headers: [
        '(request-target)',
        'date',
        'digest',
    ],
});

// Now when you use the client, it will add the headers to sign to api
client.post('https://fakeurl/api', { toto: 'toto' }, {
        headers: {
            'signing-auth': 'ok',
        },
    })
    .then(console.log)
    .catch(console.error);