@0xpolygonid/js-sdk 1.8.2 → 1.9.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.
Files changed (54) hide show
  1. package/dist/browser/esm/index.js +240 -124
  2. package/dist/browser/esm/index.js.map +1 -1
  3. package/dist/browser/umd/index.js +243 -124
  4. package/dist/browser/umd/index.js.map +1 -1
  5. package/dist/node/cjs/circuits/atomic-query-v3-on-chain.js +8 -25
  6. package/dist/node/cjs/circuits/atomic-query-v3.js +6 -5
  7. package/dist/node/cjs/circuits/common.js +1 -1
  8. package/dist/node/cjs/circuits/comparer.js +24 -3
  9. package/dist/node/cjs/circuits/linked-multi-query.js +6 -17
  10. package/dist/node/cjs/circuits/models.js +47 -3
  11. package/dist/node/cjs/iden3comm/handlers/auth.js +5 -3
  12. package/dist/node/cjs/iden3comm/handlers/contract-request.js +3 -11
  13. package/dist/node/cjs/proof/common.js +11 -5
  14. package/dist/node/cjs/proof/provers/inputs-generator.js +6 -10
  15. package/dist/node/cjs/proof/verifiers/index.js +1 -0
  16. package/dist/node/cjs/proof/verifiers/pub-signals-verifier.js +37 -22
  17. package/dist/node/cjs/proof/verifiers/query-hash.js +40 -0
  18. package/dist/node/cjs/proof/verifiers/query.js +24 -16
  19. package/dist/node/cjs/schema-processor/utils.js +2 -2
  20. package/dist/node/cjs/storage/filters/jsonQuery.js +28 -2
  21. package/dist/node/cjs/verifiable/core-utils.js +3 -3
  22. package/dist/node/cjs/verifiable/credential.js +1 -1
  23. package/dist/node/esm/circuits/atomic-query-v3-on-chain.js +9 -26
  24. package/dist/node/esm/circuits/atomic-query-v3.js +7 -6
  25. package/dist/node/esm/circuits/common.js +1 -1
  26. package/dist/node/esm/circuits/comparer.js +24 -3
  27. package/dist/node/esm/circuits/linked-multi-query.js +7 -18
  28. package/dist/node/esm/circuits/models.js +48 -4
  29. package/dist/node/esm/iden3comm/handlers/auth.js +5 -3
  30. package/dist/node/esm/iden3comm/handlers/contract-request.js +4 -12
  31. package/dist/node/esm/proof/common.js +12 -6
  32. package/dist/node/esm/proof/provers/inputs-generator.js +7 -11
  33. package/dist/node/esm/proof/verifiers/index.js +1 -0
  34. package/dist/node/esm/proof/verifiers/pub-signals-verifier.js +41 -26
  35. package/dist/node/esm/proof/verifiers/query-hash.js +35 -0
  36. package/dist/node/esm/proof/verifiers/query.js +23 -16
  37. package/dist/node/esm/schema-processor/utils.js +3 -3
  38. package/dist/node/esm/storage/filters/jsonQuery.js +28 -2
  39. package/dist/node/esm/verifiable/core-utils.js +1 -1
  40. package/dist/node/esm/verifiable/credential.js +2 -2
  41. package/dist/types/circuits/atomic-query-v3-on-chain.d.ts +4 -8
  42. package/dist/types/circuits/atomic-query-v3.d.ts +2 -2
  43. package/dist/types/circuits/common.d.ts +1 -1
  44. package/dist/types/circuits/comparer.d.ts +4 -0
  45. package/dist/types/circuits/linked-multi-query.d.ts +0 -1
  46. package/dist/types/circuits/models.d.ts +7 -4
  47. package/dist/types/iden3comm/types/protocol/contract-request.d.ts +1 -0
  48. package/dist/types/proof/verifiers/index.d.ts +1 -0
  49. package/dist/types/proof/verifiers/query-hash.d.ts +3 -0
  50. package/dist/types/proof/verifiers/query.d.ts +1 -0
  51. package/dist/types/schema-processor/utils.d.ts +1 -1
  52. package/dist/types/storage/filters/jsonQuery.d.ts +1 -1
  53. package/dist/types/verifiable/core-utils.d.ts +1 -1
  54. package/package.json +1 -1
