Skip to content

@loontail/minecraft-kit v0.8.14

Classes

ClassDescription
ChildProcessSpawnerDefault spawner backed by node:child_process.spawn.
FabricVersionsApiPublic Fabric versions API surface.
FetchHttpClientDefault HttpClient implementation backed by Node's built-in fetch (undici under the hood). Maps fetch errors to MinecraftKitError.
ForgeVersionsApiPublic Forge versions API surface.
MinecraftKitSingle facade for the entire library.
MinecraftKitErrorThe single error class thrown by every public API in @loontail/minecraft-kit.
MinecraftVersionsApiPublic Minecraft versions API surface.
MojangAuthApiHigh-level Microsoft / Mojang auth surface attached to MinecraftKit as kit.auth. Sign-in uses the OAuth 2.0 Authorization Code + PKCE flow with a loopback redirect (kit.auth.authorizationCode): the kit opens a localhost server, the caller opens the system browser, the user signs in, and the browser redirects back. The flow continues through the Xbox → XSTS → Minecraft pipeline and returns a MojangSession carrying everything launch composition needs plus the Microsoft refresh token. The library does NOT persist tokens — that's the caller's job.
PauseControllerCooperative pause primitive. Consumers call waitWhilePaused at safe checkpoints. Independent from AbortSignal — abort wins at the next signal check.
RuntimeVersionsApiPublic runtime versions API surface.
TargetsApiPublic Targets API surface.

Type Aliases

