Sign-in
CustomerSession
Section titled “CustomerSession”A device or browser the buyer is signed in on.
ID!
No description.
isCurrent
Section titled “isCurrent”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.
deviceLabel
Section titled “deviceLabel”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.
maskedIp
Section titled “maskedIp”String
The IP address the session last used, partially hidden.
approximateLocation
Section titled “approximateLocation”String
The city the IP resolved to, if any. Coarse and frequently wrong.
createdAt
Section titled “createdAt”DateTime!
When the session started.
lastSeenAt
Section titled “lastSeenAt”DateTime!
When it was last used.
CustomerSessionTokens
Section titled “CustomerSessionTokens”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.
accessToken
Section titled “accessToken”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.
accessTokenExpiresAt
Section titled “accessTokenExpiresAt”DateTime!
When the access token stops working.
refreshToken
Section titled “refreshToken”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.
refreshTokenExpiresAt
Section titled “refreshTokenExpiresAt”DateTime!
When the refresh token stops working, ending the session for good.
OtpChallenge
Section titled “OtpChallenge”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.
maskedPhone
Section titled “maskedPhone”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.
codeLength
Section titled “codeLength”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.
expiresAt
Section titled “expiresAt”DateTime!
When the code stops working. Short — minutes.
resendAfter
Section titled “resendAfter”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.
attemptsAllowed
Section titled “attemptsAllowed”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.
OtpRequestPayload
Section titled “OtpRequestPayload”What customerOtpRequest returns.
challenge
Section titled “challenge”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.
userErrors
Section titled “userErrors”[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.
OtpVerifyPayload
Section titled “OtpVerifyPayload”What customerOtpVerify returns.
tokens
Section titled “tokens”CustomerSessionTokens
The session, or null when the code was not accepted.
customer
Section titled “customer”Customer
The buyer, or null when the code was not accepted.
isNewCustomer
Section titled “isNewCustomer”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.
userErrors
Section titled “userErrors”[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.
SessionRevokePayload
Section titled “SessionRevokePayload”What customerSignOut and customerSessionRevoke return.
revoked
Section titled “revoked”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.
sessions
Section titled “sessions”[CustomerSession!]!
The sessions that remain, for a theme refreshing a device list.
userErrors
Section titled “userErrors”[UserError!]!
No description.
TokenRefreshPayload
Section titled “TokenRefreshPayload”What customerAccessTokenRefresh returns.
tokens
Section titled “tokens”CustomerSessionTokens
A fresh pair, or null when the refresh token was not accepted.
userErrors
Section titled “userErrors”[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.