-- clock is the highest time any exchange has seen. A clock that moves back -- more than 30 s refuses exchanges rather than reopening the replay window. CREATE TABLE base_consumer_clock ( id INTEGER PRIMARY KEY CHECK (id = 1), observed INTEGER NOT NULL ); INSERT INTO base_consumer_clock (id, observed) VALUES (1, 0); -- pending is one browser's sign-in in flight: the hash of its cookie secret, -- the hash of the nonce sent to Base, and where to go afterwards. CREATE TABLE base_consumer_pending ( secret_hash TEXT PRIMARY KEY, nonce_hash TEXT NOT NULL UNIQUE, return_to TEXT NOT NULL, created_at INTEGER NOT NULL, expires_at INTEGER NOT NULL ); CREATE INDEX base_consumer_pending_expiry ON base_consumer_pending (expires_at); -- inbox holds a verified assertion between the cross-site POST, which carries -- no cookies, and the same-origin finish, which does. CREATE TABLE base_consumer_inbox ( handle_hash TEXT PRIMARY KEY, jti_hash TEXT NOT NULL UNIQUE, token TEXT NOT NULL, created_at INTEGER NOT NULL, expires_at INTEGER NOT NULL ); CREATE INDEX base_consumer_inbox_expiry ON base_consumer_inbox (expires_at); -- replay holds every assertion ID used to start a session, until it expires. CREATE TABLE base_consumer_replay ( jti_hash TEXT PRIMARY KEY, expires_at INTEGER NOT NULL ); CREATE INDEX base_consumer_replay_expiry ON base_consumer_replay (expires_at); -- people holds the display fields from each person's latest assertion. They -- are for showing, never for deciding access. CREATE TABLE base_consumer_people ( subject TEXT PRIMARY KEY, name TEXT NOT NULL, email TEXT NOT NULL, base TEXT NOT NULL, updated_at INTEGER NOT NULL );