@reclaimprotocol/js-sdk 5.0.0-dev.5 → 5.1.0-dev.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
@@ -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
@@ -271,7 +271,7 @@ interface ResponseMatchSpec {
271
271
  */
272
272
  interface ResponseRedactionSpec {
273
273
  /** Optional hashing method applied to the redacted content (e.g., 'oprf') */
274
- hash?: "oprf" | "oprf-mpc" | undefined;
274
+ hash?: "oprf" | "oprf-mpc" | "oprf-raw" | undefined;
275
275
  /** JSON path for locating the value to redact */
276
276
  jsonPath: string;
277
277
  /** RegEx applied to correctly parse and extract/redact value */
@@ -280,6 +280,88 @@ interface ResponseRedactionSpec {
280
280
  xPath: string;
281
281
  }
282
282
 
283
+ /**
284
+ * Content validation configuration specifying essential required hashes and optional extra proofs.
285
+ * Used to explicitly validate that a generated proof matches the exact request structure expected.
286
+ */
287
+ type ValidationConfigWithHash = {
288
+ /**
289
+ * Array of computed hashes that must be satisfied by the proofs.
290
+ *
291
+ * An element can be a `HashRequirement` object or a string that is equivalent to
292
+ * a `{ value: '<hash>', required: true, multiple: false }` as `HashRequirement`.
293
+ */
294
+ hashes: (string | HashRequirement)[];
295
+ };
296
+ /**
297
+ * Content validation configuration specifying the provider id and version used in the verification session that generated the proofs.
298
+ * Used to explicitly validate that a generated proof matches the exact request structure expected.
299
+ *
300
+ * See also:
301
+ *
302
+ * * `ReclaimProofRequest.getProviderVersion()` - With a ReclaimProofRequest object, you can get the provider id & exact version of provider used in verification session.
303
+ */
304
+ interface ValidationConfigWithProviderInformation {
305
+ /**
306
+ * The identifier of provider used in verifications that resulted in a proof
307
+ *
308
+ * See also:
309
+ *
310
+ * * `ReclaimProofRequest.getProviderVersion()` - With a ReclaimProofRequest object, you can get the provider id & exact version of provider used in verification session.
311
+ **/
312
+ providerId: string;
313
+ /**
314
+ * The exact version of provider used in verifications that resulted in a proof.
315
+ *
316
+ * 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.
317
+ * Patches for the next provider version are also fetched and hashes from that spec is also be used to compare the hashes from proof.
318
+ *
319
+ * See also:
320
+ *
321
+ * * `ReclaimProofRequest.getProviderVersion()` - With a ReclaimProofRequest object, you can get the provider id & exact version of provider used in verification session.
322
+ **/
323
+ providerVersion?: string;
324
+ /**
325
+ * List of allowed pre-release tags.
326
+ * For example, if you are using AI, provide `['ai']` to allow AI patch versions of the provider.
327
+ */
328
+ allowedTags?: string[];
329
+ }
330
+ /**
331
+ * Legacy configuration to completely bypass content validation during verification.
332
+ * Warning: Using this poses a risk as it avoids strictly matching proof parameters to expected hashes.
333
+ */
334
+ interface ValidationConfigWithDisabledValidation {
335
+ dangerouslyDisableContentValidation: true;
336
+ }
337
+ /**
338
+ * Represents the configuration options applied when validating proof contents, allowing
339
+ * strict hash checking or intentionally skipping validation if flagged.
340
+ */
341
+ type ValidationConfig = ValidationConfigWithHash | ValidationConfigWithProviderInformation | ValidationConfigWithDisabledValidation;
342
+ /**
343
+ * Describes the comprehensive configuration required to initialize the proof verification process.
344
+ * Aligns with `ValidationConfig` options for verifying signatures alongside proof contents.
345
+ */
346
+ type VerificationConfig = ValidationConfig & {
347
+ /**
348
+ * If true, verifies TEE (Trusted Execution Environment) attestation included in the proof.
349
+ * When enabled, the result will include `isTeeVerified` and `isVerified` will be false
350
+ * if TEE data is missing or TEE verification fails.
351
+ */
352
+ verifyTEE?: boolean;
353
+ };
354
+ declare function assertValidProofsByHash(proofs: Proof[], config: ProviderHashRequirementsConfig): void;
355
+ declare function isHttpProviderClaimParams(claimParams: unknown): claimParams is HttpProviderClaimParams;
356
+ declare function getHttpProviderClaimParamsFromProof(proof: Proof): HttpProviderClaimParams;
357
+ /**
358
+ * Asserts that the proof is validated by checking the content of proof with with expectations from provider config or hash based on [options]
359
+ * @param proofs - The proofs to validate
360
+ * @param config - The validation config
361
+ * @throws {ProofNotValidatedError} When the proof is not validated
362
+ */
363
+ declare function assertValidateProof(proofs: Proof[], config: VerificationConfig): Promise<void>;
364
+
283
365
  type ClaimID = ProviderClaimData['identifier'];
284
366
  type ClaimInfo = Pick<ProviderClaimData, 'context' | 'provider' | 'parameters'>;
285
367
  type CompleteClaimData = Pick<ProviderClaimData, 'owner' | 'timestampS' | 'epoch'> & ClaimInfo;
@@ -308,6 +390,7 @@ type CreateVerificationRequest = {
308
390
  type StartSessionParams = {
309
391
  onSuccess: OnSuccess;
310
392
  onError: OnError;
393
+ verificationConfig?: VerificationConfig;
311
394
  };
312
395
  type OnSuccess = (proof?: Proof | Proof[]) => void;
313
396
  type OnError = (error: Error) => void;
@@ -614,88 +697,6 @@ type ProviderHashRequirementsResponse = {
614
697
  providerVersionString?: string;
615
698
  };
616
699
 
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
700
  /**
700
701
  * Verifies one or more Reclaim proofs by validating signatures, verifying witness information,
701
702
  * and performing content validation against the expected configuration.
@@ -1285,6 +1286,7 @@ declare class ReclaimProofRequest {
1285
1286
  *
1286
1287
  * @param onSuccess - Callback function invoked when proof is successfully submitted
1287
1288
  * @param onError - Callback function invoked when an error occurs during the session
1289
+ * @param verificationConfig - Optional configuration to customize proof verification
1288
1290
  * @returns Promise<void>
1289
1291
  * @throws {SessionNotStartedError} When session ID is not defined
1290
1292
  * @throws {ProofNotVerifiedError} When proof verification fails (default callback only)
@@ -1303,7 +1305,7 @@ declare class ReclaimProofRequest {
1303
1305
  * });
1304
1306
  * ```
1305
1307
  */
1306
- startSession({ onSuccess, onError }: StartSessionParams): Promise<void>;
1308
+ startSession({ onSuccess, onError, verificationConfig }: StartSessionParams): Promise<void>;
1307
1309
  /**
1308
1310
  * Closes the QR code modal if it is currently open
1309
1311
  *
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-dev.5",
87
+ version: "5.1.0-dev.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",
@@ -3719,6 +3719,7 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
3719
3719
  *
3720
3720
  * @param onSuccess - Callback function invoked when proof is successfully submitted
3721
3721
  * @param onError - Callback function invoked when an error occurs during the session
3722
+ * @param verificationConfig - Optional configuration to customize proof verification
3722
3723
  * @returns Promise<void>
3723
3724
  * @throws {SessionNotStartedError} When session ID is not defined
3724
3725
  * @throws {ProofNotVerifiedError} When proof verification fails (default callback only)
@@ -3738,7 +3739,7 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
3738
3739
  * ```
3739
3740
  */
3740
3741
  startSession(_0) {
3741
- return __async(this, arguments, function* ({ onSuccess, onError }) {
3742
+ return __async(this, arguments, function* ({ onSuccess, onError, verificationConfig }) {
3742
3743
  if (!this.sessionId) {
3743
3744
  const message = "Session can't be started due to undefined value of sessionId";
3744
3745
  logger10.info(message);
@@ -3772,10 +3773,10 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
3772
3773
  if (statusUrlResponse.session.proofs && statusUrlResponse.session.proofs.length > 0) {
3773
3774
  const proofs = statusUrlResponse.session.proofs;
3774
3775
  if (this.claimCreationType === "createClaim" /* STANDALONE */) {
3775
- const { isVerified: verified } = yield verifyProof(proofs, this.getProviderVersion());
3776
- if (!verified) {
3776
+ const result = yield verifyProof(proofs, verificationConfig != null ? verificationConfig : this.getProviderVersion());
3777
+ if (!result.isVerified) {
3777
3778
  logger10.info(`Proofs not verified: count=${proofs == null ? void 0 : proofs.length}`);
3778
- throw new ProofNotVerifiedError();
3779
+ throw new ProofNotVerifiedError(`Proofs not verified: count=${proofs == null ? void 0 : proofs.length}`, result.error);
3779
3780
  }
3780
3781
  }
3781
3782
  if (proofs.length === 1) {