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

@interlinklabs/mdk

v2.0.2

Published

Interlink Labs MDK – universal React/TS SDK

Readme

SDK Mdk Integration Guide

1. Introduction

The Mdk SDK provides functionalities to support user authentication using JWT tokens. This SDK is designed to integrate with React applications, enabling you to manage login sessions, validate tokens, and handle user logout.


2. Installation

  1. Install the @interlinklabs/mdk library:

    npm install @interlinklabs/mdk
  2. Import the Mdk SDK into your project from the corresponding file.


3. Using the SDK

3.1. Configuring Mdk

Integrate the SDK by using the Mdk component in your application.

import React from "react";
import Mdk from "@interlinklabs/mdk";

const App = () => {
  const handleSuccess = () => {
    console.log("Login successful!");
  };

  const handleFailure = () => {
    console.log("Login failed.");
  };

  return (
    <Mdk
      appid="your-app-id"
      onSuccess={handleSuccess}
      onFailure={handleFailure}
    >
      {({ open }) => <button onClick={open}>Login with the app</button>}
    </Mdk>
  );
};

export default App;

Mdk Properties:

  • appid (string): Your application ID for identification.
  • onSuccess (function): A callback function triggered upon successful login.
  • onFailure (function): A callback function triggered upon login failure.
  • children (function): Renders UI components with the { open } property to initiate the login process.

3.2. Mdk Methods

1. Mdk.getLoginId()

  • Description: Retrieves the loginId from the JWT stored in cookies.
  • Usage:
    const loginId = Mdk.getLoginId("your-app-id");
    console.log("Login ID:", loginId);

2. Mdk.getUserName()

  • Description: Fetches the username associated with a given loginId.
  • Usage:
    const username = await Mdk.getUserName("your-app-id");
    console.log("Username:", username);

3. Mdk.logOut()

  • Description: Deletes the JWT token and logs out the user.
  • Usage:
    Mdk.logOut("your-app-id");
    console.log("Logged out!");

3. Mdk.setInitPrice()

  • Description: Only the admin with proper authentication is allowed to call this function.

  • Usage:

    Mdk.setInitPrice();
  • Formula:
    Formula


3.3. Workflow

  1. Login Request: The user clicks the login button (triggered by the open method).
  2. Message Sent: A message containing the appid is sent to the native app.
  3. Native App Response: The native app responds with the status (pass or fail).
  4. Token Validation: The SDK validates the JWT token:
    • If valid: The token is stored in cookies, and the onSuccess function is called.
    • If invalid: The token is deleted, and the onFailure function is called.