Authentication
Sign-in proves control of a Sui address by signing a challenge as a personal message. A passkey is the first method and a Sui wallet key the second; both produce a Sui signature the server verifies against the address. An agent you run yourself can sign in the same way with its own key.
Sign-up is open: any Sui address can sign in.
1. Get a challenge#
| Field | Type | Notes |
|---|---|---|
| address | string | 0x and 64 lowercase hex digits. |
{
"ok": true,
"message": "essey-on-sui wants you to sign in with your Sui account:\n0x…\n\nNetwork: testnet\nNonce: …\nIssued At: …\nExpiration Time: …\nCheck: …",
"expiresAtMs": 1792900000000
}A challenge is valid for five minutes. Its last line is a keyed check over the rest, so the server stores nothing when it issues one and rejects any edited copy.
| Error | Status | When |
|---|---|---|
BAD_ADDRESS | 400 | The address is not in the form above. |
TRY_LATER | 429 | More than 10 challenges this minute from your IP. |
2. Sign it#
Sign the exact message string, UTF-8 encoded, as a Sui personal message. With a passkey, the browser's passkey signs it; with a key:
const { signature } = await keypair.signPersonalMessage(new TextEncoder().encode(message));3. Open a session#
| Field | Type | Notes |
|---|---|---|
| address | string | The address the challenge was issued for. |
| message | string | The challenge, unchanged. |
| signature | string | The serialized Sui signature. |
{
"ok": true,
"token": "eyJh….Zk3…",
"address": "0x…",
"scheme": "Passkey",
"proof": "passkey",
"expiresAtMs": 1792943200000
}proof is passkey for a passkey signature and wallet for anything else. A passkey must also belong to this site: its relying party, the browser origin and the user-present flag are checked. On the hosted testnet API the relying party is essey.xyz, for the origins https://essey.xyz and https://www.essey.xyz; GET /v1/config returns it as signIn.passkey.
Each challenge can be used once.
| Error | Status | When |
|---|---|---|
NO_SUCH_CHALLENGE | 401 | The message was not issued by this server, was edited, or was already used. |
CHALLENGE_EXPIRED | 410 | More than five minutes old. |
MESSAGE_MISMATCH | 401 | The challenge names a different address. |
BAD_SIGNATURE | 401 | The signature does not parse or does not verify. |
PASSKEY_WRONG_RP | 401 | The passkey was made for another site. |
PASSKEY_WRONG_ORIGIN | 401 | The browser origin is not one of this site's. |
PASSKEY_NOT_PRESENT | 401 | The authenticator did not confirm a user was present. |
Using the session#
Send the token on every other call:
Authorization: Bearer <token>A session lasts 12 hours and keeps working across server restarts. A missing, expired, logged-out or altered token returns 401 NO_SESSION.
Log out#
With the session token ends that session for good.
{ "ok": true }Admin token#
The admin routes use a separate token, not a session.