> ## Documentation Index
> Fetch the complete documentation index at: https://docs.frankieone.com/llms.txt
> Use this file to discover all available pages before exploring further.

# OneSDK Fraud Detection & Prevention

> OneSDK’s Fraud Detection system evaluates potential fraud risks by analyzing device characteristics and form-filling behavior during user onboarding. This enables real-time risk assessment to help you make informed decisions about user registration.

<Callout icon="bell" color="#FFCA16" iconType="regular">
  ##### Account Configuration Required

  To use device characteristics and behavioral biometrics, your account must be configured by FrankieOne. Contact your Customer Success representative to enable these features.
</Callout>

## Implementation Overview

<Frame>
  <img src="https://mintcdn.com/frankieone-f5583b1b/MpEYW70dy4W-choU/images/docs/image-20241010-040329.png?fit=max&auto=format&n=MpEYW70dy4W-choU&q=85&s=c2ce871646d5e91bd4f33117e5bc188d" alt="Fraud Detection Implementation Flow" width="1116" height="739" data-path="images/docs/image-20241010-040329.png" />
</Frame>

## Integration Steps

<Steps>
  <Step title="Initialize Server-Side Session">
    Your server needs to create a temporary session before serving the frontend.

    <Callout icon="bell" color="#FFCA16" iconType="regular">
      Note: The sample code below is just an example. **Never generate tokens on the frontend** — doing so can expose your credentials. Always generate tokens securely on your backend and pass them to your app as needed.
    </Callout>

    ```javascript theme={null}
    // Fetch authentication token from backend
    const tokenResultRaw = await fetch('https://backend.kycaml.uat.frankiefinancial.io/auth/v2/machine-session', {
    method: 'POST',
    headers: {
     // Create Basic Auth header using customer ID and API key
     authorization: 'machine ' + btoa(`${CUSTOMER_ID}:${API_KEY}`),
     'Content-Type': 'application/json',
    },
    body: JSON.stringify({
     permissions: {
       preset: 'one-sdk',
       // Customer reference options: pass either unique customer reference or existing EntityID
       reference: "customer-reference",  // Custom customer reference
       entityId: "abc-def-ghi"          // Existing entity ID (if exists)
     },
    }),
    });
    ```
  </Step>

  <Step title="Initialize OneSDK with Device Characteristics module">
    Set up OneSDK with the provided session data.

    ```javascript theme={null}
    const oneSdk = await OneSDK({
      session: tokenResultRaw, // Pass authentication token
      mode: "production", // Set to production environment
      recipe: {
        ocr: {
          maxDocumentCount: 3, // Maximum allowed documents for OCR
        },
      },
    });

    // Initialize device component for registration
    const device = oneSdk.component("device", {
      activityType: "REGISTRATION", // Set activity type
      sessionId: "YOUR_CUSTOM_SESSION_KEY", // Custom session identifier
    });

    // Start device monitoring
    device.start();
    ```
  </Step>

  <Step title="Retrieve Fraud Indicators">
    You can check entity's fraud indicator from Portal, or via KYC Entity Risk endpoint, read more [here](/api-reference/risk/get-an-entitys-risk-level-scorecard).
  </Step>
</Steps>

## Using Sardine

### Initialization

Once you have initialized OneSDK instance, you can create a device check component

Setting up Device Check

```javascript theme={null}
// Initialize device check component with registration activity
const device = oneSdk.component("device", {
 activityType: "REGISTRATION",
 sessionId: `session-${new Date().toISOString()}`, // Generate unique session ID using timestamp
});

// Begin device data collection
device.start();
```

### Capture Phone and Email for Fraud check

Using Individual’s module to [capture phone number and email](/docs/v1/onesdk/oneSDK/implementation-guide/module/individual), OneSDK will also allow you to run Fraud checks on these details.

## Event System

<Accordion title="Core Events">
  <CardGroup cols={2}>
    <Card title="mount" icon="circle-check">
      Emitted when Device Characteristics component is successfully mounted

      ```javascript theme={null}
      device.on('DEVICE:MOUNT', () => {
        console.log('Mounting Sardine');
      });
      ```
    </Card>

    <Card title="mount error" icon="flag-checkered">
      Signals unsucessful mount

      ```javascript theme={null}
      device.on('DEVICE:MOUNT:ERROR', () => {
        console.warn('Sardine mount failed');
      });
      ```
    </Card>
  </CardGroup>
</Accordion>

## Best Practices

<AccordionGroup>
  <Accordion title="Performance Optimization">
    * Initialize OneSDK as early as possible in your application lifecycle
    * Keep the session object readily available in your frontend state
    * Consider implementing session recovery mechanisms
  </Accordion>

  <Accordion title="Security Considerations">
    * Never expose your FrankieOne API credentials in the frontend
    * Implement proper session timeout handling
    * Always validate session data on your server
  </Accordion>
</AccordionGroup>

## Risk Level Handling

<CardGroup cols={3}>
  <Card title="Low Risk" icon="circle-check">
    Standard processing

    * Continue with normal flow
    * Regular verification
  </Card>

  <Card title="Medium Risk" icon="triangle-exclamation">
    Enhanced verification

    * Additional identity checks
    * Manual review option
  </Card>

  <Card title="High Risk" icon="circle-xmark">
    Restricted processing

    * Block registration
    * Flag for review
  </Card>
</CardGroup>

<Callout icon="star" color="#3DD892" iconType="regular">
  ##### Need Help?

  For technical support or to enable fraud detection features, contact your FrankieOne Customer Success representative or visit our support portal.
</Callout>
