@idosgames/core
v0.8.0
Published
Engine-agnostic core of the IDosGames SDK (transport, auth, cache, services, events).
Maintainers
Readme
@idosgames/core
Engine-agnostic core of the IDosGames SDK — HTTP transport, authentication, local cache, 24 feature services, and a typed event bus. It knows nothing about any rendering engine (Three.js, Phaser, React…), so it works in any browser or JS runtime.
- Typed end to end. Every backend response is validated at runtime with zod before it reaches your code; the published type declarations are flat and lightweight.
- No exceptions on expected failures. Service calls return a discriminated
OperationResult<T>({ ok: true, data }or{ ok: false, reason, error }). - One client owns the whole graph. Create it once; reach every service and the local cache from it.
Install
npm install @idosgames/corePeer runtime deps (zod, decimal.js) are installed automatically.
Quick start
import { createIDosGamesClient, isOk } from "@idosgames/core";
import { BrowserPlatformAdapter } from "@idosgames/core/platform";
const client = createIDosGamesClient({
titleID: "YOUR_TITLE_ID",
platform: new BrowserPlatformAdapter(), // storage + platform integration
});
// Authenticate (device id, Telegram, email, Google, or a platform token).
const login = await client.auth.loginWithDeviceID();
if (!isOk(login)) {
console.error("login failed:", login.reason, login.error);
}
// Call any service — results are discriminated, never thrown.
const res = await client.currency.convert(
"Virtual",
"GOLD",
"Virtual",
"GEM",
100,
);
if (isOk(res)) {
console.log("credited:", res.data.TargetCredited);
}
// Read the local cache and react to changes via the typed event bus.
const off = client.on("currency:converted", (payload) => {
console.log("balances updated", payload);
});
// later: off();What's on the client
client.auth, user, currency, item, store, lootbox, reward, quest,
timedEvent, leaderboard, season, premium, character, match, craft,
collection, coopEvent, dealOffer, referral, social, timedBoost,
userCustomData, title, gameLoop — plus client.data (local cache) and
client.on/once/off (events).
Entry points
| Import | What |
| -------------------------- | ---------------------------------------------------------------------------------------------------------------- |
| @idosgames/core | client, services, models, result & event types |
| @idosgames/core/platform | platform adapters & storage (BrowserPlatformAdapter, NoopPlatformAdapter, BrowserStorage, MemoryStorage) |
Versioning
Semantic versioning. While on 0.x the public API is still stabilizing, so
breaking changes may land in a minor bump — see
CHANGELOG.md. The backend HTTP API version (/api/v2/…) is
independent of this package's version.
License
MIT © iDos Games
