@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,368 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import { W3CCredential, ProofQuery } from '../../verifiable';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* search errors
|
|
6
|
+
*
|
|
7
|
+
* @enum {number}
|
|
8
|
+
*/
|
|
9
|
+
export enum SearchError {
|
|
10
|
+
NotDefinedQueryKey = 'not defined query key',
|
|
11
|
+
NotDefinedComparator = 'not defined comparator'
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* supported data formats
|
|
15
|
+
*
|
|
16
|
+
* @enum {number}
|
|
17
|
+
*/
|
|
18
|
+
export enum SupportedDataFormat {
|
|
19
|
+
BigInt,
|
|
20
|
+
Boolean,
|
|
21
|
+
Double,
|
|
22
|
+
DateTime,
|
|
23
|
+
String
|
|
24
|
+
}
|
|
25
|
+
/** allowed operators to search */
|
|
26
|
+
export type FilterOperatorMethod =
|
|
27
|
+
| '$noop'
|
|
28
|
+
| '$eq'
|
|
29
|
+
| '$in'
|
|
30
|
+
| '$nin'
|
|
31
|
+
| '$gt'
|
|
32
|
+
| '$lt'
|
|
33
|
+
| '$ne'
|
|
34
|
+
| '$gte'
|
|
35
|
+
| '$lte'
|
|
36
|
+
| '$sd'
|
|
37
|
+
| '$exists'
|
|
38
|
+
| '$between'
|
|
39
|
+
| '$nonbetween';
|
|
40
|
+
|
|
41
|
+
/** filter function type */
|
|
42
|
+
export type FilterOperatorFunction = (a: any, b: any) => boolean;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* query filter interface that allows to query Verifiable Credential
|
|
46
|
+
*
|
|
47
|
+
* @public
|
|
48
|
+
* @interface IFilterQuery
|
|
49
|
+
*/
|
|
50
|
+
export interface IFilterQuery {
|
|
51
|
+
/**
|
|
52
|
+
* applies filter to verifiable credential
|
|
53
|
+
*
|
|
54
|
+
* @param {W3CCredential} credential - credential to query
|
|
55
|
+
* @returns boolean
|
|
56
|
+
*/
|
|
57
|
+
execute(credential: W3CCredential): boolean;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const truthyValues = [true, 1, 'true'];
|
|
61
|
+
const falsyValues = [false, 0, 'false'];
|
|
62
|
+
type ComparableType = number | string | boolean;
|
|
63
|
+
const equalsComparator = (
|
|
64
|
+
a: ComparableType | Array<ComparableType>,
|
|
65
|
+
b: ComparableType | Array<ComparableType>
|
|
66
|
+
) => {
|
|
67
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
68
|
+
return (
|
|
69
|
+
a.length === b.length && a.every((val, index) => val === (b as Array<ComparableType>)[index])
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (!Array.isArray(a) && Array.isArray(b)) {
|
|
74
|
+
return b.includes(a);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (Array.isArray(a) && !Array.isArray(b)) {
|
|
78
|
+
return a.includes(b);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
a = a as ComparableType;
|
|
82
|
+
b = b as ComparableType;
|
|
83
|
+
if (truthyValues.includes(a) && truthyValues.includes(b)) {
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (falsyValues.includes(a) && falsyValues.includes(b)) {
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return a === b;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const greaterThan = (
|
|
95
|
+
a: ComparableType | ComparableType[],
|
|
96
|
+
b: ComparableType | ComparableType[]
|
|
97
|
+
) => {
|
|
98
|
+
const predicate = (a: ComparableType, b: ComparableType) => {
|
|
99
|
+
const dataFormat = detectDataFormat(a.toString());
|
|
100
|
+
|
|
101
|
+
switch (dataFormat) {
|
|
102
|
+
case SupportedDataFormat.BigInt:
|
|
103
|
+
case SupportedDataFormat.Boolean:
|
|
104
|
+
return BigInt(a) > BigInt(b);
|
|
105
|
+
case SupportedDataFormat.DateTime:
|
|
106
|
+
return Date.parse(a.toString()) > Date.parse(b.toString()); /// nanoseconds won't be compared.
|
|
107
|
+
case SupportedDataFormat.Double:
|
|
108
|
+
case SupportedDataFormat.String:
|
|
109
|
+
default:
|
|
110
|
+
return a > b;
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
return operatorIndependentCheck(a, b, predicate);
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const greaterThanOrEqual = (
|
|
118
|
+
a: ComparableType | ComparableType[],
|
|
119
|
+
b: ComparableType | ComparableType[]
|
|
120
|
+
) => {
|
|
121
|
+
const predicate = (a: ComparableType, b: ComparableType) => {
|
|
122
|
+
const dataFormat = detectDataFormat(a.toString());
|
|
123
|
+
|
|
124
|
+
switch (dataFormat) {
|
|
125
|
+
case SupportedDataFormat.BigInt:
|
|
126
|
+
case SupportedDataFormat.Boolean:
|
|
127
|
+
return BigInt(a) >= BigInt(b);
|
|
128
|
+
case SupportedDataFormat.DateTime:
|
|
129
|
+
return Date.parse(a.toString()) >= Date.parse(b.toString()); /// nanoseconds won't be compared.
|
|
130
|
+
case SupportedDataFormat.Double:
|
|
131
|
+
case SupportedDataFormat.String:
|
|
132
|
+
default:
|
|
133
|
+
return a >= b;
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
return operatorIndependentCheck(a, b, predicate);
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
// a - field value
|
|
141
|
+
// b - true / false (exists operator values)
|
|
142
|
+
const existsComparator = (a: ComparableType | ComparableType[] | undefined, b: ComparableType) => {
|
|
143
|
+
if (truthyValues.includes(b) && typeof a !== 'undefined') {
|
|
144
|
+
// if exists val is true , a field val exists
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
147
|
+
// if exists val is false , a field val doesn't exist
|
|
148
|
+
if (falsyValues.includes(b) && (a === undefined || (Array.isArray(a) && !a.length))) {
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
return false;
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const inOperator = (a: ComparableType | ComparableType[], b: ComparableType | ComparableType[]) => {
|
|
155
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
156
|
+
return a.every((val) => b.includes(val));
|
|
157
|
+
}
|
|
158
|
+
if (!Array.isArray(a) && Array.isArray(b)) {
|
|
159
|
+
return b.includes(a);
|
|
160
|
+
}
|
|
161
|
+
if (Array.isArray(a) && !Array.isArray(b)) {
|
|
162
|
+
return a.includes(b);
|
|
163
|
+
}
|
|
164
|
+
return false;
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const betweenOperator = (
|
|
168
|
+
a: ComparableType | ComparableType[],
|
|
169
|
+
b: ComparableType | ComparableType[]
|
|
170
|
+
) => {
|
|
171
|
+
if (!Array.isArray(b) || b.length !== 2) {
|
|
172
|
+
throw new Error('$between/$nonbetween operator value should be 2 elements array');
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const [min, max] = b.map(BigInt);
|
|
176
|
+
const predicate = (val: bigint) => val >= min && val <= max;
|
|
177
|
+
|
|
178
|
+
if (Array.isArray(a)) {
|
|
179
|
+
return a.map(BigInt).every(predicate);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return predicate(BigInt(a));
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
export const comparatorOptions: { [v in FilterOperatorMethod]: FilterOperatorFunction } = {
|
|
186
|
+
$noop: () => true,
|
|
187
|
+
$sd: () => true,
|
|
188
|
+
$exists: (a, b) => existsComparator(a, b),
|
|
189
|
+
$eq: (a, b) => equalsComparator(a, b),
|
|
190
|
+
$in: (a: ComparableType | ComparableType[], b: ComparableType | ComparableType[]) =>
|
|
191
|
+
inOperator(a, b),
|
|
192
|
+
$nin: (a: ComparableType | ComparableType[], b: ComparableType | ComparableType[]) =>
|
|
193
|
+
!inOperator(a, b),
|
|
194
|
+
$gt: (a: ComparableType | ComparableType[], b: ComparableType | ComparableType[]) =>
|
|
195
|
+
greaterThan(a, b),
|
|
196
|
+
$lt: (a: ComparableType | ComparableType[], b: ComparableType | ComparableType[]) =>
|
|
197
|
+
!greaterThanOrEqual(a, b),
|
|
198
|
+
$ne: (a, b) => !equalsComparator(a, b),
|
|
199
|
+
$gte: (a: ComparableType | ComparableType[], b: ComparableType | ComparableType[]) =>
|
|
200
|
+
greaterThanOrEqual(a, b),
|
|
201
|
+
$lte: (a: ComparableType | ComparableType[], b: ComparableType | ComparableType[]) =>
|
|
202
|
+
!greaterThan(a, b),
|
|
203
|
+
$between: (a: ComparableType | ComparableType[], b: ComparableType | ComparableType[]) =>
|
|
204
|
+
betweenOperator(a, b),
|
|
205
|
+
$nonbetween: (a: ComparableType | ComparableType[], b: ComparableType | ComparableType[]) =>
|
|
206
|
+
!betweenOperator(a, b)
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* credential search path resolver
|
|
211
|
+
*
|
|
212
|
+
* @param {object} object - object to query
|
|
213
|
+
* @param {string} path - given path
|
|
214
|
+
* @param {*} [defaultValue=null]
|
|
215
|
+
*/
|
|
216
|
+
export const resolvePath = (object: object, path: string, defaultValue = null) => {
|
|
217
|
+
const pathParts = path.split('.');
|
|
218
|
+
let o = object;
|
|
219
|
+
for (const part of pathParts) {
|
|
220
|
+
if (o === null || o === undefined) {
|
|
221
|
+
return defaultValue;
|
|
222
|
+
}
|
|
223
|
+
o = o[part as keyof typeof o];
|
|
224
|
+
}
|
|
225
|
+
return o;
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Filter for queries of credentialSubject with a json path e.g birthday.date
|
|
230
|
+
*
|
|
231
|
+
*
|
|
232
|
+
* @public
|
|
233
|
+
* @class FilterQuery
|
|
234
|
+
* @implements implements IFilterQuery interface
|
|
235
|
+
*/
|
|
236
|
+
export class FilterQuery implements IFilterQuery {
|
|
237
|
+
/**
|
|
238
|
+
* Creates an instance of FilterQuery.
|
|
239
|
+
* @param {string} path
|
|
240
|
+
* @param {FilterOperatorFunction} operatorFunc
|
|
241
|
+
* @param {*} value
|
|
242
|
+
* @param {boolean} [isReverseParams=false]
|
|
243
|
+
*/
|
|
244
|
+
constructor(
|
|
245
|
+
public path: string,
|
|
246
|
+
public operatorFunc: FilterOperatorFunction,
|
|
247
|
+
public value: any,
|
|
248
|
+
public isReverseParams = false
|
|
249
|
+
) {}
|
|
250
|
+
/** {@inheritdoc IFilterQuery} */
|
|
251
|
+
execute(credential: W3CCredential): boolean {
|
|
252
|
+
if (!this.operatorFunc) {
|
|
253
|
+
throw new Error(SearchError.NotDefinedComparator);
|
|
254
|
+
}
|
|
255
|
+
const credentialPathValue = resolvePath(credential, this.path);
|
|
256
|
+
if (
|
|
257
|
+
(credentialPathValue === null || credentialPathValue === undefined) &&
|
|
258
|
+
this.operatorFunc !== comparatorOptions.$exists
|
|
259
|
+
) {
|
|
260
|
+
return false;
|
|
261
|
+
}
|
|
262
|
+
if (this.isReverseParams) {
|
|
263
|
+
return this.operatorFunc(this.value, credentialPathValue);
|
|
264
|
+
}
|
|
265
|
+
return this.operatorFunc(credentialPathValue, this.value);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* creates filters based on proof query
|
|
271
|
+
* @param {ProofQuery} query - proof query
|
|
272
|
+
* @returns {*} {FilterQuery[]} - array of filters to apply
|
|
273
|
+
*/
|
|
274
|
+
export const StandardJSONCredentialsQueryFilter = (query: ProofQuery): FilterQuery[] => {
|
|
275
|
+
return Object.keys(query).reduce((acc: FilterQuery[], queryKey) => {
|
|
276
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
277
|
+
const queryValue: any = query[queryKey as keyof typeof query];
|
|
278
|
+
switch (queryKey) {
|
|
279
|
+
case 'claimId':
|
|
280
|
+
return acc.concat(new FilterQuery('id', comparatorOptions.$eq, queryValue));
|
|
281
|
+
case 'allowedIssuers': {
|
|
282
|
+
const queryValueParam = queryValue || ['*'];
|
|
283
|
+
if (queryValueParam.includes('*')) {
|
|
284
|
+
return acc;
|
|
285
|
+
}
|
|
286
|
+
return acc.concat(new FilterQuery('issuer', comparatorOptions.$in, queryValue));
|
|
287
|
+
}
|
|
288
|
+
case 'type':
|
|
289
|
+
return acc.concat(new FilterQuery('type', comparatorOptions.$in, queryValue, true));
|
|
290
|
+
case 'context':
|
|
291
|
+
return acc.concat(new FilterQuery('@context', comparatorOptions.$in, queryValue, true));
|
|
292
|
+
case 'credentialSubjectId':
|
|
293
|
+
return acc.concat(
|
|
294
|
+
new FilterQuery('credentialSubject.id', comparatorOptions.$eq, queryValue)
|
|
295
|
+
);
|
|
296
|
+
case 'schema':
|
|
297
|
+
return acc.concat(
|
|
298
|
+
new FilterQuery('credentialSchema.id', comparatorOptions.$eq, queryValue)
|
|
299
|
+
);
|
|
300
|
+
case 'credentialSubject': {
|
|
301
|
+
const reqFilters = Object.keys(queryValue).reduce((acc: FilterQuery[], fieldKey) => {
|
|
302
|
+
const fieldParams = queryValue[fieldKey];
|
|
303
|
+
if (typeof fieldParams === 'object' && Object.keys(fieldParams).length === 0) {
|
|
304
|
+
return acc.concat([
|
|
305
|
+
new FilterQuery(`credentialSubject.${fieldKey}`, comparatorOptions.$noop, null)
|
|
306
|
+
]);
|
|
307
|
+
}
|
|
308
|
+
const res = Object.keys(fieldParams).map((comparator) => {
|
|
309
|
+
const value = fieldParams[comparator];
|
|
310
|
+
const path = `credentialSubject.${fieldKey}`;
|
|
311
|
+
return new FilterQuery(
|
|
312
|
+
path,
|
|
313
|
+
comparatorOptions[comparator as keyof typeof comparatorOptions],
|
|
314
|
+
value
|
|
315
|
+
);
|
|
316
|
+
});
|
|
317
|
+
return acc.concat(res);
|
|
318
|
+
}, []);
|
|
319
|
+
|
|
320
|
+
return acc.concat(reqFilters);
|
|
321
|
+
}
|
|
322
|
+
case 'proofType':
|
|
323
|
+
case 'groupId':
|
|
324
|
+
case 'skipClaimRevocationCheck': {
|
|
325
|
+
return acc;
|
|
326
|
+
}
|
|
327
|
+
default:
|
|
328
|
+
throw new Error(`${queryKey} : ${SearchError.NotDefinedQueryKey}`);
|
|
329
|
+
}
|
|
330
|
+
}, []);
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
const operatorIndependentCheck = (
|
|
334
|
+
a: ComparableType | ComparableType[],
|
|
335
|
+
b: ComparableType | ComparableType[],
|
|
336
|
+
predicate: (a: ComparableType, b: ComparableType) => boolean
|
|
337
|
+
) => {
|
|
338
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
339
|
+
return a.every((val, index) => predicate(val, (b as ComparableType[])[index]));
|
|
340
|
+
}
|
|
341
|
+
if (!Array.isArray(a) && Array.isArray(b)) {
|
|
342
|
+
return b.every((val) => predicate(a, val));
|
|
343
|
+
}
|
|
344
|
+
if (Array.isArray(a) && !Array.isArray(b)) {
|
|
345
|
+
return a.every((val) => predicate(val, b));
|
|
346
|
+
}
|
|
347
|
+
// in this case a and b are not arrays
|
|
348
|
+
return predicate(a as ComparableType, b as ComparableType);
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
const regExBigInt = /^[+-]?\d+$/;
|
|
352
|
+
const regExDouble = /^(-?)(0|([1-9][0-9]*))(\\.[0-9]+)?$/;
|
|
353
|
+
const regExDateTimeRFC3339Nano =
|
|
354
|
+
/* eslint-disable-next-line */
|
|
355
|
+
/^([0-9]+)-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])[Tt]([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(\.[0-9]+)?(([Zz])|([\+|\-]([01][0-9]|2[0-3]):[0-5][0-9]))$/;
|
|
356
|
+
const regExBoolean = /^(true)|(false)$/;
|
|
357
|
+
const regExDateTimeYYYYMMDD = /^\d{4}-\d{2}-\d{2}$/;
|
|
358
|
+
|
|
359
|
+
const detectDataFormat = (s: string): SupportedDataFormat =>
|
|
360
|
+
regExBigInt.test(s)
|
|
361
|
+
? SupportedDataFormat.BigInt
|
|
362
|
+
: regExDouble.test(s)
|
|
363
|
+
? SupportedDataFormat.Double
|
|
364
|
+
: regExDateTimeRFC3339Nano.test(s) || regExDateTimeYYYYMMDD.test(s)
|
|
365
|
+
? SupportedDataFormat.DateTime
|
|
366
|
+
: regExBoolean.test(s)
|
|
367
|
+
? SupportedDataFormat.Boolean
|
|
368
|
+
: SupportedDataFormat.String;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { CircuitId } from '../../circuits';
|
|
2
|
+
import { CircuitData } from '../entities/circuitData';
|
|
3
|
+
import { ICircuitStorage } from '../interfaces/circuits';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Options for FSCircuitStorage,
|
|
7
|
+
* Path to the circuit file is constructed from `${this._dirname}/${circuitId}/${filename}`,
|
|
8
|
+
* by default values for keys are:
|
|
9
|
+
* - verification key : verification_key.json
|
|
10
|
+
* - proving key : circuit_final.zkey
|
|
11
|
+
* - wasm file : circuit.wasm
|
|
12
|
+
* you can customize filename by passing the corresponding option.
|
|
13
|
+
* dirname is mandatory.
|
|
14
|
+
* hierarchical structure for files is mandatory
|
|
15
|
+
* e.g. --circuits
|
|
16
|
+
* -----circuitId
|
|
17
|
+
* ---------file
|
|
18
|
+
* @public
|
|
19
|
+
* @interface FSCircuitStorageOptions
|
|
20
|
+
*/
|
|
21
|
+
export interface FSCircuitStorageOptions {
|
|
22
|
+
dirname: string;
|
|
23
|
+
verificationFileName?: string;
|
|
24
|
+
provingFileName?: string;
|
|
25
|
+
wasmFileName?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Implementation of ICircuitStorage to store keys data in file system
|
|
29
|
+
*
|
|
30
|
+
* @public
|
|
31
|
+
* @class FSCircuitStorage
|
|
32
|
+
* @implements implements ICircuitStorage interface
|
|
33
|
+
*/
|
|
34
|
+
export class FSCircuitStorage implements ICircuitStorage {
|
|
35
|
+
private readonly _verificationKeyPath: string = 'verification_key.json';
|
|
36
|
+
private readonly _provingKeyPath: string = 'circuit_final.zkey';
|
|
37
|
+
private readonly _wasmFilePath: string = 'circuit.wasm';
|
|
38
|
+
|
|
39
|
+
private _fs: typeof import('fs') | null = null;
|
|
40
|
+
|
|
41
|
+
private readonly _browserNotSupportedError: Error = new Error(
|
|
42
|
+
'File system operations are not supported in browser environment'
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
private async getFs(): Promise<typeof import('fs')> {
|
|
46
|
+
if (this._fs) {
|
|
47
|
+
return this._fs;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (!process.env.BUILD_BROWSER) {
|
|
51
|
+
this._fs = await import('fs');
|
|
52
|
+
} else {
|
|
53
|
+
this._fs = {
|
|
54
|
+
existsSync: () => {
|
|
55
|
+
throw this._browserNotSupportedError;
|
|
56
|
+
},
|
|
57
|
+
readFileSync: () => {
|
|
58
|
+
throw this._browserNotSupportedError;
|
|
59
|
+
},
|
|
60
|
+
writeFileSync: () => {
|
|
61
|
+
throw this._browserNotSupportedError;
|
|
62
|
+
},
|
|
63
|
+
mkdirSync: () => {
|
|
64
|
+
throw this._browserNotSupportedError;
|
|
65
|
+
}
|
|
66
|
+
} as unknown as typeof import('fs');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return this._fs;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Creates an instance of FSCircuitStorage.
|
|
73
|
+
* @param {string} opts - options to read / save files
|
|
74
|
+
*/
|
|
75
|
+
constructor(private readonly opts: FSCircuitStorageOptions) {
|
|
76
|
+
this._verificationKeyPath = this.opts.verificationFileName ?? this._verificationKeyPath;
|
|
77
|
+
this._provingKeyPath = this.opts.provingFileName ?? this._provingKeyPath;
|
|
78
|
+
this._wasmFilePath = this.opts.wasmFileName ?? this._wasmFilePath;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* loads circuit data by id from file storage
|
|
83
|
+
* {@inheritdoc ICircuitStorage.loadCircuitData}
|
|
84
|
+
* @param {CircuitId} circuitId - id of the circuit
|
|
85
|
+
* @returns `Promise<CircuitData>`
|
|
86
|
+
*/
|
|
87
|
+
async loadCircuitData(circuitId: CircuitId): Promise<CircuitData> {
|
|
88
|
+
const verificationKey = await this.loadCircuitFile(circuitId, this._verificationKeyPath);
|
|
89
|
+
const provingKey = await this.loadCircuitFile(circuitId, this._provingKeyPath);
|
|
90
|
+
const wasm = await this.loadCircuitFile(circuitId, this._wasmFilePath);
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
circuitId,
|
|
94
|
+
wasm,
|
|
95
|
+
provingKey,
|
|
96
|
+
verificationKey
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
private async loadCircuitFile(
|
|
101
|
+
circuitId: CircuitId,
|
|
102
|
+
filename: string
|
|
103
|
+
): Promise<Uint8Array | null> {
|
|
104
|
+
const keyPath = `${this.opts.dirname}/${circuitId}/${filename}`;
|
|
105
|
+
const fs = await this.getFs();
|
|
106
|
+
if (fs.existsSync(keyPath)) {
|
|
107
|
+
const keyData = fs.readFileSync(keyPath);
|
|
108
|
+
return new Uint8Array(keyData);
|
|
109
|
+
}
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
private async writeCircuitFile(
|
|
113
|
+
circuitId: CircuitId,
|
|
114
|
+
filename: string,
|
|
115
|
+
file: Uint8Array,
|
|
116
|
+
encoding?: BufferEncoding
|
|
117
|
+
): Promise<void> {
|
|
118
|
+
const dirPath = `${this.opts.dirname}/${circuitId}`;
|
|
119
|
+
const keyPath = `${dirPath}/${filename}`;
|
|
120
|
+
const fs = await this.getFs();
|
|
121
|
+
fs.mkdirSync(dirPath, { recursive: true });
|
|
122
|
+
fs.writeFileSync(keyPath, file, encoding);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* {@inheritdoc ICircuitStorage.loadCircuitData}
|
|
127
|
+
* saves circuit data for circuit id to the file storage
|
|
128
|
+
* @param {CircuitId} circuitId - id of the circuit
|
|
129
|
+
* @param {CircuitData} circuitData - circuit keys
|
|
130
|
+
* @returns `Promise<void>`
|
|
131
|
+
*/
|
|
132
|
+
async saveCircuitData(circuitId: CircuitId, circuitData: CircuitData): Promise<void> {
|
|
133
|
+
if (circuitData.verificationKey) {
|
|
134
|
+
await this.writeCircuitFile(
|
|
135
|
+
circuitId,
|
|
136
|
+
this._verificationKeyPath,
|
|
137
|
+
circuitData.verificationKey,
|
|
138
|
+
'utf-8'
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (circuitData.provingKey) {
|
|
143
|
+
await this.writeCircuitFile(circuitId, this._provingKeyPath, circuitData.provingKey);
|
|
144
|
+
}
|
|
145
|
+
if (circuitData.wasm) {
|
|
146
|
+
await this.writeCircuitFile(circuitId, this._wasmFilePath, circuitData.wasm);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './circuits-storage';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './interfaces';
|
|
2
|
+
export * from './blockchain';
|
|
3
|
+
export * from './entities';
|
|
4
|
+
export * from './filters';
|
|
5
|
+
export * from './memory';
|
|
6
|
+
export * from './local-storage';
|
|
7
|
+
export * from './indexed-db';
|
|
8
|
+
export * from './shared';
|
|
9
|
+
export * from './fs';
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
+
import { IDataSource } from '../interfaces/data-source';
|
|
3
|
+
import { set, get, del, values, createStore, UseStore } from 'idb-keyval';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Storage in the browser, uses indexed db storage
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
* @class IndexedDBDataSource
|
|
10
|
+
* @template Type
|
|
11
|
+
*/
|
|
12
|
+
export class IndexedDBDataSource<Type> implements IDataSource<Type> {
|
|
13
|
+
/**
|
|
14
|
+
* Creates an instance of IndexedDBDataSource.
|
|
15
|
+
*
|
|
16
|
+
* @param {string} _storageKey - key string to put storage name
|
|
17
|
+
*/
|
|
18
|
+
private readonly _store: UseStore;
|
|
19
|
+
constructor(private _storageKey: string) {
|
|
20
|
+
this._store = createStore(`${_storageKey}-db`, _storageKey);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Saves value to the indexed db storage
|
|
25
|
+
*
|
|
26
|
+
* @param {string} key - key value
|
|
27
|
+
* @param {Type} value - value to store
|
|
28
|
+
* @param {string} [keyName='id'] - key name
|
|
29
|
+
*/
|
|
30
|
+
async save(key: string, value: Type, keyName = 'id'): Promise<void> {
|
|
31
|
+
return set(key, value, this._store);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Gets value from the indexed db storage by given key
|
|
36
|
+
*
|
|
37
|
+
* @param {string} key - key value
|
|
38
|
+
* @param {string} [keyName='id'] - key name
|
|
39
|
+
*/
|
|
40
|
+
async get(key: string, keyName = 'id'): Promise<Type | undefined> {
|
|
41
|
+
return get(key, this._store);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* loads all from the indexed db storage
|
|
46
|
+
*/
|
|
47
|
+
async load(): Promise<Type[]> {
|
|
48
|
+
return values(this._store);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* deletes item from the indexed db storage
|
|
52
|
+
* @param {string} key - key value
|
|
53
|
+
* @param {string} [keyName='id'] - key name
|
|
54
|
+
*/
|
|
55
|
+
async delete(key: string, keyName = 'id'): Promise<void> {
|
|
56
|
+
return del(key, this._store);
|
|
57
|
+
}
|
|
58
|
+
}
|