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

@mirats/mirats-auth

v1.5.8

Published

official npm package for mirats authentication IdP

Downloads

188

Readme

Mirats Auth

This project integrates Single Sign-On (SSO) functionality using the @mirats/mirats-auth package. Follow the steps below to set up the SSO in your application.

Installation

First, install the SSO package:

npm i @mirats/mirats-auth

1. Create GlobalContext.js

Create a file called GlobalContext.js inside the root of your app directory with the following content:

"use client";
import ProtectRoute from "../components/ProtectRoute";
import { getAuth } from "@mirats/mirats-auth";
import { createContext, useContext, useEffect, useState } from "react";

const AppContext = createContext(null);
export const useGlobalContext = () => {
  return useContext(AppContext);
};
const GlobalContext = ({ children }) => {
  const [userData, setUserData] = useState({});
  const getUserData = async () => {
    try {
      const user = await getAuth();
      if (user && user?.currentUser?._id) {
        setUserData(user?.currentUser);
        return;
      }
    } catch (error) {
      console.log(error);
    }
  };

  useEffect(() => {
    if (!Object.keys(userData || {})?.length) {
      getUserData();
    }
  }, [userData?._id]);

  return (
    <AppContext.Provider value={{ userData }}>
      <ProtectRoute>
        {children}
      </ProtectRoute>
    </AppContext.Provider>
  );
};
export default GlobalContext;

2. Create ProtectRoute.js

Create a file outside the app directory called ProtectRoute.js with the following content:

"use client";
import { isLoggedIn, signIn } from "@mirats/mirats-auth";
const ProtectRoute = ({ children }) => {
  const { user, loading } = isLoggedIn();
  if (user && !loading) {
    console.log("user & loading", { user, loading });
    return children;
  } else {
    signIn();
    console.log("no user found");
    return null;
  }
};

export default ProtectRoute;

3. Import GlobalContext in layout.js

Import the GlobalContext file inside your layout.js file as shown below:

import dynamic from "next/dynamic";
const GlobalContext = dynamic(() => import("@/context/index"), { ssr: false });
const inter = Inter({ subsets: ["latin"] });

export default function RootLayout({ children }) {
  return (
    <html lang="en">
      <body className={inter.className}>
        <GlobalContext>
         {children}
        </GlobalContext>
      </body>
    </html>
  );
}

Add Team Member API Documentation

This documentation outlines the process of inviting a user to join a team using the inviteLink function and its associated steps. The goal is to generate an invite link for the user, ensuring they are properly registered and assigned a gasId, then sending the invite through the appropriate backend services.

Function Overview

 inviteLink(email: string, id: string, firstName?: string, lastName?: string, days: number = 30): string | null

Parameters:

  email:"[email protected]"// required,
  id: "" // required,
  firstName: "testers", // optional
  lastName: "test", // optional
  days: 30 // optional(default: expires in 30 days)

This function generates an invitation link for a given user, ensuring they exist in the system. It performs several steps:

-Check if the user exists in the backend system. -Retrieve or generate a gasId for the user. -Call the sendUserInvite function to send the invitation.

  await getGasId(email: string): Promise<{ gasId: string | null } | null>
For getGasId:
  email:"[email protected]"// required,
 {
  gasId: "data?.gasId"  //mongoose objectId
  email: "data?.email"  //email
 }
  await getGasIds([email: string]): Promise<{ gasId: string | null } | null>


For getGAsIds: (max limit 10)
[
    "[email protected]" ,  # required
    "[email protected]" ,
    "[email protected]" ,
    "[email protected]" ,
    "[email protected]"
]
 {
  gasId: "data?.gasId"  //mongoose objectId
  email: "data?.email"  //email
 }
  await sendUserInvite(body: inviteBody): Promise<void>
For sendUserInvite:

  type inviteBody
  {
  name: string //req
  email: string, //req
  id: string,    //req
  organizationName: string, //Optional
  invitedBy: string, //req
  days: number  //optional
  }

  { success: true, msg: "Invite sent successfully", email:"userEmail", id:"mongooseId"  }
  await sendUserInvite(body: inviteBody): Promise<void>

For sendUserInvites: (max limit of 10)

  type inviteBody[]
  [
    {
      name: string, // required
      email: string, // required
      id: string,    // required
      organizationName: string, // optional
      invitedBy: string, // required
      days: number  // optional
    },
    {
      name: string, // required
      email: string, // required
      id: string,    // required
      organizationName: string, // optional
      invitedBy: string, // required
      days: number  // optional
    },
    // More inviteBody objects can be added as needed
  ]
[{ success: true, msg: "Invite sent successfully", email:"userEmail", id:"mongooseId"  }]

-The function starts by verifying if the provided email corresponds to an existing user in the backend portal. -If the user is not found, the system still proceeds to create a gasId for the new user.

Multiple Users: -The function sendUserInvites accepts an array of inviteBody objects. -Each object in the array is validated against the same criteria as for a single user. -If any object fails validation, it is excluded from the process, and the system logs or returns the failure reason.

-The sendUserInvite function sends the invitation to the specified email address. -If successful, it confirms that the invitation has been sent.

-The sendUserInvites function iterates through the array of inviteBody objects: -Each validated user receives an invitation. -Failed invitations (due to missing/invalid data or other issues) are logged or included in a failure response.