@0xpolygonid/js-sdk 1.7.4 → 1.8.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 (108) hide show
  1. package/dist/browser/esm/index.js +13086 -11852
  2. package/dist/browser/esm/index.js.map +1 -1
  3. package/dist/browser/umd/index.js +13115 -11861
  4. package/dist/browser/umd/index.js.map +1 -1
  5. package/dist/node/cjs/circuits/atomic-query-mtp-v2.js +3 -3
  6. package/dist/node/cjs/circuits/atomic-query-sig-v2.js +3 -3
  7. package/dist/node/cjs/circuits/atomic-query-v3.js +18 -13
  8. package/dist/node/cjs/circuits/auth-v2.js +1 -1
  9. package/dist/node/cjs/circuits/index.js +0 -1
  10. package/dist/node/cjs/circuits/linked-multi-query.js +16 -6
  11. package/dist/node/cjs/circuits/models.js +0 -5
  12. package/dist/node/cjs/credentials/credential-wallet.js +1 -3
  13. package/dist/node/cjs/credentials/index.js +1 -0
  14. package/dist/node/cjs/credentials/models.js +2 -0
  15. package/dist/node/cjs/credentials/status/credential-status-publisher.js +23 -4
  16. package/dist/node/cjs/iden3comm/constants.js +3 -1
  17. package/dist/node/cjs/iden3comm/handlers/auth.js +119 -14
  18. package/dist/node/cjs/kms/key-providers/sec256k1-provider.js +5 -2
  19. package/dist/node/cjs/proof/common.js +3 -4
  20. package/dist/node/cjs/proof/index.js +2 -1
  21. package/dist/node/cjs/proof/proof-service.js +22 -2
  22. package/dist/node/cjs/proof/provers/index.js +19 -0
  23. package/dist/node/cjs/proof/{inputs-generator.js → provers/inputs-generator.js} +43 -40
  24. package/dist/node/cjs/proof/{prover.js → provers/prover.js} +1 -1
  25. package/dist/node/cjs/proof/verifiers/index.js +18 -0
  26. package/dist/node/cjs/proof/verifiers/pub-signals-verifier.js +344 -0
  27. package/dist/node/cjs/proof/verifiers/query.js +190 -0
  28. package/dist/node/cjs/schema-processor/json/parser.js +39 -198
  29. package/dist/node/cjs/schema-processor/utils.js +13 -26
  30. package/dist/node/cjs/storage/blockchain/state.js +53 -8
  31. package/dist/node/cjs/storage/filters/jsonQuery.js +2 -2
  32. package/dist/node/cjs/utils/compare-func.js +11 -0
  33. package/dist/node/cjs/utils/index.js +2 -0
  34. package/dist/node/cjs/utils/message-bus.js +73 -0
  35. package/dist/node/cjs/verifiable/core-utils.js +234 -0
  36. package/dist/node/cjs/verifiable/credential.js +139 -1
  37. package/dist/node/cjs/verifiable/index.js +1 -0
  38. package/dist/node/esm/circuits/atomic-query-mtp-v2.js +3 -3
  39. package/dist/node/esm/circuits/atomic-query-sig-v2.js +3 -3
  40. package/dist/node/esm/circuits/atomic-query-v3.js +18 -13
  41. package/dist/node/esm/circuits/auth-v2.js +2 -2
  42. package/dist/node/esm/circuits/index.js +0 -1
  43. package/dist/node/esm/circuits/linked-multi-query.js +16 -6
  44. package/dist/node/esm/circuits/models.js +0 -5
  45. package/dist/node/esm/credentials/credential-wallet.js +1 -3
  46. package/dist/node/esm/credentials/index.js +1 -0
  47. package/dist/node/esm/credentials/models.js +1 -0
  48. package/dist/node/esm/credentials/status/credential-status-publisher.js +23 -4
  49. package/dist/node/esm/iden3comm/constants.js +3 -1
  50. package/dist/node/esm/iden3comm/handlers/auth.js +116 -13
  51. package/dist/node/esm/kms/key-providers/sec256k1-provider.js +5 -2
  52. package/dist/node/esm/proof/common.js +4 -5
  53. package/dist/node/esm/proof/index.js +2 -1
  54. package/dist/node/esm/proof/proof-service.js +22 -2
  55. package/dist/node/esm/proof/provers/index.js +3 -0
  56. package/dist/node/esm/proof/{inputs-generator.js → provers/inputs-generator.js} +40 -37
  57. package/dist/node/esm/proof/{prover.js → provers/prover.js} +1 -1
  58. package/dist/node/esm/proof/verifiers/index.js +2 -0
  59. package/dist/node/esm/proof/verifiers/pub-signals-verifier.js +340 -0
  60. package/dist/node/esm/proof/verifiers/query.js +186 -0
  61. package/dist/node/esm/schema-processor/json/parser.js +40 -199
  62. package/dist/node/esm/schema-processor/utils.js +13 -26
  63. package/dist/node/esm/storage/blockchain/state.js +53 -8
  64. package/dist/node/esm/storage/filters/jsonQuery.js +2 -2
  65. package/dist/node/esm/utils/compare-func.js +7 -0
  66. package/dist/node/esm/utils/index.js +2 -0
  67. package/dist/node/esm/utils/message-bus.js +66 -0
  68. package/dist/node/esm/verifiable/core-utils.js +200 -0
  69. package/dist/node/esm/verifiable/credential.js +118 -3
  70. package/dist/node/esm/verifiable/index.js +1 -0
  71. package/dist/types/circuits/index.d.ts +0 -1
  72. package/dist/types/circuits/linked-multi-query.d.ts +3 -3
  73. package/dist/types/circuits/models.d.ts +0 -4
  74. package/dist/types/credentials/credential-wallet.d.ts +2 -60
  75. package/dist/types/credentials/index.d.ts +1 -0
  76. package/dist/types/credentials/models.d.ts +68 -0
  77. package/dist/types/credentials/status/credential-status-publisher.d.ts +2 -0
  78. package/dist/types/iden3comm/constants.d.ts +1 -0
  79. package/dist/types/iden3comm/handlers/auth.d.ts +53 -13
  80. package/dist/types/iden3comm/types/protocol/credentials.d.ts +16 -0
  81. package/dist/types/identity/identity-wallet.d.ts +3 -1
  82. package/dist/types/kms/key-providers/sec256k1-provider.d.ts +1 -1
  83. package/dist/types/proof/index.d.ts +2 -1
  84. package/dist/types/proof/proof-service.d.ts +28 -3
  85. package/dist/types/proof/provers/index.d.ts +3 -0
  86. package/dist/types/proof/{inputs-generator.d.ts → provers/inputs-generator.d.ts} +15 -9
  87. package/dist/types/proof/{prover.d.ts → provers/prover.d.ts} +2 -2
  88. package/dist/types/proof/verifiers/index.d.ts +2 -0
  89. package/dist/types/proof/verifiers/pub-signals-verifier.d.ts +58 -0
  90. package/dist/types/proof/verifiers/query.d.ts +25 -0
  91. package/dist/types/schema-processor/json/parser.d.ts +47 -28
  92. package/dist/types/schema-processor/utils.d.ts +9 -4
  93. package/dist/types/storage/blockchain/state.d.ts +5 -1
  94. package/dist/types/storage/interfaces/state.d.ts +8 -0
  95. package/dist/types/utils/compare-func.d.ts +1 -0
  96. package/dist/types/utils/index.d.ts +2 -0
  97. package/dist/types/utils/message-bus.d.ts +62 -0
  98. package/dist/types/verifiable/core-utils.d.ts +84 -0
  99. package/dist/types/verifiable/credential.d.ts +11 -1
  100. package/dist/types/verifiable/index.d.ts +1 -0
  101. package/dist/types/verifiable/proof.d.ts +4 -0
  102. package/package.json +10 -10
  103. package/dist/node/cjs/circuits/linked-nullifier.js +0 -57
  104. package/dist/node/esm/circuits/linked-nullifier.js +0 -52
  105. package/dist/types/circuits/linked-nullifier.d.ts +0 -37
  106. /package/dist/node/cjs/proof/{witness_calculator.js → provers/witness_calculator.js} +0 -0
  107. /package/dist/node/esm/proof/{witness_calculator.js → provers/witness_calculator.js} +0 -0
  108. /package/dist/types/proof/{witness_calculator.d.ts → provers/witness_calculator.d.ts} +0 -0
