sdk.auth namespace handles the complete customer authentication lifecycle: phone-based OTP login, registration for new customers, profile retrieval and updates, and logout.
OTP Authentication Flow
RMZ uses phone-based OTP (one-time password) authentication. The flow has three steps:- Start authentication — send an OTP to the customer’s phone
- Verify OTP — confirm the code the customer received
- Complete registration — (new customers only) provide name and email
Step 1: Start Phone Auth
| Field | Type | Description |
|---|---|---|
phone | string | Phone number (without country code) |
countryCode | string | Country code (e.g., '966' for Saudi Arabia) |
{ session_token: string }
Step 2: Verify OTP
| Field | Type | Description |
|---|---|---|
otp | string | The OTP code entered by the customer |
sessionToken | string | The session_token from step 1 |
{ token: string; customer: Customer }
Step 2b: Resend OTP
If the customer did not receive the code:Step 3: Complete Registration (New Customers)
For first-time customers, collect their details and complete registration:| Field | Type | Description |
|---|---|---|
firstName | string | Customer’s first name |
lastName | string | Customer’s last name |
email | string | Customer’s email address |
sessionToken | string | The session_token from step 1 |
{ token: string; customer: Customer }
Profile Management
auth.getProfile()
Retrieve the authenticated customer’s profile.
Customer
auth.updateProfile(data)
Update the authenticated customer’s profile.
Partial<Customer> — any subset of profile fields.
Returns: Customer
auth.logout()
Log out the customer and invalidate the current token.
void

