API Reference

The Flutter SDK (prophetx_sdk) mirrors the React Native surface — same provider, same options, same event payloads. Differences are called out per-section: hooks become ChangeNotifier flow controllers on ProphetX.of(context), callbacks fire on Dart Function types, and the event bus is a Dart Stream.

ProphetXProvider

Props

Environment

Pass a preset name or a custom config object:

NameEmbed URLAPI Base URL
"production"https://embed.prophetx.cohttps://api.prophetx.co
"staging"https://embed-staging.prophetx.cohttps://api-ss-staging.betprophet.co
"sandbox"https://embed-sandbox.prophetx.cohttps://api-ss-sandbox.betprophet.co

Custom config:

type EnvironmentConfig = {
  embedUrl: string;
  apiBaseUrl: string;
};

AuthConfig

Optional. When provided, the SDK manages authentication internally — you don't need to pass token yourself.

FieldTypeRequiredDescription
apiBaseUrlstringYesAPI base URL for authentication requests.
refreshBufferSecondsnumberNoAuto-refresh the token this many seconds before expiry. Default: 30.
onAuthStateChanged(state: AuthState) => voidNoCalled whenever auth state changes.
getCredentials() => LoginCredentials | Promise<LoginCredentials>NoReturns credentials on demand for auto-refresh. Avoids storing plaintext credentials in memory.
storageStorageAdapterNoCustom storage adapter. Defaults to browser localStorage.
httpHttpAdapterNoCustom HTTP adapter. Defaults to fetch.
randomRandomAdapterNoCustom random number adapter.

DevToolsConfig

FieldTypeRequiredDescription
enabledbooleanNoEnable or disable devtools.
logLevel"none" | "error" | "warn" | "info" | "debug"NoLog level threshold.
redactPIIbooleanNoWhen true, masks tokens, passwords, and emails in log output.
onEvent(entry: DevToolsLogEntry) => voidNoCustom log sink — receives every log entry.

Deposit flow

Opens the deposit flow. The SDK renders a modal that handles the full deposit UI. React/React Native expose this via the useDeposit hook; the Flutter SDK exposes a DepositFlow controller on ProphetX.of(context).deposit.

Controller surface

SurfaceFieldTypeDescription
React / React Nativeopen(options?: OpenDepositOptions) => voidOpens the deposit modal.
React / React Nativeclose() => voidCloses the deposit modal programmatically.
React / React NativeisOpenbooleanWhether the deposit modal is currently open.
Flutteropen([OpenDepositOptions?]) => voidOpens the deposit modal.
Flutterclose() => voidCloses the deposit modal programmatically.
FlutterisOpenboolWhether the deposit modal is currently open. Notifies via ChangeNotifier.

OpenDepositOptions

OptionTypeDescription
onSuccess(transactionId: string, amount?: number) => voidFires when the deposit completes. Store transactionId on your backend to track the deposit.
onError(code: string, message: string) => voidFires on any error. See Error Codes.
onCancel() => voidFires when the user closes the modal without completing the deposit.
onReady() => voidFires when the embed iframe has loaded and is ready to interact.
onGeofenceBlocked(stateCode: string, reason: string) => voidFires when the user's location is outside a permitted jurisdiction.

The JavaScript SDK's OpenOptions also accepts token, theme, and onSessionExpired — these are passed per-call instead of through a provider.

Withdraw flow

Opens the withdrawal flow. Follows the same pattern as the deposit flow above. React/React Native expose useWithdraw; Flutter exposes ProphetX.of(context).withdraw.

Controller surface

SurfaceFieldTypeDescription
React / React Nativeopen(options?: OpenWithdrawOptions) => voidOpens the withdraw modal.
React / React Nativeclose() => voidCloses the withdraw modal programmatically.
React / React NativeisOpenbooleanWhether the withdraw modal is currently open.
Flutteropen([OpenWithdrawOptions?]) => voidOpens the withdraw modal.
Flutterclose() => voidCloses the withdraw modal programmatically.
FlutterisOpenboolWhether the withdraw modal is currently open. Notifies via ChangeNotifier.

