Catalog npm
Back to packageRELEASE DETAILS

1.0.0

npm

@0xpass/key-signer

The KeySigner library is designed to simplify cryptographic operations involving the generation of digital signatures and the verification of those signatures. Built on top of Node.js's native `crypto` module, it abstracts away some of the complexities in

Published2 Apr 2024
Direct dependencies15
Transitive dependenciesNot calculated

README

Current package documentation

KeySigner Library

The KeySigner library is designed to simplify cryptographic operations involving the generation of digital signatures and the verification of those signatures. Built on top of Node.js's native crypto module, it abstracts away some of the complexities involved in handling keys and performing cryptographic signing and verification.

Installation

npm install @0xpass/key-signer

or

pnpm install @0xpass/key-signer

Usage

Initializing KeySigner

To create a new instance of KeySigner, you need to provide the private key. The private key can be supplied either as a path to a DER-encoded file in PKCS#8 format or as a base64-encoded string. This key can be generated using the openssl command-line tool, or the passport-scope cli passport-scope-cli package.

import { KeySigner } from "./path/to/keysigner";

// Using a file path
const signer = new KeySigner("/path/to/private_key.der");

// Using a base64-encoded string
const signerBase64 = new KeySigner("base64PrivateKeyString", true);

Creating a Signature

To sign data, use the createSignature method with the data you wish to sign as a string. This method returns the signature in a base64-encoded format.

const signature = signer.createSignature("data to be signed");
console.log(signature);

Creating a Signature Header

To create an HTTP header containing the signature, use the createSignatureHeader method. This can be useful for authenticated requests. This can be used for generating and formatting the correct headers for authentication requests to passport.

const { signatureHeaderName, signatureHeaderValue } =
  await signer.createSignatureHeader("data to be signed");
console.log(signatureHeaderName, signatureHeaderValue);

Verifying a Signature

To verify a signature, use the verifySignature static method, providing the original data, the signature to verify, and the public key. The public key can be supplied either as a path to a DER-encoded file in SPKI format or as a base64-encoded string.

const isVerified = KeySigner.verifySignature(
  "data to be signed",
  signature,
  "/path/to/public_key.der"
);
console.log(isVerified); // true or false

Downloads & popularity

Awaiting observations

No metric observations yet

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

Declared dependencies 15

Native requirements
15 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
@0xpass/models
Environment
{
  "local_name": "@0xpass/models",
  "alias": false,
  "peer_metadata": null
}
1.0.0runtime
jest
Environment
{
  "local_name": "jest",
  "alias": false,
  "peer_metadata": null
}
^29.7.0development
tslib
Environment
{
  "local_name": "tslib",
  "alias": false,
  "peer_metadata": null
}
^2.3.0development
rimraf
Environment
{
  "local_name": "rimraf",
  "alias": false,
  "peer_metadata": null
}
~5.0.0development
rollup
Environment
{
  "local_name": "rollup",
  "alias": false,
  "peer_metadata": null
}
^3.21.3development
ts-jest
Environment
{
  "local_name": "ts-jest",
  "alias": false,
  "peer_metadata": null
}
^29.1.1development
typescript
Environment
{
  "local_name": "typescript",
  "alias": false,
  "peer_metadata": null
}
^5.0.4development
@types/jest
Environment
{
  "local_name": "@types/jest",
  "alias": false,
  "peer_metadata": null
}
^29.5.11development
@types/node
Environment
{
  "local_name": "@types/node",
  "alias": false,
  "peer_metadata": null
}
~18.16.0development
@types/elliptic
Environment
{
  "local_name": "@types/elliptic",
  "alias": false,
  "peer_metadata": null
}
^6.4.18development
@types/node-forge
Environment
{
  "local_name": "@types/node-forge",
  "alias": false,
  "peer_metadata": null
}
^1.3.5development
@0xpass/eslint-config
Environment
{
  "local_name": "@0xpass/eslint-config",
  "alias": false,
  "peer_metadata": null
}
0.0.1development
@0xpass/typescript-config
Environment
{
  "local_name": "@0xpass/typescript-config",
  "alias": false,
  "peer_metadata": null
}
0.0.1development
rollup-plugin-typescript2
Environment
{
  "local_name": "rollup-plugin-typescript2",
  "alias": false,
  "peer_metadata": null
}
^0.34.1development
rollup-plugin-peer-deps-external
Environment
{
  "local_name": "rollup-plugin-peer-deps-external",
  "alias": false,
  "peer_metadata": null
}
^2.2.4development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "shasum": "b5f311c07151c883eae4ba3d95ddf1030454e629",
  "tarball": "https://registry.npmjs.org/@0xpass/key-signer/-/key-signer-1.0.0.tgz",
  "fileCount": 18,
  "integrity": "sha512-nROijorJlP8n7JUpWJByEGNSrssG4dwbmS6utd9dP1fLTp0zHS5NxIfHHj2YDzY5uJNzFxiDZcbSZkuXK228pg==",
  "signatures": [
    {
      "sig": "MEUCIFlmoc9Y6AXuR56yqn5eQF23Qndg+KenSQ4Vcuz7CysZAiEAuxfycGkpQ8fy4RT/F0lyspkohr/wz8spQ/ZG5Ougte0=",
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"
    }
  ],
  "unpackedSize": 15247
}

Metadata history

Meaningful changes
Current collected state Current

Observed since 21 Oct, 09:27 UTC

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

Record identity

package_version:aa39945a6519d97dc8682510ed694cb4c76bdad2d7a46d445ca04b5ae7dab38b

Other collected versions

2.0.121 Jun2.0.026 Apr0.0.325 Feb0.0.214 FebView all collected versions →