npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-native-metric-sdk

v0.3.2

Published

MetricSDK is a React Native library designed to facilitate token-based identity verification through the Metric Africa service. The SDK provides methods to initiate token verification and check the status of a verification token, as well as a customizable

Readme

MetricSDK Documentation

Overview

MetricSDK is a React Native library designed to facilitate token-based identity verification through the Metric Africa service. The SDK provides methods to initiate token verification and check the status of a verification token, as well as a Verification modal for displaying the verification process.


Installation

npm install react-native-metric-sdk
# or
yarn add react-native-metric-sdk

Features

  • Token Verification: Initiate token-based verification processes with configurable parameters.
  • Token Status Check: Retrieve the status of verification tokens.
  • Verification Modal: Seamless integration with a modal for user interactions.

Prerequisite

You should have the react-native-webview package already installed, and have the camera permissions setup for the application. You can do that in the app.json file:

for IOS:

{
  "ios": {
    ...
    "infoPlist": {
      "NSCameraUsageDescription": "To allow Metric Example App access your camera in order to verify your identity."
    }
  },
}

for Android:

{
  "android": {
    ...
    "permissions": ["android.permission.CAMERA"]
  },
}

Usage

For a full example on how to use the package, check the App.tsx file in the example directory.

Initialization

To use the SDK, initialize it with your client ID and secret key:

import MetricSDK from 'metric-sdk';

const metric = new MetricSDK({
  clientId: 'your-client-id',
  secretKey: 'your-secret-key',
});

Methods

initiateTokenVerification

Initiates the token verification process.

Parameters:

  • token (string): Required token for verification.
  • onModalClose ((data: VerificationData) => void): Callback executed with the result of the verification when the modal is closed.

Returns:

  • An object containing a JSX.Element.

Example:

const { VerificationModal } = await metric.initiateTokenVerification(
  token,
  (data) => {
    if (data) {
      console.log('Verification completed:', data);
    }
  }
);

checkTokenStatus

Checks the status of a verification token.

Parameters:

  • token (string): The verification token.

Returns:

  • A Promise<string> containing the token status message.

Example:

const status = await metric.checkTokenStatus('your-token');
console.log('Token status:', status);

Example

Below is a complete example of using the SDK in a React Native application:

Example:

import { useState } from "react";
import { View, Button, Text, TextInput } from "react-native";
import MetricSDK, { type VerificationData } from "react-native-metric-sdk";

const metric = new MetricSDK({
  clientId: "your-client-id",
  secretKey: "your-secret-key",
});

const App = () => {
  const [modalComponent, setModalComponent] = useState<JSX.Element | null>(null);
  const [token, setToken] = useState("");
  const [userData, setUserData] = useState<VerificationData>();

  const handleVerifyToken = async () => {
    try {
      const { VerificationModal } = await metric.initiateTokenVerification(
        token,
        (data) => {
          if (data) {
            setUserData(data);
            setModalComponent(null);
          }
        } // Callback to close the modal
      );

      setModalComponent(VerificationModal);
    } catch (err) {
      console.error("Error:", err instanceof Error ? err.message : err);
    }
  };

  return (
    <View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}>
      <View style={{}}>
        <Text>Token:</Text>
        <TextInput
          style={{
            width: 200,
            height: 40,
            paddingHorizontal: 8,
            borderColor: "#000",
            borderWidth: 1.5,
          }}
          value={token}
          onChangeText={setToken}
        />
      </View>
      <Button title="Verify Token" onPress={handleVerifyToken} />
      {userData && (
        <>
          <Text>name: {userData?.customer_name}</Text>
          <Text>sid: {userData?.suid}</Text>
        </>
      )}
      {modalComponent}
    </View>
  );
};

export default App;

API Reference

MetricSDKConfig

The configuration options used to initialize the MetricSDK.

| Property | Type | Description | | ----------- | -------- | ----------------------- | | clientId | string | Your Metric client ID. | | secretKey | string | Your Metric secret key. |


initiateTokenVerification

Starts a verification process and returns a React.JSX.Element component for user interaction.

async initiateTokenVerification(
token: string,
onModalClose: (data: VerificationData | null) => void
): Promise<{ VerificationModal: JSX.Element }>

| Parameter | Type | Description | | -------------- | ------------------------------------------ | ----------------------------------------- | | token | string | The verification token. | | onModalClose | (data: VerificationData \| null) => void | Callback triggered when the modal closes. |

Returns:
An object containing a React.JSX.Element component to be rendered in your application.


checkTokenStatus

Fetches the status of a verification token.

async checkTokenStatus(token: string): Promise<string>

| Parameter | Type | Description | | --------- | -------- | ----------------------- | | token | string | The verification token. |

Returns:
A string representing the status of the token.


VerificationData

The structure of the status object returned after a successful token verification.

| Property | Type | Description | | --------------- | -------- | ------------------------------------ | | status | string | The status of a the verification | | suid | string | the short guid for the verification. | | customer_name | string | The name of the verified customer. |


Error Handling

All methods in the MetricSDK throw errors when something goes wrong. Errors are instances of the MetricSDKError class, which extends the built-in Error class.

Example:

try {
  const status = await metric.checkTokenStatus('your-token');
} catch (error) {
  if (error instanceof MetricSDKError) {
    console.error('Metric SDK Error:', error.message);
  } else {
    console.error('Unexpected Error:', error);
  }
}

Note: Ensure valid tokens and configurations are provided to avoid errors and ensure smooth operation.