owpengram-server/internal/store/temp_auth_key.go
2026-09-01 12:06:31 +03:00

26 lines
1.3 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package store
import (
"context"
"errors"
"telesrv/internal/domain"
)
// ErrTempAuthKeyAlreadyBound 表示同一 temporary key 已绑定到另一个 permanent key。
// temp key 的 canonical identity 在首次 bind 后不可漂移,重放同一绑定才允许幂等成功。
var ErrTempAuthKeyAlreadyBound = errors.New("temporary auth key already bound")
// TempAuthKeyBindingStore 持久化 auth.bindTempAuthKey 的 temp→perm 绑定。
type TempAuthKeyBindingStore interface {
Save(ctx context.Context, binding domain.TempAuthKeyBinding) error
// SaveWithState performs the same write and returns the exact Layer tuple
// committed under the identity/key locks. Callers must use this result rather
// than issuing a post-commit confirmation read.
SaveWithState(ctx context.Context, binding domain.TempAuthKeyBinding) (domain.TempAuthKeyBindingResult, error)
GetByTemp(ctx context.Context, tempAuthKeyID [8]byte) (domain.TempAuthKeyBinding, bool, error)
// DeleteExpired 以 auth_keys 的握手协议 expiry 为唯一事实源,回收早于
// expiredBeforeunix 秒)的 temporary key单次最多 limit 条并返回 key 数。
// 未绑定与已绑定的 PFS key 必须走同一路径;绑定经 ON DELETE CASCADE 清除。
DeleteExpired(ctx context.Context, expiredBefore int64, limit int) (int, error)
}