@dudadev/ms-client-auth
v1.4.4
Published
Client to authenticate Duda's microservices' clients
Downloads
526
Maintainers
Keywords
Readme
Microservices authentication client
Client to authenticate Duda's microservices' clients
Usage
import { create } from '@dudadev/ms-client-auth';
const auth = create();
function authListener(authDetails) {
console.log(`Auth token: ${authDetails.value}`);
}
// Listen to auth changes
const cancelListener = auth.onAuth(authListener);
// Stop listening
cancelListener();
// Trigger authentication on demand
auth.authenticateServices()
// Set an interval to perform periodic authentication
auth.setAutoAuthInterval(5000); // This will cause the authenticator to authenticate every 5 seconds
// You can also create an auth instance with the interval
auth = create({ autoAuthInterval: 5000 });