@reclaimprotocol/js-sdk 4.7.1 → 4.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -314,7 +314,13 @@ The Reclaim SDK offers several advanced options to customize your integration:
314
314
  reclaimProofRequest.setRedirectUrl("https://example.com/redirect");
315
315
  ```
316
316
 
317
- 4. **Custom Callback URL**:
317
+ 4. **Custom Error Redirect URL**:
318
+ Set a custom URL to redirect users on an error which aborts the verification process:
319
+ ```javascript
320
+ reclaimProofRequest.setErrorRedirectUrl("https://example.com/error-redirect");
321
+ ```
322
+
323
+ 5. **Custom Callback URL**:
318
324
  Set a custom callback URL for your app which allows you to receive proofs and status updates on your callback URL:
319
325
  Pass in `jsonProofResponse: true` to receive the proof in JSON format: By default, the proof is returned as a url encoded string.
320
326
 
@@ -322,7 +328,14 @@ The Reclaim SDK offers several advanced options to customize your integration:
322
328
  reclaimProofRequest.setAppCallbackUrl("https://example.com/callback", true);
323
329
  ```
324
330
 
325
- 5. **Modal Customization for Desktop Users**:
331
+ 6. **Custom Error Callback URL**:
332
+ Set a custom error callback URL for your app which allows you to receive errors and status updates on your error callback URL:
333
+
334
+ ```javascript
335
+ reclaimProofRequest.setErrorCallbackUrl("https://example.com/error-callback");
336
+ ```
337
+
338
+ 7. **Modal Customization for Desktop Users**:
326
339
  Customize the appearance and behavior of the QR code modal shown to desktop users:
327
340
 
328
341
  ```javascript
@@ -334,7 +347,7 @@ The Reclaim SDK offers several advanced options to customize your integration:
334
347
  });
335
348
  ```
336
349
 
337
- 6. **Browser Extension Configuration**:
350
+ 8. **Browser Extension Configuration**:
338
351
  Configure browser extension behavior and detection:
339
352
 
340
353
  ```javascript
@@ -353,7 +366,7 @@ The Reclaim SDK offers several advanced options to customize your integration:
353
366
  });
354
367
  ```
355
368
 
356
- 7. **Custom Share Page and App Clip URLs**:
369
+ 9. **Custom Share Page and App Clip URLs**:
357
370
  You can customize the share page and app clip URLs for your app:
358
371
 
359
372
  ```javascript
@@ -364,7 +377,7 @@ const proofRequest = await ReclaimProofRequest.init(APP_ID, APP_SECRET, PROVIDER
364
377
  });
365
378
  ```
366
379
 
367
- 8. **Platform-Specific Flow Control**:
380
+ 10. **Platform-Specific Flow Control**:
368
381
  The `triggerReclaimFlow()` method provides intelligent platform detection, but you can still use traditional methods for custom flows:
369
382
 
370
383
  ```javascript
@@ -377,7 +390,7 @@ const proofRequest = await ReclaimProofRequest.init(APP_ID, APP_SECRET, PROVIDER
377
390
  // Automatically handles platform detection and optimal user experience
378
391
  ```
379
392
 
380
- 9. **Exporting and Importing SDK Configuration**:
393
+ 11. **Exporting and Importing SDK Configuration**:
381
394
  You can export the entire Reclaim SDK configuration as a JSON string and use it to initialize the SDK with the same configuration on a different service or backend:
382
395
 
383
396
  ```javascript
@@ -394,7 +407,7 @@ const proofRequest = await ReclaimProofRequest.init(APP_ID, APP_SECRET, PROVIDER
394
407
 
395
408
  This allows you to generate request URLs and other details from your backend or a different service while maintaining the same configuration.
396
409
 
397
- 10. **Utility Methods**:
410
+ 12. **Utility Methods**:
398
411
  Additional utility methods for managing your proof requests:
399
412
 
400
413
  ```javascript
@@ -403,7 +416,7 @@ const sessionId = reclaimProofRequest.getSessionId();
403
416
  console.log("Current session ID:", sessionId);
404
417
  ```
405
418
 
406
- 11. **Control auto-submission of proofs**:
419
+ 13. **Control auto-submission of proofs**:
407
420
 
408
421
  Whether the verification client should automatically submit necessary proofs once they are generated. If set to false, the user must manually click a button to submit.
409
422
  Defaults to true.
@@ -415,7 +428,7 @@ const proofRequest = await ReclaimProofRequest.init(APP_ID, APP_SECRET, PROVIDER
415
428
  });
416
429
  ```
417
430
 
418
- 12. **Add additional metadata for verification client**:
431
+ 14. **Add additional metadata for verification client**:
419
432
 
