|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | + <meta charset="UTF-8"> |
| 5 | + <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 6 | + <title>auths-verify — JS API</title> |
| 7 | + <style> |
| 8 | + body { font-family: system-ui, sans-serif; max-width: 600px; margin: 60px auto; padding: 0 20px; } |
| 9 | + h1 { font-size: 20px; } |
| 10 | + button { padding: 8px 16px; font-size: 14px; border: 1px solid #d1d5db; border-radius: 6px; background: #fff; cursor: pointer; } |
| 11 | + button:hover { background: #f9fafb; } |
| 12 | + #log { margin-top: 16px; padding: 12px; background: #1f2937; color: #d1d5db; border-radius: 8px; font-family: monospace; font-size: 12px; white-space: pre-wrap; min-height: 80px; } |
| 13 | + .controls { display: flex; gap: 8px; margin-top: 16px; } |
| 14 | + </style> |
| 15 | +</head> |
| 16 | +<body> |
| 17 | + <h1>Programmatic JS API</h1> |
| 18 | + <p>Use <code>element.verify()</code> and <code>element.getReport()</code> for full control.</p> |
| 19 | + |
| 20 | + <auths-verify id="widget" auto-verify="false"></auths-verify> |
| 21 | + |
| 22 | + <div class="controls"> |
| 23 | + <button id="btn-verify">verify()</button> |
| 24 | + <button id="btn-report">getReport()</button> |
| 25 | + <button id="btn-set-data">Set attestation data</button> |
| 26 | + </div> |
| 27 | + |
| 28 | + <div id="log">// Output will appear here</div> |
| 29 | + |
| 30 | + <script type="module" src="../src/auths-verify.ts"></script> |
| 31 | + <script> |
| 32 | + const widget = document.getElementById('widget'); |
| 33 | + const log = document.getElementById('log'); |
| 34 | + |
| 35 | + function appendLog(msg) { |
| 36 | + log.textContent += msg + '\n'; |
| 37 | + } |
| 38 | + |
| 39 | + widget.addEventListener('auths-verified', (e) => { |
| 40 | + appendLog('[event] auths-verified: ' + JSON.stringify(e.detail.status)); |
| 41 | + }); |
| 42 | + |
| 43 | + widget.addEventListener('auths-error', (e) => { |
| 44 | + appendLog('[event] auths-error: ' + e.detail.error); |
| 45 | + }); |
| 46 | + |
| 47 | + document.getElementById('btn-set-data').addEventListener('click', () => { |
| 48 | + widget.attestation = JSON.stringify({ |
| 49 | + version: 1, |
| 50 | + rid: 'example', |
| 51 | + issuer: 'did:keri:abc123', |
| 52 | + subject: 'did:key:z456', |
| 53 | + device_public_key: 'aabb', |
| 54 | + identity_signature: 'sig1', |
| 55 | + device_signature: 'sig2', |
| 56 | + revoked: false, |
| 57 | + }); |
| 58 | + widget.publicKey = 'aabbccddeeff00112233445566778899aabbccddeeff00112233445566778899'; |
| 59 | + appendLog('[action] Set attestation data'); |
| 60 | + }); |
| 61 | + |
| 62 | + document.getElementById('btn-verify').addEventListener('click', async () => { |
| 63 | + appendLog('[action] Calling verify()...'); |
| 64 | + await widget.verify(); |
| 65 | + appendLog('[action] verify() completed'); |
| 66 | + }); |
| 67 | + |
| 68 | + document.getElementById('btn-report').addEventListener('click', () => { |
| 69 | + const report = widget.getReport(); |
| 70 | + appendLog('[action] getReport(): ' + JSON.stringify(report)); |
| 71 | + }); |
| 72 | + </script> |
| 73 | +</body> |
| 74 | +</html> |
0 commit comments