Add account device API and APK build versioning

This commit is contained in:
2026-11-17 21:15:39 +02:00
parent 9a10f639cc
commit a11ccf15c5
11 changed files with 901 additions and 17 deletions
@@ -0,0 +1,24 @@
CREATE TABLE IF NOT EXISTS sessions (
token_hash BYTEA PRIMARY KEY CHECK (octet_length(token_hash) = 32),
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
expires_at TIMESTAMPTZ NOT NULL
);
CREATE INDEX IF NOT EXISTS sessions_user_id_idx ON sessions(user_id);
CREATE INDEX IF NOT EXISTS sessions_expires_at_idx ON sessions(expires_at);
CREATE TABLE IF NOT EXISTS device_registration_challenges (
id UUID PRIMARY KEY,
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
nonce BYTEA NOT NULL CHECK (octet_length(nonce) = 32),
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
expires_at TIMESTAMPTZ NOT NULL,
consumed_at TIMESTAMPTZ
);
CREATE INDEX IF NOT EXISTS device_registration_challenges_user_id_idx
ON device_registration_challenges(user_id);
CREATE UNIQUE INDEX IF NOT EXISTS devices_active_identity_key_idx
ON devices(user_id, identity_public_key) WHERE status = 'active';