|
| 1 | +# `<auths-verify>` Web Component |
| 2 | + |
| 3 | +[](https://www.npmjs.com/package/auths-verify) |
| 4 | +[](https://github.com/bordumb/auths-verify-widget/blob/main/LICENSE) |
| 5 | + |
| 6 | +A drop-in web component for decentralized commit verification — the decentralized equivalent of GitHub's green "Verified" badge. Powered by [Auths](https://github.com/bordumb/auths) cryptographic attestation verification via WASM. |
| 7 | + |
| 8 | +## Quick Start |
| 9 | + |
| 10 | +```html |
| 11 | +<script type="module" src="https://unpkg.com/auths-verify/dist/auths-verify.mjs"></script> |
| 12 | + |
| 13 | +<auths-verify |
| 14 | + attestation='{"version":1,"rid":"...","issuer":"did:keri:...","subject":"did:key:z...","device_public_key":"...","identity_signature":"...","device_signature":"...","revoked":false}' |
| 15 | + public-key="aabbccddeeff00112233445566778899aabbccddeeff00112233445566778899" |
| 16 | +></auths-verify> |
| 17 | +``` |
| 18 | + |
| 19 | +The widget loads WASM and verifies the attestation automatically on mount. |
| 20 | + |
| 21 | +## Display Modes |
| 22 | + |
| 23 | +### Badge (default) |
| 24 | + |
| 25 | +Compact inline pill showing verification status. |
| 26 | + |
| 27 | +```html |
| 28 | +<auths-verify attestation="..." public-key="..." mode="badge"></auths-verify> |
| 29 | +``` |
| 30 | + |
| 31 | +### Detail |
| 32 | + |
| 33 | +Badge with an expandable panel showing the full attestation chain. Click the badge to expand. |
| 34 | + |
| 35 | +```html |
| 36 | +<auths-verify attestations="[...]" public-key="..." mode="detail"></auths-verify> |
| 37 | +``` |
| 38 | + |
| 39 | +### Tooltip |
| 40 | + |
| 41 | +Badge with a hover tooltip summarizing verification status. |
| 42 | + |
| 43 | +```html |
| 44 | +<auths-verify attestation="..." public-key="..." mode="tooltip"></auths-verify> |
| 45 | +``` |
| 46 | + |
| 47 | +## Attributes |
| 48 | + |
| 49 | +| Attribute | Type | Default | Description | |
| 50 | +|---|---|---|---| |
| 51 | +| `attestation` | JSON string | `""` | Single attestation to verify | |
| 52 | +| `attestations` | JSON array string | `""` | Chain of attestations to verify | |
| 53 | +| `public-key` | hex string | `""` | Root/issuer Ed25519 public key | |
| 54 | +| `mode` | `badge\|detail\|tooltip` | `badge` | Display mode | |
| 55 | +| `size` | `sm\|md\|lg` | `md` | Badge size | |
| 56 | +| `wasm-url` | string | `""` | Optional WASM URL override | |
| 57 | +| `auto-verify` | boolean | `true` | Verify on connect/attribute change | |
| 58 | + |
| 59 | +## JavaScript API |
| 60 | + |
| 61 | +```js |
| 62 | +const el = document.querySelector('auths-verify'); |
| 63 | + |
| 64 | +// Trigger verification manually |
| 65 | +await el.verify(); |
| 66 | + |
| 67 | +// Get the last verification report |
| 68 | +const report = el.getReport(); |
| 69 | + |
| 70 | +// Listen for events |
| 71 | +el.addEventListener('auths-verified', (e) => { |
| 72 | + console.log('Status:', e.detail.status.type); |
| 73 | + console.log('Chain:', e.detail.chain); |
| 74 | +}); |
| 75 | + |
| 76 | +el.addEventListener('auths-error', (e) => { |
| 77 | + console.error('Error:', e.detail.error); |
| 78 | +}); |
| 79 | +``` |
| 80 | + |
| 81 | +## Theming |
| 82 | + |
| 83 | +All colors are overridable via CSS custom properties: |
| 84 | + |
| 85 | +```css |
| 86 | +auths-verify { |
| 87 | + --auths-verified-bg: #eef2ff; |
| 88 | + --auths-verified-fg: #3730a3; |
| 89 | + --auths-verified-border: #a5b4fc; |
| 90 | + --auths-font-family: 'Inter', sans-serif; |
| 91 | + --auths-border-radius: 6px; |
| 92 | +} |
| 93 | +``` |
| 94 | + |
| 95 | +Available properties: `--auths-{state}-bg`, `--auths-{state}-fg`, `--auths-{state}-border` for each state (`verified`, `invalid`, `expired`, `revoked`, `error`, `loading`, `idle`), plus `--auths-font-family`, `--auths-font-size`, `--auths-border-radius`, `--auths-detail-border-radius`. |
| 96 | + |
| 97 | +## Development |
| 98 | + |
| 99 | +### Prerequisites |
| 100 | + |
| 101 | +- Node.js >= 18 |
| 102 | +- Rust 1.93+ with `wasm32-unknown-unknown` target (for WASM builds) |
| 103 | +- [wasm-pack](https://rustwasm.github.io/wasm-pack/) |
| 104 | +- The [auths](https://github.com/bordumb/auths) repo cloned alongside this one: |
| 105 | + ``` |
| 106 | + auths-base/ |
| 107 | + ├── auths/ # main auths repo |
| 108 | + └── auths-verify-widget/ # this repo |
| 109 | + ``` |
| 110 | + |
| 111 | +### Setup |
| 112 | + |
| 113 | +```bash |
| 114 | +npm install |
| 115 | +``` |
| 116 | + |
| 117 | +### Build WASM (requires Rust) |
| 118 | + |
| 119 | +```bash |
| 120 | +npm run build:wasm |
| 121 | +``` |
| 122 | + |
| 123 | +### Run tests |
| 124 | + |
| 125 | +```bash |
| 126 | +# Unit tests (no WASM required — mocked) |
| 127 | +npm test |
| 128 | + |
| 129 | +# Type check |
| 130 | +npm run typecheck |
| 131 | +``` |
| 132 | + |
| 133 | +### Dev server |
| 134 | + |
| 135 | +```bash |
| 136 | +npm run dev |
| 137 | +``` |
| 138 | + |
| 139 | +Opens the examples directory with hot reload via Vite. |
| 140 | + |
| 141 | +### Production build |
| 142 | + |
| 143 | +```bash |
| 144 | +# Build WASM first |
| 145 | +npm run build:wasm |
| 146 | + |
| 147 | +# Build both full (inlined WASM) and slim (split WASM) bundles |
| 148 | +npm run build |
| 149 | +``` |
| 150 | + |
| 151 | +Outputs: |
| 152 | +- `dist/auths-verify.js` — single file with WASM base64-inlined (~100-200KB gzipped) |
| 153 | +- `dist/slim/auths-verify.js` — smaller JS, loads `.wasm` separately |
| 154 | + |
| 155 | +### Visual testing |
| 156 | + |
| 157 | +Open `tests/visual/index.html` in a browser to see all states and modes rendered side by side. |
| 158 | + |
| 159 | +## Build Outputs |
| 160 | + |
| 161 | +| File | Description | |
| 162 | +|---|---| |
| 163 | +| `dist/auths-verify.js` | CDN-ready single file (WASM inlined) | |
| 164 | +| `dist/slim/auths-verify.js` | Smaller JS bundle (loads WASM separately) | |
| 165 | + |
| 166 | +## License |
| 167 | + |
| 168 | +MIT |
0 commit comments