@reclaimprotocol/js-sdk 5.0.0 → 5.1.0-dev.1

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
@@ -138,7 +138,7 @@ Let's break down what's happening in this code:
138
138
 
139
139
  - Generate a request URL using `getRequestUrl()`. This URL is used to create the QR code.
140
140
  - Get the status URL using `getStatusUrl()`. This URL can be used to check the status of the claim process.
141
- - Start a session with `startSession()`, which sets up callbacks for successful and failed verifications.
141
+ - Start a session with `startSession()`, which sets up callbacks for successful and failed verifications, and allows you to pass an optional `verificationConfig` to customize proof verification.
142
142
 
143
143
  3. We display a QR code using the request URL. When a user scans this code, it starts the verification process.
144
144
 
package/dist/index.d.ts CHANGED
@@ -12,9 +12,11 @@ interface Proof {
12
12
  signatures: string[];
13
13
  witnesses: WitnessData[];
14
14
  extractedParameterValues: any;
15
- publicData?: {
16
- [key: string]: string;
17
- };
15
+ /**
16
+ * A JSON serializable object that is returned by the provider as additional data attached to proof.
17
+ * This data is not verified or validated.
18
+ */
19
+ publicData?: any;
18
20
  taskId?: number;
19
21
  teeAttestation?: TeeAttestation;
20
22
  }
