CREATE TABLE oauth_login_states (
	state 			BYTEA 	NOT NULL,
	expiration 		TIMESTAMPTZ NOT NULL DEFAULT (NOW() + 10 'minute'),

	PRIMARY KEY (state)
);

CREATE TABLE oauth_tokens (
	access_token 					TEXT			NOT NULL,
	token_type 						TEXT			NOT NULL,
	refresh_token 					TEXT			NOT NULL,
	expiry							TIMESTAMPTZ		NOT NULL,

	id_token_issuer 				TEXT 			NOT NULL,
	id_token_audience				TEXT[]			NOT NULL,
	id_token_subject				TEXT			NOT NULL,
	id_token_expiry					TIMESTAMPTZ		NOT NULL,
	id_token_issued_at				TIMESTAMPTZ		NOT NULL,
	id_token_nonce					TEXT			NOT NULL,
	id_token_access_token_hash		TEXT			NOT NULL,

	claims 							JSONB			NOT NULL,

	PRIMARY KEY (access_token)
);
