Skip to content
Select theme
Light
Dark
Auto
Select language
English
فارسی

Sign-in

Object

A device or browser the buyer is signed in on.

ID!

No description.

Boolean!

Whether this is the session making the request.

So a theme can label it “این دستگاه” and put its revoke button somewhere harder to hit by accident.

String

What the platform could tell about the device — “Chrome on Android”.

Derived from the user agent, which lies, so treat it as a hint for a buyer recognising their own device and never as an identity.

String

The IP address the session last used, partially hidden.

String

The city the IP resolved to, if any. Coarse and frequently wrong.

DateTime!

When the session started.

DateTime!

When it was last used.

Object

A signed-in session: what to send, and what to renew it with.

Two tokens, deliberately. The access token is short-lived and travels on every request, so a leak from a log or a proxy expires quickly. The refresh token is long-lived, travels rarely, and can be revoked individually — which is what makes “sign out on that other device” possible at all.

String!

Send as Authorization: Bearer. Short-lived.

Store it in memory. Local storage survives an XSS; a cookie set by the theme is a cookie the theme has to protect.

DateTime!

When the access token stops working.

String

Exchange for a new pair before the access token expires.

Rotated on every use: a refresh token is single-use, and presenting a spent one revokes the whole session on the assumption it was stolen.

Null when the request said X-Kaladan-Session: cookie: the token is in the session cookie, which script cannot read, and nowhere else. A browser on the shop’s own origin should always ask for that; local storage survives an XSS, and so does anything a script can read.

DateTime!

When the refresh token stops working, ending the session for good.

Object

A pending one-time-code challenge.

Holds no secret: the id is safe to keep in component state, and knowing it without receiving the SMS is worth nothing.

ID!

Send this back with the code. Bound to one phone number and one attempt budget.

String!

The number the code went to, partially hidden — 0912***4567.

Echoed so the theme can render “کد به ۰۹۱۲***۴۵۶۷ ارسال شد” without holding the full number in the page, and so a buyer who mistyped can see it.

Int!

How many digits the code has, so the input can be built to fit.

Given rather than assumed: it is a platform setting, and a theme hard-coding five breaks the day it becomes six.

DateTime!

When the code stops working. Short — minutes.

DateTime!

The earliest another code may be requested for this number.

Render a countdown from it. A theme that enables “ارسال مجدد” before this produces a request that will be refused, and a buyer who thinks the site is broken.

Int!

How many wrong codes may be entered before the challenge is burned.

Shown so a theme can warn on the last attempt rather than silently failing.

Object

What customerOtpRequest returns.

OtpChallenge

The challenge. Null only when one could not be started at all.

Present whether or not the number belongs to an existing account — the two are indistinguishable by design.

[UserError!]!

Why no challenge was started.

INVALID for a number that is not a valid Iranian mobile. RATE_LIMITED with params.retryAfterSeconds when this number or this caller has asked too often — including when a previous challenge’s resendAfter has not passed.

Object

What customerOtpVerify returns.

CustomerSessionTokens

The session, or null when the code was not accepted.

Customer

The buyer, or null when the code was not accepted.

Boolean

Whether this verification created the account.

True on a buyer’s very first sign-in. A theme should use it to show the “complete your profile” step once, rather than nagging a returning buyer who chose not to give a name.

[UserError!]!

Why the code was not accepted.

OTP_INCORRECT with params.attemptsRemaining — retype it. EXPIRED — the code aged out; request another. OTP_CONSUMED — too many wrong tries, or already used; start over. NOT_FOUND — no such challenge id.

Object

What customerSignOut and customerSessionRevoke return.

Boolean!

Whether anything was revoked.

True for a token that was already invalid. Signing out twice is not an error, and reporting it as one only tells a caller which tokens were real.

[CustomerSession!]!

The sessions that remain, for a theme refreshing a device list.

[UserError!]!

No description.

Object

What customerAccessTokenRefresh returns.

CustomerSessionTokens

A fresh pair, or null when the refresh token was not accepted.

[UserError!]!

Why not.

EXPIRED — the session is over; sign in again. NOT_FOUND — unrecognized, already rotated, or revoked. Treat all three the same: clear local state and send the buyer to sign in.