@0xpolygonid/js-sdk 1.23.0 → 1.25.1

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 (71) hide show
  1. package/dist/browser/esm/index.js +2573 -392
  2. package/dist/browser/esm/index.js.map +1 -1
  3. package/dist/browser/umd/index.js +2575 -390
  4. package/dist/browser/umd/index.js.map +1 -1
  5. package/dist/node/cjs/circuits/auth-v2.js +6 -0
  6. package/dist/node/cjs/credentials/credential-wallet.js +11 -78
  7. package/dist/node/cjs/credentials/index.js +1 -0
  8. package/dist/node/cjs/credentials/status/did-resolver-revocation.js +21 -0
  9. package/dist/node/cjs/iden3comm/handlers/contract-request.js +7 -1
  10. package/dist/node/cjs/iden3comm/handlers/fetch.js +32 -0
  11. package/dist/node/cjs/iden3comm/handlers/payment.js +30 -24
  12. package/dist/node/cjs/iden3comm/utils/contract-request.utils.js +59 -0
  13. package/dist/node/cjs/iden3comm/utils/index.js +1 -0
  14. package/dist/node/cjs/proof/proof-service.js +6 -0
  15. package/dist/node/cjs/storage/blockchain/abi/ERC20.json +1 -0
  16. package/dist/node/cjs/storage/blockchain/did-resolver-readonly-storage.js +72 -0
  17. package/dist/node/cjs/storage/blockchain/{erc20-permit-sig.js → erc20-helper.js} +14 -1
  18. package/dist/node/cjs/storage/blockchain/index.js +3 -1
  19. package/dist/node/cjs/storage/blockchain/onchain-issuer-adapter/non-merklized/version/v0.0.1/onchain-non-merklized-issuer-adapter.js +245 -0
  20. package/dist/node/cjs/storage/blockchain/onchain-issuer.js +82 -0
  21. package/dist/node/cjs/storage/blockchain/onchain-zkp-verifier.js +90 -77
  22. package/dist/node/cjs/storage/interfaces/index.js +1 -0
  23. package/dist/node/cjs/storage/interfaces/onchain-issuer.js +2 -0
  24. package/dist/node/cjs/utils/did-helper.js +11 -6
  25. package/dist/node/cjs/verifiable/constants.js +2 -2
  26. package/dist/node/cjs/verifiable/credential.js +86 -0
  27. package/dist/node/esm/circuits/auth-v2.js +6 -0
  28. package/dist/node/esm/credentials/credential-wallet.js +12 -79
  29. package/dist/node/esm/credentials/index.js +1 -0
  30. package/dist/node/esm/credentials/status/did-resolver-revocation.js +17 -0
  31. package/dist/node/esm/iden3comm/handlers/contract-request.js +7 -1
  32. package/dist/node/esm/iden3comm/handlers/fetch.js +32 -0
  33. package/dist/node/esm/iden3comm/handlers/payment.js +30 -24
  34. package/dist/node/esm/iden3comm/utils/contract-request.utils.js +54 -0
  35. package/dist/node/esm/iden3comm/utils/index.js +1 -0
  36. package/dist/node/esm/proof/proof-service.js +6 -0
  37. package/dist/node/esm/storage/blockchain/abi/ERC20.json +1 -0
  38. package/dist/node/esm/storage/blockchain/did-resolver-readonly-storage.js +68 -0
  39. package/dist/node/esm/storage/blockchain/{erc20-permit-sig.js → erc20-helper.js} +14 -2
  40. package/dist/node/esm/storage/blockchain/index.js +3 -1
  41. package/dist/node/esm/storage/blockchain/onchain-issuer-adapter/non-merklized/version/v0.0.1/onchain-non-merklized-issuer-adapter.js +241 -0
  42. package/dist/node/esm/storage/blockchain/onchain-issuer.js +78 -0
  43. package/dist/node/esm/storage/blockchain/onchain-zkp-verifier.js +92 -79
  44. package/dist/node/esm/storage/interfaces/index.js +1 -0
  45. package/dist/node/esm/storage/interfaces/onchain-issuer.js +1 -0
  46. package/dist/node/esm/utils/did-helper.js +11 -6
  47. package/dist/node/esm/verifiable/constants.js +2 -2
  48. package/dist/node/esm/verifiable/credential.js +88 -2
  49. package/dist/types/circuits/auth-v2.d.ts +3 -2
  50. package/dist/types/credentials/credential-wallet.d.ts +0 -6
  51. package/dist/types/credentials/index.d.ts +1 -0
  52. package/dist/types/credentials/models.d.ts +8 -0
  53. package/dist/types/credentials/status/did-resolver-revocation.d.ts +7 -0
  54. package/dist/types/iden3comm/handlers/fetch.d.ts +8 -0
  55. package/dist/types/iden3comm/handlers/payment.d.ts +7 -10
  56. package/dist/types/iden3comm/types/protocol/payment.d.ts +6 -5
  57. package/dist/types/iden3comm/utils/contract-request.utils.d.ts +20 -0
  58. package/dist/types/iden3comm/utils/index.d.ts +1 -0
  59. package/dist/types/proof/proof-service.d.ts +10 -0
  60. package/dist/types/storage/blockchain/did-resolver-readonly-storage.d.ts +16 -0
  61. package/dist/types/storage/blockchain/{erc20-permit-sig.d.ts → erc20-helper.d.ts} +8 -1
  62. package/dist/types/storage/blockchain/index.d.ts +3 -1
  63. package/dist/types/storage/blockchain/onchain-issuer-adapter/non-merklized/version/v0.0.1/onchain-non-merklized-issuer-adapter.d.ts +66 -0
  64. package/dist/types/storage/blockchain/onchain-issuer.d.ts +40 -0
  65. package/dist/types/storage/blockchain/onchain-zkp-verifier.d.ts +13 -12
  66. package/dist/types/storage/entities/state.d.ts +2 -0
  67. package/dist/types/storage/interfaces/index.d.ts +1 -0
  68. package/dist/types/storage/interfaces/onchain-issuer.d.ts +12 -0
  69. package/dist/types/verifiable/constants.d.ts +2 -2
  70. package/dist/types/verifiable/credential.d.ts +15 -2
  71. package/package.json +3 -2
@@ -1396,7 +1396,7 @@ var PolygonIdSdk = (function (exports) {
1396
1396
  }
1397
1397
  };
