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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@reclaimprotocol/reactnative-sdk

v1.1.6

Published

Designed to request proofs from the Reclaim protocol and manage the flow of claims.

Downloads

37

Readme

Reclaim reactnative-sdk

This README provides a step-by-step guide on integrating the Reclaim Protocol React native SDK into application

Pre-requisites

Create a new React application

npx react-native init ReclaimApp
cd ReclaimApp

Install the Reclaim Protocol JS-SDK

npm install @reclaimprotocol/reactnative-sdk

Import dependencies

In your src/App.js file, import the Reclaim SDK and the QR code generator

import { useState, useEffect } from 'react'
import { Reclaim } from '@reclaimprotocol/reactnative-sdk'

Initialize the Reclaim SDK

Declare your application ID and initialize the Reclaim Protocol client. Replace YOUR_APPLICATION_ID_HERE with the actual application ID provided by Reclaim Protocol.

File: src/App.js

import { Reclaim } from '@reclaimprotocol/reactnative-sdk'
import { SafeAreaView, Text, View } from 'react-native'

function App() {
  const APP_ID = 'YOUR_APPLICATION_ID_HERE'
  const reclaimProofRequest = new Reclaim.ProofRequest(APP_ID)

  return (
    <SafeAreaView>
      <View>
        <Text>App</Text>
      </View>
    </SafeAreaView>
  )
}

export default App

Add your app deep link

You'll need to add a deep link to your app. This will be used to redirect the user back to your app after they have completed the verification process.

  • Guide to setup deep link on react-native can be found here.
import { SafeAreaView, Text, View } from 'react-native'
import { ReclaimClient } from '@reclaimprotocol/reactnative-sdk'

function App() {
  const APP_ID = 'YOUR_APPLICATION_ID_HERE'
  const reclaimProofRequest = new Reclaim.ProofRequest(APP_ID)

  async function startVerificationFlow() {
    // id of the provider you want to generate the proof for
    await reclaimProofRequest.buildProofRequest('PROVIDER_ID')

    const appDeepLink = 'YOUR_APP_DEEP_LINK_HERE' //TODO: replace with your app deep link
    reclaimProofRequest.setAppCallbackUrl(appDeepLink)
  }

  return (
    <SafeAreaView>
      <View>
        <Text>App</Text>
      </View>
    </SafeAreaView>
  )
}

export default App

Implement Verification Request Function

Create functions to handle the verification request. You'll need separate functions for prototype and production modes due to the different handling of the application secret and signature.

Prototype Mode

For testing purposes, use the prototype mode. Note that in production, you should handle the application secret securely on your server.

File: src/App.js

import { Reclaim } from '@reclaimprotocol/reactnative-sdk'
import { SafeAreaView, Text, View, Pressable } from 'react-native'

function App() {
  const APP_ID = 'YOUR_APPLICATION_ID_HERE'

  const reclaimProofRequest = new Reclaim.ProofRequest(APP_ID)

  async function startVerificationFlow() {
    // id of the provider you want to generate the proof for
    await reclaimProofRequest.buildProofRequest('PROVIDER_ID')

    const appDeepLink = 'YOUR_APP_DEEP_LINK_HERE' //TODO: replace with your app deep link
    reclaimProofRequest.setAppCallbackUrl(appDeepLink)

    reclaimProofRequest.setSignature(
      await reclaimProofRequest.generateSignature(
        'YOUR_APPLICATION_SECRET' // Handle securely for production
      )
    )

    const { requestUrl, statusUrl } =
      await reclaimProofRequest.createVerificationRequest()

    await reclaimProofRequest.startSession({
      onSuccessCallback: proof => {
        console.log('Verification success', proof)
        // Your business logic here
      },
      onFailureCallback: error => {
        console.error('Verification failed', error)
        // Your business logic here to handle the error
      },
    })
  }

  return (
    <SafeAreaView>
      <View>
        <Pressable onPress={startVerificationFlow}>
          <Text>Start Verification Flow</Text>
        </Pressable>
      </View>
    </SafeAreaView>
  )
}

export default App

Production Mode

In production mode, securely fetch and set the signature from your backend instead of using the application secret directly in the client.

Similar to the prototype mode but ensure to fetch and set the signature securely

async function createVerificationRequestProductionMode() {
  // id of the provider you want to generate the proof for
  await reclaimProofRequest.buildProofRequest('PROVIDER_ID')

  const appDeepLink = 'YOUR_APP_DEEP_LINK_HERE' //TODO: replace with your app deep link
  reclaimProofRequest.setAppCallbackUrl(appDeepLink)

  reclaim
    .setSignature
    // TODO: fetch signature from your backend
    // On the backend, generate signature using:
    // await Reclaim.getSignature(requestedProofs, APP_SECRET)
    ()

  const { requestUrl, statusUrl } =
    await reclaimProofRequest.createVerificationRequest()

  await reclaimProofRequest.startSession({
    onSuccessCallback: proof => {
      console.log('Verification success', proof)
      // Your business logic here
    },
    onFailureCallback: error => {
      console.error('Verification failed', error)
      // Your business logic here to handle the error
    },
  })
}