-
Notifications
You must be signed in to change notification settings - Fork 0
/
attestation.go
33 lines (28 loc) · 1.1 KB
/
attestation.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
package webauthn
import (
"github.com/spiretechnology/go-webauthn/internal/errutil"
"github.com/spiretechnology/go-webauthn/pkg/codec"
"github.com/spiretechnology/go-webauthn/pkg/spec"
)
// AuthenticatorAttestationResponse is the internal response value send by the client in response to a registration ceremony.
type AuthenticatorAttestationResponse struct {
ClientDataJSON string `json:"clientDataJSON"`
AttestationObject string `json:"attestationObject"`
}
func (a *AuthenticatorAttestationResponse) Decode(c codec.Codec) (*spec.AuthenticatorAttestationResponse, error) {
// Decode the clientDataJSON
clientDataJSONBytes, err := c.DecodeString(a.ClientDataJSON)
if err != nil {
return nil, errutil.Wrapf(err, "decoding clientDataJSON")
}
// Decode the attestationObject
attestationObjectBytes, err := c.DecodeString(a.AttestationObject)
if err != nil {
return nil, errutil.Wrapf(err, "decoding attestationObject")
}
// Wrap it in the spec type
return &spec.AuthenticatorAttestationResponse{
ClientDataJSON: clientDataJSONBytes,
AttestationObjectCBOR: attestationObjectBytes,
}, nil
}