1.0.7 • Published 1 year ago

@white-matrix/matrix-universe-auth-sdk v1.0.7

Weekly downloads
-
License
-
Repository
-
Last release
1 year ago

@white-matrix/matrix-universe-auth-sdk

Install

yarn add @white-matrix/matrix-universe-auth-sdk

Usage

Init auth config & Warp AuthProvider in root

import {
  AuthProvider,
  EAuthEnv,
  initAuthConfig,
} from "@white-matrix/matrix-universe-auth-sdk";
import "@white-matrix/matrix-universe-auth-sdk/dist/style.css";
import { toast, ToastContainer } from "react-toastify";

initAuthConfig({
  // env
  env: EAuthEnv.DEV,
  // toast method
  toast: (message, type) => {
    toast[type](message);
  },
  // get sub system access token by main system auth code
  getAccessToken: async (authCode: string) => {
    if (!authCode) return;
    const data = await fetch(
      `${BASE_URL}/api/auth/callback?token=${encodeURIComponent(authCode)}`,
      {
        method: "GET",
      }
    );
    if (data.status === 200) {
      return await data.text();
    } else {
      throw new Error("Failed to get access token");
    }
  },
});

ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
  <React.StrictMode>
    <ToastContainer />
    <AuthProvider>
      <App />
    </AuthProvider>
  </React.StrictMode>
);

Methods

import {
  addWallet,
  login,
  logout,
  logoutAndShowLoginModal,
  openProfileModal,
  register,
} from "@white-matrix/matrix-universe-auth-sdk";

Check is login

import { useAuthStore } from "@white-matrix/matrix-universe-auth-sdk";
const { userInfo } = useAuthStore();
// if userInfo?.userId has value, User has logged in
1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

1.0.3

1 year ago

0.2.7

1 year ago

0.2.8

1 year ago

0.2.5

1 year ago

0.2.4

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.2.3

1 year ago

0.2.2

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago