| 79 | } |
| 80 | |
| 81 | saveAccessToken(tokenHash: string, record: PersistedAccessTokenRecord): void { |
| 82 | this.database.sqlite |
| 83 | .prepare( |
| 84 | `insert into oauth_access_tokens (token_hash, client_id, scopes_json, expires_at, resource) |
| 85 | values (?, ?, ?, ?, ?) |
| 86 | on conflict(token_hash) do update set |
| 87 | client_id = excluded.client_id, |
| 88 | scopes_json = excluded.scopes_json, |
| 89 | expires_at = excluded.expires_at, |
| 90 | resource = excluded.resource`, |
| 91 | ) |
| 92 | .run( |
| 93 | tokenHash, |
| 94 | record.clientId, |
| 95 | JSON.stringify(record.scopes), |
| 96 | record.expiresAt, |
| 97 | record.resource ?? null, |
| 98 | ); |
| 99 | } |
| 100 | |
| 101 | getAccessToken(tokenHash: string): PersistedAccessTokenRecord | undefined { |
| 102 | const row = this.database.sqlite |