on-chain-identity-client
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

On-chain Identity Gateway - Client library

This library provides a client and 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/on-chain-identity-client

Import

import { GatekeeperClient, GatekeeperClientConfig, GatekeeperRecord, findGatewayToken } from 'on-chain-identity-client';

Functions/Classes

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.

GatekeeperClient

The GatekeeperClient is a class with helper methods to enable communication with a Gatekeeper server.

initialisation

The baseUrl of the gatekeeper server must be provided when creating a client instance. Additional headers can be passed in config that will be added to HTTP requests to the gatekeeper-api:

const baseUrl: string = 'http://<gateway url>';
const clientInst = new GatekeeperClient({ baseUrl });

createGatewayToken

Requests that a gateway token be created for the given Solana public key. Returns the newly created gateway token as a string.

const gatewayToken = await gatekeeperClientInst.createGatewayToken(walletPublicKey);

An optional parameter 'selfDeclarationTextAgreedTo' can be provided indicating that the requester has read and agreed to the passed text.

const selfDeclarationTextAgreedTo = 'I declare I am not resident in <not-allowed-territory>'
...<UI for user to agree to text>
const gatewayToken = await gatekeeperClientInst.createGatewayToken({ walletPublicKey, selfDeclarationTextAgreedTo });

A gateway token can be requested by providing a Civic presentationRequestId. The gatekeeper server validates that the presentation provided by the user is successful and a token is generated. The presentationRequest created by the DAPP should contain the publicKey address to create the gateway token for.

const gatewayToken = await gatekeeperClientInst.createGatewayToken({ presentationRequestId });

auditGatewayToken

Requests a GatekeeperRecord for the given gateway token. The requester must have sufficient privileges to access the GatekeeperRecord.

const auditGatewayTokenResponse: GatekeeperRecord = await gatekeeperClientInst.auditGatewayToken(token);

requestAirdrop

Requests an airdrop of test tokens for predefined test market token accounts (defined in the gatekeeper server). Only available in test environments.

await gatekeeperClientInst.requestAirdrop(walletPublicKey);

Dependencies (2)

Dev Dependencies (32)

Package Sidebar

Install

npm i on-chain-identity-client

Weekly Downloads

2

Version

1.0.2

License

MIT

Unpacked Size

76.7 kB

Total Files

32

Last publish

Collaborators

  • dankelleher