diff --git a/lib/KindeAuthProvider.tsx b/lib/KindeAuthProvider.tsx index b6291b6..0fa008c 100644 --- a/lib/KindeAuthProvider.tsx +++ b/lib/KindeAuthProvider.tsx @@ -35,14 +35,24 @@ global.atob = decode; export const KindeAuthProvider = ({ children, + config, }: { children: React.ReactNode; + config: { + domain: string | undefined; + clientId: string | undefined; + scopes?: string; + }; }) => { - const domain = process.env.EXPO_PUBLIC_KINDE_DOMAIN!; - const clientId = process.env.EXPO_PUBLIC_KINDE_CLIENT_ID!; - const scopes = - process.env.EXPO_PUBLIC_KINDE_SCOPES?.split(" ") || - DEFAULT_TOKEN_SCOPES.split(" "); + const domain = config.domain; + if (domain === undefined) + throw new Error("KindeAuthProvider config.domain prop is undefined"); + + const clientId = config.clientId; + if (clientId === undefined) + throw new Error("KindeAuthProvider config.clientId prop is undefined"); + + const scopes = config.scopes?.split(" ") || DEFAULT_TOKEN_SCOPES.split(" "); const [isAuthenticated, setIsAuthenticated] = useState(false); const redirectUri = makeRedirectUri({ native: Constants.isDevice }); diff --git a/readme.md b/readme.md index 9230f6b..169ef98 100644 --- a/readme.md +++ b/readme.md @@ -12,13 +12,6 @@ pnpm add @kinde/expo ## **Environment variables** -```bash -EXPO_PUBLIC_KINDE_DOMAIN=[yourapp.kinde.com] -EXPO_PUBLIC_KINDE_CLIENT_ID="ApplicationClientId" -// Optional (default: "openid profile email offline") -EXPO_PUBLIC_KINDE_SCOPES="openid profile email offline" -``` - The redirection URL is automatically computed using Expo Auth Session `makeRedirectUri` function. You can find more information about this function [here](https://docs.expo.dev/versions/latest/sdk/auth-session/#makeRedirectUri). ## Integrate with your app @@ -30,7 +23,12 @@ import { KindeAuthProvider } from '@kinde/expo'; export default function App() { return ( - + );