-
Notifications
You must be signed in to change notification settings - Fork 28
/
passkey_authenticator.go
36 lines (31 loc) · 1.18 KB
/
passkey_authenticator.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package authenticator
import (
"time"
"github.com/authgear/authgear-server/pkg/api/model"
)
type Passkey struct {
ID string `json:"id"`
UserID string `json:"user_id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Kind string `json:"kind"`
IsDefault bool `json:"is_default"`
CredentialID string `json:"credential_id"`
CreationOptions *model.WebAuthnCreationOptions `json:"creation_options,omitempty"`
AttestationResponse []byte `json:"attestation_response,omitempty"`
// SignCount of 0 means sign count is not supported by the authenticator.
// So we do not include omitempty here.
SignCount int64 `json:"sign_count"`
}
func (a *Passkey) ToInfo() *Info {
return &Info{
ID: a.ID,
UserID: a.UserID,
CreatedAt: a.CreatedAt,
UpdatedAt: a.UpdatedAt,
Type: model.AuthenticatorTypePasskey,
Kind: Kind(a.Kind),
IsDefault: a.IsDefault,
Passkey: a,
}
}