OpenWithdrawOptions

OptionTypeDescription
onSuccess(transactionId: string, amount?: number) => voidFires when the withdrawal completes.
onError(code: string, message: string) => voidFires on any error. See Error Codes.
onCancel() => voidFires when the user closes the modal without completing the withdrawal.
onReady() => voidFires when the embed iframe has loaded and is ready to interact.
onGeofenceBlocked(stateCode: string, reason: string) => voidFires when the user's location is outside a permitted jurisdiction.

Onboarding flow

Opens the onboarding flow — combines terms acceptance, identity verification (KYC), and an optional first deposit into a single guided experience. React/React Native expose useOnboarding; Flutter exposes ProphetX.of(context).onboarding.

Controller surface

SurfaceFieldTypeDescription
React / React Nativeopen(options?: OpenOnboardingOptions) => voidOpens the onboarding modal.
React / React Nativeclose() => voidCloses the onboarding modal programmatically.
React / React NativeisOpenbooleanWhether the onboarding modal is currently open.
Flutteropen([OpenOnboardingOptions?]) => voidOpens the onboarding modal.
Flutterclose() => voidCloses the onboarding modal programmatically.
FlutterisOpenboolWhether the onboarding modal is currently open. Notifies via ChangeNotifier.

OpenOnboardingOptions

OptionTypeDescription
onSuccess(transactionId: string, amount?: number) => voidFires if the user completes a deposit during onboarding.
onTermsAccepted(acceptedAt: string) => voidFires when the user accepts T&C during onboarding. acceptedAt is the ISO 8601 acceptance timestamp.
onKycSuccess(identityUuid: string) => voidFires when identity verification passes.
onKycFailed(reason: string) => voidFires when identity verification fails.
onKycPending() => voidFires when identity verification is submitted but not yet resolved.
onError(code: string, message: string) => voidFires on any error. See Error Codes.
onCancel() => voidFires when the user closes the modal.
onReady() => voidFires when the embed iframe has loaded and is ready to interact.
onGeofenceBlocked(stateCode: string, reason: string) => voidFires when the user's location is outside a permitted jurisdiction.

Terms flow

Opens the terms and conditions acceptance flow as a standalone step. Use this when a user is otherwise verified but has not yet accepted ProphetX's legal documents — for example, an existing user whose terms version has changed, or a new user who skipped acceptance during onboarding. React/React Native expose useTerms; Flutter exposes ProphetX.of(context).terms.

Controller surface

SurfaceFieldTypeDescription
React / React Nativeopen(options?: OpenTermsOptions) => voidOpens the terms modal.
React / React Nativeclose() => voidCloses the terms modal programmatically.
React / React NativeisOpenbooleanWhether the terms modal is currently open.
Flutteropen([OpenTermsOptions?]) => voidOpens the terms modal.
Flutterclose() => voidCloses the terms modal programmatically.
FlutterisOpenboolWhether the terms modal is currently open. Notifies via ChangeNotifier.

OpenTermsOptions

OptionTypeDescription
onTermsAccepted(acceptedAt: string) => voidFires when the user accepts. acceptedAt is the ISO 8601 timestamp returned by the server.
onError(code: string, message: string) => voidFires on any error. See Error Codes.
onCancel() => voidFires when the user closes the modal without accepting.
onReady() => voidFires when the embed iframe has loaded and is ready to interact.
onGeofenceBlocked(stateCode: string, reason: string) => voidFires when the user's location is outside a permitted jurisdiction.

What users see

