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

OptionTypeDescription
assetKYIAssetThe asset to open the widget for. See KYIAsset.
onReady() => voidThe widget has loaded.
onClose() => voidThe user closes the widget, or the widget closes itself.
onError(error: Error) => voidThe 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.

FieldTypeDescription
namestringDisplay name of the asset.
accountIdstringCAIP-10 account ID of the deployment, e.g. eip155:1:0x….
addressstringDeployment address. If accountId is also given, both must point at the same deployment.

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.
issuerIdstringYour internal ID for the issuer: an organization or a single user. Becomes the issuer_id and sub claims. See Choosing an issuer ID.
userIdstringDeprecated alias for issuerId.
expiresInnumberLifetime 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'