New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@dfinity/ii-login-button

Package Overview
Dependencies
Maintainers
11
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dfinity/ii-login-button

Web component library to drop into your applications

latest
npmnpm
Version
0.0.7
Version published
Weekly downloads
3
Maintainers
11
Weekly downloads
 
Created
Source

@dfinity/IILoginButton

To install, run npm install @dfinity/ii-login-button

IILoginButton

Implements a standardized login button for Internet Identity

The simplest way to use this component is to import the auto.js file in your application

<script type="module" src="@dfinity/ii-login-button/auto.js"></script>

In Javascript, you can import the component and its types with

import { IILoginButton, defineComponent } from "@dfinity/ii-login-button";
defineComponent();

Example

in your application

<ii-login-button></ii-login-button>

Once the component is loaded, you can listen for the ready event, and set up more advanced configuration options. A common option would be to set loginOptions, looking like this:

const loginButton = document.querySelector("ii-login-button");

const prepareLoginButton = async (loginCallback) => {
  if (!customElements.get("ii-login-button")) {
    customElements.define("ii-login-button", LoginButton);
  }

  // Once the login button is ready, we can configure it to use Internet Identity
  loginButton?.addEventListener("ready", async (event) => {
    if (
      window.location.host.includes("localhost") ||
      window.location.host.includes("127.0.0.1")
    ) {
      loginButton.configure({
        loginOptions: {
          identityProvider: `http://${process.env.CANISTER_ID_INTERNET_IDENTITY}.localhost:4943`,
        },
      });
    }
  });

  loginButton?.addEventListener("login", async (event) => {
    const identity = loginButton?.identity;
    window.identity = identity;
    loginCallback();
  });
};

document.addEventListener("DOMContentLoaded", async () => {
  await prepareLoginButton(() => {
    // Do something after login
  });
});

Supported attributes

AttributeUseDefault Value
LabelAllows you to customize text on the button"Login With Internet Identity"
Logo-rightPositions the logo on the right side of the buttonfalse

Events

EventPurpose
readyFires once the component has loaded
loginfires once the user has finished logging in

Properties

PropertyType
authClientAuthClient
isAuthenticatedboolean
identityIdentity | undefined
principalPrincipal | undefined
principalStringstring | undefined
accountIdstring | undefined

Keywords

internet computer

FAQs

Package last updated on 28 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts