@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,371 @@
|
|
|
1
|
+
import { PROTOCOL_MESSAGE_TYPE, MediaType } from '../constants';
|
|
2
|
+
import {
|
|
3
|
+
Attachment,
|
|
4
|
+
BasicMessage,
|
|
5
|
+
CredentialOffer,
|
|
6
|
+
CredentialsOfferMessage,
|
|
7
|
+
DIDDocument,
|
|
8
|
+
IPackageManager,
|
|
9
|
+
PackerParams
|
|
10
|
+
} from '../types';
|
|
11
|
+
|
|
12
|
+
import { DID, getUnixTimestamp } from '@mocanetwork/moca-iden3';
|
|
13
|
+
import * as uuid from 'uuid';
|
|
14
|
+
import { proving } from '@iden3/js-jwz';
|
|
15
|
+
import {
|
|
16
|
+
Proposal,
|
|
17
|
+
ProposalRequestMessage,
|
|
18
|
+
ProposalMessage,
|
|
19
|
+
ProposalRequestCredential
|
|
20
|
+
} from '../types/protocol/proposal-request';
|
|
21
|
+
import { IIdentityWallet } from '../../identity';
|
|
22
|
+
import { byteEncoder } from '../../utils';
|
|
23
|
+
import { W3CCredential } from '../../verifiable';
|
|
24
|
+
import {
|
|
25
|
+
AbstractMessageHandler,
|
|
26
|
+
BasicHandlerOptions,
|
|
27
|
+
IProtocolMessageHandler
|
|
28
|
+
} from './message-handler';
|
|
29
|
+
import { verifyExpiresTime } from './common';
|
|
30
|
+
|
|
31
|
+
/** @beta ProposalRequestCreationOptions represents proposal-request creation options */
|
|
32
|
+
export type ProposalRequestCreationOptions = {
|
|
33
|
+
credentials: ProposalRequestCredential[];
|
|
34
|
+
did_doc?: DIDDocument;
|
|
35
|
+
expires_time?: Date;
|
|
36
|
+
attachments?: Attachment[];
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/** @beta ProposalCreationOptions represents proposal creation options */
|
|
40
|
+
export type ProposalCreationOptions = {
|
|
41
|
+
expires_time?: Date;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @beta
|
|
46
|
+
* createProposalRequest is a function to create protocol proposal-request protocol message
|
|
47
|
+
* @param {DID} sender - sender did
|
|
48
|
+
* @param {DID} receiver - receiver did
|
|
49
|
+
* @param {ProposalRequestCreationOptions} opts - creation options
|
|
50
|
+
* @returns `Promise<ProposalRequestMessage>`
|
|
51
|
+
*/
|
|
52
|
+
export function createProposalRequest(
|
|
53
|
+
sender: DID,
|
|
54
|
+
receiver: DID,
|
|
55
|
+
opts: ProposalRequestCreationOptions
|
|
56
|
+
): ProposalRequestMessage {
|
|
57
|
+
const uuidv4 = uuid.v4();
|
|
58
|
+
const request: ProposalRequestMessage = {
|
|
59
|
+
id: uuidv4,
|
|
60
|
+
thid: uuidv4,
|
|
61
|
+
from: sender.string(),
|
|
62
|
+
to: receiver.string(),
|
|
63
|
+
typ: MediaType.PlainMessage,
|
|
64
|
+
type: PROTOCOL_MESSAGE_TYPE.PROPOSAL_REQUEST_MESSAGE_TYPE,
|
|
65
|
+
body: opts,
|
|
66
|
+
created_time: getUnixTimestamp(new Date()),
|
|
67
|
+
expires_time: opts?.expires_time ? getUnixTimestamp(opts.expires_time) : undefined,
|
|
68
|
+
attachments: opts.attachments
|
|
69
|
+
};
|
|
70
|
+
return request;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @beta
|
|
75
|
+
* createProposal is a function to create protocol proposal protocol message
|
|
76
|
+
* @param {DID} sender - sender did
|
|
77
|
+
* @param {DID} receiver - receiver did
|
|
78
|
+
* @param {Proposal[]} proposals - proposals
|
|
79
|
+
* @returns `Promise<ProposalRequestMessage>`
|
|
80
|
+
*/
|
|
81
|
+
export function createProposal(
|
|
82
|
+
sender: DID,
|
|
83
|
+
receiver: DID,
|
|
84
|
+
proposals?: Proposal[],
|
|
85
|
+
opts?: ProposalCreationOptions
|
|
86
|
+
): ProposalMessage {
|
|
87
|
+
const uuidv4 = uuid.v4();
|
|
88
|
+
const request: ProposalMessage = {
|
|
89
|
+
id: uuidv4,
|
|
90
|
+
thid: uuidv4,
|
|
91
|
+
from: sender.string(),
|
|
92
|
+
to: receiver.string(),
|
|
93
|
+
typ: MediaType.PlainMessage,
|
|
94
|
+
type: PROTOCOL_MESSAGE_TYPE.PROPOSAL_MESSAGE_TYPE,
|
|
95
|
+
body: {
|
|
96
|
+
proposals: proposals || []
|
|
97
|
+
},
|
|
98
|
+
created_time: getUnixTimestamp(new Date()),
|
|
99
|
+
expires_time: opts?.expires_time ? getUnixTimestamp(opts.expires_time) : undefined
|
|
100
|
+
};
|
|
101
|
+
return request;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* @beta
|
|
106
|
+
* Interface that allows the processing of the proposal-request
|
|
107
|
+
*
|
|
108
|
+
* @interface ICredentialProposalHandler
|
|
109
|
+
*/
|
|
110
|
+
export interface ICredentialProposalHandler {
|
|
111
|
+
/**
|
|
112
|
+
* @beta
|
|
113
|
+
* unpacks proposal-request
|
|
114
|
+
* @param {Uint8Array} request - raw byte message
|
|
115
|
+
* @returns `Promise<ProposalRequestMessage>`
|
|
116
|
+
*/
|
|
117
|
+
parseProposalRequest(request: Uint8Array): Promise<ProposalRequestMessage>;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* @beta
|
|
121
|
+
* handle proposal-request
|
|
122
|
+
* @param {Uint8Array} request - raw byte message
|
|
123
|
+
* @param {ProposalRequestHandlerOptions} opts - handler options
|
|
124
|
+
* @returns {Promise<Uint8Array>}` - proposal response message
|
|
125
|
+
*/
|
|
126
|
+
handleProposalRequest(
|
|
127
|
+
request: Uint8Array,
|
|
128
|
+
opts?: ProposalRequestHandlerOptions
|
|
129
|
+
): Promise<Uint8Array>;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* @beta
|
|
133
|
+
* handle proposal protocol message
|
|
134
|
+
* @param {ProposalMessage} proposal - proposal message
|
|
135
|
+
* @param {ProposalHandlerOptions} opts - options
|
|
136
|
+
* @returns `Promise<{
|
|
137
|
+
proposal: ProposalMessage;
|
|
138
|
+
}>`
|
|
139
|
+
*/
|
|
140
|
+
handleProposal(
|
|
141
|
+
proposal: ProposalMessage,
|
|
142
|
+
opts?: ProposalHandlerOptions
|
|
143
|
+
): Promise<{
|
|
144
|
+
proposal: ProposalMessage;
|
|
145
|
+
}>;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** @beta ProposalRequestHandlerOptions represents proposal-request handler options */
|
|
149
|
+
export type ProposalRequestHandlerOptions = BasicHandlerOptions;
|
|
150
|
+
|
|
151
|
+
/** @beta ProposalHandlerOptions represents proposal handler options */
|
|
152
|
+
export type ProposalHandlerOptions = BasicHandlerOptions & {
|
|
153
|
+
proposalRequest?: ProposalRequestMessage;
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
/** @beta CredentialProposalHandlerParams represents credential proposal handler params */
|
|
157
|
+
export type CredentialProposalHandlerParams = {
|
|
158
|
+
agentUrl: string;
|
|
159
|
+
proposalResolverFn: (
|
|
160
|
+
context: string,
|
|
161
|
+
type: string,
|
|
162
|
+
opts?: { msg?: BasicMessage }
|
|
163
|
+
) => Promise<Proposal>;
|
|
164
|
+
packerParams: PackerParams;
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
*
|
|
169
|
+
* Allows to process ProposalRequest protocol message
|
|
170
|
+
* @beta
|
|
171
|
+
* @class CredentialProposalHandler
|
|
172
|
+
* @implements implements ICredentialProposalHandler interface
|
|
173
|
+
*/
|
|
174
|
+
export class CredentialProposalHandler
|
|
175
|
+
extends AbstractMessageHandler
|
|
176
|
+
implements ICredentialProposalHandler, IProtocolMessageHandler
|
|
177
|
+
{
|
|
178
|
+
/**
|
|
179
|
+
* @beta Creates an instance of CredentialProposalHandler.
|
|
180
|
+
* @param {IPackageManager} _packerMgr - package manager to unpack message envelope
|
|
181
|
+
* @param {IIdentityWallet} _identityWallet - identity wallet
|
|
182
|
+
* @param {CredentialProposalHandlerParams} _params - credential proposal handler params
|
|
183
|
+
*
|
|
184
|
+
*/
|
|
185
|
+
|
|
186
|
+
constructor(
|
|
187
|
+
private readonly _packerMgr: IPackageManager,
|
|
188
|
+
private readonly _identityWallet: IIdentityWallet,
|
|
189
|
+
private readonly _params: CredentialProposalHandlerParams
|
|
190
|
+
) {
|
|
191
|
+
super();
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
public async handle(
|
|
195
|
+
message: BasicMessage,
|
|
196
|
+
context: ProposalRequestHandlerOptions
|
|
197
|
+
): Promise<BasicMessage | null> {
|
|
198
|
+
switch (message.type) {
|
|
199
|
+
case PROTOCOL_MESSAGE_TYPE.PROPOSAL_REQUEST_MESSAGE_TYPE:
|
|
200
|
+
return (await this.handleProposalRequestMessage(
|
|
201
|
+
message as unknown as ProposalRequestMessage,
|
|
202
|
+
context
|
|
203
|
+
)) as BasicMessage;
|
|
204
|
+
default:
|
|
205
|
+
return super.handle(message, context as { [key: string]: unknown });
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* @inheritdoc ICredentialProposalHandler#parseProposalRequest
|
|
211
|
+
*/
|
|
212
|
+
async parseProposalRequest(request: Uint8Array): Promise<ProposalRequestMessage> {
|
|
213
|
+
const { unpackedMessage: message } = await this._packerMgr.unpack(request);
|
|
214
|
+
const proposalRequest = message as unknown as ProposalRequestMessage;
|
|
215
|
+
if (message.type !== PROTOCOL_MESSAGE_TYPE.PROPOSAL_REQUEST_MESSAGE_TYPE) {
|
|
216
|
+
throw new Error('Invalid media type');
|
|
217
|
+
}
|
|
218
|
+
return proposalRequest;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
private async handleProposalRequestMessage(
|
|
222
|
+
proposalRequest: ProposalRequestMessage,
|
|
223
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
224
|
+
ctx?: ProposalRequestHandlerOptions
|
|
225
|
+
): Promise<ProposalMessage | CredentialsOfferMessage | undefined> {
|
|
226
|
+
if (!proposalRequest.to) {
|
|
227
|
+
throw new Error(`failed request. empty 'to' field`);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (!proposalRequest.from) {
|
|
231
|
+
throw new Error(`failed request. empty 'from' field`);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
if (!proposalRequest.body?.credentials?.length) {
|
|
235
|
+
throw new Error(`failed request. no 'credentials' in body`);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
let credOfferMessage: CredentialsOfferMessage | undefined = undefined;
|
|
239
|
+
let proposalMessage: ProposalMessage | undefined = undefined;
|
|
240
|
+
|
|
241
|
+
for (let i = 0; i < proposalRequest.body.credentials.length; i++) {
|
|
242
|
+
const cred = proposalRequest.body.credentials[i];
|
|
243
|
+
|
|
244
|
+
// check if there is credentials in the wallet
|
|
245
|
+
let credsFromWallet: W3CCredential[] = [];
|
|
246
|
+
|
|
247
|
+
try {
|
|
248
|
+
credsFromWallet = await this._identityWallet.credentialWallet.findByQuery({
|
|
249
|
+
credentialSubject: {
|
|
250
|
+
id: {
|
|
251
|
+
$eq: proposalRequest.from
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
type: cred.type,
|
|
255
|
+
context: cred.context,
|
|
256
|
+
allowedIssuers: [proposalRequest.to]
|
|
257
|
+
});
|
|
258
|
+
} catch (e) {
|
|
259
|
+
if ((e as Error).message !== 'no credential satisfied query') {
|
|
260
|
+
throw e;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
if (credsFromWallet.length) {
|
|
265
|
+
const guid = uuid.v4();
|
|
266
|
+
if (!credOfferMessage) {
|
|
267
|
+
credOfferMessage = {
|
|
268
|
+
id: guid,
|
|
269
|
+
typ: this._params.packerParams.mediaType,
|
|
270
|
+
type: PROTOCOL_MESSAGE_TYPE.CREDENTIAL_OFFER_MESSAGE_TYPE,
|
|
271
|
+
thid: proposalRequest.thid ?? guid,
|
|
272
|
+
body: {
|
|
273
|
+
url: this._params.agentUrl,
|
|
274
|
+
credentials: []
|
|
275
|
+
},
|
|
276
|
+
from: proposalRequest.to,
|
|
277
|
+
to: proposalRequest.from
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
credOfferMessage.body.credentials.push(
|
|
282
|
+
...credsFromWallet.map<CredentialOffer>((c) => ({
|
|
283
|
+
id: c.id,
|
|
284
|
+
description: ''
|
|
285
|
+
}))
|
|
286
|
+
);
|
|
287
|
+
continue;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// credential not found in the wallet, prepare proposal protocol message
|
|
291
|
+
const proposal = await this._params.proposalResolverFn(cred.context, cred.type, {
|
|
292
|
+
msg: proposalRequest
|
|
293
|
+
});
|
|
294
|
+
if (!proposal) {
|
|
295
|
+
throw new Error(`can't resolve Proposal for type: ${cred.type}, context: ${cred.context}`);
|
|
296
|
+
}
|
|
297
|
+
if (!proposalMessage) {
|
|
298
|
+
const guid = uuid.v4();
|
|
299
|
+
proposalMessage = {
|
|
300
|
+
id: guid,
|
|
301
|
+
typ: this._params.packerParams.mediaType,
|
|
302
|
+
type: PROTOCOL_MESSAGE_TYPE.PROPOSAL_MESSAGE_TYPE,
|
|
303
|
+
thid: proposalRequest.thid ?? guid,
|
|
304
|
+
body: {
|
|
305
|
+
proposals: []
|
|
306
|
+
},
|
|
307
|
+
from: proposalRequest.to,
|
|
308
|
+
to: proposalRequest.from
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
proposalMessage.body?.proposals.push(proposal);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
return proposalMessage ?? credOfferMessage;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* @inheritdoc ICredentialProposalHandler#handleProposalRequest
|
|
319
|
+
*/
|
|
320
|
+
async handleProposalRequest(
|
|
321
|
+
request: Uint8Array,
|
|
322
|
+
//eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
323
|
+
opts?: ProposalRequestHandlerOptions
|
|
324
|
+
): Promise<Uint8Array> {
|
|
325
|
+
if (
|
|
326
|
+
this._params.packerParams.mediaType === MediaType.SignedMessage &&
|
|
327
|
+
!this._params.packerParams.packerOptions
|
|
328
|
+
) {
|
|
329
|
+
throw new Error(`jws packer options are required for ${MediaType.SignedMessage}`);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
const proposalRequest = await this.parseProposalRequest(request);
|
|
333
|
+
if (!proposalRequest.from) {
|
|
334
|
+
throw new Error(`failed request. empty 'from' field`);
|
|
335
|
+
}
|
|
336
|
+
if (!opts?.allowExpiredMessages) {
|
|
337
|
+
verifyExpiresTime(proposalRequest);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
const senderDID = DID.parse(proposalRequest.from);
|
|
341
|
+
const message = await this.handleProposalRequestMessage(proposalRequest);
|
|
342
|
+
const response = byteEncoder.encode(JSON.stringify(message));
|
|
343
|
+
|
|
344
|
+
const packerOpts =
|
|
345
|
+
this._params.packerParams.mediaType === MediaType.SignedMessage
|
|
346
|
+
? this._params.packerParams.packerOptions
|
|
347
|
+
: {
|
|
348
|
+
provingMethodAlg: proving.provingMethodGroth16AuthV2Instance.methodAlg
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
return this._packerMgr.pack(this._params.packerParams.mediaType, response, {
|
|
352
|
+
senderDID,
|
|
353
|
+
...packerOpts
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* @inheritdoc ICredentialProposalHandler#handleProposal
|
|
359
|
+
*/
|
|
360
|
+
async handleProposal(proposal: ProposalMessage, opts?: ProposalHandlerOptions) {
|
|
361
|
+
if (!opts?.allowExpiredMessages) {
|
|
362
|
+
verifyExpiresTime(proposal);
|
|
363
|
+
}
|
|
364
|
+
if (opts?.proposalRequest && opts.proposalRequest.from !== proposal.to) {
|
|
365
|
+
throw new Error(
|
|
366
|
+
`sender of the request is not a target of response - expected ${opts.proposalRequest.from}, given ${proposal.to}`
|
|
367
|
+
);
|
|
368
|
+
}
|
|
369
|
+
return { proposal };
|
|
370
|
+
}
|
|
371
|
+
}
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import { MediaType, PROTOCOL_MESSAGE_TYPE } from '../constants';
|
|
2
|
+
|
|
3
|
+
import { BasicMessage, IPackageManager, ProtocolMessage } from '../types';
|
|
4
|
+
|
|
5
|
+
import * as uuid from 'uuid';
|
|
6
|
+
import {
|
|
7
|
+
DiscoverFeatureDiscloseMessage,
|
|
8
|
+
DiscoverFeatureDisclosure,
|
|
9
|
+
DiscoverFeatureQueriesMessage,
|
|
10
|
+
DiscoverFeatureQuery,
|
|
11
|
+
DiscoverFeatureQueryType,
|
|
12
|
+
DiscoveryProtocolFeatureType
|
|
13
|
+
} from '../types/protocol/discovery-protocol';
|
|
14
|
+
import {
|
|
15
|
+
AbstractMessageHandler,
|
|
16
|
+
BasicHandlerOptions,
|
|
17
|
+
IProtocolMessageHandler
|
|
18
|
+
} from './message-handler';
|
|
19
|
+
import { getUnixTimestamp } from '@mocanetwork/moca-iden3';
|
|
20
|
+
import { verifyExpiresTime } from './common';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @beta
|
|
24
|
+
* DiscoveryProtocolOptions contains options for DiscoveryProtocolHandler
|
|
25
|
+
* @public
|
|
26
|
+
* @interface DiscoveryProtocolOptions
|
|
27
|
+
*/
|
|
28
|
+
export interface DiscoveryProtocolOptions {
|
|
29
|
+
packageManager: IPackageManager;
|
|
30
|
+
protocols?: Array<ProtocolMessage>;
|
|
31
|
+
goalCodes?: Array<string>;
|
|
32
|
+
headers?: Array<string>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
*
|
|
37
|
+
* Options to pass to discovery-protocol handler
|
|
38
|
+
*
|
|
39
|
+
* @beta
|
|
40
|
+
* @public
|
|
41
|
+
* @type DiscoveryProtocolHandlerOptions
|
|
42
|
+
*/
|
|
43
|
+
export type DiscoveryProtocolHandlerOptions = BasicHandlerOptions & {
|
|
44
|
+
disclosureExpiresDate?: Date;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @beta
|
|
49
|
+
* createDiscoveryFeatureQueryMessage is a function to create didcomm protocol discovery-feature query message
|
|
50
|
+
* @param opts - discovery-feature query options
|
|
51
|
+
* @returns `DiscoverFeatureQueriesMessage`
|
|
52
|
+
*/
|
|
53
|
+
export function createDiscoveryFeatureQueryMessage(
|
|
54
|
+
queries: DiscoverFeatureQuery[],
|
|
55
|
+
opts?: {
|
|
56
|
+
from?: string;
|
|
57
|
+
to?: string;
|
|
58
|
+
expires_time?: number;
|
|
59
|
+
}
|
|
60
|
+
): DiscoverFeatureQueriesMessage {
|
|
61
|
+
const uuidv4 = uuid.v4();
|
|
62
|
+
return {
|
|
63
|
+
id: uuidv4,
|
|
64
|
+
thid: uuidv4,
|
|
65
|
+
typ: MediaType.PlainMessage,
|
|
66
|
+
type: PROTOCOL_MESSAGE_TYPE.DISCOVERY_PROTOCOL_QUERIES_MESSAGE_TYPE,
|
|
67
|
+
body: {
|
|
68
|
+
queries
|
|
69
|
+
},
|
|
70
|
+
from: opts?.from,
|
|
71
|
+
to: opts?.to,
|
|
72
|
+
created_time: getUnixTimestamp(new Date()),
|
|
73
|
+
expires_time: opts?.expires_time
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @beta
|
|
79
|
+
* createDiscoveryFeatureDiscloseMessage is a function to create didcomm protocol discovery-feature disclose message
|
|
80
|
+
* @param {DiscoverFeatureDisclosure[]} disclosures - array of disclosures
|
|
81
|
+
* @param opts - basic message options
|
|
82
|
+
* @returns `DiscoverFeatureQueriesMessage`
|
|
83
|
+
*/
|
|
84
|
+
export function createDiscoveryFeatureDiscloseMessage(
|
|
85
|
+
disclosures: DiscoverFeatureDisclosure[],
|
|
86
|
+
opts?: {
|
|
87
|
+
from?: string;
|
|
88
|
+
to?: string;
|
|
89
|
+
expires_time?: number;
|
|
90
|
+
}
|
|
91
|
+
): DiscoverFeatureDiscloseMessage {
|
|
92
|
+
const uuidv4 = uuid.v4();
|
|
93
|
+
return {
|
|
94
|
+
id: uuidv4,
|
|
95
|
+
typ: MediaType.PlainMessage,
|
|
96
|
+
thid: uuidv4,
|
|
97
|
+
type: PROTOCOL_MESSAGE_TYPE.DISCOVERY_PROTOCOL_DISCLOSE_MESSAGE_TYPE,
|
|
98
|
+
body: {
|
|
99
|
+
disclosures
|
|
100
|
+
},
|
|
101
|
+
from: opts?.from,
|
|
102
|
+
to: opts?.to,
|
|
103
|
+
created_time: getUnixTimestamp(new Date()),
|
|
104
|
+
expires_time: opts?.expires_time
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Interface to work with discovery protocol handler
|
|
110
|
+
*
|
|
111
|
+
* @beta
|
|
112
|
+
* @public
|
|
113
|
+
* @interface IDiscoveryProtocolHandler
|
|
114
|
+
*/
|
|
115
|
+
export interface IDiscoveryProtocolHandler {
|
|
116
|
+
/**
|
|
117
|
+
* handle discovery query message
|
|
118
|
+
*
|
|
119
|
+
* @param {DiscoverFeatureQueriesMessage} message - discover feature queries message
|
|
120
|
+
* @param {{ expires_time?: number}} opts - discover feature handle options
|
|
121
|
+
* @returns {Promise<DiscoverFeatureDiscloseMessage>} - discover feature disclose message
|
|
122
|
+
*/
|
|
123
|
+
handleDiscoveryQuery(
|
|
124
|
+
message: DiscoverFeatureQueriesMessage,
|
|
125
|
+
opts?: DiscoveryProtocolHandlerOptions
|
|
126
|
+
): Promise<DiscoverFeatureDiscloseMessage>;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
*
|
|
131
|
+
* Handler for discovery protocol
|
|
132
|
+
*
|
|
133
|
+
* @public
|
|
134
|
+
* @beta
|
|
135
|
+
* @class DiscoveryProtocolHandler
|
|
136
|
+
* @implements implements DiscoveryProtocolHandler interface
|
|
137
|
+
*/
|
|
138
|
+
export class DiscoveryProtocolHandler
|
|
139
|
+
extends AbstractMessageHandler
|
|
140
|
+
implements IDiscoveryProtocolHandler, IProtocolMessageHandler
|
|
141
|
+
{
|
|
142
|
+
/**
|
|
143
|
+
* Creates an instance of DiscoveryProtocolHandler.
|
|
144
|
+
* @param {DiscoveryProtocolOptions} _options - discovery protocol options
|
|
145
|
+
*/
|
|
146
|
+
constructor(private readonly _options: DiscoveryProtocolOptions) {
|
|
147
|
+
super();
|
|
148
|
+
const headers = [
|
|
149
|
+
'id',
|
|
150
|
+
'typ',
|
|
151
|
+
'type',
|
|
152
|
+
'thid',
|
|
153
|
+
'body',
|
|
154
|
+
'from',
|
|
155
|
+
'to',
|
|
156
|
+
'created_time',
|
|
157
|
+
'expires_time'
|
|
158
|
+
];
|
|
159
|
+
if (!_options.headers) {
|
|
160
|
+
_options.headers = headers;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* @inheritdoc IProtocolMessageHandler#handle
|
|
166
|
+
*/
|
|
167
|
+
public async handle(
|
|
168
|
+
message: BasicMessage,
|
|
169
|
+
context: { [key: string]: unknown }
|
|
170
|
+
): Promise<BasicMessage | null> {
|
|
171
|
+
switch (message.type) {
|
|
172
|
+
case PROTOCOL_MESSAGE_TYPE.DISCOVERY_PROTOCOL_QUERIES_MESSAGE_TYPE:
|
|
173
|
+
return await this.handleDiscoveryQuery(message as DiscoverFeatureQueriesMessage, context);
|
|
174
|
+
default:
|
|
175
|
+
return super.handle(message, context as { [key: string]: unknown });
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* @inheritdoc IDiscoveryProtocolHandler#handleDiscoveryQuery
|
|
181
|
+
*/
|
|
182
|
+
async handleDiscoveryQuery(
|
|
183
|
+
message: DiscoverFeatureQueriesMessage,
|
|
184
|
+
opts?: DiscoveryProtocolHandlerOptions
|
|
185
|
+
): Promise<DiscoverFeatureDiscloseMessage> {
|
|
186
|
+
if (!opts?.allowExpiredMessages) {
|
|
187
|
+
verifyExpiresTime(message);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const disclosures: DiscoverFeatureDisclosure[] = [];
|
|
191
|
+
for (const query of message.body.queries) {
|
|
192
|
+
disclosures.push(...this.handleQuery(query));
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return Promise.resolve(
|
|
196
|
+
createDiscoveryFeatureDiscloseMessage(disclosures, {
|
|
197
|
+
to: message.from,
|
|
198
|
+
from: message.to,
|
|
199
|
+
expires_time: opts?.disclosureExpiresDate
|
|
200
|
+
? getUnixTimestamp(opts.disclosureExpiresDate)
|
|
201
|
+
: undefined
|
|
202
|
+
})
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
private handleQuery(query: DiscoverFeatureQuery): DiscoverFeatureDisclosure[] {
|
|
207
|
+
let result: DiscoverFeatureDisclosure[] = [];
|
|
208
|
+
switch (query[DiscoverFeatureQueryType.FeatureType]) {
|
|
209
|
+
case DiscoveryProtocolFeatureType.Accept:
|
|
210
|
+
result = this.handleAcceptQuery();
|
|
211
|
+
break;
|
|
212
|
+
case DiscoveryProtocolFeatureType.Protocol:
|
|
213
|
+
result = this.handleProtocolQuery();
|
|
214
|
+
break;
|
|
215
|
+
case DiscoveryProtocolFeatureType.GoalCode:
|
|
216
|
+
result = this.handleGoalCodeQuery();
|
|
217
|
+
break;
|
|
218
|
+
case DiscoveryProtocolFeatureType.Header:
|
|
219
|
+
result = this.handleHeaderQuery();
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
return this.handleMatch(result, query.match);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
private handleAcceptQuery(): DiscoverFeatureDisclosure[] {
|
|
227
|
+
const acceptProfiles = this._options.packageManager.getSupportedProfiles();
|
|
228
|
+
return acceptProfiles.map((profile) => ({
|
|
229
|
+
[DiscoverFeatureQueryType.FeatureType]: DiscoveryProtocolFeatureType.Accept,
|
|
230
|
+
id: profile
|
|
231
|
+
}));
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
private handleProtocolQuery(): DiscoverFeatureDisclosure[] {
|
|
235
|
+
return (
|
|
236
|
+
this._options.protocols?.map((protocol) => ({
|
|
237
|
+
[DiscoverFeatureQueryType.FeatureType]: DiscoveryProtocolFeatureType.Protocol,
|
|
238
|
+
id: protocol
|
|
239
|
+
})) ?? []
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
private handleGoalCodeQuery(): DiscoverFeatureDisclosure[] {
|
|
244
|
+
return (
|
|
245
|
+
this._options.goalCodes?.map((goalCode) => ({
|
|
246
|
+
[DiscoverFeatureQueryType.FeatureType]: DiscoveryProtocolFeatureType.GoalCode,
|
|
247
|
+
id: goalCode
|
|
248
|
+
})) ?? []
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
private handleHeaderQuery(): DiscoverFeatureDisclosure[] {
|
|
253
|
+
return (
|
|
254
|
+
this._options.headers?.map((header) => ({
|
|
255
|
+
[DiscoverFeatureQueryType.FeatureType]: DiscoveryProtocolFeatureType.Header,
|
|
256
|
+
id: header
|
|
257
|
+
})) ?? []
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
private handleMatch(
|
|
262
|
+
disclosures: DiscoverFeatureDisclosure[],
|
|
263
|
+
match?: string
|
|
264
|
+
): DiscoverFeatureDisclosure[] {
|
|
265
|
+
if (!match || match === '*') {
|
|
266
|
+
return disclosures;
|
|
267
|
+
}
|
|
268
|
+
const regExp = this.wildcardToRegExp(match);
|
|
269
|
+
return disclosures.filter((disclosure) => regExp.test(disclosure.id));
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
private wildcardToRegExp(match: string): RegExp {
|
|
273
|
+
// Escape special regex characters, then replace `*` with `.*`
|
|
274
|
+
const regexPattern = match.replace(/[.+^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '.*');
|
|
275
|
+
return new RegExp(`^${regexPattern}$`);
|
|
276
|
+
}
|
|
277
|
+
}
|