PasskeyProviderClient
ClientMain 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
| Option | Type | Required | Description |
|---|---|---|---|
providerUrl | string | Yes | URL of the 1auth provider |
clientId | string | Yes | Your application's client ID |
theme | ThemeConfig | No | UI 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
closeOnparameter to control when promises resolve - The client handles all WebAuthn and passkey operations internally