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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@electr1xxxx/conector

v0.3.0

Published

Adapter for installing snap and exposes API toward snap on dApps

Readme

Metamask Snap Connector

MetaMask Snap connector is used to install snap and exposes methods for calling snap on dApps and other applications.

Usage

Adapter has an exposed function for installing the snap.

async function enableSnap(
  snapOrigin?: string,
  version?: string,
): Promise<MetamaskSnap>

After snap installation, this function returns MetamaskSnap object that can be used to retrieve snap connector. An example of initializing snap and invoking snap connector is shown below.

// install snap and get connector
const snap = await enableSnap();
const connector = await snap.getConnector();

// invoke connector
const identity = await connector.createIdentity();

console.log(`Snap installed, identity created: ${identity}`);

For ease of use, the connector package also exposes this functions:

isMetamaskInstalled(): boolean
isMetamaskFlask(): Promise<boolean>
isSnapInstalled(snapOrigin?: string, version?: string): Promise<boolean>

Connector Methods

Create an identity

To create an identity you need to call this method:

createIdentity(): Promise<string>

Returns DID.

Save Verifiable Credentials

To save Verifiable Credentials you need to call this method with params:

saveCredentials(params: SaveCredentialsRequestParams): Promise<W3CCredential[]>
type SaveCredentialsRequestParams = {
  body: {
    credentials: [
      {
        description: string;
        id: string;
      },
    ];
    url: string;
  };
  from: string;
  id: string;
  thid?: string;
  to: string;
  typ?: string;
  type: string;
};

Returns all Verifiable Credentials saved inside the snap state

type W3CCredential = {
  id: string;
  '@context': string[];
  type: string[];
  expirationDate?: string;
  issuanceDate?: string;
  credentialSubject: { [key: string]: object | string | number };
  credentialStatus: CredentialStatus;
  issuer: string;
  credentialSchema: CredentialSchema;
  proof?: { [key: string]: any } | any[];
};

type CredentialStatus = {
  id: string;
  type: string;
  revocationNonce?: number;
  statusIssuer?: CredentialStatus;
};

type CredentialSchema = {
  id: string;
  type: string;
};

Create a proof

Make sure you are on the correct network before creating a proof! To create a proof you need to call this method with params:

createProof(params: CreateProofRequestParams): Promise<ZKPProofResponse>
type CreateProofRequestParams = {
  id?: number;
  accountAddress?: string; // Metamask user address for on-chain proofs
  circuitId:
    | 'credentialAtomicQueryMTPV2'
    | 'credentialAtomicQueryMTPV2OnChain'
    | 'credentialAtomicQuerySigV2'
    | 'credentialAtomicQuerySigV2OnChain';
  challenge?: string; // bigint string
  query: ProofQuery;
};

type ProofQuery = {
  allowedIssuers?: string[];
  credentialSubject?: { [key: string]: any };
  schema?: string;
  claimId?: string;
  credentialSubjectId?: string;
  context?: string;
  type?: string;
};

Returns ZKPProofResponse - zkpProof for off-chain and updateStateTx and zkpTx for on-chain

type ZKPProofResponse = {
  zkpTx?: TransactionRequest; // ethers TransactionRequest
  updateStateTx?: TransactionRequest;
  zkpProof?: ZKProof;
};

type ZKProof = {
  proof: ProofData;
  pub_signals: string[];
};
type ProofData = {
  pi_a: string[];
  pi_b: string[][];
  pi_c: string[];
  protocol: string;
};

Create a backup

To create a backup of keys and credentials:

createBackup(): Promise<boolean>

Returns true if backup created

Recovery from a backup

Recovering the identity and credentials from a backup:

recoverBackup(): Promise<boolean>

Returns true if backup recovered

Check state contract sync

checkStateContractSync(): Promise<boolean>

Returns true if the lightweight state contract on current chain doesn't need to be synced with the state contract on Rarimo chain.

Snap connector usage examples

Create a proof

const connector = await snap.getConnector();

const proof = connector.createProof({
  circuitId: 'credentialAtomicQueryMTPV2OnChain',
  accountAddress: '0x......',
  challenge: '1251760352881625298994789945427452069454957821390', // BigInt string
  query: {
    allowedIssuers: ['*'],
    context:
    'https://raw.githubusercontent.com/omegatymbjiep/schemas/main/json-ld/NaturalPerson.json-ld',
    credentialSubject: {
      isNatural: {
        $eq: 1,
      },
    },
    type: 'NaturalPerson',
  },
});

where:

  • circuitId: type of proof
  • accountAddress(optional): Metamask user address for on-chain proofs
  • challenge(optional): text that will be signed
  • query
    • allowedIssuers: types of issuers allowed
      • *: all types of Issuers are allowed
    • context: URL for getting the vocabulary for the credential
    • type: type of credentials allowed
    • credentialSubject: query request to a query circuit

Save Verifiable Credentials

const connector = await snap.getConnector();

const proof = connector.saveCredentials({
  body: {
    credentials: [
      {
        description: 'Natural Person',
        id: '86531650-023c-4c6c-a437-a82e137ead68',
      },
    ],
    url: 'http://127.0.0.1:8000/integrations/issuer/v1/public/claims/offers/callback',
  },
  from: 'did:iden3:tJnRoZ1KqUPbsfVGrk8io51iqoRc5dGhj5LLMHSrD',
  id: '026035f6-42f6-4a2d-b516-0b11d2674850',
  thid: '348b7198-7cb1-46f4-bc0a-98a358f65539',
  to: 'did:iden3:tTxif8ahrSqRWavS8Qatrp4ZEJvPdu3ELSMgqTEQN',
  typ: 'application/iden3comm-plain-json',
  type: 'https://iden3-communication.io/credentials/1.0/offer',
});

where:

  • id: request identifier
  • thid: ID of the message thread
  • from: identifier of the person from whom the offer was received
  • to: identifier of the person who received the offer
  • typ: media type of the message. In our case, it is the type of the protocol of the packed message application/iden3comm-plain-json
  • type: type of iden3comm protocol message
  • body
    • credentials[0]
      • description: description of the schema
      • id: credential id
    • url: URL to which requested information is sent and response is received