Getting started
Handling inputs
Some vouch datasources
require additional context or constraints for verification. These parameters are called inputs
and are passed as a JSON object in the inputs query parameter.
Each data source requires a specific set of input parameters. The exact inputs depend on the data source you choose. Refer to the Data Source Catalog documentation for details on required parameters for each source.
Example: Verifying Twitter Following
To verify that a user follows a specific Twitter account, you use the "X - Following" data source (1cb27231-a559-4f19-8929-463ed90446dd
), which requires the twitter_username
input parameter.
import { Vouch } from "@getvouch/sdk";
const vouch = new Vouch();
const twitterUsername = prompt("Enter the Twitter username you want to verify following:");
const toBase64 = (str) => {
return btoa(str)
.replace(/=/g, "")
.replace(/\+/g, "-")
.replace(/\//g, "_");
};
const verificationUrl = vouch.getStartUrl({
requestId: crypto.randomUUID(),
datasourceId: "1cb27231-a559-4f19-8929-463ed90446dd", // X - Following data source
customerId: "1be03be8-5014-413c-835a-feddf4020da2",
inputs: toBase64(JSON.stringify({ twitter_username: "zkmarek"})), // User-specified Twitter handle
redirectBackUrl:
`https://docs.getvouch.io/getting-started/handling-inputs?requestId=${requestId}`, // return back after verification
webhookUrl: `https://docs.getvouch.io/api/web-proof/${requestId}` // (Optional) POST web proof here
});
// Redirect the user to vouch with the constructed url
window.location.href = verificationUrl;
Enter the Twitter handle you want to verify following (without @)