Skip to main content

Midnight.js v4.0.4 release notes

For the complete documentation index, see llms.txt
  • Version: v4.0.4
  • Date: April 1, 2026
  • Node.js requirement: >=22

High-level summary​

This release strengthens Midnight.js with new package entry points, safer coin output encryption for multi-recipient flows, and important reliability fixes across proving, browser compatibility, and test tooling.

v4.0.3 was not published due to release pipeline issues, and all changes were included in v4.0.4.

Audience​

This release note is most relevant for developers who:

  • Build DApps with Midnight.js and want a single barrel import package.
  • Integrate proving via wallet-connected DApp Connector APIs.
  • Handle shielded outputs to burn addresses or third-party recipients.
  • Run compact fetch flows in CI environments with GitHub API limits.

Summary of updates​

  • Added the new @midnight-ntwrk/midnight-js barrel package.
  • Added @midnight-ntwrk/midnight-js-dapp-connector-proof-provider.
  • Fixed recipient encryption handling in zswapStateToOffer.
  • Added browser-safe constant-time fallback for timingSafeEqual.
  • Exposed additionalCoinEncPublicKeyMappings through high-level APIs.
  • Delivered broad testkit-js stability fixes and expanded test coverage.

New features​

Below is a detailed breakdown of the new capabilities introduced in this release.

@midnight-ntwrk/midnight-js barrel package (#735)​

This package provides a single import surface for core Midnight.js modules while intentionally excluding provider packages to keep bundles lightweight.

import { contracts, networkId, types, utils } from '@midnight-ntwrk/midnight-js';
import { deployContract } from '@midnight-ntwrk/midnight-js/contracts';
import { setNetworkId } from '@midnight-ntwrk/midnight-js/network-id';

Re-export namespaces:

  • contracts from @midnight-ntwrk/midnight-js-contracts
  • networkId from @midnight-ntwrk/midnight-js-network-id
  • types from @midnight-ntwrk/midnight-js-types
  • utils from @midnight-ntwrk/midnight-js-utils

@midnight-ntwrk/midnight-js-dapp-connector-proof-provider​

This package adapts DApp Connector's proving APIs to the Midnight.js ProofProvider interface, enabling wallet-delegated proving without running a standalone proof server.

import { dappConnectorProofProvider } from '@midnight-ntwrk/midnight-js-dapp-connector-proof-provider';

const proofProvider = await dappConnectorProofProvider(
walletConnectedAPI,
zkConfigProvider,
costModel
);

Main exports:

  • dappConnectorProofProvider
  • dappConnectorProvingProvider
  • DAppConnectorProvingAPI

Per-recipient encryption key resolution​

zswapStateToOffer now supports EncryptionPublicKeyResolver so each output can use the correct recipient encryption key.

The resolver supports:

  • Wallet-owned outputs
  • Shielded burn address outputs
  • Optional third-party recipient key mappings

This change prevents phantom balances caused by encrypting all outputs with the wallet's own key.

Additional encryption mappings in high-level APIs​

additionalCoinEncPublicKeyMappings is now available in:

  • DeployContractOptionsBase
  • CallOptionsBase
  • ScopedTransactionOptions
  • TransactionContext.getAdditionalMappings()

Browser-safe crypto comparison fallback​

When crypto.timingSafeEqual is unavailable in browser builds, Midnight.js now uses a constant-time fallback in level-private-state-provider.


Breaking changes​

No breaking API changes are introduced in v4.0.4.


Bug fixes and quality improvements​

The following bug fixes and quality improvements are included in this release.

Compact fetch GitHub authentication support​

Compact fetch now accepts GITHUB_TOKEN, allowing authenticated GitHub API usage for higher rate limits and private release access.

Testkit-js reliability fixes​

This release includes broad testkit-js bug fixes across assertions, error propagation, env var handling, and bigint serialization, with unit test coverage for corrected behavior.


Known issues​

No critical known issues were identified at release time.