JSPM

  • Created
  • Published
  • Downloads 2895
  • Score
    100M100P100Q122864F
  • License MIT

Authentication for web3 accounts

Package Exports

  • @interchainjs/auth
  • @interchainjs/auth/esm/index.js
  • @interchainjs/auth/ethSecp256k1
  • @interchainjs/auth/ethSecp256k1.js
  • @interchainjs/auth/index.js
  • @interchainjs/auth/secp256k1
  • @interchainjs/auth/secp256k1.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@interchainjs/auth) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@interchainjs/auth

Authentication/Wallet for web3 accounts.

Usage

npm install @interchainjs/auth

Taking secp256k1 as example.

// import * from "@interchainjs/auth"; // Error: use sub-imports, to ensure small app size
import { Secp256k1Auth } from "@interchainjs/auth/secp256k1";

const [directAuth] = Secp256k1Auth.fromMnemonic(generateMnemonic(), [
  "m/44'/118'/0'/0/0",
]);
const signature = auth.sign(Uint8Array.from([1, 2, 3]));
console.log(signature.toHex());

It's easy to derive cosmos/injective/ethereum network HD path (taking cosmos as example)

import { HDPath } from "@interchainjs/types";

// derive with Cosmos default HD path "m/44'/118'/0'/0/0"
const [auth] = Secp256k1Auth.fromMnemonic("<MNEMONIC_WORDS>", [
  // use cosmos hdpath built by HDPath
  // we can get cosmos hdpath "m/44'/118'/0'/0/0" by this:
  HDPath.cosmos().toString(),
]);
// is identical to
const [auth] = Secp256k1Auth.fromMnemonic("<MNEMONIC_WORDS>", [
  "m/44'/118'/0'/0/0",
]);

Auth objected can be utilized by different signers. See

Implementations

  • secp256k1 auth from @interchainjs/auth/secp256k1
  • ethSecp256k1 auth from @interchainjs/auth/ethSecp256k1 (Not fully implemented yet)

License

MIT License (MIT) & Apache License

Copyright (c) 2024 Cosmology (https://cosmology.zone/)