From e62945caab48a44f30e7afb2656751bd935d239e Mon Sep 17 00:00:00 2001 From: iFergal Date: Tue, 27 Aug 2024 12:23:12 +0100 Subject: [PATCH 1/7] fix: send exn to actual recipient only --- src/keri/app/exchanging.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/keri/app/exchanging.ts b/src/keri/app/exchanging.ts index cb9f9e4b..a77b9dd4 100644 --- a/src/keri/app/exchanging.ts +++ b/src/keri/app/exchanging.ts @@ -93,7 +93,7 @@ export class Exchanges { exn, sigs, atc, - recipients + [recipient] ); } } From f0762b6de127912a76da7e73f90c8544441f41e6 Mon Sep 17 00:00:00 2001 From: iFergal Date: Tue, 27 Aug 2024 12:31:26 +0100 Subject: [PATCH 2/7] refactor: prettier run --- src/keri/app/exchanging.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/keri/app/exchanging.ts b/src/keri/app/exchanging.ts index a77b9dd4..e4ef02fa 100644 --- a/src/keri/app/exchanging.ts +++ b/src/keri/app/exchanging.ts @@ -87,14 +87,9 @@ export class Exchanges { embeds, recipient ); - return await this.sendFromEvents( - name, - topic, - exn, - sigs, - atc, - [recipient] - ); + return await this.sendFromEvents(name, topic, exn, sigs, atc, [ + recipient, + ]); } } From 8dd1fad424cdd754d7bef9c763b1e49bd9f2bc11 Mon Sep 17 00:00:00 2001 From: iFergal Date: Tue, 27 Aug 2024 12:31:56 +0100 Subject: [PATCH 3/7] fix: vulnerability in dep --- package-lock.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 183e2dda..c0c5d42e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7572,12 +7572,12 @@ ] }, "node_modules/micromatch": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", - "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", "dev": true, "dependencies": { - "braces": "^3.0.2", + "braces": "^3.0.3", "picomatch": "^2.3.1" }, "engines": { From 93e4586e052bb53fd1d0d23a608b6d62c0fcfba4 Mon Sep 17 00:00:00 2001 From: iFergal Date: Tue, 27 Aug 2024 13:47:33 +0100 Subject: [PATCH 4/7] fix: don't return early in exchanges.send --- examples/integration-scripts/multisig-holder.test.ts | 10 +++++----- examples/integration-scripts/multisig.test.ts | 8 ++++---- src/keri/app/contacting.ts | 2 +- src/keri/app/exchanging.ts | 8 ++++---- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/examples/integration-scripts/multisig-holder.test.ts b/examples/integration-scripts/multisig-holder.test.ts index 8d1939af..1f155743 100644 --- a/examples/integration-scripts/multisig-holder.test.ts +++ b/examples/integration-scripts/multisig-holder.test.ts @@ -162,7 +162,7 @@ test('multisig', async function run() { rpy: [rpy, atc], }; let recp = [aid2['state']].map((state) => state['i']); - let res = await client1 + await client1 .exchanges() .send( 'member1', @@ -182,7 +182,7 @@ test('multisig', async function run() { console.log( 'Member2 received exchange message to join the end role authorization' ); - res = await client2.groups().getRequest(msgSaid); + let res = await client2.groups().getRequest(msgSaid); let exn = res[0].exn; // stamp, eid and role are provided in the exn message let rpystamp = exn.e.rpy.dt; @@ -215,7 +215,7 @@ test('multisig', async function run() { rpy: [rpy, atc], }; recp = [aid1['state']].map((state) => state['i']); - res = await client2 + await client2 .exchanges() .send( 'member2', @@ -262,7 +262,7 @@ test('multisig', async function run() { rpy: [rpy, atc], }; recp = [aid2['state']].map((state) => state['i']); - res = await client1 + await client1 .exchanges() .send( 'member1', @@ -316,7 +316,7 @@ test('multisig', async function run() { rpy: [rpy, atc], }; recp = [aid1['state']].map((state) => state['i']); - res = await client2 + await client2 .exchanges() .send( 'member2', diff --git a/examples/integration-scripts/multisig.test.ts b/examples/integration-scripts/multisig.test.ts index 723ac04b..5d0fa21d 100644 --- a/examples/integration-scripts/multisig.test.ts +++ b/examples/integration-scripts/multisig.test.ts @@ -334,7 +334,7 @@ test('multisig', async function run() { rpy: [rpy, atc], }; recp = [aid2['state'], aid3['state']].map((state) => state['i']); - res = await client1 + await client1 .exchanges() .send( 'member1', @@ -382,7 +382,7 @@ test('multisig', async function run() { rpy: [rpy, atc], }; recp = [aid1['state'], aid3['state']].map((state) => state['i']); - res = await client2 + await client2 .exchanges() .send( 'member2', @@ -429,7 +429,7 @@ test('multisig', async function run() { rpy: [rpy, atc], }; recp = [aid1['state'], aid2['state']].map((state) => state['i']); - res = await client3 + await client3 .exchanges() .send( 'member3', @@ -770,7 +770,7 @@ test('multisig', async function run() { }; recp = [aid2['state'], aid3['state']].map((state) => state['i']); - res = await client1 + await client1 .exchanges() .send( 'member1', diff --git a/src/keri/app/contacting.ts b/src/keri/app/contacting.ts index ef31beb4..9119abdf 100644 --- a/src/keri/app/contacting.ts +++ b/src/keri/app/contacting.ts @@ -149,7 +149,7 @@ export class Challenges { {}, [recipient] ); - return resp; + return resp[0]; // Only one recipient } /** diff --git a/src/keri/app/exchanging.ts b/src/keri/app/exchanging.ts index e4ef02fa..de39378b 100644 --- a/src/keri/app/exchanging.ts +++ b/src/keri/app/exchanging.ts @@ -78,8 +78,8 @@ export class Exchanges { payload: Dict, embeds: Dict, recipients: string[] - ): Promise { - for (const recipient of recipients) { + ): Promise { + return recipients.map(async (recipient) => { const [exn, sigs, atc] = await this.createExchangeMessage( sender, route, @@ -87,10 +87,10 @@ export class Exchanges { embeds, recipient ); - return await this.sendFromEvents(name, topic, exn, sigs, atc, [ + return this.sendFromEvents(name, topic, exn, sigs, atc, [ recipient, ]); - } + }); } /** From 000fd573c3c6624249f5f5884b4c8fd0735115c4 Mon Sep 17 00:00:00 2001 From: iFergal Date: Tue, 27 Aug 2024 13:47:55 +0100 Subject: [PATCH 5/7] refactor: prettier run --- src/keri/app/contacting.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/keri/app/contacting.ts b/src/keri/app/contacting.ts index 9119abdf..f9d52c83 100644 --- a/src/keri/app/contacting.ts +++ b/src/keri/app/contacting.ts @@ -149,7 +149,7 @@ export class Challenges { {}, [recipient] ); - return resp[0]; // Only one recipient + return resp[0]; // Only one recipient } /** From ff4c0ad1de0cf6ef689cb4a9b9596500a878e1c3 Mon Sep 17 00:00:00 2001 From: iFergal Date: Tue, 27 Aug 2024 15:21:44 +0100 Subject: [PATCH 6/7] fix: await sends --- src/keri/app/exchanging.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/keri/app/exchanging.ts b/src/keri/app/exchanging.ts index de39378b..4605c188 100644 --- a/src/keri/app/exchanging.ts +++ b/src/keri/app/exchanging.ts @@ -79,7 +79,8 @@ export class Exchanges { embeds: Dict, recipients: string[] ): Promise { - return recipients.map(async (recipient) => { + const responses: any[] = []; + for (const recipient of recipients) { const [exn, sigs, atc] = await this.createExchangeMessage( sender, route, @@ -87,10 +88,11 @@ export class Exchanges { embeds, recipient ); - return this.sendFromEvents(name, topic, exn, sigs, atc, [ + responses.push(await this.sendFromEvents(name, topic, exn, sigs, atc, [ recipient, - ]); - }); + ])); + }; + return responses; } /** From 02f178a81c3b2b8328c469b38f6426fea64fcf41 Mon Sep 17 00:00:00 2001 From: iFergal Date: Tue, 27 Aug 2024 15:22:56 +0100 Subject: [PATCH 7/7] refactor: prettier --- src/keri/app/exchanging.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/keri/app/exchanging.ts b/src/keri/app/exchanging.ts index 4605c188..db46b88e 100644 --- a/src/keri/app/exchanging.ts +++ b/src/keri/app/exchanging.ts @@ -88,10 +88,12 @@ export class Exchanges { embeds, recipient ); - responses.push(await this.sendFromEvents(name, topic, exn, sigs, atc, [ - recipient, - ])); - }; + responses.push( + await this.sendFromEvents(name, topic, exn, sigs, atc, [ + recipient, + ]) + ); + } return responses; }