@0xpolygonid/js-sdk 1.17.5 → 1.17.6

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.
@@ -21,45 +21,29 @@ class Query {
21
21
  throw new Error(CircuitError.EmptyQueryValue);
22
22
  }
23
23
  validateValueArraySize(maxArrSize) {
24
- switch (this.values.length) {
25
- case 0: {
26
- const zeroArrSizeOps = [comparer_1.Operators.NOOP, comparer_1.Operators.SD, comparer_1.Operators.NULLIFY];
27
- if (!zeroArrSizeOps.includes(this.operator)) {
28
- throw new Error(CircuitError.InvalidValuesArrSize);
29
- }
30
- return;
31
- }
32
- case 1: {
33
- const oneArrSizeOps = [
34
- comparer_1.Operators.EQ,
35
- comparer_1.Operators.LT,
36
- comparer_1.Operators.GT,
37
- comparer_1.Operators.NE,
38
- comparer_1.Operators.LTE,
39
- comparer_1.Operators.GTE,
40
- comparer_1.Operators.EXISTS
41
- ];
42
- if (!oneArrSizeOps.includes(this.operator)) {
43
- throw new Error(CircuitError.InvalidValuesArrSize);
44
- }
45
- return;
46
- }
47
- case 2: {
48
- const twoArrSizeOps = [comparer_1.Operators.BETWEEN, comparer_1.Operators.NONBETWEEN];
49
- if (!twoArrSizeOps.includes(this.operator)) {
50
- throw new Error(CircuitError.InvalidValuesArrSize);
51
- }
52
- return;
53
- }
54
- default: {
55
- const maxArrSizeOps = [comparer_1.Operators.IN, comparer_1.Operators.NIN];
56
- if (!maxArrSizeOps.includes(this.operator)) {
57
- throw new Error(CircuitError.InvalidOperationType);
58
- }
59
- if (!this.values.length || this.values.length > maxArrSize) {
60
- throw new Error(CircuitError.InvalidValuesArrSize);
61
- }
62
- }
24
+ if ([comparer_1.Operators.NOOP, comparer_1.Operators.SD, comparer_1.Operators.NULLIFY].includes(this.operator) &&
25
+ this.values.length !== 0) {
26
+ throw new Error(CircuitError.InvalidValuesArrSize);
27
+ }
28
+ else if ([
29
+ comparer_1.Operators.EQ,
30
+ comparer_1.Operators.LT,
31
+ comparer_1.Operators.GT,
32
+ comparer_1.Operators.NE,
33
+ comparer_1.Operators.LTE,
34
+ comparer_1.Operators.GTE,
35
+ comparer_1.Operators.EXISTS
36
+ ].includes(this.operator) &&
37
+ this.values.length !== 1) {
38
+ throw new Error(CircuitError.InvalidValuesArrSize);
39
+ }
40
+ else if ([comparer_1.Operators.BETWEEN, comparer_1.Operators.NONBETWEEN].includes(this.operator) &&
41
+ this.values.length !== 2) {
42
+ throw new Error(CircuitError.InvalidValuesArrSize);
43
+ }
44
+ else if ([comparer_1.Operators.IN, comparer_1.Operators.NIN].includes(this.operator) &&
45
+ this.values.length > maxArrSize) {
46
+ throw new Error(CircuitError.InvalidValuesArrSize);
63
47
  }
64
48
  }
65
49
  }
@@ -148,6 +148,7 @@ var PaymentType;
148
148
  var SupportedCurrencies;
149
149
  (function (SupportedCurrencies) {
150
150
  SupportedCurrencies["ETH"] = "ETH";
151
+ SupportedCurrencies["MATIC"] = "MATIC";
151
152
  })(SupportedCurrencies = exports.SupportedCurrencies || (exports.SupportedCurrencies = {}));
