Kevo Docs

TypeScript Types

Complete reference for all TypeScript interfaces and types exported by @kevo-ws/sdk.

Configuration

typescript
interface KevoConfig {
  /** Your project's publishable key */
  publishableKey: string
  /** Base URL of the Kevo API (default: https://api.kevo.ws) */
  apiUrl?: string
  /** URL of the signing iframe (default: https://iframe.kevo.ws) */
  iframeUrl?: string
  /** Timeout in ms for iframe signing operations (default: 30000) */
  iframeTimeoutMs?: number
  /**
   * Multi-chain EVM RPC map — chainId → JSON-RPC URL.
   * Enables useChain() and auto-RPC resolution for all EVM operations.
   * @example { 1: 'https://...', 8453: 'https://...', 137: 'https://...' }
   */
  chains?: Record<number, string>
  /**
   * Active chain on startup. Defaults to the first key in chains.
   * Must be a key present in chains.
   */
  defaultChainId?: number
  /**
   * Single-chain EVM RPC fallback.
   * Ignored when chains is set. Kept for backwards compatibility.
   */
  evmRpcUrl?: string
  /** Default Solana JSON-RPC URL — used by sendSolanaTransaction, getSolanaBalance, etc. */
  solanaRpcUrl?: string
}

/** Convenience alias for the multi-chain RPC map */
type EvmChains = Record<number, string>

Session

typescript
interface KevoSession {
  /** Short-lived JWT (15 min) */
  accessToken: string
  /** Unix timestamp (ms) when the access token expires */
  expiresAt: number
  /** Kevo internal user ID */
  userId: string
  /** Project-scoped decentralized identifier */
  did: string
  projectId: string
}

Wallets

typescript
/** Embedded EVM wallet */
interface KevoWallet {
  id: string
  /** Checksummed EVM address */
  address: string
  createdAt: string
}

/** Embedded Solana wallet */
interface KevoSolanaWallet {
  id: string
  /** Base58-encoded Ed25519 public key */
  address: string
  createdAt: string
}

/** Discriminated union for use in chain-agnostic contexts */
type KevoAnyWallet =
  | { chain: 'evm'; wallet: KevoWallet }
  | { chain: 'solana'; wallet: KevoSolanaWallet }

User Profile

typescript
interface KevoUserProfile {
  id: string
  did: string
  email: string | null
  profile: {
    /** Social display name when available, e.g. Google name or X name */
    name: string | null
    /** Social username when available, e.g. X handle */
    username: string | null
    /** Social profile image when available */
    avatarUrl: string | null
  }
  authMethods: { type: string; identifier: string }[]
  createdAt: string
}

interface KevoResolvedUserProfile {
  /** Always wallet-like for consistent UX, e.g. 0x1234…abcd */
  name: string
  /** Provider username/name when available */
  username: string | null
  /** Social avatar or deterministic generated avatar */
  avatarUrl: string
  /** EVM address first, then Solana address, otherwise null */
  address: string | null
  /** Raw profile returned by Kevo API */
  raw: KevoUserProfile | null
}

Signing

typescript
/** Result of a Solana message sign */
interface SolanaSignResult {
  /** 64-byte Ed25519 signature encoded as hex */
  signature: string
}

/** EVM transaction parameters */
interface TransactionRequest {
  to?: string
  data?: string
  value?: string | bigint
  chainId: number           // required
  nonce?: number
  gasLimit?: string | bigint
  maxFeePerGas?: string | bigint
  maxPriorityFeePerGas?: string | bigint
  gasPrice?: string | bigint
}

/** EIP-712 typed data */
interface Eip712TypedData {
  domain: Record<string, unknown>
  types: Record<string, Array<{ name: string; type: string }>>
  primaryType: string
  message: Record<string, unknown>
}

Auth & Providers

typescript
type AuthMethod = 'email' | 'google' | 'x' | 'apple' | 'passkey'

type SupportedChain = 'evm' | 'solana'

/** Parameter for encodeFunctionCall helper */
interface AbiParam {
  type: string   // e.g. 'address', 'uint256', 'bool', 'bytes32'
  value: unknown
}

/** Minimal Solana wallet provider interface (Phantom, Solflare, Backpack) */
interface SolanaProvider {
  isPhantom?: boolean
  isSolflare?: boolean
  isBackpack?: boolean

  /** Populated after a successful connect() call */
  publicKey?: { toBase58(): string }

  /**
   * Solflare returns void; Phantom returns { publicKey }.
   * Always read publicKey from the property after connecting.
   */
  connect(opts?: {
    onlyIfTrusted?: boolean
  }): Promise<void | { publicKey: { toBase58(): string } }>

  disconnect(): Promise<void>

  /**
   * Phantom/Backpack return { signature: Uint8Array };
   * Solflare may return Uint8Array directly.
   */
  signMessage(message: Uint8Array): Promise<{ signature: Uint8Array } | Uint8Array>
}

Project Config

typescript
interface KevoProjectConfig {
  id: string
  name: string
  uiConfig: UIConfig
  enabledAuthMethods: AuthMethod[]
  enabledChains: SupportedChain[]
}

UI Config

