From 9e7a0e43a64abeff8423c87f89899704021b873d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9cio=20Varj=C3=A3o?= <1348549+cvarjao@users.noreply.github.com> Date: Tue, 29 Oct 2024 16:51:36 -0700 Subject: [PATCH] support for didexchange and conenction reuse MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Clécio Varjão <1348549+cvarjao@users.noreply.github.com> --- src/AgentCredo.ts | 3 +++ src/AgentTraction.ts | 13 ++++++++----- src/attestation.test.ts | 6 +++--- src/basic.test.ts | 2 +- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/AgentCredo.ts b/src/AgentCredo.ts index e8cd98d..1038b49 100644 --- a/src/AgentCredo.ts +++ b/src/AgentCredo.ts @@ -136,6 +136,7 @@ export const createAgent = async ( //console.log(`Mediator URL:${config.mediatorInvitationUrl}`) //const wallet = agent.dependencyManager.resolve(InjectionSymbols.Wallet) as AskarWallet //console.dir(wallet) + /* try { fs.rmSync(path.join(homedir(), ".afj"), { recursive: true, @@ -152,6 +153,7 @@ export const createAgent = async ( } catch (error) { console.log(error); } + */ console.dir(agentConfig.walletConfig); /* try { @@ -301,6 +303,7 @@ export class AgentCredo implements AriesAgent { } = await this.agent.oob.receiveInvitation(invitation, { autoAcceptInvitation: true, autoAcceptConnection: true, + reuseConnection: true, }); const invitationRequestsThreadIds = outOfBandRecord.getTags().invitationRequestsThreadIds; diff --git a/src/AgentTraction.ts b/src/AgentTraction.ts index 58f777f..e5cc7ef 100644 --- a/src/AgentTraction.ts +++ b/src/AgentTraction.ts @@ -531,6 +531,11 @@ export class AgentTraction implements AriesAgent { "my_label":`Faber\`s 😇 - ${new Date().getTime()}`, "handshake_protocols": [invitationType.substring(6)], } + const params = { + "auto_accept": true, + "multi_use": false, + "create_unique_did": false, + } if (invitationType === INVITATION_TYPE.OOB_DIDX_1_1){ Object.assign(payload, { "protocol_version":"1.1", @@ -538,11 +543,7 @@ export class AgentTraction implements AriesAgent { }) } return http.post(`/out-of-band/create-invitation`,payload, { - params: { - "auto_accept": true, - "multi_use": false, - "create_unique_did": false, - }, + params: params, headers:{ 'Content-Type': 'application/json', 'Authorization': `Bearer ${config.auth_token}` @@ -582,6 +583,8 @@ export class AgentTraction implements AriesAgent { return this.__createInvitationToConnectConnV1() as Promise> case INVITATION_TYPE.OOB_CONN_1_0: return this.createOOBInvitationToConnect(invitationType) as Promise> + case INVITATION_TYPE.OOB_DIDX_1_1: + return this.createOOBInvitationToConnect(invitationType) as Promise> default: throw new Error("Invalid invitation type"); } diff --git a/src/attestation.test.ts b/src/attestation.test.ts index e108fbb..c1dba88 100644 --- a/src/attestation.test.ts +++ b/src/attestation.test.ts @@ -31,12 +31,12 @@ describe("AppAttestation", () => { const _logger = pino({ level: 'trace', timestamp: pino.stdTimeFunctions.isoTime, }, loggerTransport); const logger = new PinoLogger(_logger, LogLevel.trace) // eslint-disable-next-line @typescript-eslint/no-var-requires - const config = require("../local.env.json")["sovrin_testnet"]; + const config = require("../local.env.json"); // eslint-disable-next-line @typescript-eslint/no-var-requires const ledgers = require("../ledgers.json"); - const agentA = new AgentTraction(config, logger); + const agentA = new AgentTraction(config.issuer, logger); //const agentB: AriesAgent = new AgentManual(config, new ConsoleLogger(LogLevel.trace)) - const agentB: AriesAgent = process.env.HOLDER_TYPE === 'manual' ? new AgentManual(config, logger) : new AgentCredo(config, ledgers, logger) + const agentB: AriesAgent = process.env.HOLDER_TYPE === 'manual' ? new AgentManual(config.holder, logger) : new AgentCredo(config.holder, ledgers, logger) //new PinoLogger(logger, LogLevel.trace)); const schema = new SchemaBuilder().setName('app_attestation').setVersion('1.0').setSchemaId('NXp6XcGeCR2MviWuY51Dva:2:app_attestation:1.0') const credDef = new CredentialDefinitionBuilder() diff --git a/src/basic.test.ts b/src/basic.test.ts index 1705526..d197905 100644 --- a/src/basic.test.ts +++ b/src/basic.test.ts @@ -94,7 +94,7 @@ describe("Mandatory", () => { logger.info('Message Received:', msgRcvd) //expect(requests).toMatchSnapshot(); }, shortTimeout); - test.skip("OOB/connected/messaging", async () => { + test("OOB/connected/messaging", async () => { const issuer = agentIssuer const holder = agentB logger.info(`Executing ${expect.getState().currentTestName}`)