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 🙏

© 2026 – Pkg Stats / Ryan Hefner

ii-integration-helpers

v0.1.5

Published

A TypeScript library that provides helper functions for implementing the Proxy Web App component of Internet Identity (II) integration for mobile applications.

Readme

II Integration Helpers

A TypeScript library that provides helper functions for implementing the Proxy Web App component of Internet Identity (II) integration for mobile applications. This library follows the secure integration pattern described in the Internet Computer documentation.

Overview

This library implements the Proxy Web App component of the secure Internet Identity integration pattern for mobile applications. It helps create a secure bridge between mobile applications and Internet Identity by:

  1. Generating an intermediate session key
  2. Initiating the II client authentication protocol using this intermediate key
  3. Creating a delegation chain that allows the mobile application to use their session key
  4. Returning the delegation chain to the mobile app using app links/universal links and URI fragments

This approach prevents delegation theft attacks that could occur with naive implementations.

Installation

npm install ii-integration-helpers

Dependencies

Peer Dependencies

These dependencies need to be installed in your project:

npm install @dfinity/agent @dfinity/identity @dfinity/auth-client canister-manager expo-icp-app-connect-helpers expo-icp-frontend-helpers
  • @dfinity/agent: For Internet Computer agent functionality
  • @dfinity/identity: For identity and delegation management
  • @dfinity/auth-client: For authentication client functionality
  • canister-manager: For canister URL management
  • expo-icp-app-connect-helpers: For app connection functionality
  • expo-icp-frontend-helpers: For deep link and URL parsing functionality

Regular Dependencies

The following dependencies are included in the package:

  • None (all dependencies are peer dependencies)

Features

  • Secure Internet Identity authentication integration for mobile applications
  • Intermediate session key generation and management
  • Delegation chain creation and verification
  • Public key handling
  • Error formatting and rendering
  • Button setup and event handling
  • Deep link and URL parsing functionality

Usage

import {
  renderError,
  formatError,
  buildParams,
  prepareButtons,
  setupLoginButtonHandler,
} from 'ii-integration-helpers';
import { ERROR_MESSAGES } from './constants';
import {
  LOCAL_IP_ADDRESS,
  DFX_NETWORK,
  CANISTER_ID_INTERNET_IDENTITY,
  CANISTER_ID_FRONTEND,
  EXPO_SCHEME,
} from './env.generated';

const main = async (): Promise<void> => {
  try {
    // Build parameters for II integration
    const { deepLink, appPublicKey, internetIdentityURL, sessionId } =
      buildParams({
        localIPAddress: LOCAL_IP_ADDRESS,
        dfxNetwork: DFX_NETWORK,
        internetIdentityCanisterId: CANISTER_ID_INTERNET_IDENTITY,
        frontendCanisterId: CANISTER_ID_FRONTEND,
        expoScheme: EXPO_SCHEME,
      });

    // Prepare buttons
    const { iiLoginButton, backToAppButton } = prepareButtons();

    // Setup login button handler
    await setupLoginButtonHandler({
      iiLoginButton,
      backToAppButton,
      deepLink,
      sessionId,
      appPublicKey,
      internetIdentityURL,
      ttlMs: 1000 * 60 * 15, // 15 minutes until authentication expires
    });
  } catch (error) {
    renderError(formatError(ERROR_MESSAGES.INITIALIZATION, error));
  }
};

// Initialize when DOM is loaded
window.addEventListener('DOMContentLoaded', () => {
  main();
});

API Reference

Core Functions

  • buildParams: Builds parameters for II integration
  • buildAppPublicKey: Converts a hex string to a PublicKey
  • buildDelegationString: Converts a DelegationChain to a string
  • buildMiddleToAppDelegationChain: Creates a delegation chain
  • buildURIFragment: Builds a URI fragment for delegation

Authentication Functions

  • prepareLogin: Prepares the login process and returns a function to get delegation identity
  • setupLoginButtonHandler: Sets up the login button handler for II authentication
    • Parameters:
      • ttlMs: number - Time to live in milliseconds until authentication expires

Delegation Return Functions

  • handleAppDelegation: Returns delegation chain to the app via deep link or postMessage

UI Functions

  • prepareButtons: Prepares and validates UI buttons
  • renderError: Renders error messages
  • formatError: Formats error messages

Development

# Install dependencies
npm install

# Run tests
npm test

# Build the package
npm run build

# Run tests with coverage
npm run test:coverage

License

MIT