| 1 | -- clock is the highest time any exchange has seen. A clock that moves back |
| 2 | -- more than 30 s refuses exchanges rather than reopening the replay window. |
| 3 | CREATE TABLE base_consumer_clock ( |
| 4 | id INTEGER PRIMARY KEY CHECK (id = 1), |
| 5 | observed INTEGER NOT NULL |
| 6 | ); |
| 7 | INSERT INTO base_consumer_clock (id, observed) VALUES (1, 0); |
| 8 | -- pending is one browser's sign-in in flight: the hash of its cookie secret, |
| 9 | -- the hash of the nonce sent to Base, and where to go afterwards. |
| 10 | CREATE TABLE base_consumer_pending ( |
| 11 | secret_hash TEXT PRIMARY KEY, |
| 12 | nonce_hash TEXT NOT NULL UNIQUE, |
| 13 | return_to TEXT NOT NULL, |
| 14 | created_at INTEGER NOT NULL, |
| 15 | expires_at INTEGER NOT NULL |
| 16 | ); |
| 17 | CREATE INDEX base_consumer_pending_expiry ON base_consumer_pending (expires_at); |
| 18 | -- inbox holds a verified assertion between the cross-site POST, which carries |
| 19 | -- no cookies, and the same-origin finish, which does. |
| 20 | CREATE TABLE base_consumer_inbox ( |
| 21 | handle_hash TEXT PRIMARY KEY, |
| 22 | jti_hash TEXT NOT NULL UNIQUE, |
| 23 | token TEXT NOT NULL, |
| 24 | created_at INTEGER NOT NULL, |
| 25 | expires_at INTEGER NOT NULL |
| 26 | ); |
| 27 | CREATE INDEX base_consumer_inbox_expiry ON base_consumer_inbox (expires_at); |
| 28 | -- replay holds every assertion ID used to start a session, until it expires. |
| 29 | CREATE TABLE base_consumer_replay ( |
| 30 | jti_hash TEXT PRIMARY KEY, |
| 31 | expires_at INTEGER NOT NULL |
| 32 | ); |
| 33 | CREATE INDEX base_consumer_replay_expiry ON base_consumer_replay (expires_at); |
| 34 | -- people holds the display fields from each person's latest assertion. They |
| 35 | -- are for showing, never for deciding access. |
| 36 | CREATE TABLE base_consumer_people ( |
| 37 | subject TEXT PRIMARY KEY, |
| 38 | name TEXT NOT NULL, |
| 39 | email TEXT NOT NULL, |
| 40 | base TEXT NOT NULL, |
| 41 | updated_at INTEGER NOT NULL |
| 42 | ); |
| 43 | |