This is a demo of the React Native Juicebox SDK.
The e-mail demo intends to demonstrate a Juicebox onboarding flow that:
- Generates Juicebox authentication tokens on a server external to the application
- Authenticates with that server through a "magic" link sent to the user's email
The example server can be found in the server directory.
To perform authentication and achieve these goals, onboarding typically looks something like:
- Request the user's e-mail
- Send the user's e-mail to the server (
POST /email-token
) to send a confirmation e-mail - Receive a single-use token from the user's e-mail
- Use the single-use token to authenticate with the server (
GET /auth-token
) to validate the user's e-mail and receive a server token - Request the user's PIN
- Use the server token to request Juicebox tokens (
POST /juicebox-token
) for the configured realms - Perform the appropriate Juicebox operation using the SDK (register or recover)
First, you will need to start Metro, the JavaScript bundler that ships with React Native.
To start Metro, run the following command from this folder:
# using npm
npm start
# OR using Yarn
yarn start
Let Metro Bundler run in its own terminal. Open a new terminal from this folder.
Run the following command to start the Android or iOS demo:
# using npm
npm run android
# OR using Yarn
yarn android
# using npm
npm run ios
# OR using Yarn
yarn ios
If everything is set up correctly, you should see the demo running in your Android Emulator or iOS Simulator shortly provided you have set up your emulator/simulator correctly.
You can also run it directly from within Android Studio and Xcode respectively by opening the respective projects.
For your convenience, this demo is configured to use an instance of the server that is hosted on Juicebox's servers. The go source code for the backend server is available in this repository.