@reclaimprotocol/js-sdk 5.4.1 → 5.5.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/dist/index.d.ts CHANGED
@@ -686,7 +686,8 @@ declare enum SessionStatus {
686
686
  PROOF_SUBMISSION_FAILED = "PROOF_SUBMISSION_FAILED",
687
687
  ERROR_SUBMITTED = "ERROR_SUBMITTED",
688
688
  ERROR_SUBMISSION_FAILED = "ERROR_SUBMISSION_FAILED",
689
- PROOF_MANUAL_VERIFICATION_SUBMITED = "PROOF_MANUAL_VERIFICATION_SUBMITED"
689
+ PROOF_MANUAL_VERIFICATION_SUBMITED = "PROOF_MANUAL_VERIFICATION_SUBMITED",
690
+ SESSION_CANCELLED = "SESSION_CANCELLED"
690
691
  }
691
692
  type ProofPropertiesJSON = {
692
693
  applicationId: string;
@@ -1328,6 +1329,33 @@ declare class ReclaimProofRequest {
1328
1329
  * ```
1329
1330
  */
1330
1331
  closeEmbeddedFlow(): void;
1332
+ /**
1333
+ * Cancels an in-progress verification session.
1334
+ *
1335
+ * Use this when the user abandons the flow (e.g. navigates back) before a
1336
+ * proof is produced. It tears down all local session machinery — the status
1337
+ * polling interval, the 10-minute interval-ending timeout, and any portal UI
1338
+ * (modal / tab / embedded iframe) — and marks the session CANCELLED on the
1339
+ * backend.
1340
+ *
1341
+ * Marking the session CANCELLED is what prevents a stale, abandoned session
1342
+ * from later being reported as a failure: the portal's inactivity monitor
1343
+ * treats a cancelled session as a clean terminal state and will not emit a
1344
+ * connection-failure error to the cancel/error callback. Because that callback
1345
+ * URL is typically shared across sessions, suppressing it here stops an
1346
+ * abandoned session from contaminating the next one.
1347
+ *
1348
+ * `onSuccess` / `onError` are intentionally NOT invoked — cancellation is a
1349
+ * deliberate, silent teardown, not a verification outcome. Safe to call more
1350
+ * than once; a no-op when no session is active.
1351
+ *
1352
+ * @example
1353
+ * ```typescript
1354
+ * // e.g. in a React effect cleanup when the user navigates away
1355
+ * await proofRequest.cancelSession();
1356
+ * ```
1357
+ */
1358
+ cancelSession(): Promise<void>;
1331
1359
  /**
1332
1360
  * Exports the Reclaim proof verification request as a JSON string
1333
1361
  *
package/dist/index.js CHANGED
@@ -84,7 +84,7 @@ var require_package = __commonJS({
84
84
  "package.json"(exports2, module2) {
85
85
  module2.exports = {
86
86
  name: "@reclaimprotocol/js-sdk",
87
- version: "5.4.1",
87
+ version: "5.5.0",
88
88
  description: "Designed to request proofs from the Reclaim protocol and manage the flow of claims and witness interactions.",
89
89
  main: "dist/index.js",
90
90
  types: "dist/index.d.ts",
@@ -3311,6 +3311,49 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
3311
3311
  }
3312
3312
  this.clearInterval();
3313
3313
  }
3314
+ /**
3315
+ * Cancels an in-progress verification session.
3316
+ *
3317
+ * Use this when the user abandons the flow (e.g. navigates back) before a
3318
+ * proof is produced. It tears down all local session machinery — the status
3319
+ * polling interval, the 10-minute interval-ending timeout, and any portal UI
3320
+ * (modal / tab / embedded iframe) — and marks the session CANCELLED on the
3321
+ * backend.
3322
+ *
3323
+ * Marking the session CANCELLED is what prevents a stale, abandoned session
3324
+ * from later being reported as a failure: the portal's inactivity monitor
3325
+ * treats a cancelled session as a clean terminal state and will not emit a
3326
+ * connection-failure error to the cancel/error callback. Because that callback
3327
+ * URL is typically shared across sessions, suppressing it here stops an
3328
+ * abandoned session from contaminating the next one.
3329
+ *
3330
+ * `onSuccess` / `onError` are intentionally NOT invoked — cancellation is a
3331
+ * deliberate, silent teardown, not a verification outcome. Safe to call more
3332
+ * than once; a no-op when no session is active.
3333
+ *
3334
+ * @example
3335
+ * ```typescript
3336
+ * // e.g. in a React effect cleanup when the user navigates away
3337
+ * await proofRequest.cancelSession();
3338
+ * ```
3339
+ */
3340
+ cancelSession() {
3341
+ return __async(this, null, function* () {
3342
+ if (!this.sessionId) {
3343
+ return;
3344
+ }
3345
+ const sessionId = this.sessionId;
3346
+ logger11.info(`Cancelling session: ${sessionId}`);
3347
+ this.closeModal();
3348
+ this.closePortalTab();
3349
+ this.closeEmbeddedFlow();
3350
+ try {
3351
+ yield updateSession(sessionId, "SESSION_CANCELLED" /* SESSION_CANCELLED */);
3352
+ } catch (error) {
3353
+ logger11.info(`cancelSession: backend update failed for ${sessionId}: ${error}`);
3354
+ }
3355
+ });
3356
+ }
3314
3357
  /**
3315
3358
  * Exports the Reclaim proof verification request as a JSON string
3316
3359
  *