diff --git a/src/context/GlobalProvider.tsx b/src/context/GlobalProvider.tsx index 0a35129..f9beb65 100644 --- a/src/context/GlobalProvider.tsx +++ b/src/context/GlobalProvider.tsx @@ -4,6 +4,12 @@ import { useResources } from "../hooks/useResources"; import { useAppInfo } from "../hooks/useAppInfo"; import { IdentifierBuilder } from "../utils/encryption"; import { useIdentifiers } from "../hooks/useIdentifiers"; +import { objectToBase64 } from "../utils/base64"; + + +const utils = { + objectToBase64 +} // ✅ Define Global Context Type @@ -12,8 +18,10 @@ interface GlobalContextType { resources: ReturnType; appInfo: ReturnType; identifierOperations: ReturnType +utils: typeof utils } + // ✅ Define Config Type for Hook Options interface GlobalProviderProps { children: React.ReactNode; @@ -29,6 +37,8 @@ interface GlobalProviderProps { // ✅ Create Context with Proper Type const GlobalContext = createContext(null); + + // 🔹 Global Provider (Handles Multiple Hooks) export const GlobalProvider = ({ children, config, identifierBuilder }: GlobalProviderProps) => { // ✅ Call hooks and pass in options dynamically @@ -38,7 +48,7 @@ export const GlobalProvider = ({ children, config, identifierBuilder }: GlobalPr const identifierOperations = useIdentifiers(identifierBuilder, config?.publicSalt) // ✅ Merge all hooks into a single `contextValue` - const contextValue = useMemo(() => ({ auth, resources, appInfo, identifierOperations }), [auth, resources, appInfo, identifierOperations]); + const contextValue = useMemo(() => ({ auth, resources, appInfo, identifierOperations, utils }), [auth, resources, appInfo, identifierOperations]); return ( {children} diff --git a/src/hooks/useIdentifiers.tsx b/src/hooks/useIdentifiers.tsx index 1aca4fa..9ddff01 100644 --- a/src/hooks/useIdentifiers.tsx +++ b/src/hooks/useIdentifiers.tsx @@ -5,11 +5,6 @@ import { buildIdentifier, buildSearchPrefix, IdentifierBuilder } from "../utils export const useIdentifiers = (builder?: IdentifierBuilder, publicSalt?: string) => { - const [publicSaltVal, setPublicSaltVal] = useState(publicSalt) - - useEffect(()=> { - setPublicSaltVal(publicSalt) - }, [publicSalt]) const setIdentifierBuilder = useAppStore().setIdentifierBuilder const identifierBuilder = useAppStore().identifierBuilder const appName = useAppStore().appName @@ -39,7 +34,6 @@ export const useIdentifiers = (builder?: IdentifierBuilder, publicSalt?: string) } }, [stringifiedBuilder]) return { - identifierBuilder, buildIdentifier: buildIdentifierFunc, buildSearchPrefix: buildSearchPrefixFunc };