Using passport-steam and supabase auth in nextjs.

My idea is to let people sign in with discord using supabase. After a successful log in they have a option to "link" their discord account with steam. After the linking process their steam-id should be inserted into the supabase profiles table. Supabase does not have steam as a official authentication provider so i'm using passport-steam for the steam part.

The passport-steam strategy looks like this:
const SteamStrategy = passportSteam.Strategy;

export interface SteamProfile {
  displayName: string;
  id: string;
  identifier: string;
  photos: Image;
  provider: string;
}

interface Image {
  value: string;
}
passport.serializeUser(function (user, done) {
  done(null, user);
});

passport.deserializeUser(function (obj: SteamProfile, done) {
  done(null, obj);
});

passport.use(
  new SteamStrategy(
    {
      returnURL: `${process.env.DOMAIN}/api/auth/return`,
      realm: `${process.env.DOMAIN}`,
      apiKey: `${process.env.STEAM_API_KEY}`,
    },
    (
      _: string,
      profile: SteamProfile,
      done: (a: null | string, b: SteamProfile) => typeof done
    ) => {

      return done(null, profile);
      
    }
  )
);

export default passport;


My guess would be that i should use this in the passport.use:
const { error } = await supabase
  .from('profiles')
  .update({ steamid: profile.id })
  .eq('id', discord_id)


But i have no idea how could i get the logged in users discord id.
Was this page helpful?