DARKNET: Darkweb Expansion Project & Bitnode (#2139)

This is BN15. It is a really big change; see the PR for all the details.
This commit is contained in:
Michael Ficocelli
2026-02-03 06:40:36 -05:00
committed by GitHub
parent a674633f6c
commit 6073964768
225 changed files with 15010 additions and 526 deletions
+19
View File
@@ -1,3 +1,5 @@
import { exampleDarknetServerData } from "../DarkNet/Enums";
import type { DarknetServerData } from "@nsdefs";
import type { NetscriptContext } from "./APIWrapper";
import { errorMessage } from "./ErrorMessages";
@@ -55,3 +57,20 @@ export function assertFunctionWithNSContext(
): asserts v is () => void {
if (typeof v !== "function") throw errorMessage(ctx, `${argName} expected to be a function ${debugType(v)}`, "TYPE");
}
export function missingKey(expect: object, actual: unknown): string | false {
if (typeof actual !== "object" || actual === null) {
return `Expected to be an object, was ${actual === null ? "null" : typeof actual}.`;
}
for (const key in expect) {
if (!(key in actual)) return `Property ${key} was expected but not present.`;
}
return false;
}
export function assertDarknetServerData(ctx: NetscriptContext, data: unknown): asserts data is DarknetServerData {
const error = missingKey(exampleDarknetServerData, data);
if (error) {
throw errorMessage(ctx, `Invalid darknet server data.\n${error}`, "TYPE");
}
}