Overview
The OneSDK must be initialized before any modules can be used. The initialization process configures the SDK with your session token, sets the environment mode, and prepares all modules for use.Import
Method
OneSdk(parameters)
Initializes the OneSDK and returns a Promise that resolves to the SDK context object. OneSdk is the default export of the package and is itself the initialization function.
Signature:
When
telemetry is enabled, the SDK automatically redacts sensitive values (e.g. tokens, API keys, secrets, clientID) from component options and recipe data before including them in telemetry events.SessionOptions
Session configuration object. Required whenmode is not "dummy".
Recipe Configuration
Therecipe parameter controls how the SDK performs verification. You can pass either a string (recipe name) or an object (recipe configuration).
String Recipe Name
Pass a predefined recipe name to use standard verification workflows:"auto"- Automatically selects appropriate recipe (default)"default"- Standard verification flow"standard_kyc"- Standard KYC verification"full"- Full verification with all checks"safe_harbour"- Safe harbour compliance checks"safe_harbour_plus"- Enhanced safe harbour checks"international"- International verification flow"gov_id"- Government ID verification"aml_only"- AML checks only- Custom recipe names configured by FrankieOne
Recipe Configuration Object
Pass a partial configuration object to customize the verification flow:
Examples:
Recipe configuration is typically managed by FrankieOne. The SDK will fetch and merge the recipe configuration from the server with any recipe options you pass during initialization.
SDK Modes
The SDK supports three operational modes:
Type Definition:
Return Value
Returns aPromise<OneSdkContext> that resolves to the SDK context object.
OneSdkContext
The SDK context provides access to all modules and SDK functionality:Usage Examples
Basic Initialization (Production)
Development Mode with DevTools
Dummy Mode (No Backend Required)
With Recipe (String Name)
With Recipe (Object Configuration)
With Token Persistence
Generating Session Tokens
Session tokens must be generated on your backend server by calling the FrankieOne API. Never expose your API credentials in client-side code.- Backend (Node.js/Express)
- Frontend
For the complete implementation with React hooks and error handling, see the Embedded OneSDK Quick Start.
Error Handling
OneSdk() returns a Promise that will reject if initialization fails. Always wrap it in a try-catch block:
Events
The SDK emits several events during and after initialization:resolved_root_config
Emitted when the root configuration is resolved.
telemetry
Emitted for internal diagnostic data. Used by FrankieOne for troubleshooting and support.
Telemetry events are primarily for internal use by FrankieOne support. Event structure is not fully typed and may change.
error
Emitted when an error occurs.
warning
Emitted for configuration warnings.
Network Events
The SDK monitors network connectivity:Session Management
After initialization, you can access session information through thesession property:
JavaScript/TypeScript Usage
OneSDK provides type definitions for TypeScript projects, but full TypeScript support is not available for all APIs:Best Practices
- Always handle errors: Wrap initialization in try-catch blocks to handle failures gracefully.
- Use environment variables: Store tokens in environment variables, never hardcode them.
-
Enable devtools in development: Use
devtools: trueduring development for better debugging. -
Set appReference: Always provide an
appReferenceto help track issues in logs. - Listen to network events: Monitor network connectivity to improve user experience.
-
Use token persistence wisely: Only enable
persist: truewhen appropriate for your use case.