# Authenticator.getAuthenticatorData

Gets the authenticator data which contains information about the processing of an authenticator request (ie. from `Authentication.sign`).

:::warning
This function is mainly for testing purposes or for manually constructing autenticator data. In most cases you will not need this function. `authenticatorData` is typically returned as part of the authenticator response.
:::

## Imports

:::code-group
```ts [Named]
import { Authenticator } from 'ox/webauthn'
```

```ts [Entrypoint]
import * as Authenticator from 'ox/webauthn/Authenticator'
```
:::

## Examples

```ts twoslash
import { Authenticator } from 'ox/webauthn'

const authenticatorData =
  Authenticator.getAuthenticatorData({
    rpId: 'example.com',
    signCount: 420
  })
// @log: "0xa379a6f6eeafb9a55e378c118034e2751e682fab9f2d30ab13d2125586ce194705000001a4"
```

### With Attested Credential Data

Include a credential ID and public key in the authenticator data (for registration responses):

```ts twoslash
import { P256 } from 'ox'
import { Authenticator } from 'ox/webauthn'

const { publicKey } = P256.createKeyPair()

const authenticatorData =
  Authenticator.getAuthenticatorData({
    rpId: 'example.com',
    flag: 0x41, // UP + AT
    credential: {
      id: new Uint8Array(32),
      publicKey
    }
  })
```

## Definition

```ts
function getAuthenticatorData<as>(
  options?: getAuthenticatorData.Options<as>,
): getAuthenticatorData.ReturnType<as>
```

**Source:** [src/webauthn/Authenticator.ts](https://github.com/wevm/ox/blob/main/src/webauthn/Authenticator.ts#L61)

## Parameters

### options

* **Type:** `getAuthenticatorData.Options<as>`
* **Optional**

Options to construct the authenticator data.

#### options.as

* **Type:** `"Bytes" | "Hex" | as`
* **Optional**

Output representation.

#### options.credential

* **Type:** `{ id: Uint8Array; publicKey: { prefix: number; x: 0x${string}; y: 0x${string}; }; }`
* **Optional**

Attested credential data to include (credential ID + public key). When set, the AT flag (0x40) should also be set.

#### options.flag

* **Type:** `number`
* **Optional**

A bitfield that indicates various attributes that were asserted by the authenticator. [Read more](https://developer.mozilla.org/en-US/docs/Web/API/Web_Authentication_API/Authenticator_data#flags)

#### options.id

* **Type:** `Uint8Array`

The credential ID as raw bytes.

#### options.publicKey

* **Type:** `{ prefix: number; x: 0x${string}; y: 0x${string}; }`

The P256 public key associated with the credential.

#### options.rpId

* **Type:** `string`
* **Optional**

The [Relying Party ID](https://w3c.github.io/webauthn/#relying-party-identifier) that the credential is scoped to.

#### options.signCount

* **Type:** `number`
* **Optional**

A signature counter, if supported by the authenticator (set to 0 otherwise).

## Return Type

The authenticator data.

`getAuthenticatorData.ReturnType<as>`
