From e032084342cffa3b45cc0ee0e53379cc4da741e4 Mon Sep 17 00:00:00 2001 From: iFergal Date: Fri, 11 Oct 2024 15:53:08 +0100 Subject: [PATCH 1/7] feat: get credential registry state (tever vcstate) --- .../integration-scripts/credentials.test.ts | 11 ++++++- src/keri/app/credentialing.ts | 31 +++++++++++++++++++ src/keri/core/core.ts | 2 ++ test/app/credentialing.test.ts | 8 +++++ 4 files changed, 51 insertions(+), 1 deletion(-) diff --git a/examples/integration-scripts/credentials.test.ts b/examples/integration-scripts/credentials.test.ts index 3ae1f6d4..67c24e91 100644 --- a/examples/integration-scripts/credentials.test.ts +++ b/examples/integration-scripts/credentials.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'assert'; -import { Saider, Serder, SignifyClient } from 'signify-ts'; +import { Ilks, Saider, Serder, SignifyClient } from 'signify-ts'; import { resolveEnvironment } from './utils/resolve-env'; import { assertNotifications, @@ -248,6 +248,15 @@ test('single signature credentials', async () => { await waitOperation(issuerClient, op); }); + await step('holder can get the credential status before or without holding', async () => { + const state = await retry(async () => + holderClient.credentials().state(registry.regk, qviCredentialId) + ); + assert.equal(state.i, qviCredentialId); + assert.equal(state.ri, registry.regk); + assert.equal(state.et, Ilks.iss); + }); + await step('holder IPEX admit', async () => { const holderNotifications = await waitForNotifications( holderClient, diff --git a/src/keri/app/credentialing.ts b/src/keri/app/credentialing.ts index a13ddba3..15a34b89 100644 --- a/src/keri/app/credentialing.ts +++ b/src/keri/app/credentialing.ts @@ -229,6 +229,23 @@ export interface IpexAdmitArgs { datetime?: string; } +export type CredentialState = { + vn: [number, number], + i: string, + s: string, + d: string, + ri: string, + a: { s: number, d: string }, + dt: string, + et: string +} & ({ + et: "iss" | "rev", + ra: Record +} | { + et: "bis" | "brv", + ra: { i: string, s: string, d: string } +}); + /** * Credentials */ @@ -285,6 +302,20 @@ export class Credentials { return includeCESR ? await res.text() : await res.json(); } + /** + * Get the state of a credential + * @async + * @param {string} ri - management registry identifier + * @param {string} said - SAID of the credential + * @returns {Promise} A promise to the credential registry state + */ + async state(ri: string, said: string): Promise { + const path = `/registries/${ri}/${said}`; + const method = "GET"; + const res = await this.client.fetch(path, method, null); + return res.json(); + } + /** * Issue a credential */ diff --git a/src/keri/core/core.ts b/src/keri/core/core.ts index 6d4d148f..0494a5fa 100644 --- a/src/keri/core/core.ts +++ b/src/keri/core/core.ts @@ -32,6 +32,8 @@ export const Ilks = { vcp: 'vcp', iss: 'iss', rev: 'rev', + bis: 'bis', + brv: 'brv' }; export const IcpLabels = [ diff --git a/test/app/credentialing.test.ts b/test/app/credentialing.test.ts index 99f36dcc..a124050e 100644 --- a/test/app/credentialing.test.ts +++ b/test/app/credentialing.test.ts @@ -368,6 +368,14 @@ describe('Credentialing', () => { lastBody.recipient, 'EP10ooRj0DJF0HWZePEYMLPl-arMV-MAoTKK-o3DXbgX' ); + + await credentials.state("EACehJRd0wfteUAJgaTTJjMSaQqWvzeeHqAMMqxuqxU4", "EBVaw6pCqfMIiZGkA6qevzRUGsxTRuZXxl6YG1neeCGF"); + lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length - 1]!; + assert.equal( + lastCall[0]!, + url + "/registries/EACehJRd0wfteUAJgaTTJjMSaQqWvzeeHqAMMqxuqxU4/EBVaw6pCqfMIiZGkA6qevzRUGsxTRuZXxl6YG1neeCGF" + ); + assert.equal(lastCall[1]!.method, "GET"); }); }); From 63ce7ca215499e90c9c5726dfa38e8ad4ac4013e Mon Sep 17 00:00:00 2001 From: iFergal Date: Fri, 11 Oct 2024 15:59:23 +0100 Subject: [PATCH 2/7] refactor: prettier run --- .../integration-scripts/credentials.test.ts | 19 +++++----- src/keri/app/credentialing.ts | 35 ++++++++++--------- src/keri/core/core.ts | 2 +- test/app/credentialing.test.ts | 10 ++++-- 4 files changed, 38 insertions(+), 28 deletions(-) diff --git a/examples/integration-scripts/credentials.test.ts b/examples/integration-scripts/credentials.test.ts index 67c24e91..e9dc4174 100644 --- a/examples/integration-scripts/credentials.test.ts +++ b/examples/integration-scripts/credentials.test.ts @@ -248,14 +248,17 @@ test('single signature credentials', async () => { await waitOperation(issuerClient, op); }); - await step('holder can get the credential status before or without holding', async () => { - const state = await retry(async () => - holderClient.credentials().state(registry.regk, qviCredentialId) - ); - assert.equal(state.i, qviCredentialId); - assert.equal(state.ri, registry.regk); - assert.equal(state.et, Ilks.iss); - }); + await step( + 'holder can get the credential status before or without holding', + async () => { + const state = await retry(async () => + holderClient.credentials().state(registry.regk, qviCredentialId) + ); + assert.equal(state.i, qviCredentialId); + assert.equal(state.ri, registry.regk); + assert.equal(state.et, Ilks.iss); + } + ); await step('holder IPEX admit', async () => { const holderNotifications = await waitForNotifications( diff --git a/src/keri/app/credentialing.ts b/src/keri/app/credentialing.ts index 15a34b89..3b731bb3 100644 --- a/src/keri/app/credentialing.ts +++ b/src/keri/app/credentialing.ts @@ -230,21 +230,24 @@ export interface IpexAdmitArgs { } export type CredentialState = { - vn: [number, number], - i: string, - s: string, - d: string, - ri: string, - a: { s: number, d: string }, - dt: string, - et: string -} & ({ - et: "iss" | "rev", - ra: Record -} | { - et: "bis" | "brv", - ra: { i: string, s: string, d: string } -}); + vn: [number, number]; + i: string; + s: string; + d: string; + ri: string; + a: { s: number; d: string }; + dt: string; + et: string; +} & ( + | { + et: 'iss' | 'rev'; + ra: Record; + } + | { + et: 'bis' | 'brv'; + ra: { i: string; s: string; d: string }; + } +); /** * Credentials @@ -311,7 +314,7 @@ export class Credentials { */ async state(ri: string, said: string): Promise { const path = `/registries/${ri}/${said}`; - const method = "GET"; + const method = 'GET'; const res = await this.client.fetch(path, method, null); return res.json(); } diff --git a/src/keri/core/core.ts b/src/keri/core/core.ts index 0494a5fa..ee75d997 100644 --- a/src/keri/core/core.ts +++ b/src/keri/core/core.ts @@ -33,7 +33,7 @@ export const Ilks = { iss: 'iss', rev: 'rev', bis: 'bis', - brv: 'brv' + brv: 'brv', }; export const IcpLabels = [ diff --git a/test/app/credentialing.test.ts b/test/app/credentialing.test.ts index a124050e..99480919 100644 --- a/test/app/credentialing.test.ts +++ b/test/app/credentialing.test.ts @@ -369,13 +369,17 @@ describe('Credentialing', () => { 'EP10ooRj0DJF0HWZePEYMLPl-arMV-MAoTKK-o3DXbgX' ); - await credentials.state("EACehJRd0wfteUAJgaTTJjMSaQqWvzeeHqAMMqxuqxU4", "EBVaw6pCqfMIiZGkA6qevzRUGsxTRuZXxl6YG1neeCGF"); + await credentials.state( + 'EACehJRd0wfteUAJgaTTJjMSaQqWvzeeHqAMMqxuqxU4', + 'EBVaw6pCqfMIiZGkA6qevzRUGsxTRuZXxl6YG1neeCGF' + ); lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length - 1]!; assert.equal( lastCall[0]!, - url + "/registries/EACehJRd0wfteUAJgaTTJjMSaQqWvzeeHqAMMqxuqxU4/EBVaw6pCqfMIiZGkA6qevzRUGsxTRuZXxl6YG1neeCGF" + url + + '/registries/EACehJRd0wfteUAJgaTTJjMSaQqWvzeeHqAMMqxuqxU4/EBVaw6pCqfMIiZGkA6qevzRUGsxTRuZXxl6YG1neeCGF' ); - assert.equal(lastCall[1]!.method, "GET"); + assert.equal(lastCall[1]!.method, 'GET'); }); }); From 7a72ff6a00ed7735abad2d664cd4202cb5a0e810 Mon Sep 17 00:00:00 2001 From: iFergal Date: Mon, 4 Nov 2024 12:14:23 -0300 Subject: [PATCH 3/7] build: dev4 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 61ad49d1..382c0b6e 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-dev3'] + keria-version: ['0.2.0-dev4'] node-version: ['20'] env: KERIA_IMAGE_TAG: ${{ matrix.keria-version }} diff --git a/docker-compose.yaml b/docker-compose.yaml index 25d0dd40..38fd0261 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-dev3} + image: ${KERIA_IMAGE:-weboftrust/keria}:${KERIA_IMAGE_TAG:-0.2.0-dev4} environment: - KERI_AGENT_CORS=1 - KERI_URL=http://keria:3902 From 234e3578322e296a5787d9d1eec0f7f03816736a Mon Sep 17 00:00:00 2001 From: iFergal Date: Mon, 4 Nov 2024 17:15:20 -0300 Subject: [PATCH 4/7] build: npm audit run --- package-lock.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index c0c5d42e..f4d19759 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7102,9 +7102,9 @@ } }, "node_modules/mermaid": { - "version": "10.9.1", - "resolved": "https://registry.npmjs.org/mermaid/-/mermaid-10.9.1.tgz", - "integrity": "sha512-Mx45Obds5W1UkW1nv/7dHRsbfMM1aOKA2+Pxs/IGHNonygDHwmng8xTHyS9z4KWVi0rbko8gjiBmuwwXQ7tiNA==", + "version": "10.9.3", + "resolved": "https://registry.npmjs.org/mermaid/-/mermaid-10.9.3.tgz", + "integrity": "sha512-V80X1isSEvAewIL3xhmz/rVmc27CVljcsbWxkxlWJWY/1kQa4XOABqpDl2qQLGKzpKm6WbTfUEKImBlUfFYArw==", "dev": true, "dependencies": { "@braintree/sanitize-url": "^6.0.1", @@ -7116,7 +7116,7 @@ "d3-sankey": "^0.12.3", "dagre-d3-es": "7.0.10", "dayjs": "^1.11.7", - "dompurify": "^3.0.5", + "dompurify": "^3.0.5 <3.1.7", "elkjs": "^0.9.0", "katex": "^0.16.9", "khroma": "^2.0.0", From 53b6c374393cf05b8d83924f5eedbd923fe43dc0 Mon Sep 17 00:00:00 2001 From: iFergal Date: Mon, 4 Nov 2024 17:18:07 -0300 Subject: [PATCH 5/7] test: updates for long running op saids --- examples/integration-scripts/singlesig-drt.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/integration-scripts/singlesig-drt.test.ts b/examples/integration-scripts/singlesig-drt.test.ts index bb1c714f..2f099a9c 100644 --- a/examples/integration-scripts/singlesig-drt.test.ts +++ b/examples/integration-scripts/singlesig-drt.test.ts @@ -55,7 +55,7 @@ describe('singlesig-drt', () => { kargs = {}; result = await delegate.identifiers().rotate('delegate1', kargs); op = await result.op(); - expect(op.name).toEqual(`delegation.${delegate1.prefix}`); + expect(op.name).toEqual(`delegation.${result.serder.ked.d}`); // delegator approves delegate delegate1 = await delegate.identifiers().get('delegate1'); From f0fb01a0e5ee1c4f64ccceaa82c9ab548aa57ffc Mon Sep 17 00:00:00 2001 From: iFergal Date: Mon, 4 Nov 2024 17:50:29 -0300 Subject: [PATCH 6/7] test: unit tests --- test/app/credentialing.test.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/app/credentialing.test.ts b/test/app/credentialing.test.ts index 4156dcb6..89a5484c 100644 --- a/test/app/credentialing.test.ts +++ b/test/app/credentialing.test.ts @@ -315,6 +315,17 @@ describe('Credentialing', () => { ); assert.equal(lastBody.sigs[0].substring(0, 2), 'AA'); assert.equal(lastBody.sigs[0].length, 88); + + await credentials.state(mockCredential.sad.ri, mockCredential.sad.d); + lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length - 1]!; + assert.equal( + lastCall[0]!, + url + + '/registries/EGK216v1yguLfex4YRFnG7k1sXRjh3OKY7QqzdKsx7df/EMwcsEMUEruPXVwPCW7zmqmN8m0I3CihxolBm-RDrsJo' + ); + assert.equal(lastCall[1]!.method, 'GET'); + assert.equal(lastCall[1]!.body, null); + console.log(JSON.stringify(lastCall, null, 2)); }); }); From 565e8c8fd1e376d7d224b7e2f2f7d6f580765dc2 Mon Sep 17 00:00:00 2001 From: iFergal Date: Tue, 5 Nov 2024 08:59:27 -0300 Subject: [PATCH 7/7] test: remove log --- test/app/credentialing.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/test/app/credentialing.test.ts b/test/app/credentialing.test.ts index 89a5484c..a293a36a 100644 --- a/test/app/credentialing.test.ts +++ b/test/app/credentialing.test.ts @@ -325,7 +325,6 @@ describe('Credentialing', () => { ); assert.equal(lastCall[1]!.method, 'GET'); assert.equal(lastCall[1]!.body, null); - console.log(JSON.stringify(lastCall, null, 2)); }); });