0xDocs 0x.limo

Docs / JavaScript SDK

@0xlimo/paygate

Switched off on 0x.limo

x1-paygate lets only owners into a paid game's hosted site and hosted server. It is in the SDK source, but not published to the registry and not deployed on 0x.limo.

Not published, not deployed

@0xlimo/paygate 0.1.0 is in the SDK source (packages/paygate), but it is not published to the 0x registry, and it is not running on 0x.limo. The front does not route hosted sites through it, and x1-host has no paygate configured. What follows is how paid games will behave when it is switched on. One part is already live: a paid game's new versions are built origin-only, with no swarm.

You do not install or call x1-paygate yourself. It sits in front of the hosting service. What matters to you as a developer is how a paid game's site and server behave for players.

#What players see

  1. The launcher opens a paid game with ?x1_play=<play ticket>. Only owners get a ticket (POST /v1/apps/<appid>/play-ticket). Tickets last 5 minutes.

  2. The gate checks the ticket, then sets two cookies with a signed pass that lasts 12 h:

    • x1_pass with Path=/sites/<site>/
    • x1_pass with Path=/x1/game/<site>/

    Both are HttpOnly; Secure; SameSite=None; Partitioned. The gate then redirects to the same URL without x1_play.

  3. Every file of the site needs the pass, not only index.html. Without one the answer is 402 with a "Buy on 0x" page linking to the store. A bad or expired ticket gets 403 with the same page.

  4. A browser sends the /x1/game/<site>/ pass with the game's own HTTP and WebSocket requests, so @0xlimo/net and the templates need no change.

  5. A game client without the browser's cookies, such as a native client, connects with ?x1_play=<ticket>. x1-host removes the parameter before your server sees the request.

#What changes for a paid game's site

  • No swarm. New versions are built origin-only: x1.json is {"swarm": false} and there is no swarm/ manifest. The seeder skips paid sites. The gate also answers x1.json with {"swarm": false} and swarm/* with 404 for versions built before the game had a price.
  • Private caching. Paid sites get Cache-Control: private, so a shared cache does not keep them. Purge /sites/<site>/* at the CDN when a free game gets a price.

#Subscription-only games

The sites of subscription-only games are gated the same way. Only players with an active subscription get a play ticket, the refusal page says "Subscribe to on 0x", and passes last at most one hour, so a lapsed subscription is locked out within the hour. Subscriptions are switched off on 0x.limo (see @0xlimo/platform).

#Limits

  • A pass lasts 12 h, so a refund or revoked entitlement takes effect when it expires, not at once.
  • Anyone holding a ticket can exchange it during its 5 minutes. It is removed from the address at once.
  • The pass relies on partitioned cookies (CHIPS) in the store's iframe. A browser that refuses even partitioned cookies in a frame shows the buy page to owners too.

The module's exports are listed in the reference.