diff --git a/src/circuits/verifiers/query.ts b/src/circuits/verifiers/query.ts index 964c1e6c..3e90f14c 100644 --- a/src/circuits/verifiers/query.ts +++ b/src/circuits/verifiers/query.ts @@ -100,10 +100,7 @@ export async function checkQueryRequest( // validate selective disclosure if (cq.isSelectiveDisclosure) { try { - if (!verifiablePresentation) { - throw new Error(`no vp present in selective disclosure request`); - } - await validateDisclosure(verifiablePresentation, cq, outputs, schemaLoader); + await validateDisclosure(cq, outputs,verifiablePresentation, schemaLoader); } catch (e) { throw new Error(`failed to validate selective disclosure: ${(e as Error).message}`); } @@ -262,9 +259,9 @@ async function validateOperators(cq: CircuitQuery, outputs: ClaimOutputs) { } async function validateDisclosure( - verifiablePresentation: JSON, cq: CircuitQuery, outputs: ClaimOutputs, + verifiablePresentation?: JSON, ldLoader?: DocumentLoader ) { if (!verifiablePresentation) { @@ -322,8 +319,6 @@ async function validateDisclosure( if (bi !== outputs.value[0]) { throw new Error(`value that was used is not equal to requested in query`); } - - return; } async function parsePredicate( diff --git a/src/iden3comm/handlers/auth.ts b/src/iden3comm/handlers/auth.ts index e6600d80..68af50d1 100644 --- a/src/iden3comm/handlers/auth.ts +++ b/src/iden3comm/handlers/auth.ts @@ -18,7 +18,6 @@ import * as uuid from 'uuid'; import { ProofQuery, RevocationStatus, W3CCredential } from '../../verifiable'; import { byteDecoder, byteEncoder, mergeObjects } from '../../utils'; import { getRandomBytes } from '@iden3/js-crypto'; -import { CircuitId } from '../../circuits'; import { PROTOCOL_CONSTANTS } from '..'; /** @@ -403,7 +402,7 @@ export class AuthHandler implements IAuthHandler { } } - return Promise.resolve({ request, response }); + return { request, response }; } private verifyAuthRequest(request: AuthorizationRequestMessage) { diff --git a/src/storage/blockchain/state.ts b/src/storage/blockchain/state.ts index a4fc5f3b..0136bcd8 100644 --- a/src/storage/blockchain/state.ts +++ b/src/storage/blockchain/state.ts @@ -68,7 +68,7 @@ export class EthStateStorage implements IStateStorage { } /** {@inheritdoc IStateStorage.getLatestStateById} */ - async getLatestStateById(id: Id | bigint): Promise { + async getLatestStateById(id: bigint): Promise { const { stateContract } = this._getStateContractAndProviderForId(id); const rawData = await stateContract.getStateInfoById(id); const stateInfo: StateInfo = { @@ -85,7 +85,7 @@ export class EthStateStorage implements IStateStorage { } /** {@inheritdoc IStateStorage.getStateInfoByIdAndState} */ - async getStateInfoByIdAndState(id: Id | bigint, state: bigint): Promise { + async getStateInfoByIdAndState(id: bigint, state: bigint): Promise { const { stateContract } = this._getStateContractAndProviderForId(id); const rawData = await stateContract.getStateInfoByIdAndState(id, state); const stateInfo: StateInfo = { @@ -161,7 +161,7 @@ export class EthStateStorage implements IStateStorage { } /** {@inheritdoc IStateStorage.getGISTProof} */ - async getGISTProof(id: Id | bigint): Promise { + async getGISTProof(id: bigint): Promise { const { stateContract } = this._getStateContractAndProviderForId(id); const data = await stateContract.getGISTProof(id); @@ -181,7 +181,7 @@ export class EthStateStorage implements IStateStorage { } /** {@inheritdoc IStateStorage.getGISTRootInfo} */ - async getGISTRootInfo(id: Id | bigint): Promise { + async getGISTRootInfo(id: bigint): Promise { const { stateContract } = this._getStateContractAndProviderForId(id); const data = await stateContract.getGISTRootInfo(id); @@ -195,11 +195,11 @@ export class EthStateStorage implements IStateStorage { }; } - private _getStateContractAndProviderForId(id: Id | bigint): { + private _getStateContractAndProviderForId(id: bigint): { stateContract: Contract; provider: JsonRpcProvider; } { - id = typeof id === 'bigint' ? Id.fromBigInt(id as bigint) : id; + const idTyped = Id.fromBigInt(id as bigint); if (!Array.isArray(this.ethConfig)) { return { stateContract: this.stateContract, @@ -207,7 +207,7 @@ export class EthStateStorage implements IStateStorage { }; } - const chainId = getChainId(DID.blockchainFromId(id), DID.networkIdFromId(id)); + const chainId = getChainId(DID.blockchainFromId(idTyped), DID.networkIdFromId(idTyped)); const config = this._networkByChainId(chainId); const provider = new JsonRpcProvider(config.url);