152
153
  /**
153
154
  * DisplayMethodType type for display method
@@ -18,45 +18,29 @@ export class Query {
18
18
  throw new Error(CircuitError.EmptyQueryValue);
19
19
  }
20
20
  validateValueArraySize(maxArrSize) {
21
- switch (this.values.length) {
22
- case 0: {
23
- const zeroArrSizeOps = [Operators.NOOP, Operators.SD, Operators.NULLIFY];
24
- if (!zeroArrSizeOps.includes(this.operator)) {
25
- throw new Error(CircuitError.InvalidValuesArrSize);
26
- }
27
- return;
28
- }
29
- case 1: {
30
- const oneArrSizeOps = [
31
- Operators.EQ,
32
- Operators.LT,
33
- Operators.GT,
34
- Operators.NE,
35
- Operators.LTE,
36
- Operators.GTE,
37
- Operators.EXISTS
38
- ];
39
- if (!oneArrSizeOps.includes(this.operator)) {
40
- throw new Error(CircuitError.InvalidValuesArrSize);
41
- }
42
- return;
43
- }
44
- case 2: {
45
- const twoArrSizeOps = [Operators.BETWEEN, Operators.NONBETWEEN];
46
- if (!twoArrSizeOps.includes(this.operator)) {
47
- throw new Error(CircuitError.InvalidValuesArrSize);
48
- }
49
- return;
50
- }
51
- default: {
52
- const maxArrSizeOps = [Operators.IN, Operators.NIN];
53
- if (!maxArrSizeOps.includes(this.operator)) {
54
- throw new Error(CircuitError.InvalidOperationType);
55
- }
56
- if (!this.values.length || this.values.length > maxArrSize) {
57
- throw new Error(CircuitError.InvalidValuesArrSize);
58
- }
59
- }
21
+ if ([Operators.NOOP, Operators.SD, Operators.NULLIFY].includes(this.operator) &&
22
+ this.values.length !== 0) {
23
+ throw new Error(CircuitError.InvalidValuesArrSize);
24
+ }
25
+ else if ([
26
+ Operators.EQ,
27
+ Operators.LT,
28
+ Operators.GT,
29
+ Operators.NE,
30
+ Operators.LTE,
31
+ Operators.GTE,
32
+ Operators.EXISTS
33
+ ].includes(this.operator) &&
34
+ this.values.length !== 1) {
35
+ throw new Error(CircuitError.InvalidValuesArrSize);
36
+ }
37
+ else if ([Operators.BETWEEN, Operators.NONBETWEEN].includes(this.operator) &&
38
+ this.values.length !== 2) {
39
+ throw new Error(CircuitError.InvalidValuesArrSize);
40
+ }
41
+ else if ([Operators.IN, Operators.NIN].includes(this.operator) &&
42
+ this.values.length > maxArrSize) {
43
+ throw new Error(CircuitError.InvalidValuesArrSize);
60
44
  }
61
45
  }
62
46
  }
@@ -145,6 +145,7 @@ export var PaymentType;
145
145
  export var SupportedCurrencies;
146
146
  (function (SupportedCurrencies) {
147
147
  SupportedCurrencies["ETH"] = "ETH";
148
+ SupportedCurrencies["MATIC"] = "MATIC";
148
149
  })(SupportedCurrencies || (SupportedCurrencies = {}));
149
150
  /**
150
151
  * DisplayMethodType type for display method
@@ -1,5 +1,5 @@
1
1
  import { BasicMessage } from '../';
2
- import { PaymentRequestDataType, PaymentRequestType, PaymentType } from '../../../verifiable';
2
+ import { PaymentRequestDataType, PaymentRequestType, PaymentType, SupportedCurrencies } from '../../../verifiable';
3
3
  import { PROTOCOL_MESSAGE_TYPE } from '../../constants';
4
4
  /** @beta PaymentRequestMessage is struct the represents payment-request message */
5
5
  export type PaymentRequestMessage = BasicMessage & {
@@ -29,7 +29,7 @@ export type PaymentRequestDataInfo = {
29
29
  id: string;
30
30
  chainId: string;
31
31
  address: string;
32
- currency: string;
32
+ currency: SupportedCurrencies;
33
33
  signature?: string;
34
34
  };
35
35
  /** @beta PaymentMessage is struct the represents payment message */
@@ -115,7 +115,8 @@ export declare enum PaymentType {
115
115
  * @enum {number}
116
116
  */
117
117
  export declare enum SupportedCurrencies {
118
- ETH = "ETH"
118
+ ETH = "ETH",
119
+ MATIC = "MATIC"
119
120
  }
120
121
  /**
121
122
  * DisplayMethodType type for display method
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xpolygonid/js-sdk",
3
- "version": "1.17.5",
3
+ "version": "1.17.6",
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",