Tearleads

user_device_enrollments Client SQLite table

This install's enrollment in a user's signed device chain (#3503).

Declared in packages/client-sdk/src/data/sqlite/schema/userDeviceEnrollmentSchema.ts

Description

It holds the device's own private keys and the key epoch secrets it has unwrapped, so it is device-local in the strict sense: the keys are random, exist nowhere else, and must never leave this database. A backup neither exports this table nor replaces it on restore.

chainVersion and chainStateHash are the device's checkpoint of its own user's chain: a served chain that is older, or that differs at that version, is refused.

Columns

  • identity_trust_domaintext
    • not null

    API authority of the enrollment: its canonical URL (origin and path, no trailing slash).

  • user_idtext
    • not null

    Id of the user whose device chain this install enrolls in.

  • statustext
    • not null

    pending while the state that names this device may not have reached the server, enrolled once the chain names it, and removed once the chain no longer does. A removed row stays as a marker with its secrets erased: deleting it would let the next sign-in enroll the install again.

  • device_idtext
    • not null

    This install's device id in the chain. It never changes, except that a root-authorized recovery may replace a removed row with a new device.

  • signing_public_keytext
    • not null

    The device's signing public key, base64; empty once removed.

  • signing_private_keytext
    • not null

    The device's signing private key, base64; empty once removed.

  • encapsulation_public_keytext
    • not null

    The device's encapsulation public key, base64; empty once removed.

  • encapsulation_secret_keytext
    • not null

    The device's encapsulation secret key, base64; empty once removed.

  • key_epoch_secretstext
    • not null

    JSON array of base64 key epoch secrets, oldest first.

  • chain_versioninteger
    • not null

    Version of the last chain state this install verified, or 0 while a pending device's user has no chain. It never decreases.

  • chain_state_hashtext
    • not null

    Hex SHA-256 state hash of the chain at chainVersion, or empty when chainVersion is 0.

  • updated_attext
    • not null

    ISO-8601 time the row was last written.

Keys and constraints

  • Primary key(identity_trust_domain, user_id)

DDL

The statements the client runs to create this table and its indexes.

CREATE TABLE IF NOT EXISTS "user_device_enrollments" (
  "identity_trust_domain" TEXT NOT NULL,
  "user_id" TEXT NOT NULL,
  "status" TEXT NOT NULL,
  "device_id" TEXT NOT NULL,
  "signing_public_key" TEXT NOT NULL,
  "signing_private_key" TEXT NOT NULL,
  "encapsulation_public_key" TEXT NOT NULL,
  "encapsulation_secret_key" TEXT NOT NULL,
  "key_epoch_secrets" TEXT NOT NULL,
  "chain_version" INTEGER NOT NULL,
  "chain_state_hash" TEXT NOT NULL,
  "updated_at" TEXT NOT NULL,
  PRIMARY KEY ("identity_trust_domain", "user_id")
);