Skip to content

Bear auth contains a set of methods for managing JWT tokens in single page application.

License

Notifications You must be signed in to change notification settings

AckeeCZ/bear-auth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ba86fb1 Β· Apr 9, 2025

History

72 Commits
Apr 9, 2025
Dec 16, 2024
Dec 16, 2024
Apr 9, 2025
Apr 9, 2025
Apr 9, 2025
Dec 3, 2024
Dec 3, 2024
Dec 3, 2024
Dec 16, 2024
Dec 17, 2024
Dec 3, 2024
Apr 9, 2025
Dec 16, 2024
Dec 16, 2024
Apr 9, 2025

Repository files navigation

🐻 Bear Auth

Bear auth contains a set of methods for managing JWT tokens in single page applications.

Features

  • πŸͺΆ Ultra-light
  • ♻️ Auto access token refreshment
    • If the authenticate method returns valid expiration and refreshToken, the @bear-auth/core will use the refresh token hook to maintain fresh access token.
  • πŸ›œ Network status detection
    • To avoid refreshing access token while the app is offline.
    • By default it uses navigator.onLine flag and the online event but can be changed via the setContinueWhenOnline method.
  • πŸ—οΈ Highly customizable
    • You can override almost all the default behaviour – storage, network, etc.
  • πŸ’¨ Tree-shakeable & side-effect free
    • The API has been designed as pure functions (rather than one heavy object) to support tree-shaking.
  • πŸ™ˆ Framework agnostic
    • The @bear-auth/core consists of just (promised-based) TypeScript vanilla methods. No attachment to library/framework.
    • There is currently one official integration for React but others can be easily implemented.
  • βœ… Strongly typed
  • ✨ Multiple instances per origin
  • πŸ‘¨β€πŸš’ Custom error & guard functions for easier error handling
    • isBearAuthError(error: unknown): error is BearAuthError
    • isBearAuthError(error: unknown, ['bear-auth/retrieve-auth-session-failed']): error is BearAuthError<'bear-auth/retrieve-auth-session-failed'>

Packages

Examples