@0xpolygonid/js-sdk 1.21.0 → 1.21.3

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.
@@ -10,6 +10,15 @@ const utils_1 = require("../../utils");
10
10
  const allOperations = Object.values(circuits_1.QueryOperators);
11
11
  const v2Operations = [
12
12
  circuits_1.Operators.NOOP,
13
+ circuits_1.Operators.EQ,
14
+ circuits_1.Operators.LT,
15
+ circuits_1.Operators.GT,
16
+ circuits_1.Operators.IN,
17
+ circuits_1.Operators.NIN,
18
+ circuits_1.Operators.NE,
19
+ circuits_1.Operators.SD
20
+ ];
21
+ const v2OnChainOperations = [
13
22
  circuits_1.Operators.EQ,
14
23
  circuits_1.Operators.LT,
15
24
  circuits_1.Operators.GT,
@@ -19,9 +28,15 @@ const v2Operations = [
19
28
  ];
20
29
  exports.circuitValidator = {
21
30
  [circuits_1.CircuitId.AtomicQueryMTPV2]: { maxQueriesCount: 1, supportedOperations: v2Operations },
22
- [circuits_1.CircuitId.AtomicQueryMTPV2OnChain]: { maxQueriesCount: 1, supportedOperations: v2Operations },
31
+ [circuits_1.CircuitId.AtomicQueryMTPV2OnChain]: {
32
+ maxQueriesCount: 1,
33
+ supportedOperations: v2OnChainOperations
34
+ },
23
35
  [circuits_1.CircuitId.AtomicQuerySigV2]: { maxQueriesCount: 1, supportedOperations: v2Operations },
24
- [circuits_1.CircuitId.AtomicQuerySigV2OnChain]: { maxQueriesCount: 1, supportedOperations: v2Operations },
36
+ [circuits_1.CircuitId.AtomicQuerySigV2OnChain]: {
37
+ maxQueriesCount: 1,
38
+ supportedOperations: v2OnChainOperations
39
+ },
25
40
  [circuits_1.CircuitId.AtomicQueryV3]: { maxQueriesCount: 1, supportedOperations: allOperations },
26
41
  [circuits_1.CircuitId.AtomicQueryV3OnChain]: { maxQueriesCount: 1, supportedOperations: allOperations },
27
42
  [circuits_1.CircuitId.AuthV2]: { maxQueriesCount: 0, supportedOperations: [] },
@@ -88,7 +103,6 @@ class InputGenerator {
88
103
  circuitInputs.signature = signature;
89
104
  circuitInputs.challenge = params.challenge;
90
105
  const query = circuitQueries[0];
91
- query.operator = this.transformV2QueryOperator(query.operator);
92
106
  circuitInputs.query = query;
93
107
  circuitInputs.claim = {
94
108
  issuerID: circuitClaimData.issuerId,
@@ -147,7 +161,6 @@ class InputGenerator {
147
161
  circuitInputs.profileNonce = BigInt(params.authProfileNonce);
148
162
  circuitInputs.skipClaimRevocationCheck = params.skipRevocation;
149
163
  const query = circuitQueries[0];
150
- query.operator = this.transformV2QueryOperator(query.operator);
151
164
  circuitInputs.query = query;
152
165
  circuitInputs.currentTimeStamp = (0, js_iden3_core_1.getUnixTimestamp)(new Date());
153
166
  if (authClaimData.treeState) {
@@ -98,10 +98,12 @@ const betweenOperator = (a, b) => {
98
98
  if (!Array.isArray(b) || b.length !== 2) {
99
99
  throw new Error('$between/$nonbetween operator value should be 2 elements array');
100
100
  }
101
+ const [min, max] = b.map(BigInt);
102
+ const predicate = (val) => val >= min && val <= max;
101
103
  if (Array.isArray(a)) {
102
- return a.every((val) => val >= b[0] && val <= b[1]);
104
+ return a.map(BigInt).every(predicate);
103
105
  }
104
- return a >= b[0] && a <= b[1];
106
+ return predicate(BigInt(a));
105
107
  };
106
108
  exports.comparatorOptions = {
107
109
  $noop: () => true,
@@ -111,7 +113,7 @@ exports.comparatorOptions = {
111
113
  $in: (a, b) => inOperator(a, b),
112
114
  $nin: (a, b) => !inOperator(a, b),
113
115
  $gt: (a, b) => greaterThan(a, b),
114
- $lt: (a, b) => !greaterThan(a, b),
116
+ $lt: (a, b) => !greaterThanOrEqual(a, b),
115
117
  $ne: (a, b) => !equalsComparator(a, b),
116
118
  $gte: (a, b) => greaterThanOrEqual(a, b),
117
119
  $lte: (a, b) => lessThanOrEqual(a, b),
@@ -7,6 +7,15 @@ import { isEthereumIdentity } from '../../utils';
7
7
  const allOperations = Object.values(QueryOperators);
8
8
  const v2Operations = [
9
9
  Operators.NOOP,
10
+ Operators.EQ,
11
+ Operators.LT,
12
+ Operators.GT,
13
+ Operators.IN,
14
+ Operators.NIN,
15
+ Operators.NE,
16
+ Operators.SD
17
+ ];
18
+ const v2OnChainOperations = [
10
19
  Operators.EQ,
11
20
  Operators.LT,
12
21
  Operators.GT,
@@ -16,9 +25,15 @@ const v2Operations = [
16
25
  ];
17
26
  export const circuitValidator = {
18
27
  [CircuitId.AtomicQueryMTPV2]: { maxQueriesCount: 1, supportedOperations: v2Operations },
19
- [CircuitId.AtomicQueryMTPV2OnChain]: { maxQueriesCount: 1, supportedOperations: v2Operations },
28
+ [CircuitId.AtomicQueryMTPV2OnChain]: {
29
+ maxQueriesCount: 1,
30
+ supportedOperations: v2OnChainOperations
31
+ },
20
32
  [CircuitId.AtomicQuerySigV2]: { maxQueriesCount: 1, supportedOperations: v2Operations },
21
- [CircuitId.AtomicQuerySigV2OnChain]: { maxQueriesCount: 1, supportedOperations: v2Operations },
33
+ [CircuitId.AtomicQuerySigV2OnChain]: {
34
+ maxQueriesCount: 1,
35
+ supportedOperations: v2OnChainOperations
36
+ },
22
37
  [CircuitId.AtomicQueryV3]: { maxQueriesCount: 1, supportedOperations: allOperations },
23
38
  [CircuitId.AtomicQueryV3OnChain]: { maxQueriesCount: 1, supportedOperations: allOperations },
24
39
  [CircuitId.AuthV2]: { maxQueriesCount: 0, supportedOperations: [] },
@@ -85,7 +100,6 @@ export class InputGenerator {
85
100
  circuitInputs.signature = signature;
86
101
  circuitInputs.challenge = params.challenge;
87
102
  const query = circuitQueries[0];
88
- query.operator = this.transformV2QueryOperator(query.operator);
89
103
  circuitInputs.query = query;
90
104
  circuitInputs.claim = {
91
105
  issuerID: circuitClaimData.issuerId,
@@ -144,7 +158,6 @@ export class InputGenerator {
144
158
  circuitInputs.profileNonce = BigInt(params.authProfileNonce);
145
159
  circuitInputs.skipClaimRevocationCheck = params.skipRevocation;
146
160
  const query = circuitQueries[0];
147
- query.operator = this.transformV2QueryOperator(query.operator);
148
161
  circuitInputs.query = query;
149
162
  circuitInputs.currentTimeStamp = getUnixTimestamp(new Date());
150
163
  if (authClaimData.treeState) {
@@ -95,10 +95,12 @@ const betweenOperator = (a, b) => {
95
95
  if (!Array.isArray(b) || b.length !== 2) {
96
96
  throw new Error('$between/$nonbetween operator value should be 2 elements array');
97
97
  }
98
+ const [min, max] = b.map(BigInt);
99
+ const predicate = (val) => val >= min && val <= max;
98
100
  if (Array.isArray(a)) {
99
- return a.every((val) => val >= b[0] && val <= b[1]);
101
+ return a.map(BigInt).every(predicate);
100
102
  }
101
- return a >= b[0] && a <= b[1];
103
+ return predicate(BigInt(a));
102
104
  };
103
105
  export const comparatorOptions = {
104
106
  $noop: () => true,
@@ -108,7 +110,7 @@ export const comparatorOptions = {
108
110
  $in: (a, b) => inOperator(a, b),
109
111
  $nin: (a, b) => !inOperator(a, b),
110
112
  $gt: (a, b) => greaterThan(a, b),
111
- $lt: (a, b) => !greaterThan(a, b),
113
+ $lt: (a, b) => !greaterThanOrEqual(a, b),
112
114
  $ne: (a, b) => !equalsComparator(a, b),
113
115
  $gte: (a, b) => greaterThanOrEqual(a, b),
114
116
  $lte: (a, b) => lessThanOrEqual(a, b),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xpolygonid/js-sdk",
3
- "version": "1.21.0",
3
+ "version": "1.21.3",
4
4
  "description": "SDK to work with Polygon ID",
5
5
  "main": "dist/node/cjs/index.js",
6
6
  "module": "dist/node/esm/index.js",