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

yah-js-sdk

v0.1.5

Published

yah-js-sdk ===========

Downloads

8

Readme

yah-js-sdk

Client libraries includes methods to use SHIELD, libraries to ease the use of Webpack Module Federation - Promise based loading. It provides the essential packages to facilitate yahilo features across yahilo applications.

As of now, yah-js-sdk contains the following

shield helps to setup authentication for your application. It contains many methods to setup user authentication with shield and obtain tokens across yahilo applications.

ab-federation-helpers contains hooks and methods to facilitate federated Components and Modules

Installation

    npm i yah-js-sdk

Usage

    import { shield } from 'yah-js-sdk/shield'

    import { useFederatedComponent } from 'yah-js-sdk/ab-federation-helpers'

shield

yah-js-sdk/shield includes the following elements

  1. tokenStore
  2. init
  3. verifyLogin
  4. getAuthUrl
  5. logout

tokenStore

Description

Its an object which stores the token, refresh Token, expiry time as private variables along with related functions. It contains the timer id for the token

Usage

shield.tokenStore.getToken()

init

Description

Its used to initialise the tokenstore with values from the shield backend. It takes a parameter clientID which is unique for each application.

Usage

await shield.init('#client-id')

verifyLogin

Description

It retrieves for the token from the localStorage and validates the token. If the token is not present in the localStorage it redirects to the shield login.

Usage

const isLoggedinn = await shield.verifyLogin()

getAuthUrl

Description

It generates authorization URL with query parameters

Usage

const authUrl = shield.getAuthUrl()

logout

Description

It logs out the user by removing the token from localStorage and redirects to shield login.

Usage

await shield.logout()

ab-federation-helpers

ab-federation-helpers includes the following elements

  1. useFederatedComponent
  2. useFederatedModule
  3. useDynamicScript

useFederatedComponent

Description

used to obtain federated Component .

Usage

const system = {
    module: './login',
    scope: 'login',
    url: 'http://localhost:3013/remoteEntry.js',
}
const { Component: FederatedComponent, errorLoading } = useFederatedComponent(
  system?.url,
  system?.scope,
  system?.module,
  React
)
return (
  <React.Suspense fallback={''}>
    {errorLoading
      ? `Error loading module "${module}"`
      : FederatedComponent && <FederatedComponent />}
  </React.Suspense>
)

useFederatedModule

Description

used to obtain federated Module .

Usage

const system = {
    module: './login',
    scope: 'login',
    url: 'http://localhost:3013/remoteEntry.js',
}
const { Component: FederatedModule, errorLoading } = useFederatedModule(
  system?.url,
  system?.scope,
  system?.module,
  React
)

useDynamicScript

Description

loads script from remote URL.

Usage

  const { ready, errorLoading } = useDynamicScript(remoteUrl, React);