@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,698 @@
|
|
|
1
|
+
import { PROTOCOL_MESSAGE_TYPE } from '../constants';
|
|
2
|
+
import { MediaType } from '../constants';
|
|
3
|
+
import { BasicMessage, IPackageManager, PackerParams } from '../types';
|
|
4
|
+
|
|
5
|
+
import { DID, getUnixTimestamp } from '@mocanetwork/moca-iden3';
|
|
6
|
+
import * as uuid from 'uuid';
|
|
7
|
+
import { proving } from '@iden3/js-jwz';
|
|
8
|
+
import { buildSolanaPayment, byteEncoder, verifyIden3SolanaPaymentRequest } from '../../utils';
|
|
9
|
+
import {
|
|
10
|
+
AbstractMessageHandler,
|
|
11
|
+
BasicHandlerOptions,
|
|
12
|
+
IProtocolMessageHandler
|
|
13
|
+
} from './message-handler';
|
|
14
|
+
import {
|
|
15
|
+
Iden3PaymentCryptoV1,
|
|
16
|
+
Iden3PaymentRailsERC20RequestV1,
|
|
17
|
+
Iden3PaymentRailsERC20V1,
|
|
18
|
+
Iden3PaymentRailsRequestV1,
|
|
19
|
+
Iden3PaymentRailsSolanaRequestV1,
|
|
20
|
+
Iden3PaymentRailsSolanaSPLRequestV1,
|
|
21
|
+
Iden3PaymentRailsSolanaSPLV1,
|
|
22
|
+
Iden3PaymentRailsSolanaV1,
|
|
23
|
+
Iden3PaymentRailsV1,
|
|
24
|
+
Iden3PaymentRequestCryptoV1,
|
|
25
|
+
MultiChainPaymentConfig,
|
|
26
|
+
PaymentMessage,
|
|
27
|
+
PaymentRequestInfo,
|
|
28
|
+
PaymentRequestMessage,
|
|
29
|
+
PaymentRequestTypeUnion,
|
|
30
|
+
PaymentTypeUnion
|
|
31
|
+
} from '../types/protocol/payment';
|
|
32
|
+
import { PaymentFeatures, PaymentRequestDataType, PaymentType } from '../../verifiable';
|
|
33
|
+
import { Signer } from 'ethers';
|
|
34
|
+
import { Resolvable } from 'did-resolver';
|
|
35
|
+
import { verifyExpiresTime } from './common';
|
|
36
|
+
import { Keypair } from '@solana/web3.js';
|
|
37
|
+
import { buildEvmPayment, verifyEIP712TypedData } from '../../utils/payments/evm';
|
|
38
|
+
|
|
39
|
+
/** @beta PaymentRequestCreationOptions represents payment-request creation options */
|
|
40
|
+
export type PaymentRequestCreationOptions = {
|
|
41
|
+
expires_time?: Date;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/** @beta PaymentCreationOptions represents payment creation options */
|
|
45
|
+
export type PaymentCreationOptions = {
|
|
46
|
+
expires_time?: Date;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/** @beta CreatePaymentRailsV1Options holds options for PaymentRailsV1 creation */
|
|
50
|
+
export type CreatePaymentRailsV1Options = {
|
|
51
|
+
ethSigner?: Signer;
|
|
52
|
+
solSigner?: Keypair;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @beta
|
|
57
|
+
* createPaymentRequest is a function to create protocol payment-request message
|
|
58
|
+
* @param {DID} sender - sender did
|
|
59
|
+
* @param {DID} receiver - receiver did
|
|
60
|
+
* @param {string} agent - agent URL
|
|
61
|
+
* @param {PaymentRequestInfo[]} payments - payments
|
|
62
|
+
* @returns `PaymentRequestMessage`
|
|
63
|
+
*/
|
|
64
|
+
export function createPaymentRequest(
|
|
65
|
+
sender: DID,
|
|
66
|
+
receiver: DID,
|
|
67
|
+
agent: string,
|
|
68
|
+
payments: PaymentRequestInfo[],
|
|
69
|
+
opts?: PaymentRequestCreationOptions
|
|
70
|
+
): PaymentRequestMessage {
|
|
71
|
+
const uuidv4 = uuid.v4();
|
|
72
|
+
const request: PaymentRequestMessage = {
|
|
73
|
+
id: uuidv4,
|
|
74
|
+
thid: uuidv4,
|
|
75
|
+
from: sender.string(),
|
|
76
|
+
to: receiver.string(),
|
|
77
|
+
typ: MediaType.PlainMessage,
|
|
78
|
+
type: PROTOCOL_MESSAGE_TYPE.PAYMENT_REQUEST_MESSAGE_TYPE,
|
|
79
|
+
body: {
|
|
80
|
+
agent,
|
|
81
|
+
payments
|
|
82
|
+
},
|
|
83
|
+
created_time: getUnixTimestamp(new Date()),
|
|
84
|
+
expires_time: opts?.expires_time ? getUnixTimestamp(opts.expires_time) : undefined
|
|
85
|
+
};
|
|
86
|
+
return request;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @beta
|
|
91
|
+
* PaymentRailsInfo represents payment info for payment rails
|
|
92
|
+
*/
|
|
93
|
+
export type PaymentRailsInfo = {
|
|
94
|
+
credentials: {
|
|
95
|
+
type: string;
|
|
96
|
+
context: string;
|
|
97
|
+
}[];
|
|
98
|
+
description?: string;
|
|
99
|
+
options: PaymentRailsOptionInfo[];
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* @beta
|
|
104
|
+
* PaymentRailsOptionInfo represents option info for payment rails
|
|
105
|
+
*/
|
|
106
|
+
export type PaymentRailsOptionInfo = {
|
|
107
|
+
optionId: string;
|
|
108
|
+
chainId: string;
|
|
109
|
+
nonce: bigint;
|
|
110
|
+
amount: string;
|
|
111
|
+
expirationDate?: Date;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* @beta
|
|
116
|
+
* createPayment is a function to create protocol payment message
|
|
117
|
+
* @param {DID} sender - sender did
|
|
118
|
+
* @param {DID} receiver - receiver did
|
|
119
|
+
* @param {PaymentMessageBody} body - payments
|
|
120
|
+
* @returns `PaymentMessage`
|
|
121
|
+
*/
|
|
122
|
+
export function createPayment(
|
|
123
|
+
sender: DID,
|
|
124
|
+
receiver: DID,
|
|
125
|
+
payments: PaymentTypeUnion[],
|
|
126
|
+
opts?: PaymentCreationOptions
|
|
127
|
+
): PaymentMessage {
|
|
128
|
+
const uuidv4 = uuid.v4();
|
|
129
|
+
const request: PaymentMessage = {
|
|
130
|
+
id: uuidv4,
|
|
131
|
+
thid: uuidv4,
|
|
132
|
+
from: sender.string(),
|
|
133
|
+
to: receiver.string(),
|
|
134
|
+
typ: MediaType.PlainMessage,
|
|
135
|
+
type: PROTOCOL_MESSAGE_TYPE.PAYMENT_MESSAGE_TYPE,
|
|
136
|
+
body: {
|
|
137
|
+
payments
|
|
138
|
+
},
|
|
139
|
+
created_time: getUnixTimestamp(new Date()),
|
|
140
|
+
expires_time: opts?.expires_time ? getUnixTimestamp(opts.expires_time) : undefined
|
|
141
|
+
};
|
|
142
|
+
return request;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* @beta
|
|
147
|
+
* Interface that allows the processing of the payment-request and payment protocol messages
|
|
148
|
+
*
|
|
149
|
+
* @interface IPaymentHandler
|
|
150
|
+
*/
|
|
151
|
+
export interface IPaymentHandler {
|
|
152
|
+
/**
|
|
153
|
+
* @beta
|
|
154
|
+
* unpacks payment-request
|
|
155
|
+
* @param {Uint8Array} request - raw byte message
|
|
156
|
+
* @returns `Promise<PaymentRequestMessage>`
|
|
157
|
+
*/
|
|
158
|
+
parsePaymentRequest(request: Uint8Array): Promise<PaymentRequestMessage>;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* @beta
|
|
162
|
+
* handle payment-request
|
|
163
|
+
* @param {Uint8Array} request - raw byte message
|
|
164
|
+
* @param {PaymentRequestMessageHandlerOptions} opts - handler options
|
|
165
|
+
* @returns {Promise<Uint8Array>} - agent message or null
|
|
166
|
+
*/
|
|
167
|
+
handlePaymentRequest(
|
|
168
|
+
request: Uint8Array,
|
|
169
|
+
opts: PaymentRequestMessageHandlerOptions
|
|
170
|
+
): Promise<Uint8Array | null>;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* @beta
|
|
174
|
+
* handle payment protocol message
|
|
175
|
+
* @param {PaymentMessage} payment - payment message
|
|
176
|
+
* @param {PaymentHandlerOptions} opts - options
|
|
177
|
+
* @returns `Promise<void>`
|
|
178
|
+
*/
|
|
179
|
+
handlePayment(payment: PaymentMessage, opts: PaymentHandlerOptions): Promise<void>;
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* @beta
|
|
183
|
+
* createPaymentRailsV1 is a function to create protocol payment message
|
|
184
|
+
* @param {DID} sender - sender did
|
|
185
|
+
* @param {DID} receiver - receiver did
|
|
186
|
+
* @param {string} agent - agent URL
|
|
187
|
+
* @param {Signer} signer - ETH signer
|
|
188
|
+
* @param payments - payment options
|
|
189
|
+
* @param {CreatePaymentRailsV1Options} createOptions - options for payment rails creation
|
|
190
|
+
* @returns {Promise<PaymentRequestMessage>}
|
|
191
|
+
*/
|
|
192
|
+
createPaymentRailsV1(
|
|
193
|
+
sender: DID,
|
|
194
|
+
receiver: DID,
|
|
195
|
+
agent: string,
|
|
196
|
+
signer: Signer, // the same as createOptions.ethSigner (for compatibility)
|
|
197
|
+
payments: PaymentRailsInfo[],
|
|
198
|
+
createOptions?: CreatePaymentRailsV1Options
|
|
199
|
+
): Promise<PaymentRequestMessage>;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** @beta PaymentRequestMessageHandlerOptions represents payment-request handler options */
|
|
203
|
+
export type PaymentRequestMessageHandlerOptions = BasicHandlerOptions & {
|
|
204
|
+
paymentHandler: (data: PaymentRequestTypeUnion) => Promise<string>;
|
|
205
|
+
/*
|
|
206
|
+
selected payment nonce (for Iden3PaymentRequestCryptoV1 type it should be equal to Payment id field)
|
|
207
|
+
*/
|
|
208
|
+
nonce: string;
|
|
209
|
+
erc20TokenApproveHandler?: (data: Iden3PaymentRailsERC20RequestV1) => Promise<string>;
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
/** @beta PaymentHandlerOptions represents payment handler options */
|
|
213
|
+
export type PaymentHandlerOptions = BasicHandlerOptions & {
|
|
214
|
+
paymentRequest: PaymentRequestMessage;
|
|
215
|
+
paymentValidationHandler: (txId: string, data: PaymentRequestTypeUnion) => Promise<void>;
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
/** @beta PaymentHandlerParams represents payment handler params */
|
|
219
|
+
export type PaymentHandlerParams = {
|
|
220
|
+
packerParams: PackerParams;
|
|
221
|
+
documentResolver: Resolvable;
|
|
222
|
+
multiChainPaymentConfig?: MultiChainPaymentConfig[];
|
|
223
|
+
/*
|
|
224
|
+
* allowed signers for payment request (if not provided, any signer is allowed)
|
|
225
|
+
*/
|
|
226
|
+
allowedSigners?: string[];
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
*
|
|
231
|
+
* Allows to process PaymentRequest protocol message
|
|
232
|
+
* @beta
|
|
233
|
+
* @class PaymentHandler
|
|
234
|
+
* @implements implements IPaymentHandler interface
|
|
235
|
+
*/
|
|
236
|
+
export class PaymentHandler
|
|
237
|
+
extends AbstractMessageHandler
|
|
238
|
+
implements IPaymentHandler, IProtocolMessageHandler
|
|
239
|
+
{
|
|
240
|
+
/**
|
|
241
|
+
* @beta Creates an instance of PaymentHandler.
|
|
242
|
+
* @param {IPackageManager} _packerMgr - package manager to unpack message envelope
|
|
243
|
+
* @param {PaymentHandlerParams} _params - payment handler params
|
|
244
|
+
*
|
|
245
|
+
*/
|
|
246
|
+
|
|
247
|
+
constructor(
|
|
248
|
+
private readonly _packerMgr: IPackageManager,
|
|
249
|
+
private readonly _params: PaymentHandlerParams
|
|
250
|
+
) {
|
|
251
|
+
super();
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
public async handle(
|
|
255
|
+
message: BasicMessage,
|
|
256
|
+
context: PaymentRequestMessageHandlerOptions | PaymentHandlerOptions
|
|
257
|
+
): Promise<BasicMessage | null> {
|
|
258
|
+
switch (message.type) {
|
|
259
|
+
case PROTOCOL_MESSAGE_TYPE.PAYMENT_REQUEST_MESSAGE_TYPE:
|
|
260
|
+
return await this.handlePaymentRequestMessage(
|
|
261
|
+
message as PaymentRequestMessage,
|
|
262
|
+
context as PaymentRequestMessageHandlerOptions
|
|
263
|
+
);
|
|
264
|
+
case PROTOCOL_MESSAGE_TYPE.PAYMENT_MESSAGE_TYPE:
|
|
265
|
+
await this.handlePayment(message as PaymentMessage, context as PaymentHandlerOptions);
|
|
266
|
+
return null;
|
|
267
|
+
default:
|
|
268
|
+
return super.handle(message, context as { [key: string]: unknown });
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* @inheritdoc IPaymentHandler#parsePaymentRequest
|
|
274
|
+
*/
|
|
275
|
+
async parsePaymentRequest(request: Uint8Array): Promise<PaymentRequestMessage> {
|
|
276
|
+
const { unpackedMessage: message } = await this._packerMgr.unpack(request);
|
|
277
|
+
const paymentRequest = message as PaymentRequestMessage;
|
|
278
|
+
if (message.type !== PROTOCOL_MESSAGE_TYPE.PAYMENT_REQUEST_MESSAGE_TYPE) {
|
|
279
|
+
throw new Error('Invalid media type');
|
|
280
|
+
}
|
|
281
|
+
return paymentRequest;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
private async handlePaymentRequestMessage(
|
|
285
|
+
paymentRequest: PaymentRequestMessage,
|
|
286
|
+
ctx: PaymentRequestMessageHandlerOptions
|
|
287
|
+
): Promise<BasicMessage | null> {
|
|
288
|
+
if (!paymentRequest.to) {
|
|
289
|
+
throw new Error(`failed request. empty 'to' field`);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
if (!paymentRequest.from) {
|
|
293
|
+
throw new Error(`failed request. empty 'from' field`);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
if (!paymentRequest.body.payments?.length) {
|
|
297
|
+
throw new Error(`failed request. no 'payments' in body`);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
if (!ctx.paymentHandler) {
|
|
301
|
+
throw new Error(`please provide payment handler in context`);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
const senderDID = DID.parse(paymentRequest.to);
|
|
305
|
+
const receiverDID = DID.parse(paymentRequest.from);
|
|
306
|
+
|
|
307
|
+
const payments: PaymentTypeUnion[] = [];
|
|
308
|
+
for (let i = 0; i < paymentRequest.body.payments.length; i++) {
|
|
309
|
+
const { data } = paymentRequest.body.payments[i];
|
|
310
|
+
const selectedPayment = Array.isArray(data)
|
|
311
|
+
? data.find((p) => {
|
|
312
|
+
return p.type === PaymentRequestDataType.Iden3PaymentRequestCryptoV1
|
|
313
|
+
? p.id === ctx.nonce
|
|
314
|
+
: p.nonce === ctx.nonce;
|
|
315
|
+
})
|
|
316
|
+
: data;
|
|
317
|
+
|
|
318
|
+
if (!selectedPayment) {
|
|
319
|
+
throw new Error(`failed request. no payment in request for nonce ${ctx.nonce}`);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
switch (selectedPayment.type) {
|
|
323
|
+
case PaymentRequestDataType.Iden3PaymentRequestCryptoV1:
|
|
324
|
+
payments.push(
|
|
325
|
+
await this.handleIden3PaymentRequestCryptoV1(selectedPayment, ctx.paymentHandler)
|
|
326
|
+
);
|
|
327
|
+
break;
|
|
328
|
+
case PaymentRequestDataType.Iden3PaymentRailsRequestV1:
|
|
329
|
+
payments.push(
|
|
330
|
+
await this.handleIden3PaymentRailsRequestV1(selectedPayment, ctx.paymentHandler)
|
|
331
|
+
);
|
|
332
|
+
break;
|
|
333
|
+
case PaymentRequestDataType.Iden3PaymentRailsERC20RequestV1:
|
|
334
|
+
payments.push(
|
|
335
|
+
await this.handleIden3PaymentRailsERC20RequestV1(
|
|
336
|
+
selectedPayment,
|
|
337
|
+
ctx.paymentHandler,
|
|
338
|
+
ctx.erc20TokenApproveHandler
|
|
339
|
+
)
|
|
340
|
+
);
|
|
341
|
+
break;
|
|
342
|
+
case PaymentRequestDataType.Iden3PaymentRailsSolanaRequestV1:
|
|
343
|
+
payments.push(
|
|
344
|
+
await this.handleIden3PaymentRailsSolanaRequestV1(selectedPayment, ctx.paymentHandler)
|
|
345
|
+
);
|
|
346
|
+
break;
|
|
347
|
+
case PaymentRequestDataType.Iden3PaymentRailsSolanaSPLRequestV1:
|
|
348
|
+
payments.push(
|
|
349
|
+
await this.handleIden3PaymentRailsSolanaSPLRequestV1(
|
|
350
|
+
{
|
|
351
|
+
...selectedPayment,
|
|
352
|
+
type: PaymentRequestDataType.Iden3PaymentRailsSolanaSPLRequestV1
|
|
353
|
+
},
|
|
354
|
+
ctx.paymentHandler
|
|
355
|
+
)
|
|
356
|
+
);
|
|
357
|
+
break;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
const paymentMessage = createPayment(senderDID, receiverDID, payments);
|
|
362
|
+
const response = await this.packMessage(paymentMessage, senderDID);
|
|
363
|
+
|
|
364
|
+
const agentResult = await fetch(paymentRequest.body.agent, {
|
|
365
|
+
method: 'POST',
|
|
366
|
+
body: response,
|
|
367
|
+
headers: {
|
|
368
|
+
'Content-Type':
|
|
369
|
+
this._params.packerParams.mediaType === MediaType.PlainMessage
|
|
370
|
+
? 'application/json'
|
|
371
|
+
: 'application/octet-stream'
|
|
372
|
+
}
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
const arrayBuffer = await agentResult.arrayBuffer();
|
|
376
|
+
if (!arrayBuffer.byteLength) {
|
|
377
|
+
return null;
|
|
378
|
+
}
|
|
379
|
+
const { unpackedMessage } = await this._packerMgr.unpack(new Uint8Array(arrayBuffer));
|
|
380
|
+
return unpackedMessage;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* @inheritdoc IPaymentHandler#handlePaymentRequest
|
|
385
|
+
*/
|
|
386
|
+
async handlePaymentRequest(
|
|
387
|
+
request: Uint8Array,
|
|
388
|
+
opts: PaymentRequestMessageHandlerOptions
|
|
389
|
+
): Promise<Uint8Array | null> {
|
|
390
|
+
if (
|
|
391
|
+
this._params.packerParams.mediaType === MediaType.SignedMessage &&
|
|
392
|
+
!this._params.packerParams.packerOptions
|
|
393
|
+
) {
|
|
394
|
+
throw new Error(`jws packer options are required for ${MediaType.SignedMessage}`);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
const paymentRequest = await this.parsePaymentRequest(request);
|
|
398
|
+
if (!paymentRequest.from) {
|
|
399
|
+
throw new Error(`failed request. empty 'from' field`);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
if (!paymentRequest.to) {
|
|
403
|
+
throw new Error(`failed request. empty 'to' field`);
|
|
404
|
+
}
|
|
405
|
+
if (!opts?.allowExpiredMessages) {
|
|
406
|
+
verifyExpiresTime(paymentRequest);
|
|
407
|
+
}
|
|
408
|
+
const agentMessage = await this.handlePaymentRequestMessage(paymentRequest, opts);
|
|
409
|
+
if (!agentMessage) {
|
|
410
|
+
return null;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
const senderDID = DID.parse(paymentRequest.to);
|
|
414
|
+
return this.packMessage(agentMessage, senderDID);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* @inheritdoc IPaymentHandler#handlePayment
|
|
419
|
+
*/
|
|
420
|
+
async handlePayment(payment: PaymentMessage, params: PaymentHandlerOptions) {
|
|
421
|
+
if (!params?.allowExpiredMessages) {
|
|
422
|
+
verifyExpiresTime(payment);
|
|
423
|
+
}
|
|
424
|
+
if (params.paymentRequest.from !== payment.to) {
|
|
425
|
+
throw new Error(
|
|
426
|
+
`sender of the request is not a target of response - expected ${params.paymentRequest.from}, given ${payment.to}`
|
|
427
|
+
);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
if (!payment.body.payments.length) {
|
|
431
|
+
throw new Error(`failed request. empty 'payments' field in body`);
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
if (!params.paymentValidationHandler) {
|
|
435
|
+
throw new Error(`please provide payment validation handler in options`);
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
for (let i = 0; i < payment.body.payments.length; i++) {
|
|
439
|
+
const p = payment.body.payments[i];
|
|
440
|
+
const nonce = p.type === PaymentType.Iden3PaymentCryptoV1 ? p.id : p.nonce;
|
|
441
|
+
const requestDataArr = params.paymentRequest.body.payments
|
|
442
|
+
.map((r) => (Array.isArray(r.data) ? r.data : [r.data]))
|
|
443
|
+
.flat();
|
|
444
|
+
const requestData = requestDataArr.find((r) =>
|
|
445
|
+
r.type === PaymentRequestDataType.Iden3PaymentRequestCryptoV1
|
|
446
|
+
? r.id === nonce
|
|
447
|
+
: r.nonce === nonce
|
|
448
|
+
);
|
|
449
|
+
if (!requestData) {
|
|
450
|
+
throw new Error(
|
|
451
|
+
`can't find payment request for payment ${
|
|
452
|
+
p.type === PaymentType.Iden3PaymentCryptoV1 ? 'id' : 'nonce'
|
|
453
|
+
} ${nonce}`
|
|
454
|
+
);
|
|
455
|
+
}
|
|
456
|
+
await params.paymentValidationHandler(p.paymentData.txId, requestData);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* @inheritdoc IPaymentHandler#createPaymentRailsV1
|
|
462
|
+
*/
|
|
463
|
+
async createPaymentRailsV1(
|
|
464
|
+
sender: DID,
|
|
465
|
+
receiver: DID,
|
|
466
|
+
agent: string,
|
|
467
|
+
signer: Signer,
|
|
468
|
+
payments: PaymentRailsInfo[],
|
|
469
|
+
createOptions?: CreatePaymentRailsV1Options
|
|
470
|
+
): Promise<PaymentRequestMessage> {
|
|
471
|
+
const paymentRequestInfo: PaymentRequestInfo[] = [];
|
|
472
|
+
for (let i = 0; i < payments.length; i++) {
|
|
473
|
+
const { credentials, description } = payments[i];
|
|
474
|
+
const dataArr: (
|
|
475
|
+
| Iden3PaymentRailsRequestV1
|
|
476
|
+
| Iden3PaymentRailsERC20RequestV1
|
|
477
|
+
| Iden3PaymentRailsSolanaRequestV1
|
|
478
|
+
| Iden3PaymentRailsSolanaSPLRequestV1
|
|
479
|
+
)[] = [];
|
|
480
|
+
for (let j = 0; j < payments[i].options.length; j++) {
|
|
481
|
+
const { nonce, amount, chainId, optionId, expirationDate } = payments[i].options[j];
|
|
482
|
+
|
|
483
|
+
const multiChainConfig = this._params.multiChainPaymentConfig?.find(
|
|
484
|
+
(c) => c.chainId === chainId
|
|
485
|
+
);
|
|
486
|
+
if (!multiChainConfig) {
|
|
487
|
+
throw new Error(`failed request. no config for chain ${chainId}`);
|
|
488
|
+
}
|
|
489
|
+
const { recipient, paymentRails, options } = multiChainConfig;
|
|
490
|
+
|
|
491
|
+
const option = options.find((t) => t.id === optionId);
|
|
492
|
+
if (!option) {
|
|
493
|
+
throw new Error(`failed request. no option for id ${optionId}`);
|
|
494
|
+
}
|
|
495
|
+
if (
|
|
496
|
+
(option.type === PaymentRequestDataType.Iden3PaymentRailsERC20RequestV1 ||
|
|
497
|
+
option.type === PaymentRequestDataType.Iden3PaymentRailsSolanaSPLRequestV1) &&
|
|
498
|
+
!option.contractAddress
|
|
499
|
+
) {
|
|
500
|
+
throw new Error(`failed request. no token address for option id ${optionId}`);
|
|
501
|
+
}
|
|
502
|
+
const expirationDateRequired =
|
|
503
|
+
expirationDate ?? new Date(new Date().setHours(new Date().getHours() + 1));
|
|
504
|
+
|
|
505
|
+
if (
|
|
506
|
+
option.type === PaymentRequestDataType.Iden3PaymentRailsSolanaRequestV1 ||
|
|
507
|
+
option.type === PaymentRequestDataType.Iden3PaymentRailsSolanaSPLRequestV1
|
|
508
|
+
) {
|
|
509
|
+
if (!createOptions?.solSigner) {
|
|
510
|
+
throw new Error(
|
|
511
|
+
`please provide solana signer in context for ${option.type} payment type`
|
|
512
|
+
);
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
const payment = await buildSolanaPayment(
|
|
516
|
+
createOptions.solSigner,
|
|
517
|
+
option,
|
|
518
|
+
chainId,
|
|
519
|
+
paymentRails,
|
|
520
|
+
recipient,
|
|
521
|
+
BigInt(amount),
|
|
522
|
+
expirationDateRequired,
|
|
523
|
+
nonce
|
|
524
|
+
);
|
|
525
|
+
dataArr.push(payment);
|
|
526
|
+
} else {
|
|
527
|
+
const payment = await buildEvmPayment(
|
|
528
|
+
signer,
|
|
529
|
+
option,
|
|
530
|
+
chainId,
|
|
531
|
+
paymentRails,
|
|
532
|
+
recipient,
|
|
533
|
+
BigInt(amount),
|
|
534
|
+
expirationDateRequired,
|
|
535
|
+
nonce
|
|
536
|
+
);
|
|
537
|
+
dataArr.push(payment);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
paymentRequestInfo.push({
|
|
542
|
+
data: dataArr,
|
|
543
|
+
credentials,
|
|
544
|
+
description
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
return createPaymentRequest(sender, receiver, agent, paymentRequestInfo);
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
private async packMessage(message: BasicMessage, senderDID: DID): Promise<Uint8Array> {
|
|
551
|
+
const responseEncoded = byteEncoder.encode(JSON.stringify(message));
|
|
552
|
+
const packerOpts =
|
|
553
|
+
this._params.packerParams.mediaType === MediaType.SignedMessage
|
|
554
|
+
? this._params.packerParams.packerOptions
|
|
555
|
+
: {
|
|
556
|
+
provingMethodAlg: proving.provingMethodGroth16AuthV2Instance.methodAlg
|
|
557
|
+
};
|
|
558
|
+
return await this._packerMgr.pack(this._params.packerParams.mediaType, responseEncoded, {
|
|
559
|
+
senderDID,
|
|
560
|
+
...packerOpts
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
private async handleIden3PaymentRequestCryptoV1(
|
|
565
|
+
data: Iden3PaymentRequestCryptoV1,
|
|
566
|
+
paymentHandler: (data: Iden3PaymentRequestCryptoV1) => Promise<string>
|
|
567
|
+
): Promise<Iden3PaymentCryptoV1> {
|
|
568
|
+
if (data.expiration && new Date(data.expiration) < new Date()) {
|
|
569
|
+
throw new Error(`failed request. expired request`);
|
|
570
|
+
}
|
|
571
|
+
const txId = await paymentHandler(data);
|
|
572
|
+
|
|
573
|
+
return {
|
|
574
|
+
id: data.id,
|
|
575
|
+
'@context': 'https://schema.iden3.io/core/jsonld/payment.jsonld#Iden3PaymentCryptoV1',
|
|
576
|
+
type: PaymentType.Iden3PaymentCryptoV1,
|
|
577
|
+
paymentData: {
|
|
578
|
+
txId
|
|
579
|
+
}
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
private async handleIden3PaymentRailsRequestV1(
|
|
584
|
+
data: Iden3PaymentRailsRequestV1,
|
|
585
|
+
paymentHandler: (data: Iden3PaymentRailsRequestV1) => Promise<string>
|
|
586
|
+
): Promise<Iden3PaymentRailsV1> {
|
|
587
|
+
if (data.expirationDate && new Date(data.expirationDate) < new Date()) {
|
|
588
|
+
throw new Error(`failed request. expired request`);
|
|
589
|
+
}
|
|
590
|
+
const signer = await verifyEIP712TypedData(data, this._params.documentResolver);
|
|
591
|
+
if (this._params.allowedSigners && !this._params.allowedSigners.includes(signer)) {
|
|
592
|
+
throw new Error(`failed request. signer is not in the allowed signers list`);
|
|
593
|
+
}
|
|
594
|
+
const txId = await paymentHandler(data);
|
|
595
|
+
const proof = Array.isArray(data.proof) ? data.proof[0] : data.proof;
|
|
596
|
+
return {
|
|
597
|
+
nonce: data.nonce,
|
|
598
|
+
type: PaymentType.Iden3PaymentRailsV1,
|
|
599
|
+
'@context': 'https://schema.iden3.io/core/jsonld/payment.jsonld#Iden3PaymentRailsV1',
|
|
600
|
+
paymentData: {
|
|
601
|
+
txId,
|
|
602
|
+
chainId: proof.eip712.domain.chainId
|
|
603
|
+
}
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
private async handleIden3PaymentRailsSolanaRequestV1(
|
|
608
|
+
data: Iden3PaymentRailsSolanaRequestV1,
|
|
609
|
+
paymentHandler: (data: Iden3PaymentRailsSolanaRequestV1) => Promise<string>
|
|
610
|
+
): Promise<Iden3PaymentRailsSolanaV1> {
|
|
611
|
+
if (data.expirationDate && new Date(data.expirationDate) < new Date()) {
|
|
612
|
+
throw new Error(`failed request. expired request`);
|
|
613
|
+
}
|
|
614
|
+
const isValid = await verifyIden3SolanaPaymentRequest(data, this._params.documentResolver);
|
|
615
|
+
if (!isValid) {
|
|
616
|
+
throw new Error(`failed request. invalid Solana payment request signature`);
|
|
617
|
+
}
|
|
618
|
+
const proof = Array.isArray(data.proof) ? data.proof[0] : data.proof;
|
|
619
|
+
const signer = proof.verificationMethod.split(':').slice(-1)[0];
|
|
620
|
+
if (this._params.allowedSigners && !this._params.allowedSigners.includes(signer)) {
|
|
621
|
+
throw new Error(`failed request. signer is not in the allowed signers list`);
|
|
622
|
+
}
|
|
623
|
+
const txId = await paymentHandler(data);
|
|
624
|
+
return {
|
|
625
|
+
nonce: data.nonce,
|
|
626
|
+
type: PaymentType.Iden3PaymentRailsSolanaV1,
|
|
627
|
+
'@context': 'https://schema.iden3.io/core/jsonld/payment.jsonld#Iden3PaymentRailsSolanaV1',
|
|
628
|
+
paymentData: {
|
|
629
|
+
txId,
|
|
630
|
+
chainId: proof.domain.chainId
|
|
631
|
+
}
|
|
632
|
+
};
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
private async handleIden3PaymentRailsSolanaSPLRequestV1(
|
|
636
|
+
data: Iden3PaymentRailsSolanaSPLRequestV1,
|
|
637
|
+
paymentHandler: (data: Iden3PaymentRailsSolanaSPLRequestV1) => Promise<string>
|
|
638
|
+
): Promise<Iden3PaymentRailsSolanaSPLV1> {
|
|
639
|
+
if (data.expirationDate && new Date(data.expirationDate) < new Date()) {
|
|
640
|
+
throw new Error(`failed request. expired request`);
|
|
641
|
+
}
|
|
642
|
+
const isValid = await verifyIden3SolanaPaymentRequest(data, this._params.documentResolver);
|
|
643
|
+
if (!isValid) {
|
|
644
|
+
throw new Error(`failed request. invalid Solana payment request signature`);
|
|
645
|
+
}
|
|
646
|
+
const proof = Array.isArray(data.proof) ? data.proof[0] : data.proof;
|
|
647
|
+
const signer = proof.verificationMethod.split(':').slice(-1)[0];
|
|
648
|
+
if (this._params.allowedSigners && !this._params.allowedSigners.includes(signer)) {
|
|
649
|
+
throw new Error(`failed request. signer is not in the allowed signers list`);
|
|
650
|
+
}
|
|
651
|
+
const txId = await paymentHandler(data);
|
|
652
|
+
return {
|
|
653
|
+
nonce: data.nonce,
|
|
654
|
+
type: PaymentType.Iden3PaymentRailsSolanaSPLV1,
|
|
655
|
+
'@context': 'https://schema.iden3.io/core/jsonld/payment.jsonld#Iden3PaymentRailsSolanaSPLV1',
|
|
656
|
+
paymentData: {
|
|
657
|
+
txId,
|
|
658
|
+
chainId: proof.domain.chainId,
|
|
659
|
+
tokenAddress: data.tokenAddress
|
|
660
|
+
}
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
private async handleIden3PaymentRailsERC20RequestV1(
|
|
665
|
+
data: Iden3PaymentRailsERC20RequestV1,
|
|
666
|
+
paymentHandler: (data: Iden3PaymentRailsERC20RequestV1) => Promise<string>,
|
|
667
|
+
approveHandler?: (data: Iden3PaymentRailsERC20RequestV1) => Promise<string>
|
|
668
|
+
): Promise<Iden3PaymentRailsERC20V1> {
|
|
669
|
+
if (data.expirationDate && new Date(data.expirationDate) < new Date()) {
|
|
670
|
+
throw new Error(`failed request. expired request`);
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
const signer = await verifyEIP712TypedData(data, this._params.documentResolver);
|
|
674
|
+
if (this._params.allowedSigners && !this._params.allowedSigners.includes(signer)) {
|
|
675
|
+
throw new Error(`failed request. signer is not in the allowed signers list`);
|
|
676
|
+
}
|
|
677
|
+
if (!data.features?.includes(PaymentFeatures.EIP_2612) && !approveHandler) {
|
|
678
|
+
throw new Error(`please provide erc20TokenApproveHandler in context for ERC-20 payment type`);
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
if (approveHandler) {
|
|
682
|
+
await approveHandler(data);
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
const txId = await paymentHandler(data);
|
|
686
|
+
const proof = Array.isArray(data.proof) ? data.proof[0] : data.proof;
|
|
687
|
+
return {
|
|
688
|
+
nonce: data.nonce,
|
|
689
|
+
type: PaymentType.Iden3PaymentRailsERC20V1,
|
|
690
|
+
'@context': 'https://schema.iden3.io/core/jsonld/payment.jsonld#Iden3PaymentRailsERC20V1',
|
|
691
|
+
paymentData: {
|
|
692
|
+
txId,
|
|
693
|
+
chainId: proof.eip712.domain.chainId,
|
|
694
|
+
tokenAddress: data.tokenAddress
|
|
695
|
+
}
|
|
696
|
+
};
|
|
697
|
+
}
|
|
698
|
+
}
|