SDK Owner Setup

Panduan untuk yang deploy backend dan manage App Keys.

Halaman ini untuk SDK Owner

Kalau kamu developer game yang mau pakai SDK, kamu cukup lihat Getting Started — kamu hanya butuh AppKey. Halaman ini untuk yang deploy dan mengelola backend (infrastruktur penyedia SDK).

1. Setup Firebase (SDK Owner)

Satu Firebase project untuk semua developer yang pakai SDK kamu

Buat Firebase Project

  1. 1Go to console.firebase.google.com
  2. 2Buat project baru
  3. 3Tunggu init selesai

Enable Realtime Database

  1. 1Firebase Console → Realtime Database
  2. 2Klik "Create Database"
  3. 3Pilih region
  4. 4Start in Test Mode (dev) atau set rules untuk production
  5. 5Salin Database URL

Generate Service Account Key

  1. 1Project Settings → Service Accounts
  2. 2Generate New Private Key → Download JSON
  3. 3Ambil: project_id, client_email, private_key dari JSON

2. Deploy Backend ke Vercel

Satu deployment melayani semua developer

Local Dev dulu

bash
cd backend
cp .env.example .env
# isi .env dengan Firebase credentials kamu
npm install && npm run dev

Tanpa Firebase vars, backend pakai in-memory DB. AppKey apapun diterima di mode ini.

Deploy ke Vercel

bash
npm install -g vercel
cd backend
vercel

Setelah deploy, set env vars di Vercel Dashboard → Project → Settings → Environment Variables

KeyValue / Source
MASTER_KEYSecret kamu untuk buat App Keys baru
FIREBASE_PROJECT_IDJSON → project_id
FIREBASE_DATABASE_URLRealtime DB tab → URL
FIREBASE_CLIENT_EMAILJSON → client_email
FIREBASE_PRIVATE_KEYJSON → private_key (wrap in double quotes)

FIREBASE_PRIVATE_KEY harus dibungkus double quotes dan gunakan literal \n untuk newlines, bukan newline asli.

3. Buat App Key untuk Developer

Setiap game / developer dapat key unik yang terisolasi di Firebase

Gunakan endpoint POST /apps/register dengan MASTER_KEY kamu:

bash
curl -X POST https://api.mabar.studio/apps/register \
  -H "X-Master-Key: your-master-key" \
  -H "Content-Type: application/json" \
  -d '{ "name": "Nama Game Dev", "ownerEmail": "dev@example.com" }'

Response:

json
{
  "appKey": "mk_a1b2c3d4e5f6g7h8i9j0k1l2",
  "name": "Nama Game Dev",
  "message": "AppKey created. Share this with the developer."
}

Kirim appKey ke developer. Mereka paste di Unity Inspector — tidak ada setup lain. Data tiap key terisolasi di Firebase: apps/{appKey}/rooms/...

Troubleshooting