@vlydev/cs2-masked-inspect-ts 1.0.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.
Files changed (45) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +221 -0
  3. package/dist/cjs/InspectLink.d.ts +45 -0
  4. package/dist/cjs/InspectLink.d.ts.map +1 -0
  5. package/dist/cjs/InspectLink.js +368 -0
  6. package/dist/cjs/ItemPreviewData.d.ts +59 -0
  7. package/dist/cjs/ItemPreviewData.d.ts.map +1 -0
  8. package/dist/cjs/ItemPreviewData.js +28 -0
  9. package/dist/cjs/Sticker.d.ts +34 -0
  10. package/dist/cjs/Sticker.d.ts.map +1 -0
  11. package/dist/cjs/Sticker.js +19 -0
  12. package/dist/cjs/crc32.d.ts +9 -0
  13. package/dist/cjs/crc32.d.ts.map +1 -0
  14. package/dist/cjs/crc32.js +28 -0
  15. package/dist/cjs/index.d.ts +10 -0
  16. package/dist/cjs/index.d.ts.map +1 -0
  17. package/dist/cjs/index.js +15 -0
  18. package/dist/cjs/proto/reader.d.ts +42 -0
  19. package/dist/cjs/proto/reader.d.ts.map +1 -0
  20. package/dist/cjs/proto/reader.js +105 -0
  21. package/dist/cjs/proto/writer.d.ts +31 -0
  22. package/dist/cjs/proto/writer.d.ts.map +1 -0
  23. package/dist/cjs/proto/writer.js +105 -0
  24. package/dist/esm/InspectLink.d.ts +45 -0
  25. package/dist/esm/InspectLink.d.ts.map +1 -0
  26. package/dist/esm/InspectLink.js +364 -0
  27. package/dist/esm/ItemPreviewData.d.ts +59 -0
  28. package/dist/esm/ItemPreviewData.d.ts.map +1 -0
  29. package/dist/esm/ItemPreviewData.js +24 -0
  30. package/dist/esm/Sticker.d.ts +34 -0
  31. package/dist/esm/Sticker.d.ts.map +1 -0
  32. package/dist/esm/Sticker.js +15 -0
  33. package/dist/esm/crc32.d.ts +9 -0
  34. package/dist/esm/crc32.d.ts.map +1 -0
  35. package/dist/esm/crc32.js +25 -0
  36. package/dist/esm/index.d.ts +10 -0
  37. package/dist/esm/index.d.ts.map +1 -0
  38. package/dist/esm/index.js +6 -0
  39. package/dist/esm/proto/reader.d.ts +42 -0
  40. package/dist/esm/proto/reader.d.ts.map +1 -0
  41. package/dist/esm/proto/reader.js +101 -0
  42. package/dist/esm/proto/writer.d.ts +31 -0
  43. package/dist/esm/proto/writer.d.ts.map +1 -0
  44. package/dist/esm/proto/writer.js +101 -0
  45. package/package.json +43 -0
