Use MATTR Wallet SDK
Overview
The MATTR Wallet SDK allows you to take advantage of our capabilities to build your own credential apps or add this functionality to other apps where appropriate. Through our Wallet SDK, you can utilise MATTR VII to leverage our approach to digital identity and verifiable credentials. The use of the SDK will significantly reduce your development time while ensuring you are leveraging safe and reliable code libraries.
Here, we’ll explore some of the capabilities you can expect with MATTR Wallet SDK, and some of the benefits of using this powerful tool.
Why you might want to use the SDK
We wanted to make our SDK as easy to use and as flexible as possible. This allows you to start building your own wallet or adding these core pieces of functionality to your own apps.
Capabilities include:
Create and manage decentralised identifiers (DIDs)
Obtain credentials
Start OpenID Credential Provider flows
Hold credentials
Validate credential authenticity
Derive credentials to selectively disclose data using BBS+ signatures
Handle secure DID based messages
Interested in learning more about how you might use the MATTR Wallet SDK? Get in touch with us today.
Benefits
Build using the same tools as the MATTR Wallet
The MATTR Wallet SDK allows you to take advantage of the core capabilities demonstrated in our MATTR wallet app and use them to build your own mobile wallet experiences without needing to start from scratch. You can also use the SDK to integrate credential wallet 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 Wallet 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 is currently in a beta version with 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.
There is no access to a wallet backend to facilitate messaging & push notifications.
Breaking changes to the libraries may occur.
Users will be given access to the NPMJS modules that contain obfuscated and minified packages.
How it works
Create a Wallet
Create a new wallet
1import { create } from "@mattrglobal/wallet-sdk-react-native";
2
3const createWalletResult = await create();
4
5if (createWalletResult.isErr()) {
6 // Handle error from createWalletResult.error
7 return;
8}
Start an OIDC Credential Provider flow
Discover OIDC credential offer
1const discoverResult = await wallet.oidc.discover("openid://discovery?issuer=https://issuer.example.com");
2
3if (discoverResult.isErr()) {
4 // Handle error from discoverResult.error
5 return;
6}
7
8const { offer } = discoverResult.value;
Create a local subject DID for the credential
1const createDidResult = await wallet.did.create();
2
3if (createDidResult.isErr()) {
4 // Handle error from createDidResult.error
5 return;
6}
7
8const { did } = createDidResult.value;
Generate an OpenID authorization url to request the credential
1import { Linking } from "react-native";
2const genUrlResult = await wallet.oidc.generateAuthorizeUrl({ offer, did });
3
4if (genUrlResult.isErr()) {
5 // Handle error from genUrlResult.error
6 return;
7}
8
9const { url, codeVerifier, nonce } = genUrlResult.value;
10await Linking.openURL(url);
Retrieve the credential on authorization success callback
1onst retrieveResult = (retrieveCredential = await wallet.oidc.retrieveCredential({
2 offer,
3 codeVerifier,
4 nonce,
5 code: route.params.code, // code comes from part of the callback url
6}));
7
8if (retrieveResult.isErr()) {
9 // Handle error from retrieveResult.error
10 return;
11}
12
13const { credential } = retrieveResult.value;
Verify a credential
1const verifyResult = await wallet.credential.verify({ credential });
2
3if (verifyResult.isErr()) {
4 // Handle error from verifyResult.error
5 return;
6}
7
8const { credentialVerified, status } = verifyResult.value;
Respond to a Presentation
Open a presentation request DIDComm message
1import { isPresentationRequestJwm } from "wallet-sdk-react-native";
2const openResult = await wallet.messaging.openDidCommMessage(message);
3
4if (openResult.isErr() || !isPresentationRequestJwm(openResult.value)) {
5 return;
6}
7
8const presentationRequest = openResult.value;
Look up for matching credentials
1const credentialData = [
2 { id: "a", credential: credentailA },
3 { id: "b", credential: credentailB },
4];
5
6const filterResult = await wallet.presentation.filterCredentialsByQuery({ credentials: credentialData });
Create and send presentation
1const createPresentationResult = await wallet.presentation.create({
2 challenge: presentationRequest.body.challenge,
3 domain: presentationRequest.body.domain,
4 credentials,
5 holder: did,
6});
7
8if (createPresentationResult.isErr()) {
9 // Handle error from createPresentationResult.error
10 return;
11}
12
13const presentaiton = createPresentationResult.value;
14const sendPresentationResult = await wallet.presentation.sendPresentationResponse({
15 presentationRequest,
16 presentation,
17});
Find the comprehensive SDK interfaces for these examples and others in the documentation https://github.com/mattrglobal/docs-wallet-sdk
Get in touch if you wish to find out more about using the Wallet SDK in production.