@@ -27439,7 +27439,7 @@ var PolygonIdSdk = (function (exports) {
27439
27439
  * @param {Uint8Array} schemaId
27440
27440
  * @returns {*} {SchemaHash}
27441
27441
  */
27442
- const caclulateCoreSchemaHash = (schemaId) => {
27442
+ const calculateCoreSchemaHash = (schemaId) => {
27443
27443
  const sHash = b$5.decodeString(sha3Exports.keccak256(schemaId));
27444
27444
  return new B$3(sHash.slice(sHash.length - 16, sHash.length));
27445
27445
  };
@@ -27554,7 +27554,7 @@ var PolygonIdSdk = (function (exports) {
27554
27554
  if (!nonMerklized && opts.merklizedRootPosition === exports.MerklizedRootPosition.None) {
27555
27555
  opts.merklizedRootPosition = exports.MerklizedRootPosition.Index;
27556
27556
  }
27557
- const schemaHash = caclulateCoreSchemaHash(byteEncoder.encode(credentialType));
27557
+ const schemaHash = calculateCoreSchemaHash(byteEncoder.encode(credentialType));
27558
27558
  const claim = v$3.newClaim(schemaHash, C$3.withIndexDataBytes(slots.indexA, slots.indexB), C$3.withValueDataBytes(slots.valueA, slots.valueB), C$3.withRevocationNonce(BigInt(opts.revNonce)), C$3.withVersion(opts.version));
27559
27559
  if (opts.updatable) {
27560
27560
  claim.setFlagUpdatable(opts.updatable);
@@ -28486,14 +28486,14 @@ var PolygonIdSdk = (function (exports) {
28486
28486
  }
28487
28487
  /**
28488
28488
  *
28489
- * @deprecated The method should not be used. Use caclulateCoreSchemaHash from verifiable.
28489
+ * @deprecated The method should not be used. Use calculateCoreSchemaHash from verifiable.
28490
28490
  * Calculates schema hash
28491
28491
  *
28492
28492
  * @param {Uint8Array} schemaId
28493
28493
  * @returns {*} {SchemaHash}
28494
28494
  */
28495
28495
  const createSchemaHash = (schemaId) => {
28496
- return caclulateCoreSchemaHash(schemaId);
28496
+ return calculateCoreSchemaHash(schemaId);
28497
28497
  };
28498
28498
  /**
28499
28499
  *
@@ -55824,7 +55824,7 @@ var PolygonIdSdk = (function (exports) {
55824
55824
  * @returns number
55825
55825
  */
55826
55826
  getValueArrSize() {
55827
- return this.valueArraySize ? this.valueArraySize : defaultValueArraySize;
55827
+ return this.maxValueArraySize ? this.maxValueArraySize : defaultValueArraySize;
55828
55828
  }
55829
55829
  /**
55830
55830
  * getMTLevelOnChain return level on chain for given circuit
@@ -55992,6 +55992,8 @@ var PolygonIdSdk = (function (exports) {
55992
55992
  Operators[Operators["LTE"] = 7] = "LTE";
55993
55993
  Operators[Operators["GTE"] = 8] = "GTE";
55994
55994
  Operators[Operators["BETWEEN"] = 9] = "BETWEEN";
55995
+ Operators[Operators["NONBETWEEN"] = 10] = "NONBETWEEN";
55996
+ Operators[Operators["EXISTS"] = 11] = "EXISTS";
55995
55997
  Operators[Operators["SD"] = 16] = "SD";
55996
55998
  Operators[Operators["NULLIFY"] = 17] = "NULLIFY";
55997
55999
  })(exports.Operators || (exports.Operators = {}));
@@ -56007,12 +56009,17 @@ var PolygonIdSdk = (function (exports) {
56007
56009
  $lte: exports.Operators.LTE,
56008
56010
  $gte: exports.Operators.GTE,
56009
56011
  $between: exports.Operators.BETWEEN,
56012
+ $nonbetween: exports.Operators.NONBETWEEN,
56013
+ $exists: exports.Operators.EXISTS,
56010
56014
  $sd: exports.Operators.SD,
56011
56015
  $nullify: exports.Operators.NULLIFY
56012
56016
  };
56013
56017
  const allOperations$1 = Object.values(QueryOperators);
56014
56018
  const availableTypesOperators = new Map([
56015
- [exports.XSDNS.Boolean, [QueryOperators.$eq, QueryOperators.$ne, QueryOperators.$sd]],
56019
+ [
56020
+ exports.XSDNS.Boolean,
56021
+ [QueryOperators.$eq, QueryOperators.$ne, QueryOperators.$sd, QueryOperators.$exists]
56022
+ ],
56016
56023
  [exports.XSDNS.Integer, allOperations$1],
56017
56024
  [exports.XSDNS.NonNegativeInteger, allOperations$1],
56018
56025
  [exports.XSDNS.PositiveInteger, allOperations$1],
@@ -56023,7 +56030,8 @@ var PolygonIdSdk = (function (exports) {
56023
56030
  QueryOperators.$ne,
56024
56031
  QueryOperators.$in,
56025
56032
  QueryOperators.$nin,
56026
- QueryOperators.$sd
56033
+ QueryOperators.$sd,
56034
+ QueryOperators.$exists
56027
56035
  ]
56028
56036
  ],
56029
56037
  [
@@ -56033,7 +56041,8 @@ var PolygonIdSdk = (function (exports) {
56033
56041
  QueryOperators.$ne,
56034
56042
  QueryOperators.$in,
56035
56043
  QueryOperators.$nin,
56036
- QueryOperators.$sd
56044
+ QueryOperators.$sd,
56045
+ QueryOperators.$exists
56037
56046
  ]
56038
56047
  ],
56039
56048
  [exports.XSDNS.DateTime, allOperations$1]
@@ -56124,6 +56133,16 @@ var PolygonIdSdk = (function (exports) {
56124
56133
  return this.y.includes(this.x);
56125
56134
  case exports.Operators.NIN:
56126
56135
  return !this.y.includes(this.x);
56136
+ case exports.Operators.BETWEEN:
56137
+ if (this.y.length !== 2) {
56138
+ return false;
56139
+ }
56140
+ return this.x >= this.y[0] && this.x <= this.y[1];
56141
+ case exports.Operators.NONBETWEEN:
56142
+ if (this.y.length !== 2) {
56143
+ return false;
56144
+ }
56145
+ return this.x < this.y[0] || this.x > this.y[1];
56127
56146
  default:
56128
56147
  throw new Error('unknown compare type for vector');
56129
56148
  }
@@ -56149,6 +56168,8 @@ var PolygonIdSdk = (function (exports) {
56149
56168
  return new Scalar$1(x, y[0]);
56150
56169
  case exports.Operators.IN:
56151
56170
  case exports.Operators.NIN:
56171
+ case exports.Operators.BETWEEN:
56172
+ case exports.Operators.NONBETWEEN:
56152
56173
  return new Vector(x, y);
56153
56174
  default:
56154
56175
  throw new Error('unknown compare type');
@@ -56172,6 +56193,48 @@ var PolygonIdSdk = (function (exports) {
56172
56193
  this.values?.some((v) => typeof v !== 'bigint'))
56173
56194
  throw new Error(exports.CircuitError.EmptyQueryValue);
56174
56195
  }
56196
+ validateValueArraySize(maxArrSize) {
56197
+ switch (this.values.length) {
56198
+ case 0: {
56199
+ const zeroArrSizeOps = [exports.Operators.NOOP, exports.Operators.SD, exports.Operators.NULLIFY];
56200
+ if (!zeroArrSizeOps.includes(this.operator)) {
56201
+ throw new Error(exports.CircuitError.InvalidValuesArrSize);
56202
+ }
56203
+ return;
56204
+ }
56205
+ case 1: {
56206
+ const oneArrSizeOps = [
56207
+ exports.Operators.EQ,
56208
+ exports.Operators.LT,
56209
+ exports.Operators.GT,
56210
+ exports.Operators.NE,
56211
+ exports.Operators.LTE,
56212
+ exports.Operators.GTE,
56213
+ exports.Operators.EXISTS
56214
+ ];
56215
+ if (!oneArrSizeOps.includes(this.operator)) {
56216
+ throw new Error(exports.CircuitError.InvalidValuesArrSize);
56217
+ }
56218
+ return;
56219
+ }
56220
+ case 2: {
56221
+ const twoArrSizeOps = [exports.Operators.BETWEEN, exports.Operators.NONBETWEEN];
56222
+ if (!twoArrSizeOps.includes(this.operator)) {
56223
+ throw new Error(exports.CircuitError.InvalidValuesArrSize);
56224
+ }
56225
+ return;
56226
+ }
56227
+ default: {
56228
+ const maxArrSizeOps = [exports.Operators.IN, exports.Operators.NIN];
56229
+ if (!maxArrSizeOps.includes(this.operator)) {
56230
+ throw new Error(exports.CircuitError.InvalidOperationType);
56231
+ }
56232
+ if (!this.values.length || this.values.length > maxArrSize) {
56233
+ throw new Error(exports.CircuitError.InvalidValuesArrSize);
56234
+ }
56235
+ }
56236
+ }
56237
+ }
56175
56238
  }
56176
56239
  /**
56177
56240
  * CircuitID is alias for circuit identifier
@@ -56196,17 +56259,17 @@ var PolygonIdSdk = (function (exports) {
56196
56259
  * @beta
56197
56260
  */
56198
56261
  // AtomicQueryV3CircuitID is a type for credentialAtomicQueryV3.circom
56199
- CircuitId["AtomicQueryV3"] = "credentialAtomicQueryV3-beta.0";
56262
+ CircuitId["AtomicQueryV3"] = "credentialAtomicQueryV3-beta.1";
56200
56263
  /**
56201
56264
  * @beta
56202
56265
  */
56203
56266
  // AtomicQueryV3OnChainCircuitID is a type for credentialAtomicQueryV3OnChain.circom
56204
- CircuitId["AtomicQueryV3OnChain"] = "credentialAtomicQueryV3OnChain-beta.0";
56267
+ CircuitId["AtomicQueryV3OnChain"] = "credentialAtomicQueryV3OnChain-beta.1";
56205
56268
  /**
56206
56269
  * @beta
56207
56270
  */
56208
56271
  // LinkedMultiQuery is a type for linkedMultiQuery.circom
56209
- CircuitId["LinkedMultiQuery10"] = "linkedMultiQuery10-beta.0";
56272
+ CircuitId["LinkedMultiQuery10"] = "linkedMultiQuery10-beta.1";
56210
56273
  })(exports.CircuitId || (exports.CircuitId = {}));
56211
56274
  /**
56212
56275
  * Claim structure for circuit inputs
@@ -56243,6 +56306,8 @@ var PolygonIdSdk = (function (exports) {
56243
56306
  CircuitError["EmptyTreeState"] = "empty tree state";
56244
56307
  CircuitError["EmptyRequestID"] = "empty request ID";
56245
56308
  CircuitError["InvalidProofType"] = "invalid proof type";
56309
+ CircuitError["InvalidValuesArrSize"] = "invalid query Values array size";
56310
+ CircuitError["InvalidOperationType"] = "invalid operation type";
56246
56311
  })(exports.CircuitError || (exports.CircuitError = {}));
56247
56312
  /**
56248
56313
  * ValueProof represents a Merkle Proof for a value stored as MT
@@ -56852,6 +56917,7 @@ var PolygonIdSdk = (function (exports) {
56852
56917
  if (!this.query.values) {
56853
56918
  throw new Error(exports.CircuitError.EmptyQueryValue);
56854
56919
  }
56920
+ this.query.validateValueArraySize(this.getValueArrSize());
56855
56921
  if (!this.proofType) {
56856
56922
  throw new Error(exports.CircuitError.InvalidProofType);
56857
56923
  }
@@ -56981,12 +57047,12 @@ var PolygonIdSdk = (function (exports) {
56981
57047
  s.issuerClaimNonRevMtpAuxHi = nodeAuxNonRev.key.bigInt().toString();
56982
57048
  s.issuerClaimNonRevMtpAuxHv = nodeAuxNonRev.value.bigInt().toString();
56983
57049
  s.issuerClaimNonRevMtpNoAux = nodeAuxNonRev.noAux;
56984
- s.claimPathNotExists = existenceToInt(valueProof.mtp.existence);
56985
57050
  const nodAuxJSONLD = getNodeAuxValue(valueProof.mtp);
56986
57051
  s.claimPathMtpNoAux = nodAuxJSONLD.noAux;
56987
57052
  s.claimPathMtpAuxHi = nodAuxJSONLD.key.bigInt().toString();
56988
57053
  s.claimPathMtpAuxHv = nodAuxJSONLD.value.bigInt().toString();
56989
57054
  s.claimPathKey = valueProof.path.toString();
57055
+ s.valueArraySize = this.query.values.length;
56990
57056
  const values = prepareCircuitArrayValues(this.query.values, this.getValueArrSize());
56991
57057
  s.value = bigIntArrayToStringArray(values);
56992
57058
  s.linkNonce = this.linkNonce.toString();
@@ -57020,11 +57086,11 @@ var PolygonIdSdk = (function (exports) {
57020
57086
  // issuerClaimNonRevState
57021
57087
  // timestamp
57022
57088
  // claimSchema
57023
- // claimPathNotExists
57024
57089
  // claimPathKey
57025
57090
  // slotIndex
57026
57091
  // operator
57027
57092
  // value
57093
+ // valueArraySize
57028
57094
  // verifierID
57029
57095
  // nullifierSessionID
57030
57096
  // 19 is a number of fields in AtomicQueryV3PubSignals before values, values is last element in the proof and
@@ -57075,9 +57141,6 @@ var PolygonIdSdk = (function (exports) {
57075
57141
  // - claimSchema
57076
57142
  this.claimSchema = B$3.newSchemaHashFromInt(BigInt(sVals[fieldIdx]));
57077
57143
  fieldIdx++;
57078
- // - ClaimPathNotExists
57079
- this.claimPathNotExists = parseInt(sVals[fieldIdx]);
57080
- fieldIdx++;
57081
57144
  // - ClaimPathKey
57082
57145
  this.claimPathKey = BigInt(sVals[fieldIdx]);
57083
57146
  fieldIdx++;
@@ -57092,6 +57155,9 @@ var PolygonIdSdk = (function (exports) {
57092
57155
  this.value.push(BigInt(sVals[fieldIdx]));
57093
57156
  fieldIdx++;
57094
57157
  }
57158
+ // - valueArraySize
57159
+ this.valueArraySize = parseInt(sVals[fieldIdx]);
57160
+ fieldIdx++;
57095
57161
  // - verifierID
57096
57162
  if (sVals[fieldIdx] !== '0') {
57097
57163
  this.verifierID = k$2.fromBigInt(BigInt(sVals[fieldIdx]));
@@ -57122,13 +57188,14 @@ var PolygonIdSdk = (function (exports) {
57122
57188
  if (!this.query.values) {
57123
57189
  throw new Error(exports.CircuitError.EmptyQueryValue);
57124
57190
  }
57191
+ this.query.validateValueArraySize(this.getValueArrSize());
57125
57192
  if (!this.proofType) {
57126
57193
  throw new Error(exports.CircuitError.InvalidProofType);
57127
57194
  }
57128
57195
  if (!this.challenge) {
57129
57196
  throw new Error(exports.CircuitError.EmptyChallenge);
57130
57197
  }
57131
- if (this.authEnabled === 1) {
57198
+ if (this.isBJJAuthEnabled === 1) {
57132
57199
  if (!this.authClaimIncMtp) {
57133
57200
  throw new Error(exports.CircuitError.EmptyAuthClaimProof);
57134
57201
  }
@@ -57244,7 +57311,7 @@ var PolygonIdSdk = (function (exports) {
57244
57311
  isRevocationChecked: 1
57245
57312
  };
57246
57313
  s.challenge = this.challenge?.toString();
57247
- if (this.authEnabled === 1) {
57314
+ if (this.isBJJAuthEnabled === 1) {
57248
57315
  s.authClaim = this.authClaim?.marshalJson();
57249
57316
  s.userClaimsTreeRoot = this.treeState.claimsRoot?.bigInt().toString();
57250
57317
  s.userRevTreeRoot = this.treeState.revocationRoot?.bigInt().toString();
@@ -57319,18 +57386,18 @@ var PolygonIdSdk = (function (exports) {
57319
57386
  s.issuerClaimNonRevMtpAuxHi = nodeAuxNonRev.key.bigInt().toString();
57320
57387
  s.issuerClaimNonRevMtpAuxHv = nodeAuxNonRev.value.bigInt().toString();
57321
57388
  s.issuerClaimNonRevMtpNoAux = nodeAuxNonRev.noAux;
57322
- s.claimPathNotExists = existenceToInt(valueProof.mtp.existence);
57323
57389
  const nodAuxJSONLD = getNodeAuxValue(valueProof.mtp);
57324
57390
  s.claimPathMtpNoAux = nodAuxJSONLD.noAux;
57325
57391
  s.claimPathMtpAuxHi = nodAuxJSONLD.key.bigInt().toString();
57326
57392
  s.claimPathMtpAuxHv = nodAuxJSONLD.value.bigInt().toString();
57327
57393
  s.claimPathKey = valueProof.path.toString();
57394
+ s.valueArraySize = this.query.values.length;
57328
57395
  const values = prepareCircuitArrayValues(this.query.values, this.getValueArrSize());
57329
57396
  s.value = bigIntArrayToStringArray(values);
57330
57397
  s.linkNonce = this.linkNonce.toString();
57331
57398
  s.verifierID = this.verifierID?.bigInt().toString() ?? '0';
57332
57399
  s.nullifierSessionID = this.nullifierSessionID.toString();
57333
- s.authEnabled = this.authEnabled.toString();
57400
+ s.isBJJAuthEnabled = this.isBJJAuthEnabled.toString();
57334
57401
  return byteEncoder.encode(JSON.stringify(s));
57335
57402
  }
57336
57403
  }
@@ -57342,7 +57409,6 @@ var PolygonIdSdk = (function (exports) {
57342
57409
  // PubSignalsUnmarshal unmarshal credentialAtomicQueryV3.circom public signals
57343
57410
  pubSignalsUnmarshal(data) {
57344
57411
  // expected order:
57345
- // merklized
57346
57412
  // userID
57347
57413
  // circuitQueryHash
57348
57414
  // issuerState
@@ -57354,17 +57420,11 @@ var PolygonIdSdk = (function (exports) {
57354
57420
  // challenge
57355
57421
  // gistRoot
57356
57422
  // issuerID
57357
- // isRevocationChecked
57358
57423
  // issuerClaimNonRevState
57359
57424
  // timestamp
57360
- // verifierID
57361
- // nullifierSessionID
57362
- // authEnabled
57425
+ // isBJJAuthEnabled
57363
57426
  const sVals = JSON.parse(byteDecoder.decode(data));
57364
57427
  let fieldIdx = 0;
57365
- // -- merklized
57366
- this.merklized = parseInt(sVals[fieldIdx]);
57367
- fieldIdx++;
57368
57428
  // - userID
57369
57429
  this.userID = k$2.fromBigInt(BigInt(sVals[fieldIdx]));
57370
57430
  fieldIdx++;
@@ -57398,25 +57458,14 @@ var PolygonIdSdk = (function (exports) {
57398
57458
  // - issuerID
57399
57459
  this.issuerID = k$2.fromBigInt(BigInt(sVals[fieldIdx]));
57400
57460
  fieldIdx++;
57401
- // - isRevocationChecked
57402
- this.isRevocationChecked = parseInt(sVals[fieldIdx]);
57403
- fieldIdx++;
57404
57461
  // - issuerClaimNonRevState
57405
57462
  this.issuerClaimNonRevState = V$1.fromString(sVals[fieldIdx]);
57406
57463
  fieldIdx++;
57407
57464
  // - timestamp
57408
57465
  this.timestamp = parseInt(sVals[fieldIdx]);
57409
57466
  fieldIdx++;
57410
- // - verifierID
57411
- if (sVals[fieldIdx] !== '0') {
57412
- this.verifierID = k$2.fromBigInt(BigInt(sVals[fieldIdx]));
57413
- }
57414
- fieldIdx++;
57415
- // - nullifierSessionID
57416
- this.nullifierSessionID = BigInt(sVals[fieldIdx]);
57417
- fieldIdx++;
57418
- // - authEnabled
57419
- this.authEnabled = parseInt(sVals[fieldIdx]);
57467
+ // - isBJJAuthEnabled
57468
+ this.isBJJAuthEnabled = parseInt(sVals[fieldIdx]);
57420
57469
  return this;
57421
57470
  }
57422
57471
  }
@@ -57826,8 +57875,6 @@ var PolygonIdSdk = (function (exports) {
57826
57875
  class LinkedMultiQueryInputs extends BaseConfig {
57827
57876
  // InputsMarshal returns Circom private inputs for linkedMultiQueryInputs.circom
57828
57877
  inputsMarshal() {
57829
- const enabled = [];
57830
- const claimPathNotExists = [];
57831
57878
  const claimPathMtp = [];
57832
57879
  const claimPathMtpNoAux = [];
57833
57880
  const claimPathMtpAuxHi = [];
@@ -57837,10 +57884,9 @@ var PolygonIdSdk = (function (exports) {
57837
57884
  const slotIndex = [];
57838
57885
  const operator = [];
57839
57886
  const value = [];
57887
+ const valueArraySize = [];
57840
57888
  for (let i = 0; i < LinkedMultiQueryInputs.queryCount; i++) {
57841
57889
  if (!this.query[i]) {
57842
- enabled.push(0);
57843
- claimPathNotExists.push(0);
57844
57890
  claimPathMtp.push(new Array(this.getMTLevelsClaim()).fill('0'));
57845
57891
  claimPathMtpNoAux.push('0');
57846
57892
  claimPathMtpAuxHi.push('0');
@@ -57851,9 +57897,9 @@ var PolygonIdSdk = (function (exports) {
57851
57897
  operator.push(0);
57852
57898
  const valuesArr = prepareCircuitArrayValues([], this.getValueArrSize());
57853
57899
  value.push(bigIntArrayToStringArray(valuesArr));
57900
+ valueArraySize.push(0);
57854
57901
  continue;
57855
57902
  }
57856
- enabled.push(1);
57857
57903
  let valueProof = this.query[i].valueProof;
57858
57904
  if (!valueProof) {
57859
57905
  valueProof = new ValueProof();
@@ -57861,7 +57907,6 @@ var PolygonIdSdk = (function (exports) {
57861
57907
  valueProof.value = 0n;
57862
57908
  valueProof.mtp = new Kt$1();
57863
57909
  }
57864
- claimPathNotExists.push(existenceToInt(valueProof.mtp.existence));
57865
57910
  claimPathMtp.push(prepareSiblingsStr(valueProof.mtp, this.getMTLevelsClaim()));
57866
57911
  const nodAuxJSONLD = getNodeAuxValue(valueProof.mtp);
57867
57912
  claimPathMtpNoAux.push(nodAuxJSONLD.noAux);
@@ -57871,15 +57916,14 @@ var PolygonIdSdk = (function (exports) {
57871
57916
  claimPathValue.push(valueProof.value.toString());
57872
57917
  slotIndex.push(this.query[i].slotIndex);
57873
57918
  operator.push(this.query[i].operator);
57919
+ valueArraySize.push(this.query[i].values.length);
57874
57920
  const valuesArr = prepareCircuitArrayValues(this.query[i].values, this.getValueArrSize());
57875
57921
  value.push(bigIntArrayToStringArray(valuesArr));
57876
57922
  }
57877
57923
  const s = {
57878
57924
  linkNonce: this.linkNonce.toString(),
57879
57925
  issuerClaim: this.claim.marshalJson(),
57880
- enabled,
57881
57926
  claimSchema: this.claim.getSchemaHash().bigInt().toString(),
57882
- claimPathNotExists,
57883
57927
  claimPathMtp,
57884
57928
  claimPathMtpNoAux,
57885
57929
  claimPathMtpAuxHi,
@@ -57888,7 +57932,8 @@ var PolygonIdSdk = (function (exports) {
57888
57932
  claimPathValue,
57889
57933
  slotIndex,
57890
57934
  operator,
57891
- value
57935
+ value,
57936
+ valueArraySize
57892
57937
  };
57893
57938
  return byteEncoder.encode(JSON.stringify(s));
57894
57939
  }
@@ -57910,7 +57955,7 @@ var PolygonIdSdk = (function (exports) {
57910
57955
  * @returns LinkedMultiQueryPubSignals
57911
57956
  */
57912
57957
  pubSignalsUnmarshal(data) {
57913
- const len = 32;
57958
+ const len = 22;
57914
57959
  const queryLength = LinkedMultiQueryInputs.queryCount;
57915
57960
  const sVals = JSON.parse(byteDecoder.decode(data));
57916
57961
  if (sVals.length !== len) {
@@ -57935,13 +57980,6 @@ var PolygonIdSdk = (function (exports) {
57935
57980
  this.circuitQueryHash.push(BigInt(sVals[fieldIdx]));
57936
57981
  fieldIdx++;
57937
57982
  }
57938
- // - enabled
57939
- this.enabled = [];
57940
- for (let i = 0; i < queryLength; i++) {
57941
- const enabledNum = parseInt(sVals[fieldIdx]);
57942
- this.enabled.push(enabledNum === 1);
57943
- fieldIdx++;
57944
- }
57945
57983
  return this;
57946
57984
  }
57947
57985
  }
@@ -59974,6 +60012,19 @@ var PolygonIdSdk = (function (exports) {
59974
60012
  }
59975
60013
  return a <= b;
59976
60014
  };
60015
+ // a - field value
60016
+ // b - true / false (exists operator values)
60017
+ const existsComparator = (a, b) => {
60018
+ if (truthyValues.includes(b) && typeof a !== 'undefined') {
60019
+ // if exists val is true , a field val exists
60020
+ return true;
60021
+ }
60022
+ // if exists val is false , a field val doesn't exist
60023
+ if (falsyValues.includes(b) && (a === undefined || (Array.isArray(a) && !a.length))) {
60024
+ return true;
60025
+ }
60026
+ return false;
60027
+ };
59977
60028
  const inOperator = (a, b) => {
59978
60029
  if (Array.isArray(a) && Array.isArray(b)) {
59979
60030
  return a.every((val) => b.includes(val));
@@ -59986,9 +60037,19 @@ var PolygonIdSdk = (function (exports) {
59986
60037
  }
59987
60038
  return false;
59988
60039
  };
60040
+ const betweenOperator = (a, b) => {
60041
+ if (!Array.isArray(b) || b.length !== 2) {
60042
+ throw new Error('$between/$nonbetween operator value should be 2 elements array');
60043
+ }
60044
+ if (Array.isArray(a)) {
60045
+ return a.every((val) => val >= b[0] && val <= b[1]);
60046
+ }
60047
+ return a >= b[0] && a <= b[1];
60048
+ };
59989
60049
  const comparatorOptions = {
59990
60050
  $noop: () => true,
59991
60051
  $sd: () => true,
60052
+ $exists: (a, b) => existsComparator(a, b),
59992
60053
  $eq: (a, b) => equalsComparator(a, b),
59993
60054
  $in: (a, b) => inOperator(a, b),
59994
60055
  $nin: (a, b) => !inOperator(a, b),
@@ -59996,7 +60057,9 @@ var PolygonIdSdk = (function (exports) {
59996
60057
  $lt: (a, b) => !greaterThan(a, b),
59997
60058
  $ne: (a, b) => !equalsComparator(a, b),
59998
60059
  $gte: (a, b) => greaterThanOrEqual(a, b),
59999
- $lte: (a, b) => lessThanOrEqual(a, b)
60060
+ $lte: (a, b) => lessThanOrEqual(a, b),
60061
+ $between: (a, b) => betweenOperator(a, b),
60062
+ $nonbetween: (a, b) => !betweenOperator(a, b)
60000
60063
  };
60001
60064
  /**
60002
60065
  * credential search path resolver
@@ -60044,7 +60107,8 @@ var PolygonIdSdk = (function (exports) {
60044
60107
  throw new Error(exports.SearchError.NotDefinedComparator);
60045
60108
  }
60046
60109
  const credentialPathValue = resolvePath(credential, this.path);
60047
- if (credentialPathValue === null || credentialPathValue === undefined) {
60110
+ if ((credentialPathValue === null || credentialPathValue === undefined) &&
60111
+ this.operatorFunc !== existsComparator) {
60048
60112
  return false;
60049
60113
  }
60050
60114
  if (this.isReverseParams) {
@@ -62429,16 +62493,21 @@ var PolygonIdSdk = (function (exports) {
62429
62493
  return queries;
62430
62494
  };
62431
62495
  const parseQueryMetadata = async (propertyQuery, ldContextJSON, credentialType, options) => {
62432
- const datatype = await lf.newTypeFromContext(ldContextJSON, `${credentialType}.${propertyQuery.fieldName}`, options);
62433
62496
  const query = {
62434
62497
  ...propertyQuery,
62435
62498
  slotIndex: 0,
62436
62499
  merklizedSchema: false,
62437
- datatype: datatype,
62500
+ datatype: '',
62438
62501
  claimPathKey: BigInt(0),
62439
62502
  values: [],
62440
62503
  path: new lf()
62441
62504
  };
62505
+ if (!propertyQuery.fieldName && propertyQuery.operator !== exports.Operators.NOOP) {
62506
+ throw new Error('query must have a field name if operator is not $noop');
62507
+ }
62508
+ if (propertyQuery.fieldName) {
62509
+ query.datatype = await lf.newTypeFromContext(ldContextJSON, `${credentialType}.${propertyQuery.fieldName}`, options);
62510
+ }
62442
62511
  const serAttr = await getSerializationAttrFromContext(JSON.parse(ldContextJSON), options, credentialType);
62443
62512
  if (!serAttr) {
62444
62513
  query.merklizedSchema = true;
@@ -62460,9 +62529,10 @@ var PolygonIdSdk = (function (exports) {
62460
62529
  }
62461
62530
  }
62462
62531
  if (propertyQuery.operatorValue) {
62463
- if (!isValidOperation(datatype, propertyQuery.operator)) {
62464
- throw new Error(`operator ${propertyQuery.operator} is not supported for datatype ${datatype}`);
62532
+ if (!isValidOperation(query.datatype, propertyQuery.operator)) {
62533
+ throw new Error(`operator ${propertyQuery.operator} is not supported for datatype ${query.datatype}`);
62465
62534
  }
62535
+ const datatype = propertyQuery.operator === exports.Operators.EXISTS ? exports.XSDNS.Boolean : query.datatype;
62466
62536
  query.values = await transformQueryValueToBigInts(propertyQuery.operatorValue, datatype);
62467
62537
  }
62468
62538
  return query;
@@ -62472,7 +62542,7 @@ var PolygonIdSdk = (function (exports) {
62472
62542
  return Promise.all(queriesMetadata.map((m) => parseQueryMetadata(m, ldContextJSON, credentialType, options)));
62473
62543
  };
62474
62544
  const transformQueryValueToBigInts = async (value, ldType) => {
62475
- const values = new Array(64).fill(BigInt(0));
62545
+ const values = [];
62476
62546
  if (Array.isArray(value)) {
62477
62547
  for (let index = 0; index < value.length; index++) {
62478
62548
  values[index] = await ff.hashValue(ldType, value[index]);
@@ -83791,10 +83861,8 @@ var PolygonIdSdk = (function (exports) {
83791
83861
  circuitInputs.profileNonce = BigInt(params.authProfileNonce);
83792
83862
  circuitInputs.skipClaimRevocationCheck = params.skipRevocation;
83793
83863
  const query = circuitQueries[0];
83794
- query.values =
83795
- query.operator === exports.Operators.SD || query.operator === exports.Operators.NOOP
83796
- ? new Array(defaultValueArraySize).fill(0)
83797
- : query.values;
83864
+ query.values = [exports.Operators.SD, exports.Operators.NOOP].includes(query.operator) ? [] : query.values;
83865
+ query.valueProof = query.operator === exports.Operators.NOOP ? new ValueProof() : query.valueProof;
83798
83866
  circuitInputs.query = query;
83799
83867
  circuitInputs.currentTimeStamp = S$3(new Date());
83800
83868
  circuitInputs.proofType = proofType;
@@ -83842,10 +83910,8 @@ var PolygonIdSdk = (function (exports) {
83842
83910
  circuitInputs.profileNonce = BigInt(params.authProfileNonce);
83843
83911
  circuitInputs.skipClaimRevocationCheck = params.skipRevocation;
83844
83912
  const query = circuitQueries[0];
83845
- query.values =
83846
- query.operator === exports.Operators.SD || query.operator === exports.Operators.NOOP
83847
- ? new Array(defaultValueArraySize).fill(0)
83848
- : query.values;
83913
+ query.values = [exports.Operators.SD, exports.Operators.NOOP].includes(query.operator) ? [] : query.values;
83914
+ query.valueProof = query.operator === exports.Operators.NOOP ? new ValueProof() : query.valueProof;
83849
83915
  circuitInputs.query = query;
83850
83916
  circuitInputs.currentTimeStamp = S$3(new Date());
83851
83917
  circuitInputs.proofType = proofType;
@@ -83861,7 +83927,7 @@ var PolygonIdSdk = (function (exports) {
83861
83927
  catch {
83862
83928
  isEthIdentity = false;
83863
83929
  }
83864
- circuitInputs.authEnabled = isEthIdentity ? 0 : 1;
83930
+ circuitInputs.isBJJAuthEnabled = isEthIdentity ? 0 : 1;
83865
83931
  circuitInputs.challenge = BigInt(params.challenge ?? 0);
83866
83932
  const { nonce: authProfileNonce, genesisDID } = await this._identityWallet.getGenesisDIDMetadata(identifier);
83867
83933
  const id = W$2.idFromDID(genesisDID);
@@ -83869,7 +83935,7 @@ var PolygonIdSdk = (function (exports) {
83869
83935
  const gistProof = toGISTProof(stateProof);
83870
83936
  circuitInputs.gistProof = gistProof;
83871
83937
  // auth inputs
83872
- if (circuitInputs.authEnabled === 1) {
83938
+ if (circuitInputs.isBJJAuthEnabled === 1) {
83873
83939
  const authPrepared = await this.prepareAuthBJJCredential(genesisDID);
83874
83940
  const authClaimData = await this.newCircuitClaimData({
83875
83941
  credential: authPrepared.credential,
@@ -84002,7 +84068,7 @@ var PolygonIdSdk = (function (exports) {
84002
84068
  const schemaId = await lf.getTypeIDFromContext(JSON.stringify(schema), query.type, {
84003
84069
  documentLoader: schemaLoader
84004
84070
  });
84005
- const schemaHash = caclulateCoreSchemaHash(byteEncoder.encode(schemaId));
84071
+ const schemaHash = calculateCoreSchemaHash(byteEncoder.encode(schemaId));
84006
84072
  if (schemaHash.bigInt() !== outputs.schemaHash.bigInt()) {
84007
84073
  throw new Error(`schema that was used is not equal to requested in query`);
84008
84074
  }
@@ -84020,7 +84086,8 @@ var PolygonIdSdk = (function (exports) {
84020
84086
  if (notSupportedOpIndx > -1) {
84021
84087
  throw new Error(`circuit ${circuitId} not support ${queriesMetadata[notSupportedOpIndx].operator} operator`);
84022
84088
  }
84023
- queriesMetadata.forEach(async (metadata) => {
84089
+ for (let i = 0; i < queriesMetadata.length; i++) {
84090
+ const metadata = queriesMetadata[i];
84024
84091
  if (!query.type) {
84025
84092
  throw new Error(`proof query type is undefined`);
84026
84093
  }
@@ -84073,7 +84140,7 @@ var PolygonIdSdk = (function (exports) {
84073
84140
  if (timeDiff > acceptedProofGenerationDelay) {
84074
84141
  throw new Error('generated proof is outdated');
84075
84142
  }
84076
- });
84143
+ }
84077
84144
  return;
84078
84145
  }
84079
84146
  async function validateEmptyCredentialSubject(cq, outputs) {
@@ -84102,14 +84169,14 @@ var PolygonIdSdk = (function (exports) {
84102
84169
  }
84103
84170
  for (let index = 0; index < outputs.value.length; index++) {
84104
84171
  if (outputs.value[index] !== cq.values[index]) {
84172
+ if (outputs.value[index] === 0n && cq.values[index] === undefined) {
84173
+ continue;
84174
+ }
84105
84175
  throw new Error(`comparison value that was used is not equal to requested in query`);
84106
84176
  }
84107
84177
  }
84108
84178
  }
84109
84179
  async function validateDisclosure(cq, outputs, verifiablePresentation, ldLoader) {
84110
- if (!verifiablePresentation) {
84111
- throw new Error(`verifiablePresentation is required for selective disclosure request`);
84112
- }
84113
84180
  if (outputs.operator !== exports.Operators.EQ) {
84114
84181
  throw new Error(`operator for selective disclosure must be $eq`);
84115
84182
  }
@@ -84118,6 +84185,15 @@ var PolygonIdSdk = (function (exports) {
84118
84185
  throw new Error(`selective disclosure not available for array of values`);
84119
84186
  }
84120
84187
  }
84188
+ const bi = await fieldValueFromVerifiablePresentation(cq.fieldName, verifiablePresentation, ldLoader);
84189
+ if (bi !== outputs.value[0]) {
84190
+ throw new Error(`value that was used is not equal to requested in query`);
84191
+ }
84192
+ }
84193
+ const fieldValueFromVerifiablePresentation = async (fieldName, verifiablePresentation, ldLoader) => {
84194
+ if (!verifiablePresentation) {
84195
+ throw new Error(`verifiablePresentation is required for selective disclosure request`);
84196
+ }
84121
84197
  let mz;
84122
84198
  const strVerifiablePresentation = JSON.stringify(verifiablePresentation);
84123
84199
  try {
@@ -84130,13 +84206,13 @@ var PolygonIdSdk = (function (exports) {
84130
84206
  }
84131
84207
  let merklizedPath;
84132
84208
  try {
84133
- const p = `verifiableCredential.credentialSubject.${cq.fieldName}`;
84209
+ const p = `verifiableCredential.credentialSubject.${fieldName}`;
84134
84210
  merklizedPath = await lf.fromDocument(null, strVerifiablePresentation, p, {
84135
84211
  documentLoader: ldLoader
84136
84212
  });
84137
84213
  }
84138
84214
  catch (e) {
84139
- throw new Error(`can't build path to '${cq.fieldName}' key`);
84215
+ throw new Error(`can't build path to '${fieldName}' key`);
84140
84216
  }
84141
84217
  let proof;
84142
84218
  let value;
@@ -84144,18 +84220,49 @@ var PolygonIdSdk = (function (exports) {
84144
84220
  ({ proof, value } = await mz.proof(merklizedPath));
84145
84221
  }
84146
84222
  catch (e) {
84147
- throw new Error(`can't get value by path '${cq.fieldName}'`);
84223
+ throw new Error(`can't get value by path '${fieldName}'`);
84148
84224
  }
84149
84225
  if (!value) {
84150
- throw new Error(`can't get merkle value for field '${cq.fieldName}'`);
84226
+ throw new Error(`can't get merkle value for field '${fieldName}'`);
84151
84227
  }
84152
84228
  if (!proof.existence) {
84153
84229
  throw new Error(`path [${merklizedPath.parts}] doesn't exist in verifiablePresentation document`);
84154
84230
  }
84155
- const bi = await value.mtEntry();
84156
- if (bi !== outputs.value[0]) {
84157
- throw new Error(`value that was used is not equal to requested in query`);
84158
- }
84231
+ return await value.mtEntry();
84232
+ };
84233
+
84234
+ function calculateQueryHashV2(values, schema, slotIndex, operator, claimPathKey, claimPathNotExists) {
84235
+ const expValue = prepareCircuitArrayValues(values, 64);
84236
+ const valueHash = $$2.spongeHashX(expValue, 6);
84237
+ return $$2.hash([
84238
+ schema.bigInt(),
84239
+ BigInt(slotIndex),
84240
+ BigInt(operator),
84241
+ BigInt(claimPathKey),
84242
+ BigInt(claimPathNotExists),
84243
+ valueHash
84244
+ ]);
84245
+ }
84246
+ function calculateQueryHashV3(values, schema, slotIndex, operator, claimPathKey, valueArraySize, merklized, isRevocationChecked, verifierID, nullifierSessionID) {
84247
+ const expValue = prepareCircuitArrayValues(values, defaultValueArraySize);
84248
+ const valueHash = $$2.spongeHashX(expValue, 6);
84249
+ const firstPartQueryHash = $$2.hash([
84250
+ schema.bigInt(),
84251
+ BigInt(slotIndex),
84252
+ BigInt(operator),
84253
+ BigInt(claimPathKey),
84254
+ BigInt(merklized),
84255
+ valueHash
84256
+ ]);
84257
+ const queryHash = $$2.hash([
84258
+ firstPartQueryHash,
84259
+ BigInt(valueArraySize),
84260
+ BigInt(isRevocationChecked),
84261
+ BigInt(verifierID),
84262
+ BigInt(nullifierSessionID),
84263
+ 0n
84264
+ ]);
84265
+ return queryHash;
84159
84266
  }
84160
84267
 
84161
84268
  const userStateError = new Error(`user state is not valid`);
@@ -84255,7 +84362,6 @@ var PolygonIdSdk = (function (exports) {
84255
84362
  timestamp: v3PubSignals.timestamp,
84256
84363
  merklized: v3PubSignals.merklized,
84257
84364
  claimPathKey: v3PubSignals.claimPathKey,
84258
- claimPathNotExists: v3PubSignals.claimPathNotExists,
84259
84365
  valueArraySize: v3PubSignals.getValueArrSize(),
84260
84366
  isRevocationChecked: v3PubSignals.isRevocationChecked
84261
84367
  };
@@ -84332,7 +84438,7 @@ var PolygonIdSdk = (function (exports) {
84332
84438
  this.verifyIdOwnership(sender, challenge);
84333
84439
  return new BaseConfig();
84334
84440
  };
84335
- this.linkedMultiQuery10Verify = async ({ query, pubSignals }) => {
84441
+ this.linkedMultiQuery10Verify = async ({ query, verifiablePresentation, pubSignals }) => {
84336
84442
  let multiQueryPubSignals = new LinkedMultiQueryPubSignals();
84337
84443
  multiQueryPubSignals = multiQueryPubSignals.pubSignalsUnmarshal(byteEncoder.encode(JSON.stringify(pubSignals)));
84338
84444
  // verify query
@@ -84346,26 +84452,41 @@ var PolygonIdSdk = (function (exports) {
84346
84452
  }
84347
84453
  const ldContextJSON = JSON.stringify(schema);
84348
84454
  const credentialSubject = query.credentialSubject;
84349
- const schemaId = await lf.getTypeIDFromContext(JSON.stringify(schema), query.type || '', ldOpts);
84350
- const schemaHash = caclulateCoreSchemaHash(byteEncoder.encode(schemaId));
84455
+ const schemaId = await lf.getTypeIDFromContext(ldContextJSON, query.type || '', ldOpts);
84456
+ const schemaHash = calculateCoreSchemaHash(byteEncoder.encode(schemaId));
84351
84457
  const queriesMetadata = await parseQueriesMetadata(query.type || '', ldContextJSON, credentialSubject, ldOpts);
84352
- const queryHashes = queriesMetadata.map((queryMeta) => {
84353
- const valueHash = $$2.spongeHashX(queryMeta.values, 6);
84354
- return $$2.hash([
84355
- schemaHash.bigInt(),
84356
- BigInt(queryMeta.slotIndex),
84357
- BigInt(queryMeta.operator),
84358
- BigInt(queryMeta.claimPathKey),
84359
- queryMeta.merklizedSchema ? 0n : 1n,
84360
- valueHash
84361
- ]);
84362
- });
84363
- const circuitQueryHashes = multiQueryPubSignals.circuitQueryHash
84364
- .filter((i) => i !== 0n)
84365
- .sort(bigIntCompare);
84366
- queryHashes.sort(bigIntCompare);
84367
- if (!queryHashes.every((queryHash, i) => queryHash === circuitQueryHashes[i])) {
84368
- throw new Error('query hashes do not match');
84458
+ const request = [];
84459
+ const merklized = queriesMetadata[0]?.merklizedSchema ? 1 : 0;
84460
+ for (let i = 0; i < LinkedMultiQueryInputs.queryCount; i++) {
84461
+ const queryMeta = queriesMetadata[i];
84462
+ const values = queryMeta?.values ?? [];
84463
+ const valArrSize = values.length;
84464
+ const queryHash = calculateQueryHashV3(values, schemaHash, queryMeta?.slotIndex ?? 0, queryMeta?.operator ?? 0, queryMeta?.claimPathKey.toString() ?? 0, valArrSize, merklized, 0, 0, 0);
84465
+ request.push({ queryHash, queryMeta });
84466
+ }
84467
+ const queryHashCompare = (a, b) => {
84468
+ if (a.queryHash < b.queryHash)
84469
+ return -1;
84470
+ if (a.queryHash > b.queryHash)
84471
+ return 1;
84472
+ return 0;
84473
+ };
84474
+ const pubSignalsMeta = multiQueryPubSignals.circuitQueryHash.map((queryHash, index) => ({
84475
+ queryHash,
84476
+ operatorOutput: multiQueryPubSignals.operatorOutput[index]
84477
+ }));
84478
+ pubSignalsMeta.sort(queryHashCompare);
84479
+ request.sort(queryHashCompare);
84480
+ for (let i = 0; i < LinkedMultiQueryInputs.queryCount; i++) {
84481
+ if (request[i].queryHash != pubSignalsMeta[i].queryHash) {
84482
+ throw new Error('query hashes do not match');
84483
+ }
84484
+ if (request[i].queryMeta?.operator === exports.Operators.SD) {
84485
+ const disclosedValue = await fieldValueFromVerifiablePresentation(request[i].queryMeta.fieldName, verifiablePresentation, this._documentLoader);
84486
+ if (disclosedValue != pubSignalsMeta[i].operatorOutput) {
84487
+ throw new Error('disclosed value is not in the proof outputs');
84488
+ }
84489
+ }
84369
84490
  }
84370
84491
  return multiQueryPubSignals;
84371
84492
  };
@@ -85400,6 +85521,7 @@ var PolygonIdSdk = (function (exports) {
85400
85521
  if (message.type !== PROTOCOL_MESSAGE_TYPE.AUTHORIZATION_REQUEST_MESSAGE_TYPE) {
85401
85522
  throw new Error('Invalid media type');
85402
85523
  }
85524
+ authRequest.body.scope = authRequest.body.scope || [];
85403
85525
  return authRequest;
85404
85526
  }
85405
85527
  /**
@@ -85511,7 +85633,8 @@ var PolygonIdSdk = (function (exports) {
85511
85633
  throw new Error(`sender of the request is not a target of response - expected ${request.from}, given ${response.to}`);
85512
85634
  }
85513
85635
  this.verifyAuthRequest(request);
85514
- const requestScope = request.body.scope;
85636
+ const requestScope = request.body.scope || [];
85637
+ const responseScope = response.body.scope || [];
85515
85638
  if (!response.from) {
85516
85639
  throw new Error(`proof response doesn't contain from field`);
85517
85640
  }
@@ -85519,7 +85642,7 @@ var PolygonIdSdk = (function (exports) {
85519
85642
  // group requests by query group id
85520
85643
  for (const proofRequest of requestScope) {
85521
85644
  const groupId = proofRequest.query.groupId;
85522
- const proofResp = response.body.scope.find((resp) => resp.id === proofRequest.id);
85645
+ const proofResp = responseScope.find((resp) => resp.id === proofRequest.id);
85523
85646
  if (!proofResp) {
85524
85647
  throw new Error(`proof is not given for requestId ${proofRequest.id}`);
85525
85648
  }
@@ -85555,7 +85678,7 @@ var PolygonIdSdk = (function (exports) {
85555
85678
  }
85556
85679
  verifyAuthRequest(request) {
85557
85680
  const groupIdValidationMap = {};
85558
- const requestScope = request.body.scope;
85681
+ const requestScope = request.body.scope || [];
85559
85682
  for (const proofRequest of requestScope) {
85560
85683
  const groupId = proofRequest.query.groupId;
85561
85684
  if (groupId) {
@@ -85773,6 +85896,7 @@ var PolygonIdSdk = (function (exports) {
85773
85896
  if (message.type !== PROTOCOL_MESSAGE_TYPE.CONTRACT_INVOKE_REQUEST_MESSAGE_TYPE) {
85774
85897
  throw new Error('Invalid media type');
85775
85898
  }
85899
+ ciRequest.body.scope = ciRequest.body.scope || [];
85776
85900
  return ciRequest;
85777
85901
  }
85778
85902
  /**
@@ -85792,19 +85916,11 @@ var PolygonIdSdk = (function (exports) {
85792
85916
  throw new Error("Can't sign transaction. Provide Signer in options.");
85793
85917
  }
85794
85918
  const zkRequests = [];
85795
- const { contract_address, chain_id } = ciRequest.body.transaction_data;
85919
+ const { chain_id } = ciRequest.body.transaction_data;
85796
85920
  const networkFlag = Object.keys(u$2).find((key) => u$2[key] === chain_id);
85797
85921
  if (!networkFlag) {
85798
85922
  throw new Error(`Invalid chain id ${chain_id}`);
85799
85923
  }
85800
- const [blockchain, networkId] = networkFlag.split(':');
85801
- const verifierId = buildVerifierId(contract_address, {
85802
- blockchain,
85803
- networkId,
85804
- // DidMethod.Iden3 is used based on discussions: all onchain issuers have iden3 did method by default. This can be changed in the release of v3 circuit.
85805
- method: h$3.Iden3
85806
- });
85807
- const verifierDid = W$2.parseFromId(verifierId);
85808
85924
  for (const proofReq of ciRequest.body.scope) {
85809
85925
  if (!this._allowedCircuits.includes(proofReq.circuitId)) {
85810
85926
  throw new Error(`Can't handle circuit ${proofReq.circuitId}. Only onchain circuits are allowed.`);
@@ -85813,7 +85929,7 @@ var PolygonIdSdk = (function (exports) {
85813
85929
  const zkpRes = await this._proofService.generateProof(proofReq, did, {
85814
85930
  skipRevocation: query.skipClaimRevocationCheck ?? false,
85815
85931
  challenge: opts.challenge,
85816
- verifierDid
85932
+ verifierDid: ciRequest.from ? W$2.parse(ciRequest.from) : undefined
85817
85933
  });
85818
85934
  zkRequests.push(zkpRes);
85819
85935
  }
@@ -85996,7 +86112,9 @@ var PolygonIdSdk = (function (exports) {
85996
86112
  exports.bytesToBase64url = bytesToBase64url;
85997
86113
  exports.bytesToHex = bytesToHex$1;
85998
86114
  exports.cacheLoader = cacheLoader;
85999
- exports.caclulateCoreSchemaHash = caclulateCoreSchemaHash;
86115
+ exports.calculateCoreSchemaHash = calculateCoreSchemaHash;
86116
+ exports.calculateQueryHashV2 = calculateQueryHashV2;
86117
+ exports.calculateQueryHashV3 = calculateQueryHashV3;
86000
86118
  exports.checkDataInField = checkDataInField;
86001
86119
  exports.checkQueryRequest = checkQueryRequest;
86002
86120
  exports.circuitValidator = circuitValidator;
@@ -86021,6 +86139,7 @@ var PolygonIdSdk = (function (exports) {
86021
86139
  exports.extractPublicKeyBytes = extractPublicKeyBytes;
86022
86140
  exports.factoryComparer = factoryComparer;
86023
86141
  exports.fieldToByteArray = fieldToByteArray;
86142
+ exports.fieldValueFromVerifiablePresentation = fieldValueFromVerifiablePresentation;
86024
86143
  exports.fillCoreClaimSlot = fillCoreClaimSlot;
86025
86144
  exports.fillSlot = fillSlot;
86026
86145
  exports.findCredentialType = findCredentialType;