@uphold/enterprise-travel-rule-widget-web-sdk package.
The main class for creating and managing Travel Rule Widget instances is TravelRuleWidget. It requires a TravelRuleWidgetSession object that must be created through the API before instantiating the Widget.
Constructor
Generic type parameter:
The constructor accepts an optional generic type parameter that specifies the flow type. When provided, it enables better type inference for event handlers, particularly for the
complete event.
Examples:
Options
layout option:
The
layout option controls how the Widget is laid out when there is enough room to frame it — on viewports that are both at least md wide (≥768px) and at least 600px tall, i.e. tablets and up. On smaller viewports — narrower or shorter, including phones in landscape — the Widget always fills its container regardless of this option.
'boxed'(default): on viewports that are ≥768px wide and ≥600px tall, centers the Widget and frames its content as a fixed-size card; on smaller viewports it fills its container. Use this when the Widget takes up the whole page (e.g. mounted into a full-page container).'fluid': renders the Widget so it fills its container, with no frame or centering, so your own container (e.g. a modal or a sized panel) acts as the frame.
'boxed' and only set layout: 'fluid' when embedding the Widget in your own framed container.
Use
'fluid' when you already provide a centered container or modal around the Widget, to avoid a card-within-a-card appearance on larger viewports.theme option lets you control the visual appearance of the Widget. By default, the Widget automatically detects and matches the user’s browser or OS appearance preference (light or dark). Use this option when you want to enforce a specific theme regardless of the user’s system settings.
Methods
mountIframe()
Mounts the Travel Rule Widget iframe to the specified DOM element.
Parameters:
element: The HTML element where the Widget should be mounted
The container element should have explicit dimensions set via CSS. The Widget will fill the entire container. Minimum recommended size is 400px width × 600px height for optimal user experience.
unmount()
Unmounts and cleans up the Travel Rule Widget iframe.
Example:
on()
Registers an event listener for Widget events.
Parameters:
event: The event name to listen forcallback: Function to execute when the event is triggered
off()
Removes an event listener for Travel Rule Widget events.
Parameters:
event: The event name to stop listening forcallback: The specific function to remove (must be the same reference as used inon())
Events
The Travel Rule Widget emits several events during its lifecycle that you can listen to using theon() method.
complete
Fired when the Travel Rule form is completed successfully.
event.detail.value contains the Travel Rule compliance data collected from the user. This is an opaque data structure that should be passed to your backend and used when resolving RFIs or creating transactions.
Example:
cancel
Fired when the user cancels the Travel Rule form.
error
Fired when an unrecoverable error occurs during the Travel Rule flow.
ready
Fired when the Travel Rule Widget has finished loading and is ready for user interaction.
Types
TravelRuleWidgetSession
The session object obtained from the Create session endpoint.TravelRuleWidgetFlow
Represents the different flows supported by the Travel Rule Widget.TravelRuleWidgetData
The data object included in the session, containing context for the flow.TravelRuleResult
The result object returned upon successful completion of the Travel Rule form.The
event.detail.value object is an opaque data structure that should be used as-is when resolving RFIs or creating transactions.WidgetLayout
Controls how the Widget is laid out on larger viewports.WidgetThemeOption
Controls the visual appearance of the Widget.ColorTokenValue
A color value that can be a single string applied to both light and dark modes, or separate values per mode.FontFamily
A font family that can be a single string applied to all slots, or separate values per slot (mono, sans, serif).