@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,225 @@
|
|
|
1
|
+
import { BasicMessage, IPacker, JWSPackerParams } from '../types';
|
|
2
|
+
import {
|
|
3
|
+
AcceptJwsAlgorithms,
|
|
4
|
+
MediaType,
|
|
5
|
+
ProtocolVersion,
|
|
6
|
+
SUPPORTED_PUBLIC_KEY_TYPES
|
|
7
|
+
} from '../constants';
|
|
8
|
+
import { extractPublicKeyBytes, resolveVerificationMethods } from '../utils/did';
|
|
9
|
+
import { keyPath, KMS } from '../../kms/';
|
|
10
|
+
|
|
11
|
+
import { verifyJWS } from 'did-jwt';
|
|
12
|
+
import { DIDDocument, Resolvable, parse } from 'did-resolver';
|
|
13
|
+
import { bytesToBase64url } from '../../utils/encoding';
|
|
14
|
+
import {
|
|
15
|
+
byteDecoder,
|
|
16
|
+
byteEncoder,
|
|
17
|
+
bytesToHex,
|
|
18
|
+
decodeBase64url,
|
|
19
|
+
encodeBase64url
|
|
20
|
+
} from '../../utils';
|
|
21
|
+
import { parseAcceptProfile } from '../utils';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Packer that can pack message to JWZ token,
|
|
25
|
+
* and unpack and validate JWZ envelope
|
|
26
|
+
* @public
|
|
27
|
+
* @class ZKPPacker
|
|
28
|
+
* @implements implements IPacker interface
|
|
29
|
+
*/
|
|
30
|
+
export class JWSPacker implements IPacker {
|
|
31
|
+
private readonly supportedAlgorithms = [AcceptJwsAlgorithms.ES256K, AcceptJwsAlgorithms.ES256KR];
|
|
32
|
+
private readonly supportedProtocolVersions = [ProtocolVersion.V1];
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Creates an instance of JWSPacker.
|
|
36
|
+
*
|
|
37
|
+
* @param {KMS} _kms
|
|
38
|
+
* @param {Resolvable} _documentResolver
|
|
39
|
+
* @memberof JWSPacker
|
|
40
|
+
*/
|
|
41
|
+
constructor(private readonly _kms: KMS, private readonly _documentResolver: Resolvable) {}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Packs the given payload and returns a promise that resolves to the packed data.
|
|
45
|
+
*
|
|
46
|
+
* @param {Uint8Array} payload - The payload to be packed.
|
|
47
|
+
* @param {PackerParams} param - The packing parameters.
|
|
48
|
+
* @returns `Promise<Uint8Array>`
|
|
49
|
+
*/
|
|
50
|
+
packMessage(msg: BasicMessage, param: JWSPackerParams): Promise<Uint8Array> {
|
|
51
|
+
return this.packInternal(msg, param);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* creates JSON Web Signature token
|
|
55
|
+
*
|
|
56
|
+
* @param {Uint8Array} payload - serialized message
|
|
57
|
+
* @param {PackerParams} params - sender id and proving alg are required
|
|
58
|
+
* @returns `Promise<Uint8Array>`
|
|
59
|
+
*/
|
|
60
|
+
async pack(payload: Uint8Array, params: JWSPackerParams): Promise<Uint8Array> {
|
|
61
|
+
const message = JSON.parse(byteDecoder.decode(payload));
|
|
62
|
+
return this.packInternal(message, params);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* validate envelope which is jwz token
|
|
67
|
+
*
|
|
68
|
+
* @param {Uint8Array} envelope
|
|
69
|
+
* @returns `Promise<BasicMessage>`
|
|
70
|
+
*/
|
|
71
|
+
async unpack(envelope: Uint8Array): Promise<BasicMessage> {
|
|
72
|
+
const jws = byteDecoder.decode(envelope);
|
|
73
|
+
|
|
74
|
+
const [headerStr, msgStr] = jws.split('.');
|
|
75
|
+
|
|
76
|
+
const header = JSON.parse(decodeBase64url(headerStr));
|
|
77
|
+
const message = JSON.parse(decodeBase64url(msgStr));
|
|
78
|
+
const explicitSender = parse(header.kid)?.did;
|
|
79
|
+
if (explicitSender && explicitSender !== message.from) {
|
|
80
|
+
throw new Error(`Sender does not match DID in message with kid ${header?.kid}`);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const didDocument: DIDDocument = await this.resolveDidDoc(message.from);
|
|
84
|
+
|
|
85
|
+
let vms = resolveVerificationMethods(didDocument);
|
|
86
|
+
|
|
87
|
+
if (!vms?.length) {
|
|
88
|
+
throw new Error(`No verification methods defined in the DID document of ${didDocument.id}`);
|
|
89
|
+
}
|
|
90
|
+
if (header.kid) {
|
|
91
|
+
const vm = vms.find((v) => {
|
|
92
|
+
return v.id === header.kid;
|
|
93
|
+
});
|
|
94
|
+
if (!vm) {
|
|
95
|
+
throw new Error(
|
|
96
|
+
`verification method with specified kid ${header.kid} is not found in the DID Document`
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
vms = [vm];
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const verificationResponse = verifyJWS(jws, vms);
|
|
103
|
+
|
|
104
|
+
if (!verificationResponse) {
|
|
105
|
+
throw new Error('JWS verification failed');
|
|
106
|
+
}
|
|
107
|
+
return message as BasicMessage;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
mediaType(): MediaType {
|
|
111
|
+
return MediaType.SignedMessage;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** {@inheritDoc IPacker.getSupportedProfiles} */
|
|
115
|
+
getSupportedProfiles(): string[] {
|
|
116
|
+
return this.supportedProtocolVersions.map(
|
|
117
|
+
(v) => `${v};env=${this.mediaType()};alg=${this.supportedAlgorithms.join(',')}`
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** {@inheritDoc IPacker.isProfileSupported} */
|
|
122
|
+
isProfileSupported(profile: string) {
|
|
123
|
+
const { protocolVersion, env, circuits, alg } = parseAcceptProfile(profile);
|
|
124
|
+
|
|
125
|
+
if (!this.supportedProtocolVersions.includes(protocolVersion)) {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
if (env !== this.mediaType()) {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (circuits) {
|
|
133
|
+
throw new Error(`Circuits are not supported for ${env} media type`);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const algSupported =
|
|
137
|
+
!alg?.length || alg.some((a) => this.supportedAlgorithms.includes(a as AcceptJwsAlgorithms));
|
|
138
|
+
return algSupported;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
private async resolveDidDoc(from: string) {
|
|
142
|
+
let didDocument: DIDDocument;
|
|
143
|
+
try {
|
|
144
|
+
const didResolutionResult = await this._documentResolver.resolve(from);
|
|
145
|
+
if (!didResolutionResult?.didDocument?.id) {
|
|
146
|
+
throw new Error(`did document for ${from} is not found in resolution result`);
|
|
147
|
+
}
|
|
148
|
+
didDocument = didResolutionResult.didDocument;
|
|
149
|
+
} catch (err: unknown) {
|
|
150
|
+
throw new Error(`did document for ${from} is not resolved: ${(err as Error).message}`);
|
|
151
|
+
}
|
|
152
|
+
return didDocument;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
private async packInternal(message: BasicMessage, params: JWSPackerParams): Promise<Uint8Array> {
|
|
156
|
+
if (!params.alg) {
|
|
157
|
+
throw new Error('Missing algorithm');
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const from = message.from ?? '';
|
|
161
|
+
if (!from) {
|
|
162
|
+
throw new Error('Missing sender DID');
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const vmTypes: string[] =
|
|
166
|
+
SUPPORTED_PUBLIC_KEY_TYPES[params.alg as keyof typeof SUPPORTED_PUBLIC_KEY_TYPES];
|
|
167
|
+
if (!vmTypes?.length) {
|
|
168
|
+
throw new Error(`No supported verification methods for algorithm ${params.alg}`);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const didDocument: DIDDocument = params.didDocument ?? (await this.resolveDidDoc(from));
|
|
172
|
+
|
|
173
|
+
const vms = resolveVerificationMethods(didDocument);
|
|
174
|
+
|
|
175
|
+
if (!vms.length) {
|
|
176
|
+
throw new Error(`No verification methods defined in the DID document of ${didDocument.id}`);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// try to find a managed signing key that matches keyRef
|
|
180
|
+
const vm = params.kid ? vms.find((vm) => vm.id === params.kid) : vms[0];
|
|
181
|
+
|
|
182
|
+
if (!vm) {
|
|
183
|
+
throw new Error(`No key found with id ${params.kid} in DID document of ${didDocument.id}`);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const { publicKeyBytes, kmsKeyType } = extractPublicKeyBytes(vm);
|
|
187
|
+
|
|
188
|
+
if (!publicKeyBytes && !kmsKeyType) {
|
|
189
|
+
if ((vm.blockchainAccountId || vm.ethereumAddress) && !params.signer) {
|
|
190
|
+
throw new Error(`No signer provided for ${vm.blockchainAccountId || vm.ethereumAddress}`);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const kid = vm.id;
|
|
195
|
+
|
|
196
|
+
const headerObj = { alg: params.alg, kid, typ: MediaType.SignedMessage };
|
|
197
|
+
const header = encodeBase64url(JSON.stringify(headerObj));
|
|
198
|
+
const msg = encodeBase64url(JSON.stringify(message));
|
|
199
|
+
const signingInput = `${header}.${msg}`;
|
|
200
|
+
const signingInputBytes = byteEncoder.encode(signingInput);
|
|
201
|
+
let signatureBase64: string;
|
|
202
|
+
if (params.signer) {
|
|
203
|
+
const signature = await params.signer(vm, signingInputBytes);
|
|
204
|
+
signatureBase64 = bytesToBase64url(signature);
|
|
205
|
+
} else {
|
|
206
|
+
if (!publicKeyBytes) {
|
|
207
|
+
throw new Error('No public key found');
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (!kmsKeyType) {
|
|
211
|
+
throw new Error('No KMS key type found');
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const signatureBytes = await this._kms.sign(
|
|
215
|
+
{ type: kmsKeyType, id: keyPath(kmsKeyType, bytesToHex(publicKeyBytes)) },
|
|
216
|
+
signingInputBytes,
|
|
217
|
+
{ alg: params.alg }
|
|
218
|
+
);
|
|
219
|
+
|
|
220
|
+
signatureBase64 = bytesToBase64url(signatureBytes);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
return byteEncoder.encode(`${signingInput}.${signatureBase64}`);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { BasicMessage, IPacker } from '../types';
|
|
2
|
+
import { MediaType, ProtocolVersion } from '../constants';
|
|
3
|
+
import { byteDecoder, byteEncoder } from '../../utils';
|
|
4
|
+
import { parseAcceptProfile } from '../utils';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Plain packer just serializes bytes to JSON and adds media type
|
|
8
|
+
*
|
|
9
|
+
* @public
|
|
10
|
+
* @class PlainPacker
|
|
11
|
+
* @implements implements IPacker interface
|
|
12
|
+
*/
|
|
13
|
+
export class PlainPacker implements IPacker {
|
|
14
|
+
private readonly supportedProtocolVersions = [ProtocolVersion.V1];
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Packs a basic message using the specified parameters.
|
|
18
|
+
*
|
|
19
|
+
* @param msg - The basic message to pack.
|
|
20
|
+
* @param param - The packer parameters.
|
|
21
|
+
* @returns A promise that resolves to a Uint8Array representing the packed message.
|
|
22
|
+
* @throws An error if the method is not implemented.
|
|
23
|
+
*/
|
|
24
|
+
packMessage(msg: BasicMessage): Promise<Uint8Array> {
|
|
25
|
+
msg.typ = MediaType.PlainMessage;
|
|
26
|
+
return Promise.resolve(byteEncoder.encode(JSON.stringify(msg)));
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Pack returns packed message to transport envelope
|
|
30
|
+
*
|
|
31
|
+
* @param {Uint8Array} payload - json message serialized
|
|
32
|
+
* @param {PlainPackerParams} _params - not used here
|
|
33
|
+
* @returns `Promise<Uint8Array>`
|
|
34
|
+
*/
|
|
35
|
+
async pack(payload: Uint8Array): Promise<Uint8Array> {
|
|
36
|
+
const msg = JSON.parse(byteDecoder.decode(payload));
|
|
37
|
+
msg.typ = MediaType.PlainMessage;
|
|
38
|
+
return Promise.resolve(byteEncoder.encode(JSON.stringify(msg)));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Unpack returns unpacked message from transport envelope
|
|
43
|
+
*
|
|
44
|
+
* @param {Uint8Array} envelope - packed envelope (serialized json with media type)
|
|
45
|
+
* @returns `Promise<BasicMessage>`
|
|
46
|
+
*/
|
|
47
|
+
async unpack(envelope: Uint8Array): Promise<BasicMessage> {
|
|
48
|
+
return JSON.parse(byteDecoder.decode(envelope));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* returns media type for plain message
|
|
53
|
+
*
|
|
54
|
+
* @returns MediaType
|
|
55
|
+
*/
|
|
56
|
+
mediaType(): MediaType {
|
|
57
|
+
return MediaType.PlainMessage;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** {@inheritDoc IPacker.getSupportedProfiles} */
|
|
61
|
+
getSupportedProfiles(): string[] {
|
|
62
|
+
return this.supportedProtocolVersions.map((v) => `${v};env=${this.mediaType()}`);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** {@inheritDoc IPacker.isProfileSupported} */
|
|
66
|
+
isProfileSupported(profile: string) {
|
|
67
|
+
const { protocolVersion, env, circuits, alg } = parseAcceptProfile(profile);
|
|
68
|
+
|
|
69
|
+
if (!this.supportedProtocolVersions.includes(protocolVersion)) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
if (env !== this.mediaType()) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (circuits) {
|
|
77
|
+
throw new Error(`Circuits are not supported for ${env} media type`);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (alg) {
|
|
81
|
+
throw new Error(`Algorithms are not supported for ${env} media type`);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import {
|
|
2
|
+
StateVerificationOpts,
|
|
3
|
+
AuthDataPrepareFunc,
|
|
4
|
+
BasicMessage,
|
|
5
|
+
IPacker,
|
|
6
|
+
ProvingParams,
|
|
7
|
+
StateVerificationFunc,
|
|
8
|
+
VerificationParams,
|
|
9
|
+
ZKPPackerParams
|
|
10
|
+
} from '../types';
|
|
11
|
+
import { Token, Header, ProvingMethodAlg, proving } from '@iden3/js-jwz';
|
|
12
|
+
import { AuthV2PubSignals, CircuitId } from '../../circuits/index';
|
|
13
|
+
import { BytesHelper, DID } from '@mocanetwork/moca-iden3';
|
|
14
|
+
import { bytesToProtocolMessage } from '../utils/envelope';
|
|
15
|
+
import {
|
|
16
|
+
ErrNoProvingMethodAlg,
|
|
17
|
+
ErrPackedWithUnsupportedCircuit,
|
|
18
|
+
ErrProofIsInvalid,
|
|
19
|
+
ErrSenderNotUsedTokenCreation,
|
|
20
|
+
ErrStateVerificationFailed,
|
|
21
|
+
ErrUnknownCircuitID
|
|
22
|
+
} from '../errors';
|
|
23
|
+
import { AcceptAuthCircuits, AcceptJwzAlgorithms, MediaType, ProtocolVersion } from '../constants';
|
|
24
|
+
import { byteDecoder, byteEncoder } from '../../utils';
|
|
25
|
+
import { DEFAULT_AUTH_VERIFY_DELAY } from '../constants';
|
|
26
|
+
import { parseAcceptProfile } from '../utils';
|
|
27
|
+
|
|
28
|
+
const { getProvingMethod } = proving;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Handler to
|
|
32
|
+
*
|
|
33
|
+
* @public
|
|
34
|
+
* @class DataPrepareHandlerFunc
|
|
35
|
+
*/
|
|
36
|
+
export class DataPrepareHandlerFunc {
|
|
37
|
+
/**
|
|
38
|
+
* Creates an instance of DataPrepareHandlerFunc.
|
|
39
|
+
* @param {AuthDataPrepareFunc} dataPrepareFunc - function that produces marshaled inputs for auth circuits
|
|
40
|
+
*/
|
|
41
|
+
constructor(public readonly dataPrepareFunc: AuthDataPrepareFunc) {}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
*
|
|
45
|
+
*
|
|
46
|
+
* @param {Uint8Array} hash - challenge that will be signed
|
|
47
|
+
* @param {DID} did - did of identity that will prepare inputs
|
|
48
|
+
* @param {CircuitId} circuitId - circuit id
|
|
49
|
+
* @returns `Promise<Uint8Array>`
|
|
50
|
+
*/
|
|
51
|
+
prepare(hash: Uint8Array, did: DID, circuitId: CircuitId): Promise<Uint8Array> {
|
|
52
|
+
return this.dataPrepareFunc(hash, did, circuitId);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Handler to verify public signals of authorization circuits
|
|
58
|
+
*
|
|
59
|
+
* @public
|
|
60
|
+
* @class VerificationHandlerFunc
|
|
61
|
+
*/
|
|
62
|
+
export class VerificationHandlerFunc {
|
|
63
|
+
/**
|
|
64
|
+
* Creates an instance of VerificationHandlerFunc.
|
|
65
|
+
* @param {StateVerificationFunc} stateVerificationFunc - state verification function
|
|
66
|
+
*/
|
|
67
|
+
constructor(public readonly stateVerificationFunc: StateVerificationFunc) {}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
*
|
|
71
|
+
*
|
|
72
|
+
* @param {string} id - id of circuit
|
|
73
|
+
* @param {Array<string>} pubSignals - signals that must contain user id and state
|
|
74
|
+
* @returns `Promise<boolean>`
|
|
75
|
+
*/
|
|
76
|
+
verify(id: string, pubSignals: Array<string>, opts?: StateVerificationOpts): Promise<boolean> {
|
|
77
|
+
return this.stateVerificationFunc(id, pubSignals, opts);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Packer that can pack message to JWZ token,
|
|
83
|
+
* and unpack and validate JWZ envelope
|
|
84
|
+
* @public
|
|
85
|
+
* @class ZKPPacker
|
|
86
|
+
* @implements implements IPacker interface
|
|
87
|
+
*/
|
|
88
|
+
export class ZKPPacker implements IPacker {
|
|
89
|
+
private readonly supportedProtocolVersions = [ProtocolVersion.V1];
|
|
90
|
+
private readonly supportedAlgorithms = [AcceptJwzAlgorithms.Groth16];
|
|
91
|
+
private readonly supportedCircuitIds = [AcceptAuthCircuits.AuthV2];
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Creates an instance of ZKPPacker.
|
|
95
|
+
* @param {Map<string, ProvingParams>} provingParamsMap - string is derived by JSON.parse(ProvingMethodAlg)
|
|
96
|
+
* @param {Map<string, VerificationParams>} verificationParamsMap - string is derived by JSON.parse(ProvingMethodAlg)
|
|
97
|
+
*/
|
|
98
|
+
constructor(
|
|
99
|
+
public readonly provingParamsMap: Map<string, ProvingParams>,
|
|
100
|
+
public readonly verificationParamsMap: Map<string, VerificationParams>,
|
|
101
|
+
private readonly _opts: StateVerificationOpts = {
|
|
102
|
+
acceptedStateTransitionDelay: DEFAULT_AUTH_VERIFY_DELAY
|
|
103
|
+
}
|
|
104
|
+
) {}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Packs a basic message using the specified parameters.
|
|
108
|
+
* @param msg - The basic message to pack.
|
|
109
|
+
* @param param - The parameters for the ZKPPacker.
|
|
110
|
+
* @returns A promise that resolves to a Uint8Array representing the packed message.
|
|
111
|
+
*/
|
|
112
|
+
packMessage(msg: BasicMessage, param: ZKPPackerParams): Promise<Uint8Array> {
|
|
113
|
+
return this.pack(byteEncoder.encode(JSON.stringify(msg)), param as ZKPPackerParams);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* creates JSON Web Zeroknowledge token
|
|
118
|
+
*
|
|
119
|
+
* @param {Uint8Array} payload - serialized message
|
|
120
|
+
* @param {ZKPPackerParams} params - sender id and proving alg are required
|
|
121
|
+
* @returns `Promise<Uint8Array>`
|
|
122
|
+
*/
|
|
123
|
+
async pack(payload: Uint8Array, params: ZKPPackerParams): Promise<Uint8Array> {
|
|
124
|
+
const provingMethod = await getProvingMethod(params.provingMethodAlg);
|
|
125
|
+
const provingParams = this.provingParamsMap.get(params.provingMethodAlg.toString());
|
|
126
|
+
|
|
127
|
+
if (!provingParams) {
|
|
128
|
+
throw new Error(ErrNoProvingMethodAlg);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const token = new Token(
|
|
132
|
+
provingMethod,
|
|
133
|
+
byteDecoder.decode(payload),
|
|
134
|
+
(hash: Uint8Array, circuitId: string) => {
|
|
135
|
+
return provingParams?.dataPreparer?.prepare(hash, params.senderDID, circuitId as CircuitId);
|
|
136
|
+
}
|
|
137
|
+
);
|
|
138
|
+
token.setHeader(Header.Type, MediaType.ZKPMessage);
|
|
139
|
+
const tokenStr = await token.prove(provingParams.provingKey, provingParams.wasm);
|
|
140
|
+
return byteEncoder.encode(tokenStr);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* validate envelope which is jwz token
|
|
145
|
+
*
|
|
146
|
+
* @param {Uint8Array} envelope
|
|
147
|
+
* @returns `Promise<BasicMessage>`
|
|
148
|
+
*/
|
|
149
|
+
async unpack(envelope: Uint8Array): Promise<BasicMessage> {
|
|
150
|
+
const token = await Token.parse(byteDecoder.decode(envelope));
|
|
151
|
+
const provingMethodAlg = new ProvingMethodAlg(token.alg, token.circuitId);
|
|
152
|
+
const verificationParams = this.verificationParamsMap.get(provingMethodAlg.toString());
|
|
153
|
+
if (!verificationParams?.key) {
|
|
154
|
+
throw new Error(ErrPackedWithUnsupportedCircuit);
|
|
155
|
+
}
|
|
156
|
+
const isValid = await token.verify(verificationParams?.key);
|
|
157
|
+
if (!isValid) {
|
|
158
|
+
throw new Error(ErrProofIsInvalid);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const verificationResult = await verificationParams?.verificationFn?.verify(
|
|
162
|
+
token.circuitId,
|
|
163
|
+
token.zkProof.pub_signals,
|
|
164
|
+
this._opts
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
if (!verificationResult) {
|
|
168
|
+
throw new Error(ErrStateVerificationFailed);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const message = bytesToProtocolMessage(byteEncoder.encode(token.getPayload()));
|
|
172
|
+
|
|
173
|
+
// should throw if error
|
|
174
|
+
verifySender(token, message);
|
|
175
|
+
|
|
176
|
+
return message;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
mediaType(): MediaType {
|
|
180
|
+
return MediaType.ZKPMessage;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** {@inheritDoc IPacker.getSupportedProfiles} */
|
|
184
|
+
getSupportedProfiles(): string[] {
|
|
185
|
+
return this.supportedProtocolVersions.map(
|
|
186
|
+
(v) =>
|
|
187
|
+
`${v};env=${this.mediaType()};alg=${this.supportedAlgorithms.join(
|
|
188
|
+
','
|
|
189
|
+
)};circuitIds=${this.supportedCircuitIds.join(',')}`
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/** {@inheritDoc IPacker.isProfileSupported} */
|
|
194
|
+
isProfileSupported(profile: string) {
|
|
195
|
+
const { protocolVersion, env, circuits, alg } = parseAcceptProfile(profile);
|
|
196
|
+
|
|
197
|
+
if (!this.supportedProtocolVersions.includes(protocolVersion)) {
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (env !== this.mediaType()) {
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const supportedCircuitIds = this.supportedCircuitIds;
|
|
206
|
+
const circuitIdSupported =
|
|
207
|
+
!circuits?.length || circuits.some((c) => supportedCircuitIds.includes(c));
|
|
208
|
+
|
|
209
|
+
const supportedAlgArr = this.supportedAlgorithms;
|
|
210
|
+
const algSupported =
|
|
211
|
+
!alg?.length || alg.some((a) => supportedAlgArr.includes(a as AcceptJwzAlgorithms));
|
|
212
|
+
return algSupported && circuitIdSupported;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
const verifySender = async (token: Token, msg: BasicMessage): Promise<void> => {
|
|
217
|
+
switch (token.circuitId) {
|
|
218
|
+
case CircuitId.AuthV2:
|
|
219
|
+
{
|
|
220
|
+
if (!msg.from) {
|
|
221
|
+
throw new Error(ErrSenderNotUsedTokenCreation);
|
|
222
|
+
}
|
|
223
|
+
const authSignals = new AuthV2PubSignals().pubSignalsUnmarshal(
|
|
224
|
+
byteEncoder.encode(JSON.stringify(token.zkProof.pub_signals))
|
|
225
|
+
);
|
|
226
|
+
const did = DID.parseFromId(authSignals.userID);
|
|
227
|
+
|
|
228
|
+
const msgHash = await token.getMessageHash();
|
|
229
|
+
const challenge = BytesHelper.bytesToInt(msgHash.reverse());
|
|
230
|
+
|
|
231
|
+
if (challenge !== authSignals.challenge) {
|
|
232
|
+
throw new Error(ErrSenderNotUsedTokenCreation);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
if (msg.from !== did.string()) {
|
|
236
|
+
throw new Error(ErrSenderNotUsedTokenCreation);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
break;
|
|
240
|
+
default:
|
|
241
|
+
throw new Error(ErrUnknownCircuitID);
|
|
242
|
+
}
|
|
243
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export * from './protocol/auth';
|
|
2
|
+
export * from './protocol/credentials';
|
|
3
|
+
export * from './protocol/messages';
|
|
4
|
+
export * from './protocol/proof';
|
|
5
|
+
export * from './protocol/revocation';
|
|
6
|
+
export * from './protocol/contract-request';
|
|
7
|
+
export * from './protocol/proposal-request';
|
|
8
|
+
export * from './protocol/payment';
|
|
9
|
+
export * from './protocol/accept-profile';
|
|
10
|
+
export * from './protocol/discovery-protocol';
|
|
11
|
+
export * from './protocol/problem-report';
|
|
12
|
+
|
|
13
|
+
export * from './protocol/attachment';
|
|
14
|
+
export * from './protocol/common';
|
|
15
|
+
export * from './packer';
|
|
16
|
+
export * from './models';
|
|
17
|
+
export * from './packageManager';
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { BasicMessage, IPacker, PackerParams } from './packer';
|
|
2
|
+
import { MediaType } from '../constants';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Interface for defining the registry of packers
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
* @interface IPackageManager
|
|
9
|
+
*/
|
|
10
|
+
export interface IPackageManager {
|
|
11
|
+
/**
|
|
12
|
+
* Map of packers key is media type, value is packer implementation
|
|
13
|
+
*
|
|
14
|
+
* @type {Map<MediaType, IPacker>}
|
|
15
|
+
*/
|
|
16
|
+
packers: Map<MediaType, IPacker>;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* registers new packer in the manager
|
|
20
|
+
*
|
|
21
|
+
* @param {Array<IPacker>} packers
|
|
22
|
+
*/
|
|
23
|
+
registerPackers(packers: Array<IPacker>): void;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* packs payload with a packer that is assigned to media type
|
|
27
|
+
* forwards packer params to implementation
|
|
28
|
+
*
|
|
29
|
+
* @param {MediaType} mediaType
|
|
30
|
+
* @param {Uint8Array} payload
|
|
31
|
+
* @param {PackerParams} params
|
|
32
|
+
* @returns `Promise<Uint8Array>`
|
|
33
|
+
*/
|
|
34
|
+
pack(mediaType: MediaType, payload: Uint8Array, params: PackerParams): Promise<Uint8Array>;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* packs payload with a packer that is assigned to media type
|
|
38
|
+
* forwards packer params to implementation
|
|
39
|
+
*
|
|
40
|
+
* @param {MediaType} mediaType
|
|
41
|
+
* @param {BasicMessage} protocolMessage
|
|
42
|
+
* @param {PackerParams} params
|
|
43
|
+
* @returns `Promise<Uint8Array>`
|
|
44
|
+
*/
|
|
45
|
+
packMessage(
|
|
46
|
+
mediaType: MediaType,
|
|
47
|
+
protocolMessage: BasicMessage,
|
|
48
|
+
params: PackerParams
|
|
49
|
+
): Promise<Uint8Array>;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* unpacks packed envelope to basic protocol message and returns media type of the envelope
|
|
53
|
+
*
|
|
54
|
+
* @param {Uint8Array} envelope - bytes envelope
|
|
55
|
+
* @returns `Promise<{ unpackedMessage: BasicMessage; unpackedMediaType: MediaType }`
|
|
56
|
+
*/
|
|
57
|
+
unpack(
|
|
58
|
+
envelope: Uint8Array
|
|
59
|
+
): Promise<{ unpackedMessage: BasicMessage; unpackedMediaType: MediaType }>;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* unpacks an envelope with a known media type
|
|
63
|
+
*
|
|
64
|
+
* @param {MediaType} mediaType
|
|
65
|
+
* @param {Uint8Array} envelope
|
|
66
|
+
* @returns `Promise<BasicMessage>`
|
|
67
|
+
*/
|
|
68
|
+
unpackWithType(mediaType: MediaType, envelope: Uint8Array): Promise<BasicMessage>;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* gets media type from an envelope
|
|
72
|
+
*
|
|
73
|
+
* @param {string} envelope
|
|
74
|
+
* @returns MediaType
|
|
75
|
+
*/
|
|
76
|
+
getMediaType(envelope: string): MediaType;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* gets supported media types by packer manager
|
|
80
|
+
*
|
|
81
|
+
* @returns MediaType[]
|
|
82
|
+
*/
|
|
83
|
+
getSupportedMediaTypes(): MediaType[];
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* gets supported accept profiles by packer manager
|
|
87
|
+
*
|
|
88
|
+
* @returns string[]
|
|
89
|
+
*/
|
|
90
|
+
getSupportedProfiles(): string[];
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* returns true if media type and algorithms supported by packer manager
|
|
94
|
+
*
|
|
95
|
+
* @param {MediaType} mediaType
|
|
96
|
+
* @param {string} profile
|
|
97
|
+
* @returns {boolean}
|
|
98
|
+
*/
|
|
99
|
+
isProfileSupported(mediaType: MediaType, profile: string): boolean;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* EnvelopeStub is used to stub the jwt based envelops
|
|
103
|
+
*/
|
|
104
|
+
export type EnvelopeStub = {
|
|
105
|
+
protected: string;
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* HeaderStub is used to stub the jwt based envelops
|
|
109
|
+
*/
|
|
110
|
+
export type HeaderStub = {
|
|
111
|
+
typ: MediaType;
|
|
112
|
+
};
|