Introducing The Sweep: OX’s New Live Security Research Series
Register Now
Breaking: The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?
Read the Report
Are you exposed? Connect your apps in minutes.
Scan your apps free

@midnightntwrk/midnight-js

Latest version: v5.0.3-0-pre.607399e7

Overview

Last scanned
24 Nov 2026
Published
24 Nov 2026
npm package Publisher: ntwrk-bot
40 Stars
31 Forks
11 Versions
1.0K Downloads
TypeScript Repo language

Scan summary

@midnightntwrk/midnight-js was last scanned on 24 Nov 2026 at version 5.0.3-0-pre.607399e7. Risk score 0 of 100. No malicious behavior was detected.

  • Releases: 11 versions; the latest 5 were published within 2 days (23 and 24 Nov 2026).
  • Findings: No rules fired in version 5.0.3-0-pre.607399e7.
  • Downloads: 1,027 downloads.

Versions

11 versions published
Versions and the rules that fired in each
VersionPublishedStatus
5.0.3-0-pre.607399e7 LATEST 24 Nov 2026 No rules fired
5.0.3-0-pre.325b875e 24 Nov 2026 No rules fired
5.0.3-0-pre.3373fadc 24 Nov 2026 No rules fired
5.0.3-0-pre.a94adcc4 23 Nov 2026 Not shown
5.0.3-0-pre.63208040 23 Nov 2026 Not shown

No rules fired in 5.0.3-0-pre.607399e7

Findings

Findings for v5.0.3-0-pre.607399e7. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.

The score describes 5.0.3-0-pre.607399e7; other versions have their own rules, not their own score.

README

The publisher’s own README, as collected from the registry.

Midnight.js

Barrel package that provides a single entry point to the core components of Midnight.js. Import all core modules from one package instead of installing them individually.

Installation

yarn add @midnightntwrk/midnight-js

Quick Start

import { contracts, types, utils } from '@midnightntwrk/midnight-js';

// providers.config carries the network id: { networkId: 'preview', ttlSeconds: 3600 }
const deployed = await contracts.deployContract(providers, {
  compiledContract: myContract,
  privateStateId: 'my-state',
  initialPrivateState: { counter: 0n }
});

Modules

Module Package Description
contracts @midnightntwrk/midnight-js-contracts Contract deployment and interaction utilities
types @midnightntwrk/midnight-js-types Shared types, interfaces, and provider contracts
utils @midnightntwrk/midnight-js-utils Hex encoding, address validation, and utilities

Ledger Era Vocabulary

The network runs one of two ledger eras, v8 or v9. The names for saying which era produced a payload or a record are re-exported from the barrel directly, alongside the namespaces above:

import {
  LEDGER_ERAS,    // the closed, frozen set: ['v8', 'v9']
  CURRENT_LEDGER_ERA, // the current era, 'v9': the `era` of every current-era result
  type LedgerEra, // 'v8' | 'v9'
  versionOfRecord,    // a record carrying protocolVersion -> LedgerEra
  latestNetworkLedgerVersion  // asks a source for the network's current ledger era -> LedgerEra
} from '@midnightntwrk/midnight-js';

Use versionOfRecord for a protocolVersion read off an existing record, and latestNetworkLedgerVersion for the era a transaction built now would land in. Each tags its failures with the path it was called on, so a handler can tell the two apart.

Both refuse rather than guess. They raise UnknownProtocolVersionError when a protocolVersion is malformed (not a non-negative integer) or is well-formed but maps to no era this build knows. versionOfRecord throws; latestNetworkLedgerVersion is async, so it rejects instead, and a rejection from the source itself propagates unchanged.

import {
  type ProtocolVersionUnknownReason,
  UnknownProtocolVersionError,
  versionOfRecord,
  type VersionResolutionPath
} from '@midnightntwrk/midnight-js';

// Any record carrying a raw protocolVersion -- e.g. a transaction or block
// already read from the indexer. Node major 9 is one this build has no era
// for, so this record takes the failure path.
const record = { protocolVersion: 9_000_000 };

try {
  const era = versionOfRecord(record);
  console.log(`this record was written under ledger ${era}`);
} catch (error) {
  // Anything that is not ours is not ours to interpret. Never swallow it.
  if (!(error instanceof UnknownProtocolVersionError)) {
    throw error;
  }

  const path: VersionResolutionPath = error.path;            // 'read' | 'construct'
  const reason: ProtocolVersionUnknownReason = error.reason; // 'unknown' | 'malformed'

  throw new Error(
    reason === 'unknown'
      ? `This record is from a ledger era this build does not know (${path} path). Upgrade midnight-js.`
      : `The protocolVersion handed to versionOfRecord was malformed (${path} path). Check the source record.`,
    { cause: error }
  );
}

Both eras are worth handling explicitly, because the two reasons need different responses: 'unknown' means this framework build predates the network, and 'malformed' means the wrong field was wired into the resolver.

If you would rather discriminate on a stable string than on a class, every error here also carries a code. PROTOCOL_ERROR_CODES names them and utils.hasErrorCode is the guard:

import { PROTOCOL_ERROR_CODES, utils } from '@midnightntwrk/midnight-js';

if (utils.hasErrorCode(error, PROTOCOL_ERROR_CODES.UNKNOWN_PROTOCOL_VERSION_READ)) {
  // the era of an existing record could not be resolved
}
Errors from the retained era

Deploying to or calling a v8 contract runs through the retained pre-fork pipeline, which raises errors of its own. The barrel publishes those classes too, so you can catch them and read their payload without a cast:

Class Payload Means
Ledger8RuntimeMissingError subpath the retained runtime chunk could not be loaded at all
ComposeFailedError version, stage, circuitId a circuit operation is missing or under-registered
ComposeOptionError version, option one composition option cannot be used
StateDecodeFailedError version contract-state bytes could not be read as that era
StateInconsistentError version contract-state bytes were read as that era, but the state is internally inconsistent
UnknownLedgerEraError requestedVersion the value names an era outside LEDGER_ERAS, or carries no era (requestedVersion is undefined: a pre-5.0.0 provider)
PayloadNotATransactionError none a v8 payload sent for proving was not a transaction
What importing the barrel loads

The retained pre-fork (v8) ledger runtime is not re-exported here, and it is absent from the barrel's static import graph. It is loaded on demand, only once you actually touch a v8 contract.

Importing the barrel is not otherwise free: it pulls the v9 ledger and onchain-runtime, because contracts needs them. The sub-path imports below let you take one module without the rest.

Sub-path Imports

Each module is also available as a sub-path import for tree-shaking:

import { deployContract, findDeployedContract } from '@midnightntwrk/midnight-js/contracts';
import { type ProofProvider, type WalletProvider } from '@midnightntwrk/midnight-js/types';
import { toHex, fromHex } from '@midnightntwrk/midnight-js/utils';

Exports

// Namespace imports (all modules)
import { contracts, types, utils } from '@midnightntwrk/midnight-js';

// Ledger era vocabulary (named, not namespaced)
import { LEDGER_ERAS, type LedgerEra } from '@midnightntwrk/midnight-js';

// Sub-path imports (individual modules)
import { ... } from '@midnightntwrk/midnight-js/contracts';
import { ... } from '@midnightntwrk/midnight-js/types';
import { ... } from '@midnightntwrk/midnight-js/utils';

Resources

Terms & License

By using this package, you agree to Midnight's Terms and Conditions and Privacy Policy.

Licensed under Apache License 2.0.

OX Radar and Response Center

Find threats in your stack.

OX Radar can check high-priority threats, like critical package CVEs, against your context.

Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.

Where it’s listed

The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).

  • npm @midnightntwrk/midnight-js

References

The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.

Scan your whole stack

Group 1261154050 1
Group 1261154050
 

From OX Research Newsroom

Copy of Template Design OX Blog (3)
Research

Ruby2Shell: Ruby Memory Corruption Flaws Expose Applications to Remote Code Execution, But is it an Actual Risk?

Cry2Wolf: How to Tell a Real Bug from a Nothingburger
AI & VibeSec

Cry2Wolf: Not Every Branded Bug Deserves a Fire Drill

Ethersphere Hijacked With Crypto Stealing Malware (1)
npm

Ethersphere Hijacked With Crypto Stealing Malware Via Github & npm

Frame 2085668439 (1)
Group 1261154229