Once you call open(), the embed renders the acceptance screen inside the modal. You don't render any of these screens yourself — the embed owns them.

  1. Document list. The user sees ProphetX's legal documents (Privacy Policy, Terms of Use, Market Participant Agreement, Risk Disclosure Statement), each with a checkbox and a link that opens the full document in a new tab. An "Accept all" checkbox toggles all documents at once.
  2. Continue. The Continue button is disabled until every document is checked. Tapping it submits acceptance to ProphetX in a single request.
  3. Terminal state. One of two outcomes fires:
    • AcceptedonTermsAccepted(acceptedAt) is called with the ISO 8601 acceptance timestamp. The embed shows a brief success screen, then closes.
    • FailedonError(code, message) is called. The embed shows an error screen with a "Try Again" affordance that returns the user to the document list so they can resubmit.

KYC flow

Opens the identity verification (KYC) flow as a standalone step. Use this when you want to verify a user's identity without the full onboarding experience. React/React Native expose useKyc; Flutter exposes ProphetX.of(context).kyc.

Controller surface

SurfaceFieldTypeDescription
React / React Nativeopen(options?: OpenKycOptions) => voidOpens the KYC modal.
React / React Nativeclose() => voidCloses the KYC modal programmatically.
React / React NativeisOpenbooleanWhether the KYC modal is currently open.
Flutteropen([OpenKycOptions?]) => voidOpens the KYC modal.
Flutterclose() => voidCloses the KYC modal programmatically.
FlutterisOpenboolWhether the KYC modal is currently open. Notifies via ChangeNotifier.

OpenKycOptions

OptionTypeDescription
onSuccess(transactionId: string, amount?: number) => voidFires if a transaction completes as part of the KYC flow.
onKycSuccess(identityUuid: string) => voidFires when identity verification passes.
onKycFailed(reason: string) => voidFires when identity verification fails.
onKycPending() => voidFires when identity verification is submitted but not yet resolved.
onError(code: string, message: string) => voidFires on any error. See Error Codes.
onCancel() => voidFires when the user closes the modal.
onReady() => voidFires when the embed iframe has loaded and is ready to interact.
onGeofenceBlocked(stateCode: string, reason: string) => voidFires when the user's location is outside a permitted jurisdiction.

What users see

Once you call open(), the embed walks the user through a short multi-step flow inside the modal. You don't render any of these screens yourself — the embed owns them.

  1. Phone entry. The user enters their mobile number. The embed submits it and triggers an SMS one-time passcode (OTP).
  2. OTP verification. A 6-digit code arrives via SMS. The user enters it. A "Resend code" affordance is available, and a back button returns to phone entry.
  3. Additional inputs (sometimes). Depending on what the identity provider needs to complete verification, the user may be asked for extra information — most commonly a date of birth. If no extra inputs are needed, this step is skipped.
  4. Identity confirmation. The embed displays the personal information returned by the identity provider (name, date of birth, address, last 4 of SSN, phone, email) for the user to review and confirm.
  5. Terminal state. One of three outcomes fires:
    • VerifiedonKycSuccess(identityUuid) is called. The user is now cleared for transactions.
    • Pending reviewonKycPending() is called. The user has not been auto-approved and is under manual review. The flow cannot continue from here; check status on your backend or wait for a webhook.
    • FailedonKycFailed(reason) is called. Verification was rejected and cannot be retried in this session.

The embed renders its own success / pending / failed result screen with a close button before the corresponding callback fires.

Latency and retries

BehaviorDetail
OTP deliveryVia SMS. Typical delivery is seconds, but carrier delays of a minute or more are not uncommon.
OTP attemptsThe user gets 3 attempts to enter the code correctly. After the 3rd failure the embed transitions to an error screen with a retry affordance.
ResendThe user can request a fresh code from the OTP screen. The attempt counter resets when a resend succeeds.
Back navigationFrom the OTP screen, the user can return to phone entry to correct a typo. From the identity confirmation screen, the user can return to phone entry to start over.
Pending and FailedBoth are non-recoverable in the current session. Do not prompt the user to retry — the flow has terminated.

Wallet

Fetches and returns the user's current wallet balance. Requires ProphetXProvider with an environment configured. React/React Native expose useWallet; Flutter exposes ProphetX.of(context).wallet (a ChangeNotifier).

