Skip to content

Auth

Phone-based OTP authentication. The recommended approach is the <configure-auth> web component, which handles the full flow. The SDK methods below are internal — used by the component, not called directly.

The drop-in web component that handles the complete phone OTP flow:

html
<script src="https://unpkg.com/configure/dist/configure-components.global.js"></script>
<configure-auth api-key="pk_..." agent="your-agent"></configure-auth>
<script>
  document.querySelector('configure-auth')
    .addEventListener('configure:authenticated', (e) => {
      const { token, userId } = e.detail;
    });
</script>

Attributes

NameTypeRequiredDescription
api-keystringYesPublishable key (pk_...) — safe for client-side use.
agentstringYesWhich agent is authenticating.
themestringNolight or dark. Defaults to system preference.
base-urlstringNoAPI base URL override for staging/local dev.

Events

EventDetailDescription
configure:authenticated{ token, userId, phone }Fired on successful auth.
configure:error{ message }Fired on auth failure.
configure:logout{}Fired when logout() is called.

Methods

MethodReturnsDescription
getToken()string | nullCurrent auth token.
getUserId()string | nullCurrent user ID.
logout()voidClears stored auth, resets to phone input.

SDK Methods (Internal)

WARNING

These methods are used internally by the <configure-auth> component. Use the component instead of calling these directly.

sendOtp

typescript
auth.sendOtp(phone: string): Promise<OtpStartResponse>

Send a one-time password to a phone number via SMS.

NameTypeRequiredDescription
phonestringYesPhone number in E.164 format (e.g., "+14155551234").

Returns { ok: boolean }.


verifyOtp

typescript
auth.verifyOtp(phone: string, code: string): Promise<OtpVerifyResponse>

Verify a 6-digit OTP code. Returns a JWT token and user ID on success.

NameTypeRequiredDescription
phonestringYesPhone number in E.164 format. Must match the number used in sendOtp.
codestringYes6-digit OTP code received via SMS.

Returns { token: string, userId: string }.


getDemo

typescript
auth.getDemo(): Promise<string>

Get a demo authentication token for development and testing. Not for production use.

Returns a demo JWT token string.

Identity and memory infrastructure for AI agents