UNPKG

@dudadev/ms-client-auth

Version:

Client to authenticate Duda's microservices' clients

28 lines (20 loc) 719 B
# Microservices authentication client Client to authenticate Duda's microservices' clients ## Usage ```javascript 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 }); ```