mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
Refactors with-supertokens example app to move some of the helper functions into the SDK.
92 lines
3.0 KiB
TypeScript
92 lines
3.0 KiB
TypeScript
import ThirdPartyEmailPasswordNode from "supertokens-node/recipe/thirdpartyemailpassword";
|
|
import SessionNode from "supertokens-node/recipe/session";
|
|
import Dashboard from "supertokens-node/recipe/dashboard";
|
|
import UserRoles from "supertokens-node/recipe/userroles";
|
|
import { appInfo } from "./appInfo";
|
|
import { TypeInput } from "supertokens-node/types";
|
|
import SuperTokens from "supertokens-node";
|
|
|
|
export let backendConfig = (): TypeInput => {
|
|
return {
|
|
supertokens: {
|
|
// this is the location of the SuperTokens core.
|
|
connectionURI: "https://try.supertokens.com",
|
|
},
|
|
appInfo,
|
|
// recipeList contains all the modules that you want to
|
|
// use from SuperTokens. See the full list here: https://supertokens.com/docs/guides
|
|
recipeList: [
|
|
ThirdPartyEmailPasswordNode.init({
|
|
providers: [
|
|
// We have provided you with development keys which you can use for testing.
|
|
// IMPORTANT: Please replace them with your own OAuth keys for production use.
|
|
{
|
|
config: {
|
|
thirdPartyId: "google",
|
|
clients: [
|
|
{
|
|
clientId:
|
|
"1060725074195-kmeum4crr01uirfl2op9kd5acmi9jutn.apps.googleusercontent.com",
|
|
clientSecret: "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",
|
|
},
|
|
],
|
|
},
|
|
},
|
|
{
|
|
config: {
|
|
thirdPartyId: "github",
|
|
clients: [
|
|
{
|
|
clientId: "467101b197249757c71f",
|
|
clientSecret: "e97051221f4b6426e8fe8d51486396703012f5bd",
|
|
},
|
|
],
|
|
},
|
|
},
|
|
{
|
|
config: {
|
|
thirdPartyId: "apple",
|
|
clients: [
|
|
{
|
|
clientId: "4398792-io.supertokens.example.service",
|
|
additionalConfig: {
|
|
keyId: "7M48Y4RYDL",
|
|
privateKey:
|
|
"-----BEGIN PRIVATE KEY-----\nMIGTAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBHkwdwIBAQQgu8gXs+XYkqXD6Ala9Sf/iJXzhbwcoG5dMh1OonpdJUmgCgYIKoZIzj0DAQehRANCAASfrvlFbFCYqn3I2zeknYXLwtH30JuOKestDbSfZYxZNMqhF/OzdZFTV0zc5u5s3eN+oCWbnvl0hM+9IW0UlkdA\n-----END PRIVATE KEY-----",
|
|
teamId: "YWQCXGJRJL",
|
|
},
|
|
},
|
|
],
|
|
},
|
|
},
|
|
{
|
|
config: {
|
|
thirdPartyId: "twitter",
|
|
clients: [
|
|
{
|
|
clientId: "4398792-WXpqVXRiazdRMGNJdEZIa3RVQXc6MTpjaQ",
|
|
clientSecret:
|
|
"BivMbtwmcygbRLNQ0zk45yxvW246tnYnTFFq-LH39NwZMxFpdC",
|
|
},
|
|
],
|
|
},
|
|
},
|
|
],
|
|
}),
|
|
SessionNode.init(),
|
|
Dashboard.init(),
|
|
UserRoles.init(),
|
|
],
|
|
isInServerlessEnv: true,
|
|
framework: "custom",
|
|
};
|
|
};
|
|
|
|
let initialized = false;
|
|
export function ensureSuperTokensInit() {
|
|
if (!initialized) {
|
|
SuperTokens.init(backendConfig());
|
|
initialized = true;
|
|
}
|
|
}
|