New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

js-signer

Package Overview
Dependencies
Maintainers
0
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-signer

This repository provides library to sign any arbitrary message with an Bullish R1 key and produce an Bullish signature

  • 2.0.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
693
decreased by-34.99%
Maintainers
0
Weekly downloads
 
Created
Source

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

  • Code / Playground Link 🔗

React

Angular

Vue

FAQs

Package last updated on 16 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc