@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.
- package/dist/browser/esm/index.js +1123 -719
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/browser/umd/index.global.js +182 -59
- package/dist/browser/umd/index.global.js.map +1 -1
- package/dist/node/cjs/index.cjs +1330 -915
- package/dist/node/cjs/index.cjs.map +1 -1
- package/dist/node/esm/index.js +1123 -719
- package/dist/node/esm/index.js.map +1 -1
- package/dist/types/iden3comm/handlers/credential-proposal.d.ts.map +1 -1
- package/dist/types/iden3comm/handlers/fetch.d.ts.map +1 -1
- package/dist/types/iden3comm/handlers/payment.d.ts +14 -5
- package/dist/types/iden3comm/handlers/payment.d.ts.map +1 -1
- package/dist/types/iden3comm/types/protocol/payment.d.ts +58 -9
- package/dist/types/iden3comm/types/protocol/payment.d.ts.map +1 -1
- package/dist/types/utils/index.d.ts +2 -0
- package/dist/types/utils/index.d.ts.map +1 -1
- package/dist/types/utils/payments/evm.d.ts +19 -0
- package/dist/types/utils/payments/evm.d.ts.map +1 -0
- package/dist/types/utils/payments/solana.d.ts +88 -0
- package/dist/types/utils/payments/solana.d.ts.map +1 -0
- package/dist/types/verifiable/constants.d.ts +16 -3
- package/dist/types/verifiable/constants.d.ts.map +1 -1
- package/package.json +5 -1
- package/src/iden3comm/handlers/credential-proposal.ts +4 -1
- package/src/iden3comm/handlers/fetch.ts +7 -1
- package/src/iden3comm/handlers/payment.ts +138 -131
- package/src/iden3comm/types/protocol/payment.ts +79 -10
- package/src/utils/index.ts +2 -0
- package/src/utils/payments/evm.ts +152 -0
- package/src/utils/payments/solana.ts +360 -0
- package/src/verifiable/constants.ts +17 -3
package/dist/node/esm/index.js
CHANGED
|
@@ -91,8 +91,8 @@ var KMS = class {
|
|
|
91
91
|
};
|
|
92
92
|
|
|
93
93
|
// src/kms/key-providers/bjj-provider.ts
|
|
94
|
-
import { Hex as
|
|
95
|
-
import { BytesHelper, checkBigIntInField } from "@iden3/js-iden3-core";
|
|
94
|
+
import { Hex as Hex4, PrivateKey, PublicKey as PublicKey4, Signature as Signature2 } from "@iden3/js-crypto";
|
|
95
|
+
import { BytesHelper as BytesHelper2, checkBigIntInField } from "@iden3/js-iden3-core";
|
|
96
96
|
|
|
97
97
|
// src/kms/store/abstract-key-store.ts
|
|
98
98
|
var AbstractPrivateKeyStore = class {
|
|
@@ -486,616 +486,337 @@ var bigIntCompare = (a, b) => {
|
|
|
486
486
|
return 0;
|
|
487
487
|
};
|
|
488
488
|
|
|
489
|
-
// src/
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
489
|
+
// src/utils/payments/solana.ts
|
|
490
|
+
import { serialize } from "borsh";
|
|
491
|
+
import { ed25519 } from "@noble/curves/ed25519";
|
|
492
|
+
|
|
493
|
+
// src/verifiable/proof.ts
|
|
494
|
+
import { Hash as Hash2, Proof } from "@iden3/js-merkletree";
|
|
495
|
+
|
|
496
|
+
// src/verifiable/constants.ts
|
|
497
|
+
var VerifiableConstants = Object.freeze({
|
|
498
|
+
ERRORS: {
|
|
499
|
+
FiELD_IS_EMPTY: "fieldPath is empty",
|
|
500
|
+
CONTEXT_TYPE_IS_EMPTY: "ctxType is empty",
|
|
501
|
+
// ErrStateNotFound issuer state is genesis state.
|
|
502
|
+
IDENTITY_DOES_NOT_EXIST: "Identity does not exist",
|
|
503
|
+
IDENTITY_DOES_NOT_EXIST_CUSTOM_ERROR: "IdentityDoesNotExist",
|
|
504
|
+
NO_AUTH_CRED_FOUND: "no auth credentials found",
|
|
505
|
+
STATE_DOES_NOT_EXIST: "State does not exist",
|
|
506
|
+
STATE_DOES_NOT_EXIST_CUSTOM_ERROR: "StateDoesNotExist",
|
|
507
|
+
ROOT_DOES_NOT_EXIST: "Root does not exist",
|
|
508
|
+
ROOT_DOES_NOT_EXIST_CUSTOM_ERROR: "RootDoesNotExist",
|
|
509
|
+
// identity wallet
|
|
510
|
+
ID_WALLET_NO_CREDENTIAL_SATISFIED_QUERY: "no credential satisfied query",
|
|
511
|
+
ID_WALLET_SIGNER_IS_REQUIRED: "Ethereum signer is required to create Ethereum identities in order to transit state",
|
|
512
|
+
ID_WALLET_PROVER_IS_REQUIRED: "prover is required to generate proofs for non ethereum identities",
|
|
513
|
+
ID_WALLET_CORE_CLAIM_REQUIRED_IN_SIG_PROOF: "credential must have coreClaim representation in the signature proof",
|
|
514
|
+
ID_WALLET_CORE_CLAIM_REQUIRED_IN_ANY_PROOF: "credential must have coreClaim representation in proofs",
|
|
515
|
+
ID_WALLET_CORE_CLAIM_MISMATCH: "core claim representations is set in both proofs but they are not equal",
|
|
516
|
+
ID_WALLET_CORE_CLAIM_IS_NOT_SET: "core claim is not set in credential proofs",
|
|
517
|
+
ID_WALLET_PROFILE_OR_IDENTITY_NOT_FOUND: "profile or identity not found",
|
|
518
|
+
ID_WALLET_PROFILE_ALREADY_EXISTS: "profile with given nonce or verifier already exists",
|
|
519
|
+
ID_WALLET_PROFILE_ALREADY_EXISTS_VERIFIER_TAGS: "profile with given verifier and tags already exists",
|
|
520
|
+
ID_WALLET_ISSUER_AUTH_BJJ_CRED_MUST_HAVE_ANY_PROOF: "issuer auth credential must have proof",
|
|
521
|
+
ID_WALLET_ISSUER_AUTH_BJJ_CRED_MUST_HAVE_MTP_PROOF: "mtp is required for auth bjj key to issue new credentials",
|
|
522
|
+
// proof service
|
|
523
|
+
PROOF_SERVICE_NO_CREDENTIAL_FOR_IDENTITY_OR_PROFILE: "no credentials belong to did or its profiles",
|
|
524
|
+
PROOF_SERVICE_NO_CREDENTIAL_FOR_QUERY: "credential not found for query",
|
|
525
|
+
PROOF_SERVICE_PROFILE_GENESIS_DID_MISMATCH: "subject and auth profiles are not derived from the same did",
|
|
526
|
+
PROOF_SERVICE_NO_QUERIES_IN_ZKP_REQUEST: "no queries in zkp request",
|
|
527
|
+
// credential wallet
|
|
528
|
+
CREDENTIAL_WALLET_ALL_CREDENTIALS_ARE_REVOKED: "all claims are revoked"
|
|
529
|
+
},
|
|
530
|
+
CREDENTIAL_TYPE: {
|
|
531
|
+
// VerifiableCredential is a W3C verifiable credential type
|
|
532
|
+
W3C_VERIFIABLE_CREDENTIAL: "VerifiableCredential",
|
|
533
|
+
W3C_VERIFIABLE_PRESENTATION: "VerifiablePresentation"
|
|
534
|
+
},
|
|
535
|
+
CREDENTIAL_SUBJECT_PATH: "https://www.w3.org/2018/credentials#credentialSubject",
|
|
536
|
+
JSONLD_SCHEMA: {
|
|
537
|
+
// JSONLDSchemaIden3Credential is a schema for context with Iden3Credential type
|
|
538
|
+
IDEN3_CREDENTIAL: "https://schema.iden3.io/core/jsonld/iden3proofs.jsonld",
|
|
539
|
+
// JSONLDSchemaIden3DisplayMethod is a schema for context with Iden3BasicDisplayMethodV1 type
|
|
540
|
+
IDEN3_DISPLAY_METHOD: "https://schema.iden3.io/core/jsonld/displayMethod.jsonld",
|
|
541
|
+
// JSONLDSchemaW3CCredential2018 is a schema for context with VerifiableCredential type
|
|
542
|
+
W3C_CREDENTIAL_2018: "https://www.w3.org/2018/credentials/v1",
|
|
543
|
+
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"}}}`,
|
|
544
|
+
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"}}`,
|
|
545
|
+
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"}}}}`
|
|
546
|
+
},
|
|
547
|
+
// JsonSchema2023 JSON schema for verification of Iden3Credential
|
|
548
|
+
JSON_SCHEMA_VALIDATOR: "JsonSchema2023",
|
|
549
|
+
SERVICE_TYPE: {
|
|
550
|
+
// Iden3CommServiceType is service type for iden3comm protocol
|
|
551
|
+
IDEN3_COMM: "iden3-communication",
|
|
552
|
+
// PushNotificationServiceType is service type for delivering push notifications to identity
|
|
553
|
+
PUSH_NOTIFICATION: "push-notification"
|
|
554
|
+
},
|
|
555
|
+
AUTH: {
|
|
556
|
+
AUTH_BJJ_CREDENTIAL_HASH: "013fd3f623559d850fb5b02ff012d0e2",
|
|
557
|
+
AUTH_BJJ_CREDENTIAL_SCHEMA_JSON_URL: "https://schema.iden3.io/core/json/auth.json",
|
|
558
|
+
AUTH_BJJ_CREDENTIAL_SCHEMA_JSONLD_URL: "https://schema.iden3.io/core/jsonld/auth.jsonld",
|
|
559
|
+
AUTH_BJJ_CREDENTIAL_TYPE: "AuthBJJCredential",
|
|
560
|
+
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"}}}}}`,
|
|
561
|
+
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"}}}}}}]}`
|
|
516
562
|
}
|
|
563
|
+
});
|
|
564
|
+
var ProofType = /* @__PURE__ */ ((ProofType2) => {
|
|
565
|
+
ProofType2["BJJSignature"] = "BJJSignature2021";
|
|
566
|
+
ProofType2["Iden3SparseMerkleTreeProof"] = "Iden3SparseMerkleTreeProof";
|
|
567
|
+
return ProofType2;
|
|
568
|
+
})(ProofType || {});
|
|
569
|
+
var CredentialStatusType = /* @__PURE__ */ ((CredentialStatusType2) => {
|
|
570
|
+
CredentialStatusType2["SparseMerkleTreeProof"] = "SparseMerkleTreeProof";
|
|
571
|
+
CredentialStatusType2["Iden3ReverseSparseMerkleTreeProof"] = "Iden3ReverseSparseMerkleTreeProof";
|
|
572
|
+
CredentialStatusType2["Iden3commRevocationStatusV1"] = "Iden3commRevocationStatusV1.0";
|
|
573
|
+
CredentialStatusType2["Iden3OnchainSparseMerkleTreeProof2023"] = "Iden3OnchainSparseMerkleTreeProof2023";
|
|
574
|
+
return CredentialStatusType2;
|
|
575
|
+
})(CredentialStatusType || {});
|
|
576
|
+
var ProofPurpose = /* @__PURE__ */ ((ProofPurpose2) => {
|
|
577
|
+
ProofPurpose2["Authentication"] = "Authentication";
|
|
578
|
+
return ProofPurpose2;
|
|
579
|
+
})(ProofPurpose || {});
|
|
580
|
+
var MerklizedRootPosition = /* @__PURE__ */ ((MerklizedRootPosition4) => {
|
|
581
|
+
MerklizedRootPosition4["Index"] = "index";
|
|
582
|
+
MerklizedRootPosition4["Value"] = "value";
|
|
583
|
+
MerklizedRootPosition4["None"] = "";
|
|
584
|
+
return MerklizedRootPosition4;
|
|
585
|
+
})(MerklizedRootPosition || {});
|
|
586
|
+
var SubjectPosition = /* @__PURE__ */ ((SubjectPosition2) => {
|
|
587
|
+
SubjectPosition2["None"] = "";
|
|
588
|
+
SubjectPosition2["Index"] = "index";
|
|
589
|
+
SubjectPosition2["Value"] = "value";
|
|
590
|
+
return SubjectPosition2;
|
|
591
|
+
})(SubjectPosition || {});
|
|
592
|
+
var RefreshServiceType = /* @__PURE__ */ ((RefreshServiceType2) => {
|
|
593
|
+
RefreshServiceType2["Iden3RefreshService2023"] = "Iden3RefreshService2023";
|
|
594
|
+
return RefreshServiceType2;
|
|
595
|
+
})(RefreshServiceType || {});
|
|
596
|
+
var PaymentRequestDataType = /* @__PURE__ */ ((PaymentRequestDataType2) => {
|
|
597
|
+
PaymentRequestDataType2["Iden3PaymentRequestCryptoV1"] = "Iden3PaymentRequestCryptoV1";
|
|
598
|
+
PaymentRequestDataType2["Iden3PaymentRailsRequestV1"] = "Iden3PaymentRailsRequestV1";
|
|
599
|
+
PaymentRequestDataType2["Iden3PaymentRailsERC20RequestV1"] = "Iden3PaymentRailsERC20RequestV1";
|
|
600
|
+
PaymentRequestDataType2["Iden3PaymentRailsSolanaRequestV1"] = "Iden3PaymentRailsSolanaRequestV1";
|
|
601
|
+
PaymentRequestDataType2["Iden3PaymentRailsSolanaSPLRequestV1"] = "Iden3PaymentRailsSolanaSPLRequestV1";
|
|
602
|
+
return PaymentRequestDataType2;
|
|
603
|
+
})(PaymentRequestDataType || {});
|
|
604
|
+
var PaymentType = /* @__PURE__ */ ((PaymentType2) => {
|
|
605
|
+
PaymentType2["Iden3PaymentCryptoV1"] = "Iden3PaymentCryptoV1";
|
|
606
|
+
PaymentType2["Iden3PaymentRailsV1"] = "Iden3PaymentRailsV1";
|
|
607
|
+
PaymentType2["Iden3PaymentRailsERC20V1"] = "Iden3PaymentRailsERC20V1";
|
|
608
|
+
PaymentType2["Iden3PaymentRailsSolanaV1"] = "Iden3PaymentRailsSolanaV1";
|
|
609
|
+
PaymentType2["Iden3PaymentRailsSolanaSPLV1"] = "Iden3PaymentRailsSolanaSPLV1";
|
|
610
|
+
return PaymentType2;
|
|
611
|
+
})(PaymentType || {});
|
|
612
|
+
var SupportedPaymentProofType = /* @__PURE__ */ ((SupportedPaymentProofType2) => {
|
|
613
|
+
SupportedPaymentProofType2["EthereumEip712Signature2021"] = "EthereumEip712Signature2021";
|
|
614
|
+
SupportedPaymentProofType2["SolanaEd25519Signature2025"] = "SolanaEd25519Signature2025";
|
|
615
|
+
return SupportedPaymentProofType2;
|
|
616
|
+
})(SupportedPaymentProofType || {});
|
|
617
|
+
var SupportedCurrencies = /* @__PURE__ */ ((SupportedCurrencies2) => {
|
|
618
|
+
SupportedCurrencies2["ETH"] = "ETH";
|
|
619
|
+
SupportedCurrencies2["ETH_WEI"] = "ETHWEI";
|
|
620
|
+
SupportedCurrencies2["ETH_GWEI"] = "ETHGWEI";
|
|
621
|
+
SupportedCurrencies2["MATIC"] = "MATIC";
|
|
622
|
+
SupportedCurrencies2["POL"] = "POL";
|
|
623
|
+
return SupportedCurrencies2;
|
|
624
|
+
})(SupportedCurrencies || {});
|
|
625
|
+
var PaymentFeatures = /* @__PURE__ */ ((PaymentFeatures2) => {
|
|
626
|
+
PaymentFeatures2["EIP_2612"] = "EIP-2612";
|
|
627
|
+
return PaymentFeatures2;
|
|
628
|
+
})(PaymentFeatures || {});
|
|
629
|
+
var DisplayMethodType = /* @__PURE__ */ ((DisplayMethodType2) => {
|
|
630
|
+
DisplayMethodType2["Iden3BasicDisplayMethodV1"] = "Iden3BasicDisplayMethodV1";
|
|
631
|
+
return DisplayMethodType2;
|
|
632
|
+
})(DisplayMethodType || {});
|
|
633
|
+
var DEFAULT_CACHE_MAX_SIZE = 1e4;
|
|
634
|
+
var SOLANA_CHAIN_REF = Object.freeze({
|
|
635
|
+
DEVNET: "EtWTRABZaYq6iMfeYKouRu166VU2xqa1",
|
|
636
|
+
TESTNET: "4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z",
|
|
637
|
+
MAINNET: "5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"
|
|
638
|
+
});
|
|
639
|
+
|
|
640
|
+
// src/verifiable/proof.ts
|
|
641
|
+
import { Hex as Hex3, Signature } from "@iden3/js-crypto";
|
|
642
|
+
import { Claim, DID as DID2 } from "@iden3/js-iden3-core";
|
|
643
|
+
var Iden3SparseMerkleTreeProof = class _Iden3SparseMerkleTreeProof {
|
|
644
|
+
type;
|
|
645
|
+
issuerData;
|
|
646
|
+
mtp;
|
|
647
|
+
coreClaim;
|
|
517
648
|
/**
|
|
518
|
-
*
|
|
519
|
-
* @param {
|
|
520
|
-
* @returns kms key identifier
|
|
649
|
+
* Creates an instance of Iden3SparseMerkleTreeProof.
|
|
650
|
+
* @param {object} obj
|
|
521
651
|
*/
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
const publicKey = privateKey.public();
|
|
528
|
-
const kmsId = {
|
|
529
|
-
type: this.keyType,
|
|
530
|
-
id: keyPath(this.keyType, publicKey.hex())
|
|
531
|
-
};
|
|
532
|
-
await this.keyStore.importKey({ alias: kmsId.id, key: privateKey.hex() });
|
|
533
|
-
return kmsId;
|
|
652
|
+
constructor(obj) {
|
|
653
|
+
this.coreClaim = obj.coreClaim;
|
|
654
|
+
this.issuerData = obj.issuerData;
|
|
655
|
+
this.type = "Iden3SparseMerkleTreeProof" /* Iden3SparseMerkleTreeProof */;
|
|
656
|
+
this.mtp = obj.mtp;
|
|
534
657
|
}
|
|
535
658
|
/**
|
|
536
|
-
* Gets public key by kmsKeyId
|
|
537
659
|
*
|
|
538
|
-
* @param {KmsKeyId} keyId - key identifier
|
|
539
|
-
*/
|
|
540
|
-
async publicKey(keyId) {
|
|
541
|
-
const privateKey = await this.privateKey(keyId);
|
|
542
|
-
return privateKey.public().hex();
|
|
543
|
-
}
|
|
544
|
-
/**
|
|
545
|
-
* signs prepared payload of size,
|
|
546
|
-
* with a key id
|
|
547
660
|
*
|
|
548
|
-
* @
|
|
549
|
-
* @param {Uint8Array} data - data to sign (32 bytes)
|
|
550
|
-
* @returns Uint8Array signature
|
|
661
|
+
* @returns `json object in serialized presentation`
|
|
551
662
|
*/
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
const publicKey = await this.publicKey(keyId);
|
|
570
|
-
return PublicKey.newFromCompressed(hexToBytes(publicKey)).verifyPoseidon(
|
|
571
|
-
BytesHelper.bytesToInt(message),
|
|
572
|
-
Signature.newFromCompressed(hexToBytes(signatureHex))
|
|
573
|
-
);
|
|
663
|
+
toJSON() {
|
|
664
|
+
const issuerId = this.issuerData.id;
|
|
665
|
+
return {
|
|
666
|
+
issuerData: {
|
|
667
|
+
id: issuerId.string(),
|
|
668
|
+
state: {
|
|
669
|
+
...this.issuerData.state,
|
|
670
|
+
rootOfRoots: this.issuerData.state.rootOfRoots.hex(),
|
|
671
|
+
claimsTreeRoot: this.issuerData.state.claimsTreeRoot.hex(),
|
|
672
|
+
revocationTreeRoot: this.issuerData.state.revocationTreeRoot.hex(),
|
|
673
|
+
value: this.issuerData.state.value.hex()
|
|
674
|
+
}
|
|
675
|
+
},
|
|
676
|
+
type: this.type,
|
|
677
|
+
coreClaim: this.coreClaim.hex(),
|
|
678
|
+
mtp: this.mtp.toJSON()
|
|
679
|
+
};
|
|
574
680
|
}
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
return allKeysFromKeyStore.filter((key) => key.alias.startsWith(this.keyType));
|
|
596
|
-
}
|
|
597
|
-
/**
|
|
598
|
-
* generates a ed25519 key from a seed phrase
|
|
599
|
-
* @param {Uint8Array} seed - byte array seed
|
|
600
|
-
* @returns {Promise<KmsKeyId>} kms key identifier
|
|
601
|
-
*/
|
|
602
|
-
async newPrivateKeyFromSeed(seed) {
|
|
603
|
-
if (seed.length !== 32) {
|
|
604
|
-
throw new Error("Seed should be 32 bytes");
|
|
681
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
682
|
+
static fromJSON(obj) {
|
|
683
|
+
let mtp;
|
|
684
|
+
if (obj?.mtp?.notEmpties && obj?.mtp?.depth && obj?.mtp?.siblings) {
|
|
685
|
+
const ne = obj?.mtp?.notEmpties;
|
|
686
|
+
const notEmpties = ne instanceof Uint8Array ? ne : new Uint8Array(Object.values(ne));
|
|
687
|
+
const siblingsHashes = obj?.mtp?.siblings.map(
|
|
688
|
+
(h) => Hash2.fromString(JSON.stringify(h))
|
|
689
|
+
);
|
|
690
|
+
const allSiblings = Proof.buildAllSiblings(obj?.mtp?.depth, notEmpties, siblingsHashes);
|
|
691
|
+
let nodeAux = obj.mtp.nodeAux || obj.mtp.node_aux;
|
|
692
|
+
if (nodeAux) {
|
|
693
|
+
nodeAux = {
|
|
694
|
+
key: Hash2.fromString(JSON.stringify(nodeAux.key)),
|
|
695
|
+
value: Hash2.fromString(JSON.stringify(nodeAux.value))
|
|
696
|
+
};
|
|
697
|
+
}
|
|
698
|
+
mtp = new Proof({ existence: obj?.mtp.existence, nodeAux, siblings: allSiblings });
|
|
699
|
+
} else {
|
|
700
|
+
mtp = Proof.fromJSON(obj.mtp);
|
|
605
701
|
}
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
702
|
+
return new _Iden3SparseMerkleTreeProof({
|
|
703
|
+
coreClaim: new Claim().fromHex(obj.coreClaim),
|
|
704
|
+
mtp,
|
|
705
|
+
issuerData: {
|
|
706
|
+
id: DID2.parse(obj.issuerData.id),
|
|
707
|
+
state: {
|
|
708
|
+
...obj.issuerData.state,
|
|
709
|
+
rootOfRoots: Hash2.fromHex(obj.issuerData.state.rootOfRoots),
|
|
710
|
+
claimsTreeRoot: Hash2.fromHex(obj.issuerData.state.claimsTreeRoot),
|
|
711
|
+
revocationTreeRoot: Hash2.fromHex(obj.issuerData.state.revocationTreeRoot),
|
|
712
|
+
value: Hash2.fromHex(obj.issuerData.state.value)
|
|
713
|
+
}
|
|
714
|
+
}
|
|
614
715
|
});
|
|
615
|
-
return kmsId;
|
|
616
|
-
}
|
|
617
|
-
/**
|
|
618
|
-
* Gets public key by kmsKeyId
|
|
619
|
-
* @param {KmsKeyId} keyId - key identifier
|
|
620
|
-
* @returns {Promise<string>} Public key as a hex string
|
|
621
|
-
*/
|
|
622
|
-
async publicKey(keyId) {
|
|
623
|
-
const privateKeyHex = await this.privateKey(keyId);
|
|
624
|
-
const publicKey = ed25519.getPublicKey(privateKeyHex);
|
|
625
|
-
return bytesToHex(publicKey);
|
|
626
|
-
}
|
|
627
|
-
/**
|
|
628
|
-
* signs prepared payload of size,
|
|
629
|
-
* with a key id
|
|
630
|
-
* @param {KmsKeyId} keyId - key identifier
|
|
631
|
-
* @param {Uint8Array} digest - data to sign (32 bytes)
|
|
632
|
-
* @returns {Promise<Uint8Array>} signature
|
|
633
|
-
*/
|
|
634
|
-
async sign(keyId, digest) {
|
|
635
|
-
const privateKeyHex = await this.privateKey(keyId);
|
|
636
|
-
return ed25519.sign(digest, privateKeyHex);
|
|
637
|
-
}
|
|
638
|
-
/**
|
|
639
|
-
* Verifies a signature for the given message and key identifier.
|
|
640
|
-
* @param digest - The message to verify the signature against.
|
|
641
|
-
* @param signatureHex - The signature to verify, as a hexadecimal string.
|
|
642
|
-
* @param keyId - The key identifier to use for verification.
|
|
643
|
-
* @returns A Promise that resolves to a boolean indicating whether the signature is valid.
|
|
644
|
-
*/
|
|
645
|
-
async verify(digest, signatureHex, keyId) {
|
|
646
|
-
const publicKeyHex = await this.publicKey(keyId);
|
|
647
|
-
return ed25519.verify(signatureHex, digest, publicKeyHex);
|
|
648
|
-
}
|
|
649
|
-
/**
|
|
650
|
-
* Retrieves the private key for a given keyId from the key store.
|
|
651
|
-
* @param {KmsKeyId} keyId - The identifier of the key to retrieve.
|
|
652
|
-
* @returns {Promise<string>} The private key associated with the keyId.
|
|
653
|
-
*/
|
|
654
|
-
async privateKey(keyId) {
|
|
655
|
-
return this._keyStore.get({ alias: keyId.id });
|
|
656
716
|
}
|
|
657
717
|
};
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
keyType;
|
|
669
|
-
_keyStore;
|
|
670
|
-
/**
|
|
671
|
-
* Creates an instance of BjjProvider.
|
|
672
|
-
* @param {KmsKeyType} keyType - kms key type
|
|
673
|
-
* @param {AbstractPrivateKeyStore} keyStore - key store for kms
|
|
674
|
-
*/
|
|
675
|
-
constructor(keyType, keyStore) {
|
|
676
|
-
if (keyType !== "Secp256k1" /* Secp256k1 */) {
|
|
677
|
-
throw new Error("Key type must be Secp256k1");
|
|
678
|
-
}
|
|
679
|
-
this.keyType = keyType;
|
|
680
|
-
this._keyStore = keyStore;
|
|
681
|
-
}
|
|
682
|
-
/**
|
|
683
|
-
* get all keys
|
|
684
|
-
* @returns list of keys
|
|
685
|
-
*/
|
|
686
|
-
async list() {
|
|
687
|
-
const allKeysFromKeyStore = await this._keyStore.list();
|
|
688
|
-
return allKeysFromKeyStore.filter((key) => key.alias.startsWith(this.keyType));
|
|
689
|
-
}
|
|
690
|
-
/**
|
|
691
|
-
* generates a baby jub jub key from a seed phrase
|
|
692
|
-
* @param {Uint8Array} seed - byte array seed
|
|
693
|
-
* @returns kms key identifier
|
|
694
|
-
*/
|
|
695
|
-
async newPrivateKeyFromSeed(seed) {
|
|
696
|
-
if (seed.length !== 32) {
|
|
697
|
-
throw new Error("Seed should be 32 bytes");
|
|
698
|
-
}
|
|
699
|
-
const publicKey = secp256k1.getPublicKey(seed);
|
|
700
|
-
const kmsId = {
|
|
701
|
-
type: this.keyType,
|
|
702
|
-
id: keyPath(this.keyType, bytesToHex(publicKey))
|
|
703
|
-
};
|
|
704
|
-
await this._keyStore.importKey({
|
|
705
|
-
alias: kmsId.id,
|
|
706
|
-
key: bytesToHex(seed).padStart(64, "0")
|
|
707
|
-
});
|
|
708
|
-
return kmsId;
|
|
718
|
+
var BJJSignatureProof2021 = class _BJJSignatureProof2021 {
|
|
719
|
+
type;
|
|
720
|
+
issuerData;
|
|
721
|
+
signature;
|
|
722
|
+
coreClaim;
|
|
723
|
+
constructor(obj) {
|
|
724
|
+
this.type = "BJJSignature2021" /* BJJSignature */;
|
|
725
|
+
this.issuerData = obj.issuerData;
|
|
726
|
+
this.coreClaim = obj.coreClaim;
|
|
727
|
+
this.signature = obj.signature;
|
|
709
728
|
}
|
|
710
729
|
/**
|
|
711
|
-
*
|
|
730
|
+
* toJSON is a method to serialize BJJSignatureProof2021 to json
|
|
712
731
|
*
|
|
713
|
-
* @
|
|
714
|
-
*/
|
|
715
|
-
async publicKey(keyId) {
|
|
716
|
-
const privateKeyHex = await this.privateKey(keyId);
|
|
717
|
-
const publicKey = secp256k1.getPublicKey(privateKeyHex, false);
|
|
718
|
-
return bytesToHex(publicKey);
|
|
719
|
-
}
|
|
720
|
-
/**
|
|
721
|
-
* Signs the given data using the private key associated with the specified key identifier.
|
|
722
|
-
* @param keyId - The key identifier to use for signing.
|
|
723
|
-
* @param data - The data to sign.
|
|
724
|
-
* @param opts - Signing options, such as the algorithm to use.
|
|
725
|
-
* @returns A Promise that resolves to the signature as a Uint8Array.
|
|
732
|
+
* @returns `json object in serialized presentation`
|
|
726
733
|
*/
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
734
|
+
toJSON() {
|
|
735
|
+
return {
|
|
736
|
+
issuerData: {
|
|
737
|
+
id: this.issuerData.id.string(),
|
|
738
|
+
state: {
|
|
739
|
+
...this.issuerData.state,
|
|
740
|
+
rootOfRoots: this.issuerData.state.rootOfRoots.hex(),
|
|
741
|
+
claimsTreeRoot: this.issuerData.state.claimsTreeRoot.hex(),
|
|
742
|
+
revocationTreeRoot: this.issuerData.state.revocationTreeRoot.hex(),
|
|
743
|
+
value: this.issuerData.state.value.hex()
|
|
744
|
+
},
|
|
745
|
+
mtp: this.issuerData.mtp.toJSON(),
|
|
746
|
+
authCoreClaim: this.issuerData.authCoreClaim.hex(),
|
|
747
|
+
credentialStatus: this.issuerData.credentialStatus
|
|
748
|
+
},
|
|
749
|
+
type: this.type,
|
|
750
|
+
coreClaim: this.coreClaim.hex(),
|
|
751
|
+
signature: Hex3.encodeString(this.signature.compress())
|
|
752
|
+
};
|
|
737
753
|
}
|
|
738
754
|
/**
|
|
739
|
-
*
|
|
740
|
-
* @param
|
|
741
|
-
* @param signatureHex - The signature to verify, as a hexadecimal string.
|
|
742
|
-
* @param keyId - The key identifier to use for verification.
|
|
743
|
-
* @returns A Promise that resolves to a boolean indicating whether the signature is valid.
|
|
755
|
+
* fromJSON is a method to deserialize BJJSignatureProof2021 from json
|
|
756
|
+
* @param obj
|
|
744
757
|
*/
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
return
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
758
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
759
|
+
static fromJSON(obj) {
|
|
760
|
+
return new _BJJSignatureProof2021({
|
|
761
|
+
issuerData: {
|
|
762
|
+
id: DID2.parse(obj.issuerData.id),
|
|
763
|
+
mtp: Proof.fromJSON(obj.issuerData.mtp),
|
|
764
|
+
state: {
|
|
765
|
+
...obj.issuerData.state,
|
|
766
|
+
rootOfRoots: Hash2.fromHex(obj.issuerData.state.rootOfRoots),
|
|
767
|
+
claimsTreeRoot: Hash2.fromHex(obj.issuerData.state.claimsTreeRoot),
|
|
768
|
+
revocationTreeRoot: Hash2.fromHex(obj.issuerData.state.revocationTreeRoot),
|
|
769
|
+
value: Hash2.fromHex(obj.issuerData.state.value)
|
|
770
|
+
},
|
|
771
|
+
credentialStatus: obj.issuerData.credentialStatus,
|
|
772
|
+
authCoreClaim: new Claim().fromHex(obj.issuerData.authCoreClaim)
|
|
773
|
+
},
|
|
774
|
+
coreClaim: new Claim().fromHex(obj.coreClaim),
|
|
775
|
+
signature: Signature.newFromCompressed(
|
|
776
|
+
Uint8Array.from(Hex3.decodeString(obj.signature)).slice(0, 64)
|
|
777
|
+
)
|
|
778
|
+
});
|
|
751
779
|
}
|
|
752
780
|
};
|
|
753
781
|
|
|
754
|
-
// src/
|
|
782
|
+
// src/verifiable/credential.ts
|
|
755
783
|
import {
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
ClaimOptions
|
|
761
|
-
|
|
762
|
-
DidMethod,
|
|
763
|
-
getUnixTimestamp as getUnixTimestamp8,
|
|
764
|
-
Id as Id19,
|
|
765
|
-
NetworkId,
|
|
766
|
-
SchemaHash as SchemaHash7
|
|
784
|
+
Claim as Claim2,
|
|
785
|
+
DID as DID4,
|
|
786
|
+
MerklizedRootPosition as MerklizedRootPositionCore,
|
|
787
|
+
IdPosition,
|
|
788
|
+
ClaimOptions,
|
|
789
|
+
getChainId
|
|
767
790
|
} from "@iden3/js-iden3-core";
|
|
768
|
-
import {
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
sha256 as sha2562,
|
|
772
|
-
Signature as Signature3,
|
|
773
|
-
Hex as Hex6,
|
|
774
|
-
getRandomBytes as getRandomBytes2,
|
|
775
|
-
Poseidon
|
|
776
|
-
} from "@iden3/js-crypto";
|
|
777
|
-
import { hashElems as hashElems2, ZERO_HASH as ZERO_HASH6 } from "@iden3/js-merkletree";
|
|
778
|
-
|
|
779
|
-
// src/identity/common.ts
|
|
780
|
-
import { DID as DID5, Id as Id2, IdPosition as IdPosition2, MerklizedRootPosition as MerklizedRootPosition2 } from "@iden3/js-iden3-core";
|
|
781
|
-
|
|
782
|
-
// src/verifiable/proof.ts
|
|
783
|
-
import { Hash as Hash2, Proof } from "@iden3/js-merkletree";
|
|
784
|
-
|
|
785
|
-
// src/verifiable/constants.ts
|
|
786
|
-
var VerifiableConstants = Object.freeze({
|
|
787
|
-
ERRORS: {
|
|
788
|
-
FiELD_IS_EMPTY: "fieldPath is empty",
|
|
789
|
-
CONTEXT_TYPE_IS_EMPTY: "ctxType is empty",
|
|
790
|
-
// ErrStateNotFound issuer state is genesis state.
|
|
791
|
-
IDENTITY_DOES_NOT_EXIST: "Identity does not exist",
|
|
792
|
-
IDENTITY_DOES_NOT_EXIST_CUSTOM_ERROR: "IdentityDoesNotExist",
|
|
793
|
-
NO_AUTH_CRED_FOUND: "no auth credentials found",
|
|
794
|
-
STATE_DOES_NOT_EXIST: "State does not exist",
|
|
795
|
-
STATE_DOES_NOT_EXIST_CUSTOM_ERROR: "StateDoesNotExist",
|
|
796
|
-
ROOT_DOES_NOT_EXIST: "Root does not exist",
|
|
797
|
-
ROOT_DOES_NOT_EXIST_CUSTOM_ERROR: "RootDoesNotExist",
|
|
798
|
-
// identity wallet
|
|
799
|
-
ID_WALLET_NO_CREDENTIAL_SATISFIED_QUERY: "no credential satisfied query",
|
|
800
|
-
ID_WALLET_SIGNER_IS_REQUIRED: "Ethereum signer is required to create Ethereum identities in order to transit state",
|
|
801
|
-
ID_WALLET_PROVER_IS_REQUIRED: "prover is required to generate proofs for non ethereum identities",
|
|
802
|
-
ID_WALLET_CORE_CLAIM_REQUIRED_IN_SIG_PROOF: "credential must have coreClaim representation in the signature proof",
|
|
803
|
-
ID_WALLET_CORE_CLAIM_REQUIRED_IN_ANY_PROOF: "credential must have coreClaim representation in proofs",
|
|
804
|
-
ID_WALLET_CORE_CLAIM_MISMATCH: "core claim representations is set in both proofs but they are not equal",
|
|
805
|
-
ID_WALLET_CORE_CLAIM_IS_NOT_SET: "core claim is not set in credential proofs",
|
|
806
|
-
ID_WALLET_PROFILE_OR_IDENTITY_NOT_FOUND: "profile or identity not found",
|
|
807
|
-
ID_WALLET_PROFILE_ALREADY_EXISTS: "profile with given nonce or verifier already exists",
|
|
808
|
-
ID_WALLET_PROFILE_ALREADY_EXISTS_VERIFIER_TAGS: "profile with given verifier and tags already exists",
|
|
809
|
-
ID_WALLET_ISSUER_AUTH_BJJ_CRED_MUST_HAVE_ANY_PROOF: "issuer auth credential must have proof",
|
|
810
|
-
ID_WALLET_ISSUER_AUTH_BJJ_CRED_MUST_HAVE_MTP_PROOF: "mtp is required for auth bjj key to issue new credentials",
|
|
811
|
-
// proof service
|
|
812
|
-
PROOF_SERVICE_NO_CREDENTIAL_FOR_IDENTITY_OR_PROFILE: "no credentials belong to did or its profiles",
|
|
813
|
-
PROOF_SERVICE_NO_CREDENTIAL_FOR_QUERY: "credential not found for query",
|
|
814
|
-
PROOF_SERVICE_PROFILE_GENESIS_DID_MISMATCH: "subject and auth profiles are not derived from the same did",
|
|
815
|
-
PROOF_SERVICE_NO_QUERIES_IN_ZKP_REQUEST: "no queries in zkp request",
|
|
816
|
-
// credential wallet
|
|
817
|
-
CREDENTIAL_WALLET_ALL_CREDENTIALS_ARE_REVOKED: "all claims are revoked"
|
|
818
|
-
},
|
|
819
|
-
CREDENTIAL_TYPE: {
|
|
820
|
-
// VerifiableCredential is a W3C verifiable credential type
|
|
821
|
-
W3C_VERIFIABLE_CREDENTIAL: "VerifiableCredential",
|
|
822
|
-
W3C_VERIFIABLE_PRESENTATION: "VerifiablePresentation"
|
|
823
|
-
},
|
|
824
|
-
CREDENTIAL_SUBJECT_PATH: "https://www.w3.org/2018/credentials#credentialSubject",
|
|
825
|
-
JSONLD_SCHEMA: {
|
|
826
|
-
// JSONLDSchemaIden3Credential is a schema for context with Iden3Credential type
|
|
827
|
-
IDEN3_CREDENTIAL: "https://schema.iden3.io/core/jsonld/iden3proofs.jsonld",
|
|
828
|
-
// JSONLDSchemaIden3DisplayMethod is a schema for context with Iden3BasicDisplayMethodV1 type
|
|
829
|
-
IDEN3_DISPLAY_METHOD: "https://schema.iden3.io/core/jsonld/displayMethod.jsonld",
|
|
830
|
-
// JSONLDSchemaW3CCredential2018 is a schema for context with VerifiableCredential type
|
|
831
|
-
W3C_CREDENTIAL_2018: "https://www.w3.org/2018/credentials/v1",
|
|
832
|
-
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"}}}`,
|
|
833
|
-
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"}}`,
|
|
834
|
-
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"}}}}`
|
|
835
|
-
},
|
|
836
|
-
// JsonSchema2023 JSON schema for verification of Iden3Credential
|
|
837
|
-
JSON_SCHEMA_VALIDATOR: "JsonSchema2023",
|
|
838
|
-
SERVICE_TYPE: {
|
|
839
|
-
// Iden3CommServiceType is service type for iden3comm protocol
|
|
840
|
-
IDEN3_COMM: "iden3-communication",
|
|
841
|
-
// PushNotificationServiceType is service type for delivering push notifications to identity
|
|
842
|
-
PUSH_NOTIFICATION: "push-notification"
|
|
843
|
-
},
|
|
844
|
-
AUTH: {
|
|
845
|
-
AUTH_BJJ_CREDENTIAL_HASH: "013fd3f623559d850fb5b02ff012d0e2",
|
|
846
|
-
AUTH_BJJ_CREDENTIAL_SCHEMA_JSON_URL: "https://schema.iden3.io/core/json/auth.json",
|
|
847
|
-
AUTH_BJJ_CREDENTIAL_SCHEMA_JSONLD_URL: "https://schema.iden3.io/core/jsonld/auth.jsonld",
|
|
848
|
-
AUTH_BJJ_CREDENTIAL_TYPE: "AuthBJJCredential",
|
|
849
|
-
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"}}}}}`,
|
|
850
|
-
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"}}}}}}]}`
|
|
851
|
-
}
|
|
852
|
-
});
|
|
853
|
-
var ProofType = /* @__PURE__ */ ((ProofType2) => {
|
|
854
|
-
ProofType2["BJJSignature"] = "BJJSignature2021";
|
|
855
|
-
ProofType2["Iden3SparseMerkleTreeProof"] = "Iden3SparseMerkleTreeProof";
|
|
856
|
-
return ProofType2;
|
|
857
|
-
})(ProofType || {});
|
|
858
|
-
var CredentialStatusType = /* @__PURE__ */ ((CredentialStatusType2) => {
|
|
859
|
-
CredentialStatusType2["SparseMerkleTreeProof"] = "SparseMerkleTreeProof";
|
|
860
|
-
CredentialStatusType2["Iden3ReverseSparseMerkleTreeProof"] = "Iden3ReverseSparseMerkleTreeProof";
|
|
861
|
-
CredentialStatusType2["Iden3commRevocationStatusV1"] = "Iden3commRevocationStatusV1.0";
|
|
862
|
-
CredentialStatusType2["Iden3OnchainSparseMerkleTreeProof2023"] = "Iden3OnchainSparseMerkleTreeProof2023";
|
|
863
|
-
return CredentialStatusType2;
|
|
864
|
-
})(CredentialStatusType || {});
|
|
865
|
-
var ProofPurpose = /* @__PURE__ */ ((ProofPurpose2) => {
|
|
866
|
-
ProofPurpose2["Authentication"] = "Authentication";
|
|
867
|
-
return ProofPurpose2;
|
|
868
|
-
})(ProofPurpose || {});
|
|
869
|
-
var MerklizedRootPosition = /* @__PURE__ */ ((MerklizedRootPosition4) => {
|
|
870
|
-
MerklizedRootPosition4["Index"] = "index";
|
|
871
|
-
MerklizedRootPosition4["Value"] = "value";
|
|
872
|
-
MerklizedRootPosition4["None"] = "";
|
|
873
|
-
return MerklizedRootPosition4;
|
|
874
|
-
})(MerklizedRootPosition || {});
|
|
875
|
-
var SubjectPosition = /* @__PURE__ */ ((SubjectPosition2) => {
|
|
876
|
-
SubjectPosition2["None"] = "";
|
|
877
|
-
SubjectPosition2["Index"] = "index";
|
|
878
|
-
SubjectPosition2["Value"] = "value";
|
|
879
|
-
return SubjectPosition2;
|
|
880
|
-
})(SubjectPosition || {});
|
|
881
|
-
var RefreshServiceType = /* @__PURE__ */ ((RefreshServiceType2) => {
|
|
882
|
-
RefreshServiceType2["Iden3RefreshService2023"] = "Iden3RefreshService2023";
|
|
883
|
-
return RefreshServiceType2;
|
|
884
|
-
})(RefreshServiceType || {});
|
|
885
|
-
var PaymentRequestDataType = /* @__PURE__ */ ((PaymentRequestDataType2) => {
|
|
886
|
-
PaymentRequestDataType2["Iden3PaymentRequestCryptoV1"] = "Iden3PaymentRequestCryptoV1";
|
|
887
|
-
PaymentRequestDataType2["Iden3PaymentRailsRequestV1"] = "Iden3PaymentRailsRequestV1";
|
|
888
|
-
PaymentRequestDataType2["Iden3PaymentRailsERC20RequestV1"] = "Iden3PaymentRailsERC20RequestV1";
|
|
889
|
-
return PaymentRequestDataType2;
|
|
890
|
-
})(PaymentRequestDataType || {});
|
|
891
|
-
var PaymentType = /* @__PURE__ */ ((PaymentType2) => {
|
|
892
|
-
PaymentType2["Iden3PaymentCryptoV1"] = "Iden3PaymentCryptoV1";
|
|
893
|
-
PaymentType2["Iden3PaymentRailsV1"] = "Iden3PaymentRailsV1";
|
|
894
|
-
PaymentType2["Iden3PaymentRailsERC20V1"] = "Iden3PaymentRailsERC20V1";
|
|
895
|
-
return PaymentType2;
|
|
896
|
-
})(PaymentType || {});
|
|
897
|
-
var SupportedPaymentProofType = /* @__PURE__ */ ((SupportedPaymentProofType2) => {
|
|
898
|
-
SupportedPaymentProofType2["EthereumEip712Signature2021"] = "EthereumEip712Signature2021";
|
|
899
|
-
return SupportedPaymentProofType2;
|
|
900
|
-
})(SupportedPaymentProofType || {});
|
|
901
|
-
var SupportedCurrencies = /* @__PURE__ */ ((SupportedCurrencies2) => {
|
|
902
|
-
SupportedCurrencies2["ETH"] = "ETH";
|
|
903
|
-
SupportedCurrencies2["ETH_WEI"] = "ETHWEI";
|
|
904
|
-
SupportedCurrencies2["ETH_GWEI"] = "ETHGWEI";
|
|
905
|
-
SupportedCurrencies2["MATIC"] = "MATIC";
|
|
906
|
-
SupportedCurrencies2["POL"] = "POL";
|
|
907
|
-
return SupportedCurrencies2;
|
|
908
|
-
})(SupportedCurrencies || {});
|
|
909
|
-
var PaymentFeatures = /* @__PURE__ */ ((PaymentFeatures2) => {
|
|
910
|
-
PaymentFeatures2["EIP_2612"] = "EIP-2612";
|
|
911
|
-
return PaymentFeatures2;
|
|
912
|
-
})(PaymentFeatures || {});
|
|
913
|
-
var DisplayMethodType = /* @__PURE__ */ ((DisplayMethodType2) => {
|
|
914
|
-
DisplayMethodType2["Iden3BasicDisplayMethodV1"] = "Iden3BasicDisplayMethodV1";
|
|
915
|
-
return DisplayMethodType2;
|
|
916
|
-
})(DisplayMethodType || {});
|
|
917
|
-
var DEFAULT_CACHE_MAX_SIZE = 1e4;
|
|
791
|
+
import { Hash as Hash3, rootFromProof, verifyProof } from "@iden3/js-merkletree";
|
|
792
|
+
import { Merklizer as Merklizer2 } from "@iden3/js-jsonld-merklization";
|
|
793
|
+
import { PublicKey as PublicKey2, poseidon } from "@iden3/js-crypto";
|
|
918
794
|
|
|
919
|
-
// src/
|
|
920
|
-
import {
|
|
921
|
-
import {
|
|
922
|
-
var
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
mtp;
|
|
926
|
-
coreClaim;
|
|
927
|
-
/**
|
|
928
|
-
* Creates an instance of Iden3SparseMerkleTreeProof.
|
|
929
|
-
* @param {object} obj
|
|
930
|
-
*/
|
|
931
|
-
constructor(obj) {
|
|
932
|
-
this.coreClaim = obj.coreClaim;
|
|
933
|
-
this.issuerData = obj.issuerData;
|
|
934
|
-
this.type = "Iden3SparseMerkleTreeProof" /* Iden3SparseMerkleTreeProof */;
|
|
935
|
-
this.mtp = obj.mtp;
|
|
936
|
-
}
|
|
937
|
-
/**
|
|
938
|
-
*
|
|
939
|
-
*
|
|
940
|
-
* @returns `json object in serialized presentation`
|
|
941
|
-
*/
|
|
942
|
-
toJSON() {
|
|
943
|
-
const issuerId = this.issuerData.id;
|
|
944
|
-
return {
|
|
945
|
-
issuerData: {
|
|
946
|
-
id: issuerId.string(),
|
|
947
|
-
state: {
|
|
948
|
-
...this.issuerData.state,
|
|
949
|
-
rootOfRoots: this.issuerData.state.rootOfRoots.hex(),
|
|
950
|
-
claimsTreeRoot: this.issuerData.state.claimsTreeRoot.hex(),
|
|
951
|
-
revocationTreeRoot: this.issuerData.state.revocationTreeRoot.hex(),
|
|
952
|
-
value: this.issuerData.state.value.hex()
|
|
953
|
-
}
|
|
954
|
-
},
|
|
955
|
-
type: this.type,
|
|
956
|
-
coreClaim: this.coreClaim.hex(),
|
|
957
|
-
mtp: this.mtp.toJSON()
|
|
958
|
-
};
|
|
795
|
+
// src/credentials/utils.ts
|
|
796
|
+
import { DID as DID3 } from "@iden3/js-iden3-core";
|
|
797
|
+
import { PublicKey } from "@iden3/js-crypto";
|
|
798
|
+
var getUserDIDFromCredential = (issuerDID, credential) => {
|
|
799
|
+
if (!credential.credentialSubject.id) {
|
|
800
|
+
return issuerDID;
|
|
959
801
|
}
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
let mtp;
|
|
963
|
-
if (obj?.mtp?.notEmpties && obj?.mtp?.depth && obj?.mtp?.siblings) {
|
|
964
|
-
const ne = obj?.mtp?.notEmpties;
|
|
965
|
-
const notEmpties = ne instanceof Uint8Array ? ne : new Uint8Array(Object.values(ne));
|
|
966
|
-
const siblingsHashes = obj?.mtp?.siblings.map(
|
|
967
|
-
(h) => Hash2.fromString(JSON.stringify(h))
|
|
968
|
-
);
|
|
969
|
-
const allSiblings = Proof.buildAllSiblings(obj?.mtp?.depth, notEmpties, siblingsHashes);
|
|
970
|
-
let nodeAux = obj.mtp.nodeAux || obj.mtp.node_aux;
|
|
971
|
-
if (nodeAux) {
|
|
972
|
-
nodeAux = {
|
|
973
|
-
key: Hash2.fromString(JSON.stringify(nodeAux.key)),
|
|
974
|
-
value: Hash2.fromString(JSON.stringify(nodeAux.value))
|
|
975
|
-
};
|
|
976
|
-
}
|
|
977
|
-
mtp = new Proof({ existence: obj?.mtp.existence, nodeAux, siblings: allSiblings });
|
|
978
|
-
} else {
|
|
979
|
-
mtp = Proof.fromJSON(obj.mtp);
|
|
980
|
-
}
|
|
981
|
-
return new _Iden3SparseMerkleTreeProof({
|
|
982
|
-
coreClaim: new Claim().fromHex(obj.coreClaim),
|
|
983
|
-
mtp,
|
|
984
|
-
issuerData: {
|
|
985
|
-
id: DID2.parse(obj.issuerData.id),
|
|
986
|
-
state: {
|
|
987
|
-
...obj.issuerData.state,
|
|
988
|
-
rootOfRoots: Hash2.fromHex(obj.issuerData.state.rootOfRoots),
|
|
989
|
-
claimsTreeRoot: Hash2.fromHex(obj.issuerData.state.claimsTreeRoot),
|
|
990
|
-
revocationTreeRoot: Hash2.fromHex(obj.issuerData.state.revocationTreeRoot),
|
|
991
|
-
value: Hash2.fromHex(obj.issuerData.state.value)
|
|
992
|
-
}
|
|
993
|
-
}
|
|
994
|
-
});
|
|
802
|
+
if (typeof credential.credentialSubject.id !== "string") {
|
|
803
|
+
throw new Error("credential subject `id` is not a string");
|
|
995
804
|
}
|
|
805
|
+
return DID3.parse(credential.credentialSubject.id);
|
|
996
806
|
};
|
|
997
|
-
var
|
|
998
|
-
type
|
|
999
|
-
|
|
1000
|
-
signature;
|
|
1001
|
-
coreClaim;
|
|
1002
|
-
constructor(obj) {
|
|
1003
|
-
this.type = "BJJSignature2021" /* BJJSignature */;
|
|
1004
|
-
this.issuerData = obj.issuerData;
|
|
1005
|
-
this.coreClaim = obj.coreClaim;
|
|
1006
|
-
this.signature = obj.signature;
|
|
1007
|
-
}
|
|
1008
|
-
/**
|
|
1009
|
-
* toJSON is a method to serialize BJJSignatureProof2021 to json
|
|
1010
|
-
*
|
|
1011
|
-
* @returns `json object in serialized presentation`
|
|
1012
|
-
*/
|
|
1013
|
-
toJSON() {
|
|
1014
|
-
return {
|
|
1015
|
-
issuerData: {
|
|
1016
|
-
id: this.issuerData.id.string(),
|
|
1017
|
-
state: {
|
|
1018
|
-
...this.issuerData.state,
|
|
1019
|
-
rootOfRoots: this.issuerData.state.rootOfRoots.hex(),
|
|
1020
|
-
claimsTreeRoot: this.issuerData.state.claimsTreeRoot.hex(),
|
|
1021
|
-
revocationTreeRoot: this.issuerData.state.revocationTreeRoot.hex(),
|
|
1022
|
-
value: this.issuerData.state.value.hex()
|
|
1023
|
-
},
|
|
1024
|
-
mtp: this.issuerData.mtp.toJSON(),
|
|
1025
|
-
authCoreClaim: this.issuerData.authCoreClaim.hex(),
|
|
1026
|
-
credentialStatus: this.issuerData.credentialStatus
|
|
1027
|
-
},
|
|
1028
|
-
type: this.type,
|
|
1029
|
-
coreClaim: this.coreClaim.hex(),
|
|
1030
|
-
signature: Hex4.encodeString(this.signature.compress())
|
|
1031
|
-
};
|
|
1032
|
-
}
|
|
1033
|
-
/**
|
|
1034
|
-
* fromJSON is a method to deserialize BJJSignatureProof2021 from json
|
|
1035
|
-
* @param obj
|
|
1036
|
-
*/
|
|
1037
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1038
|
-
static fromJSON(obj) {
|
|
1039
|
-
return new _BJJSignatureProof2021({
|
|
1040
|
-
issuerData: {
|
|
1041
|
-
id: DID2.parse(obj.issuerData.id),
|
|
1042
|
-
mtp: Proof.fromJSON(obj.issuerData.mtp),
|
|
1043
|
-
state: {
|
|
1044
|
-
...obj.issuerData.state,
|
|
1045
|
-
rootOfRoots: Hash2.fromHex(obj.issuerData.state.rootOfRoots),
|
|
1046
|
-
claimsTreeRoot: Hash2.fromHex(obj.issuerData.state.claimsTreeRoot),
|
|
1047
|
-
revocationTreeRoot: Hash2.fromHex(obj.issuerData.state.revocationTreeRoot),
|
|
1048
|
-
value: Hash2.fromHex(obj.issuerData.state.value)
|
|
1049
|
-
},
|
|
1050
|
-
credentialStatus: obj.issuerData.credentialStatus,
|
|
1051
|
-
authCoreClaim: new Claim().fromHex(obj.issuerData.authCoreClaim)
|
|
1052
|
-
},
|
|
1053
|
-
coreClaim: new Claim().fromHex(obj.coreClaim),
|
|
1054
|
-
signature: Signature2.newFromCompressed(
|
|
1055
|
-
Uint8Array.from(Hex4.decodeString(obj.signature)).slice(0, 64)
|
|
1056
|
-
)
|
|
1057
|
-
});
|
|
1058
|
-
}
|
|
1059
|
-
};
|
|
1060
|
-
|
|
1061
|
-
// src/verifiable/credential.ts
|
|
1062
|
-
import {
|
|
1063
|
-
Claim as Claim2,
|
|
1064
|
-
DID as DID4,
|
|
1065
|
-
MerklizedRootPosition as MerklizedRootPositionCore,
|
|
1066
|
-
IdPosition,
|
|
1067
|
-
ClaimOptions,
|
|
1068
|
-
getChainId
|
|
1069
|
-
} from "@iden3/js-iden3-core";
|
|
1070
|
-
import { Hash as Hash3, rootFromProof, verifyProof } from "@iden3/js-merkletree";
|
|
1071
|
-
import { Merklizer as Merklizer2 } from "@iden3/js-jsonld-merklization";
|
|
1072
|
-
import { PublicKey as PublicKey3, poseidon } from "@iden3/js-crypto";
|
|
1073
|
-
|
|
1074
|
-
// src/credentials/utils.ts
|
|
1075
|
-
import { DID as DID3 } from "@iden3/js-iden3-core";
|
|
1076
|
-
import { PublicKey as PublicKey2 } from "@iden3/js-crypto";
|
|
1077
|
-
var getUserDIDFromCredential = (issuerDID, credential) => {
|
|
1078
|
-
if (!credential.credentialSubject.id) {
|
|
1079
|
-
return issuerDID;
|
|
1080
|
-
}
|
|
1081
|
-
if (typeof credential.credentialSubject.id !== "string") {
|
|
1082
|
-
throw new Error("credential subject `id` is not a string");
|
|
1083
|
-
}
|
|
1084
|
-
return DID3.parse(credential.credentialSubject.id);
|
|
1085
|
-
};
|
|
1086
|
-
var getKMSIdByAuthCredential = (credential) => {
|
|
1087
|
-
if (!credential.type.includes("AuthBJJCredential")) {
|
|
1088
|
-
throw new Error("can't sign with not AuthBJJCredential credential");
|
|
807
|
+
var getKMSIdByAuthCredential = (credential) => {
|
|
808
|
+
if (!credential.type.includes("AuthBJJCredential")) {
|
|
809
|
+
throw new Error("can't sign with not AuthBJJCredential credential");
|
|
1089
810
|
}
|
|
1090
811
|
const x = credential.credentialSubject["x"];
|
|
1091
812
|
const y = credential.credentialSubject["y"];
|
|
1092
|
-
const pb = new
|
|
813
|
+
const pb = new PublicKey([BigInt(x), BigInt(y)]);
|
|
1093
814
|
const kp = keyPath("BJJ" /* BabyJubJub */, pb.hex());
|
|
1094
815
|
return { type: "BJJ" /* BabyJubJub */, id: kp };
|
|
1095
816
|
};
|
|
1096
817
|
|
|
1097
818
|
// src/verifiable/core-utils.ts
|
|
1098
|
-
import { BytesHelper
|
|
819
|
+
import { BytesHelper, SchemaHash } from "@iden3/js-iden3-core";
|
|
1099
820
|
import { Path } from "@iden3/js-jsonld-merklization";
|
|
1100
821
|
import jsonld from "jsonld";
|
|
1101
822
|
import { keccak256 as keccak2562 } from "ethers";
|
|
@@ -1147,7 +868,7 @@ var fillCoreClaimSlot = async (slotData, mz, path) => {
|
|
|
1147
868
|
const p = await mz.resolveDocPath(path, mz.options);
|
|
1148
869
|
const entry = await mz.entry(p);
|
|
1149
870
|
const intVal = await entry.getValueMtEntry();
|
|
1150
|
-
const bytesVal =
|
|
871
|
+
const bytesVal = BytesHelper.intToBytes(intVal);
|
|
1151
872
|
slotData.set(bytesVal, 0);
|
|
1152
873
|
} catch (err) {
|
|
1153
874
|
if (err.toString().includes("entry not found")) {
|
|
@@ -1628,7 +1349,7 @@ var W3CCredential = class _W3CCredential {
|
|
|
1628
1349
|
async verifyBJJSignatureProof(proof, coreClaim, resolverURL, userDID, credStatusResolverRegistry) {
|
|
1629
1350
|
const authClaim = proof.issuerData.authCoreClaim;
|
|
1630
1351
|
const rawSlotsInt = authClaim.rawSlotsAsInts();
|
|
1631
|
-
const pubKey = new
|
|
1352
|
+
const pubKey = new PublicKey2([rawSlotsInt[2], rawSlotsInt[3]]);
|
|
1632
1353
|
const { hi, hv } = coreClaim.hiHv();
|
|
1633
1354
|
const claimHash = poseidon.hash([hi, hv]);
|
|
1634
1355
|
const bjjValid = pubKey.verifyPoseidon(claimHash, proof.signature);
|
|
@@ -2037,13 +1758,681 @@ var DIDDocumentJSONSchema = `{
|
|
|
2037
1758
|
},
|
|
2038
1759
|
"deprecated": true
|
|
2039
1760
|
}
|
|
2040
|
-
},
|
|
2041
|
-
"required": [
|
|
2042
|
-
"id"
|
|
2043
|
-
]
|
|
2044
|
-
}`;
|
|
1761
|
+
},
|
|
1762
|
+
"required": [
|
|
1763
|
+
"id"
|
|
1764
|
+
]
|
|
1765
|
+
}`;
|
|
1766
|
+
|
|
1767
|
+
// src/utils/payments/solana.ts
|
|
1768
|
+
import { getUnixTimestamp } from "@iden3/js-iden3-core";
|
|
1769
|
+
import { PublicKey as PublicKey3 } from "@solana/web3.js";
|
|
1770
|
+
var SolanaNativePaymentRequest = class {
|
|
1771
|
+
version;
|
|
1772
|
+
chainId;
|
|
1773
|
+
verifyingContract;
|
|
1774
|
+
recipient;
|
|
1775
|
+
amount;
|
|
1776
|
+
expirationDate;
|
|
1777
|
+
nonce;
|
|
1778
|
+
metadata;
|
|
1779
|
+
constructor(fields) {
|
|
1780
|
+
this.version = fields.version;
|
|
1781
|
+
this.chainId = fields.chainId;
|
|
1782
|
+
this.verifyingContract = fields.verifyingContract;
|
|
1783
|
+
this.recipient = fields.recipient;
|
|
1784
|
+
this.amount = fields.amount;
|
|
1785
|
+
this.expirationDate = fields.expirationDate;
|
|
1786
|
+
this.nonce = fields.nonce;
|
|
1787
|
+
this.metadata = fields.metadata;
|
|
1788
|
+
}
|
|
1789
|
+
};
|
|
1790
|
+
var SolanaSplPaymentRequest = class {
|
|
1791
|
+
version;
|
|
1792
|
+
chainId;
|
|
1793
|
+
verifyingContract;
|
|
1794
|
+
tokenAddress;
|
|
1795
|
+
recipient;
|
|
1796
|
+
amount;
|
|
1797
|
+
expirationDate;
|
|
1798
|
+
nonce;
|
|
1799
|
+
metadata;
|
|
1800
|
+
constructor(fields) {
|
|
1801
|
+
this.version = fields.version;
|
|
1802
|
+
this.chainId = fields.chainId;
|
|
1803
|
+
this.verifyingContract = fields.verifyingContract;
|
|
1804
|
+
this.tokenAddress = fields.tokenAddress;
|
|
1805
|
+
this.recipient = fields.recipient;
|
|
1806
|
+
this.amount = fields.amount;
|
|
1807
|
+
this.expirationDate = fields.expirationDate;
|
|
1808
|
+
this.nonce = fields.nonce;
|
|
1809
|
+
this.metadata = fields.metadata;
|
|
1810
|
+
}
|
|
1811
|
+
};
|
|
1812
|
+
var SolanaNativePaymentSchema = /* @__PURE__ */ new Map([
|
|
1813
|
+
[
|
|
1814
|
+
SolanaNativePaymentRequest,
|
|
1815
|
+
{
|
|
1816
|
+
kind: "struct",
|
|
1817
|
+
fields: [
|
|
1818
|
+
["version", ["u8"]],
|
|
1819
|
+
["chainId", "u64"],
|
|
1820
|
+
["verifyingContract", ["u8", 32]],
|
|
1821
|
+
["recipient", ["u8", 32]],
|
|
1822
|
+
["amount", "u64"],
|
|
1823
|
+
["expirationDate", "u64"],
|
|
1824
|
+
["nonce", "u64"],
|
|
1825
|
+
["metadata", ["u8"]]
|
|
1826
|
+
]
|
|
1827
|
+
}
|
|
1828
|
+
]
|
|
1829
|
+
]);
|
|
1830
|
+
var SolanaSplPaymentSchema = /* @__PURE__ */ new Map([
|
|
1831
|
+
[
|
|
1832
|
+
SolanaSplPaymentRequest,
|
|
1833
|
+
{
|
|
1834
|
+
kind: "struct",
|
|
1835
|
+
fields: [
|
|
1836
|
+
["version", ["u8"]],
|
|
1837
|
+
["chainId", "u64"],
|
|
1838
|
+
["verifyingContract", ["u8", 32]],
|
|
1839
|
+
["tokenAddress", ["u8", 32]],
|
|
1840
|
+
["recipient", ["u8", 32]],
|
|
1841
|
+
["amount", "u64"],
|
|
1842
|
+
["expirationDate", "u64"],
|
|
1843
|
+
["nonce", "u64"],
|
|
1844
|
+
["metadata", ["u8"]]
|
|
1845
|
+
]
|
|
1846
|
+
}
|
|
1847
|
+
]
|
|
1848
|
+
]);
|
|
1849
|
+
var SolanaPaymentInstruction = class {
|
|
1850
|
+
recipient;
|
|
1851
|
+
amount;
|
|
1852
|
+
expiration_date;
|
|
1853
|
+
nonce;
|
|
1854
|
+
metadata;
|
|
1855
|
+
signature;
|
|
1856
|
+
constructor(fields) {
|
|
1857
|
+
this.recipient = fields.recipient;
|
|
1858
|
+
this.amount = fields.amount;
|
|
1859
|
+
this.expiration_date = fields.expiration_date;
|
|
1860
|
+
this.nonce = fields.nonce;
|
|
1861
|
+
this.metadata = fields.metadata;
|
|
1862
|
+
this.signature = fields.signature;
|
|
1863
|
+
}
|
|
1864
|
+
};
|
|
1865
|
+
var SolanaPaymentInstructionSchema = /* @__PURE__ */ new Map([
|
|
1866
|
+
[
|
|
1867
|
+
SolanaPaymentInstruction,
|
|
1868
|
+
{
|
|
1869
|
+
kind: "struct",
|
|
1870
|
+
fields: [
|
|
1871
|
+
["recipient", ["u8", 32]],
|
|
1872
|
+
["amount", "u64"],
|
|
1873
|
+
["expiration_date", "u64"],
|
|
1874
|
+
["nonce", "u64"],
|
|
1875
|
+
["metadata", ["u8"]],
|
|
1876
|
+
["signature", [64]]
|
|
1877
|
+
]
|
|
1878
|
+
}
|
|
1879
|
+
]
|
|
1880
|
+
]);
|
|
1881
|
+
var buildSolanaPayment = async (solSigner, option, chainId, paymentRails, recipient, amount, expirationDate, nonce) => {
|
|
1882
|
+
let serialized;
|
|
1883
|
+
const proofVersion = option.type === "Iden3PaymentRailsSolanaRequestV1" /* Iden3PaymentRailsSolanaRequestV1 */ ? "SolanaEd25519NativeV1" : "SolanaEd25519SPLV1";
|
|
1884
|
+
let chainRef = chainId;
|
|
1885
|
+
switch (chainId) {
|
|
1886
|
+
case "101":
|
|
1887
|
+
chainRef = SOLANA_CHAIN_REF.DEVNET;
|
|
1888
|
+
break;
|
|
1889
|
+
case "102":
|
|
1890
|
+
chainRef = SOLANA_CHAIN_REF.TESTNET;
|
|
1891
|
+
break;
|
|
1892
|
+
case "103":
|
|
1893
|
+
chainRef = SOLANA_CHAIN_REF.MAINNET;
|
|
1894
|
+
break;
|
|
1895
|
+
}
|
|
1896
|
+
if (option.type === "Iden3PaymentRailsSolanaRequestV1" /* Iden3PaymentRailsSolanaRequestV1 */) {
|
|
1897
|
+
const request = new SolanaNativePaymentRequest({
|
|
1898
|
+
version: byteEncoder.encode(proofVersion),
|
|
1899
|
+
chainId: BigInt(chainId),
|
|
1900
|
+
verifyingContract: new PublicKey3(paymentRails).toBytes(),
|
|
1901
|
+
recipient: new PublicKey3(recipient).toBytes(),
|
|
1902
|
+
amount: BigInt(amount),
|
|
1903
|
+
expirationDate: BigInt(getUnixTimestamp(expirationDate)),
|
|
1904
|
+
nonce,
|
|
1905
|
+
metadata: byteEncoder.encode("0x")
|
|
1906
|
+
});
|
|
1907
|
+
serialized = serialize(SolanaNativePaymentSchema, request);
|
|
1908
|
+
} else {
|
|
1909
|
+
if (!option.contractAddress) {
|
|
1910
|
+
throw new Error(`failed request. no contract address for ${option.type} payment type`);
|
|
1911
|
+
}
|
|
1912
|
+
const request = new SolanaSplPaymentRequest({
|
|
1913
|
+
version: byteEncoder.encode(proofVersion),
|
|
1914
|
+
chainId: BigInt(chainId),
|
|
1915
|
+
verifyingContract: new PublicKey3(paymentRails).toBytes(),
|
|
1916
|
+
tokenAddress: new PublicKey3(option.contractAddress).toBytes(),
|
|
1917
|
+
recipient: new PublicKey3(recipient).toBytes(),
|
|
1918
|
+
amount: BigInt(amount),
|
|
1919
|
+
expirationDate: BigInt(getUnixTimestamp(expirationDate)),
|
|
1920
|
+
nonce,
|
|
1921
|
+
metadata: byteEncoder.encode("0x")
|
|
1922
|
+
});
|
|
1923
|
+
serialized = serialize(SolanaSplPaymentSchema, request);
|
|
1924
|
+
}
|
|
1925
|
+
const privateKey = solSigner.secretKey.slice(0, 32);
|
|
1926
|
+
const signature = await ed25519.sign(serialized, privateKey);
|
|
1927
|
+
const proof = [
|
|
1928
|
+
{
|
|
1929
|
+
type: "SolanaEd25519Signature2025" /* SolanaEd25519Signature2025 */,
|
|
1930
|
+
proofPurpose: "assertionMethod",
|
|
1931
|
+
proofValue: Buffer.from(signature).toString("hex"),
|
|
1932
|
+
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1933
|
+
verificationMethod: `did:pkh:solana:${chainRef}:${solSigner.publicKey.toBase58()}`,
|
|
1934
|
+
domain: {
|
|
1935
|
+
version: proofVersion,
|
|
1936
|
+
chainId,
|
|
1937
|
+
verifyingContract: paymentRails
|
|
1938
|
+
}
|
|
1939
|
+
}
|
|
1940
|
+
];
|
|
1941
|
+
const d = {
|
|
1942
|
+
type: "Iden3PaymentRailsSolanaRequestV1" /* Iden3PaymentRailsSolanaRequestV1 */,
|
|
1943
|
+
"@context": [
|
|
1944
|
+
`https://schema.iden3.io/core/jsonld/payment.jsonld#${option.type}`,
|
|
1945
|
+
"https://schema.iden3.io/core/jsonld/solanaEd25519.jsonld"
|
|
1946
|
+
],
|
|
1947
|
+
recipient,
|
|
1948
|
+
amount: amount.toString(),
|
|
1949
|
+
expirationDate: expirationDate.toISOString(),
|
|
1950
|
+
nonce: nonce.toString(),
|
|
1951
|
+
metadata: "0x",
|
|
1952
|
+
proof
|
|
1953
|
+
};
|
|
1954
|
+
if (option.type === "Iden3PaymentRailsSolanaRequestV1" /* Iden3PaymentRailsSolanaRequestV1 */) {
|
|
1955
|
+
return d;
|
|
1956
|
+
}
|
|
1957
|
+
return {
|
|
1958
|
+
...d,
|
|
1959
|
+
type: option.type,
|
|
1960
|
+
tokenAddress: option.contractAddress || "",
|
|
1961
|
+
features: option.features || []
|
|
1962
|
+
};
|
|
1963
|
+
};
|
|
1964
|
+
var serializeSolanaPaymentInstruction = (data) => {
|
|
1965
|
+
let serialized;
|
|
1966
|
+
const proof = Array.isArray(data.proof) ? data.proof[0] : data.proof;
|
|
1967
|
+
const proofVersion = data.type === "Iden3PaymentRailsSolanaRequestV1" /* Iden3PaymentRailsSolanaRequestV1 */ ? "SolanaEd25519NativeV1" : "SolanaEd25519SPLV1";
|
|
1968
|
+
if (data.type === "Iden3PaymentRailsSolanaRequestV1" /* Iden3PaymentRailsSolanaRequestV1 */) {
|
|
1969
|
+
const request = new SolanaNativePaymentRequest({
|
|
1970
|
+
version: byteEncoder.encode(proofVersion),
|
|
1971
|
+
chainId: BigInt(proof.domain.chainId),
|
|
1972
|
+
verifyingContract: new PublicKey3(proof.domain.verifyingContract).toBytes(),
|
|
1973
|
+
recipient: new PublicKey3(data.recipient).toBytes(),
|
|
1974
|
+
amount: BigInt(data.amount),
|
|
1975
|
+
expirationDate: BigInt(getUnixTimestamp(new Date(data.expirationDate))),
|
|
1976
|
+
nonce: BigInt(data.nonce),
|
|
1977
|
+
metadata: byteEncoder.encode("0x")
|
|
1978
|
+
});
|
|
1979
|
+
serialized = serialize(SolanaNativePaymentSchema, request);
|
|
1980
|
+
} else {
|
|
1981
|
+
const request = new SolanaSplPaymentRequest({
|
|
1982
|
+
version: byteEncoder.encode(proofVersion),
|
|
1983
|
+
chainId: BigInt(proof.domain.chainId),
|
|
1984
|
+
verifyingContract: new PublicKey3(proof.domain.verifyingContract).toBytes(),
|
|
1985
|
+
tokenAddress: new PublicKey3(data.tokenAddress).toBytes(),
|
|
1986
|
+
recipient: new PublicKey3(data.recipient).toBytes(),
|
|
1987
|
+
amount: BigInt(data.amount),
|
|
1988
|
+
expirationDate: BigInt(getUnixTimestamp(new Date(data.expirationDate))),
|
|
1989
|
+
nonce: BigInt(data.nonce),
|
|
1990
|
+
metadata: byteEncoder.encode("0x")
|
|
1991
|
+
});
|
|
1992
|
+
serialized = serialize(SolanaSplPaymentSchema, request);
|
|
1993
|
+
}
|
|
1994
|
+
return serialized;
|
|
1995
|
+
};
|
|
1996
|
+
var verifyIden3SolanaPaymentRequest = async (data, resolver) => {
|
|
1997
|
+
const proof = Array.isArray(data.proof) ? data.proof[0] : data.proof;
|
|
1998
|
+
let serialized;
|
|
1999
|
+
if (data.type === "Iden3PaymentRailsSolanaRequestV1" /* Iden3PaymentRailsSolanaRequestV1 */) {
|
|
2000
|
+
const request = new SolanaNativePaymentRequest({
|
|
2001
|
+
version: byteEncoder.encode(proof.domain.version),
|
|
2002
|
+
chainId: BigInt(proof.domain.chainId),
|
|
2003
|
+
verifyingContract: new PublicKey3(proof.domain.verifyingContract).toBytes(),
|
|
2004
|
+
recipient: new PublicKey3(data.recipient).toBytes(),
|
|
2005
|
+
amount: BigInt(data.amount),
|
|
2006
|
+
expirationDate: BigInt(getUnixTimestamp(new Date(data.expirationDate))),
|
|
2007
|
+
nonce: BigInt(data.nonce),
|
|
2008
|
+
metadata: byteEncoder.encode("0x")
|
|
2009
|
+
});
|
|
2010
|
+
serialized = serialize(SolanaNativePaymentSchema, request);
|
|
2011
|
+
} else {
|
|
2012
|
+
const request = new SolanaSplPaymentRequest({
|
|
2013
|
+
version: byteEncoder.encode(proof.domain.version),
|
|
2014
|
+
chainId: BigInt(proof.domain.chainId),
|
|
2015
|
+
verifyingContract: new PublicKey3(proof.domain.verifyingContract).toBytes(),
|
|
2016
|
+
tokenAddress: new PublicKey3(data.tokenAddress).toBytes(),
|
|
2017
|
+
recipient: new PublicKey3(data.recipient).toBytes(),
|
|
2018
|
+
amount: BigInt(data.amount),
|
|
2019
|
+
expirationDate: BigInt(getUnixTimestamp(new Date(data.expirationDate))),
|
|
2020
|
+
nonce: BigInt(data.nonce),
|
|
2021
|
+
metadata: byteEncoder.encode("0x")
|
|
2022
|
+
});
|
|
2023
|
+
serialized = serialize(SolanaSplPaymentSchema, request);
|
|
2024
|
+
}
|
|
2025
|
+
const { didDocument } = await resolver.resolve(proof.verificationMethod);
|
|
2026
|
+
let publicKeyMultibase;
|
|
2027
|
+
if (didDocument?.verificationMethod) {
|
|
2028
|
+
for (const verificationMethod of didDocument.verificationMethod) {
|
|
2029
|
+
if (verificationMethod.type === "Ed25519VerificationKey2020") {
|
|
2030
|
+
publicKeyMultibase = verificationMethod.publicKeyMultibase;
|
|
2031
|
+
}
|
|
2032
|
+
}
|
|
2033
|
+
}
|
|
2034
|
+
if (!publicKeyMultibase) {
|
|
2035
|
+
throw new Error("No Ed25519VerificationKey2020 found in DID document");
|
|
2036
|
+
}
|
|
2037
|
+
return ed25519.verify(proof.proofValue, serialized, new PublicKey3(publicKeyMultibase).toBytes());
|
|
2038
|
+
};
|
|
2039
|
+
|
|
2040
|
+
// src/utils/payments/evm.ts
|
|
2041
|
+
import { ethers } from "ethers";
|
|
2042
|
+
import { getUnixTimestamp as getUnixTimestamp2 } from "@iden3/js-iden3-core";
|
|
2043
|
+
var buildEvmPayment = async (signer, option, chainId, paymentRails, recipient, amount, expirationDateRequired, nonce) => {
|
|
2044
|
+
const typeUrl = `https://schema.iden3.io/core/json/${option.type}.json`;
|
|
2045
|
+
const typesFetchResult = await fetch(typeUrl);
|
|
2046
|
+
const types = await typesFetchResult.json();
|
|
2047
|
+
delete types.EIP712Domain;
|
|
2048
|
+
const paymentData = option.type === "Iden3PaymentRailsRequestV1" /* Iden3PaymentRailsRequestV1 */ ? {
|
|
2049
|
+
recipient,
|
|
2050
|
+
amount,
|
|
2051
|
+
expirationDate: getUnixTimestamp2(expirationDateRequired),
|
|
2052
|
+
nonce,
|
|
2053
|
+
metadata: "0x"
|
|
2054
|
+
} : {
|
|
2055
|
+
tokenAddress: option.contractAddress,
|
|
2056
|
+
recipient,
|
|
2057
|
+
amount,
|
|
2058
|
+
expirationDate: getUnixTimestamp2(expirationDateRequired),
|
|
2059
|
+
nonce,
|
|
2060
|
+
metadata: "0x"
|
|
2061
|
+
};
|
|
2062
|
+
const domain = {
|
|
2063
|
+
name: "MCPayment",
|
|
2064
|
+
version: "1.0.0",
|
|
2065
|
+
chainId,
|
|
2066
|
+
verifyingContract: paymentRails
|
|
2067
|
+
};
|
|
2068
|
+
const signature = await signer.signTypedData(domain, types, paymentData);
|
|
2069
|
+
const proof = [
|
|
2070
|
+
{
|
|
2071
|
+
type: "EthereumEip712Signature2021" /* EthereumEip712Signature2021 */,
|
|
2072
|
+
proofPurpose: "assertionMethod",
|
|
2073
|
+
proofValue: signature,
|
|
2074
|
+
verificationMethod: `did:pkh:eip155:${chainId}:${await signer.getAddress()}`,
|
|
2075
|
+
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2076
|
+
eip712: {
|
|
2077
|
+
types: typeUrl,
|
|
2078
|
+
primaryType: "Iden3PaymentRailsRequestV1",
|
|
2079
|
+
domain
|
|
2080
|
+
}
|
|
2081
|
+
}
|
|
2082
|
+
];
|
|
2083
|
+
const d = {
|
|
2084
|
+
type: "Iden3PaymentRailsRequestV1" /* Iden3PaymentRailsRequestV1 */,
|
|
2085
|
+
"@context": [
|
|
2086
|
+
`https://schema.iden3.io/core/jsonld/payment.jsonld#${option.type}`,
|
|
2087
|
+
"https://w3id.org/security/suites/eip712sig-2021/v1"
|
|
2088
|
+
],
|
|
2089
|
+
recipient,
|
|
2090
|
+
amount: amount.toString(),
|
|
2091
|
+
expirationDate: expirationDateRequired.toISOString(),
|
|
2092
|
+
nonce: nonce.toString(),
|
|
2093
|
+
metadata: "0x",
|
|
2094
|
+
proof
|
|
2095
|
+
};
|
|
2096
|
+
if (option.type === "Iden3PaymentRailsRequestV1" /* Iden3PaymentRailsRequestV1 */) {
|
|
2097
|
+
return d;
|
|
2098
|
+
}
|
|
2099
|
+
return {
|
|
2100
|
+
...d,
|
|
2101
|
+
type: option.type,
|
|
2102
|
+
tokenAddress: option.contractAddress || "",
|
|
2103
|
+
features: option.features || []
|
|
2104
|
+
};
|
|
2105
|
+
};
|
|
2106
|
+
async function verifyEIP712TypedData(data, resolver) {
|
|
2107
|
+
const paymentData = data.type === "Iden3PaymentRailsRequestV1" /* Iden3PaymentRailsRequestV1 */ ? {
|
|
2108
|
+
recipient: data.recipient,
|
|
2109
|
+
amount: data.amount,
|
|
2110
|
+
expirationDate: getUnixTimestamp2(new Date(data.expirationDate)),
|
|
2111
|
+
nonce: data.nonce,
|
|
2112
|
+
metadata: "0x"
|
|
2113
|
+
} : {
|
|
2114
|
+
tokenAddress: data.tokenAddress,
|
|
2115
|
+
recipient: data.recipient,
|
|
2116
|
+
amount: data.amount,
|
|
2117
|
+
expirationDate: getUnixTimestamp2(new Date(data.expirationDate)),
|
|
2118
|
+
nonce: data.nonce,
|
|
2119
|
+
metadata: "0x"
|
|
2120
|
+
};
|
|
2121
|
+
const proof = Array.isArray(data.proof) ? data.proof[0] : data.proof;
|
|
2122
|
+
const typesFetchResult = await fetch(proof.eip712.types);
|
|
2123
|
+
const types = await typesFetchResult.json();
|
|
2124
|
+
delete types.EIP712Domain;
|
|
2125
|
+
const recovered = ethers.verifyTypedData(
|
|
2126
|
+
proof.eip712.domain,
|
|
2127
|
+
types,
|
|
2128
|
+
paymentData,
|
|
2129
|
+
proof.proofValue
|
|
2130
|
+
);
|
|
2131
|
+
const { didDocument } = await resolver.resolve(proof.verificationMethod);
|
|
2132
|
+
if (didDocument?.verificationMethod) {
|
|
2133
|
+
for (const verificationMethod of didDocument.verificationMethod) {
|
|
2134
|
+
if (verificationMethod.blockchainAccountId?.split(":").slice(-1)[0].toLowerCase() === recovered.toLowerCase()) {
|
|
2135
|
+
return recovered;
|
|
2136
|
+
}
|
|
2137
|
+
}
|
|
2138
|
+
} else {
|
|
2139
|
+
throw new Error("failed request. issuer DIDDocument does not contain any verificationMethods");
|
|
2140
|
+
}
|
|
2141
|
+
throw new Error(`failed request. no matching verificationMethod`);
|
|
2142
|
+
}
|
|
2143
|
+
|
|
2144
|
+
// src/kms/key-providers/bjj-provider.ts
|
|
2145
|
+
var BjjProvider = class {
|
|
2146
|
+
/**
|
|
2147
|
+
* key type that is handled by BJJ Provider
|
|
2148
|
+
* @type {KmsKeyType}
|
|
2149
|
+
*/
|
|
2150
|
+
keyType;
|
|
2151
|
+
keyStore;
|
|
2152
|
+
/**
|
|
2153
|
+
* Creates an instance of BjjProvider.
|
|
2154
|
+
* @param {KmsKeyType} keyType - kms key type
|
|
2155
|
+
* @param {AbstractPrivateKeyStore} keyStore - key store for kms
|
|
2156
|
+
*/
|
|
2157
|
+
constructor(keyType, keyStore) {
|
|
2158
|
+
if (keyType !== "BJJ" /* BabyJubJub */) {
|
|
2159
|
+
throw new Error("Key type must be BabyJubJub");
|
|
2160
|
+
}
|
|
2161
|
+
this.keyType = keyType;
|
|
2162
|
+
this.keyStore = keyStore;
|
|
2163
|
+
}
|
|
2164
|
+
/**
|
|
2165
|
+
* get all keys
|
|
2166
|
+
* @returns list of keys
|
|
2167
|
+
*/
|
|
2168
|
+
async list() {
|
|
2169
|
+
const allKeysFromKeyStore = await this.keyStore.list();
|
|
2170
|
+
return allKeysFromKeyStore.filter((key) => key.alias.startsWith(this.keyType));
|
|
2171
|
+
}
|
|
2172
|
+
/**
|
|
2173
|
+
* generates a baby jub jub key from a seed phrase
|
|
2174
|
+
* @param {Uint8Array} seed - byte array seed
|
|
2175
|
+
* @returns kms key identifier
|
|
2176
|
+
*/
|
|
2177
|
+
async newPrivateKeyFromSeed(seed) {
|
|
2178
|
+
const newKey = new Uint8Array(32);
|
|
2179
|
+
newKey.set(Uint8Array.from(seed), 0);
|
|
2180
|
+
newKey.fill(seed.length, 32, 0);
|
|
2181
|
+
const privateKey = new PrivateKey(seed);
|
|
2182
|
+
const publicKey = privateKey.public();
|
|
2183
|
+
const kmsId = {
|
|
2184
|
+
type: this.keyType,
|
|
2185
|
+
id: keyPath(this.keyType, publicKey.hex())
|
|
2186
|
+
};
|
|
2187
|
+
await this.keyStore.importKey({ alias: kmsId.id, key: privateKey.hex() });
|
|
2188
|
+
return kmsId;
|
|
2189
|
+
}
|
|
2190
|
+
/**
|
|
2191
|
+
* Gets public key by kmsKeyId
|
|
2192
|
+
*
|
|
2193
|
+
* @param {KmsKeyId} keyId - key identifier
|
|
2194
|
+
*/
|
|
2195
|
+
async publicKey(keyId) {
|
|
2196
|
+
const privateKey = await this.privateKey(keyId);
|
|
2197
|
+
return privateKey.public().hex();
|
|
2198
|
+
}
|
|
2199
|
+
/**
|
|
2200
|
+
* signs prepared payload of size,
|
|
2201
|
+
* with a key id
|
|
2202
|
+
*
|
|
2203
|
+
* @param {KmsKeyId} keyId - key identifier
|
|
2204
|
+
* @param {Uint8Array} data - data to sign (32 bytes)
|
|
2205
|
+
* @returns Uint8Array signature
|
|
2206
|
+
*/
|
|
2207
|
+
async sign(keyId, data) {
|
|
2208
|
+
if (data.length != 32) {
|
|
2209
|
+
throw new Error("data to sign is too large");
|
|
2210
|
+
}
|
|
2211
|
+
const i = BytesHelper2.bytesToInt(data);
|
|
2212
|
+
if (!checkBigIntInField(i)) {
|
|
2213
|
+
throw new Error("data to sign is too large");
|
|
2214
|
+
}
|
|
2215
|
+
const privateKey = await this.privateKey(keyId);
|
|
2216
|
+
const signature = privateKey.signPoseidon(i);
|
|
2217
|
+
return signature.compress();
|
|
2218
|
+
}
|
|
2219
|
+
async privateKey(keyId) {
|
|
2220
|
+
const privateKeyHex = await this.keyStore.get({ alias: keyId.id });
|
|
2221
|
+
return new PrivateKey(Hex4.decodeString(privateKeyHex));
|
|
2222
|
+
}
|
|
2223
|
+
async verify(message, signatureHex, keyId) {
|
|
2224
|
+
const publicKey = await this.publicKey(keyId);
|
|
2225
|
+
return PublicKey4.newFromCompressed(hexToBytes(publicKey)).verifyPoseidon(
|
|
2226
|
+
BytesHelper2.bytesToInt(message),
|
|
2227
|
+
Signature2.newFromCompressed(hexToBytes(signatureHex))
|
|
2228
|
+
);
|
|
2229
|
+
}
|
|
2230
|
+
};
|
|
2231
|
+
|
|
2232
|
+
// src/kms/key-providers/ed25519-provider.ts
|
|
2233
|
+
import { ed25519 as ed255192 } from "@noble/curves/ed25519";
|
|
2234
|
+
var Ed25519Provider = class {
|
|
2235
|
+
/**
|
|
2236
|
+
* Creates an instance of Ed25519Provider.
|
|
2237
|
+
* @param {KmsKeyType} keyType - kms key type
|
|
2238
|
+
* @param {AbstractPrivateKeyStore} keyStore - key store for kms
|
|
2239
|
+
*/
|
|
2240
|
+
constructor(keyType, _keyStore) {
|
|
2241
|
+
this.keyType = keyType;
|
|
2242
|
+
this._keyStore = _keyStore;
|
|
2243
|
+
}
|
|
2244
|
+
/**
|
|
2245
|
+
* get all keys
|
|
2246
|
+
* @returns list of keys
|
|
2247
|
+
*/
|
|
2248
|
+
async list() {
|
|
2249
|
+
const allKeysFromKeyStore = await this._keyStore.list();
|
|
2250
|
+
return allKeysFromKeyStore.filter((key) => key.alias.startsWith(this.keyType));
|
|
2251
|
+
}
|
|
2252
|
+
/**
|
|
2253
|
+
* generates a ed25519 key from a seed phrase
|
|
2254
|
+
* @param {Uint8Array} seed - byte array seed
|
|
2255
|
+
* @returns {Promise<KmsKeyId>} kms key identifier
|
|
2256
|
+
*/
|
|
2257
|
+
async newPrivateKeyFromSeed(seed) {
|
|
2258
|
+
if (seed.length !== 32) {
|
|
2259
|
+
throw new Error("Seed should be 32 bytes");
|
|
2260
|
+
}
|
|
2261
|
+
const publicKey = ed255192.getPublicKey(seed);
|
|
2262
|
+
const kmsId = {
|
|
2263
|
+
type: this.keyType,
|
|
2264
|
+
id: keyPath(this.keyType, bytesToHex(publicKey))
|
|
2265
|
+
};
|
|
2266
|
+
await this._keyStore.importKey({
|
|
2267
|
+
alias: kmsId.id,
|
|
2268
|
+
key: bytesToHex(seed)
|
|
2269
|
+
});
|
|
2270
|
+
return kmsId;
|
|
2271
|
+
}
|
|
2272
|
+
/**
|
|
2273
|
+
* Gets public key by kmsKeyId
|
|
2274
|
+
* @param {KmsKeyId} keyId - key identifier
|
|
2275
|
+
* @returns {Promise<string>} Public key as a hex string
|
|
2276
|
+
*/
|
|
2277
|
+
async publicKey(keyId) {
|
|
2278
|
+
const privateKeyHex = await this.privateKey(keyId);
|
|
2279
|
+
const publicKey = ed255192.getPublicKey(privateKeyHex);
|
|
2280
|
+
return bytesToHex(publicKey);
|
|
2281
|
+
}
|
|
2282
|
+
/**
|
|
2283
|
+
* signs prepared payload of size,
|
|
2284
|
+
* with a key id
|
|
2285
|
+
* @param {KmsKeyId} keyId - key identifier
|
|
2286
|
+
* @param {Uint8Array} digest - data to sign (32 bytes)
|
|
2287
|
+
* @returns {Promise<Uint8Array>} signature
|
|
2288
|
+
*/
|
|
2289
|
+
async sign(keyId, digest) {
|
|
2290
|
+
const privateKeyHex = await this.privateKey(keyId);
|
|
2291
|
+
return ed255192.sign(digest, privateKeyHex);
|
|
2292
|
+
}
|
|
2293
|
+
/**
|
|
2294
|
+
* Verifies a signature for the given message and key identifier.
|
|
2295
|
+
* @param digest - The message to verify the signature against.
|
|
2296
|
+
* @param signatureHex - The signature to verify, as a hexadecimal string.
|
|
2297
|
+
* @param keyId - The key identifier to use for verification.
|
|
2298
|
+
* @returns A Promise that resolves to a boolean indicating whether the signature is valid.
|
|
2299
|
+
*/
|
|
2300
|
+
async verify(digest, signatureHex, keyId) {
|
|
2301
|
+
const publicKeyHex = await this.publicKey(keyId);
|
|
2302
|
+
return ed255192.verify(signatureHex, digest, publicKeyHex);
|
|
2303
|
+
}
|
|
2304
|
+
/**
|
|
2305
|
+
* Retrieves the private key for a given keyId from the key store.
|
|
2306
|
+
* @param {KmsKeyId} keyId - The identifier of the key to retrieve.
|
|
2307
|
+
* @returns {Promise<string>} The private key associated with the keyId.
|
|
2308
|
+
*/
|
|
2309
|
+
async privateKey(keyId) {
|
|
2310
|
+
return this._keyStore.get({ alias: keyId.id });
|
|
2311
|
+
}
|
|
2312
|
+
};
|
|
2313
|
+
|
|
2314
|
+
// src/kms/key-providers/secp256k1-provider.ts
|
|
2315
|
+
import { secp256k1 } from "@noble/curves/secp256k1";
|
|
2316
|
+
import { sha256 } from "@iden3/js-crypto";
|
|
2317
|
+
import { ES256KSigner, hexToBytes as hexToBytes2 } from "did-jwt";
|
|
2318
|
+
var Sec256k1Provider = class {
|
|
2319
|
+
/**
|
|
2320
|
+
* key type that is handled by BJJ Provider
|
|
2321
|
+
* @type {KmsKeyType}
|
|
2322
|
+
*/
|
|
2323
|
+
keyType;
|
|
2324
|
+
_keyStore;
|
|
2325
|
+
/**
|
|
2326
|
+
* Creates an instance of BjjProvider.
|
|
2327
|
+
* @param {KmsKeyType} keyType - kms key type
|
|
2328
|
+
* @param {AbstractPrivateKeyStore} keyStore - key store for kms
|
|
2329
|
+
*/
|
|
2330
|
+
constructor(keyType, keyStore) {
|
|
2331
|
+
if (keyType !== "Secp256k1" /* Secp256k1 */) {
|
|
2332
|
+
throw new Error("Key type must be Secp256k1");
|
|
2333
|
+
}
|
|
2334
|
+
this.keyType = keyType;
|
|
2335
|
+
this._keyStore = keyStore;
|
|
2336
|
+
}
|
|
2337
|
+
/**
|
|
2338
|
+
* get all keys
|
|
2339
|
+
* @returns list of keys
|
|
2340
|
+
*/
|
|
2341
|
+
async list() {
|
|
2342
|
+
const allKeysFromKeyStore = await this._keyStore.list();
|
|
2343
|
+
return allKeysFromKeyStore.filter((key) => key.alias.startsWith(this.keyType));
|
|
2344
|
+
}
|
|
2345
|
+
/**
|
|
2346
|
+
* generates a baby jub jub key from a seed phrase
|
|
2347
|
+
* @param {Uint8Array} seed - byte array seed
|
|
2348
|
+
* @returns kms key identifier
|
|
2349
|
+
*/
|
|
2350
|
+
async newPrivateKeyFromSeed(seed) {
|
|
2351
|
+
if (seed.length !== 32) {
|
|
2352
|
+
throw new Error("Seed should be 32 bytes");
|
|
2353
|
+
}
|
|
2354
|
+
const publicKey = secp256k1.getPublicKey(seed);
|
|
2355
|
+
const kmsId = {
|
|
2356
|
+
type: this.keyType,
|
|
2357
|
+
id: keyPath(this.keyType, bytesToHex(publicKey))
|
|
2358
|
+
};
|
|
2359
|
+
await this._keyStore.importKey({
|
|
2360
|
+
alias: kmsId.id,
|
|
2361
|
+
key: bytesToHex(seed).padStart(64, "0")
|
|
2362
|
+
});
|
|
2363
|
+
return kmsId;
|
|
2364
|
+
}
|
|
2365
|
+
/**
|
|
2366
|
+
* Gets public key by kmsKeyId
|
|
2367
|
+
*
|
|
2368
|
+
* @param {KmsKeyId} keyId - key identifier
|
|
2369
|
+
*/
|
|
2370
|
+
async publicKey(keyId) {
|
|
2371
|
+
const privateKeyHex = await this.privateKey(keyId);
|
|
2372
|
+
const publicKey = secp256k1.getPublicKey(privateKeyHex, false);
|
|
2373
|
+
return bytesToHex(publicKey);
|
|
2374
|
+
}
|
|
2375
|
+
/**
|
|
2376
|
+
* Signs the given data using the private key associated with the specified key identifier.
|
|
2377
|
+
* @param keyId - The key identifier to use for signing.
|
|
2378
|
+
* @param data - The data to sign.
|
|
2379
|
+
* @param opts - Signing options, such as the algorithm to use.
|
|
2380
|
+
* @returns A Promise that resolves to the signature as a Uint8Array.
|
|
2381
|
+
*/
|
|
2382
|
+
async sign(keyId, data, opts = { alg: "ES256K" }) {
|
|
2383
|
+
const privateKeyHex = await this.privateKey(keyId);
|
|
2384
|
+
const signatureBase64 = await ES256KSigner(
|
|
2385
|
+
hexToBytes2(privateKeyHex),
|
|
2386
|
+
opts.alg === "ES256K-R"
|
|
2387
|
+
)(data);
|
|
2388
|
+
if (typeof signatureBase64 !== "string") {
|
|
2389
|
+
throw new Error("signatureBase64 must be a string");
|
|
2390
|
+
}
|
|
2391
|
+
return base64UrlToBytes(signatureBase64);
|
|
2392
|
+
}
|
|
2393
|
+
/**
|
|
2394
|
+
* Verifies a signature for the given message and key identifier.
|
|
2395
|
+
* @param message - The message to verify the signature against.
|
|
2396
|
+
* @param signatureHex - The signature to verify, as a hexadecimal string.
|
|
2397
|
+
* @param keyId - The key identifier to use for verification.
|
|
2398
|
+
* @returns A Promise that resolves to a boolean indicating whether the signature is valid.
|
|
2399
|
+
*/
|
|
2400
|
+
async verify(message, signatureHex, keyId) {
|
|
2401
|
+
const publicKeyHex = await this.publicKey(keyId);
|
|
2402
|
+
return secp256k1.verify(signatureHex, sha256(message), publicKeyHex);
|
|
2403
|
+
}
|
|
2404
|
+
async privateKey(keyId) {
|
|
2405
|
+
return this._keyStore.get({ alias: keyId.id });
|
|
2406
|
+
}
|
|
2407
|
+
};
|
|
2408
|
+
|
|
2409
|
+
// src/identity/identity-wallet.ts
|
|
2410
|
+
import {
|
|
2411
|
+
Blockchain,
|
|
2412
|
+
buildDIDType as buildDIDType3,
|
|
2413
|
+
BytesHelper as BytesHelper9,
|
|
2414
|
+
Claim as Claim9,
|
|
2415
|
+
ClaimOptions as ClaimOptions2,
|
|
2416
|
+
DID as DID27,
|
|
2417
|
+
DidMethod,
|
|
2418
|
+
getUnixTimestamp as getUnixTimestamp10,
|
|
2419
|
+
Id as Id19,
|
|
2420
|
+
NetworkId,
|
|
2421
|
+
SchemaHash as SchemaHash7
|
|
2422
|
+
} from "@iden3/js-iden3-core";
|
|
2423
|
+
import {
|
|
2424
|
+
poseidon as poseidon4,
|
|
2425
|
+
PublicKey as PublicKey5,
|
|
2426
|
+
sha256 as sha2562,
|
|
2427
|
+
Signature as Signature3,
|
|
2428
|
+
Hex as Hex6,
|
|
2429
|
+
getRandomBytes as getRandomBytes2,
|
|
2430
|
+
Poseidon
|
|
2431
|
+
} from "@iden3/js-crypto";
|
|
2432
|
+
import { hashElems as hashElems2, ZERO_HASH as ZERO_HASH6 } from "@iden3/js-merkletree";
|
|
2045
2433
|
|
|
2046
2434
|
// src/identity/common.ts
|
|
2435
|
+
import { DID as DID5, Id as Id2, IdPosition as IdPosition2, MerklizedRootPosition as MerklizedRootPosition2 } from "@iden3/js-iden3-core";
|
|
2047
2436
|
var subjectPositionIndex = (idPosition) => {
|
|
2048
2437
|
switch (idPosition) {
|
|
2049
2438
|
case IdPosition2.Index:
|
|
@@ -4539,9 +4928,9 @@ var TransactionService = class {
|
|
|
4539
4928
|
};
|
|
4540
4929
|
|
|
4541
4930
|
// src/storage/blockchain/common.ts
|
|
4542
|
-
import { ethers } from "ethers";
|
|
4931
|
+
import { ethers as ethers2 } from "ethers";
|
|
4543
4932
|
var packZkpProof = (inputs, a, b, c) => {
|
|
4544
|
-
return new
|
|
4933
|
+
return new ethers2.AbiCoder().encode(
|
|
4545
4934
|
["uint256[] inputs", "uint256[2]", "uint256[2][2]", "uint256[2]"],
|
|
4546
4935
|
[inputs, a, b, c]
|
|
4547
4936
|
);
|
|
@@ -5591,14 +5980,14 @@ var DiscoveryProtocolFeatureType = /* @__PURE__ */ ((DiscoveryProtocolFeatureTyp
|
|
|
5591
5980
|
})(DiscoveryProtocolFeatureType || {});
|
|
5592
5981
|
|
|
5593
5982
|
// src/iden3comm/handlers/auth.ts
|
|
5594
|
-
import { DID as DID8, getUnixTimestamp as
|
|
5983
|
+
import { DID as DID8, getUnixTimestamp as getUnixTimestamp4 } from "@iden3/js-iden3-core";
|
|
5595
5984
|
import { proving as proving3 } from "@iden3/js-jwz";
|
|
5596
5985
|
import * as uuid2 from "uuid";
|
|
5597
5986
|
|
|
5598
5987
|
// src/iden3comm/handlers/common.ts
|
|
5599
5988
|
import { getRandomBytes } from "@iden3/js-crypto";
|
|
5600
|
-
import { getUnixTimestamp } from "@iden3/js-iden3-core";
|
|
5601
|
-
import { ethers as
|
|
5989
|
+
import { getUnixTimestamp as getUnixTimestamp3 } from "@iden3/js-iden3-core";
|
|
5990
|
+
import { ethers as ethers3 } from "ethers";
|
|
5602
5991
|
var getGroupedQueries = (requestScope) => requestScope.reduce((acc, proofReq) => {
|
|
5603
5992
|
const groupId = proofReq.query.groupId;
|
|
5604
5993
|
if (!groupId) {
|
|
@@ -5765,8 +6154,8 @@ var calcChallengeAuthV2 = (senderAddress, zkpResponses) => {
|
|
|
5765
6154
|
};
|
|
5766
6155
|
});
|
|
5767
6156
|
return BigInt(
|
|
5768
|
-
|
|
5769
|
-
new
|
|
6157
|
+
ethers3.keccak256(
|
|
6158
|
+
new ethers3.AbiCoder().encode(
|
|
5770
6159
|
["address", "(uint256 requestId,bytes proof,bytes metadata)[]"],
|
|
5771
6160
|
[senderAddress, responses]
|
|
5772
6161
|
)
|
|
@@ -5774,10 +6163,10 @@ var calcChallengeAuthV2 = (senderAddress, zkpResponses) => {
|
|
|
5774
6163
|
) & BigInt("0x0fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
|
5775
6164
|
};
|
|
5776
6165
|
var packMetadatas = (metas) => {
|
|
5777
|
-
return new
|
|
6166
|
+
return new ethers3.AbiCoder().encode(["tuple(string key,bytes value)[]"], [metas]);
|
|
5778
6167
|
};
|
|
5779
6168
|
var verifyExpiresTime = (message) => {
|
|
5780
|
-
if (message?.expires_time && message.expires_time <
|
|
6169
|
+
if (message?.expires_time && message.expires_time < getUnixTimestamp3(/* @__PURE__ */ new Date())) {
|
|
5781
6170
|
throw new Error("Message expired");
|
|
5782
6171
|
}
|
|
5783
6172
|
};
|
|
@@ -5895,8 +6284,8 @@ function createAuthorizationRequestWithMessage(reason, message, sender, callback
|
|
|
5895
6284
|
callbackUrl,
|
|
5896
6285
|
scope: opts?.scope ?? []
|
|
5897
6286
|
},
|
|
5898
|
-
created_time:
|
|
5899
|
-
expires_time: opts?.expires_time ?
|
|
6287
|
+
created_time: getUnixTimestamp4(/* @__PURE__ */ new Date()),
|
|
6288
|
+
expires_time: opts?.expires_time ? getUnixTimestamp4(opts.expires_time) : void 0,
|
|
5900
6289
|
attachments: opts?.attachments
|
|
5901
6290
|
};
|
|
5902
6291
|
return request;
|
|
@@ -7357,7 +7746,10 @@ var FetchHandler = class _FetchHandler extends AbstractMessageHandler {
|
|
|
7357
7746
|
if (!issuanceMsg.body?.credential) {
|
|
7358
7747
|
throw new Error("credential is missing in issuance response message");
|
|
7359
7748
|
}
|
|
7360
|
-
|
|
7749
|
+
if (!(issuanceMsg.body.credential instanceof W3CCredential)) {
|
|
7750
|
+
throw new Error("credential object is not properly unmarshaled");
|
|
7751
|
+
}
|
|
7752
|
+
await this.opts.credentialWallet.save(issuanceMsg.body.credential);
|
|
7361
7753
|
return null;
|
|
7362
7754
|
}
|
|
7363
7755
|
/**
|
|
@@ -7372,6 +7764,7 @@ var FetchHandler = class _FetchHandler extends AbstractMessageHandler {
|
|
|
7372
7764
|
if (!opts?.allowExpiredMessages) {
|
|
7373
7765
|
verifyExpiresTime(issuanceMsg);
|
|
7374
7766
|
}
|
|
7767
|
+
issuanceMsg.body.credential = W3CCredential.fromJSON(issuanceMsg.body.credential);
|
|
7375
7768
|
await this.handleIssuanceResponseMsg(issuanceMsg);
|
|
7376
7769
|
return Uint8Array.from([]);
|
|
7377
7770
|
}
|
|
@@ -7389,7 +7782,7 @@ var FetchHandler = class _FetchHandler extends AbstractMessageHandler {
|
|
|
7389
7782
|
};
|
|
7390
7783
|
|
|
7391
7784
|
// src/iden3comm/handlers/contract-request.ts
|
|
7392
|
-
import { DID as DID13, ChainIds, getUnixTimestamp as
|
|
7785
|
+
import { DID as DID13, ChainIds, getUnixTimestamp as getUnixTimestamp5, BytesHelper as BytesHelper6 } from "@iden3/js-iden3-core";
|
|
7393
7786
|
var ContractRequestHandler = class extends AbstractMessageHandler {
|
|
7394
7787
|
/**
|
|
7395
7788
|
* Creates an instance of ContractRequestHandler.
|
|
@@ -7560,7 +7953,7 @@ var ContractRequestHandler = class extends AbstractMessageHandler {
|
|
|
7560
7953
|
transaction_data: request.body.transaction_data,
|
|
7561
7954
|
scope: []
|
|
7562
7955
|
},
|
|
7563
|
-
created_time:
|
|
7956
|
+
created_time: getUnixTimestamp5(/* @__PURE__ */ new Date())
|
|
7564
7957
|
};
|
|
7565
7958
|
for (const [txHash, zkpResponses] of txHashToZkpResponseMap) {
|
|
7566
7959
|
for (const zkpResponse of zkpResponses.responses) {
|
|
@@ -7809,7 +8202,7 @@ var RevocationStatusHandler = class extends AbstractMessageHandler {
|
|
|
7809
8202
|
};
|
|
7810
8203
|
|
|
7811
8204
|
// src/iden3comm/handlers/credential-proposal.ts
|
|
7812
|
-
import { DID as DID16, getUnixTimestamp as
|
|
8205
|
+
import { DID as DID16, getUnixTimestamp as getUnixTimestamp6 } from "@iden3/js-iden3-core";
|
|
7813
8206
|
import * as uuid8 from "uuid";
|
|
7814
8207
|
import { proving as proving7 } from "@iden3/js-jwz";
|
|
7815
8208
|
function createProposalRequest(sender, receiver, opts) {
|
|
@@ -7821,9 +8214,12 @@ function createProposalRequest(sender, receiver, opts) {
|
|
|
7821
8214
|
to: receiver.string(),
|
|
7822
8215
|
typ: "application/iden3comm-plain-json" /* PlainMessage */,
|
|
7823
8216
|
type: PROTOCOL_MESSAGE_TYPE.PROPOSAL_REQUEST_MESSAGE_TYPE,
|
|
7824
|
-
body:
|
|
7825
|
-
|
|
7826
|
-
|
|
8217
|
+
body: {
|
|
8218
|
+
credentials: opts.credentials,
|
|
8219
|
+
did_doc: opts.did_doc
|
|
8220
|
+
},
|
|
8221
|
+
created_time: getUnixTimestamp6(/* @__PURE__ */ new Date()),
|
|
8222
|
+
expires_time: opts?.expires_time ? getUnixTimestamp6(opts.expires_time) : void 0,
|
|
7827
8223
|
attachments: opts.attachments
|
|
7828
8224
|
};
|
|
7829
8225
|
return request;
|
|
@@ -7840,8 +8236,8 @@ function createProposal(sender, receiver, proposals, opts) {
|
|
|
7840
8236
|
body: {
|
|
7841
8237
|
proposals: proposals || []
|
|
7842
8238
|
},
|
|
7843
|
-
created_time:
|
|
7844
|
-
expires_time: opts?.expires_time ?
|
|
8239
|
+
created_time: getUnixTimestamp6(/* @__PURE__ */ new Date()),
|
|
8240
|
+
expires_time: opts?.expires_time ? getUnixTimestamp6(opts.expires_time) : void 0
|
|
7845
8241
|
};
|
|
7846
8242
|
return request;
|
|
7847
8243
|
}
|
|
@@ -8002,10 +8398,9 @@ var CredentialProposalHandler = class extends AbstractMessageHandler {
|
|
|
8002
8398
|
};
|
|
8003
8399
|
|
|
8004
8400
|
// src/iden3comm/handlers/payment.ts
|
|
8005
|
-
import { DID as DID17, getUnixTimestamp as
|
|
8401
|
+
import { DID as DID17, getUnixTimestamp as getUnixTimestamp7 } from "@iden3/js-iden3-core";
|
|
8006
8402
|
import * as uuid9 from "uuid";
|
|
8007
8403
|
import { proving as proving8 } from "@iden3/js-jwz";
|
|
8008
|
-
import { ethers as ethers3 } from "ethers";
|
|
8009
8404
|
function createPaymentRequest(sender, receiver, agent, payments, opts) {
|
|
8010
8405
|
const uuidv4 = uuid9.v4();
|
|
8011
8406
|
const request = {
|
|
@@ -8019,48 +8414,11 @@ function createPaymentRequest(sender, receiver, agent, payments, opts) {
|
|
|
8019
8414
|
agent,
|
|
8020
8415
|
payments
|
|
8021
8416
|
},
|
|
8022
|
-
created_time:
|
|
8023
|
-
expires_time: opts?.expires_time ?
|
|
8417
|
+
created_time: getUnixTimestamp7(/* @__PURE__ */ new Date()),
|
|
8418
|
+
expires_time: opts?.expires_time ? getUnixTimestamp7(opts.expires_time) : void 0
|
|
8024
8419
|
};
|
|
8025
8420
|
return request;
|
|
8026
8421
|
}
|
|
8027
|
-
async function verifyEIP712TypedData(data, resolver) {
|
|
8028
|
-
const paymentData = data.type === "Iden3PaymentRailsRequestV1" /* Iden3PaymentRailsRequestV1 */ ? {
|
|
8029
|
-
recipient: data.recipient,
|
|
8030
|
-
amount: data.amount,
|
|
8031
|
-
expirationDate: getUnixTimestamp5(new Date(data.expirationDate)),
|
|
8032
|
-
nonce: data.nonce,
|
|
8033
|
-
metadata: "0x"
|
|
8034
|
-
} : {
|
|
8035
|
-
tokenAddress: data.tokenAddress,
|
|
8036
|
-
recipient: data.recipient,
|
|
8037
|
-
amount: data.amount,
|
|
8038
|
-
expirationDate: getUnixTimestamp5(new Date(data.expirationDate)),
|
|
8039
|
-
nonce: data.nonce,
|
|
8040
|
-
metadata: "0x"
|
|
8041
|
-
};
|
|
8042
|
-
const proof = Array.isArray(data.proof) ? data.proof[0] : data.proof;
|
|
8043
|
-
const typesFetchResult = await fetch(proof.eip712.types);
|
|
8044
|
-
const types = await typesFetchResult.json();
|
|
8045
|
-
delete types.EIP712Domain;
|
|
8046
|
-
const recovered = ethers3.verifyTypedData(
|
|
8047
|
-
proof.eip712.domain,
|
|
8048
|
-
types,
|
|
8049
|
-
paymentData,
|
|
8050
|
-
proof.proofValue
|
|
8051
|
-
);
|
|
8052
|
-
const { didDocument } = await resolver.resolve(proof.verificationMethod);
|
|
8053
|
-
if (didDocument?.verificationMethod) {
|
|
8054
|
-
for (const verificationMethod of didDocument.verificationMethod) {
|
|
8055
|
-
if (verificationMethod.blockchainAccountId?.split(":").slice(-1)[0].toLowerCase() === recovered.toLowerCase()) {
|
|
8056
|
-
return recovered;
|
|
8057
|
-
}
|
|
8058
|
-
}
|
|
8059
|
-
} else {
|
|
8060
|
-
throw new Error("failed request. issuer DIDDocument does not contain any verificationMethods");
|
|
8061
|
-
}
|
|
8062
|
-
throw new Error(`failed request. no matching verificationMethod`);
|
|
8063
|
-
}
|
|
8064
8422
|
function createPayment(sender, receiver, payments, opts) {
|
|
8065
8423
|
const uuidv4 = uuid9.v4();
|
|
8066
8424
|
const request = {
|
|
@@ -8073,8 +8431,8 @@ function createPayment(sender, receiver, payments, opts) {
|
|
|
8073
8431
|
body: {
|
|
8074
8432
|
payments
|
|
8075
8433
|
},
|
|
8076
|
-
created_time:
|
|
8077
|
-
expires_time: opts?.expires_time ?
|
|
8434
|
+
created_time: getUnixTimestamp7(/* @__PURE__ */ new Date()),
|
|
8435
|
+
expires_time: opts?.expires_time ? getUnixTimestamp7(opts.expires_time) : void 0
|
|
8078
8436
|
};
|
|
8079
8437
|
return request;
|
|
8080
8438
|
}
|
|
@@ -8159,6 +8517,22 @@ var PaymentHandler = class extends AbstractMessageHandler {
|
|
|
8159
8517
|
)
|
|
8160
8518
|
);
|
|
8161
8519
|
break;
|
|
8520
|
+
case "Iden3PaymentRailsSolanaRequestV1" /* Iden3PaymentRailsSolanaRequestV1 */:
|
|
8521
|
+
payments.push(
|
|
8522
|
+
await this.handleIden3PaymentRailsSolanaRequestV1(selectedPayment, ctx.paymentHandler)
|
|
8523
|
+
);
|
|
8524
|
+
break;
|
|
8525
|
+
case "Iden3PaymentRailsSolanaSPLRequestV1" /* Iden3PaymentRailsSolanaSPLRequestV1 */:
|
|
8526
|
+
payments.push(
|
|
8527
|
+
await this.handleIden3PaymentRailsSolanaSPLRequestV1(
|
|
8528
|
+
{
|
|
8529
|
+
...selectedPayment,
|
|
8530
|
+
type: "Iden3PaymentRailsSolanaSPLRequestV1" /* Iden3PaymentRailsSolanaSPLRequestV1 */
|
|
8531
|
+
},
|
|
8532
|
+
ctx.paymentHandler
|
|
8533
|
+
)
|
|
8534
|
+
);
|
|
8535
|
+
break;
|
|
8162
8536
|
}
|
|
8163
8537
|
}
|
|
8164
8538
|
const paymentMessage = createPayment(senderDID, receiverDID, payments);
|
|
@@ -8237,7 +8611,7 @@ var PaymentHandler = class extends AbstractMessageHandler {
|
|
|
8237
8611
|
/**
|
|
8238
8612
|
* @inheritdoc IPaymentHandler#createPaymentRailsV1
|
|
8239
8613
|
*/
|
|
8240
|
-
async createPaymentRailsV1(sender, receiver, agent, signer, payments) {
|
|
8614
|
+
async createPaymentRailsV1(sender, receiver, agent, signer, payments, createOptions) {
|
|
8241
8615
|
const paymentRequestInfo = [];
|
|
8242
8616
|
for (let i = 0; i < payments.length; i++) {
|
|
8243
8617
|
const { credentials, description } = payments[i];
|
|
@@ -8255,70 +8629,40 @@ var PaymentHandler = class extends AbstractMessageHandler {
|
|
|
8255
8629
|
if (!option) {
|
|
8256
8630
|
throw new Error(`failed request. no option for id ${optionId}`);
|
|
8257
8631
|
}
|
|
8258
|
-
if (option.type === "Iden3PaymentRailsERC20RequestV1" /* Iden3PaymentRailsERC20RequestV1 */ && !option.contractAddress) {
|
|
8632
|
+
if ((option.type === "Iden3PaymentRailsERC20RequestV1" /* Iden3PaymentRailsERC20RequestV1 */ || option.type === "Iden3PaymentRailsSolanaSPLRequestV1" /* Iden3PaymentRailsSolanaSPLRequestV1 */) && !option.contractAddress) {
|
|
8259
8633
|
throw new Error(`failed request. no token address for option id ${optionId}`);
|
|
8260
8634
|
}
|
|
8261
8635
|
const expirationDateRequired = expirationDate ?? new Date((/* @__PURE__ */ new Date()).setHours((/* @__PURE__ */ new Date()).getHours() + 1));
|
|
8262
|
-
|
|
8263
|
-
|
|
8264
|
-
|
|
8265
|
-
|
|
8266
|
-
|
|
8267
|
-
recipient,
|
|
8268
|
-
amount,
|
|
8269
|
-
expirationDate: getUnixTimestamp5(expirationDateRequired),
|
|
8270
|
-
nonce,
|
|
8271
|
-
metadata: "0x"
|
|
8272
|
-
} : {
|
|
8273
|
-
tokenAddress: option.contractAddress,
|
|
8274
|
-
recipient,
|
|
8275
|
-
amount,
|
|
8276
|
-
expirationDate: getUnixTimestamp5(expirationDateRequired),
|
|
8277
|
-
nonce,
|
|
8278
|
-
metadata: "0x"
|
|
8279
|
-
};
|
|
8280
|
-
const domain = {
|
|
8281
|
-
name: "MCPayment",
|
|
8282
|
-
version: "1.0.0",
|
|
8283
|
-
chainId,
|
|
8284
|
-
verifyingContract: paymentRails
|
|
8285
|
-
};
|
|
8286
|
-
const signature = await signer.signTypedData(domain, types, paymentData);
|
|
8287
|
-
const proof = [
|
|
8288
|
-
{
|
|
8289
|
-
type: "EthereumEip712Signature2021" /* EthereumEip712Signature2021 */,
|
|
8290
|
-
proofPurpose: "assertionMethod",
|
|
8291
|
-
proofValue: signature,
|
|
8292
|
-
verificationMethod: `did:pkh:eip155:${chainId}:${await signer.getAddress()}`,
|
|
8293
|
-
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
8294
|
-
eip712: {
|
|
8295
|
-
types: typeUrl,
|
|
8296
|
-
primaryType: "Iden3PaymentRailsRequestV1",
|
|
8297
|
-
domain
|
|
8298
|
-
}
|
|
8299
|
-
}
|
|
8300
|
-
];
|
|
8301
|
-
const d = {
|
|
8302
|
-
type: "Iden3PaymentRailsRequestV1" /* Iden3PaymentRailsRequestV1 */,
|
|
8303
|
-
"@context": [
|
|
8304
|
-
`https://schema.iden3.io/core/jsonld/payment.jsonld#${option.type}`,
|
|
8305
|
-
"https://w3id.org/security/suites/eip712sig-2021/v1"
|
|
8306
|
-
],
|
|
8307
|
-
recipient,
|
|
8308
|
-
amount: amount.toString(),
|
|
8309
|
-
expirationDate: expirationDateRequired.toISOString(),
|
|
8310
|
-
nonce: nonce.toString(),
|
|
8311
|
-
metadata: "0x",
|
|
8312
|
-
proof
|
|
8313
|
-
};
|
|
8314
|
-
dataArr.push(
|
|
8315
|
-
option.type === "Iden3PaymentRailsRequestV1" /* Iden3PaymentRailsRequestV1 */ ? d : {
|
|
8316
|
-
...d,
|
|
8317
|
-
type: option.type,
|
|
8318
|
-
tokenAddress: option.contractAddress || "",
|
|
8319
|
-
features: option.features || []
|
|
8636
|
+
if (option.type === "Iden3PaymentRailsSolanaRequestV1" /* Iden3PaymentRailsSolanaRequestV1 */ || option.type === "Iden3PaymentRailsSolanaSPLRequestV1" /* Iden3PaymentRailsSolanaSPLRequestV1 */) {
|
|
8637
|
+
if (!createOptions?.solSigner) {
|
|
8638
|
+
throw new Error(
|
|
8639
|
+
`please provide solana signer in context for ${option.type} payment type`
|
|
8640
|
+
);
|
|
8320
8641
|
}
|
|
8321
|
-
|
|
8642
|
+
const payment = await buildSolanaPayment(
|
|
8643
|
+
createOptions.solSigner,
|
|
8644
|
+
option,
|
|
8645
|
+
chainId,
|
|
8646
|
+
paymentRails,
|
|
8647
|
+
recipient,
|
|
8648
|
+
BigInt(amount),
|
|
8649
|
+
expirationDateRequired,
|
|
8650
|
+
nonce
|
|
8651
|
+
);
|
|
8652
|
+
dataArr.push(payment);
|
|
8653
|
+
} else {
|
|
8654
|
+
const payment = await buildEvmPayment(
|
|
8655
|
+
signer,
|
|
8656
|
+
option,
|
|
8657
|
+
chainId,
|
|
8658
|
+
paymentRails,
|
|
8659
|
+
recipient,
|
|
8660
|
+
BigInt(amount),
|
|
8661
|
+
expirationDateRequired,
|
|
8662
|
+
nonce
|
|
8663
|
+
);
|
|
8664
|
+
dataArr.push(payment);
|
|
8665
|
+
}
|
|
8322
8666
|
}
|
|
8323
8667
|
paymentRequestInfo.push({
|
|
8324
8668
|
data: dataArr,
|
|
@@ -8372,6 +8716,55 @@ var PaymentHandler = class extends AbstractMessageHandler {
|
|
|
8372
8716
|
}
|
|
8373
8717
|
};
|
|
8374
8718
|
}
|
|
8719
|
+
async handleIden3PaymentRailsSolanaRequestV1(data, paymentHandler) {
|
|
8720
|
+
if (data.expirationDate && new Date(data.expirationDate) < /* @__PURE__ */ new Date()) {
|
|
8721
|
+
throw new Error(`failed request. expired request`);
|
|
8722
|
+
}
|
|
8723
|
+
const isValid = await verifyIden3SolanaPaymentRequest(data, this._params.documentResolver);
|
|
8724
|
+
if (!isValid) {
|
|
8725
|
+
throw new Error(`failed request. invalid Solana payment request signature`);
|
|
8726
|
+
}
|
|
8727
|
+
const proof = Array.isArray(data.proof) ? data.proof[0] : data.proof;
|
|
8728
|
+
const signer = proof.verificationMethod.split(":").slice(-1)[0];
|
|
8729
|
+
if (this._params.allowedSigners && !this._params.allowedSigners.includes(signer)) {
|
|
8730
|
+
throw new Error(`failed request. signer is not in the allowed signers list`);
|
|
8731
|
+
}
|
|
8732
|
+
const txId = await paymentHandler(data);
|
|
8733
|
+
return {
|
|
8734
|
+
nonce: data.nonce,
|
|
8735
|
+
type: "Iden3PaymentRailsSolanaV1" /* Iden3PaymentRailsSolanaV1 */,
|
|
8736
|
+
"@context": "https://schema.iden3.io/core/jsonld/payment.jsonld#Iden3PaymentRailsSolanaV1",
|
|
8737
|
+
paymentData: {
|
|
8738
|
+
txId,
|
|
8739
|
+
chainId: proof.domain.chainId
|
|
8740
|
+
}
|
|
8741
|
+
};
|
|
8742
|
+
}
|
|
8743
|
+
async handleIden3PaymentRailsSolanaSPLRequestV1(data, paymentHandler) {
|
|
8744
|
+
if (data.expirationDate && new Date(data.expirationDate) < /* @__PURE__ */ new Date()) {
|
|
8745
|
+
throw new Error(`failed request. expired request`);
|
|
8746
|
+
}
|
|
8747
|
+
const isValid = await verifyIden3SolanaPaymentRequest(data, this._params.documentResolver);
|
|
8748
|
+
if (!isValid) {
|
|
8749
|
+
throw new Error(`failed request. invalid Solana payment request signature`);
|
|
8750
|
+
}
|
|
8751
|
+
const proof = Array.isArray(data.proof) ? data.proof[0] : data.proof;
|
|
8752
|
+
const signer = proof.verificationMethod.split(":").slice(-1)[0];
|
|
8753
|
+
if (this._params.allowedSigners && !this._params.allowedSigners.includes(signer)) {
|
|
8754
|
+
throw new Error(`failed request. signer is not in the allowed signers list`);
|
|
8755
|
+
}
|
|
8756
|
+
const txId = await paymentHandler(data);
|
|
8757
|
+
return {
|
|
8758
|
+
nonce: data.nonce,
|
|
8759
|
+
type: "Iden3PaymentRailsSolanaSPLV1" /* Iden3PaymentRailsSolanaSPLV1 */,
|
|
8760
|
+
"@context": "https://schema.iden3.io/core/jsonld/payment.jsonld#Iden3PaymentRailsSolanaSPLV1",
|
|
8761
|
+
paymentData: {
|
|
8762
|
+
txId,
|
|
8763
|
+
chainId: proof.domain.chainId,
|
|
8764
|
+
tokenAddress: data.tokenAddress
|
|
8765
|
+
}
|
|
8766
|
+
};
|
|
8767
|
+
}
|
|
8375
8768
|
async handleIden3PaymentRailsERC20RequestV1(data, paymentHandler, approveHandler) {
|
|
8376
8769
|
if (data.expirationDate && new Date(data.expirationDate) < /* @__PURE__ */ new Date()) {
|
|
8377
8770
|
throw new Error(`failed request. expired request`);
|
|
@@ -8403,7 +8796,7 @@ var PaymentHandler = class extends AbstractMessageHandler {
|
|
|
8403
8796
|
|
|
8404
8797
|
// src/iden3comm/handlers/discovery-protocol.ts
|
|
8405
8798
|
import * as uuid10 from "uuid";
|
|
8406
|
-
import { getUnixTimestamp as
|
|
8799
|
+
import { getUnixTimestamp as getUnixTimestamp8 } from "@iden3/js-iden3-core";
|
|
8407
8800
|
function createDiscoveryFeatureQueryMessage(queries, opts) {
|
|
8408
8801
|
const uuidv4 = uuid10.v4();
|
|
8409
8802
|
return {
|
|
@@ -8416,7 +8809,7 @@ function createDiscoveryFeatureQueryMessage(queries, opts) {
|
|
|
8416
8809
|
},
|
|
8417
8810
|
from: opts?.from,
|
|
8418
8811
|
to: opts?.to,
|
|
8419
|
-
created_time:
|
|
8812
|
+
created_time: getUnixTimestamp8(/* @__PURE__ */ new Date()),
|
|
8420
8813
|
expires_time: opts?.expires_time
|
|
8421
8814
|
};
|
|
8422
8815
|
}
|
|
@@ -8432,7 +8825,7 @@ function createDiscoveryFeatureDiscloseMessage(disclosures, opts) {
|
|
|
8432
8825
|
},
|
|
8433
8826
|
from: opts?.from,
|
|
8434
8827
|
to: opts?.to,
|
|
8435
|
-
created_time:
|
|
8828
|
+
created_time: getUnixTimestamp8(/* @__PURE__ */ new Date()),
|
|
8436
8829
|
expires_time: opts?.expires_time
|
|
8437
8830
|
};
|
|
8438
8831
|
}
|
|
@@ -8485,7 +8878,7 @@ var DiscoveryProtocolHandler = class extends AbstractMessageHandler {
|
|
|
8485
8878
|
createDiscoveryFeatureDiscloseMessage(disclosures, {
|
|
8486
8879
|
to: message.from,
|
|
8487
8880
|
from: message.to,
|
|
8488
|
-
expires_time: opts?.disclosureExpiresDate ?
|
|
8881
|
+
expires_time: opts?.disclosureExpiresDate ? getUnixTimestamp8(opts.disclosureExpiresDate) : void 0
|
|
8489
8882
|
})
|
|
8490
8883
|
);
|
|
8491
8884
|
}
|
|
@@ -11888,7 +12281,7 @@ var NativeProver = class _NativeProver {
|
|
|
11888
12281
|
import { getDocumentLoader as getDocumentLoader3 } from "@iden3/js-jsonld-merklization";
|
|
11889
12282
|
|
|
11890
12283
|
// src/proof/provers/inputs-generator.ts
|
|
11891
|
-
import { DID as DID23, getUnixTimestamp as
|
|
12284
|
+
import { DID as DID23, getUnixTimestamp as getUnixTimestamp9 } from "@iden3/js-iden3-core";
|
|
11892
12285
|
var allOperations2 = Object.values(QueryOperators);
|
|
11893
12286
|
var v2Operations = [
|
|
11894
12287
|
0 /* NOOP */,
|
|
@@ -12036,7 +12429,7 @@ var InputGenerator = class {
|
|
|
12036
12429
|
incProof: { proof: circuitClaimData.proof, treeState: circuitClaimData.treeState },
|
|
12037
12430
|
nonRevProof: circuitClaimData.nonRevProof
|
|
12038
12431
|
};
|
|
12039
|
-
circuitInputs.currentTimeStamp =
|
|
12432
|
+
circuitInputs.currentTimeStamp = getUnixTimestamp9(/* @__PURE__ */ new Date());
|
|
12040
12433
|
circuitInputs.claimSubjectProfileNonce = BigInt(params.credentialSubjectProfileNonce);
|
|
12041
12434
|
circuitInputs.profileNonce = BigInt(params.authProfileNonce);
|
|
12042
12435
|
circuitInputs.skipClaimRevocationCheck = params.skipRevocation;
|
|
@@ -12092,7 +12485,7 @@ var InputGenerator = class {
|
|
|
12092
12485
|
incProof: { proof: circuitClaimData.proof, treeState: circuitClaimData.treeState },
|
|
12093
12486
|
nonRevProof: circuitClaimData.nonRevProof
|
|
12094
12487
|
};
|
|
12095
|
-
circuitInputs.currentTimeStamp =
|
|
12488
|
+
circuitInputs.currentTimeStamp = getUnixTimestamp9(/* @__PURE__ */ new Date());
|
|
12096
12489
|
circuitInputs.claimSubjectProfileNonce = BigInt(params.credentialSubjectProfileNonce);
|
|
12097
12490
|
circuitInputs.profileNonce = BigInt(params.authProfileNonce);
|
|
12098
12491
|
circuitInputs.skipClaimRevocationCheck = params.skipRevocation;
|
|
@@ -12123,7 +12516,7 @@ var InputGenerator = class {
|
|
|
12123
12516
|
const query = circuitQueries[0];
|
|
12124
12517
|
query.operator = this.transformV2QueryOperator(query.operator);
|
|
12125
12518
|
circuitInputs.query = query;
|
|
12126
|
-
circuitInputs.currentTimeStamp =
|
|
12519
|
+
circuitInputs.currentTimeStamp = getUnixTimestamp9(/* @__PURE__ */ new Date());
|
|
12127
12520
|
this.checkOperatorSupport(proofReq.circuitId, query.operator);
|
|
12128
12521
|
return circuitInputs.inputsMarshal();
|
|
12129
12522
|
};
|
|
@@ -12156,7 +12549,7 @@ var InputGenerator = class {
|
|
|
12156
12549
|
circuitInputs.skipClaimRevocationCheck = params.skipRevocation;
|
|
12157
12550
|
const query = circuitQueries[0];
|
|
12158
12551
|
circuitInputs.query = query;
|
|
12159
|
-
circuitInputs.currentTimeStamp =
|
|
12552
|
+
circuitInputs.currentTimeStamp = getUnixTimestamp9(/* @__PURE__ */ new Date());
|
|
12160
12553
|
if (authClaimData.treeState) {
|
|
12161
12554
|
circuitInputs.treeState = {
|
|
12162
12555
|
state: authClaimData.treeState?.state,
|
|
@@ -12226,7 +12619,7 @@ var InputGenerator = class {
|
|
|
12226
12619
|
const query = circuitQueries[0];
|
|
12227
12620
|
query.values = [16 /* SD */, 0 /* NOOP */].includes(query.operator) ? [] : query.values;
|
|
12228
12621
|
circuitInputs.query = query;
|
|
12229
|
-
circuitInputs.currentTimeStamp =
|
|
12622
|
+
circuitInputs.currentTimeStamp = getUnixTimestamp9(/* @__PURE__ */ new Date());
|
|
12230
12623
|
circuitInputs.proofType = proofType;
|
|
12231
12624
|
circuitInputs.linkNonce = params.linkNonce ?? BigInt(0);
|
|
12232
12625
|
circuitInputs.verifierID = params.verifierDid ? DID23.idFromDID(params.verifierDid) : void 0;
|
|
@@ -12278,7 +12671,7 @@ var InputGenerator = class {
|
|
|
12278
12671
|
const query = circuitQueries[0];
|
|
12279
12672
|
query.values = [16 /* SD */, 0 /* NOOP */].includes(query.operator) ? [] : query.values;
|
|
12280
12673
|
circuitInputs.query = query;
|
|
12281
|
-
circuitInputs.currentTimeStamp =
|
|
12674
|
+
circuitInputs.currentTimeStamp = getUnixTimestamp9(/* @__PURE__ */ new Date());
|
|
12282
12675
|
circuitInputs.proofType = proofType;
|
|
12283
12676
|
circuitInputs.linkNonce = params.linkNonce ?? BigInt(0);
|
|
12284
12677
|
circuitInputs.verifierID = params.verifierDid ? DID23.idFromDID(params.verifierDid) : void 0;
|
|
@@ -13473,7 +13866,7 @@ var IdentityWallet = class {
|
|
|
13473
13866
|
async createAuthCoreClaim(revNonce, seed) {
|
|
13474
13867
|
const keyId = await this._kms.createKeyFromSeed("BJJ" /* BabyJubJub */, seed);
|
|
13475
13868
|
const pubKeyHex = await this._kms.publicKey(keyId);
|
|
13476
|
-
const pubKey =
|
|
13869
|
+
const pubKey = PublicKey5.newFromHex(pubKeyHex);
|
|
13477
13870
|
const schemaHash = SchemaHash7.authSchemaHash;
|
|
13478
13871
|
const authClaim = Claim9.newClaim(
|
|
13479
13872
|
schemaHash,
|
|
@@ -13485,7 +13878,7 @@ var IdentityWallet = class {
|
|
|
13485
13878
|
}
|
|
13486
13879
|
async createAuthBJJCredential(did, pubKey, authClaim, currentState, revocationOpts) {
|
|
13487
13880
|
const authData = authClaim.getExpirationDate();
|
|
13488
|
-
const expiration = authData ?
|
|
13881
|
+
const expiration = authData ? getUnixTimestamp10(authData) : 0;
|
|
13489
13882
|
const request = {
|
|
13490
13883
|
credentialSchema: VerifiableConstants.AUTH.AUTH_BJJ_CREDENTIAL_SCHEMA_JSON_URL,
|
|
13491
13884
|
type: VerifiableConstants.AUTH.AUTH_BJJ_CREDENTIAL_TYPE,
|
|
@@ -14350,9 +14743,16 @@ export {
|
|
|
14350
14743
|
RefreshServiceType,
|
|
14351
14744
|
RevocationStatusHandler,
|
|
14352
14745
|
SDK_EVENTS,
|
|
14746
|
+
SOLANA_CHAIN_REF,
|
|
14353
14747
|
Scalar,
|
|
14354
14748
|
SearchError,
|
|
14355
14749
|
Sec256k1Provider,
|
|
14750
|
+
SolanaNativePaymentRequest,
|
|
14751
|
+
SolanaNativePaymentSchema,
|
|
14752
|
+
SolanaPaymentInstruction,
|
|
14753
|
+
SolanaPaymentInstructionSchema,
|
|
14754
|
+
SolanaSplPaymentRequest,
|
|
14755
|
+
SolanaSplPaymentSchema,
|
|
14356
14756
|
StandardJSONCredentialsQueryFilter,
|
|
14357
14757
|
StateTransitionInputs,
|
|
14358
14758
|
StateTransitionPubSignals,
|
|
@@ -14376,7 +14776,9 @@ export {
|
|
|
14376
14776
|
bigIntCompare,
|
|
14377
14777
|
buildAccept,
|
|
14378
14778
|
buildDIDFromEthPubKey,
|
|
14779
|
+
buildEvmPayment,
|
|
14379
14780
|
buildFieldPath,
|
|
14781
|
+
buildSolanaPayment,
|
|
14380
14782
|
buildTreeState,
|
|
14381
14783
|
buildVerifierId,
|
|
14382
14784
|
byteDecoder,
|
|
@@ -14474,6 +14876,7 @@ export {
|
|
|
14474
14876
|
resolveDidDocument,
|
|
14475
14877
|
resolvePath,
|
|
14476
14878
|
resolveVerificationMethods,
|
|
14879
|
+
serializeSolanaPaymentInstruction,
|
|
14477
14880
|
strMTHex,
|
|
14478
14881
|
stringByPath,
|
|
14479
14882
|
subjectPositionIndex,
|
|
@@ -14495,6 +14898,7 @@ export {
|
|
|
14495
14898
|
verifyExpiresTime,
|
|
14496
14899
|
verifyFieldValueInclusionNativeExistsSupport,
|
|
14497
14900
|
verifyFieldValueInclusionV2,
|
|
14901
|
+
verifyIden3SolanaPaymentRequest,
|
|
14498
14902
|
witnessBuilder
|
|
14499
14903
|
};
|
|
14500
14904
|
//# sourceMappingURL=index.js.map
|