@@ -0,0 +1,59 @@
1
+ import { Sticker } from './Sticker.ts';
2
+ /**
3
+ * Represents a CS2 item as encoded in an inspect link.
4
+ *
5
+ * Fields map directly to the CEconItemPreviewDataBlock protobuf message
6
+ * used by the CS2 game coordinator.
7
+ *
8
+ * paintWear is stored as a float32 (IEEE 754). On the wire it is reinterpreted
9
+ * as a uint32 — this class always exposes it as a JavaScript number for convenience.
10
+ *
11
+ * accountId and itemId may be large integers; they are stored as number but
12
+ * can also accept bigint for construction (values > 2^53 should use bigint).
13
+ */
14
+ export interface ItemPreviewDataInit {
15
+ accountId?: number | bigint;
16
+ itemId?: number | bigint;
17
+ defIndex?: number;
18
+ paintIndex?: number;
19
+ rarity?: number;
20
+ quality?: number;
21
+ paintWear?: number | null;
22
+ paintSeed?: number;
23
+ killEaterScoreType?: number;
24
+ killEaterValue?: number;
25
+ customName?: string;
26
+ stickers?: Sticker[];
27
+ inventory?: number;
28
+ origin?: number;
29
+ questId?: number;
30
+ dropReason?: number;
31
+ musicIndex?: number;
32
+ entIndex?: number;
33
+ petIndex?: number;
34
+ keychains?: Sticker[];
35
+ }
36
+ export declare class ItemPreviewData {
37
+ accountId: number | bigint;
38
+ itemId: number | bigint;
39
+ defIndex: number;
40
+ paintIndex: number;
41
+ rarity: number;
42
+ quality: number;
43
+ paintWear: number | null;
44
+ paintSeed: number;
45
+ killEaterScoreType: number;
46
+ killEaterValue: number;
47
+ customName: string;
48
+ stickers: Sticker[];
49
+ inventory: number;
50
+ origin: number;
51
+ questId: number;
52
+ dropReason: number;
53
+ musicIndex: number;
54
+ entIndex: number;
55
+ petIndex: number;
56
+ keychains: Sticker[];
57
+ constructor({ accountId, itemId, defIndex, paintIndex, rarity, quality, paintWear, paintSeed, killEaterScoreType, killEaterValue, customName, stickers, inventory, origin, questId, dropReason, musicIndex, entIndex, petIndex, keychains, }?: ItemPreviewDataInit);
58
+ }
59
+ //# sourceMappingURL=ItemPreviewData.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ItemPreviewData.d.ts","sourceRoot":"","sources":["../../src/ItemPreviewData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,mBAAmB;IAClC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC;CACvB;AAED,qBAAa,eAAe;IAC1B,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,OAAO,EAAE,CAAC;gBAET,EACV,SAAa,EACb,MAAU,EACV,QAAY,EACZ,UAAc,EACd,MAAU,EACV,OAAW,EACX,SAAgB,EAChB,SAAa,EACb,kBAAsB,EACtB,cAAkB,EAClB,UAAe,EACf,QAAa,EACb,SAAa,EACb,MAAU,EACV,OAAW,EACX,UAAc,EACd,UAAc,EACd,QAAY,EACZ,QAAY,EACZ,SAAc,GACf,GAAE,mBAAwB;CAsB5B"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ItemPreviewData = void 0;
4
+ class ItemPreviewData {
5
+ constructor({ accountId = 0, itemId = 0, defIndex = 0, paintIndex = 0, rarity = 0, quality = 0, paintWear = null, paintSeed = 0, killEaterScoreType = 0, killEaterValue = 0, customName = '', stickers = [], inventory = 0, origin = 0, questId = 0, dropReason = 0, musicIndex = 0, entIndex = 0, petIndex = 0, keychains = [], } = {}) {
6
+ this.accountId = accountId;
7
+ this.itemId = itemId;
8
+ this.defIndex = defIndex;
9
+ this.paintIndex = paintIndex;
10
+ this.rarity = rarity;
11
+ this.quality = quality;
12
+ this.paintWear = paintWear;
13
+ this.paintSeed = paintSeed;
14
+ this.killEaterScoreType = killEaterScoreType;
15
+ this.killEaterValue = killEaterValue;
16
+ this.customName = customName;
17
+ this.stickers = stickers;
18
+ this.inventory = inventory;
19
+ this.origin = origin;
20
+ this.questId = questId;
21
+ this.dropReason = dropReason;
22
+ this.musicIndex = musicIndex;
23
+ this.entIndex = entIndex;
24
+ this.petIndex = petIndex;
25
+ this.keychains = keychains;
26
+ }
27
+ }
28
+ exports.ItemPreviewData = ItemPreviewData;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Represents a sticker or keychain applied to a CS2 item.
3
+ *
4
+ * Maps to the Sticker protobuf message nested inside CEconItemPreviewDataBlock.
5
+ * The same message is used for both stickers (field 12) and keychains (field 20).
6
+ */
7
+ export interface StickerInit {
8
+ slot?: number;
9
+ stickerId?: number;
10
+ wear?: number | null;
11
+ scale?: number | null;
12
+ rotation?: number | null;
13
+ tintId?: number;
14
+ offsetX?: number | null;
15
+ offsetY?: number | null;
16
+ offsetZ?: number | null;
17
+ pattern?: number;
18
+ highlightReel?: number | null;
19
+ }
20
+ export declare class Sticker {
21
+ slot: number;
22
+ stickerId: number;
23
+ wear: number | null;
24
+ scale: number | null;
25
+ rotation: number | null;
26
+ tintId: number;
27
+ offsetX: number | null;
28
+ offsetY: number | null;
29
+ offsetZ: number | null;
30
+ pattern: number;
31
+ highlightReel: number | null;
32
+ constructor({ slot, stickerId, wear, scale, rotation, tintId, offsetX, offsetY, offsetZ, pattern, highlightReel, }?: StickerInit);
33
+ }
34
+ //# sourceMappingURL=Sticker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Sticker.d.ts","sourceRoot":"","sources":["../../src/Sticker.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED,qBAAa,OAAO;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;gBAEjB,EACV,IAAQ,EACR,SAAa,EACb,IAAW,EACX,KAAY,EACZ,QAAe,EACf,MAAU,EACV,OAAc,EACd,OAAc,EACd,OAAc,EACd,OAAW,EACX,aAAoB,GACrB,GAAE,WAAgB;CAapB"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Sticker = void 0;
4
+ class Sticker {
5
+ constructor({ slot = 0, stickerId = 0, wear = null, scale = null, rotation = null, tintId = 0, offsetX = null, offsetY = null, offsetZ = null, pattern = 0, highlightReel = null, } = {}) {
6
+ this.slot = slot;
7
+ this.stickerId = stickerId;
8
+ this.wear = wear;
9
+ this.scale = scale;
10
+ this.rotation = rotation;
11
+ this.tintId = tintId;
12
+ this.offsetX = offsetX;
13
+ this.offsetY = offsetY;
14
+ this.offsetZ = offsetZ;
15
+ this.pattern = pattern;
16
+ this.highlightReel = highlightReel;
17
+ }
18
+ }
19
+ exports.Sticker = Sticker;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * CRC32 implementation using standard polynomial 0xEDB88320 (same as zlib/PHP crc32).
3
+ */
4
+ /**
5
+ * Compute CRC32 of a Uint8Array.
6
+ * @returns unsigned 32-bit CRC32
7
+ */
8
+ export declare function crc32(buf: Uint8Array): number;
9
+ //# sourceMappingURL=crc32.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crc32.d.ts","sourceRoot":"","sources":["../../src/crc32.ts"],"names":[],"mappings":"AAAA;;GAEG;AAcH;;;GAGG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,UAAU,GAAG,MAAM,CAM7C"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ /**
3
+ * CRC32 implementation using standard polynomial 0xEDB88320 (same as zlib/PHP crc32).
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.crc32 = crc32;
7
+ const CRC32_TABLE = (() => {
8
+ const table = new Uint32Array(256);
9
+ for (let i = 0; i < 256; i++) {
10
+ let c = i;
11
+ for (let j = 0; j < 8; j++) {
12
+ c = (c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1);
13
+ }
14
+ table[i] = c;
15
+ }
16
+ return table;
17
+ })();
18
+ /**
19
+ * Compute CRC32 of a Uint8Array.
20
+ * @returns unsigned 32-bit CRC32
21
+ */
22
+ function crc32(buf) {
23
+ let crc = 0xFFFFFFFF;
24
+ for (let i = 0; i < buf.length; i++) {
25
+ crc = (crc >>> 8) ^ CRC32_TABLE[(crc ^ buf[i]) & 0xFF];
26
+ }
27
+ return (crc ^ 0xFFFFFFFF) >>> 0;
28
+ }
@@ -0,0 +1,10 @@
1
+ export { InspectLink } from './InspectLink.ts';
2
+ export { ItemPreviewData } from './ItemPreviewData.ts';
3
+ export type { ItemPreviewDataInit } from './ItemPreviewData.ts';
4
+ export { Sticker } from './Sticker.ts';
5
+ export type { StickerInit } from './Sticker.ts';
6
+ export { crc32 } from './crc32.ts';
7
+ export { ProtoReader } from './proto/reader.ts';
8
+ export type { ProtoField } from './proto/reader.ts';
9
+ export { ProtoWriter } from './proto/writer.ts';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,YAAY,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProtoWriter = exports.ProtoReader = exports.crc32 = exports.Sticker = exports.ItemPreviewData = exports.InspectLink = void 0;
4
+ var InspectLink_ts_1 = require("./InspectLink.js");
5
+ Object.defineProperty(exports, "InspectLink", { enumerable: true, get: function () { return InspectLink_ts_1.InspectLink; } });
6
+ var ItemPreviewData_ts_1 = require("./ItemPreviewData.js");
7
+ Object.defineProperty(exports, "ItemPreviewData", { enumerable: true, get: function () { return ItemPreviewData_ts_1.ItemPreviewData; } });
8
+ var Sticker_ts_1 = require("./Sticker.js");
9
+ Object.defineProperty(exports, "Sticker", { enumerable: true, get: function () { return Sticker_ts_1.Sticker; } });
10
+ var crc32_ts_1 = require("./crc32.js");
11
+ Object.defineProperty(exports, "crc32", { enumerable: true, get: function () { return crc32_ts_1.crc32; } });
12
+ var reader_ts_1 = require("./proto/reader.js");
13
+ Object.defineProperty(exports, "ProtoReader", { enumerable: true, get: function () { return reader_ts_1.ProtoReader; } });
14
+ var writer_ts_1 = require("./proto/writer.js");
15
+ Object.defineProperty(exports, "ProtoWriter", { enumerable: true, get: function () { return writer_ts_1.ProtoWriter; } });
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Pure TypeScript protobuf binary reader.
3
+ *
4
+ * Implements the subset of wire types needed for CEconItemPreviewDataBlock:
5
+ * - Wire type 0: varint (uint32, uint64, int32)
6
+ * - Wire type 2: length-delimited (string, bytes, nested messages)
7
+ * - Wire type 5: 32-bit fixed (float32)
8
+ */
9
+ export declare const WIRE_VARINT = 0;
10
+ export declare const WIRE_64BIT = 1;
11
+ export declare const WIRE_LEN = 2;
12
+ export declare const WIRE_32BIT = 5;
13
+ export interface ProtoField {
14
+ field: number;
15
+ wire: number;
16
+ value: bigint | Uint8Array;
17
+ }
18
+ export declare class ProtoReader {
19
+ private readonly _data;
20
+ private _pos;
21
+ constructor(data: Uint8Array);
22
+ get pos(): number;
23
+ remaining(): number;
24
+ readByte(): number;
25
+ readBytes(n: number): Uint8Array;
26
+ /**
27
+ * Read a base-128 varint.
28
+ * Returns a BigInt for 64-bit range safety; callers convert as needed.
29
+ */
30
+ readVarint(): bigint;
31
+ /**
32
+ * Read tag and return [fieldNumber, wireType].
33
+ */
34
+ readTag(): [number, number];
35
+ readLengthDelimited(): Uint8Array;
36
+ /**
37
+ * Read all fields until EOF.
38
+ * Max 100 fields enforced.
39
+ */
40
+ readAllFields(): ProtoField[];
41
+ }
42
+ //# sourceMappingURL=reader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reader.d.ts","sourceRoot":"","sources":["../../../src/proto/reader.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,eAAO,MAAM,WAAW,IAAI,CAAC;AAC7B,eAAO,MAAM,UAAU,IAAK,CAAC;AAC7B,eAAO,MAAM,QAAQ,IAAO,CAAC;AAC7B,eAAO,MAAM,UAAU,IAAK,CAAC;AAE7B,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,GAAG,UAAU,CAAC;CAC5B;AAED,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAa;IACnC,OAAO,CAAC,IAAI,CAAS;gBAET,IAAI,EAAE,UAAU;IAK5B,IAAI,GAAG,IAAI,MAAM,CAEhB;IAED,SAAS,IAAI,MAAM;IAInB,QAAQ,IAAI,MAAM;IAOlB,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,UAAU;IAWhC;;;OAGG;IACH,UAAU,IAAI,MAAM;IAiBpB;;OAEG;IACH,OAAO,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;IAK3B,mBAAmB,IAAI,UAAU;IAKjC;;;OAGG;IACH,aAAa,IAAI,UAAU,EAAE;CAmC9B"}
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ /**
3
+ * Pure TypeScript protobuf binary reader.
4
+ *
5
+ * Implements the subset of wire types needed for CEconItemPreviewDataBlock:
6
+ * - Wire type 0: varint (uint32, uint64, int32)
7
+ * - Wire type 2: length-delimited (string, bytes, nested messages)
8
+ * - Wire type 5: 32-bit fixed (float32)
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.ProtoReader = exports.WIRE_32BIT = exports.WIRE_LEN = exports.WIRE_64BIT = exports.WIRE_VARINT = void 0;
12
+ exports.WIRE_VARINT = 0;
13
+ exports.WIRE_64BIT = 1;
14
+ exports.WIRE_LEN = 2;
15
+ exports.WIRE_32BIT = 5;
16
+ class ProtoReader {
17
+ constructor(data) {
18
+ this._data = data;
19
+ this._pos = 0;
20
+ }
21
+ get pos() {
22
+ return this._pos;
23
+ }
24
+ remaining() {
25
+ return this._data.length - this._pos;
26
+ }
27
+ readByte() {
28
+ if (this._pos >= this._data.length) {
29
+ throw new RangeError('Unexpected end of protobuf data');
30
+ }
31
+ return this._data[this._pos++];
32
+ }
33
+ readBytes(n) {
34
+ if (this._pos + n > this._data.length) {
35
+ throw new RangeError(`Need ${n} bytes but only ${this._data.length - this._pos} remain`);
36
+ }
37
+ const chunk = this._data.slice(this._pos, this._pos + n);
38
+ this._pos += n;
39
+ return chunk;
40
+ }
41
+ /**
42
+ * Read a base-128 varint.
43
+ * Returns a BigInt for 64-bit range safety; callers convert as needed.
44
+ */
45
+ readVarint() {
46
+ let result = 0n;
47
+ let shift = 0n;
48
+ while (true) {
49
+ const b = this.readByte();
50
+ result |= BigInt(b & 0x7F) << shift;
51
+ if (!(b & 0x80))
52
+ break;
53
+ shift += 7n;
54
+ if (shift > 63n) {
55
+ throw new RangeError('Varint too long');
56
+ }
57
+ }
58
+ return result;
59
+ }
60
+ /**
61
+ * Read tag and return [fieldNumber, wireType].
62
+ */
63
+ readTag() {
64
+ const tag = this.readVarint();
65
+ return [Number(tag >> 3n), Number(tag & 7n)];
66
+ }
67
+ readLengthDelimited() {
68
+ const length = Number(this.readVarint());
69
+ return this.readBytes(length);
70
+ }
71
+ /**
72
+ * Read all fields until EOF.
73
+ * Max 100 fields enforced.
74
+ */
75
+ readAllFields() {
76
+ const fields = [];
77
+ let fieldCount = 0;
78
+ while (this.remaining() > 0) {
79
+ if (++fieldCount > 100) {
80
+ throw new RangeError('Protobuf field count exceeds limit of 100');
81
+ }
82
+ const [fieldNum, wireType] = this.readTag();
83
+ let value;
84
+ switch (wireType) {
85
+ case exports.WIRE_VARINT:
86
+ value = this.readVarint();
87
+ break;
88
+ case exports.WIRE_64BIT:
89
+ value = this.readBytes(8);
90
+ break;
91
+ case exports.WIRE_LEN:
92
+ value = this.readLengthDelimited();
93
+ break;
94
+ case exports.WIRE_32BIT:
95
+ value = this.readBytes(4);
96
+ break;
97
+ default:
98
+ throw new RangeError(`Unknown wire type ${wireType} for field ${fieldNum}`);
99
+ }
100
+ fields.push({ field: fieldNum, wire: wireType, value });
101
+ }
102
+ return fields;
103
+ }
104
+ }
105
+ exports.ProtoReader = ProtoReader;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Pure TypeScript protobuf binary writer.
3
+ *
4
+ * Writes to an in-memory buffer; call toBytes() to retrieve the result.
5
+ * Fields with default/zero values are omitted (proto3 semantics).
6
+ */
7
+ export declare class ProtoWriter {
8
+ private _buf;
9
+ constructor();
10
+ toBytes(): Uint8Array;
11
+ private _writeVarint;
12
+ private _writeTag;
13
+ writeUint32(fieldNum: number, value: number | bigint): void;
14
+ writeUint64(fieldNum: number, value: number | bigint): void;
15
+ writeInt32(fieldNum: number, value: number | bigint): void;
16
+ writeString(fieldNum: number, value: string): void;
17
+ /**
18
+ * Write a float32 as wire type 5 (fixed 32-bit, little-endian).
19
+ * Used for sticker float fields (wear, scale, rotation, etc.).
20
+ */
21
+ writeFloat32Fixed(fieldNum: number, value: number): void;
22
+ /**
23
+ * Write raw bytes as a length-delimited field (wire type 2).
24
+ */
25
+ writeRawBytes(fieldNum: number, data: Uint8Array): void;
26
+ /**
27
+ * Write a nested message (another ProtoWriter's output) as a length-delimited field.
28
+ */
29
+ writeEmbedded(fieldNum: number, nested: ProtoWriter): void;
30
+ }
31
+ //# sourceMappingURL=writer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writer.d.ts","sourceRoot":"","sources":["../../../src/proto/writer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,qBAAa,WAAW;IACtB,OAAO,CAAC,IAAI,CAAe;;IAM3B,OAAO,IAAI,UAAU;IAerB,OAAO,CAAC,YAAY;IAkBpB,OAAO,CAAC,SAAS;IAQjB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAM3D,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAM3D,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAM1D,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAQlD;;;OAGG;IACH,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAOxD;;OAEG;IACH,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,IAAI;IAOvD;;OAEG;IACH,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,IAAI;CAG3D"}
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ /**
3
+ * Pure TypeScript protobuf binary writer.
4
+ *
5
+ * Writes to an in-memory buffer; call toBytes() to retrieve the result.
6
+ * Fields with default/zero values are omitted (proto3 semantics).
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.ProtoWriter = void 0;
10
+ const WIRE_VARINT = 0;
11
+ const WIRE_LEN = 2;
12
+ const WIRE_32BIT = 5;
13
+ class ProtoWriter {
14
+ constructor() {
15
+ this._buf = [];
16
+ }
17
+ toBytes() {
18
+ const totalLength = this._buf.reduce((sum, chunk) => sum + chunk.length, 0);
19
+ const result = new Uint8Array(totalLength);
20
+ let offset = 0;
21
+ for (const chunk of this._buf) {
22
+ result.set(chunk, offset);
23
+ offset += chunk.length;
24
+ }
25
+ return result;
26
+ }
27
+ // ------------------------------------------------------------------
28
+ // Low-level primitives
29
+ // ------------------------------------------------------------------
30
+ _writeVarint(value) {
31
+ let v = BigInt(value);
32
+ // Handle negative: treat as unsigned 64-bit two's complement
33
+ if (v < 0n) {
34
+ v = BigInt.asUintN(64, v);
35
+ }
36
+ const parts = [];
37
+ do {
38
+ let b = Number(v & 0x7fn);
39
+ v >>= 7n;
40
+ if (v !== 0n)
41
+ b |= 0x80;
42
+ parts.push(b);
43
+ } while (v !== 0n);
44
+ this._buf.push(new Uint8Array(parts));
45
+ }
46
+ _writeTag(fieldNum, wireType) {
47
+ this._writeVarint((fieldNum << 3) | wireType);
48
+ }
49
+ // ------------------------------------------------------------------
50
+ // Public field writers
51
+ // ------------------------------------------------------------------
52
+ writeUint32(fieldNum, value) {
53
+ if (value === 0 || value === 0n)
54
+ return;
55
+ this._writeTag(fieldNum, WIRE_VARINT);
56
+ this._writeVarint(value);
57
+ }
58
+ writeUint64(fieldNum, value) {
59
+ if (value === 0 || value === 0n)
60
+ return;
61
+ this._writeTag(fieldNum, WIRE_VARINT);
62
+ this._writeVarint(value);
63
+ }
64
+ writeInt32(fieldNum, value) {
65
+ if (value === 0 || value === 0n)
66
+ return;
67
+ this._writeTag(fieldNum, WIRE_VARINT);
68
+ this._writeVarint(value);
69
+ }
70
+ writeString(fieldNum, value) {
71
+ if (!value)
72
+ return;
73
+ const encoded = new TextEncoder().encode(value);
74
+ this._writeTag(fieldNum, WIRE_LEN);
75
+ this._writeVarint(encoded.length);
76
+ this._buf.push(encoded);
77
+ }
78
+ /**
79
+ * Write a float32 as wire type 5 (fixed 32-bit, little-endian).
80
+ * Used for sticker float fields (wear, scale, rotation, etc.).
81
+ */
82
+ writeFloat32Fixed(fieldNum, value) {
83
+ this._writeTag(fieldNum, WIRE_32BIT);
84
+ const dv = new DataView(new ArrayBuffer(4));
85
+ dv.setFloat32(0, value, true); // little-endian
86
+ this._buf.push(new Uint8Array(dv.buffer));
87
+ }
88
+ /**
89
+ * Write raw bytes as a length-delimited field (wire type 2).
90
+ */
91
+ writeRawBytes(fieldNum, data) {
92
+ if (!data || data.length === 0)
93
+ return;
94
+ this._writeTag(fieldNum, WIRE_LEN);
95
+ this._writeVarint(data.length);
96
+ this._buf.push(data);
97
+ }
98
+ /**
99
+ * Write a nested message (another ProtoWriter's output) as a length-delimited field.
100
+ */
101
+ writeEmbedded(fieldNum, nested) {
102
+ this.writeRawBytes(fieldNum, nested.toBytes());
103
+ }
104
+ }
105
+ exports.ProtoWriter = ProtoWriter;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Encodes and decodes CS2 masked inspect links.
3
+ *
4
+ * Binary format:
5
+ * [key_byte] [proto_bytes XOR'd with key] [4-byte checksum XOR'd with key]
6
+ *
7
+ * For tool-generated links key_byte = 0x00 (no XOR needed).
8
+ * For native CS2 links key_byte != 0x00 — every byte must be XOR'd before parsing.
9
+ *
10
+ * Checksum:
11
+ * buffer = [0x00] + proto_bytes
12
+ * crc = crc32(buffer)
13
+ * xored = (crc & 0xffff) ^ (len(proto_bytes) * crc) [unsigned 32-bit]
14
+ * checksum = big-endian uint32 of (xored & 0xFFFFFFFF)
15
+ */
16
+ import { ItemPreviewData } from './ItemPreviewData.ts';
17
+ export declare class InspectLink {
18
+ /**
19
+ * Encode an ItemPreviewData to an uppercase hex inspect-link payload.
20
+ *
21
+ * The returned string can be appended to a steam:// inspect URL or used
22
+ * standalone. The key_byte is always 0x00 (no XOR applied).
23
+ */
24
+ static serialize(data: ItemPreviewData): string;
25
+ /**
26
+ * Returns true if the link contains a decodable protobuf payload (can be decoded offline).
27
+ */
28
+ static isMasked(link: string): boolean;
29
+ /**
30
+ * Returns true if the link is a classic S/A/D inspect URL with decimal did.
31
+ */
32
+ static isClassic(link: string): boolean;
33
+ /**
34
+ * Decode an inspect-link hex payload (or full URL) into an ItemPreviewData.
35
+ *
36
+ * Accepts:
37
+ * - A raw uppercase or lowercase hex string
38
+ * - A full steam://rungame/... inspect URL
39
+ * - A CS2-style csgo://rungame/... URL
40
+ *
41
+ * Handles the XOR obfuscation used in native CS2 links.
42
+ */
43
+ static deserialize(input: string): ItemPreviewData;
44
+ }
45
+ //# sourceMappingURL=InspectLink.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InspectLink.d.ts","sourceRoot":"","sources":["../../src/InspectLink.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AA6PvD,qBAAa,WAAW;IACtB;;;;;OAKG;IACH,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM;IAiB/C;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAOtC;;OAEG;IACH,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIvC;;;;;;;;;OASG;IACH,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe;CA+BnD"}