🔐1auth SDK Docs
Back to all components

PasskeyProviderClient

Client

Main SDK client for authentication, signing, and intent execution via passkeys.

import { PasskeyProviderClient } from '@1auth/sdk'

Overview

PasskeyProviderClient 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 { PasskeyProviderClient } from '@1auth/sdk';

const client = new PasskeyProviderClient({
  providerUrl: 'https://auth.example.com',
  clientId: 'my-dapp',
  theme: {
    mode: 'dark',
    accent: '#6366f1',
  },
});

Config Options

OptionTypeRequiredDescription
providerUrlstringYesURL of the 1auth provider
clientIdstringYesYour application's client ID
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.username);
  console.log('Account:', result.accountAddress);
}

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.

With Signed Intent (Recommended)

For production, sign intents on your backend for XSS protection:

// 1. Get signed intent from your backend
const signedIntent = await fetch('/api/sign-intent', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ username, targetChain: 8453, calls }),
}).then(r => r.json());

// 2. Send it
const result = await client.sendIntent({
  signedIntent,
  closeOn: 'completed',
});

if (result.success) {
  console.log('TX Hash:', result.transactionHash);
}

See the Merchant Authentication guide for backend setup.

Coming Soon: Signed intents will support sponsorship flags, allowing merchants to sponsor transaction fees for their users. This requires signed intents to ensure only authorized merchants can enable sponsorship.

Without Signing (First-Party Only)

For first-party apps in ALLOWED_ORIGINS:

const result = await client.sendIntent({
  username: 'user@example.com',
  targetChain: 8453,
  calls: [
    {
      to: '0x...',
      data: '0x...',
      value: parseEther('0.1'),
      label: 'Mint NFT',
      sublabel: 'CoolNFT Collection',
    },
  ],
  closeOn: 'completed',
});

if (result.success) {
  console.log('Intent ID:', result.intentId);
  console.log('TX Hash:', result.transactionHash);
}

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);
}

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