@@ -271,7 +273,7 @@ interface ResponseMatchSpec {
271
273
  */
272
274
  interface ResponseRedactionSpec {
273
275
  /** Optional hashing method applied to the redacted content (e.g., 'oprf') */
274
- hash?: "oprf" | "oprf-mpc" | undefined;
276
+ hash?: "oprf" | "oprf-mpc" | "oprf-raw" | undefined;
275
277
  /** JSON path for locating the value to redact */
276
278
  jsonPath: string;
277
279
  /** RegEx applied to correctly parse and extract/redact value */
@@ -280,6 +282,88 @@ interface ResponseRedactionSpec {
280
282
  xPath: string;
281
283
  }
282
284
 
285
+ /**
286
+ * Content validation configuration specifying essential required hashes and optional extra proofs.
287
+ * Used to explicitly validate that a generated proof matches the exact request structure expected.
288
+ */
289
+ type ValidationConfigWithHash = {
290
+ /**
291
+ * Array of computed hashes that must be satisfied by the proofs.
292
+ *
293
+ * An element can be a `HashRequirement` object or a string that is equivalent to
294
+ * a `{ value: '<hash>', required: true, multiple: false }` as `HashRequirement`.
295
+ */
296
+ hashes: (string | HashRequirement)[];
297
+ };
298
+ /**
299
+ * Content validation configuration specifying the provider id and version used in the verification session that generated the proofs.
300
+ * Used to explicitly validate that a generated proof matches the exact request structure expected.
301
+ *
302
+ * See also:
303
+ *
304
+ * * `ReclaimProofRequest.getProviderVersion()` - With a ReclaimProofRequest object, you can get the provider id & exact version of provider used in verification session.
305
+ */
306
+ interface ValidationConfigWithProviderInformation {
307
+ /**
308
+ * The identifier of provider used in verifications that resulted in a proof
309
+ *
310
+ * See also:
311
+ *
312
+ * * `ReclaimProofRequest.getProviderVersion()` - With a ReclaimProofRequest object, you can get the provider id & exact version of provider used in verification session.
313
+ **/
314
+ providerId: string;
315
+ /**
316
+ * The exact version of provider used in verifications that resulted in a proof.
317
+ *
318
+ * This cannot be a version constaint or version expression. It can be undefined or left blank if proof must be validated with latest version of provider.
319
+ * Patches for the next provider version are also fetched and hashes from that spec is also be used to compare the hashes from proof.
320
+ *
321
+ * See also:
322
+ *
323
+ * * `ReclaimProofRequest.getProviderVersion()` - With a ReclaimProofRequest object, you can get the provider id & exact version of provider used in verification session.
324
+ **/
325
+ providerVersion?: string;
326
+ /**
327
+ * List of allowed pre-release tags.
328
+ * For example, if you are using AI, provide `['ai']` to allow AI patch versions of the provider.
329
+ */
330
+ allowedTags?: string[];
331
+ }
332
+ /**
333
+ * Legacy configuration to completely bypass content validation during verification.
334
+ * Warning: Using this poses a risk as it avoids strictly matching proof parameters to expected hashes.
335
+ */
336
+ interface ValidationConfigWithDisabledValidation {
337
+ dangerouslyDisableContentValidation: true;
338
+ }
339
+ /**
340
+ * Represents the configuration options applied when validating proof contents, allowing
341
+ * strict hash checking or intentionally skipping validation if flagged.
342
+ */
343
+ type ValidationConfig = ValidationConfigWithHash | ValidationConfigWithProviderInformation | ValidationConfigWithDisabledValidation;
344
+ /**
345
+ * Describes the comprehensive configuration required to initialize the proof verification process.
346
+ * Aligns with `ValidationConfig` options for verifying signatures alongside proof contents.
347
+ */
348
+ type VerificationConfig = ValidationConfig & {
349
+ /**
350
+ * If true, verifies TEE (Trusted Execution Environment) attestation included in the proof.
351
+ * When enabled, the result will include `isTeeVerified` and `isVerified` will be false
352
+ * if TEE data is missing or TEE verification fails.
353
+ */
354
+ verifyTEE?: boolean;
355
+ };
356
+ declare function assertValidProofsByHash(proofs: Proof[], config: ProviderHashRequirementsConfig): void;
357
+ declare function isHttpProviderClaimParams(claimParams: unknown): claimParams is HttpProviderClaimParams;
358
+ declare function getHttpProviderClaimParamsFromProof(proof: Proof): HttpProviderClaimParams;
359
+ /**
360
+ * Asserts that the proof is validated by checking the content of proof with with expectations from provider config or hash based on [options]
361
+ * @param proofs - The proofs to validate
362
+ * @param config - The validation config
363
+ * @throws {ProofNotValidatedError} When the proof is not validated
364
+ */
365
+ declare function assertValidateProof(proofs: Proof[], config: VerificationConfig): Promise<void>;
366
+
283
367
  type ClaimID = ProviderClaimData['identifier'];
284
368
  type ClaimInfo = Pick<ProviderClaimData, 'context' | 'provider' | 'parameters'>;
285
369
  type CompleteClaimData = Pick<ProviderClaimData, 'owner' | 'timestampS' | 'epoch'> & ClaimInfo;
@@ -306,10 +390,34 @@ type CreateVerificationRequest = {
306
390
  applicationSecret?: string;
307
391
  };
308
392
  type StartSessionParams = {
393
+ /**
394
+ * Callback function that is invoked when the session is successfully created.
395
+ *
396
+ * @param proofOrProofs - A single proof object or an array of proof objects. This can be empty when proofs are sent to callback.
397
+ */
309
398
  onSuccess: OnSuccess;
399
+ /**
400
+ * Callback function that is invoked when the session fails to be created.
401
+ *
402
+ * @param error - The error that caused the session to fail.
403
+ */
310
404
  onError: OnError;
405
+ /**
406
+ * Configuration for proof validation. Defaults to the provider id and version used in this session.
407
+ */
408
+ verificationConfig?: VerificationConfig;
311
409
  };
312
- type OnSuccess = (proof?: Proof | Proof[]) => void;
410
+ /**
411
+ * Callback function that is invoked when the session is successfully created.
412
+ *
413
+ * @param proofOrProofs - A single proof object or an array of proof objects. This can be empty when proofs are sent to callback.
414
+ */
415
+ type OnSuccess = (proofOrProofs: Proof | Proof[]) => void;
416
+ /**
417
+ * Callback function that is invoked when the session fails to be created.
418
+ *
419
+ * @param error - The error that caused the session to fail.
420
+ */
313
421
  type OnError = (error: Error) => void;
314
422
  type ProofRequestOptions = {
315
423
  /**
@@ -562,12 +670,21 @@ type TrustedData = {
562
670
  context: Record<string, unknown>;
563
671
  extractedParameters: Record<string, string>;
564
672
  };
565
- type VerifyProofResult = {
566
- isVerified: boolean;
673
+ type VerifyProofResultSuccess = {
674
+ isVerified: true;
567
675
  isTeeVerified?: boolean;
676
+ error: undefined;
568
677
  data: TrustedData[];
569
- error?: Error;
678
+ publicData: any[];
679
+ };
680
+ type VerifyProofResultFailure = {
681
+ isVerified: false;
682
+ isTeeVerified?: boolean;
683
+ error: Error;
684
+ data: [];
685
+ publicData: [];
570
686
  };
687
+ type VerifyProofResult = VerifyProofResultSuccess | VerifyProofResultFailure;
571
688
  type ProviderVersionConfig = {
572
689
  major?: number;
573
690
  minor?: number;
@@ -614,88 +731,6 @@ type ProviderHashRequirementsResponse = {
614
731
  providerVersionString?: string;
615
732
  };
616
733
 
617
- /**
618
- * Content validation configuration specifying essential required hashes and optional extra proofs.
619
- * Used to explicitly validate that a generated proof matches the exact request structure expected.
620
- */
621
- type ValidationConfigWithHash = {
622
- /**
623
- * Array of computed hashes that must be satisfied by the proofs.
624
- *
625
- * An element can be a `HashRequirement` object or a string that is equivalent to
626
- * a `{ value: '<hash>', required: true, multiple: false }` as `HashRequirement`.
627
- */
628
- hashes: (string | HashRequirement)[];
629
- };
630
- /**
631
- * Content validation configuration specifying the provider id and version used in the verification session that generated the proofs.
632
- * Used to explicitly validate that a generated proof matches the exact request structure expected.
633
- *
634
- * See also:
635
- *
636
- * * `ReclaimProofRequest.getProviderVersion()` - With a ReclaimProofRequest object, you can get the provider id & exact version of provider used in verification session.
637
- */
638
- interface ValidationConfigWithProviderInformation {
639
- /**
640
- * The identifier of provider used in verifications that resulted in a proof
641
- *
642
- * See also:
643
- *
644
- * * `ReclaimProofRequest.getProviderVersion()` - With a ReclaimProofRequest object, you can get the provider id & exact version of provider used in verification session.
645
- **/
646
- providerId: string;
647
- /**
648
- * The exact version of provider used in verifications that resulted in a proof.
649
- *
650
- * This cannot be a version constaint or version expression. It can be undefined or left blank if proof must be validated with latest version of provider.
651
- * Patches for the next provider version are also fetched and hashes from that spec is also be used to compare the hashes from proof.
652
- *
653
- * See also:
654
- *
655
- * * `ReclaimProofRequest.getProviderVersion()` - With a ReclaimProofRequest object, you can get the provider id & exact version of provider used in verification session.
656
- **/
657
- providerVersion?: string;
658
- /**
659
- * List of allowed pre-release tags.
660
- * For example, if you are using AI, provide `['ai']` to allow AI patch versions of the provider.
661
- */
662
- allowedTags?: string[];
663
- }
664
- /**
665
- * Legacy configuration to completely bypass content validation during verification.
666
- * Warning: Using this poses a risk as it avoids strictly matching proof parameters to expected hashes.
667
- */
668
- interface ValidationConfigWithDisabledValidation {
669
- dangerouslyDisableContentValidation: true;
670
- }
671
- /**
672
- * Represents the configuration options applied when validating proof contents, allowing
673
- * strict hash checking or intentionally skipping validation if flagged.
674
- */
675
- type ValidationConfig = ValidationConfigWithHash | ValidationConfigWithProviderInformation | ValidationConfigWithDisabledValidation;
676
- /**
677
- * Describes the comprehensive configuration required to initialize the proof verification process.
678
- * Aligns with `ValidationConfig` options for verifying signatures alongside proof contents.
679
- */
680
- type VerificationConfig = ValidationConfig & {
681
- /**
682
- * If true, verifies TEE (Trusted Execution Environment) attestation included in the proof.
683
- * When enabled, the result will include `isTeeVerified` and `isVerified` will be false
684
- * if TEE data is missing or TEE verification fails.
685
- */
686
- verifyTEE?: boolean;
687
- };
688
- declare function assertValidProofsByHash(proofs: Proof[], config: ProviderHashRequirementsConfig): void;
689
- declare function isHttpProviderClaimParams(claimParams: unknown): claimParams is HttpProviderClaimParams;
690
- declare function getHttpProviderClaimParamsFromProof(proof: Proof): HttpProviderClaimParams;
691
- /**
692
- * Asserts that the proof is validated by checking the content of proof with with expectations from provider config or hash based on [options]
693
- * @param proofs - The proofs to validate
694
- * @param config - The validation config
695
- * @throws {ProofNotValidatedError} When the proof is not validated
696
- */
697
- declare function assertValidateProof(proofs: Proof[], config: VerificationConfig): Promise<void>;
698
-
699
734
  /**
700
735
  * Verifies one or more Reclaim proofs by validating signatures, verifying witness information,
701
736
  * and performing content validation against the expected configuration.
@@ -756,6 +791,8 @@ declare function assertValidateProof(proofs: Proof[], config: VerificationConfig
756
791
  * ```
757
792
  */
758
793
  declare function verifyProof(proofOrProofs: Proof | Proof[], config: VerificationConfig): Promise<VerifyProofResult>;
794
+ declare function createTrustedDataFromProofData(proof: Proof): TrustedData;
795
+ declare function getPublicDataFromProofs(proofs: Proof[]): any[];
759
796
  /**
760
797
  * Transforms a Reclaim proof into a format suitable for on-chain verification
761
798
  *
@@ -1281,10 +1318,11 @@ declare class ReclaimProofRequest {
1281
1318
  * and the startSession function source for more details.
1282
1319
  *
1283
1320
  * > [!TIP]
1284
- * > **Best Practice:** When using `setAppCallbackUrl` and/or `setCancelCallbackUrl`, your backend receives the proof or cancellation details directly. We recommend your backend notifies the frontend (e.g. via WebSockets, SSE, or polling) to stop the verification process and handle the appropriate success/failure action. Do not rely completely on `startSession` callbacks on the frontend when using these backend callbacks.
1321
+ * > **Best Practice:** When using `setAppCallbackUrl` and/or `setCancelCallbackUrl`, your backend receives the proof or cancellation details directly. We recommend your backend notifies the frontend (e.g. via WebSockets, SSE, or polling) to stop the verification process and handle the appropriate success/failure action. When a callback is set, `onSuccess` callback provided to `startSession` will have an empty array as its argument.
1285
1322
  *
1286
1323
  * @param onSuccess - Callback function invoked when proof is successfully submitted
1287
1324
  * @param onError - Callback function invoked when an error occurs during the session
1325
+ * @param verificationConfig - Optional configuration to customize proof verification
1288
1326
  * @returns Promise<void>
1289
1327
  * @throws {SessionNotStartedError} When session ID is not defined
1290
1328
  * @throws {ProofNotVerifiedError} When proof verification fails (default callback only)
@@ -1303,7 +1341,7 @@ declare class ReclaimProofRequest {
1303
1341
  * });
1304
1342
  * ```
1305
1343
  */
1306
- startSession({ onSuccess, onError }: StartSessionParams): Promise<void>;
1344
+ startSession({ onSuccess, onError, verificationConfig }: StartSessionParams): Promise<void>;
1307
1345
  /**
1308
1346
  * Closes the QR code modal if it is currently open
1309
1347
  *
@@ -1480,4 +1518,4 @@ declare function isDesktopDevice(): boolean;
1480
1518
  */
1481
1519
  declare function clearDeviceCache(): void;
1482
1520
 
1483
- export { type Beacon, type BeaconState, type BodySniff, ClaimCreationType, type ClaimID, type ClaimInfo, type CompleteClaimData, type Context, type CreateVerificationRequest, DeviceType, type EmbeddedFlowHandle, type ExtensionMessage, type FlowHandle, type HashRequirement, type HashableHttpProviderClaimParams, type HttpFormEntry, type HttpProviderClaimParams, type HttpRedirectionMethod, type HttpRedirectionOptions, type InitSessionResponse, type InjectedRequestSpec, type InterceptorRequestSpec, type ModalOptions, type OnError, type OnSuccess, type Proof, type ProofPropertiesJSON, type ProofRequestOptions, type ProviderClaimData, type ProviderConfigResponse, type ProviderHashRequirementSpec, type ProviderHashRequirementsConfig, type ProviderHashRequirementsResponse, type ProviderVersionConfig, type ProviderVersionInfo, RECLAIM_EXTENSION_ACTIONS, type ReclaimFlowInitOptions, type ReclaimFlowLaunchOptions, ReclaimProofRequest, type ReclaimProviderConfig, type ReclaimProviderConfigWithRequestSpec, type RequestSpec, type ResponseMatchSpec, type ResponseRedactionSpec, type SerializableModalOptions, SessionStatus, type SignedClaim, type StartSessionParams, type StatusUrlResponse, type TeeAttestation, TeeVerificationError, type TemplateData, type TrustedData, type UpdateSessionResponse, type ValidationConfig, type ValidationConfigWithDisabledValidation, type ValidationConfigWithHash, type ValidationConfigWithProviderInformation, type VerificationConfig, type VerifyProofResult, type WitnessData, assertValidProofsByHash, assertValidateProof, assertVerifiedProof, clearDeviceCache, createLinkWithTemplateData, createSignDataForClaim, fetchProviderConfigs, fetchProviderHashRequirementsBy, fetchStatusUrl, generateSpecsFromRequestSpecTemplate, getAttestors, getDeviceType, getHttpProviderClaimParamsFromProof, getIdentifierFromClaimInfo, getMobileDeviceType, getProviderHashRequirementSpecFromProviderConfig, getProviderHashRequirementsFromSpec, getProviderParamsAsCanonicalizedString, getShortenedUrl, hashProofClaimParams, hashRequestSpec, initSession, isDesktopDevice, isHttpProviderClaimParams, isMobileDevice, recoverSignersOfSignedClaim, takePairsWhereValueIsArray, takeTemplateParametersFromProofs, transformForOnchain, updateSession, verifyProof, verifyTeeAttestation };
1521
+ export { type Beacon, type BeaconState, type BodySniff, ClaimCreationType, type ClaimID, type ClaimInfo, type CompleteClaimData, type Context, type CreateVerificationRequest, DeviceType, type EmbeddedFlowHandle, type ExtensionMessage, type FlowHandle, type HashRequirement, type HashableHttpProviderClaimParams, type HttpFormEntry, type HttpProviderClaimParams, type HttpRedirectionMethod, type HttpRedirectionOptions, type InitSessionResponse, type InjectedRequestSpec, type InterceptorRequestSpec, type ModalOptions, type OnError, type OnSuccess, type Proof, type ProofPropertiesJSON, type ProofRequestOptions, type ProviderClaimData, type ProviderConfigResponse, type ProviderHashRequirementSpec, type ProviderHashRequirementsConfig, type ProviderHashRequirementsResponse, type ProviderVersionConfig, type ProviderVersionInfo, RECLAIM_EXTENSION_ACTIONS, type ReclaimFlowInitOptions, type ReclaimFlowLaunchOptions, ReclaimProofRequest, type ReclaimProviderConfig, type ReclaimProviderConfigWithRequestSpec, type RequestSpec, type ResponseMatchSpec, type ResponseRedactionSpec, type SerializableModalOptions, SessionStatus, type SignedClaim, type StartSessionParams, type StatusUrlResponse, type TeeAttestation, TeeVerificationError, type TemplateData, type TrustedData, type UpdateSessionResponse, type ValidationConfig, type ValidationConfigWithDisabledValidation, type ValidationConfigWithHash, type ValidationConfigWithProviderInformation, type VerificationConfig, type VerifyProofResult, type VerifyProofResultFailure, type VerifyProofResultSuccess, type WitnessData, assertValidProofsByHash, assertValidateProof, assertVerifiedProof, clearDeviceCache, createLinkWithTemplateData, createSignDataForClaim, createTrustedDataFromProofData, fetchProviderConfigs, fetchProviderHashRequirementsBy, fetchStatusUrl, generateSpecsFromRequestSpecTemplate, getAttestors, getDeviceType, getHttpProviderClaimParamsFromProof, getIdentifierFromClaimInfo, getMobileDeviceType, getProviderHashRequirementSpecFromProviderConfig, getProviderHashRequirementsFromSpec, getProviderParamsAsCanonicalizedString, getPublicDataFromProofs, getShortenedUrl, hashProofClaimParams, hashRequestSpec, initSession, isDesktopDevice, isHttpProviderClaimParams, isMobileDevice, recoverSignersOfSignedClaim, takePairsWhereValueIsArray, takeTemplateParametersFromProofs, transformForOnchain, updateSession, verifyProof, verifyTeeAttestation };
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.0.0",
87
+ version: "5.1.0-dev.1",
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",
@@ -200,6 +200,7 @@ __export(index_exports, {
200
200
  clearDeviceCache: () => clearDeviceCache,
201
201
  createLinkWithTemplateData: () => createLinkWithTemplateData,
202
202
  createSignDataForClaim: () => createSignDataForClaim,
203
+ createTrustedDataFromProofData: () => createTrustedDataFromProofData,
203
204
  fetchProviderConfigs: () => fetchProviderConfigs,
204
205
  fetchProviderHashRequirementsBy: () => fetchProviderHashRequirementsBy,
205
206
  fetchStatusUrl: () => fetchStatusUrl,
@@ -212,6 +213,7 @@ __export(index_exports, {
212
213
  getProviderHashRequirementSpecFromProviderConfig: () => getProviderHashRequirementSpecFromProviderConfig,
213
214
  getProviderHashRequirementsFromSpec: () => getProviderHashRequirementsFromSpec,
214
215
  getProviderParamsAsCanonicalizedString: () => getProviderParamsAsCanonicalizedString,
216
+ getPublicDataFromProofs: () => getPublicDataFromProofs,
215
217
  getShortenedUrl: () => getShortenedUrl,
216
218
  hashProofClaimParams: () => hashProofClaimParams,
217
219
  hashRequestSpec: () => hashRequestSpec,
@@ -585,6 +587,16 @@ function validateModalOptions(modalOptions, functionName, paramPrefix = "") {
585
587
  ], functionName);
586
588
  }
587
589
  }
590
+ function hashObject(o) {
591
+ try {
592
+ const canonicalData = canonicalStringify(o);
593
+ const messageHash = import_ethers.ethers.keccak256(new TextEncoder().encode(canonicalData));
594
+ return messageHash;
595
+ } catch (e) {
596
+ logger3.info(`Failed to hash object: ${e.message}`);
597
+ throw new Error(`Failed to hash object: ${e.message}`);
598
+ }
599
+ }
588
600
 
589
601
  // src/utils/fetch.ts
590
602
  var import_fetch_retry = __toESM(require("fetch-retry"));
@@ -2350,49 +2362,69 @@ function verifyProof(proofOrProofs, config) {
2350
2362
  yield assertVerifiedProof(proof, attestors);
2351
2363
  }
2352
2364
  yield assertValidateProof(proofs, config);
2353
- const result = {
2354
- isVerified: true,
2355
- data: proofs.map(extractProofData)
2356
- };
2365
+ let isTeeVerified = void 0;
2357
2366
  if (config.verifyTEE) {
2358
2367
  const hasTeeData = proofs.every((proof) => proof.teeAttestation || JSON.parse(proof.claimData.context).attestationNonce);
2359
2368
  if (!hasTeeData) {
2360
2369
  const teeError = new TeeVerificationError("TEE verification requested but one or more proofs are missing TEE attestation data");
2361
2370
  logger10.error(teeError.message);
2362
- result.isTeeVerified = false;
2363
- result.isVerified = false;
2364
- result.error = teeError;
2365
- return result;
2371
+ const errorResult = {
2372
+ isVerified: false,
2373
+ isTeeVerified: false,
2374
+ error: teeError,
2375
+ data: [],
2376
+ publicData: []
2377
+ };
2378
+ return errorResult;
2366
2379
  }
2367
2380
  try {
2368
2381
  const teeResults = yield Promise.all(proofs.map((proof) => verifyTeeAttestation(proof)));
2369
- result.isTeeVerified = teeResults.every((r) => r === true);
2370
- if (!result.isTeeVerified) {
2382
+ isTeeVerified = teeResults.every((r) => r === true);
2383
+ if (!isTeeVerified) {
2371
2384
  const teeError = new TeeVerificationError("TEE attestation verification failed for one or more proofs");
2372
2385
  logger10.error(teeError.message);
2373
- result.isVerified = false;
2374
- result.error = teeError;
2386
+ const errorResult = {
2387
+ isVerified: false,
2388
+ isTeeVerified: false,
2389
+ error: teeError,
2390
+ data: [],
2391
+ publicData: []
2392
+ };
2393
+ return errorResult;
2375
2394
  }
2376
2395
  } catch (error) {
2377
2396
  const teeError = new TeeVerificationError("Error verifying TEE attestation", error);
2378
2397
  logger10.error(teeError.message);
2379
- result.isTeeVerified = false;
2380
- result.isVerified = false;
2381
- result.error = teeError;
2398
+ const errorResult = {
2399
+ isVerified: false,
2400
+ isTeeVerified: false,
2401
+ error: teeError,
2402
+ data: [],
2403
+ publicData: []
2404
+ };
2405
+ return errorResult;
2382
2406
  }
2383
2407
  }
2408
+ const result = {
2409
+ isVerified: true,
2410
+ isTeeVerified,
2411
+ data: proofs.map(createTrustedDataFromProofData),
2412
+ publicData: getPublicDataFromProofs(proofs),
2413
+ error: void 0
2414
+ };
2384
2415
  return result;
2385
2416
  } catch (error) {
2386
2417
  logger10.error("Error in validating proof:", error);
2387
2418
  return {
2388
2419
  isVerified: false,
2420
+ error: error instanceof Error ? error : new Error(String(error)),
2389
2421
  data: [],
2390
- error: error instanceof Error ? error : new Error(String(error))
2422
+ publicData: []
2391
2423
  };
2392
2424
  }
2393
2425
  });
2394
2426
  }
2395
- function extractProofData(proof) {
2427
+ function createTrustedDataFromProofData(proof) {
2396
2428
  try {
2397
2429
  const context = JSON.parse(proof.claimData.context);
2398
2430
  const _a = context, { extractedParameters } = _a, rest = __objRest(_a, ["extractedParameters"]);
@@ -2407,6 +2439,26 @@ function extractProofData(proof) {
2407
2439
  };
2408
2440
  }
2409
2441
  }
2442
+ function getPublicDataFromProofs(proofs) {
2443
+ const data = [];
2444
+ const seenData = /* @__PURE__ */ new Set();
2445
+ for (const proof of proofs) {
2446
+ const publicData = proof.publicData;
2447
+ if (publicData === null || publicData === void 0) {
2448
+ continue;
2449
+ }
2450
+ try {
2451
+ const hash = hashObject(publicData);
2452
+ if (seenData.has(hash)) {
2453
+ continue;
2454
+ }
2455
+ seenData.add(hash);
2456
+ } catch (_) {
2457
+ }
2458
+ data.push(publicData);
2459
+ }
2460
+ return data;
2461
+ }
2410
2462
  function transformForOnchain(proof) {
2411
2463
  const claimInfoBuilder = /* @__PURE__ */ new Map([
2412
2464
  ["context", proof.claimData.context],
@@ -3715,10 +3767,11 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
3715
3767
  * and the startSession function source for more details.
3716
3768
  *
3717
3769
  * > [!TIP]
3718
- * > **Best Practice:** When using `setAppCallbackUrl` and/or `setCancelCallbackUrl`, your backend receives the proof or cancellation details directly. We recommend your backend notifies the frontend (e.g. via WebSockets, SSE, or polling) to stop the verification process and handle the appropriate success/failure action. Do not rely completely on `startSession` callbacks on the frontend when using these backend callbacks.
3770
+ * > **Best Practice:** When using `setAppCallbackUrl` and/or `setCancelCallbackUrl`, your backend receives the proof or cancellation details directly. We recommend your backend notifies the frontend (e.g. via WebSockets, SSE, or polling) to stop the verification process and handle the appropriate success/failure action. When a callback is set, `onSuccess` callback provided to `startSession` will have an empty array as its argument.
3719
3771
  *
3720
3772
  * @param onSuccess - Callback function invoked when proof is successfully submitted
3721
3773
  * @param onError - Callback function invoked when an error occurs during the session
3774
+ * @param verificationConfig - Optional configuration to customize proof verification
3722
3775
  * @returns Promise<void>
3723
3776
  * @throws {SessionNotStartedError} When session ID is not defined
3724
3777
  * @throws {ProofNotVerifiedError} When proof verification fails (default callback only)
@@ -3738,7 +3791,7 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
3738
3791
  * ```
3739
3792
  */
3740
3793
  startSession(_0) {
3741
- return __async(this, arguments, function* ({ onSuccess, onError }) {
3794
+ return __async(this, arguments, function* ({ onSuccess, onError, verificationConfig }) {
3742
3795
  if (!this.sessionId) {
3743
3796
  const message = "Session can't be started due to undefined value of sessionId";
3744
3797
  logger10.info(message);
@@ -3772,10 +3825,10 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
3772
3825
  if (statusUrlResponse.session.proofs && statusUrlResponse.session.proofs.length > 0) {
3773
3826
  const proofs = statusUrlResponse.session.proofs;
3774
3827
  if (this.claimCreationType === "createClaim" /* STANDALONE */) {
3775
- const { isVerified: verified } = yield verifyProof(proofs, this.getProviderVersion());
3776
- if (!verified) {
3828
+ const result = yield verifyProof(proofs, verificationConfig != null ? verificationConfig : this.getProviderVersion());
3829
+ if (!result.isVerified) {
3777
3830
  logger10.info(`Proofs not verified: count=${proofs == null ? void 0 : proofs.length}`);
3778
- throw new ProofNotVerifiedError();
3831
+ throw new ProofNotVerifiedError(`Proofs not verified: count=${proofs == null ? void 0 : proofs.length}`, result.error);
3779
3832
  }
3780
3833
  }
3781
3834
  if (proofs.length === 1) {
@@ -3860,6 +3913,7 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
3860
3913
  clearDeviceCache,
3861
3914
  createLinkWithTemplateData,
3862
3915
  createSignDataForClaim,
3916
+ createTrustedDataFromProofData,
3863
3917
  fetchProviderConfigs,
3864
3918
  fetchProviderHashRequirementsBy,
3865
3919
  fetchStatusUrl,
@@ -3872,6 +3926,7 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
3872
3926
  getProviderHashRequirementSpecFromProviderConfig,
3873
3927
  getProviderHashRequirementsFromSpec,
3874
3928
  getProviderParamsAsCanonicalizedString,
3929
+ getPublicDataFromProofs,
3875
3930
  getShortenedUrl,
3876
3931
  hashProofClaimParams,
3877
3932
  hashRequestSpec,