npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@ledgerhq/context-module

v1.1.0

Published

> [!CAUTION] > This is still under development and we are free to make new interfaces which may lead to Device Management Kit breaking changes.

Downloads

1,270

Readme

Ledger Context Module Implementation

[!CAUTION] This is still under development and we are free to make new interfaces which may lead to Device Management Kit breaking changes.

Introduction

The purpose of the Context Module is to provide all the necessary context for the clear signing operation. This module includes the Ledger implementation of the context module and all the default context loaders used to fetch the context of a transaction. This open-source module can serve as an example for implementing custom context modules or loaders.

How does it work

The Context Module features an interface utilized by the Signer module to retrieve the context of a transaction. This module comprises multiple loaders, each capable of being specified individually. Each loader attempts to fetch context from the backend relevant to its domain. For example, one loader retrieves information about tokens, another fetches information about NFTs, and so on.

The following diagram illustrates the communication between the various modules when the context for a token transaction is successfully retrieved:

  flowchart LR;
      Signer --Transaction--> ContextModule
      ContextModule --Transaction--> TokenContextLoader
      ContextModule --Transaction--> NftContextLoader
      ContextModule --Transaction--> OtherContextLoader
      TokenContextLoader --> Backend1(Backend)
      NftContextLoader --> Backend2(Backend)
      OtherContextLoader --> Backend3(Backend)
      Backend1 --Context--> TokenContextLoader
      TokenContextLoader --Context--> ContextModule
      ContextModule --Context--> Signer

Installation

To install the context-module package, run the following command:

npm install @ledgerhq/context-module

Usage

Main Features

It currently supports the following features:

  • Tokens: provide information about tokens used in the transaction.
  • NFTs: provide information about NFTs used in the transaction.
  • Domain name: provide information about domain names.
  • Custom plugins: provide complex informations to external plugins such as the 1inch or paraswap plugin.

[!NOTE]
At the moment the context module is available only for Ethereum blockchain.

Setting up

The context-module package exposes a builder ContextModuleBuilder which will be used to initialise the context module with your configuration.

const contextModule = new ContextModuleBuilder().build();

You can use a custom configuration for your context module.

const config: ContextModuleCalConfig = {
  // config to use
};
const contextModule = new ContextModuleBuilder().addCalConfig(config).build();

It is also possible to instantiate the context module without the default loaders.

const contextModule = new ContextModuleBuilder().removeDefaultLoaders().build();

[!NOTE] Without loaders, a transaction cannot be clear signed. Use it with caution.

You can add a custom list of loader to the context module.

// Default Token Loader
const tokenLoader = new TokenContextLoader(new TokenDataSource());

// Custom Loader
const myCustomLoader = new MyCustomLoader();

// Custom datasource for a default Token Loader
const myCustomTokenDataSource = new MyCustomTokenDataSource();
const myTokenLoader = new TokenCOntextLoader();

const contextModule = new ContextModuleBuilder()
  .removeDefaultLoaders()
  .addLoader(tokenLoader)
  .addLoader(myTokenLoader)
  .addLoader(myCustomLoader)
  .build();

Create a custom loader

A custom loader must implement the ContextLoader interface, defined as follows:

type ContextLoader = {
  load: (transaction: TransactionContext) => Promise<ClearSignContext[]>;
};

with ClearSignContextSuccess defined as follows:

type ClearSignContextSuccess = {
  type: "token" | "nft" | "domainName" | "plugin" | "externalPlugin";
  payload: string;
};

The payload should represent the data sent to the device to provide information and must be signed by a trusted authority.

Errors handling

[!CAUTION] To be defined