Flutter SDK for Sotaid

A Flutter plugin for SotaID identity verification integration.

Features

  • App-Controlled Verification Process: The app decides whether to show complete verification (document + face) or face-only verification
  • Multiple Verification Types: Support for ID verification, face matching, and liveness detection
  • Document Capture: Capture front and back of identity documents
  • Face Verification: Record face videos for verification
  • Permission Management: Automatic camera and storage permission handling
  • Country Support: Dynamic country and document type selection
  • Session Management: Automatic storage and reminder for pending manual verifications

Getting Started

Installation

Add the plugin to your pubspec.yaml:

Basic Usage

The verification process selection is now controlled by the app, not the user. The app decides whether to show the complete verification process or just face verification.

import 'package:sotaid_pluging/sotaid_plugin.dart';

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final SotaIdPlugin _plugin = SotaIdPlugin();

  // Start complete verification (document + face)
  Future<void> _startCompleteVerification() async {
    await _plugin.startCompleteVerification(
      context: context,
      bearerToken: 'your_bearer_token',
      onVerificationComplete: (response) {
        print('Verification completed: ${response.status}');
        // Handle successful verification
      },
      onError: (error) {
        print('Verification error: $error');
        // Handle verification error
      },
    );
  }

  // Start face-only verification (requires document file)
  Future<void> _startFaceVerification() async {
    // In a real app, you would get this file from user selection or capture
    File documentFile = await _getDocumentFile();
    
    await _plugin.startFaceVerification(
      context: context,
      documentFile: documentFile,
      bearerToken: 'your_bearer_token',
      onVerificationComplete: (response) {
        print('Face verification completed: ${response.status}');
        // Handle successful verification
      },
      onError: (error) {
        print('Face verification error: $error');
        // Handle verification error
      },
    );
  }

  // Generic verification flow with custom verification type
  Future<void> _startCustomVerification() async {
    await _plugin.startVerificationFlow(
      context: context,
      verificationType: VerificationType.id, // or VerificationType.facematch, VerificationType.liveness
      documentFile: null, // Required only for VerificationType.facematch
      bearerToken: 'your_bearer_token',
      onVerificationComplete: (response) {
        print('Verification completed: ${response.status}');
      },
      onError: (error) {
        print('Verification error: $error');
      },
    );
  }

  // Manually check verification status
  Future<void> _checkVerificationStatus() async {
    await _plugin.checkPendingVerificationStatus(context);
  }
}

Legacy Verification Flow

The legacy verification flow still allows direct access to the verification widget, but now requires the verification type to be specified by the app:

import 'package:sotaid_pluging/verification_flow.dart';

// Show verification flow with app-controlled verification type
Navigator.of(context).push(
  MaterialPageRoute(
    builder: (context) => SotaIdVerificationFlow(
      verificationType: VerificationType.id, // App controls the verification type
      bearerToken: 'your_bearer_token',
      documentFile: null, // Required only for VerificationType.facematch
      onVerificationComplete: (response) {
        print('Verification completed: ${response.status}');
      },
      onError: (error) {
        print('Verification error: $error');
      },
    ),
  ),
);

Verification Types

Complete Verification (VerificationType.id)

  • User captures document front (and back if required)
  • User records face video
  • Full identity verification process

Face Verification (VerificationType.facematch)

  • App provides a reference document file
  • User only records face video
  • Face is compared against the provided document

Liveness Detection (VerificationType.liveness)

  • User records face video
  • System detects if the person is real (not a photo/video)

API Reference

SotaIdPlugin

Methods

  • startCompleteVerification() - Start complete verification flow
  • startFaceVerification() - Start face-only verification flow
  • startVerificationFlow() - Start verification with custom type
  • initialize() - Initialize plugin with configuration
  • getCountries() - Get available countries
  • createVerificationSession() - Create verification session
  • verifyFront() - Verify document front
  • verifyBack() - Verify document back
  • verifyFace() - Verify face video
  • getVerificationStatus() - Get verification status

VerificationResponse

class VerificationResponse {
  final String status; // 'verified', 'requires_back', 'requires_face', 'failed', etc.
  final Map<String, dynamic>? errors;
  final String? message;
}

Configuration

Bearer Token

The plugin requires a bearer token for API authentication. This should be provided by your app:

_plugin.initialize(bearerToken: 'your_bearer_token');

Environment Mode

The plugin defaults to sandbox mode. You can change this during initialization:

_plugin.initialize(
  sandboxMode: false, // Set to false for production
  bearerToken: 'your_bearer_token',
);

Permissions

The plugin automatically handles camera and storage permissions. Users will be prompted for permissions when needed during the verification process.

Session Management

The plugin automatically manages verification sessions, especially for manual verification processes:

Automatic Session Storage

  • When a verification returns requires_manual_verification status, the session is automatically stored locally
  • Session information includes session ID, status, and creation timestamp

Pending Verification Reminder

  • When users try to start a new verification, the plugin checks for existing pending verifications
  • If a pending manual verification exists, users are prompted with options:
    • "Vérifier le statut": Check the current status of the pending verification
    • "Nouvelle vérification": Start a new verification process

Status Checking

  • Users can check the status of pending verifications
  • The plugin fetches the latest status from the server
  • Shows appropriate messages based on current status:
    • Verified: Success message with option to clear session
    • Failed: Error message with option to start new verification
    • Pending: Shows time since submission with current status

Automatic Cleanup

  • Sessions are automatically cleared when verification completes (success or failure)
  • No manual cleanup required

Example

See the example/ directory for a complete working example demonstrating both the new app-controlled verification API and the legacy verification flow.

Migration from Previous Versions

If you were using the previous version where users could choose verification types:

  1. Remove verification type selection UI from your app
  2. Use the new app-controlled API (startCompleteVerification() or startFaceVerification())
  3. Decide verification type in your app logic based on your business requirements
  4. Update your verification flow calls to include the required verificationType parameter

License

This project is licensed under the MIT License - see the LICENSE file for details.