New Release: Lit SDK v4

The latest version of the Lit SDK, v4, is now live.

New Release: Lit SDK v4

We're thrilled to announce the latest version of the Lit SDK: v4! This release is packed with several improvements, new features, and critical changes aimed at enhancing the robustness, usability, and overall performance of the Lit SDK. 

Here's everything you need to know about key changes and additions:

🚨 Breaking Changes & Important Updates

Improved Error Handling for connect()

Possibly Breaking Change: In an effort to streamline error handling and improve the developer experience, connect() will now throw an error if connecting to the Lit network fails. This is a change from previous behavior, where failures to connect resulted in an UnhandledRejection or a dangling rejected Promise. If you have error handling already in place for connect(), this change should not impact your workflow.

Introduction of disconnect()

  • Feature Addition: We've added a new disconnect() method that effectively detaches our listeners for contract changes and network polling state. This is a step towards ensuring cleaner disconnections and better resource management.

Renaming of networkSyncInterval

  • Breaking Change: The networkSyncInterval property within lit-core (thus, in the lit-node-client) has been renamed to _networkSyncInterval and marked explicitly as private. This adjustment is crucial for those who previously relied on manually clearing the networkSyncInterval on the node client to allow their Node.js process to exit cleanly. Moving forward, please use the disconnect() method for this purpose.

🛠️ Enhancements and Fixes

Core Improvements

  • We've ensured that multiple concurrent calls to connect() on the same instance do not trigger multiple handshakes. This optimization is expected to yield significant performance improvements.
  • The connect() logic has been refined to collect server keys and build a list of connected nodes in memory before updating the core configuration. This change addresses and eliminates a range of non-deterministic behavior previously encountered.
  • Complete overhaul of the serverKeys handling: Now, server keys are entirely replaced post-handshake with nodes, removing outdated keys and ensuring up-to-date connectivity.

Bug Fixes

  • Addressed several critical bugs identified during our rigorous testing phase.
  • Resolved an issue with an incorrect key being set in config.retryTolerance — it's now correctly set to maxRetryCount.
  • Fixed naming discrepancies in config properties for Manzano and Habanero, correcting checkSevSnpAttestation to the accurate checkNodeAttestation.
  • Enhanced config mutation in the constructor for type safety, avoiding the use of any and as type coercion.
  • Made checkNodeAttestation optional, acknowledging its varying relevance based on the LitNetwork network name provided.

Type Enhancements

  • Addressed some overly generic types by introducing more specific alternatives, thereby improving type safety and developer experience.
  • Modified LitNodeClientConfig properties previously marked as required to be optional, catering to a broader range of use cases and configurations.

A comprehensive list of changes can be viewed here.

Installation

The v4 SDK is now the default for developers building on Lit. 

Install the @lit-protocol/lit-node-client package, which can be used in both browser and Node environments:

yarn add @lit-protocol/lit-node-client

Import the Lit JS SDK v4:

import * as LitJsSdk from "@lit-protocol/lit-node-client";

Note: To make sure you are on the latest 4.x.x version, you can check out the Lit NPM packages to find the latest (like so - lit-node-client) or use ^ when installing.

Get started here.

Looking Forward

This release marks a significant milestone in our commitment to delivering a robust, user-friendly development experience on Lit. The enhancements and fixes introduced in v4 are designed to streamline your development process, improve efficiency, and ensure greater reliability.

As always, we're eager to hear your feedback and experiences with the new release. Your insights are invaluable in helping us continually refine and improve the Lit SDK.

You can join the Lit developer ecosystem on Discord and Telegram

It is time to Free The Web!