Skip to content

Repo for the NPM package that handles auth token signing for the public API

License

Notifications You must be signed in to change notification settings

chronicleprotocol/api-auth-npm

Repository files navigation

Getting Started

Install the NPM module

npm install --save @chronicleprotocol/api-auth

Usage

Generating authentication tokens:

import { signAuthToken } from "@chronicleprotocol/api-auth";

const { token, message } = signAuthToken({
  // private key is 0x prefixed 32 byte hex string
  privateKey: "0xabc...",
});

// `token` is hex string to be included as Authorization header (see below)
// `message` is object containing decoded data within `token`. Optional,
// but can be useful for programmatic token handling

Your public signing address must be allow-listed on our servers before your tokens will be valid.

Using an auth token to fetch an API endpoint:

// token is received from the server
fetch(
  "https://chroniclelabs.org/api/pairs",
  {
    headers: {
      Authorization: `Bearer ${token}`,
    },
  },
);

About

Repo for the NPM package that handles auth token signing for the public API

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published