@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,20 @@
|
|
|
1
|
+
import { ProofData } from '@iden3/js-jwz';
|
|
2
|
+
import { ethers } from 'ethers';
|
|
3
|
+
|
|
4
|
+
export const packZkpProof = (inputs: string[], a: string[], b: string[][], c: string[]): string => {
|
|
5
|
+
return new ethers.AbiCoder().encode(
|
|
6
|
+
['uint256[] inputs', 'uint256[2]', 'uint256[2][2]', 'uint256[2]'],
|
|
7
|
+
[inputs, a, b, c]
|
|
8
|
+
);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const prepareZkpProof = (proof: ProofData): { a: string[]; b: string[][]; c: string[] } => {
|
|
12
|
+
return {
|
|
13
|
+
a: proof.pi_a.slice(0, 2),
|
|
14
|
+
b: [
|
|
15
|
+
[proof.pi_b[0][1], proof.pi_b[0][0]],
|
|
16
|
+
[proof.pi_b[1][1], proof.pi_b[1][0]]
|
|
17
|
+
],
|
|
18
|
+
c: proof.pi_c.slice(0, 2)
|
|
19
|
+
};
|
|
20
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { Hash } from '@iden3/js-merkletree';
|
|
2
|
+
import { DIDDocument, VerificationMethod } from '../../iden3comm';
|
|
3
|
+
import { resolveDidDocument } from '../../utils';
|
|
4
|
+
import { RootInfo, StateInfo, StateProof } from '../entities';
|
|
5
|
+
import { IStateStorage } from '../interfaces';
|
|
6
|
+
import { DID, Id } from '@mocanetwork/moca-iden3';
|
|
7
|
+
import { JsonRpcProvider } from 'ethers';
|
|
8
|
+
|
|
9
|
+
export class DidResolverStateReadonlyStorage implements IStateStorage {
|
|
10
|
+
constructor(private readonly resolverUrl: string) {}
|
|
11
|
+
async getLatestStateById(id: bigint): Promise<StateInfo> {
|
|
12
|
+
return this.getStateInfo(id);
|
|
13
|
+
}
|
|
14
|
+
async getStateInfoByIdAndState(id: bigint, state: bigint): Promise<StateInfo> {
|
|
15
|
+
return this.getStateInfo(id, state);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async getGISTProof(id: bigint): Promise<StateProof> {
|
|
19
|
+
const { didDocument } = await resolveDidDocument(
|
|
20
|
+
DID.parseFromId(Id.fromBigInt(id)),
|
|
21
|
+
this.resolverUrl
|
|
22
|
+
);
|
|
23
|
+
const { global } = this.getIden3StateInfo2023(didDocument);
|
|
24
|
+
if (!global) {
|
|
25
|
+
throw new Error('GIST root not found');
|
|
26
|
+
}
|
|
27
|
+
const { proof } = global;
|
|
28
|
+
if (!proof) {
|
|
29
|
+
throw new Error('GIST proof not found');
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
root: global.root,
|
|
33
|
+
existence: proof.existence,
|
|
34
|
+
siblings: proof.siblings?.map((sibling) => BigInt(sibling)),
|
|
35
|
+
index: BigInt(0),
|
|
36
|
+
value: BigInt(0),
|
|
37
|
+
auxExistence: !!proof.node_aux,
|
|
38
|
+
auxIndex: proof.node_aux ? BigInt(proof.node_aux.key) : BigInt(0),
|
|
39
|
+
auxValue: proof.node_aux ? BigInt(proof.node_aux.value) : BigInt(0)
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async getGISTRootInfo(root: bigint, userId: bigint): Promise<RootInfo> {
|
|
44
|
+
const { didDocument } = await resolveDidDocument(
|
|
45
|
+
DID.parseFromId(Id.fromBigInt(userId)),
|
|
46
|
+
this.resolverUrl,
|
|
47
|
+
{
|
|
48
|
+
gist: Hash.fromBigInt(root)
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
const { global } = this.getIden3StateInfo2023(didDocument);
|
|
52
|
+
if (!global) {
|
|
53
|
+
throw new Error('GIST root not found');
|
|
54
|
+
}
|
|
55
|
+
return global;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
getRpcProvider(): JsonRpcProvider {
|
|
59
|
+
return new JsonRpcProvider();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
publishState(): Promise<string> {
|
|
63
|
+
throw new Error('publishState method not implemented.');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
publishStateGeneric(): Promise<string> {
|
|
67
|
+
throw new Error('publishStateGeneric method not implemented.');
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
private async getStateInfo(id: bigint, state?: bigint): Promise<StateInfo> {
|
|
71
|
+
const opts = state ? { state: Hash.fromBigInt(state) } : undefined;
|
|
72
|
+
const { didDocument } = await resolveDidDocument(
|
|
73
|
+
DID.parseFromId(Id.fromBigInt(id)),
|
|
74
|
+
this.resolverUrl,
|
|
75
|
+
opts
|
|
76
|
+
);
|
|
77
|
+
const { info } = this.getIden3StateInfo2023(didDocument);
|
|
78
|
+
return { ...info };
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
private getIden3StateInfo2023(didDocument: DIDDocument): VerificationMethod {
|
|
82
|
+
const vm: VerificationMethod | undefined = didDocument.verificationMethod?.find(
|
|
83
|
+
(i: VerificationMethod) => i.type === 'Iden3StateInfo2023'
|
|
84
|
+
);
|
|
85
|
+
if (!vm) {
|
|
86
|
+
throw new Error('Iden3StateInfo2023 verification method not found');
|
|
87
|
+
}
|
|
88
|
+
return vm;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Contract, Signer, ethers } from 'ethers';
|
|
2
|
+
|
|
3
|
+
import permitAbi from './abi/ERC20Permit.json';
|
|
4
|
+
import erc20Abi from './abi/ERC20.json';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @beta
|
|
8
|
+
* getPermitSignature is a function to create EIP712 Permit signature
|
|
9
|
+
* @param {Signer} signer - User who owns the tokens
|
|
10
|
+
* @param {string} tokenAddress - EIP-2612 contract address
|
|
11
|
+
* @param {string} spender - The contract address that will spend tokens
|
|
12
|
+
* @param {bigint} value - Amount of tokens to approve
|
|
13
|
+
* @param {number} deadline - Timestamp when the permit expires
|
|
14
|
+
* @returns {Promise<PaymentRequestMessage>}
|
|
15
|
+
*/
|
|
16
|
+
export async function getPermitSignature(
|
|
17
|
+
signer: Signer,
|
|
18
|
+
tokenAddress: string,
|
|
19
|
+
spender: string,
|
|
20
|
+
value: bigint,
|
|
21
|
+
deadline: number
|
|
22
|
+
) {
|
|
23
|
+
const erc20PermitContract = new Contract(tokenAddress, permitAbi, signer);
|
|
24
|
+
const nonce = await erc20PermitContract.nonces(await signer.getAddress());
|
|
25
|
+
const domainData = await erc20PermitContract.eip712Domain();
|
|
26
|
+
const domain = {
|
|
27
|
+
name: domainData[1],
|
|
28
|
+
version: domainData[2],
|
|
29
|
+
chainId: domainData[3],
|
|
30
|
+
verifyingContract: tokenAddress
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const types = {
|
|
34
|
+
Permit: [
|
|
35
|
+
{ name: 'owner', type: 'address' },
|
|
36
|
+
{ name: 'spender', type: 'address' },
|
|
37
|
+
{ name: 'value', type: 'uint256' },
|
|
38
|
+
{ name: 'nonce', type: 'uint256' },
|
|
39
|
+
{ name: 'deadline', type: 'uint256' }
|
|
40
|
+
]
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const message = {
|
|
44
|
+
owner: await signer.getAddress(),
|
|
45
|
+
spender: spender,
|
|
46
|
+
value: value,
|
|
47
|
+
nonce: nonce,
|
|
48
|
+
deadline: deadline
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
return signer.signTypedData(domain, types, message);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @beta
|
|
56
|
+
* getERC20Decimals is a function to retrieve the number of decimals of an ERC20 token
|
|
57
|
+
* @param {string} tokenAddress - Token address
|
|
58
|
+
* @param {ethers.ContractRunner} runner - Contract runner
|
|
59
|
+
*/
|
|
60
|
+
export async function getERC20Decimals(
|
|
61
|
+
tokenAddress: string,
|
|
62
|
+
runner: ethers.ContractRunner
|
|
63
|
+
): Promise<number> {
|
|
64
|
+
const erc20Contract = new Contract(tokenAddress, erc20Abi, runner);
|
|
65
|
+
return erc20Contract.decimals();
|
|
66
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { VerifiableConstants } from '../../verifiable';
|
|
2
|
+
|
|
3
|
+
interface ErrorWithArgs {
|
|
4
|
+
errorArgs: string[];
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function isErrorWithArgs(error: unknown): error is ErrorWithArgs {
|
|
8
|
+
return (
|
|
9
|
+
typeof error === 'object' &&
|
|
10
|
+
error !== null &&
|
|
11
|
+
'errorArgs' in error &&
|
|
12
|
+
Array.isArray((error as ErrorWithArgs).errorArgs)
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function extractErrorMessage(error: unknown): string {
|
|
17
|
+
const errorArgs = isErrorWithArgs(error) ? error.errorArgs[0] : undefined;
|
|
18
|
+
const errMsg = errorArgs || (error instanceof Error ? error.message : '');
|
|
19
|
+
return errMsg;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function isError(error: unknown, errorMsg: string): boolean {
|
|
23
|
+
const errMsg = extractErrorMessage(error);
|
|
24
|
+
return errMsg.includes(errorMsg);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function isIdentityDoesNotExistError(error: unknown): boolean {
|
|
28
|
+
return (
|
|
29
|
+
isError(error, VerifiableConstants.ERRORS.IDENTITY_DOES_NOT_EXIST) ||
|
|
30
|
+
isError(error, VerifiableConstants.ERRORS.IDENTITY_DOES_NOT_EXIST_CUSTOM_ERROR)
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function isStateDoesNotExistError(error: unknown): boolean {
|
|
35
|
+
return (
|
|
36
|
+
isError(error, VerifiableConstants.ERRORS.STATE_DOES_NOT_EXIST) ||
|
|
37
|
+
isError(error, VerifiableConstants.ERRORS.STATE_DOES_NOT_EXIST_CUSTOM_ERROR)
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function isRootDoesNotExistError(error: unknown): boolean {
|
|
42
|
+
return (
|
|
43
|
+
isError(error, VerifiableConstants.ERRORS.ROOT_DOES_NOT_EXIST) ||
|
|
44
|
+
isError(error, VerifiableConstants.ERRORS.ROOT_DOES_NOT_EXIST_CUSTOM_ERROR)
|
|
45
|
+
);
|
|
46
|
+
}
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
import { Claim, DID, Id } from '@mocanetwork/moca-iden3';
|
|
2
|
+
import { NonMerklizedIssuerBase__factory } from '@iden3/onchain-non-merklized-issuer-base-abi';
|
|
3
|
+
import { NonMerklizedIssuerBase } from '@iden3/onchain-non-merklized-issuer-base-abi';
|
|
4
|
+
import { INonMerklizedIssuer } from '@iden3/onchain-non-merklized-issuer-base-abi';
|
|
5
|
+
import {
|
|
6
|
+
CredentialStatusType,
|
|
7
|
+
DisplayMethod,
|
|
8
|
+
DisplayMethodType,
|
|
9
|
+
Iden3SparseMerkleTreeProof,
|
|
10
|
+
W3CCredential
|
|
11
|
+
} from '../../../../../../verifiable';
|
|
12
|
+
import { Merklizer, Path } from '@iden3/js-jsonld-merklization';
|
|
13
|
+
import { XSDNS } from '../../../../../../circuits';
|
|
14
|
+
import { Hash, Proof } from '@iden3/js-merkletree';
|
|
15
|
+
import { JsonDocumentObject } from '../../../../../../iden3comm';
|
|
16
|
+
import { ethers } from 'ethers';
|
|
17
|
+
import { getDateFromUnixTimestamp } from '@mocanetwork/moca-iden3';
|
|
18
|
+
import { Options } from '@iden3/js-jsonld-merklization';
|
|
19
|
+
import { EthConnectionConfig } from '../../../../state';
|
|
20
|
+
|
|
21
|
+
enum NonMerklizedIssuerInterfaces {
|
|
22
|
+
InterfaceDetection = '0x01ffc9a7',
|
|
23
|
+
InterfaceNonMerklizedIssuer = '0x58874949',
|
|
24
|
+
InterfaceGetCredential = '0x5d1ca631'
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
enum ValueHashes {
|
|
28
|
+
BooleanTrue = '18586133768512220936620570745912940619677854269274689475585506675881198879027',
|
|
29
|
+
BooleanFalse = '19014214495641488759237505126948346942972912379615652741039992445865937985820'
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* `OnchainNonMerklizedIssuerAdapter` provides functionality to interact with a non-merklized on-chain credential issuer.
|
|
34
|
+
* This adapter enables interface detection, credential retrieval, and conversion to the W3C Verifiable Credential format.
|
|
35
|
+
*
|
|
36
|
+
* @public
|
|
37
|
+
* @beta
|
|
38
|
+
* @class OnchainNonMerklizedIssuerAdapter
|
|
39
|
+
*/
|
|
40
|
+
export class OnchainNonMerklizedIssuerAdapter {
|
|
41
|
+
private readonly _contract: NonMerklizedIssuerBase;
|
|
42
|
+
private readonly _contractAddress: string;
|
|
43
|
+
private readonly _chainId: number;
|
|
44
|
+
|
|
45
|
+
private readonly _issuerDid: DID;
|
|
46
|
+
|
|
47
|
+
private readonly _merklizationOptions?: Options;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Initializes an instance of `OnchainNonMerklizedIssuerAdapter`.
|
|
51
|
+
*
|
|
52
|
+
* @param ethConnectionConfig The configuration for the Ethereum connection.
|
|
53
|
+
* @param issuerDid The decentralized identifier (DID) of the issuer.
|
|
54
|
+
* @param merklizationOptions Optional settings for merklization.
|
|
55
|
+
*/
|
|
56
|
+
constructor(
|
|
57
|
+
ethConnectionConfig: EthConnectionConfig,
|
|
58
|
+
issuerDid: DID,
|
|
59
|
+
options?: {
|
|
60
|
+
merklizationOptions?: Options;
|
|
61
|
+
}
|
|
62
|
+
) {
|
|
63
|
+
if (!ethConnectionConfig.chainId) {
|
|
64
|
+
throw new Error('Chain ID is required');
|
|
65
|
+
}
|
|
66
|
+
this._chainId = ethConnectionConfig.chainId;
|
|
67
|
+
|
|
68
|
+
this._contractAddress = ethers.getAddress(
|
|
69
|
+
ethers.hexlify(Id.ethAddressFromId(DID.idFromDID(issuerDid)))
|
|
70
|
+
);
|
|
71
|
+
this._contract = NonMerklizedIssuerBase__factory.connect(
|
|
72
|
+
this._contractAddress,
|
|
73
|
+
new ethers.JsonRpcProvider(ethConnectionConfig.url)
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
this._issuerDid = issuerDid;
|
|
77
|
+
this._merklizationOptions = options?.merklizationOptions;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Checks if the contract supports required interfaces.
|
|
82
|
+
* Throws an error if any required interface is unsupported.
|
|
83
|
+
*
|
|
84
|
+
* @throws Error - If required interfaces are not supported.
|
|
85
|
+
*/
|
|
86
|
+
public async isInterfaceSupported() {
|
|
87
|
+
const supportedInterfaces = [
|
|
88
|
+
{
|
|
89
|
+
name: 'Interface detection ERC-165',
|
|
90
|
+
value: NonMerklizedIssuerInterfaces.InterfaceDetection
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: 'Interface non-merklized issuer',
|
|
94
|
+
value: NonMerklizedIssuerInterfaces.InterfaceNonMerklizedIssuer
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
name: 'Interface get credential',
|
|
98
|
+
value: NonMerklizedIssuerInterfaces.InterfaceGetCredential
|
|
99
|
+
}
|
|
100
|
+
];
|
|
101
|
+
|
|
102
|
+
const unsupportedInterfaces = await Promise.all(
|
|
103
|
+
supportedInterfaces.map(async (interfaceObj) => {
|
|
104
|
+
const isSupported = await this._contract.supportsInterface(interfaceObj.value);
|
|
105
|
+
return isSupported ? null : interfaceObj.name;
|
|
106
|
+
})
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
const unsupportedInterfacesFiltered = unsupportedInterfaces.filter(
|
|
110
|
+
(interfaceName) => interfaceName !== null
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
if (unsupportedInterfacesFiltered.length > 0) {
|
|
114
|
+
throw new Error(`Unsupported interfaces: ${unsupportedInterfacesFiltered.join(', ')}`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Retrieves a credential from the on-chain non-merklized contract.
|
|
120
|
+
* @param userId The user's core.Id.
|
|
121
|
+
* @param credentialId The unique identifier of the credential.
|
|
122
|
+
*/
|
|
123
|
+
public async getCredential(
|
|
124
|
+
userId: Id,
|
|
125
|
+
credentialId: bigint
|
|
126
|
+
): Promise<{
|
|
127
|
+
credentialData: INonMerklizedIssuer.CredentialDataStructOutput;
|
|
128
|
+
coreClaimBigInts: bigint[];
|
|
129
|
+
credentialSubjectFields: INonMerklizedIssuer.SubjectFieldStructOutput[];
|
|
130
|
+
}> {
|
|
131
|
+
const [credentialData, coreClaimBigInts, credentialSubjectFields] =
|
|
132
|
+
await this._contract.getCredential(userId.bigInt(), credentialId);
|
|
133
|
+
return { credentialData, coreClaimBigInts, credentialSubjectFields };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Retrieves the credential IDs of a user.
|
|
138
|
+
* @param userId The user's core.Id.
|
|
139
|
+
* @returns An array of credential IDs.
|
|
140
|
+
*/
|
|
141
|
+
public async getUserCredentialsIds(userId: Id): Promise<bigint[]> {
|
|
142
|
+
return this._contract.getUserCredentialIds(userId.bigInt());
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Converts on-chain credential to a verifiable credential.
|
|
147
|
+
*
|
|
148
|
+
* @param credentialData Data structure of the credential from the contract.
|
|
149
|
+
* @param coreClaimBigInts Claim data in bigint format.
|
|
150
|
+
* @param credentialSubjectFields Subject fields of the credential.
|
|
151
|
+
*/
|
|
152
|
+
public async convertOnChainInfoToW3CCredential(
|
|
153
|
+
credentialData: INonMerklizedIssuer.CredentialDataStructOutput,
|
|
154
|
+
coreClaimBigInts: bigint[],
|
|
155
|
+
credentialSubjectFields: INonMerklizedIssuer.SubjectFieldStructOutput[]
|
|
156
|
+
): Promise<W3CCredential> {
|
|
157
|
+
const c = new Claim().unMarshalJson(JSON.stringify(coreClaimBigInts.map((b) => b.toString())));
|
|
158
|
+
|
|
159
|
+
const credentialSubject = await this.convertCredentialSubject(
|
|
160
|
+
c,
|
|
161
|
+
credentialData.context,
|
|
162
|
+
credentialData._type,
|
|
163
|
+
credentialSubjectFields
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
const credentialRequest = {
|
|
167
|
+
id: this.credentialId(credentialData.id),
|
|
168
|
+
credentialSchema: credentialData.credentialSchema.id,
|
|
169
|
+
type: credentialData._type,
|
|
170
|
+
credentialSubject: credentialSubject,
|
|
171
|
+
expiration: c.getExpirationDate()?.getTime(),
|
|
172
|
+
displayMethod: this.convertDisplayMethod(credentialData.displayMethod),
|
|
173
|
+
context: credentialData.context,
|
|
174
|
+
revocationOpts: {
|
|
175
|
+
id: this._contractAddress,
|
|
176
|
+
nonce: Number(c.getRevocationNonce()),
|
|
177
|
+
type: CredentialStatusType.Iden3OnchainSparseMerkleTreeProof2023
|
|
178
|
+
},
|
|
179
|
+
issuanceDate: getDateFromUnixTimestamp(Number(credentialData.issuanceDate)).getTime()
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
const existenceProof = await this.existenceProof(c);
|
|
183
|
+
const w3c = W3CCredential.fromCredentialRequest(this._issuerDid, credentialRequest);
|
|
184
|
+
w3c.proof = [existenceProof];
|
|
185
|
+
return w3c;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
private credentialId(id: bigint): string {
|
|
189
|
+
return `urn:iden3:onchain:${this._chainId}:${this._contractAddress}:${id}`;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
private async convertCredentialSubject(
|
|
193
|
+
coreClaim: Claim,
|
|
194
|
+
contractContexts: string[],
|
|
195
|
+
credentialType: string,
|
|
196
|
+
credentialSubjectFields: INonMerklizedIssuer.SubjectFieldStructOutput[]
|
|
197
|
+
): Promise<JsonDocumentObject> {
|
|
198
|
+
const contractContextsStr = JSON.stringify({
|
|
199
|
+
'@context': contractContexts
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
const credentialSubject = {} as JsonDocumentObject;
|
|
203
|
+
for (const f of credentialSubjectFields) {
|
|
204
|
+
const dataType = await Path.newTypeFromContext(
|
|
205
|
+
contractContextsStr,
|
|
206
|
+
`${credentialType}.${f.key}`,
|
|
207
|
+
this._merklizationOptions
|
|
208
|
+
);
|
|
209
|
+
switch (dataType) {
|
|
210
|
+
case XSDNS.Boolean: {
|
|
211
|
+
switch (f.rawValue.toString()) {
|
|
212
|
+
case ValueHashes.BooleanTrue:
|
|
213
|
+
credentialSubject[f.key] = true;
|
|
214
|
+
break;
|
|
215
|
+
case ValueHashes.BooleanFalse:
|
|
216
|
+
credentialSubject[f.key] = false;
|
|
217
|
+
break;
|
|
218
|
+
}
|
|
219
|
+
break;
|
|
220
|
+
}
|
|
221
|
+
case (XSDNS.NonNegativeInteger,
|
|
222
|
+
XSDNS.NonPositiveInteger,
|
|
223
|
+
XSDNS.NegativeInteger,
|
|
224
|
+
XSDNS.PositiveInteger): {
|
|
225
|
+
credentialSubject[f.key] = f.value.toString();
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
case XSDNS.Integer: {
|
|
229
|
+
credentialSubject[f.key] = Number(f.value);
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
232
|
+
case XSDNS.String: {
|
|
233
|
+
this.validateSourceValue(dataType, f.value, f.rawValue);
|
|
234
|
+
credentialSubject[f.key] = f.rawValue;
|
|
235
|
+
break;
|
|
236
|
+
}
|
|
237
|
+
case XSDNS.DateTime: {
|
|
238
|
+
const timestamp = BigInt(f.rawValue);
|
|
239
|
+
const sourceTimestamp = getDateFromUnixTimestamp(Number(timestamp)).toISOString();
|
|
240
|
+
this.validateSourceValue(dataType, f.value, sourceTimestamp);
|
|
241
|
+
credentialSubject[f.key] = sourceTimestamp;
|
|
242
|
+
break;
|
|
243
|
+
}
|
|
244
|
+
case XSDNS.Double: {
|
|
245
|
+
const rawFloat = Number(f.rawValue);
|
|
246
|
+
this.validateSourceValue(dataType, f.value, rawFloat);
|
|
247
|
+
credentialSubject[f.key] = rawFloat;
|
|
248
|
+
break;
|
|
249
|
+
}
|
|
250
|
+
default: {
|
|
251
|
+
throw new Error(`Unsupported data type ${dataType}`);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
credentialSubject['type'] = credentialType;
|
|
256
|
+
|
|
257
|
+
const subjectId = coreClaim.getId();
|
|
258
|
+
const subjectDid = DID.parseFromId(subjectId);
|
|
259
|
+
credentialSubject['id'] = subjectDid.string();
|
|
260
|
+
|
|
261
|
+
return credentialSubject;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
private async existenceProof(coreClaim: Claim): Promise<Iden3SparseMerkleTreeProof> {
|
|
265
|
+
const [mtpProof, stateInfo] = await this._contract.getClaimProofWithStateInfo(
|
|
266
|
+
coreClaim.hIndex()
|
|
267
|
+
);
|
|
268
|
+
if (!mtpProof.existence) {
|
|
269
|
+
throw new Error('Claim does not exist');
|
|
270
|
+
}
|
|
271
|
+
const latestStateHash = Hash.fromBigInt(stateInfo.state);
|
|
272
|
+
const latestClaimsOfRootHash = Hash.fromBigInt(stateInfo.claimsRoot);
|
|
273
|
+
const latestRevocationOfRootHash = Hash.fromBigInt(stateInfo.revocationsRoot);
|
|
274
|
+
const latestRootsOfRootHash = Hash.fromBigInt(stateInfo.rootsRoot);
|
|
275
|
+
|
|
276
|
+
const p = new Proof({
|
|
277
|
+
siblings: mtpProof.siblings.map((s) => Hash.fromBigInt(s)),
|
|
278
|
+
existence: mtpProof.existence,
|
|
279
|
+
nodeAux: mtpProof.auxExistence
|
|
280
|
+
? {
|
|
281
|
+
key: Hash.fromBigInt(mtpProof.auxIndex),
|
|
282
|
+
value: Hash.fromBigInt(mtpProof.auxValue)
|
|
283
|
+
}
|
|
284
|
+
: undefined
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
return new Iden3SparseMerkleTreeProof({
|
|
288
|
+
issuerData: {
|
|
289
|
+
id: this._issuerDid,
|
|
290
|
+
state: {
|
|
291
|
+
value: latestStateHash,
|
|
292
|
+
claimsTreeRoot: latestClaimsOfRootHash,
|
|
293
|
+
revocationTreeRoot: latestRevocationOfRootHash,
|
|
294
|
+
rootOfRoots: latestRootsOfRootHash
|
|
295
|
+
}
|
|
296
|
+
},
|
|
297
|
+
mtp: p,
|
|
298
|
+
coreClaim: coreClaim
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
private async validateSourceValue(dataType: string, originHash: bigint, source: unknown) {
|
|
303
|
+
const sourceHash = await Merklizer.hashValue(dataType, source);
|
|
304
|
+
if (sourceHash !== originHash) {
|
|
305
|
+
throw new Error(`Invalid source value for ${dataType} type`);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
private convertDisplayMethod(
|
|
310
|
+
onchainDisplayMethod: INonMerklizedIssuer.DisplayMethodStructOutput
|
|
311
|
+
): DisplayMethod | undefined {
|
|
312
|
+
if (!onchainDisplayMethod.id || !onchainDisplayMethod._type) {
|
|
313
|
+
return undefined;
|
|
314
|
+
}
|
|
315
|
+
switch (onchainDisplayMethod._type) {
|
|
316
|
+
case DisplayMethodType.Iden3BasicDisplayMethodV1: {
|
|
317
|
+
return {
|
|
318
|
+
id: onchainDisplayMethod.id,
|
|
319
|
+
type: DisplayMethodType.Iden3BasicDisplayMethodV1
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
default: {
|
|
323
|
+
throw new Error(`Unsupported display method type ${onchainDisplayMethod._type}`);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { DID, Id, chainIDfromDID } from '@mocanetwork/moca-iden3';
|
|
2
|
+
import { Contract, ethers } from 'ethers';
|
|
3
|
+
import { INonMerklizedIssuerABI as abi } from '@iden3/onchain-non-merklized-issuer-base-abi';
|
|
4
|
+
import { Options } from '@iden3/js-jsonld-merklization';
|
|
5
|
+
import { W3CCredential } from '../../verifiable';
|
|
6
|
+
import { OnchainNonMerklizedIssuerAdapter } from './onchain-issuer-adapter/non-merklized/version/v0.0.1/onchain-non-merklized-issuer-adapter';
|
|
7
|
+
import { EthConnectionConfig } from './state';
|
|
8
|
+
import { IOnchainIssuer } from '../interfaces/onchain-issuer';
|
|
9
|
+
|
|
10
|
+
interface OnchainIssuerOptions {
|
|
11
|
+
merklizationOptions?: Options;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Represents an adapter for interacting with on-chain issuers.
|
|
16
|
+
*
|
|
17
|
+
* @public
|
|
18
|
+
* @beta
|
|
19
|
+
* @class OnchainIssuer
|
|
20
|
+
*/
|
|
21
|
+
export class OnchainIssuer implements IOnchainIssuer {
|
|
22
|
+
private readonly _ethConnectionConfig: EthConnectionConfig[];
|
|
23
|
+
private readonly _onchainIssuerOptions?: OnchainIssuerOptions;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Initializes an instance of `Adapter`.
|
|
27
|
+
* @param config The configuration for the Ethereum connection.
|
|
28
|
+
* @param merklizationOptions Optional settings for merklization.
|
|
29
|
+
*/
|
|
30
|
+
constructor(config: EthConnectionConfig[], options?: OnchainIssuerOptions) {
|
|
31
|
+
this._ethConnectionConfig = config;
|
|
32
|
+
this._onchainIssuerOptions = options;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Retrieves a credential from the on-chain issuer.
|
|
37
|
+
* @param issuerDID The issuer's core.DID.
|
|
38
|
+
* @param userId The user's core.Id.
|
|
39
|
+
* @param credentialId The unique identifier of the credential.
|
|
40
|
+
*/
|
|
41
|
+
public async getCredential(
|
|
42
|
+
issuerDID: DID,
|
|
43
|
+
userDID: DID,
|
|
44
|
+
credentialId: bigint
|
|
45
|
+
): Promise<W3CCredential> {
|
|
46
|
+
const { contract, connection } = this.getContractConnection(issuerDID);
|
|
47
|
+
const response = await contract.getCredentialAdapterVersion();
|
|
48
|
+
switch (response) {
|
|
49
|
+
case '0.0.1': {
|
|
50
|
+
const adapter = new OnchainNonMerklizedIssuerAdapter(connection, issuerDID, {
|
|
51
|
+
merklizationOptions: this._onchainIssuerOptions?.merklizationOptions
|
|
52
|
+
});
|
|
53
|
+
await adapter.isInterfaceSupported();
|
|
54
|
+
const { credentialData, coreClaimBigInts, credentialSubjectFields } =
|
|
55
|
+
await adapter.getCredential(DID.idFromDID(userDID), credentialId);
|
|
56
|
+
return await adapter.convertOnChainInfoToW3CCredential(
|
|
57
|
+
credentialData,
|
|
58
|
+
coreClaimBigInts,
|
|
59
|
+
credentialSubjectFields
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
default:
|
|
63
|
+
throw new Error(`Unsupported adapter version ${response}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Retrieves the credential identifiers for a user from the on-chain issuer.
|
|
69
|
+
* @param issuerDID The issuer's core.DID.
|
|
70
|
+
* @param userId The user's core.Id.
|
|
71
|
+
*/
|
|
72
|
+
public async getUserCredentialIds(issuerDID: DID, userDID: DID): Promise<bigint[]> {
|
|
73
|
+
const { contract, connection } = this.getContractConnection(issuerDID);
|
|
74
|
+
const response = await contract.getCredentialAdapterVersion();
|
|
75
|
+
switch (response) {
|
|
76
|
+
case '0.0.1': {
|
|
77
|
+
const adapter = new OnchainNonMerklizedIssuerAdapter(connection, issuerDID, {
|
|
78
|
+
merklizationOptions: this._onchainIssuerOptions?.merklizationOptions
|
|
79
|
+
});
|
|
80
|
+
await adapter.isInterfaceSupported();
|
|
81
|
+
return await adapter.getUserCredentialsIds(DID.idFromDID(userDID));
|
|
82
|
+
}
|
|
83
|
+
default:
|
|
84
|
+
throw new Error(`Unsupported adapter version ${response}`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
private getContractConnection(did: DID): { contract: Contract; connection: EthConnectionConfig } {
|
|
89
|
+
const issuerId = DID.idFromDID(did);
|
|
90
|
+
const chainId = chainIDfromDID(did);
|
|
91
|
+
const contractAddress = ethers.getAddress(ethers.hexlify(Id.ethAddressFromId(issuerId)));
|
|
92
|
+
const connection = this._ethConnectionConfig.find((c) => c.chainId === chainId);
|
|
93
|
+
if (!connection) {
|
|
94
|
+
throw new Error(`No connection found for chain ID ${chainId}`);
|
|
95
|
+
}
|
|
96
|
+
if (!connection.url) {
|
|
97
|
+
throw new Error(`No URL found for chain ID ${chainId}`);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const contract = new Contract(contractAddress, abi, new ethers.JsonRpcProvider(connection.url));
|
|
101
|
+
|
|
102
|
+
return { contract, connection };
|
|
103
|
+
}
|
|
104
|
+
}
|