✨Works out of the box guarantee. If you face any issue at all, hit us up on Telegram and we will write the integration for you.

JS
Advanced Configuration

Advanced Configuration of the Reclaim Protocol JavaScript SDK

This guide provides detailed information on advanced configuration options for the Reclaim Protocol JavaScript SDK. These options allow you to customize and enhance your integration for specific use cases.

Before diving into advanced configurations, make sure you're familiar with the basic usage of the SDK.

Advanced Options

⚠️

Important: All advanced configuration methods should be called before invoking getRequestUrl(). This ensures that all settings are properly applied to your proof request.

Adding Context

The addContext method allows you to add additional information to your proof request. This context is reflected in the proof object, helping to identify and distinguish between different proof requests.

const reclaimProofRequest = await ReclaimProofRequest.init(
  'YOUR_RECLAIM_APP_ID',
  'YOUR_RECLAIM_APP_SECRET',
  'YOUR_PROVIDER_ID'
)
 
reclaimProofRequest.addContext('0x1234567890abcdef', 'User registration proof')
 
const requestUrl = await reclaimProofRequest.getRequestUrl()
  • contextId: A unique identifier for the context (hex address)
  • Context message: Additional information about the proof request (string)

Use context to provide metadata about the proof request, such as its purpose or origin. This can be particularly useful when handling multiple types of proofs in your application.

⚠️

Ensure that the contextId is a valid hex address. It should start with '0x' and contain only hexadecimal characters (0-9 and a-f).

Setting Parameters

The setParams method allows you to set specific conditions that must be met for the proof to be generated. This is useful for selective triggering and manual verification flows.

const reclaimProofRequest = await ReclaimProofRequest.init(
  'YOUR_RECLAIM_APP_ID',
  'YOUR_RECLAIM_APP_SECRET',
  'YOUR_PROVIDER_ID'
)
 
reclaimProofRequest.setParams({ // Params value must be a string
  minConnections: '500', 
  industry: 'Technology'
})
 
const requestUrl = await reclaimProofRequest.getRequestUrl()
⚠️

Use this option carefully. If the actual data doesn't match the set parameters, proof generation will not trigger. Ensure that the parameters you set are achievable and relevant to the proof you're requesting.

Custom Redirect URL

The setRedirectUrl method allows you to specify a custom URL where users will be redirected after the verification process.

const reclaimProofRequest = await ReclaimProofRequest.init(
  'YOUR_RECLAIM_APP_ID',
  'YOUR_RECLAIM_APP_SECRET',
  'YOUR_PROVIDER_ID'
)
 
reclaimProofRequest.setRedirectUrl('https://your-app.com/verification-complete')
 
const requestUrl = await reclaimProofRequest.getRequestUrl()

This enhances user experience by seamlessly guiding users back to your application after proof generation. Ensure the redirect URL is prepared to handle post-verification logic.

Custom Callback URL

The setAppCallbackUrl method allows you to specify a custom API endpoint where proofs will be sent upon successful generation.

const reclaimProofRequest = await ReclaimProofRequest.init(
  'YOUR_RECLAIM_APP_ID',
  'YOUR_RECLAIM_APP_SECRET',
  'YOUR_PROVIDER_ID'
)
 
reclaimProofRequest.setAppCallbackUrl('https://your-api.com/receive-proofs')
 
const requestUrl = await reclaimProofRequest.getRequestUrl()

This method is particularly useful for backend implementations. It allows you to receive proofs directly without polling the status URL. Ensure your endpoint is secure and can handle incoming proof data.

Exporting and Importing SDK Configuration

The SDK provides methods to export and import the entire configuration as a JSON string. This allows for flexible usage across different parts of your application.

// Export configuration
const reclaimProofRequest = await ReclaimProofRequest.init(
  'YOUR_RECLAIM_APP_ID',
  'YOUR_RECLAIM_APP_SECRET',
  'YOUR_PROVIDER_ID'
)
 
const reclaimProofRequestConfig = reclaimProofRequest.toJsonString()
 
 
// On a different service or application import the configuration
const reclaimProofRequest = ReclaimProofRequest.fromJsonString(reclaimProofRequestConfig)
const requestUrl = await reclaimProofRequest.getRequestUrl()

This feature is particularly useful when you need to initialize the SDK in one part of your application (e.g., frontend) and use it in another (e.g., backend). It provides a seamless way to transfer the configuration.

Initialization Options

When initializing the SDK, you can pass additional options to customize its behavior:

const proofRequest = await ReclaimProofRequest.init(
  'YOUR_RECLAIM_APP_ID',
  'YOUR_RECLAIM_APP_SECRET',
  'YOUR_PROVIDER_ID',
  { log: true }
)
  • log: When set to true, enables detailed logging for debugging purposes.

Use this option to enhance debugging capabilities in your application. The logging option is particularly useful during development and testing phases.

Best Practices for Advanced Configuration

  1. Security: Always prioritize security when configuring callbacks and parameters. Use HTTPS for all URLs and avoid passing sensitive data in parameters.

  2. Error Handling: Implement robust error handling for all advanced configurations, especially when dealing with callbacks and redirects.

  3. Testing: Thoroughly test your advanced configurations in a staging environment before deploying to production.

  4. Documentation: Maintain clear documentation of your custom configurations, especially when using context or custom parameters.

Remember, while these advanced configurations offer more flexibility, they also require careful implementation to ensure security and reliability.

By leveraging these advanced configuration options, you can create a more tailored and robust integration of the Reclaim Protocol into your application. If you have any questions about these advanced features, don't hesitate to reach out to our support team or community forums.

Happy coding with Reclaim Protocol!