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 diff --git a/examples/integration-scripts/test-setup-single-client.test.ts b/examples/integration-scripts/test-setup-single-client.test.ts index fecf61c7..bd957743 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,32 @@ describe('test-setup-single-client', () => { break; } }); + + test('validate config', async () => { + const env = resolveEnvironment(); + const config = await client.config().get(); + 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; + } + }); }); 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..1325b945 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(); + const lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length - 1]!; + assert.equal(lastCall[0]!, url + '/config'); + assert.equal(lastCall[1]!.method, 'GET'); + }); }); describe('Operations', () => {