The Authentication process with Index Network is vital for enabling secure and decentralized identity management. By creating and signing a SIWE (Sign in With Ethereum) message for a DID session, users engage in a secure authentication method that aligns with the principles of decentralization and data ownership inherent to Index Network.

This process ensures that users can interact with the network's features, such as creating and managing indexes, in a way that maintains their privacy and autonomy.

Authenticating using SDK

To start, instantiate the IndexClient by providing the necessary configuration parameters:

import IndexClient from '@indexnetwork/sdk';

const client = new IndexClient({
  domain: '',
  privateKey: '0xa7...b35',
  network: 'ethereum' // Optional, default is 'ethereum'

// Perform authentication
await client.authenticate();

Alternatively, the client can be initialized with a session string, which you can obtain by signing in with a wallet yourself.

const client = new IndexClient({
  domain: '',
  session: 'a0c...34e',

Under the hood, the method streamlines secure authentication by creating an Ethereum wallet with the user's private key for signing and blockchain interactions, generating a unique DID key for decentralized identity, and constructing and signing a SIWE message to request data access. It then creates a DID session using this message and DID key, containing an authentication token for future requests.

Finally, it stores this token within the IndexClient, automatically including it in API request headers for user authentication.

Sending the Signature in Requests

GET /identity/verify HTTP/1.1
Authorization: Bearer YOUR_SIGNATURE_HERE

Last updated