{"modulePath":"github.com/bitechdev/ResolveSpec","version":"v1.3.14","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package procedure\n\nPackage procedure is the stored-procedure backend of lookup: it calls the resolvespec\\_\\* functions (names from lookup.ProcNames) and keeps their p\\_success / p\\_error / p\\_data contract. Error texts match the ones the security package returned before the extraction.\n\n## Functions\n\n```go\nfunc IsClosed(err error) bool\n```\nIsClosed reports whether err indicates the \\*sql.DB has been closed.\n\n## Types\n\n```go\ntype Auth struct {\n\t// contains filtered or unexported fields\n}\n```\nAuth implements lookup.AuthStore with stored procedures.\n\n```go\nfunc NewAuth(run Runner, procs lookup.ProcNames) *Auth\n```\nNewAuth creates the procedure-backed AuthStore.\n\n```go\nfunc (a *Auth) JWTLogin(ctx context.Context, req sectypes.LoginRequest) (*sectypes.LoginResponse, error)\n```\nJWTLogin implements lookup.AuthStore. The password is verified inside the procedure; the hash is never returned. The token is a placeholder until JWT signing is wired in.\n\n```go\nfunc (a *Auth) JWTLogout(ctx context.Context, req sectypes.LogoutRequest) error\n```\nJWTLogout implements lookup.AuthStore.\n\n```go\nfunc (a *Auth) Login(ctx context.Context, req sectypes.LoginRequest) (*sectypes.LoginResponse, error)\n```\nLogin implements lookup.AuthStore.\n\n```go\nfunc (a *Auth) LoginAPIKey(ctx context.Context, rawKey string, claims map[string]any) (*sectypes.LoginResponse, error)\n```\nLoginAPIKey implements lookup.AuthStore. Unknown, expired and inactive keys all return lookup.ErrInvalidAPIKey; the raw key is never logged.\n\n```go\nfunc (a *Auth) Logout(ctx context.Context, req sectypes.LogoutRequest) error\n```\nLogout implements lookup.AuthStore.\n\n```go\nfunc (a *Auth) Refresh(ctx context.Context, refreshToken string) (*sectypes.LoginResponse, error)\n```\nRefresh implements lookup.AuthStore.\n\n```go\nfunc (a *Auth) Register(ctx context.Context, req sectypes.RegisterRequest) (*sectypes.LoginResponse, error)\n```\nRegister implements lookup.AuthStore.\n\n```go\nfunc (a *Auth) ResetComplete(ctx context.Context, req sectypes.PasswordResetCompleteRequest) error\n```\nResetComplete implements lookup.AuthStore.\n\n```go\nfunc (a *Auth) ResetRequest(ctx context.Context, req sectypes.PasswordResetRequest) (*sectypes.PasswordResetResponse, error)\n```\nResetRequest implements lookup.AuthStore.\n\n```go\nfunc (a *Auth) Session(ctx context.Context, token, reference string) (*sectypes.UserContext, error)\n```\nSession implements lookup.AuthStore.\n\n```go\nfunc (a *Auth) TouchSession(ctx context.Context, token string, user *sectypes.UserContext) error\n```\nTouchSession implements lookup.AuthStore.\n\n```go\ntype DB struct {\n\t// contains filtered or unexported fields\n}\n```\nDB is a standalone Runner over a \\*sql.DB with an optional reconnect factory.\n\n```go\nfunc NewDB(db *sql.DB, factory func() (*sql.DB, error), onReconnect func()) *DB\n```\nNewDB wraps db. factory (optional) is called to obtain a fresh handle when the current one is closed; onReconnect (optional) runs after a successful reconnect, e.g. to reset cached procedure probes.\n\n```go\nfunc (d *DB) Get() *sql.DB\n```\nGet returns the current handle.\n\n```go\nfunc (d *DB) Run(run func(*sql.DB) error) error\n```\nRun implements Runner.\n\n```go\ntype Keys struct {\n\t// contains filtered or unexported fields\n}\n```\nKeys implements lookup.KeyStore with the resolvespec\\_keystore\\_\\* procedures.\n\n```go\nfunc NewKeys(run Runner, procs lookup.ProcNames) *Keys\n```\nNewKeys creates the procedure-backed KeyStore.\n\n```go\nfunc (k *Keys) Create(ctx context.Context, req sectypes.CreateKeyRequest, keyHash string) (*sectypes.UserKey, error)\n```\nCreate implements lookup.KeyStore.\n\n```go\nfunc (k *Keys) Delete(ctx context.Context, userID int, keyID int64) (string, error)\n```\nDelete implements lookup.KeyStore. The procedure returns the key hash.\n\n```go\nfunc (k *Keys) List(ctx context.Context, userID int, keyType sectypes.KeyType) ([]sectypes.UserKey, error)\n```\nList implements lookup.KeyStore.\n\n```go\nfunc (k *Keys) Validate(ctx context.Context, keyHash string, keyType sectypes.KeyType) (*sectypes.UserKey, error)\n```\nValidate implements lookup.KeyStore.\n\n```go\ntype OAuthClients struct {\n\t// contains filtered or unexported fields\n}\n```\nOAuthClients implements lookup.OAuthClientStore with the resolvespec\\_oauth\\_\\* server procedures.\n\n```go\nfunc NewOAuthClients(run Runner, procs lookup.ProcNames) *OAuthClients\n```\nNewOAuthClients creates the procedure-backed OAuthClientStore.\n\n```go\nfunc (o *OAuthClients) DeleteClient(ctx context.Context, clientID string) error\n```\nDeleteClient implements lookup.OAuthClientStore.\n\n```go\nfunc (o *OAuthClients) ExchangeCode(ctx context.Context, code string) (*sectypes.OAuthCode, error)\n```\nExchangeCode implements lookup.OAuthClientStore.\n\n```go\nfunc (o *OAuthClients) GetClient(ctx context.Context, clientID string) (*sectypes.OAuthServerClient, error)\n```\nGetClient implements lookup.OAuthClientStore.\n\n```go\nfunc (o *OAuthClients) Introspect(ctx context.Context, token string) (*sectypes.OAuthTokenInfo, error)\n```\nIntrospect implements lookup.OAuthClientStore.\n\n```go\nfunc (o *OAuthClients) RegisterClient(ctx context.Context, client *sectypes.OAuthServerClient) (*sectypes.OAuthServerClient, error)\n```\nRegisterClient implements lookup.OAuthClientStore.\n\n```go\nfunc (o *OAuthClients) Revoke(ctx context.Context, token string) error\n```\nRevoke implements lookup.OAuthClientStore.\n\n```go\nfunc (o *OAuthClients) SaveCode(ctx context.Context, code *sectypes.OAuthCode) error\n```\nSaveCode implements lookup.OAuthClientStore.\n\n```go\nfunc (o *OAuthClients) UpdateClient(ctx context.Context, client *sectypes.OAuthServerClient) error\n```\nUpdateClient implements lookup.OAuthClientStore.\n\n```go\ntype OAuthGrants struct {\n\t// contains filtered or unexported fields\n}\n```\nOAuthGrants implements lookup.OAuthGrantStore with the resolvespec\\_oauth\\_\\* grant procedures. Every procedure takes one jsonb request and returns (p\\_success, p\\_error, p\\_data). A failure that maps to a lookup sentinel carries a stable code in p\\_error (see the grantErrors table).\n\n```go\nfunc NewOAuthGrants(run Runner, procs lookup.ProcNames) *OAuthGrants\n```\nNewOAuthGrants creates the procedure-backed OAuthGrantStore.\n\n```go\nfunc (o *OAuthGrants) ConsumePushedRequest(ctx context.Context, requestURI string) (*lookup.PushedRequest, error)\n```\nConsumePushedRequest implements lookup.OAuthGrantStore.\n\n```go\nfunc (o *OAuthGrants) CreateDevice(ctx context.Context, d lookup.DeviceCode) error\n```\nCreateDevice implements lookup.OAuthGrantStore.\n\n```go\nfunc (o *OAuthGrants) DeviceByUserCode(ctx context.Context, userCode string) (*lookup.DeviceCode, error)\n```\nDeviceByUserCode implements lookup.OAuthGrantStore.\n\n```go\nfunc (o *OAuthGrants) DeviceDecide(ctx context.Context, userCode string, approve bool, userID int, sessionToken string) error\n```\nDeviceDecide implements lookup.OAuthGrantStore.\n\n```go\nfunc (o *OAuthGrants) DevicePoll(ctx context.Context, deviceHash string) (*lookup.DeviceCode, error)\n```\nDevicePoll implements lookup.OAuthGrantStore.\n\n```go\nfunc (o *OAuthGrants) GetConsent(ctx context.Context, userID int, clientID string) (*lookup.Consent, error)\n```\nGetConsent implements lookup.OAuthGrantStore.\n\n```go\nfunc (o *OAuthGrants) PeekRefresh(ctx context.Context, hash string) (*lookup.RefreshToken, error)\n```\nPeekRefresh implements lookup.OAuthGrantStore.\n\n```go\nfunc (o *OAuthGrants) RevokeConsent(ctx context.Context, userID int, clientID string) error\n```\nRevokeConsent implements lookup.OAuthGrantStore.\n\n```go\nfunc (o *OAuthGrants) RevokeRefreshBySession(ctx context.Context, sessionToken string) error\n```\nRevokeRefreshBySession implements lookup.OAuthGrantStore.\n\n```go\nfunc (o *OAuthGrants) RevokeRefreshFamily(ctx context.Context, familyID string) error\n```\nRevokeRefreshFamily implements lookup.OAuthGrantStore.\n\n```go\nfunc (o *OAuthGrants) RotateRefresh(ctx context.Context, oldHash string, next lookup.RefreshToken) (*lookup.RefreshToken, error)\n```\nRotateRefresh implements lookup.OAuthGrantStore.\n\n```go\nfunc (o *OAuthGrants) SaveConsent(ctx context.Context, c lookup.Consent) error\n```\nSaveConsent implements lookup.OAuthGrantStore.\n\n```go\nfunc (o *OAuthGrants) SavePushedRequest(ctx context.Context, r lookup.PushedRequest) error\n```\nSavePushedRequest implements lookup.OAuthGrantStore.\n\n```go\nfunc (o *OAuthGrants) SaveRefresh(ctx context.Context, t lookup.RefreshToken) error\n```\nSaveRefresh implements lookup.OAuthGrantStore.\n\n```go\nfunc (o *OAuthGrants) SeenJTI(ctx context.Context, key string, expires time.Time) (bool, error)\n```\nSeenJTI implements lookup.OAuthGrantStore.\n\n```go\ntype OAuthUsers struct {\n\t// contains filtered or unexported fields\n}\n```\nOAuthUsers implements lookup.OAuthUserStore with the resolvespec\\_oauth\\_\\* procedures.\n\n```go\nfunc NewOAuthUsers(run Runner, procs lookup.ProcNames) *OAuthUsers\n```\nNewOAuthUsers creates the procedure-backed OAuthUserStore.\n\n```go\nfunc (o *OAuthUsers) CreateSession(ctx context.Context, s lookup.OAuthSession) error\n```\nCreateSession implements lookup.OAuthUserStore.\n\n```go\nfunc (o *OAuthUsers) GetByRefreshToken(ctx context.Context, refreshToken string) (*lookup.OAuthRefreshSession, error)\n```\nGetByRefreshToken implements lookup.OAuthUserStore.\n\n```go\nfunc (o *OAuthUsers) GetOrCreateUser(ctx context.Context, user *sectypes.UserContext, provider string) (int, error)\n```\nGetOrCreateUser implements lookup.OAuthUserStore.\n\n```go\nfunc (o *OAuthUsers) GetUser(ctx context.Context, userID int) (*sectypes.UserContext, error)\n```\nGetUser implements lookup.OAuthUserStore.\n\n```go\nfunc (o *OAuthUsers) UpdateRefreshToken(ctx context.Context, userID int, oldRefreshToken, newSessionToken, newAccessToken, newRefreshToken string, expiresAt time.Time) error\n```\nUpdateRefreshToken implements lookup.OAuthUserStore.\n\n```go\ntype Passkey struct {\n\t// contains filtered or unexported fields\n}\n```\nPasskey implements lookup.PasskeyStore with the resolvespec\\_passkey\\_\\* procedures. Credential ids cross the lookup interface as base64 text; the procedures that take a bytea credential id receive the decoded bytes.\n\n```go\nfunc NewPasskey(run Runner, procs lookup.ProcNames) *Passkey\n```\nNewPasskey creates the procedure-backed PasskeyStore.\n\n```go\nfunc (p *Passkey) ByUsername(ctx context.Context, username string) (int, []lookup.PasskeyCredentialRef, error)\n```\nByUsername implements lookup.PasskeyStore.\n\n```go\nfunc (p *Passkey) Delete(ctx context.Context, userID int, credentialID string) error\n```\nDelete implements lookup.PasskeyStore.\n\n```go\nfunc (p *Passkey) Get(ctx context.Context, credentialID string) (userID int, signCount uint32, err error)\n```\nGet implements lookup.PasskeyStore.\n\n```go\nfunc (p *Passkey) List(ctx context.Context, userID int) ([]sectypes.PasskeyCredential, error)\n```\nList implements lookup.PasskeyStore.\n\n```go\nfunc (p *Passkey) Login(ctx context.Context, userID int, claims map[string]any) (*sectypes.LoginResponse, error)\n```\nLogin implements lookup.PasskeyStore: it creates the session for a user whose passkey assertion was already verified.\n\n```go\nfunc (p *Passkey) Rename(ctx context.Context, userID int, credentialID, name string) error\n```\nRename implements lookup.PasskeyStore.\n\n```go\nfunc (p *Passkey) Store(ctx context.Context, rec lookup.PasskeyCredentialRecord) (int64, error)\n```\nStore implements lookup.PasskeyStore.\n\n```go\nfunc (p *Passkey) UpdateCounter(ctx context.Context, credentialID string, newCounter uint32) (bool, error)\n```\nUpdateCounter implements lookup.PasskeyStore. Like the code it replaces, it only reports an error when the query itself fails; the procedure's success flag is not checked.\n\n```go\ntype Policy struct {\n\t// contains filtered or unexported fields\n}\n```\nPolicy implements lookup.PolicyStore with the column and row security procedures.\n\n```go\nfunc NewPolicy(run Runner, procs lookup.ProcNames) *Policy\n```\nNewPolicy creates the procedure-backed PolicyStore.\n\n```go\nfunc (p *Policy) ColumnSecurity(ctx context.Context, userID int, schema, table string) ([]sectypes.ColumnSecurity, error)\n```\nColumnSecurity implements lookup.PolicyStore.\n\n```go\nfunc (p *Policy) RowSecurity(ctx context.Context, userRef any, schema, table string) (sectypes.RowSecurity, error)\n```\nRowSecurity implements lookup.PolicyStore. userRef is unwrapped to a scalar user id because the procedure's p\\_user\\_id is an integer.\n\n```go\ntype RunFunc func(run func(*sql.DB) error) error\n```\nRunFunc adapts a function to Runner. The security package passes its own reconnecting helper this way.\n\n```go\nfunc (f RunFunc) Run(run func(*sql.DB) error) error\n```\nRun implements Runner.\n\n```go\ntype Runner interface {\n\tRun(run func(*sql.DB) error) error\n}\n```\nRunner runs a database operation, reconnecting once when the \\*sql.DB has been closed.\n\n```go\ntype TOTP struct {\n\t// contains filtered or unexported fields\n}\n```\nTOTP implements lookup.TOTPStore with the resolvespec\\_totp\\_\\* procedures.\n\n```go\nfunc NewTOTP(run Runner, procs lookup.ProcNames) *TOTP\n```\nNewTOTP creates the procedure-backed TOTPStore.\n\n```go\nfunc (t *TOTP) Disable(ctx context.Context, userID int) error\n```\nDisable implements lookup.TOTPStore.\n\n```go\nfunc (t *TOTP) Enable(ctx context.Context, userID int, secret string, hashedCodes []string) error\n```\nEnable implements lookup.TOTPStore.\n\n```go\nfunc (t *TOTP) RegenerateBackupCodes(ctx context.Context, userID int, hashedCodes []string) error\n```\nRegenerateBackupCodes implements lookup.TOTPStore.\n\n```go\nfunc (t *TOTP) Secret(ctx context.Context, userID int) (string, error)\n```\nSecret implements lookup.TOTPStore.\n\n```go\nfunc (t *TOTP) Status(ctx context.Context, userID int) (bool, error)\n```\nStatus implements lookup.TOTPStore.\n\n```go\nfunc (t *TOTP) ValidateBackupCode(ctx context.Context, userID int, codeHash string) (bool, error)\n```\nValidateBackupCode implements lookup.TOTPStore. A failure without a message means \"not valid\", not an error.\n\n","path":"github.com/bitechdev/ResolveSpec/pkg/security/lookup/procedure","name":"procedure","synopsis":"Package procedure is the stored-procedure backend of lookup: it calls the resolvespec_* functions (names from lookup.ProcNames) and keeps their p_success / p_error / p_data contract.","isRedistributable":true}