Return value (React / React Native)

FieldTypeDescription
balanceWalletBalance | nullCurrent balance, or null if not yet fetched.
loadingbooleanWhether a fetch is in progress.
errorProphetXApiError | nullLast error, or null.
refetch() => Promise<void>Call to re-fetch the balance. Not automatic — call it on mount and after deposits/withdrawals.

WalletBalance

FieldTypeDescription
totalBalancenumberThe user's available balance.
currencystringCurrency code (e.g. "USD").

JavaScript SDK

The vanilla SDK exposes a wallet property on the SDK instance:

MethodTypeDescription
sdk.wallet.getBalance()() => Promise<WalletBalance>Returns the user's balance. sdk.wallet is null if auth was not configured.

Flutter

ProphetX.of(context).wallet is a WalletClient that extends ChangeNotifier. Pair it with ListenableBuilder to react to balance / loading / error transitions.

FieldTypeDescription
balanceWalletBalance?Current balance, or null if not yet fetched.
loadingboolWhether a fetch is in progress.
errorObject?Last error, or null.
refetchFuture<WalletBalance?> Function()Re-fetches the balance. Call on mount and after deposits/withdrawals.

Auth

Manages user authentication. Requires ProphetXProvider with the auth prop configured. React/React Native expose useAuth; Flutter exposes ProphetX.of(context).auth (an AuthManager that extends ChangeNotifier).

Return value (React / React Native)

FieldTypeDescription
stateAuthStateCurrent authentication state. See AuthState.
login(credentials: LoginCredentials) => Promise<LoginResult>Authenticate with email and password.
logout() => voidClear the token and reset state.
tokenstring | nullCurrent JWT, or null if unauthenticated.
isAuthenticatedbooleanConvenience boolean — true when state.status === "authenticated".

AuthState

StatusFieldsDescription
"unauthenticated"No active session.
"authenticating"Login in progress.
"authenticated"token: string, expiresAt: numberActive session with a valid JWT.
"expired"lastToken: stringSession expired. Contains the last token for reference.
"error"error: ProphetXAuthErrorAuthentication failed.

LoginCredentials

FieldTypeRequiredDescription
emailstringYesUser's email address.
passwordstringYesUser's password.
deviceIdstringNoOptional device identifier.

LoginResult

FieldTypeDescription
tokenstringSigned JWT.
expiresAtnumberUnix timestamp (ms) when the token expires.

ProphetXAuthError

FieldTypeDescription
type"AUTH_ERROR"Always "AUTH_ERROR".
code"INVALID_CREDENTIALS" | "NETWORK_ERROR" | "SERVER_ERROR" | "TIMEOUT"Error category.
messagestringHuman-readable error message.
statusnumber | undefinedHTTP status code, if applicable.

JavaScript SDK

The vanilla SDK exposes an auth property on the SDK instance:

MethodTypeDescription
sdk.auth.login(credentials)(LoginCredentials) => Promise<LoginResult>Authenticate.
sdk.auth.logout()() => voidClear the session.
sdk.auth.getToken()() => string | nullGet the current JWT.
sdk.auth.getState()() => AuthStateGet the current auth state.
sdk.auth.onStateChange(cb)(cb: (state: AuthState) => void) => () => voidSubscribe to state changes. Returns an unsubscribe function.
sdk.auth.handleSessionExpired()() => Promise<string | null>Re-authenticates using the getCredentials callback from AuthConfig.
sdk.auth.destroy()() => voidTear down the auth manager and clear timers.

sdk.auth is null if AuthConfig was not passed to createProphetX.

Flutter

ProphetX.of(context).auth is an AuthManager that extends ChangeNotifier. state is a sealed hierarchy (Unauthenticated, Authenticating, Authenticated, Expired, AuthError) — match on it with Dart 3 pattern syntax.

