diff --git a/agents/node/vcxagent-core/demo/alice.js b/agents/node/vcxagent-core/demo/alice.js index 47101d5a0b..497ff6d27c 100644 --- a/agents/node/vcxagent-core/demo/alice.js +++ b/agents/node/vcxagent-core/demo/alice.js @@ -61,9 +61,9 @@ async function runAlice (options) { } logger.info('Connection to alice was Accepted!') - await vcxAgent.serviceCredHolder.waitForCredentialOfferAndAcceptAndProgress({ connectionId, holderCredentialId }) + await vcxAgent.serviceCredHolder.waitForCredentialOfferAndAcceptAndProgress(connectionId, holderCredentialId) - const proofRequest = (await vcxAgent.serviceProver.waitForProofRequests({ connectionId }))[0] + const proofRequest = (await vcxAgent.serviceProver.waitForProofRequests(connectionId))[0] if (!proofRequest) { throw Error('No proof request found.') } diff --git a/agents/node/vcxagent-core/demo/faber.js b/agents/node/vcxagent-core/demo/faber.js index e22d093a0e..fb7c2895a9 100644 --- a/agents/node/vcxagent-core/demo/faber.js +++ b/agents/node/vcxagent-core/demo/faber.js @@ -69,7 +69,8 @@ async function runFaber (options) { }) logger.info('Faber is going to send credential offer') - await vcxAgent.serviceCredIssuer.sendOfferAndCredential({ issuerCredId, connectionId, credDefId, schemaAttrs: getAliceSchemaAttrs() }) + const schemaAttrs = getAliceSchemaAttrs() + await vcxAgent.serviceCredIssuer.sendOfferAndCredential(issuerCredId, connectionId, credDefId, schemaAttrs) if (options.revocation) { await vcxAgent.serviceCredIssuer.revokeCredential(issuerCredId) } diff --git a/agents/node/vcxagent-core/src/agent/service-cred-holder.js b/agents/node/vcxagent-core/src/agent/service-cred-holder.js index c3d4a87e1e..dcc4b06c54 100644 --- a/agents/node/vcxagent-core/src/agent/service-cred-holder.js +++ b/agents/node/vcxagent-core/src/agent/service-cred-holder.js @@ -33,7 +33,7 @@ module.exports.createServiceCredHolder = function createServiceCredHolder (logge return offers } - async function _progressCredentialToState (credential, connection, credentialStateTarget, attemptsThreshold, timeoutMs) { + async function _progressCredentialToState (credential, connection, credentialStateTarget, attemptsThreshold = 10, timeoutMs = 2000) { async function progressToAcceptedState () { if (await credential.updateStateV2(connection) !== credentialStateTarget) { return { result: undefined, isFinished: false } @@ -48,7 +48,7 @@ module.exports.createServiceCredHolder = function createServiceCredHolder (logge } } - async function waitForCredential (connectionId, holderCredentialId, attemptsThreshold, timeoutMs) { + async function waitForCredential (connectionId, holderCredentialId, attemptsThreshold = 10, timeoutMs = 2000) { const connSerializedBefore = await loadConnection(connectionId) const connection = await Connection.deserialize(connSerializedBefore) @@ -93,7 +93,7 @@ module.exports.createServiceCredHolder = function createServiceCredHolder (logge return credential } - async function waitForCredentialOffer (connectionId, credOfferFilter, attemptsThreshold, timeoutMs) { + async function waitForCredentialOffer (connectionId, credOfferFilter = null, attemptsThreshold = 10, timeoutMs = 2000) { logger.info('Going to try fetch credential offer and receive credential.') const connSerializedBefore = await loadConnection(connectionId) const connection = await Connection.deserialize(connSerializedBefore) @@ -107,14 +107,14 @@ module.exports.createServiceCredHolder = function createServiceCredHolder (logge return pickedOffer } - async function waitForCredentialOfferAndAccept ({ connectionId, holderCredentialId, credOfferFilter, attemptsThreshold = 10, timeoutMs = 2000 }) { + async function waitForCredentialOfferAndAccept (connectionId, holderCredentialId, credOfferFilter = null, attemptsThreshold = 10, timeoutMs = 2000) { const pickedOffer = await waitForCredentialOffer(connectionId, credOfferFilter, attemptsThreshold, timeoutMs) return createCredentialFromOfferAndSendRequest(connectionId, holderCredentialId, pickedOffer) } - async function waitForCredentialOfferAndAcceptAndProgress ({ connectionId, holderCredentialId, credOfferFilter, attemptsThreshold = 10, timeoutMs = 2000 }) { + async function waitForCredentialOfferAndAcceptAndProgress (connectionId, holderCredentialId, credOfferFilter = null, attemptsThreshold = 10, timeoutMs = 2000) { logger.info('Going to try fetch credential offer and receive credential.') - await waitForCredentialOfferAndAccept({ connectionId, holderCredentialId, credOfferFilter, attemptsThreshold, timeoutMs }) + await waitForCredentialOfferAndAccept(connectionId, holderCredentialId, credOfferFilter, attemptsThreshold, timeoutMs) return waitForCredential(connectionId, holderCredentialId, attemptsThreshold, timeoutMs) } diff --git a/agents/node/vcxagent-core/src/agent/service-cred-issuer.js b/agents/node/vcxagent-core/src/agent/service-cred-issuer.js index 3b18a93909..fa5925cda1 100644 --- a/agents/node/vcxagent-core/src/agent/service-cred-issuer.js +++ b/agents/node/vcxagent-core/src/agent/service-cred-issuer.js @@ -8,7 +8,7 @@ const { pollFunction } = require('../common') module.exports.createServiceCredIssuer = function createServiceCredIssuer (logger, loadConnection, loadCredDef, storeIssuerCredential, loadIssuerCredential, listIssuerCredentialIds) { // Creates issuer credential, sends offer - async function sendOffer ({ issuerCredId, connectionId, credDefId, schemaAttrs }) { + async function sendOffer (issuerCredId, connectionId, credDefId, schemaAttrs) { logger.debug(`sendOffer >> issuerCredId=${issuerCredId} schemaAttrs=${schemaAttrs} credDefId=${credDefId} connectionId=${connectionId}`) const serConnection = await loadConnection(connectionId) const credDefSerialized = await loadCredDef(credDefId) @@ -45,7 +45,7 @@ module.exports.createServiceCredIssuer = function createServiceCredIssuer (logge } // Assuming issuer credential is in state Requested, tries to send the actual credential - async function sendCredential ({ issuerCredId, connectionId }) { + async function sendCredential (issuerCredId, connectionId) { logger.debug('sendCredential >> ') const serConnection = await loadConnection(connectionId) const connection = await Connection.deserialize(serConnection) @@ -65,9 +65,9 @@ module.exports.createServiceCredIssuer = function createServiceCredIssuer (logge } // Creates issuer credential, sends offer and waits to receive credential request - async function sendOfferAndWaitForCredRequest ({ issuerCredId, connectionId, credDefId, schemaAttrs }) { + async function sendOfferAndWaitForCredRequest (issuerCredId, connectionId, credDefId, schemaAttrs) { logger.debug('sendOfferAndWaitForCredRequest >> ') - const issuerCred = await sendOffer({ issuerCredId, schemaAttrs, credDefId, connectionId }) + const issuerCred = await sendOffer(issuerCredId, connectionId, credDefId, schemaAttrs) logger.debug('Going to wait until credential request is received.') const serConnection = await loadConnection(connectionId) @@ -81,9 +81,9 @@ module.exports.createServiceCredIssuer = function createServiceCredIssuer (logge } // Assuming issuer credential is in state "Requested", sends credential and wait to receive Ack - async function sendCredentialAndProgress ({ issuerCredId, connectionId }) { + async function sendCredentialAndProgress (issuerCredId, connectionId) { logger.debug('sendCredentialAndProgress >> ') - await sendCredential({ issuerCredId, connectionId }) + await sendCredential(issuerCredId, connectionId) const serConnection = await loadConnection(connectionId) const connection = await Connection.deserialize(serConnection) @@ -101,10 +101,10 @@ module.exports.createServiceCredIssuer = function createServiceCredIssuer (logge } // Creates issuer credential, sends offer and waits to receive credential request, then sends credential - async function sendOfferAndCredential ({ issuerCredId, connectionId, credDefId, schemaAttrs }) { + async function sendOfferAndCredential (issuerCredId, connectionId, credDefId, schemaAttrs) { logger.debug('sendOfferAndCredential >> ') - await sendOfferAndWaitForCredRequest({ issuerCredId, connectionId, credDefId, schemaAttrs }) - await sendCredentialAndProgress({ issuerCredId, connectionId }) + await sendOfferAndWaitForCredRequest(issuerCredId, connectionId, credDefId, schemaAttrs) + await sendCredentialAndProgress(issuerCredId, connectionId) } // Assuming the credential has been issued, tries to revoke the credential on ledger diff --git a/agents/node/vcxagent-core/src/agent/service-prover.js b/agents/node/vcxagent-core/src/agent/service-prover.js index b9f2188e72..558f56d6e5 100644 --- a/agents/node/vcxagent-core/src/agent/service-prover.js +++ b/agents/node/vcxagent-core/src/agent/service-prover.js @@ -43,7 +43,7 @@ module.exports.createServiceProver = function createServiceProver (logger, loadC return proofRequests } - async function waitForProofRequests ({ connectionId, attemptsThreshold = 10, timeoutMs = 2000 }) { + async function waitForProofRequests (connectionId, attemptsThreshold = 10, timeoutMs = 2000) { const connSerializedBefore = await loadConnection(connectionId) const connection = await Connection.deserialize(connSerializedBefore) diff --git a/agents/node/vcxagent-core/src/agent/service-verifier.js b/agents/node/vcxagent-core/src/agent/service-verifier.js index 3c5046978c..a75e54819b 100644 --- a/agents/node/vcxagent-core/src/agent/service-verifier.js +++ b/agents/node/vcxagent-core/src/agent/service-verifier.js @@ -5,7 +5,7 @@ const { const sleep = require('sleep-promise') module.exports.createServiceVerifier = function createServiceVerifier (logger, loadConnection, storeProof, loadProof, listProofIds) { - async function createProof ({ proofId, proofData }) { + async function createProof (proofId, proofData) { logger.info(`Verifier creating proof ${proofId}, proofData=${JSON.stringify(proofData)}`) await sleep(1000) const proof = await Proof.create(proofData) diff --git a/agents/node/vcxagent-core/test/utils/alice.js b/agents/node/vcxagent-core/test/utils/alice.js index 3900e64ac4..685275d181 100644 --- a/agents/node/vcxagent-core/test/utils/alice.js +++ b/agents/node/vcxagent-core/test/utils/alice.js @@ -45,7 +45,7 @@ module.exports.createAlice = async function createAlice () { await vcxAgent.agentInitVcx() logger.info('Alice accepting creadential offer') - await vcxAgent.serviceCredHolder.waitForCredentialOfferAndAccept({ connectionId, holderCredentialId }) + await vcxAgent.serviceCredHolder.waitForCredentialOfferAndAccept(connectionId, holderCredentialId) await vcxAgent.agentShutdownVcx() } diff --git a/agents/node/vcxagent-core/test/utils/faber.js b/agents/node/vcxagent-core/test/utils/faber.js index f4d95d695e..13bdf0f037 100644 --- a/agents/node/vcxagent-core/test/utils/faber.js +++ b/agents/node/vcxagent-core/test/utils/faber.js @@ -67,7 +67,7 @@ module.exports.createFaber = async function createFaber () { logger.info('Faber sending credential to Alice') const schemaAttrs = getAliceSchemaAttrs() const credDefId = getFaberCredDefName() - await vcxAgent.serviceCredIssuer.sendOffer({ issuerCredId, connectionId, credDefId, schemaAttrs }) + await vcxAgent.serviceCredIssuer.sendOffer(issuerCredId, connectionId, credDefId, schemaAttrs) await vcxAgent.agentShutdownVcx() } @@ -95,7 +95,7 @@ module.exports.createFaber = async function createFaber () { await vcxAgent.agentInitVcx() logger.info('Issuer sending credential') - expect(await vcxAgent.serviceCredIssuer.sendCredential({ issuerCredId, connectionId })).toBe(StateType.Accepted) + expect(await vcxAgent.serviceCredIssuer.sendCredential(issuerCredId, connectionId)).toBe(StateType.Accepted) logger.info('Credential sent') await vcxAgent.agentShutdownVcx() @@ -106,7 +106,7 @@ module.exports.createFaber = async function createFaber () { await vcxAgent.agentInitVcx() const issuerDid = vcxAgent.getInstitutionDid() const proofData = getFaberProofData(issuerDid, proofId) - await vcxAgent.serviceVerifier.createProof({ proofId, proofData }) + await vcxAgent.serviceVerifier.createProof(proofId, proofData) const { state, proofRequestMessage } = await vcxAgent.serviceVerifier.sendProofRequest(connectionId, proofId) expect(state).toBe(StateType.OfferSent) await vcxAgent.agentShutdownVcx()