Vault unlock and recovery code
RecoveryCode, VaultUnlock. They are copied into your app’s ui/ by qatjs add vault: the code is yours to edit.
Example
Unlocked: what the vault keeps shows here.
Create your vault
What you keep here is encrypted on this device. The server keeps a copy it cannot read.
import { RecoveryCode, VaultUnlock, type VaultLike } from './ui/vault/vault.qx'
// (a stand-in of @qatjs/vault's vault: this page opens nothing — its "create" shows a sample code)
const sample = 'legal winner thank year wave sausage worth useful legal winner thank yellow'.split(' ')
export default function Example() {
let status = state<ReturnType<VaultLike['status']>>('new')
const vault: VaultLike = {
status: () => status,
weak: () => false,
passkeys: async () => true,
create: async () => ((status = 'unlocked'), sample),
unlock: async () => void (status = 'unlocked'),
recover: async () => void (status = 'unlocked'),
}
return (
<VaultUnlock vault={vault}>
<p>Unlocked: what the vault keeps shows here.</p>
<button type="button" on:click={() => (status = 'locked')}>
Lock
</button>
</VaultUnlock>
<RecoveryCode on:submit={() => {}} />
)
}status stateAdd it
npx qatjs add vaultRecoveryCode
As a custom element: <ui-recovery-code>.
| Prop | Type | Attribute |
|---|---|---|
words | string[] | property only |
| Event | Detail |
|---|---|
on:done | CustomEvent<undefined> |
on:submit | CustomEvent<string> |
VaultUnlock
As a custom element: <ui-vault-unlock>.
| Prop | Type | Attribute |
|---|---|---|
vault | VaultLike | property only |