Sessions

When an existing user wants to login, you can use the Sessions API to verify their credentials.

POST /sessions

Parameters

{
	challenge: string;
	credential: LoginCredentialSchema;
}

LoginCredentialSchema should be a stringified JSON object supplied by our front-end SDK. See the Front-End JavaScript SDK documentation

Response

{
  success: boolean,
  account: {
    id: string;
    email: string | null;
    workspaceId: string;
    username: string | null;
    createdAt: Date | null;
    updatedAt: Date | null;
  }
}

JavaScript SDK

import type { CreateAccountSessionResponse } from "@0x57/schemas";
 
// `result` already has this type implicitly!
const result: CreateAccountSessionResponse = await hex57.login({
	challenge,
	credential: JSON.parse(formData.get("credential")?.toString() ?? ""),
});