Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
OneAuthClient – 1auth
Skip to content

Overview

OneAuthClient is the core class of the 1auth SDK. It handles all interactions with the passkey authentication system including:

  • User registration and authentication
  • Transaction signing with multiple UX modes
  • Cross-chain intent submission
  • Token swaps

Constructor

import { OneAuthClient } from '@rhinestone/1auth';
 
const client = new OneAuthClient({
  providerUrl: 'https://passkey.1auth.box',
  theme: {
    mode: 'dark',
    accent: '#6366f1',
  },
});

Config Options

OptionTypeRequiredDescription
providerUrlstringNoURL of the 1auth provider (defaults to https://passkey.1auth.box)
dialogUrlstringNoURL for the dialog UI (defaults to providerUrl)
redirectUrlstringNoRedirect target for redirect flow
themeThemeConfigNoUI customization options

Authentication Methods

authWithModal

Opens a combined sign-in/sign-up modal:

const result = await client.authWithModal();
 
if (result.success) {
  console.log('User:', result.user?.username);
  console.log('Address:', result.user?.address); // typed `0x${string}`
}

authenticate

Authenticate with optional challenge signing:

const result = await client.authenticate({
  username: 'user@example.com',
  challenge: '0x...', // Optional: sign a challenge
});

Signing Methods

Multiple UX modes for transaction signing:

signWithModal

Full-screen modal with transaction details:

const result = await client.signWithModal({
  username: 'user@example.com',
  calls: [{ to: '0x...', data: '0x...' }],
  targetChain: 8453,
});

signWithPopup

Opens signing in a popup window:

const result = await client.signWithPopup({
  username: 'user@example.com',
  calls: [{ to: '0x...', data: '0x...' }],
  targetChain: 8453,
});

signWithEmbed

Embeds signing UI in your page:

const result = await client.signWithEmbed({
  username: 'user@example.com',
  calls: [{ to: '0x...', data: '0x...' }],
  targetChain: 8453,
  embed: {
    containerId: 'signing-container',
  },
});

Intent Execution

sendIntent

Submit cross-chain intents to the Rhinestone orchestrator.

const result = await client.sendIntent({
  username: 'user@example.com',
  targetChain: 8453,
  calls: [
    {
      to: '0x...',
      data: '0x...',
      value: parseEther('0.1'),
    },
  ],
  closeOn: 'completed',
});
 
if (result.success) {
  console.log('TX Hash:', result.transactionHash);
}

With Token Requests (Output-First)

Use tokenRequests to specify what tokens you want to receive. The orchestrator determines the optimal path to deliver them from the user's assets across any chain.

import { parseUnits } from 'viem';
 
const result = await client.sendIntent({
  username: 'user@example.com',
  targetChain: 8453,
  calls: [{ to: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', data: '0x' }],
  tokenRequests: [
    {
      token: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', // USDC on Base
      amount: parseUnits('100', 6), // 100 USDC (bigint)
    },
  ],
  closeOn: 'completed',
});

This is ideal for swaps, cross-chain transfers, or any "output-first" operation.

Pass waitForHash: true if you need a transaction hash. Otherwise, rely on intentId + getIntentStatus.

sendSwap

High-level token swap API:

const result = await client.sendSwap({
  username: 'user@example.com',
  fromToken: '0x...', // USDC
  toToken: '0x...',   // WETH
  amount: parseUnits('100', 6),
  targetChain: 8453,
});

Utility Methods

getIntentStatus

Poll for transaction completion:

const status = await client.getIntentStatus(intentId);
console.log(status.status); // 'pending' | 'completed' | 'failed'

getPasskeys

Fetch user's registered passkeys:

const { passkeys } = await client.getPasskeys('user@example.com');
passkeys.forEach(p => console.log(p.name, p.createdAt));

setTheme

Update theme at runtime:

client.setTheme({
  accent: '#10b981',
  mode: 'dark',
});

Error Handling

All methods return result objects with success/error info:

const result = await client.sendIntent({ ... });
 
if (!result.success) {
  console.error('Code:', result.error?.code);
  console.error('Message:', result.error?.message);
}

Supported Networks

1auth supports all chains in the Rhinestone orchestrator network. Query supported chains at runtime:

import { getSupportedChains, getAllSupportedChainsAndTokens } from '@rhinestone/1auth';
 
// Get all supported chain IDs
const chains = getSupportedChains();
 
// Get chains with their supported tokens
const chainsAndTokens = getAllSupportedChainsAndTokens();

Mainnet chains include Ethereum, Base, Arbitrum, Optimism, Polygon, and others. The targetChain parameter in sendIntent() and sendSwap() accepts any supported chain ID.

Transaction Lifecycle

When you call sendIntent(), the transaction progresses through these stages:

StatusDescription
pendingIntent created, waiting for quote
quotedQuote received from orchestrator
signedUser has signed with their passkey
submittedSubmitted to the Rhinestone orchestrator
claimedA solver has claimed the intent
preconfirmedPre-confirmation received (typically < 1 second)
filledTransaction filled on the target chain
completedFully confirmed on-chain
failedIntent failed
expiredIntent expired before execution

The closeOn option controls when sendIntent() resolves:

  • "preconfirmed" (default) — Resolves quickly, recommended for most use cases
  • "claimed" — Resolves at first solver claim (fastest, less certain)
  • "filled" — Resolves when the transaction hits the target chain
  • "completed" — Waits for full on-chain confirmation (slowest)

For a transaction hash, pass waitForHash: true or poll with getIntentStatus() after the intent resolves.

Notes

  • Create one client instance and reuse it
  • Use the closeOn parameter to control when promises resolve
  • The client handles all WebAuthn and passkey operations internally
  • signMessage and signTypedData require a passkey session (call authWithModal() first)
  • If you see 401 from /api/sign/options, your session cookie is missing or blocked