Treci la conținut
ZokoGames

Autentificare

Această pagină nu este încă tradusă și este afișată în engleză.

Embedding and sitelock policy

Pe această pagină

Embedding and sitelock policy

Where your game runs#

A game uploaded to ZokoGames is served from its own origin:

https://g-<your-game-slug>.zokogames.com/<build-id>/index.html

Covers come from https://imgs.zokogames.com/. Because each game has its own origin, your localStorage, cookies and service workers are isolated from every other game and from the portal. The portal page embeds the game in an iframe and the SDK talks to it through postMessage.

The iframe sandbox#

The frame carries these sandbox tokens:

allow-scripts allow-same-origin allow-forms allow-pointer-lock
allow-orientation-lock allow-modals allow-downloads allow-presentation

Popups are opt-in per game: tick the popup option in the technical step of the submission if you need one (for example an OAuth window). Without it, window.open and target="_blank" links are blocked.

The frame also delegates these permissions: autoplay, fullscreen, gamepad, clipboard-write, accelerometer, gyroscope, microphone, camera, xr-spatial-tracking and keyboard-map. A browser can still ask the player before it grants camera or microphone.

What this means in practice:

  • Do not depend on window.top, window.parent content or cookies shared with another site. Use SDK.data for saves.
  • Do not add your own fullscreen button. The portal provides one.
  • Pointer lock works after a user gesture. Handle Escape by pausing.
  • Navigation of the top window is blocked. Do not redirect players away from the game.

Sitelock#

Sitelock stops people re-hosting your build. It is optional, and it must never lock out the portal or your own testing.

const host = location.hostname;
const allowed =
  host === "zokogames.com" || host.endsWith(".zokogames.com") ||
  host === "localhost" || host === "127.0.0.1" || host.endsWith(".localhost");

if (!allowed) {
  document.body.textContent = "Play this game on zokogames.com";
  throw new Error("sitelock");
}

Rules:

  1. Allow zokogames.com and every subdomain of it. Game origins use the g-<slug> pattern today and may change; never lock to one exact hostname.
  2. Allow localhost so the SDK's local mode and the Preview tool keep working.
  3. Run the check before you load assets, but do not block the first frame on a network call.
  4. A visible message beats a blank screen. Reviewers must be able to tell a sitelock from a crash.

Hosting on your own server#

If you choose "on your own server" in the submission, your https page must allow being framed by the portal:

Content-Security-Policy: frame-ancestors 'self' https://zokogames.com https://*.zokogames.com

Do not send X-Frame-Options: DENY or SAMEORIGIN. Cross-origin cookies are not available in the frame, so use the data module and the verified token for identity. Games on your own host only earn when they use the SDK, and they are judged on time to gameplay. See technical requirements.

Embedding the SDK handshake#

You do not need to code the handshake. SDK.init() posts a request to the parent window, pins the origin that answers and ignores messages from anywhere else. If no portal answers within 1.5 seconds, the SDK falls back to local mode on localhost (or when the URL has useLocalSdk=true), and otherwise reports "disabled". See environments.

Ceva neclar, greșit sau lipsă pe această pagină? Spune-ne prin suport · Testează-ți jocul în instrumentul de previzualizare

Setări cookie-uri

Alege ce cookie-uri poate folosi ZokoGames. Cookie-urile necesare sunt mereu active, pentru că site-ul nu poate funcționa fără ele.

  • Autentificarea, limba și aceste alegeri. Mereu active.

  • Rețin lucruri precum jocurile jucate recent pe acest dispozitiv.

  • Numără jocurile și vizitele pe pagini cu un ID aleatoriu de vizitator, ca să putem îmbunătăți site-ul.

  • Permite reclame personalizate, care plătesc jocurile gratuite.