npm.io
0.0.2-alpha • Published 14h ago

flowstudio-rn

Licence
MIT
Version
0.0.2-alpha
Deps
0
Vulns
0
Weekly
0

flowstudio-rn

React Native SDK for Bureau Flow Studio. It runs Flow Studio identity and verification journeys inside React Native.

Alpha: Android only for now. iOS support is coming. On iOS, initialize() and start() throw FlowStudio: ios is not supported yet, and isInitialized() returns false.

Installation

npm install flowstudio-rn@alpha

Expo projects can use npx expo install flowstudio-rn@alpha.

Rebuild the app after installing (npx react-native run-android, or npx expo run:android for Expo). Expo Go is not supported.

Requirements:

  • React Native 0.81 or newer, or Expo SDK 54 or newer. Their default Android build setup (Android Gradle Plugin, Gradle, compileSdkVersion 36) works as is.
  • minSdkVersion 24 or higher (the React Native 0.81+ default).
  • The SDK declares the CAMERA permission, which it uses for document capture and liveness.

Android setup

The SDK registers this repository for your app automatically:

  • Expo (prebuild / CNG): add the config plugin to app.json, then run npx expo prebuild (or npx expo run:android):

    {
      "expo": {
        "plugins": ["flowstudio-rn"]
      }
    }
  • Bare React Native: nothing to add. The library's Gradle file registers the repository for all projects.

If your settings.gradle sets repositoriesMode to FAIL_ON_PROJECT_REPOS, add the repository yourself under dependencyResolutionManagement { repositories { ... } }:

maven { url "https://packages.bureau.id/api/packages/Bureau/maven" }

API Reference

import { FlowStudio } from 'flowstudio-rn';
FlowStudio.initialize(config)

Initializes the SDK. Call it before start(), for example once you have created the execution on your backend.

Parameters (FlowStudioConfig):

  • credentialId (string): your Bureau credential ID
  • deviceCredentialId (string): credential ID used for device intelligence
  • executionId (string): ID of the Flow Studio execution to run
  • environment (string, optional): 'PROD', 'STAGING' or 'DEV' (default: 'PROD')
  • enableLogging (boolean, optional): enables SDK logs (default: false)

It throws an Error if a required field is missing or environment is invalid.

FlowStudio.start()

Opens the Flow Studio journey. The promise resolves when the journey ends.

Returns: Promise<FlowStudioResult>

type FlowStudioResult =
  | { type: 'result'; response: ExecutionResponse } // journey finished
  | { type: 'exit' }; // user left the journey without a result

interface ExecutionResponse {
  executionId: string;
  merchantId: string;
  requestId: string;
  executionStatus: string; // 'PROCESSING' | 'AWAITING' | 'COMPLETED' | 'TIMEOUT' | 'ERROR'
  currentState: Record<string, unknown>;
  createdAt: number; // epoch timestamp
  updatedAt: number; // epoch timestamp
}

Only one journey can run at a time. start() can be called again once the previous call has resolved.

FlowStudio.isInitialized()

Returns: boolean, which is true once initialize() has succeeded.

Usage Example

import { FlowStudio } from 'flowstudio-rn';

async function runVerification(executionId: string) {
  FlowStudio.initialize({
    credentialId: 'your-credential-id',
    deviceCredentialId: 'your-device-credential-id',
    executionId,
    environment: 'STAGING', // 'PROD' for live
  });

  try {
    const result = await FlowStudio.start();

    if (result.type === 'result') {
      console.log('Status:', result.response.executionStatus);
    } else {
      console.log('User exited the journey');
    }
  } catch (error) {
    console.error('FlowStudio failed:', error);
  }
}

Errors

initialize() and start() throw or reject with an Error. Errors from start() that come from the SDK carry a code:

Code Meaning
ERR_ALREADY_STARTED start() was called while a journey is already running
ERR_START_FAILED The SDK failed to start the journey (see message)
ERR_MODULE_DESTROYED The app reloaded or the React context was torn down during a journey

If the native module is missing (for example the app was not rebuilt after installing the package, or it runs in Expo Go), calls throw FlowStudio: native module not found.

Notes

  • Execution ID: create a new execution for each journey. Execution IDs are single use.
  • Environment: use 'STAGING' for testing and 'PROD' for live traffic. Credentials are environment specific.
  • Exit handling: a { type: 'exit' } result is not an error. It means the user closed the journey.

License

MIT

Keywords