Use the MATTR Pi Compact Credential Verifier SDK

Overview

We’ve transformed our credential verification capabilities to support the wider platform by making it work on your own mobile experience or integrating them into other types of your applications. Utilising the SDK will significantly reduce your development time while ensuring you are leveraging safe and reliable code libraries.

Interested in learning more about how you might use the MATTR Pi Compact Credential Verifier SDK? Get in touch with us today.

Capabilities

We wanted to make our Verifier SDK as easy to use and as flexible as possible. This allows you to start building your own verifier App or adding these core pieces of functionality to your own apps. 

Capabilities include: 

  • Build your own compact credential verification solution into existing applications

  • Validate compact and semantic compact credentials' authenticity 

  • Offline verification of your trusted credentials

  • Refresh cached revocation lists and trusted issuers

Key Benefits

Build using the same tools as the MATTR Verifier App

The MATTR Verifier SDK allows you to take advantage of the credential verification capabilities and use them to build your own mobile verifier experiences without needing to start from scratch. You can also use the SDK to integrate credential verification functionalities into other types of applications while maintaining a consistent brand and user experience. This means you can leverage the security, privacy and trust benefits of digital identity and verifiable credentials, while significantly reducing your development time and maintaining a consistent user experience.  

Ongoing support for evolving standards  

MATTR is actively engaged in the communities that define the fast-evolving standards for digital trust and verifiable data. Our investment in updating our SDK to support these standards means that you can rely on our expertise in this space to keep your application relevant and compliant. 

Using the same codebase for iOS and Android 

We’ve built the MATTR Pi Compact Credentials Verifier SDK in React Native, which means you can create both iOS and Android apps using the same codebase. React Native is ideally suited to developing complex hybrid apps – given its advanced features and ability to provide a natural user experience. In fact, React Native took the 6th spot in the Stack Overflow Developer Survey 2021, with 14.51% of all respondent votes. 

Limitations 

The SDK has the following limitations: 

  • The SDK is implemented with an initial focus on developers who want to build React Native apps. 

  • The SDK provides a set of operations only, there are no UI elements provided by the SDK. 

  • Users will be given access to the NPMJS modules that contain obfuscated and minified packages.  

How to get access to MATTR Pi Compact Credential SDK

To gain access to the MATTR Pi Verifier SDK, please follow these steps:

  1. Request us or download the "Terms of Agreement".

  2. Read the "Terms of Agreement", sign it, and return it to us.

  3. Create an account at NPMJS - Node package manager for JavaScript.

  4. Ensure multi-factor authentication (MFA) is configured on NPMJS Account.

  5. Create a personal access token here.

  6. Supply the NPMJS (Node package manager for JavaScript) account name back to MATTR.

  7. MATTR will process the request and provision access to the MATTR Pi Verifier SDK if approved.

Please reach out to us in case you need any assistance. Get in touch.

How it works

Verifier

Creating a new verifier

typescript
Copy to clipboard.
1import { InitOptions } from "@mattrglobal/verifier-sdk-react-native";
2
3const initOptions: InitOptions = {
4    issuerCacheTtl: 60000,
5    revocationListCacheTtl: 60000,
6    trustedIssuers: ["did:web:organization.com"], // defaults to trust any issuer
7    assertExpiry: true, // defaults to true
8    assertNotBefore: true, // defaults to true
9    checkRevocation: true, // defaults to true
10};
11
12const verifier = await init(initOptions);

Verifying a credential

typescript
Copy to clipboard.
1// Verify a credential payload as encoded & signed string
2const verifyResult = await verifier.verify({ payload });
3
4if (verifyResult.isErr()) {
5    // Handle error from verifyResult.error
6    return;
7}
8
9const { verified } = verifyResult.value;

Cache

The following allows you to get the expiry date of the cached revocation lists and trusted issuers, and refresh the icache.

Getting expiry date of the cache

typescript
Copy to clipboard.
1const expiry = await verifier.getCacheExpiry();

Refreshing the items in the cache

typescript
Copy to clipboard.
1const refreshCacheResult = await verifierSdk.refreshCache();
2
3if (refreshCacheResult.isErr()) {
4    /**
5     * The error contains the cache expiry date
6     * This date may have changed after partial refresh
7     */
8    console.log(refreshCacheResult.error.expiryDate);
9    // Handle error from refreshCacheResult.error
10    return;
11}
12
13// New expiry date of the cache
14const { expiryDate } = refreshCacheResult.value;

Error handling

Functions that are expected to have an error path return a Neverthrow Result type that represents either success (Ok) or failure (Err). Although this pattern is more verbose, it encourages the handling of possible errors and reserves throwing exceptions for truly exceptional situations.

typescript
Copy to clipboard.
1import { open } from "@mattrglobal/verifier-sdk-react-native";
2
3const openVerifierResult = await open();
4
5if (openVerifierResult.isErr()) {
6    // Handle error from openVerifierResult.error
7    return;
8}
9
10const verifier = openVerifierResult.value;

Unwrap

A utility function is provided for convenience if you decide not to handle your errors as results. This function will simply throw an error if the function passed in returns a Result,where Result.isErr() is true.

typescript
Copy to clipboard.
1import { unwrap } from "@mattrglobal/verifier-sdk-react-native";
2
3try {
4    const verifier = unwrap(await open());
5} catch (error) {
6    // Handle thrown error
7}

Known issues

1. Build error: "ld: symbol(s) not found for architecture x86_64"

This error can arise when using flipper and react-native-bignumber together. Disabling flipper is the only solution at the moment. See here for more details.

2. Build error: "Plugin with id 'maven' not found."

Currently, react-native-securerandom is not compatible with Gradle 7+ (see issue) and will not build for Android without downgrading Gradle to 6.9 or below.

Get in touch if you wish to find out more about using the MATTR Pi Compact Credentials Verifier SDK in production.