@masterunoco/casinowebengine-api 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,227 @@
1
+ # đŸ•šī¸ Gaming Platform – GameService SDK
2
+
3
+ A **TypeScript front-end SDK** for interacting with the `gameService` and related APIs across casino front-end projects.
4
+ It provides a unified interface for games, authentication, content, player preferences, website settings, and more — all with full type safety and automatic JWT handling.
5
+
6
+ ---
7
+
8
+ ## ✨ Features
9
+
10
+ - 🤩 **Typed API layer** – all endpoints return strongly-typed responses.
11
+ - 🔐 **Built-in JWT auth** – automatically attaches `Authorization: JWT <token>` to protected requests.
12
+ - 🌐 **Public + private endpoints** – transparent auth handling (`none`, `optional`, `required`).
13
+ - âš™ī¸ **Configurable** – base URL, brand, currency, language, and timeout.
14
+ - 🗾 **Persistent storage** – stores tokens and user data via localStorage helper.
15
+ - 🧠 **Framework-agnostic** – works with any front-end (React, Vue, Next.js, etc.).
16
+ - đŸĨˇ **Ready for npm** – ships with ESM + CJS + `.d.ts` types.
17
+
18
+ ---
19
+
20
+ ## đŸ“Ļ Installation
21
+
22
+ ### From npm (when published)
23
+ ```bash
24
+ npm install @cwe/frontend-sdk
25
+ ```
26
+
27
+ ### Local development
28
+ If the SDK is cloned locally:
29
+ ```bash
30
+ # In SDK directory
31
+ npm run build
32
+
33
+ # In your front-end project
34
+ npm install ../path-to/gameservice-sdk
35
+ # or
36
+ npm i file:../gameservice-sdk
37
+ ```
38
+
39
+ ### Workspace monorepo
40
+ If both live in the same repo:
41
+ ```json
42
+ "dependencies": {
43
+ "@cwe/frontend-sdk": "workspace:*"
44
+ }
45
+ ```
46
+
47
+ ---
48
+
49
+ ## 🧰 Basic Setup
50
+
51
+ ```ts
52
+ import { createGameSDK } from '@cwe/frontend-sdk';
53
+
54
+ const sdk = createGameSDK({
55
+ baseUrl: import.meta.env.VITE_GAMESERVICE_URL,
56
+ brand: 'BrandA',
57
+ defaultLanguage: 'en',
58
+ defaultCurrency: 'USD',
59
+ storage: localStorage,
60
+ storageKey: 'gp.jwt',
61
+ });
62
+ ```
63
+
64
+ ---
65
+
66
+ ## 🔑 Authentication
67
+
68
+ ```ts
69
+ // Login (stores JWT in localStorage automatically)
70
+ await sdk.auth.login('player3', '123123', '<recaptcha-token>');
71
+
72
+ // Check if authenticated
73
+ if (sdk.auth.isAuthenticated()) {
74
+ console.log('Logged in as', sdk.auth.getUser()?.username);
75
+ }
76
+
77
+ // Logout (clears token + user)
78
+ sdk.auth.clear();
79
+ ```
80
+
81
+ ---
82
+
83
+ ## 🤩 Example Usage
84
+
85
+ ### 🎮 Games
86
+ ```ts
87
+ // Search games
88
+ const result = await sdk.games.searchGames({ category: 'slots', page: 1 });
89
+ console.log(result.totalCount, result.results[0].name);
90
+
91
+ // Get demo link
92
+ const demo = await sdk.games.getDemoLink(1234);
93
+ window.open(demo.gameLink, '_blank');
94
+ ```
95
+
96
+ ### 📄 Content Pages
97
+ ```ts
98
+ const pages = await sdk.settings.listContentPages();
99
+ const about = await sdk.settings.getContentItem('about-us', 'en');
100
+ console.log(about.title);
101
+ ```
102
+
103
+ ### âš™ī¸ Preferences
104
+ ```ts
105
+ const prefs = await sdk.settings.getPreferences();
106
+ await sdk.settings.updatePreferences({ displayMode: 'dark' });
107
+ ```
108
+
109
+ ### đŸ’Ŧ Website Settings
110
+ ```ts
111
+ const footer = await sdk.settings.getWebSetting('en');
112
+ const providers = await sdk.settings.getWebSettingProviders('en');
113
+ const support = await sdk.settings.getSupportEmail('en');
114
+ ```
115
+
116
+ ### 🌍 Geolocation
117
+ ```ts
118
+ const geo = await sdk.geolocation.getGeolocation();
119
+ console.log(geo);
120
+ ```
121
+
122
+ ---
123
+
124
+ ## 🧱 Architecture
125
+
126
+ ```
127
+ src/
128
+ ├─ sdk.ts # Core GameSDK class
129
+ ├─ index.ts # Barrel exports
130
+ ├─ http/client.ts # Fetch wrapper with timeout & authPolicy
131
+ ├─ auth/jwtAuth.ts # JWT lifecycle (login, store, clear)
132
+ ├─ apis/
133
+ │ ├─ games.ts # /games, /games/search
134
+ │ ├─ settings.ts # /content-pages, /website-settings, /player/preferences
135
+ │ ├─ geo.ts # /geo/location
136
+ │ └─ ... (other feature modules)
137
+ ├─ types/
138
+ │ ├─ auth.ts
139
+ │ ├─ gamesSearch.ts
140
+ │ ├─ settings.ts
141
+ │ └─ signup.ts
142
+ └─ localStorage.ts # Persistent storage helper
143
+ ```
144
+
145
+ Each API module uses the shared `HttpClient` and defines its own types and interfaces.
146
+
147
+ ---
148
+
149
+ ## 🗾 Configuration Options
150
+
151
+ | Option | Type | Description |
152
+ |--------|------|-------------|
153
+ | `baseUrl` | `string` | Base API URL for gameService |
154
+ | `brand` | `string` | Optional brand name for `X-Brand` header |
155
+ | `defaultLanguage` | `string` | Default language header |
156
+ | `defaultCurrency` | `string` | Default currency header |
157
+ | `storage` | `Storage` | Browser storage (e.g., `localStorage`) |
158
+ | `storageKey` | `string` | Key under which JWT is stored |
159
+ | `timeoutMs` | `number` | Request timeout in milliseconds |
160
+
161
+ ---
162
+
163
+ ## đŸĨĒ Development
164
+
165
+ ```bash
166
+ # Build for production
167
+ npm run build
168
+
169
+ # Watch mode
170
+ npm run dev
171
+
172
+ # Type-check only
173
+ npm run typecheck
174
+
175
+ # Lint
176
+ npm run lint
177
+ ```
178
+
179
+ ---
180
+
181
+ ## đŸĨą Local Testing with Front-end
182
+
183
+ In your front-end project:
184
+
185
+ ```ts
186
+ import { createGameSDK } from '@cwe/frontend-sdk';
187
+
188
+ const sdk = createGameSDK({
189
+ baseUrl: 'https://api.yourdomain.com/game-service',
190
+ storage: localStorage,
191
+ storageKey: 'gp.jwt',
192
+ });
193
+
194
+ const games = await sdk.games.searchGames({ category: 'slots' });
195
+ console.log(games.results.length);
196
+ ```
197
+
198
+ ---
199
+
200
+ ## 🤩 Building Blocks (Available APIs)
201
+
202
+ | Module | Description |
203
+ |---------|-------------|
204
+ | `auth` | Handles login, token management, user retrieval |
205
+ | `games` | Search, list, and launch games |
206
+ | `settings` | Content pages, banners, preferences, currencies, and website settings |
207
+ | `geolocation` | Detect and cache player location |
208
+ | `localStorage` | Utility for token, user, and geo persistence |
209
+
210
+ ---
211
+
212
+ ## 🗾 Build Output
213
+
214
+ ```
215
+ dist/
216
+ ├─ index.js (ESM)
217
+ ├─ index.cjs (CJS)
218
+ └─ index.d.ts (Type declarations)
219
+ ```
220
+
221
+ ---
222
+
223
+ ## 🗾 License
224
+
225
+ MIT Š 2025 Gaming Platform
226
+ Developed by **Eyal (Venus Technology / Gaming Platform)**
227
+