diff --git a/content/docs/js-sdk/meta.json b/content/docs/js-sdk/meta.json index 36c6683..7df4646 100644 --- a/content/docs/js-sdk/meta.json +++ b/content/docs/js-sdk/meta.json @@ -4,6 +4,7 @@ "installation", "preparing-request", "generating-proof", - "verifying-proofs" + "verifying-proofs", + "sdk-methods" ] } diff --git a/content/docs/js-sdk/sdk-methods.mdx b/content/docs/js-sdk/sdk-methods.mdx new file mode 100644 index 0000000..5ce9544 --- /dev/null +++ b/content/docs/js-sdk/sdk-methods.mdx @@ -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` +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` | 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); +``` \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index bbfe115..80747e6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "reclaim-fumadocs", - "version": "0.0.0", + "version": "0.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "reclaim-fumadocs", - "version": "0.0.0", + "version": "0.1.0", "hasInstallScript": true, "dependencies": { "@theguild/remark-mermaid": "^0.2.0",