@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 +227 -0
- package/dist/index.cjs +902 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1379 -0
- package/dist/index.d.ts +1379 -0
- package/dist/index.js +892 -0
- package/dist/index.js.map +1 -0
- package/package.json +29 -0
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
|
+
|