@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,87 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import { StorageErrors } from '../errors';
|
|
3
|
+
import { IDataSource } from '../interfaces/data-source';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Storage in the browser, uses local storage
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
* @class BrowserDataSource
|
|
10
|
+
* @template Type
|
|
11
|
+
*/
|
|
12
|
+
export class BrowserDataSource<Type> implements IDataSource<Type> {
|
|
13
|
+
/**
|
|
14
|
+
* Creates an instance of BrowserDataSource.
|
|
15
|
+
* @param {string} _localStorageKey - key string to put storage name in the local storage
|
|
16
|
+
*/
|
|
17
|
+
constructor(private _localStorageKey: string) {
|
|
18
|
+
const data = localStorage.getItem(this._localStorageKey);
|
|
19
|
+
if (!data) {
|
|
20
|
+
localStorage.setItem(_localStorageKey, JSON.stringify([]));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* saves value to the local storage
|
|
27
|
+
* @param {string} key - key value
|
|
28
|
+
* @param {Type} value - value to store
|
|
29
|
+
* @param {string} [keyName='id'] - key name
|
|
30
|
+
*/
|
|
31
|
+
async save(key: string, value: Type, keyName = 'id'): Promise<void> {
|
|
32
|
+
if (localStorage) {
|
|
33
|
+
const data = localStorage.getItem(this._localStorageKey);
|
|
34
|
+
let items: Type[] = [];
|
|
35
|
+
if (data) {
|
|
36
|
+
items = JSON.parse(data) as Type[];
|
|
37
|
+
}
|
|
38
|
+
const itemIndex = items.findIndex((i: any): boolean => i[keyName] === key);
|
|
39
|
+
if (itemIndex === -1) {
|
|
40
|
+
items.push(value);
|
|
41
|
+
} else {
|
|
42
|
+
items[itemIndex] = value;
|
|
43
|
+
}
|
|
44
|
+
localStorage.setItem(this._localStorageKey, JSON.stringify(items));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* gets value from the local storage by given key
|
|
50
|
+
* @param {string} key - key value
|
|
51
|
+
* @param {string} [keyName='id'] - key name
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
async get(key: string, keyName = 'id'): Promise<Type | undefined> {
|
|
55
|
+
const data = localStorage.getItem(this._localStorageKey);
|
|
56
|
+
let parsedData: Type[] = [];
|
|
57
|
+
if (data) {
|
|
58
|
+
parsedData = JSON.parse(data) as Type[];
|
|
59
|
+
}
|
|
60
|
+
return parsedData.find((t: any) => t[keyName] === key);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* loads all from the local storage
|
|
65
|
+
*/
|
|
66
|
+
async load(): Promise<Type[]> {
|
|
67
|
+
const data = localStorage.getItem(this._localStorageKey);
|
|
68
|
+
return data && JSON.parse(data);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* deletes item from the local storage
|
|
72
|
+
* @param {string} key - key value
|
|
73
|
+
* @param {string} [keyName='id'] - key name
|
|
74
|
+
*/
|
|
75
|
+
async delete(key: string, keyName = 'id'): Promise<void> {
|
|
76
|
+
const dataStr = localStorage.getItem(this._localStorageKey);
|
|
77
|
+
let data: Type[] = [];
|
|
78
|
+
if (dataStr) {
|
|
79
|
+
data = JSON.parse(dataStr) as Type[];
|
|
80
|
+
}
|
|
81
|
+
const items = data.filter((i: any) => i[keyName] !== key);
|
|
82
|
+
if (data.length === items.length) {
|
|
83
|
+
throw new Error(`${StorageErrors.ItemNotFound} to delete: ${key}`);
|
|
84
|
+
}
|
|
85
|
+
localStorage.setItem(this._localStorageKey, JSON.stringify(items));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { LocalStorageDB, Merkletree, str2Bytes } from '@iden3/js-merkletree';
|
|
2
|
+
import { IdentityMerkleTreeMetaInformation, MerkleTreeType } from '../entities/mt';
|
|
3
|
+
import * as uuid from 'uuid';
|
|
4
|
+
|
|
5
|
+
import { IMerkleTreeStorage } from '../interfaces/merkletree';
|
|
6
|
+
import { createMerkleTreeMetaInfo } from '../utils';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Merkle tree storage that uses browser local storage
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
* @class MerkleTreeLocalStorage
|
|
13
|
+
* @implements implements IMerkleTreeStorage interface
|
|
14
|
+
*/
|
|
15
|
+
export class MerkleTreeLocalStorage implements IMerkleTreeStorage {
|
|
16
|
+
/**
|
|
17
|
+
* key for the storage key metadata
|
|
18
|
+
*
|
|
19
|
+
* @static
|
|
20
|
+
*/
|
|
21
|
+
static readonly storageKeyMeta = 'merkle-tree-meta';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Creates an instance of MerkleTreeLocalStorage.
|
|
25
|
+
* @param {number} _mtDepth
|
|
26
|
+
*/
|
|
27
|
+
constructor(private readonly _mtDepth: number) {}
|
|
28
|
+
|
|
29
|
+
/** creates a tree in the local storage */
|
|
30
|
+
async createIdentityMerkleTrees(
|
|
31
|
+
identifier: string
|
|
32
|
+
): Promise<IdentityMerkleTreeMetaInformation[]> {
|
|
33
|
+
if (!identifier) {
|
|
34
|
+
identifier = `${uuid.v4()}`;
|
|
35
|
+
}
|
|
36
|
+
const meta = localStorage.getItem(MerkleTreeLocalStorage.storageKeyMeta);
|
|
37
|
+
if (meta) {
|
|
38
|
+
const metaInfo: IdentityMerkleTreeMetaInformation[] = JSON.parse(meta);
|
|
39
|
+
const presentMetaForIdentifier = metaInfo.find((m) => m.treeId === `${identifier}+${m.type}`);
|
|
40
|
+
if (presentMetaForIdentifier) {
|
|
41
|
+
throw new Error(
|
|
42
|
+
`Present merkle tree meta information in the store for current identifier ${identifier}`
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
const identityMetaInfo = metaInfo.filter((m) => m.identifier === identifier);
|
|
46
|
+
if (identityMetaInfo.length > 0) {
|
|
47
|
+
return identityMetaInfo;
|
|
48
|
+
}
|
|
49
|
+
const treesMeta = createMerkleTreeMetaInfo(identifier);
|
|
50
|
+
localStorage.setItem(
|
|
51
|
+
MerkleTreeLocalStorage.storageKeyMeta,
|
|
52
|
+
JSON.stringify([...metaInfo, ...treesMeta])
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
return [...metaInfo, ...treesMeta];
|
|
56
|
+
}
|
|
57
|
+
const treesMeta = createMerkleTreeMetaInfo(identifier);
|
|
58
|
+
localStorage.setItem(MerkleTreeLocalStorage.storageKeyMeta, JSON.stringify(treesMeta));
|
|
59
|
+
return treesMeta;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
*
|
|
63
|
+
* getIdentityMerkleTreesInfo from the local storage
|
|
64
|
+
* @param {string} identifier
|
|
65
|
+
* @returns `{Promise<IdentityMerkleTreeMetaInformation[]>}`
|
|
66
|
+
*/
|
|
67
|
+
async getIdentityMerkleTreesInfo(
|
|
68
|
+
identifier: string
|
|
69
|
+
): Promise<IdentityMerkleTreeMetaInformation[]> {
|
|
70
|
+
const meta = localStorage.getItem(MerkleTreeLocalStorage.storageKeyMeta);
|
|
71
|
+
if (meta) {
|
|
72
|
+
const metaInfo: IdentityMerkleTreeMetaInformation[] = JSON.parse(meta);
|
|
73
|
+
return metaInfo.filter((m) => m.identifier === identifier);
|
|
74
|
+
}
|
|
75
|
+
throw new Error(`Merkle tree meta not found for identifier ${identifier}`);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** get merkle tree from the local storage */
|
|
79
|
+
async getMerkleTreeByIdentifierAndType(
|
|
80
|
+
identifier: string,
|
|
81
|
+
mtType: MerkleTreeType
|
|
82
|
+
): Promise<Merkletree> {
|
|
83
|
+
const resultMeta = this.getMeta(identifier, mtType);
|
|
84
|
+
return new Merkletree(new LocalStorageDB(str2Bytes(resultMeta.treeId)), true, this._mtDepth);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
private getMeta(identifier: string, mtType: MerkleTreeType) {
|
|
88
|
+
const meta = localStorage.getItem(MerkleTreeLocalStorage.storageKeyMeta);
|
|
89
|
+
const err = new Error(`Merkle tree not found for identifier ${identifier} and type ${mtType}`);
|
|
90
|
+
if (!meta) {
|
|
91
|
+
throw err;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const metaInfo: IdentityMerkleTreeMetaInformation[] = JSON.parse(meta);
|
|
95
|
+
const resultMeta = metaInfo.filter((m) => m.identifier === identifier && m.type === mtType)[0];
|
|
96
|
+
if (!resultMeta) {
|
|
97
|
+
throw err;
|
|
98
|
+
}
|
|
99
|
+
return resultMeta;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** adds to merkle tree in the local storage */
|
|
103
|
+
async addToMerkleTree(
|
|
104
|
+
identifier: string,
|
|
105
|
+
mtType: MerkleTreeType,
|
|
106
|
+
hindex: bigint,
|
|
107
|
+
hvalue: bigint
|
|
108
|
+
): Promise<void> {
|
|
109
|
+
const resultMeta = this.getMeta(identifier, mtType);
|
|
110
|
+
|
|
111
|
+
const tree = new Merkletree(
|
|
112
|
+
new LocalStorageDB(str2Bytes(resultMeta.treeId)),
|
|
113
|
+
true,
|
|
114
|
+
this._mtDepth
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
await tree.add(hindex, hvalue);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** binds merkle tree in the local storage to the new identifiers */
|
|
121
|
+
async bindMerkleTreeToNewIdentifier(oldIdentifier: string, newIdentifier: string): Promise<void> {
|
|
122
|
+
const meta = localStorage.getItem(MerkleTreeLocalStorage.storageKeyMeta);
|
|
123
|
+
if (!meta) {
|
|
124
|
+
throw new Error(`Merkle tree meta not found for identifier ${oldIdentifier}`);
|
|
125
|
+
}
|
|
126
|
+
const metaInfo: IdentityMerkleTreeMetaInformation[] = JSON.parse(meta);
|
|
127
|
+
const treesMeta = metaInfo
|
|
128
|
+
.filter((m) => m.identifier === oldIdentifier)
|
|
129
|
+
.map((m) => ({ ...m, identifier: newIdentifier }));
|
|
130
|
+
if (treesMeta.length === 0) {
|
|
131
|
+
throw new Error(`Merkle tree meta not found for identifier ${oldIdentifier}`);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const newMetaInfo = [...metaInfo.filter((m) => m.identifier !== oldIdentifier), ...treesMeta];
|
|
135
|
+
localStorage.setItem(MerkleTreeLocalStorage.storageKeyMeta, JSON.stringify(newMetaInfo));
|
|
136
|
+
}
|
|
137
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import QuickLRU from 'quick-lru';
|
|
2
|
+
|
|
3
|
+
export interface ICache<T> {
|
|
4
|
+
get(key: string): Promise<T | undefined>;
|
|
5
|
+
set(key: string, value: T, ttl?: number): Promise<void>;
|
|
6
|
+
delete(key: string): Promise<void>;
|
|
7
|
+
clear(): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function createInMemoryCache<T>(params: { ttl?: number; maxSize: number }): ICache<T> {
|
|
11
|
+
const cache = new QuickLRU<string, T>({ maxSize: params.maxSize, maxAge: params.ttl });
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
get: async (key: string): Promise<T | undefined> => {
|
|
15
|
+
return cache.get(key);
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
set: async (key: string, value: T, ttl?: number) => {
|
|
19
|
+
cache.set(key, value, { maxAge: ttl ?? params.ttl });
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
clear: async () => {
|
|
23
|
+
cache.clear();
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
delete: async (key: string) => {
|
|
27
|
+
cache.delete(key);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import { StorageErrors } from '../errors';
|
|
3
|
+
import { IDataSource } from '../interfaces/data-source';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Generic Memory Data Source
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
* @class InMemoryDataSource - class
|
|
10
|
+
* @template Type
|
|
11
|
+
*/
|
|
12
|
+
export class InMemoryDataSource<Type> implements IDataSource<Type> {
|
|
13
|
+
private _data: Type[] = [];
|
|
14
|
+
|
|
15
|
+
/** saves in the memory */
|
|
16
|
+
async save(key: string, value: Type, keyName = 'id'): Promise<void> {
|
|
17
|
+
const itemIndex = this._data.findIndex((i: any) => i[keyName] === key);
|
|
18
|
+
if (itemIndex === -1) {
|
|
19
|
+
this._data.push(value);
|
|
20
|
+
} else {
|
|
21
|
+
this._data[itemIndex] = value;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** gets value from from the memory */
|
|
26
|
+
async get(key: string, keyName = 'id'): Promise<Type | undefined> {
|
|
27
|
+
return this._data.find((t: any) => t[keyName] === key);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** loads from value from the memory */
|
|
31
|
+
async load(): Promise<Type[]> {
|
|
32
|
+
return this._data;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** deletes from value from the memory */
|
|
36
|
+
async delete(key: string, keyName = 'id'): Promise<void> {
|
|
37
|
+
const newData = this._data.filter((i: any) => i[keyName] !== key);
|
|
38
|
+
|
|
39
|
+
if (newData.length === this._data.length) {
|
|
40
|
+
throw new Error(`${StorageErrors.ItemNotFound} to delete: ${key}`);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
this._data = newData;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { InMemoryDB, Merkletree, str2Bytes } from '@iden3/js-merkletree';
|
|
2
|
+
import { IdentityMerkleTreeMetaInformation, MerkleTreeType } from '../entities/mt';
|
|
3
|
+
import * as uuid from 'uuid';
|
|
4
|
+
|
|
5
|
+
import { IMerkleTreeStorage } from '../interfaces/merkletree';
|
|
6
|
+
import { MERKLE_TREE_TYPES } from '../utils';
|
|
7
|
+
|
|
8
|
+
export interface TreeWithMetaInfo {
|
|
9
|
+
tree: Merkletree;
|
|
10
|
+
metaInfo: IdentityMerkleTreeMetaInformation;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
*
|
|
16
|
+
* @public
|
|
17
|
+
* @class InMemoryMerkleTreeStorage
|
|
18
|
+
* @implements implements IMerkleTreeStorage interface
|
|
19
|
+
*/
|
|
20
|
+
export class InMemoryMerkleTreeStorage implements IMerkleTreeStorage {
|
|
21
|
+
/**
|
|
22
|
+
* key value storage for trees where key is identifier
|
|
23
|
+
*
|
|
24
|
+
* @type {{
|
|
25
|
+
* [v in string]: TreeWithMetaInfo[];
|
|
26
|
+
* }}
|
|
27
|
+
*/
|
|
28
|
+
_data: {
|
|
29
|
+
[v in string]: TreeWithMetaInfo[];
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* tree depth
|
|
33
|
+
*
|
|
34
|
+
* @type {number}
|
|
35
|
+
*/
|
|
36
|
+
mtDepth: number;
|
|
37
|
+
/**
|
|
38
|
+
* Creates an instance of InMemoryMerkleTreeStorage.
|
|
39
|
+
* @param {number} _mtDepth
|
|
40
|
+
*/
|
|
41
|
+
constructor(_mtDepth: number) {
|
|
42
|
+
this.mtDepth = _mtDepth;
|
|
43
|
+
this._data = {};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** create trees in the memory*/
|
|
47
|
+
async createIdentityMerkleTrees(
|
|
48
|
+
identifier: string
|
|
49
|
+
): Promise<IdentityMerkleTreeMetaInformation[]> {
|
|
50
|
+
if (!identifier) {
|
|
51
|
+
identifier = `${uuid.v4()}`;
|
|
52
|
+
}
|
|
53
|
+
if (this._data[identifier]) {
|
|
54
|
+
throw new Error(
|
|
55
|
+
`Present merkle tree meta information in the store for current identifier ${identifier}`
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
this._data[identifier] = [];
|
|
59
|
+
|
|
60
|
+
const treesMeta: IdentityMerkleTreeMetaInformation[] = [];
|
|
61
|
+
MERKLE_TREE_TYPES.forEach((t) => {
|
|
62
|
+
const treeId = identifier.concat('+' + t.toString());
|
|
63
|
+
const tree = new Merkletree(new InMemoryDB(str2Bytes(treeId)), true, this.mtDepth);
|
|
64
|
+
|
|
65
|
+
const metaInfo = { treeId, identifier: identifier, type: t };
|
|
66
|
+
this._data[identifier].push({ tree, metaInfo });
|
|
67
|
+
|
|
68
|
+
treesMeta.push(metaInfo);
|
|
69
|
+
});
|
|
70
|
+
return treesMeta;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** get trees meta info from the memory */
|
|
74
|
+
async getIdentityMerkleTreesInfo(
|
|
75
|
+
identifier: string
|
|
76
|
+
): Promise<IdentityMerkleTreeMetaInformation[]> {
|
|
77
|
+
return this._data[identifier].map((treeWithInfo) => treeWithInfo.metaInfo);
|
|
78
|
+
}
|
|
79
|
+
/** get merkle tree by identifier and type from memory */
|
|
80
|
+
async getMerkleTreeByIdentifierAndType(
|
|
81
|
+
identifier: string,
|
|
82
|
+
mtType: MerkleTreeType
|
|
83
|
+
): Promise<Merkletree> {
|
|
84
|
+
const treeWithMeta = this._data[identifier].find(
|
|
85
|
+
(treeWithInfo) => treeWithInfo.metaInfo.type == mtType
|
|
86
|
+
);
|
|
87
|
+
if (!treeWithMeta) {
|
|
88
|
+
throw new Error(`Merkle tree not found for identifier ${identifier} and type ${mtType}`);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return treeWithMeta.tree;
|
|
92
|
+
}
|
|
93
|
+
/** adds entry to merkle tree in the memory */
|
|
94
|
+
async addToMerkleTree(
|
|
95
|
+
identifier: string,
|
|
96
|
+
mtType: MerkleTreeType,
|
|
97
|
+
hindex: bigint,
|
|
98
|
+
hvalue: bigint
|
|
99
|
+
): Promise<void> {
|
|
100
|
+
for (let index = 0; index < this._data[identifier].length; index++) {
|
|
101
|
+
if (this._data[identifier][index].metaInfo.type === mtType) {
|
|
102
|
+
await this._data[identifier][index].tree.add(hindex, hvalue);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** bind merkle tree identifier in memory */
|
|
108
|
+
async bindMerkleTreeToNewIdentifier(oldIdentifier: string, newIdentifier: string): Promise<void> {
|
|
109
|
+
this._data[newIdentifier] = [...this._data[oldIdentifier]];
|
|
110
|
+
delete this._data[oldIdentifier];
|
|
111
|
+
|
|
112
|
+
this._data[newIdentifier].forEach((treeWithMeta) => {
|
|
113
|
+
treeWithMeta.metaInfo.identifier = newIdentifier;
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { CircuitId } from '../../circuits';
|
|
2
|
+
import { CircuitData } from '../entities/circuitData';
|
|
3
|
+
import { StorageErrors } from '../errors';
|
|
4
|
+
import { ICircuitStorage } from '../interfaces/circuits';
|
|
5
|
+
import { IDataSource } from '../interfaces/data-source';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Implementation of ICircuitStorage to store keys data
|
|
9
|
+
*
|
|
10
|
+
* @public
|
|
11
|
+
* @class CircuitStorage
|
|
12
|
+
* @implements implements ICircuitStorage interface
|
|
13
|
+
*/
|
|
14
|
+
export class CircuitStorage implements ICircuitStorage {
|
|
15
|
+
/**
|
|
16
|
+
* storage key for circuits
|
|
17
|
+
*/
|
|
18
|
+
static readonly storageKey = 'circuits';
|
|
19
|
+
/**
|
|
20
|
+
* Creates an instance of CircuitStorage.
|
|
21
|
+
* @param {IDataSource<CircuitData>} _dataSource - data source to store circuit keys
|
|
22
|
+
*/
|
|
23
|
+
constructor(private readonly _dataSource: IDataSource<CircuitData>) {}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* loads circuit data by id
|
|
27
|
+
* {@inheritdoc ICircuitStorage.loadCircuitData}
|
|
28
|
+
* @param {CircuitId} circuitId - id of the circuit
|
|
29
|
+
* @returns `Promise<CircuitData>`
|
|
30
|
+
*/
|
|
31
|
+
async loadCircuitData(circuitId: CircuitId): Promise<CircuitData> {
|
|
32
|
+
const circuitData = await this._dataSource.get(circuitId.toString(), 'circuitId');
|
|
33
|
+
if (!circuitData) {
|
|
34
|
+
throw new Error(`${StorageErrors.ItemNotFound}: ${circuitId}`);
|
|
35
|
+
}
|
|
36
|
+
return circuitData;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* {@inheritdoc ICircuitStorage.loadCircuitData}
|
|
41
|
+
* saves circuit data for circuit id
|
|
42
|
+
* @param {CircuitId} circuitId - id of the circuit
|
|
43
|
+
* @param {CircuitData} circuitData - circuit keys
|
|
44
|
+
* @returns `Promise<void>`
|
|
45
|
+
*/
|
|
46
|
+
async saveCircuitData(circuitId: CircuitId, circuitData: CircuitData): Promise<void> {
|
|
47
|
+
await this._dataSource.save(circuitId.toString(), circuitData, 'circuitId');
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { ProofQuery, W3CCredential } from '../../verifiable';
|
|
2
|
+
import { StandardJSONCredentialsQueryFilter } from '../filters';
|
|
3
|
+
import { ICredentialStorage } from '../interfaces/credentials';
|
|
4
|
+
import { IDataSource } from '../interfaces/data-source';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Implementation of ICredentialStorage with KV Data source
|
|
8
|
+
*
|
|
9
|
+
* @public
|
|
10
|
+
* @class CredentialStorage
|
|
11
|
+
* @implements {ICredentialStorage}
|
|
12
|
+
*/
|
|
13
|
+
export class CredentialStorage implements ICredentialStorage {
|
|
14
|
+
/**
|
|
15
|
+
* key for storage
|
|
16
|
+
*
|
|
17
|
+
* @static
|
|
18
|
+
*/
|
|
19
|
+
static readonly storageKey = 'credentials';
|
|
20
|
+
/**
|
|
21
|
+
* Creates an instance of CredentialStorage.
|
|
22
|
+
* @param {IDataSource<W3CCredential>} _dataSource - W3CCredential credential KV data source
|
|
23
|
+
*/
|
|
24
|
+
constructor(private readonly _dataSource: IDataSource<W3CCredential>) {}
|
|
25
|
+
|
|
26
|
+
/** {@inheritdoc ICredentialStorage.listCredentials } */
|
|
27
|
+
async listCredentials(): Promise<W3CCredential[]> {
|
|
28
|
+
const creds = await this._dataSource.load();
|
|
29
|
+
return creds.filter((i) => i !== undefined).map((cred) => cred && W3CCredential.fromJSON(cred));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** @inheritdoc */
|
|
33
|
+
async saveCredential(credential: W3CCredential): Promise<void> {
|
|
34
|
+
return this._dataSource.save(credential.id, credential.toJSON());
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** {@inheritdoc ICredentialStorage.listCredentials } */
|
|
38
|
+
async saveAllCredentials(credentials: W3CCredential[]): Promise<void> {
|
|
39
|
+
for (const credential of credentials) {
|
|
40
|
+
await this.saveCredential(credential);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** {@inheritdoc ICredentialStorage.listCredentials } */
|
|
45
|
+
async removeCredential(id: string): Promise<void> {
|
|
46
|
+
return this._dataSource.delete(id);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** {@inheritdoc ICredentialStorage.listCredentials } */
|
|
50
|
+
async findCredentialById(id: string): Promise<W3CCredential | undefined> {
|
|
51
|
+
const cred = await this._dataSource.get(id);
|
|
52
|
+
return cred && W3CCredential.fromJSON(cred);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** {@inheritdoc ICredentialStorage.listCredentials }
|
|
56
|
+
* uses JSON query
|
|
57
|
+
*/
|
|
58
|
+
async findCredentialsByQuery(query: ProofQuery): Promise<W3CCredential[]> {
|
|
59
|
+
const filters = StandardJSONCredentialsQueryFilter(query);
|
|
60
|
+
const creds = (await this._dataSource.load()).filter((credential) =>
|
|
61
|
+
filters.every((filter) => filter.execute(credential))
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
const mappedCreds = creds
|
|
65
|
+
.filter((i) => i !== undefined)
|
|
66
|
+
.map((cred) => W3CCredential.fromJSON(cred));
|
|
67
|
+
|
|
68
|
+
return mappedCreds;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Identity, Profile } from '../entities';
|
|
2
|
+
import { IDataSource } from '../interfaces/data-source';
|
|
3
|
+
import { IIdentityStorage } from '../interfaces/identity';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Implementation of the IIdentityStorage with KV data source
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
* @class IdentityStorage
|
|
10
|
+
* @implements implements IIdentityStorage interface
|
|
11
|
+
*/
|
|
12
|
+
export class IdentityStorage implements IIdentityStorage {
|
|
13
|
+
/**
|
|
14
|
+
* storage key for identities
|
|
15
|
+
*
|
|
16
|
+
* @static
|
|
17
|
+
*/
|
|
18
|
+
static readonly identitiesStorageKey = 'identities';
|
|
19
|
+
/**
|
|
20
|
+
* storage key for profiles
|
|
21
|
+
*
|
|
22
|
+
* @static
|
|
23
|
+
*/
|
|
24
|
+
static readonly profilesStorageKey = 'profiles';
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Creates an instance of IdentityStorage.
|
|
28
|
+
* @param {IDataSource<Identity>} _identityDataSource - data source for identities
|
|
29
|
+
* @param {IDataSource<Profile>} _profileDataSource - data source for profiles
|
|
30
|
+
*/
|
|
31
|
+
constructor(
|
|
32
|
+
private readonly _identityDataSource: IDataSource<Identity>,
|
|
33
|
+
private readonly _profileDataSource: IDataSource<Profile>
|
|
34
|
+
) {}
|
|
35
|
+
|
|
36
|
+
async saveProfile(profile: Profile): Promise<void> {
|
|
37
|
+
const profiles = await this._profileDataSource.load();
|
|
38
|
+
const identityProfiles = profiles.filter(
|
|
39
|
+
(p) => p.genesisIdentifier === profile.genesisIdentifier
|
|
40
|
+
);
|
|
41
|
+
const toSave = identityProfiles.length ? [...identityProfiles, profile] : [profile];
|
|
42
|
+
for (let index = 0; index < toSave.length; index++) {
|
|
43
|
+
const element = toSave[index];
|
|
44
|
+
await this._profileDataSource.save(element.id, element);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* @deprecated The method should not be used. It returns only one profile per verifier, which can potentially restrict business use cases
|
|
49
|
+
* Use getProfilesByVerifier instead.
|
|
50
|
+
*/
|
|
51
|
+
async getProfileByVerifier(verifier: string): Promise<Profile | undefined> {
|
|
52
|
+
return this._profileDataSource.get(verifier, 'verifier');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async getProfilesByVerifier(verifier: string, tags?: string[]): Promise<Profile[]> {
|
|
56
|
+
return (await this._profileDataSource.load()).filter(
|
|
57
|
+
(p) => p.verifier === verifier && (!tags || tags.every((tag) => p.tags?.includes(tag)))
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async getProfileById(profileId: string): Promise<Profile | undefined> {
|
|
62
|
+
return this._profileDataSource.get(profileId);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async getProfilesByGenesisIdentifier(genesisIdentifier: string): Promise<Profile[]> {
|
|
66
|
+
return (await this._profileDataSource.load()).filter(
|
|
67
|
+
(p) => p.genesisIdentifier === genesisIdentifier
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async getAllIdentities(): Promise<Identity[]> {
|
|
72
|
+
return this._identityDataSource.load();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async saveIdentity(identity: Identity): Promise<void> {
|
|
76
|
+
return this._identityDataSource.save(identity.did, identity, 'did');
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async getIdentity(identifier: string): Promise<Identity | undefined> {
|
|
80
|
+
return this._identityDataSource.get(identifier, 'did');
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { IdentityMerkleTreeMetaInformation, MerkleTreeType } from './entities';
|
|
2
|
+
|
|
3
|
+
export const MERKLE_TREE_TYPES: MerkleTreeType[] = [
|
|
4
|
+
MerkleTreeType.Claims,
|
|
5
|
+
MerkleTreeType.Revocations,
|
|
6
|
+
MerkleTreeType.Roots
|
|
7
|
+
];
|
|
8
|
+
|
|
9
|
+
export const createMerkleTreeMetaInfo = (
|
|
10
|
+
identifier: string
|
|
11
|
+
): IdentityMerkleTreeMetaInformation[] => {
|
|
12
|
+
const treesMeta: IdentityMerkleTreeMetaInformation[] = [];
|
|
13
|
+
for (let index = 0; index < MERKLE_TREE_TYPES.length; index++) {
|
|
14
|
+
const mType = MERKLE_TREE_TYPES[index];
|
|
15
|
+
const treeId = `${identifier}+${mType}`;
|
|
16
|
+
treesMeta.push({ treeId, identifier, type: mType });
|
|
17
|
+
}
|
|
18
|
+
return treesMeta;
|
|
19
|
+
};
|