# API Reference

## Index

* [createAuthRequest](/decentralized-identity-and-data/ontid/ont-login/front-end-javascript-sdk/api-reference.md#createauthrequest)
* [createSignData](/decentralized-identity-and-data/ontid/ont-login/front-end-javascript-sdk/api-reference.md#createsigndata)
* [requestQR](/decentralized-identity-and-data/ontid/ont-login/front-end-javascript-sdk/api-reference.md#requestqr)
* [queryQRResult](/decentralized-identity-and-data/ontid/ont-login/front-end-javascript-sdk/api-reference.md#queryqrresult)[  ](/decentralized-identity-and-data/ontid/ont-login/front-end-javascript-sdk/api-reference.md#cancelqueryqrresult)
* [cancelQueryQRResult](/decentralized-identity-and-data/ontid/ont-login/front-end-javascript-sdk/api-reference.md#cancelqueryqrresult)

## createAuthRequest

Creates`AuthRequest` to get the authentication challenge message.

#### Parameters&#x20;

| Parameter | Type   | Description                      |
| --------- | ------ | -------------------------------- |
| `action`  | `enum` | IdAuth: = 0 IdAuthAndVcAuth: = 1 |

#### **Returns**

[`AuthRequest`](/decentralized-identity-and-data/ontid/ont-login/protocol-specification.md#authentication-request)

## createSignData

Creates a message for the user to sign with the wallet.

{% hint style="info" %}
Convert the message to a JSON string before signing.
{% endhint %}

#### Parameters&#x20;

| Parameter       | Type            | Description                                                                                                              |
| --------------- | --------------- | ------------------------------------------------------------------------------------------------------------------------ |
| `AuthChallenge` | `AuthChallenge` | See details [here](/decentralized-identity-and-data/ontid/ont-login/protocol-specification.md#authentication-challenge). |
| `account`       | `string`        | DID of the signer (user).                                                                                                |

#### Returns&#x20;

[`SignData`](/decentralized-identity-and-data/ontid/ont-login/protocol-specification.md#signature-and-authorization)

## requestQR

Gets the challenge in the form of a QR code with `AuthChallenge`.

#### **Parameters**

[`AuthChallenge`](/decentralized-identity-and-data/ontid/ont-login/protocol-specification.md#authentication-challenge)

#### **Returns**

`Promise<QrResult>` **,** including the following properties:

| Property | Type     | Description                      |
| -------- | -------- | -------------------------------- |
| `id`     | `string` | QR code ID.                      |
| `text`   | `string` | Text for generating the QR code. |

## `queryQRResult`

Fetches the result of a user scanning the QR code.&#x20;

The query loops until a result or an error is returned. To stop the query, call [`cancelQueryQRResult`](/decentralized-identity-and-data/ontid/ont-login/front-end-javascript-sdk/api-reference.md#cancelqueryqrresult).

#### **Parameters**

| Property   | Type     | Description                                                       | Required |
| ---------- | -------- | ----------------------------------------------------------------- | -------- |
| `id`       | `string` | QR code ID.                                                       | Yes      |
| `duration` | `number` | Time interval between two queries, in milliseconds. Default: 1000 | No       |

#### **Returns**

[`Promise<ChallengeResponse>`](/decentralized-identity-and-data/ontid/ont-login/protocol-specification.md#authentication-response)

## cancelQueryQRResult

Stops querying the result of a QR code scan.

#### **Parameters**

None

#### **Returns**

`void`

## Errors

| Member              | Value                      |
| ------------------- | -------------------------- |
| `VersionNotSupport` | `ERR_WRONG_VERSION`        |
| `TypeNotSupport`    | `ERR_TYPE_NOT_SUPPORTED`   |
| `ActionNotSupport`  | `ERR_ACTION_NOT_SUPPORTED` |
| `UserCanceled`      | `USER_CANCELED`            |
| `UnknownError`      | `ERR_UNDEFINED`            |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ont.io/decentralized-identity-and-data/ontid/ont-login/front-end-javascript-sdk/api-reference.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
