The Verida JavaScript Library is a powerful monorepo that allows developers to integrate and utilize the Verida protocol seamlessly in their applications. Whether you’re building web or React Native applications, this guide will help you understand how to leverage the library effectively.
Understanding the Core Packages
The library consists of several key packages that you should be familiar with:
- client-ts: This is the main Verida client library. Install it in your project to gain support for the Verida protocol.
- account-web-vault: Use this package to create a Verida network connection. This utilizes a QR code and the Verida Vault to sign authentication requests, suitable for web applications.
- account-node: This lets you create an instance of a Verida account using a private key or seed phrase, automatically signing all authentication requests. Ideal for NodeJS server-side apps or React Native applications.
Utility Packages
These helper packages are generally not used directly but offer valuable support:
- account: Shared code among various account implementations.
- encryption-utils: Encryption utilities that simplify the usage of tweetnacl.
- keyring: This package aids in managing asymmetric, symmetric, and signing keys for a specific account context.
- storage-link: Utilities for linking storage endpoint information to a Verida account.
Setting Up Your Environment
To work with the Verida library, ensure you are using Node version 18 (ltshydrogen). You can manage Node versions effectively with nvm:
- Install Node version 18:
nvm install ltshydrogen
- Activate the installed version:
nvm use
(this command utilizes the .nvmrc file)
Linking Dependencies
When working within a monorepo, direct dependency management through yarn can be tricky. If a package has not been published to npm, you can link unpublished dependencies by:
- Manually adding the expected dependency to your
package.json
(for example:@verida/encryption-utils
) - Running
yarn install
in the root directory of your project
Building Packages
To build packages in the Verida library:
- In the root directory, run:
yarn install
npx lerna run build
cd packages/package-name
yarn
yarn build
Creating a Release
To prepare for a new release, follow these steps:
- Update all
CHANGELOG.md
files in each package with entries for all changes since the last release. - Run the following commands:
$ npx lerna run build
$ npx lerna publish --dist-tag next
next
for upcoming releases or latest
for stable releases.Troubleshooting
If you encounter any issues during setup or usage of the Verida library, here are a few troubleshooting steps to consider:
- Ensure you are on the correct Node version by running
node -v
. - If you run into dependency issues, double-check your
package.json
for accuracy. - For potential build errors, ensure all packages are up to date and correctly linked.
- If you’re still stuck, don’t hesitate to seek help from the community!
For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.
At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.