Skip to main content

Features

  • OneSDK eKYC-only flow
  • Multi-step verification process
  • Retry handling mechanism
Instead of building your own flow, it’s highly recommended to fork an existing flow from the public sample codes found here
1

Initialize OneSDK

const oneSDKInstance = await OneSdk({
  session: sessionObjectFromBackend,
  mode: "production",
  recipe: {
    form: {
      provider: {
        name: "react",
        googleApiKey: '<YOUR GOOGLE MAPS API KEY>'
      },
    },
  },
});
Replace <YOUR GOOGLE MAPS API KEY> with your actual Google Maps API key for the address feature.
2

Set Up Individual Profile

const oneSdkIndividual = oneSDKInstance.individual();
oneSdkIndividual.setProfileType("auto");
3

Configure Form Components

// Welcome Screen
const welcome = oneSDKInstance.component("form", {
  name: "WELCOME",
  mode: "individual",
  type: "manual",
});

// Consent Form
const consent = oneSDKInstance.component("form", {
  name: "CONSENT",
  mode: "individual",
  type: "manual",
});
const personal = oneSDKInstance.component("form", {
  name: "PERSONAL",
  mode: "individual",
  type: "manual",
  title: {
    label: "Personal Details",
  },
  descriptions: [
    {
      label: "In this section, we need your personal information",
    },
    {
      label: "Please enter your information accordingly",
    },
  ],
});
const document = oneSDKInstance.component("form", {
  name: "DOCUMENT",
  mode: "individual",
  type: "manual",
  numberOfIDs: 2,
  title: {
    label: "Choose your identification",
  },
  descriptions: [
    {
      label: "We need two forms of ID to verify your identity",
    },
  ],
});
const review = oneSDKInstance.component("form", {
  name: "REVIEW",
  type: "manual",
  verify: true, // When true, automatically triggers verification
});
const result_success = oneSDKInstance.component("form", {
  name: "RESULT",
  type: "manual",
  state: "SUCCESS",
  title: { label: "Complete" },
  descriptions: [
    { label: "Process is now complete. You can close the page" },
  ],
  cta: { label: "Done" },
});

const result_fail = oneSDKInstance.component("form", {
  name: "RESULT",
  type: "manual",
  state: "FAIL",
  title: { label: "Verification Failed" },
  descriptions: [
    { label: "We were unable to verify your identity. Please contact our support team for assistance." },
  ],
  cta: { label: "Done" },
});

const result_pending = oneSDKInstance.component("form", {
  name: "RESULT",
  type: "manual",
  state: "PENDING",
  title: { label: "Verification Pending" },
  descriptions: [
    { label: "We are currently verifying your identity. Please contact our support team for assistance." },
  ],
  cta: { label: "Done" },
});

// Partial result form - Not required if implementing a retry mechanism per the Retry Logic Implementation section
const result_partial = oneSDKInstance.component("form", {
  name: "RESULT",
  type: "manual",
  state: "PARTIAL",
  title: { label: "Verification Partially Complete" },
  descriptions: [
    { label: "We were unable to fully verify your identity. Please contact our support team for assistance." },
  ],
  cta: { label: "Done" },
});

Event Handling

welcome.on("form:welcome:ready", () => {
  consent.mount(appContainer);
});

consent.on("form:consent:ready", async () => {
  personal.mount(appContainer);
});

personal.on("form:personal:ready", async () => {
  document.mount(appContainer);
});

document.on("form:document:ready", async () => {
  review.mount(appContainer);
});

Retry Logic Implementation

The implementation includes a retry mechanism that allows users up to 2 attempts before showing the failure screen.
// Define the retry form
const retry = oneSDKInstance.component("form", {
  name: "RETRY",
  type: "manual",
});

// Define the retry count
let retryCount = 0;

// Add partial result event listener to the review form
review.on("form:result:partial", async () => {
  if (retryCount < 2) {
    retry.mount(appContainer);
  } else {
    result_fail.mount(appContainer);
  }
});

Best Practices

Error Handling

Always implement proper error handling and validation for each form step to ensure data quality.

User Experience

Provide clear feedback and instructions in the user’s preferred language, especially for country-specific forms.