A system for mutual authentication of two parties over a communications channel

npm install authrite-js@0.2.0



JavaScript client for Authrite

The code is available on GitHub and the package is published on NPM.


Authrite is a system for mutual authentication over a communications channel where both parties come to know the identity of the counterparty. authrite-js provides an API for making authenticated HTTP requests from a client to a server that uses the authrite-express middleware.

During setup, the client asks for some basic information from the server and provides their identity key. The server sends back a reply, proving custody over the identity key they send back. Then, every message sent between the two parties is signed and verified, enabling everyone to have confidence in message integrity. Messages are not encrypted by Authrite, but encryption is provided by HTTPS.


npm i authrite-js

Example Usage

This example demonstrates sending a simple request sent with authrite-js

const { Authrite } = require('authrite-js')

// Authrite required parameters

const init = async () => {
    // Create a new instance of the Authrite class
    // Provide the server baseUrl, and your private identity key
    const authrite = new Authrite({
        clientPrivateKey: TEST_CLIENT_PRIVATE_KEY
    // Construct a payload to send as the body of your request
    const body = {
        user: 'Bob',
        message: 'message from client'
    // Create a new request to the server
    const response = await authrite.request('http://localhost:5000/sendSomeData', {
        method: 'POST',
        headers: {
        'Content-Type': 'application/json'
    // Retrieve the response from the server
    const responseData = JSON.parse(Buffer.from(response.body).toString('utf8'))



Table of Contents


Client-side API for establishing authenticated server communication


  • authrite object All parameters are given in an object.

    • authrite.clientPrivateKey String The client's private key used for derivations
    • authrite.initialRequestPath String Initial request path for establishing a connection (optional, default '/authrite/initialRequest')



  • requestUrl String The URL to request on an Authrite-enabled server
  • fetchConfig object Config object passed to the Fetch API. The current version of Authrite only supports JSON structures for the fetch body. However, you can include a Buffer as part of the json object. (optional, default {})

Returns object The response object. Fields are 'status', 'headers' and 'body' (containing an ArrayBuffer of the HTTP response body)


The license for the code in this repository is the Open BSV License.