邮袋 SDK
这是Vouch SDK,一个用于与Vouch互动的TypeScript库. 目前,它允许您创建链接来启动网络证明流或将用户引导到部件页面.
安装
要安装Vouch SDK,可以使用npm或其他软件包管理器.
npm install @getvouch/sdk
yarn add @getvouch/sdk
pnpm add @getvouch/sdk
bun add @getvouch/sdk
使用量
与您创建 Vouch 实例 customerId 财务报告和审定财务报表 apiKey数字 :
import { Vouch } from "@getvouch/sdk";
const vouch = new Vouch({
customerId: "customer-id", // Your unique customer ID.
apiKey: "your-api-key", // Your API key for authentication.
});
您也可以提供额外的配置选项 :
import { Vouch } from "@getvouch/sdk";
const vouch = new Vouch({
customerId: "customer-id",
apiKey: "your-api-key",
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".
});
获取数据源 URL
创建启动 Vouch 流量的链接。 。 。 .
const { verificationUrl, requestId } = await vouch.getDataSourceUrl({
datasourceId: "93826be6-6c7d-495a-9859-de5a1d17f30b", // Datasource ID. Here we use example.com data source. Must be a UUIDv4.
redirectBackUrl: "https://docs.getvouch.io/getting-started/first-steps", // Return destination.
webhookUrl: "https://docs.getvouch.io/api/web-proof", // (Optional) Proof delivery endpoint.
requestId: "your-uuid-v4", // (Optional) Provide your own UUIDv4 to use as the proof request ID. If omitted, the server generates one.
});
添加输入
更多地了解投入。 。 。 .
假设您想要使用以下输入方案的数据源 :
{
name: string;
minFollowersCount: number;
}
然后在生成数据源 URL 时需要提供输入 :
const { verificationUrl, requestId } = await vouch.getDataSourceUrl({
/// ...similar to the previous example
inputs: {
name: "John Doe",
minFollowersCount: 1337,
},
});
输入会被编码为基数64,所以在URL内部可以看到类似的东西:
inputs=eyJuYW1lIjoiSm9obiBEb2UiLCJtaW5Gb2xsb3dlcnNDb3VudCI6MTMzN30
获取部件 URL
生成一个链接到一个部件页面, 用户可以从可用数据源中选择 。 要求数 customerId 财务报告和审定财务报表 apiKey 在建筑师.
const { verificationUrl, requestId } = await vouch.getWidgetUrl({
widgetId: "41b9a0c3-1234-4678-9abc-def012345678", // Your widget ID. Must be a UUIDv4.
redirectBackUrl: "https://example.com/callback", // Return destination after proof completion.
webhookUrl: "https://example.com/webhook", // (Optional) Proof delivery endpoint.
});