@bluprynt/kyi-widget-sdk

中文文档
0.1.1发布于 2026/03/31MITTypeScriptESM + CJS近 30 天下载 2.4万

Bluprynt KYI Widget SDK - Embed Know Your Issuer verification into your application

原始使用文档
文档目录19 节
  1. Installation
  2. How KYI Widget SDK works
  3. Quick Start
  4. 1. Generate Access Token (Server-side)
  5. 2. Embed Widget (Client-side)
  6. Widget Modes
  7. Inline Mode
  8. Modal Mode
  9. Drawer Mode
  10. Widget Scopes
  11. Checking KYI Status (Server-side)
  12. API Reference
  13. kyi(mode, scope, accessToken, options?)
  14. generateToken(options) (Server-side)
  15. checkStatus(options) (Server-side)
  16. Framework Examples
  17. React
  18. Security
  19. Contributing

Bluprynt KYI Widget SDK

SOC 2 Type 1 npm version License: MIT

Embed Bluprynt's KYI (Know Your Issuer) verification widget into your web application.

Installation

npm install @bluprynt/kyi-widget-sdk
yarn add @bluprynt/kyi-widget-sdk
pnpm add @bluprynt/kyi-widget-sdk

How KYI Widget SDK works

  1. Ask Bluprynt for SECRET_KEY as part of partner integration.
  2. Implement Access Token JWT generation on your backend side.
  3. Use KYI Widget SDK with generated Access Token on behalf of your user.

Use playground to test KYI Widget SDK.

Quick Start

1. Generate Access Token (Server-side)

If you use Node.js on backend, feel free to use this package to generate the token:

// server.ts (Node.js)
import { generateToken } from "@bluprynt/kyi-widget-sdk/server";

const accessToken = await generateToken({
  issuer: "your-partner-id",
  secretKey: process.env.BLUPRYNT_SECRET_KEY!,
  userId: "user-123", // Your internal user identifier
  expiresIn: 3600, // Optional: token expiry in seconds (default: 1 hour)
});

// Return token to your frontend
res.json({ accessToken });

It is okay to use other platforms rather than Node.js, but you will need generate JWT by yourself and sign it with SECRET_KEY that you get from Bluprynt. Keep in mind the token's payload must have to following structure:

{
  "sub": "user-123",
  "iss": "your-partner-id",
  "iat": 1766146154,
  "exp": 1766149754
}

2. Embed Widget (Client-side)

Use the access token to embed the KYI widget:

// client.ts (Browser)
import { kyi } from "@bluprynt/kyi-widget-sdk";

// Fetch token from your backend
const { accessToken } = await fetch("/api/kyi-token").then((r) => r.json());

// Embed the widget
const widget = kyi("modal", "kyi", accessToken, {
  onClose: () => {
    console.log("Widget closed");
  },
  onError: (error) => {
    console.error("Error:", error);
  },
});

// Later: clean up when done
widget.destroy();

Widget Modes

Inline Mode

Embeds the widget directly into a specified container element:

const container = document.getElementById("kyi-container");

const widget = kyi("inline", "kyi", accessToken, {
  parentElement: container,
});
<div id="kyi-container" style="height: 600px;"></div>

Modal Mode

Displays the widget in a centered modal overlay:

const widget = kyi("modal", "kyi", accessToken, {
  onClose: () => console.log("Modal closed"),
});

Drawer Mode

Displays the widget in a slide-in panel from the right:

const widget = kyi("drawer", "kyi", accessToken, {
  onClose: () => console.log("Drawer closed"),
});

Widget Scopes

The scope parameter determines which page to display:

ScopeDescription
kyiNew KYI application flow
asset-listView list of verified assets
wallet-listView list of connected wallets
// Start a new KYI application
kyi("modal", "kyi", accessToken);

// View assets
kyi("modal", "asset-list", accessToken);

// View wallets
kyi("inline", "wallet-list", accessToken, { parentElement: container });

Checking KYI Status (Server-side)

Query the current KYI status for a user from your backend:

import { checkStatus } from "@bluprynt/kyi-widget-sdk/server";

const status = await checkStatus({
  issuer: "your-partner-id",
  secretKey: process.env.BLUPRYNT_SECRET_KEY!,
  userId: "user-123",
});

console.log(status);

API Reference

kyi(mode, scope, accessToken, options?)

Creates a KYI widget instance.

Parameters:

ParameterTypeDescription
mode'inline' | 'modal' | 'drawer'Widget display mode
scope'kyi' | 'asset-list' | 'wallet-list'Widget scope
accessTokenstringJWT access token from generateToken
optionsKYIOptionsOptional configuration

Options:

OptionTypeDescription
parentElementHTMLElementContainer element (inline mode only)
onClose() => voidCalled when widget is closed
onError(error: Error) => voidCalled when an error occurs
onReady() => voidCalled when widget is loaded and ready

Returns: KYIWidget

PropertyTypeDescription
iframeHTMLIFrameElementReference to the iframe element
destroy() => voidRemove widget and clean up

generateToken(options) (Server-side)

Generates a JWT access token for widget authentication.

Parameters:

OptionTypeDescription
issuerstringYour partner identifier
secretKeystringYour Bluprynt secret key
userIdstringYour internal user identifier
expiresInnumberToken expiry in seconds (default: 3600)

Returns: Promise<string> - The signed JWT token

checkStatus(options) (Server-side)

Checks the KYI verification status for a user.

Parameters:

OptionTypeDescription
issuerstringYour partner identifier
secretKeystringYour Bluprynt secret key
userIdstringYour internal user identifier

Returns: Promise<KYIStatus>

Framework Examples

React

import { useEffect, useRef } from "react";
import { kyi, type KYIWidget } from "@bluprynt/kyi-widget-sdk";

function KYIButton({ accessToken }: { accessToken: string }) {
  const widgetRef = useRef<KYIWidget | null>(null);

  const openWidget = () => {
    widgetRef.current = kyi("modal", "kyi", accessToken);
  };

  useEffect(() => {
    return () => widgetRef.current?.destroy();
  }, []);

  return <button onClick={openWidget}>Start KYI</button>;
}

Security

  • Never expose your SECRET_KEY on the client-side. Token generation must happen on your backend.
  • Access tokens are short-lived JWTs. Generate a fresh token for each widget session.
  • The widget uses postMessage for secure iframe communication.

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.


Built with care by Bluprynt

版本与发布记录

@bluprynt/kyi-widget-sdk 共发布 6 个版本,首次发布于 2026/03/20;过去 12 个月发布了 6 个版本。

版本发布日期距今
0.1.1latest2026/03/317 个月前
0.1.02026/03/317 个月前
0.0.42026/03/277 个月前
0.0.32026/03/277 个月前
0.0.22026/03/207 个月前
0.0.12026/03/207 个月前

关于 @bluprynt/kyi-widget-sdk 的常见问题

@bluprynt/kyi-widget-sdk 是什么?

Bluprynt KYI Widget SDK - Embed Know Your Issuer verification into your application

如何安装 @bluprynt/kyi-widget-sdk?

在项目目录运行 npm install @bluprynt/kyi-widget-sdk,或使用 pnpm add / yarn add / bun add。

@bluprynt/kyi-widget-sdk 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@bluprynt/kyi-widget-sdk 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@bluprynt/kyi-widget-sdk 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@bluprynt/kyi-widget-sdk 可以商用吗?

@bluprynt/kyi-widget-sdk 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@bluprynt/kyi-widget-sdk 的下载量有多少?

根据 npm 官方下载统计,@bluprynt/kyi-widget-sdk 在 2026/10/09 – 2026/11/07 这 30 天内被下载 23,600 次,日均约 787 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@bluprynt/kyi-widget-sdk 还在维护吗?

最新版本 0.1.1 发布于 2026/03/31(7 个月前);至今共发布 6 个版本,其中过去 12 个月发布了 6 个;首次发布于 2026/03/20。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。