Skip to main content

SDK Authentication

The SDK supports two main auth patterns:

1. Session-first hosted login

Use this when you want the smoothest browser UX.
  1. Send users to https://neus.network/verify?intent=login&returnUrl=<your-url>.
  2. Let NEUS complete sign-in and any hosted interaction.
  3. If your deployment supports auth code exchange, redeem the returned code at POST /api/v1/auth/code/exchange.
This avoids hand-rolling proof-envelope signing for every action when the deployment has an active authenticated session model.

2. Signature-based verification

Use this when your integration needs the generic portable verification contract.
import { standardizeVerificationRequest, signMessage } from '@neus/sdk';

const standardized = await standardizeVerificationRequest(body, {
  apiUrl: 'https://api.neus.network'
});

const signature = await signMessage({
  provider: window.ethereum,
  walletAddress: body.walletAddress,
  message: standardized.signerString
});
Prefer standardizeVerificationRequest(...) over manually building a signing string. That keeps your client aligned with server normalization.

When to use which

PatternUse when
Hosted loginYou want the lowest-friction browser UX and your deployment supports session/code exchange
Direct signingYou need a generic integrator path that works without relying on a hosted session