@jskit-ai/google-rewarded-core
v0.1.5
Published
Server runtime for Google rewarded unlock gates.
Readme
@jskit-ai/google-rewarded-core
Server runtime for Google rewarded unlock gates.
Package Shape
This package installs:
- four CRUD-owned server providers, one per persisted table
- one workflow provider for the rewarded gate API
The persisted tables are:
google_rewarded_rulesgoogle_rewarded_provider_configsgoogle_rewarded_watch_sessionsgoogle_rewarded_unlock_receipts
The package keeps the CRUD ownership strict:
- rules and provider configs are
workspace-owned - watch sessions and unlock receipts are
workspace_user-owned
Every owned row carries direct owner columns. The module does not rely on inherited ownership through parent joins.
What It Does
The workflow provider exposes four workspace-scoped app routes:
GET /api/w/:workspaceSlug/google-rewarded/currentPOST /api/w/:workspaceSlug/google-rewarded/startPOST /api/w/:workspaceSlug/google-rewarded/grantPOST /api/w/:workspaceSlug/google-rewarded/close
These are plain workflow endpoints, not CRUD JSON:API endpoints.
The flow is:
currentdecides whether the gate is enabled, blocked, or already unlocked.startcreates a watch session when a reward is required.grantmarks the session rewarded and creates an unlock receipt.closecloses a started session without granting access.
Day 0 is intentionally app-surface-only for the rewarded workflow. Rules and provider configs should therefore use surface = "app" for the active gate rows.
Required Data
Day-0 configuration lives in the CRUD-owned tables.
At minimum, apps need:
- a
google_rewarded_rulesrow for the targetgateKey - a matching enabled
google_rewarded_provider_configsrow for the surface
Important config fields:
google_rewarded_rules.gate_keygoogle_rewarded_rules.surfacegoogle_rewarded_rules.unlock_minutesgoogle_rewarded_rules.cooldown_minutesgoogle_rewarded_rules.daily_limitgoogle_rewarded_provider_configs.surfacegoogle_rewarded_provider_configs.ad_unit_pathgoogle_rewarded_provider_configs.script_mode
Day 0 assumes GPT rewarded ads for web, so script_mode should stay aligned with that flow.
Protecting Server Features
Protected server mutations should use the exported helper:
import { requireGoogleRewardedUnlock } from "@jskit-ai/google-rewarded-core/server/requireGoogleRewardedUnlock";The dedicated manual page is:
That page shows the exact service and provider wiring pattern.
Policy Model
This module is designed for rewarded unlocks, not for blocking all normal app use on boot.
Recommended usage:
- unlock bonus actions
- unlock extra quota
- unlock a temporary feature window
Do not treat it as a hard requirement for baseline product use unless the ad provider policy clearly allows that.
Install Notes
When an app adds this package, JSKIT installs the four schema migrations from templates/migrations/.
The package does not add day-0 settings pages automatically. Configuration can stay manual or be layered with app-specific UI later.
