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

> Type that represents a key that is associated with an account.
It is responsible for using the wrapped key to sign and authorize
operations against an acco

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

Interface

# KeyHandler

On this page

* [Properties](#properties)
* [authDescriptor](#authdescriptor)
* [keyStore](#keystore)
* [Methods](#methods)
* [authorize](#authorize)
* [getSigners](#getsigners)
* [satisfiesAuthRequirements](#satisfiesauthrequirements)
* [sign](#sign)

Type that represents a key that is associated with an account.
It is responsible for using the wrapped key to sign and authorize
operations against an account.

```signature
interface KeyHandler {
    authDescriptor: AnyAuthDescriptor;
    keyStore: KeyStore;
    authorize(
        accountId: BufferId,
        operation: Operation,
        context: TxContext,
        authDataService: AuthDataService,
    ): Promise<Operation[]>;
    getSigners(): Buffer<ArrayBufferLike>[];
    satisfiesAuthRequirements(flags: string[]): boolean;
    sign(
        transaction: GTX,
        merkleHashVersionSource: MerkleHashVersionSource,
    ): Promise<Buffer<ArrayBufferLike>>;
}
```

## Properties

### authDescriptor

```signature
authDescriptor: AnyAuthDescriptor
```

### keyStore

```signature
keyStore: KeyStore
```

## Methods

### authorize

* ```signature
  authorize(
      accountId: BufferId,
      operation: Operation,
      context: TxContext,
      authDataService: AuthDataService,
  ): Promise<Operation[]>
  ```

  Authorizes an operation using the provided information
  and produces an array of operations that at least contains
  the operation to authorize. It might also contain auth operations
  as appropriate.

  #### Parameters

  + accountId: BufferId

    id of the account to authorize against
  + operation: Operation

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

    the context for the current transaction
  + authDataService: [AuthDataService](https://docs.chromia.com/pages/ft4-ts-client/interfaces/authentication.AuthDataService/)

    the auth data service to use when authorizing this operation

  #### Returns Promise<Operation[]>

### getSigners

* ```signature
  getSigners(): Buffer<ArrayBufferLike>[]
  ```

  Returns the signers of this key handler

  #### Returns Buffer<ArrayBufferLike>[]

### satisfiesAuthRequirements

* ```signature
  satisfiesAuthRequirements(flags: string[]): boolean
  ```

  Checks wether this key handler satisfies the auth requirements.
  In other words, it checks if the underlying key has **all** of
  the flags specified

  #### Parameters

  + flags: string[]

    the flags to check

  #### Returns boolean

  true if this key has all of the specified flags, else false

### sign

* ```signature
  sign(
      transaction: GTX,
      merkleHashVersionSource: MerkleHashVersionSource,
  ): Promise<Buffer<ArrayBufferLike>>
  ```

  Signs a transaction using the wrapped KeyStore

  #### Parameters

  + transaction: GTX

    the transaction to sign
  + merkleHashVersionSource: [MerkleHashVersionSource](https://docs.chromia.com/pages/ft4-ts-client/types/utils.MerkleHashVersionSource/)

    the source of the merkle hash version

  #### Returns Promise<Buffer<ArrayBufferLike>>

  the signed transaction, serialized as a `Buffer`

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