Documentation
¶
Overview ¶
Package cxp provides Go types for the FIDO Alliance Credential Exchange Protocol (CXP) v1.0.
This package implements the protocol message types for secure credential exchange between providers. It is designed to be used alongside github.com/nvinuesa/go-cxf for the Credential Exchange Format types.
See: https://fidoalliance.org/specs/cx/cxp-v1.0-wd-20241003.html
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArchiveAlgorithm ¶ added in v0.1.1
type ArchiveAlgorithm string
ArchiveAlgorithm represents an archiving algorithm for compressing credentials. See: https://fidoalliance.org/specs/cx/cxp-v1.0-wd-20240522.html#dom-archivealgorithm-deflate
const ( // ArchiveAlgorithmDeflate uses the DEFLATE algorithm defined in RFC1951. ArchiveAlgorithmDeflate ArchiveAlgorithm = "deflate" )
type CredentialType ¶
type CredentialType string
CredentialType represents a type of credential that can be exchanged.
const ( CredentialTypeBasicAuth CredentialType = "basic-auth" CredentialTypePasskey CredentialType = "passkey" CredentialTypeTotp CredentialType = "totp" CredentialTypeNote CredentialType = "note" CredentialTypeFile CredentialType = "file" CredentialTypeAddress CredentialType = "address" CredentialTypeCreditCard CredentialType = "credit-card" CredentialTypeDriverLicense CredentialType = "driver-license" CredentialTypeItemReference CredentialType = "item-reference" CredentialTypeIdentityDocument CredentialType = "identity-document" CredentialTypePassport CredentialType = "passport" CredentialTypePersonName CredentialType = "person-name" CredentialTypeSshKey CredentialType = "ssh-key" CredentialTypeApiKey CredentialType = "api-key" )
type ErrorCode ¶
type ErrorCode string
ErrorCode represents an error that occurred during credential exchange.
const ( // ErrorUserCanceled indicates that a user confirmation action was refused. ErrorUserCanceled ErrorCode = "user-canceled" // ErrorIncompatibleHpkeParameters indicates the exporter doesn't support any requested HPKE parameters. ErrorIncompatibleHpkeParameters ErrorCode = "incompatible-hpke-parameters" // ErrorMissingImporterKey indicates the importer didn't provide a required key. ErrorMissingImporterKey ErrorCode = "missing-importer-key" // ErrorIncorrectImporterKeyEncoding indicates the importer provided an invalid key. ErrorIncorrectImporterKeyEncoding ErrorCode = "incorrect-importer-key-encoding" // ErrorUnsupportedVersion indicates the exporter doesn't support the requested protocol version. ErrorUnsupportedVersion ErrorCode = "unsupported-version" // ErrorInvalidJson indicates an error occurred while parsing the JSON request. ErrorInvalidJson ErrorCode = "invalid-json" // ErrorForbiddenAction indicates the exporter refused the export due to policy. ErrorForbiddenAction ErrorCode = "forbidden-action" )
type ErrorResponse ¶
ErrorResponse is sent by the exporting provider when an error occurs.
type ExportRequest ¶
type ExportRequest struct {
Version Version `json:"version"`
Hpke []HpkeParameters `json:"hpke"`
Importer string `json:"importer"`
Archive []ArchiveAlgorithm `json:"archive,omitempty"`
CredentialTypes []CredentialType `json:"credentialTypes,omitempty"`
KnownExtensions []KnownExtension `json:"knownExtensions,omitempty"`
}
ExportRequest is sent by the importing provider to request credentials from an exporting provider.
type ExportResponse ¶
type ExportResponse struct {
Version Version `json:"version"`
Hpke HpkeParameters `json:"hpke"`
Exporter string `json:"exporter"`
Archive ArchiveAlgorithm `json:"archive,omitempty"`
Payload string `json:"payload"` // base64url encoded
}
ExportResponse is sent by the exporting provider containing encrypted credentials.
type HpkeAead ¶
type HpkeAead uint16
HpkeAead represents the HPKE AEAD cipher.
func (HpkeAead) MarshalJSON ¶
MarshalJSON implements json.Marshaler for HpkeAead.
func (*HpkeAead) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler for HpkeAead.
type HpkeKdf ¶
type HpkeKdf uint16
HpkeKdf represents the HPKE Key Derivation Function.
func (HpkeKdf) MarshalJSON ¶
MarshalJSON implements json.Marshaler for HpkeKdf.
func (*HpkeKdf) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler for HpkeKdf.
type HpkeKem ¶
type HpkeKem uint16
HpkeKem represents the HPKE Key Encapsulation Mechanism.
const ( HpkeKemReserved HpkeKem = 0x0000 HpkeKemDhP256 HpkeKem = 0x0010 HpkeKemDhP384 HpkeKem = 0x0011 HpkeKemDhP521 HpkeKem = 0x0012 HpkeKemDhCP256 HpkeKem = 0x0013 HpkeKemDhCP384 HpkeKem = 0x0014 HpkeKemDhCP521 HpkeKem = 0x0015 HpkeKemDhSecP256K1 HpkeKem = 0x0016 HpkeKemDhX25519 HpkeKem = 0x0020 HpkeKemDhX448 HpkeKem = 0x0021 HpkeKemX25519Kyber768Draft00 HpkeKem = 0x0030 )
func (HpkeKem) MarshalJSON ¶
MarshalJSON implements json.Marshaler for HpkeKem.
func (*HpkeKem) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler for HpkeKem.
type HpkeParameters ¶
type HpkeParameters struct {
Mode HpkeMode `json:"mode"`
Kem HpkeKem `json:"kem"`
Kdf HpkeKdf `json:"kdf"`
Aead HpkeAead `json:"aead"`
Key json.RawMessage `json:"key,omitempty"` // JWK
}
HpkeParameters defines the HPKE configuration for encryption.
func (HpkeParameters) Equal ¶
func (h HpkeParameters) Equal(other HpkeParameters) bool
Equal compares two HpkeParameters, ignoring the Key field (which is ephemeral).
type KnownExtension ¶
type KnownExtension string
KnownExtension represents a known protocol extension.
const ( KnownExtensionShared KnownExtension = "shared" )
type Version ¶
type Version uint8
Version represents the protocol version.
const ( // VersionV0 is the current protocol version. VersionV0 Version = 0 )
func (Version) MarshalJSON ¶
MarshalJSON implements json.Marshaler for Version.
func (*Version) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler for Version.