# Authentication Integration

## Authentication Integration Flow <a href="#f822c50b-f33d-48c3-bb35-edab40bfaf74" id="f822c50b-f33d-48c3-bb35-edab40bfaf74"></a>

Some of the key features include:

* Assign an EOA to an enduser
* Authenticate the user in backend

<figure><img src="/files/nIdqm8EWxATW1QAYohnL" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}

#### Additional development is required as follows

{% endhint %}

#### Outline

If you are using Ethereum Signature Validator for verification, you need to restore the message that was used for the signature on the backend. Please add the following code to your backend. The reason for not sending the restored message directly from the frontend is to ensure that the message generated on the backend is revealed to be used for the signature. Without this assurance, there is a possibility of picking up any string and signature and impersonating someone else.

#### Summary

{% hint style="info" %}

#### Implementation Details of above Flow at No9 <a href="#a9e7ac77-e54a-461d-8f4a-15d9089c5123" id="a9e7ac77-e54a-461d-8f4a-15d9089c5123"></a>

{% endhint %}

1. Refetch the originalMessage
2. Add the logic to generate messageToBeSigned from originalMessage

```
// ① Fetch the originally generated string that was passed to the user
const originalMessage = await this.findOne(eoa)

let messageToBeSigned
if (prefix) {
	// ② Restore the messageToBeSigned, from the originalMessage, that was signed inside Startrail-sdk-js.
  messageToBeSigned = `${prefix}${originalMessage.length.toString()}${originalMessage}`;
} else {
	// Write the logic in case the prefix is undefined given the usecase that popup is not hidden
  messageToBeSigned = originalMessage
}

// HTTP call to Validator-API (message: messageToBeSigned, signature, address )
```


---

# 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.startrail.io/startrail-sdk-js/authentication-integration.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.
