@clovnet/casino-sdk 1.0.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/LICENSE +21 -0
- package/README.md +148 -0
- package/dist/client-B3-Y0Xan.d.cts +2167 -0
- package/dist/client-BxHPrkxp.d.ts +2167 -0
- package/dist/contract-DtFe4bRy.d.cts +205 -0
- package/dist/contract-DtFe4bRy.d.ts +205 -0
- package/dist/index.cjs +2337 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +56 -0
- package/dist/index.d.ts +56 -0
- package/dist/index.js +2298 -0
- package/dist/index.js.map +1 -0
- package/dist/react/index.cjs +382 -0
- package/dist/react/index.cjs.map +1 -0
- package/dist/react/index.d.cts +118 -0
- package/dist/react/index.d.ts +118 -0
- package/dist/react/index.js +370 -0
- package/dist/react/index.js.map +1 -0
- package/dist/realtime/index.cjs +407 -0
- package/dist/realtime/index.cjs.map +1 -0
- package/dist/realtime/index.d.cts +6 -0
- package/dist/realtime/index.d.ts +6 -0
- package/dist/realtime/index.js +403 -0
- package/dist/realtime/index.js.map +1 -0
- package/package.json +111 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Clovnet
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# @clovnet/casino-sdk
|
|
2
|
+
|
|
3
|
+
[](https://github.com/casinowebengine/casino-sdk/actions/workflows/ci.yml)
|
|
4
|
+
[](https://www.npmjs.com/package/@clovnet/casino-sdk)
|
|
5
|
+
[](https://www.npmjs.com/package/@clovnet/casino-sdk)
|
|
6
|
+
|
|
7
|
+
The **player / casino frontend SDK** for the [CasinoWebEngine](https://github.com/casinowebengine) Runtime
|
|
8
|
+
Core. It wraps everything a player can do — auth, cashier, wallet, catalog, real game launch, and live
|
|
9
|
+
realtime updates — and hides the cross-cutting concerns (cookie session, CSRF, tenant header, idempotency
|
|
10
|
+
keys, reconnect, dedupe) so your frontend never thinks about them.
|
|
11
|
+
|
|
12
|
+
- **Framework-agnostic core** + optional **React bindings** (`/react`) and a standalone **realtime client** (`/realtime`).
|
|
13
|
+
- **Isomorphic**: browser, Node, and Next.js (SSR/RSC-safe — realtime is client-only).
|
|
14
|
+
- **Fully typed** end-to-end, dual **ESM + CJS**, tree-shakeable, zero secrets.
|
|
15
|
+
- Money is **integer minor units** with `formatMoney` display helpers.
|
|
16
|
+
|
|
17
|
+
> The SDK talks to the runtime over the network (`baseUrl` / `wsUrl`). It is **not** a code dependency of
|
|
18
|
+
> the runtime — it is the player HTTP/WS contract, typed.
|
|
19
|
+
|
|
20
|
+
## Install
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pnpm add @clovnet/casino-sdk
|
|
24
|
+
# React bindings need react as a peer; Node realtime needs ws:
|
|
25
|
+
pnpm add react ws
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Quickstart (login → deposit → lobby → launch → live balance)
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { createCasinoClient, formatMoney } from "@clovnet/casino-sdk";
|
|
32
|
+
|
|
33
|
+
const sdk = createCasinoClient({
|
|
34
|
+
baseUrl: "https://api.staging.example",
|
|
35
|
+
wsUrl: "wss://api.staging.example/realtime",
|
|
36
|
+
tenantId: "grandbet",
|
|
37
|
+
realtime: {
|
|
38
|
+
// Re-read authoritative state after every (re)connect — the socket accelerates, REST is truth.
|
|
39
|
+
resync: async () => {
|
|
40
|
+
const b = await sdk.wallet.getBalance();
|
|
41
|
+
console.log("balance", formatMoney(b.cash, b.currency));
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// 1. Authenticate (cookie session; CSRF + tenant handled for you)
|
|
47
|
+
await sdk.auth.login({ email: "player@example.com", password: "secret123" });
|
|
48
|
+
|
|
49
|
+
// 2. Deposit (amounts in scale-4 minor units; idempotency key auto-generated)
|
|
50
|
+
await sdk.cashier.deposit({ amount: 500_000 /* €50.00 */ });
|
|
51
|
+
|
|
52
|
+
// 3. Lobby (geo/currency-aware)
|
|
53
|
+
const { games } = await sdk.catalog.lobby({ country: "DE", limit: 24 });
|
|
54
|
+
|
|
55
|
+
// 4. Open a game session with a tenant-registered provider adapter → render the URL in an iframe
|
|
56
|
+
const { launchUrl } = await sdk.games.providerSession("fake", games[0]!.id);
|
|
57
|
+
|
|
58
|
+
// 5. Live balance over the realtime gateway
|
|
59
|
+
await sdk.realtime.connect();
|
|
60
|
+
sdk.realtime.on("wallet.balance", (e) => {
|
|
61
|
+
console.log("live balance", formatMoney(e.data.balances.cash, e.data.currency));
|
|
62
|
+
});
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### React
|
|
66
|
+
|
|
67
|
+
```tsx
|
|
68
|
+
"use client";
|
|
69
|
+
import {
|
|
70
|
+
CasinoProvider,
|
|
71
|
+
useAuth,
|
|
72
|
+
useBalance,
|
|
73
|
+
useLobby,
|
|
74
|
+
useGameLaunch,
|
|
75
|
+
} from "@clovnet/casino-sdk/react";
|
|
76
|
+
import { createCasinoClient, formatMoney } from "@clovnet/casino-sdk";
|
|
77
|
+
|
|
78
|
+
const sdk = createCasinoClient({ baseUrl, wsUrl, tenantId: "grandbet" });
|
|
79
|
+
|
|
80
|
+
export default function App() {
|
|
81
|
+
return (
|
|
82
|
+
<CasinoProvider client={sdk}>
|
|
83
|
+
<Wallet />
|
|
84
|
+
</CasinoProvider>
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function Wallet() {
|
|
89
|
+
const { player } = useAuth();
|
|
90
|
+
const { data: balance, connection } = useBalance(); // live, realtime-backed
|
|
91
|
+
return (
|
|
92
|
+
<div>
|
|
93
|
+
{player?.email} — {balance && formatMoney(balance.cash, balance.currency)} ({connection})
|
|
94
|
+
</div>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Plugin actions (`sdk.ext`)
|
|
100
|
+
|
|
101
|
+
Tenant-enabled plugins expose player-facing actions on the casino API. Discover them and call them with
|
|
102
|
+
the same DX as core modules — no build-time knowledge needed:
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
// Discovery (cached; ETag-revalidated)
|
|
106
|
+
const { plugins } = await sdk.ext.catalog();
|
|
107
|
+
|
|
108
|
+
// Generic — works for any enabled plugin:
|
|
109
|
+
const summary = await sdk.ext("cashback").call("getSummary");
|
|
110
|
+
await sdk.ext("cashback").call("claim", { periodId }); // idempotency key auto-generated
|
|
111
|
+
|
|
112
|
+
// Typed — when the plugin's generated client package is installed, its ExtRegistry
|
|
113
|
+
// augmentation narrows call() keys, input, and result:
|
|
114
|
+
import { cashback } from "@cwe-plugins/cashback-client";
|
|
115
|
+
const res = await cashback(sdk).claim({ periodId });
|
|
116
|
+
|
|
117
|
+
// Live plugin events
|
|
118
|
+
sdk.realtime.on("ext.cashback", (e) => console.log(e.data.type, e.data.payload));
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
React: `useExtCatalog()`, `useExtQuery(pluginKey, actionKey, input?, { refetchOn })`,
|
|
122
|
+
`useExtAction(pluginKey, actionKey)`.
|
|
123
|
+
|
|
124
|
+
## Modules
|
|
125
|
+
|
|
126
|
+
| Module | What |
|
|
127
|
+
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
128
|
+
| `sdk.auth` | signup, login, logout, refresh, me, social OAuth, sessions ("your devices"), password reset/change, email/phone verification, login history |
|
|
129
|
+
| `sdk.cashier` | deposit, withdraw, payment methods, deposit/withdrawal history + status, cancel withdrawal |
|
|
130
|
+
| `sdk.wallet` | balance buckets (cash/bonus/locked), transaction history, ledger |
|
|
131
|
+
| `sdk.catalog` | lobby, search, categories tree, providers, game detail, suggested, trending |
|
|
132
|
+
| `sdk.games` | provider game sessions → `{ launchUrl, sessionId }` (https-validated), bet + game-session history |
|
|
133
|
+
| `sdk.realtime` | ticket handshake → WS; channels `wallet.balance`/`deposit`/`withdrawal`, `gaming`, `bonus`, `player`, `ext.<pluginKey>` |
|
|
134
|
+
| `sdk.player` | profile, preferences, consents, responsible-gaming limits + cool-off/self-exclusion, account close / GDPR export |
|
|
135
|
+
| `sdk.kyc` | KYC status, requirements, history, document upload (multipart), submit |
|
|
136
|
+
| `sdk.affiliate` | public click tracking → `clickId` join key for signup attribution |
|
|
137
|
+
| `sdk.ext` | plugin actions: catalog discovery + `ext(pluginKey).call(actionKey, input)`; typed via `ExtRegistry` augmentation |
|
|
138
|
+
|
|
139
|
+
## Documentation
|
|
140
|
+
|
|
141
|
+
- [`docs/SDK_BIBLE.md`](docs/SDK_BIBLE.md) — the SDK's source of truth (design, auth/CSRF, realtime, errors, money, versioning, publishing, endpoint map).
|
|
142
|
+
- [`docs/guides/`](docs/guides) — per-module guides.
|
|
143
|
+
- API reference: `pnpm docs` (TypeDoc → `docs/api`).
|
|
144
|
+
- Local development & linking: [`docs/guides/linking.md`](docs/guides/linking.md).
|
|
145
|
+
|
|
146
|
+
## License
|
|
147
|
+
|
|
148
|
+
MIT
|