npm.io
1.9.0 • Published 10h ago

fuse-cognito-login

Licence
ISC
Version
1.9.0
Deps
5
Size
1.4 MB
Vulns
0
Weekly
0

To use this library

  • How to debug

In your package.json, you can write this line.

  "fuse-cognito-login": "file:/path/to/this/project/npm-cognito-package",
yarn
  • How to publish

version up in package.json

./publish.sh
  • Add follows to your package.json
"browser": {
  "crypto": false
},
  • Install peer-dependencies to your project

  • Add follows to index.js

import { CookiesProvider } from "react-cookie";
    <CookiesProvider>
      <App />
    </CookiesProvider>
  • Make and use utils/fuse-lib.js

  • Logo image file: public/logo.jpg

  • Background image file: public/bg.jpg

  • define REACT_APP_TENANTHUB_API_BASEURL in .env file

  • Timezone picker (since 1.9.0)

Utils.getTimezones(axios) loads the TenantHub catalog from GET /api/timezones and resolves to [] when the request fails. Components.TimezoneAutocomplete is the picker the profile page uses: a controlled component with value (an IANA id or null), onChange(id | null), options, label, disabled and disableClearable.

import { Components, Utils } from "fuse-cognito-login";

const timezones = await Utils.getTimezones(axios);
<Components.TimezoneAutocomplete value={timezone} onChange={setTimezone} options={timezones} label="Timezone" />
  • Refresh Token

-- Install usehooks-ts to use useInterval -- Add followings to AppLayout.js

import { useInterval } from "usehooks-ts";
import { refreshAuth } from "utils/fuse-lib";
const refreshTokenInterval = 4 * 60 * 60 * 1000; // 4 hours
const AppLayout = () => {
  // ...
  useInterval(() => refreshAuth(), refreshTokenInterval);
  // ...
}