Links
Comment on page

Vault+

The API for our private data wallet that you can use to securely exchange user data and other information with Vault+.

Connecting to Vault+

Before you can use any functions interacting with Vault+ or read user data you must first connect to the user's Vault+ instance.

async isReady()

The isReady() function is used to check the status of Vault+. Whether it is installed and running in the context of the browser without any errors.
Return Type: Promise<boolean>
const response = await Serv.isReady();
Returns true or false based on the status of Vault+.

async downloadVault()

Prompt the platform-specific link where the user can download Vault+ Commonly used in combination with isReady() function to develop a fully functional flow for all users of a dApp no matter whether they have Vault+ installed or not.
Return Type: Promise<void>
await Serv.downloadVault();

async connectVault()

The connectVault() function is used to initiate an authorized session between the client and Vault+. This function must be called before any other functions can be used by the client-side code as a security measure.
Return Type: Promise<EventConnectVaultResponseData>
const response = await Serv.connectVault();
Returns a boolean response based on the input of the user through the UI of the Vault+ depending on whether they accept or decline access for the dApp.

async disconnectVault()

The disconnectVault() function is used to conclude the interaction between a dApp and Vault+. Also called internally by Vault+ after a period of 15 minutes to lock the session and prevent unauthorized calls by malicious applications.
Return Type: Promise<boolean>
const response = await Serv.disconnectVault();

Interacting with User Data and Credentials

The following functions let you add, read, and verify user data from Vault+.

async claimCredential()

The claimCertificate() function is used to initiate the process of obtaining a specific credential through Vault+. Used when a certain credential is needed but not present in the user's Vault+ credential storage. Frequently called after queryCredentials() or verifyClaim() have established that the user does not hold the credential yet.
Return Type: Promise<EventClaimCredentialResponseData>
const response = await Serv.claimCredential(schemaId);
The schemaId parameter is a unique identifier that can be obtained from Mantis for any credential of your choice.
You can view code examples on how to trigger the claimCredential() function here

async queryCredentials()

This function is used to get information from specific fields in a specific credential. Returns the data that was queried for.
const response = await Serv.queryCredentials("did:123", ["birthDay", "age"]);
The first argument passed into the queryCredentials() is the did of the credential you are looking to get information from. This can be found on Mantis.
The second argument is an array of the specific fields in that credential which you would like to get the information from. The field names can be found in the credential schema on Mantis or queried through the Blockchain SDK.
You can view some example code on how to implement queryCredentials here

async verifyClaims()

Check if a user holds a specific credential with certain property values. Meaning you can validate and check certain aspects of the data underlying a credential without needing to read any of the user's personal data itself.
const response = await Serv.verifyClaims("did:someid",{
name: {
comparison: "equalTo",
value: "Jane",
},
age: {
comparison: "greaterThan",
value: 18,
},
});

Query Operators for verifyClaims()

The following operators can be used for the string and number values of the credential that you are trying to check.

Number Methods

  1. 1.
    greaterThan - Validates that the field value is greater than the property value
  2. 2.
    lessThan - Validates that the field value is less than the property value
  3. 3.
    equalTo - Validates that the field value is equal to the property value

String Methods

  1. 1.
    contains - Validates that a certain string is included in the field value of a credential
  2. 2.
    startsWith - Validates that a field value starts with a certain string value
  3. 3.
    endsWith - Validates that a field value ends with a certain string value
  4. 4.
    equalTo - Validates that the field value is equal to a supplied value
Return Type: Promise<boolean>
You can view a code example for how to use this function here

async sign(payload : object)

Sign any arbitrary data payload with Vault+'s wallet's private key. This can be used to sign Credentials, Schemas, Verifiable Presentations, and any other use-case-specific data object.
Return Type: Promise<EventSignResponseData<object>>
const response = await Serv.sign(object);
console.log(response)
`{
signature: '0x0445174baf49b4bd9114756b11d80512d17ca8474c563934ea1fda3492d1a87e7cba5dd8ba12ceaf6061a94e51a8299cf0070a2c5261f6165cc71d942938648c'
}`
Returned Object Fields->
signature: The signature of the payload (this signature is generated within Vault+ using the wallet's public/private key pair).
The object parameter of the sign() function can be any arbitrary object.