-
Notifications
You must be signed in to change notification settings - Fork 13
docs(js-sdk): add comprehensive sdk methods reference for issue #15 #106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
CoolatMax
wants to merge
2
commits into
reclaimprotocol:main
Choose a base branch
from
CoolatMax:sdkdocs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| "installation", | ||
| "preparing-request", | ||
| "generating-proof", | ||
| "verifying-proofs" | ||
| "verifying-proofs", | ||
| "sdk-methods" | ||
| ] | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| ``` | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.