qat

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

Create your vault

What you keep here is encrypted on this device. The server keeps a copy it cannot read.

In order, separated by spaces
Example.qx25 lines, 1 reactive nameOpen in the playground
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 state

Add it

shell1 line
npx qatjs add vault

RecoveryCode

As a custom element: <ui-recovery-code>.

RecoveryCode: props
PropTypeAttribute
wordsstring[]property only
RecoveryCode: events
EventDetail
on:doneCustomEvent<undefined>
on:submitCustomEvent<string>

VaultUnlock

As a custom element: <ui-vault-unlock>.

VaultUnlock: props
PropTypeAttribute
vaultVaultLikeproperty only