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'
ParameterTypeDescription
mode'drawer'How the widget is displayed.
scope'kyi' | 'asset-list' | 'wallet-list'Which screen the widget opens on.
accessTokenstringToken generated by your backend.
optionsKYIOptionsOptional callbacks.

Throws if accessToken is empty, or if mode or scope is not one of the values above.

KYIOptions

OptionTypeCalled when
onReady() => voidThe widget has loaded.
onClose() => voidThe user closes the widget, or the widget closes itself.
onError(error: Error) => voidThe widget reports an error.

KYIWidget

PropertyTypeDescription
destroy() => voidRemoves the widget immediately. Does not call onClose.
iframeHTMLIFrameElementThe 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'
OptionTypeDescription
issuerstringYour partner ID. Becomes the iss claim. (JWT naming: this is your platform, not the user.)
secretKeystringYour SECRET_KEY.
userIdstringYour internal ID for the user. Becomes the sub claim. See Choosing a user ID.
expiresInnumberLifetime 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'