MemberTypeDescription
loginFuture<LoginResult> Function(LoginCredentials)Authenticate with email + password. Throws ProphetXAuthError.
logoutvoid Function()Clear the session.
tokenString?Current JWT, or null when not in the Authenticated state.
isAuthenticatedbooltrue when state is Authenticated.
stateAuthStateSealed hierarchy. See enum below.
handleSessionExpiredFuture<String?> Function()Re-authenticates using the getCredentials callback from AuthConfig. Used internally as the default onSessionExpired.

AuthState subtypes: Unauthenticated, Authenticating, Authenticated(token, expiresAt), Expired(lastToken), AuthError(error). expiresAt on Flutter is Unix seconds (the JS SDKs use milliseconds).

ProphetXAuthError.code is the Dart enum AuthErrorCode { invalidCredentials, networkError, serverError, timeout }.

Events

Subscribes to all SDK events globally. Useful for analytics, logging, or cross-cutting concerns that apply regardless of which flow is open. React/React Native expose useEvents; Flutter exposes a broadcast Stream on ProphetX.of(context).events.

ProphetXEventHandlers (React / React Native)

All fields are optional. Pass only the events you care about.

HandlerPayloadDescription
onReadyEmbed iframe loaded and ready.
onSuccess{ transactionId: string, amount?: number }Transaction completed.
onError{ code: string, message: string }An error occurred.
onCancelUser closed the modal.
onKycSuccess{ identityUuid: string }Identity verification passed.
onKycFailed{ reason: string }Identity verification failed.
onKycPendingIdentity verification submitted, awaiting result.
onGeofenceBlocked{ stateCode: string, reason: string }User's location is not permitted.

Note: useEvents receives payload data as objects (e.g. { transactionId, amount }), while flow hook callbacks receive them as positional arguments (e.g. (transactionId, amount)).

Flutter event types

The Flutter SDK uses a sealed ProphetXEvent hierarchy. Subscribe to a single subtype with events.on<T>(handler) or to the full union with events.stream.listen(...).

Event subtypeFieldsDescription
ReadyEventEmbed iframe loaded and ready.
SuccessEventtransactionId: String, amount: num?Transaction completed.
ErrorEventcode: String, message: StringAn error occurred.
CancelEventUser dismissed the modal.
KycSuccessEventidentityUuid: StringIdentity verification passed.
KycFailedEventreason: StringIdentity verification failed.
KycPendingEventIdentity verification submitted, awaiting result.
GeofenceBlockedEventstateCode: String, reason: StringUser's location is not permitted.
SessionExpiredEventThe session token has expired.
SessionRefreshedEventtoken: StringA new session token was obtained after expiry.
FlowOpenEventflow: StringA flow modal was opened. flow is "deposit", "withdraw", "onboarding", or "kyc".
FlowCloseEventflow: StringA flow modal was closed.

ProphetXEmbed

Low-level iframe component. Use this when you need direct control over the embed lifecycle — most integrations should use the hooks above instead.

This component is only available in @prophetx/sdk-react.


function CustomEmbed() {
  const ref = useRef<ProphetXEmbedHandle>(null);

  return (
    <ProphetXEmbed
      ref={ref}
      open={true}
      onOpenChange={(open) => console.log("Open state:", open)}
      src="https://embed.prophetx.co/deposit"
      token={token}
      title="Deposit"
      theme={{ mode: "dark" }}
      onSuccess={(transactionId, amount) => console.log("Success:", transactionId)}
      onError={(code, message) => console.error("Error:", code, message)}
      onCancel={() => console.log("Cancelled")}
      onReady={() => console.log("Ready")}
      onGeofenceBlocked={(stateCode, reason) => console.log("Blocked:", stateCode)}
      onKycSuccess={(identityUuid) => console.log("KYC passed:", identityUuid)}
      onKycFailed={(reason) => console.log("KYC failed:", reason)}
      onKycPending={() => console.log("KYC pending")}
      onSessionExpired={async () => {
        const fresh = await fetchToken();
        return fresh;
      }}
    />
  );
}

Props

