diff --git a/lib/fixtures/facebook.js b/lib/fixtures/facebook.js index 9c1e56b..530f560 100644 --- a/lib/fixtures/facebook.js +++ b/lib/fixtures/facebook.js @@ -10,25 +10,6 @@ const DANCE_CALLBACK = `fb0123456789://authorize# expires_in=12345 `.replace(/\s+/g, ''); -const VERIFY_URL = `https://graph.facebook.com/debug_token? - input_token=ACCESSTOKEN123& - access_token=ACCESSTOKEN123 -`.replace(/\s+/g, ''); - -const VERIFY_RESPONSE = { - data: { - app_id: 'APPID123', - application: 'Test App', - expires_at: 123456789, - is_valid: true, - scopes: [ - 'email', - 'public_profile', - ], - user_id: 'USER123', - }, -}; - const USER_INFO_URL = `https://graph.facebook.com/v2.8/me? fields=id,name,first_name,last_name,verified,email,location,link& access_token=ACCESSTOKEN123 @@ -43,6 +24,5 @@ const USER_INFO_RESPONSE = { export const DANCE = [AUTH_URL, DANCE_CALLBACK]; export const REQUESTS = [ - [VERIFY_URL, {}, VERIFY_RESPONSE, 'verify token'], [USER_INFO_URL, {}, USER_INFO_RESPONSE, 'get user info'], ]; diff --git a/lib/providers/facebook.js b/lib/providers/facebook.js index bbdd348..e7db882 100644 --- a/lib/providers/facebook.js +++ b/lib/providers/facebook.js @@ -1,14 +1,9 @@ import { __, curry, - equals, - identity, - ifElse, invoker, lensProp, - merge, partial, - pathSatisfies, pipeP, replace, set, @@ -20,27 +15,16 @@ import { fromQueryString } from '../utils/uri'; const SCOPE = 'email public_profile'; const AUTH = 'https://www.facebook.com/dialog/oauth'; -const DEBUG_TOKEN = 'https://graph.facebook.com/debug_token'; const ME = 'https://graph.facebook.com/v2.8/me?fields=' + 'id,name,first_name,last_name,verified,email,location,link'; -const checkAppId = curry((appId, obj) => ifElse( - pathSatisfies(equals(appId), ['data', 'app_id']), - identity, - () => { throw new Error('AppIds don\'t match.'); }, -)(obj)); - export const authorize = ({ dance, request }, { appId, callback }) => pipeP( dance, replace('#', '?'), fromQueryString, - merge({ appId }), )(authorizationUrl(AUTH, appId, callback, SCOPE)); -export const identify = curry((request, { appId, ...credentials }) => pipeP( - partial(request, [`${DEBUG_TOKEN}?input_token=${credentials.access_token}&access_token=${credentials.access_token}`, {}]), // eslint-disable-line max-len - invoker(0, 'json'), - checkAppId(appId), +export const identify = curry((request, credentials) => pipeP( partial(request, [`${ME}&access_token=${credentials.access_token}`, {}]), invoker(0, 'json'), set(lensProp('user'), __, {}), diff --git a/package.json b/package.json index 32a869a..112120f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-simple-auth", - "version": "2.0.0", + "version": "2.0.1", "description": "Native social authentication for React Native", "main": "index.js", "scripts": {