@0xpolygonid/js-sdk 1.33.0 → 1.33.3

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 (31) hide show
  1. package/dist/browser/esm/index.js +1123 -719
  2. package/dist/browser/esm/index.js.map +1 -1
  3. package/dist/browser/umd/index.global.js +182 -59
  4. package/dist/browser/umd/index.global.js.map +1 -1
  5. package/dist/node/cjs/index.cjs +1330 -915
  6. package/dist/node/cjs/index.cjs.map +1 -1
  7. package/dist/node/esm/index.js +1123 -719
  8. package/dist/node/esm/index.js.map +1 -1
  9. package/dist/types/iden3comm/handlers/credential-proposal.d.ts.map +1 -1
  10. package/dist/types/iden3comm/handlers/fetch.d.ts.map +1 -1
  11. package/dist/types/iden3comm/handlers/payment.d.ts +14 -5
  12. package/dist/types/iden3comm/handlers/payment.d.ts.map +1 -1
  13. package/dist/types/iden3comm/types/protocol/payment.d.ts +58 -9
  14. package/dist/types/iden3comm/types/protocol/payment.d.ts.map +1 -1
  15. package/dist/types/utils/index.d.ts +2 -0
  16. package/dist/types/utils/index.d.ts.map +1 -1
  17. package/dist/types/utils/payments/evm.d.ts +19 -0
  18. package/dist/types/utils/payments/evm.d.ts.map +1 -0
  19. package/dist/types/utils/payments/solana.d.ts +88 -0
  20. package/dist/types/utils/payments/solana.d.ts.map +1 -0
  21. package/dist/types/verifiable/constants.d.ts +16 -3
  22. package/dist/types/verifiable/constants.d.ts.map +1 -1
  23. package/package.json +5 -1
  24. package/src/iden3comm/handlers/credential-proposal.ts +4 -1
  25. package/src/iden3comm/handlers/fetch.ts +7 -1
  26. package/src/iden3comm/handlers/payment.ts +138 -131
  27. package/src/iden3comm/types/protocol/payment.ts +79 -10
  28. package/src/utils/index.ts +2 -0
  29. package/src/utils/payments/evm.ts +152 -0
  30. package/src/utils/payments/solana.ts +360 -0
  31. package/src/verifiable/constants.ts +17 -3
