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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@bouncecode/mrlogin-sdk

v1.0.0-alpha.15

Published

BounceCode's MrLogin SDK

Downloads

27

Readme

Mrlogin-sdk

This SDK helps developers get started with the SSO login service in React.js provided by Bouncecode.

Installation

npm install @bouncecode/mrlogin-sdk
// or
yarn add @bouncecode/mrlogin-sdk

Set up

The entry point to the JavaScript SDK is a Mrlogin instance that will give you access to its API.

import Mrlogin from "@bouncecode/mrlogin-sdk";

// MrloginOptions { projectId, endpoint, port }  default endpoint = https://mrlogin.io
// projectId :
// 1. go to https://mrlogin.io
// 2. sign up
// 3. Check the project id in url . https://mrlogin.io/manage/{your-project-id}/users/list/

// project Id is required
const projectId = 'your project id';

// endpoint is optional , default : https://mrlogin.io
const endpoint = 'https://mrlogin.io';

// port is optional.
const port = undefined;

const mrlogin = new Mrlogin({ projectId, endpoint, port  }: MrloginOptions);

Usage

login

The login method navigates to the project login page and redirects to the redirect URI containing the login result as the url parameter.


const mrlogin = new Mrlogin({ 'your-project-id', 'https://mrlogin.io' });

mrlogin.login('your-redirect-uri');
// login result : https://your-redirecrt-uri/?access_token='user-access-token'&refresh_token='user-refresh-token'

Get login result (react.js)


import Mrlogin from "@bouncecode/mrlogin-sdk";
import { useEffect, useState } from "react";

const [loggedData, setLoggedData] = useState();

useEffect(() => {
    let parsedUrl = new URL(window.location.href);
    const accessToken = parsedUrl.searchParams.get("access_token");
    const refreshToken = parsedUrl.searchParams.get("refresh_token");

    if (accessToken || refreshToken) {
      setLoggedData({
        accessToken: jwt.decode(accessToken),
        refreshToken: refreshToken,
      });
    }
  }, []);

decodeToken

The decode Token method decodes the access token issued after completing login and returns the data included in the access_token. an JwtPayload & AccessTokenData


const mrlogin = new Mrlogin({ 'your-project-id', 'https://mrlogin.io' });

const token = 'user-access-token';

const data = mrlogin.decodeToken(token);

verifyToken

The 'verify Token' method returns the data included in access_token by verifying and decrypting the access token issued after login on the server. an AccessTokenData


const mrlogin = new Mrlogin({ 'your-project-id', 'https://mrlogin.io' });

const token = 'user-access-token';

const data = mrlogin.verifyToken(token);

createDidToken

The 'createDidToken' method issues and returns a did_Token containing a decentralized ID (DID) from the server through an access_token.

The DID token is encoded as a Base64 JSON string tuple representing [proof, claim]:

proof: A digital signature that proves the validity of the given claim.

claim: Unsigned data the user asserts. This should equal the proof after Elliptic Curve recovery.


const mrlogin = new Mrlogin({ 'your-project-id', 'https://mrlogin.io' });

const token = 'user-access-token';

const didTokenSolana = await mrlogin.createDidToken("solana", token);

const didTokenEther = await mrlogin.createDidToken("ether", token);

verifyDidToken

The 'verifyDidToken' method verifies and decrypts the did token and returns the data contained in did_token. an IDidToken

access-token-data

interface AccessTokenData {
    customUserData?: any;
    email: string;
    multiFactor?: string;
    oauthToken?: any;
    passwordUpdatedDate?: Date;
    phoneNumber?: string;
    projectAdmin?: any;
    projectId: string;
    protectedBackupKey?: string;
    protectedShareKey?: string;
    provider: string;
    reported?: Date;
    tokenId?: string;
    userId: string;
    verifiedAt?: Date;
    verifiedEmail?: boolean;
    verifiedEmailAt?: Date;
    verifiedMobileIdentity?: boolean;
    verifiedMobileIdentityAt?: Date;
    verifyInterest?: Date;
    verifySMS?: boolean;
    verifyTerm?: Date;
}

did-token-data

interface IDidTokenAdd {
    tokenId: string;
    protectedKey: string;
}
interface IDidToken {
    iat: number;
    ext: number;
    iss: string;
    sub: string;
    aud: string;
    add: IDidTokenAdd;
    nbf: number;
    tid: string;
}