@cranberry-money/shared-services
Version:
Platform-agnostic API services with pure functions and dependency injection. Includes auth, portfolios, instruments, countries, sectors, and more.
30 lines • 1.11 kB
JavaScript
import { AUTH_ENDPOINTS } from '@cranberry-money/shared-constants';
let configuredApiClient = null;
export const configureAuth = (apiClient) => {
configuredApiClient = apiClient;
};
const getConfiguredClient = () => {
if (!configuredApiClient) {
throw new Error('Auth service not configured. Call configureAuth(apiClient) before using auth functions.');
}
return configuredApiClient;
};
export const signin = (data) => {
return getConfiguredClient().post(AUTH_ENDPOINTS.SIGNIN, data);
};
export const signout = () => {
return getConfiguredClient().post(AUTH_ENDPOINTS.SIGNOUT);
};
export const signup = (data) => {
return getConfiguredClient().post(AUTH_ENDPOINTS.SIGNUP, data);
};
export const verifyEmail = (data) => {
return getConfiguredClient().post(AUTH_ENDPOINTS.EMAIL_VERIFICATION, data);
};
export const resendVerificationCode = () => {
return getConfiguredClient().post(AUTH_ENDPOINTS.RESEND_VERIFICATION);
};
export const refreshToken = (data) => {
return getConfiguredClient().post(AUTH_ENDPOINTS.TOKEN_REFRESH, data);
};
//# sourceMappingURL=auth.js.map