transport

package
v1.37.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package transport contains the JSON wire-format counterparts of the webauthn package's domain types, with base64url-encoded binary fields, and the conversions from wire format to parsed domain values.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollectedClientDataFromBytes

func CollectedClientDataFromBytes(data []byte) (*webauthn.CollectedClientData, error)

CollectedClientDataFromBytes parses raw clientDataJSON into domain client data.

func MakeAssertionPublicKeyCredential

func MakeAssertionPublicKeyCredential(
	transportCredential *AssertionPublicKeyCredential,
) (*webauthn.AssertionPublicKeyCredential, error)

MakeAssertionPublicKeyCredential converts a wire-format authentication credential into its parsed domain counterpart.

func MakeAttestationPublicKeyCredential

func MakeAttestationPublicKeyCredential(
	transportCredential *AttestationPublicKeyCredential,
) (*webauthn.AttestationPublicKeyCredential, error)

MakeAttestationPublicKeyCredential converts a wire-format registration credential into its parsed domain counterpart.

Types

type AuthenticatorAssertionResponse

type AuthenticatorAssertionResponse struct {
	ClientDataJson    *Base64URL `json:"clientDataJSON"`
	AuthenticatorData *Base64URL `json:"authenticatorData"`
	Signature         *Base64URL `json:"signature"`
	// NOTE: Not required in spec, but I don't see why it mustn't be.
	UserHandle *Base64URL `json:"userHandle"`
}

AuthenticatorAssertionResponse is the wire format of an authentication ceremony response (WebAuthn §5.2.2).

func (AuthenticatorAssertionResponse) GetAuthenticatorData

func (t AuthenticatorAssertionResponse) GetAuthenticatorData() []byte

func (AuthenticatorAssertionResponse) GetClientDataJson

func (t AuthenticatorAssertionResponse) GetClientDataJson() []byte

func (AuthenticatorAssertionResponse) MakeAuthenticatorResponse

type AuthenticatorAttestationResponse

type AuthenticatorAttestationResponse struct {
	ClientDataJson    *Base64URL `json:"clientDataJSON"`
	Transports        []string   `json:"transports"`
	AttestationObject *Base64URL `json:"attestationObject"`

	AuthenticatorData  *Base64URL `json:"authenticatorData,omitzero"`
	PublicKey          *Base64URL `json:"publicKey,omitzero"`
	PublicKeyAlgorithm int        `json:"publicKeyAlgorithm,omitzero"`
}

AuthenticatorAttestationResponse is the wire format of a registration ceremony response (WebAuthn §5.2.1). The authoritative credential public key is the COSE key within the attestation object; the client-derived authenticatorData, publicKey, and publicKeyAlgorithm convenience fields are optional and cross-checked against it when present.

func (AuthenticatorAttestationResponse) GetAuthenticatorData

func (t AuthenticatorAttestationResponse) GetAuthenticatorData() []byte

func (AuthenticatorAttestationResponse) GetClientDataJson

func (t AuthenticatorAttestationResponse) GetClientDataJson() []byte

func (AuthenticatorAttestationResponse) MakeAuthenticatorResponse

type Base64URL

type Base64URL []byte

Base64URL is a byte string that is JSON-encoded as unpadded base64url.

func (*Base64URL) MarshalJSON

func (b *Base64URL) MarshalJSON() ([]byte, error)

func (*Base64URL) UnmarshalJSON

func (b *Base64URL) UnmarshalJSON(data []byte) error

type CollectedClientData

type CollectedClientData struct {
	Type        string     `json:"type"`
	Challenge   *Base64URL `json:"challenge"`
	Origin      string     `json:"origin"`
	CrossOrigin bool       `json:"crossOrigin,omitzero"`
	// TopOrigin is not part of the specification, but is sent by clients.
	TopOrigin string `json:"topOrigin,omitzero"`
}

CollectedClientData is the wire format of clientDataJSON (WebAuthn §5.8.1).

type PublicKeyCredential

type PublicKeyCredential[T AuthenticatorAttestationResponse | AuthenticatorAssertionResponse] struct {
	Id              *Base64URL     `json:"id"`
	Type            string         `json:"type"`
	RawId           *Base64URL     `json:"rawId"`
	Response        T              `json:"response"`
	ClientExtension map[string]any `json:"clientExtension,omitzero"`
}

PublicKeyCredential is the wire format of a credential from a navigator.credentials call (WebAuthn §5.1).

type PublicKeyCredentialCreationOptions

type PublicKeyCredentialCreationOptions struct {
	RelyingParty *webauthn.RelyingParty         `json:"rp"`
	User         *PublicKeyCredentialUserEntity `json:"user"`

	Challenge        *Base64URL                           `json:"challenge"`
	PubKeyCredParams []*webauthn.PublicKeyCredentialParam `json:"pubKeyCredParams"`

	Timeout                uint64                                    `json:"timeout,omitzero"`
	ExcludeCredentials     []*webauthn.PublicKeyCredentialDescriptor `json:"excludeCredentials,omitzero"`
	AuthenticatorSelection *webauthn.AuthenticatorSelection          `json:"authenticatorSelection,omitzero"`
	Attestation            string                                    `json:"attestation,omitzero"`
	Extensions             map[string]any                            `json:"extensions,omitzero"`
}

PublicKeyCredentialCreationOptions is the wire format of registration ceremony options (WebAuthn §5.4).

type PublicKeyCredentialRequestOptions

type PublicKeyCredentialRequestOptions struct {
	Challenge          *Base64URL                                `json:"challenge"`
	Timeout            uint64                                    `json:"timeout,omitzero"`
	RpId               string                                    `json:"rpId,omitzero"`
	AllowedCredentials []*webauthn.PublicKeyCredentialDescriptor `json:"allowedCredentials,omitzero"`
	UserVerification   string                                    `json:"userVerification,omitzero"`
	Extensions         map[string]any                            `json:"extensions,omitzero"`
}

PublicKeyCredentialRequestOptions is the wire format of authentication ceremony options (WebAuthn §5.5).

type PublicKeyCredentialUserEntity

type PublicKeyCredentialUserEntity struct {
	Name        string     `json:"name"`
	Id          *Base64URL `json:"id"`
	DisplayName string     `json:"displayName"`
}

PublicKeyCredentialUserEntity is the wire format of a user entity (WebAuthn §5.4.3).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL