clean9326
02/18/2023, 8:00 AMts
import { Inject, Injectable } from '@nestjs/common';
import supertokens from 'supertokens-node';
import { ConfigInjectionToken, AuthModuleConfig } from '../config.interface';
import * as SuperTokensConfig from '../../config';
@Injectable()
export class SupertokensService {
constructor(@Inject(ConfigInjectionToken) private config: AuthModuleConfig) {
supertokens.init({
appInfo: config.appInfo,
supertokens: {
connectionURI: SuperTokensConfig.connectionUri,
apiKey: SuperTokensConfig.apiKey,
},
recipeList: SuperTokensConfig.recipeList,
});
}
}
export const appInfo = {
// Learn more about this on https://supertokens.com/docs/thirdpartypasswordless/appinfo
appName: 'Studywithme',
apiDomain: process.env.API_DOMAIN ?? 'http://localhost:3001',
websiteDomain: process.env.WEBSITE_DOMAIN ?? 'http://localhost:3000',
apiBasePath: '/auth',
websiteBasePath: '/auth',
};
export const recipeList = [
ThirdPartyPasswordless.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.
ThirdPartyPasswordless.Google({
clientId: process.env.GOOGLE_ID,
clientSecret: process.env.GOOGLE_SECRET,
}),
ThirdPartyPasswordless.Github({
clientSecret: process.env.GITHUB_SECRET,
clientId: process.env.GITHUB_ID,
}),
],
contactMethod: 'EMAIL_OR_PHONE',
flowType: 'USER_INPUT_CODE_AND_MAGIC_LINK',
}),
Session.init(),
Dashboard.init({
apiKey: process.env.AUTH_API_KEY,
}),
];