@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,41 @@
|
|
|
1
|
+
import * as uuid from 'uuid';
|
|
2
|
+
import { ProblemReportMessage } from '../types/protocol/problem-report';
|
|
3
|
+
import { MediaType, PROTOCOL_MESSAGE_TYPE } from '../constants';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @beta
|
|
7
|
+
* createProblemReportMessage is a function to create didcomm protocol problem report message
|
|
8
|
+
* @param pthid - parent thread id
|
|
9
|
+
* @param code - problem report code
|
|
10
|
+
* @param opts - problem report options
|
|
11
|
+
* @returns `ProblemReportMessage`
|
|
12
|
+
*/
|
|
13
|
+
export function createProblemReportMessage(
|
|
14
|
+
pthid: string,
|
|
15
|
+
code: string,
|
|
16
|
+
opts?: {
|
|
17
|
+
comment?: string;
|
|
18
|
+
ack?: string[];
|
|
19
|
+
args?: string[];
|
|
20
|
+
escalate_to?: string;
|
|
21
|
+
from?: string;
|
|
22
|
+
to?: string;
|
|
23
|
+
}
|
|
24
|
+
): ProblemReportMessage {
|
|
25
|
+
const uuidv4 = uuid.v4();
|
|
26
|
+
return {
|
|
27
|
+
id: uuidv4,
|
|
28
|
+
pthid: pthid,
|
|
29
|
+
typ: MediaType.PlainMessage,
|
|
30
|
+
type: PROTOCOL_MESSAGE_TYPE.PROBLEM_REPORT_MESSAGE_TYPE,
|
|
31
|
+
ack: opts?.ack,
|
|
32
|
+
body: {
|
|
33
|
+
code: code,
|
|
34
|
+
comment: opts?.comment,
|
|
35
|
+
args: opts?.args,
|
|
36
|
+
escalate_to: opts?.escalate_to
|
|
37
|
+
},
|
|
38
|
+
from: opts?.from,
|
|
39
|
+
to: opts?.to
|
|
40
|
+
};
|
|
41
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { MediaType } from '../constants';
|
|
2
|
+
import { PROTOCOL_MESSAGE_TYPE } from '../constants';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
CredentialIssuanceMessage,
|
|
6
|
+
CredentialRefreshMessage,
|
|
7
|
+
IPackageManager,
|
|
8
|
+
ZKPPackerParams
|
|
9
|
+
} from '../types';
|
|
10
|
+
|
|
11
|
+
import { RefreshServiceType, W3CCredential } from '../../verifiable';
|
|
12
|
+
import { byteEncoder } from '../../utils';
|
|
13
|
+
import { proving, ProvingMethodAlg } from '@iden3/js-jwz';
|
|
14
|
+
import { DID } from '@mocanetwork/moca-iden3';
|
|
15
|
+
import { ICredentialWallet } from '../../credentials';
|
|
16
|
+
import { CircuitId } from '../../circuits';
|
|
17
|
+
import * as uuid from 'uuid';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* RefreshHandlerOptions contains options for RefreshHandler
|
|
21
|
+
* @public
|
|
22
|
+
* @interface RefreshHandlerOptions
|
|
23
|
+
*/
|
|
24
|
+
export interface RefreshHandlerOptions {
|
|
25
|
+
packageManager: IPackageManager;
|
|
26
|
+
credentialWallet?: ICredentialWallet;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
* RefreshOptions contains options for refreshCredential call
|
|
32
|
+
*
|
|
33
|
+
* @public
|
|
34
|
+
* @interface RefreshOptions
|
|
35
|
+
*/
|
|
36
|
+
export interface RefreshOptions {
|
|
37
|
+
reason?: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Interface to work with credential refresh handler
|
|
42
|
+
*
|
|
43
|
+
* @public
|
|
44
|
+
* @interface IRefreshHandler
|
|
45
|
+
*/
|
|
46
|
+
export interface IRefreshHandler {
|
|
47
|
+
/**
|
|
48
|
+
* refresh credential
|
|
49
|
+
*
|
|
50
|
+
* @param {W3CCredential} credential - credential to refresh
|
|
51
|
+
* @param {RefreshOptions} opts - options
|
|
52
|
+
* @returns {Promise<W3CCredential>}
|
|
53
|
+
*/
|
|
54
|
+
refreshCredential(credential: W3CCredential, opts?: RefreshOptions): Promise<W3CCredential>;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
*
|
|
58
|
+
* Allows to refresh credential from refresh service and return refreshed credential
|
|
59
|
+
*
|
|
60
|
+
* @public
|
|
61
|
+
|
|
62
|
+
* @class RefreshHandler
|
|
63
|
+
* @implements implements RefreshHandler interface
|
|
64
|
+
*/
|
|
65
|
+
export class RefreshHandler implements IRefreshHandler {
|
|
66
|
+
/**
|
|
67
|
+
* Creates an instance of RefreshHandler.
|
|
68
|
+
* @param {RefreshHandlerOptions} _options - refresh handler options
|
|
69
|
+
*/
|
|
70
|
+
constructor(private readonly _options: RefreshHandlerOptions) {}
|
|
71
|
+
|
|
72
|
+
async refreshCredential(
|
|
73
|
+
credential: W3CCredential,
|
|
74
|
+
opts?: RefreshOptions
|
|
75
|
+
): Promise<W3CCredential> {
|
|
76
|
+
if (!credential.refreshService) {
|
|
77
|
+
throw new Error('refreshService not specified for W3CCredential');
|
|
78
|
+
}
|
|
79
|
+
if (credential.refreshService.type !== RefreshServiceType.Iden3RefreshService2023) {
|
|
80
|
+
throw new Error(`refresh service type ${credential.refreshService.type} is not supported`);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const otherIdentifier = credential.credentialSubject.id as string;
|
|
84
|
+
|
|
85
|
+
if (!otherIdentifier) {
|
|
86
|
+
throw new Error('self credentials do not support refresh');
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const senderDID = DID.parse(otherIdentifier);
|
|
90
|
+
|
|
91
|
+
const zkpParams: ZKPPackerParams = {
|
|
92
|
+
senderDID,
|
|
93
|
+
provingMethodAlg: new ProvingMethodAlg(
|
|
94
|
+
proving.provingMethodGroth16AuthV2Instance.methodAlg.alg,
|
|
95
|
+
CircuitId.AuthV2
|
|
96
|
+
)
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const refreshMsg: CredentialRefreshMessage = {
|
|
100
|
+
id: uuid.v4(),
|
|
101
|
+
typ: MediaType.ZKPMessage,
|
|
102
|
+
type: PROTOCOL_MESSAGE_TYPE.CREDENTIAL_REFRESH_MESSAGE_TYPE,
|
|
103
|
+
thid: uuid.v4(),
|
|
104
|
+
body: {
|
|
105
|
+
id: credential.id,
|
|
106
|
+
reason: opts?.reason ?? 'credential is expired'
|
|
107
|
+
},
|
|
108
|
+
from: otherIdentifier,
|
|
109
|
+
to: credential.issuer
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const msgBytes = byteEncoder.encode(JSON.stringify(refreshMsg));
|
|
113
|
+
const jwzToken = await this._options.packageManager.pack(
|
|
114
|
+
MediaType.ZKPMessage,
|
|
115
|
+
msgBytes,
|
|
116
|
+
zkpParams
|
|
117
|
+
);
|
|
118
|
+
const resp = await fetch(credential.refreshService.id, {
|
|
119
|
+
method: 'post',
|
|
120
|
+
headers: {
|
|
121
|
+
'Content-Type': 'application/json'
|
|
122
|
+
},
|
|
123
|
+
body: jwzToken
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
if (resp.status !== 200) {
|
|
127
|
+
throw new Error(`could not refresh W3C credential, return status ${resp.status}`);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const respBody: CredentialIssuanceMessage = await resp.json();
|
|
131
|
+
|
|
132
|
+
if (!respBody.body?.credential) {
|
|
133
|
+
throw new Error('no credential in CredentialIssuanceMessage response');
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return W3CCredential.fromJSON(respBody.body.credential);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { PROTOCOL_MESSAGE_TYPE } from '../constants';
|
|
2
|
+
import { MediaType } from '../constants';
|
|
3
|
+
import {
|
|
4
|
+
BasicMessage,
|
|
5
|
+
IPackageManager,
|
|
6
|
+
JWSPackerParams,
|
|
7
|
+
RevocationStatusRequestMessage,
|
|
8
|
+
RevocationStatusResponseMessage
|
|
9
|
+
} from '../types';
|
|
10
|
+
|
|
11
|
+
import { DID } from '@mocanetwork/moca-iden3';
|
|
12
|
+
import * as uuid from 'uuid';
|
|
13
|
+
import { RevocationStatus } from '../../verifiable';
|
|
14
|
+
import { TreeState } from '../../circuits';
|
|
15
|
+
import { byteEncoder } from '../../utils';
|
|
16
|
+
import { proving } from '@iden3/js-jwz';
|
|
17
|
+
import { IIdentityWallet } from '../../identity';
|
|
18
|
+
import {
|
|
19
|
+
AbstractMessageHandler,
|
|
20
|
+
BasicHandlerOptions,
|
|
21
|
+
IProtocolMessageHandler
|
|
22
|
+
} from './message-handler';
|
|
23
|
+
import { verifyExpiresTime } from './common';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Defines the options for a RevocationStatusMessageHandler.
|
|
27
|
+
* @property senderDid - The DID (Decentralized Identifier) to be used.
|
|
28
|
+
* @property mediaType - The media type to be used.
|
|
29
|
+
* @property packerOptions - Optional parameters for the JWS packer.
|
|
30
|
+
* @property treeState - Optional tree state to be used.
|
|
31
|
+
*/
|
|
32
|
+
export type RevocationStatusMessageHandlerOptions = {
|
|
33
|
+
senderDid: DID;
|
|
34
|
+
mediaType: MediaType;
|
|
35
|
+
packerOptions?: JWSPackerParams;
|
|
36
|
+
treeState?: TreeState;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Interface that allows the processing of the revocation status
|
|
41
|
+
*
|
|
42
|
+
* @interface IRevocationStatusHandler
|
|
43
|
+
*/
|
|
44
|
+
export interface IRevocationStatusHandler {
|
|
45
|
+
/**
|
|
46
|
+
* unpacks revocation status request
|
|
47
|
+
* @param {Uint8Array} request - raw byte message
|
|
48
|
+
* @returns `Promise<RevocationStatusRequestMessage>`
|
|
49
|
+
*/
|
|
50
|
+
parseRevocationStatusRequest(request: Uint8Array): Promise<RevocationStatusRequestMessage>;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* handle revocation status request
|
|
54
|
+
* @param {did} did - sender DID
|
|
55
|
+
* @param {Uint8Array} request - raw byte message
|
|
56
|
+
* @param {RevocationStatusHandlerOptions} opts - handler options
|
|
57
|
+
* @returns {Promise<Uint8Array>}` - revocation status response message
|
|
58
|
+
*/
|
|
59
|
+
handleRevocationStatusRequest(
|
|
60
|
+
did: DID,
|
|
61
|
+
request: Uint8Array,
|
|
62
|
+
opts?: RevocationStatusHandlerOptions
|
|
63
|
+
): Promise<Uint8Array>;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** RevocationStatusHandlerOptions represents revocation status handler options */
|
|
67
|
+
export type RevocationStatusHandlerOptions = BasicHandlerOptions & {
|
|
68
|
+
mediaType: MediaType;
|
|
69
|
+
packerOptions?: JWSPackerParams;
|
|
70
|
+
treeState?: TreeState;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
*
|
|
75
|
+
* Allows to process RevocationStatusRequest protocol message
|
|
76
|
+
*
|
|
77
|
+
|
|
78
|
+
* @class RevocationStatusHandler
|
|
79
|
+
* @implements implements IRevocationStatusHandler interface
|
|
80
|
+
*/
|
|
81
|
+
export class RevocationStatusHandler
|
|
82
|
+
extends AbstractMessageHandler
|
|
83
|
+
implements IRevocationStatusHandler, IProtocolMessageHandler
|
|
84
|
+
{
|
|
85
|
+
/**
|
|
86
|
+
* Creates an instance of RevocationStatusHandler.
|
|
87
|
+
* @param {IPackageManager} _packerMgr - package manager to unpack message envelope
|
|
88
|
+
* @param {IIdentityWallet} _identityWallet - identity wallet
|
|
89
|
+
*
|
|
90
|
+
*/
|
|
91
|
+
constructor(
|
|
92
|
+
private readonly _packerMgr: IPackageManager,
|
|
93
|
+
private readonly _identityWallet: IIdentityWallet
|
|
94
|
+
) {
|
|
95
|
+
super();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
public handle(
|
|
99
|
+
message: BasicMessage,
|
|
100
|
+
context: RevocationStatusMessageHandlerOptions
|
|
101
|
+
): Promise<BasicMessage | null> {
|
|
102
|
+
if (!context.senderDid) {
|
|
103
|
+
throw new Error('DID is required');
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (!context.mediaType) {
|
|
107
|
+
throw new Error('mediaType is required');
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
switch (message.type) {
|
|
111
|
+
case PROTOCOL_MESSAGE_TYPE.REVOCATION_STATUS_REQUEST_MESSAGE_TYPE:
|
|
112
|
+
return this.handleRevocationStatusRequestMessage(
|
|
113
|
+
message as RevocationStatusRequestMessage,
|
|
114
|
+
context
|
|
115
|
+
);
|
|
116
|
+
default:
|
|
117
|
+
return super.handle(message, context);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
private async handleRevocationStatusRequestMessage(
|
|
122
|
+
rsRequest: RevocationStatusRequestMessage,
|
|
123
|
+
context: RevocationStatusMessageHandlerOptions
|
|
124
|
+
): Promise<BasicMessage | null> {
|
|
125
|
+
if (!rsRequest.to) {
|
|
126
|
+
throw new Error(`failed request. empty 'to' field`);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (!rsRequest.from) {
|
|
130
|
+
throw new Error(`failed request. empty 'from' field`);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (!rsRequest.body?.revocation_nonce) {
|
|
134
|
+
throw new Error(`failed request. empty 'revocation_nonce' field`);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const issuerDID = DID.parse(rsRequest.to);
|
|
138
|
+
|
|
139
|
+
const mtpWithTreeState = await this._identityWallet.generateNonRevocationMtpWithNonce(
|
|
140
|
+
issuerDID,
|
|
141
|
+
BigInt(rsRequest.body.revocation_nonce),
|
|
142
|
+
context.treeState
|
|
143
|
+
);
|
|
144
|
+
const treeState = mtpWithTreeState.treeState;
|
|
145
|
+
const revStatus: RevocationStatus = {
|
|
146
|
+
issuer: {
|
|
147
|
+
state: treeState?.state.string(),
|
|
148
|
+
claimsTreeRoot: treeState.claimsRoot.string(),
|
|
149
|
+
revocationTreeRoot: treeState.revocationRoot.string(),
|
|
150
|
+
rootOfRoots: treeState.rootOfRoots.string()
|
|
151
|
+
},
|
|
152
|
+
mtp: mtpWithTreeState.proof
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
const guid = uuid.v4();
|
|
156
|
+
|
|
157
|
+
const response: RevocationStatusResponseMessage = {
|
|
158
|
+
id: guid,
|
|
159
|
+
typ: MediaType.PlainMessage,
|
|
160
|
+
type: PROTOCOL_MESSAGE_TYPE.REVOCATION_STATUS_RESPONSE_MESSAGE_TYPE,
|
|
161
|
+
thid: rsRequest.thid ?? guid,
|
|
162
|
+
body: revStatus,
|
|
163
|
+
from: context.senderDid.string(),
|
|
164
|
+
to: rsRequest.from
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
return response as BasicMessage;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* @inheritdoc IRevocationStatusHandler#parseRevocationStatusRequest
|
|
172
|
+
*/
|
|
173
|
+
async parseRevocationStatusRequest(request: Uint8Array): Promise<RevocationStatusRequestMessage> {
|
|
174
|
+
const { unpackedMessage: message } = await this._packerMgr.unpack(request);
|
|
175
|
+
const ciRequest = message as unknown as RevocationStatusRequestMessage;
|
|
176
|
+
if (message.type !== PROTOCOL_MESSAGE_TYPE.REVOCATION_STATUS_REQUEST_MESSAGE_TYPE) {
|
|
177
|
+
throw new Error('Invalid media type');
|
|
178
|
+
}
|
|
179
|
+
return ciRequest;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* @inheritdoc IRevocationStatusHandler#handleRevocationStatusRequest
|
|
184
|
+
*/
|
|
185
|
+
async handleRevocationStatusRequest(
|
|
186
|
+
did: DID,
|
|
187
|
+
request: Uint8Array,
|
|
188
|
+
opts?: RevocationStatusHandlerOptions
|
|
189
|
+
): Promise<Uint8Array> {
|
|
190
|
+
if (!opts) {
|
|
191
|
+
opts = {
|
|
192
|
+
mediaType: MediaType.PlainMessage
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (opts.mediaType === MediaType.SignedMessage && !opts.packerOptions) {
|
|
197
|
+
throw new Error(`jws packer options are required for ${MediaType.SignedMessage}`);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const rsRequest = await this.parseRevocationStatusRequest(request);
|
|
201
|
+
if (!opts.allowExpiredMessages) {
|
|
202
|
+
verifyExpiresTime(rsRequest);
|
|
203
|
+
}
|
|
204
|
+
const response = await this.handleRevocationStatusRequestMessage(rsRequest, {
|
|
205
|
+
senderDid: did,
|
|
206
|
+
mediaType: opts.mediaType,
|
|
207
|
+
packerOptions: opts.packerOptions,
|
|
208
|
+
treeState: opts.treeState
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
const packerOpts =
|
|
212
|
+
opts.mediaType === MediaType.SignedMessage
|
|
213
|
+
? opts.packerOptions
|
|
214
|
+
: {
|
|
215
|
+
provingMethodAlg: proving.provingMethodGroth16AuthV2Instance.methodAlg
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
if (!rsRequest.to) {
|
|
219
|
+
throw new Error(`failed request. empty 'to' field`);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const senderDID = DID.parse(rsRequest.to);
|
|
223
|
+
return this._packerMgr.pack(opts.mediaType, byteEncoder.encode(JSON.stringify(response)), {
|
|
224
|
+
senderDID,
|
|
225
|
+
...packerOpts
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './packageManager';
|
|
2
|
+
export * from './packers';
|
|
3
|
+
export * from './types';
|
|
4
|
+
export * from './handlers';
|
|
5
|
+
export * from './utils/did';
|
|
6
|
+
export * from './utils/accept-profile';
|
|
7
|
+
|
|
8
|
+
import * as PROTOCOL_CONSTANTS from './constants';
|
|
9
|
+
export { PROTOCOL_CONSTANTS };
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { BasicMessage, IPackageManager, IPacker, PackerParams } from './types';
|
|
2
|
+
import { bytesToHeaderStub } from './utils/envelope';
|
|
3
|
+
import { base64 } from 'rfc4648';
|
|
4
|
+
import { MediaType } from './constants';
|
|
5
|
+
import { byteDecoder, byteEncoder } from '../utils';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Basic package manager for iden3 communication protocol
|
|
9
|
+
*
|
|
10
|
+
* @public
|
|
11
|
+
* @class PackageManager
|
|
12
|
+
* @implements implements IPackageManager interface
|
|
13
|
+
*/
|
|
14
|
+
export class PackageManager implements IPackageManager {
|
|
15
|
+
packers: Map<MediaType, IPacker>;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Creates an instance of PackageManager.
|
|
19
|
+
*/
|
|
20
|
+
constructor() {
|
|
21
|
+
this.packers = new Map<MediaType, IPacker>();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** {@inheritDoc IPackageManager.getSupportedProfiles} */
|
|
25
|
+
getSupportedProfiles(): string[] {
|
|
26
|
+
const acceptProfiles: string[] = [];
|
|
27
|
+
const mediaTypes = this.getSupportedMediaTypes();
|
|
28
|
+
for (const mediaType of mediaTypes) {
|
|
29
|
+
const p = this.packers.get(mediaType);
|
|
30
|
+
if (p) {
|
|
31
|
+
acceptProfiles.push(...p.getSupportedProfiles());
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return [...new Set(acceptProfiles)];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** {@inheritDoc IPackageManager.isProfileSupported} */
|
|
38
|
+
isProfileSupported(mediaType: MediaType, profile: string): boolean {
|
|
39
|
+
const p = this.packers.get(mediaType);
|
|
40
|
+
if (!p) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return p.isProfileSupported(profile);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** {@inheritDoc IPackageManager.getSupportedMediaTypes} */
|
|
48
|
+
getSupportedMediaTypes(): MediaType[] {
|
|
49
|
+
return [...this.packers.keys()];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** {@inheritDoc IPackageManager.registerPackers} */
|
|
53
|
+
registerPackers(packers: Array<IPacker>): void {
|
|
54
|
+
packers.forEach((p) => {
|
|
55
|
+
this.packers.set(p.mediaType(), p);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** {@inheritDoc IPackageManager.pack} */
|
|
60
|
+
async pack(mediaType: MediaType, payload: Uint8Array, params: PackerParams): Promise<Uint8Array> {
|
|
61
|
+
const p = this.packers.get(mediaType);
|
|
62
|
+
if (!p) {
|
|
63
|
+
throw new Error(`packer for media type ${mediaType} not found`);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return await p.pack(payload, params);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Packs a protocol message using the specified media type and packer parameters.
|
|
71
|
+
*
|
|
72
|
+
* @param mediaType - The media type to use for packing the message.
|
|
73
|
+
* @param protocolMessage - The protocol message to pack.
|
|
74
|
+
* @param params - The packer parameters.
|
|
75
|
+
* @returns A promise that resolves to the packed message as a Uint8Array.
|
|
76
|
+
* @throws An error if the packer for the specified media type is not found.
|
|
77
|
+
*/
|
|
78
|
+
packMessage(
|
|
79
|
+
mediaType: MediaType,
|
|
80
|
+
protocolMessage: BasicMessage,
|
|
81
|
+
params: PackerParams
|
|
82
|
+
): Promise<Uint8Array> {
|
|
83
|
+
const p = this.packers.get(mediaType);
|
|
84
|
+
if (!p) {
|
|
85
|
+
throw new Error(`packer for media type ${mediaType} not found`);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return p.packMessage(protocolMessage, params);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** {@inheritDoc IPackageManager.unpack} */
|
|
92
|
+
async unpack(
|
|
93
|
+
envelope: Uint8Array
|
|
94
|
+
): Promise<{ unpackedMessage: BasicMessage; unpackedMediaType: MediaType }> {
|
|
95
|
+
const decodedStr = byteDecoder.decode(envelope);
|
|
96
|
+
const safeEnvelope = decodedStr.trim();
|
|
97
|
+
const mediaType = this.getMediaType(safeEnvelope);
|
|
98
|
+
return {
|
|
99
|
+
unpackedMessage: await this.unpackWithSafeEnvelope(
|
|
100
|
+
mediaType,
|
|
101
|
+
byteEncoder.encode(safeEnvelope)
|
|
102
|
+
),
|
|
103
|
+
unpackedMediaType: mediaType
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** {@inheritDoc IPackageManager.unpackWithType} */
|
|
108
|
+
async unpackWithType(mediaType: MediaType, envelope: Uint8Array): Promise<BasicMessage> {
|
|
109
|
+
const decoder = new TextDecoder('utf-8');
|
|
110
|
+
const decodedStr = decoder.decode(envelope);
|
|
111
|
+
const safeEnvelope = decodedStr.trim();
|
|
112
|
+
return await this.unpackWithSafeEnvelope(mediaType, byteEncoder.encode(safeEnvelope));
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
private async unpackWithSafeEnvelope(
|
|
116
|
+
mediaType: MediaType,
|
|
117
|
+
envelope: Uint8Array
|
|
118
|
+
): Promise<BasicMessage> {
|
|
119
|
+
const p = this.packers.get(mediaType);
|
|
120
|
+
if (!p) {
|
|
121
|
+
throw new Error(`packer for media type ${mediaType} not found`);
|
|
122
|
+
}
|
|
123
|
+
const msg = await p.unpack(envelope);
|
|
124
|
+
return msg;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** {@inheritDoc IPackageManager.getMediaType} */
|
|
128
|
+
getMediaType(envelope: string): MediaType {
|
|
129
|
+
let base64HeaderBytes: Uint8Array;
|
|
130
|
+
|
|
131
|
+
// full serialized
|
|
132
|
+
if (envelope[0] === '{') {
|
|
133
|
+
const envelopeStub = JSON.parse(envelope);
|
|
134
|
+
return envelopeStub.typ as MediaType;
|
|
135
|
+
} else {
|
|
136
|
+
const header = envelope.split('.')[0];
|
|
137
|
+
base64HeaderBytes = base64.parse(header, { loose: true });
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const header = bytesToHeaderStub(base64HeaderBytes);
|
|
141
|
+
return header.typ;
|
|
142
|
+
}
|
|
143
|
+
}
|