Skip to main content

Overview

journey() mounts a complete, pre-assembled verification flow into an element you own and resolves with a single decision. See the quick start guide to get one running.

Method

oneSdk.journey(name, options?)

JourneyName

name is a member of the JourneyName enum. A string that isn’t one of its values is rejected at runtime.

Options

Container ownership

The journey owns the element you hand it. On stop() or destroy() it empties that element, so anything else you render inside it is removed too — including your own loading state or placeholder. Give the journey an element of its own rather than sharing one with your app’s UI:
If you omit container, the journey creates a <div data-onesdk-journey> inside document.body and removes only that node on teardown. Your page is left untouched. This default exists so a journey can be started with no markup at all — useful in a console or a spike — but a dedicated element is the intended integration, and the only form in which the journey’s styling and layout are under your control. Passing container: null is rejected outright with E_CONTAINER_NOT_FOUND, because it almost always means a document.querySelector(...) that found nothing.

Handle

journey() returns a JourneyHandle synchronously, exposing start(), stop(), and destroy() across the two bullets below:
  • start() — begins the flow. Idempotent: calling it a second time returns the same settled promise rather than starting a second run.
  • stop() and destroy() — the same operation under two names. Both settle the in-flight start() promise with abandoned / user_exited and leave no screens, vendor iframe, or journey-owned instances behind: a container you passed is emptied, and if you passed none, the journey’s own node is removed (see Container ownership). destroy() is a conventional name, not a stronger teardown — there is no behavioural difference between the two, and neither leaves the journey resumable.
A journey torn down mid-step still settles — await start() never hangs.

JourneyResult

JourneyResult is a discriminated union keyed on outcome, with reason as the second discriminant. These are the two fields a host actually branches on: Common fields, present on every result regardless of outcome:
entityId is resolved at settlement, not at construction. checkResult is a CheckSummary — see Individual module: CheckSummary Structure for its shape — and rides on decision outcomes only: it is present on success, pending, and declined, and absent otherwise. The 25 reason codes: error results carry an additional shape:

Errors

Two pre-flight errors, both OneSDKError: Both are thrown rather than resolved on the JourneyResult, because the journey never ran.

Telemetry

journey() emits JOURNEY:READY, carrying elapsedMs — the time from the journey() call to first paint. This fires for real runs only; a simulated journey (see simulate) mounts no screen and emits no JOURNEY:READY. See the event system reference for how telemetry events are consumed.