@invonetwork/web-sdk 3.26.0 → 3.27.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/CHANGELOG.md +1369 -1350
- package/README.md +119 -1
- package/dist/chunk-2DYTV74W.js +3681 -0
- package/dist/chunk-3YDO7GSH.js +6 -0
- package/dist/chunk-6CN236QH.js +473 -0
- package/dist/{chunk-7BYAUHTA.js → chunk-VP3OK4J4.js} +56 -459
- package/dist/game-server.cjs +5933 -0
- package/dist/game-server.d.cts +185 -0
- package/dist/game-server.d.ts +185 -0
- package/dist/game-server.js +716 -0
- package/dist/game.cjs +2172 -0
- package/dist/game.d.cts +197 -0
- package/dist/game.d.ts +197 -0
- package/dist/game.js +1034 -0
- package/dist/index.cjs +87 -0
- package/dist/index.d.cts +19 -3
- package/dist/index.d.ts +19 -3
- package/dist/index.js +26 -2
- package/dist/server.cjs +98 -1
- package/dist/server.d.cts +28 -10
- package/dist/server.d.ts +28 -10
- package/dist/server.js +4 -3649
- package/dist/types-CoW9LopI.d.cts +143 -0
- package/dist/types-CoW9LopI.d.ts +143 -0
- package/dist/{types-Cjd4SAR8.d.cts → types-_lIm74kd.d.cts} +40 -1
- package/dist/{types-Cjd4SAR8.d.ts → types-_lIm74kd.d.ts} +40 -1
- package/dist/version-BXFwI0-s.d.cts +8 -0
- package/dist/version-BXFwI0-s.d.ts +8 -0
- package/package.json +91 -77
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { InvoServer } from './server.cjs';
|
|
2
|
+
import { G as GameCurrencyKind, a as GamePurchaseStatus, b as GameEconomyConfig } from './types-CoW9LopI.cjs';
|
|
3
|
+
export { c as GameCatalog, d as GameCatalogItem, e as GameCheckout, f as GameCurrencyBalance, g as GameErrorBody, h as GameItemPurchase, i as GamePlayer, j as GamePremiumPack, k as GamePurchase, l as GameSession, m as GameWallet } from './types-CoW9LopI.cjs';
|
|
4
|
+
export { I as InvoError } from './types-_lIm74kd.cjs';
|
|
5
|
+
export { S as SDK_VERSION } from './version-BXFwI0-s.cjs';
|
|
6
|
+
|
|
7
|
+
interface StoredPlayer {
|
|
8
|
+
id: string;
|
|
9
|
+
email: string;
|
|
10
|
+
/** E.164; kept server-side only. */
|
|
11
|
+
phone: string | null;
|
|
12
|
+
name: string;
|
|
13
|
+
createdAt: string;
|
|
14
|
+
}
|
|
15
|
+
interface StoredSession {
|
|
16
|
+
playerId: string;
|
|
17
|
+
expiresAt: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* One ledger line. Soft-currency entries ARE the soft balance. Premium entries are an audit
|
|
21
|
+
* copy of what INVO did (INVO holds the premium balance); they are never summed into a balance.
|
|
22
|
+
*/
|
|
23
|
+
interface LedgerEntry {
|
|
24
|
+
id: string;
|
|
25
|
+
playerId: string;
|
|
26
|
+
currency: GameCurrencyKind;
|
|
27
|
+
/** Signed whole units: positive credits, negative debits. */
|
|
28
|
+
amount: number;
|
|
29
|
+
reason: string;
|
|
30
|
+
/** Unique per entry; a second entry with the same ref is never written. */
|
|
31
|
+
ref: string;
|
|
32
|
+
at: string;
|
|
33
|
+
}
|
|
34
|
+
interface StoredPurchase {
|
|
35
|
+
purchaseRef: string;
|
|
36
|
+
playerId: string;
|
|
37
|
+
packId: string;
|
|
38
|
+
sessionId: string;
|
|
39
|
+
status: GamePurchaseStatus;
|
|
40
|
+
credited: number | null;
|
|
41
|
+
orderId: string | null;
|
|
42
|
+
createdAt: string;
|
|
43
|
+
updatedAt: string;
|
|
44
|
+
}
|
|
45
|
+
/** A remembered answer to an idempotent request, replayed on a retry. */
|
|
46
|
+
interface StoredIdempotentResult {
|
|
47
|
+
at: string;
|
|
48
|
+
result: unknown;
|
|
49
|
+
}
|
|
50
|
+
interface GameStoreState {
|
|
51
|
+
version: 1;
|
|
52
|
+
players: Record<string, StoredPlayer>;
|
|
53
|
+
sessions: Record<string, StoredSession>;
|
|
54
|
+
ledger: LedgerEntry[];
|
|
55
|
+
/** Ledger `ref` → entry id, so the "write once" check is O(1). */
|
|
56
|
+
ledgerRefs: Record<string, string>;
|
|
57
|
+
purchases: Record<string, StoredPurchase>;
|
|
58
|
+
/** `playerId:clientRequestId` → the answer given. */
|
|
59
|
+
idempotency: Record<string, StoredIdempotentResult>;
|
|
60
|
+
/** Player id → item id → quantity owned. */
|
|
61
|
+
inventory: Record<string, Record<string, number>>;
|
|
62
|
+
/** Webhook idempotency key → time processed. */
|
|
63
|
+
webhooks: Record<string, string>;
|
|
64
|
+
}
|
|
65
|
+
interface GameStore {
|
|
66
|
+
/** Read a consistent snapshot. Do not mutate it. */
|
|
67
|
+
read<T>(fn: (state: Readonly<GameStoreState>) => T): Promise<T>;
|
|
68
|
+
/**
|
|
69
|
+
* Run `fn` with exclusive access and persist whatever it changed. Calls are queued, never
|
|
70
|
+
* concurrent. If `fn` throws, nothing it changed is kept.
|
|
71
|
+
*/
|
|
72
|
+
transact<T>(fn: (state: GameStoreState) => T): Promise<T>;
|
|
73
|
+
}
|
|
74
|
+
declare function emptyGameState(): GameStoreState;
|
|
75
|
+
/** Keeps state in memory only. Good for tests and throwaway demos; lost on restart. */
|
|
76
|
+
declare function createMemoryGameStore(initial?: GameStoreState): GameStore;
|
|
77
|
+
interface FileGameStoreOptions {
|
|
78
|
+
/** Where the JSON file lives. Its folder is created if needed. */
|
|
79
|
+
file: string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Keeps state in one JSON file, written atomically (temp file + rename) after every
|
|
83
|
+
* transaction. Fine for a template or a small game on one server instance; use a real
|
|
84
|
+
* database (implement {@link GameStore}) when you run more than one instance.
|
|
85
|
+
*/
|
|
86
|
+
declare function createFileGameStore(options: FileGameStoreOptions): GameStore;
|
|
87
|
+
|
|
88
|
+
type GameServerLogLevel = "info" | "warn" | "error";
|
|
89
|
+
interface InvoGameServerOptions {
|
|
90
|
+
/** An {@link InvoServer} configured with this environment's game secret. */
|
|
91
|
+
invo: InvoServer;
|
|
92
|
+
/** The webhook signing secret from the INVO console (an array during rotation). */
|
|
93
|
+
webhookSecret: string | string[];
|
|
94
|
+
economy: GameEconomyConfig;
|
|
95
|
+
store: GameStore;
|
|
96
|
+
/** True when `invo` points at INVO's sandbox. Shown to players as a SANDBOX label. */
|
|
97
|
+
sandbox: boolean;
|
|
98
|
+
/** URL prefix for every route. Default `/api/invo`. */
|
|
99
|
+
basePath?: string;
|
|
100
|
+
/**
|
|
101
|
+
* Public origin players reach the game on (e.g. `https://my-game.replit.app`), used for the
|
|
102
|
+
* checkout's return links. Default: worked out from the request's forwarded headers.
|
|
103
|
+
*/
|
|
104
|
+
publicUrl?: string;
|
|
105
|
+
/** How long a sign-in lasts. Default 7 days. */
|
|
106
|
+
sessionTtlMs?: number;
|
|
107
|
+
/** Clock override for tests. */
|
|
108
|
+
now?: () => Date;
|
|
109
|
+
/** Structured log sink. Never receives secrets, tokens or full phone numbers. */
|
|
110
|
+
log?: (level: GameServerLogLevel, message: string, fields?: Record<string, unknown>) => void;
|
|
111
|
+
}
|
|
112
|
+
interface InvoGameServer {
|
|
113
|
+
readonly basePath: string;
|
|
114
|
+
/** Answer a request for one of this server's routes, or `null` when the path is not ours. */
|
|
115
|
+
handle(request: Request): Promise<Response | null>;
|
|
116
|
+
}
|
|
117
|
+
/** A refusal with an HTTP status and a stable code, answered as {@link GameErrorBody}. */
|
|
118
|
+
declare class GameServerError extends Error {
|
|
119
|
+
readonly status: number;
|
|
120
|
+
readonly code: string;
|
|
121
|
+
readonly requestId: string | undefined;
|
|
122
|
+
constructor(status: number, code: string, message: string, requestId?: string);
|
|
123
|
+
}
|
|
124
|
+
/** Check an economy config once at start-up; a mistake here should fail loudly, not at checkout. */
|
|
125
|
+
declare function validateEconomy(economy: GameEconomyConfig): void;
|
|
126
|
+
/** Stable, non-reversible player id derived from the email. */
|
|
127
|
+
declare function playerIdFor(email: string): string;
|
|
128
|
+
/** Build the game server. Pair it with {@link toNodeListener} or any Fetch-API host. */
|
|
129
|
+
declare function createInvoGameServer(options: InvoGameServerOptions): InvoGameServer;
|
|
130
|
+
interface InvoGameServerFromEnvOptions {
|
|
131
|
+
economy: GameEconomyConfig;
|
|
132
|
+
/** Usually `process.env`. Reads INVO_GAME_SECRET, INVO_WEBHOOK_SECRET, INVO_ENV, INVO_BASE_URL, PUBLIC_URL. */
|
|
133
|
+
env: Record<string, string | undefined>;
|
|
134
|
+
store: GameStore;
|
|
135
|
+
basePath?: string;
|
|
136
|
+
log?: InvoGameServerOptions["log"];
|
|
137
|
+
/**
|
|
138
|
+
* A stable id for this copy of the game (e.g. one per Replit fork), sent to INVO's sandbox
|
|
139
|
+
* as the `X-Invo-Project-Id` header so sandbox activity can be told apart per project and
|
|
140
|
+
* carried over when the project goes live. Not sent in production. Not a secret.
|
|
141
|
+
*/
|
|
142
|
+
projectId?: string;
|
|
143
|
+
/** Override `fetch` for the calls to INVO (tests, proxies). */
|
|
144
|
+
fetch?: typeof fetch;
|
|
145
|
+
}
|
|
146
|
+
/** What {@link invoGameServerFromEnv} found: a ready server, or the secrets still missing. */
|
|
147
|
+
interface InvoGameServerSetup {
|
|
148
|
+
server: InvoGameServer;
|
|
149
|
+
/** Names of required environment variables that are not set. Empty when ready. */
|
|
150
|
+
missing: string[];
|
|
151
|
+
sandbox: boolean;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Build the game server from environment variables (Replit Secrets, `.env`, your host's
|
|
155
|
+
* config). With secrets missing it still returns a server: every INVO route answers
|
|
156
|
+
* `503 INVO_SETUP_REQUIRED` naming what to add, `/health` and `/catalog` keep working, and the
|
|
157
|
+
* game itself stays playable.
|
|
158
|
+
*
|
|
159
|
+
* - `INVO_GAME_SECRET` (required): the game secret for this environment, from the INVO console
|
|
160
|
+
* - `INVO_WEBHOOK_SECRET` (required): the webhook signing secret; several, comma-separated, while rotating
|
|
161
|
+
* - `INVO_ENV`: `sandbox` (default) or `production`
|
|
162
|
+
* - `INVO_BASE_URL`: override the API base (rarely needed)
|
|
163
|
+
* - `PUBLIC_URL`: the game's public origin, for checkout return links
|
|
164
|
+
*/
|
|
165
|
+
declare function invoGameServerFromEnv(options: InvoGameServerFromEnvOptions): InvoGameServerSetup;
|
|
166
|
+
/** The parts of Node's `IncomingMessage` the adapter reads. */
|
|
167
|
+
interface NodeRequestLike {
|
|
168
|
+
method?: string;
|
|
169
|
+
url?: string;
|
|
170
|
+
headers: Record<string, string | string[] | undefined>;
|
|
171
|
+
[Symbol.asyncIterator](): AsyncIterator<Uint8Array | string>;
|
|
172
|
+
}
|
|
173
|
+
/** The parts of Node's `ServerResponse` the adapter writes. */
|
|
174
|
+
interface NodeResponseLike {
|
|
175
|
+
statusCode: number;
|
|
176
|
+
setHeader(name: string, value: string): unknown;
|
|
177
|
+
end(chunk?: Uint8Array | string): unknown;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Adapt the game server to Node's `http.createServer` (or Express/Connect middleware).
|
|
181
|
+
* Requests outside `basePath` go to `fallback` (your static files), or get a 404.
|
|
182
|
+
*/
|
|
183
|
+
declare function toNodeListener(server: InvoGameServer, fallback?: (req: NodeRequestLike, res: NodeResponseLike) => unknown): (req: NodeRequestLike, res: NodeResponseLike) => Promise<void>;
|
|
184
|
+
|
|
185
|
+
export { type FileGameStoreOptions, GameCurrencyKind, GameEconomyConfig, GamePurchaseStatus, GameServerError, type GameServerLogLevel, type GameStore, type GameStoreState, type InvoGameServer, type InvoGameServerFromEnvOptions, type InvoGameServerOptions, type InvoGameServerSetup, InvoServer, type LedgerEntry, type NodeRequestLike, type NodeResponseLike, type StoredIdempotentResult, type StoredPlayer, type StoredPurchase, type StoredSession, createFileGameStore, createInvoGameServer, createMemoryGameStore, emptyGameState, invoGameServerFromEnv, playerIdFor, toNodeListener, validateEconomy };
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { InvoServer } from './server.js';
|
|
2
|
+
import { G as GameCurrencyKind, a as GamePurchaseStatus, b as GameEconomyConfig } from './types-CoW9LopI.js';
|
|
3
|
+
export { c as GameCatalog, d as GameCatalogItem, e as GameCheckout, f as GameCurrencyBalance, g as GameErrorBody, h as GameItemPurchase, i as GamePlayer, j as GamePremiumPack, k as GamePurchase, l as GameSession, m as GameWallet } from './types-CoW9LopI.js';
|
|
4
|
+
export { I as InvoError } from './types-_lIm74kd.js';
|
|
5
|
+
export { S as SDK_VERSION } from './version-BXFwI0-s.js';
|
|
6
|
+
|
|
7
|
+
interface StoredPlayer {
|
|
8
|
+
id: string;
|
|
9
|
+
email: string;
|
|
10
|
+
/** E.164; kept server-side only. */
|
|
11
|
+
phone: string | null;
|
|
12
|
+
name: string;
|
|
13
|
+
createdAt: string;
|
|
14
|
+
}
|
|
15
|
+
interface StoredSession {
|
|
16
|
+
playerId: string;
|
|
17
|
+
expiresAt: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* One ledger line. Soft-currency entries ARE the soft balance. Premium entries are an audit
|
|
21
|
+
* copy of what INVO did (INVO holds the premium balance); they are never summed into a balance.
|
|
22
|
+
*/
|
|
23
|
+
interface LedgerEntry {
|
|
24
|
+
id: string;
|
|
25
|
+
playerId: string;
|
|
26
|
+
currency: GameCurrencyKind;
|
|
27
|
+
/** Signed whole units: positive credits, negative debits. */
|
|
28
|
+
amount: number;
|
|
29
|
+
reason: string;
|
|
30
|
+
/** Unique per entry; a second entry with the same ref is never written. */
|
|
31
|
+
ref: string;
|
|
32
|
+
at: string;
|
|
33
|
+
}
|
|
34
|
+
interface StoredPurchase {
|
|
35
|
+
purchaseRef: string;
|
|
36
|
+
playerId: string;
|
|
37
|
+
packId: string;
|
|
38
|
+
sessionId: string;
|
|
39
|
+
status: GamePurchaseStatus;
|
|
40
|
+
credited: number | null;
|
|
41
|
+
orderId: string | null;
|
|
42
|
+
createdAt: string;
|
|
43
|
+
updatedAt: string;
|
|
44
|
+
}
|
|
45
|
+
/** A remembered answer to an idempotent request, replayed on a retry. */
|
|
46
|
+
interface StoredIdempotentResult {
|
|
47
|
+
at: string;
|
|
48
|
+
result: unknown;
|
|
49
|
+
}
|
|
50
|
+
interface GameStoreState {
|
|
51
|
+
version: 1;
|
|
52
|
+
players: Record<string, StoredPlayer>;
|
|
53
|
+
sessions: Record<string, StoredSession>;
|
|
54
|
+
ledger: LedgerEntry[];
|
|
55
|
+
/** Ledger `ref` → entry id, so the "write once" check is O(1). */
|
|
56
|
+
ledgerRefs: Record<string, string>;
|
|
57
|
+
purchases: Record<string, StoredPurchase>;
|
|
58
|
+
/** `playerId:clientRequestId` → the answer given. */
|
|
59
|
+
idempotency: Record<string, StoredIdempotentResult>;
|
|
60
|
+
/** Player id → item id → quantity owned. */
|
|
61
|
+
inventory: Record<string, Record<string, number>>;
|
|
62
|
+
/** Webhook idempotency key → time processed. */
|
|
63
|
+
webhooks: Record<string, string>;
|
|
64
|
+
}
|
|
65
|
+
interface GameStore {
|
|
66
|
+
/** Read a consistent snapshot. Do not mutate it. */
|
|
67
|
+
read<T>(fn: (state: Readonly<GameStoreState>) => T): Promise<T>;
|
|
68
|
+
/**
|
|
69
|
+
* Run `fn` with exclusive access and persist whatever it changed. Calls are queued, never
|
|
70
|
+
* concurrent. If `fn` throws, nothing it changed is kept.
|
|
71
|
+
*/
|
|
72
|
+
transact<T>(fn: (state: GameStoreState) => T): Promise<T>;
|
|
73
|
+
}
|
|
74
|
+
declare function emptyGameState(): GameStoreState;
|
|
75
|
+
/** Keeps state in memory only. Good for tests and throwaway demos; lost on restart. */
|
|
76
|
+
declare function createMemoryGameStore(initial?: GameStoreState): GameStore;
|
|
77
|
+
interface FileGameStoreOptions {
|
|
78
|
+
/** Where the JSON file lives. Its folder is created if needed. */
|
|
79
|
+
file: string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Keeps state in one JSON file, written atomically (temp file + rename) after every
|
|
83
|
+
* transaction. Fine for a template or a small game on one server instance; use a real
|
|
84
|
+
* database (implement {@link GameStore}) when you run more than one instance.
|
|
85
|
+
*/
|
|
86
|
+
declare function createFileGameStore(options: FileGameStoreOptions): GameStore;
|
|
87
|
+
|
|
88
|
+
type GameServerLogLevel = "info" | "warn" | "error";
|
|
89
|
+
interface InvoGameServerOptions {
|
|
90
|
+
/** An {@link InvoServer} configured with this environment's game secret. */
|
|
91
|
+
invo: InvoServer;
|
|
92
|
+
/** The webhook signing secret from the INVO console (an array during rotation). */
|
|
93
|
+
webhookSecret: string | string[];
|
|
94
|
+
economy: GameEconomyConfig;
|
|
95
|
+
store: GameStore;
|
|
96
|
+
/** True when `invo` points at INVO's sandbox. Shown to players as a SANDBOX label. */
|
|
97
|
+
sandbox: boolean;
|
|
98
|
+
/** URL prefix for every route. Default `/api/invo`. */
|
|
99
|
+
basePath?: string;
|
|
100
|
+
/**
|
|
101
|
+
* Public origin players reach the game on (e.g. `https://my-game.replit.app`), used for the
|
|
102
|
+
* checkout's return links. Default: worked out from the request's forwarded headers.
|
|
103
|
+
*/
|
|
104
|
+
publicUrl?: string;
|
|
105
|
+
/** How long a sign-in lasts. Default 7 days. */
|
|
106
|
+
sessionTtlMs?: number;
|
|
107
|
+
/** Clock override for tests. */
|
|
108
|
+
now?: () => Date;
|
|
109
|
+
/** Structured log sink. Never receives secrets, tokens or full phone numbers. */
|
|
110
|
+
log?: (level: GameServerLogLevel, message: string, fields?: Record<string, unknown>) => void;
|
|
111
|
+
}
|
|
112
|
+
interface InvoGameServer {
|
|
113
|
+
readonly basePath: string;
|
|
114
|
+
/** Answer a request for one of this server's routes, or `null` when the path is not ours. */
|
|
115
|
+
handle(request: Request): Promise<Response | null>;
|
|
116
|
+
}
|
|
117
|
+
/** A refusal with an HTTP status and a stable code, answered as {@link GameErrorBody}. */
|
|
118
|
+
declare class GameServerError extends Error {
|
|
119
|
+
readonly status: number;
|
|
120
|
+
readonly code: string;
|
|
121
|
+
readonly requestId: string | undefined;
|
|
122
|
+
constructor(status: number, code: string, message: string, requestId?: string);
|
|
123
|
+
}
|
|
124
|
+
/** Check an economy config once at start-up; a mistake here should fail loudly, not at checkout. */
|
|
125
|
+
declare function validateEconomy(economy: GameEconomyConfig): void;
|
|
126
|
+
/** Stable, non-reversible player id derived from the email. */
|
|
127
|
+
declare function playerIdFor(email: string): string;
|
|
128
|
+
/** Build the game server. Pair it with {@link toNodeListener} or any Fetch-API host. */
|
|
129
|
+
declare function createInvoGameServer(options: InvoGameServerOptions): InvoGameServer;
|
|
130
|
+
interface InvoGameServerFromEnvOptions {
|
|
131
|
+
economy: GameEconomyConfig;
|
|
132
|
+
/** Usually `process.env`. Reads INVO_GAME_SECRET, INVO_WEBHOOK_SECRET, INVO_ENV, INVO_BASE_URL, PUBLIC_URL. */
|
|
133
|
+
env: Record<string, string | undefined>;
|
|
134
|
+
store: GameStore;
|
|
135
|
+
basePath?: string;
|
|
136
|
+
log?: InvoGameServerOptions["log"];
|
|
137
|
+
/**
|
|
138
|
+
* A stable id for this copy of the game (e.g. one per Replit fork), sent to INVO's sandbox
|
|
139
|
+
* as the `X-Invo-Project-Id` header so sandbox activity can be told apart per project and
|
|
140
|
+
* carried over when the project goes live. Not sent in production. Not a secret.
|
|
141
|
+
*/
|
|
142
|
+
projectId?: string;
|
|
143
|
+
/** Override `fetch` for the calls to INVO (tests, proxies). */
|
|
144
|
+
fetch?: typeof fetch;
|
|
145
|
+
}
|
|
146
|
+
/** What {@link invoGameServerFromEnv} found: a ready server, or the secrets still missing. */
|
|
147
|
+
interface InvoGameServerSetup {
|
|
148
|
+
server: InvoGameServer;
|
|
149
|
+
/** Names of required environment variables that are not set. Empty when ready. */
|
|
150
|
+
missing: string[];
|
|
151
|
+
sandbox: boolean;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Build the game server from environment variables (Replit Secrets, `.env`, your host's
|
|
155
|
+
* config). With secrets missing it still returns a server: every INVO route answers
|
|
156
|
+
* `503 INVO_SETUP_REQUIRED` naming what to add, `/health` and `/catalog` keep working, and the
|
|
157
|
+
* game itself stays playable.
|
|
158
|
+
*
|
|
159
|
+
* - `INVO_GAME_SECRET` (required): the game secret for this environment, from the INVO console
|
|
160
|
+
* - `INVO_WEBHOOK_SECRET` (required): the webhook signing secret; several, comma-separated, while rotating
|
|
161
|
+
* - `INVO_ENV`: `sandbox` (default) or `production`
|
|
162
|
+
* - `INVO_BASE_URL`: override the API base (rarely needed)
|
|
163
|
+
* - `PUBLIC_URL`: the game's public origin, for checkout return links
|
|
164
|
+
*/
|
|
165
|
+
declare function invoGameServerFromEnv(options: InvoGameServerFromEnvOptions): InvoGameServerSetup;
|
|
166
|
+
/** The parts of Node's `IncomingMessage` the adapter reads. */
|
|
167
|
+
interface NodeRequestLike {
|
|
168
|
+
method?: string;
|
|
169
|
+
url?: string;
|
|
170
|
+
headers: Record<string, string | string[] | undefined>;
|
|
171
|
+
[Symbol.asyncIterator](): AsyncIterator<Uint8Array | string>;
|
|
172
|
+
}
|
|
173
|
+
/** The parts of Node's `ServerResponse` the adapter writes. */
|
|
174
|
+
interface NodeResponseLike {
|
|
175
|
+
statusCode: number;
|
|
176
|
+
setHeader(name: string, value: string): unknown;
|
|
177
|
+
end(chunk?: Uint8Array | string): unknown;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Adapt the game server to Node's `http.createServer` (or Express/Connect middleware).
|
|
181
|
+
* Requests outside `basePath` go to `fallback` (your static files), or get a 404.
|
|
182
|
+
*/
|
|
183
|
+
declare function toNodeListener(server: InvoGameServer, fallback?: (req: NodeRequestLike, res: NodeResponseLike) => unknown): (req: NodeRequestLike, res: NodeResponseLike) => Promise<void>;
|
|
184
|
+
|
|
185
|
+
export { type FileGameStoreOptions, GameCurrencyKind, GameEconomyConfig, GamePurchaseStatus, GameServerError, type GameServerLogLevel, type GameStore, type GameStoreState, type InvoGameServer, type InvoGameServerFromEnvOptions, type InvoGameServerOptions, type InvoGameServerSetup, InvoServer, type LedgerEntry, type NodeRequestLike, type NodeResponseLike, type StoredIdempotentResult, type StoredPlayer, type StoredPurchase, type StoredSession, createFileGameStore, createInvoGameServer, createMemoryGameStore, emptyGameState, invoGameServerFromEnv, playerIdFor, toNodeListener, validateEconomy };
|