Developers Guide¶
The following document is intended to help developers get started with the Bifold project. It includes information on how to set up your development environment, build the project, and run the app in an emulator.
Project Overview¶
The Aries Mobile Agent React Native (Bifold) is a user-friendly mobile agent that is built with React Native and uses Credo to exchange verifiable credentials with other agents. While Credo handles the heavy lifting of verifiable credential work, Bifold focuses on user experience and interactions with these credentials.
Key points to note:
- Bifold uses the Credo library, which in turn uses these Rust libraries.
- Credo uses the HTTP protocol to communicate with Aries agents and WebSockets for messaging via a mediator.
- Bifold relies on a mediator because mobile devices don't have a fixed IP address and often don't accept inbound network connections. The mediator, a service that runs on a server with a fixed IP address, relays messages between an agent and Bifold. The mediator is configured within the Bifold app.
Setup¶
The setup for Bifold is similar to other React Native projects. The following sections will walk you through the process of setting up your development environment, installing dependencies, and running the app in an emulator.
Prerequisites¶
This is a yarn based project, not npm. You will need to install yarn if you don't already have it installed. Also, you will need a version of node that is compatible with the version of yarn specified in the engines field of package.json If you don't have a compatible version of node installed, you can use nvm to install a compatible version of node.
This project will need to run on an iOS device or Android device or emulator. While it is recommended to test your software on both, especially if you're contributing back to the project, for demonstration purposes you can choose one or the other.
ProTip 🤓
If you are using Mac OS with ARM64 chip, see this DEVELOPER_MACOS_arm64
Setup & Configure for All Platforms¶
Start by cloning the repository:
Install all the package dependencies by running the following command from the root of the cloned repository:
Some packages need to be built (transpiled) before they can be used from the app. Do this with the following command:
As noted above Bifold requires a mediator to communicate with other Agents. For development purposes, this can be set by creating a .env file in the following directory:
Add a line to the .env file with the following content:
MEDIATOR_URL=https://public.mediator.indiciotech.io?c_i=eyJAdHlwZSI6ICJkaWQ6c292OkJ6Q2JzTlloTXJqSGlxWkRUVUFTSGc7c3BlYy9jb25uZWN0aW9ucy8xLjAvaW52aXRhdGlvbiIsICJAaWQiOiAiMDVlYzM5NDItYTEyOS00YWE3LWEzZDQtYTJmNDgwYzNjZThhIiwgInNlcnZpY2VFbmRwb2ludCI6ICJodHRwczovL3B1YmxpYy5tZWRpYXRvci5pbmRpY2lvdGVjaC5pbyIsICJyZWNpcGllbnRLZXlzIjogWyJDc2dIQVpxSktuWlRmc3h0MmRIR3JjN3U2M3ljeFlEZ25RdEZMeFhpeDIzYiJdLCAibGFiZWwiOiAiSW5kaWNpbyBQdWJsaWMgTWVkaWF0b3IifQ==
You can use the above mentioned public mediator hosted by Indecio or set up your own mediator. See Aries Mediator for more information.
Running Bifold¶
Running Bifold on an Android Device or Emulator¶
The simplest way to run Bifold on Android is via Android Studio. Here's how:
- Open Android Studio.
- Select
File -> Openand navigate to thepackages/legacy/app/androiddirectory. This will load the project into Android Studio. - Run the app on a connected device or emulator by selecting one from the list and clicking the green 'Play' button.
If you prefer using the command line interface (CLI), follow these steps:
For Linux¶
(Note: The following instructions assume you have Android Studio and the Android SDK installed in your home directory. If your setup is different, adjust the paths accordingly.)
- List the available emulators:
If no emulators are listed, check the Android Studio documentation to set up an emulator.
ProTip 🤓
Don't use the emulator located at ~/Android/Sdk/tools/emulator its older, deprecated, and will probably complain about missing the x86 emulator for newer SDK versions.
- Start an emulator from the list:
ProTip 🤓
Use -partition-size 1024 to increase the size of the emulator's data partition. This is useful if you're running the app in the emulator for an extended period of time.
- Start Metro, the React Native packager:
- Make sure you have the
JAVA_HOMEandANDROID_HOMEenvironment variables set correctly:
- Allow the Android emulator to communicate with Metro on port
tcp:8097:
- Finally, run the app in the emulator:
This will launch Bifold on your selected Android emulator for development and testing.
For MacOS¶
TBD - Help Wanted
For Windows¶
TBD - Help Wanted
Running Bifold on an iOS Device¶
Please note, you can't run the iOS version of Bifold on an iOS simulator – it must be run on an actual iOS device. To develop for iOS, you'll need a Mac with Xcode installed and potentially a developer team membership to execute Bifold on your device.
The easiest way to run Bifold on an iOS device is through Xcode, as outlined below:
- Install the Cocoapods package manager. You can use brew or any method you prefer:
- Install the necessary dependencies:
- Open the workspace (not the project file) in Xcode:
-
In Xcode, select your device, development team, and (if necessary) your Bundle ID. Note: Detailing these steps is beyond the scope of this guide.
-
Run the app on your device by clicking the 'Play' button in Xcode. This will launch Bifold on your selected iOS device for development and testing. It will also launch Metro, the React Native packager, in a separate terminal window. If you prefer to do this manually use the following command:
FAQ¶
-
Fix build
node-ffi-napichangedeps/libffi/libffi.gypin node-modules:'<(INTERMEDIATE_DIR)/<(RULE_INPUT_ROOT).asm', ], 'action': [ 'call', 'preprocess_asm.cmd', 'include', 'config/<(OS)/<(target_arch)', '<(RULE_INPUT_PATH)',to
-
Add custom leadger in
core/App/configs/ledgers/indy/ledgers.json, get ledger by url on portINDY_IP:9000/genesis: For example,{ "id": "IndyTest", "indyNamespace": "indy:test", "isProduction": false, "connectOnStartup": true, "genesisTransactions": "{\"reqSignature\":{},\"txn\":{\"data\":{\"data\":{\"alias\":\"Node1\",\"blskey\":\"4N8aUNHSgjQVgkpm8nhNEfDf6txHznoYREg9kirmJrkivgL4oSEimFF6nsQ6M41QvhM2Z33nves5vfSn9n1UwNFJBYtWVnHYMATn76vLuL3zU88KyeAYcHfsih3He6UHcXDxcaecHVz6jhCYz1P2UZn2bDVruL5wXpehgBfBaLKm3Ba\",\"blskey_pop\":\"RahHYiCvoNCtPTrVtP7nMC5eTYrsUA8WjXbdhNc8debh1agE9bGiJxWBXYNFbnJXoXhWFMvyqhqhRoq737YQemH5ik9oL7R4NTTCz2LEZhkgLJzB3QRQqJyBNyv7acbdHrAT8nQ9UkLbaVL9NBpnWXBTw4LEMePaSHEw66RzPNdAX1\",\"client_ip\":\"185.123.195.4\",\"client_port\":9702,\"node_ip\":\"185.123.195.4\",\"node_port\":9701,\"services\":[\"VALIDATOR\"]},\"dest\":\"Gw6pDLhcBcoQesN72qfotTgFa7cbuqZpkX3Xo6pLhPhv\"},\"metadata\":{\"from\":\"Th7MpTaRZVRYnPiabds81Y\"},\"type\":\"0\"},\"txnMetadata\":{\"seqNo\":1,\"txnId\":\"fea82e10e894419fe2bea7d96296a6d46f50f93f9eeda954ec461b2ed2950b62\"},\"ver\":\"1\"}\n{\"reqSignature\":{},\"txn\":{\"data\":{\"data\":{\"alias\":\"Node2\",\"blskey\":\"37rAPpXVoxzKhz7d9gkUe52XuXryuLXoM6P6LbWDB7LSbG62Lsb33sfG7zqS8TK1MXwuCHj1FKNzVpsnafmqLG1vXN88rt38mNFs9TENzm4QHdBzsvCuoBnPH7rpYYDo9DZNJePaDvRvqJKByCabubJz3XXKbEeshzpz4Ma5QYpJqjk\",\"blskey_pop\":\"Qr658mWZ2YC8JXGXwMDQTzuZCWF7NK9EwxphGmcBvCh6ybUuLxbG65nsX4JvD4SPNtkJ2w9ug1yLTj6fgmuDg41TgECXjLCij3RMsV8CwewBVgVN67wsA45DFWvqvLtu4rjNnE9JbdFTc1Z4WCPA3Xan44K1HoHAq9EVeaRYs8zoF5\",\"client_ip\":\"185.123.195.4\",\"client_port\":9704,\"node_ip\":\"185.123.195.4\",\"node_port\":9703,\"services\":[\"VALIDATOR\"]},\"dest\":\"8ECVSk179mjsjKRLWiQtssMLgp6EPhWXtaYyStWPSGAb\"},\"metadata\":{\"from\":\"EbP4aYNeTHL6q385GuVpRV\"},\"type\":\"0\"},\"txnMetadata\":{\"seqNo\":2,\"txnId\":\"1ac8aece2a18ced660fef8694b61aac3af08ba875ce3026a160acbc3a3af35fc\"},\"ver\":\"1\"}\n{\"reqSignature\":{},\"txn\":{\"data\":{\"data\":{\"alias\":\"Node3\",\"blskey\":\"3WFpdbg7C5cnLYZwFZevJqhubkFALBfCBBok15GdrKMUhUjGsk3jV6QKj6MZgEubF7oqCafxNdkm7eswgA4sdKTRc82tLGzZBd6vNqU8dupzup6uYUf32KTHTPQbuUM8Yk4QFXjEf2Usu2TJcNkdgpyeUSX42u5LqdDDpNSWUK5deC5\",\"blskey_pop\":\"QwDeb2CkNSx6r8QC8vGQK3GRv7Yndn84TGNijX8YXHPiagXajyfTjoR87rXUu4G4QLk2cF8NNyqWiYMus1623dELWwx57rLCFqGh7N4ZRbGDRP4fnVcaKg1BcUxQ866Ven4gw8y4N56S5HzxXNBZtLYmhGHvDtk6PFkFwCvxYrNYjh\",\"client_ip\":\"185.123.195.4\",\"client_port\":9706,\"node_ip\":\"185.123.195.4\",\"node_port\":9705,\"services\":[\"VALIDATOR\"]},\"dest\":\"DKVxG2fXXTU8yT5N7hGEbXB3dfdAnYv1JczDUHpmDxya\"},\"metadata\":{\"from\":\"4cU41vWW82ArfxJxHkzXPG\"},\"type\":\"0\"},\"txnMetadata\":{\"seqNo\":3,\"txnId\":\"7e9f355dffa78ed24668f0e0e369fd8c224076571c51e2ea8be5f26479edebe4\"},\"ver\":\"1\"}\n{\"reqSignature\":{},\"txn\":{\"data\":{\"data\":{\"alias\":\"Node4\",\"blskey\":\"2zN3bHM1m4rLz54MJHYSwvqzPchYp8jkHswveCLAEJVcX6Mm1wHQD1SkPYMzUDTZvWvhuE6VNAkK3KxVeEmsanSmvjVkReDeBEMxeDaayjcZjFGPydyey1qxBHmTvAnBKoPydvuTAqx5f7YNNRAdeLmUi99gERUU7TD8KfAa6MpQ9bw\",\"blskey_pop\":\"RPLagxaR5xdimFzwmzYnz4ZhWtYQEj8iR5ZU53T2gitPCyCHQneUn2Huc4oeLd2B2HzkGnjAff4hWTJT6C7qHYB1Mv2wU5iHHGFWkhnTX9WsEAbunJCV2qcaXScKj4tTfvdDKfLiVuU2av6hbsMztirRze7LvYBkRHV3tGwyCptsrP\",\"client_ip\":\"185.123.195.4\",\"client_port\":9708,\"node_ip\":\"185.123.195.4\",\"node_port\":9707,\"services\":[\"VALIDATOR\"]},\"dest\":\"4PS3EDQ3dW1tci1Bp6543CfuuebjFrg36kLAUcskGfaA\"},\"metadata\":{\"from\":\"TWwCRQRZ2ZHMJFn9TzLp7W\"},\"type\":\"0\"},\"txnMetadata\":{\"seqNo\":4,\"txnId\":\"aa5e817d7cc626170eca175822029339a444eb0ee8f0bd20d3b0b76e566fb008\"},\"ver\":\"1\"}" } -
Add .env
MEDIATOR_URLinpackages/legacy/app/.env:MEDIATOR_URL=http://mediator.svgun.ru?c_i=eyJAdHlwZSI6ICJodHRwczovL2RpZGNvbW0ub3JnL2Nvbm5lY3Rpb25zLzEuMC9pbnZpdGF0aW9uIiwgIkBpZCI6ICIyMjYyNzA0MC1hMDAzLTRjZGItOGFkMi1jMWEyYWJlNzhkYjEiLCAibGFiZWwiOiAiTWVkaWF0b3IiLCAicmVjaXBpZW50S2V5cyI6IFsiOWc1dTVzYVRGeGVXRkFSVnBkRnpQa0JtVXlMV2k2WW1DOXZEdEJ1SDMyV3YiXSwgInNlcnZpY2VFbmRwb2ludCI6ICJodHRwOi8vbWVkaWF0b3Iuc3ZndW4ucnUifQ==