SDK Authentication
The SDK supports two main auth patterns:
1. Session-first hosted login
Use this when you want the smoothest browser UX.
- Send users to
https://neus.network/verify?intent=login&returnUrl=<your-url>.
- Let NEUS complete sign-in and any hosted interaction.
- 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
| Pattern | Use when |
|---|
| Hosted login | You want the lowest-friction browser UX and your deployment supports session/code exchange |
| Direct signing | You need a generic integrator path that works without relying on a hosted session |