Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import Auth0 from "react-native-auth0";
import SP from "sp-client";
import {
TOKEN_STORAGE_KEY,
PROFILE_STORAGE_KEY,
AUTH0_DOMAIN,
AUTH0_CLIENT_ID,
AUTH0_REALM,
ID_TOKEN
} from "../constants";
import { AsyncStorage } from "react-native";
import jwtDecode from "jwt-decode";
const auth0 = new Auth0({
domain: AUTH0_DOMAIN,
clientId: AUTH0_CLIENT_ID
});
/**
* no-op; exists for API compatibility with the web auth module
*/
export async function checkLogin() {
const token = await AsyncStorage.getItem(TOKEN_STORAGE_KEY);
const user = await SP.connect({ token });
// Allow the API server to issue us a new token, then...
await AsyncStorage.setItem(TOKEN_STORAGE_KEY, SP.token);
return user;
}
export async function login({ email, password }) {