diff --git a/content/docs/js-sdk/preparing-request.mdx b/content/docs/js-sdk/preparing-request.mdx index 6eb8d98..c3d9a52 100644 --- a/content/docs/js-sdk/preparing-request.mdx +++ b/content/docs/js-sdk/preparing-request.mdx @@ -98,7 +98,7 @@ If the user cancels the session midway or after error, Reclaim will send a POST ```json { - "type": "string", + "type": "string", // Name of the exception are in the table below "message": "string", [key: any]: any } @@ -108,12 +108,12 @@ If the user cancels the session midway or after error, Reclaim will send a POST Following are some exceptions that happen when user presses a button to cancel in UI or provider custom injection script causes a cancellation by calling `Reclaim.reportProviderError` in browser. -| Exception Name | Description | +| Exception Name (`type` field) | Description | |----------------|-------------| | `ReclaimVerificationAbortedException` | User cancelled the verification (e.g., tapped on cancel or verify another way button). | | `ReclaimVerificationProviderScriptException` | The provider script encountered an error (e.g., login failed, invalid account used). | -Other errors (such as network timeouts or internal exceptions) may also trigger this callback if **auto submit is enabled**. In any case, you can always find the complete list of errors by [fetching analytics events](./troubleshooting/analytics-event) for the session. +Other errors (such as network timeouts or internal exceptions) may also trigger this callback if **auto submit is enabled**. In any case, you can always find the complete list of errors by [fetching analytics events](../troubleshooting/analytics-event) for the session. ## Redirect after proof generation or cancellation diff --git a/content/docs/js-sdk/verifying-proofs.mdx b/content/docs/js-sdk/verifying-proofs.mdx index 02635fe..c8cad86 100644 --- a/content/docs/js-sdk/verifying-proofs.mdx +++ b/content/docs/js-sdk/verifying-proofs.mdx @@ -39,11 +39,59 @@ The data that was extracted from the webpage that the user logged in into, depen const { extractedParameters } = JSON.parse(proofs[i].context); ``` -## Sanity Check -`TODO` +## Sample implementation -## Sample implementation in Next.js -`TODO` +### Example in Next.js +``` +import { NextResponse } from 'next/server'; +import { verifyProof } from '@reclaimprotocol/js-sdk'; + +export async function POST(request) { + let providerId = 'example'; + + try { + // assuming that you set callback url with json set to true + const proofs = JSON.parse(await request.text()); + const isValid = await verifyProof(proofs); + if (!isValid) { + return NextResponse.json({ + success: false, + message: 'Proof verification failed' + }); + } + + // As best practice, you MUST validate proofs as per expectations and business requirements. + // This should happen on your backend. + // + // This must be done to make sure that + // this is the proof you expected. + // + // As an example, validation can be done by checking request url, headers, + // method, and all proven fields (aka extracted params), etc. + const isProofValid = await YourBackendUsingReclaim.validateProof(proofs); + + if (!isProofValid) { + // Do not use proof that failed your validation. + return NextResponse.json({ + success: false, + message: 'Proof validation failed' + }); + } + + // save or use proof from your backend + + return NextResponse.json({ + success: true, + message: 'Proof verification successful' + }); + } catch (e) { + return NextResponse.json({ + success: false, + message: 'Proof verification failed' + }); + } +} +``` # Structure of proofs ```json diff --git a/content/docs/troubleshooting/analytics-event.mdx b/content/docs/troubleshooting/analytics-event.mdx index 7148b61..0afece2 100644 --- a/content/docs/troubleshooting/analytics-event.mdx +++ b/content/docs/troubleshooting/analytics-event.mdx @@ -27,6 +27,12 @@ Response format Following is the typescript type definition of the response: ```typescript + +export interface AnalyticsEventResponse { + message: string; + data: AnalyticsLogEntry[]; +} + // ------------------------------------------------------------------ // 1. Enums & Unions // ------------------------------------------------------------------ @@ -154,24 +160,19 @@ export interface AnalyticsLogEntry { metadata: string; platform: string | "NA"; } - -export interface AnalyticsEventResponse { - message: string; - data: AnalyticsLogEntry[]; -} ``` ### Description of `LogType`s | Event Type | Level | Description | |------------|-------|-------------| -| `FETCHED_PROVIDERS` | INFO | The list of providers has been fetched. | -| `RECLAIM_EXCEPTION` | ERROR | An exception related to Reclaim protocol has occurred. | -| `LOGIN_DETECTED` | INFO | Login to the provider was detected. | -| `LOGIN_REQUIRED_DETECTED` | INFO | Detected that login is required. | +| `FETCHED_PROVIDERS` | INFO | The provider details have been fetched. | +| `RECLAIM_EXCEPTION` | ERROR | An error has occurred in the verification journey. | +| `LOGIN_DETECTED` | INFO | Login to the provider was detected (this can be inaccurate). | +| `LOGIN_REQUIRED_DETECTED` | INFO | Detected that login is required (this can be inaccurate). | | `USER_STARTED_VERIFICATION` | INFO | User has started the verification process. | | `USER_INIT_VERIFICATION` | INFO | User initialized the verification. | -| `PROOF_GENERATION_STARTED` | INFO | Proof generation has started. | +| `PROOF_GENERATION_STARTED` | INFO | First proof generation has started. | | `PROOF_GENERATION_RETRY` | INFO | Retrying proof generation. | | `PROOF_GENERATION_SUCCESS` | INFO | Proof generated successfully. | | `PROOF_GENERATION_FAILED` | ERROR | Proof generation failed. | @@ -179,7 +180,7 @@ export interface AnalyticsEventResponse { | `AI_PROOF_SUBMITTED` | INFO | AI proof has been submitted. | | `PROOF_SUBMISSION_FAILED` | ERROR | Proof submission failed. | | `PROOF_MANUAL_VERIFICATION_SUBMITED` | INFO | Manual verification proof submitted. | -| `ERROR_SUBMITTED` | INFO | Error details have been submitted. | +| `ERROR_SUBMITTED` | INFO | Error details (Right now happens on cancellation) have been submitted. | | `ERROR_SUBMISSION_FAILED` | ERROR | Failed to submit error details. | ### Description of `RECLAIM_EXCEPTION` in metadata diff --git a/content/docs/troubleshooting/enable-troubleshooting-mode.mdx b/content/docs/troubleshooting/enable-troubleshooting-mode.mdx index a4b98d0..e4b6f59 100644 --- a/content/docs/troubleshooting/enable-troubleshooting-mode.mdx +++ b/content/docs/troubleshooting/enable-troubleshooting-mode.mdx @@ -1,6 +1,6 @@ --- title: How to Enable Troubleshooting Mode -description: For debugging purposes only +description: For debugging purposes on Verifier App, and InApp SDK --- ## How to Enable Troubleshooting Mode