Keyring Connect SDK

A TypeScript/JavaScript SDK for integrating with the Keyring Connect browser extension. This SDK enables seamless interaction with the Keyring Connect extension for user verification and attestation.

Installation

npm install @keyringnetwork/keyring-connect-sdk

Features

  • Launch Keyring Connect with custom client configuration

  • Monitor extension status and user state

  • Full TypeScript support with comprehensive type definitions

Usage

Initialize

import { KeyringConnect } from '@keyringnetwork/keyring-connect-sdk';

Launch Keyring Connect

const extensionConfig = {
  name: 'My App',
  app_url: 'https://myapp.com',
  logo_url: 'https://myapp.com/logo.png',
  policy_id: 123,
};

try {
  const isInstalled = await KeyringConnect.isKeyringConnectInstalled();

  if (isInstalled) {
    await KeyringConnect.launchExtension(extensionConfig);
  } else {
    // show UI to install extension
  }
} catch (error) {
  console.error('Failed to launch Keyring Connect:', error);
}

Monitor Extension Status

export interface ExtensionState {
  status: 'idle' | 'mounted' | 'proving' | 'prove_success' | 'error';
  manifest?: any;
  error?: string; // error message, only if status is 'error'
  user?: User;
}

const extensionState = await KeyringConnect.getExtensionState();

API Reference

Types

Full type definitions can be found here

Core Types Overview

  • ExtensionConfig: Configuration for initializing the Keyring Connect extension

  • ExtensionState: Current state and status information of the extension

  • User: User's verification and credential status information

Status Types

  • ExtensionStatus: Extension states (idle, mounted, proving, prove_success, error)

  • AttestationStatus: Off-chain verification status (onboarding_required, onboarding_pending, attestation_ready, non_compliant)

  • CredentialStatus: On-chain credential status (expired, valid, none)

Extension States

  • idle: Extension is installed but not active

  • mounted: Extension is launched and ready

  • proving: Currently generating proof

  • prove_success: Proof generation successful

  • error: An error occurred

Requirements

  • An on-chain Keyring policy

  • Chrome browser (version 88 or higher recommended)

  • Keyring Connect browser extension installed

  • Active internet connection

Last updated