import { useTuitioToken } from "@flare/tuitio-client-react";
import { useCallback } from "react";

const useResourceSecurity = () => {
  const { token } = useTuitioToken();
  const secureUrl = useCallback(
    (url) => {
      const separator = url.includes("?") ? "&" : "?";
      const securedUrl = `${url}${separator}token=${token}`;
      return securedUrl;
    },
    [token]
  );

  return { secureUrl };
};

export default useResourceSecurity;
