48 lines
1.5 KiB
TypeScript
48 lines
1.5 KiB
TypeScript
// import PasswordlessReact from 'supertokens-auth-react/recipe/passwordless'
|
|
import ThirdPartyReact from 'supertokens-auth-react/recipe/thirdparty'
|
|
import SessionReact from 'supertokens-auth-react/recipe/session'
|
|
import { appInfo } from './appInfo'
|
|
import { SuperTokensConfig } from 'supertokens-auth-react/lib/build/types'
|
|
import { useRouter } from "next/navigation";
|
|
import { faPatreon } from '@fortawesome/free-brands-svg-icons';
|
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
|
|
const routerInfo: { router?: ReturnType<typeof useRouter>; pathName?: string } = {};
|
|
|
|
export function setRouter(
|
|
router: ReturnType<typeof useRouter>,
|
|
pathName: string,
|
|
) {
|
|
routerInfo.router = router;
|
|
routerInfo.pathName = pathName;
|
|
}
|
|
|
|
export const frontendConfig = (): SuperTokensConfig => {
|
|
return {
|
|
appInfo,
|
|
recipeList: [
|
|
ThirdPartyReact.init({
|
|
signInAndUpFeature: {
|
|
providers: [
|
|
ThirdPartyReact.Github.init(),
|
|
{
|
|
id: 'patreon',
|
|
name: 'Patreon',
|
|
logo: <FontAwesomeIcon icon={faPatreon} className="fab fa-patreon" style={{ height: "17px" }} />,
|
|
}
|
|
],
|
|
},
|
|
}),
|
|
SessionReact.init(),
|
|
],
|
|
windowHandler: (original) => ({
|
|
...original,
|
|
location: {
|
|
...original.location,
|
|
getPathName: () => routerInfo.pathName!,
|
|
assign: (url) => routerInfo.router!.push(url.toString()),
|
|
setHref: (url) => routerInfo.router!.push(url.toString()),
|
|
},
|
|
}),
|
|
}
|
|
} |