Skip to content
Merged
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
6 changes: 3 additions & 3 deletions content/docs/js-sdk/preparing-request.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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

Expand Down
56 changes: 52 additions & 4 deletions content/docs/js-sdk/verifying-proofs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 12 additions & 11 deletions content/docs/troubleshooting/analytics-event.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
// ------------------------------------------------------------------
Expand Down Expand Up @@ -154,32 +160,27 @@ 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. |
| `PROOF_SUBMITTED` | INFO | The proof has been successfully submitted. |
| `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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down