passkey

package
v2.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: MIT Imports: 3 Imported by: 3 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package passkey defines stored WebAuthn credentials (passkeys and security keys) and the Store that keeps them.

The ceremonies (registration and login) live in the webauthn module (github.com/kararnab/iam/webauthn/v2), so the core stays free of their dependencies. Credentials hold only public keys.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is returned by stores for missing credentials.
	ErrNotFound = errors.New("passkey: not found")

	// ErrConflict is returned by Store.Create for a credential ID that
	// already exists.
	ErrConflict = errors.New("passkey: credential already exists")
)

Functions

This section is empty.

Types

type Credential

type Credential struct {
	ID        []byte // credential ID chosen by the authenticator
	SubjectID string
	Name      string // a label for the user ("MacBook", "YubiKey")

	PublicKey         []byte // COSE public key
	AttestationType   string
	AttestationFormat string
	AAGUID            []byte   // authenticator model, when attested
	Transports        []string // usb, nfc, ble, internal, hybrid
	SignCount         uint32

	UserPresent    bool
	UserVerified   bool
	BackupEligible bool // a synced passkey (never changes)
	BackupState    bool // currently backed up (may change)

	CreatedAt  time.Time
	LastUsedAt time.Time // zero until first used to sign in
}

Credential is a registered WebAuthn credential.

type Store

type Store interface {
	// Create persists a new credential, or returns ErrConflict.
	Create(ctx context.Context, c *Credential) error

	// Get returns a credential by ID, or ErrNotFound.
	Get(ctx context.Context, id []byte) (*Credential, error)

	// ListBySubject returns a subject's credentials, oldest first.
	ListBySubject(ctx context.Context, subjectID string) ([]*Credential, error)

	// Touch records a sign-in: the new signature counter, backup state and
	// time. Missing is ErrNotFound.
	Touch(ctx context.Context, id []byte, signCount uint32, backupState bool, at time.Time) error

	// Delete removes one of the subject's credentials. Missing (or another
	// subject's) is not an error.
	Delete(ctx context.Context, subjectID string, id []byte) error
}

Store persists credentials. Implementations must be safe for concurrent use.

Jump to

Keyboard shortcuts

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