@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,143 @@
|
|
|
1
|
+
import { TransactionReceipt } from 'ethers';
|
|
2
|
+
import { JSONObject } from '../../iden3comm';
|
|
3
|
+
import { OnChainRevocationStorage } from '../../storage';
|
|
4
|
+
import { CredentialStatusType } from '../../verifiable';
|
|
5
|
+
import { ProofNode } from './reverse-sparse-merkle-tree';
|
|
6
|
+
import { MessageBus, SDK_EVENTS } from '../../utils';
|
|
7
|
+
import { PublishMode } from '../models';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Represents a credential status publisher.
|
|
11
|
+
*/
|
|
12
|
+
export interface ICredentialStatusPublisher {
|
|
13
|
+
/**
|
|
14
|
+
* Publishes the credential status.
|
|
15
|
+
* @param params - The parameters for publishing the status.
|
|
16
|
+
* @returns A promise that resolves when the status is published.
|
|
17
|
+
*/
|
|
18
|
+
publish(params: JSONObject): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Registry for managing credential status publishers.
|
|
23
|
+
*/
|
|
24
|
+
export class CredentialStatusPublisherRegistry {
|
|
25
|
+
private _publishers: Map<CredentialStatusType, ICredentialStatusPublisher[]> = new Map();
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Registers one or more credential status publishers for a given type.
|
|
29
|
+
* @param type - The credential status type.
|
|
30
|
+
* @param publisher - One or more credential status publishers.
|
|
31
|
+
*/
|
|
32
|
+
public register(type: CredentialStatusType, ...publisher: ICredentialStatusPublisher[]): void {
|
|
33
|
+
const publishers = this._publishers.get(type) ?? [];
|
|
34
|
+
publishers.push(...publisher);
|
|
35
|
+
this._publishers.set(type, publishers);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Retrieves the credential status publishers for a given type.
|
|
40
|
+
* @param type - The credential status type.
|
|
41
|
+
* @returns An array of credential status publishers or undefined if none are registered for the given type.
|
|
42
|
+
*/
|
|
43
|
+
public get(type: CredentialStatusType): ICredentialStatusPublisher[] | undefined {
|
|
44
|
+
return this._publishers.get(type);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Implementation of the ICredentialStatusPublisher interface for publishing on-chain credential status.
|
|
50
|
+
*/
|
|
51
|
+
export class Iden3OnchainSmtCredentialStatusPublisher implements ICredentialStatusPublisher {
|
|
52
|
+
constructor(private readonly _storage: OnChainRevocationStorage) {}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Publishes the credential status to the blockchain.
|
|
56
|
+
* @param params - The parameters for publishing the credential status.
|
|
57
|
+
*/
|
|
58
|
+
public async publish(params: {
|
|
59
|
+
nodes: ProofNode[];
|
|
60
|
+
credentialStatusType: CredentialStatusType;
|
|
61
|
+
onChain?: {
|
|
62
|
+
txCallback?: (tx: TransactionReceipt) => Promise<void>;
|
|
63
|
+
publishMode?: PublishMode;
|
|
64
|
+
};
|
|
65
|
+
}): Promise<void> {
|
|
66
|
+
if (
|
|
67
|
+
![CredentialStatusType.Iden3OnchainSparseMerkleTreeProof2023].includes(
|
|
68
|
+
params.credentialStatusType
|
|
69
|
+
)
|
|
70
|
+
) {
|
|
71
|
+
throw new Error(
|
|
72
|
+
`On-chain publishing is not supported for credential status type ${params.credentialStatusType}`
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
const nodesBigInts = params.nodes.map((n) => n.children.map((c) => c.bigInt()));
|
|
76
|
+
|
|
77
|
+
const txPromise = this._storage.saveNodes(nodesBigInts);
|
|
78
|
+
|
|
79
|
+
let publishMode = params.onChain?.publishMode ?? 'sync';
|
|
80
|
+
if (params.onChain?.txCallback) {
|
|
81
|
+
publishMode = 'callback';
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
switch (publishMode) {
|
|
85
|
+
case 'sync':
|
|
86
|
+
await txPromise;
|
|
87
|
+
break;
|
|
88
|
+
case 'callback': {
|
|
89
|
+
if (!params.onChain?.txCallback) {
|
|
90
|
+
throw new Error('txCallback is required for publishMode "callback"');
|
|
91
|
+
}
|
|
92
|
+
const cb = params.onChain?.txCallback;
|
|
93
|
+
txPromise.then((receipt) => cb(receipt));
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
case 'async': {
|
|
97
|
+
const mb = MessageBus.getInstance();
|
|
98
|
+
txPromise.then((receipt) => mb.publish(SDK_EVENTS.TX_RECEIPT_ACCEPTED, receipt));
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
default:
|
|
102
|
+
throw new Error(`Invalid publishMode: ${publishMode}`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Implementation of the ICredentialStatusPublisher interface for publishing off-chain credential status.
|
|
109
|
+
*/
|
|
110
|
+
export class Iden3SmtRhsCredentialStatusPublisher implements ICredentialStatusPublisher {
|
|
111
|
+
/**
|
|
112
|
+
* Publishes the credential status to a specified node URL.
|
|
113
|
+
* @param params - The parameters for publishing the credential status.
|
|
114
|
+
* @param params.nodes - The proof nodes to be published.
|
|
115
|
+
* @param params.rhsUrl - The URL of the node to publish the credential status to.
|
|
116
|
+
* @returns A promise that resolves when the credential status is successfully published.
|
|
117
|
+
* @throws An error if the publishing fails.
|
|
118
|
+
*/
|
|
119
|
+
public async publish(params: {
|
|
120
|
+
nodes: ProofNode[];
|
|
121
|
+
credentialStatusType: CredentialStatusType;
|
|
122
|
+
|
|
123
|
+
rhsUrl: string;
|
|
124
|
+
}): Promise<void> {
|
|
125
|
+
if (
|
|
126
|
+
![CredentialStatusType.Iden3ReverseSparseMerkleTreeProof].includes(
|
|
127
|
+
params.credentialStatusType
|
|
128
|
+
)
|
|
129
|
+
) {
|
|
130
|
+
throw new Error(
|
|
131
|
+
`On-chain publishing is not supported for credential status type ${params.credentialStatusType}`
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
const nodesJSON = params.nodes.map((n) => n.toJSON());
|
|
135
|
+
const resp = await fetch(params.rhsUrl + '/node', {
|
|
136
|
+
method: 'post',
|
|
137
|
+
body: JSON.stringify(nodesJSON)
|
|
138
|
+
});
|
|
139
|
+
if (resp.status !== 200) {
|
|
140
|
+
throw new Error(`Failed to publish credential status. Status: ${resp.status}`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { CredentialStatus, RevocationStatus } from '../../verifiable';
|
|
2
|
+
import { CredentialStatusResolveOptions, CredentialStatusResolver } from './resolver';
|
|
3
|
+
|
|
4
|
+
export class DidDocumentCredentialStatusResolver implements CredentialStatusResolver {
|
|
5
|
+
constructor(private readonly didResolverUrl: string) {}
|
|
6
|
+
async resolve(
|
|
7
|
+
credentialStatus: CredentialStatus,
|
|
8
|
+
opts?: CredentialStatusResolveOptions | undefined
|
|
9
|
+
): Promise<RevocationStatus> {
|
|
10
|
+
if (!opts?.issuerDID) {
|
|
11
|
+
throw new Error('IssuerDID is not set in options');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const url = `${this.didResolverUrl}/1.0/credential-status/${encodeURIComponent(
|
|
15
|
+
opts.issuerDID.string()
|
|
16
|
+
)}`;
|
|
17
|
+
const resp = await fetch(url, {
|
|
18
|
+
method: 'POST',
|
|
19
|
+
body: JSON.stringify(credentialStatus)
|
|
20
|
+
});
|
|
21
|
+
const data = await resp.json();
|
|
22
|
+
return data;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { RevocationStatus, CredentialStatus } from '../../verifiable';
|
|
2
|
+
import { EthConnectionConfig } from '../../storage/blockchain';
|
|
3
|
+
import { CredentialStatusResolver, CredentialStatusResolveOptions } from './resolver';
|
|
4
|
+
import { OnChainRevocationStorage } from '../../storage/blockchain/onchain-revocation';
|
|
5
|
+
import { DID } from '@mocanetwork/moca-iden3';
|
|
6
|
+
import { isGenesisState } from '../../utils';
|
|
7
|
+
import { EthStateStorage, EthStateStorageOptions } from '../../storage/blockchain/state';
|
|
8
|
+
import { IStateStorage, IOnchainRevocationStore } from '../../storage';
|
|
9
|
+
import { Hash } from '@iden3/js-merkletree';
|
|
10
|
+
import { isIdentityDoesNotExistError } from '../../storage/blockchain/errors';
|
|
11
|
+
|
|
12
|
+
/*
|
|
13
|
+
* Options for OnChainResolver
|
|
14
|
+
*
|
|
15
|
+
* @public
|
|
16
|
+
* @typedef {Object} OnChainResolverOptions
|
|
17
|
+
* @property {EthStateStorageOptions} [stateStorageOptions] - options for state storage
|
|
18
|
+
*/
|
|
19
|
+
export type OnChainResolverOptions = {
|
|
20
|
+
stateStorageOptions?: EthStateStorageOptions;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* OnChainIssuer is a class that allows to interact with the onchain contract
|
|
25
|
+
* and build the revocation status.
|
|
26
|
+
*
|
|
27
|
+
* @public
|
|
28
|
+
* @class OnChainIssuer
|
|
29
|
+
*/
|
|
30
|
+
export class OnChainResolver implements CredentialStatusResolver {
|
|
31
|
+
private readonly _stateStorage: IStateStorage;
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
* Creates an instance of OnChainIssuer.
|
|
35
|
+
* @public
|
|
36
|
+
* @param {Array<EthConnectionConfig>} _configs - list of ethereum network connections
|
|
37
|
+
*/
|
|
38
|
+
constructor(private readonly _configs: EthConnectionConfig[], _opts?: OnChainResolverOptions) {
|
|
39
|
+
this._stateStorage = new EthStateStorage(_configs, _opts?.stateStorageOptions);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* resolve is a method to resolve a credential status from the blockchain.
|
|
44
|
+
*
|
|
45
|
+
* @public
|
|
46
|
+
* @param {CredentialStatus} credentialStatus - credential status to resolve
|
|
47
|
+
* @param {CredentialStatusResolveOptions} credentialStatusResolveOptions - options for resolver
|
|
48
|
+
* @returns `{Promise<RevocationStatus>}`
|
|
49
|
+
*/
|
|
50
|
+
async resolve(
|
|
51
|
+
credentialStatus: CredentialStatus,
|
|
52
|
+
credentialStatusResolveOptions?: CredentialStatusResolveOptions
|
|
53
|
+
): Promise<RevocationStatus> {
|
|
54
|
+
if (!credentialStatusResolveOptions?.issuerDID) {
|
|
55
|
+
throw new Error('IssuerDID is not set in options');
|
|
56
|
+
}
|
|
57
|
+
return this.getRevocationOnChain(credentialStatus, credentialStatusResolveOptions.issuerDID);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Gets partial revocation status info from onchain issuer contract.
|
|
62
|
+
*
|
|
63
|
+
* @param {CredentialStatus} credentialStatus - credential status section of credential
|
|
64
|
+
* @param {DID} issuerDid - issuer did
|
|
65
|
+
* @returns `{Promise<RevocationStatus>}`
|
|
66
|
+
*/
|
|
67
|
+
async getRevocationOnChain(
|
|
68
|
+
credentialStatus: CredentialStatus,
|
|
69
|
+
issuer: DID
|
|
70
|
+
): Promise<RevocationStatus> {
|
|
71
|
+
const { contractAddress, chainId, revocationNonce, stateHex } =
|
|
72
|
+
this.extractCredentialStatusInfo(credentialStatus);
|
|
73
|
+
if (revocationNonce !== credentialStatus.revocationNonce) {
|
|
74
|
+
throw new Error('revocationNonce does not match');
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const issuerId = DID.idFromDID(issuer);
|
|
78
|
+
let latestIssuerState: bigint;
|
|
79
|
+
try {
|
|
80
|
+
const latestStateInfo = await this._stateStorage.getLatestStateById(issuerId.bigInt());
|
|
81
|
+
if (!latestStateInfo.state) {
|
|
82
|
+
throw new Error('state contract returned empty state');
|
|
83
|
+
}
|
|
84
|
+
latestIssuerState = latestStateInfo.state;
|
|
85
|
+
} catch (e) {
|
|
86
|
+
if (!isIdentityDoesNotExistError(e)) {
|
|
87
|
+
throw e;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (!stateHex) {
|
|
91
|
+
throw new Error(
|
|
92
|
+
'latest state not found and state parameter is not present in credentialStatus.id'
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
const stateBigInt = Hash.fromHex(stateHex).bigInt();
|
|
96
|
+
if (!isGenesisState(issuer, stateBigInt)) {
|
|
97
|
+
throw new Error(
|
|
98
|
+
`latest state not found and state parameter ${stateHex} is not genesis state`
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
latestIssuerState = stateBigInt;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const id = DID.idFromDID(issuer);
|
|
105
|
+
const onChainCaller = this._getOnChainRevocationStorageForIssuer(chainId, contractAddress);
|
|
106
|
+
const revocationStatus = await onChainCaller.getRevocationStatusByIdAndState(
|
|
107
|
+
id.bigInt(),
|
|
108
|
+
latestIssuerState,
|
|
109
|
+
revocationNonce
|
|
110
|
+
);
|
|
111
|
+
return revocationStatus;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Extract information about credential status
|
|
116
|
+
*
|
|
117
|
+
* @param {credentialStatus} CredentialStatus - credential status
|
|
118
|
+
* @returns {{contractAddress: string, chainId: number, revocationNonce: number, issuer: string;}}
|
|
119
|
+
*/
|
|
120
|
+
extractCredentialStatusInfo(credentialStatus: CredentialStatus): {
|
|
121
|
+
contractAddress: string;
|
|
122
|
+
chainId: number;
|
|
123
|
+
revocationNonce: number;
|
|
124
|
+
stateHex: string;
|
|
125
|
+
} {
|
|
126
|
+
if (!credentialStatus.id) {
|
|
127
|
+
throw new Error('credentialStatus id is empty');
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const idParts = credentialStatus.id.split('/');
|
|
131
|
+
if (idParts.length !== 2) {
|
|
132
|
+
throw new Error('invalid credentialStatus id');
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const idURL = new URL(credentialStatus.id);
|
|
136
|
+
const stateHex = idURL.searchParams.get('state') || '';
|
|
137
|
+
const contractIdentifier = idURL.searchParams.get('contractAddress');
|
|
138
|
+
if (!contractIdentifier) {
|
|
139
|
+
throw new Error('contractAddress not found in credentialStatus.id field');
|
|
140
|
+
}
|
|
141
|
+
const parts = contractIdentifier.split(':');
|
|
142
|
+
if (parts.length != 2) {
|
|
143
|
+
throw new Error('invalid contract address encoding. should be chainId:contractAddress');
|
|
144
|
+
}
|
|
145
|
+
const chainId = parseInt(parts[0], 10);
|
|
146
|
+
const contractAddress = parts[1];
|
|
147
|
+
|
|
148
|
+
// if revocationNonce is not present in id as param, then it should be extract from credentialStatus
|
|
149
|
+
const rv = idURL.searchParams.get('revocationNonce') || credentialStatus.revocationNonce;
|
|
150
|
+
if (rv === undefined || rv === null) {
|
|
151
|
+
throw new Error('revocationNonce not found in credentialStatus id field');
|
|
152
|
+
}
|
|
153
|
+
const revocationNonce = typeof rv === 'number' ? rv : parseInt(rv, 10);
|
|
154
|
+
|
|
155
|
+
return { contractAddress, chainId, revocationNonce, stateHex };
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
networkByChainId(chainId: number): EthConnectionConfig {
|
|
159
|
+
const network = this._configs.find((c) => c.chainId === chainId);
|
|
160
|
+
if (!network) {
|
|
161
|
+
throw new Error(`chainId "${chainId}" not supported`);
|
|
162
|
+
}
|
|
163
|
+
return network;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
private _getOnChainRevocationStorageForIssuer(
|
|
167
|
+
chainId: number,
|
|
168
|
+
contractAddress: string
|
|
169
|
+
): IOnchainRevocationStore {
|
|
170
|
+
const networkConfig = this.networkByChainId(chainId);
|
|
171
|
+
const onChainCaller = new OnChainRevocationStorage(networkConfig, contractAddress);
|
|
172
|
+
return onChainCaller;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { DID } from '@mocanetwork/moca-iden3';
|
|
2
|
+
import { State, RevocationStatus, CredentialStatus, CredentialStatusType } from '../../verifiable';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* CredentialStatusResolveOptions is a set of options that can be passed to CredentialStatusResolver
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
* @interface CredentialStatusResolveOptions
|
|
9
|
+
*/
|
|
10
|
+
export interface CredentialStatusResolveOptions {
|
|
11
|
+
/**
|
|
12
|
+
@deprecated it was used only for state in case issuer has a issuerGenesisState state
|
|
13
|
+
*/
|
|
14
|
+
issuerData?: {
|
|
15
|
+
state: {
|
|
16
|
+
rootOfRoots: string;
|
|
17
|
+
claimsTreeRoot: string;
|
|
18
|
+
revocationTreeRoot: string;
|
|
19
|
+
value: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
issuerGenesisState?: State;
|
|
24
|
+
issuerDID?: DID;
|
|
25
|
+
userDID?: DID;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* CredentialStatusResolver is an interface that allows to interact with different types of credential status
|
|
30
|
+
* to resolve revocation status
|
|
31
|
+
*
|
|
32
|
+
* @public
|
|
33
|
+
* @interface CredentialStatusResolver
|
|
34
|
+
*/
|
|
35
|
+
export interface CredentialStatusResolver {
|
|
36
|
+
/**
|
|
37
|
+
* resolve is a method to resolve a credential status from the the specific source.
|
|
38
|
+
*
|
|
39
|
+
* @public
|
|
40
|
+
* @param {CredentialStatus} credentialStatus - credential status to resolve
|
|
41
|
+
* @param {CredentialStatusResolveOptions} credentialStatusResolveOptions - options for resolver
|
|
42
|
+
* @returns `{Promise<RevocationStatus>}`
|
|
43
|
+
*/
|
|
44
|
+
resolve(
|
|
45
|
+
credentialStatus: CredentialStatus,
|
|
46
|
+
opts?: CredentialStatusResolveOptions
|
|
47
|
+
): Promise<RevocationStatus>;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* CredentialStatusResolverRegistry is a registry of CredentialStatusResolver
|
|
52
|
+
*
|
|
53
|
+
* @public
|
|
54
|
+
* @interface CredentialStatusResolverRegistry
|
|
55
|
+
*/
|
|
56
|
+
export class CredentialStatusResolverRegistry {
|
|
57
|
+
private resolvers: Map<CredentialStatusType, CredentialStatusResolver> = new Map();
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* register is a method to add a credential status resolver for specific credential status type
|
|
61
|
+
*
|
|
62
|
+
* @public
|
|
63
|
+
* @param {CredentialStatusType} type - one of the credential status types
|
|
64
|
+
* @param {CredentialStatusResolver} resolver - resolver
|
|
65
|
+
*/
|
|
66
|
+
register(type: CredentialStatusType, resolver: CredentialStatusResolver) {
|
|
67
|
+
this.resolvers.set(type, resolver);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* resolve is a method to resolve a credential status from the the specific source.
|
|
72
|
+
*
|
|
73
|
+
* @public
|
|
74
|
+
* @param {CredentialStatus} credentialStatus - credential status to resolve
|
|
75
|
+
* @param {CredentialStatusResolveOptions} credentialStatusResolveOptions - options for resolver
|
|
76
|
+
* @returns `{Promise<RevocationStatus>}`
|
|
77
|
+
*/
|
|
78
|
+
get(type: CredentialStatusType): CredentialStatusResolver | undefined {
|
|
79
|
+
return this.resolvers.get(type);
|
|
80
|
+
}
|
|
81
|
+
}
|