@0xpolygonid/js-sdk 1.21.3 → 1.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/dist/browser/esm/index.js +1358 -270
  2. package/dist/browser/esm/index.js.map +1 -1
  3. package/dist/browser/umd/index.js +1363 -270
  4. package/dist/browser/umd/index.js.map +1 -1
  5. package/dist/node/cjs/iden3comm/constants.js +25 -1
  6. package/dist/node/cjs/iden3comm/handlers/auth.js +52 -8
  7. package/dist/node/cjs/iden3comm/handlers/common.js +13 -1
  8. package/dist/node/cjs/iden3comm/handlers/contract-request.js +5 -1
  9. package/dist/node/cjs/iden3comm/handlers/credential-proposal.js +14 -3
  10. package/dist/node/cjs/iden3comm/handlers/fetch.js +12 -2
  11. package/dist/node/cjs/iden3comm/handlers/message-handler.js +4 -0
  12. package/dist/node/cjs/iden3comm/handlers/payment.js +240 -28
  13. package/dist/node/cjs/iden3comm/handlers/revocation-status.js +4 -0
  14. package/dist/node/cjs/iden3comm/index.js +1 -0
  15. package/dist/node/cjs/iden3comm/packageManager.js +12 -0
  16. package/dist/node/cjs/iden3comm/packers/jws.js +21 -0
  17. package/dist/node/cjs/iden3comm/packers/plain.js +19 -0
  18. package/dist/node/cjs/iden3comm/packers/zkp.js +25 -0
  19. package/dist/node/cjs/iden3comm/types/index.js +1 -0
  20. package/dist/node/cjs/iden3comm/types/protocol/accept-profile.js +2 -0
  21. package/dist/node/cjs/iden3comm/utils/accept-profile.js +107 -0
  22. package/dist/node/cjs/iden3comm/utils/index.js +1 -0
  23. package/dist/node/cjs/storage/blockchain/abi/ERC20Permit.json +1 -0
  24. package/dist/node/cjs/storage/blockchain/erc20-permit-sig.js +46 -0
  25. package/dist/node/cjs/storage/blockchain/index.js +1 -0
  26. package/dist/node/cjs/verifiable/constants.js +28 -11
  27. package/dist/node/esm/iden3comm/constants.js +24 -0
  28. package/dist/node/esm/iden3comm/handlers/auth.js +55 -11
  29. package/dist/node/esm/iden3comm/handlers/common.js +11 -0
  30. package/dist/node/esm/iden3comm/handlers/contract-request.js +7 -3
  31. package/dist/node/esm/iden3comm/handlers/credential-proposal.js +15 -4
  32. package/dist/node/esm/iden3comm/handlers/fetch.js +12 -2
  33. package/dist/node/esm/iden3comm/handlers/message-handler.js +4 -0
  34. package/dist/node/esm/iden3comm/handlers/payment.js +240 -29
  35. package/dist/node/esm/iden3comm/handlers/revocation-status.js +4 -0
  36. package/dist/node/esm/iden3comm/index.js +1 -0
  37. package/dist/node/esm/iden3comm/packageManager.js +12 -0
  38. package/dist/node/esm/iden3comm/packers/jws.js +22 -1
  39. package/dist/node/esm/iden3comm/packers/plain.js +19 -0
  40. package/dist/node/esm/iden3comm/packers/zkp.js +26 -1
  41. package/dist/node/esm/iden3comm/types/index.js +1 -0
  42. package/dist/node/esm/iden3comm/types/protocol/accept-profile.js +1 -0
  43. package/dist/node/esm/iden3comm/utils/accept-profile.js +102 -0
  44. package/dist/node/esm/iden3comm/utils/index.js +1 -0
  45. package/dist/node/esm/storage/blockchain/abi/ERC20Permit.json +1 -0
  46. package/dist/node/esm/storage/blockchain/erc20-permit-sig.js +39 -0
  47. package/dist/node/esm/storage/blockchain/index.js +1 -0
  48. package/dist/node/esm/verifiable/constants.js +27 -10
  49. package/dist/types/iden3comm/constants.d.ts +16 -0
  50. package/dist/types/iden3comm/handlers/auth.d.ts +19 -7
  51. package/dist/types/iden3comm/handlers/common.d.ts +7 -1
  52. package/dist/types/iden3comm/handlers/contract-request.d.ts +2 -2
  53. package/dist/types/iden3comm/handlers/credential-proposal.d.ts +9 -4
  54. package/dist/types/iden3comm/handlers/fetch.d.ts +22 -6
  55. package/dist/types/iden3comm/handlers/message-handler.d.ts +6 -0
  56. package/dist/types/iden3comm/handlers/payment.d.ts +70 -10
  57. package/dist/types/iden3comm/handlers/revocation-status.d.ts +2 -2
  58. package/dist/types/iden3comm/index.d.ts +1 -0
  59. package/dist/types/iden3comm/packageManager.d.ts +4 -0
  60. package/dist/types/iden3comm/packers/jws.d.ts +5 -0
  61. package/dist/types/iden3comm/packers/plain.d.ts +4 -0
  62. package/dist/types/iden3comm/packers/zkp.d.ts +6 -0
  63. package/dist/types/iden3comm/types/index.d.ts +1 -0
  64. package/dist/types/iden3comm/types/packageManager.d.ts +14 -0
  65. package/dist/types/iden3comm/types/packer.d.ts +25 -0
  66. package/dist/types/iden3comm/types/protocol/accept-profile.d.ts +7 -0
  67. package/dist/types/iden3comm/types/protocol/auth.d.ts +1 -0
  68. package/dist/types/iden3comm/types/protocol/credentials.d.ts +6 -6
  69. package/dist/types/iden3comm/types/protocol/messages.d.ts +2 -2
  70. package/dist/types/iden3comm/types/protocol/payment.d.ts +87 -13
  71. package/dist/types/iden3comm/types/protocol/proof.d.ts +3 -3
  72. package/dist/types/iden3comm/types/protocol/revocation.d.ts +2 -2
  73. package/dist/types/iden3comm/utils/accept-profile.d.ts +3 -0
  74. package/dist/types/iden3comm/utils/index.d.ts +1 -0
  75. package/dist/types/storage/blockchain/erc20-permit-sig.d.ts +12 -0
  76. package/dist/types/storage/blockchain/index.d.ts +1 -0
  77. package/dist/types/verifiable/constants.d.ts +27 -11
  78. package/package.json +2 -2
@@ -1,4 +1,4 @@
1
- import { DID, buildDIDType, Id as Id$1, genesisFromEthAddress, BytesHelper, checkBigIntInField, Claim, SchemaHash, ClaimOptions, MerklizedRootPosition as MerklizedRootPosition$1, IdPosition, getChainId, ChainIds, getUnixTimestamp, getDateFromUnixTimestamp, DidMethod, Blockchain, NetworkId } from '@iden3/js-iden3-core';
1
+ import { DID, buildDIDType, Id as Id$1, genesisFromEthAddress, BytesHelper, checkBigIntInField, Claim, SchemaHash, ClaimOptions, MerklizedRootPosition as MerklizedRootPosition$1, IdPosition, getChainId, getUnixTimestamp, ChainIds, getDateFromUnixTimestamp, DidMethod, Blockchain, NetworkId } from '@iden3/js-iden3-core';
2
2
  import * as jsIden3Core from '@iden3/js-iden3-core';
3
3
  export { jsIden3Core as core };
4
4
  import { Path, Merklizer, getDocumentLoader } from '@iden3/js-jsonld-merklization';
@@ -7785,15 +7785,6 @@ var RefreshServiceType;
7785
7785
  (function (RefreshServiceType) {
7786
7786
  RefreshServiceType["Iden3RefreshService2023"] = "Iden3RefreshService2023";
7787
7787
  })(RefreshServiceType || (RefreshServiceType = {}));
7788
- /**
7789
- * PaymentRequestType type for payment requests
7790
- * @beta
7791
- * @enum {string}
7792
- */
7793
- var PaymentRequestType;
7794
- (function (PaymentRequestType) {
7795
- PaymentRequestType["PaymentRequest"] = "PaymentRequest";
7796
- })(PaymentRequestType || (PaymentRequestType = {}));
7797
7788
  /**
7798
7789
  * PaymentRequestDataType type for payment requests
7799
7790
  * @beta
@@ -7802,6 +7793,8 @@ var PaymentRequestType;
7802
7793
  var PaymentRequestDataType;
7803
7794
  (function (PaymentRequestDataType) {
7804
7795
  PaymentRequestDataType["Iden3PaymentRequestCryptoV1"] = "Iden3PaymentRequestCryptoV1";
7796
+ PaymentRequestDataType["Iden3PaymentRailsRequestV1"] = "Iden3PaymentRailsRequestV1";
7797
+ PaymentRequestDataType["Iden3PaymentRailsERC20RequestV1"] = "Iden3PaymentRailsERC20RequestV1";
7805
7798
  })(PaymentRequestDataType || (PaymentRequestDataType = {}));
7806
7799
  /**
7807
7800
  * PaymentType type for payment responses
@@ -7811,17 +7804,41 @@ var PaymentRequestDataType;
7811
7804
  var PaymentType;
7812
7805
  (function (PaymentType) {
7813
7806
  PaymentType["Iden3PaymentCryptoV1"] = "Iden3PaymentCryptoV1";
7807
+ PaymentType["Iden3PaymentRailsV1"] = "Iden3PaymentRailsV1";
7808
+ PaymentType["Iden3PaymentRailsERC20V1"] = "Iden3PaymentRailsERC20V1";
7814
7809
  })(PaymentType || (PaymentType = {}));
7810
+ /**
7811
+ * SupportedPaymentProofType type for payment proofs
7812
+ * @beta
7813
+ * @enum {string}
7814
+ */
7815
+ var SupportedPaymentProofType;
7816
+ (function (SupportedPaymentProofType) {
7817
+ SupportedPaymentProofType["EthereumEip712Signature2021"] = "EthereumEip712Signature2021";
7818
+ })(SupportedPaymentProofType || (SupportedPaymentProofType = {}));
7815
7819
  /**
7816
7820
  * Media types for Payment supported currencies
7817
7821
  * @beta
7818
- * @enum {number}
7822
+ * @enum {string}
7819
7823
  */
7820
7824
  var SupportedCurrencies;
7821
7825
  (function (SupportedCurrencies) {
7822
7826
  SupportedCurrencies["ETH"] = "ETH";
7827
+ SupportedCurrencies["ETH_WEI"] = "ETHWEI";
7828
+ SupportedCurrencies["ETH_GWEI"] = "ETHGWEI";
7823
7829
  SupportedCurrencies["MATIC"] = "MATIC";
7830
+ SupportedCurrencies["USDT"] = "USDT";
7831
+ SupportedCurrencies["USDC"] = "USDC";
7824
7832
  })(SupportedCurrencies || (SupportedCurrencies = {}));
7833
+ /**
7834
+ * Supported features for payment-request
7835
+ * @beta
7836
+ * @enum {string}
7837
+ */
7838
+ var PaymentFeatures;
7839
+ (function (PaymentFeatures) {
7840
+ PaymentFeatures["EIP_2612"] = "EIP-2612";
7841
+ })(PaymentFeatures || (PaymentFeatures = {}));
7825
7842
  /**
7826
7843
  * DisplayMethodType type for display method
7827
7844
  *
@@ -39847,6 +39864,12 @@ class TypedDataEncoder {
39847
39864
  };
39848
39865
  }
39849
39866
  }
39867
+ /**
39868
+ * Compute the address used to sign the typed data for the %%signature%%.
39869
+ */
39870
+ function verifyTypedData(domain, types, value, signature) {
39871
+ return recoverAddress(TypedDataEncoder.hash(domain, types, value), signature);
39872
+ }
39850
39873
 
39851
39874
  /**
39852
39875
  * A fragment is a single item from an ABI, which may represent any of:
@@ -51324,7 +51347,7 @@ class LinkedMultiQueryPubSignals {
51324
51347
  }
51325
51348
  }
51326
51349
 
51327
- var abi$2 = [
51350
+ var abi$3 = [
51328
51351
  {
51329
51352
  inputs: [
51330
51353
  ],
@@ -52438,7 +52461,7 @@ class EthStateStorage {
52438
52461
  this.ethConfig = ethConfig;
52439
52462
  const config = Array.isArray(ethConfig) ? ethConfig[0] : ethConfig;
52440
52463
  this.provider = new JsonRpcProvider(config.url);
52441
- this.stateContract = new Contract(config.contractAddress, abi$2, this.provider);
52464
+ this.stateContract = new Contract(config.contractAddress, abi$3, this.provider);
52442
52465
  this._transactionService = new TransactionService(this.getRpcProvider());
52443
52466
  }
52444
52467
  /** {@inheritdoc IStateStorage.getLatestStateById} */
@@ -52578,7 +52601,7 @@ class EthStateStorage {
52578
52601
  const chainId = getChainId(DID.blockchainFromId(idTyped), DID.networkIdFromId(idTyped));
52579
52602
  const config = this.networkByChainId(chainId);
52580
52603
  const provider = new JsonRpcProvider(config.url);
52581
- const stateContract = new Contract(config.contractAddress, abi$2, provider);
52604
+ const stateContract = new Contract(config.contractAddress, abi$3, provider);
52582
52605
  return { stateContract, provider };
52583
52606
  }
