# Authenticator · FT4 TypeScript client · Chromia Docs (concept)

> An authenticator holds keys that are associated with
a specific account and is responsible for selecting the
correct key when trying to authenticate an ope

Source: https://docs.chromia.com/pages/ft4-ts-client/interfaces/authentication.Authenticator/

Interface

# Authenticator

On this page

* [Properties](#properties)
* [accountId](#accountid)
* [authDataService](#authdataservice)
* [keyHandlers](#keyhandlers)
* [Methods](#methods)
* [getAuthDescriptorCounter](#getauthdescriptorcounter)
* [getKeyHandlerForOperation](#getkeyhandlerforoperation)

An authenticator holds keys that are associated with
a specific account and is responsible for selecting the
correct key when trying to authenticate an operation.

The "correct key" in this case refers to the key with the least
possible privileges that will still be allowed to authenticate
the operation.

```signature
interface Authenticator {
    accountId: Buffer;
    authDataService: AuthDataService;
    keyHandlers: KeyHandler[];
    getAuthDescriptorCounter(
        authDescriptorId: BufferId,
    ): Promise<number | null>;
    getKeyHandlerForOperation(
        operation: Operation,
        txContext: TxContext,
    ): Promise<KeyHandler | null>;
}
```

## Properties

### accountId

```signature
accountId: Buffer
```

### authDataService

```signature
authDataService: AuthDataService
```

### keyHandlers

```signature
keyHandlers: KeyHandler[]
```

## Methods

### getAuthDescriptorCounter

* ```signature
  getAuthDescriptorCounter(authDescriptorId: BufferId): Promise<number | null>
  ```

  Returns the counter value for the specified auth descriptor for
  the account that this authenticator is connected to.

  #### Parameters

  + authDescriptorId: BufferId

    the id of the auth descriptor to get the counter for

  #### Returns Promise<number | null>

### getKeyHandlerForOperation

* ```signature
  getKeyHandlerForOperation(
      operation: Operation,
      txContext: TxContext,
  ): Promise<KeyHandler | null>
  ```

  Selects a KeyHandler from the list of key handlers available in this authenticator
  that will be able to authenticate the specified operation.

  #### Parameters

  + operation: Operation

    the operation to authenticate
  + txContext: [TxContext](https://docs.chromia.com/pages/ft4-ts-client/types/utils.TxContext/)

    a context object that is used in the context of a transaction

  #### Returns Promise<[KeyHandler](https://docs.chromia.com/pages/ft4-ts-client/interfaces/authentication.KeyHandler/) | null>

  a key handler that will be allowed to authenticate the specified operation. Or null if no such key handler exists

[View this page on docs.chromia.com](https://docs.chromia.com/pages/ft4-ts-client/interfaces/authentication.Authenticator.html)Generated API reference, mirrored from the live docs
