package webauthn
import (
"fmt"
"github.com/mailru/easyjson"
"github.com/mailru/easyjson/jlexer"
"github.com/mailru/easyjson/jwriter"
)
type AuthenticatorID string
func (t AuthenticatorID ) String () string {
return string (t )
}
type AuthenticatorProtocol string
func (t AuthenticatorProtocol ) String () string {
return string (t )
}
const (
AuthenticatorProtocolU2f AuthenticatorProtocol = "u2f"
AuthenticatorProtocolCtap2 AuthenticatorProtocol = "ctap2"
)
func (t AuthenticatorProtocol ) MarshalEasyJSON (out *jwriter .Writer ) {
out .String (string (t ))
}
func (t AuthenticatorProtocol ) MarshalJSON () ([]byte , error ) {
return easyjson .Marshal (t )
}
func (t *AuthenticatorProtocol ) UnmarshalEasyJSON (in *jlexer .Lexer ) {
v := in .String ()
switch AuthenticatorProtocol (v ) {
case AuthenticatorProtocolU2f :
*t = AuthenticatorProtocolU2f
case AuthenticatorProtocolCtap2 :
*t = AuthenticatorProtocolCtap2
default :
in .AddError (fmt .Errorf ("unknown AuthenticatorProtocol value: %v" , v ))
}
}
func (t *AuthenticatorProtocol ) UnmarshalJSON (buf []byte ) error {
return easyjson .Unmarshal (buf , t )
}
type Ctap2version string
func (t Ctap2version ) String () string {
return string (t )
}
const (
Ctap2versionCtap20 Ctap2version = "ctap2_0"
Ctap2versionCtap21 Ctap2version = "ctap2_1"
)
func (t Ctap2version ) MarshalEasyJSON (out *jwriter .Writer ) {
out .String (string (t ))
}
func (t Ctap2version ) MarshalJSON () ([]byte , error ) {
return easyjson .Marshal (t )
}
func (t *Ctap2version ) UnmarshalEasyJSON (in *jlexer .Lexer ) {
v := in .String ()
switch Ctap2version (v ) {
case Ctap2versionCtap20 :
*t = Ctap2versionCtap20
case Ctap2versionCtap21 :
*t = Ctap2versionCtap21
default :
in .AddError (fmt .Errorf ("unknown Ctap2version value: %v" , v ))
}
}
func (t *Ctap2version ) UnmarshalJSON (buf []byte ) error {
return easyjson .Unmarshal (buf , t )
}
type AuthenticatorTransport string
func (t AuthenticatorTransport ) String () string {
return string (t )
}
const (
AuthenticatorTransportUsb AuthenticatorTransport = "usb"
AuthenticatorTransportNfc AuthenticatorTransport = "nfc"
AuthenticatorTransportBle AuthenticatorTransport = "ble"
AuthenticatorTransportCable AuthenticatorTransport = "cable"
AuthenticatorTransportInternal AuthenticatorTransport = "internal"
)
func (t AuthenticatorTransport ) MarshalEasyJSON (out *jwriter .Writer ) {
out .String (string (t ))
}
func (t AuthenticatorTransport ) MarshalJSON () ([]byte , error ) {
return easyjson .Marshal (t )
}
func (t *AuthenticatorTransport ) UnmarshalEasyJSON (in *jlexer .Lexer ) {
v := in .String ()
switch AuthenticatorTransport (v ) {
case AuthenticatorTransportUsb :
*t = AuthenticatorTransportUsb
case AuthenticatorTransportNfc :
*t = AuthenticatorTransportNfc
case AuthenticatorTransportBle :
*t = AuthenticatorTransportBle
case AuthenticatorTransportCable :
*t = AuthenticatorTransportCable
case AuthenticatorTransportInternal :
*t = AuthenticatorTransportInternal
default :
in .AddError (fmt .Errorf ("unknown AuthenticatorTransport value: %v" , v ))
}
}
func (t *AuthenticatorTransport ) UnmarshalJSON (buf []byte ) error {
return easyjson .Unmarshal (buf , t )
}
type VirtualAuthenticatorOptions struct {
Protocol AuthenticatorProtocol `json:"protocol"`
Ctap2version Ctap2version `json:"ctap2Version,omitempty"`
Transport AuthenticatorTransport `json:"transport"`
HasResidentKey bool `json:"hasResidentKey,omitempty"`
HasUserVerification bool `json:"hasUserVerification,omitempty"`
HasLargeBlob bool `json:"hasLargeBlob,omitempty"`
HasCredBlob bool `json:"hasCredBlob,omitempty"`
HasMinPinLength bool `json:"hasMinPinLength,omitempty"`
HasPrf bool `json:"hasPrf,omitempty"`
AutomaticPresenceSimulation bool `json:"automaticPresenceSimulation,omitempty"`
IsUserVerified bool `json:"isUserVerified,omitempty"`
}
type Credential struct {
CredentialID string `json:"credentialId"`
IsResidentCredential bool `json:"isResidentCredential"`
RpID string `json:"rpId,omitempty"`
PrivateKey string `json:"privateKey"`
UserHandle string `json:"userHandle,omitempty"`
SignCount int64 `json:"signCount"`
LargeBlob string `json:"largeBlob,omitempty"`
}
The pages are generated with Golds v0.8.2 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .