Documentation
¶
Index ¶
- Variables
- func Enumerate(ctx context.Context) iter.Seq2[*ghid.DeviceInfo, error]
- func OpenPath(ctx context.Context, path string) (dev io.ReadWriteCloser, err error)
- type CtxKey
- type Device
- func (d *Device) BeginEnroll(pinUvAuthToken []byte, timeoutMilliseconds uint) (*ctaptypes.AuthenticatorBioEnrollmentResponse, error)
- func (d *Device) CancelCurrentEnrollment() error
- func (d *Device) ChangePIN(currentPin, newPin string) error
- func (d *Device) Close() error
- func (d *Device) DeleteCredential(pinUvAuthToken []byte, ...) error
- func (d *Device) EnableEnterpriseAttestation(pinUvAuthToken []byte) error
- func (d *Device) EnrollCaptureNextSample(pinUvAuthToken []byte, templateID []byte, timeoutMilliseconds uint) (*ctaptypes.AuthenticatorBioEnrollmentResponse, error)
- func (d *Device) EnumerateCredentials(pinUvAuthToken []byte, rpIDHash []byte) iter.Seq2[*ctaptypes.AuthenticatorCredentialManagementResponse, error]
- func (d *Device) EnumerateEnrollments(pinUvAuthToken []byte) (*ctaptypes.AuthenticatorBioEnrollmentResponse, error)
- func (d *Device) EnumerateRPs(pinUvAuthToken []byte) iter.Seq2[*ctaptypes.AuthenticatorCredentialManagementResponse, error]
- func (d *Device) GetAssertion(pinUvAuthToken []byte, rpID string, clientData []byte, ...) iter.Seq2[*ctaptypes.AuthenticatorGetAssertionResponse, error]
- func (d *Device) GetBioModality() (*ctaptypes.AuthenticatorBioEnrollmentResponse, error)
- func (d *Device) GetCredsMetadata(pinUvAuthToken []byte) (*ctaptypes.AuthenticatorCredentialManagementResponse, error)
- func (d *Device) GetFingerprintSensorInfo() (*ctaptypes.AuthenticatorBioEnrollmentResponse, error)
- func (d *Device) GetInfo() *ctaptypes.AuthenticatorGetInfoResponse
- func (d *Device) GetLargeBlobs() ([]*ctaptypes.LargeBlob, error)
- func (d *Device) GetPINRetries() (uint, bool, error)
- func (d *Device) GetPinUvAuthTokenUsingPIN(pin string, permission ctaptypes.Permission, rpID string) ([]byte, error)
- func (d *Device) GetPinUvAuthTokenUsingUV(permission ctaptypes.Permission, rpID string) ([]byte, error)
- func (d *Device) GetUVRetries() (uint, error)
- func (d *Device) Lock(seconds uint) error
- func (d *Device) MakeCredential(pinUvAuthToken []byte, clientData []byte, ...) (*ctaptypes.AuthenticatorMakeCredentialResponse, error)
- func (d *Device) Ping(ping []byte) error
- func (d *Device) RemoveEnrollment(pinUvAuthToken []byte, templateID []byte) error
- func (d *Device) Reset() error
- func (d *Device) Selection(ctx context.Context) error
- func (d *Device) SetFriendlyName(pinUvAuthToken []byte, templateID []byte, friendlyName string) error
- func (d *Device) SetLargeBlobs(pinUvAuthToken []byte, blobs []*ctaptypes.LargeBlob) error
- func (d *Device) SetMinPINLength(pinUvAuthToken []byte, newMinPINLength uint, minPinLengthRPIDs []string, ...) error
- func (d *Device) SetPIN(pin string) error
- func (d *Device) ToggleAlwaysUV(pinUvAuthToken []byte) error
- func (d *Device) UpdateUserInformation(pinUvAuthToken []byte, ...) error
- func (d *Device) Wink() error
- type ErrorWithMessage
Constants ¶
This section is empty.
Variables ¶
var ( ErrPingPongMismatch = errors.New("device: ping/pong mismatch") ErrPinUvAuthTokenRequired = errors.New("device: pinUvAuthToken required") ErrBuiltInUVRequired = errors.New("device: built-in user verification required") ErrNotSupported = errors.New("device: not supported") SyntaxError = errors.New("device: syntax error") ErrBadType = errors.New("device: bad type") ErrInvalidSaltSize = errors.New("device: invalid salt size") ErrPinNotSet = errors.New("device: pin not set") ErrPinAlreadySet = errors.New("device: pin already set") ErrUvNotConfigured = errors.New("device: UV not configured") ErrLargeBlobsIntegrityCheck = errors.New("device: large blobs integrity check failed") ErrLargeBlobsTooBig = errors.New("device: size of serialized large blobs is too big that token") )
Functions ¶
Types ¶
type Device ¶
type Device struct {
Path string
// contains filtered or unexported fields
}
Device represents a physical or virtual hardware device supporting CTAP communication protocols.
func New ¶
New creates a new Device instance from a given HID path. It also initializes a new underlying CTAP2 client with the provided options.
func (*Device) BeginEnroll ¶
func (d *Device) BeginEnroll( pinUvAuthToken []byte, timeoutMilliseconds uint, ) (*ctaptypes.AuthenticatorBioEnrollmentResponse, error)
BeginEnroll begins a fingerprint enrollment process and returns TemplateID, LastEnrollSampleStatus, and RemainingSamples properties. Use those properties to continue to capture the next samples or cancel it.
func (*Device) CancelCurrentEnrollment ¶
CancelCurrentEnrollment cancels a current enrollment process.
func (*Device) ChangePIN ¶
ChangePIN updates the device's PIN by using the provided current PIN and new PIN. Returns an error if the device does not support clientPin or if the PIN change process fails.
func (*Device) DeleteCredential ¶
func (d *Device) DeleteCredential( pinUvAuthToken []byte, credentialID webauthntypes.PublicKeyCredentialDescriptor, ) error
DeleteCredential removes a specified credential from the device using the given authentication token. It returns an error if credential management is not supported or the operation fails.
func (*Device) EnableEnterpriseAttestation ¶
EnableEnterpriseAttestation enables enterprise attestation on the device if supported, using the provided token.
func (*Device) EnrollCaptureNextSample ¶
func (d *Device) EnrollCaptureNextSample( pinUvAuthToken []byte, templateID []byte, timeoutMilliseconds uint, ) (*ctaptypes.AuthenticatorBioEnrollmentResponse, error)
EnrollCaptureNextSample continues capturing samples from an already started enrollment process.
func (*Device) EnumerateCredentials ¶
func (d *Device) EnumerateCredentials(pinUvAuthToken []byte, rpIDHash []byte) iter.Seq2[*ctaptypes.AuthenticatorCredentialManagementResponse, error]
EnumerateCredentials provides a generator function to iterate over Credentials stored on the device for the specified Relying Party. It utilizes the Credential Management extension and yields results via a callback function. If the device does not support credential management, an error is yielded.
func (*Device) EnumerateEnrollments ¶
func (d *Device) EnumerateEnrollments(pinUvAuthToken []byte) (*ctaptypes.AuthenticatorBioEnrollmentResponse, error)
EnumerateEnrollments enumerates enrollments by returning TemplateInfos property with an array of TemplateInfo for all the enrollments available on the authenticator.
func (*Device) EnumerateRPs ¶
func (d *Device) EnumerateRPs(pinUvAuthToken []byte) iter.Seq2[*ctaptypes.AuthenticatorCredentialManagementResponse, error]
EnumerateRPs provides a generator function to iterate over Relying Parties stored on the device. It utilizes the Credential Management extension and yields results via a callback function. If the device does not support credential management, an error is yielded.
func (*Device) GetAssertion ¶
func (d *Device) GetAssertion( pinUvAuthToken []byte, rpID string, clientData []byte, allowList []webauthntypes.PublicKeyCredentialDescriptor, extInputs *webauthntypes.GetAuthenticationExtensionsClientInputs, options map[ctaptypes.Option]bool, ) iter.Seq2[*ctaptypes.AuthenticatorGetAssertionResponse, error]
GetAssertion provides a generator function to iterate over assertions stored on the device for the specified Relying Party, clientDataHash, and allowed list (in case of non-discoverable credentials). It yields results via a callback function.
func (*Device) GetBioModality ¶
func (d *Device) GetBioModality() (*ctaptypes.AuthenticatorBioEnrollmentResponse, error)
GetBioModality returns bio modality of authenticator. Currently, only fingerprint modality is defined in the FIDO 2.2 specification.
func (*Device) GetCredsMetadata ¶
func (d *Device) GetCredsMetadata(pinUvAuthToken []byte) (*ctaptypes.AuthenticatorCredentialManagementResponse, error)
GetCredsMetadata retrieves credential management metadata if the device supports it. Mainly ExistingResidentCredentialsCount and MaxPossibleRemainingResidentCredentialsCount.
func (*Device) GetFingerprintSensorInfo ¶
func (d *Device) GetFingerprintSensorInfo() (*ctaptypes.AuthenticatorBioEnrollmentResponse, error)
GetFingerprintSensorInfo returns three properties:
FingerprintKind: For touch type fingerprints, its value is 1. For swipe type fingerprints, its value is 2. MaxCaptureSamplesRequiredForEnroll: Indicates the maximum good samples required for enrollment. MaxTemplateFriendlyName: Indicates the maximum number of bytes the authenticator will accept as a templateFriendlyName.
func (*Device) GetInfo ¶
func (d *Device) GetInfo() *ctaptypes.AuthenticatorGetInfoResponse
GetInfo returns the struct containing metadata and capabilities of the device.
func (*Device) GetLargeBlobs ¶
GetLargeBlobs retrieves a list of large blobs from the device that supports the large blobs option. Returns an error if the device does not support large blobs or if there is an issue with the retrieval process. Ensures integrity by validating computed and actual hashes of the retrieved data.
func (*Device) GetPINRetries ¶
GetPINRetries retrieves the number of PIN retries remaining for the device, and if it requires a power cycle (after reaching the limit, you can reset remaining tries by re-connecting the token).
func (*Device) GetPinUvAuthTokenUsingPIN ¶
func (d *Device) GetPinUvAuthTokenUsingPIN( pin string, permission ctaptypes.Permission, rpID string, ) ([]byte, error)
GetPinUvAuthTokenUsingPIN obtains a pinUvAuthToken using a given PIN, permission, and in some cases optional Relying Party ID. Returns a token as a byte slice or an error if the operation fails. Checks device capabilities and permissions before proceeding.
func (*Device) GetPinUvAuthTokenUsingUV ¶
func (d *Device) GetPinUvAuthTokenUsingUV(permission ctaptypes.Permission, rpID string) ([]byte, error)
GetPinUvAuthTokenUsingUV obtains a pinUvAuthToken by performing user verification (UV) on a compatible device. Returns an error if the device does not support pinUvAuthToken or user verification features. Requires the permission type and optionally Relying Party ID (rpID) in some cases to execute successfully.
func (*Device) GetUVRetries ¶
GetUVRetries retrieves the number of remaining user verification retries from the device. Returns an error if the device does not support user verification.
func (*Device) Lock ¶
Lock places an exclusive lock for one channel to communicate with the device. As long as the lock is active, any other channel trying to send a message will fail. Send 0 seconds to unlock the channel.
func (*Device) MakeCredential ¶
func (d *Device) MakeCredential( pinUvAuthToken []byte, clientData []byte, rp webauthntypes.PublicKeyCredentialRpEntity, user webauthntypes.PublicKeyCredentialUserEntity, pubKeyCredParams []webauthntypes.PublicKeyCredentialParameters, excludeList []webauthntypes.PublicKeyCredentialDescriptor, extInputs *webauthntypes.CreateAuthenticationExtensionsClientInputs, options map[ctaptypes.Option]bool, enterpriseAttestation uint, attestationFormatsPreference []webauthntypes.AttestationStatementFormatIdentifier, ) (*ctaptypes.AuthenticatorMakeCredentialResponse, error)
MakeCredential initiates the process of creating a new credential on a device with specified parameters and options.
func (*Device) Ping ¶
Ping sends a ping message to the device and verifies the response matches the sent data. Returns an error on failure.
func (*Device) RemoveEnrollment ¶
RemoveEnrollment removes existing enrollment.
func (*Device) Reset ¶
Reset performs a factory reset on the device, clearing all stored user data and resetting it to its default state. Some devices require doing reset within 10 seconds after you connected the token.
func (*Device) Selection ¶
Selection is a higher-level version of ctap.Selection, which cancels the command if the context is canceled.
func (*Device) SetFriendlyName ¶
func (d *Device) SetFriendlyName(pinUvAuthToken []byte, templateID []byte, friendlyName string) error
SetFriendlyName allows renaming/setting of a friendly fingerprint name.
func (*Device) SetLargeBlobs ¶
SetLargeBlobs stores large blobs on the device, ensuring compatibility with its supported capabilities and limits. It validates device support, fragments the blob data if needed, and sends it in chunks to the device. Returns an error if the device does not support large blobs, the data exceeds size limits, or if any other failure occurs.
func (*Device) SetMinPINLength ¶
func (*Device) SetPIN ¶
SetPIN sets a new PIN on the device if the clientPin option is supported and no PIN exists. Returns an error if the device does not support clientPin or if it was already set with PIN.
func (*Device) ToggleAlwaysUV ¶
ToggleAlwaysUV toggles the always UV (User Verification) setting on the device if supported, using the provided token.
func (*Device) UpdateUserInformation ¶
func (d *Device) UpdateUserInformation( pinUvAuthToken []byte, credentialID webauthntypes.PublicKeyCredentialDescriptor, user webauthntypes.PublicKeyCredentialUserEntity, ) error
UpdateUserInformation updates information of an existing user credential on the device. Requires the device to support credential management features. Returns an error if the operation is not supported or fails.
type ErrorWithMessage ¶
func (*ErrorWithMessage) Error ¶
func (m *ErrorWithMessage) Error() string
func (*ErrorWithMessage) Unwrap ¶
func (m *ErrorWithMessage) Unwrap() error