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

ic-auth

v1.1.0

Published

A simple, modular package for integrating Internet Computer authentication providers into your app.

Readme

IC-Auth

Version 1.1.0

Welcome to IC-Auth! The easiest way to integrate Plug, Stoic, Internet Identity, and NFID authentication for your Internet Computer apps.

📌 What can you do with IC-Auth?

IC-Auth is a lightweight, modular TypeScript package that helps developers plug wallet authentication directly into their DFINITY dapps.
It gives you simple, type-safe helpers for the most common IC wallets, so you can focus on your frontend and canister logic to get up and running quickly.

Currently Supported Wallets

  • Plug Wallet
  • Internet Identity
  • NFID
  • Stoic

⚠️ Known Issues

  • Stoic: A known issue with cookie storage affects Stoic logins in some browsers. This will be addressed in a future Stoic release.
  • NFID: Supports anonymous mode only for now — so canister calls work, but payments and session delegation are limited. This will be expanded soon.

🚀 What’s New In Verson 1.x

  • Fully modernized: Uses latest DFINITY agent APIs (Agent instead of HttpAgent).
  • Dependencies updated to latest stable versions.
  • No more embedded frontend — the package is framework-agnostic.
  • Cleaner exports: UserObject type is inline.
  • Local dev now supported for all providers via host parameter.
  • Removed legacy hello canister and embedded assets.
  • Designed to pair cleanly with any custom canister IDL.

📦 Installation

npm install ic-auth

Build Your Login

These steps are for creating your own simple login UI/UX using the modular functions. A more advanced design will be shown below.

Step 1: Import

Import the login functions you want and the universal UserObject type:

import { PlugLogin, StoicLogin, NFIDLogin, IdentityLogin, CreateActor, UserObject } from "ic-auth";

Step 2: Handle Your Login

Create a function to trigger the login and catch the data afterwards. If you're using Plug, it requires a list of canister addresses that you plan to make calls to. This is only required for Plug so we will show that here.

You will also need to define the host URL that the authentication will be looking towards for login. Again, if not using Plug you only need to toss the host as a string.

const canisterID = "oyjva-2yaaa-aaaam-qbaya-cai";
const whitelist = [canisterID];
const host = "https://icp0.io" // "https://localhost:XXXX" for local dfx instances.

const handleLogin = async() => {
    const userObject = await PlugLogin(whitelist, host);
    console.log(userObject);
    // Handle code will go here...
}

Step 3: Attach To Your UI

Take the login handler and attach it to a UI element of your choice.

<button onClick={handleLogin}>Login</button>

Using The Login - What is a UserObject?

After a successful login you should receive the UserObject, which looks like this:

type UserObject = {
    principal: string,
    agent: Agent | undefined,
    provider: string
}

Reminder: You can import this specific type by adding UserObject into your imports directly from ic-auth.

The UserObject can be used to create an actor for canister calls, display the user's principal address, or trigger code depending on the provider chosen. This next example shows how to create an actor using the CreateActor function.

To create an actor you will need to pass in the canister address you wish to call, the associated canister interface description language (IDL) file, and the agent from the UserObject. You can generate the interfaces folder by running dfx generate after building your backend canister, then import from that folder.

import { PlugLogin, StoicLogin, NFIDLogin, IdentityLogin, UserObject, CreateActor } from 'ic-auth';
import { idlFactory as YourIDL } from "./interfaces/your_canister";

const canisterID = "oyjva-2yaaa-aaaam-qbaya-cai";
const whitelist = [canisterID];
const host = "https://icp0.io"; // or your local dev host

const handleLogin = async() => {
    const userObject = await PlugLogin(whitelist, host);
    console.log(userObject);
    const actor = await CreateActor(userObject.agent!, YourIDL, canisterID);
    
    // Handle code will go here...
}

Now you can style the elements, add more providers, or continue on to see a more complex and full featured example.


🎛️ Multi-Provider Login Example

This example will bring you through the steps of creating a multi-wallet supported login menu.


1️⃣ Import + Define Everything

import { PlugLogin, StoicLogin, NFIDLogin, IdentityLogin, UserObject, CreateActor } from 'ic-auth';

const canisterID = "oyjva-2yaaa-aaaam-qbaya-cai";
const whitelist = [canisterID];
const host = "https://icp0.io"; // or your local dev host

2️⃣ Create a Unified Handler

const handleLogin = async (provider: string) => {
  let user: UserObject = {
    principal: "Not Connected.",
    agent: undefined,
    provider: "N/A"
  };

  if (provider === "Plug") {
    user = await PlugLogin(whitelist, host);
  } else if (provider === "Stoic") {
    user = await StoicLogin(host);
  } else if (provider === "NFID") {
    user = await NFIDLogin(host);
  } else if (provider === "Identity") {
    user = await IdentityLogin(host);
  }

  console.log(user);

  const actor = await CreateActor(user.agent!, YourIDL, canisterID);
  // Interact with your canister here
};

3️⃣ Attach Buttons to Your UI

<div class="wallet-buttons">
  <button onclick="handleLogin('Plug')">Plug</button>
  <button onclick="handleLogin('Stoic')">Stoic</button>
  <button onclick="handleLogin('NFID')">NFID</button>
  <button onclick="handleLogin('Identity')">Internet Identity</button>
</div>

📚 More Info & Resources


Author: Daniel McCoy
Twitter: @RealDanMcCoy


Enjoy building on the Internet Computer 🚀