Registry / auth-security / tms-auth

tms-auth

JSON →
library1.3.13jsnpmunverified

TMS Auth is an authentication library for React/UMI applications, version 1.3.13. It provides hooks and components for handling authentication flows such as login, logout, and permission checks. Built specifically for UMI framework with seamless integration. It ships TypeScript definitions. Last update was several months ago; no known recent active development. Alternative: umi-plugin-auth for UMI-specific setups or generic react-auth-kit.

npm install tms-auth
INSTALL
IMPORT
SIG · TMS-AUTH
T
tms-auth
auth-securityjavascriptv1.3.13
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

useAuth
import { useAuth } from 'tms-auth';
import useAuth from 'tms-auth';
The default export is not available; use named import.
withAuth
import { withAuth } from 'tms-auth';
import { withAuth } from 'tms-auth/src';
Do not import from subpaths; only the main entry is supported.
AuthProvider
import { AuthProvider } from 'tms-auth';
import AuthProvider from 'tms-auth';
AuthProvider is a named export, not default.
TMSAuth
import { TMSAuth } from 'tms-auth';
import { TMSAuth } from 'tms-auth/TMSAuth';
TMSAuth is exported from the package root.

Shows minimal setup using AuthProvider and useAuth hook with a login button.

import { AuthProvider, useAuth } from 'tms-auth'; import React from 'react'; function LoginButton() { const { login } = useAuth(); return ( <button onClick={() => login({ username: 'user', password: 'pass' })}> Login </button> ); } function App() { return ( <AuthProvider config={{ tokenKey: 'my_app_token' }}> <LoginButton /> </AuthProvider> ); } export default App;
Debug
Known issues
gotchaThe tokenKey config option changed from 'token' to 'my_app_token' default after v1.0.0. Existing apps may break if relying on old default.
fix
Set tokenKey explicitly in AuthProvider config to match your stored token key.
affects: >=1.0.0 <1.1.0
deprecatedThe withAuth HOC is deprecated in favor of useAuth hook. It may be removed in future versions.
fix
Replace withAuth with useAuth hook in functional components.
affects: >=1.2.0
gotchaAuthProvider must be above any component using useAuth in the component tree; otherwise useAuth throws a runtime error.
fix
Ensure AuthProvider wraps the entire app or at least the components that need authentication.
affects: >=0.9.0
breakingIn v1.3.0, the logout function no longer calls a cleanup callback; it only clears the token. Code relying on the callback will break.
fix
Manually call cleanup logic after logout() if needed.
affects: >=1.3.0
Errors
Common errors & fixes
Error: useAuth must be used within an AuthProvider
The useAuth hook is called outside of the AuthProvider context.
fix
Wrap your component tree with <AuthProvider> at the top level.
Cannot find module 'tms-auth' or its corresponding type declarations.
Missing package installation or TypeScript cannot resolve types.
fix
Run 'npm install tms-auth' and ensure tsconfig includes 'node_modules' in typeRoots.
TypeError: login is not a function
The useAuth hook returns an object without login because the provider is missing or misconfigured.
fix
Check that AuthProvider is rendered and passes config correctly.
Error: Invalid tokenKey provided to AuthProvider
The tokenKey config value is not a string or is undefined.
fix
Provide a valid string for tokenKey in AuthProvider config.
Upgrade
Version history
1.3.13latest on npm
Audit
Dependencies
umirequiredPeer dependency required for plugin functionality
reactrequiredPeer dependency for React components and hooks
react-domrequiredPeer dependency for DOM rendering
Agent activity
22 hits · last 30 days
node
20
OpenAI (training)
1
Resources
tms-auth — npm install tms-auth · libregistry