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

> A utility class that is responsible for keeping track
of authorization details. Such as what operations there is,
what they require in terms of privileges 

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

Interface

# AuthDataService

On this page

* [Properties](#properties)
* [connection](#connection)
* [Methods](#methods)
* [getAllowedAuthDescriptor](#getallowedauthdescriptor)
* [getAuthDescriptorCounter](#getauthdescriptorcounter)
* [getAuthHandlerForOperation](#getauthhandlerforoperation)
* [getAuthMessageTemplate](#getauthmessagetemplate)
* [getBlockchainRid](#getblockchainrid)
* [getLoginConfig](#getloginconfig)

A utility class that is responsible for keeping track
of authorization details. Such as what operations there is,
what they require in terms of privileges and selecting the
correct auth descriptor for authorizing an operation.

```signature
interface AuthDataService {
    connection: Connection;
    getAllowedAuthDescriptor(
        operation: Operation,
        accountId: BufferId,
        adIds: BufferId[],
    ): Promise<Buffer<ArrayBufferLike> | null>;
    getAuthDescriptorCounter(
        accountId: BufferId,
        authDescriptorId: BufferId,
    ): Promise<number | null>;
    getAuthHandlerForOperation(
        operationName: string,
    ): Promise<AuthHandler | null>;
    getAuthMessageTemplate(
        operation: RellOperation | Operation,
    ): Promise<string>;
    getBlockchainRid(): Buffer;
    getLoginConfig(name?: string): Promise<LoginConfig>;
}
```

## Properties

### connection

```signature
connection: Connection
```

## Methods

### getAllowedAuthDescriptor

* ```signature
  getAllowedAuthDescriptor(
      operation: Operation,
      accountId: BufferId,
      adIds: BufferId[],
  ): Promise<Buffer<ArrayBufferLike> | null>
  ```

  Selects an auth descriptor from a list of auth descriptors which will be allowed
  to authorize the specified operation

  #### Parameters

  + operation: Operation

    the operation that is being authorized
  + accountId: BufferId

    the account for which the operation is being authorized
  + adIds: BufferId[]

    a list of auth descriptor ids to select from

  #### Returns Promise<Buffer<ArrayBufferLike> | null>

  first auth descriptor id from the provided list that will be allowed to authorize the operation,
  or null if none of the provided auth descriptors would be allowed.

### getAuthDescriptorCounter

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

  Fetches the current counter value for an auth descriptor when authorizing against a certain account.

  #### Parameters

  + accountId: BufferId

    the account id to authorize against
  + authDescriptorId: BufferId

    the auth descriptor to get the counter for

  #### Returns Promise<number | null>

  current counter value, or null if none was found

  #### Remarks

  if more than one operation is performed with this auth descriptor on this account in the same
  transaction, then this counter has to be manually increased after the first operation

### getAuthHandlerForOperation

* ```signature
  getAuthHandlerForOperation(operationName: string): Promise<AuthHandler | null>
  ```

  Retrieves the auth handler that is defined for the operation with the provided name.
  If the operation does not have an auth handler specified, null is returned

  #### Parameters

  + operationName: string

    the name of the operation to get the auth handler for

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

### getAuthMessageTemplate

* ```signature
  getAuthMessageTemplate(operation: RellOperation | Operation): Promise<string>
  ```

  Returns the auth message template to use when signing a specified operation.

  #### Parameters

  + operation: RellOperation | Operation

    the operation to get the message for

  #### Returns Promise<string>

### getBlockchainRid

* ```signature
  getBlockchainRid(): Buffer
  ```

  Returns the blockchain rid to which this auth data service is configured.

  #### Returns Buffer

### getLoginConfig

* ```signature
  getLoginConfig(name?: string): Promise<LoginConfig>
  ```

  Retrieves the login config for a specific config name. If no name is provided,
  the default login config will be used.

  #### Parameters

  + `Optional`name: string

    the name of the login config

  #### Returns Promise<[LoginConfig](https://docs.chromia.com/pages/ft4-ts-client/types/authentication.LoginConfig/)>

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