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+.
Before you can use any functions interacting with Vault+ or read user data you must first connect to the user's Vault+ instance.
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+.
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();
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.
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();
The following functions let you add, read, and verify user data from Vault+.
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.
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.
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,
},
});
The following operators can be used for the string and number values of the credential that you are trying to check.
- 1.greaterThan - Validates that the field value is greater than the property value
- 2.lessThan - Validates that the field value is less than the property value
- 3.equalTo - Validates that the field value is equal to the property value
- 1.contains - Validates that a certain string is included in the field value of a credential
- 2.startsWith - Validates that a field value starts with a certain string value
- 3.endsWith - Validates that a field value ends with a certain string value
- 4.equalTo - Validates that the field value is equal to a supplied value
Return Type: Promise<boolean>
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.
Last modified 8mo ago