···4 "context"
5 "database/sql"
6 "fmt"
078 _ "github.com/mattn/go-sqlite3"
9)
···24}
2526func Make(dbPath string) (*DB, error) {
27- db, err := sql.Open("sqlite3", dbPath)
000000028 if err != nil {
29 return nil, fmt.Errorf("failed to open db: %w", err)
30 }
31- _, err = db.Exec(`
32- pragma journal_mode = WAL;
33- pragma synchronous = normal;
34- pragma foreign_keys = on;
35- pragma temp_store = memory;
36- pragma mmap_size = 30000000000;
37- pragma page_size = 32768;
38- pragma auto_vacuum = incremental;
39- pragma busy_timeout = 5000;
4041- create table if not exists oauth_requests (
42- id integer primary key autoincrement,
43- auth_server_iss text not null,
44- state text not null,
45- did text not null,
46- handle text not null,
47- pds_url text not null,
48- pkce_verifier text not null,
49- dpop_auth_server_nonce text not null,
50- dpop_private_jwk text not null
51- );
5253- create table if not exists oauth_sessions (
54- id integer primary key autoincrement,
55- did text not null,
56- handle text not null,
57- pds_url text not null,
58- auth_server_iss text not null,
59- access_jwt text not null,
60- refresh_jwt text not null,
61- dpop_pds_nonce text,
62- dpop_auth_server_nonce text not null,
63- dpop_private_jwk text not null,
64- expiry text not null
65- );
66067 create table if not exists profiles (
68 -- id
69 id integer primary key autoincrement,