Account.import()
Import a passkey from cloud backup.
Type: static async
Signature
static async import(config: AccountConfig): Promise<Account>Parameters
config
Type: AccountConfig
| Property | Type | Required | Description |
|---|---|---|---|
chainId | number | Yes | Chain ID for the account |
apiKey | string | Yes | API key for JAW services |
paymasterUrl | string | No | Custom paymaster URL for gas sponsorship |
Returns
Promise<Account> - The imported Account instance
Behavior
- Triggers WebAuthn authentication with empty
allowCredentials(lets user select any available passkey) - User selects a passkey from their cloud-synced credentials (iCloud Keychain, Google Password Manager, etc.)
- Creates the smart account from the imported passkey
- Stores the passkey account marked as imported
- Returns the ready-to-use Account instance
Errors
| Error | Description |
|---|---|
| WebAuthn errors | User cancelled or browser doesn't support WebAuthn |
Failed to retrieve imported passkey account | Backend lookup failed |
Examples
Basic Usage
import { Account } from '@jaw.id/core';
const account = await Account.import({
chainId: 1,
apiKey: 'your-api-key',
});
console.log('Imported account:', account.address);
const metadata = account.getMetadata();
console.log('Is imported:', metadata?.isImported); // trueUsage in Custom UI Handler
class MyUIHandler implements UIHandler {
async handleConnect(request: ConnectUIRequest) {
// Show import option in your UI
const action = await this.showConnectOptions();
if (action === 'import') {
const account = await Account.import({
chainId: request.data.chainId,
apiKey: this.config?.apiKey,
});
return {
id: request.id,
approved: true,
data: {
accounts: [{ address: account.address }],
},
};
}
// ... handle other actions
}
}Cloud Sync Providers
Passkeys can be synced via:
- Apple: iCloud Keychain (iOS, macOS, Safari)
- Google: Google Password Manager (Android, Chrome)
- Microsoft: Windows Hello (Windows, Edge)
- 1Password, Dashlane, etc.: Third-party password managers
The import flow allows users to access their JAW account on any device where their passkeys are synced.
Related
- Account.create() - Create a new account
- Account.get() - Login with existing account
- Account.getStoredAccounts() - List local accounts