1398
1398
  const resolveDIDDocumentAuth = async (did, resolveURL, state) => {
1399
- let url = `${resolveURL}/${did.string().replace(/:/g, '%3A')}`;
1399
+ let url = `${resolveURL}/${encodeURIComponent(did.string())}`;
1400
1400
  if (state) {
1401
1401
  url += `?state=${state.hex()}`;
1402
1402
  }
@@ -1412,11 +1412,11 @@ var PolygonIdSdk = (function (exports) {
1412
1412
  return emptyDID;
1413
1413
  }
1414
1414
  const resolveDidDocument = async (did, resolverUrl, opts) => {
1415
- let didString = did.string().replace(/:/g, '%3A');
1415
+ let didString = encodeURIComponent(did.string());
1416
1416
  // for gist resolve we have to `hide` user did (look into resolver implementation)
1417
1417
  const isGistRequest = opts?.gist && !opts.state;
1418
1418
  if (isGistRequest) {
1419
- didString = emptyStateDID(did).string();
1419
+ didString = encodeURIComponent(emptyStateDID(did).string());
1420
1420
  }
1421
1421
  let url = `${resolverUrl}/1.0/identifiers/${didString}`;
1422
1422
  if (opts?.signature) {
@@ -1428,9 +1428,14 @@ var PolygonIdSdk = (function (exports) {
1428
1428
  if (opts?.gist) {
1429
1429
  url += `${url.includes('?') ? '&' : '?'}gist=${opts.gist.hex()}`;
1430
1430
  }
1431
- const resp = await fetch(url);
1432
- const data = await resp.json();
1433
- return data;
1431
+ try {
1432
+ const resp = await fetch(url);
1433
+ const data = await resp.json();
1434
+ return data;
1435
+ }
1436
+ catch (e) {
1437
+ throw new Error(`Failed to resolve DID document for ${did} ${e}`);
1438
+ }
1434
1439
  };
1435
1440
  const buildDIDFromEthPubKey = (didType, pubKeyEth) => {
1436
1441
  // Use Keccak-256 hash function to get public key hash
@@ -7872,6 +7877,7 @@ var PolygonIdSdk = (function (exports) {
7872
7877
  /**
7873
7878
  * Media types for Payment supported currencies
7874
7879
  * @beta
7880
+ * @deprecated
7875
7881
  * @enum {string}
7876
7882
  */
7877
7883
  exports.SupportedCurrencies = void 0;
@@ -7880,8 +7886,7 @@ var PolygonIdSdk = (function (exports) {
7880
7886
  SupportedCurrencies["ETH_WEI"] = "ETHWEI";
7881
7887
  SupportedCurrencies["ETH_GWEI"] = "ETHGWEI";
7882
7888
  SupportedCurrencies["MATIC"] = "MATIC";
7883
- SupportedCurrencies["USDT"] = "USDT";
7884
- SupportedCurrencies["USDC"] = "USDC";
7889
+ SupportedCurrencies["POL"] = "POL";
7885
7890
  })(exports.SupportedCurrencies || (exports.SupportedCurrencies = {}));
7886
7891
  /**
7887
7892
  * Supported features for payment-request
@@ -20038,6 +20043,92 @@ var PolygonIdSdk = (function (exports) {
20038
20043
  this.credentialSubject = {};
20039
20044
  this.issuer = '';
20040
20045
  }
20046
+ /**
20047
+ *
20048
+ * @param issuer - DID of the issuer
20049
+ * @param request - Credential request
20050
+ * @returns - W3C Credential
20051
+ */
20052
+ static fromCredentialRequest(issuer, request) {
20053
+ if (!request.id) {
20054
+ throw new Error('Credential id is required');
20055
+ }
20056
+ if (!request.context) {
20057
+ throw new Error('Credential context is required');
20058
+ }
20059
+ const context = [
20060
+ VerifiableConstants.JSONLD_SCHEMA.W3C_CREDENTIAL_2018,
20061
+ VerifiableConstants.JSONLD_SCHEMA.IDEN3_CREDENTIAL,
20062
+ ...request.context
20063
+ ];
20064
+ const credentialType = [
20065
+ VerifiableConstants.CREDENTIAL_TYPE.W3C_VERIFIABLE_CREDENTIAL,
20066
+ request.type
20067
+ ];
20068
+ const credentialSubject = request.credentialSubject;
20069
+ credentialSubject['type'] = request.type;
20070
+ const cr = new W3CCredential();
20071
+ cr.id = request.id;
20072
+ cr['@context'] = context;
20073
+ cr.type = credentialType;
20074
+ cr.credentialSubject = credentialSubject;
20075
+ cr.issuer = issuer.string();
20076
+ cr.credentialSchema = {
20077
+ id: request.credentialSchema,
20078
+ type: VerifiableConstants.JSON_SCHEMA_VALIDATOR
20079
+ };
20080
+ cr.credentialStatus = W3CCredential.buildCredentialStatus(request, issuer);
20081
+ request.expiration && (cr.expirationDate = new Date(request.expiration).toISOString());
20082
+ request.refreshService && (cr.refreshService = request.refreshService);
20083
+ request.displayMethod && (cr.displayMethod = request.displayMethod);
20084
+ request.issuanceDate && (cr.issuanceDate = new Date(request.issuanceDate).toISOString());
20085
+ return cr;
20086
+ }
20087
+ /**
20088
+ * Builds credential status
20089
+ * @param {CredentialRequest} request
20090
+ * @returns `CredentialStatus`
20091
+ */
20092
+ static buildCredentialStatus(request, issuer) {
20093
+ const credentialStatus = {
20094
+ id: request.revocationOpts.id,
20095
+ type: request.revocationOpts.type,
20096
+ revocationNonce: request.revocationOpts.nonce
20097
+ };
20098
+ switch (request.revocationOpts.type) {
20099
+ case exports.CredentialStatusType.SparseMerkleTreeProof:
20100
+ return {
20101
+ ...credentialStatus,
20102
+ id: `${credentialStatus.id.replace(/\/$/, '')}/${credentialStatus.revocationNonce}`
20103
+ };
20104
+ case exports.CredentialStatusType.Iden3ReverseSparseMerkleTreeProof:
20105
+ return {
20106
+ ...credentialStatus,
20107
+ id: request.revocationOpts.issuerState
20108
+ ? `${credentialStatus.id.replace(/\/$/, '')}/node?state=${request.revocationOpts.issuerState}`
20109
+ : `${credentialStatus.id.replace(/\/$/, '')}`
20110
+ };
20111
+ case exports.CredentialStatusType.Iden3OnchainSparseMerkleTreeProof2023: {
20112
+ const issuerId = Q$2.idFromDID(issuer);
20113
+ const chainId = et$2(Q$2.blockchainFromId(issuerId), Q$2.networkIdFromId(issuerId));
20114
+ const searchParams = [
20115
+ ['revocationNonce', request.revocationOpts.nonce?.toString() || ''],
20116
+ ['contractAddress', `${chainId}:${request.revocationOpts.id}`],
20117
+ ['state', request.revocationOpts.issuerState || '']
20118
+ ]
20119
+ .filter(([, value]) => Boolean(value))
20120
+ .map(([key, value]) => `${key}=${value}`)
20121
+ .join('&');
20122
+ return {
20123
+ ...credentialStatus,
20124
+ // `[did]:[methodid]:[chain]:[network]:[id]/credentialStatus?(revocationNonce=value)&[contractAddress=[chainID]:[contractAddress]]&(state=issuerState)`
20125
+ id: `${issuer.string()}/credentialStatus?${searchParams}`
20126
+ };
20127
+ }
20128
+ default:
20129
+ return credentialStatus;
20130
+ }
20131
+ }
20041
20132
  toJSON() {
20042
20133
  return {
20043
20134
  ...this,
@@ -51282,6 +51373,12 @@ var PolygonIdSdk = (function (exports) {
51282
51373
  this.GISTRoot = V$1.fromString(sVals[2]);
51283
51374
  return this;
51284
51375
  }
51376
+ getStatesInfo() {
51377
+ return {
51378
+ states: [],
51379
+ gists: [{ id: this.userID, root: this.GISTRoot }]
51380
+ };
51381
+ }
51285
51382
  }
51286
51383
 
51287
51384
  /**
@@ -53598,23 +53695,8 @@ var PolygonIdSdk = (function (exports) {
53598
53695
  constructor(_configs, _opts) {
53599
53696
  this._configs = _configs;
53600
53697
  this._opts = _opts;
53601
- /**
53602
- * supported circuits
53603
- */
53604
- this._supportedCircuits = [
53605
- exports.CircuitId.AtomicQueryMTPV2OnChain,
53606
- exports.CircuitId.AtomicQuerySigV2OnChain,
53607
- exports.CircuitId.AtomicQueryV3OnChain
53608
- ];
53609
- /**
53610
- * abi coder to encode/decode structures to solidity bytes
53611
- */
53612
- this._abiCoder = new AbiCoder();
53613
53698
  }
53614
- /**
53615
- * {@inheritDoc IOnChainZKPVerifier.prepareTxArgsSubmitV1}
53616
- */
53617
- async prepareTxArgsSubmitV1(txData, zkProofResponse) {
53699
+ static async prepareTxArgsSubmitV1(txData, zkProofResponse) {
53618
53700
  if (txData.method_id.replace('0x', '') !== exports.FunctionSignatures.SubmitZKPResponseV1) {
53619
53701
  throw new Error(`prepareTxArgsSubmitV1 function doesn't implement requested method id. Only '0x${exports.FunctionSignatures.SubmitZKPResponseV1}' is supported.`);
53620
53702
  }
@@ -53632,6 +53714,12 @@ var PolygonIdSdk = (function (exports) {
53632
53714
  ];
53633
53715
  return payload;
53634
53716
  }
53717
+ /**
53718
+ * {@inheritDoc IOnChainZKPVerifier.prepareTxArgsSubmitV1}
53719
+ */
53720
+ async prepareTxArgsSubmitV1(txData, zkProofResponse) {
53721
+ return OnChainZKPVerifier.prepareTxArgsSubmitV1(txData, zkProofResponse);
53722
+ }
53635
53723
  /**
53636
53724
  * {@inheritDoc IOnChainZKPVerifier.submitZKPResponse}
53637
53725
  */
@@ -53721,55 +53809,60 @@ var PolygonIdSdk = (function (exports) {
53721
53809
  const { txnHash } = await transactionService.sendTransactionRequest(ethSigner, request);
53722
53810
  return new Map().set(txnHash, zkProofResponses);
53723
53811
  }
53724
- async prepareTxArgsSubmitV2(txData, zkProofResponses) {
53812
+ static getCrossChainResolvers(source, txDataChainId, type, didResolverUrl) {
53813
+ return [
53814
+ ...new Set(source.map((info) => JSON.stringify({
53815
+ id: info.id.string(),
53816
+ [type]: type === 'gist' ? info.root?.string() : info.state?.string()
53817
+ })))
53818
+ ].reduce((acc, s) => {
53819
+ const info = JSON.parse(s);
53820
+ const id = $$1.fromString(info.id);
53821
+ const chainId = rt$2(Q$2.parseFromId(id));
53822
+ if (txDataChainId === chainId) {
53823
+ return acc;
53824
+ }
53825
+ const promise = this.resolveDidDocumentEip712MessageAndSignature(Q$2.parseFromId($$1.fromString(info.id)), didResolverUrl, {
53826
+ [type]: V$1.fromString(info[type])
53827
+ });
53828
+ return [...acc, promise];
53829
+ }, []);
53830
+ }
53831
+ static async prepareTxArgsSubmitV2(resolverUrl, txData, zkProofResponses) {
53725
53832
  if (txData.method_id.replace('0x', '') !== exports.FunctionSignatures.SubmitZKPResponseV2) {
53726
53833
  throw new Error(`submit cross chain doesn't implement requested method id. Only '0x${exports.FunctionSignatures.SubmitZKPResponseV2}' is supported.`);
53727
53834
  }
53728
- if (!this._opts?.didResolverUrl) {
53729
- throw new Error(`did resolver url required for crosschain verification`);
53730
- }
53731
- const gistUpdateArr = [];
53732
- const stateUpdateArr = [];
53835
+ const gistUpdates = [];
53836
+ const stateUpdates = [];
53733
53837
  const payload = [];
53734
- // Resolved gists and states to avoid duplicate requests
53735
- const gistUpdateResolutionsPending = [];
53736
- const stateUpdateResolutionsPending = [];
53838
+ const emptyBytes = '0x';
53737
53839
  for (const zkProof of zkProofResponses) {
53738
- const requestID = zkProof.id;
53739
- const inputs = zkProof.pub_signals;
53740
- if (!this._supportedCircuits.includes(zkProof.circuitId)) {
53840
+ const { id: requestId, pub_signals: inputs } = zkProof;
53841
+ const proofCircuitId = zkProof.circuitId;
53842
+ if (!this._supportedCircuits.includes(proofCircuitId)) {
53741
53843
  throw new Error(`Circuit ${zkProof.circuitId} not supported by OnChainZKPVerifier`);
53742
53844
  }
53845
+ if (inputs.length === 0) {
53846
+ payload.push({
53847
+ requestId: requestId,
53848
+ zkProof: emptyBytes,
53849
+ data: emptyBytes
53850
+ });
53851
+ continue;
53852
+ }
53743
53853
  const zkProofEncoded = this.packZkpProof(inputs, zkProof.proof.pi_a.slice(0, 2), [
53744
53854
  [zkProof.proof.pi_b[0][1], zkProof.proof.pi_b[0][0]],
53745
53855
  [zkProof.proof.pi_b[1][1], zkProof.proof.pi_b[1][0]]
53746
53856
  ], zkProof.proof.pi_c.slice(0, 2));
53747
- const stateInfo = this.getOnChainGistRootStatePubSignals(zkProof.circuitId, zkProof.pub_signals);
53748
- const gistUpdateResolutions = [];
53749
- for (const gist of stateInfo.gists) {
53750
- const gistResolutionPending = gistUpdateResolutionsPending.find((g) => g == JSON.stringify(gist));
53751
- if (gistResolutionPending) {
53752
- continue;
53753
- }
53754
- gistUpdateResolutionsPending.push(JSON.stringify(gist));
53755
- gistUpdateResolutions.push(this.resolveDidDocumentEip712MessageAndSignature(Q$2.parseFromId(gist.id), this._opts.didResolverUrl, { gist: gist.root }));
53756
- }
53757
- const stateUpdateResolutions = [];
53758
- for (const state of stateInfo.states) {
53759
- const stateResolutionPending = stateUpdateResolutionsPending.find((s) => s == JSON.stringify(state));
53760
- if (stateResolutionPending) {
53761
- continue;
53762
- }
53763
- stateUpdateResolutionsPending.push(JSON.stringify(state));
53764
- stateUpdateResolutions.push(this.resolveDidDocumentEip712MessageAndSignature(Q$2.parseFromId(state.id), this._opts.didResolverUrl, {
53765
- state: state.state
53766
- }));
53767
- }
53857
+ const stateInfo = this.getOnChainGistRootStatePubSignals(proofCircuitId, inputs);
53858
+ const chainId = txData.chain_id;
53859
+ const gistUpdateResolutions = this.getCrossChainResolvers(stateInfo.gists, chainId, 'gist', resolverUrl);
53860
+ const stateUpdateResolutions = this.getCrossChainResolvers(stateInfo.states, chainId, 'state', resolverUrl);
53768
53861
  if (gistUpdateResolutions.length > 0) {
53769
- gistUpdateArr.push(...(await Promise.all(gistUpdateResolutions)));
53862
+ gistUpdates.push(...(await Promise.all(gistUpdateResolutions)));
53770
53863
  }
53771
53864
  if (stateUpdateResolutions.length > 0) {
53772
- stateUpdateArr.push(...(await Promise.all(stateUpdateResolutions)));
53865
+ stateUpdates.push(...(await Promise.all(stateUpdateResolutions)));
53773
53866
  }
53774
53867
  const metadataArr = [];
53775
53868
  if (zkProof.vp) {
@@ -53785,20 +53878,28 @@ var PolygonIdSdk = (function (exports) {
53785
53878
  });
53786
53879
  }
53787
53880
  }
53788
- const metadata = metadataArr.length ? this.packMetadatas(metadataArr) : '0x';
53881
+ const metadata = metadataArr.length ? this.packMetadatas(metadataArr) : emptyBytes;
53789
53882
  payload.push({
53790
- requestId: requestID,
53883
+ requestId: requestId,
53791
53884
  zkProof: zkProofEncoded,
53792
53885
  data: metadata
53793
53886
  });
53794
53887
  }
53795
- const crossChainProofs = this.packCrossChainProofs(gistUpdateArr, stateUpdateArr);
53888
+ const crossChainProofs = gistUpdates.length || stateUpdates.length
53889
+ ? this.packCrossChainProofs(gistUpdates, stateUpdates)
53890
+ : emptyBytes;
53796
53891
  return [payload, crossChainProofs];
53797
53892
  }
53798
- packZkpProof(inputs, a, b, c) {
53799
- return this._abiCoder.encode(['uint256[] inputs', 'uint256[2]', 'uint256[2][2]', 'uint256[2]'], [inputs, a, b, c]);
53893
+ async prepareTxArgsSubmitV2(txData, zkProofResponses) {
53894
+ if (!this._opts?.didResolverUrl) {
53895
+ throw new Error(`did resolver url required for crosschain verification`);
53896
+ }
53897
+ return OnChainZKPVerifier.prepareTxArgsSubmitV2(this._opts.didResolverUrl, txData, zkProofResponses);
53898
+ }
53899
+ static packZkpProof(inputs, a, b, c) {
53900
+ return new AbiCoder().encode(['uint256[] inputs', 'uint256[2]', 'uint256[2][2]', 'uint256[2]'], [inputs, a, b, c]);
53800
53901
  }
53801
- packCrossChainProofs(gistUpdateArr, stateUpdateArr) {
53902
+ static packCrossChainProofs(gistUpdateArr, stateUpdateArr) {
53802
53903
  const proofs = [];
53803
53904
  for (const globalStateUpdate of gistUpdateArr) {
53804
53905
  proofs.push({
@@ -53812,10 +53913,10 @@ var PolygonIdSdk = (function (exports) {
53812
53913
  proof: this.packIdentityStateMsg(stateUpdate)
53813
53914
  });
53814
53915
  }
53815
- return this._abiCoder.encode(['tuple(' + 'string proofType,' + 'bytes proof' + ')[]'], [proofs]);
53916
+ return new AbiCoder().encode(['tuple(' + 'string proofType,' + 'bytes proof' + ')[]'], [proofs]);
53816
53917
  }
53817
- packGlobalStateMsg(msg) {
53818
- return this._abiCoder.encode([
53918
+ static packGlobalStateMsg(msg) {
53919
+ return new AbiCoder().encode([
53819
53920
  'tuple(' +
53820
53921
  'tuple(' +
53821
53922
  'uint256 timestamp,' +
@@ -53827,8 +53928,8 @@ var PolygonIdSdk = (function (exports) {
53827
53928
  ')'
53828
53929
  ], [msg]);
53829
53930
  }
53830
- packIdentityStateMsg(msg) {
53831
- return this._abiCoder.encode([
53931
+ static packIdentityStateMsg(msg) {
53932
+ return new AbiCoder().encode([
53832
53933
  'tuple(' +
53833
53934
  'tuple(' +
53834
53935
  'uint256 timestamp,' +
@@ -53840,27 +53941,20 @@ var PolygonIdSdk = (function (exports) {
53840
53941
  ')'
53841
53942
  ], [msg]);
53842
53943
  }
53843
- packMetadatas(metas) {
53844
- return this._abiCoder.encode(['tuple(' + 'string key,' + 'bytes value' + ')[]'], [metas]);
53944
+ static packMetadatas(metas) {
53945
+ return new AbiCoder().encode(['tuple(' + 'string key,' + 'bytes value' + ')[]'], [metas]);
53845
53946
  }
53846
- getOnChainGistRootStatePubSignals(onChainCircuitId, inputs) {
53847
- let atomicQueryPubSignals;
53848
- switch (onChainCircuitId) {
53849
- case exports.CircuitId.AtomicQueryMTPV2OnChain:
53850
- atomicQueryPubSignals = new AtomicQueryMTPV2OnChainPubSignals();
53851
- break;
53852
- case exports.CircuitId.AtomicQuerySigV2OnChain:
53853
- atomicQueryPubSignals = new AtomicQuerySigV2OnChainPubSignals();
53854
- break;
53855
- case exports.CircuitId.AtomicQueryV3OnChain:
53856
- atomicQueryPubSignals = new AtomicQueryV3OnChainPubSignals();
53857
- break;
53947
+ static getOnChainGistRootStatePubSignals(onChainCircuitId, inputs) {
53948
+ const PubSignals = this._supportedCircuitsPubSignalsMap[onChainCircuitId];
53949
+ if (!PubSignals) {
53950
+ throw new Error(`Circuit ${onChainCircuitId} not supported by OnChainZKPVerifier`);
53858
53951
  }
53952
+ const atomicQueryPubSignals = new PubSignals();
53859
53953
  const encodedInputs = byteEncoder.encode(JSON.stringify(inputs));
53860
53954
  atomicQueryPubSignals.pubSignalsUnmarshal(encodedInputs);
53861
53955
  return atomicQueryPubSignals.getStatesInfo();
53862
53956
  }
53863
- async resolveDidDocumentEip712MessageAndSignature(did, resolverUrl, opts) {
53957
+ static async resolveDidDocumentEip712MessageAndSignature(did, resolverUrl, opts) {
53864
53958
  const didDoc = await resolveDidDocument(did, resolverUrl, {
53865
53959
  ...opts,
53866
53960
  signature: exports.DIDDocumentSignature.EthereumEip712Signature2021
@@ -53893,6 +53987,21 @@ var PolygonIdSdk = (function (exports) {
53893
53987
  };
53894
53988
  }
53895
53989
  }
53990
+ /**
53991
+ * supported circuits
53992
+ */
53993
+ OnChainZKPVerifier._supportedCircuits = [
53994
+ exports.CircuitId.AuthV2,
53995
+ exports.CircuitId.AtomicQueryMTPV2OnChain,
53996
+ exports.CircuitId.AtomicQuerySigV2OnChain,
53997
+ exports.CircuitId.AtomicQueryV3OnChain
53998
+ ];
53999
+ OnChainZKPVerifier._supportedCircuitsPubSignalsMap = {
54000
+ [exports.CircuitId.AtomicQueryMTPV2OnChain]: AtomicQueryMTPV2OnChainPubSignals,
54001
+ [exports.CircuitId.AtomicQuerySigV2OnChain]: AtomicQuerySigV2OnChainPubSignals,
54002
+ [exports.CircuitId.AtomicQueryV3OnChain]: AtomicQueryV3OnChainPubSignals,
54003
+ [exports.CircuitId.AuthV2]: AuthV2PubSignals
54004
+ };
53896
54005
 
53897
54006
  var abi$1 = [
53898
54007
  {
@@ -54266,31 +54375,2279 @@ var PolygonIdSdk = (function (exports) {
54266
54375
  var abi = [
54267
54376
  {
54268
54377
  inputs: [
54378
+ {
54379
+ internalType: "uint256",
54380
+ name: "_userId",
54381
+ type: "uint256"
54382
+ },
54383
+ {
54384
+ internalType: "uint256",
54385
+ name: "_credentialId",
54386
+ type: "uint256"
54387
+ }
54269
54388
  ],
54270
- name: "ECDSAInvalidSignature",
54271
- type: "error"
54389
+ name: "getCredential",
54390
+ outputs: [
54391
+ {
54392
+ components: [
54393
+ {
54394
+ internalType: "uint256",
54395
+ name: "id",
54396
+ type: "uint256"
54397
+ },
54398
+ {
54399
+ internalType: "string[]",
54400
+ name: "context",
54401
+ type: "string[]"
54402
+ },
54403
+ {
54404
+ internalType: "string",
54405
+ name: "_type",
54406
+ type: "string"
54407
+ },
54408
+ {
54409
+ internalType: "uint64",
54410
+ name: "issuanceDate",
54411
+ type: "uint64"
54412
+ },
54413
+ {
54414
+ components: [
54415
+ {
54416
+ internalType: "string",
54417
+ name: "id",
54418
+ type: "string"
54419
+ },
54420
+ {
54421
+ internalType: "string",
54422
+ name: "_type",
54423
+ type: "string"
54424
+ }
54425
+ ],
54426
+ internalType: "struct INonMerklizedIssuer.CredentialSchema",
54427
+ name: "credentialSchema",
54428
+ type: "tuple"
54429
+ },
54430
+ {
54431
+ components: [
54432
+ {
54433
+ internalType: "string",
54434
+ name: "id",
54435
+ type: "string"
54436
+ },
54437
+ {
54438
+ internalType: "string",
54439
+ name: "_type",
54440
+ type: "string"
54441
+ }
54442
+ ],
54443
+ internalType: "struct INonMerklizedIssuer.DisplayMethod",
54444
+ name: "displayMethod",
54445
+ type: "tuple"
54446
+ }
54447
+ ],
54448
+ internalType: "struct INonMerklizedIssuer.CredentialData",
54449
+ name: "",
54450
+ type: "tuple"
54451
+ },
54452
+ {
54453
+ internalType: "uint256[8]",
54454
+ name: "",
54455
+ type: "uint256[8]"
54456
+ },
54457
+ {
54458
+ components: [
54459
+ {
54460
+ internalType: "string",
54461
+ name: "key",
54462
+ type: "string"
54463
+ },
54464
+ {
54465
+ internalType: "uint256",
54466
+ name: "value",
54467
+ type: "uint256"
54468
+ },
54469
+ {
54470
+ internalType: "bytes",
54471
+ name: "rawValue",
54472
+ type: "bytes"
54473
+ }
54474
+ ],
54475
+ internalType: "struct INonMerklizedIssuer.SubjectField[]",
54476
+ name: "",
54477
+ type: "tuple[]"
54478
+ }
54479
+ ],
54480
+ stateMutability: "view",
54481
+ type: "function"
54272
54482
  },
54273
54483
  {
54274
54484
  inputs: [
54485
+ ],
54486
+ name: "getCredentialAdapterVersion",
54487
+ outputs: [
54275
54488
  {
54276
- internalType: "uint256",
54277
- name: "length",
54278
- type: "uint256"
54489
+ internalType: "string",
54490
+ name: "",
54491
+ type: "string"
54279
54492
  }
54280
54493
  ],
54281
- name: "ECDSAInvalidSignatureLength",
54282
- type: "error"
54494
+ stateMutability: "view",
54495
+ type: "function"
54283
54496
  },
54284
54497
  {
54285
54498
  inputs: [
54286
54499
  {
54287
- internalType: "bytes32",
54288
- name: "s",
54289
- type: "bytes32"
54500
+ internalType: "uint256",
54501
+ name: "_userId",
54502
+ type: "uint256"
54290
54503
  }
54291
54504
  ],
54292
- name: "ECDSAInvalidSignatureS",
54293
- type: "error"
54505
+ name: "getUserCredentialIds",
54506
+ outputs: [
54507
+ {
54508
+ internalType: "uint256[]",
54509
+ name: "",
54510
+ type: "uint256[]"
54511
+ }
54512
+ ],
54513
+ stateMutability: "view",
54514
+ type: "function"
54515
+ }
54516
+ ];
54517
+
54518
+ /* Autogenerated file. Do not edit manually. */
54519
+ /* tslint:disable */
54520
+ /* eslint-disable */
54521
+ const _abi = [
54522
+ {
54523
+ inputs: [],
54524
+ name: 'CREDENTIAL_ADAPTER_VERSION',
54525
+ outputs: [
54526
+ {
54527
+ internalType: 'string',
54528
+ name: '',
54529
+ type: 'string'
54530
+ }
54531
+ ],
54532
+ stateMutability: 'view',
54533
+ type: 'function'
54534
+ },
54535
+ {
54536
+ inputs: [
54537
+ {
54538
+ internalType: 'uint256',
54539
+ name: 'claimIndexHash',
54540
+ type: 'uint256'
54541
+ }
54542
+ ],
54543
+ name: 'getClaimProof',
54544
+ outputs: [
54545
+ {
54546
+ components: [
54547
+ {
54548
+ internalType: 'uint256',
54549
+ name: 'root',
54550
+ type: 'uint256'
54551
+ },
54552
+ {
54553
+ internalType: 'bool',
54554
+ name: 'existence',
54555
+ type: 'bool'
54556
+ },
54557
+ {
54558
+ internalType: 'uint256[]',
54559
+ name: 'siblings',
54560
+ type: 'uint256[]'
54561
+ },
54562
+ {
54563
+ internalType: 'uint256',
54564
+ name: 'index',
54565
+ type: 'uint256'
54566
+ },
54567
+ {
54568
+ internalType: 'uint256',
54569
+ name: 'value',
54570
+ type: 'uint256'
54571
+ },
54572
+ {
54573
+ internalType: 'bool',
54574
+ name: 'auxExistence',
54575
+ type: 'bool'
54576
+ },
54577
+ {
54578
+ internalType: 'uint256',
54579
+ name: 'auxIndex',
54580
+ type: 'uint256'
54581
+ },
54582
+ {
54583
+ internalType: 'uint256',
54584
+ name: 'auxValue',
54585
+ type: 'uint256'
54586
+ }
54587
+ ],
54588
+ internalType: 'struct SmtLib.Proof',
54589
+ name: '',
54590
+ type: 'tuple'
54591
+ }
54592
+ ],
54593
+ stateMutability: 'view',
54594
+ type: 'function'
54595
+ },
54596
+ {
54597
+ inputs: [
54598
+ {
54599
+ internalType: 'uint256',
54600
+ name: 'claimIndexHash',
54601
+ type: 'uint256'
54602
+ },
54603
+ {
54604
+ internalType: 'uint256',
54605
+ name: 'root',
54606
+ type: 'uint256'
54607
+ }
54608
+ ],
54609
+ name: 'getClaimProofByRoot',
54610
+ outputs: [
54611
+ {
54612
+ components: [
54613
+ {
54614
+ internalType: 'uint256',
54615
+ name: 'root',
54616
+ type: 'uint256'
54617
+ },
54618
+ {
54619
+ internalType: 'bool',
54620
+ name: 'existence',
54621
+ type: 'bool'
54622
+ },
54623
+ {
54624
+ internalType: 'uint256[]',
54625
+ name: 'siblings',
54626
+ type: 'uint256[]'
54627
+ },
54628
+ {
54629
+ internalType: 'uint256',
54630
+ name: 'index',
54631
+ type: 'uint256'
54632
+ },
54633
+ {
54634
+ internalType: 'uint256',
54635
+ name: 'value',
54636
+ type: 'uint256'
54637
+ },
54638
+ {
54639
+ internalType: 'bool',
54640
+ name: 'auxExistence',
54641
+ type: 'bool'
54642
+ },
54643
+ {
54644
+ internalType: 'uint256',
54645
+ name: 'auxIndex',
54646
+ type: 'uint256'
54647
+ },
54648
+ {
54649
+ internalType: 'uint256',
54650
+ name: 'auxValue',
54651
+ type: 'uint256'
54652
+ }
54653
+ ],
54654
+ internalType: 'struct SmtLib.Proof',
54655
+ name: '',
54656
+ type: 'tuple'
54657
+ }
54658
+ ],
54659
+ stateMutability: 'view',
54660
+ type: 'function'
54661
+ },
54662
+ {
54663
+ inputs: [
54664
+ {
54665
+ internalType: 'uint256',
54666
+ name: 'claimIndexHash',
54667
+ type: 'uint256'
54668
+ }
54669
+ ],
54670
+ name: 'getClaimProofWithStateInfo',
54671
+ outputs: [
54672
+ {
54673
+ components: [
54674
+ {
54675
+ internalType: 'uint256',
54676
+ name: 'root',
54677
+ type: 'uint256'
54678
+ },
54679
+ {
54680
+ internalType: 'bool',
54681
+ name: 'existence',
54682
+ type: 'bool'
54683
+ },
54684
+ {
54685
+ internalType: 'uint256[]',
54686
+ name: 'siblings',
54687
+ type: 'uint256[]'
54688
+ },
54689
+ {
54690
+ internalType: 'uint256',
54691
+ name: 'index',
54692
+ type: 'uint256'
54693
+ },
54694
+ {
54695
+ internalType: 'uint256',
54696
+ name: 'value',
54697
+ type: 'uint256'
54698
+ },
54699
+ {
54700
+ internalType: 'bool',
54701
+ name: 'auxExistence',
54702
+ type: 'bool'
54703
+ },
54704
+ {
54705
+ internalType: 'uint256',
54706
+ name: 'auxIndex',
54707
+ type: 'uint256'
54708
+ },
54709
+ {
54710
+ internalType: 'uint256',
54711
+ name: 'auxValue',
54712
+ type: 'uint256'
54713
+ }
54714
+ ],
54715
+ internalType: 'struct SmtLib.Proof',
54716
+ name: '',
54717
+ type: 'tuple'
54718
+ },
54719
+ {
54720
+ components: [
54721
+ {
54722
+ internalType: 'uint256',
54723
+ name: 'state',
54724
+ type: 'uint256'
54725
+ },
54726
+ {
54727
+ internalType: 'uint256',
54728
+ name: 'claimsRoot',
54729
+ type: 'uint256'
54730
+ },
54731
+ {
54732
+ internalType: 'uint256',
54733
+ name: 'revocationsRoot',
54734
+ type: 'uint256'
54735
+ },
54736
+ {
54737
+ internalType: 'uint256',
54738
+ name: 'rootsRoot',
54739
+ type: 'uint256'
54740
+ }
54741
+ ],
54742
+ internalType: 'struct IdentityLib.StateInfo',
54743
+ name: '',
54744
+ type: 'tuple'
54745
+ }
54746
+ ],
54747
+ stateMutability: 'view',
54748
+ type: 'function'
54749
+ },
54750
+ {
54751
+ inputs: [],
54752
+ name: 'getClaimsTreeRoot',
54753
+ outputs: [
54754
+ {
54755
+ internalType: 'uint256',
54756
+ name: '',
54757
+ type: 'uint256'
54758
+ }
54759
+ ],
54760
+ stateMutability: 'view',
54761
+ type: 'function'
54762
+ },
54763
+ {
54764
+ inputs: [
54765
+ {
54766
+ internalType: 'uint256',
54767
+ name: '_userId',
54768
+ type: 'uint256'
54769
+ },
54770
+ {
54771
+ internalType: 'uint256',
54772
+ name: '_credentialId',
54773
+ type: 'uint256'
54774
+ }
54775
+ ],
54776
+ name: 'getCredential',
54777
+ outputs: [
54778
+ {
54779
+ components: [
54780
+ {
54781
+ internalType: 'uint256',
54782
+ name: 'id',
54783
+ type: 'uint256'
54784
+ },
54785
+ {
54786
+ internalType: 'string[]',
54787
+ name: 'context',
54788
+ type: 'string[]'
54789
+ },
54790
+ {
54791
+ internalType: 'string',
54792
+ name: '_type',
54793
+ type: 'string'
54794
+ },
54795
+ {
54796
+ internalType: 'uint64',
54797
+ name: 'issuanceDate',
54798
+ type: 'uint64'
54799
+ },
54800
+ {
54801
+ components: [
54802
+ {
54803
+ internalType: 'string',
54804
+ name: 'id',
54805
+ type: 'string'
54806
+ },
54807
+ {
54808
+ internalType: 'string',
54809
+ name: '_type',
54810
+ type: 'string'
54811
+ }
54812
+ ],
54813
+ internalType: 'struct INonMerklizedIssuer.CredentialSchema',
54814
+ name: 'credentialSchema',
54815
+ type: 'tuple'
54816
+ },
54817
+ {
54818
+ components: [
54819
+ {
54820
+ internalType: 'string',
54821
+ name: 'id',
54822
+ type: 'string'
54823
+ },
54824
+ {
54825
+ internalType: 'string',
54826
+ name: '_type',
54827
+ type: 'string'
54828
+ }
54829
+ ],
54830
+ internalType: 'struct INonMerklizedIssuer.DisplayMethod',
54831
+ name: 'displayMethod',
54832
+ type: 'tuple'
54833
+ }
54834
+ ],
54835
+ internalType: 'struct INonMerklizedIssuer.CredentialData',
54836
+ name: '',
54837
+ type: 'tuple'
54838
+ },
54839
+ {
54840
+ internalType: 'uint256[8]',
54841
+ name: '',
54842
+ type: 'uint256[8]'
54843
+ },
54844
+ {
54845
+ components: [
54846
+ {
54847
+ internalType: 'string',
54848
+ name: 'key',
54849
+ type: 'string'
54850
+ },
54851
+ {
54852
+ internalType: 'uint256',
54853
+ name: 'value',
54854
+ type: 'uint256'
54855
+ },
54856
+ {
54857
+ internalType: 'bytes',
54858
+ name: 'rawValue',
54859
+ type: 'bytes'
54860
+ }
54861
+ ],
54862
+ internalType: 'struct INonMerklizedIssuer.SubjectField[]',
54863
+ name: '',
54864
+ type: 'tuple[]'
54865
+ }
54866
+ ],
54867
+ stateMutability: 'view',
54868
+ type: 'function'
54869
+ },
54870
+ {
54871
+ inputs: [],
54872
+ name: 'getCredentialAdapterVersion',
54873
+ outputs: [
54874
+ {
54875
+ internalType: 'string',
54876
+ name: '',
54877
+ type: 'string'
54878
+ }
54879
+ ],
54880
+ stateMutability: 'pure',
54881
+ type: 'function'
54882
+ },
54883
+ {
54884
+ inputs: [],
54885
+ name: 'getId',
54886
+ outputs: [
54887
+ {
54888
+ internalType: 'uint256',
54889
+ name: '',
54890
+ type: 'uint256'
54891
+ }
54892
+ ],
54893
+ stateMutability: 'view',
54894
+ type: 'function'
54895
+ },
54896
+ {
54897
+ inputs: [],
54898
+ name: 'getIsOldStateGenesis',
54899
+ outputs: [
54900
+ {
54901
+ internalType: 'bool',
54902
+ name: '',
54903
+ type: 'bool'
54904
+ }
54905
+ ],
54906
+ stateMutability: 'view',
54907
+ type: 'function'
54908
+ },
54909
+ {
54910
+ inputs: [],
54911
+ name: 'getLatestPublishedClaimsRoot',
54912
+ outputs: [
54913
+ {
54914
+ internalType: 'uint256',
54915
+ name: '',
54916
+ type: 'uint256'
54917
+ }
54918
+ ],
54919
+ stateMutability: 'view',
54920
+ type: 'function'
54921
+ },
54922
+ {
54923
+ inputs: [],
54924
+ name: 'getLatestPublishedRevocationsRoot',
54925
+ outputs: [
54926
+ {
54927
+ internalType: 'uint256',
54928
+ name: '',
54929
+ type: 'uint256'
54930
+ }
54931
+ ],
54932
+ stateMutability: 'view',
54933
+ type: 'function'
54934
+ },
54935
+ {
54936
+ inputs: [],
54937
+ name: 'getLatestPublishedRootsRoot',
54938
+ outputs: [
54939
+ {
54940
+ internalType: 'uint256',
54941
+ name: '',
54942
+ type: 'uint256'
54943
+ }
54944
+ ],
54945
+ stateMutability: 'view',
54946
+ type: 'function'
54947
+ },
54948
+ {
54949
+ inputs: [],
54950
+ name: 'getLatestPublishedState',
54951
+ outputs: [
54952
+ {
54953
+ internalType: 'uint256',
54954
+ name: '',
54955
+ type: 'uint256'
54956
+ }
54957
+ ],
54958
+ stateMutability: 'view',
54959
+ type: 'function'
54960
+ },
54961
+ {
54962
+ inputs: [
54963
+ {
54964
+ internalType: 'uint64',
54965
+ name: 'revocationNonce',
54966
+ type: 'uint64'
54967
+ }
54968
+ ],
54969
+ name: 'getRevocationProof',
54970
+ outputs: [
54971
+ {
54972
+ components: [
54973
+ {
54974
+ internalType: 'uint256',
54975
+ name: 'root',
54976
+ type: 'uint256'
54977
+ },
54978
+ {
54979
+ internalType: 'bool',
54980
+ name: 'existence',
54981
+ type: 'bool'
54982
+ },
54983
+ {
54984
+ internalType: 'uint256[]',
54985
+ name: 'siblings',
54986
+ type: 'uint256[]'
54987
+ },
54988
+ {
54989
+ internalType: 'uint256',
54990
+ name: 'index',
54991
+ type: 'uint256'
54992
+ },
54993
+ {
54994
+ internalType: 'uint256',
54995
+ name: 'value',
54996
+ type: 'uint256'
54997
+ },
54998
+ {
54999
+ internalType: 'bool',
55000
+ name: 'auxExistence',
55001
+ type: 'bool'
55002
+ },
55003
+ {
55004
+ internalType: 'uint256',
55005
+ name: 'auxIndex',
55006
+ type: 'uint256'
55007
+ },
55008
+ {
55009
+ internalType: 'uint256',
55010
+ name: 'auxValue',
55011
+ type: 'uint256'
55012
+ }
55013
+ ],
55014
+ internalType: 'struct SmtLib.Proof',
55015
+ name: '',
55016
+ type: 'tuple'
55017
+ }
55018
+ ],
55019
+ stateMutability: 'view',
55020
+ type: 'function'
55021
+ },
55022
+ {
55023
+ inputs: [
55024
+ {
55025
+ internalType: 'uint64',
55026
+ name: 'revocationNonce',
55027
+ type: 'uint64'
55028
+ },
55029
+ {
55030
+ internalType: 'uint256',
55031
+ name: 'root',
55032
+ type: 'uint256'
55033
+ }
55034
+ ],
55035
+ name: 'getRevocationProofByRoot',
55036
+ outputs: [
55037
+ {
55038
+ components: [
55039
+ {
55040
+ internalType: 'uint256',
55041
+ name: 'root',
55042
+ type: 'uint256'
55043
+ },
55044
+ {
55045
+ internalType: 'bool',
55046
+ name: 'existence',
55047
+ type: 'bool'
55048
+ },
55049
+ {
55050
+ internalType: 'uint256[]',
55051
+ name: 'siblings',
55052
+ type: 'uint256[]'
55053
+ },
55054
+ {
55055
+ internalType: 'uint256',
55056
+ name: 'index',
55057
+ type: 'uint256'
55058
+ },
55059
+ {
55060
+ internalType: 'uint256',
55061
+ name: 'value',
55062
+ type: 'uint256'
55063
+ },
55064
+ {
55065
+ internalType: 'bool',
55066
+ name: 'auxExistence',
55067
+ type: 'bool'
55068
+ },
55069
+ {
55070
+ internalType: 'uint256',
55071
+ name: 'auxIndex',
55072
+ type: 'uint256'
55073
+ },
55074
+ {
55075
+ internalType: 'uint256',
55076
+ name: 'auxValue',
55077
+ type: 'uint256'
55078
+ }
55079
+ ],
55080
+ internalType: 'struct SmtLib.Proof',
55081
+ name: '',
55082
+ type: 'tuple'
55083
+ }
55084
+ ],
55085
+ stateMutability: 'view',
55086
+ type: 'function'
55087
+ },
55088
+ {
55089
+ inputs: [
55090
+ {
55091
+ internalType: 'uint64',
55092
+ name: 'revocationNonce',
55093
+ type: 'uint64'
55094
+ }
55095
+ ],
55096
+ name: 'getRevocationProofWithStateInfo',
55097
+ outputs: [
55098
+ {
55099
+ components: [
55100
+ {
55101
+ internalType: 'uint256',
55102
+ name: 'root',
55103
+ type: 'uint256'
55104
+ },
55105
+ {
55106
+ internalType: 'bool',
55107
+ name: 'existence',
55108
+ type: 'bool'
55109
+ },
55110
+ {
55111
+ internalType: 'uint256[]',
55112
+ name: 'siblings',
55113
+ type: 'uint256[]'
55114
+ },
55115
+ {
55116
+ internalType: 'uint256',
55117
+ name: 'index',
55118
+ type: 'uint256'
55119
+ },
55120
+ {
55121
+ internalType: 'uint256',
55122
+ name: 'value',
55123
+ type: 'uint256'
55124
+ },
55125
+ {
55126
+ internalType: 'bool',
55127
+ name: 'auxExistence',
55128
+ type: 'bool'
55129
+ },
55130
+ {
55131
+ internalType: 'uint256',
55132
+ name: 'auxIndex',
55133
+ type: 'uint256'
55134
+ },
55135
+ {
55136
+ internalType: 'uint256',
55137
+ name: 'auxValue',
55138
+ type: 'uint256'
55139
+ }
55140
+ ],
55141
+ internalType: 'struct SmtLib.Proof',
55142
+ name: '',
55143
+ type: 'tuple'
55144
+ },
55145
+ {
55146
+ components: [
55147
+ {
55148
+ internalType: 'uint256',
55149
+ name: 'state',
55150
+ type: 'uint256'
55151
+ },
55152
+ {
55153
+ internalType: 'uint256',
55154
+ name: 'claimsRoot',
55155
+ type: 'uint256'
55156
+ },
55157
+ {
55158
+ internalType: 'uint256',
55159
+ name: 'revocationsRoot',
55160
+ type: 'uint256'
55161
+ },
55162
+ {
55163
+ internalType: 'uint256',
55164
+ name: 'rootsRoot',
55165
+ type: 'uint256'
55166
+ }
55167
+ ],
55168
+ internalType: 'struct IdentityLib.StateInfo',
55169
+ name: '',
55170
+ type: 'tuple'
55171
+ }
55172
+ ],
55173
+ stateMutability: 'view',
55174
+ type: 'function'
55175
+ },
55176
+ {
55177
+ inputs: [
55178
+ {
55179
+ internalType: 'uint256',
55180
+ name: 'id',
55181
+ type: 'uint256'
55182
+ },
55183
+ {
55184
+ internalType: 'uint64',
55185
+ name: 'nonce',
55186
+ type: 'uint64'
55187
+ }
55188
+ ],
55189
+ name: 'getRevocationStatus',
55190
+ outputs: [
55191
+ {
55192
+ components: [
55193
+ {
55194
+ components: [
55195
+ {
55196
+ internalType: 'uint256',
55197
+ name: 'state',
55198
+ type: 'uint256'
55199
+ },
55200
+ {
55201
+ internalType: 'uint256',
55202
+ name: 'claimsTreeRoot',
55203
+ type: 'uint256'
55204
+ },
55205
+ {
55206
+ internalType: 'uint256',
55207
+ name: 'revocationTreeRoot',
55208
+ type: 'uint256'
55209
+ },
55210
+ {
55211
+ internalType: 'uint256',
55212
+ name: 'rootOfRoots',
55213
+ type: 'uint256'
55214
+ }
55215
+ ],
55216
+ internalType: 'struct IOnchainCredentialStatusResolver.IdentityStateRoots',
55217
+ name: 'issuer',
55218
+ type: 'tuple'
55219
+ },
55220
+ {
55221
+ components: [
55222
+ {
55223
+ internalType: 'uint256',
55224
+ name: 'root',
55225
+ type: 'uint256'
55226
+ },
55227
+ {
55228
+ internalType: 'bool',
55229
+ name: 'existence',
55230
+ type: 'bool'
55231
+ },
55232
+ {
55233
+ internalType: 'uint256[]',
55234
+ name: 'siblings',
55235
+ type: 'uint256[]'
55236
+ },
55237
+ {
55238
+ internalType: 'uint256',
55239
+ name: 'index',
55240
+ type: 'uint256'
55241
+ },
55242
+ {
55243
+ internalType: 'uint256',
55244
+ name: 'value',
55245
+ type: 'uint256'
55246
+ },
55247
+ {
55248
+ internalType: 'bool',
55249
+ name: 'auxExistence',
55250
+ type: 'bool'
55251
+ },
55252
+ {
55253
+ internalType: 'uint256',
55254
+ name: 'auxIndex',
55255
+ type: 'uint256'
55256
+ },
55257
+ {
55258
+ internalType: 'uint256',
55259
+ name: 'auxValue',
55260
+ type: 'uint256'
55261
+ }
55262
+ ],
55263
+ internalType: 'struct IOnchainCredentialStatusResolver.Proof',
55264
+ name: 'mtp',
55265
+ type: 'tuple'
55266
+ }
55267
+ ],
55268
+ internalType: 'struct IOnchainCredentialStatusResolver.CredentialStatus',
55269
+ name: '',
55270
+ type: 'tuple'
55271
+ }
55272
+ ],
55273
+ stateMutability: 'view',
55274
+ type: 'function'
55275
+ },
55276
+ {
55277
+ inputs: [
55278
+ {
55279
+ internalType: 'uint256',
55280
+ name: 'id',
55281
+ type: 'uint256'
55282
+ },
55283
+ {
55284
+ internalType: 'uint256',
55285
+ name: 'state',
55286
+ type: 'uint256'
55287
+ },
55288
+ {
55289
+ internalType: 'uint64',
55290
+ name: 'nonce',
55291
+ type: 'uint64'
55292
+ }
55293
+ ],
55294
+ name: 'getRevocationStatusByIdAndState',
55295
+ outputs: [
55296
+ {
55297
+ components: [
55298
+ {
55299
+ components: [
55300
+ {
55301
+ internalType: 'uint256',
55302
+ name: 'state',
55303
+ type: 'uint256'
55304
+ },
55305
+ {
55306
+ internalType: 'uint256',
55307
+ name: 'claimsTreeRoot',
55308
+ type: 'uint256'
55309
+ },
55310
+ {
55311
+ internalType: 'uint256',
55312
+ name: 'revocationTreeRoot',
55313
+ type: 'uint256'
55314
+ },
55315
+ {
55316
+ internalType: 'uint256',
55317
+ name: 'rootOfRoots',
55318
+ type: 'uint256'
55319
+ }
55320
+ ],
55321
+ internalType: 'struct IOnchainCredentialStatusResolver.IdentityStateRoots',
55322
+ name: 'issuer',
55323
+ type: 'tuple'
55324
+ },
55325
+ {
55326
+ components: [
55327
+ {
55328
+ internalType: 'uint256',
55329
+ name: 'root',
55330
+ type: 'uint256'
55331
+ },
55332
+ {
55333
+ internalType: 'bool',
55334
+ name: 'existence',
55335
+ type: 'bool'
55336
+ },
55337
+ {
55338
+ internalType: 'uint256[]',
55339
+ name: 'siblings',
55340
+ type: 'uint256[]'
55341
+ },
55342
+ {
55343
+ internalType: 'uint256',
55344
+ name: 'index',
55345
+ type: 'uint256'
55346
+ },
55347
+ {
55348
+ internalType: 'uint256',
55349
+ name: 'value',
55350
+ type: 'uint256'
55351
+ },
55352
+ {
55353
+ internalType: 'bool',
55354
+ name: 'auxExistence',
55355
+ type: 'bool'
55356
+ },
55357
+ {
55358
+ internalType: 'uint256',
55359
+ name: 'auxIndex',
55360
+ type: 'uint256'
55361
+ },
55362
+ {
55363
+ internalType: 'uint256',
55364
+ name: 'auxValue',
55365
+ type: 'uint256'
55366
+ }
55367
+ ],
55368
+ internalType: 'struct IOnchainCredentialStatusResolver.Proof',
55369
+ name: 'mtp',
55370
+ type: 'tuple'
55371
+ }
55372
+ ],
55373
+ internalType: 'struct IOnchainCredentialStatusResolver.CredentialStatus',
55374
+ name: '',
55375
+ type: 'tuple'
55376
+ }
55377
+ ],
55378
+ stateMutability: 'view',
55379
+ type: 'function'
55380
+ },
55381
+ {
55382
+ inputs: [],
55383
+ name: 'getRevocationsTreeRoot',
55384
+ outputs: [
55385
+ {
55386
+ internalType: 'uint256',
55387
+ name: '',
55388
+ type: 'uint256'
55389
+ }
55390
+ ],
55391
+ stateMutability: 'view',
55392
+ type: 'function'
55393
+ },
55394
+ {
55395
+ inputs: [
55396
+ {
55397
+ internalType: 'uint256',
55398
+ name: 'rootsTreeRoot',
55399
+ type: 'uint256'
55400
+ }
55401
+ ],
55402
+ name: 'getRootProof',
55403
+ outputs: [
55404
+ {
55405
+ components: [
55406
+ {
55407
+ internalType: 'uint256',
55408
+ name: 'root',
55409
+ type: 'uint256'
55410
+ },
55411
+ {
55412
+ internalType: 'bool',
55413
+ name: 'existence',
55414
+ type: 'bool'
55415
+ },
55416
+ {
55417
+ internalType: 'uint256[]',
55418
+ name: 'siblings',
55419
+ type: 'uint256[]'
55420
+ },
55421
+ {
55422
+ internalType: 'uint256',
55423
+ name: 'index',
55424
+ type: 'uint256'
55425
+ },
55426
+ {
55427
+ internalType: 'uint256',
55428
+ name: 'value',
55429
+ type: 'uint256'
55430
+ },
55431
+ {
55432
+ internalType: 'bool',
55433
+ name: 'auxExistence',
55434
+ type: 'bool'
55435
+ },
55436
+ {
55437
+ internalType: 'uint256',
55438
+ name: 'auxIndex',
55439
+ type: 'uint256'
55440
+ },
55441
+ {
55442
+ internalType: 'uint256',
55443
+ name: 'auxValue',
55444
+ type: 'uint256'
55445
+ }
55446
+ ],
55447
+ internalType: 'struct SmtLib.Proof',
55448
+ name: '',
55449
+ type: 'tuple'
55450
+ }
55451
+ ],
55452
+ stateMutability: 'view',
55453
+ type: 'function'
55454
+ },
55455
+ {
55456
+ inputs: [
55457
+ {
55458
+ internalType: 'uint256',
55459
+ name: 'claimsTreeRoot',
55460
+ type: 'uint256'
55461
+ },
55462
+ {
55463
+ internalType: 'uint256',
55464
+ name: 'root',
55465
+ type: 'uint256'
55466
+ }
55467
+ ],
55468
+ name: 'getRootProofByRoot',
55469
+ outputs: [
55470
+ {
55471
+ components: [
55472
+ {
55473
+ internalType: 'uint256',
55474
+ name: 'root',
55475
+ type: 'uint256'
55476
+ },
55477
+ {
55478
+ internalType: 'bool',
55479
+ name: 'existence',
55480
+ type: 'bool'
55481
+ },
55482
+ {
55483
+ internalType: 'uint256[]',
55484
+ name: 'siblings',
55485
+ type: 'uint256[]'
55486
+ },
55487
+ {
55488
+ internalType: 'uint256',
55489
+ name: 'index',
55490
+ type: 'uint256'
55491
+ },
55492
+ {
55493
+ internalType: 'uint256',
55494
+ name: 'value',
55495
+ type: 'uint256'
55496
+ },
55497
+ {
55498
+ internalType: 'bool',
55499
+ name: 'auxExistence',
55500
+ type: 'bool'
55501
+ },
55502
+ {
55503
+ internalType: 'uint256',
55504
+ name: 'auxIndex',
55505
+ type: 'uint256'
55506
+ },
55507
+ {
55508
+ internalType: 'uint256',
55509
+ name: 'auxValue',
55510
+ type: 'uint256'
55511
+ }
55512
+ ],
55513
+ internalType: 'struct SmtLib.Proof',
55514
+ name: '',
55515
+ type: 'tuple'
55516
+ }
55517
+ ],
55518
+ stateMutability: 'view',
55519
+ type: 'function'
55520
+ },
55521
+ {
55522
+ inputs: [
55523
+ {
55524
+ internalType: 'uint256',
55525
+ name: 'rootsTreeRoot',
55526
+ type: 'uint256'
55527
+ }
55528
+ ],
55529
+ name: 'getRootProofWithStateInfo',
55530
+ outputs: [
55531
+ {
55532
+ components: [
55533
+ {
55534
+ internalType: 'uint256',
55535
+ name: 'root',
55536
+ type: 'uint256'
55537
+ },
55538
+ {
55539
+ internalType: 'bool',
55540
+ name: 'existence',
55541
+ type: 'bool'
55542
+ },
55543
+ {
55544
+ internalType: 'uint256[]',
55545
+ name: 'siblings',
55546
+ type: 'uint256[]'
55547
+ },
55548
+ {
55549
+ internalType: 'uint256',
55550
+ name: 'index',
55551
+ type: 'uint256'
55552
+ },
55553
+ {
55554
+ internalType: 'uint256',
55555
+ name: 'value',
55556
+ type: 'uint256'
55557
+ },
55558
+ {
55559
+ internalType: 'bool',
55560
+ name: 'auxExistence',
55561
+ type: 'bool'
55562
+ },
55563
+ {
55564
+ internalType: 'uint256',
55565
+ name: 'auxIndex',
55566
+ type: 'uint256'
55567
+ },
55568
+ {
55569
+ internalType: 'uint256',
55570
+ name: 'auxValue',
55571
+ type: 'uint256'
55572
+ }
55573
+ ],
55574
+ internalType: 'struct SmtLib.Proof',
55575
+ name: '',
55576
+ type: 'tuple'
55577
+ },
55578
+ {
55579
+ components: [
55580
+ {
55581
+ internalType: 'uint256',
55582
+ name: 'state',
55583
+ type: 'uint256'
55584
+ },
55585
+ {
55586
+ internalType: 'uint256',
55587
+ name: 'claimsRoot',
55588
+ type: 'uint256'
55589
+ },
55590
+ {
55591
+ internalType: 'uint256',
55592
+ name: 'revocationsRoot',
55593
+ type: 'uint256'
55594
+ },
55595
+ {
55596
+ internalType: 'uint256',
55597
+ name: 'rootsRoot',
55598
+ type: 'uint256'
55599
+ }
55600
+ ],
55601
+ internalType: 'struct IdentityLib.StateInfo',
55602
+ name: '',
55603
+ type: 'tuple'
55604
+ }
55605
+ ],
55606
+ stateMutability: 'view',
55607
+ type: 'function'
55608
+ },
55609
+ {
55610
+ inputs: [
55611
+ {
55612
+ internalType: 'uint256',
55613
+ name: 'state',
55614
+ type: 'uint256'
55615
+ }
55616
+ ],
55617
+ name: 'getRootsByState',
55618
+ outputs: [
55619
+ {
55620
+ components: [
55621
+ {
55622
+ internalType: 'uint256',
55623
+ name: 'claimsRoot',
55624
+ type: 'uint256'
55625
+ },
55626
+ {
55627
+ internalType: 'uint256',
55628
+ name: 'revocationsRoot',
55629
+ type: 'uint256'
55630
+ },
55631
+ {
55632
+ internalType: 'uint256',
55633
+ name: 'rootsRoot',
55634
+ type: 'uint256'
55635
+ }
55636
+ ],
55637
+ internalType: 'struct IdentityLib.Roots',
55638
+ name: '',
55639
+ type: 'tuple'
55640
+ }
55641
+ ],
55642
+ stateMutability: 'view',
55643
+ type: 'function'
55644
+ },
55645
+ {
55646
+ inputs: [],
55647
+ name: 'getRootsTreeRoot',
55648
+ outputs: [
55649
+ {
55650
+ internalType: 'uint256',
55651
+ name: '',
55652
+ type: 'uint256'
55653
+ }
55654
+ ],
55655
+ stateMutability: 'view',
55656
+ type: 'function'
55657
+ },
55658
+ {
55659
+ inputs: [],
55660
+ name: 'getSmtDepth',
55661
+ outputs: [
55662
+ {
55663
+ internalType: 'uint256',
55664
+ name: '',
55665
+ type: 'uint256'
55666
+ }
55667
+ ],
55668
+ stateMutability: 'pure',
55669
+ type: 'function'
55670
+ },
55671
+ {
55672
+ inputs: [
55673
+ {
55674
+ internalType: 'uint256',
55675
+ name: '_userId',
55676
+ type: 'uint256'
55677
+ }
55678
+ ],
55679
+ name: 'getUserCredentialIds',
55680
+ outputs: [
55681
+ {
55682
+ internalType: 'uint256[]',
55683
+ name: '',
55684
+ type: 'uint256[]'
55685
+ }
55686
+ ],
55687
+ stateMutability: 'view',
55688
+ type: 'function'
55689
+ },
55690
+ {
55691
+ inputs: [
55692
+ {
55693
+ internalType: 'address',
55694
+ name: '_stateContractAddr',
55695
+ type: 'address'
55696
+ },
55697
+ {
55698
+ internalType: 'bytes2',
55699
+ name: 'idType',
55700
+ type: 'bytes2'
55701
+ }
55702
+ ],
55703
+ name: 'initialize',
55704
+ outputs: [],
55705
+ stateMutability: 'nonpayable',
55706
+ type: 'function'
55707
+ },
55708
+ {
55709
+ inputs: [
55710
+ {
55711
+ internalType: 'bytes4',
55712
+ name: 'interfaceId',
55713
+ type: 'bytes4'
55714
+ }
55715
+ ],
55716
+ name: 'supportsInterface',
55717
+ outputs: [
55718
+ {
55719
+ internalType: 'bool',
55720
+ name: '',
55721
+ type: 'bool'
55722
+ }
55723
+ ],
55724
+ stateMutability: 'view',
55725
+ type: 'function'
55726
+ }
55727
+ ];
55728
+ class NonMerklizedIssuerBase__factory {
55729
+ static abi = _abi;
55730
+ static createInterface() {
55731
+ return new Interface(_abi);
55732
+ }
55733
+ static connect(address, runner) {
55734
+ return new Contract(address, _abi, runner);
55735
+ }
55736
+ }
55737
+
55738
+ var NonMerklizedIssuerInterfaces;
55739
+ (function (NonMerklizedIssuerInterfaces) {
55740
+ NonMerklizedIssuerInterfaces["InterfaceDetection"] = "0x01ffc9a7";
55741
+ NonMerklizedIssuerInterfaces["InterfaceNonMerklizedIssuer"] = "0x58874949";
55742
+ NonMerklizedIssuerInterfaces["InterfaceGetCredential"] = "0x5d1ca631";
55743
+ })(NonMerklizedIssuerInterfaces || (NonMerklizedIssuerInterfaces = {}));
55744
+ var ValueHashes;
55745
+ (function (ValueHashes) {
55746
+ ValueHashes["BooleanTrue"] = "18586133768512220936620570745912940619677854269274689475585506675881198879027";
55747
+ ValueHashes["BooleanFalse"] = "19014214495641488759237505126948346942972912379615652741039992445865937985820";
55748
+ })(ValueHashes || (ValueHashes = {}));
55749
+ /**
55750
+ * `OnchainNonMerklizedIssuerAdapter` provides functionality to interact with a non-merklized on-chain credential issuer.
55751
+ * This adapter enables interface detection, credential retrieval, and conversion to the W3C Verifiable Credential format.
55752
+ *
55753
+ * @public
55754
+ * @beta
55755
+ * @class OnchainNonMerklizedIssuerAdapter
55756
+ */
55757
+ class OnchainNonMerklizedIssuerAdapter {
55758
+ /**
55759
+ * Initializes an instance of `OnchainNonMerklizedIssuerAdapter`.
55760
+ *
55761
+ * @param ethConnectionConfig The configuration for the Ethereum connection.
55762
+ * @param issuerDid The decentralized identifier (DID) of the issuer.
55763
+ * @param merklizationOptions Optional settings for merklization.
55764
+ */
55765
+ constructor(ethConnectionConfig, issuerDid, options) {
55766
+ if (!ethConnectionConfig.chainId) {
55767
+ throw new Error('Chain ID is required');
55768
+ }
55769
+ this._chainId = ethConnectionConfig.chainId;
55770
+ this._contractAddress = getAddress(hexlify($$1.ethAddressFromId(Q$2.idFromDID(issuerDid))));
55771
+ this._contract = NonMerklizedIssuerBase__factory.connect(this._contractAddress, new JsonRpcProvider(ethConnectionConfig.url));
55772
+ this._issuerDid = issuerDid;
55773
+ this._merklizationOptions = options?.merklizationOptions;
55774
+ }
55775
+ /**
55776
+ * Checks if the contract supports required interfaces.
55777
+ * Throws an error if any required interface is unsupported.
55778
+ *
55779
+ * @throws Error - If required interfaces are not supported.
55780
+ */
55781
+ async isInterfaceSupported() {
55782
+ const supportedInterfaces = [
55783
+ {
55784
+ name: 'Interface detection ERC-165',
55785
+ value: NonMerklizedIssuerInterfaces.InterfaceDetection
55786
+ },
55787
+ {
55788
+ name: 'Interface non-merklized issuer',
55789
+ value: NonMerklizedIssuerInterfaces.InterfaceNonMerklizedIssuer
55790
+ },
55791
+ {
55792
+ name: 'Interface get credential',
55793
+ value: NonMerklizedIssuerInterfaces.InterfaceGetCredential
55794
+ }
55795
+ ];
55796
+ const unsupportedInterfaces = await Promise.all(supportedInterfaces.map(async (interfaceObj) => {
55797
+ const isSupported = await this._contract.supportsInterface(interfaceObj.value);
55798
+ return isSupported ? null : interfaceObj.name;
55799
+ }));
55800
+ const unsupportedInterfacesFiltered = unsupportedInterfaces.filter((interfaceName) => interfaceName !== null);
55801
+ if (unsupportedInterfacesFiltered.length > 0) {
55802
+ throw new Error(`Unsupported interfaces: ${unsupportedInterfacesFiltered.join(', ')}`);
55803
+ }
55804
+ }
55805
+ /**
55806
+ * Retrieves a credential from the on-chain non-merklized contract.
55807
+ * @param userId The user's core.Id.
55808
+ * @param credentialId The unique identifier of the credential.
55809
+ */
55810
+ async getCredential(userId, credentialId) {
55811
+ const [credentialData, coreClaimBigInts, credentialSubjectFields] = await this._contract.getCredential(userId.bigInt(), credentialId);
55812
+ return { credentialData, coreClaimBigInts, credentialSubjectFields };
55813
+ }
55814
+ /**
55815
+ * Retrieves the credential IDs of a user.
55816
+ * @param userId The user's core.Id.
55817
+ * @returns An array of credential IDs.
55818
+ */
55819
+ async getUserCredentialsIds(userId) {
55820
+ return this._contract.getUserCredentialIds(userId.bigInt());
55821
+ }
55822
+ /**
55823
+ * Converts on-chain credential to a verifiable credential.
55824
+ *
55825
+ * @param credentialData Data structure of the credential from the contract.
55826
+ * @param coreClaimBigInts Claim data in bigint format.
55827
+ * @param credentialSubjectFields Subject fields of the credential.
55828
+ */
55829
+ async convertOnChainInfoToW3CCredential(credentialData, coreClaimBigInts, credentialSubjectFields) {
55830
+ const c = new P$2().unMarshalJson(JSON.stringify(coreClaimBigInts.map((b) => b.toString())));
55831
+ const credentialSubject = await this.convertCredentialSubject(c, credentialData.context, credentialData._type, credentialSubjectFields);
55832
+ const credentialRequest = {
55833
+ id: this.credentialId(credentialData.id),
55834
+ credentialSchema: credentialData.credentialSchema.id,
55835
+ type: credentialData._type,
55836
+ credentialSubject: credentialSubject,
55837
+ expiration: c.getExpirationDate()?.getTime(),
55838
+ displayMethod: this.convertDisplayMethod(credentialData.displayMethod),
55839
+ context: credentialData.context,
55840
+ revocationOpts: {
55841
+ id: this._contractAddress,
55842
+ nonce: Number(c.getRevocationNonce()),
55843
+ type: exports.CredentialStatusType.Iden3OnchainSparseMerkleTreeProof2023
55844
+ },
55845
+ issuanceDate: p$3(Number(credentialData.issuanceDate)).getTime()
55846
+ };
55847
+ const existenceProof = await this.existenceProof(c);
55848
+ const w3c = W3CCredential.fromCredentialRequest(this._issuerDid, credentialRequest);
55849
+ w3c.proof = [existenceProof];
55850
+ return w3c;
55851
+ }
55852
+ credentialId(id) {
55853
+ return `urn:iden3:onchain:${this._chainId}:${this._contractAddress}:${id}`;
55854
+ }
55855
+ async convertCredentialSubject(coreClaim, contractContexts, credentialType, credentialSubjectFields) {
55856
+ const contractContextsStr = JSON.stringify({
55857
+ '@context': contractContexts
55858
+ });
55859
+ const credentialSubject = {};
55860
+ for (const f of credentialSubjectFields) {
55861
+ const dataType = await lf.newTypeFromContext(contractContextsStr, `${credentialType}.${f.key}`, this._merklizationOptions);
55862
+ switch (dataType) {
55863
+ case exports.XSDNS.Boolean: {
55864
+ switch (f.rawValue.toString()) {
55865
+ case ValueHashes.BooleanTrue:
55866
+ credentialSubject[f.key] = true;
55867
+ break;
55868
+ case ValueHashes.BooleanFalse:
55869
+ credentialSubject[f.key] = false;
55870
+ break;
55871
+ }
55872
+ break;
55873
+ }
55874
+ case (exports.XSDNS.PositiveInteger):
55875
+ {
55876
+ credentialSubject[f.key] = f.value.toString();
55877
+ break;
55878
+ }
55879
+ case exports.XSDNS.Integer: {
55880
+ credentialSubject[f.key] = Number(f.value);
55881
+ break;
55882
+ }
55883
+ case exports.XSDNS.String: {
55884
+ this.validateSourceValue(dataType, f.value, f.rawValue);
55885
+ credentialSubject[f.key] = f.rawValue;
55886
+ break;
55887
+ }
55888
+ case exports.XSDNS.DateTime: {
55889
+ const timestamp = BigInt(f.rawValue);
55890
+ const sourceTimestamp = p$3(Number(timestamp)).toISOString();
55891
+ this.validateSourceValue(dataType, f.value, sourceTimestamp);
55892
+ credentialSubject[f.key] = sourceTimestamp;
55893
+ break;
55894
+ }
55895
+ case exports.XSDNS.Double: {
55896
+ const rawFloat = Number(f.rawValue);
55897
+ this.validateSourceValue(dataType, f.value, rawFloat);
55898
+ credentialSubject[f.key] = rawFloat;
55899
+ break;
55900
+ }
55901
+ default: {
55902
+ throw new Error(`Unsupported data type ${dataType}`);
55903
+ }
55904
+ }
55905
+ }
55906
+ credentialSubject['type'] = credentialType;
55907
+ const subjectId = coreClaim.getId();
55908
+ const subjectDid = Q$2.parseFromId(subjectId);
55909
+ credentialSubject['id'] = subjectDid.string();
55910
+ return credentialSubject;
55911
+ }
55912
+ async existenceProof(coreClaim) {
55913
+ const [mtpProof, stateInfo] = await this._contract.getClaimProofWithStateInfo(coreClaim.hIndex());
55914
+ if (!mtpProof.existence) {
55915
+ throw new Error('Claim does not exist');
55916
+ }
55917
+ const latestStateHash = V$1.fromBigInt(stateInfo.state);
55918
+ const latestClaimsOfRootHash = V$1.fromBigInt(stateInfo.claimsRoot);
55919
+ const latestRevocationOfRootHash = V$1.fromBigInt(stateInfo.revocationsRoot);
55920
+ const latestRootsOfRootHash = V$1.fromBigInt(stateInfo.rootsRoot);
55921
+ const p = new Kt$1({
55922
+ siblings: mtpProof.siblings.map((s) => V$1.fromBigInt(s)),
55923
+ existence: mtpProof.existence,
55924
+ nodeAux: mtpProof.auxExistence
55925
+ ? {
55926
+ key: V$1.fromBigInt(mtpProof.auxIndex),
55927
+ value: V$1.fromBigInt(mtpProof.auxValue)
55928
+ }
55929
+ : undefined
55930
+ });
55931
+ return new Iden3SparseMerkleTreeProof({
55932
+ issuerData: {
55933
+ id: this._issuerDid,
55934
+ state: {
55935
+ value: latestStateHash,
55936
+ claimsTreeRoot: latestClaimsOfRootHash,
55937
+ revocationTreeRoot: latestRevocationOfRootHash,
55938
+ rootOfRoots: latestRootsOfRootHash
55939
+ }
55940
+ },
55941
+ mtp: p,
55942
+ coreClaim: coreClaim
55943
+ });
55944
+ }
55945
+ async validateSourceValue(dataType, originHash, source) {
55946
+ const sourceHash = await ff.hashValue(dataType, source);
55947
+ if (sourceHash !== originHash) {
55948
+ throw new Error(`Invalid source value for ${dataType} type`);
55949
+ }
55950
+ }
55951
+ convertDisplayMethod(onchainDisplayMethod) {
55952
+ if (!onchainDisplayMethod.id || !onchainDisplayMethod._type) {
55953
+ return undefined;
55954
+ }
55955
+ switch (onchainDisplayMethod._type) {
55956
+ case exports.DisplayMethodType.Iden3BasicDisplayMethodV1: {
55957
+ return {
55958
+ id: onchainDisplayMethod.id,
55959
+ type: exports.DisplayMethodType.Iden3BasicDisplayMethodV1
55960
+ };
55961
+ }
55962
+ default: {
55963
+ throw new Error(`Unsupported display method type ${onchainDisplayMethod._type}`);
55964
+ }
55965
+ }
55966
+ }
55967
+ }
55968
+
55969
+ /**
55970
+ * Represents an adapter for interacting with on-chain issuers.
55971
+ *
55972
+ * @public
55973
+ * @beta
55974
+ * @class OnchainIssuer
55975
+ */
55976
+ class OnchainIssuer {
55977
+ /**
55978
+ * Initializes an instance of `Adapter`.
55979
+ * @param config The configuration for the Ethereum connection.
55980
+ * @param merklizationOptions Optional settings for merklization.
55981
+ */
55982
+ constructor(config, options) {
55983
+ this._ethConnectionConfig = config;
55984
+ this._onchainIssuerOptions = options;
55985
+ }
55986
+ /**
55987
+ * Retrieves a credential from the on-chain issuer.
55988
+ * @param issuerDID The issuer's core.DID.
55989
+ * @param userId The user's core.Id.
55990
+ * @param credentialId The unique identifier of the credential.
55991
+ */
55992
+ async getCredential(issuerDID, userDID, credentialId) {
55993
+ const { contract, connection } = this.getContractConnection(issuerDID);
55994
+ const response = await contract.getCredentialAdapterVersion();
55995
+ switch (response) {
55996
+ case '0.0.1': {
55997
+ const adapter = new OnchainNonMerklizedIssuerAdapter(connection, issuerDID, {
55998
+ merklizationOptions: this._onchainIssuerOptions?.merklizationOptions
55999
+ });
56000
+ await adapter.isInterfaceSupported();
56001
+ const { credentialData, coreClaimBigInts, credentialSubjectFields } = await adapter.getCredential(Q$2.idFromDID(userDID), credentialId);
56002
+ return await adapter.convertOnChainInfoToW3CCredential(credentialData, coreClaimBigInts, credentialSubjectFields);
56003
+ }
56004
+ default:
56005
+ throw new Error(`Unsupported adapter version ${response}`);
56006
+ }
56007
+ }
56008
+ /**
56009
+ * Retrieves the credential identifiers for a user from the on-chain issuer.
56010
+ * @param issuerDID The issuer's core.DID.
56011
+ * @param userId The user's core.Id.
56012
+ */
56013
+ async getUserCredentialIds(issuerDID, userDID) {
56014
+ const { contract, connection } = this.getContractConnection(issuerDID);
56015
+ const response = await contract.getCredentialAdapterVersion();
56016
+ switch (response) {
56017
+ case '0.0.1': {
56018
+ const adapter = new OnchainNonMerklizedIssuerAdapter(connection, issuerDID, {
56019
+ merklizationOptions: this._onchainIssuerOptions?.merklizationOptions
56020
+ });
56021
+ await adapter.isInterfaceSupported();
56022
+ return await adapter.getUserCredentialsIds(Q$2.idFromDID(userDID));
56023
+ }
56024
+ default:
56025
+ throw new Error(`Unsupported adapter version ${response}`);
56026
+ }
56027
+ }
56028
+ getContractConnection(did) {
56029
+ const issuerId = Q$2.idFromDID(did);
56030
+ const chainId = rt$2(did);
56031
+ const contractAddress = getAddress(hexlify($$1.ethAddressFromId(issuerId)));
56032
+ const connection = this._ethConnectionConfig.find((c) => c.chainId === chainId);
56033
+ if (!connection) {
56034
+ throw new Error(`No connection found for chain ID ${chainId}`);
56035
+ }
56036
+ if (!connection.url) {
56037
+ throw new Error(`No URL found for chain ID ${chainId}`);
56038
+ }
56039
+ const contract = new Contract(contractAddress, abi, new JsonRpcProvider(connection.url));
56040
+ return { contract, connection };
56041
+ }
56042
+ }
56043
+
56044
+ class DidResolverStateReadonlyStorage {
56045
+ constructor(resolverUrl) {
56046
+ this.resolverUrl = resolverUrl;
56047
+ }
56048
+ async getLatestStateById(id) {
56049
+ return this.getStateInfo(id);
56050
+ }
56051
+ async getStateInfoByIdAndState(id, state) {
56052
+ return this.getStateInfo(id, state);
56053
+ }
56054
+ async getGISTProof(id) {
56055
+ const { didDocument } = await resolveDidDocument(Q$2.parseFromId($$1.fromBigInt(id)), this.resolverUrl);
56056
+ const { global } = this.getIden3StateInfo2023(didDocument);
56057
+ if (!global) {
56058
+ throw new Error('GIST root not found');
56059
+ }
56060
+ const { proof } = global;
56061
+ if (!proof) {
56062
+ throw new Error('GIST proof not found');
56063
+ }
56064
+ return {
56065
+ root: global.root,
56066
+ existence: proof.existence,
56067
+ siblings: proof.siblings?.map((sibling) => BigInt(sibling)),
56068
+ index: BigInt(0),
56069
+ value: BigInt(0),
56070
+ auxExistence: !!proof.node_aux,
56071
+ auxIndex: proof.node_aux ? BigInt(proof.node_aux.key) : BigInt(0),
56072
+ auxValue: proof.node_aux ? BigInt(proof.node_aux.value) : BigInt(0)
56073
+ };
56074
+ }
56075
+ async getGISTRootInfo(root, userId) {
56076
+ const { didDocument } = await resolveDidDocument(Q$2.parseFromId($$1.fromBigInt(userId)), this.resolverUrl, {
56077
+ gist: V$1.fromBigInt(root)
56078
+ });
56079
+ const { global } = this.getIden3StateInfo2023(didDocument);
56080
+ if (!global) {
56081
+ throw new Error('GIST root not found');
56082
+ }
56083
+ return global;
56084
+ }
56085
+ getRpcProvider() {
56086
+ return new JsonRpcProvider();
56087
+ }
56088
+ publishState() {
56089
+ throw new Error('publishState method not implemented.');
56090
+ }
56091
+ publishStateGeneric() {
56092
+ throw new Error('publishStateGeneric method not implemented.');
56093
+ }
56094
+ async getStateInfo(id, state) {
56095
+ const opts = state ? { state: V$1.fromBigInt(state) } : undefined;
56096
+ const { didDocument } = await resolveDidDocument(Q$2.parseFromId($$1.fromBigInt(id)), this.resolverUrl, opts);
56097
+ const { info } = this.getIden3StateInfo2023(didDocument);
56098
+ return { ...info };
56099
+ }
56100
+ getIden3StateInfo2023(didDocument) {
56101
+ const vm = didDocument.verificationMethod?.find((i) => i.type === 'Iden3StateInfo2023');
56102
+ if (!vm) {
56103
+ throw new Error('Iden3StateInfo2023 verification method not found');
56104
+ }
56105
+ return vm;
56106
+ }
56107
+ }
56108
+
56109
+ var permitAbi = [
56110
+ {
56111
+ inputs: [
56112
+ ],
56113
+ name: "ECDSAInvalidSignature",
56114
+ type: "error"
56115
+ },
56116
+ {
56117
+ inputs: [
56118
+ {
56119
+ internalType: "uint256",
56120
+ name: "length",
56121
+ type: "uint256"
56122
+ }
56123
+ ],
56124
+ name: "ECDSAInvalidSignatureLength",
56125
+ type: "error"
56126
+ },
56127
+ {
56128
+ inputs: [
56129
+ {
56130
+ internalType: "bytes32",
56131
+ name: "s",
56132
+ type: "bytes32"
56133
+ }
56134
+ ],
56135
+ name: "ECDSAInvalidSignatureS",
56136
+ type: "error"
56137
+ },
56138
+ {
56139
+ inputs: [
56140
+ {
56141
+ internalType: "address",
56142
+ name: "spender",
56143
+ type: "address"
56144
+ },
56145
+ {
56146
+ internalType: "uint256",
56147
+ name: "allowance",
56148
+ type: "uint256"
56149
+ },
56150
+ {
56151
+ internalType: "uint256",
56152
+ name: "needed",
56153
+ type: "uint256"
56154
+ }
56155
+ ],
56156
+ name: "ERC20InsufficientAllowance",
56157
+ type: "error"
56158
+ },
56159
+ {
56160
+ inputs: [
56161
+ {
56162
+ internalType: "address",
56163
+ name: "sender",
56164
+ type: "address"
56165
+ },
56166
+ {
56167
+ internalType: "uint256",
56168
+ name: "balance",
56169
+ type: "uint256"
56170
+ },
56171
+ {
56172
+ internalType: "uint256",
56173
+ name: "needed",
56174
+ type: "uint256"
56175
+ }
56176
+ ],
56177
+ name: "ERC20InsufficientBalance",
56178
+ type: "error"
56179
+ },
56180
+ {
56181
+ inputs: [
56182
+ {
56183
+ internalType: "address",
56184
+ name: "approver",
56185
+ type: "address"
56186
+ }
56187
+ ],
56188
+ name: "ERC20InvalidApprover",
56189
+ type: "error"
56190
+ },
56191
+ {
56192
+ inputs: [
56193
+ {
56194
+ internalType: "address",
56195
+ name: "receiver",
56196
+ type: "address"
56197
+ }
56198
+ ],
56199
+ name: "ERC20InvalidReceiver",
56200
+ type: "error"
56201
+ },
56202
+ {
56203
+ inputs: [
56204
+ {
56205
+ internalType: "address",
56206
+ name: "sender",
56207
+ type: "address"
56208
+ }
56209
+ ],
56210
+ name: "ERC20InvalidSender",
56211
+ type: "error"
56212
+ },
56213
+ {
56214
+ inputs: [
56215
+ {
56216
+ internalType: "address",
56217
+ name: "spender",
56218
+ type: "address"
56219
+ }
56220
+ ],
56221
+ name: "ERC20InvalidSpender",
56222
+ type: "error"
56223
+ },
56224
+ {
56225
+ inputs: [
56226
+ {
56227
+ internalType: "uint256",
56228
+ name: "deadline",
56229
+ type: "uint256"
56230
+ }
56231
+ ],
56232
+ name: "ERC2612ExpiredSignature",
56233
+ type: "error"
56234
+ },
56235
+ {
56236
+ inputs: [
56237
+ {
56238
+ internalType: "address",
56239
+ name: "signer",
56240
+ type: "address"
56241
+ },
56242
+ {
56243
+ internalType: "address",
56244
+ name: "owner",
56245
+ type: "address"
56246
+ }
56247
+ ],
56248
+ name: "ERC2612InvalidSigner",
56249
+ type: "error"
56250
+ },
56251
+ {
56252
+ inputs: [
56253
+ {
56254
+ internalType: "address",
56255
+ name: "account",
56256
+ type: "address"
56257
+ },
56258
+ {
56259
+ internalType: "uint256",
56260
+ name: "currentNonce",
56261
+ type: "uint256"
56262
+ }
56263
+ ],
56264
+ name: "InvalidAccountNonce",
56265
+ type: "error"
56266
+ },
56267
+ {
56268
+ inputs: [
56269
+ ],
56270
+ name: "InvalidShortString",
56271
+ type: "error"
56272
+ },
56273
+ {
56274
+ inputs: [
56275
+ {
56276
+ internalType: "string",
56277
+ name: "str",
56278
+ type: "string"
56279
+ }
56280
+ ],
56281
+ name: "StringTooLong",
56282
+ type: "error"
56283
+ },
56284
+ {
56285
+ anonymous: false,
56286
+ inputs: [
56287
+ {
56288
+ indexed: true,
56289
+ internalType: "address",
56290
+ name: "owner",
56291
+ type: "address"
56292
+ },
56293
+ {
56294
+ indexed: true,
56295
+ internalType: "address",
56296
+ name: "spender",
56297
+ type: "address"
56298
+ },
56299
+ {
56300
+ indexed: false,
56301
+ internalType: "uint256",
56302
+ name: "value",
56303
+ type: "uint256"
56304
+ }
56305
+ ],
56306
+ name: "Approval",
56307
+ type: "event"
56308
+ },
56309
+ {
56310
+ anonymous: false,
56311
+ inputs: [
56312
+ ],
56313
+ name: "EIP712DomainChanged",
56314
+ type: "event"
56315
+ },
56316
+ {
56317
+ anonymous: false,
56318
+ inputs: [
56319
+ {
56320
+ indexed: true,
56321
+ internalType: "address",
56322
+ name: "from",
56323
+ type: "address"
56324
+ },
56325
+ {
56326
+ indexed: true,
56327
+ internalType: "address",
56328
+ name: "to",
56329
+ type: "address"
56330
+ },
56331
+ {
56332
+ indexed: false,
56333
+ internalType: "uint256",
56334
+ name: "value",
56335
+ type: "uint256"
56336
+ }
56337
+ ],
56338
+ name: "Transfer",
56339
+ type: "event"
56340
+ },
56341
+ {
56342
+ inputs: [
56343
+ ],
56344
+ name: "DOMAIN_SEPARATOR",
56345
+ outputs: [
56346
+ {
56347
+ internalType: "bytes32",
56348
+ name: "",
56349
+ type: "bytes32"
56350
+ }
56351
+ ],
56352
+ stateMutability: "view",
56353
+ type: "function"
56354
+ },
56355
+ {
56356
+ inputs: [
56357
+ {
56358
+ internalType: "address",
56359
+ name: "owner",
56360
+ type: "address"
56361
+ },
56362
+ {
56363
+ internalType: "address",
56364
+ name: "spender",
56365
+ type: "address"
56366
+ }
56367
+ ],
56368
+ name: "allowance",
56369
+ outputs: [
56370
+ {
56371
+ internalType: "uint256",
56372
+ name: "",
56373
+ type: "uint256"
56374
+ }
56375
+ ],
56376
+ stateMutability: "view",
56377
+ type: "function"
56378
+ },
56379
+ {
56380
+ inputs: [
56381
+ {
56382
+ internalType: "address",
56383
+ name: "spender",
56384
+ type: "address"
56385
+ },
56386
+ {
56387
+ internalType: "uint256",
56388
+ name: "value",
56389
+ type: "uint256"
56390
+ }
56391
+ ],
56392
+ name: "approve",
56393
+ outputs: [
56394
+ {
56395
+ internalType: "bool",
56396
+ name: "",
56397
+ type: "bool"
56398
+ }
56399
+ ],
56400
+ stateMutability: "nonpayable",
56401
+ type: "function"
56402
+ },
56403
+ {
56404
+ inputs: [
56405
+ {
56406
+ internalType: "address",
56407
+ name: "account",
56408
+ type: "address"
56409
+ }
56410
+ ],
56411
+ name: "balanceOf",
56412
+ outputs: [
56413
+ {
56414
+ internalType: "uint256",
56415
+ name: "",
56416
+ type: "uint256"
56417
+ }
56418
+ ],
56419
+ stateMutability: "view",
56420
+ type: "function"
56421
+ },
56422
+ {
56423
+ inputs: [
56424
+ ],
56425
+ name: "decimals",
56426
+ outputs: [
56427
+ {
56428
+ internalType: "uint8",
56429
+ name: "",
56430
+ type: "uint8"
56431
+ }
56432
+ ],
56433
+ stateMutability: "view",
56434
+ type: "function"
56435
+ },
56436
+ {
56437
+ inputs: [
56438
+ ],
56439
+ name: "eip712Domain",
56440
+ outputs: [
56441
+ {
56442
+ internalType: "bytes1",
56443
+ name: "fields",
56444
+ type: "bytes1"
56445
+ },
56446
+ {
56447
+ internalType: "string",
56448
+ name: "name",
56449
+ type: "string"
56450
+ },
56451
+ {
56452
+ internalType: "string",
56453
+ name: "version",
56454
+ type: "string"
56455
+ },
56456
+ {
56457
+ internalType: "uint256",
56458
+ name: "chainId",
56459
+ type: "uint256"
56460
+ },
56461
+ {
56462
+ internalType: "address",
56463
+ name: "verifyingContract",
56464
+ type: "address"
56465
+ },
56466
+ {
56467
+ internalType: "bytes32",
56468
+ name: "salt",
56469
+ type: "bytes32"
56470
+ },
56471
+ {
56472
+ internalType: "uint256[]",
56473
+ name: "extensions",
56474
+ type: "uint256[]"
56475
+ }
56476
+ ],
56477
+ stateMutability: "view",
56478
+ type: "function"
56479
+ },
56480
+ {
56481
+ inputs: [
56482
+ ],
56483
+ name: "name",
56484
+ outputs: [
56485
+ {
56486
+ internalType: "string",
56487
+ name: "",
56488
+ type: "string"
56489
+ }
56490
+ ],
56491
+ stateMutability: "view",
56492
+ type: "function"
56493
+ },
56494
+ {
56495
+ inputs: [
56496
+ {
56497
+ internalType: "address",
56498
+ name: "owner",
56499
+ type: "address"
56500
+ }
56501
+ ],
56502
+ name: "nonces",
56503
+ outputs: [
56504
+ {
56505
+ internalType: "uint256",
56506
+ name: "",
56507
+ type: "uint256"
56508
+ }
56509
+ ],
56510
+ stateMutability: "view",
56511
+ type: "function"
56512
+ },
56513
+ {
56514
+ inputs: [
56515
+ {
56516
+ internalType: "address",
56517
+ name: "owner",
56518
+ type: "address"
56519
+ },
56520
+ {
56521
+ internalType: "address",
56522
+ name: "spender",
56523
+ type: "address"
56524
+ },
56525
+ {
56526
+ internalType: "uint256",
56527
+ name: "value",
56528
+ type: "uint256"
56529
+ },
56530
+ {
56531
+ internalType: "uint256",
56532
+ name: "deadline",
56533
+ type: "uint256"
56534
+ },
56535
+ {
56536
+ internalType: "uint8",
56537
+ name: "v",
56538
+ type: "uint8"
56539
+ },
56540
+ {
56541
+ internalType: "bytes32",
56542
+ name: "r",
56543
+ type: "bytes32"
56544
+ },
56545
+ {
56546
+ internalType: "bytes32",
56547
+ name: "s",
56548
+ type: "bytes32"
56549
+ }
56550
+ ],
56551
+ name: "permit",
56552
+ outputs: [
56553
+ ],
56554
+ stateMutability: "nonpayable",
56555
+ type: "function"
56556
+ },
56557
+ {
56558
+ inputs: [
56559
+ ],
56560
+ name: "symbol",
56561
+ outputs: [
56562
+ {
56563
+ internalType: "string",
56564
+ name: "",
56565
+ type: "string"
56566
+ }
56567
+ ],
56568
+ stateMutability: "view",
56569
+ type: "function"
56570
+ },
56571
+ {
56572
+ inputs: [
56573
+ ],
56574
+ name: "totalSupply",
56575
+ outputs: [
56576
+ {
56577
+ internalType: "uint256",
56578
+ name: "",
56579
+ type: "uint256"
56580
+ }
56581
+ ],
56582
+ stateMutability: "view",
56583
+ type: "function"
56584
+ },
56585
+ {
56586
+ inputs: [
56587
+ {
56588
+ internalType: "address",
56589
+ name: "to",
56590
+ type: "address"
56591
+ },
56592
+ {
56593
+ internalType: "uint256",
56594
+ name: "value",
56595
+ type: "uint256"
56596
+ }
56597
+ ],
56598
+ name: "transfer",
56599
+ outputs: [
56600
+ {
56601
+ internalType: "bool",
56602
+ name: "",
56603
+ type: "bool"
56604
+ }
56605
+ ],
56606
+ stateMutability: "nonpayable",
56607
+ type: "function"
56608
+ },
56609
+ {
56610
+ inputs: [
56611
+ {
56612
+ internalType: "address",
56613
+ name: "from",
56614
+ type: "address"
56615
+ },
56616
+ {
56617
+ internalType: "address",
56618
+ name: "to",
56619
+ type: "address"
56620
+ },
56621
+ {
56622
+ internalType: "uint256",
56623
+ name: "value",
56624
+ type: "uint256"
56625
+ }
56626
+ ],
56627
+ name: "transferFrom",
56628
+ outputs: [
56629
+ {
56630
+ internalType: "bool",
56631
+ name: "",
56632
+ type: "bool"
56633
+ }
56634
+ ],
56635
+ stateMutability: "nonpayable",
56636
+ type: "function"
56637
+ }
56638
+ ];
56639
+
56640
+ var erc20Abi = [
56641
+ {
56642
+ inputs: [
56643
+ {
56644
+ internalType: "uint256",
56645
+ name: "initialSupply",
56646
+ type: "uint256"
56647
+ }
56648
+ ],
56649
+ stateMutability: "nonpayable",
56650
+ type: "constructor"
54294
56651
  },
54295
56652
  {
54296
56653
  inputs: [
@@ -54378,66 +56735,6 @@ var PolygonIdSdk = (function (exports) {
54378
56735
  name: "ERC20InvalidSpender",
54379
56736
  type: "error"
54380
56737
  },
54381
- {
54382
- inputs: [
54383
- {
54384
- internalType: "uint256",
54385
- name: "deadline",
54386
- type: "uint256"
54387
- }
54388
- ],
54389
- name: "ERC2612ExpiredSignature",
54390
- type: "error"
54391
- },
54392
- {
54393
- inputs: [
54394
- {
54395
- internalType: "address",
54396
- name: "signer",
54397
- type: "address"
54398
- },
54399
- {
54400
- internalType: "address",
54401
- name: "owner",
54402
- type: "address"
54403
- }
54404
- ],
54405
- name: "ERC2612InvalidSigner",
54406
- type: "error"
54407
- },
54408
- {
54409
- inputs: [
54410
- {
54411
- internalType: "address",
54412
- name: "account",
54413
- type: "address"
54414
- },
54415
- {
54416
- internalType: "uint256",
54417
- name: "currentNonce",
54418
- type: "uint256"
54419
- }
54420
- ],
54421
- name: "InvalidAccountNonce",
54422
- type: "error"
54423
- },
54424
- {
54425
- inputs: [
54426
- ],
54427
- name: "InvalidShortString",
54428
- type: "error"
54429
- },
54430
- {
54431
- inputs: [
54432
- {
54433
- internalType: "string",
54434
- name: "str",
54435
- type: "string"
54436
- }
54437
- ],
54438
- name: "StringTooLong",
54439
- type: "error"
54440
- },
54441
56738
  {
54442
56739
  anonymous: false,
54443
56740
  inputs: [
@@ -54463,13 +56760,6 @@ var PolygonIdSdk = (function (exports) {
54463
56760
  name: "Approval",
54464
56761
  type: "event"
54465
56762
  },
54466
- {
54467
- anonymous: false,
54468
- inputs: [
54469
- ],
54470
- name: "EIP712DomainChanged",
54471
- type: "event"
54472
- },
54473
56763
  {
54474
56764
  anonymous: false,
54475
56765
  inputs: [
@@ -54495,20 +56785,6 @@ var PolygonIdSdk = (function (exports) {
54495
56785
  name: "Transfer",
54496
56786
  type: "event"
54497
56787
  },
54498
- {
54499
- inputs: [
54500
- ],
54501
- name: "DOMAIN_SEPARATOR",
54502
- outputs: [
54503
- {
54504
- internalType: "bytes32",
54505
- name: "",
54506
- type: "bytes32"
54507
- }
54508
- ],
54509
- stateMutability: "view",
54510
- type: "function"
54511
- },
54512
56788
  {
54513
56789
  inputs: [
54514
56790
  {
@@ -54590,50 +56866,6 @@ var PolygonIdSdk = (function (exports) {
54590
56866
  stateMutability: "view",
54591
56867
  type: "function"
54592
56868
  },
54593
- {
54594
- inputs: [
54595
- ],
54596
- name: "eip712Domain",
54597
- outputs: [
54598
- {
54599
- internalType: "bytes1",
54600
- name: "fields",
54601
- type: "bytes1"
54602
- },
54603
- {
54604
- internalType: "string",
54605
- name: "name",
54606
- type: "string"
54607
- },
54608
- {
54609
- internalType: "string",
54610
- name: "version",
54611
- type: "string"
54612
- },
54613
- {
54614
- internalType: "uint256",
54615
- name: "chainId",
54616
- type: "uint256"
54617
- },
54618
- {
54619
- internalType: "address",
54620
- name: "verifyingContract",
54621
- type: "address"
54622
- },
54623
- {
54624
- internalType: "bytes32",
54625
- name: "salt",
54626
- type: "bytes32"
54627
- },
54628
- {
54629
- internalType: "uint256[]",
54630
- name: "extensions",
54631
- type: "uint256[]"
54632
- }
54633
- ],
54634
- stateMutability: "view",
54635
- type: "function"
54636
- },
54637
56869
  {
54638
56870
  inputs: [
54639
56871
  ],
@@ -54648,69 +56880,6 @@ var PolygonIdSdk = (function (exports) {
54648
56880
  stateMutability: "view",
54649
56881
  type: "function"
54650
56882
  },
54651
- {
54652
- inputs: [
54653
- {
54654
- internalType: "address",
54655
- name: "owner",
54656
- type: "address"
54657
- }
54658
- ],
54659
- name: "nonces",
54660
- outputs: [
54661
- {
54662
- internalType: "uint256",
54663
- name: "",
54664
- type: "uint256"
54665
- }
54666
- ],
54667
- stateMutability: "view",
54668
- type: "function"
54669
- },
54670
- {
54671
- inputs: [
54672
- {
54673
- internalType: "address",
54674
- name: "owner",
54675
- type: "address"
54676
- },
54677
- {
54678
- internalType: "address",
54679
- name: "spender",
54680
- type: "address"
54681
- },
54682
- {
54683
- internalType: "uint256",
54684
- name: "value",
54685
- type: "uint256"
54686
- },
54687
- {
54688
- internalType: "uint256",
54689
- name: "deadline",
54690
- type: "uint256"
54691
- },
54692
- {
54693
- internalType: "uint8",
54694
- name: "v",
54695
- type: "uint8"
54696
- },
54697
- {
54698
- internalType: "bytes32",
54699
- name: "r",
54700
- type: "bytes32"
54701
- },
54702
- {
54703
- internalType: "bytes32",
54704
- name: "s",
54705
- type: "bytes32"
54706
- }
54707
- ],
54708
- name: "permit",
54709
- outputs: [
54710
- ],
54711
- stateMutability: "nonpayable",
54712
- type: "function"
54713
- },
54714
56883
  {
54715
56884
  inputs: [
54716
56885
  ],
@@ -54805,10 +56974,11 @@ var PolygonIdSdk = (function (exports) {
54805
56974
  * @returns {Promise<PaymentRequestMessage>}
54806
56975
  */
54807
56976
  async function getPermitSignature(signer, tokenAddress, spender, value, deadline) {
54808
- const erc20PermitContract = new Contract(tokenAddress, abi, signer);
56977
+ const erc20PermitContract = new Contract(tokenAddress, permitAbi, signer);
54809
56978
  const nonce = await erc20PermitContract.nonces(await signer.getAddress());
54810
56979
  const domainData = await erc20PermitContract.eip712Domain();
54811
56980
  const domain = {
56981
+ name: domainData[1],
54812
56982
  version: domainData[2],
54813
56983
  chainId: domainData[3],
54814
56984
  verifyingContract: tokenAddress
@@ -54831,6 +57001,16 @@ var PolygonIdSdk = (function (exports) {
54831
57001
  };
54832
57002
  return signer.signTypedData(domain, types, message);
54833
57003
  }
57004
+ /**
57005
+ * @beta
57006
+ * getERC20Decimals is a function to retrieve the number of decimals of an ERC20 token
57007
+ * @param {string} tokenAddress - Token address
57008
+ * @param {ethers.ContractRunner} runner - Contract runner
57009
+ */
57010
+ async function getERC20Decimals(tokenAddress, runner) {
57011
+ const erc20Contract = new Contract(tokenAddress, erc20Abi, runner);
57012
+ return erc20Contract.decimals();
57013
+ }
54834
57014
 
54835
57015
  /**
54836
57016
  * Type of MerkleTree
@@ -56509,6 +58689,24 @@ var PolygonIdSdk = (function (exports) {
56509
58689
  }
56510
58690
  }
56511
58691
 
58692
+ class DidDocumentCredentialStatusResolver {
58693
+ constructor(didResolverUrl) {
58694
+ this.didResolverUrl = didResolverUrl;
58695
+ }
58696
+ async resolve(credentialStatus, opts) {
58697
+ if (!opts?.issuerDID) {
58698
+ throw new Error('IssuerDID is not set in options');
58699
+ }
58700
+ const url = `${this.didResolverUrl}/1.0/credential-status/${encodeURIComponent(opts.issuerDID.string())}`;
58701
+ const resp = await fetch(url, {
58702
+ method: 'POST',
58703
+ body: JSON.stringify(credentialStatus)
58704
+ });
58705
+ const data = await resp.json();
58706
+ return data;
58707
+ }
58708
+ }
58709
+
56512
58710
  /**
56513
58711
  *
56514
58712
  * Wallet instance is a wrapper of CRUD logic for W3C credentials,
@@ -56535,40 +58733,18 @@ var PolygonIdSdk = (function (exports) {
56535
58733
  if (!schema.$metadata.uris['jsonLdContext']) {
56536
58734
  throw new Error('jsonLdContext is missing is the schema');
56537
58735
  }
56538
- request.context = request.context ?? [];
56539
- if (request.displayMethod?.type === exports.DisplayMethodType.Iden3BasicDisplayMethodV1 &&
56540
- !request.context.includes(VerifiableConstants.JSONLD_SCHEMA.IDEN3_DISPLAY_METHOD)) {
56541
- request.context.push(VerifiableConstants.JSONLD_SCHEMA.IDEN3_DISPLAY_METHOD);
56542
- }
56543
- const context = [
56544
- VerifiableConstants.JSONLD_SCHEMA.W3C_CREDENTIAL_2018,
56545
- ...request.context,
56546
- VerifiableConstants.JSONLD_SCHEMA.IDEN3_CREDENTIAL,
56547
- schema.$metadata.uris['jsonLdContext']
56548
- ];
56549
- const credentialType = [
56550
- VerifiableConstants.CREDENTIAL_TYPE.W3C_VERIFIABLE_CREDENTIAL,
56551
- request.type
56552
- ];
56553
- const expirationDate = !request.expiration || request.expiration == 0 ? null : request.expiration;
56554
- const credentialSubject = request.credentialSubject;
56555
- credentialSubject['type'] = request.type;
56556
- const cr = new W3CCredential();
56557
- cr.id = `urn:${v4()}`;
56558
- cr['@context'] = context;
56559
- cr.type = credentialType;
56560
- cr.expirationDate = expirationDate ? new Date(expirationDate * 1000).toISOString() : undefined;
56561
- cr.refreshService = request.refreshService;
56562
- cr.displayMethod = request.displayMethod;
56563
- cr.issuanceDate = new Date().toISOString();
56564
- cr.credentialSubject = credentialSubject;
56565
- cr.issuer = issuer.string();
56566
- cr.credentialSchema = {
56567
- id: request.credentialSchema,
56568
- type: VerifiableConstants.JSON_SCHEMA_VALIDATOR
56569
- };
56570
- cr.credentialStatus = this.buildCredentialStatus(request, issuer);
56571
- return cr;
58736
+ // do copy of request to avoid mutation
58737
+ const r = { ...request };
58738
+ r.context = r.context ?? [];
58739
+ if (r.displayMethod?.type === exports.DisplayMethodType.Iden3BasicDisplayMethodV1 &&
58740
+ !r.context.includes(VerifiableConstants.JSONLD_SCHEMA.IDEN3_DISPLAY_METHOD)) {
58741
+ r.context.push(VerifiableConstants.JSONLD_SCHEMA.IDEN3_DISPLAY_METHOD);
58742
+ }
58743
+ r.context.push(schema.$metadata.uris['jsonLdContext']);
58744
+ r.expiration = r.expiration ? r.expiration * 1000 : undefined;
58745
+ r.id = r.id ? r.id : `urn:${v4()}`;
58746
+ r.issuanceDate = r.issuanceDate ? r.issuanceDate * 1000 : Date.now();
58747
+ return W3CCredential.fromCredentialRequest(issuer, r);
56572
58748
  };
56573
58749
  // if no credential status resolvers are provided
56574
58750
  // register default issuer resolver
@@ -56638,51 +58814,6 @@ var PolygonIdSdk = (function (exports) {
56638
58814
  }
56639
58815
  return statusResolver.resolve(credStatus, credentialStatusResolveOptions);
56640
58816
  }
56641
- /**
56642
- * Builds credential status
56643
- * @param {CredentialRequest} request
56644
- * @returns `CredentialStatus`
56645
- */
56646
- buildCredentialStatus(request, issuer) {
56647
- const credentialStatus = {
56648
- id: request.revocationOpts.id,
56649
- type: request.revocationOpts.type,
56650
- revocationNonce: request.revocationOpts.nonce
56651
- };
56652
- switch (request.revocationOpts.type) {
56653
- case exports.CredentialStatusType.SparseMerkleTreeProof:
56654
- return {
56655
- ...credentialStatus,
56656
- id: `${credentialStatus.id.replace(/\/$/, '')}/${credentialStatus.revocationNonce}`
56657
- };
56658
- case exports.CredentialStatusType.Iden3ReverseSparseMerkleTreeProof:
56659
- return {
56660
- ...credentialStatus,
56661
- id: request.revocationOpts.issuerState
56662
- ? `${credentialStatus.id.replace(/\/$/, '')}/node?state=${request.revocationOpts.issuerState}`
56663
- : `${credentialStatus.id.replace(/\/$/, '')}`
56664
- };
56665
- case exports.CredentialStatusType.Iden3OnchainSparseMerkleTreeProof2023: {
56666
- const issuerId = Q$2.idFromDID(issuer);
56667
- const chainId = et$2(Q$2.blockchainFromId(issuerId), Q$2.networkIdFromId(issuerId));
56668
- const searchParams = [
56669
- ['revocationNonce', request.revocationOpts.nonce?.toString() || ''],
56670
- ['contractAddress', `${chainId}:${request.revocationOpts.id}`],
56671
- ['state', request.revocationOpts.issuerState || '']
56672
- ]
56673
- .filter(([, value]) => Boolean(value))
56674
- .map(([key, value]) => `${key}=${value}`)
56675
- .join('&');
56676
- return {
56677
- ...credentialStatus,
56678
- // `[did]:[methodid]:[chain]:[network]:[id]/credentialStatus?(revocationNonce=value)&[contractAddress=[chainID]:[contractAddress]]&(state=issuerState)`
56679
- id: `${issuer.string()}/credentialStatus?${searchParams}`
56680
- };
56681
- }
56682
- default:
56683
- return credentialStatus;
56684
- }
56685
- }
56686
58817
  /**
56687
58818
  * {@inheritDoc ICredentialWallet.findById}
56688
58819
  */
@@ -79402,10 +81533,34 @@ var PolygonIdSdk = (function (exports) {
79402
81533
  return this.handleFetchRequest(message);
79403
81534
  case PROTOCOL_MESSAGE_TYPE.CREDENTIAL_ISSUANCE_RESPONSE_MESSAGE_TYPE:
79404
81535
  return this.handleIssuanceResponseMsg(message);
81536
+ case PROTOCOL_MESSAGE_TYPE.CREDENTIAL_ONCHAIN_OFFER_MESSAGE_TYPE: {
81537
+ const result = await this.handleOnchainOfferMessage(message);
81538
+ if (Array.isArray(result)) {
81539
+ const credWallet = this.opts?.credentialWallet;
81540
+ if (!credWallet)
81541
+ throw new Error('Credential wallet is not provided');
81542
+ await credWallet.saveAll(result);
81543
+ return null;
81544
+ }
81545
+ return result;
81546
+ }
79405
81547
  default:
79406
81548
  return super.handle(message, ctx);
79407
81549
  }
79408
81550
  }
81551
+ async handleOnchainOfferMessage(offerMessage) {
81552
+ if (!this.opts?.onchainIssuer) {
81553
+ throw new Error('onchain issuer is not provided');
81554
+ }
81555
+ const credentials = [];
81556
+ for (const credentialInfo of offerMessage.body.credentials) {
81557
+ const issuerDID = Q$2.parse(offerMessage.from);
81558
+ const userDID = Q$2.parse(offerMessage.to);
81559
+ const credential = await this.opts.onchainIssuer.getCredential(issuerDID, userDID, BigInt(credentialInfo.id));
81560
+ credentials.push(credential);
81561
+ }
81562
+ return credentials;
81563
+ }
79409
81564
  async handleOfferMessage(offerMessage, ctx) {
79410
81565
  if (!ctx.mediaType) {
79411
81566
  ctx.mediaType = MediaType.ZKPMessage;
@@ -79490,6 +81645,14 @@ var PolygonIdSdk = (function (exports) {
79490
81645
  }
79491
81646
  throw new Error('invalid protocol message response');
79492
81647
  }
81648
+ /**
81649
+ * Handles only messages with credentials/1.0/onchain-offer type
81650
+ * @beta
81651
+ */
81652
+ async handleOnchainOffer(offer) {
81653
+ const offerMessage = await FetchHandler.unpackMessage(this._packerMgr, offer, PROTOCOL_MESSAGE_TYPE.CREDENTIAL_ONCHAIN_OFFER_MESSAGE_TYPE);
81654
+ return this.handleOnchainOfferMessage(offerMessage);
81655
+ }
79493
81656
  async handleFetchRequest(msgRequest) {
79494
81657
  if (!msgRequest.to) {
79495
81658
  throw new Error("failed request. empty 'to' field");
@@ -79592,6 +81755,7 @@ var PolygonIdSdk = (function (exports) {
79592
81755
  this._proofService = _proofService;
79593
81756
  this._zkpVerifier = _zkpVerifier;
79594
81757
  this._supportedCircuits = [
81758
+ exports.CircuitId.AuthV2,
79595
81759
  exports.CircuitId.AtomicQueryMTPV2OnChain,
79596
81760
  exports.CircuitId.AtomicQuerySigV2OnChain,
79597
81761
  exports.CircuitId.AtomicQueryV3OnChain
@@ -79622,7 +81786,12 @@ var PolygonIdSdk = (function (exports) {
79622
81786
  throw new Error(`Invalid chain id ${chain_id}`);
79623
81787
  }
79624
81788
  const verifierDid = message.from ? Q$2.parse(message.from) : undefined;
79625
- const zkpResponses = await processZeroKnowledgeProofRequests(did, message?.body?.scope, verifierDid, this._proofService, { ethSigner, challenge, supportedCircuits: this._supportedCircuits });
81789
+ const { scope = [] } = message.body;
81790
+ const zkpResponses = await processZeroKnowledgeProofRequests(did, scope, verifierDid, this._proofService, {
81791
+ ethSigner,
81792
+ challenge,
81793
+ supportedCircuits: this._supportedCircuits
81794
+ });
79626
81795
  const methodId = message.body.transaction_data.method_id.replace('0x', '');
79627
81796
  switch (methodId) {
79628
81797
  case exports.FunctionSignatures.SubmitZKPResponseV2:
@@ -80147,7 +82316,7 @@ var PolygonIdSdk = (function (exports) {
80147
82316
  ? {
80148
82317
  recipient: data.recipient,
80149
82318
  amount: data.amount,
80150
- expirationDate: new Date(data.expirationDate).getTime(),
82319
+ expirationDate: b$4(new Date(data.expirationDate)),
80151
82320
  nonce: data.nonce,
80152
82321
  metadata: '0x'
80153
82322
  }
@@ -80155,7 +82324,7 @@ var PolygonIdSdk = (function (exports) {
80155
82324
  tokenAddress: data.tokenAddress,
80156
82325
  recipient: data.recipient,
80157
82326
  amount: data.amount,
80158
- expirationDate: new Date(data.expirationDate).getTime(),
82327
+ expirationDate: b$4(new Date(data.expirationDate)),
80159
82328
  nonce: data.nonce,
80160
82329
  metadata: '0x'
80161
82330
  };
@@ -80364,37 +82533,39 @@ var PolygonIdSdk = (function (exports) {
80364
82533
  for (let i = 0; i < payments.length; i++) {
80365
82534
  const { credentials, description } = payments[i];
80366
82535
  const dataArr = [];
80367
- for (let j = 0; j < payments[i].chains.length; j++) {
80368
- const { features, nonce, amount, currency, chainId, expirationDate, type } = payments[i].chains[j];
82536
+ for (let j = 0; j < payments[i].options.length; j++) {
82537
+ const { nonce, amount, chainId, optionId, expirationDate } = payments[i].options[j];
80369
82538
  const multiChainConfig = this._params.multiChainPaymentConfig?.find((c) => c.chainId === chainId);
80370
82539
  if (!multiChainConfig) {
80371
82540
  throw new Error(`failed request. no config for chain ${chainId}`);
80372
82541
  }
80373
- const { recipient, paymentContract, erc20TokenAddressArr } = multiChainConfig;
80374
- const tokenAddress = erc20TokenAddressArr.find((t) => t.symbol === currency)?.address;
80375
- if (type === exports.PaymentRequestDataType.Iden3PaymentRailsERC20RequestV1 && !tokenAddress) {
80376
- throw new Error(`failed request. no token address for currency ${currency}`);
82542
+ const { recipient, paymentRails, options } = multiChainConfig;
82543
+ const option = options.find((t) => t.id === optionId);
82544
+ if (!option) {
82545
+ throw new Error(`failed request. no option for id ${optionId}`);
80377
82546
  }
80378
- const expirationTime = expirationDate
80379
- ? new Date(expirationDate).getTime()
80380
- : new Date(new Date().setHours(new Date().getHours() + 1)).getTime();
80381
- const typeUrl = `https://schema.iden3.io/core/json/${type}.json`;
82547
+ if (option.type === exports.PaymentRequestDataType.Iden3PaymentRailsERC20RequestV1 &&
82548
+ !option.contractAddress) {
82549
+ throw new Error(`failed request. no token address for option id ${optionId}`);
82550
+ }
82551
+ const expirationDateRequired = expirationDate ?? new Date(new Date().setHours(new Date().getHours() + 1));
82552
+ const typeUrl = `https://schema.iden3.io/core/json/${option.type}.json`;
80382
82553
  const typesFetchResult = await fetch(typeUrl);
80383
82554
  const types = await typesFetchResult.json();
80384
82555
  delete types.EIP712Domain;
80385
- const paymentData = type === exports.PaymentRequestDataType.Iden3PaymentRailsRequestV1
82556
+ const paymentData = option.type === exports.PaymentRequestDataType.Iden3PaymentRailsRequestV1
80386
82557
  ? {
80387
82558
  recipient,
80388
- amount,
80389
- expirationDate: expirationTime,
82559
+ amount: amount,
82560
+ expirationDate: b$4(expirationDateRequired),
80390
82561
  nonce,
80391
82562
  metadata: '0x'
80392
82563
  }
80393
82564
  : {
80394
- tokenAddress,
82565
+ tokenAddress: option.contractAddress,
80395
82566
  recipient,
80396
- amount,
80397
- expirationDate: expirationTime,
82567
+ amount: amount,
82568
+ expirationDate: b$4(expirationDateRequired),
80398
82569
  nonce,
80399
82570
  metadata: '0x'
80400
82571
  };
@@ -80402,7 +82573,7 @@ var PolygonIdSdk = (function (exports) {
80402
82573
  name: 'MCPayment',
80403
82574
  version: '1.0.0',
80404
82575
  chainId,
80405
- verifyingContract: paymentContract
82576
+ verifyingContract: paymentRails
80406
82577
  };
80407
82578
  const signature = await signer.signTypedData(domain, types, paymentData);
80408
82579
  const proof = [
@@ -80422,20 +82593,24 @@ var PolygonIdSdk = (function (exports) {
80422
82593
  const d = {
80423
82594
  type: exports.PaymentRequestDataType.Iden3PaymentRailsRequestV1,
80424
82595
  '@context': [
80425
- `https://schema.iden3.io/core/jsonld/payment.jsonld#${type}`,
82596
+ `https://schema.iden3.io/core/jsonld/payment.jsonld#${option.type}`,
80426
82597
  'https://w3id.org/security/suites/eip712sig-2021/v1'
80427
82598
  ],
80428
82599
  recipient,
80429
82600
  amount: amount.toString(),
80430
- currency,
80431
- expirationDate: new Date(expirationTime).toISOString(),
82601
+ expirationDate: expirationDateRequired.toISOString(),
80432
82602
  nonce: nonce.toString(),
80433
82603
  metadata: '0x',
80434
82604
  proof
80435
82605
  };
80436
- dataArr.push(type === exports.PaymentRequestDataType.Iden3PaymentRailsRequestV1
82606
+ dataArr.push(option.type === exports.PaymentRequestDataType.Iden3PaymentRailsRequestV1
80437
82607
  ? d
80438
- : { ...d, type, tokenAddress: tokenAddress || '', features: features || [] });
82608
+ : {
82609
+ ...d,
82610
+ type: option.type,
82611
+ tokenAddress: option.contractAddress || '',
82612
+ features: option.features || []
82613
+ });
80439
82614
  }
80440
82615
  paymentRequestInfo.push({
80441
82616
  data: dataArr,
@@ -81790,6 +83965,12 @@ var PolygonIdSdk = (function (exports) {
81790
83965
  authInputs.gistProof = gistProof;
81791
83966
  return authInputs.inputsMarshal();
81792
83967
  }
83968
+ /** {@inheritdoc IProofService.generateAuthV2Proof} */
83969
+ async generateAuthV2Proof(challenge, did) {
83970
+ const authInputs = await this.generateAuthV2Inputs(challenge, did, exports.CircuitId.AuthV2);
83971
+ const zkProof = await this._prover.generate(authInputs, exports.CircuitId.AuthV2);
83972
+ return zkProof;
83973
+ }
81793
83974
  async verifyState(circuitId, pubSignals, opts = {
81794
83975
  acceptedStateTransitionDelay: DEFAULT_AUTH_VERIFY_DELAY
81795
83976
  }) {
@@ -82587,6 +84768,8 @@ var PolygonIdSdk = (function (exports) {
82587
84768
  exports.CredentialWallet = CredentialWallet;
82588
84769
  exports.DIDDocumentJSONSchema = DIDDocumentJSONSchema;
82589
84770
  exports.DataPrepareHandlerFunc = DataPrepareHandlerFunc;
84771
+ exports.DidDocumentCredentialStatusResolver = DidDocumentCredentialStatusResolver;
84772
+ exports.DidResolverStateReadonlyStorage = DidResolverStateReadonlyStorage;
82590
84773
  exports.Ed25519Provider = Ed25519Provider;
82591
84774
  exports.ErrorEmptyAuthClaimNonRevProof = ErrorEmptyAuthClaimNonRevProof;
82592
84775
  exports.ErrorEmptyAuthClaimProof = ErrorEmptyAuthClaimProof;
@@ -82629,6 +84812,7 @@ var PolygonIdSdk = (function (exports) {
82629
84812
  exports.OnChainResolver = OnChainResolver;
82630
84813
  exports.OnChainRevocationStorage = OnChainRevocationStorage;
82631
84814
  exports.OnChainZKPVerifier = OnChainZKPVerifier;
84815
+ exports.OnchainIssuer = OnchainIssuer;
82632
84816
  exports.PROTOCOL_CONSTANTS = constants;
82633
84817
  exports.PackageManager = PackageManager;
82634
84818
  exports.Parser = Parser;
@@ -82712,6 +84896,7 @@ var PolygonIdSdk = (function (exports) {
82712
84896
  exports.findCredentialType = findCredentialType;
82713
84897
  exports.findValue = findValue;
82714
84898
  exports.generateProfileDID = generateProfileDID;
84899
+ exports.getERC20Decimals = getERC20Decimals;
82715
84900
  exports.getFieldSlotIndex = getFieldSlotIndex;
82716
84901
  exports.getKMSIdByAuthCredential = getKMSIdByAuthCredential;
82717
84902
  exports.getNodeAuxValue = getNodeAuxValue;