@@ -1,9 +1,10 @@
1
1
  import { BJJSignatureProof2021, Iden3SparseMerkleTreeProof, CredentialStatus, RefreshService } from './proof';
2
2
  import { Claim } from '@iden3/js-iden3-core';
3
- import { ProofType } from './constants';
4
3
  import { Proof } from '@iden3/js-merkletree';
5
4
  import { Merklizer, Options } from '@iden3/js-jsonld-merklization';
6
5
  import { CredentialStatusResolverRegistry } from '../credentials';
6
+ import { ProofType } from './constants';
7
+ import { CoreClaimCreationOptions } from './core-utils';
7
8
  /**
8
9
  * W3C Verifiable credential
9
10
  *
@@ -44,6 +45,13 @@ export declare class W3CCredential {
44
45
  * @returns {*} {(Claim | undefined)}
45
46
  */
46
47
  getCoreClaimFromProof(proofType: ProofType): Claim | undefined;
48
+ /**
49
+ * gets core claim representation from W3CCredential
50
+ *
51
+ * @param {CoreClaimParsingOptions} [opts] - options to create core claim
52
+ * @returns {*} {(Promise<Claim>)}
53
+ */
54
+ toCoreClaim(opts?: CoreClaimCreationOptions): Promise<Claim>;
47
55
  /**
48
56
  * checks BJJSignatureProof2021 in W3C VC
49
57
  *
@@ -62,6 +70,7 @@ export declare class W3CCredential {
62
70
  * @returns {*} {(boolean)}
63
71
  */
