# modules/auth/passkey/passkeytest

```go
import "apistock.dev/modules/auth/passkey/passkeytest"
```

Package passkeytest is a software passkey authenticator for tests. It answers registration and sign-in options with real, signed responses (P-256 keys, attestation none), so tests exercise the same verification browsers and devices go through.

Stability: pre-1.0 (ADR-0015).

## Types

### type Authenticator

```go
type Authenticator struct {

	// UserVerified sets the user-verification flag (default true). Set it
	// false to test a passkey used without verifying the person.
	UserVerified bool
	// Synced makes it behave like a synced passkey: backup flags set and a
	// signature counter that stays 0.
	Synced bool
	// contains filtered or unexported fields
}
```

Authenticator holds one passkey and answers ceremonies with it.

#### func New

```go
func New(origin string) *Authenticator
```

New returns an authenticator that reports origin, such as [http://localhost:8080](http://localhost:8080) or an android:apk-key-hash: origin.

#### func (*Authenticator) Create

```go
func (a *Authenticator) Create(options []byte) ([]byte, error)
```

Create answers registration options ({"publicKey": ...}) with a new passkey, returning the JSON a browser would send.

#### func (*Authenticator) CredentialID

```go
func (a *Authenticator) CredentialID() []byte
```

CredentialID returns the passkey's credential ID, after Create.

#### func (*Authenticator) Get

```go
func (a *Authenticator) Get(options []byte) ([]byte, error)
```

Get answers sign-in options ({"publicKey": ...}) with a signed assertion, returning the JSON a browser would send.

#### func (*Authenticator) SetSignCount

```go
func (a *Authenticator) SetSignCount(n uint32)
```

SetSignCount sets the signature counter; the next Get reports n+1.

