@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,157 @@
|
|
|
1
|
+
import { Hex } from '@iden3/js-crypto';
|
|
2
|
+
import { Id, buildDIDType, genesisFromEthAddress, DID } from '@mocanetwork/moca-iden3';
|
|
3
|
+
import { Hash } from '@iden3/js-merkletree';
|
|
4
|
+
import { DIDResolutionResult, VerificationMethod, DIDResolutionMetadata } from 'did-resolver';
|
|
5
|
+
import { keccak256 } from 'ethers';
|
|
6
|
+
import { hexToBytes } from './encoding';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Supported DID Document Signatures
|
|
10
|
+
*/
|
|
11
|
+
export enum DIDDocumentSignature {
|
|
12
|
+
EthereumEip712Signature2021 = 'EthereumEip712Signature2021'
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Checks if state is genesis state
|
|
17
|
+
*
|
|
18
|
+
* @param {DID} did - did
|
|
19
|
+
* @param {bigint|string} state - hash on bigInt or hex string format
|
|
20
|
+
* @returns boolean
|
|
21
|
+
*/
|
|
22
|
+
export function isGenesisState(did: DID, state: bigint | string): boolean {
|
|
23
|
+
if (typeof state === 'string') {
|
|
24
|
+
state = Hash.fromHex(state).bigInt();
|
|
25
|
+
}
|
|
26
|
+
const id = DID.idFromDID(did);
|
|
27
|
+
const { method, blockchain, networkId } = DID.decodePartsFromId(id);
|
|
28
|
+
const type = buildDIDType(method, blockchain, networkId);
|
|
29
|
+
const idFromState = Id.idGenesisFromIdenState(type, state);
|
|
30
|
+
|
|
31
|
+
return id.bigInt().toString() === idFromState.bigInt().toString();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Checks if DID is an ethereum identity
|
|
36
|
+
*
|
|
37
|
+
* @param {DID} did - did
|
|
38
|
+
* @returns boolean
|
|
39
|
+
*/
|
|
40
|
+
export function isEthereumIdentity(did: DID): boolean {
|
|
41
|
+
const issuerId = DID.idFromDID(did);
|
|
42
|
+
try {
|
|
43
|
+
Id.ethAddressFromId(issuerId);
|
|
44
|
+
// is an ethereum identity
|
|
45
|
+
return true;
|
|
46
|
+
} catch {
|
|
47
|
+
// not an ethereum identity (BabyJubJub or other)
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export const buildVerifierId = (
|
|
53
|
+
address: string,
|
|
54
|
+
info: { method: string; blockchain: string; networkId: string }
|
|
55
|
+
): Id => {
|
|
56
|
+
address = address.replace('0x', '');
|
|
57
|
+
const ethAddrBytes = Hex.decodeString(address);
|
|
58
|
+
const ethAddr = ethAddrBytes.slice(0, 20);
|
|
59
|
+
const genesis = genesisFromEthAddress(ethAddr);
|
|
60
|
+
|
|
61
|
+
const tp = buildDIDType(info.method, info.blockchain, info.networkId);
|
|
62
|
+
|
|
63
|
+
return new Id(tp, genesis);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const validateDIDDocumentAuth = async (did: DID, resolverURL: string, state: Hash) => {
|
|
67
|
+
const vm = await resolveDIDDocumentAuth(did, resolverURL, state);
|
|
68
|
+
if (!vm) {
|
|
69
|
+
throw new Error(`can't resolve DID document`);
|
|
70
|
+
}
|
|
71
|
+
// published or genesis
|
|
72
|
+
if (
|
|
73
|
+
!(vm as VerificationMethod & { published: string }).published &&
|
|
74
|
+
!isGenesisState(did, state.bigInt())
|
|
75
|
+
) {
|
|
76
|
+
throw new Error(`issuer state not published and not genesis`);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export const resolveDIDDocumentAuth = async (
|
|
81
|
+
did: DID,
|
|
82
|
+
resolveURL: string,
|
|
83
|
+
state?: Hash
|
|
84
|
+
): Promise<VerificationMethod | undefined> => {
|
|
85
|
+
let url = `${resolveURL}/${encodeURIComponent(did.string())}`;
|
|
86
|
+
if (state) {
|
|
87
|
+
url += `?state=${state.hex()}`;
|
|
88
|
+
}
|
|
89
|
+
const resp = await fetch(url);
|
|
90
|
+
const didResolutionRes = (await resp.json()) as DIDResolutionResult;
|
|
91
|
+
return didResolutionRes.didDocument?.verificationMethod?.find(
|
|
92
|
+
(i) => i.type === 'Iden3StateInfo2023'
|
|
93
|
+
);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
function emptyStateDID(did: DID) {
|
|
97
|
+
const id = DID.idFromDID(did);
|
|
98
|
+
const didType = buildDIDType(
|
|
99
|
+
DID.methodFromId(id),
|
|
100
|
+
DID.blockchainFromId(id),
|
|
101
|
+
DID.networkIdFromId(id)
|
|
102
|
+
);
|
|
103
|
+
const identifier = Id.idGenesisFromIdenState(didType, 0n);
|
|
104
|
+
const emptyDID = DID.parseFromId(identifier);
|
|
105
|
+
|
|
106
|
+
return emptyDID;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export const resolveDidDocument = async (
|
|
110
|
+
did: DID,
|
|
111
|
+
resolverUrl: string,
|
|
112
|
+
opts?: {
|
|
113
|
+
state?: Hash;
|
|
114
|
+
gist?: Hash;
|
|
115
|
+
signature?: DIDDocumentSignature;
|
|
116
|
+
}
|
|
117
|
+
): Promise<DIDResolutionMetadata> => {
|
|
118
|
+
let didString = encodeURIComponent(did.string());
|
|
119
|
+
// for gist resolve we have to `hide` user did (look into resolver implementation)
|
|
120
|
+
const isGistRequest = opts?.gist && !opts.state;
|
|
121
|
+
if (isGistRequest) {
|
|
122
|
+
didString = encodeURIComponent(emptyStateDID(did).string());
|
|
123
|
+
}
|
|
124
|
+
let url = `${resolverUrl}/1.0/identifiers/${didString}`;
|
|
125
|
+
|
|
126
|
+
if (opts?.signature) {
|
|
127
|
+
url += `?signature=${opts.signature}`;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (opts?.state) {
|
|
131
|
+
url += `${url.includes('?') ? '&' : '?'}state=${opts.state.hex()}`;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (opts?.gist) {
|
|
135
|
+
url += `${url.includes('?') ? '&' : '?'}gist=${opts.gist.hex()}`;
|
|
136
|
+
}
|
|
137
|
+
try {
|
|
138
|
+
const resp = await fetch(url);
|
|
139
|
+
const data = await resp.json();
|
|
140
|
+
return data;
|
|
141
|
+
} catch (e) {
|
|
142
|
+
throw new Error(`Failed to resolve DID document for ${did} ${e}`);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
export const buildDIDFromEthPubKey = (didType: Uint8Array, pubKeyEth: string): DID => {
|
|
147
|
+
// Use Keccak-256 hash function to get public key hash
|
|
148
|
+
const hashOfPublicKey = keccak256(hexToBytes(pubKeyEth));
|
|
149
|
+
// Convert hash to buffer
|
|
150
|
+
const ethAddressBuffer = hexToBytes(hashOfPublicKey);
|
|
151
|
+
// Ethereum Address is '0x' concatenated with last 20 bytes
|
|
152
|
+
// of the public key hash
|
|
153
|
+
const ethAddr = ethAddressBuffer.slice(-20);
|
|
154
|
+
const genesis = genesisFromEthAddress(ethAddr);
|
|
155
|
+
const identifier = new Id(didType, genesis);
|
|
156
|
+
return DID.parseFromId(identifier);
|
|
157
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { base58FromBytes, base58ToBytes as b58ToBytes, Hex } from '@iden3/js-crypto';
|
|
2
|
+
import { base64url, base64 } from 'rfc4648';
|
|
3
|
+
|
|
4
|
+
export const byteEncoder = new TextEncoder();
|
|
5
|
+
export const byteDecoder = new TextDecoder();
|
|
6
|
+
|
|
7
|
+
export function bytesToBase64url(b: Uint8Array, opts = { pad: false }): string {
|
|
8
|
+
return base64url.stringify(b, opts);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function base64ToBytes(s: string, opts = { loose: true }): Uint8Array {
|
|
12
|
+
return base64.parse(s, opts);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function bytesToBase64(b: Uint8Array, opts = { pad: false }): string {
|
|
16
|
+
return base64.stringify(b, opts);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function base64UrlToBytes(s: string, opts = { loose: true }): Uint8Array {
|
|
20
|
+
const inputBase64Url = s.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
|
|
21
|
+
return base64url.parse(inputBase64Url, opts);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function base58ToBytes(s: string): Uint8Array {
|
|
25
|
+
return b58ToBytes(s);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function bytesToBase58(b: Uint8Array): string {
|
|
29
|
+
return base58FromBytes(b);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function hexToBytes(s: string): Uint8Array {
|
|
33
|
+
const input = s.startsWith('0x') ? s.substring(2) : s;
|
|
34
|
+
return Hex.decodeString(input.toLowerCase());
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function encodeBase64url(s: string, opts = { pad: false }): string {
|
|
38
|
+
return base64url.stringify(byteEncoder.encode(s), opts);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function decodeBase64url(s: string, opts = { loose: true }): string {
|
|
42
|
+
return byteDecoder.decode(base64url.parse(s, opts));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function bytesToHex(b: Uint8Array): string {
|
|
46
|
+
return Hex.encodeString(b);
|
|
47
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import PubSub from 'pubsub-js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Represents an event in the SDK.
|
|
5
|
+
*/
|
|
6
|
+
type SdkEvent = string;
|
|
7
|
+
|
|
8
|
+
export const SDK_EVENTS: { [k: SdkEvent]: SdkEvent } = {
|
|
9
|
+
TX_RECEIPT_ACCEPTED: 'TX_RECEIPT_ACCEPTED'
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Represents a topic in the SDK message bus.
|
|
14
|
+
*/
|
|
15
|
+
export type SdkTopic = keyof typeof SDK_EVENTS;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Represents a message bus that allows publishing and subscribing to topics.
|
|
19
|
+
*/
|
|
20
|
+
export class MessageBus {
|
|
21
|
+
/**
|
|
22
|
+
* The singleton instance of the MessageBus class.
|
|
23
|
+
*/
|
|
24
|
+
private static instance: MessageBus;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Private constructor for the MessageBus class.
|
|
28
|
+
*/
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
30
|
+
private constructor() {}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Returns the singleton instance of the MessageBus class.
|
|
34
|
+
* If the instance doesn't exist, it creates a new one.
|
|
35
|
+
* @returns The singleton instance of the MessageBus class.
|
|
36
|
+
*/
|
|
37
|
+
public static getInstance(): MessageBus {
|
|
38
|
+
// If the instance doesn't exist, create it
|
|
39
|
+
if (!MessageBus.instance) {
|
|
40
|
+
MessageBus.instance = new MessageBus();
|
|
41
|
+
}
|
|
42
|
+
// Return the instance
|
|
43
|
+
return MessageBus.instance;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Publishes a message to the specified topic.
|
|
48
|
+
*
|
|
49
|
+
* @template T - The type of data being published.
|
|
50
|
+
* @param {SdkTopic} topic - The topic to publish the message to.
|
|
51
|
+
* @param {T} data - The data to be published.
|
|
52
|
+
* @returns {boolean} - Returns true if the message was successfully published, false otherwise.
|
|
53
|
+
*/
|
|
54
|
+
public publish<T>(topic: SdkTopic, data: T): boolean {
|
|
55
|
+
return PubSub.publish(topic.toString(), data);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Subscribes to a specific topic and registers a callback function to be executed when a message is published.
|
|
60
|
+
*
|
|
61
|
+
* @param topic - The topic to subscribe to.
|
|
62
|
+
* @param callback - The callback function to be executed when a message is published.
|
|
63
|
+
*/
|
|
64
|
+
public subscribe<T>(topic: SdkTopic, callback: (data: T) => void): string {
|
|
65
|
+
return PubSub.subscribe(topic.toString(), (_, data) => callback(data));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Subscribes to a specific topic and registers a callback function to be executed when a message is published.
|
|
70
|
+
* The callback function is executed only once.
|
|
71
|
+
*
|
|
72
|
+
* @param topic - The topic to subscribe to.
|
|
73
|
+
* @param callback - The callback function to be executed when a message is published.
|
|
74
|
+
*/
|
|
75
|
+
public subscribeOnce<T>(topic: SdkTopic, callback: (data: T) => void): void {
|
|
76
|
+
PubSub.subscribeOnce(topic.toString(), (_, data) => callback(data));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Unsubscribes from a specific topic in the message bus.
|
|
81
|
+
*
|
|
82
|
+
* @param topic - The topic to unsubscribe from.
|
|
83
|
+
* @returns A string or boolean indicating the success of the unsubscribe operation.
|
|
84
|
+
*/
|
|
85
|
+
public unsubscribe(topic: SdkTopic): string | boolean {
|
|
86
|
+
return PubSub.unsubscribe(topic.toString());
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Merges two objects together, prioritizing the properties of the second object.
|
|
3
|
+
* If a property exists in both objects, the value from the second object will be used.
|
|
4
|
+
* @param credSubject - The first object to merge.
|
|
5
|
+
* @param otherCredSubject - The second object to merge.
|
|
6
|
+
* @returns A new object with the merged properties.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { JsonDocumentObject } from '../iden3comm';
|
|
10
|
+
|
|
11
|
+
export function mergeObjects(
|
|
12
|
+
credSubject: JsonDocumentObject,
|
|
13
|
+
otherCredSubject: JsonDocumentObject
|
|
14
|
+
) {
|
|
15
|
+
let result = {} as JsonDocumentObject;
|
|
16
|
+
const credSubjectKeys = Object.keys(credSubject);
|
|
17
|
+
|
|
18
|
+
for (const key of credSubjectKeys) {
|
|
19
|
+
if (typeof otherCredSubject[key] !== 'undefined') {
|
|
20
|
+
if (typeof credSubject[key] !== 'object' && typeof otherCredSubject[key] !== 'object') {
|
|
21
|
+
throw new Error('Invalid query');
|
|
22
|
+
}
|
|
23
|
+
const subjectProperty = credSubject[key] as JsonDocumentObject;
|
|
24
|
+
const otherSubjectProperty = otherCredSubject[key] as JsonDocumentObject;
|
|
25
|
+
const propertyOperators = Object.keys(subjectProperty);
|
|
26
|
+
const subjectPropertyResult: JsonDocumentObject = {};
|
|
27
|
+
for (const operatorKey of propertyOperators) {
|
|
28
|
+
if (typeof otherSubjectProperty[operatorKey] !== 'undefined') {
|
|
29
|
+
const operatorValue1 = subjectProperty[operatorKey] as JsonDocumentObject;
|
|
30
|
+
const operatorValue2 = otherSubjectProperty[operatorKey];
|
|
31
|
+
subjectPropertyResult[operatorKey] = [
|
|
32
|
+
...new Set([
|
|
33
|
+
...((subjectPropertyResult[operatorKey] as Array<JsonDocumentObject>) ?? []),
|
|
34
|
+
operatorValue1,
|
|
35
|
+
...(Array.isArray(operatorValue2) ? operatorValue2 : [operatorValue2])
|
|
36
|
+
])
|
|
37
|
+
];
|
|
38
|
+
} else {
|
|
39
|
+
subjectPropertyResult[operatorKey] = subjectProperty[operatorKey];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
result[key] = {
|
|
43
|
+
...(otherCredSubject[key] as JsonDocumentObject),
|
|
44
|
+
...subjectPropertyResult
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Add remaining keys from obj2
|
|
50
|
+
result = { ...credSubject, ...otherCredSubject, ...result };
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { Signer, ethers } from 'ethers';
|
|
2
|
+
import {
|
|
3
|
+
EthereumEip712Signature2021,
|
|
4
|
+
Iden3PaymentRailsERC20RequestV1,
|
|
5
|
+
Iden3PaymentRailsRequestV1,
|
|
6
|
+
MultiChainPaymentConfigOption
|
|
7
|
+
} from '../../iden3comm';
|
|
8
|
+
import { PaymentRequestDataType, SupportedPaymentProofType } from '../../verifiable';
|
|
9
|
+
import { getUnixTimestamp } from '@mocanetwork/moca-iden3';
|
|
10
|
+
import { Resolvable } from 'did-resolver';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @beta
|
|
14
|
+
* buildEvmPayment creates an EVM-based payment request and signs it using EIP-712.
|
|
15
|
+
* @param {Signer} signer - EIP-712 compatible signer
|
|
16
|
+
* @param {MultiChainPaymentConfigOption} option - payment option configuration
|
|
17
|
+
* @param {string} chainId - EVM chain ID
|
|
18
|
+
* @param {string} paymentRails - payment rails contract address
|
|
19
|
+
* @param {string} recipient - recipient address
|
|
20
|
+
* @param {bigint} amount - payment amount in smallest units
|
|
21
|
+
* @param {Date} expirationDateRequired - expiration date
|
|
22
|
+
* @param {bigint} nonce - unique nonce for the payment
|
|
23
|
+
* @returns {Promise<Iden3PaymentRailsRequestV1 | Iden3PaymentRailsERC20RequestV1>} payment request object
|
|
24
|
+
*/
|
|
25
|
+
export const buildEvmPayment = async (
|
|
26
|
+
signer: Signer,
|
|
27
|
+
option: MultiChainPaymentConfigOption,
|
|
28
|
+
chainId: string,
|
|
29
|
+
paymentRails: string,
|
|
30
|
+
recipient: string,
|
|
31
|
+
amount: bigint,
|
|
32
|
+
expirationDateRequired: Date,
|
|
33
|
+
nonce: bigint
|
|
34
|
+
): Promise<Iden3PaymentRailsRequestV1 | Iden3PaymentRailsERC20RequestV1> => {
|
|
35
|
+
const typeUrl = `https://schema.iden3.io/core/json/${option.type}.json`;
|
|
36
|
+
const typesFetchResult = await fetch(typeUrl);
|
|
37
|
+
const types = await typesFetchResult.json();
|
|
38
|
+
delete types.EIP712Domain;
|
|
39
|
+
const paymentData =
|
|
40
|
+
option.type === PaymentRequestDataType.Iden3PaymentRailsRequestV1
|
|
41
|
+
? {
|
|
42
|
+
recipient,
|
|
43
|
+
amount: amount,
|
|
44
|
+
expirationDate: getUnixTimestamp(expirationDateRequired),
|
|
45
|
+
nonce,
|
|
46
|
+
metadata: '0x'
|
|
47
|
+
}
|
|
48
|
+
: {
|
|
49
|
+
tokenAddress: option.contractAddress,
|
|
50
|
+
recipient,
|
|
51
|
+
amount: amount,
|
|
52
|
+
expirationDate: getUnixTimestamp(expirationDateRequired),
|
|
53
|
+
nonce,
|
|
54
|
+
metadata: '0x'
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const domain = {
|
|
58
|
+
name: 'MCPayment',
|
|
59
|
+
version: '1.0.0',
|
|
60
|
+
chainId,
|
|
61
|
+
verifyingContract: paymentRails
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const signature = await signer.signTypedData(domain, types, paymentData);
|
|
65
|
+
|
|
66
|
+
const proof: EthereumEip712Signature2021[] = [
|
|
67
|
+
{
|
|
68
|
+
type: SupportedPaymentProofType.EthereumEip712Signature2021,
|
|
69
|
+
proofPurpose: 'assertionMethod',
|
|
70
|
+
proofValue: signature,
|
|
71
|
+
verificationMethod: `did:pkh:eip155:${chainId}:${await signer.getAddress()}`,
|
|
72
|
+
created: new Date().toISOString(),
|
|
73
|
+
eip712: {
|
|
74
|
+
types: typeUrl,
|
|
75
|
+
primaryType: 'Iden3PaymentRailsRequestV1',
|
|
76
|
+
domain
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
];
|
|
80
|
+
const d: Iden3PaymentRailsRequestV1 = {
|
|
81
|
+
type: PaymentRequestDataType.Iden3PaymentRailsRequestV1,
|
|
82
|
+
'@context': [
|
|
83
|
+
`https://schema.iden3.io/core/jsonld/payment.jsonld#${option.type}`,
|
|
84
|
+
'https://w3id.org/security/suites/eip712sig-2021/v1'
|
|
85
|
+
],
|
|
86
|
+
recipient,
|
|
87
|
+
amount: amount.toString(),
|
|
88
|
+
expirationDate: expirationDateRequired.toISOString(),
|
|
89
|
+
nonce: nonce.toString(),
|
|
90
|
+
metadata: '0x',
|
|
91
|
+
proof
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
if (option.type === PaymentRequestDataType.Iden3PaymentRailsRequestV1) {
|
|
95
|
+
return d;
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
...d,
|
|
99
|
+
type: option.type,
|
|
100
|
+
tokenAddress: option.contractAddress || '',
|
|
101
|
+
features: option.features || []
|
|
102
|
+
} as Iden3PaymentRailsERC20RequestV1;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export async function verifyEIP712TypedData(
|
|
106
|
+
data: Iden3PaymentRailsRequestV1 | Iden3PaymentRailsERC20RequestV1,
|
|
107
|
+
resolver: Resolvable
|
|
108
|
+
): Promise<string> {
|
|
109
|
+
const paymentData =
|
|
110
|
+
data.type === PaymentRequestDataType.Iden3PaymentRailsRequestV1
|
|
111
|
+
? {
|
|
112
|
+
recipient: data.recipient,
|
|
113
|
+
amount: data.amount,
|
|
114
|
+
expirationDate: getUnixTimestamp(new Date(data.expirationDate)),
|
|
115
|
+
nonce: data.nonce,
|
|
116
|
+
metadata: '0x'
|
|
117
|
+
}
|
|
118
|
+
: {
|
|
119
|
+
tokenAddress: data.tokenAddress,
|
|
120
|
+
recipient: data.recipient,
|
|
121
|
+
amount: data.amount,
|
|
122
|
+
expirationDate: getUnixTimestamp(new Date(data.expirationDate)),
|
|
123
|
+
nonce: data.nonce,
|
|
124
|
+
metadata: '0x'
|
|
125
|
+
};
|
|
126
|
+
const proof = Array.isArray(data.proof) ? data.proof[0] : data.proof;
|
|
127
|
+
const typesFetchResult = await fetch(proof.eip712.types);
|
|
128
|
+
const types = await typesFetchResult.json();
|
|
129
|
+
delete types.EIP712Domain;
|
|
130
|
+
const recovered = ethers.verifyTypedData(
|
|
131
|
+
proof.eip712.domain,
|
|
132
|
+
types,
|
|
133
|
+
paymentData,
|
|
134
|
+
proof.proofValue
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
const { didDocument } = await resolver.resolve(proof.verificationMethod);
|
|
138
|
+
if (didDocument?.verificationMethod) {
|
|
139
|
+
for (const verificationMethod of didDocument.verificationMethod) {
|
|
140
|
+
if (
|
|
141
|
+
verificationMethod.blockchainAccountId?.split(':').slice(-1)[0].toLowerCase() ===
|
|
142
|
+
recovered.toLowerCase()
|
|
143
|
+
) {
|
|
144
|
+
return recovered;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
} else {
|
|
148
|
+
throw new Error('failed request. issuer DIDDocument does not contain any verificationMethods');
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
throw new Error(`failed request. no matching verificationMethod`);
|
|
152
|
+
}
|