@0xpolygonid/js-sdk 1.17.5 → 1.17.7
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/dist/browser/esm/index.js +375 -356
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/browser/umd/index.js +398 -405
- package/dist/browser/umd/index.js.map +1 -1
- package/dist/node/cjs/circuits/models.js +23 -39
- package/dist/node/cjs/credentials/status/sparse-merkle-tree.js +1 -6
- package/dist/node/cjs/storage/blockchain/onchain-revocation.js +3 -9
- package/dist/node/cjs/verifiable/constants.js +1 -0
- package/dist/node/cjs/verifiable/proof.js +4 -4
- package/dist/node/esm/circuits/models.js +23 -39
- package/dist/node/esm/credentials/status/sparse-merkle-tree.js +1 -6
- package/dist/node/esm/storage/blockchain/onchain-revocation.js +3 -9
- package/dist/node/esm/verifiable/constants.js +1 -0
- package/dist/node/esm/verifiable/proof.js +4 -4
- package/dist/types/credentials/status/sparse-merkle-tree.d.ts +2 -8
- package/dist/types/iden3comm/types/protocol/payment.d.ts +2 -2
- package/dist/types/verifiable/constants.d.ts +2 -1
- package/dist/types/verifiable/proof.d.ts +2 -2
- package/package.json +4 -4
|
@@ -21,45 +21,29 @@ class Query {
|
|
|
21
21
|
throw new Error(CircuitError.EmptyQueryValue);
|
|
22
22
|
}
|
|
23
23
|
validateValueArraySize(maxArrSize) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
}
|
|
@@ -31,13 +31,8 @@ exports.IssuerResolver = IssuerResolver;
|
|
|
31
31
|
* @returns {RevocationStatus} RevocationStatus
|
|
32
32
|
*/
|
|
33
33
|
const toRevocationStatus = ({ issuer, mtp }) => {
|
|
34
|
-
const p = js_merkletree_1.Proof.fromJSON({
|
|
35
|
-
nodeAux: mtp.node_aux,
|
|
36
|
-
existence: mtp.existence,
|
|
37
|
-
siblings: mtp.siblings
|
|
38
|
-
});
|
|
39
34
|
return {
|
|
40
|
-
mtp:
|
|
35
|
+
mtp: js_merkletree_1.Proof.fromJSON(mtp),
|
|
41
36
|
issuer
|
|
42
37
|
};
|
|
43
38
|
};
|
|
@@ -99,18 +99,12 @@ class OnChainRevocationStorage {
|
|
|
99
99
|
let nodeAux = undefined;
|
|
100
100
|
const siblings = mtp.siblings?.map((s) => s.toString());
|
|
101
101
|
if (mtp.auxExistence) {
|
|
102
|
-
const auxIndex = BigInt(mtp.auxIndex.toString());
|
|
103
|
-
const auxValue = BigInt(mtp.auxValue.toString());
|
|
104
102
|
nodeAux = {
|
|
105
|
-
key: auxIndex.toString(),
|
|
106
|
-
value: auxValue.toString()
|
|
103
|
+
key: mtp.auxIndex.toString(),
|
|
104
|
+
value: mtp.auxValue.toString()
|
|
107
105
|
};
|
|
108
106
|
}
|
|
109
|
-
return js_merkletree_1.Proof.fromJSON({
|
|
110
|
-
existence: mtp.existence,
|
|
111
|
-
nodeAux,
|
|
112
|
-
siblings
|
|
113
|
-
});
|
|
107
|
+
return js_merkletree_1.Proof.fromJSON({ existence: mtp.existence, node_aux: nodeAux, siblings });
|
|
114
108
|
}
|
|
115
109
|
}
|
|
116
110
|
exports.OnChainRevocationStorage = OnChainRevocationStorage;
|
|
@@ -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
|
|
@@ -54,11 +54,11 @@ class Iden3SparseMerkleTreeProof {
|
|
|
54
54
|
const notEmpties = ne instanceof Uint8Array ? ne : new Uint8Array(Object.values(ne));
|
|
55
55
|
const siblingsHashes = obj?.mtp?.siblings.map((h) => js_merkletree_1.Hash.fromString(JSON.stringify(h)));
|
|
56
56
|
const allSiblings = js_merkletree_1.Proof.buildAllSiblings(obj?.mtp?.depth, notEmpties, siblingsHashes);
|
|
57
|
-
let nodeAux =
|
|
58
|
-
if (
|
|
57
|
+
let nodeAux = obj.mtp.nodeAux || obj.mtp.node_aux;
|
|
58
|
+
if (nodeAux) {
|
|
59
59
|
nodeAux = {
|
|
60
|
-
key: js_merkletree_1.Hash.fromString(JSON.stringify(
|
|
61
|
-
value: js_merkletree_1.Hash.fromString(JSON.stringify(
|
|
60
|
+
key: js_merkletree_1.Hash.fromString(JSON.stringify(nodeAux.key)),
|
|
61
|
+
value: js_merkletree_1.Hash.fromString(JSON.stringify(nodeAux.value))
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
64
|
mtp = new js_merkletree_1.Proof({ existence: obj?.mtp.existence, nodeAux: nodeAux, siblings: allSiblings });
|
|
@@ -18,45 +18,29 @@ export class Query {
|
|
|
18
18
|
throw new Error(CircuitError.EmptyQueryValue);
|
|
19
19
|
}
|
|
20
20
|
validateValueArraySize(maxArrSize) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
}
|
|
@@ -27,13 +27,8 @@ export class IssuerResolver {
|
|
|
27
27
|
* @returns {RevocationStatus} RevocationStatus
|
|
28
28
|
*/
|
|
29
29
|
export const toRevocationStatus = ({ issuer, mtp }) => {
|
|
30
|
-
const p = Proof.fromJSON({
|
|
31
|
-
nodeAux: mtp.node_aux,
|
|
32
|
-
existence: mtp.existence,
|
|
33
|
-
siblings: mtp.siblings
|
|
34
|
-
});
|
|
35
30
|
return {
|
|
36
|
-
mtp:
|
|
31
|
+
mtp: Proof.fromJSON(mtp),
|
|
37
32
|
issuer
|
|
38
33
|
};
|
|
39
34
|
};
|
|
@@ -93,17 +93,11 @@ export class OnChainRevocationStorage {
|
|
|
93
93
|
let nodeAux = undefined;
|
|
94
94
|
const siblings = mtp.siblings?.map((s) => s.toString());
|
|
95
95
|
if (mtp.auxExistence) {
|
|
96
|
-
const auxIndex = BigInt(mtp.auxIndex.toString());
|
|
97
|
-
const auxValue = BigInt(mtp.auxValue.toString());
|
|
98
96
|
nodeAux = {
|
|
99
|
-
key: auxIndex.toString(),
|
|
100
|
-
value: auxValue.toString()
|
|
97
|
+
key: mtp.auxIndex.toString(),
|
|
98
|
+
value: mtp.auxValue.toString()
|
|
101
99
|
};
|
|
102
100
|
}
|
|
103
|
-
return Proof.fromJSON({
|
|
104
|
-
existence: mtp.existence,
|
|
105
|
-
nodeAux,
|
|
106
|
-
siblings
|
|
107
|
-
});
|
|
101
|
+
return Proof.fromJSON({ existence: mtp.existence, node_aux: nodeAux, siblings });
|
|
108
102
|
}
|
|
109
103
|
}
|
|
@@ -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
|
|
@@ -51,11 +51,11 @@ export class Iden3SparseMerkleTreeProof {
|
|
|
51
51
|
const notEmpties = ne instanceof Uint8Array ? ne : new Uint8Array(Object.values(ne));
|
|
52
52
|
const siblingsHashes = obj?.mtp?.siblings.map((h) => Hash.fromString(JSON.stringify(h)));
|
|
53
53
|
const allSiblings = Proof.buildAllSiblings(obj?.mtp?.depth, notEmpties, siblingsHashes);
|
|
54
|
-
let nodeAux =
|
|
55
|
-
if (
|
|
54
|
+
let nodeAux = obj.mtp.nodeAux || obj.mtp.node_aux;
|
|
55
|
+
if (nodeAux) {
|
|
56
56
|
nodeAux = {
|
|
57
|
-
key: Hash.fromString(JSON.stringify(
|
|
58
|
-
value: Hash.fromString(JSON.stringify(
|
|
57
|
+
key: Hash.fromString(JSON.stringify(nodeAux.key)),
|
|
58
|
+
value: Hash.fromString(JSON.stringify(nodeAux.value))
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
61
|
mtp = new Proof({ existence: obj?.mtp.existence, nodeAux: nodeAux, siblings: allSiblings });
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CredentialStatus, RevocationStatus, Issuer } from '../../verifiable';
|
|
2
2
|
import { CredentialStatusResolver } from './resolver';
|
|
3
|
+
import { ProofJSON } from '@iden3/js-merkletree';
|
|
3
4
|
/**
|
|
4
5
|
* IssuerResolver is a class that allows to interact with the issuer's http endpoint to get revocation status.
|
|
5
6
|
*
|
|
@@ -25,14 +26,7 @@ export declare class IssuerResolver implements CredentialStatusResolver {
|
|
|
25
26
|
*/
|
|
26
27
|
export interface RevocationStatusResponse {
|
|
27
28
|
issuer: Issuer;
|
|
28
|
-
mtp:
|
|
29
|
-
existence: boolean;
|
|
30
|
-
siblings: string[];
|
|
31
|
-
node_aux: {
|
|
32
|
-
key: string;
|
|
33
|
-
value: string;
|
|
34
|
-
};
|
|
35
|
-
};
|
|
29
|
+
mtp: ProofJSON;
|
|
36
30
|
}
|
|
37
31
|
/**
|
|
38
32
|
* toRevocationStatus is a result of fetching credential status with type SparseMerkleTreeProof converts to RevocationStatus
|
|
@@ -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:
|
|
32
|
+
currency: SupportedCurrencies;
|
|
33
33
|
signature?: string;
|
|
34
34
|
};
|
|
35
35
|
/** @beta PaymentMessage is struct the represents payment message */
|
|
@@ -70,7 +70,7 @@ export declare class Iden3SparseMerkleTreeProof {
|
|
|
70
70
|
mtp: {
|
|
71
71
|
existence: boolean;
|
|
72
72
|
siblings: string[];
|
|
73
|
-
|
|
73
|
+
node_aux: {
|
|
74
74
|
key: string;
|
|
75
75
|
value: string;
|
|
76
76
|
} | undefined;
|
|
@@ -127,7 +127,7 @@ export declare class BJJSignatureProof2021 {
|
|
|
127
127
|
mtp: {
|
|
128
128
|
existence: boolean;
|
|
129
129
|
siblings: string[];
|
|
130
|
-
|
|
130
|
+
node_aux: {
|
|
131
131
|
key: string;
|
|
132
132
|
value: string;
|
|
133
133
|
} | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xpolygonid/js-sdk",
|
|
3
|
-
"version": "1.17.
|
|
3
|
+
"version": "1.17.7",
|
|
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",
|
|
@@ -89,9 +89,9 @@
|
|
|
89
89
|
"peerDependencies": {
|
|
90
90
|
"@iden3/js-crypto": "1.1.0",
|
|
91
91
|
"@iden3/js-iden3-core": "1.4.0",
|
|
92
|
-
"@iden3/js-jsonld-merklization": "1.
|
|
93
|
-
"@iden3/js-jwz": "1.
|
|
94
|
-
"@iden3/js-merkletree": "1.
|
|
92
|
+
"@iden3/js-jsonld-merklization": "1.4.1",
|
|
93
|
+
"@iden3/js-jwz": "1.7.1",
|
|
94
|
+
"@iden3/js-merkletree": "1.3.1",
|
|
95
95
|
"ffjavascript": "0.3.0",
|
|
96
96
|
"rfc4648": "1.5.3",
|
|
97
97
|
"snarkjs": "0.7.4"
|