@srvquery/protocol-valve 0.0.1-next.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,37 @@
1
+ /**
2
+ * Valve protocol query opcodes.
3
+ * @link https://developer.valvesoftware.com/wiki/Server_queries#Requests
4
+ */
5
+ export declare const requestOpcodes: {
6
+ readonly INFO: 84;
7
+ readonly PLAYERS: 85;
8
+ readonly RULES: 86;
9
+ readonly PING: 105;
10
+ readonly SERVERQUERY_GETCHALLENGE: 87;
11
+ };
12
+ /** Symbolic opcode accepted by a Valve server query. */
13
+ export type ValveProtocolRequestOpcode = keyof typeof requestOpcodes;
14
+ /** Numeric wire value for a Valve request opcode. */
15
+ export type ValveProtocolRequestOpcodeValue = (typeof requestOpcodes)[keyof typeof requestOpcodes];
16
+ /** Header values that identify simple and fragmented Valve responses. */
17
+ export declare const responseTypeOpcodes: {
18
+ readonly SIMPLE: -1;
19
+ readonly MULTI: -2;
20
+ };
21
+ /** Symbolic name for a Valve response packet format. */
22
+ export type ValveProtocolResponseTypeOpcode = keyof typeof responseTypeOpcodes;
23
+ /** Numeric header value for a Valve response packet format. */
24
+ export type ValveProtocolResponseTypeOpcodeValue = (typeof responseTypeOpcodes)[keyof typeof responseTypeOpcodes];
25
+ /** Recognized Valve response payload opcodes. */
26
+ export declare const responseOpcodes: {
27
+ readonly CHALLENGE: 65;
28
+ readonly INFO: 73;
29
+ readonly PLAYERS: 68;
30
+ readonly RULES: 69;
31
+ readonly PING: 106;
32
+ };
33
+ /** Symbolic opcode for a recognized Valve response payload. */
34
+ export type ValveProtocolResponseOpcode = keyof typeof responseOpcodes;
35
+ /** Numeric wire value for a recognized Valve response payload opcode. */
36
+ export type ValveProtocolResponseOpcodeValue = (typeof responseOpcodes)[keyof typeof responseOpcodes];
37
+ //# sourceMappingURL=opcodes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opcodes.d.ts","sourceRoot":"","sources":["../../src/packet/opcodes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,cAAc;aACzB,IAAI,EAAE,EAAE;aACR,OAAO,EAAE,EAAE;aACX,KAAK,EAAE,EAAE;aACT,IAAI,EAAE,GAAG;aACT,wBAAwB,EAAE,EAAE;CACpB,CAAC;AAEX,wDAAwD;AACxD,MAAM,MAAM,0BAA0B,GAAG,MAAM,OAAO,cAAc,CAAC;AACrE,qDAAqD;AACrD,MAAM,MAAM,+BAA+B,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC;AAEnG,yEAAyE;AACzE,eAAO,MAAM,mBAAmB;aAC9B,MAAM,EAAE,CAAC,CAAC;aACV,KAAK,EAAE,CAAC,CAAC;CACD,CAAC;AAEX,wDAAwD;AACxD,MAAM,MAAM,+BAA+B,GAAG,MAAM,OAAO,mBAAmB,CAAC;AAC/E,+DAA+D;AAC/D,MAAM,MAAM,oCAAoC,GAC9C,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,OAAO,mBAAmB,CAAC,CAAC;AAEjE,iDAAiD;AACjD,eAAO,MAAM,eAAe;aAC1B,SAAS,EAAE,EAAI;aACf,IAAI,EAAE,EAAI;aACV,OAAO,EAAE,EAAI;aACb,KAAK,EAAE,EAAI;aACX,IAAI,EAAE,GAAI;CACF,CAAC;AAEX,+DAA+D;AAC/D,MAAM,MAAM,2BAA2B,GAAG,MAAM,OAAO,eAAe,CAAC;AACvE,yEAAyE;AACzE,MAAM,MAAM,gCAAgC,GAC1C,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,OAAO,eAAe,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Reassembles fragmented packets into a single contiguous buffer.
3
+ *
4
+ * @param packets The fragmented packet buffers.
5
+ * @returns The reassembled payload buffer.
6
+ */
7
+ export declare const combineFragments: (packets: Buffer[]) => Buffer;
8
+ //# sourceMappingURL=reassembly.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reassembly.d.ts","sourceRoot":"","sources":["../../src/packet/reassembly.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,YAAa,MAAM,EAAE,KAAG,MAUpD,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { ValveProtocolRequestOpcode } from "./opcodes";
2
+ /** Values encoded into a Valve server query request packet. */
3
+ export type BuildRequestPacketParams = {
4
+ /** Query opcode to encode. */
5
+ opcode: ValveProtocolRequestOpcode;
6
+ /** Challenge token supplied for protected query types. */
7
+ challenge?: number;
8
+ };
9
+ /**
10
+ * Builds a Valve server query request packet.
11
+ * @param params Opcode and optional challenge token to encode.
12
+ * @returns Encoded request packet.
13
+ * @link https://developer.valvesoftware.com/wiki/Server_queries#Requests
14
+ */
15
+ export declare const buildRequestPacket: ({ opcode, challenge }: BuildRequestPacketParams) => Buffer;
16
+ //# sourceMappingURL=request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/packet/request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,0BAA0B,EAAE,MAAM,WAAW,CAAC;AAEvE,+DAA+D;AAC/D,MAAM,MAAM,wBAAwB,GAAG;IACrC,8BAA8B;IAC9B,MAAM,EAAE,0BAA0B,CAAC;IACnC,0DAA0D;IAC1D,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,0BAA2B,wBAAwB,KAAG,MA2BpF,CAAC"}
@@ -0,0 +1,77 @@
1
+ import z from "zod";
2
+ /**
3
+ * Validates a Valve `A2S_INFO` response, including fields selected by the extra data flag.
4
+ */
5
+ export declare const ValveServerInfoSchema: z.ZodObject<{
6
+ protocol: z.ZodNumber;
7
+ name: z.ZodString;
8
+ map: z.ZodString;
9
+ folder: z.ZodString;
10
+ game: z.ZodString;
11
+ appId: z.ZodNumber;
12
+ players: z.ZodNumber;
13
+ maxPlayers: z.ZodNumber;
14
+ bots: z.ZodNumber;
15
+ serverType: z.ZodUnion<readonly [z.ZodEnum<{
16
+ d: "d";
17
+ l: "l";
18
+ p: "p";
19
+ }>, z.ZodLiteral<0>]>;
20
+ environment: z.ZodEnum<{
21
+ l: "l";
22
+ m: "m";
23
+ o: "o";
24
+ w: "w";
25
+ }>;
26
+ visibility: z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodLiteral<1>]>;
27
+ vac: z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodLiteral<1>]>;
28
+ shipMode: z.ZodOptional<z.ZodNumber>;
29
+ shipWitnesses: z.ZodOptional<z.ZodNumber>;
30
+ shipDuration: z.ZodOptional<z.ZodNumber>;
31
+ version: z.ZodString;
32
+ edf: z.ZodOptional<z.ZodNumber>;
33
+ port: z.ZodOptional<z.ZodNumber>;
34
+ steamId: z.ZodOptional<z.ZodBigInt>;
35
+ ValveTvPort: z.ZodOptional<z.ZodNumber>;
36
+ ValveTvName: z.ZodOptional<z.ZodString>;
37
+ keywords: z.ZodOptional<z.ZodString>;
38
+ gameId: z.ZodOptional<z.ZodBigInt>;
39
+ }, z.core.$strip>;
40
+ /** Server metadata returned by a Valve `A2S_INFO` query. */
41
+ export type ValveServerInfo = z.infer<typeof ValveServerInfoSchema>;
42
+ /** Validates a player entry returned by a Valve `A2S_PLAYER` query. */
43
+ export declare const ValvePlayerSchema: z.ZodObject<{
44
+ index: z.ZodNumber;
45
+ name: z.ZodString;
46
+ score: z.ZodNumber;
47
+ duration: z.ZodNumber;
48
+ }, z.core.$strip>;
49
+ /** Validates the player list returned by a Valve `A2S_PLAYER` query. */
50
+ export declare const ValvePlayersSchema: z.ZodArray<z.ZodObject<{
51
+ index: z.ZodNumber;
52
+ name: z.ZodString;
53
+ score: z.ZodNumber;
54
+ duration: z.ZodNumber;
55
+ }, z.core.$strip>>;
56
+ /** Validates a rule whose key and value could not be decoded as strings. */
57
+ export declare const ValveBinaryRuleSchema: z.ZodObject<{
58
+ key: z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>;
59
+ value: z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>;
60
+ }, z.core.$strip>;
61
+ /** Validates the payload returned by a legacy Valve ping query. */
62
+ export declare const ValvePingSchema: z.ZodObject<{
63
+ payload: z.ZodString;
64
+ }, z.core.$strip>;
65
+ /** Validates the signed 32-bit challenge token returned by a Valve server. */
66
+ export declare const ValveChallengeSchema: z.ZodNumber;
67
+ /** Player entry containing its response index, name, score, and connected duration. */
68
+ export type ValvePlayer = z.infer<typeof ValvePlayerSchema>;
69
+ /** Player entries returned by a Valve `A2S_PLAYER` query. */
70
+ export type ValvePlayers = z.infer<typeof ValvePlayersSchema>;
71
+ /** Rule preserved as raw bytes when it cannot be represented as a string pair. */
72
+ export type ValveBinaryRule = z.infer<typeof ValveBinaryRuleSchema>;
73
+ /** Payload returned by a legacy Valve ping query. */
74
+ export type ValvePing = z.infer<typeof ValvePingSchema>;
75
+ /** Signed 32-bit challenge token used by protected Valve queries. */
76
+ export type ValveChallenge = z.infer<typeof ValveChallengeSchema>;
77
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/packet/schema.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAOpB;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiD9B,CAAC;AAEL,4DAA4D;AAC5D,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE,uEAAuE;AACvE,eAAO,MAAM,iBAAiB;;;;;iBAK5B,CAAC;AAEH,wEAAwE;AACxE,eAAO,MAAM,kBAAkB;;;;;kBAA6B,CAAC;AAC7D,4EAA4E;AAC5E,eAAO,MAAM,qBAAqB;;;iBAGhC,CAAC;AACH,mEAAmE;AACnE,eAAO,MAAM,eAAe;;iBAE1B,CAAC;AACH,8EAA8E;AAC9E,eAAO,MAAM,oBAAoB,aAAQ,CAAC;AAE1C,uFAAuF;AACvF,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAC5D,6DAA6D;AAC7D,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAC9D,kFAAkF;AAClF,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACpE,qDAAqD;AACrD,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AACxD,qEAAqE;AACrE,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { BufferCursor } from "@srvquery/core";
2
+ import { ValvePing, ValvePlayers, ValveServerInfo } from "./schema";
3
+ /** Deserializes a Valve response from a cursor positioned at its payload opcode. */
4
+ export type ValvePacketDeserializeFn = (cursor: BufferCursor) => unknown;
5
+ /**
6
+ * Deserializes a Valve server info packet from the given buffer cursor.
7
+ *
8
+ * @param cursor The buffer cursor pointing to the start of the server info packet.
9
+ * @returns The deserialized Valve server info object.
10
+ */
11
+ export declare const deserializeInfoPacket: (cursor: BufferCursor) => ValveServerInfo;
12
+ /**
13
+ * Deserializes a Valve players packet from the given buffer.
14
+ *
15
+ * @param body The buffer containing the players packet.
16
+ * @returns The deserialized Valve players object.
17
+ */
18
+ export declare const deserializePlayersPacket: (cursor: BufferCursor) => ValvePlayers;
19
+ /**
20
+ * Deserializes a Valve challenge packet from the given buffer cursor.
21
+ *
22
+ * @param cursor The buffer cursor pointing to the start of the challenge packet.
23
+ * @returns The deserialized challenge number.
24
+ */
25
+ export declare const deserializeChallengePacket: (cursor: BufferCursor) => number;
26
+ /**
27
+ * Deserializes a legacy Valve ping response.
28
+ * @param cursor Cursor positioned at the response payload opcode.
29
+ * @returns Validated ping payload.
30
+ */
31
+ export declare const deserializePingPacket: (cursor: BufferCursor) => ValvePing;
32
+ //# sourceMappingURL=serde.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serde.d.ts","sourceRoot":"","sources":["../../src/packet/serde.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAEL,SAAS,EAET,YAAY,EAEZ,eAAe,EAEhB,MAAM,UAAU,CAAC;AAElB,oFAAoF;AACpF,MAAM,MAAM,wBAAwB,GAAG,CAAC,MAAM,EAAE,YAAY,KAAK,OAAO,CAAC;AAEzE;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,WAAY,YAAY,KAAG,eA0C5D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,WAAY,YAAY,KAAG,YAS/D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,WAAY,YAAY,KAAG,MAEjE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,WAAY,YAAY,KAAG,SAE5D,CAAC"}
@@ -0,0 +1,44 @@
1
+ import { BufferCursor, CreateUdpSocketOptions, CreateUdpSocketParams } from "@srvquery/core";
2
+ import { ValveProtocolRequestOpcode } from "./packet/opcodes";
3
+ import { ValveChallenge, ValvePing, ValvePlayers, ValveServerInfo } from "./packet/schema";
4
+ import { type ValveRules } from "./rules/valve-rule-parser";
5
+ type ValveProtocolQueryResponseMap = {
6
+ INFO: ValveServerInfo;
7
+ SERVERQUERY_GETCHALLENGE: ValveChallenge;
8
+ PLAYERS: ValvePlayers;
9
+ PING: ValvePing;
10
+ RULES: ValveRules;
11
+ };
12
+ /** Parameters for querying Valve rules with a game-specific parser. */
13
+ export type ValveRulesQueryParams<Result = ValveRules> = {
14
+ /** Valve rules request opcode. */
15
+ opcode: "RULES";
16
+ /**
17
+ * Parses the raw Valve rules response into a game-specific model.
18
+ * In most cases, use the {@link valveRulesParser | default Valve rules parser}.
19
+ *
20
+ * @param cursor Cursor positioned at the first byte after the response opcode.
21
+ * @returns The parsed game-specific rules model.
22
+ */
23
+ parser: (cursor: BufferCursor) => Result;
24
+ };
25
+ /** Parameters for querying a Valve opcode and optionally customizing RULES parsing. */
26
+ export type ValveProtocolQueryParams<Opcode extends ValveProtocolRequestOpcode, Result = ValveProtocolQueryResponseMap[Opcode]> = Opcode extends "RULES" ? ValveRulesQueryParams<Result> : {
27
+ /** Valve request opcode to query. */
28
+ opcode: Opcode;
29
+ };
30
+ /** Client for querying servers that implement the Valve server query protocol. */
31
+ export interface ValveProtocol {
32
+ /** Queries one Valve opcode and resolves with its parsed response model. */
33
+ query<Opcode extends ValveProtocolRequestOpcode, Result = ValveProtocolQueryResponseMap[Opcode]>(params: ValveProtocolQueryParams<Opcode, Result>): Promise<Result>;
34
+ }
35
+ /** Connection and retry settings used to create a Valve protocol client. */
36
+ export type CreateValveProtocolParams = CreateUdpSocketParams & CreateUdpSocketOptions;
37
+ /**
38
+ * Creates a client for querying servers that implement the Valve server query protocol.
39
+ * @param params Target server and UDP transport settings.
40
+ * @returns A client whose `query` method returns the response type for the requested opcode.
41
+ */
42
+ export declare const createValveProtocol: ({ host, port, retry, timeout, ...socketOptions }: CreateValveProtocolParams) => ValveProtocol;
43
+ export {};
44
+ //# sourceMappingURL=protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAEZ,sBAAsB,EACtB,qBAAqB,EAItB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAwC,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAGpG,OAAO,EACL,cAAc,EAEd,SAAS,EACT,YAAY,EACZ,eAAe,EAChB,MAAM,iBAAiB,CAAC;AAQzB,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE5D,KAAK,6BAA6B,GAAG;IACnC,IAAI,EAAE,eAAe,CAAC;IACtB,wBAAwB,EAAE,cAAc,CAAC;IACzC,OAAO,EAAE,YAAY,CAAC;IACtB,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,UAAU,CAAC;CACnB,CAAC;AAEF,uEAAuE;AACvE,MAAM,MAAM,qBAAqB,CAAC,MAAM,GAAG,UAAU,IAAI;IACvD,kCAAkC;IAClC,MAAM,EAAE,OAAO,CAAC;IAChB;;;;;;OAMG;IACH,MAAM,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,MAAM,CAAC;CAC1C,CAAC;AAEF,uFAAuF;AACvF,MAAM,MAAM,wBAAwB,CAClC,MAAM,SAAS,0BAA0B,EACzC,MAAM,GAAG,6BAA6B,CAAC,MAAM,CAAC,IAC5C,MAAM,SAAS,OAAO,GACtB,qBAAqB,CAAC,MAAM,CAAC,GAC7B;IACE,qCAAqC;IACrC,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEN,kFAAkF;AAClF,MAAM,WAAW,aAAa;IAC5B,4EAA4E;IAC5E,KAAK,CAAC,MAAM,SAAS,0BAA0B,EAAE,MAAM,GAAG,6BAA6B,CAAC,MAAM,CAAC,EAC7F,MAAM,EAAE,wBAAwB,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/C,OAAO,CAAC,MAAM,CAAC,CAAC;CACpB;AAiBD,4EAA4E;AAC5E,MAAM,MAAM,yBAAyB,GAAG,qBAAqB,GAAG,sBAAsB,CAAC;AAOvF;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,qDAM7B,yBAAyB,KAAG,aAsE9B,CAAC"}
@@ -0,0 +1,42 @@
1
+ type UnsupportedServerBrowserProtocolVersionErrorCtor = {
2
+ version: number;
3
+ };
4
+ /** Error thrown when a server browser protocol message reports a version this parser doesn't handle. */
5
+ export declare class UnsupportedServerBrowserProtocolVersionError extends Error {
6
+ /** Version byte reported by the message. */
7
+ readonly version: number;
8
+ constructor({ version }: UnsupportedServerBrowserProtocolVersionErrorCtor);
9
+ }
10
+ /** Error thrown when a server browser protocol message's pages are missing or malformed. */
11
+ export declare class IncompleteServerBrowserProtocolMessageError extends Error {
12
+ constructor();
13
+ }
14
+ type InvalidServerBrowserProtocolEscapeSequenceErrorCtor = {
15
+ marker?: number;
16
+ };
17
+ /** Error thrown when a page payload contains an unrecognized 0x01-prefixed escape sequence. */
18
+ export declare class InvalidServerBrowserProtocolEscapeSequenceError extends Error {
19
+ /** Byte following the 0x01 escape marker. */
20
+ readonly marker?: number;
21
+ constructor({ marker }: InvalidServerBrowserProtocolEscapeSequenceErrorCtor);
22
+ }
23
+ type UnsupportedServerBrowserProtocolModIdLengthErrorCtor = {
24
+ idLength: number;
25
+ };
26
+ /** Error thrown when a mod entry declares an ID length this parser doesn't handle. */
27
+ export declare class UnsupportedServerBrowserProtocolModIdLengthError extends Error {
28
+ /** Unsupported ID length declared by the mod entry. */
29
+ readonly idLength: number;
30
+ constructor({ idLength }: UnsupportedServerBrowserProtocolModIdLengthErrorCtor);
31
+ }
32
+ type TrailingServerBrowserProtocolDataErrorCtor = {
33
+ remaining: number;
34
+ };
35
+ /** Error thrown when bytes remain unconsumed after decoding a server browser protocol message. */
36
+ export declare class TrailingServerBrowserProtocolDataError extends Error {
37
+ /** Number of unconsumed bytes remaining in the message. */
38
+ readonly remaining: number;
39
+ constructor({ remaining }: TrailingServerBrowserProtocolDataErrorCtor);
40
+ }
41
+ export {};
42
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/rules/errors.ts"],"names":[],"mappings":"AAAA,KAAK,gDAAgD,GAAG;IACtD,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,wGAAwG;AACxG,qBAAa,4CAA6C,SAAQ,KAAK;IACrE,4CAA4C;IAC5C,SAAgB,OAAO,EAAE,MAAM,CAAC;IAEhC,YAAY,EAAE,OAAO,EAAE,EAAE,gDAAgD,EAIxE;CACF;AAED,4FAA4F;AAC5F,qBAAa,2CAA4C,SAAQ,KAAK;IACpE,cAGC;CACF;AAED,KAAK,mDAAmD,GAAG;IACzD,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,+FAA+F;AAC/F,qBAAa,+CAAgD,SAAQ,KAAK;IACxE,6CAA6C;IAC7C,SAAgB,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhC,YAAY,EAAE,MAAM,EAAE,EAAE,mDAAmD,EAQ1E;CACF;AAED,KAAK,oDAAoD,GAAG;IAC1D,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,sFAAsF;AACtF,qBAAa,gDAAiD,SAAQ,KAAK;IACzE,uDAAuD;IACvD,SAAgB,QAAQ,EAAE,MAAM,CAAC;IAEjC,YAAY,EAAE,QAAQ,EAAE,EAAE,oDAAoD,EAI7E;CACF;AAED,KAAK,0CAA0C,GAAG;IAChD,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,kGAAkG;AAClG,qBAAa,sCAAuC,SAAQ,KAAK;IAC/D,2DAA2D;IAC3D,SAAgB,SAAS,EAAE,MAAM,CAAC;IAElC,YAAY,EAAE,SAAS,EAAE,EAAE,0CAA0C,EAIpE;CACF"}
@@ -0,0 +1,30 @@
1
+ import { BufferCursor } from "@srvquery/core";
2
+ import z from "zod";
3
+ /** Validates the decoded "Server Message" body of a server browser protocol 2 (DayZ) response. */
4
+ export declare const ServerBrowserProtocol2MessageSchema: z.ZodObject<{
5
+ version: z.ZodLiteral<2>;
6
+ generalFlags: z.ZodNumber;
7
+ dlcs: z.ZodArray<z.ZodObject<{
8
+ mask: z.ZodNumber;
9
+ appId: z.ZodOptional<z.ZodNumber>;
10
+ name: z.ZodString;
11
+ hash: z.ZodNumber;
12
+ }, z.core.$strip>>;
13
+ mods: z.ZodArray<z.ZodObject<{
14
+ hash: z.ZodNumber;
15
+ id: z.ZodBigInt;
16
+ name: z.ZodString;
17
+ }, z.core.$strip>>;
18
+ signatures: z.ZodArray<z.ZodString>;
19
+ description: z.ZodString;
20
+ extraRules: z.ZodRecord<z.ZodString, z.ZodString>;
21
+ }, z.core.$strip>;
22
+ /** Decoded "Server Message" body of a server browser protocol 2 (DayZ) response. */
23
+ export type ServerBrowserProtocol2Message = z.infer<typeof ServerBrowserProtocol2MessageSchema>;
24
+ /**
25
+ * Parses a server browser protocol 2 (DayZ) `A2S_RULES` response: reassembles the paged, escaped
26
+ * message from the rule pairs, then decodes its "Server Message" body.
27
+ * @param cursor Cursor positioned at the first byte after the response opcode.
28
+ */
29
+ export declare const serverBrowserProtocol2RulesParser: (cursor: BufferCursor) => ServerBrowserProtocol2Message;
30
+ //# sourceMappingURL=server-browser-protocol-2-parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-browser-protocol-2-parser.d.ts","sourceRoot":"","sources":["../../src/rules/server-browser-protocol-2-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,CAAC,MAAM,KAAK,CAAC;AAuBpB,kGAAkG;AAClG,eAAO,MAAM,mCAAmC;;;;;;;;;;;;;;;;;iBAS9C,CAAC;AAEH,oFAAoF;AACpF,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mCAAmC,CAAC,CAAC;AAEhG;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,WACpC,YAAY,KACnB,6BA8BF,CAAC"}
@@ -0,0 +1,48 @@
1
+ import { BufferCursor } from "@srvquery/core";
2
+ import z from "zod";
3
+ /** Validates the difficulty settings carried by a server browser protocol 3 message. */
4
+ export declare const ServerBrowserProtocol3DifficultySchema: z.ZodObject<{
5
+ level: z.ZodNumber;
6
+ aiLevel: z.ZodNumber;
7
+ advancedFlightModel: z.ZodBoolean;
8
+ thirdPersonCamera: z.ZodBoolean;
9
+ weaponCrosshair: z.ZodBoolean;
10
+ }, z.core.$strip>;
11
+ /** Validates the decoded "Server Message" body of a server browser protocol 3 (Arma 3) response. */
12
+ export declare const ServerBrowserProtocol3MessageSchema: z.ZodObject<{
13
+ version: z.ZodLiteral<3>;
14
+ generalFlags: z.ZodNumber;
15
+ dlcs: z.ZodArray<z.ZodObject<{
16
+ mask: z.ZodNumber;
17
+ appId: z.ZodOptional<z.ZodNumber>;
18
+ name: z.ZodString;
19
+ hash: z.ZodNumber;
20
+ }, z.core.$strip>>;
21
+ difficulty: z.ZodObject<{
22
+ level: z.ZodNumber;
23
+ aiLevel: z.ZodNumber;
24
+ advancedFlightModel: z.ZodBoolean;
25
+ thirdPersonCamera: z.ZodBoolean;
26
+ weaponCrosshair: z.ZodBoolean;
27
+ }, z.core.$strip>;
28
+ mods: z.ZodArray<z.ZodObject<{
29
+ hash: z.ZodNumber;
30
+ id: z.ZodBigInt;
31
+ name: z.ZodString;
32
+ }, z.core.$strip>>;
33
+ creatorDlcs: z.ZodArray<z.ZodObject<{
34
+ appId: z.ZodNumber;
35
+ name: z.ZodOptional<z.ZodString>;
36
+ }, z.core.$strip>>;
37
+ signatures: z.ZodArray<z.ZodString>;
38
+ extraRules: z.ZodRecord<z.ZodString, z.ZodString>;
39
+ }, z.core.$strip>;
40
+ /** Decoded "Server Message" body of a server browser protocol 3 (Arma 3) response. */
41
+ export type ServerBrowserProtocol3Message = z.infer<typeof ServerBrowserProtocol3MessageSchema>;
42
+ /**
43
+ * Parses a server browser protocol 3 (Arma 3) `A2S_RULES` response: reassembles the paged,
44
+ * escaped message from the rule pairs, then decodes its "Server Message" body.
45
+ * @param cursor Cursor positioned at the first byte after the response opcode.
46
+ */
47
+ export declare const serverBrowserProtocol3RulesParser: (cursor: BufferCursor) => ServerBrowserProtocol3Message;
48
+ //# sourceMappingURL=server-browser-protocol-3-parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-browser-protocol-3-parser.d.ts","sourceRoot":"","sources":["../../src/rules/server-browser-protocol-3-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,CAAC,MAAM,KAAK,CAAC;AA4CpB,wFAAwF;AACxF,eAAO,MAAM,sCAAsC;;;;;;iBAMjD,CAAC;AAEH,oGAAoG;AACpG,eAAO,MAAM,mCAAmC;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAU9C,CAAC;AAEH,sFAAsF;AACtF,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mCAAmC,CAAC,CAAC;AAEhG;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,WACpC,YAAY,KACnB,6BAsCF,CAAC"}
@@ -0,0 +1,51 @@
1
+ import { BufferCursor } from "@srvquery/core";
2
+ import z from "zod";
3
+ export declare const byte: z.ZodNumber;
4
+ export declare const uint16: z.ZodNumber;
5
+ export declare const uint32: z.ZodNumber;
6
+ /** Validates a DLC entry, including its bit mask and content hash. */
7
+ export declare const ServerBrowserProtocolDlcSchema: z.ZodObject<{
8
+ mask: z.ZodNumber;
9
+ appId: z.ZodOptional<z.ZodNumber>;
10
+ name: z.ZodString;
11
+ hash: z.ZodNumber;
12
+ }, z.core.$strip>;
13
+ /** Validates a mod required by the server, including its Workshop ID and content hash. */
14
+ export declare const ServerBrowserProtocolModSchema: z.ZodObject<{
15
+ hash: z.ZodNumber;
16
+ id: z.ZodBigInt;
17
+ name: z.ZodString;
18
+ }, z.core.$strip>;
19
+ /** Validates a Creator DLC entry encoded in the mods section (Arma 3 only). */
20
+ export declare const ServerBrowserProtocolCreatorDlcSchema: z.ZodObject<{
21
+ appId: z.ZodNumber;
22
+ name: z.ZodOptional<z.ZodString>;
23
+ }, z.core.$strip>;
24
+ /** DLC required by a server, including its bit mask and content hash. */
25
+ export type ServerBrowserProtocolDlc = z.infer<typeof ServerBrowserProtocolDlcSchema>;
26
+ /** Mod required by a server, including its Workshop ID and content hash. */
27
+ export type ServerBrowserProtocolMod = z.infer<typeof ServerBrowserProtocolModSchema>;
28
+ /** Creator DLC entry encoded in a mods section (Arma 3 only). */
29
+ export type ServerBrowserProtocolCreatorDlc = z.infer<typeof ServerBrowserProtocolCreatorDlcSchema>;
30
+ /**
31
+ * Reads a raw `A2S_RULES` response, reassembling its server browser protocol pages into a single
32
+ * unescaped message buffer. Rule pairs that aren't pages are returned separately as extra rules.
33
+ * @param cursor Cursor positioned at the first byte after the response opcode.
34
+ */
35
+ export declare const reassembleServerBrowserProtocolMessage: (cursor: BufferCursor) => {
36
+ message: BufferCursor;
37
+ extraRules: Record<string, string>;
38
+ };
39
+ /** Reads a 4-byte content hash for every set bit in `dlcMask`, naming known DLCs from `names`. */
40
+ export declare const readServerBrowserProtocolDlcs: (message: BufferCursor, dlcMask: number, names: Record<number, {
41
+ appId: number;
42
+ name: string;
43
+ }>) => ServerBrowserProtocolDlc[];
44
+ /** Reads the mods section, splitting out Creator DLC entries (ID length 19) by `creatorDlcNames`. */
45
+ export declare const readServerBrowserProtocolMods: (message: BufferCursor, creatorDlcNames?: Record<number, string>) => {
46
+ mods: ServerBrowserProtocolMod[];
47
+ creatorDlcs: ServerBrowserProtocolCreatorDlc[];
48
+ };
49
+ /** Reads the signature list, skipping zero-length entries. */
50
+ export declare const readServerBrowserProtocolSignatures: (message: BufferCursor) => string[];
51
+ //# sourceMappingURL=server-browser-protocol-reassembly.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-browser-protocol-reassembly.d.ts","sourceRoot":"","sources":["../../src/rules/server-browser-protocol-reassembly.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,CAAC,MAAM,KAAK,CAAC;AAOpB,eAAO,MAAM,IAAI,aAAoC,CAAC;AACtD,eAAO,MAAM,MAAM,aAAsC,CAAC;AAC1D,eAAO,MAAM,MAAM,aAA0C,CAAC;AAE9D,sEAAsE;AACtE,eAAO,MAAM,8BAA8B;;;;;iBAKzC,CAAC;AAEH,0FAA0F;AAC1F,eAAO,MAAM,8BAA8B;;;;iBAIzC,CAAC;AAEH,+EAA+E;AAC/E,eAAO,MAAM,qCAAqC;;;iBAGhD,CAAC;AAEH,yEAAyE;AACzE,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC;AACtF,4EAA4E;AAC5E,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC;AACtF,iEAAiE;AACjE,MAAM,MAAM,+BAA+B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qCAAqC,CAAC,CAAC;AAiDpG;;;;GAIG;AACH,eAAO,MAAM,sCAAsC,WACzC,YAAY,KACnB;IAAE,OAAO,EAAE,YAAY,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAiB7D,CAAC;AAEF,kGAAkG;AAClG,eAAO,MAAM,6BAA6B,YAC/B,YAAY,WACZ,MAAM,SACR,MAAM,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,KACrD,wBAAwB,EAa1B,CAAC;AAEF,qGAAqG;AACrG,eAAO,MAAM,6BAA6B,YAC/B,YAAY,oBACJ,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KACtC;IAAE,IAAI,EAAE,wBAAwB,EAAE,CAAC;IAAC,WAAW,EAAE,+BAA+B,EAAE,CAAA;CAgCpF,CAAC;AAEF,8DAA8D;AAC9D,eAAO,MAAM,mCAAmC,YAAa,YAAY,KAAG,MAAM,EASjF,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { BufferCursor } from "@srvquery/core";
2
+ import z from "zod";
3
+ /**
4
+ * Deserializes a Valve rules packet from the given buffer cursor.
5
+ * @param cursor The buffer cursor pointing to the start of the rules packet.
6
+ * @returns The deserialized Valve rules array.
7
+ */
8
+ export declare const valveRulesParser: (cursor: BufferCursor) => ValveRules;
9
+ /** Validates decoded string rules from an `A2S_RULES` response. */
10
+ export declare const ValveRulesSchema: z.ZodArray<z.ZodObject<{
11
+ name: z.ZodString;
12
+ value: z.ZodString;
13
+ }, z.core.$strip>>;
14
+ /** String rules returned by a Valve `A2S_RULES` response. */
15
+ export type ValveRules = z.infer<typeof ValveRulesSchema>;
16
+ //# sourceMappingURL=valve-rule-parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"valve-rule-parser.d.ts","sourceRoot":"","sources":["../../src/rules/valve-rule-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,WAAY,YAAY,KAAG,UAQvD,CAAC;AAEF,mEAAmE;AACnE,eAAO,MAAM,gBAAgB;;;kBAK5B,CAAC;AAEF,6DAA6D;AAC7D,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@srvquery/protocol-valve",
3
+ "version": "0.0.1-next.0",
4
+ "files": [
5
+ "dist"
6
+ ],
7
+ "type": "module",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ }
13
+ },
14
+ "dependencies": {
15
+ "zod": "^4.5.4"
16
+ },
17
+ "devDependencies": {
18
+ "@internal/typescript-config": "0.0.0",
19
+ "@srvquery/core": "0.0.1-next.0",
20
+ "@types/node": "^26.4.1",
21
+ "rolldown": "^1.2.7",
22
+ "typescript": "^7.0.2",
23
+ "vitest": "^5.0.0"
24
+ },
25
+ "peerDependencies": {
26
+ "@srvquery/core": "0.0.1-next.0"
27
+ },
28
+ "scripts": {
29
+ "build": "rolldown -c rolldown.config.ts && tsc -p tsconfig.json",
30
+ "test": "vitest run",
31
+ "test:watch": "vitest"
32
+ }
33
+ }