64
72
  verifyProof(proofType: ProofType, resolverURL: string, opts?: W3CProofVerificationOptions): Promise<boolean>;
73
+ private verifyCoreClaimMatch;
65
74
  private verifyBJJSignatureProof;
66
75
  private verifyIden3SparseMerkleTreeProof;
67
76
  private getProofByType;
@@ -123,4 +132,5 @@ export interface RevocationStatus {
123
132
  */
124
133
  export interface W3CProofVerificationOptions {
125
134
  credStatusResolverRegistry?: CredentialStatusResolverRegistry;
135
+ merklizeOptions?: Options;
126
136
  }
@@ -3,3 +3,4 @@ export * from './presentation';
3
3
  export * from './proof';
4
4
  export * from './schema';
5
5
  export * from './constants';
6
+ export * from './core-utils';
@@ -3,6 +3,7 @@ import { ProofType, CredentialStatusType, RefreshServiceType } from './constants
3
3
  import { TreeState } from '../circuits';
4
4
  import { Signature } from '@iden3/js-crypto';
5
5
  import { Claim, DID } from '@iden3/js-iden3-core';
6
+ import { JSONObject } from '../iden3comm';
6
7
  /**
7
8
  * Represents the published state of the issuer
8
9
  *
@@ -161,6 +162,9 @@ export interface ProofQuery {
161
162
  context?: string;
162
163
  type?: string;
163
164
  skipClaimRevocationCheck?: boolean;
165
+ proofType?: string;
166
+ groupId?: number;
167
+ params?: JSONObject;
164
168
  }
165
169
  /**
166
170
  * Proof with MerkleTree info
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xpolygonid/js-sdk",
3
- "version": "1.7.4",
3
+ "version": "1.8.0",
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",
@@ -24,7 +24,7 @@
24
24
  "build": "npm run clean && npm run build:node && npm run build:browser",
25
25
  "build:node": "npm run build:tsc && npm run build:esm",
26
26
  "build:esm": "tsc --outDir dist/node/esm --declaration --declarationDir dist/types",
27
- "build:browser": "rollup -c rollup.config.mjs",
27
+ "build:browser": "rollup -c rollup.config.mjs --failAfterWarnings",
28
28
  "build:tsc": "tsc --module commonjs --outDir dist/node/cjs",
29
29
  "doc:extract": "ts-node ./scripts/doc-extract.ts",
30
30
  "doc:documenter": "ts-node ./scripts/doc-documenter.ts",
@@ -33,8 +33,7 @@
33
33
  "tsc:declaration:watch": "tsc --watch --module commonjs --emitDeclarationOnly",
34
34
  "test": "env TS_NODE_COMPILER_OPTIONS='{\"strict\": false, \"module\": \"CommonJS\"}' mocha",
35
35
  "lint": "eslint --fix --ext .ts src/** tests/**",
36
- "format": "prettier --write \"src/**/*.ts\" \"tests/**/*.ts\"",
37
- "deps:check": "madge --circular --extensions ts ./"
36
+ "format": "prettier --write \"src/**/*.ts\" \"tests/**/*.ts\""
38
37
  },
