Custom-server authentication
client.customServer targets an authentication server you operate. Configure customServerUrl and projectId; this setting does not configure an identity provider on its own. Your server must implement the routes and return Modem customer tokens.
import {
createCustomerClient,
CustomerOAuthProvider
} from '@preternatural-js/client-sdk'
const client = createCustomerClient({
environment: 'production',
projectId: 'your-project-id',
customServerUrl: 'https://api.example.com'
})
const url = client.customServer.authorizationUrl(
CustomerOAuthProvider.google,
'https://app.example.com/sign-in/callback',
{ sandboxMode: false }
)The URL defaults to /auth/{provider} with project_id, redirect_url, sandbox_mode and a request ID. The provider enum includes GitHub, Google and Twitter; your server must actually implement the selected provider. Override routePrefix: '/api/auth' if that is where your server mounts it. Redirect validation, provider credentials and callback handling belong to your server.
Register with email and password
const tokens = await client.customServer.registerWithEmailPassword({
email: 'customer@example.com',
password: passwordFromYourForm,
name: 'Example customer'
})This POSTs JSON to /api/auth/register?project_id=…; its default prefix differs from authorizationUrl. It validates and returns IssuedCustomerTokens, and does not automatically establish a CustomerSession. Use the authenticated customer identity and returned tokens to construct the session your application adopts; never infer a customer ID from an unverified form value.
The response must match the token schema. A malformed response becomes ApiClientError with INTERNAL_ERROR. This helper is not a hosted Modem email/password service. For Modem-hosted Sandbox GitHub sign-in, use Hosted GitHub sign-in.