420
433
  Additional metadata to pass to the verification client. This can be used to customize the client experience, such as customizing themes or UI by passing context-specific information.
421
434
  The keys and values must be strings. For most clients, this is not required and goes unused.
@@ -431,11 +444,16 @@ const proofRequest = await ReclaimProofRequest.init(APP_ID, APP_SECRET, PROVIDER
431
444
 
432
445
  ## Handling Proofs on Your Backend
433
446
 
434
- For production applications, it's recommended to handle proofs on your backend:
447
+ For production applications, it's recommended to handle proofs, and errors on your backend:
435
448
 
436
449
  1. Set a callback URL:
437
450
  ```javascript
438
- reclaimProofRequest.setCallbackUrl("https://your-backend.com/receive-proofs");
451
+ reclaimProofRequest.setAppCallbackUrl("https://your-backend.com/receive-proofs");
452
+ ```
453
+
454
+ 2. Set a error callback URL:
455
+ ```javascript
456
+ reclaimProofRequest.setErrorCallbackUrl("https://your-backend.com/receive-errors");
439
457
  ```
440
458
 
441
459
  These options allow you to securely process proofs and status updates on your server.
@@ -517,6 +535,7 @@ try {
517
535
  - `ProviderFailedError`: Provider failed to generate proof
518
536
  - `SessionNotStartedError`: Session could not be started
519
537
  - `ProofSubmissionFailedError`: Proof submission to callback failed
538
+ - `ErrorDuringVerificationError`: An abort error during verification which was caused by the user aborting the verification process or provider's JS script raising a validation error
520
539
 
521
540
  ## Next Steps
522
541
 
package/dist/index.js CHANGED
@@ -72,7 +72,7 @@ var require_package = __commonJS({
72
72
  "package.json"(exports2, module2) {
73
73
  module2.exports = {
74
74
  name: "@reclaimprotocol/js-sdk",
75
- version: "4.7.1",
75
+ version: "4.7.0",
76
76
  description: "Designed to request proofs from the Reclaim protocol and manage the flow of claims and witness interactions.",
77
77
  main: "dist/index.js",
78
78
  types: "dist/index.d.ts",
@@ -2768,7 +2768,7 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
2768
2768
  logger7.info("Starting session");
2769
2769
  const sessionUpdatePollingInterval = 3 * 1e3;
2770
2770
  const interval = setInterval(() => __async(this, null, function* () {
2771
- var _a, _b, _c, _d;
2771
+ var _a, _b, _c;
2772
2772
  try {
2773
2773
  const statusUrlResponse = yield fetchStatusUrl(this.sessionId);
2774
2774
  if (!statusUrlResponse.session) return;
@@ -2789,7 +2789,7 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
2789
2789
  if (statusUrlResponse.session.proofs && statusUrlResponse.session.proofs.length > 0) {
2790
2790
  const proofs = statusUrlResponse.session.proofs;
2791
2791
  if (this.claimCreationType === "createClaim" /* STANDALONE */) {
2792
- const verified = yield verifyProof(proofs, (_a = this.options) == null ? void 0 : _a.acceptAiProviders);
2792
+ const verified = yield verifyProof(proofs);
2793
2793
  if (!verified) {
2794
2794
  logger7.info(`Proofs not verified: ${JSON.stringify(proofs)}`);
2795
2795
  throw new ProofNotVerifiedError();
@@ -2801,7 +2801,7 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
2801
2801
  onSuccess(proofs);
2802
2802
  }
2803
2803
  this.clearInterval();
2804
- (_b = this.modal) == null ? void 0 : _b.close();
2804
+ (_a = this.modal) == null ? void 0 : _a.close();
2805
2805
  }
2806
2806
  } else {
2807
2807
  if (statusUrlResponse.session.statusV2 === "PROOF_SUBMISSION_FAILED" /* PROOF_SUBMISSION_FAILED */) {
@@ -2812,7 +2812,7 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
2812
2812
  onSuccess("Proof submitted successfully to the custom callback url");
2813
2813
  }
2814
2814
  this.clearInterval();
2815
- (_c = this.modal) == null ? void 0 : _c.close();
2815
+ (_b = this.modal) == null ? void 0 : _b.close();
2816
2816
  }
2817
2817
  }
2818
2818
  } catch (e) {
@@ -2820,7 +2820,7 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
2820
2820
  onError(e);
2821
2821
  }
2822
2822
  this.clearInterval();
2823
- (_d = this.modal) == null ? void 0 : _d.close();
2823
+ (_c = this.modal) == null ? void 0 : _c.close();
2824
2824
  }
2825
2825
  }), sessionUpdatePollingInterval);
2826
2826
  this.intervals.set(this.sessionId, interval);