@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,366 @@
|
|
|
1
|
+
import { buildDIDType, BytesHelper, DID, Id } from '@mocanetwork/moca-iden3';
|
|
2
|
+
|
|
3
|
+
import { Hash, Proof, NodeAux, ZERO_HASH, testBit } from '@iden3/js-merkletree';
|
|
4
|
+
import { IStateStorage } from '../../storage';
|
|
5
|
+
import { CredentialStatusResolver, CredentialStatusResolveOptions } from './resolver';
|
|
6
|
+
import { CredentialStatus, RevocationStatus, State } from '../../verifiable';
|
|
7
|
+
import { CredentialStatusType } from '../../verifiable/constants';
|
|
8
|
+
import { isEthereumIdentity, isGenesisState } from '../../utils';
|
|
9
|
+
import { IssuerResolver } from './sparse-merkle-tree';
|
|
10
|
+
import { isIdentityDoesNotExistError } from '../../storage/blockchain/errors';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* ProofNode is a partial Reverse Hash Service result
|
|
14
|
+
* it contains the current node hash and its children
|
|
15
|
+
*
|
|
16
|
+
* @public
|
|
17
|
+
* @class ProofNode
|
|
18
|
+
*/
|
|
19
|
+
export class ProofNode {
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
* Creates an instance of ProofNode.
|
|
23
|
+
* @param {Hash} [hash=ZERO_HASH] - current node hash
|
|
24
|
+
* @param {Hash[]} [children=[]] - children of the node
|
|
25
|
+
*/
|
|
26
|
+
constructor(public hash: Hash = ZERO_HASH, public children: Hash[] = []) {}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Determination of Node type
|
|
30
|
+
* Can be: Leaf, Middle or State node
|
|
31
|
+
*
|
|
32
|
+
* @returns NodeType
|
|
33
|
+
*/
|
|
34
|
+
nodeType(): NodeType {
|
|
35
|
+
if (this.children.length === 2) {
|
|
36
|
+
return NodeType.Middle;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (this.children.length === 3 && this.children[2].hex() === Hash.fromBigInt(BigInt(1)).hex()) {
|
|
40
|
+
return NodeType.Leaf;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (this.children.length === 3) {
|
|
44
|
+
return NodeType.State;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return NodeType.Unknown;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* JSON Representation of ProofNode with a hex values
|
|
51
|
+
*
|
|
52
|
+
* @returns {*} - ProofNode with hexes
|
|
53
|
+
*/
|
|
54
|
+
toJSON() {
|
|
55
|
+
return {
|
|
56
|
+
hash: this.hash.hex(),
|
|
57
|
+
children: this.children.map((h) => h.hex())
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Creates ProofNode Hashes from hex values
|
|
62
|
+
*
|
|
63
|
+
* @static
|
|
64
|
+
* @param {ProofNodeHex} hexNode
|
|
65
|
+
* @returns ProofNode
|
|
66
|
+
*/
|
|
67
|
+
static fromHex(hexNode: ProofNodeHex): ProofNode {
|
|
68
|
+
return new ProofNode(
|
|
69
|
+
Hash.fromHex(hexNode.hash),
|
|
70
|
+
hexNode.children.map((ch) => Hash.fromHex(ch))
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
interface ProofNodeHex {
|
|
76
|
+
hash: string;
|
|
77
|
+
children: string[];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
interface NodeHexResponse {
|
|
81
|
+
node: ProofNodeHex;
|
|
82
|
+
status: string;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
enum NodeType {
|
|
86
|
+
Unknown = 0,
|
|
87
|
+
Middle = 1,
|
|
88
|
+
Leaf = 2,
|
|
89
|
+
State = 3
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* RHSResolver is a class that allows to interact with the RHS service to get revocation status.
|
|
94
|
+
*
|
|
95
|
+
* @public
|
|
96
|
+
* @class RHSResolver
|
|
97
|
+
*/
|
|
98
|
+
export class RHSResolver implements CredentialStatusResolver {
|
|
99
|
+
constructor(private readonly _state: IStateStorage) {}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* resolve is a method to resolve a credential status from the blockchain.
|
|
103
|
+
*
|
|
104
|
+
* @public
|
|
105
|
+
* @param {CredentialStatus} credentialStatus - credential status to resolve
|
|
106
|
+
* @param {CredentialStatusResolveOptions} credentialStatusResolveOptions - options for resolver
|
|
107
|
+
* @returns `{Promise<RevocationStatus>}`
|
|
108
|
+
*/
|
|
109
|
+
async resolve(
|
|
110
|
+
credentialStatus: CredentialStatus,
|
|
111
|
+
credentialStatusResolveOptions?: CredentialStatusResolveOptions
|
|
112
|
+
): Promise<RevocationStatus> {
|
|
113
|
+
if (!credentialStatusResolveOptions?.issuerDID) {
|
|
114
|
+
throw new Error('IssuerDID is not set in options');
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
try {
|
|
118
|
+
return await this.getStatus(
|
|
119
|
+
credentialStatus,
|
|
120
|
+
credentialStatusResolveOptions.issuerDID,
|
|
121
|
+
credentialStatusResolveOptions.issuerData,
|
|
122
|
+
credentialStatusResolveOptions.issuerGenesisState
|
|
123
|
+
);
|
|
124
|
+
} catch (e: unknown) {
|
|
125
|
+
if (credentialStatus?.statusIssuer?.type === CredentialStatusType.SparseMerkleTreeProof) {
|
|
126
|
+
try {
|
|
127
|
+
return await new IssuerResolver().resolve(credentialStatus.statusIssuer);
|
|
128
|
+
} catch (e) {
|
|
129
|
+
throw new Error(
|
|
130
|
+
`can't fetch revocation status from backup endpoint: ${(e as Error)?.message}`
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
throw new Error(`can't fetch revocation status: ${(e as Error)?.message}`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Gets revocation status from rhs service.
|
|
140
|
+
* @param {CredentialStatus} credentialStatus
|
|
141
|
+
* @param {DID} issuerDID
|
|
142
|
+
* @param {IssuerData} issuerData
|
|
143
|
+
* @returns Promise<RevocationStatus>
|
|
144
|
+
*/
|
|
145
|
+
private async getStatus(
|
|
146
|
+
credentialStatus: CredentialStatus,
|
|
147
|
+
issuerDID: DID,
|
|
148
|
+
issuerData?: {
|
|
149
|
+
state: {
|
|
150
|
+
rootOfRoots: string;
|
|
151
|
+
claimsTreeRoot: string;
|
|
152
|
+
revocationTreeRoot: string;
|
|
153
|
+
value: string;
|
|
154
|
+
};
|
|
155
|
+
},
|
|
156
|
+
genesisState?: State
|
|
157
|
+
): Promise<RevocationStatus> {
|
|
158
|
+
const issuerId = DID.idFromDID(issuerDID);
|
|
159
|
+
|
|
160
|
+
let latestState: bigint;
|
|
161
|
+
try {
|
|
162
|
+
const latestStateInfo = await this._state.getLatestStateById(issuerId.bigInt());
|
|
163
|
+
if (!latestStateInfo.state) {
|
|
164
|
+
throw new Error('state contract returned empty state');
|
|
165
|
+
}
|
|
166
|
+
latestState = latestStateInfo.state;
|
|
167
|
+
} catch (e) {
|
|
168
|
+
if (!isIdentityDoesNotExistError(e)) {
|
|
169
|
+
throw e;
|
|
170
|
+
}
|
|
171
|
+
const stateHex = this.extractState(credentialStatus.id);
|
|
172
|
+
if (!stateHex) {
|
|
173
|
+
return this.getRevocationStatusFromIssuerData(issuerDID, issuerData, genesisState);
|
|
174
|
+
}
|
|
175
|
+
const currentStateBigInt = Hash.fromHex(stateHex).bigInt();
|
|
176
|
+
|
|
177
|
+
const isEthIdentity = isEthereumIdentity(issuerDID);
|
|
178
|
+
|
|
179
|
+
if (!isEthIdentity && !isGenesisState(issuerDID, currentStateBigInt)) {
|
|
180
|
+
throw new Error(
|
|
181
|
+
`latest state not found and state parameter ${stateHex} is not genesis state`
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (isEthIdentity) {
|
|
186
|
+
throw new Error(`State must be published for Ethereum based identity`);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
latestState = currentStateBigInt;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const rhsHost = credentialStatus.id.split('/node')[0];
|
|
193
|
+
const hashedRevNonce = Hash.fromBigInt(BigInt(credentialStatus.revocationNonce ?? 0));
|
|
194
|
+
const hashedIssuerRoot = Hash.fromBigInt(latestState);
|
|
195
|
+
return await this.getRevocationStatusFromRHS(hashedRevNonce, hashedIssuerRoot, rhsHost);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Extract revocation status from issuer data.
|
|
200
|
+
* @param {DID} issuerDID
|
|
201
|
+
* @param {IssuerData} issuerData
|
|
202
|
+
*/
|
|
203
|
+
private getRevocationStatusFromIssuerData(
|
|
204
|
+
issuerDID: DID,
|
|
205
|
+
issuerData?: {
|
|
206
|
+
state: {
|
|
207
|
+
rootOfRoots: string;
|
|
208
|
+
claimsTreeRoot: string;
|
|
209
|
+
revocationTreeRoot: string;
|
|
210
|
+
value: string;
|
|
211
|
+
};
|
|
212
|
+
},
|
|
213
|
+
genesisState?: State
|
|
214
|
+
): RevocationStatus {
|
|
215
|
+
if (!!genesisState && isGenesisState(issuerDID, genesisState.value.bigInt())) {
|
|
216
|
+
return {
|
|
217
|
+
mtp: new Proof(),
|
|
218
|
+
issuer: {
|
|
219
|
+
state: genesisState.value.hex(),
|
|
220
|
+
revocationTreeRoot: genesisState.revocationTreeRoot.hex(),
|
|
221
|
+
rootOfRoots: genesisState.rootOfRoots.hex(),
|
|
222
|
+
claimsTreeRoot: genesisState.claimsTreeRoot.hex()
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// legacy
|
|
228
|
+
if (!!issuerData && isGenesisState(issuerDID, issuerData.state.value)) {
|
|
229
|
+
return {
|
|
230
|
+
mtp: new Proof(),
|
|
231
|
+
issuer: {
|
|
232
|
+
state: issuerData.state.value,
|
|
233
|
+
revocationTreeRoot: issuerData.state.revocationTreeRoot,
|
|
234
|
+
rootOfRoots: issuerData.state.rootOfRoots,
|
|
235
|
+
claimsTreeRoot: issuerData.state.claimsTreeRoot
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
throw new Error(`issuer data / genesis state param is empty`);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Gets partial revocation status info from rhs service.
|
|
244
|
+
*
|
|
245
|
+
* @param {Hash} data - hash to fetch
|
|
246
|
+
* @param {Hash} issuerRoot - issuer root which is a part of url
|
|
247
|
+
* @param {string} rhsUrl - base URL for reverse hash service
|
|
248
|
+
* @returns Promise<RevocationStatus>
|
|
249
|
+
*/
|
|
250
|
+
private async getRevocationStatusFromRHS(
|
|
251
|
+
data: Hash,
|
|
252
|
+
issuerRoot: Hash,
|
|
253
|
+
rhsUrl: string
|
|
254
|
+
): Promise<RevocationStatus> {
|
|
255
|
+
if (!rhsUrl) throw new Error('HTTP reverse hash service URL is not specified');
|
|
256
|
+
|
|
257
|
+
const resp = await fetch(`${rhsUrl}/node/${issuerRoot.hex()}`);
|
|
258
|
+
const treeRoots = ((await resp.json()) as NodeHexResponse)?.node;
|
|
259
|
+
if (treeRoots.children.length !== 3) {
|
|
260
|
+
throw new Error('state should has tree children');
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
const s = issuerRoot.hex();
|
|
264
|
+
const [cTR, rTR, roTR] = treeRoots.children;
|
|
265
|
+
|
|
266
|
+
const rtrHashed = Hash.fromHex(rTR);
|
|
267
|
+
const nonRevProof = await this.rhsGenerateProof(rtrHashed, data, `${rhsUrl}/node`);
|
|
268
|
+
|
|
269
|
+
return {
|
|
270
|
+
mtp: nonRevProof,
|
|
271
|
+
issuer: {
|
|
272
|
+
state: s,
|
|
273
|
+
claimsTreeRoot: cTR,
|
|
274
|
+
revocationTreeRoot: rTR,
|
|
275
|
+
rootOfRoots: roTR
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
async rhsGenerateProof(treeRoot: Hash, key: Hash, rhsUrl: string): Promise<Proof> {
|
|
281
|
+
let existence = false;
|
|
282
|
+
const siblings: Hash[] = [];
|
|
283
|
+
let nodeAux: NodeAux;
|
|
284
|
+
|
|
285
|
+
const mkProof = () => new Proof({ siblings, existence, nodeAux });
|
|
286
|
+
|
|
287
|
+
let nextKey = treeRoot;
|
|
288
|
+
for (let depth = 0; depth < key.bytes.length * 8; depth++) {
|
|
289
|
+
if (nextKey.bytes.every((i) => i === 0)) {
|
|
290
|
+
return mkProof();
|
|
291
|
+
}
|
|
292
|
+
const data = await fetch(`${rhsUrl}/${nextKey.hex()}`);
|
|
293
|
+
const resp = ((await data.json()) as NodeHexResponse)?.node;
|
|
294
|
+
|
|
295
|
+
const n = ProofNode.fromHex(resp);
|
|
296
|
+
switch (n.nodeType()) {
|
|
297
|
+
case NodeType.Leaf:
|
|
298
|
+
if (key.bytes.every((b, index) => b === n.children[0].bytes[index])) {
|
|
299
|
+
existence = true;
|
|
300
|
+
return mkProof();
|
|
301
|
+
}
|
|
302
|
+
// We found a leaf whose entry didn't match hIndex
|
|
303
|
+
nodeAux = {
|
|
304
|
+
key: n.children[0],
|
|
305
|
+
value: n.children[1]
|
|
306
|
+
};
|
|
307
|
+
return mkProof();
|
|
308
|
+
case NodeType.Middle:
|
|
309
|
+
if (testBit(key.bytes, depth)) {
|
|
310
|
+
nextKey = n.children[1];
|
|
311
|
+
siblings.push(n.children[0]);
|
|
312
|
+
} else {
|
|
313
|
+
nextKey = n.children[0];
|
|
314
|
+
siblings.push(n.children[1]);
|
|
315
|
+
}
|
|
316
|
+
break;
|
|
317
|
+
default:
|
|
318
|
+
throw new Error(`found unexpected node type in tree ${n.hash.hex()}`);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
throw new Error('tree depth is too high');
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Get state param from rhs url
|
|
327
|
+
* @param {string} id
|
|
328
|
+
* @returns string | null
|
|
329
|
+
*/
|
|
330
|
+
private extractState(id: string): string | null {
|
|
331
|
+
const u = new URL(id);
|
|
332
|
+
return u.searchParams.get('state');
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* @deprecated The method should not be used. Use isGenesisState instead.
|
|
338
|
+
* Checks if issuer did is created from given state is genesis
|
|
339
|
+
*
|
|
340
|
+
* @param {string} issuer - did (string)
|
|
341
|
+
* @param {string} state - hex state
|
|
342
|
+
* @returns boolean
|
|
343
|
+
*/
|
|
344
|
+
export function isIssuerGenesis(issuer: string, state: string): boolean {
|
|
345
|
+
const did = DID.parse(issuer);
|
|
346
|
+
const id = DID.idFromDID(did);
|
|
347
|
+
const { method, blockchain, networkId } = DID.decodePartsFromId(id);
|
|
348
|
+
const arr = BytesHelper.hexToBytes(state);
|
|
349
|
+
const stateBigInt = BytesHelper.bytesToInt(arr);
|
|
350
|
+
const type = buildDIDType(method, blockchain, networkId);
|
|
351
|
+
return isGenesisStateId(DID.idFromDID(did).bigInt(), stateBigInt, type);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* @deprecated The method should not be used. Use isGenesisState instead.
|
|
356
|
+
* Checks if id is created from given state and type is genesis
|
|
357
|
+
*
|
|
358
|
+
* @param {bigint} id
|
|
359
|
+
* @param {bigint} state
|
|
360
|
+
* @param {Uint8Array} type
|
|
361
|
+
* @returns boolean - returns if id is genesis
|
|
362
|
+
*/
|
|
363
|
+
export function isGenesisStateId(id: bigint, state: bigint, type: Uint8Array): boolean {
|
|
364
|
+
const idFromState = Id.idGenesisFromIdenState(type, state);
|
|
365
|
+
return id.toString() === idFromState.bigInt().toString();
|
|
366
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { CredentialStatus, RevocationStatus, Issuer } from '../../verifiable';
|
|
2
|
+
import { CredentialStatusResolver } from './resolver';
|
|
3
|
+
import { Proof, ProofJSON } from '@iden3/js-merkletree';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* IssuerResolver is a class that allows to interact with the issuer's http endpoint to get revocation status.
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
* @class IssuerResolver
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export class IssuerResolver implements CredentialStatusResolver {
|
|
13
|
+
/**
|
|
14
|
+
* resolve is a method to resolve a credential status directly from the issuer.
|
|
15
|
+
*
|
|
16
|
+
* @public
|
|
17
|
+
* @param {CredentialStatus} credentialStatus - credential status to resolve
|
|
18
|
+
* @param {CredentialStatusResolveOptions} credentialStatusResolveOptions - options for resolver
|
|
19
|
+
* @returns `{Promise<RevocationStatus>}`
|
|
20
|
+
*/
|
|
21
|
+
async resolve(credentialStatus: CredentialStatus): Promise<RevocationStatus> {
|
|
22
|
+
const revStatusResp = await fetch(credentialStatus.id);
|
|
23
|
+
const revStatus = await revStatusResp.json();
|
|
24
|
+
return toRevocationStatus(revStatus);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* RevocationStatusResponse is a response of fetching credential status with type SparseMerkleTreeProof
|
|
30
|
+
*
|
|
31
|
+
* @export
|
|
32
|
+
* @interface RevocationStatusResponse
|
|
33
|
+
*/
|
|
34
|
+
export interface RevocationStatusResponse {
|
|
35
|
+
issuer: Issuer;
|
|
36
|
+
mtp: ProofJSON;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* toRevocationStatus is a result of fetching credential status with type SparseMerkleTreeProof converts to RevocationStatus
|
|
41
|
+
*
|
|
42
|
+
* @param {RevocationStatusResponse} { issuer, mtp }
|
|
43
|
+
* @returns {RevocationStatus} RevocationStatus
|
|
44
|
+
*/
|
|
45
|
+
export const toRevocationStatus = ({ issuer, mtp }: RevocationStatusResponse): RevocationStatus => {
|
|
46
|
+
return {
|
|
47
|
+
mtp: Proof.fromJSON(mtp),
|
|
48
|
+
issuer
|
|
49
|
+
};
|
|
50
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { DID } from '@mocanetwork/moca-iden3';
|
|
2
|
+
import { W3CCredential } from '../verifiable';
|
|
3
|
+
import { PublicKey } from '@iden3/js-crypto';
|
|
4
|
+
import { KmsKeyId, KmsKeyType, keyPath } from '../kms';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Retrieves the user DID from a given credential.
|
|
8
|
+
* If the credential does not have a credentialSubject.id property, the issuer DID is returned.
|
|
9
|
+
* If the credentialSubject.id is not a string, an error is thrown.
|
|
10
|
+
* @param issuerDID The DID of the issuer.
|
|
11
|
+
* @param credential The credential object.
|
|
12
|
+
* @returns The user DID parsed from the credential.
|
|
13
|
+
* @throws Error if the credentialSubject.id is not a string.
|
|
14
|
+
*/
|
|
15
|
+
export const getUserDIDFromCredential = (issuerDID: DID, credential: W3CCredential) => {
|
|
16
|
+
if (!credential.credentialSubject.id) {
|
|
17
|
+
return issuerDID;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (typeof credential.credentialSubject.id !== 'string') {
|
|
21
|
+
throw new Error('credential subject `id` is not a string');
|
|
22
|
+
}
|
|
23
|
+
return DID.parse(credential.credentialSubject.id);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const getKMSIdByAuthCredential = (credential: W3CCredential): KmsKeyId => {
|
|
27
|
+
if (!credential.type.includes('AuthBJJCredential')) {
|
|
28
|
+
throw new Error("can't sign with not AuthBJJCredential credential");
|
|
29
|
+
}
|
|
30
|
+
const x = credential.credentialSubject['x'] as string;
|
|
31
|
+
const y = credential.credentialSubject['y'] as string;
|
|
32
|
+
|
|
33
|
+
const pb: PublicKey = new PublicKey([BigInt(x), BigInt(y)]);
|
|
34
|
+
const kp = keyPath(KmsKeyType.BabyJubJub, pb.hex());
|
|
35
|
+
return { type: KmsKeyType.BabyJubJub, id: kp };
|
|
36
|
+
};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { AcceptProfile } from './types';
|
|
2
|
+
|
|
3
|
+
const IDEN3_PROTOCOL = 'https://iden3-communication.io/';
|
|
4
|
+
const DIDCOMM_PROTOCOL = 'https://didcomm.org/';
|
|
5
|
+
/**
|
|
6
|
+
* Constants for Iden3 protocol
|
|
7
|
+
*/
|
|
8
|
+
export const PROTOCOL_MESSAGE_TYPE = Object.freeze({
|
|
9
|
+
// AuthorizationV2RequestMessageType defines auth request type of the communication protocol
|
|
10
|
+
AUTHORIZATION_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}authorization/1.0/request` as const,
|
|
11
|
+
// AuthorizationResponseMessageType defines auth response type of the communication protocol
|
|
12
|
+
AUTHORIZATION_RESPONSE_MESSAGE_TYPE: `${IDEN3_PROTOCOL}authorization/1.0/response` as const,
|
|
13
|
+
// CredentialIssuanceRequestMessageType accepts request for credential creation
|
|
14
|
+
CREDENTIAL_ISSUANCE_REQUEST_MESSAGE_TYPE:
|
|
15
|
+
`${IDEN3_PROTOCOL}credentials/1.0/issuance-request` as const,
|
|
16
|
+
// CredentialFetchRequestMessageType is type for request of credential generation
|
|
17
|
+
CREDENTIAL_FETCH_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/1.0/fetch-request` as const,
|
|
18
|
+
// CredentialOfferMessageType is type of message with credential offering
|
|
19
|
+
CREDENTIAL_OFFER_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/1.0/offer` as const,
|
|
20
|
+
// CredentialIssuanceResponseMessageType is type for message with a credential issuance
|
|
21
|
+
CREDENTIAL_ISSUANCE_RESPONSE_MESSAGE_TYPE:
|
|
22
|
+
`${IDEN3_PROTOCOL}credentials/1.0/issuance-response` as const,
|
|
23
|
+
// CredentialRefreshMessageType is type for message with a credential issuance
|
|
24
|
+
CREDENTIAL_REFRESH_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/1.0/refresh` as const,
|
|
25
|
+
// DeviceRegistrationRequestMessageType defines device registration request type of the communication protocol
|
|
26
|
+
DEVICE_REGISTRATION_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}devices/1.0/registration` as const,
|
|
27
|
+
// MessageFetMessageFetchRequestMessageType defines message fetch request type of the communication protocol.
|
|
28
|
+
MESSAGE_FETCH_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}messages/1.0/fetch` as const,
|
|
29
|
+
// ProofGenerationRequestMessageType is type for request of proof generation
|
|
30
|
+
PROOF_GENERATION_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}proofs/1.0/request` as const,
|
|
31
|
+
// ProofGenerationResponseMessageType is type for response of proof generation
|
|
32
|
+
PROOF_GENERATION_RESPONSE_MESSAGE_TYPE: `${IDEN3_PROTOCOL}proofs/1.0/response` as const,
|
|
33
|
+
// RevocationStatusRequestMessageType is type for request of revocation status
|
|
34
|
+
REVOCATION_STATUS_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}revocation/1.0/request-status` as const,
|
|
35
|
+
// RevocationStatusResponseMessageType is type for response with a revocation status
|
|
36
|
+
REVOCATION_STATUS_RESPONSE_MESSAGE_TYPE: `${IDEN3_PROTOCOL}revocation/1.0/status` as const,
|
|
37
|
+
// ContractInvokeRequestMessageType is type for request of contract invoke request
|
|
38
|
+
CONTRACT_INVOKE_REQUEST_MESSAGE_TYPE:
|
|
39
|
+
`${IDEN3_PROTOCOL}proofs/1.0/contract-invoke-request` as const,
|
|
40
|
+
// ContractInvokeResponseMessageType is type for response of contract invoke request
|
|
41
|
+
CONTRACT_INVOKE_RESPONSE_MESSAGE_TYPE:
|
|
42
|
+
`${IDEN3_PROTOCOL}proofs/1.0/contract-invoke-response` as const,
|
|
43
|
+
// CredentialOnchainOfferMessageType is type of message with credential onchain offering
|
|
44
|
+
CREDENTIAL_ONCHAIN_OFFER_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/1.0/onchain-offer` as const,
|
|
45
|
+
// ProposalRequestMessageType is type for proposal-request message
|
|
46
|
+
PROPOSAL_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/0.1/proposal-request` as const,
|
|
47
|
+
// ProposalMessageType is type for proposal message
|
|
48
|
+
PROPOSAL_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/0.1/proposal` as const,
|
|
49
|
+
// PaymentRequestMessageType is type for payment-request message
|
|
50
|
+
PAYMENT_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/0.1/payment-request` as const,
|
|
51
|
+
// PaymentMessageType is type for payment message
|
|
52
|
+
PAYMENT_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/0.1/payment` as const,
|
|
53
|
+
// DiscoveryProtocolQueriesMessageType is type for didcomm discovery protocol queries
|
|
54
|
+
DISCOVERY_PROTOCOL_QUERIES_MESSAGE_TYPE:
|
|
55
|
+
`${DIDCOMM_PROTOCOL}discover-features/2.0/queries` as const,
|
|
56
|
+
// DiscoveryProtocolDiscloseMessageType is type for didcomm discovery protocol disclose
|
|
57
|
+
DISCOVERY_PROTOCOL_DISCLOSE_MESSAGE_TYPE:
|
|
58
|
+
`${DIDCOMM_PROTOCOL}discover-features/2.0/disclose` as const,
|
|
59
|
+
// ProblemReportMessageType is type for didcomm problem report
|
|
60
|
+
PROBLEM_REPORT_MESSAGE_TYPE: `${DIDCOMM_PROTOCOL}report-problem/2.0/problem-report` as const
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Media types for iden3 comm communication protocol
|
|
65
|
+
*
|
|
66
|
+
* @enum {number}
|
|
67
|
+
*/
|
|
68
|
+
export enum MediaType {
|
|
69
|
+
ZKPMessage = 'application/iden3-zkp-json',
|
|
70
|
+
PlainMessage = 'application/iden3comm-plain-json',
|
|
71
|
+
SignedMessage = 'application/iden3comm-signed-json'
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export const SUPPORTED_PUBLIC_KEY_TYPES = {
|
|
75
|
+
ES256K: [
|
|
76
|
+
'EcdsaSecp256k1VerificationKey2019',
|
|
77
|
+
/**
|
|
78
|
+
* Equivalent to EcdsaSecp256k1VerificationKey2019 when key is an ethereumAddress
|
|
79
|
+
*/
|
|
80
|
+
'EcdsaSecp256k1RecoveryMethod2020',
|
|
81
|
+
'JsonWebKey2020'
|
|
82
|
+
],
|
|
83
|
+
'ES256K-R': [
|
|
84
|
+
'EcdsaSecp256k1VerificationKey2019',
|
|
85
|
+
/**
|
|
86
|
+
* Equivalent to EcdsaSecp256k1VerificationKey2019 when key is an ethereumAddress
|
|
87
|
+
*/
|
|
88
|
+
'EcdsaSecp256k1RecoveryMethod2020',
|
|
89
|
+
'JsonWebKey2020'
|
|
90
|
+
]
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export enum ProtocolVersion {
|
|
94
|
+
V1 = 'iden3comm/v1'
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export enum AcceptAuthCircuits {
|
|
98
|
+
AuthV2 = 'authV2',
|
|
99
|
+
AuthV3 = 'authV3'
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export enum AcceptJwzAlgorithms {
|
|
103
|
+
Groth16 = 'groth16'
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export enum AcceptJwsAlgorithms {
|
|
107
|
+
ES256K = 'ES256K',
|
|
108
|
+
ES256KR = 'ES256K-R'
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export const defaultAcceptProfile: AcceptProfile = {
|
|
112
|
+
protocolVersion: ProtocolVersion.V1,
|
|
113
|
+
env: MediaType.ZKPMessage,
|
|
114
|
+
circuits: [AcceptAuthCircuits.AuthV2],
|
|
115
|
+
alg: [AcceptJwzAlgorithms.Groth16]
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export const DEFAULT_PROOF_VERIFY_DELAY = 1 * 60 * 60 * 1000; // 1 hour
|
|
119
|
+
export const DEFAULT_AUTH_VERIFY_DELAY = 5 * 60 * 1000; // 5 minutes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Envelope Errors
|
|
2
|
+
export const ErrNotProtocolMessage = 'the envelope is not a protocol message';
|
|
3
|
+
export const ErrNotEnvelopeStub = "the envelope doesn't contain field protected";
|
|
4
|
+
export const ErrNotHeaderStub = "the envelope doesn't contain field typ";
|
|
5
|
+
|
|
6
|
+
// Token Errors
|
|
7
|
+
export const ErrUnknownCircuitID = "unknown circuit ID. can't verify msg sender";
|
|
8
|
+
export const ErrSenderNotUsedTokenCreation = 'sender of message is not used for jwz token creation';
|
|
9
|
+
|
|
10
|
+
// ZKP-Packer Errors
|
|
11
|
+
export const ErrPackedWithUnsupportedCircuit = 'message was packed with unsupported circuit';
|
|
12
|
+
export const ErrProofIsInvalid = 'message proof is invalid';
|
|
13
|
+
export const ErrStateVerificationFailed = 'message state verification failed';
|
|
14
|
+
export const ErrNoProvingMethodAlg = 'unknown proving method algorithm';
|