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

@nbcom/auth

Package Overview
Dependencies
Maintainers
1
Versions
112
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nbcom/auth

[![N|Solid](https://svgshare.com/i/nwR.svg)](nbcomputers.ru)

latest
npmnpm
Version
0.6.0
Version published
Maintainers
1
Created
Source

Auth flow

N|Solid

Work auth flow context that enables any component to get the current auth state user type and rerender if it changes

  • React/TypeScript
  • Redux
  • NextJS
  • ✨Magic ✨

Features

  • UserProvider includes a user type and a setter function to change it
  • useJWTAuthentication checks for a VERIFY cookie and sets the authorization flag isAuthorized=true. If the user is logged in, it sends a request to refresh the token
  • setAuthCookie Callback for set expire auth cookies
  • Logout hook

Installation

@nbcom/auth requires Node.js v16+, @nbcom/api to run.

Install the package

npm install @nbcom/auth

Development

Using user provider

import { UserProvider } from '@nbcom/auth'

  <UserProvider>
    <Template>
      <Component {...pageProps} />
    </Template>
  </UserProvider>

Using logout hook

You must create proxy file pages/api/removeAuthCookiesProxy.ts with your domain like 'someurl.ru'

import { removeAuthCookies } from "@nbcom/auth";

export default removeAuthCookies('domain');

Then you can use the hook logOut

import { useLogOut } from '@nbcom/auth'

const { logOut } = useLogOut();
<Button onClick={logOut}> Exit from acc</Button>

Boolean flag && set type user

import { useUser } from '@nbcom/auth'
const { isJuridicalUser, changeUserType, isAuthorized } = useUser();

Good luck

FAQs

Package last updated on 06 Apr 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