0.12.0 • Published 1 month ago

@identity.com/solana-gateway-ts v0.12.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

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 @identity.com/solana-gateway-ts

Import

import {
  addGatekeeper,
  getGatekeeperAccountKeyFromGatekeeperAuthority,
  getGatewayTokenKeyForOwner,
  issueVanilla,
  findGatewayTokens,
} from "@identity.com/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);

issueVanilla

Issue a vanilla gatewayToken for 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(
  issueVanilla(
    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
  );
0.13.0-alpha.0

1 month ago

0.12.0-alpha.3

11 months ago

0.12.0

11 months ago

0.12.0-alpha.1

1 year ago

0.12.0-alpha.2

1 year ago

0.10.0-alpha.2

1 year ago

0.11.0-alpha.5

1 year ago

0.11.0-alpha.2

1 year ago

0.11.0-alpha.1

1 year ago

0.11.0-alpha.4

1 year ago

0.11.0-alpha.3

1 year ago

0.9.0-alpha.1

2 years ago

0.10.0-alpha.1

2 years ago

0.10.0

2 years ago

0.9.0

2 years ago

0.9.0-beta.2

2 years ago

0.9.0-beta.1

2 years ago

0.6.0-beta1

2 years ago

0.7.0-beta1

2 years ago

0.5.0-beta1

2 years ago

0.8.1

2 years ago

0.8.0

2 years ago

0.8.2

2 years ago

0.7.0

2 years ago

0.4.4-beta1

2 years ago

0.4.4-beta2

2 years ago

0.4.1-beta8

2 years ago

0.4.1-beta7

2 years ago

0.4.1-beta5

2 years ago

0.4.1-beta4

2 years ago

0.4.1-beta3

2 years ago

0.4.1-beta2

2 years ago

0.4.1-beta1

2 years ago

0.4.4

2 years ago

0.4.1

2 years ago

0.4.0

2 years ago

0.4.3

2 years ago

0.4.2

2 years ago

0.3.3

3 years ago

0.3.2

3 years ago

0.3.1

3 years ago

0.3.0

3 years ago

0.2.0

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago