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 | Called when |
|---|---|---|
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. |
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. |
userId | string | Your internal ID for the user. Becomes the sub claim. See Choosing a user ID. |
expiresIn | number | Lifetime in seconds. Defaults to 3600. |
Throws if issuer, secretKey or userId is empty.
Types
These TypeScript types are exported from the main entry point:
import type { KYIMode, KYIScope, KYIOptions, KYIWidget } from '@bluprynt/kyi-widget-sdk'