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

@civic/solana-gateway-ts

v0.13.0

Published

Typescript adapters for interacting with Solana gateway program

Downloads

712

Readme

Gateway-ts - library

This library provides a utility methods for helping decentralized Apps (dApps) to make use of on-chain identity methods like gateway token retrieval, lookup, and revocation.

Usage

Installation

yarn add @civic/solana-gateway-ts

Import

import {
  addGatekeeper,
  getGatekeeperAccountKeyFromGatekeeperAuthority,
  getGatewayTokenKeyForOwner,
  issue,
  findGatewayTokens,
} from "@civic/solana-gateway-ts";

Functions

findGatewayTokens

Utility method for finding gateway token created for a given public key. This method does the lookup against the Solana blockchain. Returns an empty array if gateway tokens doesn't exist for the given public key.

const gatewayToken: PublicKey = await findGatewayToken(connection, owner, gatekeeperKey);

Optionally, a 'revoked' flag can be passed to allow retrieval of all, even revoked, tokens.

addGatekeeper

Creates the instruction for adding a gatekeeper to the gatekeeper network Usage:

const payer: Keypair;
const gatekeeperNetwork: Keypair;
const gatekeeperAccount: PublicKey;
const gatekeeperAuthority: PublicKey;
const transaction = new Transaction().add(
      addGatekeeper(
        payer.publicKey,
        gatekeeperAccount,
        gatekeeperAuthority,
        gatekeeperNetwork.publicKey
      )
    );

    await send(
      connection,
      transaction,
      payer,
      gatekeeperNetwork
    );

getGatekeeperAccountKeyFromGatekeeperAuthority

Retrieves the gatekeeperAccount for a gatekeeper authority key, so the caller doens't need to keep a record of the gatekeeper account.

const gatekeeperAccount =
      await getGatekeeperAccountKeyFromGatekeeperAuthority(
        this.gatekeeperAuthority.publicKey
      );

getGatewayTokenKeyForOwner

Derives a gateway token key for an owner using the gateway program, additionally accepting a seed parameter

const gatewayTokenKey = await getGatewayTokenKeyForOwner(owner);

issue

Issue a gatewayToken to an account

const owner: PublicKey;
const payer: Keypair;
const gatekeeperNetwork: Keypair;
const gatekeeperAccount: PublicKey;
const gatekeeperAuthority: PublicKey;

const gatewayTokenKey = await getGatewayTokenKeyForOwner(owner);
const gatekeeperAccount =
  await getGatekeeperAccountKeyFromGatekeeperAuthority(
    gatekeeperAuthority.publicKey
  );

const transaction = new Transaction().add(
  issue(
    seed,
    gatewayTokenKey,
    payer.publicKey,
    gatekeeperAccount,
    owner,
    gatekeeperAuthority.publicKey,
    gatekeeperNetwork
  )
);

await send(
  connection,
  transaction,
  payer,
  gatekeeperAuthority
);

findGatewayTokens

Find gatewayTokens that have been created on a network for an account

const owner: PublicKey;
const gatekeeperNetwork: Keypair;
const accounts = await findGatewayTokens(
    connection,
    owner.publicKey,
    gatekeeperNetworkKey
  );