npm install @getvouch/sdk
This is the vouch SDK, a TypeScript library for interacting with vouch. Currently, it allows you to generate a link to start the web proof flow.
To install the vouch SDK, you can use npm or other package managers.
``bash`
npm install @getvouch/sdk
yarn add @getvouch/sdk
pnpm add @getvouch/sdk
bun add @getvouch/sdk
Create vouch instance:
`typescript`
import { Vouch } from "@getvouch/sdk";
const vouch = new Vouch();
You may provide a configuration object with a set of optional parameters:
`typescript`
import { Vouch } from "@getvouch/sdk";
const vouch = new Vouch({
vouchHost: "https://app.getvouch.io", // The base URL for the Vouch API. Can be a string or an URL object. Defaults to "https://app.getvouch.io".
});
Generate a link to start the vouch flow.
`typescripthttps://docs.getvouch.io/getting-started/first-steps?requestId=${requestId}
const url = vouch.getStartUrl({
requestId, // Optional. If not provided, a new request ID will be generated.
datasourceId: "93826be6-6c7d-495a-9859-de5a1d17f30b", // Datasource ID. Here we use example.com data source. Must be a UUIDv4.
customerId: "1be03be8-5014-413c-835a-feddf4020da2", // Your unique customer ID.
redirectBackUrl: , // Return destination.https://docs.getvouch.io/api/web-proof/${requestId}
webhookUrl: , // (Optional) Proof delivery endpoint.`
});
Suppose, you want to use a datasource with the following inputs schema:
`typescript`
{
name: string;
minFollowersCount: number;
}
You'd then need to provide the inputs when generating the start URL:
`typescript`
const url = vouch.getStartUrl({
/// ...similar to the previous example
inputs: {
name: "John Doe",
minFollowersCount: 1337,
},
});
The inputs will be encoded to base64, so you'd see something like this inside the URL:
inputs=eyJuYW1lIjoiSm9obiBEb2UiLCJtaW5Gb2xsb3dlcnNDb3VudCI6MTMzN30`