@soulcode/bexio-oauth 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,32 +0,0 @@
1
- -- @soulcode/bexio-oauth 0001: the grants table.
2
- -- One row per (owner, Bexio company, Bexio user). Token columns hold JWE
3
- -- ciphertext; only your server-side database role should be able to read them.
4
-
5
- CREATE TABLE IF NOT EXISTS bexio_grants (
6
- id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
7
- owner_id text NOT NULL,
8
- bexio_company_id text NOT NULL,
9
- bexio_user_id text NOT NULL,
10
- bexio_company_user_id integer,
11
- company_name text,
12
- user_name text,
13
- user_email text,
14
- role text NOT NULL DEFAULT 'member' CHECK (role IN ('admin', 'member')),
15
- status text NOT NULL DEFAULT 'active' CHECK (status IN ('active', 'reauth_required')),
16
- access_token text NOT NULL,
17
- refresh_token text,
18
- access_expires_at timestamptz,
19
- refresh_expires_at timestamptz,
20
- scope text,
21
- refresh_locked_until timestamptz,
22
- refresh_lock_token text,
23
- last_refreshed_at timestamptz NOT NULL DEFAULT now(),
24
- created_at timestamptz NOT NULL DEFAULT now(),
25
- updated_at timestamptz NOT NULL DEFAULT now(),
26
- CONSTRAINT bexio_grants_owner_company_user_key UNIQUE (owner_id, bexio_company_id, bexio_user_id)
27
- );
28
-
29
- -- refreshIdle(): active grants by last refresh.
30
- CREATE INDEX IF NOT EXISTS bexio_grants_idle_idx
31
- ON bexio_grants (last_refreshed_at)
32
- WHERE status = 'active';