API reference
Everything exported by @bluprynt/kyi-widget-sdk and @bluprynt/kyi-widget-sdk/server.
kyi(mode, scope, accessToken, options?)
Browser only. Opens the widget and returns a KYIWidget.
import { kyi } from '@bluprynt/kyi-widget-sdk'
| Parameter | Type | Description |
|---|---|---|
mode | 'drawer' | How the widget is displayed. |
scope | 'kyi' | 'asset-list' | 'wallet-list' | Which screen the widget opens on. |
accessToken | string | Token generated by your backend. |
options | KYIOptions | Optional callbacks. |
Throws if accessToken is empty, or if mode or scope is not one of the values above.
KYIOptions
| Option | Type | Description |
|---|---|---|
asset | KYIAsset | The asset to open the widget for. See KYIAsset. |
onReady | () => void | The widget has loaded. |
onClose | () => void | The user closes the widget, or the widget closes itself. |
onError | (error: Error) => void | The widget reports an error. |
KYIAsset
Prefills the flow and selects which of the issuer's assets to show. It is not proof of ownership: verification still runs on the asset's own application. All fields are optional.
| Field | Type | Description |
|---|---|---|
name | string | Display name of the asset. |
accountId | string | CAIP-10 account ID of the deployment, e.g. eip155:1:0x…. |
address | string | Deployment address. If accountId is also given, both must point at the same deployment. |
KYIWidget
| Property | Type | Description |
|---|---|---|
destroy | () => void | Removes the widget immediately. Does not call onClose. |
iframe | HTMLIFrameElement | The iframe that hosts the widget. |
generateToken(options)
Server only (Node.js 18+). Returns a Promise<string> that resolves to a signed HS256 JWT.
import { generateToken } from '@bluprynt/kyi-widget-sdk/server'
| Option | Type | Description |
|---|---|---|
issuer | string | Your partner ID. Becomes the iss claim. (JWT naming: this is your platform, not the user.) |
secretKey | string | Your SECRET_KEY. |
issuerId | string | Your internal ID for the issuer: an organization or a single user. Becomes the issuer_id and sub claims. See Choosing an issuer ID. |
userId | string | Deprecated alias for issuerId. |
expiresIn | number | Lifetime in seconds. Defaults to 3600, which is also the maximum; larger values are capped. |
Throws if issuer, secretKey or issuerId is empty, or if expiresIn is under 1 second.
Types
These TypeScript types are exported from the main entry point:
import type { KYIMode, KYIScope, KYIOptions, KYIWidget } from '@bluprynt/kyi-widget-sdk'