Security Considerations
Origin Validation
In production, always validate the origin of messages:Content Security Policy
Add CSP headers to allow iframe embedding:Input Validation
Validate wallet addresses before sending:Best Practices
- Wait for Ready Signal: Always wait for
IFRAME_READYbefore sending commands - Queue Messages: Queue messages if iframe isn’t ready yet
- Validate Input: Validate wallet addresses before sending
- Handle Timeouts: Implement timeouts for async operations
- Error Handling: Always handle potential errors and edge cases
- Type Safety: Use TypeScript types for better development experience
- Security: Validate message origins in production
Troubleshooting
Common Issues
| Issue | Solution |
|---|---|
| Messages not received | Check if iframe is fully loaded |
| CORS errors | Ensure proper CORS configuration |
| Type errors | Verify message structure matches interfaces |
| Timeout errors | Increase timeout or check network connectivity |