PropTypeRequiredDescription
openbooleanYesControls whether the embed is visible.
onOpenChange(open: boolean) => voidYesCalled when the open state should change (e.g. user closes the modal).
srcstringYesFull URL of the embed page to load.
tokenstringYesPartner session JWT.
titlestringNoAccessible title for the iframe.
themeEmbedThemeNoTheme overrides.
localestringNoBCP 47 locale tag (e.g. "en", "es"). Sent to the embed via PROPHETX_LOCALE. Defaults to "en".
onSuccess(transactionId: string, amount?: number) => voidNoTransaction completed.
onError(code: string, message: string) => voidNoAn error occurred.
onCancel() => voidNoUser closed the modal.
onReady() => voidNoEmbed iframe loaded and ready.
onGeofenceBlocked(stateCode: string, reason: string) => voidNoLocation not permitted.
onKycSuccess(identityUuid: string) => voidNoIdentity verification passed.
onKycFailed(reason: string) => voidNoIdentity verification failed.
onKycPending() => voidNoIdentity verification pending.
onSessionExpired() => Promise<string | null>NoReturn a fresh JWT or null to abort.

ProphetXEmbedHandle (ref)

Access the imperative handle via useRef<ProphetXEmbedHandle>:

MethodTypeDescription
sendMessage(message: { type: string; payload?: unknown }) => voidSend a raw postMessage to the iframe.
reload() => voidReload the iframe.

JavaScript SDK instance

The object returned by createProphetX().

Method / PropertyTypeDescription
openDeposit(opts)(OpenOptions) => voidOpen the deposit flow.
openWithdraw(opts)(OpenOptions) => voidOpen the withdraw flow.
openOnboarding(opts)(KycOpenOptions) => voidOpen the onboarding flow.
openKyc(opts)(KycOpenOptions) => voidOpen the KYC flow.
openTerms(opts)(TermsOpenOptions) => voidOpen the terms acceptance flow.
close()() => voidClose any open flow.
destroy()() => voidTear down the SDK — removes DOM elements, clears listeners, destroys auth manager.
updateTheme(theme)(EmbedTheme) => voidUpdate the theme on a currently open embed.
on(event, handler)See EventEmitterSubscribe to an event. Returns an unsubscribe function.
off(event, handler)See EventEmitterUnsubscribe from an event.
authAuthManager | nullAuth manager instance. null if AuthConfig was not provided.
walletWalletClient | nullWallet client instance. null if auth was not configured.

OpenOptions (JavaScript SDK)

OptionTypeDescription
tokenstringSession JWT. Required unless using the auth module.
themeEmbedThemePer-flow theme overrides.
localestringBCP 47 locale tag (e.g. "en", "es"). Defaults to "en".
onSuccess(transactionId: string, amount?: number) => voidTransaction completed.
onError(code: string, message: string) => voidAn error occurred.
onCancel() => voidUser closed the modal.
onReady() => voidEmbed loaded and ready.
onGeofenceBlocked(stateCode: string, reason: string) => voidLocation not permitted.
onSessionExpired() => Promise<string | null>Return a fresh JWT or null to abort.

KycOpenOptions (JavaScript SDK)

OptionTypeDescription
tokenstringSession JWT. Required unless using the auth module.
themeEmbedThemePer-flow theme overrides.
localestringBCP 47 locale tag (e.g. "en", "es"). Defaults to "en".
onKycSuccess(identityUuid: string) => voidIdentity verification passed.
onKycFailed(reason: string) => voidIdentity verification failed.
onKycPending() => voidIdentity verification pending.
onError(code: string, message: string) => voidAn error occurred.
onCancel() => voidUser closed the modal.
onReady() => voidEmbed loaded and ready.
onGeofenceBlocked(stateCode: string, reason: string) => voidLocation not permitted.
onSessionExpired() => Promise<string | null>Return a fresh JWT or null to abort.

TermsOpenOptions (JavaScript SDK)

