1.0.11 • Published 1 month ago

js-signer v1.0.11

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

NodeJS/Javascript message signing example

This repository provides an example of signing any arbitrary message with an R1 key and produce an Bullish compatible signature

How to use

Import the library

const getSignature = require('js-signer').getSignature
import { getSignature } from 'js-signer'

Generate Signature

// import public private keys
// for demo: keys are hardcoded here
const privateKeyString = 'PVT_R1_ENSnpAGb4NHNA2chipxHQMVnAZdEAfRzHmJFEuxFkWvCXC5CG'
const publicKeyString = 'PUB_R1_8CHJquaQWe4Pkhp1fBR9deP5wkqfjuWdfhaKYDxGKCo7gQwU9C'

// create a function to generate singature for payload
// this functions internally calls getSignature from library
const signMessage = async message => {
  // create singature from payload by using getSignature from library
  const signature = await getSignature(message, publicKeyString, privateKeyString)

  // use the signature to add in the header of the API communication
  return signature
}

async function useSignature() {
  console.time('Signature generate in: ')

  // retrieve signature for the message
  const signature = await signMessage({ message: 'A very secret message' })

  // for demo: print the signature
  console.log(signature)
  console.timeEnd('Signature generate in: ')
}

useSignature()

Example for different frameworks

NodeJs

React

Angular

Vue

1.0.11

1 month ago

1.0.11-beta.0

2 months ago

2.0.0-alpha.0

2 months ago

2.0.0-alpha.1

2 months ago

2.0.0-alpha.2

2 months ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.7-beta.1

1 year ago

1.0.3-beta.8

1 year ago

1.0.6

1 year ago

1.0.3-beta.7

1 year ago

1.0.3-beta.6

1 year ago

1.0.3-beta.5

1 year ago

1.0.3-beta.4

1 year ago

1.0.3-beta.3

1 year ago

1.0.3-beta.2

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3-beta.0

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago