# Midnight.js v4.0.4 release notes

> For the complete documentation index, see [llms.txt](https://docs.midnight.network/llms.txt)

* **Version**: v4.0.4
* **Date**: April 1, 2026
* **Node.js requirement**: >=22

***

## High-level summary[​](#high-level-summary "Direct link to 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[​](#audience "Direct link to 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[​](#summary-of-updates "Direct link to 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[​](#new-features "Direct link to New features")

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

### `@midnight-ntwrk/midnight-js` barrel package (#735)[​](#midnight-ntwrkmidnight-js-barrel-package-735 "Direct link to midnight-ntwrkmidnight-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`[​](#midnight-ntwrkmidnight-js-dapp-connector-proof-provider "Direct link to midnight-ntwrkmidnight-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[​](#per-recipient-encryption-key-resolution "Direct link to 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[​](#additional-encryption-mappings-in-high-level-apis "Direct link to Additional encryption mappings in high-level APIs")

`additionalCoinEncPublicKeyMappings` is now available in:

* `DeployContractOptionsBase`
* `CallOptionsBase`
* `ScopedTransactionOptions`
* `TransactionContext.getAdditionalMappings()`

### Browser-safe crypto comparison fallback[​](#browser-safe-crypto-comparison-fallback "Direct link to 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[​](#breaking-changes "Direct link to Breaking changes")

No breaking API changes are introduced in v4.0.4.

***

## Bug fixes and quality improvements[​](#bug-fixes-and-quality-improvements "Direct link to Bug fixes and quality improvements")

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

### Compact fetch GitHub authentication support[​](#compact-fetch-github-authentication-support "Direct link to 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[​](#testkit-js-reliability-fixes "Direct link to 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[​](#known-issues "Direct link to Known issues")

No critical known issues were identified at release time.

***

## Links and references[​](#links-and-references "Direct link to Links and references")

* **GitHub**: [Midnight.js repository](https://github.com/midnightntwrk/midnight-js)
* **API reference**: [Midnight.js API documentation](https://docs.midnight.network/api-reference/midnight-js/packages.md)
* **Related issue**: [GitHub issue #742](https://github.com/midnightntwrk/midnight-js/issues/742)
