@getvouch/sdk
v0.1.3
Published
vouch SDK
Readme
vouch 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.
Installation
To install the vouch SDK, you can use npm or other package managers.
npm install @getvouch/sdk
yarn add @getvouch/sdk
pnpm add @getvouch/sdk
bun add @getvouch/sdkUsage
Create vouch instance:
import { Vouch } from "@getvouch/sdk";
const vouch = new Vouch();You may provide a configuration object with a set of optional parameters:
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".
});Get vouch start URL
Generate a link to start the vouch flow.
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: `https://docs.getvouch.io/getting-started/first-steps?requestId=${requestId}`, // Return destination.
webhookUrl: `https://docs.getvouch.io/api/web-proof/${requestId}`, // (Optional) Proof delivery endpoint.
});Adding inputs
Suppose, you want to use a datasource with the following inputs schema:
{
name: string;
minFollowersCount: number;
}You'd then need to provide the inputs when generating the start URL:
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
