Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion content/docs/js-sdk/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"installation",
"preparing-request",
"generating-proof",
"verifying-proofs"
"verifying-proofs",
"sdk-methods"
]
}
94 changes: 94 additions & 0 deletions content/docs/js-sdk/sdk-methods.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
---
title: SDK Methods Reference
description: Detailed technical reference for the Reclaim Protocol JS-SDK methods, including parameters and return types.
---

# ReclaimProofRequest

The `ReclaimProofRequest` class is the core component used to initialize, configure, and trigger the proof generation process.

## Methods Overview

| Method | Description |
| :--- | :--- |
| `init()` | Creates a new SDK instance. |
| `setContext()` | Adds user-specific identifiers to the request. |
| `setParams()` | Sets expected values for data extraction. |
| `setAppCallbackUrl()` | Define backend URL for Reclaim to POST proofs upon verification. |

## init()

The `init` method is a static asynchronous function used to initialize the Reclaim SDK. It creates a `ReclaimProofRequest` instance that holds your configuration.

### Parameters

| Parameter | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| `appId` | `string` | Yes | Your unique Application ID generated from the Reclaim DevTool. |
| `appSecret` | `string` | Yes | Your Application Secret. **Security Note:** This should only be used on the backend. |
| `providerId` | `string` | Yes | The unique identifier for the data provider you want the user to verify. |
| `options` | `object` | No | Advanced configuration object (e.g., `metadata`, `preferredLocale`). |

### Return Value
**Type:** `Promise<ReclaimProofRequest>`
Returns a "Promise" that resolves to a new instance of the `ReclaimProofRequest` class once initialization is complete.

### Example
```javascript
const reclaimProofRequest = await ReclaimProofRequest.init(
process.env.RECLAIM_APP_ID,
process.env.RECLAIM_APP_SECRET,
'your-provider-id'
);
```
## setContext()

Adds context to the proof request. This helps you identify and verify the request when the proof is sent back to your callback endpoint.

### Parameters

| Parameter | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| `contextAddress` | `string` | Yes | A unique identifier for the user (e.g., a wallet address or email). |
| `contextMessage` | `string` | Yes | A message or stringified JSON containing additional session data. |

### Example
```javascript
reclaimProofRequest.setContext('user-wallet-address', 'session-id-12345');
```


## setParams()

Defines the expected values for the parameters being extracted. If the extracted data from the provider does not match these parameters, the proof generation will fail.

### Parameters

| Parameter | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| `params` | `Record<string, string>` | Yes | A key-value object where keys match the template's parameter names. |

### Example
```javascript
reclaimProofRequest.setParams({
userName: "John Doe",
membershipType: "Premium"
});
```

## setAppCallbackUrl()

Specifies a backend URL where the Reclaim Protocol will send the proof results once the user completes the verification.

### Parameters

| Parameter | Type | Required | Description | Default |
| :--- | :--- | :--- | :--- | :--- |
| `url` | `string` | **Yes** | Your backend endpoint URL (e.g., `https://api.your-app.com/callback`). | - |
| `useJson` | `boolean` | No | If `true`, the proof is sent as raw JSON. If `false`, it is urlencoded. | `false` |

### Example

```javascript
reclaimProofRequest.setAppCallbackUrl('https://my-backend.com/reclaim-webhook', true);
```
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.