Catalog npm
Back to packageRELEASE DETAILS

2.1.1

npm

@0xbigboss/pocketjs-signer

Signer for Pocket Network V0 accounts

Published30 Oct 2022
Direct dependencies19
Transitive dependenciesNot calculated

README

Current package documentation

Key Manager

This package houses both the abstract Key Manager interface we expose to people so that they build their own KeyManager, and an actual KeyManager ready to use for handling account-related operations.

Installation

Install through your package manager of choice:

pnpm install @pokt-foundation/pocketjs-signer

Usage

import { AbstractSigner, KeyManager } from '@pokt-foundation/pocketjs-signer'

// For the AbstractSigner, just implement it!
class MySigner extends AbstractSigner {
 // Now override the required methods...
}

// For the KeyManager, there's a few ways you can initialize it:
// 1. Create a random (new) account with the KeyManager
const randomAccount = await KeyManager.createRandom()

// 2. Use a private key you own
const account = await KeyManager.fromPrivateKey(process.env.PRIVATE_KEY);

// 3. Use a Portable-Private-Key file, stringified.
// A PPK is generated by exporting an account through the `exportPPK` method.
const ppkAccount = await KeyManager.fromPPK({ password: process.env.PASS, ppk: process.env.PPK })

// Now, you can use it!
// Get your address
const address = account.getAddress()

// Get your public key 
const publicKey = account.getPublicKey()

// Sign a message
const signedCoffee = account.sign("0xcafe")

KeyManager API

Constructor

Instanciating through the constructor is only possible if all params are known beforehand. If not, use one of the initialization methods provided.

address

  • type: 'String' The address of the account to instanciate manually.

privateKey

  • type: 'String' The private key of the account to instanciate manually.

publicKey

  • type: 'String' The public key of the account to instanciate manually.

Methods

static createRandom(): Promise

Creates a new, random pocket account. Can be called from the base class as it's static.

Returns a Promise<KeyManager>: The new key manager instance with the account attached.

static fromPrivateKey(privateKey): Promise

Instanciates a new KeyManager from a valid ED25519 private key.

Returns a Promise<KeyManager>: The new key manager instance with the account attached.

ParamTypeDescription
privateKeystringThe private key to use for instanciating the account.

static fromPPK({ password, ppk }): Promise

Instanciates a new KeyManager from a valid Portable-Private-Key file.

Returns a Promise<KeyManager>: The new key manager instance with the account attached.

ParamTypeDescription
passwordstringThe password of the account to instanciate from the PPK.
ppkstringPPK, stringified. (PPKs are valid JSON files)

exportPPK({ privateKey, password, hint }): Promise

Exports a provided private key as a Portable-Private-Key, unlockable with the provided password.

Returns a Promise<string>: A PPK, in stringified manner.

ParamTypeDescription
passwordstringThe password to use in the PPK.
privateKeystringThe private key to create the PPK from.
hintstringThe password hint.

exportPPK({ password, hint }): Promise

Exports the current account's private key as a Portable-Private-Key, unlockable with the provided password.

Returns a Promise<string>: A PPK, in stringified manner.

ParamTypeDescription
passwordstringThe password to use in the PPK.
hintstringThe password hint.

sign(payload): Promise

Signs a valid hex-string payload with the imported private key.

Returns a Promise<string>: The signed payload as a string.

ParamTypeDescription
payloadstringThe hex payload to sign.

getAddress(): string

Gets the account address.

Returns string: The attached account's address.

getPublicKey(): string.

Gets teh account public key.

Returns string: The attached account's public key.

getPrivateKey(): string

Gets the account private key.

Returns string: The attached account's private key.

getAccount(): Account

Gets the attached account.

Returns Account: The attached account in its entirety in an object.

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 19

