onekey-widget
v1.0.0
Published
OneKEY authentication widget for relying party websites
Maintainers
Readme
@onekey/widget
Official OneKEY authentication widget for relying party websites.
Installation
CDN (Recommended)
<script src="https://unpkg.com/@onekey/[email protected]" crossorigin="anonymous"></script>Or with integrity hash (SRI):
<script
src="https://unpkg.com/@onekey/[email protected]"
integrity="sha384-..."
crossorigin="anonymous">
</script>npm
npm install @onekey/widgetimport '@onekey/widget';Usage
<!DOCTYPE html>
<html>
<head>
<script src="https://unpkg.com/@onekey/[email protected]"></script>
</head>
<body>
<div id="onekey-root"></div>
<script>
window.ONEKEY_CONFIG = {
apiUrl: 'https://api.onekey.example.com',
onSuccess: (sessionData) => {
console.log('Authenticated:', sessionData);
// Redirect or update UI
},
onError: (error) => {
console.error('Auth failed:', error);
}
};
</script>
</body>
</html>Configuration
| Option | Type | Description |
|--------|------|-------------|
| apiUrl | string | OneKEY API server URL |
| onSuccess | function | Called when authentication succeeds |
| onError | function | Called on authentication error |
| containerSelector | string | CSS selector for widget container (default: #onekey-root) |
Browser Support
- Chrome/Edge 90+
- Firefox 88+
- Safari 14+
- Modern mobile browsers
License
MIT