@@ -144,9 +144,16 @@ __export(index_exports, {
144
144
  RefreshServiceType: () => RefreshServiceType,
145
145
  RevocationStatusHandler: () => RevocationStatusHandler,
146
146
  SDK_EVENTS: () => SDK_EVENTS,
147
+ SOLANA_CHAIN_REF: () => SOLANA_CHAIN_REF,
147
148
  Scalar: () => Scalar,
148
149
  SearchError: () => SearchError,
149
150
  Sec256k1Provider: () => Sec256k1Provider,
151
+ SolanaNativePaymentRequest: () => SolanaNativePaymentRequest,
152
+ SolanaNativePaymentSchema: () => SolanaNativePaymentSchema,
153
+ SolanaPaymentInstruction: () => SolanaPaymentInstruction,
154
+ SolanaPaymentInstructionSchema: () => SolanaPaymentInstructionSchema,
155
+ SolanaSplPaymentRequest: () => SolanaSplPaymentRequest,
156
+ SolanaSplPaymentSchema: () => SolanaSplPaymentSchema,
150
157
  StandardJSONCredentialsQueryFilter: () => StandardJSONCredentialsQueryFilter,
151
158
  StateTransitionInputs: () => StateTransitionInputs,
152
159
  StateTransitionPubSignals: () => StateTransitionPubSignals,
@@ -170,7 +177,9 @@ __export(index_exports, {
170
177
  bigIntCompare: () => bigIntCompare,
171
178
  buildAccept: () => buildAccept,
172
179
  buildDIDFromEthPubKey: () => buildDIDFromEthPubKey,
180
+ buildEvmPayment: () => buildEvmPayment,
173
181
  buildFieldPath: () => buildFieldPath,
182
+ buildSolanaPayment: () => buildSolanaPayment,
174
183
  buildTreeState: () => buildTreeState,
175
184
  buildVerifierId: () => buildVerifierId,
176
185
  byteDecoder: () => byteDecoder,
@@ -268,6 +277,7 @@ __export(index_exports, {
268
277
  resolveDidDocument: () => resolveDidDocument,
269
278
  resolvePath: () => resolvePath,
270
279
  resolveVerificationMethods: () => resolveVerificationMethods,
280
+ serializeSolanaPaymentInstruction: () => serializeSolanaPaymentInstruction,
271
281
  strMTHex: () => strMTHex,
272
282
  stringByPath: () => stringByPath,
273
283
  subjectPositionIndex: () => subjectPositionIndex,
@@ -289,6 +299,7 @@ __export(index_exports, {
289
299
  verifyExpiresTime: () => verifyExpiresTime,
290
300
  verifyFieldValueInclusionNativeExistsSupport: () => verifyFieldValueInclusionNativeExistsSupport,
291
301
  verifyFieldValueInclusionV2: () => verifyFieldValueInclusionV2,
302
+ verifyIden3SolanaPaymentRequest: () => verifyIden3SolanaPaymentRequest,
292
303
  witnessBuilder: () => witnessBuilder
293
304
  });
294
305
  module.exports = __toCommonJS(index_exports);
@@ -380,8 +391,8 @@ var KMS = class {
380
391
  };
381
392
 
382
393
  // src/kms/key-providers/bjj-provider.ts
383
- var import_js_crypto3 = require("@iden3/js-crypto");
384
- var import_js_iden3_core2 = require("@iden3/js-iden3-core");
394
+ var import_js_crypto6 = require("@iden3/js-crypto");
395
+ var import_js_iden3_core8 = require("@iden3/js-iden3-core");
385
396
 
386
397
  // src/kms/store/abstract-key-store.ts
387
398
  var AbstractPrivateKeyStore = class {
@@ -775,629 +786,370 @@ var bigIntCompare = (a, b) => {
775
786
  return 0;
776
787
  };
777
788
 
778
- // src/kms/key-providers/bjj-provider.ts
779
- var BjjProvider = class {
780
- /**
781
- * key type that is handled by BJJ Provider
782
- * @type {KmsKeyType}
783
- */
784
- keyType;
785
- keyStore;
786
- /**
787
- * Creates an instance of BjjProvider.
788
- * @param {KmsKeyType} keyType - kms key type
789
- * @param {AbstractPrivateKeyStore} keyStore - key store for kms
790
- */
791
- constructor(keyType, keyStore) {
792
- if (keyType !== "BJJ" /* BabyJubJub */) {
793
- throw new Error("Key type must be BabyJubJub");
794
- }
795
- this.keyType = keyType;
796
- this.keyStore = keyStore;
797
- }
798
- /**
799
- * get all keys
800
- * @returns list of keys
801
- */
802
- async list() {
803
- const allKeysFromKeyStore = await this.keyStore.list();
804
- return allKeysFromKeyStore.filter((key) => key.alias.startsWith(this.keyType));
789
+ // src/utils/payments/solana.ts
790
+ var import_borsh = require("borsh");
791
+ var import_ed25519 = require("@noble/curves/ed25519");
792
+
793
+ // src/verifiable/proof.ts
794
+ var import_js_merkletree2 = require("@iden3/js-merkletree");
795
+
796
+ // src/verifiable/constants.ts
797
+ var VerifiableConstants = Object.freeze({
798
+ ERRORS: {
799
+ FiELD_IS_EMPTY: "fieldPath is empty",
800
+ CONTEXT_TYPE_IS_EMPTY: "ctxType is empty",
801
+ // ErrStateNotFound issuer state is genesis state.
802
+ IDENTITY_DOES_NOT_EXIST: "Identity does not exist",
803
+ IDENTITY_DOES_NOT_EXIST_CUSTOM_ERROR: "IdentityDoesNotExist",
804
+ NO_AUTH_CRED_FOUND: "no auth credentials found",
805
+ STATE_DOES_NOT_EXIST: "State does not exist",
806
+ STATE_DOES_NOT_EXIST_CUSTOM_ERROR: "StateDoesNotExist",
807
+ ROOT_DOES_NOT_EXIST: "Root does not exist",
808
+ ROOT_DOES_NOT_EXIST_CUSTOM_ERROR: "RootDoesNotExist",
809
+ // identity wallet
810
+ ID_WALLET_NO_CREDENTIAL_SATISFIED_QUERY: "no credential satisfied query",
811
+ ID_WALLET_SIGNER_IS_REQUIRED: "Ethereum signer is required to create Ethereum identities in order to transit state",
812
+ ID_WALLET_PROVER_IS_REQUIRED: "prover is required to generate proofs for non ethereum identities",
813
+ ID_WALLET_CORE_CLAIM_REQUIRED_IN_SIG_PROOF: "credential must have coreClaim representation in the signature proof",
814
+ ID_WALLET_CORE_CLAIM_REQUIRED_IN_ANY_PROOF: "credential must have coreClaim representation in proofs",
815
+ ID_WALLET_CORE_CLAIM_MISMATCH: "core claim representations is set in both proofs but they are not equal",
816
+ ID_WALLET_CORE_CLAIM_IS_NOT_SET: "core claim is not set in credential proofs",
817
+ ID_WALLET_PROFILE_OR_IDENTITY_NOT_FOUND: "profile or identity not found",
818
+ ID_WALLET_PROFILE_ALREADY_EXISTS: "profile with given nonce or verifier already exists",
819
+ ID_WALLET_PROFILE_ALREADY_EXISTS_VERIFIER_TAGS: "profile with given verifier and tags already exists",
820
+ ID_WALLET_ISSUER_AUTH_BJJ_CRED_MUST_HAVE_ANY_PROOF: "issuer auth credential must have proof",
821
+ ID_WALLET_ISSUER_AUTH_BJJ_CRED_MUST_HAVE_MTP_PROOF: "mtp is required for auth bjj key to issue new credentials",
822
+ // proof service
823
+ PROOF_SERVICE_NO_CREDENTIAL_FOR_IDENTITY_OR_PROFILE: "no credentials belong to did or its profiles",
824
+ PROOF_SERVICE_NO_CREDENTIAL_FOR_QUERY: "credential not found for query",
825
+ PROOF_SERVICE_PROFILE_GENESIS_DID_MISMATCH: "subject and auth profiles are not derived from the same did",
826
+ PROOF_SERVICE_NO_QUERIES_IN_ZKP_REQUEST: "no queries in zkp request",
827
+ // credential wallet
828
+ CREDENTIAL_WALLET_ALL_CREDENTIALS_ARE_REVOKED: "all claims are revoked"
829
+ },
830
+ CREDENTIAL_TYPE: {
831
+ // VerifiableCredential is a W3C verifiable credential type
832
+ W3C_VERIFIABLE_CREDENTIAL: "VerifiableCredential",
833
+ W3C_VERIFIABLE_PRESENTATION: "VerifiablePresentation"
834
+ },
835
+ CREDENTIAL_SUBJECT_PATH: "https://www.w3.org/2018/credentials#credentialSubject",
836
+ JSONLD_SCHEMA: {
837
+ // JSONLDSchemaIden3Credential is a schema for context with Iden3Credential type
838
+ IDEN3_CREDENTIAL: "https://schema.iden3.io/core/jsonld/iden3proofs.jsonld",
839
+ // JSONLDSchemaIden3DisplayMethod is a schema for context with Iden3BasicDisplayMethodV1 type
840
+ IDEN3_DISPLAY_METHOD: "https://schema.iden3.io/core/jsonld/displayMethod.jsonld",
841
+ // JSONLDSchemaW3CCredential2018 is a schema for context with VerifiableCredential type
842
+ W3C_CREDENTIAL_2018: "https://www.w3.org/2018/credentials/v1",
843
+ W3C_VC_DOCUMENT_2018: `{"@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","VerifiableCredential":{"@id":"https://www.w3.org/2018/credentials#VerifiableCredential","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","cred":"https://www.w3.org/2018/credentials#","sec":"https://w3id.org/security#","xsd":"http://www.w3.org/2001/XMLSchema#","credentialSchema":{"@id":"cred:credentialSchema","@type":"@id","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","cred":"https://www.w3.org/2018/credentials#","JsonSchemaValidator2018":"cred:JsonSchemaValidator2018"}},"credentialStatus":{"@id":"cred:credentialStatus","@type":"@id"},"credentialSubject":{"@id":"cred:credentialSubject","@type":"@id"},"evidence":{"@id":"cred:evidence","@type":"@id"},"expirationDate":{"@id":"cred:expirationDate","@type":"xsd:dateTime"},"holder":{"@id":"cred:holder","@type":"@id"},"issued":{"@id":"cred:issued","@type":"xsd:dateTime"},"issuer":{"@id":"cred:issuer","@type":"@id"},"issuanceDate":{"@id":"cred:issuanceDate","@type":"xsd:dateTime"},"proof":{"@id":"sec:proof","@type":"@id","@container":"@graph"},"refreshService":{"@id":"cred:refreshService","@type":"@id","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","cred":"https://www.w3.org/2018/credentials#","ManualRefreshService2018":"cred:ManualRefreshService2018"}},"termsOfUse":{"@id":"cred:termsOfUse","@type":"@id"},"validFrom":{"@id":"cred:validFrom","@type":"xsd:dateTime"},"validUntil":{"@id":"cred:validUntil","@type":"xsd:dateTime"}}},"VerifiablePresentation":{"@id":"https://www.w3.org/2018/credentials#VerifiablePresentation","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","cred":"https://www.w3.org/2018/credentials#","sec":"https://w3id.org/security#","holder":{"@id":"cred:holder","@type":"@id"},"proof":{"@id":"sec:proof","@type":"@id","@container":"@graph"},"verifiableCredential":{"@id":"cred:verifiableCredential","@type":"@id","@container":"@graph"}}},"EcdsaSecp256k1Signature2019":{"@id":"https://w3id.org/security#EcdsaSecp256k1Signature2019","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","sec":"https://w3id.org/security#","xsd":"http://www.w3.org/2001/XMLSchema#","challenge":"sec:challenge","created":{"@id":"http://purl.org/dc/terms/created","@type":"xsd:dateTime"},"domain":"sec:domain","expires":{"@id":"sec:expiration","@type":"xsd:dateTime"},"jws":"sec:jws","nonce":"sec:nonce","proofPurpose":{"@id":"sec:proofPurpose","@type":"@vocab","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","sec":"https://w3id.org/security#","assertionMethod":{"@id":"sec:assertionMethod","@type":"@id","@container":"@set"},"authentication":{"@id":"sec:authenticationMethod","@type":"@id","@container":"@set"}}},"proofValue":"sec:proofValue","verificationMethod":{"@id":"sec:verificationMethod","@type":"@id"}}},"EcdsaSecp256r1Signature2019":{"@id":"https://w3id.org/security#EcdsaSecp256r1Signature2019","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","sec":"https://w3id.org/security#","xsd":"http://www.w3.org/2001/XMLSchema#","challenge":"sec:challenge","created":{"@id":"http://purl.org/dc/terms/created","@type":"xsd:dateTime"},"domain":"sec:domain","expires":{"@id":"sec:expiration","@type":"xsd:dateTime"},"jws":"sec:jws","nonce":"sec:nonce","proofPurpose":{"@id":"sec:proofPurpose","@type":"@vocab","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","sec":"https://w3id.org/security#","assertionMethod":{"@id":"sec:assertionMethod","@type":"@id","@container":"@set"},"authentication":{"@id":"sec:authenticationMethod","@type":"@id","@container":"@set"}}},"proofValue":"sec:proofValue","verificationMethod":{"@id":"sec:verificationMethod","@type":"@id"}}},"Ed25519Signature2018":{"@id":"https://w3id.org/security#Ed25519Signature2018","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","sec":"https://w3id.org/security#","xsd":"http://www.w3.org/2001/XMLSchema#","challenge":"sec:challenge","created":{"@id":"http://purl.org/dc/terms/created","@type":"xsd:dateTime"},"domain":"sec:domain","expires":{"@id":"sec:expiration","@type":"xsd:dateTime"},"jws":"sec:jws","nonce":"sec:nonce","proofPurpose":{"@id":"sec:proofPurpose","@type":"@vocab","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","sec":"https://w3id.org/security#","assertionMethod":{"@id":"sec:assertionMethod","@type":"@id","@container":"@set"},"authentication":{"@id":"sec:authenticationMethod","@type":"@id","@container":"@set"}}},"proofValue":"sec:proofValue","verificationMethod":{"@id":"sec:verificationMethod","@type":"@id"}}},"RsaSignature2018":{"@id":"https://w3id.org/security#RsaSignature2018","@context":{"@version":1.1,"@protected":true,"challenge":"sec:challenge","created":{"@id":"http://purl.org/dc/terms/created","@type":"xsd:dateTime"},"domain":"sec:domain","expires":{"@id":"sec:expiration","@type":"xsd:dateTime"},"jws":"sec:jws","nonce":"sec:nonce","proofPurpose":{"@id":"sec:proofPurpose","@type":"@vocab","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","sec":"https://w3id.org/security#","assertionMethod":{"@id":"sec:assertionMethod","@type":"@id","@container":"@set"},"authentication":{"@id":"sec:authenticationMethod","@type":"@id","@container":"@set"}}},"proofValue":"sec:proofValue","verificationMethod":{"@id":"sec:verificationMethod","@type":"@id"}}},"proof":{"@id":"https://w3id.org/security#proof","@type":"@id","@container":"@graph"}}}`,
844
+ IDEN3_PROOFS_DEFINITION_DOCUMENT: `{"@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","Iden3SparseMerkleTreeProof":{"@id":"https://schema.iden3.io/core/jsonld/iden3proofs.jsonld#Iden3SparseMerkleTreeProof","@context":{"@version":1.1,"@protected":true,"@propagate":true,"id":"@id","type":"@type","sec":"https://w3id.org/security#","@vocab":"https://schema.iden3.io/core/vocab/Iden3SparseMerkleTreeProof.md#","xsd":"http://www.w3.org/2001/XMLSchema#","mtp":{"@id":"https://schema.iden3.io/core/jsonld/iden3proofs.jsonld#SparseMerkleTreeProof","@type":"SparseMerkleTreeProof"},"coreClaim":{"@id":"coreClaim","@type":"xsd:string"},"issuerData":{"@id":"issuerData","@context":{"@version":1.1,"state":{"@id":"state","@context":{"txId":{"@id":"txId","@type":"xsd:string"},"blockTimestamp":{"@id":"blockTimestamp","@type":"xsd:integer"},"blockNumber":{"@id":"blockNumber","@type":"xsd:integer"},"rootOfRoots":{"@id":"rootOfRoots","@type":"xsd:string"},"claimsTreeRoot":{"@id":"claimsTreeRoot","@type":"xsd:string"},"revocationTreeRoot":{"@id":"revocationTreeRoot","@type":"xsd:string"},"authCoreClaim":{"@id":"authCoreClaim","@type":"xsd:string"},"value":{"@id":"value","@type":"xsd:string"}}}}}}},"SparseMerkleTreeProof":{"@id":"https://schema.iden3.io/core/jsonld/iden3proofs.jsonld#SparseMerkleTreeProof","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","sec":"https://w3id.org/security#","smt-proof-vocab":"https://schema.iden3.io/core/vocab/SparseMerkleTreeProof.md#","xsd":"http://www.w3.org/2001/XMLSchema#","existence":{"@id":"smt-proof-vocab:existence","@type":"xsd:boolean"},"revocationNonce":{"@id":"smt-proof-vocab:revocationNonce","@type":"xsd:number"},"siblings":{"@id":"smt-proof-vocab:siblings","@container":"@list"},"nodeAux":"@nest","hIndex":{"@id":"smt-proof-vocab:hIndex","@nest":"nodeAux","@type":"xsd:string"},"hValue":{"@id":"smt-proof-vocab:hValue","@nest":"nodeAux","@type":"xsd:string"}}},"BJJSignature2021":{"@id":"https://schema.iden3.io/core/jsonld/iden3proofs.jsonld#BJJSignature2021","@context":{"@version":1.1,"@protected":true,"id":"@id","@vocab":"https://schema.iden3.io/core/vocab/BJJSignature2021.md#","@propagate":true,"type":"@type","xsd":"http://www.w3.org/2001/XMLSchema#","coreClaim":{"@id":"coreClaim","@type":"xsd:string"},"issuerData":{"@id":"issuerData","@context":{"@version":1.1,"authCoreClaim":{"@id":"authCoreClaim","@type":"xsd:string"},"mtp":{"@id":"https://schema.iden3.io/core/jsonld/iden3proofs.jsonld#SparseMerkleTreeProof","@type":"SparseMerkleTreeProof"},"revocationStatus":{"@id":"revocationStatus","@type":"@id"},"state":{"@id":"state","@context":{"@version":1.1,"rootOfRoots":{"@id":"rootOfRoots","@type":"xsd:string"},"claimsTreeRoot":{"@id":"claimsTreeRoot","@type":"xsd:string"},"revocationTreeRoot":{"@id":"revocationTreeRoot","@type":"xsd:string"},"value":{"@id":"value","@type":"xsd:string"}}}}},"signature":{"@id":"signature","@type":"https://w3id.org/security#multibase"},"domain":"https://w3id.org/security#domain","creator":{"@id":"creator","@type":"http://www.w3.org/2001/XMLSchema#string"},"challenge":"https://w3id.org/security#challenge","created":{"@id":"created","@type":"http://www.w3.org/2001/XMLSchema#dateTime"},"expires":{"@id":"https://w3id.org/security#expiration","@type":"http://www.w3.org/2001/XMLSchema#dateTime"},"nonce":"https://w3id.org/security#nonce","proofPurpose":{"@id":"https://w3id.org/security#proofPurpose","@type":"@vocab","@context":{"@protected":true,"id":"@id","type":"@type","assertionMethod":{"@id":"https://w3id.org/security#assertionMethod","@type":"@id","@container":"@set"},"authentication":{"@id":"https://w3id.org/security#authenticationMethod","@type":"@id","@container":"@set"},"capabilityInvocation":{"@id":"https://w3id.org/security#capabilityInvocationMethod","@type":"@id","@container":"@set"},"capabilityDelegation":{"@id":"https://w3id.org/security#capabilityDelegationMethod","@type":"@id","@container":"@set"},"keyAgreement":{"@id":"https://w3id.org/security#keyAgreementMethod","@type":"@id","@container":"@set"}}},"proofValue":{"@id":"https://w3id.org/security#proofValue","@type":"https://w3id.org/security#multibase"},"verificationMethod":{"@id":"https://w3id.org/security#verificationMethod","@type":"@id"}}},"Iden3ReverseSparseMerkleTreeProof":{"@id":"https://schema.iden3.io/core/jsonld/iden3proofs.jsonld#Iden3ReverseSparseMerkleTreeProof","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","iden3-reverse-sparse-merkle-tree-proof-vocab":"https://schema.iden3.io/core/vocab/Iden3ReverseSparseMerkleTreeProof.md#","xsd":"http://www.w3.org/2001/XMLSchema#","revocationNonce":{"@id":"iden3-reverse-sparse-merkle-tree-proof-vocab:revocationNonce","@type":"xsd:integer"},"statusIssuer":{"@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type"},"@id":"iden3-reverse-sparse-merkle-tree-proof-vocab:statusIssuer"}}},"Iden3commRevocationStatusV1.0":{"@id":"https://schema.iden3.io/core/jsonld/iden3proofs.jsonld#Iden3commRevocationStatusV1.0","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","iden3-comm-revocation-statusV1.0-vocab":"https://schema.iden3.io/core/vocab/Iden3commRevocationStatusV1.0.md#","xsd":"http://www.w3.org/2001/XMLSchema#","revocationNonce":{"@id":"iden3-comm-revocation-statusV1.0-vocab:revocationNonce","@type":"xsd:integer"},"statusIssuer":{"@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type"},"@id":"iden3-comm-revocation-statusV1.0-vocab:statusIssuer"}}},"Iden3OnchainSparseMerkleTreeProof2023":{"@id":"https://schema.iden3.io/core/jsonld/iden3proofs.jsonld#Iden3OnchainSparseMerkleTreeProof2023","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","iden3-onchain-sparse-merkle-tree-proof-2023-vocab":"https://schema.iden3.io/core/vocab/Iden3OnchainSparseMerkleTreeProof2023.md#","xsd":"http://www.w3.org/2001/XMLSchema#","revocationNonce":{"@id":"iden3-onchain-sparse-merkle-tree-proof-2023-vocab:revocationNonce","@type":"xsd:integer"},"statusIssuer":{"@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type"},"@id":"iden3-onchain-sparse-merkle-tree-proof-2023-vocab:statusIssuer"}}},"JsonSchema2023":"https://www.w3.org/ns/credentials#JsonSchema2023","Iden3RefreshService2023":"https://schema.iden3.io/core/jsonld/iden3proofs.jsonld#Iden3RefreshService2023"}}`,
845
+ IDEN3_DISPLAY_METHOD_DEFINITION_DOCUMENT: `{"@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","displayMethod":{"@id":"https://schema.iden3.io/core/vocab/displayMethod.md#displayMethod","@type":"@id","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","Iden3BasicDisplayMethodV1":"https://schema.iden3.io/core/vocab/displayMethod.md#Iden3BasicDisplayMethodV1"}}}}`
846
+ },
847
+ // JsonSchema2023 JSON schema for verification of Iden3Credential
848
+ JSON_SCHEMA_VALIDATOR: "JsonSchema2023",
849
+ SERVICE_TYPE: {
850
+ // Iden3CommServiceType is service type for iden3comm protocol
851
+ IDEN3_COMM: "iden3-communication",
852
+ // PushNotificationServiceType is service type for delivering push notifications to identity
853
+ PUSH_NOTIFICATION: "push-notification"
854
+ },
855
+ AUTH: {
856
+ AUTH_BJJ_CREDENTIAL_HASH: "013fd3f623559d850fb5b02ff012d0e2",
857
+ AUTH_BJJ_CREDENTIAL_SCHEMA_JSON_URL: "https://schema.iden3.io/core/json/auth.json",
858
+ AUTH_BJJ_CREDENTIAL_SCHEMA_JSONLD_URL: "https://schema.iden3.io/core/jsonld/auth.jsonld",
859
+ AUTH_BJJ_CREDENTIAL_TYPE: "AuthBJJCredential",
860
+ AUTH_BJJ_CREDENTIAL_SCHEMA_JSON: `{"$schema":"http://json-schema.org/draft-07/schema#","$metadata":{"uris":{"jsonLdContext":"https://schema.iden3.io/core/jsonld/auth.jsonld","jsonSchema":"https://schema.iden3.io/core/json/auth.json"},"serialization":{"indexDataSlotA":"x","indexDataSlotB":"y"}},"type":"object","required":["@context","id","type","issuanceDate","credentialSubject","credentialSchema","credentialStatus","issuer"],"properties":{"@context":{"type":["string","array","object"]},"id":{"type":"string"},"type":{"type":["string","array"],"items":{"type":"string"}},"issuer":{"type":["string","object"],"format":"uri","required":["id"],"properties":{"id":{"type":"string","format":"uri"}}},"issuanceDate":{"type":"string","format":"date-time"},"expirationDate":{"type":"string","format":"date-time"},"credentialSchema":{"type":"object","required":["id","type"],"properties":{"id":{"type":"string","format":"uri"},"type":{"type":"string"}}},"credentialSubject":{"type":"object","required":["x","y"],"properties":{"id":{"title":"Credential Subject ID","type":"string","format":"uri"},"x":{"type":"string"},"y":{"type":"string"}}}}}`,
861
+ AUTH_BJJ_CREDENTIAL_SCHEMA_JSONLD: `{"@context":[{"@version":1.1,"@protected":true,"id":"@id","type":"@type","AuthBJJCredential":{"@id":"https://schema.iden3.io/core/jsonld/auth.jsonld#AuthBJJCredential","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","iden3_serialization":"iden3:v1:slotIndexA=x&slotIndexB=y","xsd":"http://www.w3.org/2001/XMLSchema#","auth-vocab":"https://schema.iden3.io/core/vocab/auth.md#","x":{"@id":"auth-vocab:x","@type":"xsd:positiveInteger"},"y":{"@id":"auth-vocab:y","@type":"xsd:positiveInteger"}}},"Iden3StateInfo2023":{"@id":"https://schema.iden3.io/core/jsonld/auth.jsonld#Iden3StateInfo2023","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","xsd":"http://www.w3.org/2001/XMLSchema#","@vocab":"https://schema.iden3.io/core/vocab/state-info.md#","@propagate":true,"stateContractAddress":{"@id":"stateContractAddress","@type":"xsd:string"},"published":{"@id":"published","@type":"xsd:boolean"},"info":{"@id":"info","@type":"@id","@context":{"@protected":true,"id":{"@id":"id","@type":"xsd:string"},"state":{"@id":"state","@type":"xsd:string"},"replacedByState":{"@id":"replacedByState","@type":"xsd:string"},"createdAtTimestamp":{"@id":"createdAtTimestamp","@type":"xsd:string"},"replacedAtTimestamp":{"@id":"replacedAtTimestamp","@type":"xsd:string"},"createdAtBlock":{"@id":"createdAtBlock","@type":"xsd:string"},"replacedAtBlock":{"@id":"replacedAtBlock","@type":"xsd:string"}}},"global":{"@id":"global","@type":"@id","@context":{"@protected":true,"sec":"https://w3id.org/security#","root":{"@id":"root","@type":"xsd:string"},"replacedByRoot":{"@id":"replacedByRoot","@type":"xsd:string"},"createdAtTimestamp":{"@id":"createdAtTimestamp","@type":"xsd:string"},"replacedAtTimestamp":{"@id":"replacedAtTimestamp","@type":"xsd:string"},"createdAtBlock":{"@id":"createdAtBlock","@type":"xsd:string"},"replacedAtBlock":{"@id":"replacedAtBlock","@type":"xsd:string"},"proof":{"@id":"sec:proof","@type":"@id","@container":"@graph"}}}}}}]}`
805
862
  }
863
+ });
864
+ var ProofType = /* @__PURE__ */ ((ProofType2) => {
865
+ ProofType2["BJJSignature"] = "BJJSignature2021";
866
+ ProofType2["Iden3SparseMerkleTreeProof"] = "Iden3SparseMerkleTreeProof";
867
+ return ProofType2;
868
+ })(ProofType || {});
869
+ var CredentialStatusType = /* @__PURE__ */ ((CredentialStatusType2) => {
870
+ CredentialStatusType2["SparseMerkleTreeProof"] = "SparseMerkleTreeProof";
871
+ CredentialStatusType2["Iden3ReverseSparseMerkleTreeProof"] = "Iden3ReverseSparseMerkleTreeProof";
872
+ CredentialStatusType2["Iden3commRevocationStatusV1"] = "Iden3commRevocationStatusV1.0";
873
+ CredentialStatusType2["Iden3OnchainSparseMerkleTreeProof2023"] = "Iden3OnchainSparseMerkleTreeProof2023";
874
+ return CredentialStatusType2;
875
+ })(CredentialStatusType || {});
876
+ var ProofPurpose = /* @__PURE__ */ ((ProofPurpose2) => {
877
+ ProofPurpose2["Authentication"] = "Authentication";
878
+ return ProofPurpose2;
879
+ })(ProofPurpose || {});
880
+ var MerklizedRootPosition = /* @__PURE__ */ ((MerklizedRootPosition4) => {
881
+ MerklizedRootPosition4["Index"] = "index";
882
+ MerklizedRootPosition4["Value"] = "value";
883
+ MerklizedRootPosition4["None"] = "";
884
+ return MerklizedRootPosition4;
885
+ })(MerklizedRootPosition || {});
886
+ var SubjectPosition = /* @__PURE__ */ ((SubjectPosition2) => {
887
+ SubjectPosition2["None"] = "";
888
+ SubjectPosition2["Index"] = "index";
889
+ SubjectPosition2["Value"] = "value";
890
+ return SubjectPosition2;
891
+ })(SubjectPosition || {});
892
+ var RefreshServiceType = /* @__PURE__ */ ((RefreshServiceType2) => {
893
+ RefreshServiceType2["Iden3RefreshService2023"] = "Iden3RefreshService2023";
894
+ return RefreshServiceType2;
895
+ })(RefreshServiceType || {});
896
+ var PaymentRequestDataType = /* @__PURE__ */ ((PaymentRequestDataType2) => {
897
+ PaymentRequestDataType2["Iden3PaymentRequestCryptoV1"] = "Iden3PaymentRequestCryptoV1";
898
+ PaymentRequestDataType2["Iden3PaymentRailsRequestV1"] = "Iden3PaymentRailsRequestV1";
899
+ PaymentRequestDataType2["Iden3PaymentRailsERC20RequestV1"] = "Iden3PaymentRailsERC20RequestV1";
900
+ PaymentRequestDataType2["Iden3PaymentRailsSolanaRequestV1"] = "Iden3PaymentRailsSolanaRequestV1";
901
+ PaymentRequestDataType2["Iden3PaymentRailsSolanaSPLRequestV1"] = "Iden3PaymentRailsSolanaSPLRequestV1";
902
+ return PaymentRequestDataType2;
903
+ })(PaymentRequestDataType || {});
904
+ var PaymentType = /* @__PURE__ */ ((PaymentType2) => {
905
+ PaymentType2["Iden3PaymentCryptoV1"] = "Iden3PaymentCryptoV1";
906
+ PaymentType2["Iden3PaymentRailsV1"] = "Iden3PaymentRailsV1";
907
+ PaymentType2["Iden3PaymentRailsERC20V1"] = "Iden3PaymentRailsERC20V1";
908
+ PaymentType2["Iden3PaymentRailsSolanaV1"] = "Iden3PaymentRailsSolanaV1";
909
+ PaymentType2["Iden3PaymentRailsSolanaSPLV1"] = "Iden3PaymentRailsSolanaSPLV1";
910
+ return PaymentType2;
911
+ })(PaymentType || {});
912
+ var SupportedPaymentProofType = /* @__PURE__ */ ((SupportedPaymentProofType2) => {
913
+ SupportedPaymentProofType2["EthereumEip712Signature2021"] = "EthereumEip712Signature2021";
914
+ SupportedPaymentProofType2["SolanaEd25519Signature2025"] = "SolanaEd25519Signature2025";
915
+ return SupportedPaymentProofType2;
916
+ })(SupportedPaymentProofType || {});
917
+ var SupportedCurrencies = /* @__PURE__ */ ((SupportedCurrencies2) => {
918
+ SupportedCurrencies2["ETH"] = "ETH";
919
+ SupportedCurrencies2["ETH_WEI"] = "ETHWEI";
920
+ SupportedCurrencies2["ETH_GWEI"] = "ETHGWEI";
921
+ SupportedCurrencies2["MATIC"] = "MATIC";
922
+ SupportedCurrencies2["POL"] = "POL";
923
+ return SupportedCurrencies2;
924
+ })(SupportedCurrencies || {});
925
+ var PaymentFeatures = /* @__PURE__ */ ((PaymentFeatures2) => {
926
+ PaymentFeatures2["EIP_2612"] = "EIP-2612";
927
+ return PaymentFeatures2;
928
+ })(PaymentFeatures || {});
929
+ var DisplayMethodType = /* @__PURE__ */ ((DisplayMethodType2) => {
930
+ DisplayMethodType2["Iden3BasicDisplayMethodV1"] = "Iden3BasicDisplayMethodV1";
931
+ return DisplayMethodType2;
932
+ })(DisplayMethodType || {});
933
+ var DEFAULT_CACHE_MAX_SIZE = 1e4;
934
+ var SOLANA_CHAIN_REF = Object.freeze({
935
+ DEVNET: "EtWTRABZaYq6iMfeYKouRu166VU2xqa1",
936
+ TESTNET: "4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z",
937
+ MAINNET: "5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"
938
+ });
939
+
940
+ // src/verifiable/proof.ts
941
+ var import_js_crypto3 = require("@iden3/js-crypto");
942
+ var import_js_iden3_core2 = require("@iden3/js-iden3-core");
943
+ var Iden3SparseMerkleTreeProof = class _Iden3SparseMerkleTreeProof {
944
+ type;
945
+ issuerData;
946
+ mtp;
947
+ coreClaim;
806
948
  /**
807
- * generates a baby jub jub key from a seed phrase
808
- * @param {Uint8Array} seed - byte array seed
809
- * @returns kms key identifier
949
+ * Creates an instance of Iden3SparseMerkleTreeProof.
950
+ * @param {object} obj
810
951
  */
811
- async newPrivateKeyFromSeed(seed) {
812
- const newKey = new Uint8Array(32);
813
- newKey.set(Uint8Array.from(seed), 0);
814
- newKey.fill(seed.length, 32, 0);
815
- const privateKey = new import_js_crypto3.PrivateKey(seed);
816
- const publicKey = privateKey.public();
817
- const kmsId = {
818
- type: this.keyType,
819
- id: keyPath(this.keyType, publicKey.hex())
820
- };
821
- await this.keyStore.importKey({ alias: kmsId.id, key: privateKey.hex() });
822
- return kmsId;
952
+ constructor(obj) {
953
+ this.coreClaim = obj.coreClaim;
954
+ this.issuerData = obj.issuerData;
955
+ this.type = "Iden3SparseMerkleTreeProof" /* Iden3SparseMerkleTreeProof */;
956
+ this.mtp = obj.mtp;
823
957
  }
824
958
  /**
825
- * Gets public key by kmsKeyId
826
959
  *
827
- * @param {KmsKeyId} keyId - key identifier
828
- */
829
- async publicKey(keyId) {
830
- const privateKey = await this.privateKey(keyId);
831
- return privateKey.public().hex();
832
- }
833
- /**
834
- * signs prepared payload of size,
835
- * with a key id
836
960
  *
837
- * @param {KmsKeyId} keyId - key identifier
838
- * @param {Uint8Array} data - data to sign (32 bytes)
839
- * @returns Uint8Array signature
961
+ * @returns `json object in serialized presentation`
840
962
  */
841
- async sign(keyId, data) {
842
- if (data.length != 32) {
843
- throw new Error("data to sign is too large");
844
- }
845
- const i = import_js_iden3_core2.BytesHelper.bytesToInt(data);
846
- if (!(0, import_js_iden3_core2.checkBigIntInField)(i)) {
847
- throw new Error("data to sign is too large");
848
- }
849
- const privateKey = await this.privateKey(keyId);
850
- const signature = privateKey.signPoseidon(i);
851
- return signature.compress();
852
- }
853
- async privateKey(keyId) {
854
- const privateKeyHex = await this.keyStore.get({ alias: keyId.id });
855
- return new import_js_crypto3.PrivateKey(import_js_crypto3.Hex.decodeString(privateKeyHex));
856
- }
857
- async verify(message, signatureHex, keyId) {
858
- const publicKey = await this.publicKey(keyId);
859
- return import_js_crypto3.PublicKey.newFromCompressed(hexToBytes(publicKey)).verifyPoseidon(
860
- import_js_iden3_core2.BytesHelper.bytesToInt(message),
861
- import_js_crypto3.Signature.newFromCompressed(hexToBytes(signatureHex))
862
- );
963
+ toJSON() {
964
+ const issuerId = this.issuerData.id;
965
+ return {
966
+ issuerData: {
967
+ id: issuerId.string(),
968
+ state: {
969
+ ...this.issuerData.state,
970
+ rootOfRoots: this.issuerData.state.rootOfRoots.hex(),
971
+ claimsTreeRoot: this.issuerData.state.claimsTreeRoot.hex(),
972
+ revocationTreeRoot: this.issuerData.state.revocationTreeRoot.hex(),
973
+ value: this.issuerData.state.value.hex()
974
+ }
975
+ },
976
+ type: this.type,
977
+ coreClaim: this.coreClaim.hex(),
978
+ mtp: this.mtp.toJSON()
979
+ };
863
980
  }
864
- };
865
-
866
- // src/kms/key-providers/ed25519-provider.ts
867
- var import_ed25519 = require("@noble/curves/ed25519");
868
- var Ed25519Provider = class {
869
- /**
870
- * Creates an instance of Ed25519Provider.
871
- * @param {KmsKeyType} keyType - kms key type
872
- * @param {AbstractPrivateKeyStore} keyStore - key store for kms
873
- */
874
- constructor(keyType, _keyStore) {
875
- this.keyType = keyType;
876
- this._keyStore = _keyStore;
877
- }
878
- /**
879
- * get all keys
880
- * @returns list of keys
881
- */
882
- async list() {
883
- const allKeysFromKeyStore = await this._keyStore.list();
884
- return allKeysFromKeyStore.filter((key) => key.alias.startsWith(this.keyType));
885
- }
886
- /**
887
- * generates a ed25519 key from a seed phrase
888
- * @param {Uint8Array} seed - byte array seed
889
- * @returns {Promise<KmsKeyId>} kms key identifier
890
- */
891
- async newPrivateKeyFromSeed(seed) {
892
- if (seed.length !== 32) {
893
- throw new Error("Seed should be 32 bytes");
981
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
982
+ static fromJSON(obj) {
983
+ let mtp;
984
+ if (obj?.mtp?.notEmpties && obj?.mtp?.depth && obj?.mtp?.siblings) {
985
+ const ne = obj?.mtp?.notEmpties;
986
+ const notEmpties = ne instanceof Uint8Array ? ne : new Uint8Array(Object.values(ne));
987
+ const siblingsHashes = obj?.mtp?.siblings.map(
988
+ (h) => import_js_merkletree2.Hash.fromString(JSON.stringify(h))
989
+ );
990
+ const allSiblings = import_js_merkletree2.Proof.buildAllSiblings(obj?.mtp?.depth, notEmpties, siblingsHashes);
991
+ let nodeAux = obj.mtp.nodeAux || obj.mtp.node_aux;
992
+ if (nodeAux) {
993
+ nodeAux = {
994
+ key: import_js_merkletree2.Hash.fromString(JSON.stringify(nodeAux.key)),
995
+ value: import_js_merkletree2.Hash.fromString(JSON.stringify(nodeAux.value))
996
+ };
997
+ }
998
+ mtp = new import_js_merkletree2.Proof({ existence: obj?.mtp.existence, nodeAux, siblings: allSiblings });
999
+ } else {
1000
+ mtp = import_js_merkletree2.Proof.fromJSON(obj.mtp);
894
1001
  }
895
- const publicKey = import_ed25519.ed25519.getPublicKey(seed);
896
- const kmsId = {
897
- type: this.keyType,
898
- id: keyPath(this.keyType, bytesToHex(publicKey))
899
- };
900
- await this._keyStore.importKey({
901
- alias: kmsId.id,
902
- key: bytesToHex(seed)
1002
+ return new _Iden3SparseMerkleTreeProof({
1003
+ coreClaim: new import_js_iden3_core2.Claim().fromHex(obj.coreClaim),
1004
+ mtp,
1005
+ issuerData: {
1006
+ id: import_js_iden3_core2.DID.parse(obj.issuerData.id),
1007
+ state: {
1008
+ ...obj.issuerData.state,
1009
+ rootOfRoots: import_js_merkletree2.Hash.fromHex(obj.issuerData.state.rootOfRoots),
1010
+ claimsTreeRoot: import_js_merkletree2.Hash.fromHex(obj.issuerData.state.claimsTreeRoot),
1011
+ revocationTreeRoot: import_js_merkletree2.Hash.fromHex(obj.issuerData.state.revocationTreeRoot),
1012
+ value: import_js_merkletree2.Hash.fromHex(obj.issuerData.state.value)
1013
+ }
1014
+ }
903
1015
  });
904
- return kmsId;
905
- }
906
- /**
907
- * Gets public key by kmsKeyId
908
- * @param {KmsKeyId} keyId - key identifier
909
- * @returns {Promise<string>} Public key as a hex string
910
- */
911
- async publicKey(keyId) {
912
- const privateKeyHex = await this.privateKey(keyId);
913
- const publicKey = import_ed25519.ed25519.getPublicKey(privateKeyHex);
914
- return bytesToHex(publicKey);
915
1016
  }
916
- /**
917
- * signs prepared payload of size,
918
- * with a key id
919
- * @param {KmsKeyId} keyId - key identifier
920
- * @param {Uint8Array} digest - data to sign (32 bytes)
921
- * @returns {Promise<Uint8Array>} signature
922
- */
923
- async sign(keyId, digest) {
924
- const privateKeyHex = await this.privateKey(keyId);
925
- return import_ed25519.ed25519.sign(digest, privateKeyHex);
1017
+ };
1018
+ var BJJSignatureProof2021 = class _BJJSignatureProof2021 {
1019
+ type;
1020
+ issuerData;
1021
+ signature;
1022
+ coreClaim;
1023
+ constructor(obj) {
1024
+ this.type = "BJJSignature2021" /* BJJSignature */;
1025
+ this.issuerData = obj.issuerData;
1026
+ this.coreClaim = obj.coreClaim;
1027
+ this.signature = obj.signature;
926
1028
  }
927
1029
  /**
928
- * Verifies a signature for the given message and key identifier.
929
- * @param digest - The message to verify the signature against.
930
- * @param signatureHex - The signature to verify, as a hexadecimal string.
931
- * @param keyId - The key identifier to use for verification.
932
- * @returns A Promise that resolves to a boolean indicating whether the signature is valid.
1030
+ * toJSON is a method to serialize BJJSignatureProof2021 to json
1031
+ *
1032
+ * @returns `json object in serialized presentation`
933
1033
  */
934
- async verify(digest, signatureHex, keyId) {
935
- const publicKeyHex = await this.publicKey(keyId);
936
- return import_ed25519.ed25519.verify(signatureHex, digest, publicKeyHex);
1034
+ toJSON() {
1035
+ return {
1036
+ issuerData: {
1037
+ id: this.issuerData.id.string(),
1038
+ state: {
1039
+ ...this.issuerData.state,
1040
+ rootOfRoots: this.issuerData.state.rootOfRoots.hex(),
1041
+ claimsTreeRoot: this.issuerData.state.claimsTreeRoot.hex(),
1042
+ revocationTreeRoot: this.issuerData.state.revocationTreeRoot.hex(),
1043
+ value: this.issuerData.state.value.hex()
1044
+ },
1045
+ mtp: this.issuerData.mtp.toJSON(),
1046
+ authCoreClaim: this.issuerData.authCoreClaim.hex(),
1047
+ credentialStatus: this.issuerData.credentialStatus
1048
+ },
1049
+ type: this.type,
1050
+ coreClaim: this.coreClaim.hex(),
1051
+ signature: import_js_crypto3.Hex.encodeString(this.signature.compress())
1052
+ };
937
1053
  }
938
1054
  /**
939
- * Retrieves the private key for a given keyId from the key store.
940
- * @param {KmsKeyId} keyId - The identifier of the key to retrieve.
941
- * @returns {Promise<string>} The private key associated with the keyId.
1055
+ * fromJSON is a method to deserialize BJJSignatureProof2021 from json
1056
+ * @param obj
942
1057
  */
943
- async privateKey(keyId) {
944
- return this._keyStore.get({ alias: keyId.id });
1058
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1059
+ static fromJSON(obj) {
1060
+ return new _BJJSignatureProof2021({
1061
+ issuerData: {
1062
+ id: import_js_iden3_core2.DID.parse(obj.issuerData.id),
1063
+ mtp: import_js_merkletree2.Proof.fromJSON(obj.issuerData.mtp),
1064
+ state: {
1065
+ ...obj.issuerData.state,
1066
+ rootOfRoots: import_js_merkletree2.Hash.fromHex(obj.issuerData.state.rootOfRoots),
1067
+ claimsTreeRoot: import_js_merkletree2.Hash.fromHex(obj.issuerData.state.claimsTreeRoot),
1068
+ revocationTreeRoot: import_js_merkletree2.Hash.fromHex(obj.issuerData.state.revocationTreeRoot),
1069
+ value: import_js_merkletree2.Hash.fromHex(obj.issuerData.state.value)
1070
+ },
1071
+ credentialStatus: obj.issuerData.credentialStatus,
1072
+ authCoreClaim: new import_js_iden3_core2.Claim().fromHex(obj.issuerData.authCoreClaim)
1073
+ },
1074
+ coreClaim: new import_js_iden3_core2.Claim().fromHex(obj.coreClaim),
1075
+ signature: import_js_crypto3.Signature.newFromCompressed(
1076
+ Uint8Array.from(import_js_crypto3.Hex.decodeString(obj.signature)).slice(0, 64)
1077
+ )
1078
+ });
945
1079
  }
946
1080
  };
947
1081
 
948
- // src/kms/key-providers/secp256k1-provider.ts
949
- var import_secp256k1 = require("@noble/curves/secp256k1");
1082
+ // src/verifiable/credential.ts
1083
+ var import_js_iden3_core5 = require("@iden3/js-iden3-core");
1084
+ var import_js_merkletree3 = require("@iden3/js-merkletree");
1085
+ var import_js_jsonld_merklization2 = require("@iden3/js-jsonld-merklization");
1086
+ var import_js_crypto5 = require("@iden3/js-crypto");
1087
+
1088
+ // src/credentials/utils.ts
1089
+ var import_js_iden3_core3 = require("@iden3/js-iden3-core");
950
1090
  var import_js_crypto4 = require("@iden3/js-crypto");
951
- var import_did_jwt = require("did-jwt");
952
- var Sec256k1Provider = class {
953
- /**
954
- * key type that is handled by BJJ Provider
955
- * @type {KmsKeyType}
956
- */
957
- keyType;
958
- _keyStore;
959
- /**
960
- * Creates an instance of BjjProvider.
961
- * @param {KmsKeyType} keyType - kms key type
962
- * @param {AbstractPrivateKeyStore} keyStore - key store for kms
963
- */
964
- constructor(keyType, keyStore) {
965
- if (keyType !== "Secp256k1" /* Secp256k1 */) {
966
- throw new Error("Key type must be Secp256k1");
967
- }
968
- this.keyType = keyType;
969
- this._keyStore = keyStore;
970
- }
971
- /**
972
- * get all keys
973
- * @returns list of keys
974
- */
975
- async list() {
976
- const allKeysFromKeyStore = await this._keyStore.list();
977
- return allKeysFromKeyStore.filter((key) => key.alias.startsWith(this.keyType));
978
- }
979
- /**
980
- * generates a baby jub jub key from a seed phrase
981
- * @param {Uint8Array} seed - byte array seed
982
- * @returns kms key identifier
983
- */
984
- async newPrivateKeyFromSeed(seed) {
985
- if (seed.length !== 32) {
986
- throw new Error("Seed should be 32 bytes");
987
- }
988
- const publicKey = import_secp256k1.secp256k1.getPublicKey(seed);
989
- const kmsId = {
990
- type: this.keyType,
991
- id: keyPath(this.keyType, bytesToHex(publicKey))
992
- };
993
- await this._keyStore.importKey({
994
- alias: kmsId.id,
995
- key: bytesToHex(seed).padStart(64, "0")
996
- });
997
- return kmsId;
998
- }
999
- /**
1000
- * Gets public key by kmsKeyId
1001
- *
1002
- * @param {KmsKeyId} keyId - key identifier
1003
- */
1004
- async publicKey(keyId) {
1005
- const privateKeyHex = await this.privateKey(keyId);
1006
- const publicKey = import_secp256k1.secp256k1.getPublicKey(privateKeyHex, false);
1007
- return bytesToHex(publicKey);
1008
- }
1009
- /**
1010
- * Signs the given data using the private key associated with the specified key identifier.
1011
- * @param keyId - The key identifier to use for signing.
1012
- * @param data - The data to sign.
1013
- * @param opts - Signing options, such as the algorithm to use.
1014
- * @returns A Promise that resolves to the signature as a Uint8Array.
1015
- */
1016
- async sign(keyId, data, opts = { alg: "ES256K" }) {
1017
- const privateKeyHex = await this.privateKey(keyId);
1018
- const signatureBase64 = await (0, import_did_jwt.ES256KSigner)(
1019
- (0, import_did_jwt.hexToBytes)(privateKeyHex),
1020
- opts.alg === "ES256K-R"
1021
- )(data);
1022
- if (typeof signatureBase64 !== "string") {
1023
- throw new Error("signatureBase64 must be a string");
1024
- }
1025
- return base64UrlToBytes(signatureBase64);
1091
+ var getUserDIDFromCredential = (issuerDID, credential) => {
1092
+ if (!credential.credentialSubject.id) {
1093
+ return issuerDID;
1026
1094
  }
1027
- /**
1028
- * Verifies a signature for the given message and key identifier.
1029
- * @param message - The message to verify the signature against.
1030
- * @param signatureHex - The signature to verify, as a hexadecimal string.
1031
- * @param keyId - The key identifier to use for verification.
1032
- * @returns A Promise that resolves to a boolean indicating whether the signature is valid.
1033
- */
1034
- async verify(message, signatureHex, keyId) {
1035
- const publicKeyHex = await this.publicKey(keyId);
1036
- return import_secp256k1.secp256k1.verify(signatureHex, (0, import_js_crypto4.sha256)(message), publicKeyHex);
1095
+ if (typeof credential.credentialSubject.id !== "string") {
1096
+ throw new Error("credential subject `id` is not a string");
1037
1097
  }
1038
- async privateKey(keyId) {
1039
- return this._keyStore.get({ alias: keyId.id });
1098
+ return import_js_iden3_core3.DID.parse(credential.credentialSubject.id);
1099
+ };
1100
+ var getKMSIdByAuthCredential = (credential) => {
1101
+ if (!credential.type.includes("AuthBJJCredential")) {
1102
+ throw new Error("can't sign with not AuthBJJCredential credential");
1040
1103
  }
1104
+ const x = credential.credentialSubject["x"];
1105
+ const y = credential.credentialSubject["y"];
1106
+ const pb = new import_js_crypto4.PublicKey([BigInt(x), BigInt(y)]);
1107
+ const kp = keyPath("BJJ" /* BabyJubJub */, pb.hex());
1108
+ return { type: "BJJ" /* BabyJubJub */, id: kp };
1041
1109
  };
1042
1110
 
1043
- // src/identity/identity-wallet.ts
1044
- var import_js_iden3_core40 = require("@iden3/js-iden3-core");
1045
- var import_js_crypto12 = require("@iden3/js-crypto");
1046
- var import_js_merkletree29 = require("@iden3/js-merkletree");
1047
-
1048
- // src/identity/common.ts
1049
- var import_js_iden3_core7 = require("@iden3/js-iden3-core");
1050
-
1051
- // src/verifiable/proof.ts
1052
- var import_js_merkletree2 = require("@iden3/js-merkletree");
1053
-
1054
- // src/verifiable/constants.ts
1055
- var VerifiableConstants = Object.freeze({
1056
- ERRORS: {
1057
- FiELD_IS_EMPTY: "fieldPath is empty",
1058
- CONTEXT_TYPE_IS_EMPTY: "ctxType is empty",
1059
- // ErrStateNotFound issuer state is genesis state.
1060
- IDENTITY_DOES_NOT_EXIST: "Identity does not exist",
1061
- IDENTITY_DOES_NOT_EXIST_CUSTOM_ERROR: "IdentityDoesNotExist",
1062
- NO_AUTH_CRED_FOUND: "no auth credentials found",
1063
- STATE_DOES_NOT_EXIST: "State does not exist",
1064
- STATE_DOES_NOT_EXIST_CUSTOM_ERROR: "StateDoesNotExist",
1065
- ROOT_DOES_NOT_EXIST: "Root does not exist",
1066
- ROOT_DOES_NOT_EXIST_CUSTOM_ERROR: "RootDoesNotExist",
1067
- // identity wallet
1068
- ID_WALLET_NO_CREDENTIAL_SATISFIED_QUERY: "no credential satisfied query",
1069
- ID_WALLET_SIGNER_IS_REQUIRED: "Ethereum signer is required to create Ethereum identities in order to transit state",
1070
- ID_WALLET_PROVER_IS_REQUIRED: "prover is required to generate proofs for non ethereum identities",
1071
- ID_WALLET_CORE_CLAIM_REQUIRED_IN_SIG_PROOF: "credential must have coreClaim representation in the signature proof",
1072
- ID_WALLET_CORE_CLAIM_REQUIRED_IN_ANY_PROOF: "credential must have coreClaim representation in proofs",
1073
- ID_WALLET_CORE_CLAIM_MISMATCH: "core claim representations is set in both proofs but they are not equal",
1074
- ID_WALLET_CORE_CLAIM_IS_NOT_SET: "core claim is not set in credential proofs",
1075
- ID_WALLET_PROFILE_OR_IDENTITY_NOT_FOUND: "profile or identity not found",
1076
- ID_WALLET_PROFILE_ALREADY_EXISTS: "profile with given nonce or verifier already exists",
1077
- ID_WALLET_PROFILE_ALREADY_EXISTS_VERIFIER_TAGS: "profile with given verifier and tags already exists",
1078
- ID_WALLET_ISSUER_AUTH_BJJ_CRED_MUST_HAVE_ANY_PROOF: "issuer auth credential must have proof",
1079
- ID_WALLET_ISSUER_AUTH_BJJ_CRED_MUST_HAVE_MTP_PROOF: "mtp is required for auth bjj key to issue new credentials",
1080
- // proof service
1081
- PROOF_SERVICE_NO_CREDENTIAL_FOR_IDENTITY_OR_PROFILE: "no credentials belong to did or its profiles",
1082
- PROOF_SERVICE_NO_CREDENTIAL_FOR_QUERY: "credential not found for query",
1083
- PROOF_SERVICE_PROFILE_GENESIS_DID_MISMATCH: "subject and auth profiles are not derived from the same did",
1084
- PROOF_SERVICE_NO_QUERIES_IN_ZKP_REQUEST: "no queries in zkp request",
1085
- // credential wallet
1086
- CREDENTIAL_WALLET_ALL_CREDENTIALS_ARE_REVOKED: "all claims are revoked"
1087
- },
1088
- CREDENTIAL_TYPE: {
1089
- // VerifiableCredential is a W3C verifiable credential type
1090
- W3C_VERIFIABLE_CREDENTIAL: "VerifiableCredential",
1091
- W3C_VERIFIABLE_PRESENTATION: "VerifiablePresentation"
1092
- },
1093
- CREDENTIAL_SUBJECT_PATH: "https://www.w3.org/2018/credentials#credentialSubject",
1094
- JSONLD_SCHEMA: {
1095
- // JSONLDSchemaIden3Credential is a schema for context with Iden3Credential type
1096
- IDEN3_CREDENTIAL: "https://schema.iden3.io/core/jsonld/iden3proofs.jsonld",
1097
- // JSONLDSchemaIden3DisplayMethod is a schema for context with Iden3BasicDisplayMethodV1 type
1098
- IDEN3_DISPLAY_METHOD: "https://schema.iden3.io/core/jsonld/displayMethod.jsonld",
1099
- // JSONLDSchemaW3CCredential2018 is a schema for context with VerifiableCredential type
1100
- W3C_CREDENTIAL_2018: "https://www.w3.org/2018/credentials/v1",
1101
- W3C_VC_DOCUMENT_2018: `{"@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","VerifiableCredential":{"@id":"https://www.w3.org/2018/credentials#VerifiableCredential","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","cred":"https://www.w3.org/2018/credentials#","sec":"https://w3id.org/security#","xsd":"http://www.w3.org/2001/XMLSchema#","credentialSchema":{"@id":"cred:credentialSchema","@type":"@id","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","cred":"https://www.w3.org/2018/credentials#","JsonSchemaValidator2018":"cred:JsonSchemaValidator2018"}},"credentialStatus":{"@id":"cred:credentialStatus","@type":"@id"},"credentialSubject":{"@id":"cred:credentialSubject","@type":"@id"},"evidence":{"@id":"cred:evidence","@type":"@id"},"expirationDate":{"@id":"cred:expirationDate","@type":"xsd:dateTime"},"holder":{"@id":"cred:holder","@type":"@id"},"issued":{"@id":"cred:issued","@type":"xsd:dateTime"},"issuer":{"@id":"cred:issuer","@type":"@id"},"issuanceDate":{"@id":"cred:issuanceDate","@type":"xsd:dateTime"},"proof":{"@id":"sec:proof","@type":"@id","@container":"@graph"},"refreshService":{"@id":"cred:refreshService","@type":"@id","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","cred":"https://www.w3.org/2018/credentials#","ManualRefreshService2018":"cred:ManualRefreshService2018"}},"termsOfUse":{"@id":"cred:termsOfUse","@type":"@id"},"validFrom":{"@id":"cred:validFrom","@type":"xsd:dateTime"},"validUntil":{"@id":"cred:validUntil","@type":"xsd:dateTime"}}},"VerifiablePresentation":{"@id":"https://www.w3.org/2018/credentials#VerifiablePresentation","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","cred":"https://www.w3.org/2018/credentials#","sec":"https://w3id.org/security#","holder":{"@id":"cred:holder","@type":"@id"},"proof":{"@id":"sec:proof","@type":"@id","@container":"@graph"},"verifiableCredential":{"@id":"cred:verifiableCredential","@type":"@id","@container":"@graph"}}},"EcdsaSecp256k1Signature2019":{"@id":"https://w3id.org/security#EcdsaSecp256k1Signature2019","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","sec":"https://w3id.org/security#","xsd":"http://www.w3.org/2001/XMLSchema#","challenge":"sec:challenge","created":{"@id":"http://purl.org/dc/terms/created","@type":"xsd:dateTime"},"domain":"sec:domain","expires":{"@id":"sec:expiration","@type":"xsd:dateTime"},"jws":"sec:jws","nonce":"sec:nonce","proofPurpose":{"@id":"sec:proofPurpose","@type":"@vocab","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","sec":"https://w3id.org/security#","assertionMethod":{"@id":"sec:assertionMethod","@type":"@id","@container":"@set"},"authentication":{"@id":"sec:authenticationMethod","@type":"@id","@container":"@set"}}},"proofValue":"sec:proofValue","verificationMethod":{"@id":"sec:verificationMethod","@type":"@id"}}},"EcdsaSecp256r1Signature2019":{"@id":"https://w3id.org/security#EcdsaSecp256r1Signature2019","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","sec":"https://w3id.org/security#","xsd":"http://www.w3.org/2001/XMLSchema#","challenge":"sec:challenge","created":{"@id":"http://purl.org/dc/terms/created","@type":"xsd:dateTime"},"domain":"sec:domain","expires":{"@id":"sec:expiration","@type":"xsd:dateTime"},"jws":"sec:jws","nonce":"sec:nonce","proofPurpose":{"@id":"sec:proofPurpose","@type":"@vocab","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","sec":"https://w3id.org/security#","assertionMethod":{"@id":"sec:assertionMethod","@type":"@id","@container":"@set"},"authentication":{"@id":"sec:authenticationMethod","@type":"@id","@container":"@set"}}},"proofValue":"sec:proofValue","verificationMethod":{"@id":"sec:verificationMethod","@type":"@id"}}},"Ed25519Signature2018":{"@id":"https://w3id.org/security#Ed25519Signature2018","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","sec":"https://w3id.org/security#","xsd":"http://www.w3.org/2001/XMLSchema#","challenge":"sec:challenge","created":{"@id":"http://purl.org/dc/terms/created","@type":"xsd:dateTime"},"domain":"sec:domain","expires":{"@id":"sec:expiration","@type":"xsd:dateTime"},"jws":"sec:jws","nonce":"sec:nonce","proofPurpose":{"@id":"sec:proofPurpose","@type":"@vocab","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","sec":"https://w3id.org/security#","assertionMethod":{"@id":"sec:assertionMethod","@type":"@id","@container":"@set"},"authentication":{"@id":"sec:authenticationMethod","@type":"@id","@container":"@set"}}},"proofValue":"sec:proofValue","verificationMethod":{"@id":"sec:verificationMethod","@type":"@id"}}},"RsaSignature2018":{"@id":"https://w3id.org/security#RsaSignature2018","@context":{"@version":1.1,"@protected":true,"challenge":"sec:challenge","created":{"@id":"http://purl.org/dc/terms/created","@type":"xsd:dateTime"},"domain":"sec:domain","expires":{"@id":"sec:expiration","@type":"xsd:dateTime"},"jws":"sec:jws","nonce":"sec:nonce","proofPurpose":{"@id":"sec:proofPurpose","@type":"@vocab","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","sec":"https://w3id.org/security#","assertionMethod":{"@id":"sec:assertionMethod","@type":"@id","@container":"@set"},"authentication":{"@id":"sec:authenticationMethod","@type":"@id","@container":"@set"}}},"proofValue":"sec:proofValue","verificationMethod":{"@id":"sec:verificationMethod","@type":"@id"}}},"proof":{"@id":"https://w3id.org/security#proof","@type":"@id","@container":"@graph"}}}`,
1102
- IDEN3_PROOFS_DEFINITION_DOCUMENT: `{"@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","Iden3SparseMerkleTreeProof":{"@id":"https://schema.iden3.io/core/jsonld/iden3proofs.jsonld#Iden3SparseMerkleTreeProof","@context":{"@version":1.1,"@protected":true,"@propagate":true,"id":"@id","type":"@type","sec":"https://w3id.org/security#","@vocab":"https://schema.iden3.io/core/vocab/Iden3SparseMerkleTreeProof.md#","xsd":"http://www.w3.org/2001/XMLSchema#","mtp":{"@id":"https://schema.iden3.io/core/jsonld/iden3proofs.jsonld#SparseMerkleTreeProof","@type":"SparseMerkleTreeProof"},"coreClaim":{"@id":"coreClaim","@type":"xsd:string"},"issuerData":{"@id":"issuerData","@context":{"@version":1.1,"state":{"@id":"state","@context":{"txId":{"@id":"txId","@type":"xsd:string"},"blockTimestamp":{"@id":"blockTimestamp","@type":"xsd:integer"},"blockNumber":{"@id":"blockNumber","@type":"xsd:integer"},"rootOfRoots":{"@id":"rootOfRoots","@type":"xsd:string"},"claimsTreeRoot":{"@id":"claimsTreeRoot","@type":"xsd:string"},"revocationTreeRoot":{"@id":"revocationTreeRoot","@type":"xsd:string"},"authCoreClaim":{"@id":"authCoreClaim","@type":"xsd:string"},"value":{"@id":"value","@type":"xsd:string"}}}}}}},"SparseMerkleTreeProof":{"@id":"https://schema.iden3.io/core/jsonld/iden3proofs.jsonld#SparseMerkleTreeProof","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","sec":"https://w3id.org/security#","smt-proof-vocab":"https://schema.iden3.io/core/vocab/SparseMerkleTreeProof.md#","xsd":"http://www.w3.org/2001/XMLSchema#","existence":{"@id":"smt-proof-vocab:existence","@type":"xsd:boolean"},"revocationNonce":{"@id":"smt-proof-vocab:revocationNonce","@type":"xsd:number"},"siblings":{"@id":"smt-proof-vocab:siblings","@container":"@list"},"nodeAux":"@nest","hIndex":{"@id":"smt-proof-vocab:hIndex","@nest":"nodeAux","@type":"xsd:string"},"hValue":{"@id":"smt-proof-vocab:hValue","@nest":"nodeAux","@type":"xsd:string"}}},"BJJSignature2021":{"@id":"https://schema.iden3.io/core/jsonld/iden3proofs.jsonld#BJJSignature2021","@context":{"@version":1.1,"@protected":true,"id":"@id","@vocab":"https://schema.iden3.io/core/vocab/BJJSignature2021.md#","@propagate":true,"type":"@type","xsd":"http://www.w3.org/2001/XMLSchema#","coreClaim":{"@id":"coreClaim","@type":"xsd:string"},"issuerData":{"@id":"issuerData","@context":{"@version":1.1,"authCoreClaim":{"@id":"authCoreClaim","@type":"xsd:string"},"mtp":{"@id":"https://schema.iden3.io/core/jsonld/iden3proofs.jsonld#SparseMerkleTreeProof","@type":"SparseMerkleTreeProof"},"revocationStatus":{"@id":"revocationStatus","@type":"@id"},"state":{"@id":"state","@context":{"@version":1.1,"rootOfRoots":{"@id":"rootOfRoots","@type":"xsd:string"},"claimsTreeRoot":{"@id":"claimsTreeRoot","@type":"xsd:string"},"revocationTreeRoot":{"@id":"revocationTreeRoot","@type":"xsd:string"},"value":{"@id":"value","@type":"xsd:string"}}}}},"signature":{"@id":"signature","@type":"https://w3id.org/security#multibase"},"domain":"https://w3id.org/security#domain","creator":{"@id":"creator","@type":"http://www.w3.org/2001/XMLSchema#string"},"challenge":"https://w3id.org/security#challenge","created":{"@id":"created","@type":"http://www.w3.org/2001/XMLSchema#dateTime"},"expires":{"@id":"https://w3id.org/security#expiration","@type":"http://www.w3.org/2001/XMLSchema#dateTime"},"nonce":"https://w3id.org/security#nonce","proofPurpose":{"@id":"https://w3id.org/security#proofPurpose","@type":"@vocab","@context":{"@protected":true,"id":"@id","type":"@type","assertionMethod":{"@id":"https://w3id.org/security#assertionMethod","@type":"@id","@container":"@set"},"authentication":{"@id":"https://w3id.org/security#authenticationMethod","@type":"@id","@container":"@set"},"capabilityInvocation":{"@id":"https://w3id.org/security#capabilityInvocationMethod","@type":"@id","@container":"@set"},"capabilityDelegation":{"@id":"https://w3id.org/security#capabilityDelegationMethod","@type":"@id","@container":"@set"},"keyAgreement":{"@id":"https://w3id.org/security#keyAgreementMethod","@type":"@id","@container":"@set"}}},"proofValue":{"@id":"https://w3id.org/security#proofValue","@type":"https://w3id.org/security#multibase"},"verificationMethod":{"@id":"https://w3id.org/security#verificationMethod","@type":"@id"}}},"Iden3ReverseSparseMerkleTreeProof":{"@id":"https://schema.iden3.io/core/jsonld/iden3proofs.jsonld#Iden3ReverseSparseMerkleTreeProof","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","iden3-reverse-sparse-merkle-tree-proof-vocab":"https://schema.iden3.io/core/vocab/Iden3ReverseSparseMerkleTreeProof.md#","xsd":"http://www.w3.org/2001/XMLSchema#","revocationNonce":{"@id":"iden3-reverse-sparse-merkle-tree-proof-vocab:revocationNonce","@type":"xsd:integer"},"statusIssuer":{"@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type"},"@id":"iden3-reverse-sparse-merkle-tree-proof-vocab:statusIssuer"}}},"Iden3commRevocationStatusV1.0":{"@id":"https://schema.iden3.io/core/jsonld/iden3proofs.jsonld#Iden3commRevocationStatusV1.0","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","iden3-comm-revocation-statusV1.0-vocab":"https://schema.iden3.io/core/vocab/Iden3commRevocationStatusV1.0.md#","xsd":"http://www.w3.org/2001/XMLSchema#","revocationNonce":{"@id":"iden3-comm-revocation-statusV1.0-vocab:revocationNonce","@type":"xsd:integer"},"statusIssuer":{"@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type"},"@id":"iden3-comm-revocation-statusV1.0-vocab:statusIssuer"}}},"Iden3OnchainSparseMerkleTreeProof2023":{"@id":"https://schema.iden3.io/core/jsonld/iden3proofs.jsonld#Iden3OnchainSparseMerkleTreeProof2023","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","iden3-onchain-sparse-merkle-tree-proof-2023-vocab":"https://schema.iden3.io/core/vocab/Iden3OnchainSparseMerkleTreeProof2023.md#","xsd":"http://www.w3.org/2001/XMLSchema#","revocationNonce":{"@id":"iden3-onchain-sparse-merkle-tree-proof-2023-vocab:revocationNonce","@type":"xsd:integer"},"statusIssuer":{"@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type"},"@id":"iden3-onchain-sparse-merkle-tree-proof-2023-vocab:statusIssuer"}}},"JsonSchema2023":"https://www.w3.org/ns/credentials#JsonSchema2023","Iden3RefreshService2023":"https://schema.iden3.io/core/jsonld/iden3proofs.jsonld#Iden3RefreshService2023"}}`,
1103
- IDEN3_DISPLAY_METHOD_DEFINITION_DOCUMENT: `{"@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","displayMethod":{"@id":"https://schema.iden3.io/core/vocab/displayMethod.md#displayMethod","@type":"@id","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","Iden3BasicDisplayMethodV1":"https://schema.iden3.io/core/vocab/displayMethod.md#Iden3BasicDisplayMethodV1"}}}}`
1104
- },
1105
- // JsonSchema2023 JSON schema for verification of Iden3Credential
1106
- JSON_SCHEMA_VALIDATOR: "JsonSchema2023",
1107
- SERVICE_TYPE: {
1108
- // Iden3CommServiceType is service type for iden3comm protocol
1109
- IDEN3_COMM: "iden3-communication",
1110
- // PushNotificationServiceType is service type for delivering push notifications to identity
1111
- PUSH_NOTIFICATION: "push-notification"
1112
- },
1113
- AUTH: {
1114
- AUTH_BJJ_CREDENTIAL_HASH: "013fd3f623559d850fb5b02ff012d0e2",
1115
- AUTH_BJJ_CREDENTIAL_SCHEMA_JSON_URL: "https://schema.iden3.io/core/json/auth.json",
1116
- AUTH_BJJ_CREDENTIAL_SCHEMA_JSONLD_URL: "https://schema.iden3.io/core/jsonld/auth.jsonld",
1117
- AUTH_BJJ_CREDENTIAL_TYPE: "AuthBJJCredential",
1118
- AUTH_BJJ_CREDENTIAL_SCHEMA_JSON: `{"$schema":"http://json-schema.org/draft-07/schema#","$metadata":{"uris":{"jsonLdContext":"https://schema.iden3.io/core/jsonld/auth.jsonld","jsonSchema":"https://schema.iden3.io/core/json/auth.json"},"serialization":{"indexDataSlotA":"x","indexDataSlotB":"y"}},"type":"object","required":["@context","id","type","issuanceDate","credentialSubject","credentialSchema","credentialStatus","issuer"],"properties":{"@context":{"type":["string","array","object"]},"id":{"type":"string"},"type":{"type":["string","array"],"items":{"type":"string"}},"issuer":{"type":["string","object"],"format":"uri","required":["id"],"properties":{"id":{"type":"string","format":"uri"}}},"issuanceDate":{"type":"string","format":"date-time"},"expirationDate":{"type":"string","format":"date-time"},"credentialSchema":{"type":"object","required":["id","type"],"properties":{"id":{"type":"string","format":"uri"},"type":{"type":"string"}}},"credentialSubject":{"type":"object","required":["x","y"],"properties":{"id":{"title":"Credential Subject ID","type":"string","format":"uri"},"x":{"type":"string"},"y":{"type":"string"}}}}}`,
1119
- AUTH_BJJ_CREDENTIAL_SCHEMA_JSONLD: `{"@context":[{"@version":1.1,"@protected":true,"id":"@id","type":"@type","AuthBJJCredential":{"@id":"https://schema.iden3.io/core/jsonld/auth.jsonld#AuthBJJCredential","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","iden3_serialization":"iden3:v1:slotIndexA=x&slotIndexB=y","xsd":"http://www.w3.org/2001/XMLSchema#","auth-vocab":"https://schema.iden3.io/core/vocab/auth.md#","x":{"@id":"auth-vocab:x","@type":"xsd:positiveInteger"},"y":{"@id":"auth-vocab:y","@type":"xsd:positiveInteger"}}},"Iden3StateInfo2023":{"@id":"https://schema.iden3.io/core/jsonld/auth.jsonld#Iden3StateInfo2023","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","xsd":"http://www.w3.org/2001/XMLSchema#","@vocab":"https://schema.iden3.io/core/vocab/state-info.md#","@propagate":true,"stateContractAddress":{"@id":"stateContractAddress","@type":"xsd:string"},"published":{"@id":"published","@type":"xsd:boolean"},"info":{"@id":"info","@type":"@id","@context":{"@protected":true,"id":{"@id":"id","@type":"xsd:string"},"state":{"@id":"state","@type":"xsd:string"},"replacedByState":{"@id":"replacedByState","@type":"xsd:string"},"createdAtTimestamp":{"@id":"createdAtTimestamp","@type":"xsd:string"},"replacedAtTimestamp":{"@id":"replacedAtTimestamp","@type":"xsd:string"},"createdAtBlock":{"@id":"createdAtBlock","@type":"xsd:string"},"replacedAtBlock":{"@id":"replacedAtBlock","@type":"xsd:string"}}},"global":{"@id":"global","@type":"@id","@context":{"@protected":true,"sec":"https://w3id.org/security#","root":{"@id":"root","@type":"xsd:string"},"replacedByRoot":{"@id":"replacedByRoot","@type":"xsd:string"},"createdAtTimestamp":{"@id":"createdAtTimestamp","@type":"xsd:string"},"replacedAtTimestamp":{"@id":"replacedAtTimestamp","@type":"xsd:string"},"createdAtBlock":{"@id":"createdAtBlock","@type":"xsd:string"},"replacedAtBlock":{"@id":"replacedAtBlock","@type":"xsd:string"},"proof":{"@id":"sec:proof","@type":"@id","@container":"@graph"}}}}}}]}`
1120
- }
1121
- });
1122
- var ProofType = /* @__PURE__ */ ((ProofType2) => {
1123
- ProofType2["BJJSignature"] = "BJJSignature2021";
1124
- ProofType2["Iden3SparseMerkleTreeProof"] = "Iden3SparseMerkleTreeProof";
1125
- return ProofType2;
1126
- })(ProofType || {});
1127
- var CredentialStatusType = /* @__PURE__ */ ((CredentialStatusType2) => {
1128
- CredentialStatusType2["SparseMerkleTreeProof"] = "SparseMerkleTreeProof";
1129
- CredentialStatusType2["Iden3ReverseSparseMerkleTreeProof"] = "Iden3ReverseSparseMerkleTreeProof";
1130
- CredentialStatusType2["Iden3commRevocationStatusV1"] = "Iden3commRevocationStatusV1.0";
1131
- CredentialStatusType2["Iden3OnchainSparseMerkleTreeProof2023"] = "Iden3OnchainSparseMerkleTreeProof2023";
1132
- return CredentialStatusType2;
1133
- })(CredentialStatusType || {});
1134
- var ProofPurpose = /* @__PURE__ */ ((ProofPurpose2) => {
1135
- ProofPurpose2["Authentication"] = "Authentication";
1136
- return ProofPurpose2;
1137
- })(ProofPurpose || {});
1138
- var MerklizedRootPosition = /* @__PURE__ */ ((MerklizedRootPosition4) => {
1139
- MerklizedRootPosition4["Index"] = "index";
1140
- MerklizedRootPosition4["Value"] = "value";
1141
- MerklizedRootPosition4["None"] = "";
1142
- return MerklizedRootPosition4;
1143
- })(MerklizedRootPosition || {});
1144
- var SubjectPosition = /* @__PURE__ */ ((SubjectPosition2) => {
1145
- SubjectPosition2["None"] = "";
1146
- SubjectPosition2["Index"] = "index";
1147
- SubjectPosition2["Value"] = "value";
1148
- return SubjectPosition2;
1149
- })(SubjectPosition || {});
1150
- var RefreshServiceType = /* @__PURE__ */ ((RefreshServiceType2) => {
1151
- RefreshServiceType2["Iden3RefreshService2023"] = "Iden3RefreshService2023";
1152
- return RefreshServiceType2;
1153
- })(RefreshServiceType || {});
1154
- var PaymentRequestDataType = /* @__PURE__ */ ((PaymentRequestDataType2) => {
1155
- PaymentRequestDataType2["Iden3PaymentRequestCryptoV1"] = "Iden3PaymentRequestCryptoV1";
1156
- PaymentRequestDataType2["Iden3PaymentRailsRequestV1"] = "Iden3PaymentRailsRequestV1";
1157
- PaymentRequestDataType2["Iden3PaymentRailsERC20RequestV1"] = "Iden3PaymentRailsERC20RequestV1";
1158
- return PaymentRequestDataType2;
1159
- })(PaymentRequestDataType || {});
1160
- var PaymentType = /* @__PURE__ */ ((PaymentType2) => {
1161
- PaymentType2["Iden3PaymentCryptoV1"] = "Iden3PaymentCryptoV1";
1162
- PaymentType2["Iden3PaymentRailsV1"] = "Iden3PaymentRailsV1";
1163
- PaymentType2["Iden3PaymentRailsERC20V1"] = "Iden3PaymentRailsERC20V1";
1164
- return PaymentType2;
1165
- })(PaymentType || {});
1166
- var SupportedPaymentProofType = /* @__PURE__ */ ((SupportedPaymentProofType2) => {
1167
- SupportedPaymentProofType2["EthereumEip712Signature2021"] = "EthereumEip712Signature2021";
1168
- return SupportedPaymentProofType2;
1169
- })(SupportedPaymentProofType || {});
1170
- var SupportedCurrencies = /* @__PURE__ */ ((SupportedCurrencies2) => {
1171
- SupportedCurrencies2["ETH"] = "ETH";
1172
- SupportedCurrencies2["ETH_WEI"] = "ETHWEI";
1173
- SupportedCurrencies2["ETH_GWEI"] = "ETHGWEI";
1174
- SupportedCurrencies2["MATIC"] = "MATIC";
1175
- SupportedCurrencies2["POL"] = "POL";
1176
- return SupportedCurrencies2;
1177
- })(SupportedCurrencies || {});
1178
- var PaymentFeatures = /* @__PURE__ */ ((PaymentFeatures2) => {
1179
- PaymentFeatures2["EIP_2612"] = "EIP-2612";
1180
- return PaymentFeatures2;
1181
- })(PaymentFeatures || {});
1182
- var DisplayMethodType = /* @__PURE__ */ ((DisplayMethodType2) => {
1183
- DisplayMethodType2["Iden3BasicDisplayMethodV1"] = "Iden3BasicDisplayMethodV1";
1184
- return DisplayMethodType2;
1185
- })(DisplayMethodType || {});
1186
- var DEFAULT_CACHE_MAX_SIZE = 1e4;
1187
-
1188
- // src/verifiable/proof.ts
1189
- var import_js_crypto5 = require("@iden3/js-crypto");
1190
- var import_js_iden3_core3 = require("@iden3/js-iden3-core");
1191
- var Iden3SparseMerkleTreeProof = class _Iden3SparseMerkleTreeProof {
1192
- type;
1193
- issuerData;
1194
- mtp;
1195
- coreClaim;
1196
- /**
1197
- * Creates an instance of Iden3SparseMerkleTreeProof.
1198
- * @param {object} obj
1199
- */
1200
- constructor(obj) {
1201
- this.coreClaim = obj.coreClaim;
1202
- this.issuerData = obj.issuerData;
1203
- this.type = "Iden3SparseMerkleTreeProof" /* Iden3SparseMerkleTreeProof */;
1204
- this.mtp = obj.mtp;
1111
+ // src/verifiable/core-utils.ts
1112
+ var import_js_iden3_core4 = require("@iden3/js-iden3-core");
1113
+ var import_js_jsonld_merklization = require("@iden3/js-jsonld-merklization");
1114
+ var import_jsonld = __toESM(require("jsonld"), 1);
1115
+ var import_ethers2 = require("ethers");
1116
+ var credentialSubjectKey = "credentialSubject";
1117
+ var contextFullKey = "@context";
1118
+ var serializationFullKey = "iden3_serialization";
1119
+ var fieldPrefix = "iden3:v1:";
1120
+ var credentialSubjectFullKey = "https://www.w3.org/2018/credentials#credentialSubject";
1121
+ var verifiableCredentialFullKey = "https://www.w3.org/2018/credentials#VerifiableCredential";
1122
+ var typeFullKey = "@type";
1123
+ var getFieldSlotIndex = async (field, typeName, schemaBytes) => {
1124
+ let ctxDoc = JSON.parse(byteDecoder.decode(schemaBytes));
1125
+ ctxDoc = ctxDoc[contextFullKey];
1126
+ if (ctxDoc === void 0) {
1127
+ throw new Error("document has no @context");
1205
1128
  }
1206
- /**
1207
- *
1208
- *
1209
- * @returns `json object in serialized presentation`
1210
- */
1211
- toJSON() {
1212
- const issuerId = this.issuerData.id;
1213
- return {
1214
- issuerData: {
1215
- id: issuerId.string(),
1216
- state: {
1217
- ...this.issuerData.state,
1218
- rootOfRoots: this.issuerData.state.rootOfRoots.hex(),
1219
- claimsTreeRoot: this.issuerData.state.claimsTreeRoot.hex(),
1220
- revocationTreeRoot: this.issuerData.state.revocationTreeRoot.hex(),
1221
- value: this.issuerData.state.value.hex()
1222
- }
1223
- },
1224
- type: this.type,
1225
- coreClaim: this.coreClaim.hex(),
1226
- mtp: this.mtp.toJSON()
1227
- };
1129
+ const ldCtx = await import_jsonld.default.processContext(
1130
+ await import_jsonld.default.processContext(null, null, {}),
1131
+ ctxDoc,
1132
+ {}
1133
+ );
1134
+ const serAttr = await getSerializationAttrFromParsedContext(
1135
+ ldCtx,
1136
+ typeName
1137
+ );
1138
+ if (!serAttr) {
1139
+ throw new Error("serialization attribute is not set");
1228
1140
  }
1229
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1230
- static fromJSON(obj) {
1231
- let mtp;
1232
- if (obj?.mtp?.notEmpties && obj?.mtp?.depth && obj?.mtp?.siblings) {
1233
- const ne = obj?.mtp?.notEmpties;
1234
- const notEmpties = ne instanceof Uint8Array ? ne : new Uint8Array(Object.values(ne));
1235
- const siblingsHashes = obj?.mtp?.siblings.map(
1236
- (h) => import_js_merkletree2.Hash.fromString(JSON.stringify(h))
1237
- );
1238
- const allSiblings = import_js_merkletree2.Proof.buildAllSiblings(obj?.mtp?.depth, notEmpties, siblingsHashes);
1239
- let nodeAux = obj.mtp.nodeAux || obj.mtp.node_aux;
1240
- if (nodeAux) {
1241
- nodeAux = {
1242
- key: import_js_merkletree2.Hash.fromString(JSON.stringify(nodeAux.key)),
1243
- value: import_js_merkletree2.Hash.fromString(JSON.stringify(nodeAux.value))
1244
- };
1245
- }
1246
- mtp = new import_js_merkletree2.Proof({ existence: obj?.mtp.existence, nodeAux, siblings: allSiblings });
1247
- } else {
1248
- mtp = import_js_merkletree2.Proof.fromJSON(obj.mtp);
1249
- }
1250
- return new _Iden3SparseMerkleTreeProof({
1251
- coreClaim: new import_js_iden3_core3.Claim().fromHex(obj.coreClaim),
1252
- mtp,
1253
- issuerData: {
1254
- id: import_js_iden3_core3.DID.parse(obj.issuerData.id),
1255
- state: {
1256
- ...obj.issuerData.state,
1257
- rootOfRoots: import_js_merkletree2.Hash.fromHex(obj.issuerData.state.rootOfRoots),
1258
- claimsTreeRoot: import_js_merkletree2.Hash.fromHex(obj.issuerData.state.claimsTreeRoot),
1259
- revocationTreeRoot: import_js_merkletree2.Hash.fromHex(obj.issuerData.state.revocationTreeRoot),
1260
- value: import_js_merkletree2.Hash.fromHex(obj.issuerData.state.value)
1261
- }
1262
- }
1263
- });
1264
- }
1265
- };
1266
- var BJJSignatureProof2021 = class _BJJSignatureProof2021 {
1267
- type;
1268
- issuerData;
1269
- signature;
1270
- coreClaim;
1271
- constructor(obj) {
1272
- this.type = "BJJSignature2021" /* BJJSignature */;
1273
- this.issuerData = obj.issuerData;
1274
- this.coreClaim = obj.coreClaim;
1275
- this.signature = obj.signature;
1276
- }
1277
- /**
1278
- * toJSON is a method to serialize BJJSignatureProof2021 to json
1279
- *
1280
- * @returns `json object in serialized presentation`
1281
- */
1282
- toJSON() {
1283
- return {
1284
- issuerData: {
1285
- id: this.issuerData.id.string(),
1286
- state: {
1287
- ...this.issuerData.state,
1288
- rootOfRoots: this.issuerData.state.rootOfRoots.hex(),
1289
- claimsTreeRoot: this.issuerData.state.claimsTreeRoot.hex(),
1290
- revocationTreeRoot: this.issuerData.state.revocationTreeRoot.hex(),
1291
- value: this.issuerData.state.value.hex()
1292
- },
1293
- mtp: this.issuerData.mtp.toJSON(),
1294
- authCoreClaim: this.issuerData.authCoreClaim.hex(),
1295
- credentialStatus: this.issuerData.credentialStatus
1296
- },
1297
- type: this.type,
1298
- coreClaim: this.coreClaim.hex(),
1299
- signature: import_js_crypto5.Hex.encodeString(this.signature.compress())
1300
- };
1301
- }
1302
- /**
1303
- * fromJSON is a method to deserialize BJJSignatureProof2021 from json
1304
- * @param obj
1305
- */
1306
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1307
- static fromJSON(obj) {
1308
- return new _BJJSignatureProof2021({
1309
- issuerData: {
1310
- id: import_js_iden3_core3.DID.parse(obj.issuerData.id),
1311
- mtp: import_js_merkletree2.Proof.fromJSON(obj.issuerData.mtp),
1312
- state: {
1313
- ...obj.issuerData.state,
1314
- rootOfRoots: import_js_merkletree2.Hash.fromHex(obj.issuerData.state.rootOfRoots),
1315
- claimsTreeRoot: import_js_merkletree2.Hash.fromHex(obj.issuerData.state.claimsTreeRoot),
1316
- revocationTreeRoot: import_js_merkletree2.Hash.fromHex(obj.issuerData.state.revocationTreeRoot),
1317
- value: import_js_merkletree2.Hash.fromHex(obj.issuerData.state.value)
1318
- },
1319
- credentialStatus: obj.issuerData.credentialStatus,
1320
- authCoreClaim: new import_js_iden3_core3.Claim().fromHex(obj.issuerData.authCoreClaim)
1321
- },
1322
- coreClaim: new import_js_iden3_core3.Claim().fromHex(obj.coreClaim),
1323
- signature: import_js_crypto5.Signature.newFromCompressed(
1324
- Uint8Array.from(import_js_crypto5.Hex.decodeString(obj.signature)).slice(0, 64)
1325
- )
1326
- });
1327
- }
1328
- };
1329
-
1330
- // src/verifiable/credential.ts
1331
- var import_js_iden3_core6 = require("@iden3/js-iden3-core");
1332
- var import_js_merkletree3 = require("@iden3/js-merkletree");
1333
- var import_js_jsonld_merklization2 = require("@iden3/js-jsonld-merklization");
1334
- var import_js_crypto7 = require("@iden3/js-crypto");
1335
-
1336
- // src/credentials/utils.ts
1337
- var import_js_iden3_core4 = require("@iden3/js-iden3-core");
1338
- var import_js_crypto6 = require("@iden3/js-crypto");
1339
- var getUserDIDFromCredential = (issuerDID, credential) => {
1340
- if (!credential.credentialSubject.id) {
1341
- return issuerDID;
1342
- }
1343
- if (typeof credential.credentialSubject.id !== "string") {
1344
- throw new Error("credential subject `id` is not a string");
1345
- }
1346
- return import_js_iden3_core4.DID.parse(credential.credentialSubject.id);
1347
- };
1348
- var getKMSIdByAuthCredential = (credential) => {
1349
- if (!credential.type.includes("AuthBJJCredential")) {
1350
- throw new Error("can't sign with not AuthBJJCredential credential");
1351
- }
1352
- const x = credential.credentialSubject["x"];
1353
- const y = credential.credentialSubject["y"];
1354
- const pb = new import_js_crypto6.PublicKey([BigInt(x), BigInt(y)]);
1355
- const kp = keyPath("BJJ" /* BabyJubJub */, pb.hex());
1356
- return { type: "BJJ" /* BabyJubJub */, id: kp };
1357
- };
1358
-
1359
- // src/verifiable/core-utils.ts
1360
- var import_js_iden3_core5 = require("@iden3/js-iden3-core");
1361
- var import_js_jsonld_merklization = require("@iden3/js-jsonld-merklization");
1362
- var import_jsonld = __toESM(require("jsonld"), 1);
1363
- var import_ethers2 = require("ethers");
1364
- var credentialSubjectKey = "credentialSubject";
1365
- var contextFullKey = "@context";
1366
- var serializationFullKey = "iden3_serialization";
1367
- var fieldPrefix = "iden3:v1:";
1368
- var credentialSubjectFullKey = "https://www.w3.org/2018/credentials#credentialSubject";
1369
- var verifiableCredentialFullKey = "https://www.w3.org/2018/credentials#VerifiableCredential";
1370
- var typeFullKey = "@type";
1371
- var getFieldSlotIndex = async (field, typeName, schemaBytes) => {
1372
- let ctxDoc = JSON.parse(byteDecoder.decode(schemaBytes));
1373
- ctxDoc = ctxDoc[contextFullKey];
1374
- if (ctxDoc === void 0) {
1375
- throw new Error("document has no @context");
1376
- }
1377
- const ldCtx = await import_jsonld.default.processContext(
1378
- await import_jsonld.default.processContext(null, null, {}),
1379
- ctxDoc,
1380
- {}
1381
- );
1382
- const serAttr = await getSerializationAttrFromParsedContext(
1383
- ldCtx,
1384
- typeName
1385
- );
1386
- if (!serAttr) {
1387
- throw new Error("serialization attribute is not set");
1388
- }
1389
- const sPaths = parseSerializationAttr(serAttr);
1390
- switch (field) {
1391
- case sPaths.indexAPath:
1392
- return 2;
1393
- case sPaths.indexBPath:
1394
- return 3;
1395
- case sPaths.valueAPath:
1396
- return 6;
1397
- case sPaths.valueBPath:
1398
- return 7;
1399
- default:
1400
- throw new Error(`field ${field} not specified in serialization info`);
1141
+ const sPaths = parseSerializationAttr(serAttr);
1142
+ switch (field) {
1143
+ case sPaths.indexAPath:
1144
+ return 2;
1145
+ case sPaths.indexBPath:
1146
+ return 3;
1147
+ case sPaths.valueAPath:
1148
+ return 6;
1149
+ case sPaths.valueBPath:
1150
+ return 7;
1151
+ default:
1152
+ throw new Error(`field ${field} not specified in serialization info`);
1401
1153
  }
1402
1154
  };
1403
1155
  var fillCoreClaimSlot = async (slotData, mz, path) => {
@@ -1409,7 +1161,7 @@ var fillCoreClaimSlot = async (slotData, mz, path) => {
1409
1161
  const p = await mz.resolveDocPath(path, mz.options);
1410
1162
  const entry = await mz.entry(p);
1411
1163
  const intVal = await entry.getValueMtEntry();
1412
- const bytesVal = import_js_iden3_core5.BytesHelper.intToBytes(intVal);
1164
+ const bytesVal = import_js_iden3_core4.BytesHelper.intToBytes(intVal);
1413
1165
  slotData.set(bytesVal, 0);
1414
1166
  } catch (err) {
1415
1167
  if (err.toString().includes("entry not found")) {
@@ -1524,7 +1276,7 @@ var parseCoreClaimSlots = async (ldCtx, mz, credentialType) => {
1524
1276
  };
1525
1277
  var calculateCoreSchemaHash = (schemaId) => {
1526
1278
  const sHash = hexToBytes((0, import_ethers2.keccak256)(schemaId));
1527
- return new import_js_iden3_core5.SchemaHash(sHash.slice(sHash.length - 16, sHash.length));
1279
+ return new import_js_iden3_core4.SchemaHash(sHash.slice(sHash.length - 16, sHash.length));
1528
1280
  };
1529
1281
 
1530
1282
  // src/verifiable/credential.ts
@@ -1606,8 +1358,8 @@ var W3CCredential = class _W3CCredential {
1606
1358
  id: request.revocationOpts.issuerState ? `${credentialStatus.id.replace(/\/$/, "")}/node?state=${request.revocationOpts.issuerState}` : `${credentialStatus.id.replace(/\/$/, "")}`
1607
1359
  };
1608
1360
  case "Iden3OnchainSparseMerkleTreeProof2023" /* Iden3OnchainSparseMerkleTreeProof2023 */: {
1609
- const issuerId = import_js_iden3_core6.DID.idFromDID(issuer);
1610
- const chainId = (0, import_js_iden3_core6.getChainId)(import_js_iden3_core6.DID.blockchainFromId(issuerId), import_js_iden3_core6.DID.networkIdFromId(issuerId));
1361
+ const issuerId = import_js_iden3_core5.DID.idFromDID(issuer);
1362
+ const chainId = (0, import_js_iden3_core5.getChainId)(import_js_iden3_core5.DID.blockchainFromId(issuerId), import_js_iden3_core5.DID.networkIdFromId(issuerId));
1611
1363
  const searchParams = [
1612
1364
  ["revocationNonce", request.revocationOpts.nonce?.toString() || ""],
1613
1365
  ["contractAddress", `${chainId}:${request.revocationOpts.id}`],
@@ -1735,12 +1487,12 @@ var W3CCredential = class _W3CCredential {
1735
1487
  opts.merklizedRootPosition = "index" /* Index */;
1736
1488
  }
1737
1489
  const schemaHash = calculateCoreSchemaHash(byteEncoder.encode(credentialType));
1738
- const claim = import_js_iden3_core6.Claim.newClaim(
1490
+ const claim = import_js_iden3_core5.Claim.newClaim(
1739
1491
  schemaHash,
1740
- import_js_iden3_core6.ClaimOptions.withIndexDataBytes(slots.indexA, slots.indexB),
1741
- import_js_iden3_core6.ClaimOptions.withValueDataBytes(slots.valueA, slots.valueB),
1742
- import_js_iden3_core6.ClaimOptions.withRevocationNonce(BigInt(opts.revNonce)),
1743
- import_js_iden3_core6.ClaimOptions.withVersion(opts.version)
1492
+ import_js_iden3_core5.ClaimOptions.withIndexDataBytes(slots.indexA, slots.indexB),
1493
+ import_js_iden3_core5.ClaimOptions.withValueDataBytes(slots.valueA, slots.valueB),
1494
+ import_js_iden3_core5.ClaimOptions.withRevocationNonce(BigInt(opts.revNonce)),
1495
+ import_js_iden3_core5.ClaimOptions.withVersion(opts.version)
1744
1496
  );
1745
1497
  if (opts.updatable) {
1746
1498
  claim.setFlagUpdatable(opts.updatable);
@@ -1749,8 +1501,8 @@ var W3CCredential = class _W3CCredential {
1749
1501
  claim.setExpirationDate(new Date(this.expirationDate));
1750
1502
  }
1751
1503
  if (subjectId) {
1752
- const did = import_js_iden3_core6.DID.parse(subjectId.toString());
1753
- const id = import_js_iden3_core6.DID.idFromDID(did);
1504
+ const did = import_js_iden3_core5.DID.parse(subjectId.toString());
1505
+ const id = import_js_iden3_core5.DID.idFromDID(did);
1754
1506
  switch (opts.subjectPosition) {
1755
1507
  case "":
1756
1508
  case "index" /* Index */:
@@ -1851,26 +1603,26 @@ var W3CCredential = class _W3CCredential {
1851
1603
  let merklizedRootPosition = "";
1852
1604
  const merklizedPosition = coreClaim.getMerklizedPosition();
1853
1605
  switch (merklizedPosition) {
1854
- case import_js_iden3_core6.MerklizedRootPosition.None:
1606
+ case import_js_iden3_core5.MerklizedRootPosition.None:
1855
1607
  merklizedRootPosition = "" /* None */;
1856
1608
  break;
1857
- case import_js_iden3_core6.MerklizedRootPosition.Index:
1609
+ case import_js_iden3_core5.MerklizedRootPosition.Index:
1858
1610
  merklizedRootPosition = "index" /* Index */;
1859
1611
  break;
1860
- case import_js_iden3_core6.MerklizedRootPosition.Value:
1612
+ case import_js_iden3_core5.MerklizedRootPosition.Value:
1861
1613
  merklizedRootPosition = "value" /* Value */;
1862
1614
  break;
1863
1615
  }
1864
1616
  let subjectPosition = "";
1865
1617
  const idPosition = coreClaim.getIdPosition();
1866
1618
  switch (idPosition) {
1867
- case import_js_iden3_core6.IdPosition.None:
1619
+ case import_js_iden3_core5.IdPosition.None:
1868
1620
  subjectPosition = "" /* None */;
1869
1621
  break;
1870
- case import_js_iden3_core6.IdPosition.Index:
1622
+ case import_js_iden3_core5.IdPosition.Index:
1871
1623
  subjectPosition = "index" /* Index */;
1872
1624
  break;
1873
- case import_js_iden3_core6.IdPosition.Value:
1625
+ case import_js_iden3_core5.IdPosition.Value:
1874
1626
  subjectPosition = "value" /* Value */;
1875
1627
  break;
1876
1628
  }
@@ -1890,9 +1642,9 @@ var W3CCredential = class _W3CCredential {
1890
1642
  async verifyBJJSignatureProof(proof, coreClaim, resolverURL, userDID, credStatusResolverRegistry) {
1891
1643
  const authClaim = proof.issuerData.authCoreClaim;
1892
1644
  const rawSlotsInt = authClaim.rawSlotsAsInts();
1893
- const pubKey = new import_js_crypto7.PublicKey([rawSlotsInt[2], rawSlotsInt[3]]);
1645
+ const pubKey = new import_js_crypto5.PublicKey([rawSlotsInt[2], rawSlotsInt[3]]);
1894
1646
  const { hi, hv } = coreClaim.hiHv();
1895
- const claimHash = import_js_crypto7.poseidon.hash([hi, hv]);
1647
+ const claimHash = import_js_crypto5.poseidon.hash([hi, hv]);
1896
1648
  const bjjValid = pubKey.verifyPoseidon(claimHash, proof.signature);
1897
1649
  if (!bjjValid) {
1898
1650
  throw new Error("signature is not valid");
@@ -1976,7 +1728,7 @@ function extractProof(proof) {
1976
1728
  if (!p.coreClaim) {
1977
1729
  throw new Error(`coreClaim field is not defined in proof type ${defaultProofType}`);
1978
1730
  }
1979
- const coreClaim = p.coreClaim instanceof import_js_iden3_core6.Claim ? p.coreClaim : new import_js_iden3_core6.Claim().fromHex(p.coreClaim);
1731
+ const coreClaim = p.coreClaim instanceof import_js_iden3_core5.Claim ? p.coreClaim : new import_js_iden3_core5.Claim().fromHex(p.coreClaim);
1980
1732
  return { claim: coreClaim, proofType: defaultProofType };
1981
1733
  }
1982
1734
  throw new Error("proof format is not supported");
@@ -1985,7 +1737,7 @@ function validateTreeState(treeState) {
1985
1737
  const ctrHash = treeState.claimsTreeRoot ? import_js_merkletree3.Hash.fromHex(treeState.claimsTreeRoot) : new import_js_merkletree3.Hash();
1986
1738
  const rtrHash = treeState.revocationTreeRoot ? import_js_merkletree3.Hash.fromHex(treeState.revocationTreeRoot) : new import_js_merkletree3.Hash();
1987
1739
  const rorHash = treeState.rootOfRoots ? import_js_merkletree3.Hash.fromHex(treeState.rootOfRoots) : new import_js_merkletree3.Hash();
1988
- const wantState = import_js_crypto7.poseidon.hash([ctrHash.bigInt(), rtrHash.bigInt(), rorHash.bigInt()]);
1740
+ const wantState = import_js_crypto5.poseidon.hash([ctrHash.bigInt(), rtrHash.bigInt(), rorHash.bigInt()]);
1989
1741
  const stateHash = treeState.state ? import_js_merkletree3.Hash.fromHex(treeState.state) : new import_js_merkletree3.Hash();
1990
1742
  return wantState === stateHash.bigInt();
1991
1743
  }
@@ -2299,18 +2051,666 @@ var DIDDocumentJSONSchema = `{
2299
2051
  },
2300
2052
  "deprecated": true
2301
2053
  }
2302
- },
2303
- "required": [
2304
- "id"
2305
- ]
2306
- }`;
2054
+ },
2055
+ "required": [
2056
+ "id"
2057
+ ]
2058
+ }`;
2059
+
2060
+ // src/utils/payments/solana.ts
2061
+ var import_js_iden3_core6 = require("@iden3/js-iden3-core");
2062
+ var import_web3 = require("@solana/web3.js");
2063
+ var SolanaNativePaymentRequest = class {
2064
+ version;
2065
+ chainId;
2066
+ verifyingContract;
2067
+ recipient;
2068
+ amount;
2069
+ expirationDate;
2070
+ nonce;
2071
+ metadata;
2072
+ constructor(fields) {
2073
+ this.version = fields.version;
2074
+ this.chainId = fields.chainId;
2075
+ this.verifyingContract = fields.verifyingContract;
2076
+ this.recipient = fields.recipient;
2077
+ this.amount = fields.amount;
2078
+ this.expirationDate = fields.expirationDate;
2079
+ this.nonce = fields.nonce;
2080
+ this.metadata = fields.metadata;
2081
+ }
2082
+ };
2083
+ var SolanaSplPaymentRequest = class {
2084
+ version;
2085
+ chainId;
2086
+ verifyingContract;
2087
+ tokenAddress;
2088
+ recipient;
2089
+ amount;
2090
+ expirationDate;
2091
+ nonce;
2092
+ metadata;
2093
+ constructor(fields) {
2094
+ this.version = fields.version;
2095
+ this.chainId = fields.chainId;
2096
+ this.verifyingContract = fields.verifyingContract;
2097
+ this.tokenAddress = fields.tokenAddress;
2098
+ this.recipient = fields.recipient;
2099
+ this.amount = fields.amount;
2100
+ this.expirationDate = fields.expirationDate;
2101
+ this.nonce = fields.nonce;
2102
+ this.metadata = fields.metadata;
2103
+ }
2104
+ };
2105
+ var SolanaNativePaymentSchema = /* @__PURE__ */ new Map([
2106
+ [
2107
+ SolanaNativePaymentRequest,
2108
+ {
2109
+ kind: "struct",
2110
+ fields: [
2111
+ ["version", ["u8"]],
2112
+ ["chainId", "u64"],
2113
+ ["verifyingContract", ["u8", 32]],
2114
+ ["recipient", ["u8", 32]],
2115
+ ["amount", "u64"],
2116
+ ["expirationDate", "u64"],
2117
+ ["nonce", "u64"],
2118
+ ["metadata", ["u8"]]
2119
+ ]
2120
+ }
2121
+ ]
2122
+ ]);
2123
+ var SolanaSplPaymentSchema = /* @__PURE__ */ new Map([
2124
+ [
2125
+ SolanaSplPaymentRequest,
2126
+ {
2127
+ kind: "struct",
2128
+ fields: [
2129
+ ["version", ["u8"]],
2130
+ ["chainId", "u64"],
2131
+ ["verifyingContract", ["u8", 32]],
2132
+ ["tokenAddress", ["u8", 32]],
2133
+ ["recipient", ["u8", 32]],
2134
+ ["amount", "u64"],
2135
+ ["expirationDate", "u64"],
2136
+ ["nonce", "u64"],
2137
+ ["metadata", ["u8"]]
2138
+ ]
2139
+ }
2140
+ ]
2141
+ ]);
2142
+ var SolanaPaymentInstruction = class {
2143
+ recipient;
2144
+ amount;
2145
+ expiration_date;
2146
+ nonce;
2147
+ metadata;
2148
+ signature;
2149
+ constructor(fields) {
2150
+ this.recipient = fields.recipient;
2151
+ this.amount = fields.amount;
2152
+ this.expiration_date = fields.expiration_date;
2153
+ this.nonce = fields.nonce;
2154
+ this.metadata = fields.metadata;
2155
+ this.signature = fields.signature;
2156
+ }
2157
+ };
2158
+ var SolanaPaymentInstructionSchema = /* @__PURE__ */ new Map([
2159
+ [
2160
+ SolanaPaymentInstruction,
2161
+ {
2162
+ kind: "struct",
2163
+ fields: [
2164
+ ["recipient", ["u8", 32]],
2165
+ ["amount", "u64"],
2166
+ ["expiration_date", "u64"],
2167
+ ["nonce", "u64"],
2168
+ ["metadata", ["u8"]],
2169
+ ["signature", [64]]
2170
+ ]
2171
+ }
2172
+ ]
2173
+ ]);
2174
+ var buildSolanaPayment = async (solSigner, option, chainId, paymentRails, recipient, amount, expirationDate, nonce) => {
2175
+ let serialized;
2176
+ const proofVersion = option.type === "Iden3PaymentRailsSolanaRequestV1" /* Iden3PaymentRailsSolanaRequestV1 */ ? "SolanaEd25519NativeV1" : "SolanaEd25519SPLV1";
2177
+ let chainRef = chainId;
2178
+ switch (chainId) {
2179
+ case "101":
2180
+ chainRef = SOLANA_CHAIN_REF.DEVNET;
2181
+ break;
2182
+ case "102":
2183
+ chainRef = SOLANA_CHAIN_REF.TESTNET;
2184
+ break;
2185
+ case "103":
2186
+ chainRef = SOLANA_CHAIN_REF.MAINNET;
2187
+ break;
2188
+ }
2189
+ if (option.type === "Iden3PaymentRailsSolanaRequestV1" /* Iden3PaymentRailsSolanaRequestV1 */) {
2190
+ const request = new SolanaNativePaymentRequest({
2191
+ version: byteEncoder.encode(proofVersion),
2192
+ chainId: BigInt(chainId),
2193
+ verifyingContract: new import_web3.PublicKey(paymentRails).toBytes(),
2194
+ recipient: new import_web3.PublicKey(recipient).toBytes(),
2195
+ amount: BigInt(amount),
2196
+ expirationDate: BigInt((0, import_js_iden3_core6.getUnixTimestamp)(expirationDate)),
2197
+ nonce,
2198
+ metadata: byteEncoder.encode("0x")
2199
+ });
2200
+ serialized = (0, import_borsh.serialize)(SolanaNativePaymentSchema, request);
2201
+ } else {
2202
+ if (!option.contractAddress) {
2203
+ throw new Error(`failed request. no contract address for ${option.type} payment type`);
2204
+ }
2205
+ const request = new SolanaSplPaymentRequest({
2206
+ version: byteEncoder.encode(proofVersion),
2207
+ chainId: BigInt(chainId),
2208
+ verifyingContract: new import_web3.PublicKey(paymentRails).toBytes(),
2209
+ tokenAddress: new import_web3.PublicKey(option.contractAddress).toBytes(),
2210
+ recipient: new import_web3.PublicKey(recipient).toBytes(),
2211
+ amount: BigInt(amount),
2212
+ expirationDate: BigInt((0, import_js_iden3_core6.getUnixTimestamp)(expirationDate)),
2213
+ nonce,
2214
+ metadata: byteEncoder.encode("0x")
2215
+ });
2216
+ serialized = (0, import_borsh.serialize)(SolanaSplPaymentSchema, request);
2217
+ }
2218
+ const privateKey = solSigner.secretKey.slice(0, 32);
2219
+ const signature = await import_ed25519.ed25519.sign(serialized, privateKey);
2220
+ const proof = [
2221
+ {
2222
+ type: "SolanaEd25519Signature2025" /* SolanaEd25519Signature2025 */,
2223
+ proofPurpose: "assertionMethod",
2224
+ proofValue: Buffer.from(signature).toString("hex"),
2225
+ created: (/* @__PURE__ */ new Date()).toISOString(),
2226
+ verificationMethod: `did:pkh:solana:${chainRef}:${solSigner.publicKey.toBase58()}`,
2227
+ domain: {
2228
+ version: proofVersion,
2229
+ chainId,
2230
+ verifyingContract: paymentRails
2231
+ }
2232
+ }
2233
+ ];
2234
+ const d = {
2235
+ type: "Iden3PaymentRailsSolanaRequestV1" /* Iden3PaymentRailsSolanaRequestV1 */,
2236
+ "@context": [
2237
+ `https://schema.iden3.io/core/jsonld/payment.jsonld#${option.type}`,
2238
+ "https://schema.iden3.io/core/jsonld/solanaEd25519.jsonld"
2239
+ ],
2240
+ recipient,
2241
+ amount: amount.toString(),
2242
+ expirationDate: expirationDate.toISOString(),
2243
+ nonce: nonce.toString(),
2244
+ metadata: "0x",
2245
+ proof
2246
+ };
2247
+ if (option.type === "Iden3PaymentRailsSolanaRequestV1" /* Iden3PaymentRailsSolanaRequestV1 */) {
2248
+ return d;
2249
+ }
2250
+ return {
2251
+ ...d,
2252
+ type: option.type,
2253
+ tokenAddress: option.contractAddress || "",
2254
+ features: option.features || []
2255
+ };
2256
+ };
2257
+ var serializeSolanaPaymentInstruction = (data) => {
2258
+ let serialized;
2259
+ const proof = Array.isArray(data.proof) ? data.proof[0] : data.proof;
2260
+ const proofVersion = data.type === "Iden3PaymentRailsSolanaRequestV1" /* Iden3PaymentRailsSolanaRequestV1 */ ? "SolanaEd25519NativeV1" : "SolanaEd25519SPLV1";
2261
+ if (data.type === "Iden3PaymentRailsSolanaRequestV1" /* Iden3PaymentRailsSolanaRequestV1 */) {
2262
+ const request = new SolanaNativePaymentRequest({
2263
+ version: byteEncoder.encode(proofVersion),
2264
+ chainId: BigInt(proof.domain.chainId),
2265
+ verifyingContract: new import_web3.PublicKey(proof.domain.verifyingContract).toBytes(),
2266
+ recipient: new import_web3.PublicKey(data.recipient).toBytes(),
2267
+ amount: BigInt(data.amount),
2268
+ expirationDate: BigInt((0, import_js_iden3_core6.getUnixTimestamp)(new Date(data.expirationDate))),
2269
+ nonce: BigInt(data.nonce),
2270
+ metadata: byteEncoder.encode("0x")
2271
+ });
2272
+ serialized = (0, import_borsh.serialize)(SolanaNativePaymentSchema, request);
2273
+ } else {
2274
+ const request = new SolanaSplPaymentRequest({
2275
+ version: byteEncoder.encode(proofVersion),
2276
+ chainId: BigInt(proof.domain.chainId),
2277
+ verifyingContract: new import_web3.PublicKey(proof.domain.verifyingContract).toBytes(),
2278
+ tokenAddress: new import_web3.PublicKey(data.tokenAddress).toBytes(),
2279
+ recipient: new import_web3.PublicKey(data.recipient).toBytes(),
2280
+ amount: BigInt(data.amount),
2281
+ expirationDate: BigInt((0, import_js_iden3_core6.getUnixTimestamp)(new Date(data.expirationDate))),
2282
+ nonce: BigInt(data.nonce),
2283
+ metadata: byteEncoder.encode("0x")
2284
+ });
2285
+ serialized = (0, import_borsh.serialize)(SolanaSplPaymentSchema, request);
2286
+ }
2287
+ return serialized;
2288
+ };
2289
+ var verifyIden3SolanaPaymentRequest = async (data, resolver) => {
2290
+ const proof = Array.isArray(data.proof) ? data.proof[0] : data.proof;
2291
+ let serialized;
2292
+ if (data.type === "Iden3PaymentRailsSolanaRequestV1" /* Iden3PaymentRailsSolanaRequestV1 */) {
2293
+ const request = new SolanaNativePaymentRequest({
2294
+ version: byteEncoder.encode(proof.domain.version),
2295
+ chainId: BigInt(proof.domain.chainId),
2296
+ verifyingContract: new import_web3.PublicKey(proof.domain.verifyingContract).toBytes(),
2297
+ recipient: new import_web3.PublicKey(data.recipient).toBytes(),
2298
+ amount: BigInt(data.amount),
2299
+ expirationDate: BigInt((0, import_js_iden3_core6.getUnixTimestamp)(new Date(data.expirationDate))),
2300
+ nonce: BigInt(data.nonce),
2301
+ metadata: byteEncoder.encode("0x")
2302
+ });
2303
+ serialized = (0, import_borsh.serialize)(SolanaNativePaymentSchema, request);
2304
+ } else {
2305
+ const request = new SolanaSplPaymentRequest({
2306
+ version: byteEncoder.encode(proof.domain.version),
2307
+ chainId: BigInt(proof.domain.chainId),
2308
+ verifyingContract: new import_web3.PublicKey(proof.domain.verifyingContract).toBytes(),
2309
+ tokenAddress: new import_web3.PublicKey(data.tokenAddress).toBytes(),
2310
+ recipient: new import_web3.PublicKey(data.recipient).toBytes(),
2311
+ amount: BigInt(data.amount),
2312
+ expirationDate: BigInt((0, import_js_iden3_core6.getUnixTimestamp)(new Date(data.expirationDate))),
2313
+ nonce: BigInt(data.nonce),
2314
+ metadata: byteEncoder.encode("0x")
2315
+ });
2316
+ serialized = (0, import_borsh.serialize)(SolanaSplPaymentSchema, request);
2317
+ }
2318
+ const { didDocument } = await resolver.resolve(proof.verificationMethod);
2319
+ let publicKeyMultibase;
2320
+ if (didDocument?.verificationMethod) {
2321
+ for (const verificationMethod of didDocument.verificationMethod) {
2322
+ if (verificationMethod.type === "Ed25519VerificationKey2020") {
2323
+ publicKeyMultibase = verificationMethod.publicKeyMultibase;
2324
+ }
2325
+ }
2326
+ }
2327
+ if (!publicKeyMultibase) {
2328
+ throw new Error("No Ed25519VerificationKey2020 found in DID document");
2329
+ }
2330
+ return import_ed25519.ed25519.verify(proof.proofValue, serialized, new import_web3.PublicKey(publicKeyMultibase).toBytes());
2331
+ };
2332
+
2333
+ // src/utils/payments/evm.ts
2334
+ var import_ethers3 = require("ethers");
2335
+ var import_js_iden3_core7 = require("@iden3/js-iden3-core");
2336
+ var buildEvmPayment = async (signer, option, chainId, paymentRails, recipient, amount, expirationDateRequired, nonce) => {
2337
+ const typeUrl = `https://schema.iden3.io/core/json/${option.type}.json`;
2338
+ const typesFetchResult = await fetch(typeUrl);
2339
+ const types = await typesFetchResult.json();
2340
+ delete types.EIP712Domain;
2341
+ const paymentData = option.type === "Iden3PaymentRailsRequestV1" /* Iden3PaymentRailsRequestV1 */ ? {
2342
+ recipient,
2343
+ amount,
2344
+ expirationDate: (0, import_js_iden3_core7.getUnixTimestamp)(expirationDateRequired),
2345
+ nonce,
2346
+ metadata: "0x"
2347
+ } : {
2348
+ tokenAddress: option.contractAddress,
2349
+ recipient,
2350
+ amount,
2351
+ expirationDate: (0, import_js_iden3_core7.getUnixTimestamp)(expirationDateRequired),
2352
+ nonce,
2353
+ metadata: "0x"
2354
+ };
2355
+ const domain = {
2356
+ name: "MCPayment",
2357
+ version: "1.0.0",
2358
+ chainId,
2359
+ verifyingContract: paymentRails
2360
+ };
2361
+ const signature = await signer.signTypedData(domain, types, paymentData);
2362
+ const proof = [
2363
+ {
2364
+ type: "EthereumEip712Signature2021" /* EthereumEip712Signature2021 */,
2365
+ proofPurpose: "assertionMethod",
2366
+ proofValue: signature,
2367
+ verificationMethod: `did:pkh:eip155:${chainId}:${await signer.getAddress()}`,
2368
+ created: (/* @__PURE__ */ new Date()).toISOString(),
2369
+ eip712: {
2370
+ types: typeUrl,
2371
+ primaryType: "Iden3PaymentRailsRequestV1",
2372
+ domain
2373
+ }
2374
+ }
2375
+ ];
2376
+ const d = {
2377
+ type: "Iden3PaymentRailsRequestV1" /* Iden3PaymentRailsRequestV1 */,
2378
+ "@context": [
2379
+ `https://schema.iden3.io/core/jsonld/payment.jsonld#${option.type}`,
2380
+ "https://w3id.org/security/suites/eip712sig-2021/v1"
2381
+ ],
2382
+ recipient,
2383
+ amount: amount.toString(),
2384
+ expirationDate: expirationDateRequired.toISOString(),
2385
+ nonce: nonce.toString(),
2386
+ metadata: "0x",
2387
+ proof
2388
+ };
2389
+ if (option.type === "Iden3PaymentRailsRequestV1" /* Iden3PaymentRailsRequestV1 */) {
2390
+ return d;
2391
+ }
2392
+ return {
2393
+ ...d,
2394
+ type: option.type,
2395
+ tokenAddress: option.contractAddress || "",
2396
+ features: option.features || []
2397
+ };
2398
+ };
2399
+ async function verifyEIP712TypedData(data, resolver) {
2400
+ const paymentData = data.type === "Iden3PaymentRailsRequestV1" /* Iden3PaymentRailsRequestV1 */ ? {
2401
+ recipient: data.recipient,
2402
+ amount: data.amount,
2403
+ expirationDate: (0, import_js_iden3_core7.getUnixTimestamp)(new Date(data.expirationDate)),
2404
+ nonce: data.nonce,
2405
+ metadata: "0x"
2406
+ } : {
2407
+ tokenAddress: data.tokenAddress,
2408
+ recipient: data.recipient,
2409
+ amount: data.amount,
2410
+ expirationDate: (0, import_js_iden3_core7.getUnixTimestamp)(new Date(data.expirationDate)),
2411
+ nonce: data.nonce,
2412
+ metadata: "0x"
2413
+ };
2414
+ const proof = Array.isArray(data.proof) ? data.proof[0] : data.proof;
2415
+ const typesFetchResult = await fetch(proof.eip712.types);
2416
+ const types = await typesFetchResult.json();
2417
+ delete types.EIP712Domain;
2418
+ const recovered = import_ethers3.ethers.verifyTypedData(
2419
+ proof.eip712.domain,
2420
+ types,
2421
+ paymentData,
2422
+ proof.proofValue
2423
+ );
2424
+ const { didDocument } = await resolver.resolve(proof.verificationMethod);
2425
+ if (didDocument?.verificationMethod) {
2426
+ for (const verificationMethod of didDocument.verificationMethod) {
2427
+ if (verificationMethod.blockchainAccountId?.split(":").slice(-1)[0].toLowerCase() === recovered.toLowerCase()) {
2428
+ return recovered;
2429
+ }
2430
+ }
2431
+ } else {
2432
+ throw new Error("failed request. issuer DIDDocument does not contain any verificationMethods");
2433
+ }
2434
+ throw new Error(`failed request. no matching verificationMethod`);
2435
+ }
2436
+
2437
+ // src/kms/key-providers/bjj-provider.ts
2438
+ var BjjProvider = class {
2439
+ /**
2440
+ * key type that is handled by BJJ Provider
2441
+ * @type {KmsKeyType}
2442
+ */
2443
+ keyType;
2444
+ keyStore;
2445
+ /**
2446
+ * Creates an instance of BjjProvider.
2447
+ * @param {KmsKeyType} keyType - kms key type
2448
+ * @param {AbstractPrivateKeyStore} keyStore - key store for kms
2449
+ */
2450
+ constructor(keyType, keyStore) {
2451
+ if (keyType !== "BJJ" /* BabyJubJub */) {
2452
+ throw new Error("Key type must be BabyJubJub");
2453
+ }
2454
+ this.keyType = keyType;
2455
+ this.keyStore = keyStore;
2456
+ }
2457
+ /**
2458
+ * get all keys
2459
+ * @returns list of keys
2460
+ */
2461
+ async list() {
2462
+ const allKeysFromKeyStore = await this.keyStore.list();
2463
+ return allKeysFromKeyStore.filter((key) => key.alias.startsWith(this.keyType));
2464
+ }
2465
+ /**
2466
+ * generates a baby jub jub key from a seed phrase
2467
+ * @param {Uint8Array} seed - byte array seed
2468
+ * @returns kms key identifier
2469
+ */
2470
+ async newPrivateKeyFromSeed(seed) {
2471
+ const newKey = new Uint8Array(32);
2472
+ newKey.set(Uint8Array.from(seed), 0);
2473
+ newKey.fill(seed.length, 32, 0);
2474
+ const privateKey = new import_js_crypto6.PrivateKey(seed);
2475
+ const publicKey = privateKey.public();
2476
+ const kmsId = {
2477
+ type: this.keyType,
2478
+ id: keyPath(this.keyType, publicKey.hex())
2479
+ };
2480
+ await this.keyStore.importKey({ alias: kmsId.id, key: privateKey.hex() });
2481
+ return kmsId;
2482
+ }
2483
+ /**
2484
+ * Gets public key by kmsKeyId
2485
+ *
2486
+ * @param {KmsKeyId} keyId - key identifier
2487
+ */
2488
+ async publicKey(keyId) {
2489
+ const privateKey = await this.privateKey(keyId);
2490
+ return privateKey.public().hex();
2491
+ }
2492
+ /**
2493
+ * signs prepared payload of size,
2494
+ * with a key id
2495
+ *
2496
+ * @param {KmsKeyId} keyId - key identifier
2497
+ * @param {Uint8Array} data - data to sign (32 bytes)
2498
+ * @returns Uint8Array signature
2499
+ */
2500
+ async sign(keyId, data) {
2501
+ if (data.length != 32) {
2502
+ throw new Error("data to sign is too large");
2503
+ }
2504
+ const i = import_js_iden3_core8.BytesHelper.bytesToInt(data);
2505
+ if (!(0, import_js_iden3_core8.checkBigIntInField)(i)) {
2506
+ throw new Error("data to sign is too large");
2507
+ }
2508
+ const privateKey = await this.privateKey(keyId);
2509
+ const signature = privateKey.signPoseidon(i);
2510
+ return signature.compress();
2511
+ }
2512
+ async privateKey(keyId) {
2513
+ const privateKeyHex = await this.keyStore.get({ alias: keyId.id });
2514
+ return new import_js_crypto6.PrivateKey(import_js_crypto6.Hex.decodeString(privateKeyHex));
2515
+ }
2516
+ async verify(message, signatureHex, keyId) {
2517
+ const publicKey = await this.publicKey(keyId);
2518
+ return import_js_crypto6.PublicKey.newFromCompressed(hexToBytes(publicKey)).verifyPoseidon(
2519
+ import_js_iden3_core8.BytesHelper.bytesToInt(message),
2520
+ import_js_crypto6.Signature.newFromCompressed(hexToBytes(signatureHex))
2521
+ );
2522
+ }
2523
+ };
2524
+
2525
+ // src/kms/key-providers/ed25519-provider.ts
2526
+ var import_ed255192 = require("@noble/curves/ed25519");
2527
+ var Ed25519Provider = class {
2528
+ /**
2529
+ * Creates an instance of Ed25519Provider.
2530
+ * @param {KmsKeyType} keyType - kms key type
2531
+ * @param {AbstractPrivateKeyStore} keyStore - key store for kms
2532
+ */
2533
+ constructor(keyType, _keyStore) {
2534
+ this.keyType = keyType;
2535
+ this._keyStore = _keyStore;
2536
+ }
2537
+ /**
2538
+ * get all keys
2539
+ * @returns list of keys
2540
+ */
2541
+ async list() {
2542
+ const allKeysFromKeyStore = await this._keyStore.list();
2543
+ return allKeysFromKeyStore.filter((key) => key.alias.startsWith(this.keyType));
2544
+ }
2545
+ /**
2546
+ * generates a ed25519 key from a seed phrase
2547
+ * @param {Uint8Array} seed - byte array seed
2548
+ * @returns {Promise<KmsKeyId>} kms key identifier
2549
+ */
2550
+ async newPrivateKeyFromSeed(seed) {
2551
+ if (seed.length !== 32) {
2552
+ throw new Error("Seed should be 32 bytes");
2553
+ }
2554
+ const publicKey = import_ed255192.ed25519.getPublicKey(seed);
2555
+ const kmsId = {
2556
+ type: this.keyType,
2557
+ id: keyPath(this.keyType, bytesToHex(publicKey))
2558
+ };
2559
+ await this._keyStore.importKey({
2560
+ alias: kmsId.id,
2561
+ key: bytesToHex(seed)
2562
+ });
2563
+ return kmsId;
2564
+ }
2565
+ /**
2566
+ * Gets public key by kmsKeyId
2567
+ * @param {KmsKeyId} keyId - key identifier
2568
+ * @returns {Promise<string>} Public key as a hex string
2569
+ */
2570
+ async publicKey(keyId) {
2571
+ const privateKeyHex = await this.privateKey(keyId);
2572
+ const publicKey = import_ed255192.ed25519.getPublicKey(privateKeyHex);
2573
+ return bytesToHex(publicKey);
2574
+ }
2575
+ /**
2576
+ * signs prepared payload of size,
2577
+ * with a key id
2578
+ * @param {KmsKeyId} keyId - key identifier
2579
+ * @param {Uint8Array} digest - data to sign (32 bytes)
2580
+ * @returns {Promise<Uint8Array>} signature
2581
+ */
2582
+ async sign(keyId, digest) {
2583
+ const privateKeyHex = await this.privateKey(keyId);
2584
+ return import_ed255192.ed25519.sign(digest, privateKeyHex);
2585
+ }
2586
+ /**
2587
+ * Verifies a signature for the given message and key identifier.
2588
+ * @param digest - The message to verify the signature against.
2589
+ * @param signatureHex - The signature to verify, as a hexadecimal string.
2590
+ * @param keyId - The key identifier to use for verification.
2591
+ * @returns A Promise that resolves to a boolean indicating whether the signature is valid.
2592
+ */
2593
+ async verify(digest, signatureHex, keyId) {
2594
+ const publicKeyHex = await this.publicKey(keyId);
2595
+ return import_ed255192.ed25519.verify(signatureHex, digest, publicKeyHex);
2596
+ }
2597
+ /**
2598
+ * Retrieves the private key for a given keyId from the key store.
2599
+ * @param {KmsKeyId} keyId - The identifier of the key to retrieve.
2600
+ * @returns {Promise<string>} The private key associated with the keyId.
2601
+ */
2602
+ async privateKey(keyId) {
2603
+ return this._keyStore.get({ alias: keyId.id });
2604
+ }
2605
+ };
2606
+
2607
+ // src/kms/key-providers/secp256k1-provider.ts
2608
+ var import_secp256k1 = require("@noble/curves/secp256k1");
2609
+ var import_js_crypto7 = require("@iden3/js-crypto");
2610
+ var import_did_jwt = require("did-jwt");
2611
+ var Sec256k1Provider = class {
2612
+ /**
2613
+ * key type that is handled by BJJ Provider
2614
+ * @type {KmsKeyType}
2615
+ */
2616
+ keyType;
2617
+ _keyStore;
2618
+ /**
2619
+ * Creates an instance of BjjProvider.
2620
+ * @param {KmsKeyType} keyType - kms key type
2621
+ * @param {AbstractPrivateKeyStore} keyStore - key store for kms
2622
+ */
2623
+ constructor(keyType, keyStore) {
2624
+ if (keyType !== "Secp256k1" /* Secp256k1 */) {
2625
+ throw new Error("Key type must be Secp256k1");
2626
+ }
2627
+ this.keyType = keyType;
2628
+ this._keyStore = keyStore;
2629
+ }
2630
+ /**
2631
+ * get all keys
2632
+ * @returns list of keys
2633
+ */
2634
+ async list() {
2635
+ const allKeysFromKeyStore = await this._keyStore.list();
2636
+ return allKeysFromKeyStore.filter((key) => key.alias.startsWith(this.keyType));
2637
+ }
2638
+ /**
2639
+ * generates a baby jub jub key from a seed phrase
2640
+ * @param {Uint8Array} seed - byte array seed
2641
+ * @returns kms key identifier
2642
+ */
2643
+ async newPrivateKeyFromSeed(seed) {
2644
+ if (seed.length !== 32) {
2645
+ throw new Error("Seed should be 32 bytes");
2646
+ }
2647
+ const publicKey = import_secp256k1.secp256k1.getPublicKey(seed);
2648
+ const kmsId = {
2649
+ type: this.keyType,
2650
+ id: keyPath(this.keyType, bytesToHex(publicKey))
2651
+ };
2652
+ await this._keyStore.importKey({
2653
+ alias: kmsId.id,
2654
+ key: bytesToHex(seed).padStart(64, "0")
2655
+ });
2656
+ return kmsId;
2657
+ }
2658
+ /**
2659
+ * Gets public key by kmsKeyId
2660
+ *
2661
+ * @param {KmsKeyId} keyId - key identifier
2662
+ */
2663
+ async publicKey(keyId) {
2664
+ const privateKeyHex = await this.privateKey(keyId);
2665
+ const publicKey = import_secp256k1.secp256k1.getPublicKey(privateKeyHex, false);
2666
+ return bytesToHex(publicKey);
2667
+ }
2668
+ /**
2669
+ * Signs the given data using the private key associated with the specified key identifier.
2670
+ * @param keyId - The key identifier to use for signing.
2671
+ * @param data - The data to sign.
2672
+ * @param opts - Signing options, such as the algorithm to use.
2673
+ * @returns A Promise that resolves to the signature as a Uint8Array.
2674
+ */
2675
+ async sign(keyId, data, opts = { alg: "ES256K" }) {
2676
+ const privateKeyHex = await this.privateKey(keyId);
2677
+ const signatureBase64 = await (0, import_did_jwt.ES256KSigner)(
2678
+ (0, import_did_jwt.hexToBytes)(privateKeyHex),
2679
+ opts.alg === "ES256K-R"
2680
+ )(data);
2681
+ if (typeof signatureBase64 !== "string") {
2682
+ throw new Error("signatureBase64 must be a string");
2683
+ }
2684
+ return base64UrlToBytes(signatureBase64);
2685
+ }
2686
+ /**
2687
+ * Verifies a signature for the given message and key identifier.
2688
+ * @param message - The message to verify the signature against.
2689
+ * @param signatureHex - The signature to verify, as a hexadecimal string.
2690
+ * @param keyId - The key identifier to use for verification.
2691
+ * @returns A Promise that resolves to a boolean indicating whether the signature is valid.
2692
+ */
2693
+ async verify(message, signatureHex, keyId) {
2694
+ const publicKeyHex = await this.publicKey(keyId);
2695
+ return import_secp256k1.secp256k1.verify(signatureHex, (0, import_js_crypto7.sha256)(message), publicKeyHex);
2696
+ }
2697
+ async privateKey(keyId) {
2698
+ return this._keyStore.get({ alias: keyId.id });
2699
+ }
2700
+ };
2701
+
2702
+ // src/identity/identity-wallet.ts
2703
+ var import_js_iden3_core42 = require("@iden3/js-iden3-core");
2704
+ var import_js_crypto12 = require("@iden3/js-crypto");
2705
+ var import_js_merkletree29 = require("@iden3/js-merkletree");
2307
2706
 
2308
2707
  // src/identity/common.ts
2708
+ var import_js_iden3_core9 = require("@iden3/js-iden3-core");
2309
2709
  var subjectPositionIndex = (idPosition) => {
2310
2710
  switch (idPosition) {
2311
- case import_js_iden3_core7.IdPosition.Index:
2711
+ case import_js_iden3_core9.IdPosition.Index:
2312
2712
  return "index" /* Index */;
2313
- case import_js_iden3_core7.IdPosition.Value:
2713
+ case import_js_iden3_core9.IdPosition.Value:
2314
2714
  return "value" /* Value */;
2315
2715
  default:
2316
2716
  return "" /* None */;
@@ -2318,21 +2718,21 @@ var subjectPositionIndex = (idPosition) => {
2318
2718
  };
2319
2719
  var defineMerklizedRootPosition = (metadata, position) => {
2320
2720
  if (!metadata?.serialization) {
2321
- return import_js_iden3_core7.MerklizedRootPosition.None;
2721
+ return import_js_iden3_core9.MerklizedRootPosition.None;
2322
2722
  }
2323
- if (position != null && position !== import_js_iden3_core7.MerklizedRootPosition.None) {
2723
+ if (position != null && position !== import_js_iden3_core9.MerklizedRootPosition.None) {
2324
2724
  return position;
2325
2725
  }
2326
- return import_js_iden3_core7.MerklizedRootPosition.Index;
2726
+ return import_js_iden3_core9.MerklizedRootPosition.Index;
2327
2727
  };
2328
2728
  var generateProfileDID = (did, profileNonce) => {
2329
- const id = import_js_iden3_core7.DID.idFromDID(did);
2729
+ const id = import_js_iden3_core9.DID.idFromDID(did);
2330
2730
  profileNonce = profileNonce ?? 0;
2331
2731
  if (!isBigInt(profileNonce)) {
2332
2732
  throw new Error("profile must be number or decimal string");
2333
2733
  }
2334
- const profile = import_js_iden3_core7.Id.profileId(id, BigInt(profileNonce));
2335
- return import_js_iden3_core7.DID.parseFromId(profile);
2734
+ const profile = import_js_iden3_core9.Id.profileId(id, BigInt(profileNonce));
2735
+ return import_js_iden3_core9.DID.parseFromId(profile);
2336
2736
  };
2337
2737
  var isBigInt = (x) => {
2338
2738
  try {
@@ -2346,7 +2746,7 @@ var isBigInt = (x) => {
2346
2746
  var uuid14 = __toESM(require("uuid"), 1);
2347
2747
 
2348
2748
  // src/schema-processor/utils.ts
2349
- var import_js_iden3_core8 = require("@iden3/js-iden3-core");
2749
+ var import_js_iden3_core10 = require("@iden3/js-iden3-core");
2350
2750
  var swapEndianness = (buf) => buf.reverse();
2351
2751
  function fieldToByteArray(field) {
2352
2752
  let bigIntField;
@@ -2357,13 +2757,13 @@ function fieldToByteArray(field) {
2357
2757
  } else {
2358
2758
  throw new Error("field type is not supported");
2359
2759
  }
2360
- return import_js_iden3_core8.BytesHelper.intToBytes(bigIntField);
2760
+ return import_js_iden3_core10.BytesHelper.intToBytes(bigIntField);
2361
2761
  }
2362
2762
  function dataFillsSlot(slot, newData) {
2363
- return (0, import_js_iden3_core8.checkBigIntInField)(import_js_iden3_core8.BytesHelper.bytesToInt(Uint8Array.from([...slot, ...newData])));
2763
+ return (0, import_js_iden3_core10.checkBigIntInField)(import_js_iden3_core10.BytesHelper.bytesToInt(Uint8Array.from([...slot, ...newData])));
2364
2764
  }
2365
2765
  function checkDataInField(data) {
2366
- return (0, import_js_iden3_core8.checkBigIntInField)(import_js_iden3_core8.BytesHelper.bytesToInt(data));
2766
+ return (0, import_js_iden3_core10.checkBigIntInField)(import_js_iden3_core10.BytesHelper.bytesToInt(data));
2367
2767
  }
2368
2768
  var createSchemaHash = (schemaId) => {
2369
2769
  return calculateCoreSchemaHash(schemaId);
@@ -3110,7 +3510,7 @@ var ValueProof = class {
3110
3510
  };
3111
3511
 
3112
3512
  // src/circuits/atomic-query-mtp-v2.ts
3113
- var import_js_iden3_core9 = require("@iden3/js-iden3-core");
3513
+ var import_js_iden3_core11 = require("@iden3/js-iden3-core");
3114
3514
  var import_js_merkletree6 = require("@iden3/js-merkletree");
3115
3515
  var AtomicQueryMTPV2Inputs = class extends BaseConfig {
3116
3516
  // auth
@@ -3223,11 +3623,11 @@ var AtomicQueryMTPV2PubSignals = class extends BaseConfig {
3223
3623
  let fieldIdx = 0;
3224
3624
  this.merklized = parseInt(sVals[fieldIdx]);
3225
3625
  fieldIdx++;
3226
- this.userID = import_js_iden3_core9.Id.fromBigInt(BigInt(sVals[fieldIdx]));
3626
+ this.userID = import_js_iden3_core11.Id.fromBigInt(BigInt(sVals[fieldIdx]));
3227
3627
  fieldIdx++;
3228
3628
  this.requestID = BigInt(sVals[fieldIdx]);
3229
3629
  fieldIdx++;
3230
- this.issuerID = import_js_iden3_core9.Id.fromBigInt(BigInt(sVals[fieldIdx]));
3630
+ this.issuerID = import_js_iden3_core11.Id.fromBigInt(BigInt(sVals[fieldIdx]));
3231
3631
  fieldIdx++;
3232
3632
  this.issuerClaimIdenState = import_js_merkletree6.Hash.fromString(sVals[fieldIdx]);
3233
3633
  fieldIdx++;
@@ -3237,7 +3637,7 @@ var AtomicQueryMTPV2PubSignals = class extends BaseConfig {
3237
3637
  fieldIdx++;
3238
3638
  this.timestamp = parseInt(sVals[fieldIdx]);
3239
3639
  fieldIdx++;
3240
- this.claimSchema = import_js_iden3_core9.SchemaHash.newSchemaHashFromInt(BigInt(sVals[fieldIdx]));
3640
+ this.claimSchema = import_js_iden3_core11.SchemaHash.newSchemaHashFromInt(BigInt(sVals[fieldIdx]));
3241
3641
  fieldIdx++;
3242
3642
  this.claimPathNotExists = parseInt(sVals[fieldIdx]);
3243
3643
  fieldIdx++;
@@ -3256,7 +3656,7 @@ var AtomicQueryMTPV2PubSignals = class extends BaseConfig {
3256
3656
  };
3257
3657
 
3258
3658
  // src/circuits/atomic-query-mtp-v2-on-chain.ts
3259
- var import_js_iden3_core10 = require("@iden3/js-iden3-core");
3659
+ var import_js_iden3_core12 = require("@iden3/js-iden3-core");
3260
3660
  var import_js_merkletree7 = require("@iden3/js-merkletree");
3261
3661
  var AtomicQueryMTPV2OnChainInputs = class extends BaseConfig {
3262
3662
  // auth
@@ -3401,7 +3801,7 @@ var AtomicQueryMTPV2OnChainPubSignals = class extends BaseConfig {
3401
3801
  let fieldIdx = 0;
3402
3802
  this.merklized = parseInt(sVals[fieldIdx]);
3403
3803
  fieldIdx++;
3404
- this.userID = import_js_iden3_core10.Id.fromBigInt(BigInt(sVals[fieldIdx]));
3804
+ this.userID = import_js_iden3_core12.Id.fromBigInt(BigInt(sVals[fieldIdx]));
3405
3805
  fieldIdx++;
3406
3806
  this.circuitQueryHash = BigInt(sVals[fieldIdx]);
3407
3807
  fieldIdx++;
@@ -3411,7 +3811,7 @@ var AtomicQueryMTPV2OnChainPubSignals = class extends BaseConfig {
3411
3811
  fieldIdx++;
3412
3812
  this.gistRoot = import_js_merkletree7.Hash.fromString(sVals[fieldIdx]);
3413
3813
  fieldIdx++;
3414
- this.issuerID = import_js_iden3_core10.Id.fromBigInt(BigInt(sVals[fieldIdx]));
3814
+ this.issuerID = import_js_iden3_core12.Id.fromBigInt(BigInt(sVals[fieldIdx]));
3415
3815
  fieldIdx++;
3416
3816
  this.issuerClaimIdenState = import_js_merkletree7.Hash.fromString(sVals[fieldIdx]);
3417
3817
  fieldIdx++;
@@ -3436,7 +3836,7 @@ var AtomicQueryMTPV2OnChainPubSignals = class extends BaseConfig {
3436
3836
  };
3437
3837
 
3438
3838
  // src/circuits/atomic-query-sig-v2.ts
3439
- var import_js_iden3_core11 = require("@iden3/js-iden3-core");
3839
+ var import_js_iden3_core13 = require("@iden3/js-iden3-core");
3440
3840
  var import_js_merkletree8 = require("@iden3/js-merkletree");
3441
3841
  var AtomicQuerySigV2Inputs = class extends BaseConfig {
3442
3842
  requestID;
@@ -3583,13 +3983,13 @@ var AtomicQuerySigV2PubSignals = class extends BaseConfig {
3583
3983
  let fieldIdx = 0;
3584
3984
  this.merklized = parseInt(sVals[fieldIdx]);
3585
3985
  fieldIdx++;
3586
- this.userID = import_js_iden3_core11.Id.fromBigInt(BigInt(sVals[fieldIdx]));
3986
+ this.userID = import_js_iden3_core13.Id.fromBigInt(BigInt(sVals[fieldIdx]));
3587
3987
  fieldIdx++;
3588
3988
  this.issuerAuthState = import_js_merkletree8.Hash.fromString(sVals[fieldIdx]);
3589
3989
  fieldIdx++;
3590
3990
  this.requestID = BigInt(sVals[fieldIdx]);
3591
3991
  fieldIdx++;
3592
- this.issuerID = import_js_iden3_core11.Id.fromBigInt(BigInt(sVals[fieldIdx]));
3992
+ this.issuerID = import_js_iden3_core13.Id.fromBigInt(BigInt(sVals[fieldIdx]));
3593
3993
  fieldIdx++;
3594
3994
  this.isRevocationChecked = parseInt(sVals[fieldIdx]);
3595
3995
  fieldIdx++;
@@ -3597,7 +3997,7 @@ var AtomicQuerySigV2PubSignals = class extends BaseConfig {
3597
3997
  fieldIdx++;
3598
3998
  this.timestamp = parseInt(sVals[fieldIdx]);
3599
3999
  fieldIdx++;
3600
- this.claimSchema = import_js_iden3_core11.SchemaHash.newSchemaHashFromInt(BigInt(sVals[fieldIdx]));
4000
+ this.claimSchema = import_js_iden3_core13.SchemaHash.newSchemaHashFromInt(BigInt(sVals[fieldIdx]));
3601
4001
  fieldIdx++;
3602
4002
  this.claimPathNotExists = parseInt(sVals[fieldIdx]);
3603
4003
  fieldIdx++;
@@ -3616,7 +4016,7 @@ var AtomicQuerySigV2PubSignals = class extends BaseConfig {
3616
4016
  };
3617
4017
 
3618
4018
  // src/circuits/atomic-query-v3.ts
3619
- var import_js_iden3_core12 = require("@iden3/js-iden3-core");
4019
+ var import_js_iden3_core14 = require("@iden3/js-iden3-core");
3620
4020
  var import_js_merkletree9 = require("@iden3/js-merkletree");
3621
4021
  var zero = "0";
3622
4022
  var AtomicQueryV3Inputs = class extends BaseConfig {
@@ -3674,7 +4074,7 @@ var AtomicQueryV3Inputs = class extends BaseConfig {
3674
4074
  s.issuerClaimSignatureR8x = zero;
3675
4075
  s.issuerClaimSignatureR8y = zero;
3676
4076
  s.issuerClaimSignatureS = zero;
3677
- s.issuerAuthClaim = new import_js_iden3_core12.Claim().marshalJson();
4077
+ s.issuerAuthClaim = new import_js_iden3_core14.Claim().marshalJson();
3678
4078
  s.issuerAuthClaimMtp = prepareSiblingsStr(new import_js_merkletree9.Proof(), this.getMTLevel());
3679
4079
  s.issuerAuthClaimsTreeRoot = zero;
3680
4080
  s.issuerAuthRevTreeRoot = zero;
@@ -3821,7 +4221,7 @@ var AtomicQueryV3PubSignals = class extends BaseConfig {
3821
4221
  let fieldIdx = 0;
3822
4222
  this.merklized = parseInt(sVals[fieldIdx]);
3823
4223
  fieldIdx++;
3824
- this.userID = import_js_iden3_core12.Id.fromBigInt(BigInt(sVals[fieldIdx]));
4224
+ this.userID = import_js_iden3_core14.Id.fromBigInt(BigInt(sVals[fieldIdx]));
3825
4225
  fieldIdx++;
3826
4226
  this.issuerState = import_js_merkletree9.Hash.fromString(sVals[fieldIdx]);
3827
4227
  fieldIdx++;
@@ -3835,7 +4235,7 @@ var AtomicQueryV3PubSignals = class extends BaseConfig {
3835
4235
  fieldIdx++;
3836
4236
  this.requestID = BigInt(sVals[fieldIdx]);
3837
4237
  fieldIdx++;
3838
- this.issuerID = import_js_iden3_core12.Id.fromBigInt(BigInt(sVals[fieldIdx]));
4238
+ this.issuerID = import_js_iden3_core14.Id.fromBigInt(BigInt(sVals[fieldIdx]));
3839
4239
  fieldIdx++;
3840
4240
  this.isRevocationChecked = parseInt(sVals[fieldIdx]);
3841
4241
  fieldIdx++;
@@ -3843,7 +4243,7 @@ var AtomicQueryV3PubSignals = class extends BaseConfig {
3843
4243
  fieldIdx++;
3844
4244
  this.timestamp = parseInt(sVals[fieldIdx]);
3845
4245
  fieldIdx++;
3846
- this.claimSchema = import_js_iden3_core12.SchemaHash.newSchemaHashFromInt(BigInt(sVals[fieldIdx]));
4246
+ this.claimSchema = import_js_iden3_core14.SchemaHash.newSchemaHashFromInt(BigInt(sVals[fieldIdx]));
3847
4247
  fieldIdx++;
3848
4248
  this.claimPathKey = BigInt(sVals[fieldIdx]);
3849
4249
  fieldIdx++;
@@ -3858,7 +4258,7 @@ var AtomicQueryV3PubSignals = class extends BaseConfig {
3858
4258
  this.valueArraySize = parseInt(sVals[fieldIdx]);
3859
4259
  fieldIdx++;
3860
4260
  if (sVals[fieldIdx] !== "0") {
3861
- this.verifierID = import_js_iden3_core12.Id.fromBigInt(BigInt(sVals[fieldIdx]));
4261
+ this.verifierID = import_js_iden3_core14.Id.fromBigInt(BigInt(sVals[fieldIdx]));
3862
4262
  }
3863
4263
  fieldIdx++;
3864
4264
  this.nullifierSessionID = BigInt(sVals[fieldIdx]);
@@ -3867,7 +4267,7 @@ var AtomicQueryV3PubSignals = class extends BaseConfig {
3867
4267
  };
3868
4268
 
3869
4269
  // src/circuits/atomic-query-v3-on-chain.ts
3870
- var import_js_iden3_core13 = require("@iden3/js-iden3-core");
4270
+ var import_js_iden3_core15 = require("@iden3/js-iden3-core");
3871
4271
  var import_js_merkletree10 = require("@iden3/js-merkletree");
3872
4272
  var zero2 = "0";
3873
4273
  var AtomicQueryV3OnChainInputs = class extends BaseConfig {
@@ -3951,7 +4351,7 @@ var AtomicQueryV3OnChainInputs = class extends BaseConfig {
3951
4351
  s.issuerClaimSignatureR8x = zero2;
3952
4352
  s.issuerClaimSignatureR8y = zero2;
3953
4353
  s.issuerClaimSignatureS = zero2;
3954
- s.issuerAuthClaim = new import_js_iden3_core13.Claim().marshalJson();
4354
+ s.issuerAuthClaim = new import_js_iden3_core15.Claim().marshalJson();
3955
4355
  s.issuerAuthClaimMtp = prepareSiblingsStr(new import_js_merkletree10.Proof(), this.getMTLevel());
3956
4356
  s.issuerAuthClaimsTreeRoot = zero2;
3957
4357
  s.issuerAuthRevTreeRoot = zero2;
@@ -3963,7 +4363,7 @@ var AtomicQueryV3OnChainInputs = class extends BaseConfig {
3963
4363
  s.issuerAuthState = zero2;
3964
4364
  }
3965
4365
  fillAuthWithZero(s) {
3966
- s.authClaim = new import_js_iden3_core13.Claim().marshalJson();
4366
+ s.authClaim = new import_js_iden3_core15.Claim().marshalJson();
3967
4367
  s.userClaimsTreeRoot = import_js_merkletree10.ZERO_HASH.bigInt().toString();
3968
4368
  s.userRevTreeRoot = import_js_merkletree10.ZERO_HASH.bigInt().toString();
3969
4369
  s.userRootsTreeRoot = import_js_merkletree10.ZERO_HASH.bigInt().toString();
@@ -4134,7 +4534,7 @@ var AtomicQueryV3OnChainPubSignals = class extends BaseConfig {
4134
4534
  pubSignalsUnmarshal(data) {
4135
4535
  const sVals = JSON.parse(byteDecoder.decode(data));
4136
4536
  let fieldIdx = 0;
4137
- this.userID = import_js_iden3_core13.Id.fromBigInt(BigInt(sVals[fieldIdx]));
4537
+ this.userID = import_js_iden3_core15.Id.fromBigInt(BigInt(sVals[fieldIdx]));
4138
4538
  fieldIdx++;
4139
4539
  this.circuitQueryHash = BigInt(sVals[fieldIdx]);
4140
4540
  fieldIdx++;
@@ -4154,7 +4554,7 @@ var AtomicQueryV3OnChainPubSignals = class extends BaseConfig {
4154
4554
  fieldIdx++;
4155
4555
  this.gistRoot = import_js_merkletree10.Hash.fromString(sVals[fieldIdx]);
4156
4556
  fieldIdx++;
4157
- this.issuerID = import_js_iden3_core13.Id.fromBigInt(BigInt(sVals[fieldIdx]));
4557
+ this.issuerID = import_js_iden3_core15.Id.fromBigInt(BigInt(sVals[fieldIdx]));
4158
4558
  fieldIdx++;
4159
4559
  this.issuerClaimNonRevState = import_js_merkletree10.Hash.fromString(sVals[fieldIdx]);
4160
4560
  fieldIdx++;
@@ -4176,7 +4576,7 @@ var AtomicQueryV3OnChainPubSignals = class extends BaseConfig {
4176
4576
  };
4177
4577
 
4178
4578
  // src/circuits/atomic-query-sig-v2-on-chain.ts
4179
- var import_js_iden3_core14 = require("@iden3/js-iden3-core");
4579
+ var import_js_iden3_core16 = require("@iden3/js-iden3-core");
4180
4580
  var import_js_merkletree11 = require("@iden3/js-merkletree");
4181
4581
  var AtomicQuerySigV2OnChainInputs = class extends BaseConfig {
4182
4582
  requestID;
@@ -4427,7 +4827,7 @@ var AtomicQuerySigV2OnChainPubSignals = class extends BaseConfig {
4427
4827
  let fieldIdx = 0;
4428
4828
  this.merklized = parseInt(sVals[fieldIdx]);
4429
4829
  fieldIdx++;
4430
- this.userID = import_js_iden3_core14.Id.fromBigInt(BigInt(sVals[fieldIdx]));
4830
+ this.userID = import_js_iden3_core16.Id.fromBigInt(BigInt(sVals[fieldIdx]));
4431
4831
  fieldIdx++;
4432
4832
  this.circuitQueryHash = BigInt(sVals[fieldIdx]);
4433
4833
  fieldIdx++;
@@ -4439,7 +4839,7 @@ var AtomicQuerySigV2OnChainPubSignals = class extends BaseConfig {
4439
4839
  fieldIdx++;
4440
4840
  this.gistRoot = import_js_merkletree11.Hash.fromString(sVals[fieldIdx]);
4441
4841
  fieldIdx++;
4442
- this.issuerID = import_js_iden3_core14.Id.fromBigInt(BigInt(sVals[fieldIdx]));
4842
+ this.issuerID = import_js_iden3_core16.Id.fromBigInt(BigInt(sVals[fieldIdx]));
4443
4843
  fieldIdx++;
4444
4844
  this.isRevocationChecked = parseInt(sVals[fieldIdx]);
4445
4845
  fieldIdx++;
@@ -4463,7 +4863,7 @@ var AtomicQuerySigV2OnChainPubSignals = class extends BaseConfig {
4463
4863
 
4464
4864
  // src/circuits/auth-v2.ts
4465
4865
  var import_js_merkletree12 = require("@iden3/js-merkletree");
4466
- var import_js_iden3_core15 = require("@iden3/js-iden3-core");
4866
+ var import_js_iden3_core17 = require("@iden3/js-iden3-core");
4467
4867
  var AuthV2Inputs = class extends BaseConfig {
4468
4868
  genesisID;
4469
4869
  profileNonce;
@@ -4541,7 +4941,7 @@ var AuthV2PubSignals = class {
4541
4941
  if (sVals.length !== len) {
4542
4942
  throw new Error(`invalid number of Output values expected ${len} got ${sVals.length}`);
4543
4943
  }
4544
- this.userID = import_js_iden3_core15.Id.fromBigInt(BigInt(sVals[0]));
4944
+ this.userID = import_js_iden3_core17.Id.fromBigInt(BigInt(sVals[0]));
4545
4945
  this.challenge = BigInt(sVals[1]);
4546
4946
  this.GISTRoot = import_js_merkletree12.Hash.fromString(sVals[2]);
4547
4947
  return this;
@@ -4555,7 +4955,7 @@ var AuthV2PubSignals = class {
4555
4955
  };
4556
4956
 
4557
4957
  // src/circuits/state-transition.ts
4558
- var import_js_iden3_core16 = require("@iden3/js-iden3-core");
4958
+ var import_js_iden3_core18 = require("@iden3/js-iden3-core");
4559
4959
  var import_js_merkletree13 = require("@iden3/js-merkletree");
4560
4960
  var StateTransitionInputs = class extends BaseConfig {
4561
4961
  id;
@@ -4630,7 +5030,7 @@ var StateTransitionPubSignals = class {
4630
5030
  `invalid number of Output values expected ${fieldLength} got ${sVals.length}`
4631
5031
  );
4632
5032
  }
4633
- this.userId = import_js_iden3_core16.Id.fromBigInt(BigInt(sVals[0]));
5033
+ this.userId = import_js_iden3_core18.Id.fromBigInt(BigInt(sVals[0]));
4634
5034
  this.oldUserState = import_js_merkletree13.Hash.fromString(sVals[1]);
4635
5035
  this.newUserState = import_js_merkletree13.Hash.fromString(sVals[2]);
4636
5036
  this.isOldStateGenesis = BigInt(sVals[3]) === BigInt(1);
@@ -4752,7 +5152,7 @@ var LinkedMultiQueryPubSignals = class {
4752
5152
  var State_default = [{ inputs: [], stateMutability: "nonpayable", type: "constructor" }, { anonymous: false, inputs: [{ indexed: false, internalType: "uint8", name: "version", type: "uint8" }], name: "Initialized", type: "event" }, { anonymous: false, inputs: [{ indexed: true, internalType: "address", name: "previousOwner", type: "address" }, { indexed: true, internalType: "address", name: "newOwner", type: "address" }], name: "OwnershipTransferStarted", type: "event" }, { anonymous: false, inputs: [{ indexed: true, internalType: "address", name: "previousOwner", type: "address" }, { indexed: true, internalType: "address", name: "newOwner", type: "address" }], name: "OwnershipTransferred", type: "event" }, { inputs: [], name: "VERSION", outputs: [{ internalType: "string", name: "", type: "string" }], stateMutability: "view", type: "function" }, { inputs: [], name: "acceptOwnership", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [], name: "getDefaultIdType", outputs: [{ internalType: "bytes2", name: "", type: "bytes2" }], stateMutability: "view", type: "function" }, { inputs: [{ internalType: "uint256", name: "id", type: "uint256" }], name: "getGISTProof", outputs: [{ components: [{ internalType: "uint256", name: "root", type: "uint256" }, { internalType: "bool", name: "existence", type: "bool" }, { internalType: "uint256[64]", name: "siblings", type: "uint256[64]" }, { internalType: "uint256", name: "index", type: "uint256" }, { internalType: "uint256", name: "value", type: "uint256" }, { internalType: "bool", name: "auxExistence", type: "bool" }, { internalType: "uint256", name: "auxIndex", type: "uint256" }, { internalType: "uint256", name: "auxValue", type: "uint256" }], internalType: "structIState.GistProof", name: "", type: "tuple" }], stateMutability: "view", type: "function" }, { inputs: [{ internalType: "uint256", name: "id", type: "uint256" }, { internalType: "uint256", name: "blockNumber", type: "uint256" }], name: "getGISTProofByBlock", outputs: [{ components: [{ internalType: "uint256", name: "root", type: "uint256" }, { internalType: "bool", name: "existence", type: "bool" }, { internalType: "uint256[64]", name: "siblings", type: "uint256[64]" }, { internalType: "uint256", name: "index", type: "uint256" }, { internalType: "uint256", name: "value", type: "uint256" }, { internalType: "bool", name: "auxExistence", type: "bool" }, { internalType: "uint256", name: "auxIndex", type: "uint256" }, { internalType: "uint256", name: "auxValue", type: "uint256" }], internalType: "structIState.GistProof", name: "", type: "tuple" }], stateMutability: "view", type: "function" }, { inputs: [{ internalType: "uint256", name: "id", type: "uint256" }, { internalType: "uint256", name: "root", type: "uint256" }], name: "getGISTProofByRoot", outputs: [{ components: [{ internalType: "uint256", name: "root", type: "uint256" }, { internalType: "bool", name: "existence", type: "bool" }, { internalType: "uint256[64]", name: "siblings", type: "uint256[64]" }, { internalType: "uint256", name: "index", type: "uint256" }, { internalType: "uint256", name: "value", type: "uint256" }, { internalType: "bool", name: "auxExistence", type: "bool" }, { internalType: "uint256", name: "auxIndex", type: "uint256" }, { internalType: "uint256", name: "auxValue", type: "uint256" }], internalType: "structIState.GistProof", name: "", type: "tuple" }], stateMutability: "view", type: "function" }, { inputs: [{ internalType: "uint256", name: "id", type: "uint256" }, { internalType: "uint256", name: "timestamp", type: "uint256" }], name: "getGISTProofByTime", outputs: [{ components: [{ internalType: "uint256", name: "root", type: "uint256" }, { internalType: "bool", name: "existence", type: "bool" }, { internalType: "uint256[64]", name: "siblings", type: "uint256[64]" }, { internalType: "uint256", name: "index", type: "uint256" }, { internalType: "uint256", name: "value", type: "uint256" }, { internalType: "bool", name: "auxExistence", type: "bool" }, { internalType: "uint256", name: "auxIndex", type: "uint256" }, { internalType: "uint256", name: "auxValue", type: "uint256" }], internalType: "structIState.GistProof", name: "", type: "tuple" }], stateMutability: "view", type: "function" }, { inputs: [], name: "getGISTRoot", outputs: [{ internalType: "uint256", name: "", type: "uint256" }], stateMutability: "view", type: "function" }, { inputs: [{ internalType: "uint256", name: "start", type: "uint256" }, { internalType: "uint256", name: "length", type: "uint256" }], name: "getGISTRootHistory", outputs: [{ components: [{ internalType: "uint256", name: "root", type: "uint256" }, { internalType: "uint256", name: "replacedByRoot", type: "uint256" }, { internalType: "uint256", name: "createdAtTimestamp", type: "uint256" }, { internalType: "uint256", name: "replacedAtTimestamp", type: "uint256" }, { internalType: "uint256", name: "createdAtBlock", type: "uint256" }, { internalType: "uint256", name: "replacedAtBlock", type: "uint256" }], internalType: "structIState.GistRootInfo[]", name: "", type: "tuple[]" }], stateMutability: "view", type: "function" }, { inputs: [], name: "getGISTRootHistoryLength", outputs: [{ internalType: "uint256", name: "", type: "uint256" }], stateMutability: "view", type: "function" }, { inputs: [{ internalType: "uint256", name: "root", type: "uint256" }], name: "getGISTRootInfo", outputs: [{ components: [{ internalType: "uint256", name: "root", type: "uint256" }, { internalType: "uint256", name: "replacedByRoot", type: "uint256" }, { internalType: "uint256", name: "createdAtTimestamp", type: "uint256" }, { internalType: "uint256", name: "replacedAtTimestamp", type: "uint256" }, { internalType: "uint256", name: "createdAtBlock", type: "uint256" }, { internalType: "uint256", name: "replacedAtBlock", type: "uint256" }], internalType: "structIState.GistRootInfo", name: "", type: "tuple" }], stateMutability: "view", type: "function" }, { inputs: [{ internalType: "uint256", name: "blockNumber", type: "uint256" }], name: "getGISTRootInfoByBlock", outputs: [{ components: [{ internalType: "uint256", name: "root", type: "uint256" }, { internalType: "uint256", name: "replacedByRoot", type: "uint256" }, { internalType: "uint256", name: "createdAtTimestamp", type: "uint256" }, { internalType: "uint256", name: "replacedAtTimestamp", type: "uint256" }, { internalType: "uint256", name: "createdAtBlock", type: "uint256" }, { internalType: "uint256", name: "replacedAtBlock", type: "uint256" }], internalType: "structIState.GistRootInfo", name: "", type: "tuple" }], stateMutability: "view", type: "function" }, { inputs: [{ internalType: "uint256", name: "timestamp", type: "uint256" }], name: "getGISTRootInfoByTime", outputs: [{ components: [{ internalType: "uint256", name: "root", type: "uint256" }, { internalType: "uint256", name: "replacedByRoot", type: "uint256" }, { internalType: "uint256", name: "createdAtTimestamp", type: "uint256" }, { internalType: "uint256", name: "replacedAtTimestamp", type: "uint256" }, { internalType: "uint256", name: "createdAtBlock", type: "uint256" }, { internalType: "uint256", name: "replacedAtBlock", type: "uint256" }], internalType: "structIState.GistRootInfo", name: "", type: "tuple" }], stateMutability: "view", type: "function" }, { inputs: [{ internalType: "uint256", name: "id", type: "uint256" }], name: "getStateInfoById", outputs: [{ components: [{ internalType: "uint256", name: "id", type: "uint256" }, { internalType: "uint256", name: "state", type: "uint256" }, { internalType: "uint256", name: "replacedByState", type: "uint256" }, { internalType: "uint256", name: "createdAtTimestamp", type: "uint256" }, { internalType: "uint256", name: "replacedAtTimestamp", type: "uint256" }, { internalType: "uint256", name: "createdAtBlock", type: "uint256" }, { internalType: "uint256", name: "replacedAtBlock", type: "uint256" }], internalType: "structIState.StateInfo", name: "", type: "tuple" }], stateMutability: "view", type: "function" }, { inputs: [{ internalType: "uint256", name: "id", type: "uint256" }, { internalType: "uint256", name: "state", type: "uint256" }], name: "getStateInfoByIdAndState", outputs: [{ components: [{ internalType: "uint256", name: "id", type: "uint256" }, { internalType: "uint256", name: "state", type: "uint256" }, { internalType: "uint256", name: "replacedByState", type: "uint256" }, { internalType: "uint256", name: "createdAtTimestamp", type: "uint256" }, { internalType: "uint256", name: "replacedAtTimestamp", type: "uint256" }, { internalType: "uint256", name: "createdAtBlock", type: "uint256" }, { internalType: "uint256", name: "replacedAtBlock", type: "uint256" }], internalType: "structIState.StateInfo", name: "", type: "tuple" }], stateMutability: "view", type: "function" }, { inputs: [{ internalType: "uint256", name: "id", type: "uint256" }, { internalType: "uint256", name: "startIndex", type: "uint256" }, { internalType: "uint256", name: "length", type: "uint256" }], name: "getStateInfoHistoryById", outputs: [{ components: [{ internalType: "uint256", name: "id", type: "uint256" }, { internalType: "uint256", name: "state", type: "uint256" }, { internalType: "uint256", name: "replacedByState", type: "uint256" }, { internalType: "uint256", name: "createdAtTimestamp", type: "uint256" }, { internalType: "uint256", name: "replacedAtTimestamp", type: "uint256" }, { internalType: "uint256", name: "createdAtBlock", type: "uint256" }, { internalType: "uint256", name: "replacedAtBlock", type: "uint256" }], internalType: "structIState.StateInfo[]", name: "", type: "tuple[]" }], stateMutability: "view", type: "function" }, { inputs: [{ internalType: "uint256", name: "id", type: "uint256" }], name: "getStateInfoHistoryLengthById", outputs: [{ internalType: "uint256", name: "", type: "uint256" }], stateMutability: "view", type: "function" }, { inputs: [], name: "getVerifier", outputs: [{ internalType: "address", name: "", type: "address" }], stateMutability: "view", type: "function" }, { inputs: [{ internalType: "uint256", name: "id", type: "uint256" }], name: "idExists", outputs: [{ internalType: "bool", name: "", type: "bool" }], stateMutability: "view", type: "function" }, { inputs: [{ internalType: "contractIStateTransitionVerifier", name: "verifierContractAddr", type: "address" }, { internalType: "bytes2", name: "defaultIdType", type: "bytes2" }], name: "initialize", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [], name: "owner", outputs: [{ internalType: "address", name: "", type: "address" }], stateMutability: "view", type: "function" }, { inputs: [], name: "pendingOwner", outputs: [{ internalType: "address", name: "", type: "address" }], stateMutability: "view", type: "function" }, { inputs: [], name: "renounceOwnership", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [{ internalType: "bytes2", name: "defaultIdType", type: "bytes2" }], name: "setDefaultIdType", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [{ internalType: "address", name: "newVerifierAddr", type: "address" }], name: "setVerifier", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [{ internalType: "uint256", name: "id", type: "uint256" }, { internalType: "uint256", name: "state", type: "uint256" }], name: "stateExists", outputs: [{ internalType: "bool", name: "", type: "bool" }], stateMutability: "view", type: "function" }, { inputs: [{ internalType: "address", name: "newOwner", type: "address" }], name: "transferOwnership", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [{ internalType: "uint256", name: "id", type: "uint256" }, { internalType: "uint256", name: "oldState", type: "uint256" }, { internalType: "uint256", name: "newState", type: "uint256" }, { internalType: "bool", name: "isOldStateGenesis", type: "bool" }, { internalType: "uint256[2]", name: "a", type: "uint256[2]" }, { internalType: "uint256[2][2]", name: "b", type: "uint256[2][2]" }, { internalType: "uint256[2]", name: "c", type: "uint256[2]" }], name: "transitState", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [{ internalType: "uint256", name: "id", type: "uint256" }, { internalType: "uint256", name: "oldState", type: "uint256" }, { internalType: "uint256", name: "newState", type: "uint256" }, { internalType: "bool", name: "isOldStateGenesis", type: "bool" }, { internalType: "uint256", name: "methodId", type: "uint256" }, { internalType: "bytes", name: "methodParams", type: "bytes" }], name: "transitStateGeneric", outputs: [], stateMutability: "nonpayable", type: "function" }];
4753
5153
 
4754
5154
  // src/storage/blockchain/state.ts
4755
- var import_js_iden3_core30 = require("@iden3/js-iden3-core");
5155
+ var import_js_iden3_core32 = require("@iden3/js-iden3-core");
4756
5156
 
4757
5157
  // src/blockchain/transaction-service.ts
4758
5158
  var TransactionService = class {
@@ -4801,9 +5201,9 @@ var TransactionService = class {
4801
5201
  };
4802
5202
 
4803
5203
  // src/storage/blockchain/common.ts
4804
- var import_ethers3 = require("ethers");
5204
+ var import_ethers4 = require("ethers");
4805
5205
  var packZkpProof = (inputs, a, b, c) => {
4806
- return new import_ethers3.ethers.AbiCoder().encode(
5206
+ return new import_ethers4.ethers.AbiCoder().encode(
4807
5207
  ["uint256[] inputs", "uint256[2]", "uint256[2][2]", "uint256[2]"],
4808
5208
  [inputs, a, b, c]
4809
5209
  );
@@ -5405,7 +5805,7 @@ var PackageManager = class {
5405
5805
 
5406
5806
  // src/iden3comm/packers/zkp.ts
5407
5807
  var import_js_jwz2 = require("@iden3/js-jwz");
5408
- var import_js_iden3_core17 = require("@iden3/js-iden3-core");
5808
+ var import_js_iden3_core19 = require("@iden3/js-iden3-core");
5409
5809
 
5410
5810
  // src/iden3comm/constants.ts
5411
5811
  var constants_exports = {};
@@ -5822,9 +6222,9 @@ var verifySender = async (token, msg) => {
5822
6222
  const authSignals = new AuthV2PubSignals().pubSignalsUnmarshal(
5823
6223
  byteEncoder.encode(JSON.stringify(token.zkProof.pub_signals))
5824
6224
  );
5825
- const did = import_js_iden3_core17.DID.parseFromId(authSignals.userID);
6225
+ const did = import_js_iden3_core19.DID.parseFromId(authSignals.userID);
5826
6226
  const msgHash = await token.getMessageHash();
5827
- const challenge = import_js_iden3_core17.BytesHelper.bytesToInt(msgHash.reverse());
6227
+ const challenge = import_js_iden3_core19.BytesHelper.bytesToInt(msgHash.reverse());
5828
6228
  if (challenge !== authSignals.challenge) {
5829
6229
  throw new Error(ErrSenderNotUsedTokenCreation);
5830
6230
  }
@@ -6101,14 +6501,14 @@ var DiscoveryProtocolFeatureType = /* @__PURE__ */ ((DiscoveryProtocolFeatureTyp
6101
6501
  })(DiscoveryProtocolFeatureType || {});
6102
6502
 
6103
6503
  // src/iden3comm/handlers/auth.ts
6104
- var import_js_iden3_core19 = require("@iden3/js-iden3-core");
6504
+ var import_js_iden3_core21 = require("@iden3/js-iden3-core");
6105
6505
  var import_js_jwz4 = require("@iden3/js-jwz");
6106
6506
  var uuid2 = __toESM(require("uuid"), 1);
6107
6507
 
6108
6508
  // src/iden3comm/handlers/common.ts
6109
6509
  var import_js_crypto9 = require("@iden3/js-crypto");
6110
- var import_js_iden3_core18 = require("@iden3/js-iden3-core");
6111
- var import_ethers4 = require("ethers");
6510
+ var import_js_iden3_core20 = require("@iden3/js-iden3-core");
6511
+ var import_ethers5 = require("ethers");
6112
6512
  var getGroupedQueries = (requestScope) => requestScope.reduce((acc, proofReq) => {
6113
6513
  const groupId = proofReq.query.groupId;
6114
6514
  if (!groupId) {
@@ -6275,8 +6675,8 @@ var calcChallengeAuthV2 = (senderAddress, zkpResponses) => {
6275
6675
  };
6276
6676
  });
6277
6677
  return BigInt(
6278
- import_ethers4.ethers.keccak256(
6279
- new import_ethers4.ethers.AbiCoder().encode(
6678
+ import_ethers5.ethers.keccak256(
6679
+ new import_ethers5.ethers.AbiCoder().encode(
6280
6680
  ["address", "(uint256 requestId,bytes proof,bytes metadata)[]"],
6281
6681
  [senderAddress, responses]
6282
6682
  )
@@ -6284,10 +6684,10 @@ var calcChallengeAuthV2 = (senderAddress, zkpResponses) => {
6284
6684
  ) & BigInt("0x0fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
6285
6685
  };
6286
6686
  var packMetadatas = (metas) => {
6287
- return new import_ethers4.ethers.AbiCoder().encode(["tuple(string key,bytes value)[]"], [metas]);
6687
+ return new import_ethers5.ethers.AbiCoder().encode(["tuple(string key,bytes value)[]"], [metas]);
6288
6688
  };
6289
6689
  var verifyExpiresTime = (message) => {
6290
- if (message?.expires_time && message.expires_time < (0, import_js_iden3_core18.getUnixTimestamp)(/* @__PURE__ */ new Date())) {
6690
+ if (message?.expires_time && message.expires_time < (0, import_js_iden3_core20.getUnixTimestamp)(/* @__PURE__ */ new Date())) {
6291
6691
  throw new Error("Message expired");
6292
6692
  }
6293
6693
  };
@@ -6405,8 +6805,8 @@ function createAuthorizationRequestWithMessage(reason, message, sender, callback
6405
6805
  callbackUrl,
6406
6806
  scope: opts?.scope ?? []
6407
6807
  },
6408
- created_time: (0, import_js_iden3_core19.getUnixTimestamp)(/* @__PURE__ */ new Date()),
6409
- expires_time: opts?.expires_time ? (0, import_js_iden3_core19.getUnixTimestamp)(opts.expires_time) : void 0,
6808
+ created_time: (0, import_js_iden3_core21.getUnixTimestamp)(/* @__PURE__ */ new Date()),
6809
+ expires_time: opts?.expires_time ? (0, import_js_iden3_core21.getUnixTimestamp)(opts.expires_time) : void 0,
6410
6810
  attachments: opts?.attachments
6411
6811
  };
6412
6812
  return request;
@@ -6461,7 +6861,7 @@ var AuthHandler = class extends AbstractMessageHandler {
6461
6861
  if (authRequest.type !== PROTOCOL_MESSAGE_TYPE.AUTHORIZATION_REQUEST_MESSAGE_TYPE) {
6462
6862
  throw new Error("Invalid message type for authorization request");
6463
6863
  }
6464
- const to = authRequest.to ? import_js_iden3_core19.DID.parse(authRequest.to) : ctx.senderDid;
6864
+ const to = authRequest.to ? import_js_iden3_core21.DID.parse(authRequest.to) : ctx.senderDid;
6465
6865
  const guid = uuid2.v4();
6466
6866
  if (!authRequest.from) {
6467
6867
  throw new Error("auth request should contain from field");
@@ -6472,7 +6872,7 @@ var AuthHandler = class extends AbstractMessageHandler {
6472
6872
  responseType,
6473
6873
  authRequest.body.accept
6474
6874
  );
6475
- const from = import_js_iden3_core19.DID.parse(authRequest.from);
6875
+ const from = import_js_iden3_core21.DID.parse(authRequest.from);
6476
6876
  const responseScope = await processZeroKnowledgeProofRequests(
6477
6877
  to,
6478
6878
  authRequest?.body.scope,
@@ -6560,7 +6960,7 @@ var AuthHandler = class extends AbstractMessageHandler {
6560
6960
  );
6561
6961
  }
6562
6962
  const params = proofRequest.params ?? {};
6563
- params.verifierDid = import_js_iden3_core19.DID.parse(request.from);
6963
+ params.verifierDid = import_js_iden3_core21.DID.parse(request.from);
6564
6964
  const opts = [ctx.acceptedProofGenerationDelay, ctx.acceptedStateTransitionDelay].some(
6565
6965
  (delay) => delay !== void 0
6566
6966
  ) ? {
@@ -6653,7 +7053,7 @@ var AuthHandler = class extends AbstractMessageHandler {
6653
7053
  };
6654
7054
 
6655
7055
  // src/storage/blockchain/onchain-revocation.ts
6656
- var import_ethers5 = require("ethers");
7056
+ var import_ethers6 = require("ethers");
6657
7057
  var import_js_merkletree16 = require("@iden3/js-merkletree");
6658
7058
 
6659
7059
  // src/storage/blockchain/abi/CredentialStatusResolver.json
@@ -6671,8 +7071,8 @@ var OnChainRevocationStorage = class _OnChainRevocationStorage {
6671
7071
  constructor(_config, contractAddress, _signer) {
6672
7072
  this._config = _config;
6673
7073
  this._signer = _signer;
6674
- this._provider = new import_ethers5.JsonRpcProvider(_config.url);
6675
- let contract = new import_ethers5.Contract(contractAddress, CredentialStatusResolver_default, this._provider);
7074
+ this._provider = new import_ethers6.JsonRpcProvider(_config.url);
7075
+ let contract = new import_ethers6.Contract(contractAddress, CredentialStatusResolver_default, this._provider);
6676
7076
  if (this._signer) {
6677
7077
  this._signer = this._signer.connect(this._provider);
6678
7078
  contract = contract.connect(this._signer);
@@ -6758,7 +7158,7 @@ var OnChainRevocationStorage = class _OnChainRevocationStorage {
6758
7158
  };
6759
7159
 
6760
7160
  // src/credentials/status/on-chain-revocation.ts
6761
- var import_js_iden3_core20 = require("@iden3/js-iden3-core");
7161
+ var import_js_iden3_core22 = require("@iden3/js-iden3-core");
6762
7162
  var import_js_merkletree17 = require("@iden3/js-merkletree");
6763
7163
 
6764
7164
  // src/storage/blockchain/errors.ts
@@ -6823,7 +7223,7 @@ var OnChainResolver = class {
6823
7223
  if (revocationNonce !== credentialStatus.revocationNonce) {
6824
7224
  throw new Error("revocationNonce does not match");
6825
7225
  }
6826
- const issuerId = import_js_iden3_core20.DID.idFromDID(issuer);
7226
+ const issuerId = import_js_iden3_core22.DID.idFromDID(issuer);
6827
7227
  let latestIssuerState;
6828
7228
  try {
6829
7229
  const latestStateInfo = await this._stateStorage.getLatestStateById(issuerId.bigInt());
@@ -6848,7 +7248,7 @@ var OnChainResolver = class {
6848
7248
  }
6849
7249
  latestIssuerState = stateBigInt;
6850
7250
  }
6851
- const id = import_js_iden3_core20.DID.idFromDID(issuer);
7251
+ const id = import_js_iden3_core22.DID.idFromDID(issuer);
6852
7252
  const onChainCaller = this._getOnChainRevocationStorageForIssuer(chainId, contractAddress);
6853
7253
  const revocationStatus = await onChainCaller.getRevocationStatusByIdAndState(
6854
7254
  id.bigInt(),
@@ -6905,7 +7305,7 @@ var OnChainResolver = class {
6905
7305
  };
6906
7306
 
6907
7307
  // src/credentials/status/reverse-sparse-merkle-tree.ts
6908
- var import_js_iden3_core21 = require("@iden3/js-iden3-core");
7308
+ var import_js_iden3_core23 = require("@iden3/js-iden3-core");
6909
7309
  var import_js_merkletree19 = require("@iden3/js-merkletree");
6910
7310
 
6911
7311
  // src/credentials/status/sparse-merkle-tree.ts
@@ -7031,7 +7431,7 @@ var RHSResolver = class {
7031
7431
  * @returns Promise<RevocationStatus>
7032
7432
  */
7033
7433
  async getStatus(credentialStatus, issuerDID, issuerData, genesisState) {
7034
- const issuerId = import_js_iden3_core21.DID.idFromDID(issuerDID);
7434
+ const issuerId = import_js_iden3_core23.DID.idFromDID(issuerDID);
7035
7435
  let latestState;
7036
7436
  try {
7037
7437
  const latestStateInfo = await this._state.getLatestStateById(issuerId.bigInt());
@@ -7173,16 +7573,16 @@ var RHSResolver = class {
7173
7573
  }
7174
7574
  };
7175
7575
  function isIssuerGenesis(issuer, state) {
7176
- const did = import_js_iden3_core21.DID.parse(issuer);
7177
- const id = import_js_iden3_core21.DID.idFromDID(did);
7178
- const { method, blockchain, networkId } = import_js_iden3_core21.DID.decodePartsFromId(id);
7179
- const arr = import_js_iden3_core21.BytesHelper.hexToBytes(state);
7180
- const stateBigInt = import_js_iden3_core21.BytesHelper.bytesToInt(arr);
7181
- const type = (0, import_js_iden3_core21.buildDIDType)(method, blockchain, networkId);
7182
- return isGenesisStateId(import_js_iden3_core21.DID.idFromDID(did).bigInt(), stateBigInt, type);
7576
+ const did = import_js_iden3_core23.DID.parse(issuer);
7577
+ const id = import_js_iden3_core23.DID.idFromDID(did);
7578
+ const { method, blockchain, networkId } = import_js_iden3_core23.DID.decodePartsFromId(id);
7579
+ const arr = import_js_iden3_core23.BytesHelper.hexToBytes(state);
7580
+ const stateBigInt = import_js_iden3_core23.BytesHelper.bytesToInt(arr);
7581
+ const type = (0, import_js_iden3_core23.buildDIDType)(method, blockchain, networkId);
7582
+ return isGenesisStateId(import_js_iden3_core23.DID.idFromDID(did).bigInt(), stateBigInt, type);
7183
7583
  }
7184
7584
  function isGenesisStateId(id, state, type) {
7185
- const idFromState = import_js_iden3_core21.Id.idGenesisFromIdenState(type, state);
7585
+ const idFromState = import_js_iden3_core23.Id.idGenesisFromIdenState(type, state);
7186
7586
  return id.toString() === idFromState.bigInt().toString();
7187
7587
  }
7188
7588
 
@@ -7377,7 +7777,7 @@ var DidDocumentCredentialStatusResolver = class {
7377
7777
  };
7378
7778
 
7379
7779
  // src/credentials/credential-wallet.ts
7380
- var import_js_iden3_core22 = require("@iden3/js-iden3-core");
7780
+ var import_js_iden3_core24 = require("@iden3/js-iden3-core");
7381
7781
  var uuid4 = __toESM(require("uuid"), 1);
7382
7782
  var CredentialWallet = class {
7383
7783
  /**
@@ -7439,7 +7839,7 @@ var CredentialWallet = class {
7439
7839
  const mtpProof = cred.getIden3SparseMerkleTreeProof();
7440
7840
  const sigProof = cred.getBJJSignature2021Proof();
7441
7841
  const stateInfo = mtpProof ? mtpProof.issuerData.state : sigProof?.issuerData.state;
7442
- const issuerDID = import_js_iden3_core22.DID.parse(cred.issuer);
7842
+ const issuerDID = import_js_iden3_core24.DID.parse(cred.issuer);
7443
7843
  const userDID = getUserDIDFromCredential(issuerDID, cred);
7444
7844
  const opts = {
7445
7845
  issuerGenesisState: stateInfo,
@@ -7638,7 +8038,7 @@ async function buildNodesUp(siblings, node) {
7638
8038
 
7639
8039
  // src/iden3comm/handlers/fetch.ts
7640
8040
  var import_js_jwz5 = require("@iden3/js-jwz");
7641
- var import_js_iden3_core23 = require("@iden3/js-iden3-core");
8041
+ var import_js_iden3_core25 = require("@iden3/js-iden3-core");
7642
8042
  var uuid5 = __toESM(require("uuid"), 1);
7643
8043
  var FetchHandler = class _FetchHandler extends AbstractMessageHandler {
7644
8044
  /**
@@ -7691,8 +8091,8 @@ var FetchHandler = class _FetchHandler extends AbstractMessageHandler {
7691
8091
  }
7692
8092
  const credentials = [];
7693
8093
  for (const credentialInfo of offerMessage.body.credentials) {
7694
- const issuerDID = import_js_iden3_core23.DID.parse(offerMessage.from);
7695
- const userDID = import_js_iden3_core23.DID.parse(offerMessage.to);
8094
+ const issuerDID = import_js_iden3_core25.DID.parse(offerMessage.from);
8095
+ const userDID = import_js_iden3_core25.DID.parse(offerMessage.to);
7696
8096
  const credential = await this.opts.onchainIssuer.getCredential(
7697
8097
  issuerDID,
7698
8098
  userDID,
@@ -7724,7 +8124,7 @@ var FetchHandler = class _FetchHandler extends AbstractMessageHandler {
7724
8124
  const packerOpts = ctx.mediaType === "application/iden3comm-signed-json" /* SignedMessage */ ? ctx.packerOptions : {
7725
8125
  provingMethodAlg: import_js_jwz5.proving.provingMethodGroth16AuthV2Instance.methodAlg
7726
8126
  };
7727
- const senderDID = import_js_iden3_core23.DID.parse(offerMessage.to);
8127
+ const senderDID = import_js_iden3_core25.DID.parse(offerMessage.to);
7728
8128
  const token = byteDecoder.decode(
7729
8129
  await this._packerMgr.pack(ctx.mediaType, msgBytes, {
7730
8130
  senderDID,
@@ -7814,8 +8214,8 @@ var FetchHandler = class _FetchHandler extends AbstractMessageHandler {
7814
8214
  if (!msgRequest.from) {
7815
8215
  throw new Error("failed request. empty 'from' field");
7816
8216
  }
7817
- const issuerDID = import_js_iden3_core23.DID.parse(msgRequest.to);
7818
- const userDID = import_js_iden3_core23.DID.parse(msgRequest.from);
8217
+ const issuerDID = import_js_iden3_core25.DID.parse(msgRequest.to);
8218
+ const userDID = import_js_iden3_core25.DID.parse(msgRequest.from);
7819
8219
  const credId = msgRequest.body?.id;
7820
8220
  if (!credId) {
7821
8221
  throw new Error("invalid credential id in fetch request body");
@@ -7867,7 +8267,10 @@ var FetchHandler = class _FetchHandler extends AbstractMessageHandler {
7867
8267
  if (!issuanceMsg.body?.credential) {
7868
8268
  throw new Error("credential is missing in issuance response message");
7869
8269
  }
7870
- await this.opts.credentialWallet.save(W3CCredential.fromJSON(issuanceMsg.body.credential));
8270
+ if (!(issuanceMsg.body.credential instanceof W3CCredential)) {
8271
+ throw new Error("credential object is not properly unmarshaled");
8272
+ }
8273
+ await this.opts.credentialWallet.save(issuanceMsg.body.credential);
7871
8274
  return null;
7872
8275
  }
7873
8276
  /**
@@ -7882,6 +8285,7 @@ var FetchHandler = class _FetchHandler extends AbstractMessageHandler {
7882
8285
  if (!opts?.allowExpiredMessages) {
7883
8286
  verifyExpiresTime(issuanceMsg);
7884
8287
  }
8288
+ issuanceMsg.body.credential = W3CCredential.fromJSON(issuanceMsg.body.credential);
7885
8289
  await this.handleIssuanceResponseMsg(issuanceMsg);
7886
8290
  return Uint8Array.from([]);
7887
8291
  }
@@ -7899,7 +8303,7 @@ var FetchHandler = class _FetchHandler extends AbstractMessageHandler {
7899
8303
  };
7900
8304
 
7901
8305
  // src/iden3comm/handlers/contract-request.ts
7902
- var import_js_iden3_core24 = require("@iden3/js-iden3-core");
8306
+ var import_js_iden3_core26 = require("@iden3/js-iden3-core");
7903
8307
  var ContractRequestHandler = class extends AbstractMessageHandler {
7904
8308
  /**
7905
8309
  * Creates an instance of ContractRequestHandler.
@@ -7946,11 +8350,11 @@ var ContractRequestHandler = class extends AbstractMessageHandler {
7946
8350
  throw new Error("Can't sign transaction. Provide Signer in options.");
7947
8351
  }
7948
8352
  const { chain_id } = message.body.transaction_data;
7949
- const networkFlag = Object.keys(import_js_iden3_core24.ChainIds).find((key) => import_js_iden3_core24.ChainIds[key] === chain_id);
8353
+ const networkFlag = Object.keys(import_js_iden3_core26.ChainIds).find((key) => import_js_iden3_core26.ChainIds[key] === chain_id);
7950
8354
  if (!networkFlag) {
7951
8355
  throw new Error(`Invalid chain id ${chain_id}`);
7952
8356
  }
7953
- const verifierDid = message.from ? import_js_iden3_core24.DID.parse(message.from) : void 0;
8357
+ const verifierDid = message.from ? import_js_iden3_core26.DID.parse(message.from) : void 0;
7954
8358
  const { scope = [] } = message.body;
7955
8359
  const zkpResponses = await processZeroKnowledgeProofRequests(
7956
8360
  did,
@@ -7959,7 +8363,7 @@ var ContractRequestHandler = class extends AbstractMessageHandler {
7959
8363
  this._proofService,
7960
8364
  {
7961
8365
  ethSigner,
7962
- challenge: challenge ?? import_js_iden3_core24.BytesHelper.bytesToInt(hexToBytes(await ethSigner.getAddress())),
8366
+ challenge: challenge ?? import_js_iden3_core26.BytesHelper.bytesToInt(hexToBytes(await ethSigner.getAddress())),
7963
8367
  supportedCircuits: this._supportedCircuits
7964
8368
  }
7965
8369
  );
@@ -7999,7 +8403,7 @@ var ContractRequestHandler = class extends AbstractMessageHandler {
7999
8403
  PROTOCOL_MESSAGE_TYPE.CONTRACT_INVOKE_REQUEST_MESSAGE_TYPE,
8000
8404
  message.body.accept
8001
8405
  );
8002
- const identifier = import_js_iden3_core24.DID.parse(message.to);
8406
+ const identifier = import_js_iden3_core26.DID.parse(message.to);
8003
8407
  const { authProof } = await processProofAuth(identifier, this._proofService, {
8004
8408
  supportedCircuits: this._supportedCircuits,
8005
8409
  acceptProfile,
@@ -8070,7 +8474,7 @@ var ContractRequestHandler = class extends AbstractMessageHandler {
8070
8474
  transaction_data: request.body.transaction_data,
8071
8475
  scope: []
8072
8476
  },
8073
- created_time: (0, import_js_iden3_core24.getUnixTimestamp)(/* @__PURE__ */ new Date())
8477
+ created_time: (0, import_js_iden3_core26.getUnixTimestamp)(/* @__PURE__ */ new Date())
8074
8478
  };
8075
8479
  for (const [txHash, zkpResponses] of txHashToZkpResponseMap) {
8076
8480
  for (const zkpResponse of zkpResponses.responses) {
@@ -8113,11 +8517,11 @@ var ContractRequestHandler = class extends AbstractMessageHandler {
8113
8517
  throw new Error("Can't sign transaction. Provide Signer in options.");
8114
8518
  }
8115
8519
  const { chain_id } = ciRequest.body.transaction_data;
8116
- const networkFlag = Object.keys(import_js_iden3_core24.ChainIds).find((key) => import_js_iden3_core24.ChainIds[key] === chain_id);
8520
+ const networkFlag = Object.keys(import_js_iden3_core26.ChainIds).find((key) => import_js_iden3_core26.ChainIds[key] === chain_id);
8117
8521
  if (!networkFlag) {
8118
8522
  throw new Error(`Invalid chain id ${chain_id}`);
8119
8523
  }
8120
- const verifierDid = ciRequest.from ? import_js_iden3_core24.DID.parse(ciRequest.from) : void 0;
8524
+ const verifierDid = ciRequest.from ? import_js_iden3_core26.DID.parse(ciRequest.from) : void 0;
8121
8525
  const zkpResponses = await processZeroKnowledgeProofRequests(
8122
8526
  did,
8123
8527
  ciRequest?.body?.scope,
@@ -8135,7 +8539,7 @@ var ContractRequestHandler = class extends AbstractMessageHandler {
8135
8539
 
8136
8540
  // src/iden3comm/handlers/refresh.ts
8137
8541
  var import_js_jwz6 = require("@iden3/js-jwz");
8138
- var import_js_iden3_core25 = require("@iden3/js-iden3-core");
8542
+ var import_js_iden3_core27 = require("@iden3/js-iden3-core");
8139
8543
  var uuid6 = __toESM(require("uuid"), 1);
8140
8544
  var RefreshHandler = class {
8141
8545
  /**
@@ -8156,7 +8560,7 @@ var RefreshHandler = class {
8156
8560
  if (!otherIdentifier) {
8157
8561
  throw new Error("self credentials do not support refresh");
8158
8562
  }
8159
- const senderDID = import_js_iden3_core25.DID.parse(otherIdentifier);
8563
+ const senderDID = import_js_iden3_core27.DID.parse(otherIdentifier);
8160
8564
  const zkpParams = {
8161
8565
  senderDID,
8162
8566
  provingMethodAlg: new import_js_jwz6.ProvingMethodAlg(
@@ -8201,7 +8605,7 @@ var RefreshHandler = class {
8201
8605
  };
8202
8606
 
8203
8607
  // src/iden3comm/handlers/revocation-status.ts
8204
- var import_js_iden3_core26 = require("@iden3/js-iden3-core");
8608
+ var import_js_iden3_core28 = require("@iden3/js-iden3-core");
8205
8609
  var uuid7 = __toESM(require("uuid"), 1);
8206
8610
  var import_js_jwz7 = require("@iden3/js-jwz");
8207
8611
  var RevocationStatusHandler = class extends AbstractMessageHandler {
@@ -8243,7 +8647,7 @@ var RevocationStatusHandler = class extends AbstractMessageHandler {
8243
8647
  if (!rsRequest.body?.revocation_nonce) {
8244
8648
  throw new Error(`failed request. empty 'revocation_nonce' field`);
8245
8649
  }
8246
- const issuerDID = import_js_iden3_core26.DID.parse(rsRequest.to);
8650
+ const issuerDID = import_js_iden3_core28.DID.parse(rsRequest.to);
8247
8651
  const mtpWithTreeState = await this._identityWallet.generateNonRevocationMtpWithNonce(
8248
8652
  issuerDID,
8249
8653
  BigInt(rsRequest.body.revocation_nonce),
@@ -8310,7 +8714,7 @@ var RevocationStatusHandler = class extends AbstractMessageHandler {
8310
8714
  if (!rsRequest.to) {
8311
8715
  throw new Error(`failed request. empty 'to' field`);
8312
8716
  }
8313
- const senderDID = import_js_iden3_core26.DID.parse(rsRequest.to);
8717
+ const senderDID = import_js_iden3_core28.DID.parse(rsRequest.to);
8314
8718
  return this._packerMgr.pack(opts.mediaType, byteEncoder.encode(JSON.stringify(response)), {
8315
8719
  senderDID,
8316
8720
  ...packerOpts
@@ -8319,7 +8723,7 @@ var RevocationStatusHandler = class extends AbstractMessageHandler {
8319
8723
  };
8320
8724
 
8321
8725
  // src/iden3comm/handlers/credential-proposal.ts
8322
- var import_js_iden3_core27 = require("@iden3/js-iden3-core");
8726
+ var import_js_iden3_core29 = require("@iden3/js-iden3-core");
8323
8727
  var uuid8 = __toESM(require("uuid"), 1);
8324
8728
  var import_js_jwz8 = require("@iden3/js-jwz");
8325
8729
  function createProposalRequest(sender, receiver, opts) {
@@ -8331,9 +8735,12 @@ function createProposalRequest(sender, receiver, opts) {
8331
8735
  to: receiver.string(),
8332
8736
  typ: "application/iden3comm-plain-json" /* PlainMessage */,
8333
8737
  type: PROTOCOL_MESSAGE_TYPE.PROPOSAL_REQUEST_MESSAGE_TYPE,
8334
- body: opts,
8335
- created_time: (0, import_js_iden3_core27.getUnixTimestamp)(/* @__PURE__ */ new Date()),
8336
- expires_time: opts?.expires_time ? (0, import_js_iden3_core27.getUnixTimestamp)(opts.expires_time) : void 0,
8738
+ body: {
8739
+ credentials: opts.credentials,
8740
+ did_doc: opts.did_doc
8741
+ },
8742
+ created_time: (0, import_js_iden3_core29.getUnixTimestamp)(/* @__PURE__ */ new Date()),
8743
+ expires_time: opts?.expires_time ? (0, import_js_iden3_core29.getUnixTimestamp)(opts.expires_time) : void 0,
8337
8744
  attachments: opts.attachments
8338
8745
  };
8339
8746
  return request;
@@ -8350,8 +8757,8 @@ function createProposal(sender, receiver, proposals, opts) {
8350
8757
  body: {
8351
8758
  proposals: proposals || []
8352
8759
  },
8353
- created_time: (0, import_js_iden3_core27.getUnixTimestamp)(/* @__PURE__ */ new Date()),
8354
- expires_time: opts?.expires_time ? (0, import_js_iden3_core27.getUnixTimestamp)(opts.expires_time) : void 0
8760
+ created_time: (0, import_js_iden3_core29.getUnixTimestamp)(/* @__PURE__ */ new Date()),
8761
+ expires_time: opts?.expires_time ? (0, import_js_iden3_core29.getUnixTimestamp)(opts.expires_time) : void 0
8355
8762
  };
8356
8763
  return request;
8357
8764
  }
@@ -8484,7 +8891,7 @@ var CredentialProposalHandler = class extends AbstractMessageHandler {
8484
8891
  if (!opts?.allowExpiredMessages) {
8485
8892
  verifyExpiresTime(proposalRequest);
8486
8893
  }
8487
- const senderDID = import_js_iden3_core27.DID.parse(proposalRequest.from);
8894
+ const senderDID = import_js_iden3_core29.DID.parse(proposalRequest.from);
8488
8895
  const message = await this.handleProposalRequestMessage(proposalRequest);
8489
8896
  const response = byteEncoder.encode(JSON.stringify(message));
8490
8897
  const packerOpts = this._params.packerParams.mediaType === "application/iden3comm-signed-json" /* SignedMessage */ ? this._params.packerParams.packerOptions : {
@@ -8512,10 +8919,9 @@ var CredentialProposalHandler = class extends AbstractMessageHandler {
8512
8919
  };
8513
8920
 
8514
8921
  // src/iden3comm/handlers/payment.ts
8515
- var import_js_iden3_core28 = require("@iden3/js-iden3-core");
8922
+ var import_js_iden3_core30 = require("@iden3/js-iden3-core");
8516
8923
  var uuid9 = __toESM(require("uuid"), 1);
8517
8924
  var import_js_jwz9 = require("@iden3/js-jwz");
8518
- var import_ethers6 = require("ethers");
8519
8925
  function createPaymentRequest(sender, receiver, agent, payments, opts) {
8520
8926
  const uuidv4 = uuid9.v4();
8521
8927
  const request = {
@@ -8529,48 +8935,11 @@ function createPaymentRequest(sender, receiver, agent, payments, opts) {
8529
8935
  agent,
8530
8936
  payments
8531
8937
  },
8532
- created_time: (0, import_js_iden3_core28.getUnixTimestamp)(/* @__PURE__ */ new Date()),
8533
- expires_time: opts?.expires_time ? (0, import_js_iden3_core28.getUnixTimestamp)(opts.expires_time) : void 0
8938
+ created_time: (0, import_js_iden3_core30.getUnixTimestamp)(/* @__PURE__ */ new Date()),
8939
+ expires_time: opts?.expires_time ? (0, import_js_iden3_core30.getUnixTimestamp)(opts.expires_time) : void 0
8534
8940
  };
8535
8941
  return request;
8536
8942
  }
8537
- async function verifyEIP712TypedData(data, resolver) {
8538
- const paymentData = data.type === "Iden3PaymentRailsRequestV1" /* Iden3PaymentRailsRequestV1 */ ? {
8539
- recipient: data.recipient,
8540
- amount: data.amount,
8541
- expirationDate: (0, import_js_iden3_core28.getUnixTimestamp)(new Date(data.expirationDate)),
8542
- nonce: data.nonce,
8543
- metadata: "0x"
8544
- } : {
8545
- tokenAddress: data.tokenAddress,
8546
- recipient: data.recipient,
8547
- amount: data.amount,
8548
- expirationDate: (0, import_js_iden3_core28.getUnixTimestamp)(new Date(data.expirationDate)),
8549
- nonce: data.nonce,
8550
- metadata: "0x"
8551
- };
8552
- const proof = Array.isArray(data.proof) ? data.proof[0] : data.proof;
8553
- const typesFetchResult = await fetch(proof.eip712.types);
8554
- const types = await typesFetchResult.json();
8555
- delete types.EIP712Domain;
8556
- const recovered = import_ethers6.ethers.verifyTypedData(
8557
- proof.eip712.domain,
8558
- types,
8559
- paymentData,
8560
- proof.proofValue
8561
- );
8562
- const { didDocument } = await resolver.resolve(proof.verificationMethod);
8563
- if (didDocument?.verificationMethod) {
8564
- for (const verificationMethod of didDocument.verificationMethod) {
8565
- if (verificationMethod.blockchainAccountId?.split(":").slice(-1)[0].toLowerCase() === recovered.toLowerCase()) {
8566
- return recovered;
8567
- }
8568
- }
8569
- } else {
8570
- throw new Error("failed request. issuer DIDDocument does not contain any verificationMethods");
8571
- }
8572
- throw new Error(`failed request. no matching verificationMethod`);
8573
- }
8574
8943
  function createPayment(sender, receiver, payments, opts) {
8575
8944
  const uuidv4 = uuid9.v4();
8576
8945
  const request = {
@@ -8583,8 +8952,8 @@ function createPayment(sender, receiver, payments, opts) {
8583
8952
  body: {
8584
8953
  payments
8585
8954
  },
8586
- created_time: (0, import_js_iden3_core28.getUnixTimestamp)(/* @__PURE__ */ new Date()),
8587
- expires_time: opts?.expires_time ? (0, import_js_iden3_core28.getUnixTimestamp)(opts.expires_time) : void 0
8955
+ created_time: (0, import_js_iden3_core30.getUnixTimestamp)(/* @__PURE__ */ new Date()),
8956
+ expires_time: opts?.expires_time ? (0, import_js_iden3_core30.getUnixTimestamp)(opts.expires_time) : void 0
8588
8957
  };
8589
8958
  return request;
8590
8959
  }
@@ -8638,8 +9007,8 @@ var PaymentHandler = class extends AbstractMessageHandler {
8638
9007
  if (!ctx.paymentHandler) {
8639
9008
  throw new Error(`please provide payment handler in context`);
8640
9009
  }
8641
- const senderDID = import_js_iden3_core28.DID.parse(paymentRequest.to);
8642
- const receiverDID = import_js_iden3_core28.DID.parse(paymentRequest.from);
9010
+ const senderDID = import_js_iden3_core30.DID.parse(paymentRequest.to);
9011
+ const receiverDID = import_js_iden3_core30.DID.parse(paymentRequest.from);
8643
9012
  const payments = [];
8644
9013
  for (let i = 0; i < paymentRequest.body.payments.length; i++) {
8645
9014
  const { data } = paymentRequest.body.payments[i];
@@ -8669,6 +9038,22 @@ var PaymentHandler = class extends AbstractMessageHandler {
8669
9038
  )
8670
9039
  );
8671
9040
  break;
9041
+ case "Iden3PaymentRailsSolanaRequestV1" /* Iden3PaymentRailsSolanaRequestV1 */:
9042
+ payments.push(
9043
+ await this.handleIden3PaymentRailsSolanaRequestV1(selectedPayment, ctx.paymentHandler)
9044
+ );
9045
+ break;
9046
+ case "Iden3PaymentRailsSolanaSPLRequestV1" /* Iden3PaymentRailsSolanaSPLRequestV1 */:
9047
+ payments.push(
9048
+ await this.handleIden3PaymentRailsSolanaSPLRequestV1(
9049
+ {
9050
+ ...selectedPayment,
9051
+ type: "Iden3PaymentRailsSolanaSPLRequestV1" /* Iden3PaymentRailsSolanaSPLRequestV1 */
9052
+ },
9053
+ ctx.paymentHandler
9054
+ )
9055
+ );
9056
+ break;
8672
9057
  }
8673
9058
  }
8674
9059
  const paymentMessage = createPayment(senderDID, receiverDID, payments);
@@ -8708,7 +9093,7 @@ var PaymentHandler = class extends AbstractMessageHandler {
8708
9093
  if (!agentMessage) {
8709
9094
  return null;
8710
9095
  }
8711
- const senderDID = import_js_iden3_core28.DID.parse(paymentRequest.to);
9096
+ const senderDID = import_js_iden3_core30.DID.parse(paymentRequest.to);
8712
9097
  return this.packMessage(agentMessage, senderDID);
8713
9098
  }
8714
9099
  /**
@@ -8747,7 +9132,7 @@ var PaymentHandler = class extends AbstractMessageHandler {
8747
9132
  /**
8748
9133
  * @inheritdoc IPaymentHandler#createPaymentRailsV1
8749
9134
  */
8750
- async createPaymentRailsV1(sender, receiver, agent, signer, payments) {
9135
+ async createPaymentRailsV1(sender, receiver, agent, signer, payments, createOptions) {
8751
9136
  const paymentRequestInfo = [];
8752
9137
  for (let i = 0; i < payments.length; i++) {
8753
9138
  const { credentials, description } = payments[i];
@@ -8765,70 +9150,40 @@ var PaymentHandler = class extends AbstractMessageHandler {
8765
9150
  if (!option) {
8766
9151
  throw new Error(`failed request. no option for id ${optionId}`);
8767
9152
  }
8768
- if (option.type === "Iden3PaymentRailsERC20RequestV1" /* Iden3PaymentRailsERC20RequestV1 */ && !option.contractAddress) {
9153
+ if ((option.type === "Iden3PaymentRailsERC20RequestV1" /* Iden3PaymentRailsERC20RequestV1 */ || option.type === "Iden3PaymentRailsSolanaSPLRequestV1" /* Iden3PaymentRailsSolanaSPLRequestV1 */) && !option.contractAddress) {
8769
9154
  throw new Error(`failed request. no token address for option id ${optionId}`);
8770
9155
  }
8771
9156
  const expirationDateRequired = expirationDate ?? new Date((/* @__PURE__ */ new Date()).setHours((/* @__PURE__ */ new Date()).getHours() + 1));
8772
- const typeUrl = `https://schema.iden3.io/core/json/${option.type}.json`;
8773
- const typesFetchResult = await fetch(typeUrl);
8774
- const types = await typesFetchResult.json();
8775
- delete types.EIP712Domain;
8776
- const paymentData = option.type === "Iden3PaymentRailsRequestV1" /* Iden3PaymentRailsRequestV1 */ ? {
8777
- recipient,
8778
- amount,
8779
- expirationDate: (0, import_js_iden3_core28.getUnixTimestamp)(expirationDateRequired),
8780
- nonce,
8781
- metadata: "0x"
8782
- } : {
8783
- tokenAddress: option.contractAddress,
8784
- recipient,
8785
- amount,
8786
- expirationDate: (0, import_js_iden3_core28.getUnixTimestamp)(expirationDateRequired),
8787
- nonce,
8788
- metadata: "0x"
8789
- };
8790
- const domain = {
8791
- name: "MCPayment",
8792
- version: "1.0.0",
8793
- chainId,
8794
- verifyingContract: paymentRails
8795
- };
8796
- const signature = await signer.signTypedData(domain, types, paymentData);
8797
- const proof = [
8798
- {
8799
- type: "EthereumEip712Signature2021" /* EthereumEip712Signature2021 */,
8800
- proofPurpose: "assertionMethod",
8801
- proofValue: signature,
8802
- verificationMethod: `did:pkh:eip155:${chainId}:${await signer.getAddress()}`,
8803
- created: (/* @__PURE__ */ new Date()).toISOString(),
8804
- eip712: {
8805
- types: typeUrl,
8806
- primaryType: "Iden3PaymentRailsRequestV1",
8807
- domain
8808
- }
8809
- }
8810
- ];
8811
- const d = {
8812
- type: "Iden3PaymentRailsRequestV1" /* Iden3PaymentRailsRequestV1 */,
8813
- "@context": [
8814
- `https://schema.iden3.io/core/jsonld/payment.jsonld#${option.type}`,
8815
- "https://w3id.org/security/suites/eip712sig-2021/v1"
8816
- ],
8817
- recipient,
8818
- amount: amount.toString(),
8819
- expirationDate: expirationDateRequired.toISOString(),
8820
- nonce: nonce.toString(),
8821
- metadata: "0x",
8822
- proof
8823
- };
8824
- dataArr.push(
8825
- option.type === "Iden3PaymentRailsRequestV1" /* Iden3PaymentRailsRequestV1 */ ? d : {
8826
- ...d,
8827
- type: option.type,
8828
- tokenAddress: option.contractAddress || "",
8829
- features: option.features || []
9157
+ if (option.type === "Iden3PaymentRailsSolanaRequestV1" /* Iden3PaymentRailsSolanaRequestV1 */ || option.type === "Iden3PaymentRailsSolanaSPLRequestV1" /* Iden3PaymentRailsSolanaSPLRequestV1 */) {
9158
+ if (!createOptions?.solSigner) {
9159
+ throw new Error(
9160
+ `please provide solana signer in context for ${option.type} payment type`
9161
+ );
8830
9162
  }
8831
- );
9163
+ const payment = await buildSolanaPayment(
9164
+ createOptions.solSigner,
9165
+ option,
9166
+ chainId,
9167
+ paymentRails,
9168
+ recipient,
9169
+ BigInt(amount),
9170
+ expirationDateRequired,
9171
+ nonce
9172
+ );
9173
+ dataArr.push(payment);
9174
+ } else {
9175
+ const payment = await buildEvmPayment(
9176
+ signer,
9177
+ option,
9178
+ chainId,
9179
+ paymentRails,
9180
+ recipient,
9181
+ BigInt(amount),
9182
+ expirationDateRequired,
9183
+ nonce
9184
+ );
9185
+ dataArr.push(payment);
9186
+ }
8832
9187
  }
8833
9188
  paymentRequestInfo.push({
8834
9189
  data: dataArr,
@@ -8882,6 +9237,55 @@ var PaymentHandler = class extends AbstractMessageHandler {
8882
9237
  }
8883
9238
  };
8884
9239
  }
9240
+ async handleIden3PaymentRailsSolanaRequestV1(data, paymentHandler) {
9241
+ if (data.expirationDate && new Date(data.expirationDate) < /* @__PURE__ */ new Date()) {
9242
+ throw new Error(`failed request. expired request`);
9243
+ }
9244
+ const isValid = await verifyIden3SolanaPaymentRequest(data, this._params.documentResolver);
9245
+ if (!isValid) {
9246
+ throw new Error(`failed request. invalid Solana payment request signature`);
9247
+ }
9248
+ const proof = Array.isArray(data.proof) ? data.proof[0] : data.proof;
9249
+ const signer = proof.verificationMethod.split(":").slice(-1)[0];
9250
+ if (this._params.allowedSigners && !this._params.allowedSigners.includes(signer)) {
9251
+ throw new Error(`failed request. signer is not in the allowed signers list`);
9252
+ }
9253
+ const txId = await paymentHandler(data);
9254
+ return {
9255
+ nonce: data.nonce,
9256
+ type: "Iden3PaymentRailsSolanaV1" /* Iden3PaymentRailsSolanaV1 */,
9257
+ "@context": "https://schema.iden3.io/core/jsonld/payment.jsonld#Iden3PaymentRailsSolanaV1",
9258
+ paymentData: {
9259
+ txId,
9260
+ chainId: proof.domain.chainId
9261
+ }
9262
+ };
9263
+ }
9264
+ async handleIden3PaymentRailsSolanaSPLRequestV1(data, paymentHandler) {
9265
+ if (data.expirationDate && new Date(data.expirationDate) < /* @__PURE__ */ new Date()) {
9266
+ throw new Error(`failed request. expired request`);
9267
+ }
9268
+ const isValid = await verifyIden3SolanaPaymentRequest(data, this._params.documentResolver);
9269
+ if (!isValid) {
9270
+ throw new Error(`failed request. invalid Solana payment request signature`);
9271
+ }
9272
+ const proof = Array.isArray(data.proof) ? data.proof[0] : data.proof;
9273
+ const signer = proof.verificationMethod.split(":").slice(-1)[0];
9274
+ if (this._params.allowedSigners && !this._params.allowedSigners.includes(signer)) {
9275
+ throw new Error(`failed request. signer is not in the allowed signers list`);
9276
+ }
9277
+ const txId = await paymentHandler(data);
9278
+ return {
9279
+ nonce: data.nonce,
9280
+ type: "Iden3PaymentRailsSolanaSPLV1" /* Iden3PaymentRailsSolanaSPLV1 */,
9281
+ "@context": "https://schema.iden3.io/core/jsonld/payment.jsonld#Iden3PaymentRailsSolanaSPLV1",
9282
+ paymentData: {
9283
+ txId,
9284
+ chainId: proof.domain.chainId,
9285
+ tokenAddress: data.tokenAddress
9286
+ }
9287
+ };
9288
+ }
8885
9289
  async handleIden3PaymentRailsERC20RequestV1(data, paymentHandler, approveHandler) {
8886
9290
  if (data.expirationDate && new Date(data.expirationDate) < /* @__PURE__ */ new Date()) {
8887
9291
  throw new Error(`failed request. expired request`);
@@ -8913,7 +9317,7 @@ var PaymentHandler = class extends AbstractMessageHandler {
8913
9317
 
8914
9318
  // src/iden3comm/handlers/discovery-protocol.ts
8915
9319
  var uuid10 = __toESM(require("uuid"), 1);
8916
- var import_js_iden3_core29 = require("@iden3/js-iden3-core");
9320
+ var import_js_iden3_core31 = require("@iden3/js-iden3-core");
8917
9321
  function createDiscoveryFeatureQueryMessage(queries, opts) {
8918
9322
  const uuidv4 = uuid10.v4();
8919
9323
  return {
@@ -8926,7 +9330,7 @@ function createDiscoveryFeatureQueryMessage(queries, opts) {
8926
9330
  },
8927
9331
  from: opts?.from,
8928
9332
  to: opts?.to,
8929
- created_time: (0, import_js_iden3_core29.getUnixTimestamp)(/* @__PURE__ */ new Date()),
9333
+ created_time: (0, import_js_iden3_core31.getUnixTimestamp)(/* @__PURE__ */ new Date()),
8930
9334
  expires_time: opts?.expires_time
8931
9335
  };
8932
9336
  }
@@ -8942,7 +9346,7 @@ function createDiscoveryFeatureDiscloseMessage(disclosures, opts) {
8942
9346
  },
8943
9347
  from: opts?.from,
8944
9348
  to: opts?.to,
8945
- created_time: (0, import_js_iden3_core29.getUnixTimestamp)(/* @__PURE__ */ new Date()),
9349
+ created_time: (0, import_js_iden3_core31.getUnixTimestamp)(/* @__PURE__ */ new Date()),
8946
9350
  expires_time: opts?.expires_time
8947
9351
  };
8948
9352
  }
@@ -8995,7 +9399,7 @@ var DiscoveryProtocolHandler = class extends AbstractMessageHandler {
8995
9399
  createDiscoveryFeatureDiscloseMessage(disclosures, {
8996
9400
  to: message.from,
8997
9401
  from: message.to,
8998
- expires_time: opts?.disclosureExpiresDate ? (0, import_js_iden3_core29.getUnixTimestamp)(opts.disclosureExpiresDate) : void 0
9402
+ expires_time: opts?.disclosureExpiresDate ? (0, import_js_iden3_core31.getUnixTimestamp)(opts.disclosureExpiresDate) : void 0
8999
9403
  })
9000
9404
  );
9001
9405
  }
@@ -9330,8 +9734,8 @@ var EthStateStorage = class {
9330
9734
  this._disableCache = true;
9331
9735
  }
9332
9736
  getStateContractAndProviderForId(id) {
9333
- const idTyped = import_js_iden3_core30.Id.fromBigInt(id);
9334
- const chainId = (0, import_js_iden3_core30.getChainId)(import_js_iden3_core30.DID.blockchainFromId(idTyped), import_js_iden3_core30.DID.networkIdFromId(idTyped));
9737
+ const idTyped = import_js_iden3_core32.Id.fromBigInt(id);
9738
+ const chainId = (0, import_js_iden3_core32.getChainId)(import_js_iden3_core32.DID.blockchainFromId(idTyped), import_js_iden3_core32.DID.networkIdFromId(idTyped));
9335
9739
  const config = this.networkByChainId(chainId);
9336
9740
  const provider = new import_ethers7.JsonRpcProvider(config.url);
9337
9741
  const stateContract = new import_ethers7.Contract(config.contractAddress, State_default, provider);
@@ -10155,7 +10559,7 @@ var ZkpVerifier_default = [
10155
10559
 
10156
10560
  // src/storage/blockchain/onchain-zkp-verifier.ts
10157
10561
  var import_universal_verifier_v2_abi = require("@iden3/universal-verifier-v2-abi");
10158
- var import_js_iden3_core31 = require("@iden3/js-iden3-core");
10562
+ var import_js_iden3_core33 = require("@iden3/js-iden3-core");
10159
10563
  var import_js_merkletree23 = require("@iden3/js-merkletree");
10160
10564
  var maxGasLimit = 10000000n;
10161
10565
  var FunctionSignatures = /* @__PURE__ */ ((FunctionSignatures2) => {
@@ -10463,13 +10867,13 @@ var OnChainZKPVerifier = class _OnChainZKPVerifier {
10463
10867
  )
10464
10868
  ].reduce((acc, s) => {
10465
10869
  const info = JSON.parse(s);
10466
- const id = import_js_iden3_core31.Id.fromString(info.id);
10467
- const chainId = (0, import_js_iden3_core31.chainIDfromDID)(import_js_iden3_core31.DID.parseFromId(id));
10870
+ const id = import_js_iden3_core33.Id.fromString(info.id);
10871
+ const chainId = (0, import_js_iden3_core33.chainIDfromDID)(import_js_iden3_core33.DID.parseFromId(id));
10468
10872
  if (txDataChainId === chainId) {
10469
10873
  return acc;
10470
10874
  }
10471
10875
  const promise = this.resolveDidDocumentEip712MessageAndSignature(
10472
- import_js_iden3_core31.DID.parseFromId(import_js_iden3_core31.Id.fromString(info.id)),
10876
+ import_js_iden3_core33.DID.parseFromId(import_js_iden3_core33.Id.fromString(info.id)),
10473
10877
  didResolverUrl,
10474
10878
  {
10475
10879
  [type]: import_js_merkletree23.Hash.fromString(info[type])
@@ -10619,21 +11023,21 @@ var OnChainZKPVerifier = class _OnChainZKPVerifier {
10619
11023
  }
10620
11024
  };
10621
11025
  var packEthIdentityProof = (did) => {
10622
- return `0x${bytesToHex(import_js_iden3_core31.BytesHelper.intToBytes(import_js_iden3_core31.DID.idFromDID(did).bigInt()))}`;
11026
+ return `0x${bytesToHex(import_js_iden3_core33.BytesHelper.intToBytes(import_js_iden3_core33.DID.idFromDID(did).bigInt()))}`;
10623
11027
  };
10624
11028
 
10625
11029
  // src/storage/blockchain/onchain-issuer.ts
10626
- var import_js_iden3_core34 = require("@iden3/js-iden3-core");
11030
+ var import_js_iden3_core36 = require("@iden3/js-iden3-core");
10627
11031
  var import_ethers10 = require("ethers");
10628
11032
  var import_onchain_non_merklized_issuer_base_abi2 = require("@iden3/onchain-non-merklized-issuer-base-abi");
10629
11033
 
10630
11034
  // src/storage/blockchain/onchain-issuer-adapter/non-merklized/version/v0.0.1/onchain-non-merklized-issuer-adapter.ts
10631
- var import_js_iden3_core32 = require("@iden3/js-iden3-core");
11035
+ var import_js_iden3_core34 = require("@iden3/js-iden3-core");
10632
11036
  var import_onchain_non_merklized_issuer_base_abi = require("@iden3/onchain-non-merklized-issuer-base-abi");
10633
11037
  var import_js_jsonld_merklization5 = require("@iden3/js-jsonld-merklization");
10634
11038
  var import_js_merkletree24 = require("@iden3/js-merkletree");
10635
11039
  var import_ethers9 = require("ethers");
10636
- var import_js_iden3_core33 = require("@iden3/js-iden3-core");
11040
+ var import_js_iden3_core35 = require("@iden3/js-iden3-core");
10637
11041
  var OnchainNonMerklizedIssuerAdapter = class {
10638
11042
  _contract;
10639
11043
  _contractAddress;
@@ -10653,7 +11057,7 @@ var OnchainNonMerklizedIssuerAdapter = class {
10653
11057
  }
10654
11058
  this._chainId = ethConnectionConfig.chainId;
10655
11059
  this._contractAddress = import_ethers9.ethers.getAddress(
10656
- import_ethers9.ethers.hexlify(import_js_iden3_core32.Id.ethAddressFromId(import_js_iden3_core32.DID.idFromDID(issuerDid)))
11060
+ import_ethers9.ethers.hexlify(import_js_iden3_core34.Id.ethAddressFromId(import_js_iden3_core34.DID.idFromDID(issuerDid)))
10657
11061
  );
10658
11062
  this._contract = import_onchain_non_merklized_issuer_base_abi.NonMerklizedIssuerBase__factory.connect(
10659
11063
  this._contractAddress,
@@ -10721,7 +11125,7 @@ var OnchainNonMerklizedIssuerAdapter = class {
10721
11125
  * @param credentialSubjectFields Subject fields of the credential.
10722
11126
  */
10723
11127
  async convertOnChainInfoToW3CCredential(credentialData, coreClaimBigInts, credentialSubjectFields) {
10724
- const c = new import_js_iden3_core32.Claim().unMarshalJson(JSON.stringify(coreClaimBigInts.map((b) => b.toString())));
11128
+ const c = new import_js_iden3_core34.Claim().unMarshalJson(JSON.stringify(coreClaimBigInts.map((b) => b.toString())));
10725
11129
  const credentialSubject = await this.convertCredentialSubject(
10726
11130
  c,
10727
11131
  credentialData.context,
@@ -10741,7 +11145,7 @@ var OnchainNonMerklizedIssuerAdapter = class {
10741
11145
  nonce: Number(c.getRevocationNonce()),
10742
11146
  type: "Iden3OnchainSparseMerkleTreeProof2023" /* Iden3OnchainSparseMerkleTreeProof2023 */
10743
11147
  },
10744
- issuanceDate: (0, import_js_iden3_core33.getDateFromUnixTimestamp)(Number(credentialData.issuanceDate)).getTime()
11148
+ issuanceDate: (0, import_js_iden3_core35.getDateFromUnixTimestamp)(Number(credentialData.issuanceDate)).getTime()
10745
11149
  };
10746
11150
  const existenceProof = await this.existenceProof(c);
10747
11151
  const w3c = W3CCredential.fromCredentialRequest(this._issuerDid, credentialRequest);
@@ -10789,7 +11193,7 @@ var OnchainNonMerklizedIssuerAdapter = class {
10789
11193
  }
10790
11194
  case "http://www.w3.org/2001/XMLSchema#dateTime" /* DateTime */: {
10791
11195
  const timestamp = BigInt(f.rawValue);
10792
- const sourceTimestamp = (0, import_js_iden3_core33.getDateFromUnixTimestamp)(Number(timestamp)).toISOString();
11196
+ const sourceTimestamp = (0, import_js_iden3_core35.getDateFromUnixTimestamp)(Number(timestamp)).toISOString();
10793
11197
  this.validateSourceValue(dataType, f.value, sourceTimestamp);
10794
11198
  credentialSubject[f.key] = sourceTimestamp;
10795
11199
  break;
@@ -10807,7 +11211,7 @@ var OnchainNonMerklizedIssuerAdapter = class {
10807
11211
  }
10808
11212
  credentialSubject["type"] = credentialType;
10809
11213
  const subjectId = coreClaim.getId();
10810
- const subjectDid = import_js_iden3_core32.DID.parseFromId(subjectId);
11214
+ const subjectDid = import_js_iden3_core34.DID.parseFromId(subjectId);
10811
11215
  credentialSubject["id"] = subjectDid.string();
10812
11216
  return credentialSubject;
10813
11217
  }
@@ -10896,7 +11300,7 @@ var OnchainIssuer = class {
10896
11300
  merklizationOptions: this._onchainIssuerOptions?.merklizationOptions
10897
11301
  });
10898
11302
  await adapter.isInterfaceSupported();
10899
- const { credentialData, coreClaimBigInts, credentialSubjectFields } = await adapter.getCredential(import_js_iden3_core34.DID.idFromDID(userDID), credentialId);
11303
+ const { credentialData, coreClaimBigInts, credentialSubjectFields } = await adapter.getCredential(import_js_iden3_core36.DID.idFromDID(userDID), credentialId);
10900
11304
  return await adapter.convertOnChainInfoToW3CCredential(
10901
11305
  credentialData,
10902
11306
  coreClaimBigInts,
@@ -10921,16 +11325,16 @@ var OnchainIssuer = class {
10921
11325
  merklizationOptions: this._onchainIssuerOptions?.merklizationOptions
10922
11326
  });
10923
11327
  await adapter.isInterfaceSupported();
10924
- return await adapter.getUserCredentialsIds(import_js_iden3_core34.DID.idFromDID(userDID));
11328
+ return await adapter.getUserCredentialsIds(import_js_iden3_core36.DID.idFromDID(userDID));
10925
11329
  }
10926
11330
  default:
10927
11331
  throw new Error(`Unsupported adapter version ${response}`);
10928
11332
  }
10929
11333
  }
10930
11334
  getContractConnection(did) {
10931
- const issuerId = import_js_iden3_core34.DID.idFromDID(did);
10932
- const chainId = (0, import_js_iden3_core34.chainIDfromDID)(did);
10933
- const contractAddress = import_ethers10.ethers.getAddress(import_ethers10.ethers.hexlify(import_js_iden3_core34.Id.ethAddressFromId(issuerId)));
11335
+ const issuerId = import_js_iden3_core36.DID.idFromDID(did);
11336
+ const chainId = (0, import_js_iden3_core36.chainIDfromDID)(did);
11337
+ const contractAddress = import_ethers10.ethers.getAddress(import_ethers10.ethers.hexlify(import_js_iden3_core36.Id.ethAddressFromId(issuerId)));
10934
11338
  const connection = this._ethConnectionConfig.find((c) => c.chainId === chainId);
10935
11339
  if (!connection) {
10936
11340
  throw new Error(`No connection found for chain ID ${chainId}`);
@@ -10945,7 +11349,7 @@ var OnchainIssuer = class {
10945
11349
 
10946
11350
  // src/storage/blockchain/did-resolver-readonly-storage.ts
10947
11351
  var import_js_merkletree25 = require("@iden3/js-merkletree");
10948
- var import_js_iden3_core35 = require("@iden3/js-iden3-core");
11352
+ var import_js_iden3_core37 = require("@iden3/js-iden3-core");
10949
11353
  var import_ethers11 = require("ethers");
10950
11354
  var DidResolverStateReadonlyStorage = class {
10951
11355
  constructor(resolverUrl) {
@@ -10959,7 +11363,7 @@ var DidResolverStateReadonlyStorage = class {
10959
11363
  }
10960
11364
  async getGISTProof(id) {
10961
11365
  const { didDocument } = await resolveDidDocument(
10962
- import_js_iden3_core35.DID.parseFromId(import_js_iden3_core35.Id.fromBigInt(id)),
11366
+ import_js_iden3_core37.DID.parseFromId(import_js_iden3_core37.Id.fromBigInt(id)),
10963
11367
  this.resolverUrl
10964
11368
  );
10965
11369
  const { global } = this.getIden3StateInfo2023(didDocument);
@@ -10983,7 +11387,7 @@ var DidResolverStateReadonlyStorage = class {
10983
11387
  }
10984
11388
  async getGISTRootInfo(root, userId) {
10985
11389
  const { didDocument } = await resolveDidDocument(
10986
- import_js_iden3_core35.DID.parseFromId(import_js_iden3_core35.Id.fromBigInt(userId)),
11390
+ import_js_iden3_core37.DID.parseFromId(import_js_iden3_core37.Id.fromBigInt(userId)),
10987
11391
  this.resolverUrl,
10988
11392
  {
10989
11393
  gist: import_js_merkletree25.Hash.fromBigInt(root)
@@ -11007,7 +11411,7 @@ var DidResolverStateReadonlyStorage = class {
11007
11411
  async getStateInfo(id, state) {
11008
11412
  const opts = state ? { state: import_js_merkletree25.Hash.fromBigInt(state) } : void 0;
11009
11413
  const { didDocument } = await resolveDidDocument(
11010
- import_js_iden3_core35.DID.parseFromId(import_js_iden3_core35.Id.fromBigInt(id)),
11414
+ import_js_iden3_core37.DID.parseFromId(import_js_iden3_core37.Id.fromBigInt(id)),
11011
11415
  this.resolverUrl,
11012
11416
  opts
11013
11417
  );
@@ -11896,7 +12300,7 @@ var FSCircuitStorage = class {
11896
12300
  };
11897
12301
 
11898
12302
  // src/proof/proof-service.ts
11899
- var import_js_iden3_core39 = require("@iden3/js-iden3-core");
12303
+ var import_js_iden3_core41 = require("@iden3/js-iden3-core");
11900
12304
 
11901
12305
  // src/proof/common.ts
11902
12306
  var import_js_merkletree28 = require("@iden3/js-merkletree");
@@ -12393,7 +12797,7 @@ var NativeProver = class _NativeProver {
12393
12797
  var import_js_jsonld_merklization9 = require("@iden3/js-jsonld-merklization");
12394
12798
 
12395
12799
  // src/proof/provers/inputs-generator.ts
12396
- var import_js_iden3_core36 = require("@iden3/js-iden3-core");
12800
+ var import_js_iden3_core38 = require("@iden3/js-iden3-core");
12397
12801
  var allOperations2 = Object.values(QueryOperators);
12398
12802
  var v2Operations = [
12399
12803
  0 /* NOOP */,
@@ -12455,7 +12859,7 @@ var InputGenerator = class {
12455
12859
  const smtProof = preparedCredential.credential.getIden3SparseMerkleTreeProof();
12456
12860
  const circuitClaim = new CircuitClaim();
12457
12861
  circuitClaim.claim = preparedCredential.credentialCoreClaim;
12458
- circuitClaim.issuerId = import_js_iden3_core36.DID.idFromDID(import_js_iden3_core36.DID.parse(preparedCredential.credential.issuer));
12862
+ circuitClaim.issuerId = import_js_iden3_core38.DID.idFromDID(import_js_iden3_core38.DID.parse(preparedCredential.credential.issuer));
12459
12863
  if (smtProof) {
12460
12864
  circuitClaim.proof = smtProof.mtp;
12461
12865
  circuitClaim.treeState = {
@@ -12530,7 +12934,7 @@ var InputGenerator = class {
12530
12934
  const circuitClaimData = await this.newCircuitClaimData(preparedCredential);
12531
12935
  circuitClaimData.nonRevProof = toClaimNonRevStatus(preparedCredential.revStatus);
12532
12936
  const circuitInputs = new AtomicQueryMTPV2Inputs();
12533
- circuitInputs.id = import_js_iden3_core36.DID.idFromDID(identifier);
12937
+ circuitInputs.id = import_js_iden3_core38.DID.idFromDID(identifier);
12534
12938
  circuitInputs.requestID = BigInt(proofReq.id);
12535
12939
  const query = circuitQueries[0];
12536
12940
  query.operator = this.transformV2QueryOperator(query.operator);
@@ -12541,7 +12945,7 @@ var InputGenerator = class {
12541
12945
  incProof: { proof: circuitClaimData.proof, treeState: circuitClaimData.treeState },
12542
12946
  nonRevProof: circuitClaimData.nonRevProof
12543
12947
  };
12544
- circuitInputs.currentTimeStamp = (0, import_js_iden3_core36.getUnixTimestamp)(/* @__PURE__ */ new Date());
12948
+ circuitInputs.currentTimeStamp = (0, import_js_iden3_core38.getUnixTimestamp)(/* @__PURE__ */ new Date());
12545
12949
  circuitInputs.claimSubjectProfileNonce = BigInt(params.credentialSubjectProfileNonce);
12546
12950
  circuitInputs.profileNonce = BigInt(params.authProfileNonce);
12547
12951
  circuitInputs.skipClaimRevocationCheck = params.skipRevocation;
@@ -12563,8 +12967,8 @@ var InputGenerator = class {
12563
12967
  });
12564
12968
  circuitClaimData.nonRevProof = toClaimNonRevStatus(preparedCredential.revStatus);
12565
12969
  const circuitInputs = new AtomicQueryMTPV2OnChainInputs();
12566
- const id = import_js_iden3_core36.DID.idFromDID(identifier);
12567
- circuitInputs.id = import_js_iden3_core36.DID.idFromDID(identifier);
12970
+ const id = import_js_iden3_core38.DID.idFromDID(identifier);
12971
+ circuitInputs.id = import_js_iden3_core38.DID.idFromDID(identifier);
12568
12972
  circuitInputs.requestID = BigInt(proofReq.id);
12569
12973
  const stateProof = await this._stateStorage.getGISTProof(id.bigInt());
12570
12974
  const gistProof = toGISTProof(stateProof);
@@ -12597,7 +13001,7 @@ var InputGenerator = class {
12597
13001
  incProof: { proof: circuitClaimData.proof, treeState: circuitClaimData.treeState },
12598
13002
  nonRevProof: circuitClaimData.nonRevProof
12599
13003
  };
12600
- circuitInputs.currentTimeStamp = (0, import_js_iden3_core36.getUnixTimestamp)(/* @__PURE__ */ new Date());
13004
+ circuitInputs.currentTimeStamp = (0, import_js_iden3_core38.getUnixTimestamp)(/* @__PURE__ */ new Date());
12601
13005
  circuitInputs.claimSubjectProfileNonce = BigInt(params.credentialSubjectProfileNonce);
12602
13006
  circuitInputs.profileNonce = BigInt(params.authProfileNonce);
12603
13007
  circuitInputs.skipClaimRevocationCheck = params.skipRevocation;
@@ -12614,7 +13018,7 @@ var InputGenerator = class {
12614
13018
  const circuitClaimData = await this.newCircuitClaimData(preparedCredential);
12615
13019
  circuitClaimData.nonRevProof = toClaimNonRevStatus(preparedCredential.revStatus);
12616
13020
  const circuitInputs = new AtomicQuerySigV2Inputs();
12617
- circuitInputs.id = import_js_iden3_core36.DID.idFromDID(identifier);
13021
+ circuitInputs.id = import_js_iden3_core38.DID.idFromDID(identifier);
12618
13022
  circuitInputs.claim = {
12619
13023
  issuerID: circuitClaimData?.issuerId,
12620
13024
  signatureProof: circuitClaimData.signatureProof,
@@ -12628,7 +13032,7 @@ var InputGenerator = class {
12628
13032
  const query = circuitQueries[0];
12629
13033
  query.operator = this.transformV2QueryOperator(query.operator);
12630
13034
  circuitInputs.query = query;
12631
- circuitInputs.currentTimeStamp = (0, import_js_iden3_core36.getUnixTimestamp)(/* @__PURE__ */ new Date());
13035
+ circuitInputs.currentTimeStamp = (0, import_js_iden3_core38.getUnixTimestamp)(/* @__PURE__ */ new Date());
12632
13036
  this.checkOperatorSupport(proofReq.circuitId, query.operator);
12633
13037
  return circuitInputs.inputsMarshal();
12634
13038
  };
@@ -12647,7 +13051,7 @@ var InputGenerator = class {
12647
13051
  });
12648
13052
  circuitClaimData.nonRevProof = toClaimNonRevStatus(preparedCredential.revStatus);
12649
13053
  const circuitInputs = new AtomicQuerySigV2OnChainInputs();
12650
- const id = import_js_iden3_core36.DID.idFromDID(identifier);
13054
+ const id = import_js_iden3_core38.DID.idFromDID(identifier);
12651
13055
  circuitInputs.id = id;
12652
13056
  circuitInputs.claim = {
12653
13057
  issuerID: circuitClaimData.issuerId,
@@ -12661,7 +13065,7 @@ var InputGenerator = class {
12661
13065
  circuitInputs.skipClaimRevocationCheck = params.skipRevocation;
12662
13066
  const query = circuitQueries[0];
12663
13067
  circuitInputs.query = query;
12664
- circuitInputs.currentTimeStamp = (0, import_js_iden3_core36.getUnixTimestamp)(/* @__PURE__ */ new Date());
13068
+ circuitInputs.currentTimeStamp = (0, import_js_iden3_core38.getUnixTimestamp)(/* @__PURE__ */ new Date());
12665
13069
  if (authClaimData.treeState) {
12666
13070
  circuitInputs.treeState = {
12667
13071
  state: authClaimData.treeState?.state,
@@ -12716,7 +13120,7 @@ var InputGenerator = class {
12716
13120
  break;
12717
13121
  }
12718
13122
  const circuitInputs = new AtomicQueryV3Inputs();
12719
- circuitInputs.id = import_js_iden3_core36.DID.idFromDID(identifier);
13123
+ circuitInputs.id = import_js_iden3_core38.DID.idFromDID(identifier);
12720
13124
  circuitInputs.claim = {
12721
13125
  issuerID: circuitClaimData?.issuerId,
12722
13126
  signatureProof: circuitClaimData.signatureProof,
@@ -12731,10 +13135,10 @@ var InputGenerator = class {
12731
13135
  const query = circuitQueries[0];
12732
13136
  query.values = [16 /* SD */, 0 /* NOOP */].includes(query.operator) ? [] : query.values;
12733
13137
  circuitInputs.query = query;
12734
- circuitInputs.currentTimeStamp = (0, import_js_iden3_core36.getUnixTimestamp)(/* @__PURE__ */ new Date());
13138
+ circuitInputs.currentTimeStamp = (0, import_js_iden3_core38.getUnixTimestamp)(/* @__PURE__ */ new Date());
12735
13139
  circuitInputs.proofType = proofType;
12736
13140
  circuitInputs.linkNonce = params.linkNonce ?? BigInt(0);
12737
- circuitInputs.verifierID = params.verifierDid ? import_js_iden3_core36.DID.idFromDID(params.verifierDid) : void 0;
13141
+ circuitInputs.verifierID = params.verifierDid ? import_js_iden3_core38.DID.idFromDID(params.verifierDid) : void 0;
12738
13142
  circuitInputs.nullifierSessionID = proofReq.params?.nullifierSessionId ? BigInt(proofReq.params?.nullifierSessionId?.toString()) : BigInt(0);
12739
13143
  this.checkOperatorSupport(proofReq.circuitId, query.operator);
12740
13144
  return circuitInputs.inputsMarshal();
@@ -12746,7 +13150,7 @@ var InputGenerator = class {
12746
13150
  params,
12747
13151
  circuitQueries
12748
13152
  }) => {
12749
- const id = import_js_iden3_core36.DID.idFromDID(identifier);
13153
+ const id = import_js_iden3_core38.DID.idFromDID(identifier);
12750
13154
  const circuitClaimData = await this.newCircuitClaimData(preparedCredential);
12751
13155
  circuitClaimData.nonRevProof = toClaimNonRevStatus(preparedCredential.revStatus);
12752
13156
  let proofType;
@@ -12768,7 +13172,7 @@ var InputGenerator = class {
12768
13172
  break;
12769
13173
  }
12770
13174
  const circuitInputs = new AtomicQueryV3OnChainInputs();
12771
- circuitInputs.id = import_js_iden3_core36.DID.idFromDID(identifier);
13175
+ circuitInputs.id = import_js_iden3_core38.DID.idFromDID(identifier);
12772
13176
  circuitInputs.claim = {
12773
13177
  issuerID: circuitClaimData?.issuerId,
12774
13178
  signatureProof: circuitClaimData.signatureProof,
@@ -12783,10 +13187,10 @@ var InputGenerator = class {
12783
13187
  const query = circuitQueries[0];
12784
13188
  query.values = [16 /* SD */, 0 /* NOOP */].includes(query.operator) ? [] : query.values;
12785
13189
  circuitInputs.query = query;
12786
- circuitInputs.currentTimeStamp = (0, import_js_iden3_core36.getUnixTimestamp)(/* @__PURE__ */ new Date());
13190
+ circuitInputs.currentTimeStamp = (0, import_js_iden3_core38.getUnixTimestamp)(/* @__PURE__ */ new Date());
12787
13191
  circuitInputs.proofType = proofType;
12788
13192
  circuitInputs.linkNonce = params.linkNonce ?? BigInt(0);
12789
- circuitInputs.verifierID = params.verifierDid ? import_js_iden3_core36.DID.idFromDID(params.verifierDid) : void 0;
13193
+ circuitInputs.verifierID = params.verifierDid ? import_js_iden3_core38.DID.idFromDID(params.verifierDid) : void 0;
12790
13194
  circuitInputs.nullifierSessionID = proofReq.params?.nullifierSessionId ? BigInt(proofReq.params?.nullifierSessionId?.toString()) : BigInt(0);
12791
13195
  const isEthIdentity = isEthereumIdentity(identifier);
12792
13196
  circuitInputs.isBJJAuthEnabled = isEthIdentity ? 0 : 1;
@@ -12847,16 +13251,16 @@ var InputGenerator = class {
12847
13251
  };
12848
13252
 
12849
13253
  // src/proof/verifiers/pub-signals-verifier.ts
12850
- var import_js_iden3_core38 = require("@iden3/js-iden3-core");
13254
+ var import_js_iden3_core40 = require("@iden3/js-iden3-core");
12851
13255
  var import_js_jsonld_merklization8 = require("@iden3/js-jsonld-merklization");
12852
13256
 
12853
13257
  // src/proof/verifiers/query.ts
12854
- var import_js_iden3_core37 = require("@iden3/js-iden3-core");
13258
+ var import_js_iden3_core39 = require("@iden3/js-iden3-core");
12855
13259
  var import_js_jsonld_merklization7 = require("@iden3/js-jsonld-merklization");
12856
13260
  var import_ethers13 = require("ethers");
12857
13261
  var defaultProofGenerationDelayOpts = 24 * 60 * 60 * 1e3;
12858
13262
  async function checkQueryRequest(query, queriesMetadata, ldContext, outputs, circuitId, schemaLoader, opts) {
12859
- const userDID = import_js_iden3_core37.DID.parseFromId(outputs.issuerId);
13263
+ const userDID = import_js_iden3_core39.DID.parseFromId(outputs.issuerId);
12860
13264
  const issuerAllowed = !query.allowedIssuers || query.allowedIssuers?.some((issuer) => issuer === "*" || issuer === userDID.string());
12861
13265
  if (!issuerAllowed) {
12862
13266
  throw new Error("issuer is not in allowed list");
@@ -12879,7 +13283,7 @@ async function checkQueryRequest(query, queriesMetadata, ldContext, outputs, cir
12879
13283
  if (opts?.acceptedProofGenerationDelay) {
12880
13284
  acceptedProofGenerationDelay = opts.acceptedProofGenerationDelay;
12881
13285
  }
12882
- const timeDiff = Date.now() - (0, import_js_iden3_core37.getDateFromUnixTimestamp)(Number(outputs.timestamp)).getTime();
13286
+ const timeDiff = Date.now() - (0, import_js_iden3_core39.getDateFromUnixTimestamp)(Number(outputs.timestamp)).getTime();
12883
13287
  if (timeDiff > acceptedProofGenerationDelay) {
12884
13288
  throw new Error("generated proof is outdated");
12885
13289
  }
@@ -13345,7 +13749,7 @@ var PubSignalsVerifier = class {
13345
13749
  if (!verifierDIDParam) {
13346
13750
  throw new Error("verifierDid is required");
13347
13751
  }
13348
- const id = import_js_iden3_core38.DID.idFromDID(verifierDIDParam);
13752
+ const id = import_js_iden3_core40.DID.idFromDID(verifierDIDParam);
13349
13753
  if (verifierID.bigInt() != id.bigInt()) {
13350
13754
  throw new Error("wrong verifier is used for nullification");
13351
13755
  }
@@ -13392,7 +13796,7 @@ var PubSignalsVerifier = class {
13392
13796
  acceptedStateTransitionDelay = opts.acceptedStateTransitionDelay;
13393
13797
  }
13394
13798
  if (!gist.latest) {
13395
- const timeDiff = Date.now() - (0, import_js_iden3_core38.getDateFromUnixTimestamp)(Number(gist.transitionTimestamp)).getTime();
13799
+ const timeDiff = Date.now() - (0, import_js_iden3_core40.getDateFromUnixTimestamp)(Number(gist.transitionTimestamp)).getTime();
13396
13800
  if (timeDiff > acceptedStateTransitionDelay) {
13397
13801
  throw new Error("global state is outdated");
13398
13802
  }
@@ -13479,7 +13883,7 @@ var PubSignalsVerifier = class {
13479
13883
  return multiQueryPubSignals;
13480
13884
  };
13481
13885
  verifyIdOwnership = (sender, challenge) => {
13482
- const senderId = import_js_iden3_core38.DID.idFromDID(import_js_iden3_core38.DID.parse(sender));
13886
+ const senderId = import_js_iden3_core40.DID.idFromDID(import_js_iden3_core40.DID.parse(sender));
13483
13887
  if (senderId.string() !== this.userId.string()) {
13484
13888
  throw new Error(
13485
13889
  `sender id is not used for proof creation, expected ${sender}, user from public signals: ${this.userId.string()}`
@@ -13544,7 +13948,7 @@ var PubSignalsVerifier = class {
13544
13948
  }
13545
13949
  async resolve(id, state) {
13546
13950
  const idBigInt = id.bigInt();
13547
- const did = import_js_iden3_core38.DID.parseFromId(id);
13951
+ const did = import_js_iden3_core40.DID.parseFromId(id);
13548
13952
  const isGenesis = isGenesisState(did, state);
13549
13953
  let contractState;
13550
13954
  try {
@@ -13622,7 +14026,7 @@ var PubSignalsVerifier = class {
13622
14026
  );
13623
14027
  const acceptedStateTransitionDelay = opts?.acceptedStateTransitionDelay ?? constants_exports.DEFAULT_PROOF_VERIFY_DELAY;
13624
14028
  if (!issuerNonRevStateResolved.latest) {
13625
- const timeDiff = Date.now() - (0, import_js_iden3_core38.getDateFromUnixTimestamp)(Number(issuerNonRevStateResolved.transitionTimestamp)).getTime();
14029
+ const timeDiff = Date.now() - (0, import_js_iden3_core40.getDateFromUnixTimestamp)(Number(issuerNonRevStateResolved.transitionTimestamp)).getTime();
13626
14030
  if (timeDiff > acceptedStateTransitionDelay) {
13627
14031
  throw new Error("issuer state is outdated");
13628
14032
  }
@@ -13711,7 +14115,7 @@ var ProofService = class {
13711
14115
  credentialCoreClaim,
13712
14116
  revStatus: credentialWithRevStatus.revStatus
13713
14117
  };
13714
- const subjectDID = import_js_iden3_core39.DID.parse(preparedCredential.credential.credentialSubject["id"]);
14118
+ const subjectDID = import_js_iden3_core41.DID.parse(preparedCredential.credential.credentialSubject["id"]);
13715
14119
  const { nonce: credentialSubjectProfileNonce, genesisDID: subjectGenesisDID } = await this._identityWallet.getGenesisDIDMetadata(subjectDID);
13716
14120
  if (subjectGenesisDID.string() !== genesisDID.string()) {
13717
14121
  throw new Error(VerifiableConstants.ERRORS.PROOF_SERVICE_PROFILE_GENESIS_DID_MISMATCH);
@@ -13724,7 +14128,7 @@ var ProofService = class {
13724
14128
  }
13725
14129
  const mtPosition = preparedCredential.credentialCoreClaim.getMerklizedPosition();
13726
14130
  let mk;
13727
- if (mtPosition !== import_js_iden3_core39.MerklizedRootPosition.None) {
14131
+ if (mtPosition !== import_js_iden3_core41.MerklizedRootPosition.None) {
13728
14132
  mk = await preparedCredential.credential.merklize(this._ldOptions);
13729
14133
  }
13730
14134
  const context = proofReq.query["context"];
@@ -13790,7 +14194,7 @@ var ProofService = class {
13790
14194
  switch (circuitId) {
13791
14195
  case "authV2" /* AuthV2 */:
13792
14196
  {
13793
- const challenge = opts.challenge ? import_js_iden3_core39.BytesHelper.intToBytes(opts.challenge).reverse() : new Uint8Array(32);
14197
+ const challenge = opts.challenge ? import_js_iden3_core41.BytesHelper.intToBytes(opts.challenge).reverse() : new Uint8Array(32);
13794
14198
  zkProof = await this.generateAuthV2Proof(challenge, identifier);
13795
14199
  }
13796
14200
  return {
@@ -13873,10 +14277,10 @@ var ProofService = class {
13873
14277
  throw new Error("CircuitId is not supported");
13874
14278
  }
13875
14279
  const { nonce: authProfileNonce, genesisDID } = await this._identityWallet.getGenesisDIDMetadata(did);
13876
- const challenge = import_js_iden3_core39.BytesHelper.bytesToInt(hash.reverse());
14280
+ const challenge = import_js_iden3_core41.BytesHelper.bytesToInt(hash.reverse());
13877
14281
  const authPrepared = await this._inputsGenerator.prepareAuthBJJCredential(genesisDID);
13878
14282
  const signature = await this._identityWallet.signChallenge(challenge, authPrepared.credential);
13879
- const id = import_js_iden3_core39.DID.idFromDID(genesisDID);
14283
+ const id = import_js_iden3_core41.DID.idFromDID(genesisDID);
13880
14284
  const stateProof = await this._stateStorage.getGISTProof(id.bigInt());
13881
14285
  const gistProof = toGISTProof(stateProof);
13882
14286
  const authInputs = new AuthV2Inputs();
@@ -13916,7 +14320,7 @@ var ProofService = class {
13916
14320
  if (globalStateInfo.replacedAtTimestamp === 0n) {
13917
14321
  throw new Error(`state was replaced, but replaced time unknown`);
13918
14322
  }
13919
- const timeDiff = Date.now() - (0, import_js_iden3_core39.getDateFromUnixTimestamp)(Number(globalStateInfo.replacedAtTimestamp)).getTime();
14323
+ const timeDiff = Date.now() - (0, import_js_iden3_core41.getDateFromUnixTimestamp)(Number(globalStateInfo.replacedAtTimestamp)).getTime();
13920
14324
  if (timeDiff > (opts?.acceptedStateTransitionDelay ?? constants_exports.DEFAULT_AUTH_VERIFY_DELAY)) {
13921
14325
  throw new Error("global state is outdated");
13922
14326
  }
@@ -13979,18 +14383,18 @@ var IdentityWallet = class {
13979
14383
  const keyId = await this._kms.createKeyFromSeed("BJJ" /* BabyJubJub */, seed);
13980
14384
  const pubKeyHex = await this._kms.publicKey(keyId);
13981
14385
  const pubKey = import_js_crypto12.PublicKey.newFromHex(pubKeyHex);
13982
- const schemaHash = import_js_iden3_core40.SchemaHash.authSchemaHash;
13983
- const authClaim = import_js_iden3_core40.Claim.newClaim(
14386
+ const schemaHash = import_js_iden3_core42.SchemaHash.authSchemaHash;
14387
+ const authClaim = import_js_iden3_core42.Claim.newClaim(
13984
14388
  schemaHash,
13985
- import_js_iden3_core40.ClaimOptions.withIndexDataInts(pubKey.p[0], pubKey.p[1]),
13986
- import_js_iden3_core40.ClaimOptions.withRevocationNonce(BigInt(0))
14389
+ import_js_iden3_core42.ClaimOptions.withIndexDataInts(pubKey.p[0], pubKey.p[1]),
14390
+ import_js_iden3_core42.ClaimOptions.withRevocationNonce(BigInt(0))
13987
14391
  );
13988
14392
  authClaim.setRevocationNonce(BigInt(revNonce));
13989
14393
  return { authClaim, pubKey };
13990
14394
  }
13991
14395
  async createAuthBJJCredential(did, pubKey, authClaim, currentState, revocationOpts) {
13992
14396
  const authData = authClaim.getExpirationDate();
13993
- const expiration = authData ? (0, import_js_iden3_core40.getUnixTimestamp)(authData) : 0;
14397
+ const expiration = authData ? (0, import_js_iden3_core42.getUnixTimestamp)(authData) : 0;
13994
14398
  const request = {
13995
14399
  credentialSchema: VerifiableConstants.AUTH.AUTH_BJJ_CREDENTIAL_SCHEMA_JSON_URL,
13996
14400
  type: VerifiableConstants.AUTH.AUTH_BJJ_CREDENTIAL_TYPE,
@@ -14039,13 +14443,13 @@ var IdentityWallet = class {
14039
14443
  );
14040
14444
  const ctr = await claimsTree.root();
14041
14445
  const currentState = (0, import_js_merkletree29.hashElems)([ctr.bigInt(), import_js_merkletree29.ZERO_HASH.bigInt(), import_js_merkletree29.ZERO_HASH.bigInt()]);
14042
- const didType = (0, import_js_iden3_core40.buildDIDType)(
14043
- opts.method || import_js_iden3_core40.DidMethod.Iden3,
14044
- opts.blockchain || import_js_iden3_core40.Blockchain.Polygon,
14045
- opts.networkId || import_js_iden3_core40.NetworkId.Amoy
14446
+ const didType = (0, import_js_iden3_core42.buildDIDType)(
14447
+ opts.method || import_js_iden3_core42.DidMethod.Iden3,
14448
+ opts.blockchain || import_js_iden3_core42.Blockchain.Polygon,
14449
+ opts.networkId || import_js_iden3_core42.NetworkId.Amoy
14046
14450
  );
14047
- const identifier = import_js_iden3_core40.Id.idGenesisFromIdenState(didType, currentState.bigInt());
14048
- const did = import_js_iden3_core40.DID.parseFromId(identifier);
14451
+ const identifier = import_js_iden3_core42.Id.idGenesisFromIdenState(didType, currentState.bigInt());
14452
+ const did = import_js_iden3_core42.DID.parseFromId(identifier);
14049
14453
  await this._storage.mt.bindMerkleTreeToNewIdentifier(tmpIdentifier, did.string());
14050
14454
  const oldTreeState = {
14051
14455
  revocationRoot: import_js_merkletree29.ZERO_HASH,
@@ -14129,10 +14533,10 @@ var IdentityWallet = class {
14129
14533
  throw new Error(VerifiableConstants.ERRORS.ID_WALLET_SIGNER_IS_REQUIRED);
14130
14534
  }
14131
14535
  const currentState = import_js_merkletree29.ZERO_HASH;
14132
- const didType = (0, import_js_iden3_core40.buildDIDType)(
14133
- opts.method || import_js_iden3_core40.DidMethod.Iden3,
14134
- opts.blockchain || import_js_iden3_core40.Blockchain.Polygon,
14135
- opts.networkId || import_js_iden3_core40.NetworkId.Amoy
14536
+ const didType = (0, import_js_iden3_core42.buildDIDType)(
14537
+ opts.method || import_js_iden3_core42.DidMethod.Iden3,
14538
+ opts.blockchain || import_js_iden3_core42.Blockchain.Polygon,
14539
+ opts.networkId || import_js_iden3_core42.NetworkId.Amoy
14136
14540
  );
14137
14541
  const keyIdEth = await this._kms.createKeyFromSeed("Secp256k1" /* Secp256k1 */, opts.seed);
14138
14542
  const pubKeyHexEth = (await this._kms.publicKey(keyIdEth)).slice(2);
@@ -14162,13 +14566,13 @@ var IdentityWallet = class {
14162
14566
  async getGenesisDIDMetadata(did) {
14163
14567
  const identity = await this._storage.identity.getIdentity(did.string());
14164
14568
  if (identity) {
14165
- return { nonce: 0, genesisDID: import_js_iden3_core40.DID.parse(identity.did) };
14569
+ return { nonce: 0, genesisDID: import_js_iden3_core42.DID.parse(identity.did) };
14166
14570
  }
14167
14571
  const profile = await this._storage.identity.getProfileById(did.string());
14168
14572
  if (!profile) {
14169
14573
  throw new Error(VerifiableConstants.ERRORS.ID_WALLET_PROFILE_OR_IDENTITY_NOT_FOUND);
14170
14574
  }
14171
- return { nonce: profile.nonce, genesisDID: import_js_iden3_core40.DID.parse(profile.genesisIdentifier) };
14575
+ return { nonce: profile.nonce, genesisDID: import_js_iden3_core42.DID.parse(profile.genesisIdentifier) };
14172
14576
  }
14173
14577
  /** {@inheritDoc IIdentityWallet.createProfile} */
14174
14578
  async createProfile(did, nonce, verifier, tags) {
@@ -14312,13 +14716,13 @@ var IdentityWallet = class {
14312
14716
  async sign(message, credential) {
14313
14717
  const keyKMSId = getKMSIdByAuthCredential(credential);
14314
14718
  const payload = import_js_crypto12.poseidon.hashBytes(message);
14315
- const signature = await this._kms.sign(keyKMSId, import_js_iden3_core40.BytesHelper.intToBytes(payload));
14719
+ const signature = await this._kms.sign(keyKMSId, import_js_iden3_core42.BytesHelper.intToBytes(payload));
14316
14720
  return import_js_crypto12.Signature.newFromCompressed(signature);
14317
14721
  }
14318
14722
  /** {@inheritDoc IIdentityWallet.signChallenge} */
14319
14723
  async signChallenge(challenge, credential) {
14320
14724
  const keyKMSId = getKMSIdByAuthCredential(credential);
14321
- const signature = await this._kms.sign(keyKMSId, import_js_iden3_core40.BytesHelper.intToBytes(challenge));
14725
+ const signature = await this._kms.sign(keyKMSId, import_js_iden3_core42.BytesHelper.intToBytes(challenge));
14322
14726
  return import_js_crypto12.Signature.newFromCompressed(signature);
14323
14727
  }
14324
14728
  /** {@inheritDoc IIdentityWallet.issueCredential} */
@@ -14598,7 +15002,7 @@ var IdentityWallet = class {
14598
15002
  state: newTreeModel.state,
14599
15003
  rootOfRoots
14600
15004
  };
14601
- const userId = import_js_iden3_core40.DID.idFromDID(did);
15005
+ const userId = import_js_iden3_core42.DID.idFromDID(did);
14602
15006
  let proof;
14603
15007
  const isEthIdentity = isEthereumIdentity(did);
14604
15008
  let txId;
@@ -14856,9 +15260,16 @@ var jsonLDMerklizer = __toESM(require("@iden3/js-jsonld-merklization"), 1);
14856
15260
  RefreshServiceType,
14857
15261
  RevocationStatusHandler,
14858
15262
  SDK_EVENTS,
15263
+ SOLANA_CHAIN_REF,
14859
15264
  Scalar,
14860
15265
  SearchError,
14861
15266
  Sec256k1Provider,
15267
+ SolanaNativePaymentRequest,
15268
+ SolanaNativePaymentSchema,
15269
+ SolanaPaymentInstruction,
15270
+ SolanaPaymentInstructionSchema,
15271
+ SolanaSplPaymentRequest,
15272
+ SolanaSplPaymentSchema,
14862
15273
  StandardJSONCredentialsQueryFilter,
14863
15274
  StateTransitionInputs,
14864
15275
  StateTransitionPubSignals,
@@ -14882,7 +15293,9 @@ var jsonLDMerklizer = __toESM(require("@iden3/js-jsonld-merklization"), 1);
14882
15293
  bigIntCompare,
14883
15294
  buildAccept,
14884
15295
  buildDIDFromEthPubKey,
15296
+ buildEvmPayment,
14885
15297
  buildFieldPath,
15298
+ buildSolanaPayment,
14886
15299
  buildTreeState,
14887
15300
  buildVerifierId,
14888
15301
  byteDecoder,
@@ -14980,6 +15393,7 @@ var jsonLDMerklizer = __toESM(require("@iden3/js-jsonld-merklization"), 1);
14980
15393
  resolveDidDocument,
14981
15394
  resolvePath,
14982
15395
  resolveVerificationMethods,
15396
+ serializeSolanaPaymentInstruction,
14983
15397
  strMTHex,
14984
15398
  stringByPath,
14985
15399
  subjectPositionIndex,
@@ -15001,6 +15415,7 @@ var jsonLDMerklizer = __toESM(require("@iden3/js-jsonld-merklization"), 1);
15001
15415
  verifyExpiresTime,
15002
15416
  verifyFieldValueInclusionNativeExistsSupport,
15003
15417
  verifyFieldValueInclusionV2,
15418
+ verifyIden3SolanaPaymentRequest,
15004
15419
  witnessBuilder
15005
15420
  });
15006
15421
  //# sourceMappingURL=index.cjs.map