typescript
interface UIConfig {
  /** Primary brand color, buttons, focus rings */
  accentColor: string
  /** Modal background */
  backgroundColor: string
  /** Primary text color */
  foregroundColor: string
  /** Corner radius in pixels */
  borderRadius: number
  /** Logo URL (empty string = hidden) */
  logoUrl: string
  /** CSS font-family */
  fontFamily?: string
  /** Text color on filled buttons */
  buttonTextColor?: string
  /** Input border color */
  inputBorderColor?: string
  /** Modal heading text */
  modalTitle?: string
  /** Subtitle below heading */
  subtitleText?: string
  /** Show "Powered by Kevo" badge */
  showPoweredBy?: boolean
  /** Backdrop blur in pixels */
  overlayBlur?: number
  /** Max modal width in pixels */
  modalMaxWidth?: number
  /** Social button style */
  socialButtonStyle?: 'outline' | 'filled'
  /** Suppress signing confirmation popups */
  hideSigningConfirmations?: boolean
}

// DEFAULT_UI_CONFIG — for reference only, not exported.
// Project-level defaults are fetched from the Kevo Portal and merged with any
// uiConfig override you pass to KevoProvider.
const DEFAULT_UI_CONFIG: UIConfig = {
  accentColor: '#111827',
  backgroundColor: '#ffffff',
  foregroundColor: '#111827',
  borderRadius: 12,
  logoUrl: '',
  showPoweredBy: true,
  overlayBlur: 2,
  modalMaxWidth: 400,
  socialButtonStyle: 'outline',
}

Signing Confirmation

These types are used internally by the signing iframe for the confirmation UI. You won't typically use them directly unless building a custom confirmation handler.

typescript
interface DecodedTx {
  /** Human-readable function name from the 4-byte selector */
  functionName?: string
  /** Formatted ETH value (e.g. "0.05 ETH"), omitted if zero */
  valueEth?: string
}

type ConfirmationRequest =
  | { type: 'sign_message'; message: string }
  | { type: 'sign_typed_data'; domain: Record<string, unknown>; primaryType: string; message: Record<string, unknown> }
  | { type: 'sign_transaction'; tx: TransactionRequest; decoded: DecodedTx }
  | { type: 'send_transaction'; tx: TransactionRequest; decoded: DecodedTx }
  | { type: 'sol_sign_message'; message: string }
  | { type: 'sol_sign_transaction'; txBase64: string }
  | { type: 'sol_send_transaction'; txBase64: string }

Auth Options

typescript
interface LoginWithEmailOptions {
  email: string
}

interface VerifyEmailOptions {
  email: string
  code: string
}

Server SDK Types

Types used by KevoAdmin from @kevo-ws/sdk/server:

typescript
interface KevoAdminConfig {
  secretKey: string   // sk_...
  apiUrl?: string
  /** Default EVM RPC — used by delegations.sendTransaction */
  evmRpcUrl?: string
  /** Default Solana RPC — used by delegations.sendSolanaTransaction */
  solanaRpcUrl?: string
}

/** Options for admin.delegations.sendTransaction() */
interface SendTransactionOptions {
  to: string
  data?: string        // calldata hex
  value?: string | bigint
  chainId: number
  nonce?: number       // override auto-fill
  gasLimit?: string | bigint
  maxFeePerGas?: string | bigint
  maxPriorityFeePerGas?: string | bigint
}

/** Options for admin.delegations.sendSolanaTransaction() */
interface SendSolanaTransactionOptions {
  /** Serialized Solana transaction message (Uint8Array or base64) */
  message: Uint8Array | string
}

Delegation

typescript
interface GrantDelegationOptions {
  /** Which wallet capability/capabilities to delegate: 'evm' | 'solana' | 'both' (default: 'both') */
  include?: 'evm' | 'solana' | 'both'
  policies?: {
    expiresAt?: string       // ISO 8601 — hard expiry
    maxTxCount?: number      // max total signatures
    allowedChainIds?: number[] // EVM only — chain ID whitelist
    allowedContracts?: string[] // EVM only — contract address whitelist
    maxAmountWei?: string    // EVM only — max wei per tx (decimal string)
  }
}

interface KevoDelegation {
  id: string
  active: boolean
  policies: GrantDelegationOptions['policies'] | null
  txCount: number
  walletId: string | null
  solanaWalletId: string | null
  createdAt: string
  revokedAt: string | null
}

Import Paths

All types can be imported from the main package:

typescript
import type {
  KevoConfig,
  KevoSession,
  KevoWallet,
  KevoSolanaWallet,
  KevoAnyWallet,
  SolanaSignResult,
  TransactionRequest,
  Eip712TypedData,
  AuthMethod,
  SupportedChain,
  KevoProjectConfig,
  SolanaProvider,
  UIConfig,
} from '@kevo-ws/sdk'

// Helpers (zero-dependency EVM / Solana utilities)
import {
  nativeTransfer,
  erc20Transfer,
  erc20Approve,
  encodeFunctionCall,
  keccak256Selector,
  solTransfer,
  getRecentBlockhash,
  splTokenTransfer,
  getAssociatedTokenAddress,
} from '@kevo-ws/sdk/helpers'
import type { AbiParam } from '@kevo-ws/sdk/helpers'

// React hooks & components
import {
  KevoProvider,
  KevoModal,
  KevoDashboard,
  useKevo,
  useWallets,
  useSignMessage,
  useSignSolanaMessage,
  useSignTypedData,
  useSignTransaction,
  useSignSolanaTransaction,
  useEstimateGas,
  useBalance,
  useTokenBalance,
  useSolanaBalance,
  useExportKey,
  useSolanaExportKey,
  useKevoModal,
  useKevoDashboard,
} from '@kevo-ws/sdk/react'

// Server SDK (Node.js only)
import {
  KevoAdmin,
  KevoAdminError,
  verifyWebhookSignature,
} from '@kevo-ws/sdk/server'
import type {
  SendTransactionOptions,
  SendSolanaTransactionOptions,
  WebhookPayload,
} from '@kevo-ws/sdk/server'