Request or download the MATTR Pi SDK Trial License Agreement and the MATTR Customer Agreement and review these terms.
Technology | Version |
---|---|
Xcode | 16.2 or higher |
iOS | 15(*) or higher |
iPhone | iPhone 6S or higher |
Technology | Version |
---|---|
Android Gradle Plugin | 8.3.0 |
Gradle | 8.3 |
Kotlin | 1.9.0 |
JDK | 17 |
Android min API level | 24 |
Android target API level | 34 |
Technology | Version |
---|---|
Node | v18 or higher |
React Native | 0.73.x, 0.77.x, 0.78.x and 0.79.x |
SDK was tested with react-native 0.73.10, 0.77.2, 0.78.2, and 0.79.2.
Refer to our SDK Docs landing page for step-by-step instructions to gain access to any of our SDKs.
Please reach out in case you need any assistance.
yarn add @mattrglobal/mobile-credential-holder-react-native
Linking the package manually is not required from React Native 0.60 and higher that supports Autolinking.
The SDK relies on the following peer dependencies:
Install the pods (via Cocoapods) to complete the linking.
npx pod-install ios
The precompiled MATTR Mobile Credential Holder Android Native SDK is provided in the published NPM package.
To bundle the native libraries, append the following changes to the android/build.gradle
script:
allprojects {
repositories {
…
google()
+ maven {
+ url = "$rootDir/../node_modules/@mattrglobal/mobile-credential-holder-react-native/android/frameworks"
+ }
}
}
Add the following manifest placeholders to your app's build.gradle
file:
android {
defaultConfig {
// Add the next line
manifestPlaceholders = [mattrDomain: "credentials", mattrScheme: "io.mattrlabs.sample.mobilecredentialtutorialholderapp"]
}
...
}
This configuration allows your Android app to receive authentication results from the browser. The specified values are used to construct the URI that the SDK will use to redirect the user back to your app after they complete authentication with the issuer:
mattrScheme
: Can be any path that is handled by your application and registered with the issuer.mattrDomain
: Can be any path, however our best practice recommendation is to configure this to be credentials
, as the standard format for the redirect URI is {redirect.scheme}://credentials/callback
.The combination of these values ({mattrScheme}://{mattrDomain}/*
) must exactly match a redirect URI that has been whitelisted for the OAuth client used to authenticate the holder. This is required for the SDK to successfully retrieve credentials.
This SDK can be used in the same application with version 7.2.0 of the React Native mDocs Verifier SDK (mobile-credential-verifier-react-native
).
When combining both SDKs in the same application, add the following activity to your app's android manifest:
<application>
...
+ <activity
+ android:name="global.mattr.mobilecredential.common.webcallback.WebCallbackActivity"
+ android:exported="true"
+ android:label="@string/web_callback_activity_label"
+ android:launchMode="singleTask" >
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.BROWSABLE" />
+ <data android:scheme="${mattrScheme}"
+ android:host="${mattrDomain}" />
+ </intent-filter>
+ </activity>
...
</application>
The SDK distinguishes between expected and unexpected errors to help you write clearer and more predictable code.
Expected errors are part of the normal operation of a function. In these cases, the SDK function will be wrapped in a Result
object from the neverthrow library, with an explicit error type you can handle programmatically. Some functions do not have expected failure modes. When that’s the case, their return type will not be wrapped in a Result
object. Although this pattern is more verbose, it encourages the handling of possible errors and reserves throwing exceptions for truly exceptional situations.
Unexpected errors represent bugs, SDK misuse, or system-level failures. In these cases the SDK will throw an exception which results in a rejected promise. Because the root cause is unknown or unrecoverable, we recommend handling them with a generic fallback strategy (e.g., showing an error screen or logging the issue) appropriate to your app’s context.
This separation ensures you know which errors to handle explicitly and which indicate deeper issues that need broader handling.
import { initialise } from "@mattrglobal/mobile-credential-holder-react-native";
const initialiseWalletResult = await initialise();
if (initialiseWalletResult.isErr()) {
// Handle error from initialiseWalletResult.error
return;
}
const wallet = initialiseWalletResult.value;
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
.
import { unwrap } from "@mattrglobal/mobile-credential-holder-react-native";
try {
const wallet = unwrap(await initialise());
} catch (error) {
// Handle thrown error
}
The SDK now supports credential claiming using the OID4VCI Pre-Authorized Code Flow. Accordingly, the following changes have been introduced:
Method Signatures:
retrieveCredentials
method now accepts:String
, instead of the previous CredentialOfferResponse
type for the
credentialOffer
parametertransactionCode
autoTrustMobileIaca
and redirectUri
parameters are now set in the initialise
method, whereas previously
they were parameters of retrieveCredentials
.discoverCredentialOffer
and are now managed
interally to the SDK:authorizeEndpoint
,tokenEndpoint
,credentialEndpoint
,mdocIacasUri
discoverCredentialOffer
:TransactionCode
structThe initialise
method now allows configuring how biometric authentication is performed. To allow this the following
changes were introduced:
UserAuthenticationConfiguration
object:UserAuthenticationConfiguration.userAuthenticationBehavior
supports the following options:always
requires user authentication for all supported operationsnone
no user authentication is requiredonDeviceKeyAccess
requires user authentication when presenting or issuing a credentialonInitialise
requires user authentication when initialising the SDKUserAuthenticationConfiguration.userAuthenticationType
is iOS only and supports the following options:biometricOnly
only biometric authentication is allowedbiometricOrPasscode
authentication with either biometrics or device passcodeuserAuthRequiredOnInitialise
boolean parameter in the initialise
method with
userAuthenticationConfiguration
of type UserAuthenticationConfiguration
.MobileCredentialHolderErrorType.UserAuthenticationOnInitChanged
error type to
MobileCredentialHolderErrorType.UserAuthenticationConfigurationChanged
.CredentialIssuanceOptions
to CredentialIssuanceConfiguration
In order to provide a more cohesive and manageable error handling in the OID4VCI flow, we have consolidated some error cases into broader ones. This change aims to make it easier for developers to handle errors consistently. Below is a summary of the changes:
discoverCredentialOffer
no longer throws the following errors:DiscoverCredentialOfferErrorType.CredentialOfferNotFound
DiscoverCredentialOfferErrorType.SupportedCredentialsNotFound
DiscoverCredentialOfferErrorType.CredentialOfferNotInCredentialIssuerMetadata
DiscoverCredentialOfferErrorType.IssuerMetadataServiceError
DiscoverCredentialOfferErrorType.FailedToDiscoverCredentialOffer
To see the full list of errors that discoverCredentialOffer
may throw, refer to this method in the
SDK documentation.
retrieveCredentials
no longer throws the following errors:RetrieveCredentialsErrorTypes.AuthCodeNotFound
RetrieveCredentialsErrorTypes.AuthenticationFailed
RetrieveCredentialsErrorTypes.CertificateNotFound
RetrieveCredentialsErrorTypes.DeviceKeyGenerationError
RetrieveCredentialsErrorTypes.GenerateAuthorisationUrlFailed
RetrieveCredentialsErrorTypes.RedirectUriNotFound
RetrieveCredentialsErrorTypes.InvalidTransactionCode
RetrieveCredentialsErrorTypes.WebAuthenticationFailed
RetrieveCredentialsErrorTypes.FailedToDiscoverCredentialOffer
addCredential
method can now be used to add credentials with a
future validity period to the storage.First GA release as a standalone SDK.
Previous versions of this SDK were only available as an extension. For a detailed list of previous changes to this SDK please refer to the React Native Holder SDK changelog under the Mobile Credential category.
Generated using TypeDoc