Type aliasDescription
ArchitectureArchitecture literal used in launcher metadata.
ArgumentEntryA single argument entry: bare string or rule-gated value.
ArtifactDownloadA single hash-verified download.
AspectRepairInputInputs accepted by every aspect-specific planXxxRepair (planMinecraftRepair, planFabricRepair, planForgeRepair, planRuntimeRepair). The per-aspect input types are aliases over this shape.
AssetIndexReferenceReference to the asset-index JSON file.
AuthModeAuth mode literal.
AuthorizationCodeRunOptionsOptions accepted by kit.auth.authorizationCode.run.
AzureClientIdBranded Azure AD application id. Construct via asAzureClientId (exported from the package root) — the brand prevents accidentally passing a refresh token or a UUID where the kit expects a client id.
DetectSystemInputInputs allowing the host system to be derived from current Node values or overrides.
DiscoveredLoaderHintInferred loader hint (does not assert correctness).
DiscoveredRuntimeHintDetected runtime files.
DiscoveredTargetDiscovered installation found by scanning a root directory. Contains only what was actually read from disk — no assumptions about correctness, completeness, or repair state.
DownloadActionA single download step.
DownloadCategoryDownload category literal — drives runInstall phase boundaries.
EventTypeLiteral type of the type discriminator of a ProgressEvent.
ExtractNativeActionA native extraction step. Source jar must already exist on disk.
FabricGameVersionEntryOne entry from the upstream Fabric gameVersions listing — the set of Minecraft versions Fabric supports at all, independent of any specific loader version.
FabricGameVersionsInputInputs to FabricVersionsApi.gameVersions.
FabricListInputInputs to FabricVersionsApi.list.
FabricLoaderSummarySummary entry from /v2/versions/loader.
FabricProfileFabric profile JSON returned by /v2/versions/loader/{mc}/{loader}/profile/json.
FabricResolveInputInputs to FabricVersionsApi.resolve.
FileRefReference to a single file used in download events.
ForgeBuildSummaryA Forge build entry derived from the Maven metadata XML.
ForgeListInputInputs to ForgeVersionsApi.list.
ForgeResolveInputInputs to ForgeVersionsApi.resolve.
HttpClientPluggable HTTP client. The default implementation uses Node's built-in fetch; consumers can inject a fake (e.g. for tests) by passing an httpClient to the MinecraftKit constructor.
HttpHeadersSubset of fetch headers the library actually uses.
HttpMethodHTTP method supported by HttpClient.
HttpRequestBodyBody payload accepted on POST requests.
HttpRequestOptionsOptions for an HTTP request.
HttpResponseResponse delivered by the HttpClient interface.
InstallActionDiscriminated union of install actions.
InstallActionKindDiscriminator for an install action.
InstallAspectShape of kit.install. Consumers usually access this through kit.install; the alias is exported so the facade documentation can show the concrete surface.
InstallPhaseInstall phase literal.
InstallPlanPre-computed install plan: a flat ordered list of actions plus computed totals.
InstallPlanTargetShape of InstallPlan.target. Either a fully-resolved Target (from ./target) or a runtime-only stand-in. The install runner only reads target.minecraft/target.loader when the plan actually contains those steps, so runtime-only plans are safe.
InstallProgressTrackerAggregator returned by createInstallProgressTracker. Wire onEvent into install.run / repair.run, and subscribe into your UI layer.
InstallReportOutcome summary returned by install.run.
InstallRunOptionsOptions accepted by install.run (and install.runtime.run).
LaunchAspectShape of kit.launch.
LaunchAuthAuth shape consumed by kit.launch.compose. Either an OfflineAuth or OnlineAuth.
LaunchCompositionFully composed launch command, ready to be passed to kit.launch.run.
LaunchExitOutcome of a finished launch.
LaunchMemoryOptionsOptional memory configuration.
LaunchOptionsInputs for kit.launch.compose (and the lower-level composeLaunch helper).
LaunchPreflightResultResult of a network-free kit.launch.preflight(target) check.
LaunchResolutionOptionsOptional resolution / window configuration.
LaunchRunOptionsOptions for kit.launch.run (and the lower-level runLaunch helper).
LaunchSessionLive handle for a running game process.
LibraryArtifactAn individual library artifact (jar/zip).
LibraryRuleRule entry used by libraries and modern arguments.
LoaderA fully resolved loader pinned to a specific Minecraft version. Use the type field to narrow to the concrete shape.
LoaderKindLoader-kind literal (used as discriminator on loader objects).
LogLevelLog-level literal.
LoggerPluggable logger. Default implementation is a silent logger; pass your own to surface logs.
MemoryCacheOptionsInputs to createMemoryCache.
MetadataCachePluggable in-memory cache for HTTP metadata responses. Default implementation: createMemoryCache. Implement this to back the cache by Redis, disk, etc.
MicrosoftRefreshTokenBranded Microsoft refresh token. Construct via asMicrosoftRefreshToken (exported from the package root) — the brand prevents accidentally passing an access token, XSTS token, or another opaque string where a Microsoft refresh token is expected.
MinecraftArgumentsModern (1.13+) arguments structure.
MinecraftChannelChannel literal as it appears in version manifest entries.
MinecraftDownloadsPer-platform downloads block of the Minecraft per-version manifest.
MinecraftGetInputInputs to MinecraftVersionsApi.get / .resolve.
MinecraftJavaVersionRequired Java runtime descriptor from the version manifest.
MinecraftKitErrorCodeUnion of every value in MinecraftKitErrorCodes. Use as the key type when building exhaustive lookup tables that translate kit codes to a consumer-facing taxonomy.
MinecraftKitErrorContextStructured context attached to errors. Always safe to serialize via JSON.stringify.
MinecraftKitOptionsConstructor options for MinecraftKit.
MinecraftLatestInputInputs to MinecraftVersionsApi.latest.
MinecraftLibraryLibrary entry. Combines vanilla, modern-natives, and legacy-classifier shapes.
MinecraftLibraryDownloadsLibrary downloads block.
MinecraftListInputInputs to MinecraftVersionsApi.list.
MinecraftLoggingLogging-config entry from the version manifest.
MinecraftProfileSnapshot of /minecraft/profile — uuid + display name + every skin slot Mojang has issued. Returned by every kit.auth.profile.* mutation so callers can refresh their UI without an extra round-trip.
MinecraftVersionIdBranded Minecraft version id (e.g. "1.20.1", "1.20.1-forge-47.2.0", "fabric-loader-0.14.21-1.20.1"). Construct via asMinecraftVersionId (exported from the package root) — the brand prevents accidentally passing a player UUID, an asset-index id, or another opaque string where the install/launch pipeline expects a Minecraft version id.
MinecraftVersionManifestSubset of the per-version manifest used by resolvers and consumers.
MinecraftVersionSummaryOne entry from the top-level Minecraft version_manifest_v2.json listing.
MojangAssetState-
MojangProfileSkinA single skin slot returned by /minecraft/profile.
MojangSessionCombined Microsoft + Minecraft session returned by kit.auth.authorizationCode.run and kit.auth.refresh.
OfflineAuthOffline authentication.
OnlineAuthOnline (token-based) authentication.
OperatingSystemOS literal as used inside Mojang/Forge/Fabric JSON manifests.
OperationOptionsCommon options accepted by long-running operations.
PersistentMetadataCacheDisk-backed MetadataCache plus a PersistentMetadataCache.flush hook for awaiting in-flight writes (e.g. on app quit, or in tests).
PersistentMetadataCacheOptionsOptions for createPersistentMetadataCache.
PlanStandaloneRuntimeInstallInputInputs to planStandaloneRuntimeInstall.
PlayerUuidBranded Minecraft player UUID. Construct via asPlayerUuid (exported from the package root) — the brand prevents accidentally passing a Minecraft version id, an Xbox userhash, or another opaque string where the launch composer expects a player UUID.
ProcessStreamStream-of-text channel exposed by spawned processes.
ProcessorRefA single processor description used in Forge events.
ProgressEventDiscriminated union of all runtime progress events. Pass an onEvent callback to install.run, update.run, verify.run, repair.run, or launch.run to receive these.
ProgressEventContextOptional aspect metadata attached by verification and aggregate repair flows.
ProgressListenerListener signature accepted by every long-running operation.
ProgressSnapshotSnapshot pushed to InstallProgressTracker subscribers.
ProgressStageLiteral type of ProgressStages. Use for exhaustive switches in UI code.
ProgressTrackerOptionsOptions for createInstallProgressTracker.
ReadProfileInputInputs to readProfile.
RefreshOptionsOptions accepted by kit.auth.refresh.
RepairAllOptionsOptions for kit.repair.all. Extends the common long-running operation options with caller-owned issue filtering.
RepairAllReportResult of repairAll: every verification it ran, every repair it performed, every aspect a connectivity failure blocked, and the aggregate cost.
RepairAspectShared shape of every aspect-specific repair surface (repair.minecraft, .fabric, …).
RepairBlockedAspectWhy an aspect could not be repaired this run. Recorded by repairAll when planning or running a repair fails with a connectivity error, so an offline "Repair" degrades to "these aspects still need the network" instead of rejecting the whole operation.
RepairFromErrorInputInputs to kit.repair.fromError({ error, target }). Resume a failed install by deriving the smallest possible RepairPlan from a typed MinecraftKitError thrown by a previous kit.install.run (or any other operation that surfaces the same codes).
RepairIssueFilterPredicate used by repair planning to decide whether a verification issue belongs to the kit-managed repair plan. Return false for files intentionally owned by the caller.
RepairIssueFilterInputContext passed to caller-owned repair filters.
RepairModeRepair-mode literal accepted by kit.repair.runVerifyAndRepair.
RepairPhaseRepair phase literal.
RepairPlanA repair plan is, structurally, an install plan limited to actions needed to fix the issues reported by a previous VerificationResult. The runner is the same.
RepairPlanOptionsOptions for any repair.<aspect>.plan call. Accepts one or many verification results.
RepairReportRepair report — same shape as install report.
RepairSurfaceShape of kit.repair. Four aspect-specific surfaces plus the all convenience that verifies every applicable slice and repairs each broken one, and fromError which resumes a failed install by deriving a focused plan from a typed MinecraftKitError.
RepairableErrorLikeStructural shape of the MinecraftKitError passed to RepairFromErrorInput. Defined here so src/types/ does not need to import the error class from src/core/. Any thrown MinecraftKitError satisfies this shape.
ResetSkinInputInputs to resetSkin.
ResolvedFabricLoaderResolved Fabric loader for a specific Minecraft version.
ResolvedForgeLoaderResolved Forge loader.
ResolvedLaunchVersionResult of resolving the on-disk version JSON for a target.
ResolvedMinecraftFully resolved Minecraft version: summary + parsed manifest, ready to feed into kit.targets.create or kit.install.plan.
ResolvedRuntimeResolved runtime ready to install or launch with.
ResolvedVanillaLoaderTrivial loader used when no mod loader is in play. Carries the resolved Minecraft so the launch composer has a uniform view across vanilla / Fabric / Forge.
RunForgeProcessorActionA Forge processor invocation. Main-Class is intentionally NOT carried here — the runner reads it from classpath[0]'s manifest at execution time, because the JAR is not guaranteed to exist on disk during planning (newer Forge versions ship some processor JARs as regular Maven libraries instead of bundling them in the installer).
RunVerifyAndRepairDepsDependencies for the standalone runVerifyAndRepair helper.
RuntimeComponentRuntime component literal. Always a string; the RuntimeComponents const lists the components we know about but unknown ones (added by Mojang in the future) are resolved dynamically.
RuntimeListEntryA summary entry for the list API.
RuntimeListInputInputs to RuntimeVersionsApi.list.
RuntimeOnlyInstallTargetA "runtime-only" install plan target. Used by planStandaloneRuntimeInstall to plan a JRE-only install without a Minecraft version/loader pinned to the plan.
RuntimePreferenceKindRuntime preference literal.
RuntimeResolveInputInputs to RuntimeVersionsApi.resolve.
RuntimeSystemIdentifies the host system for the launcher. All resolvers consume this object to pick the right artifacts (libraries, natives, runtime).
SetSkinFromUrlInputInputs to setSkinFromUrl.
SkinVariant-
SkinVariantInput-
SpawnOptionsOptions accepted by the spawner.
SpawnedProcessLive handle for a child process.
SpawnerPluggable process spawner. The default implementation uses node:child_process; tests inject a fake to avoid spawning real processes.
TargetFully resolved target: a concrete Minecraft + loader + runtime + directory.
TargetCreateInputInputs accepted by kit.targets.create.
TargetListInputInputs to TargetsApi.list.
TargetLoaderInputLoader input variants.
TargetReadinessIssueA verification issue annotated with the aspect that produced it.
TargetReadinessResultAggregate launch-readiness report for every aspect that applies to a target.
TargetResolveInputInputs to TargetsApi.resolve.
TargetsApiContextConstructor inputs for TargetsApi.
UploadSkinInputInputs to uploadSkin.
VerificationFileResultA single verified file.
VerificationKindVerification kind literal.
VerificationResultAggregate verification result returned by each verify.<kind>.run API.
VerifyAndRepairInputInputs to kit.repair.runVerifyAndRepair({ aspect, target, mode? }). Runs a single aspect's verifier and, in 'fix' mode, plans + executes the repair for any issues it finds. In 'report' mode the function never writes to disk.
VerifyAndRepairResultResult of kit.repair.runVerifyAndRepair. verified is always the verification result; repair is the repair report when a fix ran, or null when nothing needed fixing or mode === RepairModes.REPORT.
VerifyAspectShape of kit.verify. The four per-aspect surfaces share the same (target, options) → Promise<VerificationResult> contract; targetReady aggregates them for launch gating.
VerifyFileCategoryVerification file category literal.
VerifyFileStatusFile status literal.
VerifyOperationOptionsOptions accepted by every verify.<kind>.run.
VersionPreferenceKindResolution-preference literal.
WriteLoggingConfigActionWrite a logging config (log4j XML) to disk.
WriteVersionJsonActionWrite a version JSON to disk (Fabric / Forge).

