2026-08-26 06:41:07 +08:00
|
|
|
package deviceauth
|
|
|
|
|
|
|
|
|
|
import "context"
|
|
|
|
|
|
|
|
|
|
type contextKey string
|
|
|
|
|
|
|
|
|
|
const identityKey contextKey = "device-identity"
|
|
|
|
|
|
|
|
|
|
type Identity struct {
|
2026-09-12 08:57:29 +08:00
|
|
|
EnrollmentMode string
|
|
|
|
|
BindingGeneration int64
|
|
|
|
|
ActivationTest bool
|
2026-09-06 17:04:11 +08:00
|
|
|
ID string
|
|
|
|
|
PublicID string
|
|
|
|
|
TenantID string
|
|
|
|
|
Status string
|
|
|
|
|
ActivationState string
|
|
|
|
|
VoiceRuntime string
|
|
|
|
|
HardwareLicenseReady bool
|
|
|
|
|
CredentialRef string
|
2026-08-26 06:41:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func WithIdentity(ctx context.Context, identity Identity) context.Context {
|
|
|
|
|
return context.WithValue(ctx, identityKey, identity)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func FromContext(ctx context.Context) (Identity, bool) {
|
|
|
|
|
identity, ok := ctx.Value(identityKey).(Identity)
|
|
|
|
|
return identity, ok
|
|
|
|
|
}
|