52584
52607
  networkByChainId(chainId) {
@@ -52591,7 +52614,7 @@ class EthStateStorage {
52591
52614
  }
52592
52615
  }
52593
52616
 
52594
- var abi$1 = [
52617
+ var abi$2 = [
52595
52618
  {
52596
52619
  inputs: [
52597
52620
  ],
@@ -53491,7 +53514,7 @@ class OnChainZKPVerifier {
53491
53514
  const maxPriorityFeePerGas = chainConfig.maxPriorityFeePerGas
53492
53515
  ? BigInt(chainConfig.maxPriorityFeePerGas)
53493
53516
  : feeData.maxPriorityFeePerGas;
53494
- const verifierContract = new Contract(txData.contract_address, abi$1);
53517
+ const verifierContract = new Contract(txData.contract_address, abi$2);
53495
53518
  for (const zkProofResponse of zkProofResponses) {
53496
53519
  const txArgs = await this.prepareTxArgsSubmitV1(txData, zkProofResponse);
53497
53520
  const payload = await verifierContract.submitZKPResponse.populateTransaction(...txArgs);
@@ -53539,7 +53562,7 @@ class OnChainZKPVerifier {
53539
53562
  const maxPriorityFeePerGas = chainConfig.maxPriorityFeePerGas
53540
53563
  ? BigInt(chainConfig.maxPriorityFeePerGas)
53541
53564
  : feeData.maxPriorityFeePerGas;
53542
- const verifierContract = new Contract(txData.contract_address, abi$1);
53565
+ const verifierContract = new Contract(txData.contract_address, abi$2);
53543
53566
  const txRequestData = await verifierContract.submitZKPResponseV2.populateTransaction(...txDataArgs);
53544
53567
  const request = {
53545
53568
  to: txData.contract_address,
@@ -53732,7 +53755,7 @@ class OnChainZKPVerifier {
53732
53755
  }
53733
53756
  }
53734
53757
 
53735
- var abi = [
53758
+ var abi$1 = [
53736
53759
  {
53737
53760
  inputs: [
53738
53761
  ],
@@ -54020,7 +54043,7 @@ class OnChainRevocationStorage {
54020
54043
  this._config = _config;
54021
54044
  this._signer = _signer;
54022
54045
  this._provider = new JsonRpcProvider(_config.url);
54023
- let contract = new Contract(contractAddress, abi, this._provider);
54046
+ let contract = new Contract(contractAddress, abi$1, this._provider);
54024
54047
  if (this._signer) {
54025
54048
  this._signer = this._signer.connect(this._provider);
54026
54049
  contract = contract.connect(this._signer);
@@ -54101,6 +54124,575 @@ class OnChainRevocationStorage {
54101
54124
  }
54102
54125
  }
54103
54126
 
54127
+ var abi = [
54128
+ {
54129
+ inputs: [
54130
+ ],
54131
+ name: "ECDSAInvalidSignature",
54132
+ type: "error"
54133
+ },
54134
+ {
54135
+ inputs: [
54136
+ {
54137
+ internalType: "uint256",
54138
+ name: "length",
54139
+ type: "uint256"
54140
+ }
54141
+ ],
54142
+ name: "ECDSAInvalidSignatureLength",
54143
+ type: "error"
54144
+ },
54145
+ {
54146
+ inputs: [
54147
+ {
54148
+ internalType: "bytes32",
54149
+ name: "s",
54150
+ type: "bytes32"
54151
+ }
54152
+ ],
54153
+ name: "ECDSAInvalidSignatureS",
54154
+ type: "error"
54155
+ },
54156
+ {
54157
+ inputs: [
54158
+ {
54159
+ internalType: "address",
54160
+ name: "spender",
54161
+ type: "address"
54162
+ },
54163
+ {
54164
+ internalType: "uint256",
54165
+ name: "allowance",
54166
+ type: "uint256"
54167
+ },
54168
+ {
54169
+ internalType: "uint256",
54170
+ name: "needed",
54171
+ type: "uint256"
54172
+ }
54173
+ ],
54174
+ name: "ERC20InsufficientAllowance",
54175
+ type: "error"
54176
+ },
54177
+ {
54178
+ inputs: [
54179
+ {
54180
+ internalType: "address",
54181
+ name: "sender",
54182
+ type: "address"
54183
+ },
54184
+ {
54185
+ internalType: "uint256",
54186
+ name: "balance",
54187
+ type: "uint256"
54188
+ },
54189
+ {
54190
+ internalType: "uint256",
54191
+ name: "needed",
54192
+ type: "uint256"
54193
+ }
54194
+ ],
54195
+ name: "ERC20InsufficientBalance",
54196
+ type: "error"
54197
+ },
54198
+ {
54199
+ inputs: [
54200
+ {
54201
+ internalType: "address",
54202
+ name: "approver",
54203
+ type: "address"
54204
+ }
54205
+ ],
54206
+ name: "ERC20InvalidApprover",
54207
+ type: "error"
54208
+ },
54209
+ {
54210
+ inputs: [
54211
+ {
54212
+ internalType: "address",
54213
+ name: "receiver",
54214
+ type: "address"
54215
+ }
54216
+ ],
54217
+ name: "ERC20InvalidReceiver",
54218
+ type: "error"
54219
+ },
54220
+ {
54221
+ inputs: [
54222
+ {
54223
+ internalType: "address",
54224
+ name: "sender",
54225
+ type: "address"
54226
+ }
54227
+ ],
54228
+ name: "ERC20InvalidSender",
54229
+ type: "error"
54230
+ },
54231
+ {
54232
+ inputs: [
54233
+ {
54234
+ internalType: "address",
54235
+ name: "spender",
54236
+ type: "address"
54237
+ }
54238
+ ],
54239
+ name: "ERC20InvalidSpender",
54240
+ type: "error"
54241
+ },
54242
+ {
54243
+ inputs: [
54244
+ {
54245
+ internalType: "uint256",
54246
+ name: "deadline",
54247
+ type: "uint256"
54248
+ }
54249
+ ],
54250
+ name: "ERC2612ExpiredSignature",
54251
+ type: "error"
54252
+ },
54253
+ {
54254
+ inputs: [
54255
+ {
54256
+ internalType: "address",
54257
+ name: "signer",
54258
+ type: "address"
54259
+ },
54260
+ {
54261
+ internalType: "address",
54262
+ name: "owner",
54263
+ type: "address"
54264
+ }
54265
+ ],
54266
+ name: "ERC2612InvalidSigner",
54267
+ type: "error"
54268
+ },
54269
+ {
54270
+ inputs: [
54271
+ {
54272
+ internalType: "address",
54273
+ name: "account",
54274
+ type: "address"
54275
+ },
54276
+ {
54277
+ internalType: "uint256",
54278
+ name: "currentNonce",
54279
+ type: "uint256"
54280
+ }
54281
+ ],
54282
+ name: "InvalidAccountNonce",
54283
+ type: "error"
54284
+ },
54285
+ {
54286
+ inputs: [
54287
+ ],
54288
+ name: "InvalidShortString",
54289
+ type: "error"
54290
+ },
54291
+ {
54292
+ inputs: [
54293
+ {
54294
+ internalType: "string",
54295
+ name: "str",
54296
+ type: "string"
54297
+ }
54298
+ ],
54299
+ name: "StringTooLong",
54300
+ type: "error"
54301
+ },
54302
+ {
54303
+ anonymous: false,
54304
+ inputs: [
54305
+ {
54306
+ indexed: true,
54307
+ internalType: "address",
54308
+ name: "owner",
54309
+ type: "address"
54310
+ },
54311
+ {
54312
+ indexed: true,
54313
+ internalType: "address",
54314
+ name: "spender",
54315
+ type: "address"
54316
+ },
54317
+ {
54318
+ indexed: false,
54319
+ internalType: "uint256",
54320
+ name: "value",
54321
+ type: "uint256"
54322
+ }
54323
+ ],
54324
+ name: "Approval",
54325
+ type: "event"
54326
+ },
54327
+ {
54328
+ anonymous: false,
54329
+ inputs: [
54330
+ ],
54331
+ name: "EIP712DomainChanged",
54332
+ type: "event"
54333
+ },
54334
+ {
54335
+ anonymous: false,
54336
+ inputs: [
54337
+ {
54338
+ indexed: true,
54339
+ internalType: "address",
54340
+ name: "from",
54341
+ type: "address"
54342
+ },
54343
+ {
54344
+ indexed: true,
54345
+ internalType: "address",
54346
+ name: "to",
54347
+ type: "address"
54348
+ },
54349
+ {
54350
+ indexed: false,
54351
+ internalType: "uint256",
54352
+ name: "value",
54353
+ type: "uint256"
54354
+ }
54355
+ ],
54356
+ name: "Transfer",
54357
+ type: "event"
54358
+ },
54359
+ {
54360
+ inputs: [
54361
+ ],
54362
+ name: "DOMAIN_SEPARATOR",
54363
+ outputs: [
54364
+ {
54365
+ internalType: "bytes32",
54366
+ name: "",
54367
+ type: "bytes32"
54368
+ }
54369
+ ],
54370
+ stateMutability: "view",
54371
+ type: "function"
54372
+ },
54373
+ {
54374
+ inputs: [
54375
+ {
54376
+ internalType: "address",
54377
+ name: "owner",
54378
+ type: "address"
54379
+ },
54380
+ {
54381
+ internalType: "address",
54382
+ name: "spender",
54383
+ type: "address"
54384
+ }
54385
+ ],
54386
+ name: "allowance",
54387
+ outputs: [
54388
+ {
54389
+ internalType: "uint256",
54390
+ name: "",
54391
+ type: "uint256"
54392
+ }
54393
+ ],
54394
+ stateMutability: "view",
54395
+ type: "function"
54396
+ },
54397
+ {
54398
+ inputs: [
54399
+ {
54400
+ internalType: "address",
54401
+ name: "spender",
54402
+ type: "address"
54403
+ },
54404
+ {
54405
+ internalType: "uint256",
54406
+ name: "value",
54407
+ type: "uint256"
54408
+ }
54409
+ ],
54410
+ name: "approve",
54411
+ outputs: [
54412
+ {
54413
+ internalType: "bool",
54414
+ name: "",
54415
+ type: "bool"
54416
+ }
54417
+ ],
54418
+ stateMutability: "nonpayable",
54419
+ type: "function"
54420
+ },
54421
+ {
54422
+ inputs: [
54423
+ {
54424
+ internalType: "address",
54425
+ name: "account",
54426
+ type: "address"
54427
+ }
54428
+ ],
54429
+ name: "balanceOf",
54430
+ outputs: [
54431
+ {
54432
+ internalType: "uint256",
54433
+ name: "",
54434
+ type: "uint256"
54435
+ }
54436
+ ],
54437
+ stateMutability: "view",
54438
+ type: "function"
54439
+ },
54440
+ {
54441
+ inputs: [
54442
+ ],
54443
+ name: "decimals",
54444
+ outputs: [
54445
+ {
54446
+ internalType: "uint8",
54447
+ name: "",
54448
+ type: "uint8"
54449
+ }
54450
+ ],
54451
+ stateMutability: "view",
54452
+ type: "function"
54453
+ },
54454
+ {
54455
+ inputs: [
54456
+ ],
54457
+ name: "eip712Domain",
54458
+ outputs: [
54459
+ {
54460
+ internalType: "bytes1",
54461
+ name: "fields",
54462
+ type: "bytes1"
54463
+ },
54464
+ {
54465
+ internalType: "string",
54466
+ name: "name",
54467
+ type: "string"
54468
+ },
54469
+ {
54470
+ internalType: "string",
54471
+ name: "version",
54472
+ type: "string"
54473
+ },
54474
+ {
54475
+ internalType: "uint256",
54476
+ name: "chainId",
54477
+ type: "uint256"
54478
+ },
54479
+ {
54480
+ internalType: "address",
54481
+ name: "verifyingContract",
54482
+ type: "address"
54483
+ },
54484
+ {
54485
+ internalType: "bytes32",
54486
+ name: "salt",
54487
+ type: "bytes32"
54488
+ },
54489
+ {
54490
+ internalType: "uint256[]",
54491
+ name: "extensions",
54492
+ type: "uint256[]"
54493
+ }
54494
+ ],
54495
+ stateMutability: "view",
54496
+ type: "function"
54497
+ },
54498
+ {
54499
+ inputs: [
54500
+ ],
54501
+ name: "name",
54502
+ outputs: [
54503
+ {
54504
+ internalType: "string",
54505
+ name: "",
54506
+ type: "string"
54507
+ }
54508
+ ],
54509
+ stateMutability: "view",
54510
+ type: "function"
54511
+ },
54512
+ {
54513
+ inputs: [
54514
+ {
54515
+ internalType: "address",
54516
+ name: "owner",
54517
+ type: "address"
54518
+ }
54519
+ ],
54520
+ name: "nonces",
54521
+ outputs: [
54522
+ {
54523
+ internalType: "uint256",
54524
+ name: "",
54525
+ type: "uint256"
54526
+ }
54527
+ ],
54528
+ stateMutability: "view",
54529
+ type: "function"
54530
+ },
54531
+ {
54532
+ inputs: [
54533
+ {
54534
+ internalType: "address",
54535
+ name: "owner",
54536
+ type: "address"
54537
+ },
54538
+ {
54539
+ internalType: "address",
54540
+ name: "spender",
54541
+ type: "address"
54542
+ },
54543
+ {
54544
+ internalType: "uint256",
54545
+ name: "value",
54546
+ type: "uint256"
54547
+ },
54548
+ {
54549
+ internalType: "uint256",
54550
+ name: "deadline",
54551
+ type: "uint256"
54552
+ },
54553
+ {
54554
+ internalType: "uint8",
54555
+ name: "v",
54556
+ type: "uint8"
54557
+ },
54558
+ {
54559
+ internalType: "bytes32",
54560
+ name: "r",
54561
+ type: "bytes32"
54562
+ },
54563
+ {
54564
+ internalType: "bytes32",
54565
+ name: "s",
54566
+ type: "bytes32"
54567
+ }
54568
+ ],
54569
+ name: "permit",
54570
+ outputs: [
54571
+ ],
54572
+ stateMutability: "nonpayable",
54573
+ type: "function"
54574
+ },
54575
+ {
54576
+ inputs: [
54577
+ ],
54578
+ name: "symbol",
54579
+ outputs: [
54580
+ {
54581
+ internalType: "string",
54582
+ name: "",
54583
+ type: "string"
54584
+ }
54585
+ ],
54586
+ stateMutability: "view",
54587
+ type: "function"
54588
+ },
54589
+ {
54590
+ inputs: [
54591
+ ],
54592
+ name: "totalSupply",
54593
+ outputs: [
54594
+ {
54595
+ internalType: "uint256",
54596
+ name: "",
54597
+ type: "uint256"
54598
+ }
54599
+ ],
54600
+ stateMutability: "view",
54601
+ type: "function"
54602
+ },
54603
+ {
54604
+ inputs: [
54605
+ {
54606
+ internalType: "address",
54607
+ name: "to",
54608
+ type: "address"
54609
+ },
54610
+ {
54611
+ internalType: "uint256",
54612
+ name: "value",
54613
+ type: "uint256"
54614
+ }
54615
+ ],
54616
+ name: "transfer",
54617
+ outputs: [
54618
+ {
54619
+ internalType: "bool",
54620
+ name: "",
54621
+ type: "bool"
54622
+ }
54623
+ ],
54624
+ stateMutability: "nonpayable",
54625
+ type: "function"
54626
+ },
54627
+ {
54628
+ inputs: [
54629
+ {
54630
+ internalType: "address",
54631
+ name: "from",
54632
+ type: "address"
54633
+ },
54634
+ {
54635
+ internalType: "address",
54636
+ name: "to",
54637
+ type: "address"
54638
+ },
54639
+ {
54640
+ internalType: "uint256",
54641
+ name: "value",
54642
+ type: "uint256"
54643
+ }
54644
+ ],
54645
+ name: "transferFrom",
54646
+ outputs: [
54647
+ {
54648
+ internalType: "bool",
54649
+ name: "",
54650
+ type: "bool"
54651
+ }
54652
+ ],
54653
+ stateMutability: "nonpayable",
54654
+ type: "function"
54655
+ }
54656
+ ];
54657
+
54658
+ /**
54659
+ * @beta
54660
+ * getPermitSignature is a function to create EIP712 Permit signature
54661
+ * @param {Signer} signer - User who owns the tokens
54662
+ * @param {string} tokenAddress - EIP-2612 contract address
54663
+ * @param {string} spender - The contract address that will spend tokens
54664
+ * @param {bigint} value - Amount of tokens to approve
54665
+ * @param {number} deadline - Timestamp when the permit expires
54666
+ * @returns {Promise<PaymentRequestMessage>}
54667
+ */
54668
+ async function getPermitSignature(signer, tokenAddress, spender, value, deadline) {
54669
+ const erc20PermitContract = new Contract(tokenAddress, abi, signer);
54670
+ const nonce = await erc20PermitContract.nonces(await signer.getAddress());
54671
+ const domainData = await erc20PermitContract.eip712Domain();
54672
+ const domain = {
54673
+ version: domainData[2],
54674
+ chainId: domainData[3],
54675
+ verifyingContract: tokenAddress
54676
+ };
54677
+ const types = {
54678
+ Permit: [
54679
+ { name: 'owner', type: 'address' },
54680
+ { name: 'spender', type: 'address' },
54681
+ { name: 'value', type: 'uint256' },
54682
+ { name: 'nonce', type: 'uint256' },
54683
+ { name: 'deadline', type: 'uint256' }
54684
+ ]
54685
+ };
54686
+ const message = {
54687
+ owner: await signer.getAddress(),
54688
+ spender: spender,
54689
+ value: value,
54690
+ nonce: nonce,
54691
+ deadline: deadline
54692
+ };
54693
+ return signer.signTypedData(domain, types, message);
54694
+ }
54695
+
54104
54696
  /**
54105
54697
  * Type of MerkleTree
54106
54698
  *
@@ -55588,16 +56180,45 @@ const SUPPORTED_PUBLIC_KEY_TYPES = {
55588
56180
  'JsonWebKey2020'
55589
56181
  ]
55590
56182
  };
56183
+ var ProtocolVersion;
56184
+ (function (ProtocolVersion) {
56185
+ ProtocolVersion["V1"] = "iden3comm/v1";
56186
+ })(ProtocolVersion || (ProtocolVersion = {}));
56187
+ var AcceptAuthCircuits;
56188
+ (function (AcceptAuthCircuits) {
56189
+ AcceptAuthCircuits["AuthV2"] = "authV2";
56190
+ AcceptAuthCircuits["AuthV3"] = "authV3";
56191
+ })(AcceptAuthCircuits || (AcceptAuthCircuits = {}));
56192
+ var AcceptJwzAlgorithms;
56193
+ (function (AcceptJwzAlgorithms) {
56194
+ AcceptJwzAlgorithms["Groth16"] = "groth16";
56195
+ })(AcceptJwzAlgorithms || (AcceptJwzAlgorithms = {}));
56196
+ var AcceptJwsAlgorithms;
56197
+ (function (AcceptJwsAlgorithms) {
56198
+ AcceptJwsAlgorithms["ES256K"] = "ES256K";
56199
+ AcceptJwsAlgorithms["ES256KR"] = "ES256K-R";
56200
+ })(AcceptJwsAlgorithms || (AcceptJwsAlgorithms = {}));
56201
+ const defaultAcceptProfile = {
56202
+ protocolVersion: ProtocolVersion.V1,
56203
+ env: MediaType.ZKPMessage,
56204
+ circuits: [AcceptAuthCircuits.AuthV2],
56205
+ alg: [AcceptJwzAlgorithms.Groth16]
56206
+ };
55591
56207
  const DEFAULT_PROOF_VERIFY_DELAY = 1 * 60 * 60 * 1000; // 1 hour
55592
56208
  const DEFAULT_AUTH_VERIFY_DELAY = 5 * 60 * 1000; // 5 minutes
55593
56209
 
55594
56210
  var constants = /*#__PURE__*/Object.freeze({
55595
56211
  __proto__: null,
56212
+ get AcceptAuthCircuits () { return AcceptAuthCircuits; },
56213
+ get AcceptJwsAlgorithms () { return AcceptJwsAlgorithms; },
56214
+ get AcceptJwzAlgorithms () { return AcceptJwzAlgorithms; },
55596
56215
  DEFAULT_AUTH_VERIFY_DELAY: DEFAULT_AUTH_VERIFY_DELAY,
55597
56216
  DEFAULT_PROOF_VERIFY_DELAY: DEFAULT_PROOF_VERIFY_DELAY,
55598
56217
  get MediaType () { return MediaType; },
55599
56218
  PROTOCOL_MESSAGE_TYPE: PROTOCOL_MESSAGE_TYPE,
55600
- SUPPORTED_PUBLIC_KEY_TYPES: SUPPORTED_PUBLIC_KEY_TYPES
56219
+ get ProtocolVersion () { return ProtocolVersion; },
56220
+ SUPPORTED_PUBLIC_KEY_TYPES: SUPPORTED_PUBLIC_KEY_TYPES,
56221
+ defaultAcceptProfile: defaultAcceptProfile
55601
56222
  });
55602
56223
 
55603
56224
  /**
@@ -56721,6 +57342,18 @@ class PackageManager {
56721
57342
  constructor() {
56722
57343
  this.packers = new Map();
56723
57344
  }
57345
+ /** {@inheritDoc IPackageManager.isProfileSupported} */
57346
+ isProfileSupported(mediaType, profile) {
57347
+ const p = this.packers.get(mediaType);
57348
+ if (!p) {
57349
+ return false;
57350
+ }
57351
+ return p.isProfileSupported(profile);
57352
+ }
57353
+ /** {@inheritDoc IPackageManager.getSupportedMediaTypes} */
57354
+ getSupportedMediaTypes() {
57355
+ return [...this.packers.keys()];
57356
+ }
56724
57357
  /** {@inheritDoc IPackageManager.registerPackers} */
56725
57358
  registerPackers(packers) {
56726
57359
  packers.forEach((p) => {
@@ -56793,212 +57426,6 @@ class PackageManager {
56793
57426
  }
56794
57427
  }
56795
57428
 
56796
- const { getProvingMethod } = proving;
56797
- /**
56798
- * Handler to
56799
- *
56800
- * @public
56801
- * @class DataPrepareHandlerFunc
56802
- */
56803
- class DataPrepareHandlerFunc {
56804
- /**
56805
- * Creates an instance of DataPrepareHandlerFunc.
56806
- * @param {AuthDataPrepareFunc} dataPrepareFunc - function that produces marshaled inputs for auth circuits
56807
- */
56808
- constructor(dataPrepareFunc) {
56809
- this.dataPrepareFunc = dataPrepareFunc;
56810
- }
56811
- /**
56812
- *
56813
- *
56814
- * @param {Uint8Array} hash - challenge that will be signed
56815
- * @param {DID} did - did of identity that will prepare inputs
56816
- * @param {CircuitId} circuitId - circuit id
56817
- * @returns `Promise<Uint8Array>`
56818
- */
56819
- prepare(hash, did, circuitId) {
56820
- return this.dataPrepareFunc(hash, did, circuitId);
56821
- }
56822
- }
56823
- /**
56824
- * Handler to verify public signals of authorization circuits
56825
- *
56826
- * @public
56827
- * @class VerificationHandlerFunc
56828
- */
56829
- class VerificationHandlerFunc {
56830
- /**
56831
- * Creates an instance of VerificationHandlerFunc.
56832
- * @param {StateVerificationFunc} stateVerificationFunc - state verification function
56833
- */
56834
- constructor(stateVerificationFunc) {
56835
- this.stateVerificationFunc = stateVerificationFunc;
56836
- }
56837
- /**
56838
- *
56839
- *
56840
- * @param {string} id - id of circuit
56841
- * @param {Array<string>} pubSignals - signals that must contain user id and state
56842
- * @returns `Promise<boolean>`
56843
- */
56844
- verify(id, pubSignals, opts) {
56845
- return this.stateVerificationFunc(id, pubSignals, opts);
56846
- }
56847
- }
56848
- /**
56849
- * Packer that can pack message to JWZ token,
56850
- * and unpack and validate JWZ envelope
56851
- * @public
56852
- * @class ZKPPacker
56853
- * @implements implements IPacker interface
56854
- */
56855
- class ZKPPacker {
56856
- /**
56857
- * Creates an instance of ZKPPacker.
56858
- * @param {Map<string, ProvingParams>} provingParamsMap - string is derived by JSON.parse(ProvingMethodAlg)
56859
- * @param {Map<string, VerificationParams>} verificationParamsMap - string is derived by JSON.parse(ProvingMethodAlg)
56860
- */
56861
- constructor(provingParamsMap, verificationParamsMap, _opts = {
56862
- acceptedStateTransitionDelay: DEFAULT_AUTH_VERIFY_DELAY
56863
- }) {
56864
- this.provingParamsMap = provingParamsMap;
56865
- this.verificationParamsMap = verificationParamsMap;
56866
- this._opts = _opts;
56867
- }
56868
- /**
56869
- * Packs a basic message using the specified parameters.
56870
- * @param msg - The basic message to pack.
56871
- * @param param - The parameters for the ZKPPacker.
56872
- * @returns A promise that resolves to a Uint8Array representing the packed message.
56873
- */
56874
- packMessage(msg, param) {
56875
- return this.pack(byteEncoder.encode(JSON.stringify(msg)), param);
56876
- }
56877
- /**
56878
- * creates JSON Web Zeroknowledge token
56879
- *
56880
- * @param {Uint8Array} payload - serialized message
56881
- * @param {ZKPPackerParams} params - sender id and proving alg are required
56882
- * @returns `Promise<Uint8Array>`
56883
- */
56884
- async pack(payload, params) {
56885
- const provingMethod = await getProvingMethod(params.provingMethodAlg);
56886
- const provingParams = this.provingParamsMap.get(params.provingMethodAlg.toString());
56887
- if (!provingParams) {
56888
- throw new Error(ErrNoProvingMethodAlg);
56889
- }
56890
- const token = new Token(provingMethod, byteDecoder.decode(payload), (hash, circuitId) => {
56891
- return provingParams?.dataPreparer?.prepare(hash, params.senderDID, circuitId);
56892
- });
56893
- token.setHeader(Header.Type, MediaType.ZKPMessage);
56894
- const tokenStr = await token.prove(provingParams.provingKey, provingParams.wasm);
56895
- return byteEncoder.encode(tokenStr);
56896
- }
56897
- /**
56898
- * validate envelope which is jwz token
56899
- *
56900
- * @param {Uint8Array} envelope
56901
- * @returns `Promise<BasicMessage>`
56902
- */
56903
- async unpack(envelope) {
56904
- const token = await Token.parse(byteDecoder.decode(envelope));
56905
- const provingMethodAlg = new ProvingMethodAlg(token.alg, token.circuitId);
56906
- const verificationParams = this.verificationParamsMap.get(provingMethodAlg.toString());
56907
- if (!verificationParams?.key) {
56908
- throw new Error(ErrPackedWithUnsupportedCircuit);
56909
- }
56910
- const isValid = await token.verify(verificationParams?.key);
56911
- if (!isValid) {
56912
- throw new Error(ErrProofIsInvalid);
56913
- }
56914
- const verificationResult = await verificationParams?.verificationFn?.verify(token.circuitId, token.zkProof.pub_signals, this._opts);
56915
- if (!verificationResult) {
56916
- throw new Error(ErrStateVerificationFailed);
56917
- }
56918
- const message = bytesToProtocolMessage(byteEncoder.encode(token.getPayload()));
56919
- // should throw if error
56920
- verifySender(token, message);
56921
- return message;
56922
- }
56923
- mediaType() {
56924
- return MediaType.ZKPMessage;
56925
- }
56926
- }
56927
- const verifySender = async (token, msg) => {
56928
- switch (token.circuitId) {
56929
- case CircuitId.AuthV2:
56930
- {
56931
- if (!msg.from) {
56932
- throw new Error(ErrSenderNotUsedTokenCreation);
56933
- }
56934
- const authSignals = new AuthV2PubSignals().pubSignalsUnmarshal(byteEncoder.encode(JSON.stringify(token.zkProof.pub_signals)));
56935
- const did = DID.parseFromId(authSignals.userID);
56936
- const msgHash = await token.getMessageHash();
56937
- const challenge = BytesHelper.bytesToInt(msgHash.reverse());
56938
- if (challenge !== authSignals.challenge) {
56939
- throw new Error(ErrSenderNotUsedTokenCreation);
56940
- }
56941
- if (msg.from !== did.string()) {
56942
- throw new Error(ErrSenderNotUsedTokenCreation);
56943
- }
56944
- }
56945
- break;
56946
- default:
56947
- throw new Error(ErrUnknownCircuitID);
56948
- }
56949
- };
56950
-
56951
- /**
56952
- * Plain packer just serializes bytes to JSON and adds media type
56953
- *
56954
- * @public
56955
- * @class PlainPacker
56956
- * @implements implements IPacker interface
56957
- */
56958
- class PlainPacker {
56959
- /**
56960
- * Packs a basic message using the specified parameters.
56961
- *
56962
- * @param msg - The basic message to pack.
56963
- * @param param - The packer parameters.
56964
- * @returns A promise that resolves to a Uint8Array representing the packed message.
56965
- * @throws An error if the method is not implemented.
56966
- */
56967
- packMessage(msg) {
56968
- msg.typ = MediaType.PlainMessage;
56969
- return Promise.resolve(byteEncoder.encode(JSON.stringify(msg)));
56970
- }
56971
- /**
56972
- * Pack returns packed message to transport envelope
56973
- *
56974
- * @param {Uint8Array} payload - json message serialized
56975
- * @param {PlainPackerParams} _params - not used here
56976
- * @returns `Promise<Uint8Array>`
56977
- */
56978
- async pack(payload) {
56979
- const msg = JSON.parse(byteDecoder.decode(payload));
56980
- msg.typ = MediaType.PlainMessage;
56981
- return Promise.resolve(byteEncoder.encode(JSON.stringify(msg)));
56982
- }
56983
- /**
56984
- * Unpack returns unpacked message from transport envelope
56985
- *
56986
- * @param {Uint8Array} envelope - packed envelope (serialized json with media type)
56987
- * @returns `Promise<BasicMessage>`
56988
- */
56989
- async unpack(envelope) {
56990
- return JSON.parse(byteDecoder.decode(envelope));
56991
- }
56992
- /**
56993
- * returns media type for plain message
56994
- *
56995
- * @returns MediaType
56996
- */
56997
- mediaType() {
56998
- return MediaType.PlainMessage;
56999
- }
57000
- }
57001
-
57002
57429
  const DIDAuthenticationSection = 'authentication';
57003
57430
  const resolveVerificationMethods = (didDocument) => {
57004
57431
  const vms = didDocument.verificationMethod || [];
@@ -57055,6 +57482,356 @@ const extractPublicKeyBytes = (vm) => {
57055
57482
  return { publicKeyBytes: null };
57056
57483
  };
57057
57484
 
57485
+ function isProtocolVersion(value) {
57486
+ return Object.values(ProtocolVersion).includes(value);
57487
+ }
57488
+ function isMediaType(value) {
57489
+ return Object.values(MediaType).includes(value);
57490
+ }
57491
+ function isAcceptAuthCircuits(value) {
57492
+ return Object.values(AcceptAuthCircuits).includes(value);
57493
+ }
57494
+ function isAcceptJwsAlgorithms(value) {
57495
+ return Object.values(AcceptJwsAlgorithms).includes(value);
57496
+ }
57497
+ function isAcceptJwzAlgorithms(value) {
57498
+ return Object.values(AcceptJwzAlgorithms).includes(value);
57499
+ }
57500
+ const buildAccept = (profiles) => {
57501
+ const result = [];
57502
+ for (const profile of profiles) {
57503
+ let accept = `${profile.protocolVersion};env=${profile.env}`;
57504
+ if (profile.circuits?.length) {
57505
+ accept += `;circuitId=${profile.circuits.join(',')}`;
57506
+ }
57507
+ if (profile.alg?.length) {
57508
+ accept += `;alg=${profile.alg.join(',')}`;
57509
+ }
57510
+ result.push(accept);
57511
+ }
57512
+ return result;
57513
+ };
57514
+ const parseAcceptProfile = (profile) => {
57515
+ const params = profile.split(';');
57516
+ if (params.length < 2) {
57517
+ throw new Error('Invalid accept profile');
57518
+ }
57519
+ const protocolVersion = params[0].trim();
57520
+ if (!isProtocolVersion(protocolVersion)) {
57521
+ throw new Error(`Protocol version '${protocolVersion}' not supported`);
57522
+ }
57523
+ const envParam = params[1].split('=');
57524
+ if (envParam.length !== 2) {
57525
+ throw new Error(`Invalid accept profile 'env' parameter`);
57526
+ }
57527
+ const env = params[1].split('=')[1].trim();
57528
+ if (!isMediaType(env)) {
57529
+ throw new Error(`Envelop '${env}' not supported`);
57530
+ }
57531
+ const circuitsIndex = params.findIndex((i) => i.includes('circuitId='));
57532
+ if (env !== MediaType.ZKPMessage && circuitsIndex > 0) {
57533
+ throw new Error(`Circuits not supported for env '${env}'`);
57534
+ }
57535
+ let circuits = undefined;
57536
+ if (circuitsIndex > 0) {
57537
+ circuits = params[circuitsIndex]
57538
+ .split('=')[1]
57539
+ .split(',')
57540
+ .map((i) => i.trim())
57541
+ .map((i) => {
57542
+ if (!isAcceptAuthCircuits(i)) {
57543
+ throw new Error(`Circuit '${i}' not supported`);
57544
+ }
57545
+ return i;
57546
+ });
57547
+ }
57548
+ const algIndex = params.findIndex((i) => i.includes('alg='));
57549
+ let alg = undefined;
57550
+ if (algIndex > 0) {
57551
+ if (env === MediaType.ZKPMessage) {
57552
+ alg = params[algIndex]
57553
+ .split('=')[1]
57554
+ .split(',')
57555
+ .map((i) => {
57556
+ i = i.trim();
57557
+ if (!isAcceptJwzAlgorithms(i)) {
57558
+ throw new Error(`Algorithm '${i}' not supported for '${env}'`);
57559
+ }
57560
+ return i;
57561
+ });
57562
+ }
57563
+ else if (env === MediaType.SignedMessage) {
57564
+ alg = params[algIndex]
57565
+ .split('=')[1]
57566
+ .split(',')
57567
+ .map((i) => {
57568
+ i = i.trim();
57569
+ if (!isAcceptJwsAlgorithms(i)) {
57570
+ throw new Error(`Algorithm '${i}' not supported for '${env}'`);
57571
+ }
57572
+ return i;
57573
+ });
57574
+ }
57575
+ else {
57576
+ throw new Error(`Algorithm not supported for '${env}'`);
57577
+ }
57578
+ }
57579
+ return {
57580
+ protocolVersion,
57581
+ env,
57582
+ circuits,
57583
+ alg
57584
+ };
57585
+ };
57586
+
57587
+ const { getProvingMethod } = proving;
57588
+ /**
57589
+ * Handler to
57590
+ *
57591
+ * @public
57592
+ * @class DataPrepareHandlerFunc
57593
+ */
57594
+ class DataPrepareHandlerFunc {
57595
+ /**
57596
+ * Creates an instance of DataPrepareHandlerFunc.
57597
+ * @param {AuthDataPrepareFunc} dataPrepareFunc - function that produces marshaled inputs for auth circuits
57598
+ */
57599
+ constructor(dataPrepareFunc) {
57600
+ this.dataPrepareFunc = dataPrepareFunc;
57601
+ }
57602
+ /**
57603
+ *
57604
+ *
57605
+ * @param {Uint8Array} hash - challenge that will be signed
57606
+ * @param {DID} did - did of identity that will prepare inputs
57607
+ * @param {CircuitId} circuitId - circuit id
57608
+ * @returns `Promise<Uint8Array>`
57609
+ */
57610
+ prepare(hash, did, circuitId) {
57611
+ return this.dataPrepareFunc(hash, did, circuitId);
57612
+ }
57613
+ }
57614
+ /**
57615
+ * Handler to verify public signals of authorization circuits
57616
+ *
57617
+ * @public
57618
+ * @class VerificationHandlerFunc
57619
+ */
57620
+ class VerificationHandlerFunc {
57621
+ /**
57622
+ * Creates an instance of VerificationHandlerFunc.
57623
+ * @param {StateVerificationFunc} stateVerificationFunc - state verification function
57624
+ */
57625
+ constructor(stateVerificationFunc) {
57626
+ this.stateVerificationFunc = stateVerificationFunc;
57627
+ }
57628
+ /**
57629
+ *
57630
+ *
57631
+ * @param {string} id - id of circuit
57632
+ * @param {Array<string>} pubSignals - signals that must contain user id and state
57633
+ * @returns `Promise<boolean>`
57634
+ */
57635
+ verify(id, pubSignals, opts) {
57636
+ return this.stateVerificationFunc(id, pubSignals, opts);
57637
+ }
57638
+ }
57639
+ /**
57640
+ * Packer that can pack message to JWZ token,
57641
+ * and unpack and validate JWZ envelope
57642
+ * @public
57643
+ * @class ZKPPacker
57644
+ * @implements implements IPacker interface
57645
+ */
57646
+ class ZKPPacker {
57647
+ /**
57648
+ * Creates an instance of ZKPPacker.
57649
+ * @param {Map<string, ProvingParams>} provingParamsMap - string is derived by JSON.parse(ProvingMethodAlg)
57650
+ * @param {Map<string, VerificationParams>} verificationParamsMap - string is derived by JSON.parse(ProvingMethodAlg)
57651
+ */
57652
+ constructor(provingParamsMap, verificationParamsMap, _opts = {
57653
+ acceptedStateTransitionDelay: DEFAULT_AUTH_VERIFY_DELAY
57654
+ }) {
57655
+ this.provingParamsMap = provingParamsMap;
57656
+ this.verificationParamsMap = verificationParamsMap;
57657
+ this._opts = _opts;
57658
+ }
57659
+ /**
57660
+ * Packs a basic message using the specified parameters.
57661
+ * @param msg - The basic message to pack.
57662
+ * @param param - The parameters for the ZKPPacker.
57663
+ * @returns A promise that resolves to a Uint8Array representing the packed message.
57664
+ */
57665
+ packMessage(msg, param) {
57666
+ return this.pack(byteEncoder.encode(JSON.stringify(msg)), param);
57667
+ }
57668
+ /**
57669
+ * creates JSON Web Zeroknowledge token
57670
+ *
57671
+ * @param {Uint8Array} payload - serialized message
57672
+ * @param {ZKPPackerParams} params - sender id and proving alg are required
57673
+ * @returns `Promise<Uint8Array>`
57674
+ */
57675
+ async pack(payload, params) {
57676
+ const provingMethod = await getProvingMethod(params.provingMethodAlg);
57677
+ const provingParams = this.provingParamsMap.get(params.provingMethodAlg.toString());
57678
+ if (!provingParams) {
57679
+ throw new Error(ErrNoProvingMethodAlg);
57680
+ }
57681
+ const token = new Token(provingMethod, byteDecoder.decode(payload), (hash, circuitId) => {
57682
+ return provingParams?.dataPreparer?.prepare(hash, params.senderDID, circuitId);
57683
+ });
57684
+ token.setHeader(Header.Type, MediaType.ZKPMessage);
57685
+ const tokenStr = await token.prove(provingParams.provingKey, provingParams.wasm);
57686
+ return byteEncoder.encode(tokenStr);
57687
+ }
57688
+ /**
57689
+ * validate envelope which is jwz token
57690
+ *
57691
+ * @param {Uint8Array} envelope
57692
+ * @returns `Promise<BasicMessage>`
57693
+ */
57694
+ async unpack(envelope) {
57695
+ const token = await Token.parse(byteDecoder.decode(envelope));
57696
+ const provingMethodAlg = new ProvingMethodAlg(token.alg, token.circuitId);
57697
+ const verificationParams = this.verificationParamsMap.get(provingMethodAlg.toString());
57698
+ if (!verificationParams?.key) {
57699
+ throw new Error(ErrPackedWithUnsupportedCircuit);
57700
+ }
57701
+ const isValid = await token.verify(verificationParams?.key);
57702
+ if (!isValid) {
57703
+ throw new Error(ErrProofIsInvalid);
57704
+ }
57705
+ const verificationResult = await verificationParams?.verificationFn?.verify(token.circuitId, token.zkProof.pub_signals, this._opts);
57706
+ if (!verificationResult) {
57707
+ throw new Error(ErrStateVerificationFailed);
57708
+ }
57709
+ const message = bytesToProtocolMessage(byteEncoder.encode(token.getPayload()));
57710
+ // should throw if error
57711
+ verifySender(token, message);
57712
+ return message;
57713
+ }
57714
+ mediaType() {
57715
+ return MediaType.ZKPMessage;
57716
+ }
57717
+ /** {@inheritDoc IPacker.getSupportedProfiles} */
57718
+ getSupportedProfiles() {
57719
+ return [
57720
+ `env=${this.mediaType()}&alg=${this.getSupportedAlgorithms().join(',')}&circuitIds=${this.getSupportedCircuitIds().join(',')}`
57721
+ ];
57722
+ }
57723
+ /** {@inheritDoc IPacker.isProfileSupported} */
57724
+ isProfileSupported(profile) {
57725
+ const { env, circuits, alg } = parseAcceptProfile(profile);
57726
+ if (env !== this.mediaType()) {
57727
+ return false;
57728
+ }
57729
+ const supportedCircuitIds = this.getSupportedCircuitIds();
57730
+ const circuitIdSupported = !circuits?.length || circuits.some((c) => supportedCircuitIds.includes(c));
57731
+ const supportedAlgArr = this.getSupportedAlgorithms();
57732
+ const algSupported = !alg?.length || alg.some((a) => supportedAlgArr.includes(a));
57733
+ return algSupported && circuitIdSupported;
57734
+ }
57735
+ getSupportedAlgorithms() {
57736
+ return [AcceptJwzAlgorithms.Groth16];
57737
+ }
57738
+ getSupportedCircuitIds() {
57739
+ return [AcceptAuthCircuits.AuthV2];
57740
+ }
57741
+ }
57742
+ const verifySender = async (token, msg) => {
57743
+ switch (token.circuitId) {
57744
+ case CircuitId.AuthV2:
57745
+ {
57746
+ if (!msg.from) {
57747
+ throw new Error(ErrSenderNotUsedTokenCreation);
57748
+ }
57749
+ const authSignals = new AuthV2PubSignals().pubSignalsUnmarshal(byteEncoder.encode(JSON.stringify(token.zkProof.pub_signals)));
57750
+ const did = DID.parseFromId(authSignals.userID);
57751
+ const msgHash = await token.getMessageHash();
57752
+ const challenge = BytesHelper.bytesToInt(msgHash.reverse());
57753
+ if (challenge !== authSignals.challenge) {
57754
+ throw new Error(ErrSenderNotUsedTokenCreation);
57755
+ }
57756
+ if (msg.from !== did.string()) {
57757
+ throw new Error(ErrSenderNotUsedTokenCreation);
57758
+ }
57759
+ }
57760
+ break;
57761
+ default:
57762
+ throw new Error(ErrUnknownCircuitID);
57763
+ }
57764
+ };
57765
+
57766
+ /**
57767
+ * Plain packer just serializes bytes to JSON and adds media type
57768
+ *
57769
+ * @public
57770
+ * @class PlainPacker
57771
+ * @implements implements IPacker interface
57772
+ */
57773
+ class PlainPacker {
57774
+ /**
57775
+ * Packs a basic message using the specified parameters.
57776
+ *
57777
+ * @param msg - The basic message to pack.
57778
+ * @param param - The packer parameters.
57779
+ * @returns A promise that resolves to a Uint8Array representing the packed message.
57780
+ * @throws An error if the method is not implemented.
57781
+ */
57782
+ packMessage(msg) {
57783
+ msg.typ = MediaType.PlainMessage;
57784
+ return Promise.resolve(byteEncoder.encode(JSON.stringify(msg)));
57785
+ }
57786
+ /**
57787
+ * Pack returns packed message to transport envelope
57788
+ *
57789
+ * @param {Uint8Array} payload - json message serialized
57790
+ * @param {PlainPackerParams} _params - not used here
57791
+ * @returns `Promise<Uint8Array>`
57792
+ */
57793
+ async pack(payload) {
57794
+ const msg = JSON.parse(byteDecoder.decode(payload));
57795
+ msg.typ = MediaType.PlainMessage;
57796
+ return Promise.resolve(byteEncoder.encode(JSON.stringify(msg)));
57797
+ }
57798
+ /**
57799
+ * Unpack returns unpacked message from transport envelope
57800
+ *
57801
+ * @param {Uint8Array} envelope - packed envelope (serialized json with media type)
57802
+ * @returns `Promise<BasicMessage>`
57803
+ */
57804
+ async unpack(envelope) {
57805
+ return JSON.parse(byteDecoder.decode(envelope));
57806
+ }
57807
+ /**
57808
+ * returns media type for plain message
57809
+ *
57810
+ * @returns MediaType
57811
+ */
57812
+ mediaType() {
57813
+ return MediaType.PlainMessage;
57814
+ }
57815
+ /** {@inheritDoc IPacker.getSupportedProfiles} */
57816
+ getSupportedProfiles() {
57817
+ return [`env=${this.mediaType()}`];
57818
+ }
57819
+ /** {@inheritDoc IPacker.isProfileSupported} */
57820
+ isProfileSupported(profile) {
57821
+ const { env, circuits, alg } = parseAcceptProfile(profile);
57822
+ if (env !== this.mediaType()) {
57823
+ return false;
57824
+ }
57825
+ if (circuits) {
57826
+ throw new Error(`Circuits are not supported for ${env} media type`);
57827
+ }
57828
+ if (alg) {
57829
+ throw new Error(`Algorithms are not supported for ${env} media type`);
57830
+ }
57831
+ return true;
57832
+ }
57833
+ }
57834
+
57058
57835
  /**
57059
57836
  * Packer that can pack message to JWZ token,
57060
57837
  * and unpack and validate JWZ envelope
@@ -57133,6 +57910,26 @@ class JWSPacker {
57133
57910
  mediaType() {
57134
57911
  return MediaType.SignedMessage;
57135
57912
  }
57913
+ /** {@inheritDoc IPacker.getSupportedProfiles} */
57914
+ getSupportedProfiles() {
57915
+ return [`env=${this.mediaType()}&alg=${this.getSupportedAlgorithms().join(',')}`];
57916
+ }
57917
+ /** {@inheritDoc IPacker.isProfileSupported} */
57918
+ isProfileSupported(profile) {
57919
+ const { env, circuits, alg } = parseAcceptProfile(profile);
57920
+ if (env !== this.mediaType()) {
57921
+ return false;
57922
+ }
57923
+ if (circuits) {
57924
+ throw new Error(`Circuits are not supported for ${env} media type`);
57925
+ }
57926
+ const supportedAlgArr = this.getSupportedAlgorithms();
57927
+ const algSupported = !alg?.length || alg.some((a) => supportedAlgArr.includes(a));
57928
+ return algSupported;
57929
+ }
57930
+ getSupportedAlgorithms() {
57931
+ return [AcceptJwsAlgorithms.ES256K, AcceptJwsAlgorithms.ES256KR];
57932
+ }
57136
57933
  async resolveDidDoc(from) {
57137
57934
  let didDocument;
57138
57935
  try {
@@ -57287,6 +58084,16 @@ const processZeroKnowledgeProofRequests = async (to, requests, from, proofServic
57287
58084
  }
57288
58085
  return zkpResponses;
57289
58086
  };
58087
+ /**
58088
+ * Verifies that the expires_time field of a message is not in the past. Throws an error if it is.
58089
+ *
58090
+ * @param message - Basic message to verify.
58091
+ */
58092
+ const verifyExpiresTime = (message) => {
58093
+ if (message?.expires_time && message.expires_time < getUnixTimestamp(new Date())) {
58094
+ throw new Error('Message expired');
58095
+ }
58096
+ };
57290
58097
 
57291
58098
  /**
57292
58099
  * Base implementation of protocol message handler
@@ -57302,6 +58109,9 @@ class AbstractMessageHandler {
57302
58109
  return messageHandler;
57303
58110
  }
57304
58111
  async handle(message, context) {
58112
+ if (!context.allowExpiredMessages) {
58113
+ verifyExpiresTime(message);
58114
+ }
57305
58115
  if (this.nextMessageHandler)
57306
58116
  return this.nextMessageHandler.handle(message, context);
57307
58117
  return Promise.reject('Message handler not provided or message not supported');
@@ -57394,10 +58204,11 @@ class MessageHandler {
57394
58204
  * @param {string} reason - reason to request proof
57395
58205
  * @param {string} sender - sender did
57396
58206
  * @param {string} callbackUrl - callback that user should use to send response
58207
+ * @param {AuthorizationRequestCreateOptions} opts - authorization request options
57397
58208
  * @returns `Promise<AuthorizationRequestMessage>`
57398
58209
  */
57399
- function createAuthorizationRequest(reason, sender, callbackUrl) {
57400
- return createAuthorizationRequestWithMessage(reason, '', sender, callbackUrl);
58210
+ function createAuthorizationRequest(reason, sender, callbackUrl, opts) {
58211
+ return createAuthorizationRequestWithMessage(reason, '', sender, callbackUrl, opts);
57401
58212
  }
57402
58213
  /**
57403
58214
  * createAuthorizationRequestWithMessage is a function to create protocol authorization request with explicit message to sign
@@ -57405,9 +58216,10 @@ function createAuthorizationRequest(reason, sender, callbackUrl) {
57405
58216
  * @param {string} message - message to sign in the response
57406
58217
  * @param {string} sender - sender did
57407
58218
  * @param {string} callbackUrl - callback that user should use to send response
58219
+ * @param {AuthorizationRequestCreateOptions} opts - authorization request options
57408
58220
  * @returns `Promise<AuthorizationRequestMessage>`
57409
58221
  */
57410
- function createAuthorizationRequestWithMessage(reason, message, sender, callbackUrl) {
58222
+ function createAuthorizationRequestWithMessage(reason, message, sender, callbackUrl, opts) {
57411
58223
  const uuidv4 = v4();
57412
58224
  const request = {
57413
58225
  id: uuidv4,
@@ -57416,11 +58228,14 @@ function createAuthorizationRequestWithMessage(reason, message, sender, callback
57416
58228
  typ: MediaType.PlainMessage,
57417
58229
  type: PROTOCOL_MESSAGE_TYPE.AUTHORIZATION_REQUEST_MESSAGE_TYPE,
57418
58230
  body: {
58231
+ accept: opts?.accept,
57419
58232
  reason: reason,
57420
58233
  message: message,
57421
58234
  callbackUrl: callbackUrl,
57422
- scope: []
57423
- }
58235
+ scope: opts?.scope ?? []
58236
+ },
58237
+ created_time: getUnixTimestamp(new Date()),
58238
+ expires_time: opts?.expires_time ? getUnixTimestamp(opts.expires_time) : undefined
57424
58239
  };
57425
58240
  return request;
57426
58241
  }
@@ -57479,17 +58294,18 @@ class AuthHandler extends AbstractMessageHandler {
57479
58294
  }
57480
58295
  // override sender did if it's explicitly specified in the auth request
57481
58296
  const to = authRequest.to ? DID.parse(authRequest.to) : ctx.senderDid;
57482
- const mediaType = ctx.mediaType || MediaType.ZKPMessage;
57483
58297
  const guid = v4();
57484
58298
  if (!authRequest.from) {
57485
58299
  throw new Error('auth request should contain from field');
57486
58300
  }
58301
+ const responseType = PROTOCOL_MESSAGE_TYPE.AUTHORIZATION_RESPONSE_MESSAGE_TYPE;
58302
+ const mediaType = this.getSupportedMediaTypeByProfile(ctx, responseType, authRequest.body.accept);
57487
58303
  const from = DID.parse(authRequest.from);
57488
58304
  const responseScope = await processZeroKnowledgeProofRequests(to, authRequest?.body.scope, from, this._proofService, { mediaType, supportedCircuits: this._supportedCircuits });
57489
58305
  return {
57490
58306
  id: guid,
57491
- typ: ctx.mediaType,
57492
- type: PROTOCOL_MESSAGE_TYPE.AUTHORIZATION_RESPONSE_MESSAGE_TYPE,
58307
+ typ: mediaType,
58308
+ type: responseType,
57493
58309
  thid: authRequest.thid ?? guid,
57494
58310
  body: {
57495
58311
  message: authRequest?.body?.message,
@@ -57504,6 +58320,9 @@ class AuthHandler extends AbstractMessageHandler {
57504
58320
  */
57505
58321
  async handleAuthorizationRequest(did, request, opts) {
57506
58322
  const authRequest = await this.parseAuthorizationRequest(request);
58323
+ if (!opts?.allowExpiredMessages) {
58324
+ verifyExpiresTime(authRequest);
58325
+ }
57507
58326
  if (!opts) {
57508
58327
  opts = {
57509
58328
  mediaType: MediaType.ZKPMessage
@@ -57593,6 +58412,9 @@ class AuthHandler extends AbstractMessageHandler {
57593
58412
  * @inheritdoc IAuthHandler#handleAuthorizationResponse
57594
58413
  */
57595
58414
  async handleAuthorizationResponse(response, request, opts) {
58415
+ if (!opts?.allowExpiredMessages) {
58416
+ verifyExpiresTime(response);
58417
+ }
57596
58418
  const authResp = (await this.handleAuthResponse(response, {
57597
58419
  request,
57598
58420
  acceptedStateTransitionDelay: opts?.acceptedStateTransitionDelay,
@@ -57626,6 +58448,37 @@ class AuthHandler extends AbstractMessageHandler {
57626
58448
  }
57627
58449
  }
57628
58450
  }
58451
+ getSupportedMediaTypeByProfile(ctx, responseType, profile) {
58452
+ let mediaType;
58453
+ if (profile?.length) {
58454
+ const supportedMediaTypes = [];
58455
+ for (const acceptProfile of profile) {
58456
+ // 1. check protocol version
58457
+ const { protocolVersion, env } = parseAcceptProfile(acceptProfile);
58458
+ const responseTypeVersion = Number(responseType.split('/').at(-2));
58459
+ if (protocolVersion !== ProtocolVersion.V1 ||
58460
+ (protocolVersion === ProtocolVersion.V1 &&
58461
+ (responseTypeVersion < 1 || responseTypeVersion >= 2))) {
58462
+ continue;
58463
+ }
58464
+ // 2. check packer support
58465
+ if (this._packerMgr.isProfileSupported(env, acceptProfile)) {
58466
+ supportedMediaTypes.push(env);
58467
+ }
58468
+ }
58469
+ if (!supportedMediaTypes.length) {
58470
+ throw new Error('no packer with profile which meets `accept` header requirements');
58471
+ }
58472
+ mediaType = supportedMediaTypes[0];
58473
+ if (ctx.mediaType && supportedMediaTypes.includes(ctx.mediaType)) {
58474
+ mediaType = ctx.mediaType;
58475
+ }
58476
+ }
58477
+ else {
58478
+ mediaType = ctx.mediaType || MediaType.ZKPMessage;
58479
+ }
58480
+ return mediaType;
58481
+ }
57629
58482
  }
57630
58483
 
57631
58484
  /**
@@ -57742,6 +58595,9 @@ class FetchHandler extends AbstractMessageHandler {
57742
58595
  throw new Error(`jws packer options are required for ${MediaType.SignedMessage}`);
57743
58596
  }
57744
58597
  const offerMessage = await FetchHandler.unpackMessage(this._packerMgr, offer, PROTOCOL_MESSAGE_TYPE.CREDENTIAL_OFFER_MESSAGE_TYPE);
58598
+ if (!opts?.allowExpiredMessages) {
58599
+ verifyExpiresTime(offerMessage);
58600
+ }
57745
58601
  const result = await this.handleOfferMessage(offerMessage, {
57746
58602
  mediaType: opts?.mediaType,
57747
58603
  headers: opts?.headers,
@@ -57789,8 +58645,11 @@ class FetchHandler extends AbstractMessageHandler {
57789
58645
  /**
57790
58646
  * @inheritdoc IFetchHandler#handleCredentialFetchRequest
57791
58647
  */
57792
- async handleCredentialFetchRequest(envelope) {
58648
+ async handleCredentialFetchRequest(envelope, opts) {
57793
58649
  const msgRequest = await FetchHandler.unpackMessage(this._packerMgr, envelope, PROTOCOL_MESSAGE_TYPE.CREDENTIAL_FETCH_REQUEST_MESSAGE_TYPE);
58650
+ if (!opts?.allowExpiredMessages) {
58651
+ verifyExpiresTime(msgRequest);
58652
+ }
57794
58653
  const request = await this.handleFetchRequest(msgRequest);
57795
58654
  return this._packerMgr.pack(MediaType.PlainMessage, byteEncoder.encode(JSON.stringify(request)), {});
57796
58655
  }
@@ -57807,8 +58666,11 @@ class FetchHandler extends AbstractMessageHandler {
57807
58666
  /**
57808
58667
  * @inheritdoc IFetchHandler#handleIssuanceResponseMessage
57809
58668
  */
57810
- async handleIssuanceResponseMessage(envelop) {
58669
+ async handleIssuanceResponseMessage(envelop, opts) {
57811
58670
  const issuanceMsg = await FetchHandler.unpackMessage(this._packerMgr, envelop, PROTOCOL_MESSAGE_TYPE.CREDENTIAL_ISSUANCE_RESPONSE_MESSAGE_TYPE);
58671
+ if (!opts?.allowExpiredMessages) {
58672
+ verifyExpiresTime(issuanceMsg);
58673
+ }
57812
58674
  await this.handleIssuanceResponseMsg(issuanceMsg);
57813
58675
  return Uint8Array.from([]);
57814
58676
  }
@@ -57928,7 +58790,8 @@ class ContractRequestHandler extends AbstractMessageHandler {
57928
58790
  body: {
57929
58791
  transaction_data: request.body.transaction_data,
57930
58792
  scope: []
57931
- }
58793
+ },
58794
+ created_time: getUnixTimestamp(new Date())
57932
58795
  };
57933
58796
  for (const [txHash, zkpResponses] of txHashToZkpResponseMap) {
57934
58797
  for (const zkpResponse of zkpResponses) {
@@ -57952,6 +58815,9 @@ class ContractRequestHandler extends AbstractMessageHandler {
57952
58815
  */
57953
58816
  async handleContractInvokeRequest(did, request, opts) {
57954
58817
  const ciRequest = await this.parseContractInvokeRequest(request);
58818
+ if (!opts.allowExpiredMessages) {
58819
+ verifyExpiresTime(ciRequest);
58820
+ }
57955
58821
  if (ciRequest.body.transaction_data.method_id !== FunctionSignatures.SubmitZKPResponseV1) {
57956
58822
  throw new Error(`please use handle method to work with other method ids`);
57957
58823
  }
@@ -58130,6 +58996,9 @@ class RevocationStatusHandler extends AbstractMessageHandler {
58130
58996
  throw new Error(`jws packer options are required for ${MediaType.SignedMessage}`);
58131
58997
  }
58132
58998
  const rsRequest = await this.parseRevocationStatusRequest(request);
58999
+ if (!opts.allowExpiredMessages) {
59000
+ verifyExpiresTime(rsRequest);
59001
+ }
58133
59002
  const response = await this.handleRevocationStatusRequestMessage(rsRequest, {
58134
59003
  senderDid: did,
58135
59004
  mediaType: opts.mediaType,
@@ -58169,7 +59038,9 @@ function createProposalRequest(sender, receiver, opts) {
58169
59038
  to: receiver.string(),
58170
59039
  typ: MediaType.PlainMessage,
58171
59040
  type: PROTOCOL_MESSAGE_TYPE.PROPOSAL_REQUEST_MESSAGE_TYPE,
58172
- body: opts
59041
+ body: opts,
59042
+ created_time: getUnixTimestamp(new Date()),
59043
+ expires_time: opts?.expires_time ? getUnixTimestamp(opts.expires_time) : undefined
58173
59044
  };
58174
59045
  return request;
58175
59046
  }
@@ -58181,7 +59052,7 @@ function createProposalRequest(sender, receiver, opts) {
58181
59052
  * @param {Proposal[]} proposals - proposals
58182
59053
  * @returns `Promise<ProposalRequestMessage>`
58183
59054
  */
58184
- function createProposal(sender, receiver, proposals) {
59055
+ function createProposal(sender, receiver, proposals, opts) {
58185
59056
  const uuidv4 = v4();
58186
59057
  const request = {
58187
59058
  id: uuidv4,
@@ -58192,7 +59063,9 @@ function createProposal(sender, receiver, proposals) {
58192
59063
  type: PROTOCOL_MESSAGE_TYPE.PROPOSAL_MESSAGE_TYPE,
58193
59064
  body: {
58194
59065
  proposals: proposals || []
58195
- }
59066
+ },
59067
+ created_time: getUnixTimestamp(new Date()),
59068
+ expires_time: opts?.expires_time ? getUnixTimestamp(opts.expires_time) : undefined
58196
59069
  };
58197
59070
  return request;
58198
59071
  }
@@ -58330,6 +59203,9 @@ class CredentialProposalHandler extends AbstractMessageHandler {
58330
59203
  if (!proposalRequest.from) {
58331
59204
  throw new Error(`failed request. empty 'from' field`);
58332
59205
  }
59206
+ if (!opts?.allowExpiredMessages) {
59207
+ verifyExpiresTime(proposalRequest);
59208
+ }
58333
59209
  const senderDID = DID.parse(proposalRequest.from);
58334
59210
  const message = await this.handleProposalRequestMessage(proposalRequest);
58335
59211
  const response = byteEncoder.encode(JSON.stringify(message));
@@ -58347,6 +59223,9 @@ class CredentialProposalHandler extends AbstractMessageHandler {
58347
59223
  * @inheritdoc ICredentialProposalHandler#handleProposal
58348
59224
  */
58349
59225
  async handleProposal(proposal, opts) {
59226
+ if (!opts?.allowExpiredMessages) {
59227
+ verifyExpiresTime(proposal);
59228
+ }
58350
59229
  if (opts?.proposalRequest && opts.proposalRequest.from !== proposal.to) {
58351
59230
  throw new Error(`sender of the request is not a target of response - expected ${opts.proposalRequest.from}, given ${proposal.to}`);
58352
59231
  }
@@ -58363,7 +59242,7 @@ class CredentialProposalHandler extends AbstractMessageHandler {
58363
59242
  * @param {PaymentRequestInfo[]} payments - payments
58364
59243
  * @returns `PaymentRequestMessage`
58365
59244
  */
58366
- function createPaymentRequest(sender, receiver, agent, payments) {
59245
+ function createPaymentRequest(sender, receiver, agent, payments, opts) {
58367
59246
  const uuidv4 = v4();
58368
59247
  const request = {
58369
59248
  id: uuidv4,
@@ -58375,19 +59254,57 @@ function createPaymentRequest(sender, receiver, agent, payments) {
58375
59254
  body: {
58376
59255
  agent,
58377
59256
  payments
58378
- }
59257
+ },
59258
+ created_time: getUnixTimestamp(new Date()),
59259
+ expires_time: opts?.expires_time ? getUnixTimestamp(opts.expires_time) : undefined
58379
59260
  };
58380
59261
  return request;
58381
59262
  }
59263
+ async function verifyEIP712TypedData(data, resolver) {
59264
+ const paymentData = data.type === PaymentRequestDataType.Iden3PaymentRailsRequestV1
59265
+ ? {
59266
+ recipient: data.recipient,
59267
+ amount: data.amount,
59268
+ expirationDate: new Date(data.expirationDate).getTime(),
59269
+ nonce: data.nonce,
59270
+ metadata: '0x'
59271
+ }
59272
+ : {
59273
+ tokenAddress: data.tokenAddress,
59274
+ recipient: data.recipient,
59275
+ amount: data.amount,
59276
+ expirationDate: new Date(data.expirationDate).getTime(),
59277
+ nonce: data.nonce,
59278
+ metadata: '0x'
59279
+ };
59280
+ const proof = Array.isArray(data.proof) ? data.proof[0] : data.proof;
59281
+ const typesFetchResult = await fetch(proof.eip712.types);
59282
+ const types = await typesFetchResult.json();
59283
+ delete types.EIP712Domain;
59284
+ const recovered = verifyTypedData(proof.eip712.domain, types, paymentData, proof.proofValue);
59285
+ const { didDocument } = await resolver.resolve(proof.verificationMethod);
59286
+ if (didDocument?.verificationMethod) {
59287
+ for (const verificationMethod of didDocument.verificationMethod) {
59288
+ if (verificationMethod.blockchainAccountId?.split(':').slice(-1)[0].toLowerCase() ===
59289
+ recovered.toLowerCase()) {
59290
+ return recovered;
59291
+ }
59292
+ }
59293
+ }
59294
+ else {
59295
+ throw new Error('failed request. issuer DIDDocument does not contain any verificationMethods');
59296
+ }
59297
+ throw new Error(`failed request. no matching verificationMethod`);
59298
+ }
58382
59299
  /**
58383
59300
  * @beta
58384
59301
  * createPayment is a function to create protocol payment message
58385
59302
  * @param {DID} sender - sender did
58386
59303
  * @param {DID} receiver - receiver did
58387
- * @param {PaymentInfo[]} payments - payments
59304
+ * @param {PaymentMessageBody} body - payments
58388
59305
  * @returns `PaymentMessage`
58389
59306
  */
58390
- function createPayment(sender, receiver, payments) {
59307
+ function createPayment(sender, receiver, payments, opts) {
58391
59308
  const uuidv4 = v4();
58392
59309
  const request = {
58393
59310
  id: uuidv4,
@@ -58398,7 +59315,9 @@ function createPayment(sender, receiver, payments) {
58398
59315
  type: PROTOCOL_MESSAGE_TYPE.PAYMENT_MESSAGE_TYPE,
58399
59316
  body: {
58400
59317
  payments
58401
- }
59318
+ },
59319
+ created_time: getUnixTimestamp(new Date()),
59320
+ expires_time: opts?.expires_time ? getUnixTimestamp(opts.expires_time) : undefined
58402
59321
  };
58403
59322
  return request;
58404
59323
  }
@@ -58460,21 +59379,28 @@ class PaymentHandler extends AbstractMessageHandler {
58460
59379
  const receiverDID = DID.parse(paymentRequest.from);
58461
59380
  const payments = [];
58462
59381
  for (let i = 0; i < paymentRequest.body.payments.length; i++) {
58463
- const paymentReq = paymentRequest.body.payments[i];
58464
- if (paymentReq.type !== PaymentRequestType.PaymentRequest) {
58465
- throw new Error(`failed request. not supported '${paymentReq.type}' payment type `);
59382
+ const { data } = paymentRequest.body.payments[i];
59383
+ const selectedPayment = Array.isArray(data)
59384
+ ? data.find((p) => {
59385
+ return p.type === PaymentRequestDataType.Iden3PaymentRequestCryptoV1
59386
+ ? p.id === ctx.nonce
59387
+ : p.nonce === ctx.nonce;
59388
+ })
59389
+ : data;
59390
+ if (!selectedPayment) {
59391
+ throw new Error(`failed request. no payment in request for nonce ${ctx.nonce}`);
58466
59392
  }
58467
- if (paymentReq.data.type !== PaymentRequestDataType.Iden3PaymentRequestCryptoV1) {
58468
- throw new Error(`failed request. not supported '${paymentReq.data.type}' payment type `);
59393
+ switch (selectedPayment.type) {
59394
+ case PaymentRequestDataType.Iden3PaymentRequestCryptoV1:
59395
+ payments.push(await this.handleIden3PaymentRequestCryptoV1(selectedPayment, ctx.paymentHandler));
59396
+ break;
59397
+ case PaymentRequestDataType.Iden3PaymentRailsRequestV1:
59398
+ payments.push(await this.handleIden3PaymentRailsRequestV1(selectedPayment, ctx.paymentHandler));
59399
+ break;
59400
+ case PaymentRequestDataType.Iden3PaymentRailsERC20RequestV1:
59401
+ payments.push(await this.handleIden3PaymentRailsERC20RequestV1(selectedPayment, ctx.paymentHandler, ctx.erc20TokenApproveHandler));
59402
+ break;
58469
59403
  }
58470
- const txId = await ctx.paymentHandler(paymentReq.data);
58471
- payments.push({
58472
- id: paymentReq.data.id,
58473
- type: PaymentType.Iden3PaymentCryptoV1,
58474
- paymentData: {
58475
- txId
58476
- }
58477
- });
58478
59404
  }
58479
59405
  const paymentMessage = createPayment(senderDID, receiverDID, payments);
58480
59406
  const response = await this.packMessage(paymentMessage, senderDID);
@@ -58507,6 +59433,9 @@ class PaymentHandler extends AbstractMessageHandler {
58507
59433
  if (!paymentRequest.to) {
58508
59434
  throw new Error(`failed request. empty 'to' field`);
58509
59435
  }
59436
+ if (!opts?.allowExpiredMessages) {
59437
+ verifyExpiresTime(paymentRequest);
59438
+ }
58510
59439
  const agentMessage = await this.handlePaymentRequestMessage(paymentRequest, opts);
58511
59440
  if (!agentMessage) {
58512
59441
  return null;
@@ -58517,24 +59446,122 @@ class PaymentHandler extends AbstractMessageHandler {
58517
59446
  /**
58518
59447
  * @inheritdoc IPaymentHandler#handlePayment
58519
59448
  */
58520
- async handlePayment(payment, opts) {
58521
- if (opts.paymentRequest.from !== payment.to) {
58522
- throw new Error(`sender of the request is not a target of response - expected ${opts.paymentRequest.from}, given ${payment.to}`);
59449
+ async handlePayment(payment, params) {
59450
+ if (!params?.allowExpiredMessages) {
59451
+ verifyExpiresTime(payment);
59452
+ }
59453
+ if (params.paymentRequest.from !== payment.to) {
59454
+ throw new Error(`sender of the request is not a target of response - expected ${params.paymentRequest.from}, given ${payment.to}`);
58523
59455
  }
58524
59456
  if (!payment.body.payments.length) {
58525
59457
  throw new Error(`failed request. empty 'payments' field in body`);
58526
59458
  }
59459
+ if (!params.paymentValidationHandler) {
59460
+ throw new Error(`please provide payment validation handler in options`);
59461
+ }
58527
59462
  for (let i = 0; i < payment.body.payments.length; i++) {
58528
59463
  const p = payment.body.payments[i];
58529
- const paymentRequestData = opts.paymentRequest.body.payments.find((r) => r.data.id === p.id);
58530
- if (!paymentRequestData) {
58531
- throw new Error(`can't find payment request for payment id ${p.id}`);
58532
- }
58533
- if (!opts.paymentValidationHandler) {
58534
- throw new Error(`please provide payment validation handler in options`);
58535
- }
58536
- await opts.paymentValidationHandler(p.paymentData.txId, paymentRequestData.data);
59464
+ const nonce = p.type === PaymentType.Iden3PaymentCryptoV1 ? p.id : p.nonce;
59465
+ const requestDataArr = params.paymentRequest.body.payments
59466
+ .map((r) => (Array.isArray(r.data) ? r.data : [r.data]))
59467
+ .flat();
59468
+ const requestData = requestDataArr.find((r) => r.type === PaymentRequestDataType.Iden3PaymentRequestCryptoV1
59469
+ ? r.id === nonce
59470
+ : r.nonce === nonce);
59471
+ if (!requestData) {
59472
+ throw new Error(`can't find payment request for payment ${p.type === PaymentType.Iden3PaymentCryptoV1 ? 'id' : 'nonce'} ${nonce}`);
59473
+ }
59474
+ await params.paymentValidationHandler(p.paymentData.txId, requestData);
59475
+ }
59476
+ }
59477
+ /**
59478
+ * @inheritdoc IPaymentHandler#createPaymentRailsV1
59479
+ */
59480
+ async createPaymentRailsV1(sender, receiver, agent, signer, payments) {
59481
+ const paymentRequestInfo = [];
59482
+ for (let i = 0; i < payments.length; i++) {
59483
+ const { credentials, description } = payments[i];
59484
+ const dataArr = [];
59485
+ for (let j = 0; j < payments[i].chains.length; j++) {
59486
+ const { features, nonce, amount, currency, chainId, expirationDate, type } = payments[i].chains[j];
59487
+ const multiChainConfig = this._params.multiChainPaymentConfig?.find((c) => c.chainId === chainId);
59488
+ if (!multiChainConfig) {
59489
+ throw new Error(`failed request. no config for chain ${chainId}`);
59490
+ }
59491
+ const { recipient, paymentContract, erc20TokenAddressArr } = multiChainConfig;
59492
+ const tokenAddress = erc20TokenAddressArr.find((t) => t.symbol === currency)?.address;
59493
+ if (type === PaymentRequestDataType.Iden3PaymentRailsERC20RequestV1 && !tokenAddress) {
59494
+ throw new Error(`failed request. no token address for currency ${currency}`);
59495
+ }
59496
+ const expirationTime = expirationDate
59497
+ ? new Date(expirationDate).getTime()
59498
+ : new Date(new Date().setHours(new Date().getHours() + 1)).getTime();
59499
+ const typeUrl = `https://schema.iden3.io/core/json/${type}.json`;
59500
+ const typesFetchResult = await fetch(typeUrl);
59501
+ const types = await typesFetchResult.json();
59502
+ delete types.EIP712Domain;
59503
+ const paymentData = type === PaymentRequestDataType.Iden3PaymentRailsRequestV1
59504
+ ? {
59505
+ recipient,
59506
+ amount,
59507
+ expirationDate: expirationTime,
59508
+ nonce,
59509
+ metadata: '0x'
59510
+ }
59511
+ : {
59512
+ tokenAddress,
59513
+ recipient,
59514
+ amount,
59515
+ expirationDate: expirationTime,
59516
+ nonce,
59517
+ metadata: '0x'
59518
+ };
59519
+ const domain = {
59520
+ name: 'MCPayment',
59521
+ version: '1.0.0',
59522
+ chainId,
59523
+ verifyingContract: paymentContract
59524
+ };
59525
+ const signature = await signer.signTypedData(domain, types, paymentData);
59526
+ const proof = [
59527
+ {
59528
+ type: SupportedPaymentProofType.EthereumEip712Signature2021,
59529
+ proofPurpose: 'assertionMethod',
59530
+ proofValue: signature,
59531
+ verificationMethod: `did:pkh:eip155:${chainId}:${await signer.getAddress()}`,
59532
+ created: new Date().toISOString(),
59533
+ eip712: {
59534
+ types: typeUrl,
59535
+ primaryType: 'Iden3PaymentRailsRequestV1',
59536
+ domain
59537
+ }
59538
+ }
59539
+ ];
59540
+ const d = {
59541
+ type: PaymentRequestDataType.Iden3PaymentRailsRequestV1,
59542
+ '@context': [
59543
+ `https://schema.iden3.io/core/jsonld/payment.jsonld#${type}`,
59544
+ 'https://w3id.org/security/suites/eip712sig-2021/v1'
59545
+ ],
59546
+ recipient,
59547
+ amount: amount.toString(),
59548
+ currency,
59549
+ expirationDate: new Date(expirationTime).toISOString(),
59550
+ nonce: nonce.toString(),
59551
+ metadata: '0x',
59552
+ proof
59553
+ };
59554
+ dataArr.push(type === PaymentRequestDataType.Iden3PaymentRailsRequestV1
59555
+ ? d
59556
+ : { ...d, type, tokenAddress: tokenAddress || '', features: features || [] });
59557
+ }
59558
+ paymentRequestInfo.push({
59559
+ data: dataArr,
59560
+ credentials,
59561
+ description
59562
+ });
58537
59563
  }
59564
+ return createPaymentRequest(sender, receiver, agent, paymentRequestInfo);
58538
59565
  }
58539
59566
  async packMessage(message, senderDID) {
58540
59567
  const responseEncoded = byteEncoder.encode(JSON.stringify(message));
@@ -58548,6 +59575,67 @@ class PaymentHandler extends AbstractMessageHandler {
58548
59575
  ...packerOpts
58549
59576
  });
58550
59577
  }
59578
+ async handleIden3PaymentRequestCryptoV1(data, paymentHandler) {
59579
+ if (data.expiration && new Date(data.expiration) < new Date()) {
59580
+ throw new Error(`failed request. expired request`);
59581
+ }
59582
+ const txId = await paymentHandler(data);
59583
+ return {
59584
+ id: data.id,
59585
+ '@context': 'https://schema.iden3.io/core/jsonld/payment.jsonld#Iden3PaymentCryptoV1',
59586
+ type: PaymentType.Iden3PaymentCryptoV1,
59587
+ paymentData: {
59588
+ txId
59589
+ }
59590
+ };
59591
+ }
59592
+ async handleIden3PaymentRailsRequestV1(data, paymentHandler) {
59593
+ if (data.expirationDate && new Date(data.expirationDate) < new Date()) {
59594
+ throw new Error(`failed request. expired request`);
59595
+ }
59596
+ const signer = await verifyEIP712TypedData(data, this._params.documentResolver);
59597
+ if (this._params.allowedSigners && !this._params.allowedSigners.includes(signer)) {
59598
+ throw new Error(`failed request. signer is not in the allowed signers list`);
59599
+ }
59600
+ const txId = await paymentHandler(data);
59601
+ const proof = Array.isArray(data.proof) ? data.proof[0] : data.proof;
59602
+ return {
59603
+ nonce: data.nonce,
59604
+ type: PaymentType.Iden3PaymentRailsV1,
59605
+ '@context': 'https://schema.iden3.io/core/jsonld/payment.jsonld#Iden3PaymentRailsV1',
59606
+ paymentData: {
59607
+ txId,
59608
+ chainId: proof.eip712.domain.chainId
59609
+ }
59610
+ };
59611
+ }
59612
+ async handleIden3PaymentRailsERC20RequestV1(data, paymentHandler, approveHandler) {
59613
+ if (data.expirationDate && new Date(data.expirationDate) < new Date()) {
59614
+ throw new Error(`failed request. expired request`);
59615
+ }
59616
+ const signer = await verifyEIP712TypedData(data, this._params.documentResolver);
59617
+ if (this._params.allowedSigners && !this._params.allowedSigners.includes(signer)) {
59618
+ throw new Error(`failed request. signer is not in the allowed signers list`);
59619
+ }
59620
+ if (!data.features?.includes(PaymentFeatures.EIP_2612) && !approveHandler) {
59621
+ throw new Error(`please provide erc20TokenApproveHandler in context for ERC-20 payment type`);
59622
+ }
59623
+ if (approveHandler) {
59624
+ await approveHandler(data);
59625
+ }
59626
+ const txId = await paymentHandler(data);
59627
+ const proof = Array.isArray(data.proof) ? data.proof[0] : data.proof;
59628
+ return {
59629
+ nonce: data.nonce,
59630
+ type: PaymentType.Iden3PaymentRailsERC20V1,
59631
+ '@context': 'https://schema.iden3.io/core/jsonld/payment.jsonld#Iden3PaymentRailsERC20V1',
59632
+ paymentData: {
59633
+ txId,
59634
+ chainId: proof.eip712.domain.chainId,
59635
+ tokenAddress: data.tokenAddress
59636
+ }
59637
+ };
59638
+ }
58551
59639
  }
58552
59640
 
58553
59641
  const allOperations = Object.values(QueryOperators);
@@ -60584,5 +61672,5 @@ class IdentityWallet {
60584
61672
  }
60585
61673
  }
60586
61674
 
60587
- export { AbstractMessageHandler, AbstractPrivateKeyStore, AgentResolver, AtomicQueryMTPV2Inputs, AtomicQueryMTPV2OnChainInputs, AtomicQueryMTPV2OnChainPubSignals, AtomicQueryMTPV2PubSignals, AtomicQuerySigV2Inputs, AtomicQuerySigV2OnChainCircuitInputs, AtomicQuerySigV2OnChainInputs, AtomicQuerySigV2OnChainPubSignals, AtomicQuerySigV2PubSignals, AtomicQueryV3Inputs, AtomicQueryV3OnChainInputs, AtomicQueryV3OnChainPubSignals, AtomicQueryV3PubSignals, AuthHandler, AuthV2Inputs, AuthV2PubSignals, BJJSignatureProof2021, BaseConfig, BjjProvider, BrowserDataSource, CircuitClaim, CircuitError, CircuitId, CircuitStorage, ContractRequestHandler, CredentialOfferStatus, CredentialProposalHandler, CredentialStatusPublisherRegistry, CredentialStatusResolverRegistry, CredentialStatusType, CredentialStorage, CredentialWallet, DIDDocumentJSONSchema, DIDDocumentSignature, DataPrepareHandlerFunc, DisplayMethodType, Ed25519Provider, ErrorEmptyAuthClaimNonRevProof, ErrorEmptyAuthClaimProof, ErrorEmptyChallengeSignature, ErrorEmptyClaimNonRevProof, ErrorEmptyClaimProof, ErrorEmptyClaimSignature, ErrorEmptyIssuerAuthClaimNonRevProof, ErrorEmptyIssuerAuthClaimProof, ErrorUserStateInRelayClaimProof, EthStateStorage, FSCircuitStorage, FetchHandler, FilterQuery, FunctionSignatures, Iden3OnchainSmtCredentialStatusPublisher, Iden3SmtRhsCredentialStatusPublisher, Iden3SparseMerkleTreeProof, IdentityStorage, IdentityWallet, InMemoryDataSource, InMemoryMerkleTreeStorage, InMemoryPrivateKeyStore, IndexedDBDataSource, IndexedDBPrivateKeyStore, InputGenerator, IssuerResolver, JSON_SCHEMA_VALIDATORS_REGISTRY, JWSPacker, JsonSchemaValidator, KMS, KmsKeyType, LDParser, LinkedMultiQueryInputs, LinkedMultiQueryPubSignals, LocalStoragePrivateKeyStore, MerkleTreeIndexedDBStorage, MerkleTreeLocalStorage, MerkleTreeType, MerklizedRootPosition, MessageBus, MessageHandler, NativeProver, OnChainResolver, OnChainRevocationStorage, OnChainZKPVerifier, Operators, constants as PROTOCOL_CONSTANTS, PackageManager, Parser, PaymentHandler, PaymentRequestDataType, PaymentRequestType, PaymentType, PlainPacker, ProofNode, ProofPurpose, ProofService, ProofType, PubSignalsVerifier, Query, QueryOperators, RHSResolver, RefreshHandler, RefreshServiceType, RevocationStatusHandler, SDK_EVENTS, Scalar, SearchError, Sec256k1Provider, StandardJSONCredentialsQueryFilter, StateTransitionInputs, StateTransitionPubSignals, SubjectPosition, SupportedCurrencies, TransactionService, ValueProof, Vector, VerifiableConstants, VerificationHandlerFunc, W3CCredential, XSDNS, ZKPPacker, availableTypesOperators, base58ToBytes$1 as base58ToBytes, base64ToBytes$1 as base64ToBytes, base64UrlToBytes, bigIntArrayToStringArray, bigIntCompare, buildDIDFromEthPubKey, buildFieldPath, buildTreeState, buildVerifierId, byteDecoder, byteEncoder, bytesToBase58$1 as bytesToBase58, bytesToBase64, bytesToBase64url$1 as bytesToBase64url, bytesToHex$3 as bytesToHex, cacheLoader, calculateCoreSchemaHash, calculateQueryHashV2, calculateQueryHashV3, checkCircuitOperator, checkCircuitQueriesLength, checkDataInField, checkQueryRequest, circuitValidator, comparatorOptions, createAuthorizationRequest, createAuthorizationRequestWithMessage, createPayment, createPaymentRequest, createProposal, createProposalRequest, createSchemaHash, createVerifiablePresentation, credentialSubjectKey, dataFillsSlot, decodeBase64url$1 as decodeBase64url, defaultEthConnectionConfig, defaultMTLevels, defaultMTLevelsClaim, defaultMTLevelsOnChain, defaultValueArraySize, defineMerklizedRootPosition, encodeBase64url, existenceToInt, extractProof, extractPublicKeyBytes, factoryComparer, fieldToByteArray, fieldValueFromVerifiablePresentation, fillCoreClaimSlot, fillSlot, findCredentialType, findValue, generateProfileDID, getFieldSlotIndex, getKMSIdByAuthCredential, getNodeAuxValue, getNodesRepresentation, getOperatorNameByValue, getProperties, getSerializationAttrFromContext, getSerializationAttrFromParsedContext, getUserDIDFromCredential, hexToBytes$3 as hexToBytes, isEthereumIdentity, isGenesisState, isGenesisStateId, isIssuerGenesis, isValidOperation, keyPath, mergeObjects, parseCoreClaimSlots, parseCredentialSubject, parseQueriesMetadata, parseQueryMetadata, parseSerializationAttr, prepareCircuitArrayValues, prepareSiblingsStr, processZeroKnowledgeProofRequests, pushHashesToRHS, resolveDIDDocumentAuth, resolveDidDocument, resolvePath, resolveVerificationMethods, strMTHex, stringByPath, subjectPositionIndex, swapEndianness, toClaimNonRevStatus, toGISTProof, toRevocationStatus, transformQueryValueToBigInts, userStateError, validateDIDDocumentAuth, validateDisclosureNativeSDSupport, validateDisclosureV2Circuit, validateEmptyCredentialSubjectNoopNativeSupport, validateEmptyCredentialSubjectV2Circuit, validateOperators, validateTreeState, verifyFieldValueInclusionNativeExistsSupport, verifyFieldValueInclusionV2, witnessBuilder };
61675
+ export { AbstractMessageHandler, AbstractPrivateKeyStore, AgentResolver, AtomicQueryMTPV2Inputs, AtomicQueryMTPV2OnChainInputs, AtomicQueryMTPV2OnChainPubSignals, AtomicQueryMTPV2PubSignals, AtomicQuerySigV2Inputs, AtomicQuerySigV2OnChainCircuitInputs, AtomicQuerySigV2OnChainInputs, AtomicQuerySigV2OnChainPubSignals, AtomicQuerySigV2PubSignals, AtomicQueryV3Inputs, AtomicQueryV3OnChainInputs, AtomicQueryV3OnChainPubSignals, AtomicQueryV3PubSignals, AuthHandler, AuthV2Inputs, AuthV2PubSignals, BJJSignatureProof2021, BaseConfig, BjjProvider, BrowserDataSource, CircuitClaim, CircuitError, CircuitId, CircuitStorage, ContractRequestHandler, CredentialOfferStatus, CredentialProposalHandler, CredentialStatusPublisherRegistry, CredentialStatusResolverRegistry, CredentialStatusType, CredentialStorage, CredentialWallet, DIDDocumentJSONSchema, DIDDocumentSignature, DataPrepareHandlerFunc, DisplayMethodType, Ed25519Provider, ErrorEmptyAuthClaimNonRevProof, ErrorEmptyAuthClaimProof, ErrorEmptyChallengeSignature, ErrorEmptyClaimNonRevProof, ErrorEmptyClaimProof, ErrorEmptyClaimSignature, ErrorEmptyIssuerAuthClaimNonRevProof, ErrorEmptyIssuerAuthClaimProof, ErrorUserStateInRelayClaimProof, EthStateStorage, FSCircuitStorage, FetchHandler, FilterQuery, FunctionSignatures, Iden3OnchainSmtCredentialStatusPublisher, Iden3SmtRhsCredentialStatusPublisher, Iden3SparseMerkleTreeProof, IdentityStorage, IdentityWallet, InMemoryDataSource, InMemoryMerkleTreeStorage, InMemoryPrivateKeyStore, IndexedDBDataSource, IndexedDBPrivateKeyStore, InputGenerator, IssuerResolver, JSON_SCHEMA_VALIDATORS_REGISTRY, JWSPacker, JsonSchemaValidator, KMS, KmsKeyType, LDParser, LinkedMultiQueryInputs, LinkedMultiQueryPubSignals, LocalStoragePrivateKeyStore, MerkleTreeIndexedDBStorage, MerkleTreeLocalStorage, MerkleTreeType, MerklizedRootPosition, MessageBus, MessageHandler, NativeProver, OnChainResolver, OnChainRevocationStorage, OnChainZKPVerifier, Operators, constants as PROTOCOL_CONSTANTS, PackageManager, Parser, PaymentFeatures, PaymentHandler, PaymentRequestDataType, PaymentType, PlainPacker, ProofNode, ProofPurpose, ProofService, ProofType, PubSignalsVerifier, Query, QueryOperators, RHSResolver, RefreshHandler, RefreshServiceType, RevocationStatusHandler, SDK_EVENTS, Scalar, SearchError, Sec256k1Provider, StandardJSONCredentialsQueryFilter, StateTransitionInputs, StateTransitionPubSignals, SubjectPosition, SupportedCurrencies, SupportedPaymentProofType, TransactionService, ValueProof, Vector, VerifiableConstants, VerificationHandlerFunc, W3CCredential, XSDNS, ZKPPacker, availableTypesOperators, base58ToBytes$1 as base58ToBytes, base64ToBytes$1 as base64ToBytes, base64UrlToBytes, bigIntArrayToStringArray, bigIntCompare, buildAccept, buildDIDFromEthPubKey, buildFieldPath, buildTreeState, buildVerifierId, byteDecoder, byteEncoder, bytesToBase58$1 as bytesToBase58, bytesToBase64, bytesToBase64url$1 as bytesToBase64url, bytesToHex$3 as bytesToHex, cacheLoader, calculateCoreSchemaHash, calculateQueryHashV2, calculateQueryHashV3, checkCircuitOperator, checkCircuitQueriesLength, checkDataInField, checkQueryRequest, circuitValidator, comparatorOptions, createAuthorizationRequest, createAuthorizationRequestWithMessage, createPayment, createPaymentRequest, createProposal, createProposalRequest, createSchemaHash, createVerifiablePresentation, credentialSubjectKey, dataFillsSlot, decodeBase64url$1 as decodeBase64url, defaultEthConnectionConfig, defaultMTLevels, defaultMTLevelsClaim, defaultMTLevelsOnChain, defaultValueArraySize, defineMerklizedRootPosition, encodeBase64url, existenceToInt, extractProof, extractPublicKeyBytes, factoryComparer, fieldToByteArray, fieldValueFromVerifiablePresentation, fillCoreClaimSlot, fillSlot, findCredentialType, findValue, generateProfileDID, getFieldSlotIndex, getKMSIdByAuthCredential, getNodeAuxValue, getNodesRepresentation, getOperatorNameByValue, getPermitSignature, getProperties, getSerializationAttrFromContext, getSerializationAttrFromParsedContext, getUserDIDFromCredential, hexToBytes$3 as hexToBytes, isEthereumIdentity, isGenesisState, isGenesisStateId, isIssuerGenesis, isValidOperation, keyPath, mergeObjects, parseAcceptProfile, parseCoreClaimSlots, parseCredentialSubject, parseQueriesMetadata, parseQueryMetadata, parseSerializationAttr, prepareCircuitArrayValues, prepareSiblingsStr, processZeroKnowledgeProofRequests, pushHashesToRHS, resolveDIDDocumentAuth, resolveDidDocument, resolvePath, resolveVerificationMethods, strMTHex, stringByPath, subjectPositionIndex, swapEndianness, toClaimNonRevStatus, toGISTProof, toRevocationStatus, transformQueryValueToBigInts, userStateError, validateDIDDocumentAuth, validateDisclosureNativeSDSupport, validateDisclosureV2Circuit, validateEmptyCredentialSubjectNoopNativeSupport, validateEmptyCredentialSubjectV2Circuit, validateOperators, validateTreeState, verifyEIP712TypedData, verifyExpiresTime, verifyFieldValueInclusionNativeExistsSupport, verifyFieldValueInclusionV2, witnessBuilder };
60588
61676
  //# sourceMappingURL=index.js.map