@smart-auth/shared
v0.1.2
Published
Shared utilities for Smart Auth SDK — JWT decoding, event emitter, environment detection, and logging
Maintainers
Readme
@smart-auth/shared
Shared utilities for the Smart Auth SDK ecosystem.
What it does
@smart-auth/shared provides internal utilities used across Smart Auth SDK packages — JWT decoding, token expiration checks, environment detection, typed event emitter, and a secure logger with sensitive data masking.
Note: This is an internal package. You typically don't need to install it directly — it's automatically included as a dependency of
@smart-auth/coreand@smart-auth/express.
What's included
| Utility | Description |
| -------------------------- | ------------------------------------------------------------ |
| decodeToken() | Decode a JWT payload without verification (client-side safe) |
| isTokenExpired() | Check if a JWT is expired with clock skew support |
| getTokenExpiration() | Get the expiration timestamp from a JWT |
| getTokenTimeRemaining() | Get milliseconds until a token expires |
| TypedEventEmitter | Type-safe event emitter for auth events |
| createLogger() | Logger with sensitive data masking |
| resolveConfig() | Merge user config with sensible defaults |
| isBrowser() / isNode() | Environment detection helpers |
| safeLocalStorage() | Safe access to localStorage (handles SSR and private mode) |
Installation
npm install @smart-auth/sharedPart of Smart Auth SDK
| Package | Description |
| -------------------------------------------------------------------------- | ------------------ |
| @smart-auth/core | Core auth engine |
| @smart-auth/react | React integration |
| @smart-auth/express | Express middleware |
License
MIT © Durjoy Ghosh