OptionTypeDescription
tokenstringSession JWT. Required unless using the auth module.
themeEmbedThemePer-flow theme overrides.
localestringBCP 47 locale tag (e.g. "en", "es"). Defaults to "en".
onTermsAccepted(acceptedAt: string) => voidUser accepted T&C. acceptedAt is the ISO 8601 acceptance timestamp.
onError(code: string, message: string) => voidAn error occurred.
onCancel() => voidUser closed the modal without accepting.
onReady() => voidEmbed loaded and ready.
onGeofenceBlocked(stateCode: string, reason: string) => voidLocation not permitted.
onSessionExpired() => Promise<string | null>Return a fresh JWT or null to abort.

Events

The SDK has three event layers. Most integrations only use callback events (passed to open()). Use the EventEmitter for global analytics or logging. Use the postMessage protocol only if building a custom integration without the SDK.

Callback events

Passed as options to open() on each flow hook. See the individual hook sections above for the full list per flow.

Summary of all callback events across flows:

CallbackAvailable onPayload
onSuccessAll flows(transactionId: string, amount?: number)
onErrorAll flows(code: string, message: string)
onCancelAll flows
onReadyAll flows
onGeofenceBlockedAll flows(stateCode: string, reason: string)
onKycSuccessuseOnboarding, useKyc(identityUuid: string)
onKycFaileduseOnboarding, useKyc(reason: string)
onKycPendinguseOnboarding, useKyc

EventEmitter

A typed pub/sub system available in all three SDKs. In React/React Native, use useEvents. In JavaScript, use sdk.on() / sdk.off().

Event namePayload typeDescription
readyEmbed iframe loaded and ready to interact.
success{ transactionId: string; amount?: number }Transaction completed successfully.
error{ code: string; message: string }An error occurred.
cancelUser dismissed the modal.
kycSuccess{ identityUuid: string }Identity verification passed.
kycFailed{ reason: string }Identity verification failed.
kycPendingIdentity verification submitted, awaiting result.
geofenceBlocked{ stateCode: string; reason: string }User's location is outside a permitted jurisdiction.
resize{ height: number }Embed content height changed. Useful for inline (non-modal) embeds.
sessionExpiredThe session token has expired.
sessionRefreshed{ token: string }A new session token was obtained after expiry.
open{ flow: string }A flow modal was opened. flow is "deposit", "withdraw", "onboarding", or "kyc".
close{ flow: string }A flow modal was closed.

EventEmitter API:

// Subscribe — returns an unsubscribe function
const unsub = sdk.on("success", ({ transactionId, amount }) => { ... });

// Unsubscribe by reference
sdk.off("success", handler);

// Unsubscribe via return value
unsub();

postMessage protocol

Raw messages exchanged between the host page and the ProphetX iframe via window.postMessage. The SDK handles these automatically — use this reference only if you are building a custom integration without the SDK.

Outbound messages (iframe to host)

These messages are sent by the ProphetX embed to your page:

Message typePayloadDescription
PROPHETX_READYEmbed loaded and ready.
PROPHETX_EMBED_LOADEDIframe DOM content loaded.
PROPHETX_SUCCESS{ transactionId: string; amount?: number }Transaction completed.
PROPHETX_ERROR{ code: string; message: string }An error occurred.
PROPHETX_CANCELUser dismissed the flow.
PROPHETX_RESIZE{ height: number }Embed content height changed.
PROPHETX_GEOFENCE_BLOCKED{ stateCode: string; reason: string }Location not permitted.
PROPHETX_KYC_SUCCESS{ identityUuid: string }Identity verification passed.
PROPHETX_KYC_FAILED{ reason: string }Identity verification failed.
PROPHETX_KYC_PENDING{}Identity verification pending.
PROPHETX_SESSION_EXPIREDSession token expired.

Inbound messages (host to iframe)

Send these messages to the ProphetX iframe:

