go-client icon indicating copy to clipboard operation
go-client copied to clipboard

CoseAlgorithmIdentifier is typed as a string but the API returns integers

Open germainc opened this issue 2 years ago • 0 comments

API response from /api/webauthn/register/start:

{
  "options": { 
    "pubKeyCredParams": [
      {
        "alg": -36,
        "type": "public-key"
      },
      {
        "alg": -35,
        "type": "public-key"
      },
    ...
  }
}

Golang type:

type PublicKeyCredentialParameters struct {
	Alg  CoseAlgorithmIdentifier `json:"alg,omitempty"`
	Type PublicKeyCredentialType `json:"type,omitempty"`
}

...

type CoseAlgorithmIdentifier string

func (e CoseAlgorithmIdentifier) String() string {
	return string(e)
}

const (
	CoseAlgorithmIdentifier_ES256 CoseAlgorithmIdentifier = "ES256"
	CoseAlgorithmIdentifier_ES384 CoseAlgorithmIdentifier = "ES384"
	CoseAlgorithmIdentifier_ES512 CoseAlgorithmIdentifier = "ES512"
	CoseAlgorithmIdentifier_RS256 CoseAlgorithmIdentifier = "RS256"
	CoseAlgorithmIdentifier_RS384 CoseAlgorithmIdentifier = "RS384"
	CoseAlgorithmIdentifier_RS512 CoseAlgorithmIdentifier = "RS512"
	CoseAlgorithmIdentifier_PS256 CoseAlgorithmIdentifier = "PS256"
	CoseAlgorithmIdentifier_PS384 CoseAlgorithmIdentifier = "PS384"
	CoseAlgorithmIdentifier_PS512 CoseAlgorithmIdentifier = "PS512"
)

Error:

cannot unmarshal number into Go struct field PublicKeyCredentialParameters.options.pubKeyCredParams.alg of type fusionauth.CoseAlgorithmIdentifier

germainc avatar Jul 25 '23 20:07 germainc