npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@silencelaboratories/universal-mpc-auth

v0.0.1-beta

Published

Universal MPC Authenticator SDK

Downloads

35

Readme

MPC Authenticator JS library

Getting started

Install the SDK:

npm i --save @silencelaboratories/mpc-sdk

Overview:

The library provides the following 2 main components:

  1. MpcAuthenticator
  2. MpcSigner

MpcAuthenticator

The MpcAuthenticator class is designed to handle authentication processes using MPC SDK for {2,2} TSS.

import {
  MpcAuthenticator,
  StoragePlatform,
  WalletId,
} from "@silencelaboratories/mpc-sdk";

// 1. Set up MpcAuthenticator with custom storage and development mode
const storage = new CliStorage(); // Ref: https://github.com/silence-laboratories/mpc-auth-client/blob/staging/packages/biconomy/cli/mpc/storage.ts

const mpcAuth = MpcAuthenticator.instance({
  walletId: WalletId.Biconomy,
  storagePlatform: StoragePlatform.CLI,
  customStorage: storage,
  isDev: process.env.NEXT_PUBLIC_SDK_MODE === "development",
});

// 2. Generate QR code for Silent Shard App pairing
const qrCode = await mpcAuth.initPairing();

// ... Scanning happens

const pairingSessionData = await mpcAuth.runStartPairingSession();
await mpcAuth.runEndPairingSession(pairingSessionData);

// 3. Key generation after pairing is done
const keygenResult = await mpcAuth.runKeygen(); // The generated keyshares will be stored to do signing later

// 4. (Optional) Sent backup to Silent Shard App for key restoration later
await mpcAuth.runBackup("demopassword");

MpcAuthenticator options

  • walletId - Supported Wallet ID to use for identifying the wallet. Check WalletId enum for available options.
  • storagePlatform - Supported Storage platform to use for storing keyshares and pairing data. Check StoragePlatform enum for available options.
  • customStorage - Custom storage object to use for storing keyshares and pairing data. If not provided, the library will use the default storage, which is localStorage (assuming the library is used in the browser).
  • isDev - Development mode flag. If set to true, the library will use the development mode for the MPC SDK.

Custom Storage

The library provides a way to use custom storage for data storing. The custom storage must implement IStorage interface, MpcAuthenticator will access the storage using the provided methods.

interface IStorage {
  clearStorageData: () => Promise<void>;
  setStorageData: (data: StorageData) => Promise<void>;
  getStorageData: () => Promise<StorageData>;
  migrate?(): void;
}

MpcSigner

The MpcSigner class is designed for signing Ethereum transactions and messages using MpcAuthenticator keyshares.

An example of MpcSigner with Biconomy account creation:

// MpcSigner initialization
const provider = new providers.JsonRpcProvider("https://rpc.sepolia.org");
const mpcSigner = await MpcSigner.instance(mpcAuth, provider); // Now, mpcSigner could be used to sign ETH transactions
const biconomySmartAccount = await createSmartAccountClient({
  signer: client as SupportedSigner,
  bundlerUrl: `https://bundler.biconomy.io/api/v2/11155111/${process.env.API_KEY}`,
});

ViemSigner

The ViemSigner class is designed to facilitate signing Ethereum transactions and messages using a MpcAuthenticator for key management. This signer integrates with the viem library to provide a seamless signing experience.

An example of ViemSigner with Pimlico account creation:

// ViemSigner initialization
const client = await ViemSigner.instance(mpcAuth);
const signer = await client.getViemAccount();
const walletClient = createWalletClient({
  account: signer,
  chain: sepolia,
  transport: http(
    `https://rpc.zerodev.app/api/v2/bundler/${process.env.API_KEY}`
  ),
});
const smartAccountSigner = walletClientToSmartAccountSigner(walletClient);

Error codes

The library provides the following error codes:

enum BaseErrorCode {
  StorageWriteFailed = 1,
  StorageFetchFailed = 2,
  HttpError = 3,
  // Action errors
  PairingFailed = 4,
  KeygenFailed = 5,
  BackupFailed = 6,
  SignFailed = 7,
  RecoverFailed = 8,

  KeygenResourceBusy = 9,
  SignResourceBusy = 10,
  InternalLibError = 11,
  PhoneDenied = 12,
  InvalidBackupData = 13,
  InvalidMessageHashLength = 14,
  WalletNotCreated = 15,
  UnknownError = 16,
}

How to build:

git clone https://github.com/silence-laboratories/mpc-account-abstraction-sdk.git
cd ./mpc-account-abstraction-sdk
npm i
cd ./packages/mpc
npm run build