@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,520 @@
|
|
|
1
|
+
import { MediaType } from '../constants';
|
|
2
|
+
import { IProofService } from '../../proof/proof-service';
|
|
3
|
+
import { PROTOCOL_MESSAGE_TYPE } from '../constants';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
StateVerificationOpts,
|
|
7
|
+
AuthorizationRequestMessage,
|
|
8
|
+
AuthorizationResponseMessage,
|
|
9
|
+
BasicMessage,
|
|
10
|
+
IPackageManager,
|
|
11
|
+
JWSPackerParams,
|
|
12
|
+
ZeroKnowledgeProofRequest,
|
|
13
|
+
JSONObject,
|
|
14
|
+
Attachment
|
|
15
|
+
} from '../types';
|
|
16
|
+
import { DID, getUnixTimestamp } from '@mocanetwork/moca-iden3';
|
|
17
|
+
import { proving } from '@iden3/js-jwz';
|
|
18
|
+
|
|
19
|
+
import * as uuid from 'uuid';
|
|
20
|
+
import { ProofQuery } from '../../verifiable';
|
|
21
|
+
import { byteDecoder, byteEncoder } from '../../utils';
|
|
22
|
+
import { processZeroKnowledgeProofRequests, verifyExpiresTime } from './common';
|
|
23
|
+
import { CircuitId } from '../../circuits';
|
|
24
|
+
import {
|
|
25
|
+
AbstractMessageHandler,
|
|
26
|
+
BasicHandlerOptions,
|
|
27
|
+
IProtocolMessageHandler
|
|
28
|
+
} from './message-handler';
|
|
29
|
+
import { parseAcceptProfile } from '../utils';
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Options to pass to createAuthorizationRequest function
|
|
33
|
+
* @public
|
|
34
|
+
*/
|
|
35
|
+
export type AuthorizationRequestCreateOptions = {
|
|
36
|
+
accept?: string[];
|
|
37
|
+
scope?: ZeroKnowledgeProofRequest[];
|
|
38
|
+
expires_time?: Date;
|
|
39
|
+
attachments?: Attachment[];
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* createAuthorizationRequest is a function to create protocol authorization request
|
|
44
|
+
* @param {string} reason - reason to request proof
|
|
45
|
+
* @param {string} sender - sender did
|
|
46
|
+
* @param {string} callbackUrl - callback that user should use to send response
|
|
47
|
+
* @param {AuthorizationRequestCreateOptions} opts - authorization request options
|
|
48
|
+
* @returns `Promise<AuthorizationRequestMessage>`
|
|
49
|
+
*/
|
|
50
|
+
export function createAuthorizationRequest(
|
|
51
|
+
reason: string,
|
|
52
|
+
sender: string,
|
|
53
|
+
callbackUrl: string,
|
|
54
|
+
opts?: AuthorizationRequestCreateOptions
|
|
55
|
+
): AuthorizationRequestMessage {
|
|
56
|
+
return createAuthorizationRequestWithMessage(reason, '', sender, callbackUrl, opts);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* createAuthorizationRequestWithMessage is a function to create protocol authorization request with explicit message to sign
|
|
60
|
+
* @param {string} reason - reason to request proof
|
|
61
|
+
* @param {string} message - message to sign in the response
|
|
62
|
+
* @param {string} sender - sender did
|
|
63
|
+
* @param {string} callbackUrl - callback that user should use to send response
|
|
64
|
+
* @param {AuthorizationRequestCreateOptions} opts - authorization request options
|
|
65
|
+
* @returns `Promise<AuthorizationRequestMessage>`
|
|
66
|
+
*/
|
|
67
|
+
export function createAuthorizationRequestWithMessage(
|
|
68
|
+
reason: string,
|
|
69
|
+
message: string,
|
|
70
|
+
sender: string,
|
|
71
|
+
callbackUrl: string,
|
|
72
|
+
opts?: AuthorizationRequestCreateOptions
|
|
73
|
+
): AuthorizationRequestMessage {
|
|
74
|
+
const uuidv4 = uuid.v4();
|
|
75
|
+
const request: AuthorizationRequestMessage = {
|
|
76
|
+
id: uuidv4,
|
|
77
|
+
thid: uuidv4,
|
|
78
|
+
from: sender,
|
|
79
|
+
typ: MediaType.PlainMessage,
|
|
80
|
+
type: PROTOCOL_MESSAGE_TYPE.AUTHORIZATION_REQUEST_MESSAGE_TYPE,
|
|
81
|
+
body: {
|
|
82
|
+
accept: opts?.accept,
|
|
83
|
+
reason: reason,
|
|
84
|
+
message: message,
|
|
85
|
+
callbackUrl: callbackUrl,
|
|
86
|
+
scope: opts?.scope ?? []
|
|
87
|
+
},
|
|
88
|
+
created_time: getUnixTimestamp(new Date()),
|
|
89
|
+
expires_time: opts?.expires_time ? getUnixTimestamp(opts.expires_time) : undefined,
|
|
90
|
+
attachments: opts?.attachments
|
|
91
|
+
};
|
|
92
|
+
return request;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
*
|
|
97
|
+
* Options to pass to auth response handler
|
|
98
|
+
*
|
|
99
|
+
* @public
|
|
100
|
+
*/
|
|
101
|
+
export type AuthResponseHandlerOptions = StateVerificationOpts &
|
|
102
|
+
BasicHandlerOptions & {
|
|
103
|
+
// acceptedProofGenerationDelay is the period of time in milliseconds that a generated proof remains valid.
|
|
104
|
+
acceptedProofGenerationDelay?: number;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Interface that allows the processing of the authorization request in the raw format for given identifier
|
|
109
|
+
*
|
|
110
|
+
* @public
|
|
111
|
+
* @interface IAuthHandler
|
|
112
|
+
*/
|
|
113
|
+
export interface IAuthHandler {
|
|
114
|
+
/**
|
|
115
|
+
* unpacks authorization request
|
|
116
|
+
* @public
|
|
117
|
+
* @param {Uint8Array} request - raw byte message
|
|
118
|
+
* @returns `Promise<AuthorizationRequestMessage>`
|
|
119
|
+
*/
|
|
120
|
+
parseAuthorizationRequest(request: Uint8Array): Promise<AuthorizationRequestMessage>;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* unpacks authorization request
|
|
124
|
+
* @public
|
|
125
|
+
* @param {did} did - sender DID
|
|
126
|
+
* @param {Uint8Array} request - raw byte message
|
|
127
|
+
* @returns `Promise<{
|
|
128
|
+
token: string;
|
|
129
|
+
authRequest: AuthorizationRequestMessage;
|
|
130
|
+
authResponse: AuthorizationResponseMessage;
|
|
131
|
+
}>`
|
|
132
|
+
*/
|
|
133
|
+
handleAuthorizationRequest(
|
|
134
|
+
did: DID,
|
|
135
|
+
request: Uint8Array,
|
|
136
|
+
opts?: AuthHandlerOptions
|
|
137
|
+
): Promise<{
|
|
138
|
+
token: string;
|
|
139
|
+
authRequest: AuthorizationRequestMessage;
|
|
140
|
+
authResponse: AuthorizationResponseMessage;
|
|
141
|
+
}>;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* handle authorization response
|
|
145
|
+
* @public
|
|
146
|
+
* @param {AuthorizationResponseMessage} response - auth response
|
|
147
|
+
* @param {AuthorizationRequestMessage} request - auth request
|
|
148
|
+
* @param {AuthResponseHandlerOptions} opts - options
|
|
149
|
+
* @returns `Promise<{
|
|
150
|
+
request: AuthorizationRequestMessage;
|
|
151
|
+
response: AuthorizationResponseMessage;
|
|
152
|
+
}>`
|
|
153
|
+
*/
|
|
154
|
+
handleAuthorizationResponse(
|
|
155
|
+
response: AuthorizationResponseMessage,
|
|
156
|
+
request: AuthorizationRequestMessage,
|
|
157
|
+
opts?: AuthResponseHandlerOptions
|
|
158
|
+
): Promise<{
|
|
159
|
+
request: AuthorizationRequestMessage;
|
|
160
|
+
response: AuthorizationResponseMessage;
|
|
161
|
+
}>;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
type AuthReqOptions = {
|
|
165
|
+
senderDid: DID;
|
|
166
|
+
mediaType?: MediaType;
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
type AuthRespOptions = {
|
|
170
|
+
request: AuthorizationRequestMessage;
|
|
171
|
+
acceptedStateTransitionDelay?: number;
|
|
172
|
+
acceptedProofGenerationDelay?: number;
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
export type AuthMessageHandlerOptions = AuthReqOptions | AuthRespOptions;
|
|
176
|
+
/**
|
|
177
|
+
*
|
|
178
|
+
* Options to pass to auth handler
|
|
179
|
+
*
|
|
180
|
+
* @public
|
|
181
|
+
* @interface AuthHandlerOptions
|
|
182
|
+
*/
|
|
183
|
+
export type AuthHandlerOptions = BasicHandlerOptions & {
|
|
184
|
+
mediaType: MediaType;
|
|
185
|
+
packerOptions?: JWSPackerParams;
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
*
|
|
190
|
+
* Allows to process AuthorizationRequest protocol message and produce JWZ response.
|
|
191
|
+
*
|
|
192
|
+
* @public
|
|
193
|
+
|
|
194
|
+
* @class AuthHandler
|
|
195
|
+
* @implements implements IAuthHandler interface
|
|
196
|
+
*/
|
|
197
|
+
export class AuthHandler
|
|
198
|
+
extends AbstractMessageHandler
|
|
199
|
+
implements IAuthHandler, IProtocolMessageHandler
|
|
200
|
+
{
|
|
201
|
+
private readonly _supportedCircuits = [
|
|
202
|
+
CircuitId.AtomicQueryV3,
|
|
203
|
+
CircuitId.AtomicQuerySigV2,
|
|
204
|
+
CircuitId.AtomicQueryMTPV2,
|
|
205
|
+
CircuitId.LinkedMultiQuery10
|
|
206
|
+
];
|
|
207
|
+
/**
|
|
208
|
+
* Creates an instance of AuthHandler.
|
|
209
|
+
* @param {IPackageManager} _packerMgr - package manager to unpack message envelope
|
|
210
|
+
* @param {IProofService} _proofService - proof service to verify zk proofs
|
|
211
|
+
*
|
|
212
|
+
*/
|
|
213
|
+
constructor(
|
|
214
|
+
private readonly _packerMgr: IPackageManager,
|
|
215
|
+
private readonly _proofService: IProofService
|
|
216
|
+
) {
|
|
217
|
+
super();
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
handle(message: BasicMessage, ctx: AuthMessageHandlerOptions): Promise<BasicMessage | null> {
|
|
221
|
+
switch (message.type) {
|
|
222
|
+
case PROTOCOL_MESSAGE_TYPE.AUTHORIZATION_REQUEST_MESSAGE_TYPE:
|
|
223
|
+
return this.handleAuthRequest(
|
|
224
|
+
message as AuthorizationRequestMessage,
|
|
225
|
+
ctx as AuthReqOptions
|
|
226
|
+
);
|
|
227
|
+
case PROTOCOL_MESSAGE_TYPE.AUTHORIZATION_RESPONSE_MESSAGE_TYPE:
|
|
228
|
+
return this.handleAuthResponse(
|
|
229
|
+
message as AuthorizationResponseMessage,
|
|
230
|
+
ctx as AuthRespOptions
|
|
231
|
+
);
|
|
232
|
+
default:
|
|
233
|
+
return super.handle(message, ctx);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* @inheritdoc IAuthHandler#parseAuthorizationRequest
|
|
239
|
+
*/
|
|
240
|
+
async parseAuthorizationRequest(request: Uint8Array): Promise<AuthorizationRequestMessage> {
|
|
241
|
+
const { unpackedMessage: message } = await this._packerMgr.unpack(request);
|
|
242
|
+
const authRequest = message as unknown as AuthorizationRequestMessage;
|
|
243
|
+
if (message.type !== PROTOCOL_MESSAGE_TYPE.AUTHORIZATION_REQUEST_MESSAGE_TYPE) {
|
|
244
|
+
throw new Error('Invalid media type');
|
|
245
|
+
}
|
|
246
|
+
authRequest.body.scope = authRequest.body.scope || [];
|
|
247
|
+
return authRequest;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
private async handleAuthRequest(
|
|
251
|
+
authRequest: AuthorizationRequestMessage,
|
|
252
|
+
ctx: AuthReqOptions
|
|
253
|
+
): Promise<AuthorizationResponseMessage> {
|
|
254
|
+
if (authRequest.type !== PROTOCOL_MESSAGE_TYPE.AUTHORIZATION_REQUEST_MESSAGE_TYPE) {
|
|
255
|
+
throw new Error('Invalid message type for authorization request');
|
|
256
|
+
}
|
|
257
|
+
// override sender did if it's explicitly specified in the auth request
|
|
258
|
+
const to = authRequest.to ? DID.parse(authRequest.to) : ctx.senderDid;
|
|
259
|
+
const guid = uuid.v4();
|
|
260
|
+
|
|
261
|
+
if (!authRequest.from) {
|
|
262
|
+
throw new Error('auth request should contain from field');
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
const responseType = PROTOCOL_MESSAGE_TYPE.AUTHORIZATION_RESPONSE_MESSAGE_TYPE;
|
|
266
|
+
const mediaType = this.getSupportedMediaTypeByProfile(
|
|
267
|
+
ctx,
|
|
268
|
+
responseType,
|
|
269
|
+
authRequest.body.accept
|
|
270
|
+
);
|
|
271
|
+
const from = DID.parse(authRequest.from);
|
|
272
|
+
|
|
273
|
+
const responseScope = await processZeroKnowledgeProofRequests(
|
|
274
|
+
to,
|
|
275
|
+
authRequest?.body.scope,
|
|
276
|
+
from,
|
|
277
|
+
this._proofService,
|
|
278
|
+
{ mediaType, supportedCircuits: this._supportedCircuits }
|
|
279
|
+
);
|
|
280
|
+
|
|
281
|
+
return {
|
|
282
|
+
id: guid,
|
|
283
|
+
typ: mediaType,
|
|
284
|
+
type: responseType,
|
|
285
|
+
thid: authRequest.thid ?? guid,
|
|
286
|
+
body: {
|
|
287
|
+
message: authRequest?.body?.message,
|
|
288
|
+
scope: responseScope
|
|
289
|
+
},
|
|
290
|
+
from: to.string(),
|
|
291
|
+
to: authRequest.from
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* @inheritdoc IAuthHandler#handleAuthorizationRequest
|
|
297
|
+
*/
|
|
298
|
+
async handleAuthorizationRequest(
|
|
299
|
+
did: DID,
|
|
300
|
+
request: Uint8Array,
|
|
301
|
+
opts?: AuthHandlerOptions
|
|
302
|
+
): Promise<{
|
|
303
|
+
token: string;
|
|
304
|
+
authRequest: AuthorizationRequestMessage;
|
|
305
|
+
authResponse: AuthorizationResponseMessage;
|
|
306
|
+
}> {
|
|
307
|
+
const authRequest = await this.parseAuthorizationRequest(request);
|
|
308
|
+
if (!opts?.allowExpiredMessages) {
|
|
309
|
+
verifyExpiresTime(authRequest);
|
|
310
|
+
}
|
|
311
|
+
if (!opts) {
|
|
312
|
+
opts = {
|
|
313
|
+
mediaType: MediaType.ZKPMessage
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
if (opts.mediaType === MediaType.SignedMessage && !opts.packerOptions) {
|
|
318
|
+
throw new Error(`jws packer options are required for ${MediaType.SignedMessage}`);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
const authResponse = await this.handleAuthRequest(authRequest, {
|
|
322
|
+
senderDid: did,
|
|
323
|
+
mediaType: opts.mediaType
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
const msgBytes = byteEncoder.encode(JSON.stringify(authResponse));
|
|
327
|
+
|
|
328
|
+
const packerOpts =
|
|
329
|
+
opts.mediaType === MediaType.SignedMessage
|
|
330
|
+
? opts.packerOptions
|
|
331
|
+
: {
|
|
332
|
+
provingMethodAlg: proving.provingMethodGroth16AuthV2Instance.methodAlg
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
const token = byteDecoder.decode(
|
|
336
|
+
await this._packerMgr.pack(opts.mediaType, msgBytes, {
|
|
337
|
+
senderDID: did,
|
|
338
|
+
...packerOpts
|
|
339
|
+
})
|
|
340
|
+
);
|
|
341
|
+
|
|
342
|
+
return { authRequest, authResponse, token };
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
private async handleAuthResponse(
|
|
346
|
+
response: AuthorizationResponseMessage,
|
|
347
|
+
ctx: AuthRespOptions
|
|
348
|
+
): Promise<BasicMessage | null> {
|
|
349
|
+
const request = ctx.request;
|
|
350
|
+
if (response.type !== PROTOCOL_MESSAGE_TYPE.AUTHORIZATION_RESPONSE_MESSAGE_TYPE) {
|
|
351
|
+
throw new Error('Invalid message type for authorization response');
|
|
352
|
+
}
|
|
353
|
+
if ((request.body.message ?? '') !== (response.body.message ?? '')) {
|
|
354
|
+
throw new Error('message for signing from request is not presented in response');
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
if (request.from !== response.to) {
|
|
358
|
+
throw new Error(
|
|
359
|
+
`sender of the request is not a target of response - expected ${request.from}, given ${response.to}`
|
|
360
|
+
);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
this.verifyAuthRequest(request);
|
|
364
|
+
const requestScope = request.body.scope || [];
|
|
365
|
+
const responseScope = response.body.scope || [];
|
|
366
|
+
|
|
367
|
+
if (!response.from) {
|
|
368
|
+
throw new Error(`proof response doesn't contain from field`);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
const groupIdToLinkIdMap = new Map<number, { linkID: number; requestId: number | string }[]>();
|
|
372
|
+
// group requests by query group id
|
|
373
|
+
for (const proofRequest of requestScope) {
|
|
374
|
+
const groupId = proofRequest.query.groupId as number;
|
|
375
|
+
|
|
376
|
+
const proofResp = responseScope.find(
|
|
377
|
+
(resp) => resp.id.toString() === proofRequest.id.toString()
|
|
378
|
+
);
|
|
379
|
+
if (!proofResp) {
|
|
380
|
+
throw new Error(`proof is not given for requestId ${proofRequest.id}`);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
const circuitId = proofResp.circuitId;
|
|
384
|
+
if (circuitId !== proofRequest.circuitId) {
|
|
385
|
+
throw new Error(
|
|
386
|
+
`proof is not given for requested circuit expected: ${proofRequest.circuitId}, given ${circuitId}`
|
|
387
|
+
);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
const params: JSONObject = proofRequest.params ?? {};
|
|
391
|
+
params.verifierDid = DID.parse(request.from);
|
|
392
|
+
|
|
393
|
+
const opts = [ctx.acceptedProofGenerationDelay, ctx.acceptedStateTransitionDelay].some(
|
|
394
|
+
(delay) => delay !== undefined
|
|
395
|
+
)
|
|
396
|
+
? {
|
|
397
|
+
acceptedProofGenerationDelay: ctx.acceptedProofGenerationDelay,
|
|
398
|
+
acceptedStateTransitionDelay: ctx.acceptedStateTransitionDelay
|
|
399
|
+
}
|
|
400
|
+
: undefined;
|
|
401
|
+
|
|
402
|
+
const { linkID } = await this._proofService.verifyZKPResponse(proofResp, {
|
|
403
|
+
query: proofRequest.query as unknown as ProofQuery,
|
|
404
|
+
sender: response.from,
|
|
405
|
+
params,
|
|
406
|
+
opts
|
|
407
|
+
});
|
|
408
|
+
// write linkId to the proof response
|
|
409
|
+
// const pubSig = pubSignals as unknown as { linkID?: number };
|
|
410
|
+
|
|
411
|
+
if (linkID && groupId) {
|
|
412
|
+
groupIdToLinkIdMap.set(groupId, [
|
|
413
|
+
...(groupIdToLinkIdMap.get(groupId) ?? []),
|
|
414
|
+
{ linkID: linkID, requestId: proofResp.id }
|
|
415
|
+
]);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
// verify grouping links
|
|
420
|
+
for (const [groupId, metas] of groupIdToLinkIdMap.entries()) {
|
|
421
|
+
// check that all linkIds are the same
|
|
422
|
+
if (metas.some((meta) => meta.linkID !== metas[0].linkID)) {
|
|
423
|
+
throw new Error(
|
|
424
|
+
`Link id validation failed for group ${groupId}, request linkID to requestIds info: ${JSON.stringify(
|
|
425
|
+
metas
|
|
426
|
+
)}`
|
|
427
|
+
);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
return response;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* @inheritdoc IAuthHandler#handleAuthorizationResponse
|
|
436
|
+
*/
|
|
437
|
+
async handleAuthorizationResponse(
|
|
438
|
+
response: AuthorizationResponseMessage,
|
|
439
|
+
request: AuthorizationRequestMessage,
|
|
440
|
+
opts?: AuthResponseHandlerOptions | undefined
|
|
441
|
+
): Promise<{
|
|
442
|
+
request: AuthorizationRequestMessage;
|
|
443
|
+
response: AuthorizationResponseMessage;
|
|
444
|
+
}> {
|
|
445
|
+
if (!opts?.allowExpiredMessages) {
|
|
446
|
+
verifyExpiresTime(response);
|
|
447
|
+
}
|
|
448
|
+
const authResp = (await this.handleAuthResponse(response, {
|
|
449
|
+
request,
|
|
450
|
+
acceptedStateTransitionDelay: opts?.acceptedStateTransitionDelay,
|
|
451
|
+
acceptedProofGenerationDelay: opts?.acceptedProofGenerationDelay
|
|
452
|
+
})) as AuthorizationResponseMessage;
|
|
453
|
+
|
|
454
|
+
return { request, response: authResp };
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
private verifyAuthRequest(request: AuthorizationRequestMessage) {
|
|
458
|
+
const groupIdValidationMap: { [k: string]: ZeroKnowledgeProofRequest[] } = {};
|
|
459
|
+
const requestScope = request.body.scope || [];
|
|
460
|
+
for (const proofRequest of requestScope) {
|
|
461
|
+
const groupId = proofRequest.query.groupId as number;
|
|
462
|
+
if (groupId) {
|
|
463
|
+
const existingRequests = groupIdValidationMap[groupId] ?? [];
|
|
464
|
+
|
|
465
|
+
//validate that all requests in the group have the same schema, issuer and circuit
|
|
466
|
+
for (const existingRequest of existingRequests) {
|
|
467
|
+
if (existingRequest.query.type !== proofRequest.query.type) {
|
|
468
|
+
throw new Error(`all requests in the group should have the same type`);
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
if (existingRequest.query.context !== proofRequest.query.context) {
|
|
472
|
+
throw new Error(`all requests in the group should have the same context`);
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
const allowedIssuers = proofRequest.query.allowedIssuers as string[];
|
|
476
|
+
const existingRequestAllowedIssuers = existingRequest.query.allowedIssuers as string[];
|
|
477
|
+
if (
|
|
478
|
+
!(
|
|
479
|
+
allowedIssuers.includes('*') ||
|
|
480
|
+
allowedIssuers.every((issuer) => existingRequestAllowedIssuers.includes(issuer))
|
|
481
|
+
)
|
|
482
|
+
) {
|
|
483
|
+
throw new Error(`all requests in the group should have the same issuer`);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
groupIdValidationMap[groupId] = [...(groupIdValidationMap[groupId] ?? []), proofRequest];
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
private getSupportedMediaTypeByProfile(
|
|
492
|
+
ctx: AuthReqOptions,
|
|
493
|
+
responseType: string,
|
|
494
|
+
profile?: string[] | undefined
|
|
495
|
+
): MediaType {
|
|
496
|
+
let mediaType: MediaType;
|
|
497
|
+
if (!profile?.length) {
|
|
498
|
+
return ctx.mediaType || MediaType.ZKPMessage;
|
|
499
|
+
}
|
|
500
|
+
const supportedMediaTypes: MediaType[] = [];
|
|
501
|
+
for (const acceptProfile of profile) {
|
|
502
|
+
const { env } = parseAcceptProfile(acceptProfile);
|
|
503
|
+
if (this._packerMgr.isProfileSupported(env, acceptProfile)) {
|
|
504
|
+
supportedMediaTypes.push(env);
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
if (!supportedMediaTypes.length) {
|
|
509
|
+
throw new Error('no packer with profile which meets `accept` header requirements');
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
mediaType = supportedMediaTypes.includes(MediaType.ZKPMessage)
|
|
513
|
+
? MediaType.ZKPMessage
|
|
514
|
+
: supportedMediaTypes[0];
|
|
515
|
+
if (ctx.mediaType && supportedMediaTypes.includes(ctx.mediaType)) {
|
|
516
|
+
mediaType = ctx.mediaType;
|
|
517
|
+
}
|
|
518
|
+
return mediaType;
|
|
519
|
+
}
|
|
520
|
+
}
|