Something went wrong. Try again.
(READ ONLY) Margin is an open annotation layer for the internet. Powered by the AT Protocol.
margin.at
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314// Code generated by sqlc. DO NOT EDIT.// versions:// sqlc v1.31.1// source: oauth.sql
package sqlcdb
import ( "context"
"github.com/jackc/pgx/v5/pgtype")
const countOAuthSessionsByDID = `-- name: CountOAuthSessionsByDID :oneSELECT COUNT(*) FROM oauth_sessions WHERE did = $1`
func (q *Queries) CountOAuthSessionsByDID(ctx context.Context, did string) (int64, error) { row := q.db.QueryRow(ctx, countOAuthSessionsByDID, did) var count int64 err := row.Scan(&count) return count, err}
const createOAuthSession = `-- name: CreateOAuthSession :execINSERT INTO oauth_sessions (id, did, handle, pds, email, access_token, refresh_token, token_endpoint, issuer, dpop_crv, dpop_d, dpop_x, dpop_y, access_token_expires_at, expires_at, created_at)VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15, NOW())ON CONFLICT (id) DO UPDATE SET access_token = EXCLUDED.access_token, refresh_token = EXCLUDED.refresh_token, access_token_expires_at = EXCLUDED.access_token_expires_at, expires_at = EXCLUDED.expires_at`
type CreateOAuthSessionParams struct { ID string `json:"id"` Did string `json:"did"` Handle string `json:"handle"` Pds string `json:"pds"` Email string `json:"email"` AccessToken string `json:"accessToken"` RefreshToken string `json:"refreshToken"` TokenEndpoint string `json:"tokenEndpoint"` Issuer string `json:"issuer"` DpopCrv string `json:"dpopCrv"` DpopD string `json:"dpopD"` DpopX string `json:"dpopX"` DpopY string `json:"dpopY"` AccessTokenExpiresAt pgtype.Timestamptz `json:"accessTokenExpiresAt"` ExpiresAt pgtype.Timestamptz `json:"expiresAt"`}
func (q *Queries) CreateOAuthSession(ctx context.Context, arg CreateOAuthSessionParams) error { _, err := q.db.Exec(ctx, createOAuthSession, arg.ID, arg.Did, arg.Handle, arg.Pds, arg.Email, arg.AccessToken, arg.RefreshToken, arg.TokenEndpoint, arg.Issuer, arg.DpopCrv, arg.DpopD, arg.DpopX, arg.DpopY, arg.AccessTokenExpiresAt, arg.ExpiresAt, ) return err}
const deleteExpiredOAuthSessions = `-- name: DeleteExpiredOAuthSessions :execDELETE FROM oauth_sessions WHERE expires_at <= NOW()`
func (q *Queries) DeleteExpiredOAuthSessions(ctx context.Context) error { _, err := q.db.Exec(ctx, deleteExpiredOAuthSessions) return err}
const deleteExpiredPendingAuthsOAuth = `-- name: DeleteExpiredPendingAuthsOAuth :execDELETE FROM oauth_pending_auths WHERE created_at < $1`
func (q *Queries) DeleteExpiredPendingAuthsOAuth(ctx context.Context, createdAt pgtype.Timestamptz) error { _, err := q.db.Exec(ctx, deleteExpiredPendingAuthsOAuth, createdAt) return err}
const deleteOAuthSession = `-- name: DeleteOAuthSession :execDELETE FROM oauth_sessions WHERE id = $1`
func (q *Queries) DeleteOAuthSession(ctx context.Context, id string) error { _, err := q.db.Exec(ctx, deleteOAuthSession, id) return err}
const deleteOAuthSessionsByDID = `-- name: DeleteOAuthSessionsByDID :execDELETE FROM oauth_sessions WHERE did = $1`
func (q *Queries) DeleteOAuthSessionsByDID(ctx context.Context, did string) error { _, err := q.db.Exec(ctx, deleteOAuthSessionsByDID, did) return err}
const deletePendingAuthOAuth = `-- name: DeletePendingAuthOAuth :execDELETE FROM oauth_pending_auths WHERE state = $1`
func (q *Queries) DeletePendingAuthOAuth(ctx context.Context, state string) error { _, err := q.db.Exec(ctx, deletePendingAuthOAuth, state) return err}
const getLatestOAuthSessionByDID = `-- name: GetLatestOAuthSessionByDID :oneSELECT id, did, handle, pds, email, access_token, refresh_token, token_endpoint, issuer, dpop_crv, dpop_d, dpop_x, dpop_y, access_token_expires_at, expires_at, created_atFROM oauth_sessions WHERE did = $1 AND expires_at > NOW()ORDER BY created_at DESC LIMIT 1`
func (q *Queries) GetLatestOAuthSessionByDID(ctx context.Context, did string) (OauthSession, error) { row := q.db.QueryRow(ctx, getLatestOAuthSessionByDID, did) var i OauthSession err := row.Scan( &i.ID, &i.Did, &i.Handle, &i.Pds, &i.Email, &i.AccessToken, &i.RefreshToken, &i.TokenEndpoint, &i.Issuer, &i.DpopCrv, &i.DpopD, &i.DpopX, &i.DpopY, &i.AccessTokenExpiresAt, &i.ExpiresAt, &i.CreatedAt, ) return i, err}
const getOAuthSessionByID = `-- name: GetOAuthSessionByID :oneSELECT did, handle, pds, email, access_token, refresh_token, token_endpoint, issuer, dpop_crv, dpop_d, dpop_x, dpop_y, access_token_expires_at, expires_at, created_atFROM oauth_sessions WHERE id = $1 AND expires_at > NOW()`
type GetOAuthSessionByIDRow struct { Did string `json:"did"` Handle string `json:"handle"` Pds string `json:"pds"` Email string `json:"email"` AccessToken string `json:"accessToken"` RefreshToken string `json:"refreshToken"` TokenEndpoint string `json:"tokenEndpoint"` Issuer string `json:"issuer"` DpopCrv string `json:"dpopCrv"` DpopD string `json:"dpopD"` DpopX string `json:"dpopX"` DpopY string `json:"dpopY"` AccessTokenExpiresAt pgtype.Timestamptz `json:"accessTokenExpiresAt"` ExpiresAt pgtype.Timestamptz `json:"expiresAt"` CreatedAt pgtype.Timestamptz `json:"createdAt"`}
func (q *Queries) GetOAuthSessionByID(ctx context.Context, id string) (GetOAuthSessionByIDRow, error) { row := q.db.QueryRow(ctx, getOAuthSessionByID, id) var i GetOAuthSessionByIDRow err := row.Scan( &i.Did, &i.Handle, &i.Pds, &i.Email, &i.AccessToken, &i.RefreshToken, &i.TokenEndpoint, &i.Issuer, &i.DpopCrv, &i.DpopD, &i.DpopX, &i.DpopY, &i.AccessTokenExpiresAt, &i.ExpiresAt, &i.CreatedAt, ) return i, err}
const getPendingAuthOAuth = `-- name: GetPendingAuthOAuth :oneSELECT did, handle, pds, issuer, token_endpoint, pkce_verifier, dpop_crv, dpop_d, dpop_x, dpop_y, dpop_nonce, created_atFROM oauth_pending_auths WHERE state = $1`
type GetPendingAuthOAuthRow struct { Did string `json:"did"` Handle string `json:"handle"` Pds string `json:"pds"` Issuer string `json:"issuer"` TokenEndpoint string `json:"tokenEndpoint"` PkceVerifier string `json:"pkceVerifier"` DpopCrv string `json:"dpopCrv"` DpopD string `json:"dpopD"` DpopX string `json:"dpopX"` DpopY string `json:"dpopY"` DpopNonce string `json:"dpopNonce"` CreatedAt pgtype.Timestamptz `json:"createdAt"`}
func (q *Queries) GetPendingAuthOAuth(ctx context.Context, state string) (GetPendingAuthOAuthRow, error) { row := q.db.QueryRow(ctx, getPendingAuthOAuth, state) var i GetPendingAuthOAuthRow err := row.Scan( &i.Did, &i.Handle, &i.Pds, &i.Issuer, &i.TokenEndpoint, &i.PkceVerifier, &i.DpopCrv, &i.DpopD, &i.DpopX, &i.DpopY, &i.DpopNonce, &i.CreatedAt, ) return i, err}
const savePendingAuthOAuth = `-- name: SavePendingAuthOAuth :execINSERT INTO oauth_pending_auths (state, did, handle, pds, issuer, token_endpoint, pkce_verifier, dpop_crv, dpop_d, dpop_x, dpop_y, dpop_nonce, created_at)VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13)ON CONFLICT (state) DO UPDATE SET did = EXCLUDED.did, handle = EXCLUDED.handle, pds = EXCLUDED.pds, issuer = EXCLUDED.issuer, token_endpoint = EXCLUDED.token_endpoint, pkce_verifier = EXCLUDED.pkce_verifier, dpop_crv = EXCLUDED.dpop_crv, dpop_d = EXCLUDED.dpop_d, dpop_x = EXCLUDED.dpop_x, dpop_y = EXCLUDED.dpop_y, dpop_nonce = EXCLUDED.dpop_nonce, created_at = EXCLUDED.created_at`
type SavePendingAuthOAuthParams struct { State string `json:"state"` Did string `json:"did"` Handle string `json:"handle"` Pds string `json:"pds"` Issuer string `json:"issuer"` TokenEndpoint string `json:"tokenEndpoint"` PkceVerifier string `json:"pkceVerifier"` DpopCrv string `json:"dpopCrv"` DpopD string `json:"dpopD"` DpopX string `json:"dpopX"` DpopY string `json:"dpopY"` DpopNonce string `json:"dpopNonce"` CreatedAt pgtype.Timestamptz `json:"createdAt"`}
func (q *Queries) SavePendingAuthOAuth(ctx context.Context, arg SavePendingAuthOAuthParams) error { _, err := q.db.Exec(ctx, savePendingAuthOAuth, arg.State, arg.Did, arg.Handle, arg.Pds, arg.Issuer, arg.TokenEndpoint, arg.PkceVerifier, arg.DpopCrv, arg.DpopD, arg.DpopX, arg.DpopY, arg.DpopNonce, arg.CreatedAt, ) return err}
const updateOAuthSessionTokens = `-- name: UpdateOAuthSessionTokens :execUPDATE oauth_sessionsSET access_token = $2, refresh_token = $3, access_token_expires_at = $4WHERE id = $1`
type UpdateOAuthSessionTokensParams struct { ID string `json:"id"` AccessToken string `json:"accessToken"` RefreshToken string `json:"refreshToken"` AccessTokenExpiresAt pgtype.Timestamptz `json:"accessTokenExpiresAt"`}
func (q *Queries) UpdateOAuthSessionTokens(ctx context.Context, arg UpdateOAuthSessionTokensParams) error { _, err := q.db.Exec(ctx, updateOAuthSessionTokens, arg.ID, arg.AccessToken, arg.RefreshToken, arg.AccessTokenExpiresAt, ) return err}