@voltro/plugin-engine-servers 0.0.0-stage → 0.91.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.
@@ -0,0 +1,168 @@
1
+ import { ANTICHEAT_STATUSES as e, ANTICHEAT_TABLE as t, BACKFILLS_TABLE as n, CHECKPOINTS_TABLE as r, CREDENTIALS_TABLE as i, ENGINE_SERVER_LIFECYCLE_EVENTS as a, ENGINE_SERVER_LIVE_STATES as o, ENGINE_SERVER_SESSION_STATES as s, ENGINE_SERVER_STATES as c, ENGINE_SERVER_TICKET_STATES as l, REPORTS_TABLE as u, SERVERS_TABLE as d, SESSIONS_TABLE as f, SESSION_EVENTS_TABLE as p, TICKETS_TABLE as m } from "./contract.js";
2
+ import { ENGINE_SERVER_PROTOCOLS as h, ENGINE_SERVER_TRUST_LEVELS as g } from "./pool.js";
3
+ import { boolean as _, id as v, integer as y, json as b, table as x, text as S, timestamp as C } from "@voltro/database";
4
+ // src/tables.entity.ts
5
+ var w = x(d, {
6
+ id: v({ prefix: "esv" }),
7
+ tenantId: S().maxLength(256).externalId().serverOnly(),
8
+ pool: S().maxLength(63).safe(),
9
+ region: S().maxLength(64).safe(),
10
+ buildId: S().maxLength(128).safe(),
11
+ protocol: S().maxLength(16).oneOf([...h]).safe(),
12
+ address: S().maxLength(253).nullable().safe(),
13
+ port: y().nullable().safe(),
14
+ relay: S().maxLength(512).nullable().safe(),
15
+ capacity: y().safe(),
16
+ labels: b().safe(),
17
+ state: S().maxLength(16).oneOf([...c]).safe(),
18
+ leaseId: S().maxLength(64).serverOnly(),
19
+ resumeState: S().maxLength(16).oneOf([...o]).nullable().safe(),
20
+ sessionId: S().maxLength(191).nullable().safe(),
21
+ version: y().default(0).safe(),
22
+ registeredAt: C().safe(),
23
+ lastHeartbeatAt: C().safe(),
24
+ stateChangedAt: C().safe(),
25
+ goneReason: S().maxLength(32).nullable().safe(),
26
+ sessionOrigin: S().maxLength(64).nullable().safe(),
27
+ exitedAt: C().nullable().safe()
28
+ }).index("byEngineServerPoolState", [
29
+ "tenantId",
30
+ "pool",
31
+ "state",
32
+ "region"
33
+ ]).index("byEngineServerHeartbeat", ["state", "lastHeartbeatAt"]).index("byEngineServerSession", ["tenantId", "sessionId"]), T = x(i, {
34
+ id: v({ prefix: "esc" }),
35
+ tenantId: S().maxLength(256).externalId().serverOnly(),
36
+ pool: S().maxLength(63).safe(),
37
+ serverId: S().maxLength(64).nullable().safe(),
38
+ issuedAt: C().safe(),
39
+ expiresAt: C().safe(),
40
+ revokedAt: C().nullable().safe()
41
+ }).index("byEngineServerCredentialPool", [
42
+ "tenantId",
43
+ "pool",
44
+ "revokedAt"
45
+ ]).index("byEngineServerCredentialServer", ["tenantId", "serverId"]), E = x(m, {
46
+ id: v({ prefix: "est" }),
47
+ tenantId: S().maxLength(256).externalId().sensitive("pii"),
48
+ serverId: S().maxLength(64).safe(),
49
+ sessionId: S().maxLength(191).safe(),
50
+ subjectId: S().maxLength(256).externalId().sensitive("pii"),
51
+ subjectKind: S().maxLength(16).oneOf(["user", "guest"]).safe(),
52
+ digest: S().maxLength(64).serverOnly(),
53
+ state: S().maxLength(16).oneOf([...l]).safe(),
54
+ issuedAt: C().safe(),
55
+ redeemBy: C().safe(),
56
+ redeemedAt: C().nullable().safe(),
57
+ redemptions: y().default(0).safe(),
58
+ joinedAt: C().nullable().safe(),
59
+ leftAt: C().nullable().safe(),
60
+ claims: b().sensitive("pii")
61
+ }).unique("byEngineServerTicketDigest", ["digest"]).index("byEngineServerTicketSubject", ["tenantId", "subjectId"]).index("byEngineServerTicketSession", [
62
+ "tenantId",
63
+ "serverId",
64
+ "sessionId",
65
+ "state"
66
+ ]), D = x(f, {
67
+ id: v({ prefix: "ess" }),
68
+ tenantId: S().maxLength(256).externalId().serverOnly(),
69
+ serverId: S().maxLength(64).safe(),
70
+ pool: S().maxLength(63).safe(),
71
+ sessionId: S().maxLength(191).safe(),
72
+ trust: S().maxLength(16).oneOf([...g]).safe(),
73
+ state: S().maxLength(16).oneOf([...s]).safe(),
74
+ sequence: y().safe(),
75
+ startedAt: C().safe(),
76
+ endedAt: C().nullable().safe(),
77
+ endReason: S().maxLength(64).nullable().safe(),
78
+ waitingSince: C().nullable().safe(),
79
+ resumedAt: C().nullable().safe(),
80
+ resumes: y().default(0).safe(),
81
+ recoveries: y().default(0).safe(),
82
+ recoveredAt: C().nullable().safe()
83
+ }).unique("byEngineServerSessionRun", [
84
+ "tenantId",
85
+ "serverId",
86
+ "sessionId"
87
+ ]).index("byEngineServerSessionState", [
88
+ "tenantId",
89
+ "serverId",
90
+ "state"
91
+ ]), O = x(p, {
92
+ id: v({ prefix: "ese" }),
93
+ tenantId: S().maxLength(256).externalId().sensitive("pii"),
94
+ runId: S().maxLength(64).safe(),
95
+ sequence: y().safe(),
96
+ type: S().maxLength(32).oneOf([...a]).safe(),
97
+ subjectId: S().maxLength(256).nullable().externalId().sensitive("pii"),
98
+ digest: S().maxLength(64).safe(),
99
+ at: C().safe()
100
+ }).unique("byEngineServerSessionEventSequence", ["runId", "sequence"]).index("byEngineServerSessionEventSubject", ["tenantId", "subjectId"]), k = x(u, {
101
+ id: v({ prefix: "esr" }),
102
+ tenantId: S().maxLength(256).externalId().sensitive("pii"),
103
+ serverId: S().maxLength(64).safe(),
104
+ pool: S().maxLength(63).safe(),
105
+ sessionId: S().maxLength(191).safe(),
106
+ trust: S().maxLength(16).oneOf([...g]).safe(),
107
+ trusted: _().safe(),
108
+ credentialId: S().maxLength(64).serverOnly(),
109
+ outcome: S().maxLength(16).oneOf(["completed", "aborted"]).safe(),
110
+ result: b().sensitive("pii"),
111
+ digest: S().maxLength(64).safe(),
112
+ reportedAt: C().safe()
113
+ }).unique("byEngineServerReportRun", [
114
+ "tenantId",
115
+ "serverId",
116
+ "sessionId"
117
+ ]), A = x(t, {
118
+ id: v({ prefix: "esa" }),
119
+ tenantId: S().maxLength(256).externalId().sensitive("pii"),
120
+ subjectId: S().maxLength(256).externalId().sensitive("pii"),
121
+ status: S().maxLength(16).oneOf([...e]).safe(),
122
+ provider: S().maxLength(64).safe(),
123
+ serverId: S().maxLength(64).safe(),
124
+ sessionId: S().maxLength(191).safe(),
125
+ updatedAt: C().safe()
126
+ }).unique("byEngineServerAntiCheatSubject", ["tenantId", "subjectId"]), j = x(n, {
127
+ id: v({ prefix: "esb" }),
128
+ tenantId: S().maxLength(256).externalId().serverOnly(),
129
+ serverId: S().maxLength(64).safe(),
130
+ sessionId: S().maxLength(191).safe(),
131
+ requestKey: S().maxLength(128).safe(),
132
+ ticketIds: b().safe(),
133
+ createdAt: C().safe()
134
+ }).unique("byEngineServerBackfillRequest", [
135
+ "tenantId",
136
+ "serverId",
137
+ "sessionId",
138
+ "requestKey"
139
+ ]), M = x(r, {
140
+ id: v({ prefix: "esk" }),
141
+ tenantId: S().maxLength(256).externalId().serverOnly(),
142
+ runId: S().maxLength(64).safe(),
143
+ serverId: S().maxLength(64).safe(),
144
+ sessionId: S().maxLength(191).safe(),
145
+ revision: y().safe(),
146
+ schemaVersion: y().safe(),
147
+ bytes: y().safe(),
148
+ digest: S().maxLength(64).safe(),
149
+ data: S().serverOnly(),
150
+ writtenAt: C().safe()
151
+ }).unique("byEngineServerCheckpointRun", ["tenantId", "runId"]).index("byEngineServerCheckpointSession", [
152
+ "tenantId",
153
+ "serverId",
154
+ "sessionId"
155
+ ]), N = Object.freeze([
156
+ w,
157
+ T,
158
+ E,
159
+ D,
160
+ O,
161
+ k,
162
+ A
163
+ ]), P = Object.freeze([
164
+ ...N,
165
+ j,
166
+ M
167
+ ]);
168
+ export { A as engineServerAntiCheatTable, j as engineServerBackfillsTable, M as engineServerCheckpointsTable, T as engineServerCredentialsTable, k as engineServerReportsTable, O as engineServerSessionEventsTable, D as engineServerSessionsTable, N as engineServerSubjectTables, P as engineServerTables, E as engineServerTicketsTable, w as engineServersTable };
package/dist/tokens.js ADDED
@@ -0,0 +1,97 @@
1
+ import { ENGINE_SERVER_LIMITS as e, SERVICE_TOKEN_PURPOSE as t, SESSION_SEAT_PURPOSE as n, SeatAttributesSchema as r } from "./contract.js";
2
+ import { Result as i, Schema as a } from "effect";
3
+ import { MIN_SESSION_SECRET_LENGTH as o, signSession as s, verifySessionKeyed as c } from "@voltro/protocol/session";
4
+ import { createHash as l, randomBytes as u, timingSafeEqual as d } from "node:crypto";
5
+ // src/tokens.ts
6
+ var f = (e) => `${e}_${u(16).toString("hex")}`, p = () => u(24).toString("base64url"), m = (e) => l("sha256").update(e, "utf8").digest("hex"), h = (e, t) => {
7
+ let n = Buffer.from(e, "utf8"), r = Buffer.from(m(t), "utf8");
8
+ return n.length === r.length && d(n, r);
9
+ }, g = (e, t) => {
10
+ for (let n of [t?.current, ...t?.previous ? [t.previous] : []]) if (!n || typeof n.kid != "string" || !n.kid.trim() || typeof n.secret != "string" || n.secret.length < o) throw Error(`Project-owned ${e} signing keys of at least ${o} characters are required; there is no fallback`);
11
+ if (t.previous?.kid === t.current.kid) throw Error(`${e} rotation keys require distinct identities`);
12
+ }, _ = (e, t) => Math.max(1, Math.ceil((e - Math.floor(t / 1e3) * 1e3) / 1e3)), v = a.Struct({
13
+ purpose: a.Literal(t),
14
+ credentialId: a.NonEmptyString,
15
+ pool: a.NonEmptyString,
16
+ serverId: a.NullOr(a.NonEmptyString)
17
+ }), y = (e, n, r, i) => s({
18
+ type: "serviceAccount",
19
+ id: e.credentialId,
20
+ tenantId: e.tenantId,
21
+ auditActorId: null,
22
+ metadata: {
23
+ purpose: t,
24
+ credentialId: e.credentialId,
25
+ pool: e.pool,
26
+ serverId: e.serverId
27
+ }
28
+ }, n.current, {
29
+ now: () => r,
30
+ ttlSeconds: _(i, r)
31
+ }), b = (t, n, r) => {
32
+ if (typeof t != "string" || t.length < 1 || t.length > e.tokenBytes) return null;
33
+ let o = c(t, n, { now: () => r });
34
+ if (!o || o.subject.type !== "serviceAccount" || typeof o.subject.tenantId != "string") return null;
35
+ let s = a.decodeUnknownResult(v)(o.subject.metadata);
36
+ return i.isFailure(s) || s.success.credentialId !== o.subject.id ? null : {
37
+ credentialId: s.success.credentialId,
38
+ pool: s.success.pool,
39
+ serverId: s.success.serverId,
40
+ tenantId: o.subject.tenantId
41
+ };
42
+ }, x = a.Struct({
43
+ purpose: a.Literal(n),
44
+ ticketId: a.NonEmptyString,
45
+ tenantId: a.NonEmptyString,
46
+ serverId: a.NonEmptyString,
47
+ sessionId: a.NonEmptyString,
48
+ subjectId: a.NonEmptyString,
49
+ subjectType: a.Literals([
50
+ "user",
51
+ "apiKey",
52
+ "serviceAccount"
53
+ ]),
54
+ subjectKind: a.optionalKey(a.Literal("guest")),
55
+ partyId: a.NullOr(a.NonEmptyString),
56
+ team: a.NullOr(a.NonEmptyString),
57
+ attributes: r,
58
+ redeemBy: a.Number.pipe(a.check(a.isFinite())),
59
+ nonce: a.NonEmptyString
60
+ }), S = (e, t, r, i) => {
61
+ let o = a.decodeUnknownSync(x)({
62
+ ...e,
63
+ purpose: n,
64
+ nonce: u(12).toString("base64url")
65
+ });
66
+ return s({
67
+ type: "serviceAccount",
68
+ id: o.ticketId,
69
+ tenantId: o.tenantId,
70
+ auditActorId: null,
71
+ metadata: o
72
+ }, t.current, {
73
+ now: () => r,
74
+ ttlSeconds: _(i, r)
75
+ });
76
+ }, C = (t, n, r) => {
77
+ if (typeof t != "string" || t.length < 1 || t.length > e.ticketBytes) return null;
78
+ let o = c(t, n, { now: () => r });
79
+ if (!o || o.subject.type !== "serviceAccount") return null;
80
+ let s = a.decodeUnknownResult(x)(o.subject.metadata);
81
+ if (i.isFailure(s)) return null;
82
+ let l = s.success, u = {
83
+ ticketId: l.ticketId,
84
+ tenantId: l.tenantId,
85
+ serverId: l.serverId,
86
+ sessionId: l.sessionId,
87
+ subjectId: l.subjectId,
88
+ subjectType: l.subjectType,
89
+ ...l.subjectKind === void 0 ? {} : { subjectKind: l.subjectKind },
90
+ partyId: l.partyId,
91
+ team: l.team,
92
+ attributes: l.attributes,
93
+ redeemBy: l.redeemBy
94
+ };
95
+ return u.ticketId !== o.subject.id || u.tenantId !== o.subject.tenantId ? null : u;
96
+ };
97
+ export { g as assertEngineSecrets, h as digestMatches, f as randomId, p as randomLease, S as signSeatTicket, y as signServiceToken, m as tokenDigest, C as verifySeatTicket, b as verifyServiceToken };
package/dist/writes.js ADDED
@@ -0,0 +1,16 @@
1
+ import { ENGINE_SERVER_WRITE_KINDS as e } from "./pool.js";
2
+ // src/writes.ts
3
+ var t = /^[a-z][a-z0-9-]{0,63}$/, n = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/, r = (r, i, a) => {
4
+ let o = {
5
+ inventory: typeof i?.inventory?.inventory?.service == "function",
6
+ economy: typeof i?.economy?.plugin?.economy?.service == "function",
7
+ progression: typeof i?.progression?.progression?.service == "function" && typeof i.progression.progression.quests == "function",
8
+ leaderboards: typeof i?.leaderboards?.leaderboards?.service == "function",
9
+ telemetry: !0
10
+ };
11
+ for (let t of e) if (t !== "telemetry" && i?.[t] !== void 0 && !o[t]) throw TypeError(`engineServersPlugin: writes.${t} is not an installed ${t} plugin`);
12
+ if (i?.economy !== void 0 && (typeof i.economy.systemAccount != "string" || !n.test(i.economy.systemAccount))) throw TypeError("engineServersPlugin: writes.economy.systemAccount must be a system account id");
13
+ if (a !== void 0 && (typeof a.assess != "function" || typeof a.name != "string" || !t.test(a.name))) throw TypeError("engineServersPlugin: antiCheat needs a name and an assess function");
14
+ for (let t of r) for (let n of e) if (t.scopes.includes(`writes:${n}`) && !o[n]) throw TypeError(`engineServersPlugin: pool ${t.name} declares writes:${n} but writes.${n} is not configured`);
15
+ };
16
+ export { r as checkWriteSources };
package/package.json CHANGED
@@ -1,6 +1,87 @@
1
1
  {
2
2
  "name": "@voltro/plugin-engine-servers",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.91.0",
4
+ "description": "Engine-neutral service identity, server registry, join tickets, session lifecycle and authoritative writes for engine servers.",
5
+ "keywords": [
6
+ "voltro",
7
+ "typescript",
8
+ "framework"
9
+ ],
10
+ "license": "SEE LICENSE IN LICENSE",
11
+ "homepage": "https://voltro.dev",
12
+ "bugs": {
13
+ "email": "support@voltro.dev"
14
+ },
15
+ "author": {
16
+ "name": "Voltro UG",
17
+ "url": "https://voltro.dev"
18
+ },
19
+ "type": "module",
20
+ "exports": {
21
+ ".": {
22
+ "types": "./dist/index.d.ts",
23
+ "import": "./dist/index.js",
24
+ "default": "./dist/index.js"
25
+ },
26
+ "./server": {
27
+ "types": "./dist/server.d.ts",
28
+ "import": "./dist/server.js",
29
+ "default": "./dist/server.js"
30
+ },
31
+ "./errors": {
32
+ "types": "./dist/errors.d.ts",
33
+ "import": "./dist/errors.js",
34
+ "default": "./dist/errors.js"
35
+ },
36
+ "./rpc": {
37
+ "types": "./dist/rpc.d.ts",
38
+ "import": "./dist/rpc.js",
39
+ "default": "./dist/rpc.js"
40
+ },
41
+ "./pool": {
42
+ "types": "./dist/pool.d.ts",
43
+ "import": "./dist/pool.js",
44
+ "default": "./dist/pool.js"
45
+ },
46
+ "./package.json": "./package.json"
47
+ },
48
+ "main": "./dist/index.js",
49
+ "module": "./dist/index.js",
50
+ "types": "./dist/index.d.ts",
51
+ "sideEffects": false,
52
+ "engines": {
53
+ "node": ">=24.0.0"
54
+ },
55
+ "dependencies": {
56
+ "@voltro/protocol": "0.91.0",
57
+ "@voltro/database": "0.91.0",
58
+ "@voltro/kv": "0.91.0",
59
+ "@voltro/runtime": "0.91.0",
60
+ "@voltro/plugin-licensing": "0.91.0",
61
+ "@voltro/plugin-sanctions": "0.91.0"
62
+ },
63
+ "peerDependencies": {
64
+ "effect": "4.1.4",
65
+ "@voltro/plugin-economy": "0.91.0",
66
+ "@voltro/plugin-inventory": "0.91.0",
67
+ "@voltro/plugin-leaderboards": "0.91.0",
68
+ "@voltro/plugin-progression": "0.91.0"
69
+ },
70
+ "peerDependenciesMeta": {
71
+ "@voltro/plugin-economy": {
72
+ "optional": true
73
+ },
74
+ "@voltro/plugin-inventory": {
75
+ "optional": true
76
+ },
77
+ "@voltro/plugin-leaderboards": {
78
+ "optional": true
79
+ },
80
+ "@voltro/plugin-progression": {
81
+ "optional": true
82
+ }
83
+ },
84
+ "publishConfig": {
85
+ "access": "public"
86
+ }
87
+ }