Function Signature

function verifyIdentity(
  options: Options
): Promise<Response>;
options
[Options](/sdk-reference/types#verifyidentity-options)
The options for initiating identity verification.
Promise
Promise<[Response](/sdk-reference/types#verifyidentity-response)>
A promise that resolves with the response from the identity verification request.
Type Definitions: For detailed type information including all properties and their descriptions, visit the Types page.

Usage

import { TrustEngineSDK } from '@trust-engine/sdk';
import { useState } from 'react';

const sdk = new TrustEngineSDK();

export default function IdentityVerifier() {
  const [walletAddress, setWalletAddress] = useState('');
  const [isVerifying, setIsVerifying] = useState(false);
  const [result, setResult] = useState<any | null>(null);

  const handleVerify = async () => {
    if (!walletAddress) return;
    setIsVerifying(true);
    try {
      const verificationResult = await sdk.verifyIdentity({
        walletAddress: walletAddress,
        disclosures: {
          name: true,
          nationality: true,
          date_of_birth: true,
          issuing_state: false,
          passport_number: false,
          gender: false,
          expiry_date: false
        }
      });
      
      setResult(verificationResult);
    } catch (error) {
      console.error('❌ Identity verification failed:', error.message);
    } finally {
      setIsVerifying(false);
    }
  };

  return (
    <div>
      <input 
        type="text" 
        placeholder="Enter wallet address"
        value={walletAddress}
        onChange={(e) => setWalletAddress(e.target.value)}
      />
      <button onClick={handleVerify} disabled={!walletAddress || isVerifying}>
        {isVerifying ? 'Starting Verification...' : 'Verify Identity'}
      </button>
      {result && (
        <div>
          <pre>{JSON.stringify(result, null, 2)}</pre>
          {result.details?.qrCodeUrl && (
            <p>
              <a href={result.details.qrCodeUrl} target="_blank" rel="noopener noreferrer">
                Open Verification QR Code
              </a>
            </p>
          )}
        </div>
      )}
    </div>
  );
}

Response Patterns

New Session Created (201)

When a new identity verification session is successfully created:
{
  message: "Identity verification session created successfully",
  details: {
    qrCodeUrl: "https://trustengine.org/identity-verification?walletAddress=...",
    walletAddress: "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU",
    selectedDisclosures: {
      name: true,
      nationality: true,
      date_of_birth: true
    },
    status: "pending",
    createdAt: "2024-01-15T10:30:00.000Z",
    expiresAt: "2024-01-16T10:30:00.000Z",
    instructions: "Visit the QR code URL and scan with Self app to verify your identity"
  }
}

Existing Session Found (200)

When there’s already a pending verification session for the wallet:
{
  message: "You already have a pending identity verification session",
  details: {
    qrCodeUrl: "https://trustengine.org/identity-verification?walletAddress=...",
    walletAddress: "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU",
    requestedDisclosures: {
      name: true,
      nationality: true,
      date_of_birth: true,
      issuing_state: false,
      passport_number: false,
      gender: false,
      expiry_date: false
    },
    status: "pending",
    createdAt: "2024-01-15T09:30:00.000Z",
    expiresAt: "2024-01-16T09:30:00.000Z",
    instructions: "Complete your existing verification or wait for it to expire before starting a new one"
  }
}

Requirements

Before using this method, ensure the wallet has a user-key relation established. Use the linkWallet or createWallet methods first.

Next Steps

After initiating verification:
  1. Share QR Code: Direct users to the qrCodeUrl for identity verification
  2. Monitor Status: Use checkIdentityStatus to check verification progress
  3. Handle Completion: Verification results are processed automatically when users complete their verification
Sessions expire after 24 hours. Users must complete verification within this timeframe, or a new session must be created.