
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
limbus-formation-deck
Advanced tools
TypeScript library for encoding and decoding Limbus Company formation deck codes
TypeScript library for encoding and decoding Limbus Company formation deck codes.
npm install
import { FormationDeckCode } from "limbus-formation-deck";
const encoded = "H4sIAAAAAAAA..."; // Your encoded deck code
const result = FormationDeckCode.decode(encoded);
console.log(result.formations);
console.log(result.hadErrors);
import { FormationDeckCode, FormationDetailInfo } from "limbus-formation-deck";
const formations: FormationDetailInfo[] = [
{
slot: 1,
personalityId: 10101,
ego1: 20101,
ego2: 0,
ego3: 0,
ego4: 0,
ego5: 0,
enabled: true,
slotType: 1,
},
// ... more formations
];
const encoded = FormationDeckCode.encode(formations);
console.log(encoded);
FormationDeckCode.decode(encoded: string, validate?: boolean): DecodeResultDecodes a formation deck code string into a list of formations.
Parameters:
encoded - Base64+gzip encoded deck codevalidate - Optional, whether to perform basic validation (default: false)Returns:
DecodeResult object containing:
formations - Array of FormationDetailInfo objectshadErrors - Boolean flag indicating if errors were encounteredFormationDeckCode.encode(formations: FormationDetailInfo[], outOfRule?: boolean): stringEncodes formations into a deck code string.
Parameters:
formations - Array of formations to encodeoutOfRule - Optional, whether to use out-of-rule encoding (default: false)Returns:
FormationDetailInfo Interfaceinterface FormationDetailInfo {
slot: number; // Slot number (1-12)
personalityId: number; // Character ID
ego1: number; // EGO slot 1
ego2: number; // EGO slot 2
ego3: number; // EGO slot 3
ego4: number; // EGO slot 4
ego5: number; // EGO slot 5
enabled: boolean; // Whether slot is active
slotType: number; // Slot type (0-15)
}
npm run build
This will compile the TypeScript code to JavaScript in the dist directory.
npm test
This library replicates the assembly-level logic from Limbus Company's formation deck code encoder/decoder. The code was reverse-engineered from the game's binary to ensure exact compatibility.
The formation deck code uses a multi-layer encoding scheme:
Original Formation Data
↓
Bit Packing (or Integer List for out-of-rule)
↓
Base64 Encoding
↓
Gzip Compression
↓
Base64 Encoding (outer layer)
↓
Final Deck Code
Each formation deck code encodes exactly 12 slots, regardless of how many are actually used.
For each slot, the following data is encoded:
| Field | Bits | Range | Description |
|---|---|---|---|
| Personality Modifier | 7 | 0-127 | Character ID modifier |
| Slot Type | 4 | 0-15 | Slot activation type |
| EGO 1 Modifier | 7 | 0-127 | First EGO modifier |
| EGO 2 Modifier | 7 | 0-127 | Second EGO modifier |
| EGO 3 Modifier | 7 | 0-127 | Third EGO modifier |
| EGO 4 Modifier | 7 | 0-127 | Fourth EGO modifier |
| EGO 5 Modifier | 7 | 0-127 | Fifth EGO modifier |
Total: 46 bits per slot × 12 slots = 552 bits + 1 header bit = 553 bits (0x229)
The actual IDs are computed from modifiers using a slot-based offset:
slotOffset = slotNumber × 100
// Personality ID
if (personalityModifier > 0) {
personalityId = personalityModifier + 10000 + slotOffset
} else {
personalityId = 0
}
// EGO ID
if (egoModifier > 0) {
egoId = egoModifier + 20000 + slotOffset
} else {
egoId = 0
}
1 + 10000 + 100 = 101015 + 20000 + 300 = 2030599 + 10000 + 1200 = 11299The assembly code builds numbers using the pattern value = (value × 2) | bit, which reads bits in MSB-first order.
5 into 7 bitsValue 5 in binary: 0000101
Bit order in stream:
[0][0][0][0][1][0][1]
↑ ↑
MSB LSB
Reading process (assembly):
value = 0
value = (0 × 2) | 0 = 0
value = (0 × 2) | 0 = 0
value = (0 × 2) | 0 = 0
value = (0 × 2) | 0 = 0
value = (0 × 2) | 1 = 1
value = (1 × 2) | 0 = 2
value = (2 × 2) | 1 = 5 ✓
Bit Index: 0 1-7 8-11 12-18 19-25 26-32 33-39 40-46
─── ─────── ────── ───────────────────────────────────────
Content: [1] [Pers1] [Type1] [EGO1₁] [EGO2₁] [EGO3₁] [EGO4₁] [EGO5₁]
47-53 54-57 58-64 ... (continues for all 12 slots)
─────── ────── ───────
[Pers2] [Type2] [EGO1₂] ...
The first bit (index 0) is always 1 (header bit).
The boolean array is packed into bytes:
// Each byte stores 8 bits, MSB-first
byte = 0;
for (j = 0; j < 8; j++) {
if (bools[i + j]) {
bitPosition = 7 - j;
byte |= 1 << bitPosition;
}
}
Booleans [true, false, false, false, true, false, true, false]
Bit positions: 7 6 5 4 3 2 1 0
Values: [1][0][0][0][1][0][1][0]
Binary: 10001010
Hex: 0x8A
Decimal: 138
The Base64-encoded boolean array is then compressed using gzip and encoded again with Base64:
boolArray → Base64 → UTF-8 bytes → Gzip → Base64 → Final Code
This dual Base64 + gzip approach achieves high compression ratios (typically 70-90% size reduction).
When outOfRule = true, the encoding uses a simpler integer list format instead of bit packing:
// For each formation:
intList = [personalityId, slotType, ego1, ego2, ego3, ego4, ego5];
// Then: intList → Base64 (as int32 LE) → Gzip → Base64
This format is less compact but easier to parse and doesn't require the slot offset calculations.
The implementation is based on reverse-engineering the following game assembly functions:
| Function | Address | Purpose |
|---|---|---|
FormationDeckCode::Decode | 0x1812247b0 | Main decode entry point |
FormationDeckCode::Encode | 0x18122457f | Main encode entry point |
| Bit reading loop | 0x18122496c | Reads 7-bit personality |
| Slot type reading | 0x1812249a4 | Reads 4-bit slot type |
| EGO reading loop | 0x1812249cd | Reads 5×7-bit EGO values |
| ID reconstruction | 0x181224abb | Converts modifiers to IDs |
The decode function optionally validates:
[10000, 99999][20000, 99999][0, 15]Invalid values are set to 0 and the hadErrors flag is set to true.
The constant-time performance is due to the fixed 12-slot format, making it very efficient regardless of how many slots are actually populated.
MIT
FAQs
TypeScript library for encoding and decoding Limbus Company formation deck codes
We found that limbus-formation-deck demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.