@0xlimo/paygate reference
Switched off on 0x.limoThe exports, cookies, pass format and HTTP answers of @0xlimo/paygate 0.1.0, which is in the SDK source and neither published nor deployed.
Not published, not deployed
Source only (packages/paygate, version 0.1.0). It is not in the 0x registry and does not run
on 0x.limo.
The entry point is src/index.js. The package has no typings; the signatures below are
written as TypeScript.
#Exports
const COOKIE = "x1_pass";
createGate(o: {
paid: { loaded: boolean; get(site: string): { appid: number; id: string; name: string; subscription?: boolean } | undefined };
cookieKey: Buffer;
ticketSecret?: Buffer | string; // or verifyUrl (POST {ticket} to the backend's /v1/play-tickets/verify)
verifyUrl?: string;
origin?: string; // the tickets' "o" must equal it: the sites' origin
storeUrl?: string; // default "https://0x.limo"; the buy link is <store>/game/<id>
passSecs?: number; // default 12 h
fetch?: typeof fetch; now?: () => number; log?: (o: object) => void;
}): { handler(req: IncomingMessage, res: ServerResponse): void }
target(uri: string): string // the original URI from the forwarded request
sign(key: Buffer, payload: string): string // <b64url(payload)>.<b64url(HMAC-SHA256)>
open(key: Buffer, token: string): object | null
verifyTicket(secret: Buffer | string, ticket: string, now?: number): object | null // checks e (expiry)
cookieKey(o: { cookieSecret?: string; ticketSecret?: string }): Buffer // derived: HMAC(ticketSecret, "x1-paygate pass cookie v1")
signPass(key: Buffer, p: { site: string; appid: number; steamid: string; expires: number }): string
verifyPass(key: Buffer, value: string, site: string, now?: number): object | null
cookieValues(header: string, name: string): string[]
class PaidSites { constructor(o: { url?: string; catalogUrl?: string; stateFile?: string; markerDir?: string; refreshMs?: number; log?: Function }); get(site: string): object | undefined; refresh(): Promise<void>; start(): Promise<PaidSites>; stop(): void; loaded: boolean; sites: Map<string, object>; at: number }
paidFromCatalog(catalog: object, sitesPath?: string): Record<string, { appid: number; id: string | null; name: string | null; subscription?: true }>
siteOf(url: string, sitesPath?: string): string | null#Pass
The cookie value is sign(key, JSON.stringify({v: 1, t: <site>, a: <appid>, s: <steamid>, e: <expiry, unix s>})).
A pass is valid for one site, until e. It lasts 12 h, or at most 1 h for subscription-only
games (SUBSCRIPTION_PASS_SECS = 3600).
#Answers
| Status | When |
|---|---|
| 2xx (pass through) | free site, or a valid pass for this site |
| 302 | a valid ?x1_play= ticket: sets the passes and redirects to the URL without it |
| 402 | no pass: the "Buy" (or "Subscribe") page |
| 403 | bad or expired ticket: the same page |
| 502 (Caddy) / 503 (x1-host) | the gate is down: paid sites are refused, free sites keep working |
#Paid sites list
The gate polls GET /v1/hosting/paid-sites every 30 s (public; it lists the sites of apps with
a price, {"<site>": {appid, id, name, subscription?}}).
