https://github.com/ackeecz/bear-auth
Bear auth contains a set of methods for managing JWT tokens in single page application.
https://github.com/ackeecz/bear-auth
authentication client-authentication frontend indexeddb jwt-authentication jwt-bearer-tokens jwt-client jwt-token react single-page-app typescript
Last synced: 5 months ago
JSON representation
Bear auth contains a set of methods for managing JWT tokens in single page application.
- Host: GitHub
- URL: https://github.com/ackeecz/bear-auth
- Owner: AckeeCZ
- License: gpl-3.0
- Created: 2024-12-03T14:56:39.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-04-09T10:41:45.000Z (6 months ago)
- Last Synced: 2025-05-10T01:06:20.496Z (5 months ago)
- Topics: authentication, client-authentication, frontend, indexeddb, jwt-authentication, jwt-bearer-tokens, jwt-client, jwt-token, react, single-page-app, typescript
- Language: TypeScript
- Homepage:
- Size: 729 KB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# ðŧ Bear Auth
Bear auth contains a set of methods for managing JWT tokens in single page applications.
## Features
- ðŠķ **Ultra-light**
- `@bear-auth/core`: [4.6 kB (min + gzip)](https://bundlephobia.com/package/@bear-auth/core)
- `@bear-auth/react`: [0.55 kB (min + gzip)](https://bundlephobia.com/package/@bear-auth/react)
- `@bear-auth/storage`: [0.44 kB (min + gzip)](https://bundlephobia.com/package/@bear-auth/storage)
- âŧïļ **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](./packages/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
- [`@bear-auth/core`](./packages/core)
- [`@bear-auth/react`](./packages/react)
- [`@bear-auth/storage`](./packages/storage)## Examples
- [`@bear-auth/core` example](./examples/core)
- [`@bear-auth/react` example](./examples/react)