All import paths updated to git.wntrmute.dev/mc/. Bumps mcdsl to v1.2.0. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
20 lines
632 B
Go
20 lines
632 B
Go
package auth
|
|
|
|
import "context"
|
|
|
|
// contextKey is an unexported type used as the context key for TokenInfo,
|
|
// preventing collisions with keys from other packages.
|
|
type contextKey struct{}
|
|
|
|
// ContextWithTokenInfo returns a new context carrying the given TokenInfo.
|
|
func ContextWithTokenInfo(ctx context.Context, info *TokenInfo) context.Context {
|
|
return context.WithValue(ctx, contextKey{}, info)
|
|
}
|
|
|
|
// TokenInfoFromContext extracts TokenInfo from the context. It returns nil
|
|
// if no TokenInfo is present.
|
|
func TokenInfoFromContext(ctx context.Context) *TokenInfo {
|
|
info, _ := ctx.Value(contextKey{}).(*TokenInfo)
|
|
return info
|
|
}
|