Custom Server
Use Custom Server when your backend issues signed identity JWTs for your app’s users. Connect the issuer URL in Projects → your project → General → Authentication → Custom Server. The configured issuer becomes read-only after connection.
Identity-token requirements
Your issuer must publish public signing keys at:
https://identity.example.com/.well-known/jwks.jsonReplace the example with your issuer. Modem verifies JWTs using those keys and accepts RS256 or ES256. The token must have the configured iss, a valid nonempty sub and a nonnegative integer iat. Any supplied expiry is checked. Issue short-lived expiring tokens in your own authentication system; do not expose a signing private key to the browser.
The subject should be your stable user ID. Changing it creates a different identity; an email address is not an account-linking mechanism.
Supply a token
import { createCustomerClient } from '@preternatural-js/client-sdk'
const client = createCustomerClient({
environment: 'production',
projectId: 'YOUR_PROJECT_ID',
authentication: {
type: 'identity-token-provider',
getIdentityToken: async () => {
const response = await fetch('/api/identity-token', { credentials: 'include' })
if (!response.ok) throw new Error('Could not obtain an identity token')
const { token } = await response.json()
return token
}
}
})/api/identity-token is an example endpoint you implement on your app’s backend. Authenticate the app user before issuing the token. Modem exchanges that identity token for its own customer session; it does not need your app’s signing private key.
Optional custom-server helpers
The Client SDK also exposes customServer.authorizationUrl() and customServer.registerWithEmailPassword() for a compatible authentication server. Those helpers do not implement an authentication server or replace the JWT/JWKS requirements above. See Client SDK authentication for their configuration and callback session handling.
If signing keys cannot be fetched, verification is temporarily unavailable. If signature, issuer or subject checks fail, obtain a correctly issued token. Replacing or disconnecting an issuer has the access consequences described in provider lifecycle.