From 0cbfbca64a0f15e4060dbd4d9030a621962fda0c Mon Sep 17 00:00:00 2001 From: iFergal Date: Fri, 8 Nov 2024 18:24:38 -0300 Subject: [PATCH 1/5] feat: agent config interface --- .../test-setup-single-client.test.ts | 15 ++++++++++++ src/keri/app/clienting.ts | 10 +++++++- src/keri/app/coring.ts | 23 +++++++++++++++++++ test/app/coring.test.ts | 17 ++++++++++++++ 4 files changed, 64 insertions(+), 1 deletion(-) diff --git a/examples/integration-scripts/test-setup-single-client.test.ts b/examples/integration-scripts/test-setup-single-client.test.ts index fecf61c7..a382cb27 100644 --- a/examples/integration-scripts/test-setup-single-client.test.ts +++ b/examples/integration-scripts/test-setup-single-client.test.ts @@ -27,6 +27,7 @@ describe('test-setup-single-client', () => { 'EB3UGWwIMq7ppzcQ697ImQIuXlBG5jzh-baSx-YG3-tY' ); }); + test('step2', async () => { const env = resolveEnvironment(); const oobi = await client.oobis().get('name1', 'witness'); @@ -62,4 +63,18 @@ describe('test-setup-single-client', () => { break; } }); + + test('validate config', async () => { + const config = await client.config().get(); + expect(config).toEqual({ + iurls: [ + 'http://witness-demo:5642/oobi/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha/controller', + 'http://witness-demo:5643/oobi/BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM/controller', + 'http://witness-demo:5644/oobi/BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX/controller', + 'http://witness-demo:5645/oobi/BM35JN8XeJSEfpxopjn5jr7tAHCE5749f0OobhMLCorE/controller', + 'http://witness-demo:5646/oobi/BIj15u5V11bkbtAxMA7gcNJZcax-7TgaBMLsQnMHpYHP/controller', + 'http://witness-demo:5647/oobi/BF2rZTW79z4IXocYRQnjjsOuvFUQv-ptCf8Yltd7PfsM/controller', + ], + }); + }); }); diff --git a/src/keri/app/clienting.ts b/src/keri/app/clienting.ts index 9da24ecd..df1d7356 100644 --- a/src/keri/app/clienting.ts +++ b/src/keri/app/clienting.ts @@ -6,7 +6,7 @@ import { Tier } from '../core/salter'; import { Identifier } from './aiding'; import { Contacts, Challenges } from './contacting'; import { Agent, Controller } from './controller'; -import { Oobis, Operations, KeyEvents, KeyStates } from './coring'; +import { Oobis, Operations, KeyEvents, KeyStates, Config } from './coring'; import { Credentials, Ipex, Registries, Schemas } from './credentialing'; import { Delegations } from './delegating'; import { Escrows } from './escrowing'; @@ -478,4 +478,12 @@ export class SignifyClient { delegations(): Delegations { return new Delegations(this); } + + /** + * Get agent config resource + * @returns {Config} + */ + config(): Config { + return new Config(this); + } } diff --git a/src/keri/app/coring.ts b/src/keri/app/coring.ts index fd5a1161..9a0eb3f9 100644 --- a/src/keri/app/coring.ts +++ b/src/keri/app/coring.ts @@ -81,6 +81,10 @@ export interface OperationsDeps { ): Promise; } +export interface AgentConfig { + iurls?: string[]; +} + /** * Operations * @remarks @@ -278,3 +282,22 @@ export class KeyStates { return await res.json(); } } + +export class Config { + public client: SignifyClient; + + /** + * Config + * @param {SignifyClient} client + */ + constructor(client: SignifyClient) { + this.client = client; + } + + async get(): Promise { + const path = `/config`; + const method = 'GET'; + const res = await this.client.fetch(path, method, null); + return await res.json(); + } +} diff --git a/test/app/coring.test.ts b/test/app/coring.test.ts index f25c8be0..a20e3a45 100644 --- a/test/app/coring.test.ts +++ b/test/app/coring.test.ts @@ -267,6 +267,23 @@ describe('Coring', () => { 'EBfdlu8R27Fbx-ehrqwImnK-8Cm79sqbAQ4MmvEAYqao' ); }); + + it('Agent configuration', async () => { + await libsodium.ready; + const bran = '0123456789abcdefghijk'; + + const client = new SignifyClient(url, bran, Tier.low, boot_url); + + await client.boot(); + await client.connect(); + + const config = client.config(); + + await config.get(); + let lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length - 1]!; + assert.equal(lastCall[0]!, url + '/config'); + assert.equal(lastCall[1]!.method, 'GET'); + }); }); describe('Operations', () => { From 19c542ff7309bedf449ee8511c1629c372151bbb Mon Sep 17 00:00:00 2001 From: iFergal Date: Fri, 8 Nov 2024 18:36:03 -0300 Subject: [PATCH 2/5] test: linting --- test/app/coring.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/app/coring.test.ts b/test/app/coring.test.ts index a20e3a45..1325b945 100644 --- a/test/app/coring.test.ts +++ b/test/app/coring.test.ts @@ -280,7 +280,7 @@ describe('Coring', () => { const config = client.config(); await config.get(); - let lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length - 1]!; + const lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length - 1]!; assert.equal(lastCall[0]!, url + '/config'); assert.equal(lastCall[1]!.method, 'GET'); }); From 0659422efdb4868c3718d2c9e97492e7ee4bae2d Mon Sep 17 00:00:00 2001 From: iFergal Date: Mon, 18 Nov 2024 17:27:04 -0300 Subject: [PATCH 3/5] test: local config iurls [skip ci] --- .../test-setup-single-client.test.ts | 34 +++++++++++++------ 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/examples/integration-scripts/test-setup-single-client.test.ts b/examples/integration-scripts/test-setup-single-client.test.ts index a382cb27..7e544493 100644 --- a/examples/integration-scripts/test-setup-single-client.test.ts +++ b/examples/integration-scripts/test-setup-single-client.test.ts @@ -65,16 +65,30 @@ describe('test-setup-single-client', () => { }); test('validate config', async () => { + const env = resolveEnvironment(); const config = await client.config().get(); - expect(config).toEqual({ - iurls: [ - 'http://witness-demo:5642/oobi/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha/controller', - 'http://witness-demo:5643/oobi/BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM/controller', - 'http://witness-demo:5644/oobi/BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX/controller', - 'http://witness-demo:5645/oobi/BM35JN8XeJSEfpxopjn5jr7tAHCE5749f0OobhMLCorE/controller', - 'http://witness-demo:5646/oobi/BIj15u5V11bkbtAxMA7gcNJZcax-7TgaBMLsQnMHpYHP/controller', - 'http://witness-demo:5647/oobi/BF2rZTW79z4IXocYRQnjjsOuvFUQv-ptCf8Yltd7PfsM/controller', - ], - }); + switch (env.preset) { + case 'local': + expect(config).toEqual({ + iurls: [ + 'http://127.0.0.1:5642/oobi/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha/controller?name=Wan&tag=witness', + 'http://127.0.0.1:5643/oobi/BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM/controller?name=Wes&tag=witness', + 'http://127.0.0.1:5644/oobi/BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX/controller?name=Wil&tag=witness' + ] + }); + break; + case 'docker': + expect(config).toEqual({ + iurls: [ + 'http://witness-demo:5642/oobi/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha/controller', + 'http://witness-demo:5643/oobi/BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM/controller', + 'http://witness-demo:5644/oobi/BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX/controller', + 'http://witness-demo:5645/oobi/BM35JN8XeJSEfpxopjn5jr7tAHCE5749f0OobhMLCorE/controller', + 'http://witness-demo:5646/oobi/BIj15u5V11bkbtAxMA7gcNJZcax-7TgaBMLsQnMHpYHP/controller', + 'http://witness-demo:5647/oobi/BF2rZTW79z4IXocYRQnjjsOuvFUQv-ptCf8Yltd7PfsM/controller', + ], + }); + break; + } }); }); From eb9ec9e4d67ee26024b9d0fec8f8459474701925 Mon Sep 17 00:00:00 2001 From: iFergal Date: Mon, 18 Nov 2024 17:47:46 -0300 Subject: [PATCH 4/5] build: dev5 keria --- .github/workflows/main.yml | 2 +- docker-compose.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 382c0b6e..c7509258 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -57,7 +57,7 @@ jobs: strategy: matrix: os: ['ubuntu-latest'] - keria-version: ['0.2.0-dev4'] + keria-version: ['0.2.0-dev5'] node-version: ['20'] env: KERIA_IMAGE_TAG: ${{ matrix.keria-version }} diff --git a/docker-compose.yaml b/docker-compose.yaml index 38fd0261..cfc5416f 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -26,7 +26,7 @@ services: - 7723:7723 keria: - image: ${KERIA_IMAGE:-weboftrust/keria}:${KERIA_IMAGE_TAG:-0.2.0-dev4} + image: ${KERIA_IMAGE:-weboftrust/keria}:${KERIA_IMAGE_TAG:-0.2.0-dev5} environment: - KERI_AGENT_CORS=1 - KERI_URL=http://keria:3902 From cba180b3649bcd8b43f4d5bdedd9e148d974d4b8 Mon Sep 17 00:00:00 2001 From: iFergal Date: Mon, 18 Nov 2024 17:48:41 -0300 Subject: [PATCH 5/5] prettier --- examples/integration-scripts/test-setup-single-client.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/integration-scripts/test-setup-single-client.test.ts b/examples/integration-scripts/test-setup-single-client.test.ts index 7e544493..bd957743 100644 --- a/examples/integration-scripts/test-setup-single-client.test.ts +++ b/examples/integration-scripts/test-setup-single-client.test.ts @@ -73,8 +73,8 @@ describe('test-setup-single-client', () => { iurls: [ 'http://127.0.0.1:5642/oobi/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha/controller?name=Wan&tag=witness', 'http://127.0.0.1:5643/oobi/BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM/controller?name=Wes&tag=witness', - 'http://127.0.0.1:5644/oobi/BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX/controller?name=Wil&tag=witness' - ] + 'http://127.0.0.1:5644/oobi/BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX/controller?name=Wil&tag=witness', + ], }); break; case 'docker':