UNPKG

analytica-frontend-lib

Version:

Repositório público dos componentes utilizados nas plataformas da Analytica Ensino

70 lines (69 loc) 2.42 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/components/Auth/zustandAuthAdapter.ts var zustandAuthAdapter_exports = {}; __export(zustandAuthAdapter_exports, { createZustandAuthAdapter: () => createZustandAuthAdapter }); module.exports = __toCommonJS(zustandAuthAdapter_exports); function createZustandAuthAdapter(useAuthStore) { return { /** * Check if the user is authenticated based on sessionInfo and tokens * * @returns {Promise<boolean>} Promise that resolves to authentication status */ checkAuth: async () => { const { sessionInfo, tokens } = useAuthStore.getState(); return Boolean(sessionInfo && tokens); }, /** * Get the current user from the store * * @returns {unknown} Current user data from the store */ getUser: () => useAuthStore.getState().user, /** * Get the current session information from the store * * @returns {unknown} Current session info from the store */ getSessionInfo: () => useAuthStore.getState().sessionInfo, /** * Get the current authentication tokens from the store * * @returns {unknown} Current tokens from the store */ getTokens: () => useAuthStore.getState().tokens, /** * Sign out the user by calling the store's signOut function if available * * @returns {void} */ signOut: () => { const signOutFn = useAuthStore.getState().signOut; if (typeof signOutFn === "function") signOutFn(); } }; } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { createZustandAuthAdapter }); //# sourceMappingURL=index.js.map