All files / src/security FacebookAuthStrategy.ts

75% Statements 6/8
100% Branches 0/0
33.33% Functions 1/3
75% Lines 6/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 238x 8x 8x 8x   8x   1x                              
import passport from 'passport'
import { Strategy } from 'passport-facebook'
import { Commun } from '@commun/core'
import { ExternalAuth } from './ExternalAuth'
 
export const FacebookAuthStrategy = {
  registerStrategy () {
    passport.use(new Strategy({
        clientID: process.env.FACEBOOK_APP_ID!,
        clientSecret: process.env.FACEBOOK_APP_SECRET!,
        callbackURL: `${Commun.getOptions().endpoint}/api/v1/auth/facebook/callback`,
        profileFields: ['id', 'emails', 'displayName'],
      }, async (...args) => {
        await ExternalAuth.authCallback('facebook', ...args)
      })
    )
  },
 
  authOptions: {
    scope: 'email'
  },
}