39
38
  "repository": {
40
39
  "type": "git",
@@ -67,6 +66,7 @@
67
66
  "@types/jsonld": "^1.5.11",
68
67
  "@types/mocha": "^10.0.3",
69
68
  "@types/node": "^20.8.9",
69
+ "@types/pubsub-js": "^1.8.6",
70
70
  "@types/uuid": "^9.0.6",
71
71
  "@typescript-eslint/eslint-plugin": "^5.41.0",
72
72
  "chai": "^4.3.10",
@@ -75,7 +75,6 @@
75
75
  "chokidar": "^3.5.3",
76
76
  "eslint-config-prettier": "^8.8.0",
77
77
  "eslint-plugin-prettier": "^4.2.1",
78
- "madge": "^6.1.0",
79
78
  "mocha": "10.2.0",
80
79
  "prettier": "^2.7.1",
81
80
  "rimraf": "^5.0.5",
@@ -88,11 +87,11 @@
88
87
  "@iden3/js-crypto": "1.0.3",
89
88
  "@iden3/js-iden3-core": "1.2.1",
90
89
  "@iden3/js-jsonld-merklization": "1.1.2",
91
- "@iden3/js-jwz": "1.2.1",
90
+ "@iden3/js-jwz": "1.3.0",
92
91
  "@iden3/js-merkletree": "1.1.2",
93
- "ffjavascript": "0.2.62",
94
- "snarkjs": "0.7.2",
95
- "rfc4648": "1.5.3"
92
+ "ffjavascript": "0.2.63",
93
+ "rfc4648": "1.5.3",
94
+ "snarkjs": "0.7.3"
96
95
  },
97
96
  "dependencies": {
98
97
  "ajv": "8.12.0",
@@ -102,8 +101,9 @@
102
101
  "elliptic": "6.5.4",
103
102
  "ethers": "6.8.0",
104
103
  "idb-keyval": "6.2.0",
105
- "js-sha3": "0.9.2",
104
+ "js-sha3": "0.9.3",
106
105
  "jsonld": "8.3.1",
106
+ "pubsub-js": "1.9.4",
107
107
  "uuid": "9.0.1"
108
108
  },