Native requirements
19 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
debug
Environment
{
  "local_name": "debug",
  "alias": false,
  "peer_metadata": null
}
^4.3.3runtime
buffer
Environment
{
  "local_name": "buffer",
  "alias": false,
  "peer_metadata": null
}
^6.0.3runtime
scrypt-js
Environment
{
  "local_name": "scrypt-js",
  "alias": false,
  "peer_metadata": null
}
^3.0.1runtime
@noble/ed25519
Environment
{
  "local_name": "@noble/ed25519",
  "alias": false,
  "peer_metadata": null
}
^1.5.3runtime
isomorphic-crypto
Environment
{
  "local_name": "isomorphic-crypto",
  "alias": false,
  "peer_metadata": null
}
^3.0.0runtime
libsodium-wrappers
Environment
{
  "local_name": "libsodium-wrappers",
  "alias": false,
  "peer_metadata": null
}
^0.7.9runtime
@0xbigboss/pocketjs-utils
Environment
{
  "local_name": "@0xbigboss/pocketjs-utils",
  "alias": false,
  "peer_metadata": null
}
2.1.1runtime
@0xbigboss/pocketjs-provider
Environment
{
  "local_name": "@0xbigboss/pocketjs-provider",
  "alias": false,
  "peer_metadata": null
}
2.1.1runtime
@0xbigboss/pocketjs-abstract-provider
Environment
{
  "local_name": "@0xbigboss/pocketjs-abstract-provider",
  "alias": false,
  "peer_metadata": null
}
2.1.1runtime
jest
Environment
{
  "local_name": "jest",
  "alias": false,
  "peer_metadata": null
}
^27.4.7development
eslint
Environment
{
  "local_name": "eslint",
  "alias": false,
  "peer_metadata": null
}
7.32.0development
ts-jest
Environment
{
  "local_name": "ts-jest",
  "alias": false,
  "peer_metadata": null
}
^27.1.3development
prettier
Environment
{
  "local_name": "prettier",
  "alias": false,
  "peer_metadata": null
}
^2.5.1development
typescript
Environment
{
  "local_name": "typescript",
  "alias": false,
  "peer_metadata": null
}
^4.5.5development
@types/jest
Environment
{
  "local_name": "@types/jest",
  "alias": false,
  "peer_metadata": null
}
^27.4.0development
microbundle
Environment
{
  "local_name": "microbundle",
  "alias": false,
  "peer_metadata": null
}
^0.14.2development
@0xbigboss/pocketjs-types
Environment
{
  "local_name": "@0xbigboss/pocketjs-types",
  "alias": false,
  "peer_metadata": null
}
2.1.1development
@typescript-eslint/parser
Environment
{
  "local_name": "@typescript-eslint/parser",
  "alias": false,
  "peer_metadata": null
}
^5.10.2development
@typescript-eslint/eslint-plugin
Environment
{
  "local_name": "@typescript-eslint/eslint-plugin",
  "alias": false,
  "peer_metadata": null
}
^5.10.2development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "shasum": "db51a7881011aaa151bd7d939b7ea988760c6cf5",
  "tarball": "https://registry.npmjs.org/@0xbigboss/pocketjs-signer/-/pocketjs-signer-2.1.1.tgz",
  "fileCount": 28,
  "integrity": "sha512-zuTI2NYO/9s6wtwf3Hig36aNJiuMrfduXh9O6W0D5c4YtB63e7cP5PoWYQXNvaTxgVzlop+5YcP61dDQVnuMSQ==",
  "signatures": [
    {
      "sig": "MEYCIQCAn5G149NP31uoBrzo/5BHGmYi3V/ci7+ldC3y5NhdnQIhAMxdIr9rehcnJfPe5Jjsy+ipbn8DdYxIl4GaMAx3FaLa",
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"
    }
  ],
  "unpackedSize": 231984,
  "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjXwYBACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpyWxAAmwcoqseYpidhnOXYcr3D05sPP1mR+SgJ9MUzhf7vSvGKaG7X\r\nhD8eJwODq52C9Y1h9p5AknWz91Adpx37zHwyqiYtJpeiLoJBzZSlPFQuPrie\r\nbCu0iahn297ZOVEixmIhGhquIE284MaryxiBHlzzHbQjg4kavs0tZ+sN++6W\r\nP1cNqgsRtdPrSpAUjg9HeFspsz/0110VfGKN/lAFfJwvcaSqaFwVaayUL1Ki\r\n4BtyD2fWazQBllG7yRhl9DEk57sLHjQAgC/QhXQMCkn1A9E6FKxnipJ3guBW\r\nawuNnPP3NjKCBeoCQLo8u8SQ38Jzg6y/7wjFkkRJWbCGYVMcT2gIhEGVZOlW\r\nvjRBpZu5koTUHv+mmYm3mIB5CBlyloy4/he8zA9Nffm+6lUF6iYrtCp8PhcD\r\nYhDK/ujuaeXFW9DWBnuE6y+UUf5/i/Fpbq5rrVr9vmu0rWkwmV5voxnltied\r\nRQnVFUMD/iq38Ppq8jPUwBIQwyWZsGCtrQ9PbasNiq6yTJUUIIee4tHxis7i\r\nn4jhL48D3tlydyYqf5p2l6+X2jwX0rif4yQpgUz41i/50w8uB7tXVMwMlRCk\r\nHCCHsKd5Y1prmRNz/+Xb4Y8J9hxJq+h9LZE7evjMSY2OWHE2OgMQ7GOOrxVz\r\njF7Y6eqHMBI45/AaQ3cxTnnq1kDH3BzMNNs=\r\n=TleE\r\n-----END PGP SIGNATURE-----\r\n"
}

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 22:43 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:6f8cda4c2bbfe2953e602e3f93d9f9b3857d5dcc2306142c49a2df293aba9a58

Other collected versions

2.1.02 OctView all collected versions →