Variables

VariableDescription
ArchitecturesCPU architecture identifiers. Matches the values that appear in Mojang library os.arch fields, after normalization from Node's NodeJS.Architecture.
AuthModesAuthentication modes accepted by the launch composer.
CLIENT_ID_ENV_VAREnv var consulted when no explicit clientId is supplied.
DownloadCategoriesCategorisation tag on every DownloadAction. Drives the install-phase mapping and lets consumers filter the plan to a subset (e.g. "runtime only").
EventTypesStable string constants for the type discriminator of every ProgressEvent. Use these instead of bare string literals when filtering events.
InstallActionKindsAction kinds inside an InstallPlan.
InstallPhasesCoarse-grained install phases. Used in install:phase-changed events so consumers can render a progress bar with named steps.
LoadersDiscriminator literal identifying which mod loader is active for a target.
LogLevelsLog levels accepted by the pluggable logger.
MinecraftChannelsMinecraft release channels matching the type field of Mojang version manifest entries.
MinecraftKitErrorCodesStable error code registry. MinecraftKitError carries one of these as code; consumers can switch on it exhaustively via the derived MinecraftKitErrorCode union.
MojangAssetStatesLifecycle state of a Mojang-issued skin slot.
OperatingSystemsOperating-system identifiers used by Mojang launcher metadata.
ProgressStagesUI-oriented coarse progress stages, identical across install and repair flows.
RepairModesModes accepted by kit.repair.runVerifyAndRepair.
RepairPhasesCoarse-grained repair phases used for repair:phase-changed events.
RuntimeComponentsMojang Java-runtime component identifiers. New components appear over time (e.g. java-runtime-delta for Java 21).
RuntimePreferenceUser-supplied resolution preferences.
SkinVariantInputsSkin-variant input that accepts "AUTO" in addition to the regular SkinVariant. "AUTO" triggers per-pixel detection by detectSkinVariant — useful when the caller does not know whether the user picked a Steve-style or Alex-style PNG.
SkinVariantsSkin model variant — "CLASSIC" for standard 4-pixel arms (Steve) or "SLIM" for 3-pixel arms (Alex).
VerificationKindsAspect of an installation a verification result describes.
VerifyFileCategoriesCategories assigned to each verified file for easier filtering.
VerifyFileStatusesStatus of an individual file checked during verification.
VersionPreferenceResolution preference used when a user wants the latest, recommended, or a specific version. Preferences are inputs to resolvers; resolved targets always carry concrete versions.
consoleLoggerLogger that mirrors messages to console.<level> with structured fields.
silentLoggerLogger that drops every message. Default when no logger is supplied.
targetPathsHelpers for the per-target Minecraft directory layout. Use these to derive paths to a specific file (versions/<id>/<id>.jar, assets/objects/<aa>/<sha1>, …) consistently with what the install and verify runners write/expect.