Message typePayloadDescription
PROPHETX_SESSION{ token: string }Provide the session JWT when opening a flow.
PROPHETX_SESSION_REFRESH{ token: string }Provide a refreshed JWT after a PROPHETX_SESSION_EXPIRED event.
PROPHETX_THEMEEmbedThemeUpdate the embed's theme.
PROPHETX_CLOSEClose the embed.

Example — listening without the SDK:

window.addEventListener("message", (event) => {
  // Validate origin
  if (event.origin !== "https://embed.prophetx.co") return;

  const { type, payload } = event.data;

  switch (type) {
    case "PROPHETX_READY":
      console.log("Embed ready");
      break;
    case "PROPHETX_SUCCESS":
      console.log("Transaction:", payload.transactionId, payload.amount);
      break;
    case "PROPHETX_ERROR":
      console.error("Error:", payload.code, payload.message);
      break;
    case "PROPHETX_CANCEL":
      console.log("Cancelled");
      break;
    case "PROPHETX_SESSION_EXPIRED":
      // Fetch a new token and send it back
      fetchToken().then((token) => {
        iframe.contentWindow.postMessage(
          { type: "PROPHETX_SESSION_REFRESH", payload: { token } },
          "https://embed.prophetx.co"
        );
      });
      break;
  }
});

EmbedTheme

Theme overrides applied to the embed UI. Pass via the theme prop on ProphetXProvider (React/React Native), as part of OpenOptions (JavaScript SDK), or dynamically via sdk.updateTheme().

type EmbedTheme = {
  mode?: "light" | "dark";
  primaryColor?: string;
  colorOverrides?: Partial<ColorOverrides>;
  spacingOverrides?: Partial<SpacingOverrides>;
  radiusOverrides?: Partial<RadiusOverrides>;
  fontSizeOverrides?: Partial<FontSizeOverrides>;
};

Top-level fields

FieldTypeDescription
mode"light" | "dark"Base color scheme. Defaults to "dark".
primaryColorstringPrimary brand color. Applied to primary, primaryHover, cta, and ctaHover tokens.

colorOverrides

Fine-grained color tokens. All fields are optional CSS color strings.

TokenDescription
primaryPrimary brand color
primaryHoverHover state for primary elements
primaryForegroundText/icon color on primary backgrounds
secondarySecondary color
secondaryHoverHover state for secondary elements
backgroundPage background
surfaceCard/panel background
surfaceElevatedElevated surface (modals, dropdowns)
textDefault text color
textMutedDe-emphasized text
textSubtleLeast prominent text (placeholders, hints)
borderDefault border color
borderSubtleSubtle border (dividers, separators)
errorError text/icon color
errorBackgroundError background (alerts, badges)
successSuccess text/icon color
successBackgroundSuccess background
warningWarning text/icon color
warningBackgroundWarning background
ctaCall-to-action button color
ctaHoverCTA hover state
ctaForegroundText on CTA buttons
filledFilled/solid button color
filledHoverFilled button hover state
filledForegroundText on filled buttons
dangerDestructive action color
dangerHoverDestructive action hover state
dangerForegroundText on destructive action buttons

spacingOverrides

TokenDescription
xsExtra-small spacing
smSmall spacing
mdMedium spacing
lgLarge spacing
xlExtra-large spacing

radiusOverrides

TokenDescription
smSmall border radius
mdMedium border radius
lgLarge border radius
fullFully rounded (pill shape)

fontSizeOverrides

TokenDescription
xsExtra-small font size
smSmall font size
mdMedium (base) font size
lgLarge font size
xlExtra-large font size

DevToolsLogEntry

Entries emitted by the devtools system. Receive them via DevToolsConfig.onEvent.

FieldTypeDescription
timestampnumberUnix timestamp (ms).
category"auth" | "message" | "api" | "lifecycle" | "event"Log category.
level"error" | "warn" | "info" | "debug"Severity level.
messagestringHuman-readable log message.
dataRecord<string, unknown> | undefinedOptional structured data.

Type exports

All types are exported from the SDK package you're using. Import them alongside components and hooks: