@pokertools/sdk 1.0.11 → 1.0.15

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 CHANGED
@@ -8,7 +8,7 @@ The official TypeScript SDK for the **PokerTools** platform. Build real-time Tex
8
8
  ## ✨ Features
9
9
 
10
10
  - 🔌 **Real-time WebSocket Client**: Automatic reconnection, heartbeats, and typed events. JWTs are sent as WebSocket subprotocol credentials (not in the URL query string) to avoid leaking tokens in access logs.
11
- - 🎣 **React Hooks**: `PokerProvider`, `usePoker`, `usePokerClient`, `usePokerSocket`, `useTable`, `useUser`, `useTables`, `useConnection` for seamless UI integration.
11
+ - 🎣 **React Hooks**: `PokerProvider`, `usePoker`, `usePokerClient`, `usePokerSocket`, `useTable`, `useUser`, `useTables`, `useTournaments`, `useTournament`, `useConnection` for seamless UI integration.
12
12
  - 🔐 **Authentication**: Built-in support for Sign-In with Ethereum (SIWE), nonce/lifecycle helpers, and replay-safe withdrawal message generation.
13
13
  - 🛡️ **Type-Safe**: Full TypeScript support with shared types re-exported from `@pokertools/types`.
14
14
  - 🔄 **State Management**: Automatic synchronization of game state (snapshots + delta updates) with version-tracking and conditional fetching.
@@ -24,7 +24,7 @@ yarn add @pokertools/sdk @pokertools/types
24
24
  pnpm add @pokertools/sdk @pokertools/types
25
25
  ```
26
26
 
27
- `@pokertools/sdk` (v1.0.11) depends on `@pokertools/types` (v1.0.11) for shared TypeScript types.
27
+ `@pokertools/sdk` (v1.0.15) depends on `@pokertools/types` (v1.0.15) for shared TypeScript types.
28
28
  The React hooks require `react >= 19.2.3` as an **optional** peer dependency — install `react`
29
29
  and `react-dom` only if you plan to use the React integration.
30
30
 
@@ -159,12 +159,14 @@ The SDK bridges your frontend application with the PokerTools API and Real-time
159
159
 
160
160
  | Component | Description |
161
161
  | ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
162
- | `PokerClient` | Handles REST API requests (Tables, User, Finance, Notes, Health). Auto-retry with exponential backoff. |
162
+ | `PokerClient` | Handles REST API requests (Tables, Tournaments, User, Finance, Notes, Health). Auto-retry with exponential backoff. |
163
163
  | `PokerSocket` | Manages WebSocket connection, auto-reconnection, heartbeats, and typed real-time events. |
164
164
  | `PokerProvider` | React Context provider that initializes the client and socket. Accepts `autoConnect` prop (default `true`) to automatically connect the WebSocket when a token is present. |
165
165
  | `useTable` | Hook that subscribes to a specific table's real-time updates via WebSocket (snapshots + deltas). |
166
166
  | `useUser` | Hook to fetch and manage the current user's profile and balances. |
167
167
  | `useTables` | Hook to fetch the list of active tables from the REST API. |
168
+ | `useTournaments` | Hook to fetch active and registering tournament lobbies from the REST API. |
169
+ | `useTournament` | Hook to fetch one tournament's entries, table assignments, blind structure, and payout configuration. |
168
170
  | `usePoker` | Low-level hook to access the full `PokerContextValue` (client, socket, connection state). |
169
171
  | `usePokerClient` | Convenience hook to get the `PokerClient` instance. |
170
172
  | `usePokerSocket` | Convenience hook to get the `PokerSocket` instance (null if not connected). |
@@ -395,20 +397,28 @@ interface PokerSDKConfig {
395
397
 
396
398
  #### Methods
397
399
 
398
- | Method | Description |
399
- | --------------------------- | ----------------------------------------------------------------------- |
400
- | `setToken(token)` | Update or clear the JWT. |
401
- | `getToken()` | Get current token. |
402
- | `isAuthenticated()` | Check if token is present. |
403
- | `health()` | `GET /health` — health check. |
404
- | `getNonce()` | `POST /auth/nonce` — get SIWE nonce. |
405
- | `login(request)` | `POST /auth/login` — complete SIWE auth. |
406
- | `logout()` | `POST /auth/logout` — revoke session. |
407
- | `getTables()` | `GET /tables` — list active tables. |
408
- | `createTable(config)` | `POST /tables` — create a new table. Returns `tableId`. |
409
- | `getTableState(id, since?)` | `GET /tables/:id` — fetch state; returns `null` (via 304) if unchanged. |
410
- | `buyIn(tableId, request)` | `POST /tables/:id/buy-in` — join a table. |
411
- | `action(tableId, request)` | `POST /tables/:id/action` — execute game action. |
400
+ | Method | Description |
401
+ | --------------------------------- | ----------------------------------------------------------------------- |
402
+ | `setToken(token)` | Update or clear the JWT. |
403
+ | `getToken()` | Get current token. |
404
+ | `isAuthenticated()` | Check if token is present. |
405
+ | `health()` | `GET /health` — health check. |
406
+ | `getNonce()` | `POST /auth/nonce` — get SIWE nonce. |
407
+ | `login(request)` | `POST /auth/login` — complete SIWE auth. |
408
+ | `logout()` | `POST /auth/logout` — revoke session. |
409
+ | `getTables()` | `GET /tables` — list active tables. |
410
+ | `createTable(config)` | `POST /tables` — create a new table. Returns `tableId`. |
411
+ | `getTableState(id, since?)` | `GET /tables/:id` — fetch state; returns `null` (via 304) if unchanged. |
412
+ | `buyIn(tableId, request)` | `POST /tables/:id/buy-in` — join a table. |
413
+ | `action(tableId, request)` | `POST /tables/:id/action` — execute game action. |
414
+ | `getTournaments()` | `GET /tournaments` — list registration and running tournaments. |
415
+ | `createTournament(request)` | `POST /tournaments` — create a tournament lobby. |
416
+ | `getTournament(id)` | `GET /tournaments/:id` — fetch entries, tables, and payout config. |
417
+ | `registerTournament(id, request)` | `POST /tournaments/:id/register` — register and debit buy-in/fee. |
418
+ | `startTournament(id)` | `POST /tournaments/:id/start` — start and receive table distribution. |
419
+ | `reconcileTournament(id)` | `POST /tournaments/:id/reconcile` — run tournament-director balancing. |
420
+ | `advanceTournamentBlinds(id)` | `POST /tournaments/:id/advance-blinds` — advance active table blinds. |
421
+ | `settleTournament(id)` | `POST /tournaments/:id/settle` — pay configured prize distribution. |
412
422
 
413
423
  **Convenience action wrappers** (all return `Promise<PublicState>`):
414
424
 
@@ -556,26 +566,26 @@ Exported from `@pokertools/sdk` (25+ helpers for formatting, state inspection, a
556
566
 
557
567
  #### `@pokertools/sdk` (main entry)
558
568
 
559
- | Export | Kind |
560
- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------- |
561
- | `PokerClient` | Class |
562
- | `PokerSocket` | Class |
563
- | `createSiweMessage`, `parseSiweMessage`, `isSiweExpired`, `createWithdrawalMessage`, `generateIdempotencyKey` | Function |
564
- | `SiweMessageParams` | Type |
565
- | `formatChips`, `parseChips`, `getActivePlayer`, `getPlayerById`, `getPlayerSeat`, `isPlayerTurn`, `getCallAmount`, `getMinRaise`, `canCheck`, `canBet`, `getTotalPot`, `getActivePlayers`, `getPlayersInHand`, `suitToEmoji`, `formatCard`, `formatCards`, `getStreetName`, `isShowdown`, `isHandComplete`, `getPotOdds`, `abbreviateNumber` | Function |
566
- | `PokerSDKConfig`, `UserBalances`, `UserProfile`, `BlockchainInfo`, `TokenInfo`, `DepositSession`, `DepositRecord`, `WithdrawalRequest`, `WithdrawalRecord`, `HandHistoryEntry`, `PlayerNote`, `ConnectionState`, `PokerSocketEvents`, `EventListener` | Type |
567
- | `PokerSDKError` | Class |
568
- | `PublicState`, `PublicPlayer`, `GameState`, `Player`, `Action`, `ActionType`, `TableConfig`, `ServerMessage`, `ClientMessage`, `SnapshotMessage`, `StateUpdateMessage`, `ErrorMessage`, `JoinTableMessage`, `LeaveTableMessage`, `CreateTableRequest`, `BuyInRequest`, `AddChipsRequest`, `GameActionRequest`, `LoginRequest`, `LoginResponse`, `NonceResponse`, `TableListItem` | Type (re-exported from `@pokertools/types`) |
569
+ | Export | Kind |
570
+ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------- |
571
+ | `PokerClient` | Class |
572
+ | `PokerSocket` | Class |
573
+ | `createSiweMessage`, `parseSiweMessage`, `isSiweExpired`, `createWithdrawalMessage`, `generateIdempotencyKey` | Function |
574
+ | `SiweMessageParams` | Type |
575
+ | `formatChips`, `parseChips`, `getActivePlayer`, `getPlayerById`, `getPlayerSeat`, `isPlayerTurn`, `getCallAmount`, `getMinRaise`, `canCheck`, `canBet`, `getTotalPot`, `getActivePlayers`, `getPlayersInHand`, `suitToEmoji`, `formatCard`, `formatCards`, `getStreetName`, `isShowdown`, `isHandComplete`, `getPotOdds`, `abbreviateNumber` | Function |
576
+ | `PokerSDKConfig`, `UserBalances`, `UserProfile`, `BlockchainInfo`, `TokenInfo`, `DepositSession`, `DepositRecord`, `WithdrawalRequest`, `WithdrawalRecord`, `HandHistoryEntry`, `PlayerNote`, `ConnectionState`, `PokerSocketEvents`, `EventListener` | Type |
577
+ | `PokerSDKError` | Class |
578
+ | `PublicState`, `PublicPlayer`, `GameState`, `Player`, `Action`, `ActionType`, `TableConfig`, `ServerMessage`, `ClientMessage`, `SnapshotMessage`, `StateUpdateMessage`, `ErrorMessage`, `JoinTableMessage`, `LeaveTableMessage`, `CreateTableRequest`, `BuyInRequest`, `AddChipsRequest`, `GameActionRequest`, `LoginRequest`, `LoginResponse`, `NonceResponse`, `TableListItem`, `TournamentListItem`, `TournamentDetails`, `StartTournamentResponse`, `ReconcileTournamentResponse`, `SettleTournamentResponse` | Type (re-exported from `@pokertools/types`) |
569
579
 
570
580
  #### `@pokertools/sdk/react` (React subpath)
571
581
 
572
- | Export | Kind |
573
- | --------------------------------------------------------------------------------------------------- | --------- |
574
- | `PokerProvider` | Component |
575
- | `PokerProviderProps` | Type |
576
- | `PokerContextValue` | Type |
577
- | `usePoker`, `usePokerClient`, `usePokerSocket`, `useTable`, `useUser`, `useTables`, `useConnection` | Hook |
578
- | `UseTableOptions`, `UseTableResult`, `UseUserResult`, `UseTablesResult` | Type |
582
+ | Export | Kind |
583
+ | -------------------------------------------------------------------------------------------------------------------------------------- | --------- |
584
+ | `PokerProvider` | Component |
585
+ | `PokerProviderProps` | Type |
586
+ | `PokerContextValue` | Type |
587
+ | `usePoker`, `usePokerClient`, `usePokerSocket`, `useTable`, `useUser`, `useTables`, `useTournaments`, `useTournament`, `useConnection` | Hook |
588
+ | `UseTableOptions`, `UseTableResult`, `UseUserResult`, `UseTablesResult` | Type |
579
589
 
580
590
  ---
581
591