auth.yourcompany.com) while leveraging the Grid API to proxy WebAuthn requests to the blockchain.
Primary Use Case: Custom Domain - Host passkey authentication on your own domain instead of the default Grid domain for branding, compliance, or security requirements.
When to Use Advanced Integration
Choose this approach when you need:- Custom Domain: Host passkey flows on
auth.yourcompany.cominstead of the default Grid domain - Compliance Requirements: Internal policies require authentication to happen on company domains
- Brand Consistency: Maintain your brand throughout the entire authentication flow
- Security Policies: Security requirements mandate own domain usage
How It Works
WebAuthn Proxy Flow
- Create Session: Use the passkeys endpoint with your custom
baseUrl - Extract Challenge: Parse the challenge from the returned URL
- WebAuthn Ceremony: Implement WebAuthn protocol on your domain with proper ES256 support
- Submit Response: Use the submit endpoint to process the response
- Create Account: Optionally use the create account endpoint to deploy a smart account
- Get Account: Retrieve account details using the get account endpoint
Custom UI Requirements
When implementing a custom passkey UI, your implementation must:- Extract the challenge: Parse the
challengeparameter from the URL - Use challenge directly: Pass the challenge to the WebAuthn protocol as-is (already base64 encoded)
- Do NOT re-encode: The challenge is already base64 encoded - additional encoding will cause errors
- Return complete response: For authentication, return the entire WebAuthn authentication response object
- Time constraint: The challenge is only valid for 60 seconds from URL generation
Advanced API Endpoints
For custom UI implementations, use these endpoints:- Create Passkey Session - Initialize passkey creation with custom baseUrl
- Authorize Passkey Session - Authenticate with custom baseUrl
- Submit Passkey Session - Process WebAuthn responses
- Create Smart Account - Deploy Grid account with passkey
- Get Passkey Account - Retrieve passkey details
- Find Passkey Account - Lookup passkey by authenticator
MetaInfo and BaseURL Usage
Default vs Custom BaseURL
- Default baseUrl: When not specified, Grid uses its default hosted UI which handles the
meta_infofields - Custom baseUrl: Use your custom domain (e.g.,
https://auth.yourcompany.com) - your UI handles passkey identification and naming
Example Configuration
WebAuthn Configuration Requirements
Required Settings
The on-chain passkey program has specific requirements: User Presence Required:userPresentmust betruein the WebAuthn authenticator response- The authenticator must verify user presence through biometric, PIN, or physical interaction
- Only ES256 (algorithm
-7) is supported - No other cryptographic algorithms are accepted
Error Handling
Common Errors
| Error Code | Description | Solution |
|---|---|---|
MissingSessionKey | Session key required for auth actions | Provide valid session key |
InvalidAuthenticatorResponse | Malformed WebAuthn response | Validate WebAuthn data |
NoValidExternallySignedAccount | Account not found | Verify account exists |
InvalidExternallySignedAccountAddress | Invalid account address format | Use valid Solana address |
Registration Failure Recovery
If local passkey creation succeeds but submission fails:- The passkey exists locally but has no associated on-chain account
- Solution: Re-request a new URL and submit again
- The existing local passkey will work with the new challenge
- No need to recreate the local passkey
Best Practices
Challenge Handling
- Parse challenge from URL parameters
- Use challenge directly - it’s already base64 encoded
- Never re-encode the challenge
- Complete WebAuthn ceremony within 60 seconds of URL generation
Security
- Validate all inputs
- Use HTTPS for all communications
- Implement proper CORS policies
- Never expose API keys in client-side code
- Store session keys securely on client side
- Validate session expiration on blockchain clock
Implementation
- Generate unique session keys for each authentication
- Implement comprehensive error handling
- Provide user-friendly error messages
- Use clear, recognizable app names
- Provide loading states during authentication
- Handle environment isolation (sandbox vs production)
Smart Account Creation
- Use the dedicated create account endpoint after passkey submission
- Store both passkey address and smart account address
- Verify account creation before allowing transactions
- Handle devnet funding appropriately (sandbox only)
- Test account creation flow thoroughly in sandbox
Getting Started
- Review Requirements: Ensure you have WebAuthn expertise and need custom domain branding
- Set Up Domain: Configure your custom domain for passkey flows
- Implement WebAuthn: Build custom UI following the requirements above
- Test on Sandbox: Thoroughly test your implementation before production
- Handle Errors: Implement robust error handling and recovery
- Deploy Smart Accounts: Use the create account endpoint to deploy Grid accounts