@mocanetwork/privado-js-sdk 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +75 -0
- package/dist/browser/esm/index.js +14901 -0
- package/dist/browser/esm/index.js.map +1 -0
- package/dist/browser/umd/index.global.js +678 -0
- package/dist/browser/umd/index.global.js.map +1 -0
- package/dist/node/cjs/index.cjs +15418 -0
- package/dist/node/cjs/index.cjs.map +1 -0
- package/dist/node/esm/index.js +14901 -0
- package/dist/node/esm/index.js.map +1 -0
- package/dist/types/blockchain/index.d.ts +2 -0
- package/dist/types/blockchain/index.d.ts.map +1 -0
- package/dist/types/blockchain/transaction-service.d.ts +81 -0
- package/dist/types/blockchain/transaction-service.d.ts.map +1 -0
- package/dist/types/circuits/atomic-query-mtp-v2-on-chain.d.ts +70 -0
- package/dist/types/circuits/atomic-query-mtp-v2-on-chain.d.ts.map +1 -0
- package/dist/types/circuits/atomic-query-mtp-v2.d.ts +63 -0
- package/dist/types/circuits/atomic-query-mtp-v2.d.ts.map +1 -0
- package/dist/types/circuits/atomic-query-sig-v2-on-chain.d.ts +137 -0
- package/dist/types/circuits/atomic-query-sig-v2-on-chain.d.ts.map +1 -0
- package/dist/types/circuits/atomic-query-sig-v2.d.ts +64 -0
- package/dist/types/circuits/atomic-query-sig-v2.d.ts.map +1 -0
- package/dist/types/circuits/atomic-query-v3-on-chain.d.ts +141 -0
- package/dist/types/circuits/atomic-query-v3-on-chain.d.ts.map +1 -0
- package/dist/types/circuits/atomic-query-v3.d.ts +121 -0
- package/dist/types/circuits/atomic-query-v3.d.ts.map +1 -0
- package/dist/types/circuits/auth-v2.d.ts +46 -0
- package/dist/types/circuits/auth-v2.d.ts.map +1 -0
- package/dist/types/circuits/common.d.ts +153 -0
- package/dist/types/circuits/common.d.ts.map +1 -0
- package/dist/types/circuits/comparer.d.ts +122 -0
- package/dist/types/circuits/comparer.d.ts.map +1 -0
- package/dist/types/circuits/index.d.ts +13 -0
- package/dist/types/circuits/index.d.ts.map +1 -0
- package/dist/types/circuits/linked-multi-query.d.ts +38 -0
- package/dist/types/circuits/linked-multi-query.d.ts.map +1 -0
- package/dist/types/circuits/models.d.ts +189 -0
- package/dist/types/circuits/models.d.ts.map +1 -0
- package/dist/types/circuits/state-transition.d.ts +49 -0
- package/dist/types/circuits/state-transition.d.ts.map +1 -0
- package/dist/types/credentials/credential-wallet.d.ts +200 -0
- package/dist/types/credentials/credential-wallet.d.ts.map +1 -0
- package/dist/types/credentials/index.d.ts +12 -0
- package/dist/types/credentials/index.d.ts.map +1 -0
- package/dist/types/credentials/models.d.ts +84 -0
- package/dist/types/credentials/models.d.ts.map +1 -0
- package/dist/types/credentials/rhs.d.ts +38 -0
- package/dist/types/credentials/rhs.d.ts.map +1 -0
- package/dist/types/credentials/status/agent-revocation.d.ts +20 -0
- package/dist/types/credentials/status/agent-revocation.d.ts.map +1 -0
- package/dist/types/credentials/status/credential-status-publisher.d.ts +73 -0
- package/dist/types/credentials/status/credential-status-publisher.d.ts.map +1 -0
- package/dist/types/credentials/status/did-resolver-revocation.d.ts +8 -0
- package/dist/types/credentials/status/did-resolver-revocation.d.ts.map +1 -0
- package/dist/types/credentials/status/on-chain-revocation.d.ts +58 -0
- package/dist/types/credentials/status/on-chain-revocation.d.ts.map +1 -0
- package/dist/types/credentials/status/resolver.d.ts +69 -0
- package/dist/types/credentials/status/resolver.d.ts.map +1 -0
- package/dist/types/credentials/status/reverse-sparse-merkle-tree.d.ts +126 -0
- package/dist/types/credentials/status/reverse-sparse-merkle-tree.d.ts.map +1 -0
- package/dist/types/credentials/status/sparse-merkle-tree.d.ts +38 -0
- package/dist/types/credentials/status/sparse-merkle-tree.d.ts.map +1 -0
- package/dist/types/credentials/utils.d.ts +15 -0
- package/dist/types/credentials/utils.d.ts.map +1 -0
- package/dist/types/iden3comm/constants.d.ts +61 -0
- package/dist/types/iden3comm/constants.d.ts.map +1 -0
- package/dist/types/iden3comm/errors.d.ts +10 -0
- package/dist/types/iden3comm/errors.d.ts.map +1 -0
- package/dist/types/iden3comm/handlers/auth.d.ts +157 -0
- package/dist/types/iden3comm/handlers/auth.d.ts.map +1 -0
- package/dist/types/iden3comm/handlers/common.d.ts +72 -0
- package/dist/types/iden3comm/handlers/common.d.ts.map +1 -0
- package/dist/types/iden3comm/handlers/contract-request.d.ts +96 -0
- package/dist/types/iden3comm/handlers/contract-request.d.ts.map +1 -0
- package/dist/types/iden3comm/handlers/credential-proposal.d.ts +120 -0
- package/dist/types/iden3comm/handlers/credential-proposal.d.ts.map +1 -0
- package/dist/types/iden3comm/handlers/discovery-protocol.d.ts +101 -0
- package/dist/types/iden3comm/handlers/discovery-protocol.d.ts.map +1 -0
- package/dist/types/iden3comm/handlers/fetch.d.ts +130 -0
- package/dist/types/iden3comm/handlers/fetch.d.ts.map +1 -0
- package/dist/types/iden3comm/handlers/index.d.ts +12 -0
- package/dist/types/iden3comm/handlers/index.d.ts.map +1 -0
- package/dist/types/iden3comm/handlers/message-handler.d.ts +93 -0
- package/dist/types/iden3comm/handlers/message-handler.d.ts.map +1 -0
- package/dist/types/iden3comm/handlers/payment.d.ts +167 -0
- package/dist/types/iden3comm/handlers/payment.d.ts.map +1 -0
- package/dist/types/iden3comm/handlers/problem-report.d.ts +18 -0
- package/dist/types/iden3comm/handlers/problem-report.d.ts.map +1 -0
- package/dist/types/iden3comm/handlers/refresh.d.ts +57 -0
- package/dist/types/iden3comm/handlers/refresh.d.ts.map +1 -0
- package/dist/types/iden3comm/handlers/revocation-status.d.ts +76 -0
- package/dist/types/iden3comm/handlers/revocation-status.d.ts.map +1 -0
- package/dist/types/iden3comm/index.d.ts +9 -0
- package/dist/types/iden3comm/index.d.ts.map +1 -0
- package/dist/types/iden3comm/packageManager.d.ts +47 -0
- package/dist/types/iden3comm/packageManager.d.ts.map +1 -0
- package/dist/types/iden3comm/packers/index.d.ts +4 -0
- package/dist/types/iden3comm/packers/index.d.ts.map +1 -0
- package/dist/types/iden3comm/packers/jws.d.ts +56 -0
- package/dist/types/iden3comm/packers/jws.d.ts.map +1 -0
- package/dist/types/iden3comm/packers/plain.d.ts +47 -0
- package/dist/types/iden3comm/packers/plain.d.ts.map +1 -0
- package/dist/types/iden3comm/packers/zkp.d.ts +98 -0
- package/dist/types/iden3comm/packers/zkp.d.ts.map +1 -0
- package/dist/types/iden3comm/types/index.d.ts +17 -0
- package/dist/types/iden3comm/types/index.d.ts.map +1 -0
- package/dist/types/iden3comm/types/models.d.ts +7 -0
- package/dist/types/iden3comm/types/models.d.ts.map +1 -0
- package/dist/types/iden3comm/types/packageManager.d.ts +100 -0
- package/dist/types/iden3comm/types/packageManager.d.ts.map +1 -0
- package/dist/types/iden3comm/types/packer.d.ts +158 -0
- package/dist/types/iden3comm/types/packer.d.ts.map +1 -0
- package/dist/types/iden3comm/types/protocol/accept-profile.d.ts +8 -0
- package/dist/types/iden3comm/types/protocol/accept-profile.d.ts.map +1 -0
- package/dist/types/iden3comm/types/protocol/attachment.d.ts +11 -0
- package/dist/types/iden3comm/types/protocol/attachment.d.ts.map +1 -0
- package/dist/types/iden3comm/types/protocol/auth.d.ts +90 -0
- package/dist/types/iden3comm/types/protocol/auth.d.ts.map +1 -0
- package/dist/types/iden3comm/types/protocol/common.d.ts +11 -0
- package/dist/types/iden3comm/types/protocol/common.d.ts.map +1 -0
- package/dist/types/iden3comm/types/protocol/contract-request.d.ts +62 -0
- package/dist/types/iden3comm/types/protocol/contract-request.d.ts.map +1 -0
- package/dist/types/iden3comm/types/protocol/credentials.d.ts +82 -0
- package/dist/types/iden3comm/types/protocol/credentials.d.ts.map +1 -0
- package/dist/types/iden3comm/types/protocol/discovery-protocol.d.ts +42 -0
- package/dist/types/iden3comm/types/protocol/discovery-protocol.d.ts.map +1 -0
- package/dist/types/iden3comm/types/protocol/messages.d.ts +12 -0
- package/dist/types/iden3comm/types/protocol/messages.d.ts.map +1 -0
- package/dist/types/iden3comm/types/protocol/payment.d.ts +178 -0
- package/dist/types/iden3comm/types/protocol/payment.d.ts.map +1 -0
- package/dist/types/iden3comm/types/protocol/problem-report.d.ts +17 -0
- package/dist/types/iden3comm/types/protocol/problem-report.d.ts.map +1 -0
- package/dist/types/iden3comm/types/protocol/proof.d.ts +22 -0
- package/dist/types/iden3comm/types/protocol/proof.d.ts.map +1 -0
- package/dist/types/iden3comm/types/protocol/proposal-request.d.ts +33 -0
- package/dist/types/iden3comm/types/protocol/proposal-request.d.ts.map +1 -0
- package/dist/types/iden3comm/types/protocol/revocation.d.ts +20 -0
- package/dist/types/iden3comm/types/protocol/revocation.d.ts.map +1 -0
- package/dist/types/iden3comm/utils/accept-profile.d.ts +4 -0
- package/dist/types/iden3comm/utils/accept-profile.d.ts.map +1 -0
- package/dist/types/iden3comm/utils/did.d.ts +8 -0
- package/dist/types/iden3comm/utils/did.d.ts.map +1 -0
- package/dist/types/iden3comm/utils/envelope.d.ts +32 -0
- package/dist/types/iden3comm/utils/envelope.d.ts.map +1 -0
- package/dist/types/iden3comm/utils/index.d.ts +5 -0
- package/dist/types/iden3comm/utils/index.d.ts.map +1 -0
- package/dist/types/iden3comm/utils/message.d.ts +20 -0
- package/dist/types/iden3comm/utils/message.d.ts.map +1 -0
- package/dist/types/identity/common.d.ts +27 -0
- package/dist/types/identity/common.d.ts.map +1 -0
- package/dist/types/identity/identity-wallet.d.ts +472 -0
- package/dist/types/identity/identity-wallet.d.ts.map +1 -0
- package/dist/types/identity/index.d.ts +3 -0
- package/dist/types/identity/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +17 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/kms/index.d.ts +5 -0
- package/dist/types/kms/index.d.ts.map +1 -0
- package/dist/types/kms/key-providers/bjj-provider.d.ts +54 -0
- package/dist/types/kms/key-providers/bjj-provider.d.ts.map +1 -0
- package/dist/types/kms/key-providers/ed25519-provider.d.ts +61 -0
- package/dist/types/kms/key-providers/ed25519-provider.d.ts.map +1 -0
- package/dist/types/kms/key-providers/index.d.ts +4 -0
- package/dist/types/kms/key-providers/index.d.ts.map +1 -0
- package/dist/types/kms/key-providers/secp256k1-provider.d.ts +62 -0
- package/dist/types/kms/key-providers/secp256k1-provider.d.ts.map +1 -0
- package/dist/types/kms/kms.d.ts +120 -0
- package/dist/types/kms/kms.d.ts.map +1 -0
- package/dist/types/kms/provider-helpers.d.ts +10 -0
- package/dist/types/kms/provider-helpers.d.ts.map +1 -0
- package/dist/types/kms/store/abstract-key-store.d.ts +41 -0
- package/dist/types/kms/store/abstract-key-store.d.ts.map +1 -0
- package/dist/types/kms/store/index.d.ts +6 -0
- package/dist/types/kms/store/index.d.ts.map +1 -0
- package/dist/types/kms/store/indexed-db-key-store.d.ts +44 -0
- package/dist/types/kms/store/indexed-db-key-store.d.ts.map +1 -0
- package/dist/types/kms/store/local-storage-key-store.d.ts +42 -0
- package/dist/types/kms/store/local-storage-key-store.d.ts.map +1 -0
- package/dist/types/kms/store/memory-key-store.d.ts +24 -0
- package/dist/types/kms/store/memory-key-store.d.ts.map +1 -0
- package/dist/types/kms/store/types.d.ts +21 -0
- package/dist/types/kms/store/types.d.ts.map +1 -0
- package/dist/types/proof/common.d.ts +49 -0
- package/dist/types/proof/common.d.ts.map +1 -0
- package/dist/types/proof/index.d.ts +5 -0
- package/dist/types/proof/index.d.ts.map +1 -0
- package/dist/types/proof/proof-service.d.ts +169 -0
- package/dist/types/proof/proof-service.d.ts.map +1 -0
- package/dist/types/proof/provers/index.d.ts +4 -0
- package/dist/types/proof/provers/index.d.ts.map +1 -0
- package/dist/types/proof/provers/inputs-generator.d.ts +57 -0
- package/dist/types/proof/provers/inputs-generator.d.ts.map +1 -0
- package/dist/types/proof/provers/prover.d.ts +56 -0
- package/dist/types/proof/provers/prover.d.ts.map +1 -0
- package/dist/types/proof/provers/witness_calculator.d.ts +17 -0
- package/dist/types/proof/provers/witness_calculator.d.ts.map +1 -0
- package/dist/types/proof/verifiers/index.d.ts +4 -0
- package/dist/types/proof/verifiers/index.d.ts.map +1 -0
- package/dist/types/proof/verifiers/pub-signals-verifier.d.ts +60 -0
- package/dist/types/proof/verifiers/pub-signals-verifier.d.ts.map +1 -0
- package/dist/types/proof/verifiers/query-hash.d.ts +4 -0
- package/dist/types/proof/verifiers/query-hash.d.ts.map +1 -0
- package/dist/types/proof/verifiers/query.d.ts +43 -0
- package/dist/types/proof/verifiers/query.d.ts.map +1 -0
- package/dist/types/schema-processor/index.d.ts +4 -0
- package/dist/types/schema-processor/index.d.ts.map +1 -0
- package/dist/types/schema-processor/json/index.d.ts +3 -0
- package/dist/types/schema-processor/json/index.d.ts.map +1 -0
- package/dist/types/schema-processor/json/parser.d.ts +141 -0
- package/dist/types/schema-processor/json/parser.d.ts.map +1 -0
- package/dist/types/schema-processor/json/validator.d.ts +26 -0
- package/dist/types/schema-processor/json/validator.d.ts.map +1 -0
- package/dist/types/schema-processor/jsonld/cache.d.ts +3 -0
- package/dist/types/schema-processor/jsonld/cache.d.ts.map +1 -0
- package/dist/types/schema-processor/jsonld/index.d.ts +3 -0
- package/dist/types/schema-processor/jsonld/index.d.ts.map +1 -0
- package/dist/types/schema-processor/jsonld/parser.d.ts +30 -0
- package/dist/types/schema-processor/jsonld/parser.d.ts.map +1 -0
- package/dist/types/schema-processor/utils.d.ts +54 -0
- package/dist/types/schema-processor/utils.d.ts.map +1 -0
- package/dist/types/storage/blockchain/common.d.ts +8 -0
- package/dist/types/storage/blockchain/common.d.ts.map +1 -0
- package/dist/types/storage/blockchain/did-resolver-readonly-storage.d.ts +17 -0
- package/dist/types/storage/blockchain/did-resolver-readonly-storage.d.ts.map +1 -0
- package/dist/types/storage/blockchain/erc20-helper.d.ts +20 -0
- package/dist/types/storage/blockchain/erc20-helper.d.ts.map +1 -0
- package/dist/types/storage/blockchain/errors.d.ts +4 -0
- package/dist/types/storage/blockchain/errors.d.ts.map +1 -0
- package/dist/types/storage/blockchain/index.d.ts +8 -0
- package/dist/types/storage/blockchain/index.d.ts.map +1 -0
- package/dist/types/storage/blockchain/onchain-issuer-adapter/non-merklized/version/v0.0.1/onchain-non-merklized-issuer-adapter.d.ts +67 -0
- package/dist/types/storage/blockchain/onchain-issuer-adapter/non-merklized/version/v0.0.1/onchain-non-merklized-issuer-adapter.d.ts.map +1 -0
- package/dist/types/storage/blockchain/onchain-issuer.d.ts +41 -0
- package/dist/types/storage/blockchain/onchain-issuer.d.ts.map +1 -0
- package/dist/types/storage/blockchain/onchain-revocation.d.ts +41 -0
- package/dist/types/storage/blockchain/onchain-revocation.d.ts.map +1 -0
- package/dist/types/storage/blockchain/onchain-zkp-verifier.d.ts +116 -0
- package/dist/types/storage/blockchain/onchain-zkp-verifier.d.ts.map +1 -0
- package/dist/types/storage/blockchain/state.d.ts +127 -0
- package/dist/types/storage/blockchain/state.d.ts.map +1 -0
- package/dist/types/storage/entities/circuitData.d.ts +8 -0
- package/dist/types/storage/entities/circuitData.d.ts.map +1 -0
- package/dist/types/storage/entities/identity.d.ts +17 -0
- package/dist/types/storage/entities/identity.d.ts.map +1 -0
- package/dist/types/storage/entities/index.d.ts +5 -0
- package/dist/types/storage/entities/index.d.ts.map +1 -0
- package/dist/types/storage/entities/mt.d.ts +22 -0
- package/dist/types/storage/entities/mt.d.ts.map +1 -0
- package/dist/types/storage/entities/state.d.ts +92 -0
- package/dist/types/storage/entities/state.d.ts.map +1 -0
- package/dist/types/storage/errors.d.ts +9 -0
- package/dist/types/storage/errors.d.ts.map +1 -0
- package/dist/types/storage/filters/index.d.ts +2 -0
- package/dist/types/storage/filters/index.d.ts.map +1 -0
- package/dist/types/storage/filters/jsonQuery.d.ts +83 -0
- package/dist/types/storage/filters/jsonQuery.d.ts.map +1 -0
- package/dist/types/storage/fs/circuits-storage.d.ts +64 -0
- package/dist/types/storage/fs/circuits-storage.d.ts.map +1 -0
- package/dist/types/storage/fs/index.d.ts +2 -0
- package/dist/types/storage/fs/index.d.ts.map +1 -0
- package/dist/types/storage/index.d.ts +10 -0
- package/dist/types/storage/index.d.ts.map +1 -0
- package/dist/types/storage/indexed-db/data-source.d.ts +44 -0
- package/dist/types/storage/indexed-db/data-source.d.ts.map +1 -0
- package/dist/types/storage/indexed-db/index.d.ts +3 -0
- package/dist/types/storage/indexed-db/index.d.ts.map +1 -0
- package/dist/types/storage/indexed-db/merkletree.d.ts +43 -0
- package/dist/types/storage/indexed-db/merkletree.d.ts.map +1 -0
- package/dist/types/storage/interfaces/circuits.d.ts +26 -0
- package/dist/types/storage/interfaces/circuits.d.ts.map +1 -0
- package/dist/types/storage/interfaces/credentials.d.ts +53 -0
- package/dist/types/storage/interfaces/credentials.d.ts.map +1 -0
- package/dist/types/storage/interfaces/data-source.d.ts +39 -0
- package/dist/types/storage/interfaces/data-source.d.ts.map +1 -0
- package/dist/types/storage/interfaces/data-storage.d.ts +17 -0
- package/dist/types/storage/interfaces/data-storage.d.ts.map +1 -0
- package/dist/types/storage/interfaces/identity.d.ts +70 -0
- package/dist/types/storage/interfaces/identity.d.ts.map +1 -0
- package/dist/types/storage/interfaces/index.d.ts +11 -0
- package/dist/types/storage/interfaces/index.d.ts.map +1 -0
- package/dist/types/storage/interfaces/merkletree.d.ts +44 -0
- package/dist/types/storage/interfaces/merkletree.d.ts.map +1 -0
- package/dist/types/storage/interfaces/onchain-issuer.d.ts +13 -0
- package/dist/types/storage/interfaces/onchain-issuer.d.ts.map +1 -0
- package/dist/types/storage/interfaces/onchain-revocation.d.ts +19 -0
- package/dist/types/storage/interfaces/onchain-revocation.d.ts.map +1 -0
- package/dist/types/storage/interfaces/onchain-zkp-verifier.d.ts +63 -0
- package/dist/types/storage/interfaces/onchain-zkp-verifier.d.ts.map +1 -0
- package/dist/types/storage/interfaces/state.d.ts +74 -0
- package/dist/types/storage/interfaces/state.d.ts.map +1 -0
- package/dist/types/storage/local-storage/data-source.d.ts +41 -0
- package/dist/types/storage/local-storage/data-source.d.ts.map +1 -0
- package/dist/types/storage/local-storage/index.d.ts +3 -0
- package/dist/types/storage/local-storage/index.d.ts.map +1 -0
- package/dist/types/storage/local-storage/merkletree.d.ts +41 -0
- package/dist/types/storage/local-storage/merkletree.d.ts.map +1 -0
- package/dist/types/storage/memory/cache-lru.d.ts +11 -0
- package/dist/types/storage/memory/cache-lru.d.ts.map +1 -0
- package/dist/types/storage/memory/data-source.d.ts +20 -0
- package/dist/types/storage/memory/data-source.d.ts.map +1 -0
- package/dist/types/storage/memory/index.d.ts +4 -0
- package/dist/types/storage/memory/index.d.ts.map +1 -0
- package/dist/types/storage/memory/merkletree.d.ts +48 -0
- package/dist/types/storage/memory/merkletree.d.ts.map +1 -0
- package/dist/types/storage/shared/circuit-storage.d.ts +39 -0
- package/dist/types/storage/shared/circuit-storage.d.ts.map +1 -0
- package/dist/types/storage/shared/credential-storage.d.ts +39 -0
- package/dist/types/storage/shared/credential-storage.d.ts.map +1 -0
- package/dist/types/storage/shared/identity-storage.d.ts +45 -0
- package/dist/types/storage/shared/identity-storage.d.ts.map +1 -0
- package/dist/types/storage/shared/index.d.ts +4 -0
- package/dist/types/storage/shared/index.d.ts.map +1 -0
- package/dist/types/storage/utils.d.ts +4 -0
- package/dist/types/storage/utils.d.ts.map +1 -0
- package/dist/types/utils/compare-func.d.ts +2 -0
- package/dist/types/utils/compare-func.d.ts.map +1 -0
- package/dist/types/utils/did-helper.d.ts +38 -0
- package/dist/types/utils/did-helper.d.ts.map +1 -0
- package/dist/types/utils/encoding.d.ts +25 -0
- package/dist/types/utils/encoding.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +8 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/dist/types/utils/message-bus.d.ts +63 -0
- package/dist/types/utils/message-bus.d.ts.map +1 -0
- package/dist/types/utils/object.d.ts +10 -0
- package/dist/types/utils/object.d.ts.map +1 -0
- 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 +188 -0
- package/dist/types/verifiable/constants.d.ts.map +1 -0
- package/dist/types/verifiable/core-utils.d.ts +87 -0
- package/dist/types/verifiable/core-utils.d.ts.map +1 -0
- package/dist/types/verifiable/credential.d.ts +150 -0
- package/dist/types/verifiable/credential.d.ts.map +1 -0
- package/dist/types/verifiable/index.d.ts +7 -0
- package/dist/types/verifiable/index.d.ts.map +1 -0
- package/dist/types/verifiable/presentation.d.ts +11 -0
- package/dist/types/verifiable/presentation.d.ts.map +1 -0
- package/dist/types/verifiable/proof.d.ts +211 -0
- package/dist/types/verifiable/proof.d.ts.map +1 -0
- package/dist/types/verifiable/schema.d.ts +3 -0
- package/dist/types/verifiable/schema.d.ts.map +1 -0
- package/package.json +104 -0
- package/src/blockchain/index.ts +1 -0
- package/src/blockchain/transaction-service.ts +121 -0
- package/src/circuits/atomic-query-mtp-v2-on-chain.ts +338 -0
- package/src/circuits/atomic-query-mtp-v2.ts +283 -0
- package/src/circuits/atomic-query-sig-v2-on-chain.ts +411 -0
- package/src/circuits/atomic-query-sig-v2.ts +340 -0
- package/src/circuits/atomic-query-v3-on-chain.ts +531 -0
- package/src/circuits/atomic-query-v3.ts +461 -0
- package/src/circuits/auth-v2.ts +159 -0
- package/src/circuits/common.ts +261 -0
- package/src/circuits/comparer.ts +227 -0
- package/src/circuits/index.ts +12 -0
- package/src/circuits/linked-multi-query.ts +180 -0
- package/src/circuits/models.ts +263 -0
- package/src/circuits/state-transition.ts +139 -0
- package/src/credentials/credential-wallet.ts +353 -0
- package/src/credentials/index.ts +11 -0
- package/src/credentials/models.ts +93 -0
- package/src/credentials/rhs.ts +176 -0
- package/src/credentials/status/agent-revocation.ts +69 -0
- package/src/credentials/status/credential-status-publisher.ts +143 -0
- package/src/credentials/status/did-resolver-revocation.ts +24 -0
- package/src/credentials/status/on-chain-revocation.ts +174 -0
- package/src/credentials/status/resolver.ts +81 -0
- package/src/credentials/status/reverse-sparse-merkle-tree.ts +366 -0
- package/src/credentials/status/sparse-merkle-tree.ts +50 -0
- package/src/credentials/utils.ts +36 -0
- package/src/iden3comm/constants.ts +119 -0
- package/src/iden3comm/errors.ts +14 -0
- package/src/iden3comm/handlers/auth.ts +520 -0
- package/src/iden3comm/handlers/common.ts +324 -0
- package/src/iden3comm/handlers/contract-request.ts +367 -0
- package/src/iden3comm/handlers/credential-proposal.ts +371 -0
- package/src/iden3comm/handlers/discovery-protocol.ts +277 -0
- package/src/iden3comm/handlers/fetch.ts +450 -0
- package/src/iden3comm/handlers/index.ts +11 -0
- package/src/iden3comm/handlers/message-handler.ts +165 -0
- package/src/iden3comm/handlers/payment.ts +698 -0
- package/src/iden3comm/handlers/problem-report.ts +41 -0
- package/src/iden3comm/handlers/refresh.ts +138 -0
- package/src/iden3comm/handlers/revocation-status.ts +228 -0
- package/src/iden3comm/index.ts +9 -0
- package/src/iden3comm/packageManager.ts +143 -0
- package/src/iden3comm/packers/index.ts +3 -0
- package/src/iden3comm/packers/jws.ts +225 -0
- package/src/iden3comm/packers/plain.ts +86 -0
- package/src/iden3comm/packers/zkp.ts +243 -0
- package/src/iden3comm/types/index.ts +17 -0
- package/src/iden3comm/types/models.ts +7 -0
- package/src/iden3comm/types/packageManager.ts +112 -0
- package/src/iden3comm/types/packer.ts +190 -0
- package/src/iden3comm/types/protocol/accept-profile.ts +14 -0
- package/src/iden3comm/types/protocol/attachment.ts +12 -0
- package/src/iden3comm/types/protocol/auth.ts +104 -0
- package/src/iden3comm/types/protocol/common.ts +10 -0
- package/src/iden3comm/types/protocol/contract-request.ts +76 -0
- package/src/iden3comm/types/protocol/credentials.ts +96 -0
- package/src/iden3comm/types/protocol/discovery-protocol.ts +49 -0
- package/src/iden3comm/types/protocol/messages.ts +13 -0
- package/src/iden3comm/types/protocol/payment.ts +231 -0
- package/src/iden3comm/types/protocol/problem-report.ts +18 -0
- package/src/iden3comm/types/protocol/proof.ts +25 -0
- package/src/iden3comm/types/protocol/proposal-request.ts +38 -0
- package/src/iden3comm/types/protocol/revocation.ts +23 -0
- package/src/iden3comm/utils/accept-profile.ts +121 -0
- package/src/iden3comm/utils/did.ts +71 -0
- package/src/iden3comm/utils/envelope.ts +101 -0
- package/src/iden3comm/utils/index.ts +4 -0
- package/src/iden3comm/utils/message.ts +41 -0
- package/src/identity/common.ts +69 -0
- package/src/identity/identity-wallet.ts +1592 -0
- package/src/identity/index.ts +2 -0
- package/src/index.ts +16 -0
- package/src/kms/index.ts +4 -0
- package/src/kms/key-providers/bjj-provider.ts +118 -0
- package/src/kms/key-providers/ed25519-provider.ts +105 -0
- package/src/kms/key-providers/index.ts +3 -0
- package/src/kms/key-providers/secp256k1-provider.ts +125 -0
- package/src/kms/kms.ts +173 -0
- package/src/kms/provider-helpers.ts +13 -0
- package/src/kms/store/abstract-key-store.ts +34 -0
- package/src/kms/store/index.ts +5 -0
- package/src/kms/store/indexed-db-key-store.ts +60 -0
- package/src/kms/store/local-storage-key-store.ts +69 -0
- package/src/kms/store/memory-key-store.ts +29 -0
- package/src/kms/store/types.ts +21 -0
- package/src/proof/common.ts +273 -0
- package/src/proof/index.ts +4 -0
- package/src/proof/proof-service.ts +623 -0
- package/src/proof/provers/index.ts +3 -0
- package/src/proof/provers/inputs-generator.ts +627 -0
- package/src/proof/provers/prover.ts +104 -0
- package/src/proof/provers/witness_calculator.ts +315 -0
- package/src/proof/verifiers/index.ts +3 -0
- package/src/proof/verifiers/pub-signals-verifier.ts +730 -0
- package/src/proof/verifiers/query-hash.ts +57 -0
- package/src/proof/verifiers/query.ts +340 -0
- package/src/schema-processor/index.ts +3 -0
- package/src/schema-processor/json/index.ts +2 -0
- package/src/schema-processor/json/parser.ts +256 -0
- package/src/schema-processor/json/validator.ts +67 -0
- package/src/schema-processor/jsonld/cache.ts +49 -0
- package/src/schema-processor/jsonld/index.ts +2 -0
- package/src/schema-processor/jsonld/parser.ts +93 -0
- package/src/schema-processor/utils.ts +84 -0
- package/src/storage/blockchain/abi/CredentialStatusResolver.json +1 -0
- package/src/storage/blockchain/abi/ERC20.json +1 -0
- package/src/storage/blockchain/abi/ERC20Permit.json +1 -0
- package/src/storage/blockchain/abi/IdentityBase.json +1 -0
- package/src/storage/blockchain/abi/State.json +1 -0
- package/src/storage/blockchain/abi/ZkpVerifier.json +789 -0
- package/src/storage/blockchain/common.ts +20 -0
- package/src/storage/blockchain/did-resolver-readonly-storage.ts +90 -0
- package/src/storage/blockchain/erc20-helper.ts +66 -0
- package/src/storage/blockchain/errors.ts +46 -0
- package/src/storage/blockchain/index.ts +7 -0
- package/src/storage/blockchain/onchain-issuer-adapter/non-merklized/version/v0.0.1/onchain-non-merklized-issuer-adapter.ts +327 -0
- package/src/storage/blockchain/onchain-issuer.ts +104 -0
- package/src/storage/blockchain/onchain-revocation.ts +143 -0
- package/src/storage/blockchain/onchain-zkp-verifier.ts +704 -0
- package/src/storage/blockchain/state.ts +471 -0
- package/src/storage/entities/circuitData.ts +7 -0
- package/src/storage/entities/identity.ts +18 -0
- package/src/storage/entities/index.ts +4 -0
- package/src/storage/entities/mt.ts +25 -0
- package/src/storage/entities/state.ts +97 -0
- package/src/storage/errors.ts +8 -0
- package/src/storage/filters/index.ts +1 -0
- package/src/storage/filters/jsonQuery.ts +368 -0
- package/src/storage/fs/circuits-storage.ts +149 -0
- package/src/storage/fs/index.ts +1 -0
- package/src/storage/index.ts +9 -0
- package/src/storage/indexed-db/data-source.ts +58 -0
- package/src/storage/indexed-db/index.ts +2 -0
- package/src/storage/indexed-db/merkletree.ts +140 -0
- package/src/storage/interfaces/circuits.ts +27 -0
- package/src/storage/interfaces/credentials.ts +53 -0
- package/src/storage/interfaces/data-source.ts +41 -0
- package/src/storage/interfaces/data-storage.ts +17 -0
- package/src/storage/interfaces/identity.ts +73 -0
- package/src/storage/interfaces/index.ts +10 -0
- package/src/storage/interfaces/merkletree.ts +52 -0
- package/src/storage/interfaces/onchain-issuer.ts +13 -0
- package/src/storage/interfaces/onchain-revocation.ts +22 -0
- package/src/storage/interfaces/onchain-zkp-verifier.ts +94 -0
- package/src/storage/interfaces/state.ts +81 -0
- package/src/storage/local-storage/data-source.ts +87 -0
- package/src/storage/local-storage/index.ts +2 -0
- package/src/storage/local-storage/merkletree.ts +137 -0
- package/src/storage/memory/cache-lru.ts +30 -0
- package/src/storage/memory/data-source.ts +45 -0
- package/src/storage/memory/index.ts +3 -0
- package/src/storage/memory/merkletree.ts +116 -0
- package/src/storage/shared/circuit-storage.ts +49 -0
- package/src/storage/shared/credential-storage.ts +70 -0
- package/src/storage/shared/identity-storage.ts +82 -0
- package/src/storage/shared/index.ts +3 -0
- package/src/storage/utils.ts +19 -0
- package/src/utils/compare-func.ts +5 -0
- package/src/utils/did-helper.ts +157 -0
- package/src/utils/encoding.ts +47 -0
- package/src/utils/index.ts +7 -0
- package/src/utils/message-bus.ts +88 -0
- package/src/utils/object.ts +52 -0
- package/src/utils/payments/evm.ts +152 -0
- package/src/utils/payments/solana.ts +360 -0
- package/src/verifiable/constants.ts +239 -0
- package/src/verifiable/core-utils.ts +307 -0
- package/src/verifiable/credential.ts +649 -0
- package/src/verifiable/index.ts +6 -0
- package/src/verifiable/presentation.ts +97 -0
- package/src/verifiable/proof.ts +277 -0
- package/src/verifiable/schema.ts +241 -0
|
@@ -0,0 +1,471 @@
|
|
|
1
|
+
import { RootInfo, StateProof } from './../entities/state';
|
|
2
|
+
import { ZKProof } from '@iden3/js-jwz';
|
|
3
|
+
import { IStateStorage, UserStateTransitionInfo } from '../interfaces/state';
|
|
4
|
+
import { Contract, JsonRpcProvider, Signer, TransactionRequest } from 'ethers';
|
|
5
|
+
import { StateInfo } from '../entities/state';
|
|
6
|
+
import { StateTransitionPubSignals } from '../../circuits';
|
|
7
|
+
import { byteEncoder } from '../../utils';
|
|
8
|
+
import abi from './abi/State.json';
|
|
9
|
+
import { DID, getChainId, Id } from '@mocanetwork/moca-iden3';
|
|
10
|
+
import { ITransactionService, TransactionService } from '../../blockchain';
|
|
11
|
+
import { prepareZkpProof } from './common';
|
|
12
|
+
import { ICache, createInMemoryCache } from '../memory';
|
|
13
|
+
import { PROTOCOL_CONSTANTS } from '../../iden3comm';
|
|
14
|
+
import { DEFAULT_CACHE_MAX_SIZE } from '../../verifiable';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Configuration options for caching behavior
|
|
18
|
+
*/
|
|
19
|
+
export type ResolverCacheOptions = {
|
|
20
|
+
/** TTL in milliseconds for latest states/roots (shorter since they can change) */
|
|
21
|
+
notReplacedTtl?: number;
|
|
22
|
+
/** TTL in milliseconds for historical states/roots (longer since they can change with less probability) */
|
|
23
|
+
replacedTtl?: number;
|
|
24
|
+
/** Maximum number of entries to store in cache */
|
|
25
|
+
maxSize?: number;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Simplified cache config with a single TTL (used for latest/gist proofs etc.)
|
|
30
|
+
*/
|
|
31
|
+
export type SimpleCacheOptions = {
|
|
32
|
+
/** TTL in milliseconds for latest states/gist proof */
|
|
33
|
+
ttl?: number;
|
|
34
|
+
/** Maximum number of entries to store in cache */
|
|
35
|
+
maxSize?: number;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* EthStateStorageOptions options for the Ethereum state storage.
|
|
40
|
+
*/
|
|
41
|
+
export type EthStateStorageOptions = {
|
|
42
|
+
/** Disable caching */
|
|
43
|
+
disableCache?: boolean;
|
|
44
|
+
/** Configuration for latest state resolution caching */
|
|
45
|
+
latestStateCacheOptions?: {
|
|
46
|
+
/** Custom cache implementation (if not provided, uses in-memory cache) */
|
|
47
|
+
cache?: ICache<StateInfo>;
|
|
48
|
+
} & SimpleCacheOptions;
|
|
49
|
+
/** Configuration for state resolution caching */
|
|
50
|
+
stateCacheOptions?: {
|
|
51
|
+
/** Custom cache implementation (if not provided, uses in-memory cache) */
|
|
52
|
+
cache?: ICache<StateInfo>;
|
|
53
|
+
} & ResolverCacheOptions;
|
|
54
|
+
/** Configuration for GIST root resolution caching */
|
|
55
|
+
rootCacheOptions?: {
|
|
56
|
+
/** Custom cache implementation (if not provided, uses in-memory cache) */
|
|
57
|
+
cache?: ICache<RootInfo>;
|
|
58
|
+
} & ResolverCacheOptions;
|
|
59
|
+
gistProofCacheOptions?: {
|
|
60
|
+
/** Custom cache implementation for GIST proofs (if not provided, uses in-memory cache) */
|
|
61
|
+
cache?: ICache<StateProof>;
|
|
62
|
+
} & SimpleCacheOptions;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Configuration of ethereum based blockchain connection
|
|
67
|
+
*
|
|
68
|
+
* @public
|
|
69
|
+
* @interface EthConnectionConfig
|
|
70
|
+
*/
|
|
71
|
+
export interface EthConnectionConfig {
|
|
72
|
+
url: string;
|
|
73
|
+
defaultGasLimit: number;
|
|
74
|
+
minGasPrice?: string;
|
|
75
|
+
maxGasPrice?: string; // eip-1559 transaction do not support gasPrice
|
|
76
|
+
maxFeePerGas?: string;
|
|
77
|
+
maxPriorityFeePerGas?: string;
|
|
78
|
+
confirmationBlockCount: number;
|
|
79
|
+
confirmationTimeout: number;
|
|
80
|
+
contractAddress: string;
|
|
81
|
+
receiptTimeout: number;
|
|
82
|
+
rpcResponseTimeout: number;
|
|
83
|
+
waitReceiptCycleTime: number;
|
|
84
|
+
waitBlockCycleTime: number;
|
|
85
|
+
chainId?: number;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export /** @type {EthConnectionConfig} - default configuration for EthConnectionConfig */
|
|
89
|
+
const defaultEthConnectionConfig: EthConnectionConfig = {
|
|
90
|
+
url: 'http://localhost:8545',
|
|
91
|
+
defaultGasLimit: 600000,
|
|
92
|
+
minGasPrice: '0',
|
|
93
|
+
maxGasPrice: '100000000000',
|
|
94
|
+
confirmationBlockCount: 5,
|
|
95
|
+
confirmationTimeout: 600000,
|
|
96
|
+
contractAddress: '',
|
|
97
|
+
receiptTimeout: 600000,
|
|
98
|
+
rpcResponseTimeout: 5000,
|
|
99
|
+
waitReceiptCycleTime: 30000,
|
|
100
|
+
waitBlockCycleTime: 3000
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
*
|
|
105
|
+
*
|
|
106
|
+
* @public
|
|
107
|
+
* @class EthStateStorage
|
|
108
|
+
* @implements implements IStateStorage interface
|
|
109
|
+
*/
|
|
110
|
+
export class EthStateStorage implements IStateStorage {
|
|
111
|
+
public readonly stateContract: Contract;
|
|
112
|
+
private readonly provider: JsonRpcProvider;
|
|
113
|
+
private readonly _transactionService: ITransactionService;
|
|
114
|
+
|
|
115
|
+
private _latestStateResolveCache: ICache<StateInfo>;
|
|
116
|
+
private _stateResolveCache: ICache<StateInfo>;
|
|
117
|
+
private _rootResolveCache: ICache<RootInfo>;
|
|
118
|
+
private _gistProofResolveCache: ICache<StateProof>;
|
|
119
|
+
|
|
120
|
+
private _latestStateCacheOptions: Required<SimpleCacheOptions>;
|
|
121
|
+
private _stateCacheOptions: Required<ResolverCacheOptions>;
|
|
122
|
+
private _rootCacheOptions: Required<ResolverCacheOptions>;
|
|
123
|
+
private _gistProofCacheOptions: Required<SimpleCacheOptions>;
|
|
124
|
+
|
|
125
|
+
private _disableCache = false;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Creates an instance of EthStateStorage.
|
|
129
|
+
* @param {EthConnectionConfig} [ethConfig=defaultEthConnectionConfig]
|
|
130
|
+
*/
|
|
131
|
+
constructor(
|
|
132
|
+
private readonly ethConfig: EthConnectionConfig | EthConnectionConfig[],
|
|
133
|
+
options?: EthStateStorageOptions
|
|
134
|
+
) {
|
|
135
|
+
const config = Array.isArray(ethConfig) ? ethConfig[0] : ethConfig;
|
|
136
|
+
this.provider = new JsonRpcProvider(config.url);
|
|
137
|
+
this.stateContract = new Contract(config.contractAddress, abi, this.provider);
|
|
138
|
+
this._transactionService = new TransactionService(this.getRpcProvider());
|
|
139
|
+
|
|
140
|
+
// Store cache options for later use
|
|
141
|
+
this._latestStateCacheOptions = {
|
|
142
|
+
ttl:
|
|
143
|
+
options?.latestStateCacheOptions?.ttl ?? PROTOCOL_CONSTANTS.DEFAULT_PROOF_VERIFY_DELAY / 2,
|
|
144
|
+
maxSize: options?.latestStateCacheOptions?.maxSize ?? DEFAULT_CACHE_MAX_SIZE
|
|
145
|
+
};
|
|
146
|
+
this._stateCacheOptions = {
|
|
147
|
+
notReplacedTtl:
|
|
148
|
+
options?.stateCacheOptions?.notReplacedTtl ??
|
|
149
|
+
PROTOCOL_CONSTANTS.DEFAULT_PROOF_VERIFY_DELAY / 2,
|
|
150
|
+
replacedTtl:
|
|
151
|
+
options?.stateCacheOptions?.replacedTtl ?? PROTOCOL_CONSTANTS.DEFAULT_PROOF_VERIFY_DELAY,
|
|
152
|
+
maxSize: options?.stateCacheOptions?.maxSize ?? DEFAULT_CACHE_MAX_SIZE
|
|
153
|
+
};
|
|
154
|
+
this._rootCacheOptions = {
|
|
155
|
+
replacedTtl:
|
|
156
|
+
options?.rootCacheOptions?.replacedTtl ?? PROTOCOL_CONSTANTS.DEFAULT_AUTH_VERIFY_DELAY,
|
|
157
|
+
notReplacedTtl:
|
|
158
|
+
options?.rootCacheOptions?.notReplacedTtl ??
|
|
159
|
+
PROTOCOL_CONSTANTS.DEFAULT_AUTH_VERIFY_DELAY / 2,
|
|
160
|
+
maxSize: options?.rootCacheOptions?.maxSize ?? DEFAULT_CACHE_MAX_SIZE
|
|
161
|
+
};
|
|
162
|
+
this._gistProofCacheOptions = {
|
|
163
|
+
ttl: PROTOCOL_CONSTANTS.DEFAULT_AUTH_VERIFY_DELAY / 2,
|
|
164
|
+
maxSize: options?.gistProofCacheOptions?.maxSize ?? DEFAULT_CACHE_MAX_SIZE
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
// Initialize cache instances
|
|
168
|
+
this._latestStateResolveCache =
|
|
169
|
+
options?.latestStateCacheOptions?.cache ??
|
|
170
|
+
createInMemoryCache({
|
|
171
|
+
maxSize: this._latestStateCacheOptions.maxSize,
|
|
172
|
+
ttl: this._latestStateCacheOptions.ttl
|
|
173
|
+
});
|
|
174
|
+
this._stateResolveCache =
|
|
175
|
+
options?.stateCacheOptions?.cache ??
|
|
176
|
+
createInMemoryCache({
|
|
177
|
+
maxSize: this._stateCacheOptions.maxSize,
|
|
178
|
+
ttl: this._stateCacheOptions.replacedTtl
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
this._rootResolveCache =
|
|
182
|
+
options?.rootCacheOptions?.cache ??
|
|
183
|
+
createInMemoryCache({
|
|
184
|
+
maxSize: this._rootCacheOptions.maxSize,
|
|
185
|
+
ttl: this._rootCacheOptions.replacedTtl
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
this._gistProofResolveCache =
|
|
189
|
+
options?.gistProofCacheOptions?.cache ??
|
|
190
|
+
createInMemoryCache({
|
|
191
|
+
maxSize: this._gistProofCacheOptions.maxSize,
|
|
192
|
+
ttl: this._gistProofCacheOptions.ttl
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
this._disableCache = options?.disableCache ?? false;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/** {@inheritdoc IStateStorage.getLatestStateById} */
|
|
199
|
+
async getLatestStateById(id: bigint): Promise<StateInfo> {
|
|
200
|
+
const cacheKey = this.getLatestStateCacheKey(id);
|
|
201
|
+
if (!this._disableCache) {
|
|
202
|
+
// Check cache first
|
|
203
|
+
const cachedResult = await this._latestStateResolveCache?.get(cacheKey);
|
|
204
|
+
if (cachedResult) {
|
|
205
|
+
return cachedResult;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const { stateContract } = this.getStateContractAndProviderForId(id);
|
|
210
|
+
const rawData = await stateContract.getStateInfoById(id);
|
|
211
|
+
const stateInfo: StateInfo = {
|
|
212
|
+
id: BigInt(rawData[0]),
|
|
213
|
+
state: BigInt(rawData[1]),
|
|
214
|
+
replacedByState: BigInt(rawData[2]),
|
|
215
|
+
createdAtTimestamp: BigInt(rawData[3]),
|
|
216
|
+
replacedAtTimestamp: BigInt(rawData[4]),
|
|
217
|
+
createdAtBlock: BigInt(rawData[5]),
|
|
218
|
+
replacedAtBlock: BigInt(rawData[6])
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
!this._disableCache &&
|
|
222
|
+
(await this._latestStateResolveCache?.set(
|
|
223
|
+
cacheKey,
|
|
224
|
+
stateInfo,
|
|
225
|
+
this._latestStateCacheOptions.ttl
|
|
226
|
+
));
|
|
227
|
+
return stateInfo;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/** {@inheritdoc IStateStorage.getStateInfoByIdAndState} */
|
|
231
|
+
async getStateInfoByIdAndState(id: bigint, state: bigint): Promise<StateInfo> {
|
|
232
|
+
const cacheKey = this.getStateCacheKey(id, state);
|
|
233
|
+
if (!this._disableCache) {
|
|
234
|
+
// Check cache first
|
|
235
|
+
const cachedResult = await this._stateResolveCache?.get(cacheKey);
|
|
236
|
+
if (cachedResult) {
|
|
237
|
+
return cachedResult;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const { stateContract } = this.getStateContractAndProviderForId(id);
|
|
242
|
+
const rawData = await stateContract.getStateInfoByIdAndState(id, state);
|
|
243
|
+
const stateInfo: StateInfo = {
|
|
244
|
+
id: BigInt(rawData[0]),
|
|
245
|
+
state: BigInt(rawData[1]),
|
|
246
|
+
replacedByState: BigInt(rawData[2]),
|
|
247
|
+
createdAtTimestamp: BigInt(rawData[3]),
|
|
248
|
+
replacedAtTimestamp: BigInt(rawData[4]),
|
|
249
|
+
createdAtBlock: BigInt(rawData[5]),
|
|
250
|
+
replacedAtBlock: BigInt(rawData[6])
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
const ttl =
|
|
254
|
+
stateInfo.replacedAtTimestamp === 0n
|
|
255
|
+
? this._stateCacheOptions.notReplacedTtl
|
|
256
|
+
: this._stateCacheOptions.replacedTtl;
|
|
257
|
+
!this._disableCache && (await this._stateResolveCache?.set(cacheKey, stateInfo, ttl));
|
|
258
|
+
return stateInfo;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/** {@inheritdoc IStateStorage.publishState} */
|
|
262
|
+
async publishState(proof: ZKProof, signer: Signer): Promise<string> {
|
|
263
|
+
const stateTransitionPubSig = new StateTransitionPubSignals();
|
|
264
|
+
stateTransitionPubSig.pubSignalsUnmarshal(
|
|
265
|
+
byteEncoder.encode(JSON.stringify(proof.pub_signals))
|
|
266
|
+
);
|
|
267
|
+
const { userId, oldUserState, newUserState, isOldStateGenesis } = stateTransitionPubSig;
|
|
268
|
+
|
|
269
|
+
const { stateContract, provider } = this.getStateContractAndProviderForId(userId.bigInt());
|
|
270
|
+
const contract = stateContract.connect(signer) as Contract;
|
|
271
|
+
|
|
272
|
+
const preparedZkpProof = prepareZkpProof(proof.proof);
|
|
273
|
+
const payload = [
|
|
274
|
+
userId.bigInt().toString(),
|
|
275
|
+
oldUserState.bigInt().toString(),
|
|
276
|
+
newUserState.bigInt().toString(),
|
|
277
|
+
isOldStateGenesis,
|
|
278
|
+
preparedZkpProof.a,
|
|
279
|
+
preparedZkpProof.b,
|
|
280
|
+
preparedZkpProof.c
|
|
281
|
+
];
|
|
282
|
+
|
|
283
|
+
const feeData = await provider.getFeeData();
|
|
284
|
+
|
|
285
|
+
const maxFeePerGas = defaultEthConnectionConfig.maxFeePerGas
|
|
286
|
+
? BigInt(defaultEthConnectionConfig.maxFeePerGas)
|
|
287
|
+
: feeData.maxFeePerGas;
|
|
288
|
+
const maxPriorityFeePerGas = defaultEthConnectionConfig.maxPriorityFeePerGas
|
|
289
|
+
? BigInt(defaultEthConnectionConfig.maxPriorityFeePerGas)
|
|
290
|
+
: feeData.maxPriorityFeePerGas;
|
|
291
|
+
|
|
292
|
+
const gasLimit = await contract.transitState.estimateGas(...payload);
|
|
293
|
+
const txData = await contract.transitState.populateTransaction(...payload);
|
|
294
|
+
|
|
295
|
+
const request: TransactionRequest = {
|
|
296
|
+
to: txData.to,
|
|
297
|
+
data: txData.data,
|
|
298
|
+
gasLimit,
|
|
299
|
+
maxFeePerGas,
|
|
300
|
+
maxPriorityFeePerGas
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
const { txnHash } = await this._transactionService.sendTransactionRequest(signer, request);
|
|
304
|
+
|
|
305
|
+
return txnHash;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/** {@inheritdoc IStateStorage.publishStateGeneric} */
|
|
309
|
+
async publishStateGeneric(
|
|
310
|
+
signer: Signer,
|
|
311
|
+
userStateTransitionInfo: UserStateTransitionInfo
|
|
312
|
+
): Promise<string> {
|
|
313
|
+
const { userId, oldUserState, newUserState, isOldStateGenesis, methodId, methodParams } =
|
|
314
|
+
userStateTransitionInfo;
|
|
315
|
+
const { stateContract, provider } = this.getStateContractAndProviderForId(userId.bigInt());
|
|
316
|
+
const contract = stateContract.connect(signer) as Contract;
|
|
317
|
+
const feeData = await provider.getFeeData();
|
|
318
|
+
|
|
319
|
+
const maxFeePerGas = defaultEthConnectionConfig.maxFeePerGas
|
|
320
|
+
? BigInt(defaultEthConnectionConfig.maxFeePerGas)
|
|
321
|
+
: feeData.maxFeePerGas;
|
|
322
|
+
const maxPriorityFeePerGas = defaultEthConnectionConfig.maxPriorityFeePerGas
|
|
323
|
+
? BigInt(defaultEthConnectionConfig.maxPriorityFeePerGas)
|
|
324
|
+
: feeData.maxPriorityFeePerGas;
|
|
325
|
+
|
|
326
|
+
const payload = [
|
|
327
|
+
userId.bigInt().toString(),
|
|
328
|
+
oldUserState.bigInt().toString(),
|
|
329
|
+
newUserState.bigInt().toString(),
|
|
330
|
+
isOldStateGenesis,
|
|
331
|
+
methodId, //BigInt(1),
|
|
332
|
+
methodParams //'0x'
|
|
333
|
+
];
|
|
334
|
+
const gasLimit = await contract.transitStateGeneric.estimateGas(...payload);
|
|
335
|
+
const txData = await contract.transitStateGeneric.populateTransaction(...payload);
|
|
336
|
+
|
|
337
|
+
const request: TransactionRequest = {
|
|
338
|
+
to: txData.to,
|
|
339
|
+
data: txData.data,
|
|
340
|
+
gasLimit,
|
|
341
|
+
maxFeePerGas,
|
|
342
|
+
maxPriorityFeePerGas
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
const { txnHash } = await this._transactionService.sendTransactionRequest(signer, request);
|
|
346
|
+
|
|
347
|
+
return txnHash;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/** {@inheritdoc IStateStorage.getGISTProof} */
|
|
351
|
+
async getGISTProof(id: bigint): Promise<StateProof> {
|
|
352
|
+
const cacheKey = this.getGistProofCacheKey(id);
|
|
353
|
+
if (!this._disableCache) {
|
|
354
|
+
// Check cache first
|
|
355
|
+
const cachedResult = await this._gistProofResolveCache?.get(cacheKey);
|
|
356
|
+
if (cachedResult) {
|
|
357
|
+
return cachedResult;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
const { stateContract } = this.getStateContractAndProviderForId(id);
|
|
362
|
+
const data = await stateContract.getGISTProof(id);
|
|
363
|
+
|
|
364
|
+
const stateProof = {
|
|
365
|
+
root: BigInt(data.root.toString()),
|
|
366
|
+
existence: data.existence,
|
|
367
|
+
siblings: data.siblings?.map(
|
|
368
|
+
(sibling: { toString: () => string | number | bigint | boolean }) =>
|
|
369
|
+
BigInt(sibling.toString())
|
|
370
|
+
),
|
|
371
|
+
index: BigInt(data.index.toString()),
|
|
372
|
+
value: BigInt(data.value.toString()),
|
|
373
|
+
auxExistence: data.auxExistence,
|
|
374
|
+
auxIndex: BigInt(data.auxIndex.toString()),
|
|
375
|
+
auxValue: BigInt(data.auxValue.toString())
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
!this._disableCache &&
|
|
379
|
+
(await this._gistProofResolveCache?.set(
|
|
380
|
+
cacheKey,
|
|
381
|
+
stateProof,
|
|
382
|
+
this._gistProofCacheOptions.ttl
|
|
383
|
+
));
|
|
384
|
+
return stateProof;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/** {@inheritdoc IStateStorage.getGISTRootInfo} */
|
|
388
|
+
async getGISTRootInfo(root: bigint, id: bigint): Promise<RootInfo> {
|
|
389
|
+
const cacheKey = this.getRootCacheKey(root);
|
|
390
|
+
if (!this._disableCache) {
|
|
391
|
+
// Check cache first
|
|
392
|
+
const cachedResult = await this._rootResolveCache?.get(cacheKey);
|
|
393
|
+
if (cachedResult) {
|
|
394
|
+
return cachedResult;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
const { stateContract } = this.getStateContractAndProviderForId(id);
|
|
399
|
+
const data = await stateContract.getGISTRootInfo(root);
|
|
400
|
+
|
|
401
|
+
const rootInfo = {
|
|
402
|
+
root: BigInt(data.root.toString()),
|
|
403
|
+
replacedByRoot: BigInt(data.replacedByRoot.toString()),
|
|
404
|
+
createdAtTimestamp: BigInt(data.createdAtTimestamp.toString()),
|
|
405
|
+
replacedAtTimestamp: BigInt(data.replacedAtTimestamp.toString()),
|
|
406
|
+
createdAtBlock: BigInt(data.createdAtBlock.toString()),
|
|
407
|
+
replacedAtBlock: BigInt(data.replacedAtBlock.toString())
|
|
408
|
+
};
|
|
409
|
+
|
|
410
|
+
const ttl =
|
|
411
|
+
rootInfo.replacedAtTimestamp == 0n
|
|
412
|
+
? this._rootCacheOptions.notReplacedTtl
|
|
413
|
+
: this._rootCacheOptions.replacedTtl;
|
|
414
|
+
!this._disableCache && (await this._rootResolveCache?.set(cacheKey, rootInfo, ttl));
|
|
415
|
+
return rootInfo;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/** {@inheritdoc IStateStorage.getRpcProvider} */
|
|
419
|
+
getRpcProvider(): JsonRpcProvider {
|
|
420
|
+
return this.provider;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/** enable caching */
|
|
424
|
+
enableCache(): void {
|
|
425
|
+
this._disableCache = false;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/** disable caching */
|
|
429
|
+
disableCache(): void {
|
|
430
|
+
this._disableCache = true;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
private getStateContractAndProviderForId(id: bigint): {
|
|
434
|
+
stateContract: Contract;
|
|
435
|
+
provider: JsonRpcProvider;
|
|
436
|
+
} {
|
|
437
|
+
const idTyped = Id.fromBigInt(id as bigint);
|
|
438
|
+
const chainId = getChainId(DID.blockchainFromId(idTyped), DID.networkIdFromId(idTyped));
|
|
439
|
+
const config = this.networkByChainId(chainId);
|
|
440
|
+
|
|
441
|
+
const provider = new JsonRpcProvider(config.url);
|
|
442
|
+
const stateContract = new Contract(config.contractAddress, abi, provider);
|
|
443
|
+
|
|
444
|
+
return { stateContract, provider };
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
private networkByChainId(chainId: number): EthConnectionConfig {
|
|
448
|
+
const config = Array.isArray(this.ethConfig) ? this.ethConfig : [this.ethConfig];
|
|
449
|
+
const network = config.find((c) => c.chainId === chainId);
|
|
450
|
+
if (!network) {
|
|
451
|
+
throw new Error(`chainId "${chainId}" not supported`);
|
|
452
|
+
}
|
|
453
|
+
return network;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
private getGistProofCacheKey(id: bigint): string {
|
|
457
|
+
return `gist-${id.toString()}`;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
private getLatestStateCacheKey(id: bigint): string {
|
|
461
|
+
return `latest-${id.toString()}`;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
private getStateCacheKey(id: bigint, state: bigint): string {
|
|
465
|
+
return `${id.toString()}-${state.toString()}`;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
private getRootCacheKey(root: bigint): string {
|
|
469
|
+
return root.toString();
|
|
470
|
+
}
|
|
471
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Hash } from '@iden3/js-merkletree';
|
|
2
|
+
|
|
3
|
+
/** Identity structure that can be used for identity storage */
|
|
4
|
+
export type Identity = {
|
|
5
|
+
did: string;
|
|
6
|
+
state?: Hash;
|
|
7
|
+
isStatePublished?: boolean;
|
|
8
|
+
isStateGenesis?: boolean;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/** Profile structure that can be used for profiles storage */
|
|
12
|
+
export type Profile = {
|
|
13
|
+
id: string;
|
|
14
|
+
nonce: number | string;
|
|
15
|
+
genesisIdentifier: string;
|
|
16
|
+
verifier: string;
|
|
17
|
+
tags?: string[]; // format of the tags can be defined by client of sdk
|
|
18
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface to store metadata about merkle tree
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
|
+
* @interface IdentityMerkleTreeMetaInformation
|
|
6
|
+
*/
|
|
7
|
+
export interface IdentityMerkleTreeMetaInformation {
|
|
8
|
+
treeId: string;
|
|
9
|
+
identifier: string;
|
|
10
|
+
type: MerkleTreeType;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Type of MerkleTree
|
|
15
|
+
*
|
|
16
|
+
* @enum {number}
|
|
17
|
+
*/
|
|
18
|
+
export enum MerkleTreeType {
|
|
19
|
+
// Claims is merkle tree type for claims tree
|
|
20
|
+
Claims = 0,
|
|
21
|
+
// Revocations is merkle tree type for revocations tree
|
|
22
|
+
Revocations = 1,
|
|
23
|
+
// Roots is merkle tree type for roots tree
|
|
24
|
+
Roots = 2
|
|
25
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { ProofJSON } from '@iden3/js-merkletree';
|
|
2
|
+
/**
|
|
3
|
+
* state information of identity from chain.
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
* @interface StateInfo
|
|
7
|
+
*/
|
|
8
|
+
export interface StateInfo {
|
|
9
|
+
id?: bigint;
|
|
10
|
+
state?: bigint;
|
|
11
|
+
replacedByState?: bigint;
|
|
12
|
+
createdAtTimestamp?: bigint;
|
|
13
|
+
replacedAtTimestamp?: bigint;
|
|
14
|
+
createdAtBlock?: bigint;
|
|
15
|
+
replacedAtBlock?: bigint;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* state proof of identity from chain
|
|
20
|
+
*
|
|
21
|
+
* @public
|
|
22
|
+
* @interface StateProof
|
|
23
|
+
*/
|
|
24
|
+
export interface StateProof {
|
|
25
|
+
root: bigint;
|
|
26
|
+
existence: boolean;
|
|
27
|
+
siblings: bigint[];
|
|
28
|
+
index: bigint;
|
|
29
|
+
value: bigint;
|
|
30
|
+
auxExistence: boolean;
|
|
31
|
+
auxIndex: bigint;
|
|
32
|
+
auxValue: bigint;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* global identity state root info from chain
|
|
37
|
+
*
|
|
38
|
+
* @public
|
|
39
|
+
* @interface RootInfo
|
|
40
|
+
*/
|
|
41
|
+
export interface RootInfo {
|
|
42
|
+
root: bigint;
|
|
43
|
+
replacedByRoot: bigint;
|
|
44
|
+
createdAtTimestamp: bigint;
|
|
45
|
+
replacedAtTimestamp: bigint;
|
|
46
|
+
createdAtBlock: bigint;
|
|
47
|
+
replacedAtBlock: bigint;
|
|
48
|
+
proof?: ProofJSON;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* identity state message
|
|
53
|
+
*
|
|
54
|
+
* @public
|
|
55
|
+
* @interface IdentityStateMsg
|
|
56
|
+
*/
|
|
57
|
+
export interface IdentityStateMsg {
|
|
58
|
+
timestamp: number;
|
|
59
|
+
id: bigint;
|
|
60
|
+
state: bigint;
|
|
61
|
+
replacedAtTimestamp: number;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* global state message
|
|
66
|
+
*
|
|
67
|
+
* @public
|
|
68
|
+
* @interface GlobalStateMsg
|
|
69
|
+
*/
|
|
70
|
+
export interface GlobalStateMsg {
|
|
71
|
+
timestamp: number;
|
|
72
|
+
idType: string;
|
|
73
|
+
root: bigint;
|
|
74
|
+
replacedAtTimestamp: number;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* identity state update
|
|
79
|
+
*
|
|
80
|
+
* @public
|
|
81
|
+
* @interface IdentityStateUpdate
|
|
82
|
+
*/
|
|
83
|
+
export interface IdentityStateUpdate {
|
|
84
|
+
idStateMsg: IdentityStateMsg;
|
|
85
|
+
signature: string;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* global state update
|
|
90
|
+
*
|
|
91
|
+
* @public
|
|
92
|
+
* @interface GlobalStateUpdate
|
|
93
|
+
*/
|
|
94
|
+
export interface GlobalStateUpdate {
|
|
95
|
+
globalStateMsg: GlobalStateMsg;
|
|
96
|
+
signature: string;
|
|
97
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './jsonQuery';
|