109
109
  "browserslist": {
@@ -1,57 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LinkedNullifierPubSignals = exports.LinkedNullifierInputs = void 0;
4
- const js_iden3_core_1 = require("@iden3/js-iden3-core");
5
- const utils_1 = require("../utils");
6
- /**
7
- * LinkedNullifier circuit representation
8
- * Inputs and public signals declaration, marshalling and parsing
9
- *
10
- * @beta
11
- * @class LinkedNullifierInputs
12
- */
13
- class LinkedNullifierInputs {
14
- // InputsMarshal returns Circom private inputs for nullifier.circom
15
- inputsMarshal() {
16
- const s = {
17
- linkNonce: this.linkNonce.toString(),
18
- issuerClaim: this.issuerClaim.marshalJson(),
19
- userGenesisID: this.id.bigInt().toString(),
20
- claimSubjectProfileNonce: this.claimSubjectProfileNonce.toString(),
21
- claimSchema: this.issuerClaim.getSchemaHash().bigInt().toString(),
22
- verifierID: this.verifierID?.bigInt().toString() ?? '0',
23
- nullifierSessionID: this.nullifierSessionID.toString()
24
- };
25
- return utils_1.byteEncoder.encode(JSON.stringify(s));
26
- }
27
- }
28
- exports.LinkedNullifierInputs = LinkedNullifierInputs;
29
- // LinkedNullifierPubSignals nullifier.circom public signals
30
- /**
31
- * public signals
32
- *
33
- * @beta
34
- * @class LinkedNullifierPubSignals
35
- */
36
- class LinkedNullifierPubSignals {
37
- /**
38
- * PubSignalsUnmarshal unmarshal nullifier.circom public inputs to LinkedNullifierPubSignals
39
- *
40
- * @beta
41
- * @param {Uint8Array} data
42
- * @returns LinkedNullifierPubSignals
43
- */
44
- pubSignalsUnmarshal(data) {
45
- const len = 4;
46
- const sVals = JSON.parse(utils_1.byteDecoder.decode(data));
47
- if (sVals.length !== len) {
48
- throw new Error(`invalid number of Output values expected ${len} got ${sVals.length}`);
49
- }
50
- this.nullifier = BigInt(sVals[0]);
51
- this.linkID = BigInt(sVals[1]);
52
- this.verifierID = js_iden3_core_1.Id.fromBigInt(BigInt(sVals[2]));
53
- this.nullifierSessionID = BigInt(sVals[3]);
54
- return this;
55
- }
56
- }
57
- exports.LinkedNullifierPubSignals = LinkedNullifierPubSignals;
@@ -1,52 +0,0 @@
1
- import { Id } from '@iden3/js-iden3-core';
2
- import { byteDecoder, byteEncoder } from '../utils';
3
- /**
4
- * LinkedNullifier circuit representation
5
- * Inputs and public signals declaration, marshalling and parsing
6
- *
7
- * @beta
8
- * @class LinkedNullifierInputs
9
- */
10
- export class LinkedNullifierInputs {
11
- // InputsMarshal returns Circom private inputs for nullifier.circom
12
- inputsMarshal() {
13
- const s = {
14
- linkNonce: this.linkNonce.toString(),
15
- issuerClaim: this.issuerClaim.marshalJson(),
16
- userGenesisID: this.id.bigInt().toString(),
17
- claimSubjectProfileNonce: this.claimSubjectProfileNonce.toString(),
18
- claimSchema: this.issuerClaim.getSchemaHash().bigInt().toString(),
19
- verifierID: this.verifierID?.bigInt().toString() ?? '0',
20
- nullifierSessionID: this.nullifierSessionID.toString()
21
- };
22
- return byteEncoder.encode(JSON.stringify(s));
23
- }
24
- }
25
- // LinkedNullifierPubSignals nullifier.circom public signals
26
- /**
27
- * public signals
28
- *
29
- * @beta
30
- * @class LinkedNullifierPubSignals
31
- */
32
- export class LinkedNullifierPubSignals {
33
- /**
34
- * PubSignalsUnmarshal unmarshal nullifier.circom public inputs to LinkedNullifierPubSignals
35
- *
36
- * @beta
37
- * @param {Uint8Array} data
38
- * @returns LinkedNullifierPubSignals
39
- */
40
- pubSignalsUnmarshal(data) {
41
- const len = 4;
42
- const sVals = JSON.parse(byteDecoder.decode(data));
43
- if (sVals.length !== len) {
44
- throw new Error(`invalid number of Output values expected ${len} got ${sVals.length}`);
45
- }
46
- this.nullifier = BigInt(sVals[0]);
47
- this.linkID = BigInt(sVals[1]);
48
- this.verifierID = Id.fromBigInt(BigInt(sVals[2]));
49
- this.nullifierSessionID = BigInt(sVals[3]);
50
- return this;
51
- }
52
- }
@@ -1,37 +0,0 @@
1
- import { Claim, Id } from '@iden3/js-iden3-core';
2
- /**
3
- * LinkedNullifier circuit representation
4
- * Inputs and public signals declaration, marshalling and parsing
5
- *
6
- * @beta
7
- * @class LinkedNullifierInputs
8
- */
9
- export declare class LinkedNullifierInputs {
10
- linkNonce: bigint;
11
- issuerClaim: Claim;
12
- id: Id;
13
- claimSubjectProfileNonce: bigint;
14
- verifierID?: Id;
15
- nullifierSessionID: bigint;
16
- inputsMarshal(): Uint8Array;
17
- }
18
- /**
19
- * public signals
20
- *
21
- * @beta
22
- * @class LinkedNullifierPubSignals
23
- */
24
- export declare class LinkedNullifierPubSignals {
25
- nullifier: bigint;
26
- linkID: bigint;
27
- verifierID: Id;
28
- nullifierSessionID: bigint;
29
- /**
30
- * PubSignalsUnmarshal unmarshal nullifier.circom public inputs to LinkedNullifierPubSignals
31
- *
32
- * @beta
33
- * @param {Uint8Array} data
34
- * @returns LinkedNullifierPubSignals
35
- */
36
- pubSignalsUnmarshal(data: Uint8Array): LinkedNullifierPubSignals;
37
- }