Socket
Book a DemoInstallSign in
Socket

@force-bridge/keystore

Package Overview
Dependencies
Maintainers
4
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@force-bridge/keystore

A simple keystore for managing the private keys

0.1.7
latest
npmnpm
Version published
Weekly downloads
14
Maintainers
4
Weekly downloads
 
Created
Source

@force-bridge/keystore

A simple keystore for managing the private keys

Quick Start

Start With JSON File

import { KeyStore } from '@force-bridge/keystore';

const password = '123456';
const store = KeyStore.createFromPairs(
  {
    Alice: '0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
    Bob: '0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
  },
  password,
);

const encrypted = store.getEncryptedData();
saveToFile(JSON.stringify(encrypted));

Read The Encrypted JSON file

const store = new KeyStore(fs.readFileSync(filePath).toString());

// decrypt before using the keystore
store.decrypt(process.env.KEYSTORE_PASSWORD);

store.getDecryptedByKeyID('Alice');
store.getDecryptedByKeyID('Bob');

Define A Function With Required Key IDs

function AliceTransferToBob(store: KeyStore<'Alice' | 'AliceSecondary'>) {
  const privateKey = store.getDecryptedByKeyID('Alice');
  const privateKey1 = store.getDecryptedByKeyID('AliceSecondary');

  // typescript would marks error if getting with an unknown key
  // const privateKeyUnknown = store.getDecryptedByKeyID('unknown-key');

  signTransaction(tx, privateKey);
  signTransaction(tx1, privateKey1);
}

FAQs

Package last updated on 03 Mar 2025

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.