Documentation
¶
Overview ¶
Package cxf reads and writes CXF 1.0 documents. It models and validates all credential types defined by CXF 1.0. Unknown credential types remain raw JSON.
Index ¶
- Constants
- Variables
- func CredentialTypeOf(raw json.RawMessage) (string, error)
- func Encode(w io.Writer, header *Header) error
- func ValidateCredential(data []byte) error
- type APIKey
- type Account
- type Address
- type AndroidAppCertificateFingerprint
- type AndroidAppID
- type BasicAuth
- type Collection
- type CredentialScope
- type CreditCard
- type CustomFields
- type DriversLicense
- type EditableField
- type FIDO2Extensions
- type FIDO2HMACCredentials
- type FIDO2LargeBlob
- type File
- type GeneratedPassword
- type Header
- type IdentityDocument
- type Item
- type ItemReference
- type LinkedItem
- type Note
- type Passkey
- type Passport
- type PersonName
- type SSHKey
- type Shared
- type SharingAccessor
- type SharingAccessorPermission
- type SharingAccessorType
- type TOTP
- type ValidationError
- type Version
- type WiFi
Examples ¶
Constants ¶
const CredentialTypeAPIKey = "api-key"
CredentialTypeAPIKey is the CXF API key type.
const CredentialTypeAddress = "address"
CredentialTypeAddress is the CXF address type.
const CredentialTypeBasicAuth = "basic-auth"
CredentialTypeBasicAuth is the CXF basic-auth type.
const CredentialTypeCreditCard = "credit-card"
CredentialTypeCreditCard is the CXF credit card type.
const CredentialTypeCustomFields = "custom-fields"
CredentialTypeCustomFields is the CXF custom fields type.
const CredentialTypeDriversLicense = "drivers-license"
CredentialTypeDriversLicense is the CXF driver's license type.
const CredentialTypeFile = "file"
CredentialTypeFile is the CXF file type.
const CredentialTypeGeneratedPassword = "generated-password"
CredentialTypeGeneratedPassword is the CXF generated-password type.
const CredentialTypeIdentityDocument = "identity-document"
CredentialTypeIdentityDocument is the CXF identity document type.
const CredentialTypeItemReference = "item-reference"
CredentialTypeItemReference is the CXF item reference type.
const CredentialTypeNote = "note"
CredentialTypeNote is the CXF note type.
const CredentialTypePasskey = "passkey"
CredentialTypePasskey is the CXF passkey type.
const CredentialTypePassport = "passport"
CredentialTypePassport is the CXF passport type.
const CredentialTypePersonName = "person-name"
CredentialTypePersonName is the CXF person name type.
const CredentialTypeSSHKey = "ssh-key"
CredentialTypeSSHKey is the CXF SSH key type.
const CredentialTypeTOTP = "totp"
CredentialTypeTOTP is the CXF TOTP type.
const CredentialTypeWiFi = "wifi"
CredentialTypeWiFi is the CXF Wi-Fi type.
const FIDO2HMACCredentialAlgorithmSHA256 = "hmac-sha256"
FIDO2HMACCredentialAlgorithmSHA256 is the supported FIDO2 HMAC algorithm.
const FieldTypeBoolean = "boolean"
FieldTypeBoolean is the CXF boolean field type.
const FieldTypeConcealedString = "concealed-string"
FieldTypeConcealedString is the CXF editable secret field type.
const FieldTypeCountryCode = "country-code"
FieldTypeCountryCode is the CXF country code field type.
const FieldTypeDate = "date"
FieldTypeDate is the CXF editable date field type.
const FieldTypeEmail = "email"
FieldTypeEmail is the CXF editable email field type.
const FieldTypeNumber = "number"
FieldTypeNumber is the CXF editable numeric field type.
const FieldTypeString = "string"
FieldTypeString is the CXF editable string field type.
const FieldTypeSubdivisionCode = "subdivision-code"
FieldTypeSubdivisionCode is the CXF subdivision code field type.
const FieldTypeWiFiNetworkSecurityType = "wifi-network-security-type"
FieldTypeWiFiNetworkSecurityType is the CXF Wi-Fi security field type.
const FieldTypeYearMonth = "year-month"
FieldTypeYearMonth is the CXF year-month field type.
const OTPHashAlgorithmSHA1 = "sha1"
OTPHashAlgorithmSHA1 is the SHA-1 algorithm used by TOTP credentials.
const OTPHashAlgorithmSHA256 = "sha256"
OTPHashAlgorithmSHA256 is the SHA-256 algorithm used by TOTP credentials.
const OTPHashAlgorithmSHA512 = "sha512"
OTPHashAlgorithmSHA512 is the SHA-512 algorithm used by TOTP credentials.
const WiFiNetworkSecurityTypeUnsecured = "unsecured"
WiFiNetworkSecurityTypeUnsecured identifies an unsecured Wi-Fi network.
const WiFiNetworkSecurityTypeWEP = "wep"
WiFiNetworkSecurityTypeWEP identifies a WEP network.
const WiFiNetworkSecurityTypeWPA2Personal = "wpa2-personal"
WiFiNetworkSecurityTypeWPA2Personal identifies a WPA2-Personal network.
const WiFiNetworkSecurityTypeWPA3Personal = "wpa3-personal"
WiFiNetworkSecurityTypeWPA3Personal identifies a WPA3-Personal network.
const WiFiNetworkSecurityTypeWPAPersonal = "wpa-personal"
WiFiNetworkSecurityTypeWPAPersonal identifies a WPA-Personal network.
Variables ¶
var ( // ErrInvalidDocument marks invalid JSON or CXF data. ErrInvalidDocument = errors.New("invalid CXF document") // ErrUnsupportedVersion marks an unsupported CXF major version. ErrUnsupportedVersion = errors.New("unsupported CXF major version") )
Functions ¶
func CredentialTypeOf ¶
func CredentialTypeOf(raw json.RawMessage) (string, error)
CredentialTypeOf returns a credential's type without decoding its contents.
func Encode ¶
Encode validates a document before writing it.
Example ¶
ExampleEncode encodes and decodes a document.
package main
import (
"bytes"
"fmt"
"go.lucor.dev/cxf"
)
func main() {
document := &cxf.Header{
Version: cxf.Version{Major: 1, Minor: 0},
ExporterRPID: "example.com",
ExporterDisplayName: "Example manager",
Accounts: []cxf.Account{},
}
var output bytes.Buffer
if err := cxf.Encode(&output, document); err != nil {
panic(err)
}
decoded, err := cxf.Decode(&output)
if err != nil {
panic(err)
}
fmt.Println(decoded.Version.Major, len(decoded.Accounts))
}
Output: 1 0
func ValidateCredential ¶
ValidateCredential checks a supported credential and accepts unknown types.
Types ¶
type APIKey ¶
type APIKey struct {
// Type must be CredentialTypeAPIKey.
Type string `json:"type"`
// Key holds the API secret; FieldTypeConcealedString is recommended.
Key *EditableField `json:"key,omitempty"`
// Username identifies the account; FieldTypeString is recommended.
Username *EditableField `json:"username,omitempty"`
// KeyType describes the key, such as a bearer token; FieldTypeString is recommended.
KeyType *EditableField `json:"keyType,omitempty"`
// URL identifies the API endpoint; FieldTypeString is recommended.
URL *EditableField `json:"url,omitempty"`
// ValidFrom records when the key becomes valid; FieldTypeDate is recommended.
ValidFrom *EditableField `json:"validFrom,omitempty"`
// ExpiryDate records when the key expires; FieldTypeDate is recommended.
ExpiryDate *EditableField `json:"expiryDate,omitempty"`
}
APIKey stores an API key and its optional metadata.
func (*APIKey) UnmarshalJSON ¶
UnmarshalJSON decodes and validates an API key credential atomically.
type Account ¶
type Account struct {
// ID is a Base64url identifier of at most 64 decoded bytes.
ID string `json:"id"`
// Username is the account's chosen name, or an empty string if unset.
Username string `json:"username"`
// Email is the address used to register the account.
Email string `json:"email"`
// FullName optionally records the account owner's full name.
FullName *string `json:"fullName,omitempty"`
// Collections lists collections owned by this account, excluding those shared with it.
Collections []Collection `json:"collections"`
// Items lists items owned by this account, excluding those shared with it.
Items []Item `json:"items"`
// Extensions holds optional account extension objects as JSON.
Extensions []json.RawMessage `json:"extensions,omitempty"`
}
Account holds one provider account and its items.
func DecodeAccount ¶
DecodeAccount reads and validates one account, including its items and collections.
func (*Account) UnmarshalJSON ¶
UnmarshalJSON decodes and validates an account atomically.
type Address ¶
type Address struct {
// Type must be CredentialTypeAddress.
Type string `json:"type"`
// StreetAddress holds address lines separated by newlines; FieldTypeString is recommended.
StreetAddress *EditableField `json:"streetAddress,omitempty"`
// PostalCode holds a postal or ZIP code; FieldTypeString is recommended.
PostalCode *EditableField `json:"postalCode,omitempty"`
// City names the city; FieldTypeString is recommended.
City *EditableField `json:"city,omitempty"`
// Territory identifies a state or province; FieldTypeSubdivisionCode is recommended.
Territory *EditableField `json:"territory,omitempty"`
// Country identifies the country; FieldTypeCountryCode is recommended.
Country *EditableField `json:"country,omitempty"`
// Tel holds a phone number; FieldTypeString is recommended.
Tel *EditableField `json:"tel,omitempty"`
}
Address stores address fields used for autofill.
func (*Address) UnmarshalJSON ¶
UnmarshalJSON decodes and validates an address credential atomically.
type AndroidAppCertificateFingerprint ¶
type AndroidAppCertificateFingerprint struct {
// Fingerprint is the Base64url-encoded certificate digest.
Fingerprint string `json:"fingerprint"`
// HashAlg names the digest algorithm.
HashAlg string `json:"hashAlg"`
}
AndroidAppCertificateFingerprint identifies an Android signing certificate.
func (*AndroidAppCertificateFingerprint) UnmarshalJSON ¶
func (certificate *AndroidAppCertificateFingerprint) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes and validates an Android certificate fingerprint atomically.
func (*AndroidAppCertificateFingerprint) Validate ¶
func (certificate *AndroidAppCertificateFingerprint) Validate() error
Validate checks an Android certificate fingerprint.
type AndroidAppID ¶
type AndroidAppID struct {
// BundleID is the application identifier.
BundleID string `json:"bundleId"`
// Certificate is the optional signing certificate fingerprint.
Certificate *AndroidAppCertificateFingerprint `json:"certificate,omitempty"`
// Name is the optional display name.
Name *string `json:"name,omitempty"`
}
AndroidAppID identifies an Android application.
func (*AndroidAppID) UnmarshalJSON ¶
func (app *AndroidAppID) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes and validates Android application data atomically.
func (*AndroidAppID) Validate ¶
func (app *AndroidAppID) Validate() error
Validate checks an Android application identifier.
type BasicAuth ¶
type BasicAuth struct {
// Type must be CredentialTypeBasicAuth.
Type string `json:"type"`
// Username is optional; FieldTypeString is recommended.
Username *EditableField `json:"username,omitempty"`
// Password is optional; FieldTypeConcealedString is recommended.
Password *EditableField `json:"password,omitempty"`
}
BasicAuth stores a username and password.
func (*BasicAuth) UnmarshalJSON ¶
UnmarshalJSON decodes and validates a basic-auth credential atomically.
type Collection ¶
type Collection struct {
// ID is a Base64url identifier, unique within its account and at most 64 decoded bytes.
ID string `json:"id"`
// CreationAt is the optional creation time, in Unix seconds.
CreationAt *uint64 `json:"creationAt,omitempty"`
// ModifiedAt is the optional last modification time, in Unix seconds.
ModifiedAt *uint64 `json:"modifiedAt,omitempty"`
// Title is the collection's display name.
Title string `json:"title"`
// Subtitle is an optional description.
Subtitle *string `json:"subtitle,omitempty"`
// Items lists linked items. The array is required even when empty.
Items []LinkedItem `json:"items"`
// SubCollections optionally lists nested collections.
SubCollections []Collection `json:"subCollections,omitempty"`
// Extensions holds optional collection extension objects as JSON.
Extensions []json.RawMessage `json:"extensions,omitempty"`
}
Collection groups item references and nested collections.
func (*Collection) UnmarshalJSON ¶
func (collection *Collection) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes and validates a collection atomically.
type CredentialScope ¶
type CredentialScope struct {
// URLs lists credential locations, preferably as RFC 3986 URIs.
URLs []string `json:"urls"`
// AndroidApps lists applications that may use these credentials.
AndroidApps []AndroidAppID `json:"androidApps"`
}
CredentialScope lists websites and Android apps for an item.
func (*CredentialScope) UnmarshalJSON ¶
func (scope *CredentialScope) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes and validates a credential scope atomically.
func (*CredentialScope) Validate ¶
func (scope *CredentialScope) Validate() error
Validate checks the required scope arrays and Android application records.
type CreditCard ¶
type CreditCard struct {
// Type must be CredentialTypeCreditCard.
Type string `json:"type"`
// Number holds the card number; FieldTypeConcealedString is recommended.
Number *EditableField `json:"number,omitempty"`
// FullName is the name printed on the card; FieldTypeString is recommended.
FullName *EditableField `json:"fullName,omitempty"`
// CardType names the card brand; FieldTypeString is recommended.
CardType *EditableField `json:"cardType,omitempty"`
// VerificationNumber holds the card security code; FieldTypeConcealedString is recommended.
VerificationNumber *EditableField `json:"verificationNumber,omitempty"`
// PIN holds the card's PIN; FieldTypeConcealedString is recommended.
PIN *EditableField `json:"pin,omitempty"`
// ExpiryDate is the expiry month; FieldTypeYearMonth is recommended.
ExpiryDate *EditableField `json:"expiryDate,omitempty"`
// ValidFrom is the first valid month; FieldTypeYearMonth is recommended.
ValidFrom *EditableField `json:"validFrom,omitempty"`
}
CreditCard stores payment card fields.
func (*CreditCard) UnmarshalJSON ¶
func (credential *CreditCard) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes and validates a credit card credential atomically.
func (*CreditCard) Validate ¶
func (credential *CreditCard) Validate() error
Validate checks the payment card fields.
type CustomFields ¶
type CustomFields struct {
// Type must be CredentialTypeCustomFields.
Type string `json:"type"`
// ID is an optional Base64url group identifier, at most 64 decoded bytes.
ID *string `json:"id,omitempty"`
// Label optionally names the field group.
Label string `json:"label,omitempty"`
// Fields lists editable values of any field type; an empty array is allowed.
Fields []EditableField `json:"fields"`
// Extensions holds optional group extension objects as JSON.
Extensions []json.RawMessage `json:"extensions,omitempty"`
}
CustomFields stores a labeled group of editable fields.
func (*CustomFields) UnmarshalJSON ¶
func (credential *CustomFields) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes and validates custom fields atomically.
func (*CustomFields) Validate ¶
func (credential *CustomFields) Validate() error
Validate checks the custom fields and their extensions.
type DriversLicense ¶
type DriversLicense struct {
// Type must be CredentialTypeDriversLicense.
Type string `json:"type"`
// FullName names the license holder; FieldTypeString is recommended.
FullName *EditableField `json:"fullName,omitempty"`
// BirthDate records the holder's birth date; FieldTypeDate is recommended.
BirthDate *EditableField `json:"birthDate,omitempty"`
// IssueDate records when the license was issued; FieldTypeDate is recommended.
IssueDate *EditableField `json:"issueDate,omitempty"`
// ExpiryDate records when the license expires; FieldTypeDate is recommended.
ExpiryDate *EditableField `json:"expiryDate,omitempty"`
// IssuingAuthority names the issuer; FieldTypeString is recommended.
IssuingAuthority *EditableField `json:"issuingAuthority,omitempty"`
// Territory identifies the issuing region; FieldTypeSubdivisionCode is recommended.
Territory *EditableField `json:"territory,omitempty"`
// Country identifies the issuing country; FieldTypeCountryCode is recommended.
Country *EditableField `json:"country,omitempty"`
// LicenseNumber holds the issuer's assigned number; FieldTypeString is recommended.
LicenseNumber *EditableField `json:"licenseNumber,omitempty"`
// LicenseClass describes permitted vehicle types; FieldTypeString is recommended.
LicenseClass *EditableField `json:"licenseClass,omitempty"`
}
DriversLicense stores driver's license fields.
func (*DriversLicense) UnmarshalJSON ¶
func (credential *DriversLicense) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes and validates a driver's-license credential atomically.
func (*DriversLicense) Validate ¶
func (credential *DriversLicense) Validate() error
Validate checks the driver's-license fields.
type EditableField ¶
type EditableField struct {
// ID is an optional Base64url identifier, at most 64 decoded bytes.
ID *string `json:"id,omitempty"`
// FieldType describes the value's format and how it should be displayed.
FieldType string `json:"fieldType"`
// Value holds text or the string representation of another value.
Value string `json:"value"`
// Label is an optional description shown to the user.
Label string `json:"label,omitempty"`
// Extensions holds optional field extension objects as JSON.
Extensions []json.RawMessage `json:"extensions,omitempty"`
}
EditableField stores a user-editable credential value.
func (*EditableField) UnmarshalJSON ¶
func (field *EditableField) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes and validates an editable field atomically.
func (*EditableField) Validate ¶
func (field *EditableField) Validate() error
Validate checks the editable field's value and extensions.
type FIDO2Extensions ¶
type FIDO2Extensions struct {
// HMACCredentials optionally supplies seeds for PRF or hmac-secret operations.
HMACCredentials *FIDO2HMACCredentials `json:"hmacCredentials,omitempty"`
// CredBlob optionally holds credential blob bytes encoded as Base64url.
CredBlob *string `json:"credBlob,omitempty"`
// LargeBlob optionally holds the credential's compressed large blob.
LargeBlob *FIDO2LargeBlob `json:"largeBlob,omitempty"`
// Payments optionally marks the credential for Secure Payment Confirmation.
Payments *bool `json:"payments,omitempty"`
}
FIDO2Extensions stores supported WebAuthn extension data.
func (*FIDO2Extensions) UnmarshalJSON ¶
func (extensions *FIDO2Extensions) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes and validates FIDO2 extension data atomically.
func (*FIDO2Extensions) Validate ¶
func (extensions *FIDO2Extensions) Validate() error
Validate checks FIDO2 extension values.
type FIDO2HMACCredentials ¶
type FIDO2HMACCredentials struct {
// Algorithm names the HMAC algorithm; CXF recommends "hmac-sha256".
Algorithm string `json:"algorithm"`
// CredWithUV is the Base64url seed used after user verification; 32 bytes are recommended.
CredWithUV string `json:"credWithUV"`
// CredWithoutUV is the Base64url seed used without user verification; 32 bytes are recommended.
CredWithoutUV string `json:"credWithoutUV"`
}
FIDO2HMACCredentials stores credentials used by the PRF extension.
func (*FIDO2HMACCredentials) UnmarshalJSON ¶
func (credentials *FIDO2HMACCredentials) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes and validates FIDO2 HMAC credentials atomically.
func (*FIDO2HMACCredentials) Validate ¶
func (credentials *FIDO2HMACCredentials) Validate() error
Validate checks FIDO2 HMAC credentials.
type FIDO2LargeBlob ¶
type FIDO2LargeBlob struct {
// UncompressedSize is the claimed size of the original data, in bytes.
UncompressedSize uint64 `json:"uncompressedSize"`
// Data contains DEFLATE-compressed bytes encoded as Base64url.
Data string `json:"data"`
}
FIDO2LargeBlob stores compressed large-blob data.
func (*FIDO2LargeBlob) UnmarshalJSON ¶
func (blob *FIDO2LargeBlob) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes and validates FIDO2 large-blob data atomically.
func (*FIDO2LargeBlob) Validate ¶
func (blob *FIDO2LargeBlob) Validate() error
Validate checks FIDO2 large-blob data.
type File ¶
type File struct {
// Type must be CredentialTypeFile.
Type string `json:"type"`
// ID is the Base64url identifier used to match the separately transferred file.
ID string `json:"id"`
// Name is the file name, including its extension when present.
Name string `json:"name"`
// DecryptedSize is the size of the decrypted file, in bytes.
DecryptedSize uint64 `json:"decryptedSize"`
// IntegrityHash is the decrypted file's SHA-256 digest encoded as Base64url.
IntegrityHash string `json:"integrityHash"`
}
File stores metadata for a separately transferred binary file.
func (*File) UnmarshalJSON ¶
UnmarshalJSON decodes and validates file metadata atomically.
type GeneratedPassword ¶
type GeneratedPassword struct {
// Type must be CredentialTypeGeneratedPassword.
Type string `json:"type"`
// Password holds the generated secret and should be concealed in the UI.
Password string `json:"password"`
}
GeneratedPassword stores a password created by a password generator.
func (*GeneratedPassword) UnmarshalJSON ¶
func (credential *GeneratedPassword) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes and validates a generated-password credential atomically.
func (*GeneratedPassword) Validate ¶
func (credential *GeneratedPassword) Validate() error
Validate checks the credential type.
type Header ¶
type Header struct {
// Version identifies the CXF revision used by this document.
Version Version `json:"version"`
// ExporterRPID is the exporting application's relying party identifier.
ExporterRPID string `json:"exporterRpId"`
// ExporterDisplayName is the exporting application's display name.
ExporterDisplayName string `json:"exporterDisplayName"`
// Timestamp is the export completion time, in Unix seconds.
Timestamp uint64 `json:"timestamp"`
// Accounts lists the exported accounts. The array is required even when empty.
Accounts []Account `json:"accounts"`
}
Header is a CXF document.
func (*Header) UnmarshalJSON ¶
UnmarshalJSON decodes and validates a CXF document atomically.
type IdentityDocument ¶
type IdentityDocument struct {
// Type must be CredentialTypeIdentityDocument.
Type string `json:"type"`
// IssuingCountry identifies the issuer's country; FieldTypeCountryCode is recommended.
IssuingCountry *EditableField `json:"issuingCountry,omitempty"`
// DocumentNumber identifies this issuance of the document; FieldTypeString is recommended.
DocumentNumber *EditableField `json:"documentNumber,omitempty"`
// IdentificationNumber identifies the person or entity, such as an SSN or tax ID.
// FieldTypeString is recommended.
IdentificationNumber *EditableField `json:"identificationNumber,omitempty"`
// Nationality records nationality; FieldTypeString is recommended.
Nationality *EditableField `json:"nationality,omitempty"`
// FullName names the document holder; FieldTypeString is recommended.
FullName *EditableField `json:"fullName,omitempty"`
// BirthDate records the holder's date of birth; FieldTypeDate is recommended.
BirthDate *EditableField `json:"birthDate,omitempty"`
// BirthPlace records where the holder was born; FieldTypeString is recommended.
BirthPlace *EditableField `json:"birthPlace,omitempty"`
// Sex records sex or gender; FieldTypeString is recommended.
Sex *EditableField `json:"sex,omitempty"`
// IssueDate records when the document was issued; FieldTypeDate is recommended.
IssueDate *EditableField `json:"issueDate,omitempty"`
// ExpiryDate records when the document expires; FieldTypeDate is recommended.
ExpiryDate *EditableField `json:"expiryDate,omitempty"`
// IssuingAuthority names the issuer; FieldTypeString is recommended.
IssuingAuthority *EditableField `json:"issuingAuthority,omitempty"`
}
IdentityDocument stores identity document fields.
func (*IdentityDocument) UnmarshalJSON ¶
func (credential *IdentityDocument) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes and validates an identity-document credential atomically.
func (*IdentityDocument) Validate ¶
func (credential *IdentityDocument) Validate() error
Validate checks the identity-document fields.
type Item ¶
type Item struct {
// ID is a Base64url identifier, unique within its account and at most 64 decoded bytes.
ID string `json:"id"`
// CreationAt is the optional creation time, in Unix seconds.
CreationAt *uint64 `json:"creationAt,omitempty"`
// ModifiedAt is the optional last modification time, in Unix seconds.
ModifiedAt *uint64 `json:"modifiedAt,omitempty"`
// Title is the item's display name.
Title string `json:"title"`
// Subtitle is an optional description.
Subtitle *string `json:"subtitle,omitempty"`
// Favorite records whether the user marked the item as a favorite; absent means false.
Favorite *bool `json:"favorite,omitempty"`
// Scope optionally identifies where the credentials should be offered.
Scope *CredentialScope `json:"scope,omitempty"`
// Credentials groups related credential objects as JSON; an empty array is allowed.
Credentials []json.RawMessage `json:"credentials"`
// Tags optionally lists labels chosen by the user.
Tags []string `json:"tags,omitempty"`
// Extensions holds optional item extension objects as JSON.
Extensions []json.RawMessage `json:"extensions,omitempty"`
}
Item holds related credentials, such as a login and a TOTP secret.
func (*Item) UnmarshalJSON ¶
UnmarshalJSON decodes and validates an item atomically.
type ItemReference ¶
type ItemReference struct {
// Type must be CredentialTypeItemReference.
Type string `json:"type"`
// Reference identifies the linked item and optionally its owning account.
Reference LinkedItem `json:"reference"`
}
ItemReference points to another item in or outside the document.
func (*ItemReference) UnmarshalJSON ¶
func (credential *ItemReference) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes and validates an item-reference credential atomically.
func (*ItemReference) Validate ¶
func (credential *ItemReference) Validate() error
Validate checks the referenced item identifiers.
type LinkedItem ¶
type LinkedItem struct {
// Item is the referenced item's Base64url ID; the item may be outside the document.
Item string `json:"item"`
// Account is the owning account's Base64url ID; absent means the current account.
Account *string `json:"account,omitempty"`
}
LinkedItem refers to an item, which may be outside this document.
func (*LinkedItem) UnmarshalJSON ¶
func (item *LinkedItem) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes and validates a linked item atomically.
func (*LinkedItem) Validate ¶
func (item *LinkedItem) Validate() error
Validate checks the referenced item and optional account identifiers.
type Note ¶
type Note struct {
// Type must be CredentialTypeNote.
Type string `json:"type"`
// Content holds the note text; FieldTypeString is recommended.
Content EditableField `json:"content"`
}
Note stores a text note.
func (*Note) UnmarshalJSON ¶
UnmarshalJSON decodes and validates a note credential atomically.
type Passkey ¶
type Passkey struct {
// Type must be CredentialTypePasskey.
Type string `json:"type"`
// CredentialID is the registration credential's rawId encoded as Base64url.
CredentialID string `json:"credentialId"`
// RPID scopes this passkey to its registered relying party; Item.Scope does not apply.
RPID string `json:"rpId"`
// Username is the account name, including any edits made by the user.
Username string `json:"username"`
// UserDisplayName is the account's display name, including user edits.
UserDisplayName string `json:"userDisplayName"`
// UserHandle is the account identifier from registration, encoded as Base64url.
UserHandle string `json:"userHandle"`
// Key contains the credential's PKCS#8 DER private key encoded as Base64url.
Key string `json:"key"`
// FIDO2Extensions optionally holds associated WebAuthn and CTAP2 extension data.
FIDO2Extensions *FIDO2Extensions `json:"fido2Extensions,omitempty"`
}
Passkey stores a WebAuthn credential and its private key.
func (*Passkey) UnmarshalJSON ¶
UnmarshalJSON decodes and validates a passkey credential atomically.
type Passport ¶
type Passport struct {
// Type must be CredentialTypePassport.
Type string `json:"type"`
// IssuingCountry identifies the issuer's country; FieldTypeCountryCode is recommended.
IssuingCountry *EditableField `json:"issuingCountry,omitempty"`
// PassportType holds an ICAO document code; FieldTypeString is recommended.
PassportType *EditableField `json:"passportType,omitempty"`
// PassportNumber identifies the passport; FieldTypeString is recommended.
PassportNumber *EditableField `json:"passportNumber,omitempty"`
// NationalIdentificationNumber holds the person's national ID; FieldTypeString is recommended.
NationalIdentificationNumber *EditableField `json:"nationalIdentificationNumber,omitempty"`
// Nationality records nationality; FieldTypeString is recommended.
Nationality *EditableField `json:"nationality,omitempty"`
// FullName names the passport holder; FieldTypeString is recommended.
FullName *EditableField `json:"fullName,omitempty"`
// BirthDate records the holder's date of birth; FieldTypeDate is recommended.
BirthDate *EditableField `json:"birthDate,omitempty"`
// BirthPlace records where the holder was born; FieldTypeString is recommended.
BirthPlace *EditableField `json:"birthPlace,omitempty"`
// Sex records sex or gender; FieldTypeString is recommended.
Sex *EditableField `json:"sex,omitempty"`
// IssueDate records when the passport was issued; FieldTypeDate is recommended.
IssueDate *EditableField `json:"issueDate,omitempty"`
// ExpiryDate records when the passport expires; FieldTypeDate is recommended.
ExpiryDate *EditableField `json:"expiryDate,omitempty"`
// IssuingAuthority names the issuer; FieldTypeString is recommended.
IssuingAuthority *EditableField `json:"issuingAuthority,omitempty"`
}
Passport stores passport fields.
func (*Passport) UnmarshalJSON ¶
UnmarshalJSON decodes and validates a passport credential atomically.
type PersonName ¶
type PersonName struct {
// Type must be CredentialTypePersonName.
Type string `json:"type"`
// Title holds an honorific; FieldTypeString is recommended.
Title *EditableField `json:"title,omitempty"`
// Given holds the given name; FieldTypeString is recommended.
Given *EditableField `json:"given,omitempty"`
// GivenInformal holds a nickname or preferred name; FieldTypeString is recommended.
GivenInformal *EditableField `json:"givenInformal,omitempty"`
// Given2 holds additional given names; FieldTypeString is recommended.
Given2 *EditableField `json:"given2,omitempty"`
// SurnamePrefix holds a family-name prefix; FieldTypeString is recommended.
SurnamePrefix *EditableField `json:"surnamePrefix,omitempty"`
// Surname holds the family name; FieldTypeString is recommended.
Surname *EditableField `json:"surname,omitempty"`
// Surname2 holds a second family name; FieldTypeString is recommended.
Surname2 *EditableField `json:"surname2,omitempty"`
// Credentials holds academic or professional suffixes; FieldTypeString is recommended.
Credentials *EditableField `json:"credentials,omitempty"`
// Generation holds a suffix such as "Jr."; FieldTypeString is recommended.
Generation *EditableField `json:"generation,omitempty"`
}
PersonName stores the parts of a person's name.
func (*PersonName) UnmarshalJSON ¶
func (credential *PersonName) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes and validates a person-name credential atomically.
func (*PersonName) Validate ¶
func (credential *PersonName) Validate() error
Validate checks the person-name fields.
type SSHKey ¶
type SSHKey struct {
// Type must be CredentialTypeSSHKey.
Type string `json:"type"`
// KeyType names the SSH algorithm, for example "ssh-ed25519".
KeyType string `json:"keyType"`
// PrivateKey contains PKCS#8 DER bytes encoded as Base64url.
PrivateKey string `json:"privateKey"`
// KeyComment optionally describes the key.
KeyComment string `json:"keyComment,omitempty"`
// CreationDate is optional; FieldTypeDate is recommended.
CreationDate *EditableField `json:"creationDate,omitempty"`
// ExpiryDate is optional; FieldTypeDate is recommended.
ExpiryDate *EditableField `json:"expiryDate,omitempty"`
// KeyGenerationSource optionally names the key's origin; FieldTypeString is recommended.
KeyGenerationSource *EditableField `json:"keyGenerationSource,omitempty"`
}
SSHKey stores an SSH private key in PKCS#8 DER format.
func (*SSHKey) UnmarshalJSON ¶
UnmarshalJSON decodes and validates an SSH-key credential atomically.
type Shared ¶
type Shared struct {
Name string `json:"name"`
Accessors []SharingAccessor `json:"accessors"`
}
Shared marks an item or collection as shared with other accounts.
func (*Shared) UnmarshalJSON ¶
UnmarshalJSON decodes and validates a shared extension atomically.
type SharingAccessor ¶
type SharingAccessor struct {
// Type identifies a user or group.
Type SharingAccessorType `json:"type"`
// AccountID identifies the account receiving access.
AccountID string `json:"accountId"`
// Name is the account or group name.
Name string `json:"name"`
// Permissions lists the granted permissions, including unknown future values.
Permissions []SharingAccessorPermission `json:"permissions"`
}
SharingAccessor describes an account that can access a shared entity.
func (*SharingAccessor) UnmarshalJSON ¶
func (accessor *SharingAccessor) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes and validates a sharing accessor atomically.
func (*SharingAccessor) Validate ¶
func (accessor *SharingAccessor) Validate() error
Validate checks the accessor's required data and account identifier.
type SharingAccessorPermission ¶
type SharingAccessorPermission string
SharingAccessorPermission identifies an access permission.
const ( // SharingAccessorPermissionRead allows reading metadata without secrets. SharingAccessorPermissionRead SharingAccessorPermission = "read" // SharingAccessorPermissionReadSecret allows reading secrets. SharingAccessorPermissionReadSecret SharingAccessorPermission = "readSecret" // SharingAccessorPermissionUpdate allows updating the entity. SharingAccessorPermissionUpdate SharingAccessorPermission = "update" // SharingAccessorPermissionCreate allows creating child entities. SharingAccessorPermissionCreate SharingAccessorPermission = "create" // SharingAccessorPermissionDelete allows deleting child entities. SharingAccessorPermissionDelete SharingAccessorPermission = "delete" SharingAccessorPermissionShare SharingAccessorPermission = "share" // SharingAccessorPermissionManage allows managing the entity. SharingAccessorPermissionManage SharingAccessorPermission = "manage" )
type SharingAccessorType ¶
type SharingAccessorType string
SharingAccessorType identifies a user or group.
const ( // SharingAccessorTypeUser identifies an individual user. SharingAccessorTypeUser SharingAccessorType = "user" // SharingAccessorTypeGroup identifies a group of users. SharingAccessorTypeGroup SharingAccessorType = "group" )
type TOTP ¶
type TOTP struct {
// Type must be CredentialTypeTOTP.
Type string `json:"type"`
// Secret is the shared OTP secret encoded as Base32.
Secret string `json:"secret"`
// Period is the time step in seconds; CXF recommends 30.
Period uint16 `json:"period"`
// Digits is the number of displayed digits; CXF recommends 6.
Digits uint16 `json:"digits"`
// Username optionally identifies the account using the OTP.
Username string `json:"username,omitempty"`
// Algorithm names the hash, usually "sha1", "sha256", or "sha512".
// Importers must ignore credentials using an unknown algorithm.
Algorithm string `json:"algorithm"`
// Issuer optionally names the service that issued the secret.
Issuer string `json:"issuer,omitempty"`
}
TOTP stores a time-based one-time password secret.
func (*TOTP) UnmarshalJSON ¶
UnmarshalJSON decodes and validates a TOTP credential atomically.
type ValidationError ¶
type ValidationError struct {
// Path is the JSON path of the invalid value.
Path string
// Reason describes the violation without including the value.
Reason string
// contains filtered or unexported fields
}
ValidationError describes a CXF schema violation.
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
Error returns the path and reason without including the rejected value.
func (*ValidationError) Unwrap ¶
func (e *ValidationError) Unwrap() []error
Unwrap identifies this error as an invalid CXF document.
type Version ¶
type Version struct {
// Major changes when the format introduces incompatible changes.
Major uint8 `json:"major"`
// Minor changes for additions compatible with the same major version.
Minor uint8 `json:"minor"`
}
Version identifies the CXF schema version.
func (*Version) UnmarshalJSON ¶
UnmarshalJSON decodes a CXF version atomically.
type WiFi ¶
type WiFi struct {
// Type must be CredentialTypeWiFi.
Type string `json:"type"`
// SSID names the network; FieldTypeString is recommended.
SSID *EditableField `json:"ssid,omitempty"`
// NetworkSecurityType describes network security; FieldTypeWiFiNetworkSecurityType or FieldTypeString is recommended.
NetworkSecurityType *EditableField `json:"networkSecurityType,omitempty"`
// Passphrase holds the network secret; FieldTypeConcealedString is recommended.
Passphrase *EditableField `json:"passphrase,omitempty"`
// Hidden marks a hidden network; FieldTypeBoolean is recommended.
Hidden *EditableField `json:"hidden,omitempty"`
}
WiFi stores wireless network fields.
func (*WiFi) UnmarshalJSON ¶
UnmarshalJSON decodes and validates a Wi-Fi credential atomically.
Source Files
¶
- account.go
- address.go
- android_app.go
- api_key.go
- basic_auth.go
- collection.go
- credential.go
- credential_scope.go
- credit_card.go
- custom_fields.go
- cxf.go
- doc.go
- drivers_license.go
- editable_field.go
- extension.go
- file.go
- generated_password.go
- header.go
- identity_document.go
- item.go
- item_reference.go
- linked_item.go
- note.go
- passkey.go
- passport.go
- person_name.go
- sharing.go
- ssh_key.go
- totp.go
- validation.go
- version.go
- wifi.go