@masterunoco/casinowebengine-api
v0.1.2
Published
Typed front-end SDK for casino web-engine API
Readme
🕹️ Casino Web Engine API SDK
A TypeScript front-end SDK for interacting with the casino web-engine API across casino front-end projects. It provides a unified interface for games, authentication, content, player preferences, website settings, and more — all with full type safety and automatic JWT handling.
✨ Features
- 🤩 Typed API layer – all endpoints return strongly-typed responses.
- 🔐 Built-in JWT auth – automatically attaches
Authorization: JWT <token>to protected requests. - 🌐 Public + private endpoints – transparent auth handling (
none,optional,required). - ⚙️ Configurable – base URL and timeout.
- 🗾 Persistent storage – stores tokens and user data via localStorage helper.
- 🧠 Framework-agnostic – works with any front-end (React, Vue, Next.js, etc.).
- 🥷 Ready for npm – ships with ESM + CJS +
.d.tstypes.
📦 Installation
npm install @masterunoco/casinowebengine-apiLocal development
If the SDK is cloned locally:
# In SDK directory
npm run build
# In your front-end project
npm install ../path-to/casinowebengine-api
# or
npm i file:../path-to/casinowebengine-api🧰 Basic Setup
import { createGameSDK } from '@masterunoco/casinowebengine-api';
const sdk = createGameSDK({
baseUrl: import.meta.env.VITE_GAMESERVICE_URL,
timeoutMs: 15000,
});🔑 Authentication
// Login (stores JWT in localStorage automatically)
await sdk.auth.login('player3', '123123', '<recaptcha-token>');
// Check if authenticated
if (sdk.auth.isAuthenticated()) {
console.log('Logged in as', sdk.auth.getUser()?.username);
}
// Logout (clears token + user)
sdk.auth.clear();🤩 Example Usage
🎮 Games
// Search games
const result = await sdk.games.searchGames({ category: 'slots', page: 1 });
console.log(result.totalCount, result.results[0].name);
// Get demo link
const demo = await sdk.games.getDemoLink(1234);
window.open(demo.gameLink, '_blank');📄 Content Pages
const pages = await sdk.settings.listContentPages();
const about = await sdk.settings.getContentItem('about-us', 'en');
console.log(about.title);⚙️ Preferences
const prefs = await sdk.settings.getPreferences();
await sdk.settings.updatePreferences({ displayMode: 'dark' });💬 Website Settings
const footer = await sdk.settings.getWebSetting('en');
const providers = await sdk.settings.getWebSettingProviders('en');
const support = await sdk.settings.getSupportEmail('en');🌍 Geolocation
const geo = await sdk.geolocation.getGeolocation();
console.log(geo);🧱 Architecture
src/
├─ sdk.ts # Core GameSDK class
├─ index.ts # Barrel exports
├─ http/client.ts # Fetch wrapper with timeout & authPolicy
├─ auth/jwtAuth.ts # JWT lifecycle (login, store, clear)
├─ apis/
│ ├─ games.ts
│ ├─ settings.ts
│ ├─ geo.ts
│ └─ ...
├─ types/
│ ├─ auth.ts
│ ├─ gamesSearch.ts
│ ├─ settings.ts
│ └─ signup.ts
└─ localStorage.ts🗾 Build Output
dist/
├─ index.js (ESM)
├─ index.cjs (CJS)
└─ index.d.ts (Type declarations)🗾 License
MIT © 2025