Functions

FunctionDescription
asAzureClientIdValidate raw as an Azure AD application id and brand it as AzureClientId. Throws MinecraftKitError(INVALID_INPUT) if the input is empty or does not match the GUID-ish shape Azure uses (hex characters and dashes, at least 8 characters).
asMicrosoftRefreshTokenBrand raw as a MicrosoftRefreshToken. Validates only that the value is non-empty after trimming — Microsoft refresh tokens are opaque, so the constructor's job is to put a brand on the value, not to second-guess Microsoft's format.
asMinecraftVersionIdValidate raw as a Minecraft version id and brand it as MinecraftVersionId. Throws MinecraftKitError(INVALID_INPUT) when the input is empty after trimming. Version ids span vanilla ("1.20.1"), snapshot ("24w14a"), and loader-flavoured shapes ("fabric-loader-0.14.21-1.20.1", "1.20.1-forge-47.2.0"), so the constructor only enforces non-emptiness — the resolver decides whether the id actually corresponds to a published version.
asPlayerUuidValidate raw as a Minecraft player UUID and brand it as PlayerUuid. Throws MinecraftKitError(INVALID_INPUT) when the input is empty after trimming. The constructor does not enforce a specific UUID shape — Mojang accepts both dashed and undashed forms in different APIs — but it does reject the empty string so a missing storage entry can't quietly become a UUID-shaped placeholder.
assertNeverExhaustiveness sentinel for discriminated unions. Drop into the default of a switch on kind / type / status so the compiler errors when a new variant is added but the switch is not updated.
createInstallProgressTrackerAggregate ProgressEvents from one install/repair run into throttled UI snapshots.
createMemoryCacheIn-memory metadata cache backed by lru-cache. Suitable for short-lived processes; pass a custom MetadataCache to share entries across runs (Redis, disk, etc.).
createPersistentMetadataCacheCreate a MetadataCache that survives process restarts. Resolved version manifests, asset indexes, and runtime indexes written during one launch are still readable on the next — so a target resolved while online resolves offline later without the per-endpoint 30s network stall. This is the kit side of the launcher's fully-offline status seed (launcher optimization-13).
detectSkinVariantInspect the raw PNG bytes of a Minecraft skin and decide whether it follows the 4-pixel-wide arm ("CLASSIC" / Steve) or 3-pixel-wide arm ("SLIM" / Alex) model.
detectSystemResolve the current host system identifiers.
isErrorCodeTrue when e is an MinecraftKitError carrying the given MinecraftKitErrorCode.
isMinecraftKitErrorTrue when e is an MinecraftKitError.
offlineUuidForDerive a stable v3-style UUID for an offline player username.
planFabricRepairBuild a repair plan covering the Fabric loader slice: profile JSON + libraries.
planForgeRepairBuild a repair plan covering the Forge loader slice: version JSON, libraries, installer download, and the Forge processors that produce the final installation. When the Forge version JSON was missing during verify (so libraries couldn't be enumerated), every forge-library download is added defensively — downloadFile skips files already on disk.
planMinecraftRepairBuild a repair plan covering only the vanilla Minecraft slice: client jar, version JSON, libraries (incl. native jars), assets, logging config, and native extractions.
planRuntimeInstallBuild an install plan that downloads ONLY the Java runtime declared by target.runtime.
planRuntimeRepairBuild a repair plan covering the Java runtime files. target.runtime.installRoot is honoured automatically because both planInstall and the verify side resolve runtime paths through the same targetPaths.runtimeRoot(..., installRoot) helper.
planStandaloneRuntimeInstallPlan a runtime-only install without a Minecraft target. Useful for "Install Java/runtime" flows where the user just wants a JRE on disk and never had a Minecraft version to choose from. The returned plan is shaped exactly like a normal InstallPlan but uses a RuntimeOnlyInstallTarget that carries only the runtime + directory — the runner skips Minecraft/loader-specific stages because they have no actions in this plan.
repairAllVerify every applicable aspect and repair each broken one. Aspects whose repair cannot reach the network are reported in blockedAspects instead of rejecting the operation, so an offline "Repair" still fixes everything that is locally fixable.
resolveLaunchVersionRead the installed version JSON appropriate for a target's loader and merge inheritsFrom.
runRepairExecute any repair plan. Reuses the install runner.
runVerifyAndRepairVerify a single aspect and, in 'fix' mode (default), repair every broken file before returning. In 'report' mode the function never touches disk — it returns the verification only and leaves repair as null.
scopedLoggerWrap a Logger so every message is prefixed with [scope]. Mirrors the scopedLogger(scope) convention used by the launcher: each module reaches for one named logger at the top of the file (e.g. const log = scopedLogger(input.logger, "http")) instead of threading the scope through every callsite.
stripUuidDashesStrip the dashes from a UUID. Used by ${auth_uuid}.
toOnlineAuthProject a MojangSession into the OnlineAuth shape that kit.launch.compose accepts.
verifyFabricVerify the Fabric loader slice: profile JSON + every library it pulls in.
verifyForgeVerify the Forge loader slice: the on-disk Forge version JSON and every library it declares. Libraries can only be enumerated once the JSON is present and parsable; a malformed JSON is surfaced as a CORRUPT issue so repair rewrites it before re-running.
verifyMinecraftVerify the vanilla Minecraft slice of an installation: the client jar, version JSON, libraries (incl. native jars), assets (index + objects), logging config, and the extracted natives directory.
verifyRuntimeVerify the Java runtime files. Honours target.runtime.installRoot when set so a shared/global runtime install is checked at its real location instead of the per-target runtime/ subfolder.
verifyTargetReadinessVerify every launch-critical aspect that applies to the target.

MIT License