Skip to main content

Key Server OAuth

The KeyServerClient enables dApps to verify user ownership of GitHub and Discord accounts through the Key Server OAuth flow. Each successful verification produces a DAHR (Demos Attestation Hash Response) attestation - a cryptographic proof that the Key Server performed the verification.

Installation

The KeyServerClient is included in the SDK:

Quick Start


API Reference

KeyServerClient

Constructor

getProviders()

Get list of available OAuth providers.

initiateOAuth()

Start an OAuth flow and get the authorization URL.

pollOAuth()

Check the status of an OAuth flow.

verifyOAuth()

Complete OAuth flow with automatic polling (recommended).

Types

OAuthUserInfo

User identity information from OAuth provider.

WalletBinding

Wallet binding for proving ownership during OAuth verification.
The message to sign is: demos-oauth-bind:{state} where state is from initiateOAuth().

DAHRAttestation

Cryptographic proof of verification.

Attestation Verification

You can cryptographically verify that the Key Server actually signed the attestation:

Verification Options


Error Handling

The client throws OAuthError for all OAuth-related errors:

Error Codes


Wallet Binding

Wallet binding allows you to cryptographically prove ownership of a blockchain wallet during OAuth verification. The wallet address and signature are included in the DAHR attestation, creating a verifiable link between the OAuth identity and the wallet.

Why Use Wallet Binding?

  • Sybil Resistance: Link social accounts to wallets to prevent one person from claiming multiple identities
  • Access Control: Gate access based on both wallet and verified social identity
  • Attestation Integrity: The wallet binding is part of the signed attestation, tamper-proof

How It Works

  1. User initiates OAuth flow
  2. dApp receives the state parameter in onAuthUrl callback
  3. User signs message demos-oauth-bind:{state} with their wallet
  4. Signature is sent with subsequent poll requests
  5. Key Server verifies the signature and includes binding in attestation

Usage

You can provide wallet binding as a function that receives the state:
Or provide a pre-computed binding (if state is known ahead of time):

Supported Signature Types


Full Example

Complete example with UI feedback and wallet binding:

Architecture

The Key Server OAuth flow works as follows:
  1. dApp calls KeyServerClient.verifyOAuth()
  2. SDK sends request to Node RPC
  3. Node proxies to Key Server (same host)
  4. Key Server redirects user to GitHub/Discord
  5. User authorizes, Key Server receives callback
  6. Key Server creates DAHR attestation
  7. Attestation returned through the chain to dApp
The Key Server and Node communicate on the same host, so no signatures are needed for this internal communication. The DAHR attestation provides cryptographic proof to external parties.