@voltro/plugin-engine-servers 0.0.0-stage → 0.90.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 +26466 -0
- package/LICENSE +61 -0
- package/README.md +25 -2
- package/SECURITY.md +56 -0
- package/THIRD-PARTY-NOTICES.md +8333 -0
- package/dist/antiCheat.js +14 -0
- package/dist/bootstrap.js +40 -0
- package/dist/contract.js +374 -0
- package/dist/errors.d.ts +23 -0
- package/dist/errors.js +30 -0
- package/dist/hotStore.js +43 -0
- package/dist/index.d.ts +1244 -0
- package/dist/index.js +8 -0
- package/dist/inspect.js +402 -0
- package/dist/plugin.js +189 -0
- package/dist/pool.d.ts +223 -0
- package/dist/pool.js +166 -0
- package/dist/port.js +4 -0
- package/dist/registry.server.js +884 -0
- package/dist/rows.js +20 -0
- package/dist/rpc.d.ts +329 -0
- package/dist/rpc.js +115 -0
- package/dist/server.d.ts +1365 -0
- package/dist/server.js +5 -0
- package/dist/session.server.js +687 -0
- package/dist/tables.entity.js +168 -0
- package/dist/tokens.js +97 -0
- package/dist/writes.js +16 -0
- package/package.json +85 -4
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Effect as e } from "effect";
|
|
2
|
+
// src/antiCheat.ts
|
|
3
|
+
var t = (t, n = {}) => {
|
|
4
|
+
let r = n.violationConfidence ?? .9;
|
|
5
|
+
if (!Number.isFinite(r) || r < 0 || r > 1) throw TypeError("serverReportedAntiCheat: violationConfidence must be between 0 and 1");
|
|
6
|
+
return Object.freeze({
|
|
7
|
+
name: t,
|
|
8
|
+
assess: (t) => e.succeed({
|
|
9
|
+
status: t.reported,
|
|
10
|
+
confidence: t.reported === "violation" ? r : 0
|
|
11
|
+
})
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
export { t as serverReportedAntiCheat };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { engineServersError as e } from "./errors.js";
|
|
2
|
+
import { ENGINE_SERVER_LIMITS as t } from "./contract.js";
|
|
3
|
+
import { Effect as n } from "effect";
|
|
4
|
+
import { MIN_SESSION_SECRET_LENGTH as r, timingSafeStringEqual as i } from "@voltro/protocol/session";
|
|
5
|
+
// src/bootstrap.ts
|
|
6
|
+
var a = (e) => {
|
|
7
|
+
let n = e(), i = [n?.current, ...n?.previous === void 0 ? [] : [n.previous]];
|
|
8
|
+
for (let e of i) if (typeof e != "string" || e.length < r || e.length > t.credentialLength.max) throw Error(`Engine server bootstrap secrets must be project-owned strings of ${r}..${t.credentialLength.max} characters; there is no default`);
|
|
9
|
+
if (n.previous !== void 0 && n.previous === n.current) throw Error("Engine server bootstrap rotation needs a different previous secret");
|
|
10
|
+
return n;
|
|
11
|
+
}, o = (t) => {
|
|
12
|
+
if (typeof t?.tenantId != "string" || !t.tenantId.trim() || t.tenantId.length > 256) throw TypeError("staticBootstrapSource: tenantId is required");
|
|
13
|
+
if (typeof t.secrets != "function") throw TypeError("staticBootstrapSource: secrets must be a function");
|
|
14
|
+
let r = t.tenantId, o = t.secrets, s = t.pools === void 0 ? void 0 : new Set(t.pools);
|
|
15
|
+
return Object.freeze({
|
|
16
|
+
name: "static",
|
|
17
|
+
check: () => {
|
|
18
|
+
a(o);
|
|
19
|
+
},
|
|
20
|
+
verify: ({ pool: t, credential: c }) => n.try({
|
|
21
|
+
try: () => {
|
|
22
|
+
if (s !== void 0 && !s.has(t)) return null;
|
|
23
|
+
let e = a(o), n = i(c, e.current), l = e.previous !== void 0 && i(c, e.previous);
|
|
24
|
+
return n || l ? { tenantId: r } : null;
|
|
25
|
+
},
|
|
26
|
+
catch: () => e("unavailable")
|
|
27
|
+
})
|
|
28
|
+
});
|
|
29
|
+
}, s = (e) => {
|
|
30
|
+
let t = new Map(Object.entries(e));
|
|
31
|
+
if (t.size === 0) throw TypeError("bootstrapByPool: at least one pool source is required");
|
|
32
|
+
return Object.freeze({
|
|
33
|
+
name: "by-pool",
|
|
34
|
+
check: () => {
|
|
35
|
+
for (let e of t.values()) e.check?.();
|
|
36
|
+
},
|
|
37
|
+
verify: (e) => t.get(e.pool)?.verify(e) ?? n.succeed(null)
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
export { s as bootstrapByPool, o as staticBootstrapSource };
|
package/dist/contract.js
ADDED
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
import { ENGINE_SERVER_PROTOCOLS as e, ENGINE_SERVER_SCOPES as t, ENGINE_SERVER_TRUST_LEVELS as n } from "./pool.js";
|
|
2
|
+
import { Schema as r } from "effect";
|
|
3
|
+
// src/contract.ts
|
|
4
|
+
var i = "_voltro_engine_servers", a = "_voltro_engine_server_credentials", o = "_voltro_engine_server_tickets", s = "_voltro_engine_server_sessions", c = "_voltro_engine_server_session_events", l = "_voltro_engine_server_reports", u = "_voltro_engine_server_anticheat", d = "_voltro_engine_server_backfills", f = "_voltro_engine_server_checkpoints", p = Object.freeze([
|
|
5
|
+
"starting",
|
|
6
|
+
"ready",
|
|
7
|
+
"allocated",
|
|
8
|
+
"draining",
|
|
9
|
+
"suspended",
|
|
10
|
+
"gone"
|
|
11
|
+
]), m = Object.freeze([
|
|
12
|
+
"starting",
|
|
13
|
+
"ready",
|
|
14
|
+
"allocated",
|
|
15
|
+
"draining"
|
|
16
|
+
]), h = Object.freeze([
|
|
17
|
+
"deregistered",
|
|
18
|
+
"lease_expired",
|
|
19
|
+
"revoked",
|
|
20
|
+
"recovered"
|
|
21
|
+
]), ee = Object.freeze([
|
|
22
|
+
"issued",
|
|
23
|
+
"redeemed",
|
|
24
|
+
"revoked",
|
|
25
|
+
"superseded",
|
|
26
|
+
"expired"
|
|
27
|
+
]), g = Object.freeze([
|
|
28
|
+
"running",
|
|
29
|
+
"waiting",
|
|
30
|
+
"recovering",
|
|
31
|
+
"ended",
|
|
32
|
+
"abandoned"
|
|
33
|
+
]), _ = Object.freeze([
|
|
34
|
+
"session.started",
|
|
35
|
+
"player.joined",
|
|
36
|
+
"player.left",
|
|
37
|
+
"session.recovering",
|
|
38
|
+
"session.recovered",
|
|
39
|
+
"session.ended"
|
|
40
|
+
]), v = Object.freeze([
|
|
41
|
+
"verified",
|
|
42
|
+
"unverified",
|
|
43
|
+
"violation",
|
|
44
|
+
"unknown"
|
|
45
|
+
]), y = "voltro.sessions.seat.v1", b = "voltro.engine-servers.service.v1", x = Object.freeze({
|
|
46
|
+
labels: 16,
|
|
47
|
+
labelKeyLength: 63,
|
|
48
|
+
labelValueLength: 128,
|
|
49
|
+
attributes: 32,
|
|
50
|
+
attributeKeyLength: 64,
|
|
51
|
+
attributeTextLength: 256,
|
|
52
|
+
tokenBytes: 4096,
|
|
53
|
+
ticketBytes: 8192,
|
|
54
|
+
credentialLength: {
|
|
55
|
+
min: 32,
|
|
56
|
+
max: 1024
|
|
57
|
+
},
|
|
58
|
+
leaseLength: 128,
|
|
59
|
+
sweepBatch: 64,
|
|
60
|
+
sessionIdLength: 191,
|
|
61
|
+
subjectIdLength: 256,
|
|
62
|
+
sequence: 1e6,
|
|
63
|
+
eventIdLength: 128,
|
|
64
|
+
reasonLength: 64,
|
|
65
|
+
standings: 4096,
|
|
66
|
+
stats: 64,
|
|
67
|
+
telemetryProperties: 32,
|
|
68
|
+
evidenceBytes: 8192,
|
|
69
|
+
checkpointBytes: 1048576,
|
|
70
|
+
checkpointRevision: 2147483647,
|
|
71
|
+
checkpointSchemaVersion: 65535
|
|
72
|
+
}), S = (e) => r.NonEmptyString.pipe(r.check(r.isMaxLength(e))), C = (e, t) => r.Number.pipe(r.check(r.isInt()), r.check(r.isBetween({
|
|
73
|
+
minimum: e,
|
|
74
|
+
maximum: t
|
|
75
|
+
}))), w = r.Number.pipe(r.check(r.isFinite())), T = S(x.tokenBytes), E = r.Record(r.String, r.String), D = r.Literals(e);
|
|
76
|
+
r.Literals(t);
|
|
77
|
+
var O = r.Literals(p), k = r.Struct({
|
|
78
|
+
id: S(64),
|
|
79
|
+
pool: S(63),
|
|
80
|
+
region: S(64),
|
|
81
|
+
buildId: S(128),
|
|
82
|
+
protocol: D,
|
|
83
|
+
address: r.NullOr(S(253)),
|
|
84
|
+
port: r.NullOr(C(1, 65535)),
|
|
85
|
+
relay: r.NullOr(S(512)),
|
|
86
|
+
capacity: C(1, 4096),
|
|
87
|
+
labels: E,
|
|
88
|
+
state: O,
|
|
89
|
+
sessionId: r.NullOr(S(x.sessionIdLength)),
|
|
90
|
+
registeredAt: w,
|
|
91
|
+
lastHeartbeatAt: w,
|
|
92
|
+
stateChangedAt: w,
|
|
93
|
+
goneReason: r.NullOr(r.Literals(h))
|
|
94
|
+
}), A = r.Struct({
|
|
95
|
+
token: T,
|
|
96
|
+
expiresAt: w
|
|
97
|
+
}), j = r.Union([
|
|
98
|
+
r.String,
|
|
99
|
+
r.Number,
|
|
100
|
+
r.Boolean,
|
|
101
|
+
r.Null
|
|
102
|
+
]), M = r.Record(r.String, j), N = r.Struct({
|
|
103
|
+
id: S(x.subjectIdLength),
|
|
104
|
+
type: r.Literals([
|
|
105
|
+
"user",
|
|
106
|
+
"apiKey",
|
|
107
|
+
"serviceAccount"
|
|
108
|
+
]),
|
|
109
|
+
kind: r.optionalKey(r.Literal("guest"))
|
|
110
|
+
}), P = r.Struct({
|
|
111
|
+
ticketId: S(64),
|
|
112
|
+
serverId: S(64),
|
|
113
|
+
sessionId: S(x.sessionIdLength),
|
|
114
|
+
subject: N,
|
|
115
|
+
partyId: r.NullOr(S(64)),
|
|
116
|
+
team: r.NullOr(S(64)),
|
|
117
|
+
attributes: M,
|
|
118
|
+
reconnect: r.Boolean,
|
|
119
|
+
reconnectUntil: w,
|
|
120
|
+
recovery: r.Boolean
|
|
121
|
+
});
|
|
122
|
+
r.Struct({
|
|
123
|
+
ticket: S(x.ticketBytes),
|
|
124
|
+
ticketId: S(64),
|
|
125
|
+
serverId: S(64),
|
|
126
|
+
redeemBy: w,
|
|
127
|
+
connect: r.Struct({
|
|
128
|
+
protocol: D,
|
|
129
|
+
address: r.NullOr(S(253)),
|
|
130
|
+
port: r.NullOr(C(1, 65535)),
|
|
131
|
+
relay: r.NullOr(S(512))
|
|
132
|
+
})
|
|
133
|
+
});
|
|
134
|
+
var F = r.Struct({
|
|
135
|
+
token: T,
|
|
136
|
+
region: S(64),
|
|
137
|
+
buildId: S(128),
|
|
138
|
+
protocol: D,
|
|
139
|
+
address: r.optionalKey(S(253)),
|
|
140
|
+
port: r.optionalKey(C(1, 65535)),
|
|
141
|
+
relay: r.optionalKey(S(512)),
|
|
142
|
+
capacity: r.optionalKey(C(1, 4096)),
|
|
143
|
+
labels: r.optionalKey(E)
|
|
144
|
+
}), I = S(x.leaseLength), L = r.Struct({
|
|
145
|
+
server: k,
|
|
146
|
+
token: T,
|
|
147
|
+
expiresAt: w,
|
|
148
|
+
heartbeatIntervalMs: C(1, 12e4),
|
|
149
|
+
lease: I
|
|
150
|
+
}), R = r.Struct({
|
|
151
|
+
token: T,
|
|
152
|
+
serverId: S(64),
|
|
153
|
+
lease: I
|
|
154
|
+
}), z = r.Struct({
|
|
155
|
+
server: k,
|
|
156
|
+
token: T,
|
|
157
|
+
expiresAt: w,
|
|
158
|
+
heartbeatIntervalMs: C(1, 12e4)
|
|
159
|
+
}), B = r.Struct({
|
|
160
|
+
state: O,
|
|
161
|
+
drain: r.Boolean,
|
|
162
|
+
heartbeatIntervalMs: C(1, 12e4),
|
|
163
|
+
renewed: r.NullOr(A),
|
|
164
|
+
sessionId: r.NullOr(S(x.sessionIdLength)),
|
|
165
|
+
recovery: r.Boolean
|
|
166
|
+
}), V = r.Union([
|
|
167
|
+
r.String.pipe(r.check(r.isMaxLength(x.attributeTextLength))),
|
|
168
|
+
r.Number.pipe(r.check(r.isFinite())),
|
|
169
|
+
r.Boolean,
|
|
170
|
+
r.Null
|
|
171
|
+
]), H = (e) => r.Record(r.String.pipe(r.check(r.isPattern(/^[A-Za-z0-9_.:-]{1,64}$/))), V).pipe(r.check(r.makeFilter((t) => Object.keys(t).length <= e))), U = S(x.subjectIdLength), W = S(x.sessionIdLength), G = S(x.reasonLength), K = r.String.pipe(r.check(r.isPattern(/^[1-9][0-9]{0,29}$/))), q = r.String.pipe(r.check(r.isPattern(/^(?:0|-?[1-9][0-9]{0,18})$/))), J = r.Union([
|
|
172
|
+
r.Struct({ type: r.Literal("session.started") }),
|
|
173
|
+
r.Struct({
|
|
174
|
+
type: r.Literal("player.joined"),
|
|
175
|
+
playerId: U
|
|
176
|
+
}),
|
|
177
|
+
r.Struct({
|
|
178
|
+
type: r.Literal("player.left"),
|
|
179
|
+
playerId: U,
|
|
180
|
+
reconnect: r.optionalKey(r.Boolean)
|
|
181
|
+
}),
|
|
182
|
+
r.Struct({ type: r.Literal("session.recovered") }),
|
|
183
|
+
r.Struct({
|
|
184
|
+
type: r.Literal("session.ended"),
|
|
185
|
+
reason: r.optionalKey(G)
|
|
186
|
+
})
|
|
187
|
+
]), Y = r.Struct({
|
|
188
|
+
token: T,
|
|
189
|
+
sessionId: W,
|
|
190
|
+
sequence: C(1, x.sequence),
|
|
191
|
+
event: J
|
|
192
|
+
}), X = r.Struct({
|
|
193
|
+
sessionId: S(x.sessionIdLength),
|
|
194
|
+
sequence: C(1, x.sequence),
|
|
195
|
+
replay: r.Boolean,
|
|
196
|
+
state: r.Literals(g)
|
|
197
|
+
}), Z = r.Union([
|
|
198
|
+
r.Struct({
|
|
199
|
+
kind: r.Literal("inventory.grant"),
|
|
200
|
+
playerId: U,
|
|
201
|
+
itemId: S(128),
|
|
202
|
+
qty: C(1, 1e9),
|
|
203
|
+
attributes: r.optionalKey(H(x.attributes)),
|
|
204
|
+
reason: G
|
|
205
|
+
}),
|
|
206
|
+
r.Struct({
|
|
207
|
+
kind: r.Literal("inventory.consume"),
|
|
208
|
+
playerId: U,
|
|
209
|
+
instanceId: S(128),
|
|
210
|
+
qty: C(1, 1e9),
|
|
211
|
+
reason: G
|
|
212
|
+
}),
|
|
213
|
+
r.Struct({
|
|
214
|
+
kind: r.Literal("economy.grant"),
|
|
215
|
+
playerId: U,
|
|
216
|
+
currency: S(64),
|
|
217
|
+
amount: K,
|
|
218
|
+
reason: G
|
|
219
|
+
}),
|
|
220
|
+
r.Struct({
|
|
221
|
+
kind: r.Literal("economy.charge"),
|
|
222
|
+
playerId: U,
|
|
223
|
+
currency: S(64),
|
|
224
|
+
amount: K,
|
|
225
|
+
reason: G
|
|
226
|
+
}),
|
|
227
|
+
r.Struct({
|
|
228
|
+
kind: r.Literal("progression.xp"),
|
|
229
|
+
playerId: U,
|
|
230
|
+
trackId: S(128),
|
|
231
|
+
amount: K
|
|
232
|
+
}),
|
|
233
|
+
r.Struct({
|
|
234
|
+
kind: r.Literal("progression.stat"),
|
|
235
|
+
playerId: U,
|
|
236
|
+
stat: S(128),
|
|
237
|
+
period: r.Literals(["lifetime", "season"]),
|
|
238
|
+
seasonId: r.optionalKey(S(128)),
|
|
239
|
+
operator: r.Literals([
|
|
240
|
+
"increment",
|
|
241
|
+
"max",
|
|
242
|
+
"min",
|
|
243
|
+
"set"
|
|
244
|
+
]),
|
|
245
|
+
operand: K
|
|
246
|
+
}),
|
|
247
|
+
r.Struct({
|
|
248
|
+
kind: r.Literal("progression.quest"),
|
|
249
|
+
playerId: U,
|
|
250
|
+
poolId: S(128),
|
|
251
|
+
windowId: S(128),
|
|
252
|
+
signal: r.Union([r.Struct({
|
|
253
|
+
kind: r.Literal("stat"),
|
|
254
|
+
stat: S(128),
|
|
255
|
+
delta: K
|
|
256
|
+
}), r.Struct({
|
|
257
|
+
kind: r.Literal("event"),
|
|
258
|
+
event: S(128),
|
|
259
|
+
data: r.optionalKey(H(x.attributes))
|
|
260
|
+
})])
|
|
261
|
+
}),
|
|
262
|
+
r.Struct({
|
|
263
|
+
kind: r.Literal("leaderboards.submit"),
|
|
264
|
+
playerId: U,
|
|
265
|
+
board: S(128),
|
|
266
|
+
score: q,
|
|
267
|
+
subscore: r.optionalKey(q),
|
|
268
|
+
metadata: r.optionalKey(H(x.attributes))
|
|
269
|
+
}),
|
|
270
|
+
r.Struct({
|
|
271
|
+
kind: r.Literal("telemetry.track"),
|
|
272
|
+
name: S(128),
|
|
273
|
+
playerId: r.optionalKey(U),
|
|
274
|
+
properties: r.optionalKey(H(x.telemetryProperties))
|
|
275
|
+
})
|
|
276
|
+
]), Q = r.Struct({
|
|
277
|
+
token: T,
|
|
278
|
+
sessionId: W,
|
|
279
|
+
eventId: S(x.eventIdLength),
|
|
280
|
+
write: Z
|
|
281
|
+
}), te = r.Struct({
|
|
282
|
+
eventId: S(x.eventIdLength),
|
|
283
|
+
kind: r.String,
|
|
284
|
+
requestId: S(128),
|
|
285
|
+
operationId: r.NullOr(r.String)
|
|
286
|
+
}), $ = r.Struct({
|
|
287
|
+
playerId: U,
|
|
288
|
+
rank: C(1, 4096),
|
|
289
|
+
team: r.optionalKey(S(64)),
|
|
290
|
+
score: r.optionalKey(q)
|
|
291
|
+
}), ne = r.Struct({
|
|
292
|
+
token: T,
|
|
293
|
+
sessionId: W,
|
|
294
|
+
outcome: r.Literals(["completed", "aborted"]),
|
|
295
|
+
standings: r.Array($).pipe(r.check(r.isMaxLength(x.standings))),
|
|
296
|
+
stats: r.optionalKey(H(x.stats)),
|
|
297
|
+
ratings: r.optionalKey(r.Struct({ pool: S(256) }))
|
|
298
|
+
}), re = r.Struct({
|
|
299
|
+
reportId: S(64),
|
|
300
|
+
sessionId: S(x.sessionIdLength),
|
|
301
|
+
trusted: r.Boolean,
|
|
302
|
+
digest: S(64),
|
|
303
|
+
replay: r.Boolean,
|
|
304
|
+
ratings: r.Literals(["applied", "skipped"])
|
|
305
|
+
});
|
|
306
|
+
r.Struct({
|
|
307
|
+
reportId: S(64),
|
|
308
|
+
serverId: S(64),
|
|
309
|
+
pool: S(63),
|
|
310
|
+
sessionId: S(x.sessionIdLength),
|
|
311
|
+
trust: r.Literals(n),
|
|
312
|
+
trusted: r.Boolean,
|
|
313
|
+
outcome: r.Literals(["completed", "aborted"]),
|
|
314
|
+
standings: r.Array(r.Struct({
|
|
315
|
+
playerId: r.NullOr(U),
|
|
316
|
+
rank: C(1, 4096),
|
|
317
|
+
team: r.NullOr(S(64)),
|
|
318
|
+
score: r.NullOr(q)
|
|
319
|
+
})),
|
|
320
|
+
stats: r.Record(r.String, V),
|
|
321
|
+
digest: S(64),
|
|
322
|
+
reportedAt: w
|
|
323
|
+
});
|
|
324
|
+
var ie = r.Struct({
|
|
325
|
+
token: T,
|
|
326
|
+
sessionId: W,
|
|
327
|
+
eventId: S(x.eventIdLength),
|
|
328
|
+
playerId: U,
|
|
329
|
+
status: r.Literals([
|
|
330
|
+
"verified",
|
|
331
|
+
"unverified",
|
|
332
|
+
"violation"
|
|
333
|
+
]),
|
|
334
|
+
evidence: r.optionalKey(S(x.evidenceBytes))
|
|
335
|
+
}), ae = r.Struct({
|
|
336
|
+
playerId: U,
|
|
337
|
+
status: r.Literals(v),
|
|
338
|
+
recorded: r.Boolean,
|
|
339
|
+
signal: r.Boolean
|
|
340
|
+
});
|
|
341
|
+
r.Struct({
|
|
342
|
+
serverId: S(64),
|
|
343
|
+
pool: S(63),
|
|
344
|
+
sessionId: S(x.sessionIdLength),
|
|
345
|
+
connected: r.Boolean,
|
|
346
|
+
joinable: r.Boolean,
|
|
347
|
+
freeSeats: C(0, 4096)
|
|
348
|
+
});
|
|
349
|
+
var oe = r.Struct({
|
|
350
|
+
token: T,
|
|
351
|
+
sessionId: W,
|
|
352
|
+
revision: C(1, x.checkpointRevision),
|
|
353
|
+
schemaVersion: C(1, x.checkpointSchemaVersion),
|
|
354
|
+
data: r.String.pipe(r.check(r.isMaxLength(x.checkpointBytes)))
|
|
355
|
+
}), se = r.Struct({
|
|
356
|
+
sessionId: S(x.sessionIdLength),
|
|
357
|
+
revision: C(1, x.checkpointRevision),
|
|
358
|
+
bytes: C(0, x.checkpointBytes),
|
|
359
|
+
replay: r.Boolean
|
|
360
|
+
}), ce = r.Struct({
|
|
361
|
+
token: T,
|
|
362
|
+
sessionId: W
|
|
363
|
+
}), le = r.Struct({
|
|
364
|
+
sessionId: S(x.sessionIdLength),
|
|
365
|
+
sequence: C(1, x.sequence),
|
|
366
|
+
recoveries: C(1, 64),
|
|
367
|
+
checkpoint: r.Struct({
|
|
368
|
+
revision: C(1, x.checkpointRevision),
|
|
369
|
+
schemaVersion: C(1, x.checkpointSchemaVersion),
|
|
370
|
+
data: r.String,
|
|
371
|
+
writtenAt: w
|
|
372
|
+
})
|
|
373
|
+
});
|
|
374
|
+
export { v as ANTICHEAT_STATUSES, u as ANTICHEAT_TABLE, ae as AntiCheatReceiptSchema, ie as AntiCheatReportInputSchema, d as BACKFILLS_TABLE, f as CHECKPOINTS_TABLE, a as CREDENTIALS_TABLE, oe as CheckpointInputSchema, se as CheckpointReceiptSchema, h as ENGINE_SERVER_GONE_REASONS, _ as ENGINE_SERVER_LIFECYCLE_EVENTS, x as ENGINE_SERVER_LIMITS, m as ENGINE_SERVER_LIVE_STATES, g as ENGINE_SERVER_SESSION_STATES, p as ENGINE_SERVER_STATES, ee as ENGINE_SERVER_TICKET_STATES, E as EngineServerLabelsSchema, I as EngineServerLeaseSchema, D as EngineServerProtocolSchema, k as EngineServerSchema, O as EngineServerStateSchema, T as EngineServerTokenSchema, B as HeartbeatOutputSchema, J as LifecycleEventSchema, ne as MatchReportInputSchema, re as MatchReportReceiptSchema, $ as MatchStandingSchema, l as REPORTS_TABLE, ce as RecoveryInputSchema, le as RecoverySchema, F as RegisterInputSchema, L as RegisterOutputSchema, R as ResumeInputSchema, z as ResumeOutputSchema, i as SERVERS_TABLE, b as SERVICE_TOKEN_PURPOSE, s as SESSIONS_TABLE, c as SESSION_EVENTS_TABLE, y as SESSION_SEAT_PURPOSE, j as SeatAttributeValueSchema, M as SeatAttributesSchema, N as SeatSubjectSchema, A as ServiceTokenSchema, Y as SessionEventInputSchema, X as SessionEventReceiptSchema, Q as SessionWriteInputSchema, te as SessionWriteReceiptSchema, Z as SessionWriteSchema, o as TICKETS_TABLE, P as VerifiedSeatSchema };
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Schema } from 'effect';
|
|
2
|
+
import { YieldableError } from 'effect/Cause';
|
|
3
|
+
|
|
4
|
+
/** Every refusal of the engine-server contract. Codes are stable wire values. */
|
|
5
|
+
export declare const ENGINE_SERVERS_ERROR_CODES: readonly ["invalid_input", "unauthenticated", "forbidden", "not_found", "unavailable", "conflict", "lease_lost", "lease_suspended", "revoked", "expired", "replayed", "wrong_server", "no_capacity", "invalid_ticket", "out_of_order", "rate_limited", "implausible", "not_seated", "rejected"];
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* `lease_suspended`: the server's lease lapsed and the server waits inside its pool's resume window; only its own
|
|
9
|
+
* process resumes it (`engineServers.resume`). `rejected` carries the refusing system's own error code in `reason` (for example `insufficient_funds`).
|
|
10
|
+
*/
|
|
11
|
+
export declare class EngineServersError extends EngineServersError_base {
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export declare const engineServersError: (code: EngineServersErrorCode, reason?: string) => EngineServersError;
|
|
15
|
+
|
|
16
|
+
declare const EngineServersError_base: Schema.Class<EngineServersError, Schema.TaggedStruct<"EngineServersError", {
|
|
17
|
+
readonly code: Schema.Literals<readonly ["invalid_input", "unauthenticated", "forbidden", "not_found", "unavailable", "conflict", "lease_lost", "lease_suspended", "revoked", "expired", "replayed", "wrong_server", "no_capacity", "invalid_ticket", "out_of_order", "rate_limited", "implausible", "not_seated", "rejected"]>;
|
|
18
|
+
readonly reason: Schema.optionalKey<Schema.String>;
|
|
19
|
+
}>, YieldableError>;
|
|
20
|
+
|
|
21
|
+
export declare type EngineServersErrorCode = typeof ENGINE_SERVERS_ERROR_CODES[number];
|
|
22
|
+
|
|
23
|
+
export { }
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Schema as e } from "effect";
|
|
2
|
+
// src/errors.ts
|
|
3
|
+
var t = Object.freeze([
|
|
4
|
+
"invalid_input",
|
|
5
|
+
"unauthenticated",
|
|
6
|
+
"forbidden",
|
|
7
|
+
"not_found",
|
|
8
|
+
"unavailable",
|
|
9
|
+
"conflict",
|
|
10
|
+
"lease_lost",
|
|
11
|
+
"lease_suspended",
|
|
12
|
+
"revoked",
|
|
13
|
+
"expired",
|
|
14
|
+
"replayed",
|
|
15
|
+
"wrong_server",
|
|
16
|
+
"no_capacity",
|
|
17
|
+
"invalid_ticket",
|
|
18
|
+
"out_of_order",
|
|
19
|
+
"rate_limited",
|
|
20
|
+
"implausible",
|
|
21
|
+
"not_seated",
|
|
22
|
+
"rejected"
|
|
23
|
+
]), n = class extends e.TaggedError()("EngineServersError", {
|
|
24
|
+
code: e.Literals(t),
|
|
25
|
+
reason: e.optionalKey(e.String.pipe(e.check(e.isPattern(/^[a-z][a-z0-9_]{0,63}$/))))
|
|
26
|
+
}) {}, r = (e, t) => new n(t === void 0 ? { code: e } : {
|
|
27
|
+
code: e,
|
|
28
|
+
reason: t
|
|
29
|
+
});
|
|
30
|
+
export { t as ENGINE_SERVERS_ERROR_CODES, n as EngineServersError, r as engineServersError };
|
package/dist/hotStore.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Duration as e, Effect as t } from "effect";
|
|
2
|
+
import { HotError as n } from "@voltro/kv/hot/contract";
|
|
3
|
+
// src/hotStore.ts
|
|
4
|
+
var r = 6e4, i = (e, t) => `engine-servers:writes-seen:${e}:${t}`, a = 2e3, o = (r, i) => {
|
|
5
|
+
if (!Number.isSafeInteger(i) || i < 1) throw RangeError("hotTimeoutMs must be a positive integer");
|
|
6
|
+
let a = (r, a, o) => o.pipe(t.timeoutOrElse({
|
|
7
|
+
duration: e.millis(i),
|
|
8
|
+
orElse: () => t.fail(new n({
|
|
9
|
+
operation: r,
|
|
10
|
+
key: a,
|
|
11
|
+
reason: "unavailable"
|
|
12
|
+
}))
|
|
13
|
+
}));
|
|
14
|
+
return Object.freeze({
|
|
15
|
+
zadd: (e, t, n) => a("zadd", e, r.zadd(e, t, n)),
|
|
16
|
+
zrem: (e, t) => a("zrem", e, r.zrem(e, t)),
|
|
17
|
+
zrank: (e, t, n, i) => a("zrank", e, r.zrank(e, t, n, i)),
|
|
18
|
+
zscore: (e, t, n) => a("zscore", e, r.zscore(e, t, n)),
|
|
19
|
+
zrange: (e, t, n, i) => a("zrange", e, r.zrange(e, t, n, i)),
|
|
20
|
+
zcard: (e, t) => a("zcard", e, r.zcard(e, t)),
|
|
21
|
+
zremRange: (e, t) => a("zremRange", e, r.zremRange(e, t)),
|
|
22
|
+
incrBy: (e, t, n) => a("incrBy", e, r.incrBy(e, t, n)),
|
|
23
|
+
tokenBucket: (e, t, n) => a("tokenBucket", e, r.tokenBucket(e, t, n)),
|
|
24
|
+
rateLimit: (e, t, n) => a("rateLimit", e, r.rateLimit(e, t, n)),
|
|
25
|
+
hset: (e, t, n) => a("hset", e, r.hset(e, t, n)),
|
|
26
|
+
hget: (e, t, n) => a("hget", e, r.hget(e, t, n)),
|
|
27
|
+
hgetAll: (e, t) => a("hgetAll", e, r.hgetAll(e, t)),
|
|
28
|
+
hdel: (e, t) => a("hdel", e, r.hdel(e, t)),
|
|
29
|
+
sadd: (e, t, n) => a("sadd", e, r.sadd(e, t, n)),
|
|
30
|
+
srem: (e, t) => a("srem", e, r.srem(e, t)),
|
|
31
|
+
smembers: (e, t) => a("smembers", e, r.smembers(e, t)),
|
|
32
|
+
sismember: (e, t, n) => a("sismember", e, r.sismember(e, t, n)),
|
|
33
|
+
setNx: (e, t, n) => a("setNx", e, r.setNx(e, t, n)),
|
|
34
|
+
compareDelete: (e, t) => a("compareDelete", e, r.compareDelete(e, t)),
|
|
35
|
+
compareExpire: (e, t, n) => a("compareExpire", e, r.compareExpire(e, t, n)),
|
|
36
|
+
expire: (e, t) => a("expire", e, r.expire(e, t)),
|
|
37
|
+
delete: (e) => a("delete", e, r.delete(e)),
|
|
38
|
+
scanPrefix: (e) => r.scanPrefix(e),
|
|
39
|
+
multi: (e) => a("multi", "", r.multi(e)),
|
|
40
|
+
capabilities: r.capabilities
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
export { a as ENGINE_SERVER_HOT_TIMEOUT_MS, r as ENGINE_SERVER_WRITE_WINDOW_MS, o as boundedHotStore, i as writeUsageKey };
|