From 8e72adf145e0622fc6878d9d82cf5fc8c046822f Mon Sep 17 00:00:00 2001 From: Patrick Vu Date: Thu, 7 Aug 2025 18:25:44 +0700 Subject: [PATCH 1/6] aiding.py type hints and auto-generated OpenAPI specs --- src/keri/app/aiding.ts | 2 +- src/keri/app/clienting.ts | 5 +- src/keri/app/controller.ts | 3 +- src/keri/core/keeping.ts | 2 +- src/keri/core/manager.ts | 3 +- src/types/keria-api-schema.ts | 374 ++++++++++++++++++++++++++- test-integration/delegation.test.ts | 1 + test-integration/utils/test-setup.ts | 153 +++++++++++ test-integration/utils/test-util.ts | 2 +- test/app/aiding.test.ts | 1 + test/app/clienting.test.ts | 2 +- test/app/contacting.test.ts | 2 +- test/app/controller.test.ts | 3 +- test/app/coring.test.ts | 2 +- test/app/credentialing.test.ts | 2 +- test/app/delegating.test.ts | 2 +- test/app/escrowing.test.ts | 2 +- test/app/exchanging.test.ts | 2 +- test/app/grouping.test.ts | 2 +- test/app/notifying.test.ts | 2 +- test/app/test-utils.ts | 2 +- test/core/manager.test.ts | 3 +- test/core/serder.test.ts | 3 +- test/end/ending.test.ts | 3 +- 24 files changed, 555 insertions(+), 23 deletions(-) create mode 100644 test-integration/utils/test-setup.ts diff --git a/src/keri/app/aiding.ts b/src/keri/app/aiding.ts index 1d40d6cd..42b5cfaf 100644 --- a/src/keri/app/aiding.ts +++ b/src/keri/app/aiding.ts @@ -1,4 +1,4 @@ -import { Tier } from '../core/salter.ts'; +import { Tier} from '../../types/keria-api-schema.ts'; import { Algos } from '../core/manager.ts'; import { incept, interact, reply, rotate } from '../core/eventing.ts'; import { b, Ilks, Serials, Vrsn_1_0 } from '../core/core.ts'; diff --git a/src/keri/app/clienting.ts b/src/keri/app/clienting.ts index 53debd7e..ff7e7726 100644 --- a/src/keri/app/clienting.ts +++ b/src/keri/app/clienting.ts @@ -1,8 +1,7 @@ -import { components } from '../../types/keria-api-schema.ts'; +import { components, Tier } from '../../types/keria-api-schema.ts'; import { Authenticater } from '../core/authing.ts'; import { HEADER_SIG_TIME } from '../core/httping.ts'; import { ExternalModule, IdentifierManagerFactory } from '../core/keeping.ts'; -import { Tier } from '../core/salter.ts'; import { Identifier } from './aiding.ts'; import { Contacts, Challenges } from './contacting.ts'; @@ -18,7 +17,7 @@ import { Notifications } from './notifying.ts'; const DEFAULT_BOOT_URL = 'http://localhost:3903'; // Export type outside the class -export type AgentResourceResult = components['schemas']['AgentResourceResult']; +export type AgentResourceResult = components["schemas"]["AgentResourceResult"]; class State { agent: any | null; diff --git a/src/keri/app/controller.ts b/src/keri/app/controller.ts index 2495ee9e..d209e1de 100644 --- a/src/keri/app/controller.ts +++ b/src/keri/app/controller.ts @@ -1,5 +1,6 @@ import { SaltyCreator } from '../core/manager.ts'; -import { Salter, Tier } from '../core/salter.ts'; +import { Salter } from '../core/salter.ts'; +import { Tier} from '../../types/keria-api-schema.ts'; import { MtrDex } from '../core/matter.ts'; import { Diger } from '../core/diger.ts'; import { incept, rotate, interact } from '../core/eventing.ts'; diff --git a/src/keri/core/keeping.ts b/src/keri/core/keeping.ts index 99eeffdc..b56c6116 100644 --- a/src/keri/core/keeping.ts +++ b/src/keri/core/keeping.ts @@ -1,7 +1,7 @@ import { Salter } from './salter.ts'; import { Algos, SaltyCreator, RandyCreator } from './manager.ts'; import { MtrDex } from './matter.ts'; -import { Tier } from './salter.ts'; +import { Tier} from '../../types/keria-api-schema.ts'; import { Encrypter } from '../core/encrypter.ts'; import { Decrypter } from './decrypter.ts'; import { b } from './core.ts'; diff --git a/src/keri/core/manager.ts b/src/keri/core/manager.ts index 59ccd440..68fef4a6 100644 --- a/src/keri/core/manager.ts +++ b/src/keri/core/manager.ts @@ -1,6 +1,7 @@ import { Encrypter } from './encrypter.ts'; import { Decrypter } from './decrypter.ts'; -import { Salter, Tier } from './salter.ts'; +import { Salter } from './salter.ts'; +import { Tier} from '../../types/keria-api-schema.ts'; import { Signer } from './signer.ts'; import { Verfer } from './verfer.ts'; import { MtrDex } from './matter.ts'; diff --git a/src/types/keria-api-schema.ts b/src/types/keria-api-schema.ts index 5360b47d..cded34db 100644 --- a/src/types/keria-api-schema.ts +++ b/src/types/keria-api-schema.ts @@ -1,4 +1,37 @@ -// AUTO-GENERATED: Only components retained from OpenAPI schema +// AUTO-GENERATED: Only components and enums retained from OpenAPI schema + +export enum IssEvtT { + iss = "iss", + bis = "bis" +} + +export enum CredentialStateIssOrRevEt { + iss = "iss", + rev = "rev" +} + +export enum CredentialStateBisOrBrvEt { + bis = "bis", + brv = "brv" +} + +export enum Tier { + low = "low", + med = "med", + high = "high" +} + +export enum OOBIRole { + controller = "controller", + witness = "witness", + registrar = "registrar", + watcher = "watcher", + judge = "judge", + juror = "juror", + peer = "peer", + mailbox = "mailbox", + agent = "agent" +} export interface components { schemas: { @@ -540,6 +573,345 @@ export interface components { signing: components['schemas']['AidRecord'][]; rotation: components['schemas']['AidRecord'][]; }; + Icp: { + /** @default */ + v: string; + /** @default */ + t: string; + /** @default */ + d: string; + /** @default */ + i: string; + /** @default 0 */ + s: string; + /** @default 0 */ + kt: string; + k?: string[]; + /** @default 0 */ + nt: string; + n?: string[]; + /** @default 0 */ + bt: string; + b?: string[]; + c?: string[]; + a?: unknown; + }; + RotV1: { + /** @default */ + v: string; + /** @default */ + t: string; + /** @default */ + d: string; + /** @default */ + i: string; + /** @default 0 */ + s: string; + /** @default */ + p: string; + /** @default 0 */ + kt: string; + k?: string[]; + /** @default 0 */ + nt: string; + n?: string[]; + /** @default 0 */ + bt: string; + br?: string[]; + ba?: string[]; + a?: unknown; + }; + RotV2: { + /** @default */ + v: string; + /** @default */ + t: string; + /** @default */ + d: string; + /** @default */ + i: string; + /** @default 0 */ + s: string; + /** @default */ + p: string; + /** @default 0 */ + kt: string; + k?: string[]; + /** @default 0 */ + nt: string; + n?: string[]; + /** @default 0 */ + bt: string; + br?: string[]; + ba?: string[]; + c?: string[]; + a?: unknown; + }; + Dip: { + /** @default */ + v: string; + /** @default */ + t: string; + /** @default */ + d: string; + /** @default */ + i: string; + /** @default 0 */ + s: string; + /** @default 0 */ + kt: string; + k?: string[]; + /** @default 0 */ + nt: string; + n?: string[]; + /** @default 0 */ + bt: string; + b?: string[]; + c?: string[]; + a?: unknown; + /** @default */ + di: string; + }; + DrtV1: { + /** @default */ + v: string; + /** @default */ + t: string; + /** @default */ + d: string; + /** @default */ + i: string; + /** @default 0 */ + s: string; + /** @default */ + p: string; + /** @default 0 */ + kt: string; + k?: string[]; + /** @default 0 */ + nt: string; + n?: string[]; + /** @default 0 */ + bt: string; + br?: string[]; + ba?: string[]; + a?: unknown; + }; + DrtV2: { + /** @default */ + v: string; + /** @default */ + t: string; + /** @default */ + d: string; + /** @default */ + i: string; + /** @default 0 */ + s: string; + /** @default */ + p: string; + /** @default 0 */ + kt: string; + k?: string[]; + /** @default 0 */ + nt: string; + n?: string[]; + /** @default 0 */ + bt: string; + br?: string[]; + ba?: string[]; + c?: string[]; + a?: unknown; + }; + Vcp: { + /** @default */ + v: string; + /** @default */ + t: string; + /** @default */ + d: string; + /** @default */ + i: string; + /** @default */ + ii: string; + /** @default 0 */ + s: string; + c?: string[]; + /** @default 0 */ + bt: string; + b?: string[]; + /** @default */ + n: string; + }; + Vrt: { + /** @default */ + v: string; + /** @default */ + t: string; + /** @default */ + d: string; + /** @default */ + i: string; + /** @default */ + p: string; + /** @default 0 */ + s: string; + /** @default 0 */ + bt: string; + br?: string[]; + ba?: string[]; + }; + StateEERecord: { + /** @default 0 */ + s: string; + /** @default */ + d: string; + br?: unknown[]; + ba?: unknown[]; + }; + KeyStateRecord: { + vn?: number[]; + /** @default */ + i: string; + /** @default 0 */ + s: string; + /** @default */ + p: string; + /** @default */ + d: string; + /** @default 0 */ + f: string; + /** @default */ + dt: string; + /** @default */ + et: string; + /** @default 0 */ + kt: string; + k: string[]; + /** @default 0 */ + nt: string; + n: string[]; + /** @default 0 */ + bt: string; + b: string[]; + c: string[]; + ee: components["schemas"]["StateEERecord"]; + /** @default */ + di: string; + }; + Controller: { + state: components["schemas"]["KeyStateRecord"]; + ee: components["schemas"]["Icp"] | components["schemas"]["RotV1"] | components["schemas"]["RotV2"] | components["schemas"]["Dip"] | components["schemas"]["DrtV1"] | components["schemas"]["DrtV2"] | components["schemas"]["Vcp"] | components["schemas"]["Vrt"]; + }; + AgentResourceResult: { + agent: components["schemas"]["KeyStateRecord"]; + controller: components["schemas"]["Controller"]; + pidx: number; + /** @default null */ + ridx: number | null; + /** @default null */ + sxlt: string | null; + }; + SaltyState: { + tier: components["schemas"]["Tier"]; + /** @default */ + sxlt: string; + /** @default 0 */ + pidx: number; + /** @default 0 */ + kidx: number; + /** @default */ + stem: string; + /** @default */ + dcode: string; + icodes: string[]; + ncodes: string[]; + /** @default false */ + transferable: boolean; + }; + RandyKeyState: { + prxs: string[]; + nxts: string[]; + }; + GroupKeyState: { + mhab: components["schemas"]["Identifier"]; + keys: string[]; + ndigs: string[]; + }; + ExternState: { + extern_type: string; + pidx: number; + } & { + [key: string]: unknown; + }; + Identifier: { + name: string; + prefix: string; + icp_dt: string; + state: components["schemas"]["KeyStateRecord"]; + /** @default null */ + transferable: boolean | null; + /** @default null */ + windexes: string[] | null; + salty?: components["schemas"]["SaltyState"]; + randy?: components["schemas"]["RandyKeyState"]; + group?: components["schemas"]["GroupKeyState"]; + extern?: components["schemas"]["ExternState"]; + }; + /** + * @description Tier of key material + * @enum {string} + */ + Tier: Tier; + OOBI: { + /** @enum {string} */ + role: OOBIRole; + oobis: string[]; + }; + EndRole: { + cid: string; + role: string; + eid: string; + }; + RpyV1: { + /** @default */ + v: string; + /** @default */ + t: string; + /** @default */ + d: string; + /** @default */ + dt: string; + /** @default */ + r: string; + a?: unknown; + }; + RpyV2: { + /** @default */ + v: string; + /** @default */ + t: string; + /** @default */ + d: string; + /** @default */ + i: string; + /** @default */ + dt: string; + /** @default */ + r: string; + a?: unknown; + }; + Rpy: components["schemas"]["RpyV1"] | components["schemas"]["RpyV2"]; + Challenge: { + words: string[]; + }; + Contact: { + id: string; + alias: string; + oobi: string; + } & { + [key: string]: unknown; + }; }; responses: never; parameters: never; diff --git a/test-integration/delegation.test.ts b/test-integration/delegation.test.ts index 0e534c93..9c6a7763 100644 --- a/test-integration/delegation.test.ts +++ b/test-integration/delegation.test.ts @@ -8,6 +8,7 @@ import { } from './utils/test-util.ts'; import { retry } from './utils/retry.ts'; import { step } from './utils/test-step.ts'; +import { Tier } from '../src/types/keria-api-schema.ts'; test('delegation', async () => { const [client1, client2] = await getOrCreateClients(2); diff --git a/test-integration/utils/test-setup.ts b/test-integration/utils/test-setup.ts new file mode 100644 index 00000000..65a0034a --- /dev/null +++ b/test-integration/utils/test-setup.ts @@ -0,0 +1,153 @@ +import { + CreateIdentiferArgs, + EventResult, + SignifyClient, + randomPasscode, + ready, +} from 'signify-ts'; +import { resolveEnvironment } from './resolve-env.ts'; +import { waitOperation } from './test-util.ts'; +import { Tier } from '../../src/types/keria-api-schema.ts'; + +/** + * Connect or boot a SignifyClient instance + */ +export async function getOrCreateClient( + bran: string | undefined = undefined +): Promise { + const env = resolveEnvironment(); + await ready(); + bran ??= randomPasscode(); + bran = bran.padEnd(21, '_'); + const client = new SignifyClient(env.url, bran, Tier.low, env.bootUrl); + try { + await client.connect(); + } catch { + const res = await client.boot(); + if (!res.ok) throw new Error(); + await client.connect(); + } + console.log('client', { + agent: client.agent?.pre, + controller: client.controller.pre, + }); + return client; +} + +/** + * Get or create a Keri identifier. Uses default witness config from `resolveEnvironment` + * @example + * Create a Keri identifier before running tests + * let name1_id: string, name1_oobi: string; + * beforeAll(async () => { + * [name1_id, name1_oobi] = await getOrCreateIdentifier(client1, "name1"); + * }); + * @see resolveEnvironment + */ +export async function getOrCreateIdentifier( + client: SignifyClient, + name: string, + kargs: CreateIdentiferArgs | undefined = undefined +): Promise<[string, string]> { + let id: string; + try { + const identfier = await client.identifiers().get(name); + // console.log("identifiers.get", identfier); + id = identfier.prefix; + } catch { + const env = resolveEnvironment(); + kargs ??= { + toad: env.witnessIds.length, + wits: env.witnessIds, + }; + const result: EventResult = await client + .identifiers() + .create(name, kargs); + let op = await result.op(); + op = await waitOperation(client, op); + // console.log("identifiers.create", op); + id = op.response.i; + } + const eid = client.agent?.pre; + if (!eid) { + throw new Error('No agent on client'); + } + if (!(await hasEndRole(client, name, 'agent', eid))) { + const result: EventResult = await client + .identifiers() + .addEndRole(name, 'agent', eid); + const op = await result.op(); + await waitOperation(client, op); + // console.log("identifiers.addEndRole", op); + } + const oobi = await client.oobis().get(name, 'agent'); + const result: [string, string] = [id, oobi.oobis[0]]; + console.log(name, result); + return result; +} + +/** + * Get list of end role authorizations for a Keri idenfitier + */ +export async function getEndRoles( + client: SignifyClient, + alias: string, + role?: string +): Promise { + const path = + role !== undefined + ? `/identifiers/${alias}/endroles/${role}` + : `/identifiers/${alias}/endroles`; + const response: Response = await client.fetch(path, 'GET', null); + if (!response.ok) throw new Error(await response.text()); + const result = await response.json(); + // console.log("getEndRoles", result); + return result; +} + +/** + * Test if end role is authorized for a Keri identifier + */ +export async function hasEndRole( + client: SignifyClient, + alias: string, + role: string, + eid: string +): Promise { + const list = await getEndRoles(client, alias, role); + for (const i of list) { + if (i.role === role && i.eid === eid) { + return true; + } + } + return false; +} + +/** + * Get or resolve a Keri contact + * @example + * Create a Keri contact before running tests + * let contact1_id: string; + * beforeAll(async () => { + * contact1_id = await getOrCreateContact(client2, "contact1", name1_oobi); + * }); + */ +export async function getOrCreateContact( + client: SignifyClient, + name: string, + oobi: string +): Promise { + const list = await client.contacts().list(undefined, 'alias', `^${name}$`); + // console.log("contacts.list", list); + if (list.length > 0) { + const contact = list[0]; + if (contact.oobi === oobi) { + // console.log("contacts.id", contact.id); + return contact.id; + } + } + let op = await client.oobis().resolve(oobi, name); + op = await waitOperation(client, op); + // console.log("oobis.resolve", op); + return op.response.i; +} diff --git a/test-integration/utils/test-util.ts b/test-integration/utils/test-util.ts index 54dfb760..50be8b29 100644 --- a/test-integration/utils/test-util.ts +++ b/test-integration/utils/test-util.ts @@ -6,7 +6,6 @@ import signify, { ready, Salter, SignifyClient, - Tier, HabState, ExternalModule, } from 'signify-ts'; @@ -14,6 +13,7 @@ import { RetryOptions, retry } from './retry.ts'; import assert from 'assert'; import { resolveEnvironment } from './resolve-env.ts'; import { expect } from 'vitest'; +import { Tier } from '../../src/types/keria-api-schema.ts'; export interface Aid { name: string; diff --git a/test/app/aiding.test.ts b/test/app/aiding.test.ts index bcc7527b..b270b933 100644 --- a/test/app/aiding.test.ts +++ b/test/app/aiding.test.ts @@ -15,6 +15,7 @@ import { Tier, } from '../../src/index.ts'; import { createMockIdentifierState } from './test-utils.ts'; +import { Tier } from '../../src/types/keria-api-schema.ts'; const bran = '0123456789abcdefghijk'; diff --git a/test/app/clienting.test.ts b/test/app/clienting.test.ts index b969ba7b..34dd7c9b 100644 --- a/test/app/clienting.test.ts +++ b/test/app/clienting.test.ts @@ -22,7 +22,7 @@ import { HEADER_SIG_INPUT, HEADER_SIG_TIME, } from '../../src/keri/core/httping.ts'; -import { Tier } from '../../src/keri/core/salter.ts'; +import { Tier } from '../../src/types/keria-api-schema.ts'; import libsodium from 'libsodium-wrappers-sumo'; import { createMockFetch } from './test-utils.ts'; diff --git a/test/app/contacting.test.ts b/test/app/contacting.test.ts index c4ff45ee..c0110bca 100644 --- a/test/app/contacting.test.ts +++ b/test/app/contacting.test.ts @@ -1,6 +1,6 @@ import { assert, describe, it } from 'vitest'; import { SignifyClient } from '../../src/keri/app/clienting.ts'; -import { Tier } from '../../src/keri/core/salter.ts'; +import { Tier } from '../../src/types/keria-api-schema.ts'; import libsodium from 'libsodium-wrappers-sumo'; import { createMockFetch } from './test-utils.ts'; diff --git a/test/app/controller.test.ts b/test/app/controller.test.ts index a4c814a3..426837ca 100644 --- a/test/app/controller.test.ts +++ b/test/app/controller.test.ts @@ -4,7 +4,8 @@ import libsodium from 'libsodium-wrappers-sumo'; import { openManager } from '../../src/keri/core/manager.ts'; import { Signer } from '../../src/keri/core/signer.ts'; import { MtrDex } from '../../src/keri/core/matter.ts'; -import { Tier, randomPasscode } from '../../src/index.ts'; +import { randomPasscode } from '../../src/index.ts'; +import { Tier } from '../../src/types/keria-api-schema.ts'; describe('Controller', () => { it('manage account AID signing and agent verification', async () => { diff --git a/test/app/coring.test.ts b/test/app/coring.test.ts index 53be7043..6e6c25a1 100644 --- a/test/app/coring.test.ts +++ b/test/app/coring.test.ts @@ -7,7 +7,7 @@ import { OperationsDeps, } from '../../src/keri/app/coring.ts'; import { SignifyClient } from '../../src/keri/app/clienting.ts'; -import { Tier } from '../../src/keri/core/salter.ts'; +import { Tier } from '../../src/types/keria-api-schema.ts'; import { randomUUID } from 'node:crypto'; import { createMockFetch } from './test-utils.ts'; diff --git a/test/app/credentialing.test.ts b/test/app/credentialing.test.ts index e298fba2..6ea5eafc 100644 --- a/test/app/credentialing.test.ts +++ b/test/app/credentialing.test.ts @@ -1,7 +1,7 @@ import { assert, describe, it } from 'vitest'; import { SignifyClient } from '../../src/keri/app/clienting.ts'; -import { Tier } from '../../src/keri/core/salter.ts'; +import { Tier } from '../../src/types/keria-api-schema.ts'; import libsodium from 'libsodium-wrappers-sumo'; import { d, diff --git a/test/app/delegating.test.ts b/test/app/delegating.test.ts index 48bff125..dd34afdd 100644 --- a/test/app/delegating.test.ts +++ b/test/app/delegating.test.ts @@ -1,5 +1,5 @@ import { assert, describe, it } from 'vitest'; -import { Tier } from '../../src/index.ts'; +import { Tier } from '../../src/types/keria-api-schema.ts'; import libsodium from 'libsodium-wrappers-sumo'; import { SignifyClient } from '../../src/keri/app/clienting.ts'; import { createMockFetch } from './test-utils.ts'; diff --git a/test/app/escrowing.test.ts b/test/app/escrowing.test.ts index 9150e9cf..354754b5 100644 --- a/test/app/escrowing.test.ts +++ b/test/app/escrowing.test.ts @@ -1,6 +1,6 @@ import { assert, describe, it } from 'vitest'; import { SignifyClient } from '../../src/keri/app/clienting.ts'; -import { Tier } from '../../src/keri/core/salter.ts'; +import { Tier } from '../../src/types/keria-api-schema.ts'; import libsodium from 'libsodium-wrappers-sumo'; import { createMockFetch } from './test-utils.ts'; diff --git a/test/app/exchanging.test.ts b/test/app/exchanging.test.ts index 9b79b53e..b14faace 100644 --- a/test/app/exchanging.test.ts +++ b/test/app/exchanging.test.ts @@ -8,8 +8,8 @@ import { MtrDex, Salter, Serder, - Tier, } from '../../src/index.ts'; +import { Tier } from '../../src/types/keria-api-schema.ts'; import libsodium from 'libsodium-wrappers-sumo'; import { SignifyClient } from '../../src/keri/app/clienting.ts'; import { createMockFetch } from './test-utils.ts'; diff --git a/test/app/grouping.test.ts b/test/app/grouping.test.ts index 197da9ad..bbb8df92 100644 --- a/test/app/grouping.test.ts +++ b/test/app/grouping.test.ts @@ -1,6 +1,6 @@ import { assert, describe, it } from 'vitest'; import { SignifyClient } from '../../src/keri/app/clienting.ts'; -import { Tier } from '../../src/keri/core/salter.ts'; +import { Tier } from '../../src/types/keria-api-schema.ts'; import libsodium from 'libsodium-wrappers-sumo'; import { createMockFetch } from './test-utils.ts'; diff --git a/test/app/notifying.test.ts b/test/app/notifying.test.ts index 885abf20..bae6c595 100644 --- a/test/app/notifying.test.ts +++ b/test/app/notifying.test.ts @@ -1,5 +1,5 @@ import { assert, describe, it } from 'vitest'; -import { Tier } from '../../src/keri/core/salter.ts'; +import { Tier } from '../../src/types/keria-api-schema.ts'; import { SignifyClient } from '../../src/keri/app/clienting.ts'; import libsodium from 'libsodium-wrappers-sumo'; import { createMockFetch } from './test-utils.ts'; diff --git a/test/app/test-utils.ts b/test/app/test-utils.ts index e224c546..66279cc4 100644 --- a/test/app/test-utils.ts +++ b/test/app/test-utils.ts @@ -9,10 +9,10 @@ import { MtrDex, Salter, Serials, - Tier, Vrsn_1_0, incept, } from '../../src/index.ts'; +import { Tier } from '../../src/types/keria-api-schema.ts'; import { EstablishmentState, HabState, diff --git a/test/core/manager.test.ts b/test/core/manager.test.ts index 88985c47..d5a5fb1f 100644 --- a/test/core/manager.test.ts +++ b/test/core/manager.test.ts @@ -9,7 +9,8 @@ import { } from '../../src/keri/core/manager.ts'; import { assert, describe, it, expect, vitest, Mocked } from 'vitest'; import { MtrDex } from '../../src/keri/core/matter.ts'; -import { Salter, Tier } from '../../src/keri/core/salter.ts'; +import { Salter } from '../../src/keri/core/salter.ts'; +import { Tier } from '../../src/types/keria-api-schema.ts'; import { Signer } from '../../src/keri/core/signer.ts'; import { Encrypter } from '../../src/keri/core/encrypter.ts'; import { Decrypter } from '../../src/keri/core/decrypter.ts'; diff --git a/test/core/serder.test.ts b/test/core/serder.test.ts index 75f1d127..d6f15a77 100644 --- a/test/core/serder.test.ts +++ b/test/core/serder.test.ts @@ -1,6 +1,7 @@ import { deversify, Ilks, Serials, Version } from '../../src/keri/core/core.ts'; import { assert, describe, it } from 'vitest'; -import { Salter, Tier } from '../../src/keri/core/salter.ts'; +import { Salter } from '../../src/keri/core/salter.ts'; +import { Tier } from '../../src/types/keria-api-schema.ts'; import { MtrDex } from '../../src/keri/core/matter.ts'; import { Diger } from '../../src/keri/core/diger.ts'; import { Serder } from '../../src/keri/core/serder.ts'; diff --git a/test/end/ending.test.ts b/test/end/ending.test.ts index c9f31bf3..65986d75 100644 --- a/test/end/ending.test.ts +++ b/test/end/ending.test.ts @@ -1,6 +1,7 @@ import { assert, describe, it, beforeAll, beforeEach } from 'vitest'; import libsodium from 'libsodium-wrappers-sumo'; -import { Salter, Tier } from '../../src/keri/core/salter.ts'; +import { Salter } from '../../src/keri/core/salter.ts'; +import { Tier } from '../../src/types/keria-api-schema.ts'; import { b } from '../../src/keri/core/core.ts'; import { MtrDex } from '../../src/keri/core/matter.ts'; import { designature, Signage, signature } from '../../src/keri/end/ending.ts'; From e6b3a3cd1a68fd28a7f29fc8d293b46290711ff8 Mon Sep 17 00:00:00 2001 From: Patrick Vu Date: Thu, 14 Aug 2025 15:27:59 +0700 Subject: [PATCH 2/6] resolve review comments --- src/keri/app/aiding.ts | 2 +- src/keri/app/clienting.ts | 3 +- src/keri/app/controller.ts | 3 +- src/keri/core/keeping.ts | 2 +- src/keri/core/keyState.ts | 14 +++- src/keri/core/manager.ts | 3 +- src/keri/core/salter.ts | 2 + src/types/keria-api-schema.ts | 92 +++++++++++++++++++----- test-integration/delegation.test.ts | 1 - test-integration/utils/multisig-utils.ts | 6 +- test-integration/utils/resolve-env.ts | 2 +- test-integration/utils/test-setup.ts | 2 +- test-integration/utils/test-util.ts | 2 +- test/app/aiding.test.ts | 1 - test/app/clienting.test.ts | 2 +- test/app/contacting.test.ts | 2 +- test/app/controller.test.ts | 3 +- test/app/coring.test.ts | 2 +- test/app/credentialing.test.ts | 2 +- test/app/delegating.test.ts | 2 +- test/app/escrowing.test.ts | 2 +- test/app/exchanging.test.ts | 2 +- test/app/grouping.test.ts | 2 +- test/app/notifying.test.ts | 2 +- test/app/registry.test.ts | 4 +- test/app/test-utils.ts | 2 +- test/core/manager.test.ts | 9 ++- test/core/serder.test.ts | 3 +- test/end/ending.test.ts | 3 +- 29 files changed, 123 insertions(+), 54 deletions(-) diff --git a/src/keri/app/aiding.ts b/src/keri/app/aiding.ts index 42b5cfaf..1d40d6cd 100644 --- a/src/keri/app/aiding.ts +++ b/src/keri/app/aiding.ts @@ -1,4 +1,4 @@ -import { Tier} from '../../types/keria-api-schema.ts'; +import { Tier } from '../core/salter.ts'; import { Algos } from '../core/manager.ts'; import { incept, interact, reply, rotate } from '../core/eventing.ts'; import { b, Ilks, Serials, Vrsn_1_0 } from '../core/core.ts'; diff --git a/src/keri/app/clienting.ts b/src/keri/app/clienting.ts index ff7e7726..ca26942e 100644 --- a/src/keri/app/clienting.ts +++ b/src/keri/app/clienting.ts @@ -1,7 +1,8 @@ -import { components, Tier } from '../../types/keria-api-schema.ts'; +import { components } from '../../types/keria-api-schema.ts'; import { Authenticater } from '../core/authing.ts'; import { HEADER_SIG_TIME } from '../core/httping.ts'; import { ExternalModule, IdentifierManagerFactory } from '../core/keeping.ts'; +import { Tier } from '../core/salter.ts'; import { Identifier } from './aiding.ts'; import { Contacts, Challenges } from './contacting.ts'; diff --git a/src/keri/app/controller.ts b/src/keri/app/controller.ts index d209e1de..2495ee9e 100644 --- a/src/keri/app/controller.ts +++ b/src/keri/app/controller.ts @@ -1,6 +1,5 @@ import { SaltyCreator } from '../core/manager.ts'; -import { Salter } from '../core/salter.ts'; -import { Tier} from '../../types/keria-api-schema.ts'; +import { Salter, Tier } from '../core/salter.ts'; import { MtrDex } from '../core/matter.ts'; import { Diger } from '../core/diger.ts'; import { incept, rotate, interact } from '../core/eventing.ts'; diff --git a/src/keri/core/keeping.ts b/src/keri/core/keeping.ts index b56c6116..99eeffdc 100644 --- a/src/keri/core/keeping.ts +++ b/src/keri/core/keeping.ts @@ -1,7 +1,7 @@ import { Salter } from './salter.ts'; import { Algos, SaltyCreator, RandyCreator } from './manager.ts'; import { MtrDex } from './matter.ts'; -import { Tier} from '../../types/keria-api-schema.ts'; +import { Tier } from './salter.ts'; import { Encrypter } from '../core/encrypter.ts'; import { Decrypter } from './decrypter.ts'; import { b } from './core.ts'; diff --git a/src/keri/core/keyState.ts b/src/keri/core/keyState.ts index cf26dba4..3c21a2b6 100644 --- a/src/keri/core/keyState.ts +++ b/src/keri/core/keyState.ts @@ -33,4 +33,16 @@ export type ExternState = components['schemas']['ExternState']; /** * Defining properties of an identifier habitat, know as a Hab in KERIpy. */ -export type HabState = components['schemas']['Identifier']; +// export type HabState = components['schemas']['Identifier']; + +export type HabStateBase = components['schemas']['HabState']; +export type SaltyHabState = HabStateBase & SaltyKeyState; +export type RandyHabState = HabStateBase & RandyKeyState; +export type GroupHabState = HabStateBase & GroupKeyState; +export type ExternHabState = HabStateBase & ExternState; +export type HabState = + | SaltyHabState + | RandyHabState + | GroupHabState + | ExternHabState; + diff --git a/src/keri/core/manager.ts b/src/keri/core/manager.ts index 68fef4a6..59ccd440 100644 --- a/src/keri/core/manager.ts +++ b/src/keri/core/manager.ts @@ -1,7 +1,6 @@ import { Encrypter } from './encrypter.ts'; import { Decrypter } from './decrypter.ts'; -import { Salter } from './salter.ts'; -import { Tier} from '../../types/keria-api-schema.ts'; +import { Salter, Tier } from './salter.ts'; import { Signer } from './signer.ts'; import { Verfer } from './verfer.ts'; import { MtrDex } from './matter.ts'; diff --git a/src/keri/core/salter.ts b/src/keri/core/salter.ts index 61fbe8d1..a06c39d3 100644 --- a/src/keri/core/salter.ts +++ b/src/keri/core/salter.ts @@ -7,6 +7,8 @@ import { Tier } from '../../types/keria-api-schema.ts'; export { Tier } from '../../types/keria-api-schema.ts'; +export { Tier } from '../../types/keria-api-schema.ts'; + interface SalterArgs { raw?: Uint8Array | undefined; code?: string; diff --git a/src/types/keria-api-schema.ts b/src/types/keria-api-schema.ts index cded34db..a4d33c2a 100644 --- a/src/types/keria-api-schema.ts +++ b/src/types/keria-api-schema.ts @@ -573,7 +573,30 @@ export interface components { signing: components['schemas']['AidRecord'][]; rotation: components['schemas']['AidRecord'][]; }; - Icp: { + IcpV1: { + /** @default */ + v: string; + /** @default */ + t: string; + /** @default */ + d: string; + /** @default */ + i: string; + /** @default 0 */ + s: string; + /** @default 0 */ + kt: string; + k?: string[]; + /** @default 0 */ + nt: string; + n?: string[]; + /** @default 0 */ + bt: string; + b?: string[]; + c?: string[]; + a?: unknown; + }; + IcpV2: { /** @default */ v: string; /** @default */ @@ -647,7 +670,32 @@ export interface components { c?: string[]; a?: unknown; }; - Dip: { + DipV1: { + /** @default */ + v: string; + /** @default */ + t: string; + /** @default */ + d: string; + /** @default */ + i: string; + /** @default 0 */ + s: string; + /** @default 0 */ + kt: string; + k?: string[]; + /** @default 0 */ + nt: string; + n?: string[]; + /** @default 0 */ + bt: string; + b?: string[]; + c?: string[]; + a?: unknown; + /** @default */ + di: string; + }; + DipV2: { /** @default */ v: string; /** @default */ @@ -723,7 +771,7 @@ export interface components { c?: string[]; a?: unknown; }; - Vcp: { + VcpV1: { /** @default */ v: string; /** @default */ @@ -743,7 +791,7 @@ export interface components { /** @default */ n: string; }; - Vrt: { + VrtV1: { /** @default */ v: string; /** @default */ @@ -801,7 +849,7 @@ export interface components { }; Controller: { state: components["schemas"]["KeyStateRecord"]; - ee: components["schemas"]["Icp"] | components["schemas"]["RotV1"] | components["schemas"]["RotV2"] | components["schemas"]["Dip"] | components["schemas"]["DrtV1"] | components["schemas"]["DrtV2"] | components["schemas"]["Vcp"] | components["schemas"]["Vrt"]; + ee: components["schemas"]["IcpV1"] | components["schemas"]["IcpV2"] | components["schemas"]["RotV1"] | components["schemas"]["RotV2"] | components["schemas"]["DipV1"] | components["schemas"]["DipV2"] | components["schemas"]["DrtV1"] | components["schemas"]["DrtV2"] | components["schemas"]["VcpV1"] | components["schemas"]["VrtV1"]; }; AgentResourceResult: { agent: components["schemas"]["KeyStateRecord"]; @@ -833,6 +881,16 @@ export interface components { prxs: string[]; nxts: string[]; }; + HabState: { + name: string; + prefix: string; + icp_dt: string; + state: components["schemas"]["KeyStateRecord"]; + /** @default null */ + transferable: boolean | null; + /** @default null */ + windexes: string[] | null; + }; GroupKeyState: { mhab: components["schemas"]["Identifier"]; keys: string[]; @@ -853,11 +911,15 @@ export interface components { transferable: boolean | null; /** @default null */ windexes: string[] | null; - salty?: components["schemas"]["SaltyState"]; - randy?: components["schemas"]["RandyKeyState"]; - group?: components["schemas"]["GroupKeyState"]; - extern?: components["schemas"]["ExternState"]; - }; + } & ({ + salty: components["schemas"]["SaltyState"]; + } | { + randy: components["schemas"]["RandyKeyState"]; + } | { + group: components["schemas"]["GroupKeyState"]; + } | { + extern: components["schemas"]["ExternState"]; + }); /** * @description Tier of key material * @enum {string} @@ -904,13 +966,9 @@ export interface components { Rpy: components["schemas"]["RpyV1"] | components["schemas"]["RpyV2"]; Challenge: { words: string[]; - }; - Contact: { - id: string; - alias: string; - oobi: string; - } & { - [key: string]: unknown; + dt?: string; + said?: string; + authenticated?: boolean; }; }; responses: never; diff --git a/test-integration/delegation.test.ts b/test-integration/delegation.test.ts index 9c6a7763..0e534c93 100644 --- a/test-integration/delegation.test.ts +++ b/test-integration/delegation.test.ts @@ -8,7 +8,6 @@ import { } from './utils/test-util.ts'; import { retry } from './utils/retry.ts'; import { step } from './utils/test-step.ts'; -import { Tier } from '../src/types/keria-api-schema.ts'; test('delegation', async () => { const [client1, client2] = await getOrCreateClients(2); diff --git a/test-integration/utils/multisig-utils.ts b/test-integration/utils/multisig-utils.ts index ba76000e..5affccc6 100644 --- a/test-integration/utils/multisig-utils.ts +++ b/test-integration/utils/multisig-utils.ts @@ -8,6 +8,10 @@ import signify, { d, messagize, HabState, + SaltyHabState, + GroupHabState, + ExternHabState, + RandyHabState, } from 'signify-ts'; import { getStates, waitAndMarkNotification } from './test-util.ts'; import assert from 'assert'; @@ -85,7 +89,7 @@ export async function acceptMultisigIncept( export async function addEndRoleMultisig( client: SignifyClient, groupName: string, - aid: HabState, + aid: SaltyHabState | GroupHabState | ExternHabState | RandyHabState, otherMembersAIDs: HabState[], multisigAID: HabState, timestamp: string, diff --git a/test-integration/utils/resolve-env.ts b/test-integration/utils/resolve-env.ts index d41ce4d1..767f24fd 100644 --- a/test-integration/utils/resolve-env.ts +++ b/test-integration/utils/resolve-env.ts @@ -16,7 +16,7 @@ const WES = 'BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX'; export function resolveEnvironment( input?: TestEnvironmentPreset ): TestEnvironment { - const preset = input ?? process.env.TEST_ENVIRONMENT ?? 'docker'; + const preset = input ?? process.env.TEST_ENVIRONMENT ?? 'local'; const url = 'http://127.0.0.1:3901'; const bootUrl = 'http://127.0.0.1:3903'; diff --git a/test-integration/utils/test-setup.ts b/test-integration/utils/test-setup.ts index 65a0034a..71cf6ada 100644 --- a/test-integration/utils/test-setup.ts +++ b/test-integration/utils/test-setup.ts @@ -2,12 +2,12 @@ import { CreateIdentiferArgs, EventResult, SignifyClient, + Tier, randomPasscode, ready, } from 'signify-ts'; import { resolveEnvironment } from './resolve-env.ts'; import { waitOperation } from './test-util.ts'; -import { Tier } from '../../src/types/keria-api-schema.ts'; /** * Connect or boot a SignifyClient instance diff --git a/test-integration/utils/test-util.ts b/test-integration/utils/test-util.ts index 50be8b29..54dfb760 100644 --- a/test-integration/utils/test-util.ts +++ b/test-integration/utils/test-util.ts @@ -6,6 +6,7 @@ import signify, { ready, Salter, SignifyClient, + Tier, HabState, ExternalModule, } from 'signify-ts'; @@ -13,7 +14,6 @@ import { RetryOptions, retry } from './retry.ts'; import assert from 'assert'; import { resolveEnvironment } from './resolve-env.ts'; import { expect } from 'vitest'; -import { Tier } from '../../src/types/keria-api-schema.ts'; export interface Aid { name: string; diff --git a/test/app/aiding.test.ts b/test/app/aiding.test.ts index b270b933..bcc7527b 100644 --- a/test/app/aiding.test.ts +++ b/test/app/aiding.test.ts @@ -15,7 +15,6 @@ import { Tier, } from '../../src/index.ts'; import { createMockIdentifierState } from './test-utils.ts'; -import { Tier } from '../../src/types/keria-api-schema.ts'; const bran = '0123456789abcdefghijk'; diff --git a/test/app/clienting.test.ts b/test/app/clienting.test.ts index 34dd7c9b..b969ba7b 100644 --- a/test/app/clienting.test.ts +++ b/test/app/clienting.test.ts @@ -22,7 +22,7 @@ import { HEADER_SIG_INPUT, HEADER_SIG_TIME, } from '../../src/keri/core/httping.ts'; -import { Tier } from '../../src/types/keria-api-schema.ts'; +import { Tier } from '../../src/keri/core/salter.ts'; import libsodium from 'libsodium-wrappers-sumo'; import { createMockFetch } from './test-utils.ts'; diff --git a/test/app/contacting.test.ts b/test/app/contacting.test.ts index c0110bca..c4ff45ee 100644 --- a/test/app/contacting.test.ts +++ b/test/app/contacting.test.ts @@ -1,6 +1,6 @@ import { assert, describe, it } from 'vitest'; import { SignifyClient } from '../../src/keri/app/clienting.ts'; -import { Tier } from '../../src/types/keria-api-schema.ts'; +import { Tier } from '../../src/keri/core/salter.ts'; import libsodium from 'libsodium-wrappers-sumo'; import { createMockFetch } from './test-utils.ts'; diff --git a/test/app/controller.test.ts b/test/app/controller.test.ts index 426837ca..a4c814a3 100644 --- a/test/app/controller.test.ts +++ b/test/app/controller.test.ts @@ -4,8 +4,7 @@ import libsodium from 'libsodium-wrappers-sumo'; import { openManager } from '../../src/keri/core/manager.ts'; import { Signer } from '../../src/keri/core/signer.ts'; import { MtrDex } from '../../src/keri/core/matter.ts'; -import { randomPasscode } from '../../src/index.ts'; -import { Tier } from '../../src/types/keria-api-schema.ts'; +import { Tier, randomPasscode } from '../../src/index.ts'; describe('Controller', () => { it('manage account AID signing and agent verification', async () => { diff --git a/test/app/coring.test.ts b/test/app/coring.test.ts index 6e6c25a1..53be7043 100644 --- a/test/app/coring.test.ts +++ b/test/app/coring.test.ts @@ -7,7 +7,7 @@ import { OperationsDeps, } from '../../src/keri/app/coring.ts'; import { SignifyClient } from '../../src/keri/app/clienting.ts'; -import { Tier } from '../../src/types/keria-api-schema.ts'; +import { Tier } from '../../src/keri/core/salter.ts'; import { randomUUID } from 'node:crypto'; import { createMockFetch } from './test-utils.ts'; diff --git a/test/app/credentialing.test.ts b/test/app/credentialing.test.ts index 6ea5eafc..e298fba2 100644 --- a/test/app/credentialing.test.ts +++ b/test/app/credentialing.test.ts @@ -1,7 +1,7 @@ import { assert, describe, it } from 'vitest'; import { SignifyClient } from '../../src/keri/app/clienting.ts'; -import { Tier } from '../../src/types/keria-api-schema.ts'; +import { Tier } from '../../src/keri/core/salter.ts'; import libsodium from 'libsodium-wrappers-sumo'; import { d, diff --git a/test/app/delegating.test.ts b/test/app/delegating.test.ts index dd34afdd..db886b01 100644 --- a/test/app/delegating.test.ts +++ b/test/app/delegating.test.ts @@ -1,5 +1,5 @@ import { assert, describe, it } from 'vitest'; -import { Tier } from '../../src/types/keria-api-schema.ts'; +import { Tier } from '../../src/keri/core/salter.ts'; import libsodium from 'libsodium-wrappers-sumo'; import { SignifyClient } from '../../src/keri/app/clienting.ts'; import { createMockFetch } from './test-utils.ts'; diff --git a/test/app/escrowing.test.ts b/test/app/escrowing.test.ts index 354754b5..9150e9cf 100644 --- a/test/app/escrowing.test.ts +++ b/test/app/escrowing.test.ts @@ -1,6 +1,6 @@ import { assert, describe, it } from 'vitest'; import { SignifyClient } from '../../src/keri/app/clienting.ts'; -import { Tier } from '../../src/types/keria-api-schema.ts'; +import { Tier } from '../../src/keri/core/salter.ts'; import libsodium from 'libsodium-wrappers-sumo'; import { createMockFetch } from './test-utils.ts'; diff --git a/test/app/exchanging.test.ts b/test/app/exchanging.test.ts index b14faace..9b79b53e 100644 --- a/test/app/exchanging.test.ts +++ b/test/app/exchanging.test.ts @@ -8,8 +8,8 @@ import { MtrDex, Salter, Serder, + Tier, } from '../../src/index.ts'; -import { Tier } from '../../src/types/keria-api-schema.ts'; import libsodium from 'libsodium-wrappers-sumo'; import { SignifyClient } from '../../src/keri/app/clienting.ts'; import { createMockFetch } from './test-utils.ts'; diff --git a/test/app/grouping.test.ts b/test/app/grouping.test.ts index bbb8df92..197da9ad 100644 --- a/test/app/grouping.test.ts +++ b/test/app/grouping.test.ts @@ -1,6 +1,6 @@ import { assert, describe, it } from 'vitest'; import { SignifyClient } from '../../src/keri/app/clienting.ts'; -import { Tier } from '../../src/types/keria-api-schema.ts'; +import { Tier } from '../../src/keri/core/salter.ts'; import libsodium from 'libsodium-wrappers-sumo'; import { createMockFetch } from './test-utils.ts'; diff --git a/test/app/notifying.test.ts b/test/app/notifying.test.ts index bae6c595..885abf20 100644 --- a/test/app/notifying.test.ts +++ b/test/app/notifying.test.ts @@ -1,5 +1,5 @@ import { assert, describe, it } from 'vitest'; -import { Tier } from '../../src/types/keria-api-schema.ts'; +import { Tier } from '../../src/keri/core/salter.ts'; import { SignifyClient } from '../../src/keri/app/clienting.ts'; import libsodium from 'libsodium-wrappers-sumo'; import { createMockFetch } from './test-utils.ts'; diff --git a/test/app/registry.test.ts b/test/app/registry.test.ts index 6ddb07e2..cff65027 100644 --- a/test/app/registry.test.ts +++ b/test/app/registry.test.ts @@ -67,7 +67,7 @@ describe('registry', () => { const mockedClient = mock(SignifyClient); const mockedIdentifiers = mock(Identifier); - const hab = { + const hab = ({ prefix: 'hab prefix', state: { s: 0, d: 'a digest', c: ['EO'] } as unknown as KeyState, name: 'a name', @@ -78,7 +78,7 @@ describe('registry', () => { prxs: [], nxts: [], }, - }; + } as unknown) as HabState; when(mockedIdentifiers.get('a name')).thenResolve(hab); when(mockedClient.identifiers()).thenReturn( diff --git a/test/app/test-utils.ts b/test/app/test-utils.ts index 66279cc4..e224c546 100644 --- a/test/app/test-utils.ts +++ b/test/app/test-utils.ts @@ -9,10 +9,10 @@ import { MtrDex, Salter, Serials, + Tier, Vrsn_1_0, incept, } from '../../src/index.ts'; -import { Tier } from '../../src/types/keria-api-schema.ts'; import { EstablishmentState, HabState, diff --git a/test/core/manager.test.ts b/test/core/manager.test.ts index d5a5fb1f..236e39b1 100644 --- a/test/core/manager.test.ts +++ b/test/core/manager.test.ts @@ -9,8 +9,7 @@ import { } from '../../src/keri/core/manager.ts'; import { assert, describe, it, expect, vitest, Mocked } from 'vitest'; import { MtrDex } from '../../src/keri/core/matter.ts'; -import { Salter } from '../../src/keri/core/salter.ts'; -import { Tier } from '../../src/types/keria-api-schema.ts'; +import { Salter, Tier } from '../../src/keri/core/salter.ts'; import { Signer } from '../../src/keri/core/signer.ts'; import { Encrypter } from '../../src/keri/core/encrypter.ts'; import { Decrypter } from '../../src/keri/core/decrypter.ts'; @@ -732,7 +731,7 @@ describe('Manager', () => { transferable: false, windexes: [], icp_dt: '2023-12-01T10:05:25.062609+00:00', - }); + } as unknown as RandyHabState); assert(keeper0 instanceof RandyIdentifierManager); assert(keeper1 instanceof RandyIdentifierManager); @@ -833,7 +832,7 @@ describe('Manager', () => { }, transferable: true, icp_dt: '2023-12-01T10:05:25.062609+00:00', - }); + } as unknown as ExternHabState); assert(keeper instanceof MockModule); expect(keeper.params()).toMatchObject({ param, pidx: 3 }); @@ -860,7 +859,7 @@ describe('Manager', () => { }, transferable: true, icp_dt: '2023-12-01T10:05:25.062609+00:00', - }) + } as unknown as ExternHabState) ).toThrow('unsupported external module type mock'); }); }); diff --git a/test/core/serder.test.ts b/test/core/serder.test.ts index d6f15a77..75f1d127 100644 --- a/test/core/serder.test.ts +++ b/test/core/serder.test.ts @@ -1,7 +1,6 @@ import { deversify, Ilks, Serials, Version } from '../../src/keri/core/core.ts'; import { assert, describe, it } from 'vitest'; -import { Salter } from '../../src/keri/core/salter.ts'; -import { Tier } from '../../src/types/keria-api-schema.ts'; +import { Salter, Tier } from '../../src/keri/core/salter.ts'; import { MtrDex } from '../../src/keri/core/matter.ts'; import { Diger } from '../../src/keri/core/diger.ts'; import { Serder } from '../../src/keri/core/serder.ts'; diff --git a/test/end/ending.test.ts b/test/end/ending.test.ts index 65986d75..c9f31bf3 100644 --- a/test/end/ending.test.ts +++ b/test/end/ending.test.ts @@ -1,7 +1,6 @@ import { assert, describe, it, beforeAll, beforeEach } from 'vitest'; import libsodium from 'libsodium-wrappers-sumo'; -import { Salter } from '../../src/keri/core/salter.ts'; -import { Tier } from '../../src/types/keria-api-schema.ts'; +import { Salter, Tier } from '../../src/keri/core/salter.ts'; import { b } from '../../src/keri/core/core.ts'; import { MtrDex } from '../../src/keri/core/matter.ts'; import { designature, Signage, signature } from '../../src/keri/end/ending.ts'; From 505aa17990439c89fd7a7491b9342da70d316feb Mon Sep 17 00:00:00 2001 From: Patrick Vu Date: Thu, 14 Aug 2025 18:21:46 +0700 Subject: [PATCH 3/6] feat: agenting.py type hints and OpenAPI specs #377 --- src/keri/app/contacting.ts | 6 +- src/keri/app/coring.ts | 25 +- src/types/keria-api-schema.ts | 417 +++++++++++++++++++++---- test-integration/singlesig-ixn.test.ts | 21 +- test-integration/singlesig-rot.test.ts | 24 +- 5 files changed, 385 insertions(+), 108 deletions(-) diff --git a/src/keri/app/contacting.ts b/src/keri/app/contacting.ts index 8ba731ca..63d912f1 100644 --- a/src/keri/app/contacting.ts +++ b/src/keri/app/contacting.ts @@ -183,15 +183,15 @@ export class Challenges { * Mark challenge response as signed and accepted * @param source Prefix of the identifier that was challenged * @param said qb64 AID of exn message representing the signed response - * @returns {Promise} A promise to the result + * @returns {Promise>} A promise to the result */ - async responded(source: string, said: string): Promise { + async responded(source: string, said: string): Promise> { const path = `/challenges_verify/${source}`; const method = 'PUT'; const data = { said: said, }; const res = await this.client.fetch(path, method, data); - return res; + return await res.json() as Operation; } } diff --git a/src/keri/app/coring.ts b/src/keri/app/coring.ts index 0969de89..84ecf721 100644 --- a/src/keri/app/coring.ts +++ b/src/keri/app/coring.ts @@ -5,6 +5,9 @@ import { Matter, MtrDex } from '../core/matter.ts'; import { components } from '../../types/keria-api-schema.ts'; type OOBI = components['schemas']['OOBI']; +type KeyState = components['schemas']['KeyStateRecord']; +type KeyEventRecord = components['schemas']['KeyEventRecord']; +type AgentConfig = components['schemas']['AgentConfig']; export function randomPasscode(): string { const raw = libsodium.randombytes_buf(16); @@ -48,9 +51,9 @@ export class Oobis { * @async * @param {string} oobi The OOBI to be resolver * @param {string} [alias] Optional name or alias to link the OOBI resolution to a contact - * @returns {Promise} A promise to the long-running operation + * @returns {Promise>} A promise to the long-running operation */ - async resolve(oobi: string, alias?: string): Promise { + async resolve(oobi: string, alias?: string): Promise> { const path = `/oobis`; const data: any = { url: oobi, @@ -85,10 +88,6 @@ export interface OperationsDeps { ): Promise; } -export interface AgentConfig { - iurls?: string[]; -} - /** * Operations * @remarks @@ -208,9 +207,9 @@ export class KeyEvents { * Retrieve key events for an identifier * @async * @param {string} pre Identifier prefix - * @returns {Promise} A promise to the key events + * @returns {Promise} A promise to the key events */ - async get(pre: string): Promise { + async get(pre: string): Promise { const path = `/events?pre=${pre}`; const data = null; const method = 'GET'; @@ -236,9 +235,9 @@ export class KeyStates { * Retriene the key state for an identifier * @async * @param {string} pre Identifier prefix - * @returns {Promise} A promise to the key states + * @returns {Promise} A promise to the key states */ - async get(pre: string): Promise { + async get(pre: string): Promise { const path = `/states?pre=${pre}`; const data = null; const method = 'GET'; @@ -252,7 +251,7 @@ export class KeyStates { * @param {Array} pres List of identifier prefixes * @returns {Promise} A promise to the key states */ - async list(pres: string[]): Promise { + async list(pres: string[]): Promise { const path = `/states?${pres.map((pre) => `pre=${pre}`).join('&')}`; const data = null; const method = 'GET'; @@ -266,9 +265,9 @@ export class KeyStates { * @param {string} pre Identifier prefix * @param {number} [sn] Optional sequence number * @param {any} [anchor] Optional anchor - * @returns {Promise} A promise to the long-running operation + * @returns {Promise>} A promise to the long-running operation */ - async query(pre: string, sn?: string, anchor?: any): Promise { + async query(pre: string, sn?: string, anchor?: any): Promise> { const path = `/queries`; const data: any = { pre: pre, diff --git a/src/types/keria-api-schema.ts b/src/types/keria-api-schema.ts index a4d33c2a..8440f4db 100644 --- a/src/types/keria-api-schema.ts +++ b/src/types/keria-api-schema.ts @@ -596,7 +596,7 @@ export interface components { c?: string[]; a?: unknown; }; - IcpV2: { + RotV1: { /** @default */ v: string; /** @default */ @@ -607,6 +607,8 @@ export interface components { i: string; /** @default 0 */ s: string; + /** @default */ + p: string; /** @default 0 */ kt: string; k?: string[]; @@ -615,11 +617,11 @@ export interface components { n?: string[]; /** @default 0 */ bt: string; - b?: string[]; - c?: string[]; + br?: string[]; + ba?: string[]; a?: unknown; }; - RotV1: { + DipV1: { /** @default */ v: string; /** @default */ @@ -630,8 +632,6 @@ export interface components { i: string; /** @default 0 */ s: string; - /** @default */ - p: string; /** @default 0 */ kt: string; k?: string[]; @@ -640,11 +640,13 @@ export interface components { n?: string[]; /** @default 0 */ bt: string; - br?: string[]; - ba?: string[]; + b?: string[]; + c?: string[]; a?: unknown; + /** @default */ + di: string; }; - RotV2: { + DrtV1: { /** @default */ v: string; /** @default */ @@ -667,10 +669,231 @@ export interface components { bt: string; br?: string[]; ba?: string[]; + a?: unknown; + }; + VcpV1: { + /** @default */ + v: string; + /** @default */ + t: string; + /** @default */ + d: string; + /** @default */ + i: string; + /** @default */ + ii: string; + /** @default 0 */ + s: string; c?: string[]; + /** @default 0 */ + bt: string; + b?: string[]; + /** @default */ + n: string; + }; + VrtV1: { + /** @default */ + v: string; + /** @default */ + t: string; + /** @default */ + d: string; + /** @default */ + i: string; + /** @default */ + p: string; + /** @default 0 */ + s: string; + /** @default 0 */ + bt: string; + br?: string[]; + ba?: string[]; + }; + IxnV1: { + /** @default */ + v: string; + /** @default */ + t: string; + /** @default */ + d: string; + /** @default */ + i: string; + /** @default 0 */ + s: string; + /** @default */ + p: string; a?: unknown; }; - DipV1: { + RctV1: { + /** @default */ + v: string; + /** @default */ + t: string; + /** @default */ + d: string; + /** @default */ + i: string; + /** @default 0 */ + s: string; + }; + QryV1: { + /** @default */ + v: string; + /** @default */ + t: string; + /** @default */ + d: string; + /** @default */ + dt: string; + /** @default */ + r: string; + /** @default */ + rr: string; + q?: { + [key: string]: unknown; + }; + }; + RpyV1: { + /** @default */ + v: string; + /** @default */ + t: string; + /** @default */ + d: string; + /** @default */ + dt: string; + /** @default */ + r: string; + a?: unknown; + }; + ProV1: { + /** @default */ + v: string; + /** @default */ + t: string; + /** @default */ + d: string; + /** @default */ + dt: string; + /** @default */ + r: string; + /** @default */ + rr: string; + q?: { + [key: string]: unknown; + }; + }; + BarV1: { + /** @default */ + v: string; + /** @default */ + t: string; + /** @default */ + d: string; + /** @default */ + dt: string; + /** @default */ + r: string; + a?: unknown; + }; + ExnV1: { + /** @default */ + v: string; + /** @default */ + t: string; + /** @default */ + d: string; + /** @default */ + i: string; + /** @default */ + rp: string; + /** @default */ + p: string; + /** @default */ + dt: string; + /** @default */ + r: string; + q?: { + [key: string]: unknown; + }; + a?: unknown; + e?: { + [key: string]: unknown; + }; + }; + IssV1: { + /** @default */ + v: string; + /** @default */ + t: string; + /** @default */ + d: string; + /** @default */ + i: string; + /** @default 0 */ + s: string; + /** @default */ + ri: string; + /** @default */ + dt: string; + }; + RevV1: { + /** @default */ + v: string; + /** @default */ + t: string; + /** @default */ + d: string; + /** @default */ + i: string; + /** @default 0 */ + s: string; + /** @default */ + ri: string; + /** @default */ + p: string; + /** @default */ + dt: string; + }; + BisV1: { + /** @default */ + v: string; + /** @default */ + t: string; + /** @default */ + d: string; + /** @default */ + i: string; + /** @default */ + ii: string; + /** @default 0 */ + s: string; + ra?: { + [key: string]: unknown; + }; + /** @default */ + dt: string; + }; + BrvV1: { + /** @default */ + v: string; + /** @default */ + t: string; + /** @default */ + d: string; + /** @default */ + i: string; + /** @default 0 */ + s: string; + /** @default */ + p: string; + ra?: { + [key: string]: unknown; + }; + /** @default */ + dt: string; + }; + IcpV2: { /** @default */ v: string; /** @default */ @@ -692,10 +915,8 @@ export interface components { b?: string[]; c?: string[]; a?: unknown; - /** @default */ - di: string; }; - DipV2: { + RotV2: { /** @default */ v: string; /** @default */ @@ -706,6 +927,8 @@ export interface components { i: string; /** @default 0 */ s: string; + /** @default */ + p: string; /** @default 0 */ kt: string; k?: string[]; @@ -714,13 +937,12 @@ export interface components { n?: string[]; /** @default 0 */ bt: string; - b?: string[]; + br?: string[]; + ba?: string[]; c?: string[]; a?: unknown; - /** @default */ - di: string; }; - DrtV1: { + DipV2: { /** @default */ v: string; /** @default */ @@ -731,8 +953,6 @@ export interface components { i: string; /** @default 0 */ s: string; - /** @default */ - p: string; /** @default 0 */ kt: string; k?: string[]; @@ -741,9 +961,11 @@ export interface components { n?: string[]; /** @default 0 */ bt: string; - br?: string[]; - ba?: string[]; + b?: string[]; + c?: string[]; a?: unknown; + /** @default */ + di: string; }; DrtV2: { /** @default */ @@ -771,7 +993,7 @@ export interface components { c?: string[]; a?: unknown; }; - VcpV1: { + IxnV2: { /** @default */ v: string; /** @default */ @@ -780,18 +1002,111 @@ export interface components { d: string; /** @default */ i: string; - /** @default */ - ii: string; /** @default 0 */ s: string; - c?: string[]; + /** @default */ + p: string; + a?: unknown; + }; + RctV2: { + /** @default */ + v: string; + /** @default */ + t: string; + /** @default */ + d: string; + /** @default */ + i: string; /** @default 0 */ - bt: string; - b?: string[]; + s: string; + }; + QryV2: { /** @default */ - n: string; + v: string; + /** @default */ + t: string; + /** @default */ + d: string; + /** @default */ + i: string; + /** @default */ + dt: string; + /** @default */ + r: string; + /** @default */ + rr: string; + q?: { + [key: string]: unknown; + }; }; - VrtV1: { + RpyV2: { + /** @default */ + v: string; + /** @default */ + t: string; + /** @default */ + d: string; + /** @default */ + i: string; + /** @default */ + dt: string; + /** @default */ + r: string; + a?: unknown; + }; + ProV2: { + /** @default */ + v: string; + /** @default */ + t: string; + /** @default */ + d: string; + /** @default */ + i: string; + /** @default */ + dt: string; + /** @default */ + r: string; + /** @default */ + rr: string; + q?: { + [key: string]: unknown; + }; + }; + BarV2: { + /** @default */ + v: string; + /** @default */ + t: string; + /** @default */ + d: string; + /** @default */ + i: string; + /** @default */ + dt: string; + /** @default */ + r: string; + a?: unknown; + }; + XipV2: { + /** @default */ + v: string; + /** @default */ + t: string; + /** @default */ + d: string; + /** @default */ + i: string; + /** @default */ + dt: string; + /** @default */ + r: string; + q?: { + [key: string]: unknown; + }; + a?: unknown; + }; + ExnV2: { /** @default */ v: string; /** @default */ @@ -801,13 +1116,17 @@ export interface components { /** @default */ i: string; /** @default */ + x: string; + /** @default */ p: string; - /** @default 0 */ - s: string; - /** @default 0 */ - bt: string; - br?: string[]; - ba?: string[]; + /** @default */ + dt: string; + /** @default */ + r: string; + q?: { + [key: string]: unknown; + }; + a?: unknown; }; StateEERecord: { /** @default 0 */ @@ -935,34 +1254,6 @@ export interface components { role: string; eid: string; }; - RpyV1: { - /** @default */ - v: string; - /** @default */ - t: string; - /** @default */ - d: string; - /** @default */ - dt: string; - /** @default */ - r: string; - a?: unknown; - }; - RpyV2: { - /** @default */ - v: string; - /** @default */ - t: string; - /** @default */ - d: string; - /** @default */ - i: string; - /** @default */ - dt: string; - /** @default */ - r: string; - a?: unknown; - }; Rpy: components["schemas"]["RpyV1"] | components["schemas"]["RpyV2"]; Challenge: { words: string[]; diff --git a/test-integration/singlesig-ixn.test.ts b/test-integration/singlesig-ixn.test.ts index aa7513c1..fbb2eb76 100644 --- a/test-integration/singlesig-ixn.test.ts +++ b/test-integration/singlesig-ixn.test.ts @@ -1,4 +1,4 @@ -import { EventResult, SignifyClient } from 'signify-ts'; +import signify, { EventResult, SignifyClient } from 'signify-ts'; import { assertOperations, getOrCreateClients, @@ -25,11 +25,6 @@ afterAll(async () => { await assertOperations(client1, client2); }); -interface KeyState { - i: string; - s: string; - [property: string]: any; -} describe('singlesig-ixn', () => { test('step1', async () => { @@ -46,9 +41,9 @@ describe('singlesig-ixn', () => { }); test('ixn1', async () => { // local keystate before ixn - const keystate0: KeyState = ( + const keystate0: signify.KeyState = ( await client1.keyStates().get(name1_id) - ).at(0); + ).at(0)!; expect(keystate0).not.toBeNull(); // ixn @@ -58,17 +53,17 @@ describe('singlesig-ixn', () => { await waitOperation(client1, await result.op()); // local keystate after ixn - const keystate1: KeyState = ( + const keystate1: signify.KeyState = ( await client1.keyStates().get(name1_id) - ).at(0); + ).at(0)!; expect(parseInt(keystate1.s)).toBeGreaterThan(0); // sequence has incremented assert.equal(parseInt(keystate1.s), parseInt(keystate0.s) + 1); // remote keystate after ixn - const keystate2: KeyState = ( + const keystate2: signify.KeyState = ( await client2.keyStates().get(contact1_id) - ).at(0); + ).at(0)!; // remote keystate is one behind assert.equal(parseInt(keystate2.s), parseInt(keystate1.s) - 1); @@ -77,7 +72,7 @@ describe('singlesig-ixn', () => { .keyStates() .query(contact1_id, keystate1.s, undefined); op = await waitOperation(client2, op); - const keystate3: KeyState = op.response; + const keystate3: signify.KeyState = op.response; // local and remote keystate match assert.equal(keystate3.s, keystate1.s); }); diff --git a/test-integration/singlesig-rot.test.ts b/test-integration/singlesig-rot.test.ts index cf07b070..4f439d88 100644 --- a/test-integration/singlesig-rot.test.ts +++ b/test-integration/singlesig-rot.test.ts @@ -1,5 +1,5 @@ import { afterAll, assert, beforeAll, describe, expect, test } from 'vitest'; -import { EventResult, RotateIdentifierArgs, SignifyClient } from 'signify-ts'; +import signify, { EventResult, RotateIdentifierArgs, SignifyClient } from 'signify-ts'; import { assertOperations, getOrCreateClients, @@ -25,14 +25,6 @@ afterAll(async () => { await assertOperations(client1, client2); }); -interface KeyState { - i: string; - s: string; - k: string[]; - n: string[]; - [property: string]: any; -} - describe('singlesig-rot', () => { test('step1', async () => { assert.equal(name1_id, contact1_id); @@ -48,9 +40,9 @@ describe('singlesig-rot', () => { }); test('rot1', async () => { // local keystate before rot - const keystate0: KeyState = ( + const keystate0: signify.KeyState = ( await client1.keyStates().get(name1_id) - ).at(0); + ).at(0)!; expect(keystate0).not.toBeNull(); assert.strictEqual(keystate0.k.length, 1); assert.strictEqual(keystate0.n.length, 1); @@ -63,9 +55,9 @@ describe('singlesig-rot', () => { await waitOperation(client1, await result.op()); // local keystate after rot - const keystate1: KeyState = ( + const keystate1: signify.KeyState = ( await client1.keyStates().get(name1_id) - ).at(0); + ).at(0)!; expect(parseInt(keystate1.s)).toBeGreaterThan(0); // sequence has incremented assert.equal(parseInt(keystate1.s), parseInt(keystate0.s) + 1); @@ -75,9 +67,9 @@ describe('singlesig-rot', () => { expect(keystate1.n[0]).not.toEqual(keystate0.n[0]); // remote keystate after rot - const keystate2: KeyState = ( + const keystate2: signify.KeyState = ( await client2.keyStates().get(contact1_id) - ).at(0); + ).at(0)!; // remote keystate is one behind assert.equal(parseInt(keystate2.s), parseInt(keystate1.s) - 1); @@ -86,7 +78,7 @@ describe('singlesig-rot', () => { .keyStates() .query(contact1_id, keystate1.s, undefined); op = await waitOperation(client2, op); - const keystate3: KeyState = op.response; + const keystate3: signify.KeyState = op.response; // local and remote keystate match assert.equal(keystate3.s, keystate1.s); assert.equal(keystate3.k[0], keystate1.k[0]); From d984b3cc11cee0f8b2d9072bd2612889b7d991e0 Mon Sep 17 00:00:00 2001 From: Patrick Vu Date: Wed, 27 Aug 2025 16:31:09 +0700 Subject: [PATCH 4/6] fix an error for multisig tests --- src/keri/app/contacting.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/keri/app/contacting.ts b/src/keri/app/contacting.ts index 63d912f1..cbe4a098 100644 --- a/src/keri/app/contacting.ts +++ b/src/keri/app/contacting.ts @@ -192,6 +192,14 @@ export class Challenges { said: said, }; const res = await this.client.fetch(path, method, data); - return await res.json() as Operation; + // Check for empty response + if (res.status === 204 || res.headers.get('content-length') === '0') { + return {} as Operation; + } + const text = await res.text(); + if (!text) { + return {} as Operation; + } + return JSON.parse(text) as Operation; } } From 65af0eeb715e30c5c4feba608f2979ff380657ff Mon Sep 17 00:00:00 2001 From: Patrick Vu Date: Wed, 15 Oct 2025 16:47:50 +0700 Subject: [PATCH 5/6] fix after rebasing from parent branch --- src/keri/app/clienting.ts | 2 +- src/keri/app/coring.ts | 6 +- src/keri/core/keeping.ts | 115 ++-- src/keri/core/keyState.ts | 1 - src/keri/core/salter.ts | 3 - src/types/keria-api-schema.ts | 918 ++++++------------------- test-integration/singlesig-ixn.test.ts | 1 - test-integration/singlesig-rot.test.ts | 6 +- test-integration/utils/test-setup.ts | 153 ----- test/app/registry.test.ts | 4 +- test/core/manager.test.ts | 2 + 11 files changed, 283 insertions(+), 928 deletions(-) delete mode 100644 test-integration/utils/test-setup.ts diff --git a/src/keri/app/clienting.ts b/src/keri/app/clienting.ts index ca26942e..53debd7e 100644 --- a/src/keri/app/clienting.ts +++ b/src/keri/app/clienting.ts @@ -18,7 +18,7 @@ import { Notifications } from './notifying.ts'; const DEFAULT_BOOT_URL = 'http://localhost:3903'; // Export type outside the class -export type AgentResourceResult = components["schemas"]["AgentResourceResult"]; +export type AgentResourceResult = components['schemas']['AgentResourceResult']; class State { agent: any | null; diff --git a/src/keri/app/coring.ts b/src/keri/app/coring.ts index 84ecf721..f0683999 100644 --- a/src/keri/app/coring.ts +++ b/src/keri/app/coring.ts @@ -267,7 +267,11 @@ export class KeyStates { * @param {any} [anchor] Optional anchor * @returns {Promise>} A promise to the long-running operation */ - async query(pre: string, sn?: string, anchor?: any): Promise> { + async query( + pre: string, + sn?: string, + anchor?: any + ): Promise> { const path = `/queries`; const data: any = { pre: pre, diff --git a/src/keri/core/keeping.ts b/src/keri/core/keeping.ts index 99eeffdc..fb520c4e 100644 --- a/src/keri/core/keeping.ts +++ b/src/keri/core/keeping.ts @@ -181,57 +181,82 @@ export class IdentifierManagerFactory { let kargs: any; if (Algos.salty in aid) { - return new SaltyIdentifierManager( - this.salter, - aid.salty.pidx, - aid.salty.kidx, - aid.salty.tier, - aid.salty.transferable, - aid.salty.stem, - undefined, - undefined, - aid.salty.icodes, - undefined, - undefined, - aid.salty.ncodes, - aid.salty.dcode, - undefined, - aid.salty.sxlt - ); + algo = Algos.salty; + kargs = aid.salty; } else if (Algos.randy in aid) { - return new RandyIdentifierManager( - this.salter, - undefined, - undefined, - undefined, - new Prefixer({ qb64: aid['prefix'] }).transferable, - undefined, - undefined, - [], - undefined, - aid.randy.prxs, - aid.randy.nxts - ); + algo = Algos.randy; + kargs = aid.randy; } else if (Algos.group in aid) { - return new GroupIdentifierManager( - this, - aid.group.mhab, - undefined, - undefined, - aid.group.keys, - aid.group.ndigs - ); + algo = Algos.group; + kargs = aid.group; } else if (Algos.extern in aid) { - const typ = aid.extern.extern_type; - if (typ in this.modules) { - const mod = new this.modules[typ](aid.extern.pidx, aid.extern); - return mod; - } else { - throw new Error(`unsupported external module type ${typ}`); - } + algo = Algos.extern; + kargs = aid.extern; } else { throw new Error('No algo specified'); } + + if (!kargs) { + throw new Error('No kargs found in HabState'); + } + switch (algo) { + case Algos.salty: + kargs = kargs as SaltyKeyState; + return new SaltyIdentifierManager( + this.salter, + kargs.pidx, + kargs.kidx, + kargs.tier, + kargs.transferable, + kargs.stem, + undefined, + undefined, + kargs.icodes, + undefined, + undefined, + kargs.ncodes, + kargs.dcode, + undefined, + kargs.sxlt + ); + case Algos.randy: + kargs = kargs as RandyKeyState; + return new RandyIdentifierManager( + this.salter, + undefined, + undefined, + undefined, + new Prefixer({ qb64: aid['prefix'] }).transferable, + undefined, + undefined, + [], + undefined, + kargs.prxs, + kargs.nxts + ); + case Algos.group: + kargs = kargs as GroupKeyState; + return new GroupIdentifierManager( + this, + kargs.mhab, + undefined, + undefined, + kargs.keys, + kargs.ndigs + ); + case Algos.extern: { + kargs = kargs as ExternState; + const typ = kargs.extern_type; + if (typ in this.modules) { + const mod = new this.modules[typ](kargs.pidx, kargs); + return mod; + } else { + throw new Error(`unsupported external module type ${typ}`); + } + } + default: + throw new Error('Algo not allowed yet'); + } } } diff --git a/src/keri/core/keyState.ts b/src/keri/core/keyState.ts index 3c21a2b6..924fe436 100644 --- a/src/keri/core/keyState.ts +++ b/src/keri/core/keyState.ts @@ -45,4 +45,3 @@ export type HabState = | RandyHabState | GroupHabState | ExternHabState; - diff --git a/src/keri/core/salter.ts b/src/keri/core/salter.ts index a06c39d3..46064a9e 100644 --- a/src/keri/core/salter.ts +++ b/src/keri/core/salter.ts @@ -4,9 +4,6 @@ import { Matter, MtrDex } from './matter.ts'; import { EmptyMaterialError } from './kering.ts'; import libsodium from 'libsodium-wrappers-sumo'; import { Tier } from '../../types/keria-api-schema.ts'; - -export { Tier } from '../../types/keria-api-schema.ts'; - export { Tier } from '../../types/keria-api-schema.ts'; interface SalterArgs { diff --git a/src/types/keria-api-schema.ts b/src/types/keria-api-schema.ts index 8440f4db..d4592124 100644 --- a/src/types/keria-api-schema.ts +++ b/src/types/keria-api-schema.ts @@ -1,37 +1,4 @@ -// AUTO-GENERATED: Only components and enums retained from OpenAPI schema - -export enum IssEvtT { - iss = "iss", - bis = "bis" -} - -export enum CredentialStateIssOrRevEt { - iss = "iss", - rev = "rev" -} - -export enum CredentialStateBisOrBrvEt { - bis = "bis", - brv = "brv" -} - -export enum Tier { - low = "low", - med = "med", - high = "high" -} - -export enum OOBIRole { - controller = "controller", - witness = "witness", - registrar = "registrar", - watcher = "watcher", - judge = "judge", - juror = "juror", - peer = "peer", - mailbox = "mailbox", - agent = "agent" -} +// AUTO-GENERATED: Only components retained from OpenAPI schema export interface components { schemas: { @@ -285,6 +252,169 @@ export interface components { r: string; a: unknown; }; + RCT_V_1: { + v: string; + t: string; + d: string; + i: string; + s: string; + }; + RCT_V_2: { + v: string; + t: string; + d: string; + i: string; + s: string; + }; + QRY_V_1: { + v: string; + t: string; + d: string; + dt: string; + r: string; + rr: string; + q: { + [key: string]: unknown; + }; + }; + QRY_V_2: { + v: string; + t: string; + d: string; + i: string; + dt: string; + r: string; + rr: string; + q: { + [key: string]: unknown; + }; + }; + PRO_V_1: { + v: string; + t: string; + d: string; + dt: string; + r: string; + rr: string; + q: { + [key: string]: unknown; + }; + }; + PRO_V_2: { + v: string; + t: string; + d: string; + i: string; + dt: string; + r: string; + rr: string; + q: { + [key: string]: unknown; + }; + }; + BAR_V_1: { + v: string; + t: string; + d: string; + dt: string; + r: string; + a: unknown; + }; + BAR_V_2: { + v: string; + t: string; + d: string; + i: string; + dt: string; + r: string; + a: unknown; + }; + XIP_V_2: { + v: string; + t: string; + d: string; + i: string; + dt: string; + r: string; + q: { + [key: string]: unknown; + }; + a: unknown; + }; + EXN_V_1: { + v: string; + t: string; + d: string; + i: string; + rp: string; + p: string; + dt: string; + r: string; + q: { + [key: string]: unknown; + }; + a: unknown; + e: { + [key: string]: unknown; + }; + }; + EXN_V_2: { + v: string; + t: string; + d: string; + i: string; + x: string; + p: string; + dt: string; + r: string; + q: { + [key: string]: unknown; + }; + a: unknown; + }; + ISS_V_1: { + v: string; + t: string; + d: string; + i: string; + s: string; + ri: string; + dt: string; + }; + REV_V_1: { + v: string; + t: string; + d: string; + i: string; + s: string; + ri: string; + p: string; + dt: string; + }; + BIS_V_1: { + v: string; + t: string; + d: string; + i: string; + ii: string; + s: string; + ra: { + [key: string]: unknown; + }; + dt: string; + }; + BRV_V_1: { + v: string; + t: string; + d: string; + i: string; + s: string; + p: string; + ra: { + [key: string]: unknown; + }; + dt: string; + }; Credential: { sad: | components['schemas']['ACDC_V_1'] @@ -573,693 +703,41 @@ export interface components { signing: components['schemas']['AidRecord'][]; rotation: components['schemas']['AidRecord'][]; }; - IcpV1: { - /** @default */ - v: string; - /** @default */ - t: string; - /** @default */ - d: string; - /** @default */ - i: string; - /** @default 0 */ - s: string; - /** @default 0 */ - kt: string; - k?: string[]; - /** @default 0 */ - nt: string; - n?: string[]; - /** @default 0 */ - bt: string; - b?: string[]; - c?: string[]; - a?: unknown; - }; - RotV1: { - /** @default */ - v: string; - /** @default */ - t: string; - /** @default */ - d: string; - /** @default */ - i: string; - /** @default 0 */ - s: string; - /** @default */ - p: string; - /** @default 0 */ - kt: string; - k?: string[]; - /** @default 0 */ - nt: string; - n?: string[]; - /** @default 0 */ - bt: string; - br?: string[]; - ba?: string[]; - a?: unknown; - }; - DipV1: { - /** @default */ - v: string; - /** @default */ - t: string; - /** @default */ - d: string; - /** @default */ - i: string; - /** @default 0 */ - s: string; - /** @default 0 */ - kt: string; - k?: string[]; - /** @default 0 */ - nt: string; - n?: string[]; - /** @default 0 */ - bt: string; - b?: string[]; - c?: string[]; - a?: unknown; - /** @default */ - di: string; - }; - DrtV1: { - /** @default */ - v: string; - /** @default */ - t: string; - /** @default */ - d: string; - /** @default */ - i: string; - /** @default 0 */ - s: string; - /** @default */ - p: string; - /** @default 0 */ - kt: string; - k?: string[]; - /** @default 0 */ - nt: string; - n?: string[]; - /** @default 0 */ - bt: string; - br?: string[]; - ba?: string[]; - a?: unknown; - }; - VcpV1: { - /** @default */ - v: string; - /** @default */ - t: string; - /** @default */ - d: string; - /** @default */ - i: string; - /** @default */ - ii: string; - /** @default 0 */ - s: string; - c?: string[]; - /** @default 0 */ - bt: string; - b?: string[]; - /** @default */ - n: string; + KeyEventRecord: { + ked: + | components['schemas']['ICP_V_1'] + | components['schemas']['ROT_V_1'] + | components['schemas']['IXN_V_1'] + | components['schemas']['DIP_V_1'] + | components['schemas']['DRT_V_1'] + | components['schemas']['RCT_V_1'] + | components['schemas']['QRY_V_1'] + | components['schemas']['RPY_V_1'] + | components['schemas']['PRO_V_1'] + | components['schemas']['BAR_V_1'] + | components['schemas']['EXN_V_1'] + | components['schemas']['VCP_V_1'] + | components['schemas']['VRT_V_1'] + | components['schemas']['ISS_V_1'] + | components['schemas']['REV_V_1'] + | components['schemas']['BIS_V_1'] + | components['schemas']['BRV_V_1'] + | components['schemas']['ICP_V_2'] + | components['schemas']['ROT_V_2'] + | components['schemas']['IXN_V_2'] + | components['schemas']['DIP_V_2'] + | components['schemas']['DRT_V_2'] + | components['schemas']['RCT_V_2'] + | components['schemas']['QRY_V_2'] + | components['schemas']['RPY_V_2'] + | components['schemas']['PRO_V_2'] + | components['schemas']['BAR_V_2'] + | components['schemas']['XIP_V_2'] + | components['schemas']['EXN_V_2']; + atc: string; }; - VrtV1: { - /** @default */ - v: string; - /** @default */ - t: string; - /** @default */ - d: string; - /** @default */ - i: string; - /** @default */ - p: string; - /** @default 0 */ - s: string; - /** @default 0 */ - bt: string; - br?: string[]; - ba?: string[]; - }; - IxnV1: { - /** @default */ - v: string; - /** @default */ - t: string; - /** @default */ - d: string; - /** @default */ - i: string; - /** @default 0 */ - s: string; - /** @default */ - p: string; - a?: unknown; - }; - RctV1: { - /** @default */ - v: string; - /** @default */ - t: string; - /** @default */ - d: string; - /** @default */ - i: string; - /** @default 0 */ - s: string; - }; - QryV1: { - /** @default */ - v: string; - /** @default */ - t: string; - /** @default */ - d: string; - /** @default */ - dt: string; - /** @default */ - r: string; - /** @default */ - rr: string; - q?: { - [key: string]: unknown; - }; - }; - RpyV1: { - /** @default */ - v: string; - /** @default */ - t: string; - /** @default */ - d: string; - /** @default */ - dt: string; - /** @default */ - r: string; - a?: unknown; - }; - ProV1: { - /** @default */ - v: string; - /** @default */ - t: string; - /** @default */ - d: string; - /** @default */ - dt: string; - /** @default */ - r: string; - /** @default */ - rr: string; - q?: { - [key: string]: unknown; - }; - }; - BarV1: { - /** @default */ - v: string; - /** @default */ - t: string; - /** @default */ - d: string; - /** @default */ - dt: string; - /** @default */ - r: string; - a?: unknown; - }; - ExnV1: { - /** @default */ - v: string; - /** @default */ - t: string; - /** @default */ - d: string; - /** @default */ - i: string; - /** @default */ - rp: string; - /** @default */ - p: string; - /** @default */ - dt: string; - /** @default */ - r: string; - q?: { - [key: string]: unknown; - }; - a?: unknown; - e?: { - [key: string]: unknown; - }; - }; - IssV1: { - /** @default */ - v: string; - /** @default */ - t: string; - /** @default */ - d: string; - /** @default */ - i: string; - /** @default 0 */ - s: string; - /** @default */ - ri: string; - /** @default */ - dt: string; - }; - RevV1: { - /** @default */ - v: string; - /** @default */ - t: string; - /** @default */ - d: string; - /** @default */ - i: string; - /** @default 0 */ - s: string; - /** @default */ - ri: string; - /** @default */ - p: string; - /** @default */ - dt: string; - }; - BisV1: { - /** @default */ - v: string; - /** @default */ - t: string; - /** @default */ - d: string; - /** @default */ - i: string; - /** @default */ - ii: string; - /** @default 0 */ - s: string; - ra?: { - [key: string]: unknown; - }; - /** @default */ - dt: string; - }; - BrvV1: { - /** @default */ - v: string; - /** @default */ - t: string; - /** @default */ - d: string; - /** @default */ - i: string; - /** @default 0 */ - s: string; - /** @default */ - p: string; - ra?: { - [key: string]: unknown; - }; - /** @default */ - dt: string; - }; - IcpV2: { - /** @default */ - v: string; - /** @default */ - t: string; - /** @default */ - d: string; - /** @default */ - i: string; - /** @default 0 */ - s: string; - /** @default 0 */ - kt: string; - k?: string[]; - /** @default 0 */ - nt: string; - n?: string[]; - /** @default 0 */ - bt: string; - b?: string[]; - c?: string[]; - a?: unknown; - }; - RotV2: { - /** @default */ - v: string; - /** @default */ - t: string; - /** @default */ - d: string; - /** @default */ - i: string; - /** @default 0 */ - s: string; - /** @default */ - p: string; - /** @default 0 */ - kt: string; - k?: string[]; - /** @default 0 */ - nt: string; - n?: string[]; - /** @default 0 */ - bt: string; - br?: string[]; - ba?: string[]; - c?: string[]; - a?: unknown; - }; - DipV2: { - /** @default */ - v: string; - /** @default */ - t: string; - /** @default */ - d: string; - /** @default */ - i: string; - /** @default 0 */ - s: string; - /** @default 0 */ - kt: string; - k?: string[]; - /** @default 0 */ - nt: string; - n?: string[]; - /** @default 0 */ - bt: string; - b?: string[]; - c?: string[]; - a?: unknown; - /** @default */ - di: string; - }; - DrtV2: { - /** @default */ - v: string; - /** @default */ - t: string; - /** @default */ - d: string; - /** @default */ - i: string; - /** @default 0 */ - s: string; - /** @default */ - p: string; - /** @default 0 */ - kt: string; - k?: string[]; - /** @default 0 */ - nt: string; - n?: string[]; - /** @default 0 */ - bt: string; - br?: string[]; - ba?: string[]; - c?: string[]; - a?: unknown; - }; - IxnV2: { - /** @default */ - v: string; - /** @default */ - t: string; - /** @default */ - d: string; - /** @default */ - i: string; - /** @default 0 */ - s: string; - /** @default */ - p: string; - a?: unknown; - }; - RctV2: { - /** @default */ - v: string; - /** @default */ - t: string; - /** @default */ - d: string; - /** @default */ - i: string; - /** @default 0 */ - s: string; - }; - QryV2: { - /** @default */ - v: string; - /** @default */ - t: string; - /** @default */ - d: string; - /** @default */ - i: string; - /** @default */ - dt: string; - /** @default */ - r: string; - /** @default */ - rr: string; - q?: { - [key: string]: unknown; - }; - }; - RpyV2: { - /** @default */ - v: string; - /** @default */ - t: string; - /** @default */ - d: string; - /** @default */ - i: string; - /** @default */ - dt: string; - /** @default */ - r: string; - a?: unknown; - }; - ProV2: { - /** @default */ - v: string; - /** @default */ - t: string; - /** @default */ - d: string; - /** @default */ - i: string; - /** @default */ - dt: string; - /** @default */ - r: string; - /** @default */ - rr: string; - q?: { - [key: string]: unknown; - }; - }; - BarV2: { - /** @default */ - v: string; - /** @default */ - t: string; - /** @default */ - d: string; - /** @default */ - i: string; - /** @default */ - dt: string; - /** @default */ - r: string; - a?: unknown; - }; - XipV2: { - /** @default */ - v: string; - /** @default */ - t: string; - /** @default */ - d: string; - /** @default */ - i: string; - /** @default */ - dt: string; - /** @default */ - r: string; - q?: { - [key: string]: unknown; - }; - a?: unknown; - }; - ExnV2: { - /** @default */ - v: string; - /** @default */ - t: string; - /** @default */ - d: string; - /** @default */ - i: string; - /** @default */ - x: string; - /** @default */ - p: string; - /** @default */ - dt: string; - /** @default */ - r: string; - q?: { - [key: string]: unknown; - }; - a?: unknown; - }; - StateEERecord: { - /** @default 0 */ - s: string; - /** @default */ - d: string; - br?: unknown[]; - ba?: unknown[]; - }; - KeyStateRecord: { - vn?: number[]; - /** @default */ - i: string; - /** @default 0 */ - s: string; - /** @default */ - p: string; - /** @default */ - d: string; - /** @default 0 */ - f: string; - /** @default */ - dt: string; - /** @default */ - et: string; - /** @default 0 */ - kt: string; - k: string[]; - /** @default 0 */ - nt: string; - n: string[]; - /** @default 0 */ - bt: string; - b: string[]; - c: string[]; - ee: components["schemas"]["StateEERecord"]; - /** @default */ - di: string; - }; - Controller: { - state: components["schemas"]["KeyStateRecord"]; - ee: components["schemas"]["IcpV1"] | components["schemas"]["IcpV2"] | components["schemas"]["RotV1"] | components["schemas"]["RotV2"] | components["schemas"]["DipV1"] | components["schemas"]["DipV2"] | components["schemas"]["DrtV1"] | components["schemas"]["DrtV2"] | components["schemas"]["VcpV1"] | components["schemas"]["VrtV1"]; - }; - AgentResourceResult: { - agent: components["schemas"]["KeyStateRecord"]; - controller: components["schemas"]["Controller"]; - pidx: number; - /** @default null */ - ridx: number | null; - /** @default null */ - sxlt: string | null; - }; - SaltyState: { - tier: components["schemas"]["Tier"]; - /** @default */ - sxlt: string; - /** @default 0 */ - pidx: number; - /** @default 0 */ - kidx: number; - /** @default */ - stem: string; - /** @default */ - dcode: string; - icodes: string[]; - ncodes: string[]; - /** @default false */ - transferable: boolean; - }; - RandyKeyState: { - prxs: string[]; - nxts: string[]; - }; - HabState: { - name: string; - prefix: string; - icp_dt: string; - state: components["schemas"]["KeyStateRecord"]; - /** @default null */ - transferable: boolean | null; - /** @default null */ - windexes: string[] | null; - }; - GroupKeyState: { - mhab: components["schemas"]["Identifier"]; - keys: string[]; - ndigs: string[]; - }; - ExternState: { - extern_type: string; - pidx: number; - } & { - [key: string]: unknown; - }; - Identifier: { - name: string; - prefix: string; - icp_dt: string; - state: components["schemas"]["KeyStateRecord"]; - /** @default null */ - transferable: boolean | null; - /** @default null */ - windexes: string[] | null; - } & ({ - salty: components["schemas"]["SaltyState"]; - } | { - randy: components["schemas"]["RandyKeyState"]; - } | { - group: components["schemas"]["GroupKeyState"]; - } | { - extern: components["schemas"]["ExternState"]; - }); - /** - * @description Tier of key material - * @enum {string} - */ - Tier: Tier; - OOBI: { - /** @enum {string} */ - role: OOBIRole; - oobis: string[]; - }; - EndRole: { - cid: string; - role: string; - eid: string; - }; - Rpy: components["schemas"]["RpyV1"] | components["schemas"]["RpyV2"]; - Challenge: { - words: string[]; - dt?: string; - said?: string; - authenticated?: boolean; + AgentConfig: { + iurls?: string[]; }; }; responses: never; diff --git a/test-integration/singlesig-ixn.test.ts b/test-integration/singlesig-ixn.test.ts index fbb2eb76..0aca5f17 100644 --- a/test-integration/singlesig-ixn.test.ts +++ b/test-integration/singlesig-ixn.test.ts @@ -25,7 +25,6 @@ afterAll(async () => { await assertOperations(client1, client2); }); - describe('singlesig-ixn', () => { test('step1', async () => { assert.equal(name1_id, contact1_id); diff --git a/test-integration/singlesig-rot.test.ts b/test-integration/singlesig-rot.test.ts index 4f439d88..6364a666 100644 --- a/test-integration/singlesig-rot.test.ts +++ b/test-integration/singlesig-rot.test.ts @@ -1,5 +1,9 @@ import { afterAll, assert, beforeAll, describe, expect, test } from 'vitest'; -import signify, { EventResult, RotateIdentifierArgs, SignifyClient } from 'signify-ts'; +import signify, { + EventResult, + RotateIdentifierArgs, + SignifyClient, +} from 'signify-ts'; import { assertOperations, getOrCreateClients, diff --git a/test-integration/utils/test-setup.ts b/test-integration/utils/test-setup.ts deleted file mode 100644 index 71cf6ada..00000000 --- a/test-integration/utils/test-setup.ts +++ /dev/null @@ -1,153 +0,0 @@ -import { - CreateIdentiferArgs, - EventResult, - SignifyClient, - Tier, - randomPasscode, - ready, -} from 'signify-ts'; -import { resolveEnvironment } from './resolve-env.ts'; -import { waitOperation } from './test-util.ts'; - -/** - * Connect or boot a SignifyClient instance - */ -export async function getOrCreateClient( - bran: string | undefined = undefined -): Promise { - const env = resolveEnvironment(); - await ready(); - bran ??= randomPasscode(); - bran = bran.padEnd(21, '_'); - const client = new SignifyClient(env.url, bran, Tier.low, env.bootUrl); - try { - await client.connect(); - } catch { - const res = await client.boot(); - if (!res.ok) throw new Error(); - await client.connect(); - } - console.log('client', { - agent: client.agent?.pre, - controller: client.controller.pre, - }); - return client; -} - -/** - * Get or create a Keri identifier. Uses default witness config from `resolveEnvironment` - * @example - * Create a Keri identifier before running tests - * let name1_id: string, name1_oobi: string; - * beforeAll(async () => { - * [name1_id, name1_oobi] = await getOrCreateIdentifier(client1, "name1"); - * }); - * @see resolveEnvironment - */ -export async function getOrCreateIdentifier( - client: SignifyClient, - name: string, - kargs: CreateIdentiferArgs | undefined = undefined -): Promise<[string, string]> { - let id: string; - try { - const identfier = await client.identifiers().get(name); - // console.log("identifiers.get", identfier); - id = identfier.prefix; - } catch { - const env = resolveEnvironment(); - kargs ??= { - toad: env.witnessIds.length, - wits: env.witnessIds, - }; - const result: EventResult = await client - .identifiers() - .create(name, kargs); - let op = await result.op(); - op = await waitOperation(client, op); - // console.log("identifiers.create", op); - id = op.response.i; - } - const eid = client.agent?.pre; - if (!eid) { - throw new Error('No agent on client'); - } - if (!(await hasEndRole(client, name, 'agent', eid))) { - const result: EventResult = await client - .identifiers() - .addEndRole(name, 'agent', eid); - const op = await result.op(); - await waitOperation(client, op); - // console.log("identifiers.addEndRole", op); - } - const oobi = await client.oobis().get(name, 'agent'); - const result: [string, string] = [id, oobi.oobis[0]]; - console.log(name, result); - return result; -} - -/** - * Get list of end role authorizations for a Keri idenfitier - */ -export async function getEndRoles( - client: SignifyClient, - alias: string, - role?: string -): Promise { - const path = - role !== undefined - ? `/identifiers/${alias}/endroles/${role}` - : `/identifiers/${alias}/endroles`; - const response: Response = await client.fetch(path, 'GET', null); - if (!response.ok) throw new Error(await response.text()); - const result = await response.json(); - // console.log("getEndRoles", result); - return result; -} - -/** - * Test if end role is authorized for a Keri identifier - */ -export async function hasEndRole( - client: SignifyClient, - alias: string, - role: string, - eid: string -): Promise { - const list = await getEndRoles(client, alias, role); - for (const i of list) { - if (i.role === role && i.eid === eid) { - return true; - } - } - return false; -} - -/** - * Get or resolve a Keri contact - * @example - * Create a Keri contact before running tests - * let contact1_id: string; - * beforeAll(async () => { - * contact1_id = await getOrCreateContact(client2, "contact1", name1_oobi); - * }); - */ -export async function getOrCreateContact( - client: SignifyClient, - name: string, - oobi: string -): Promise { - const list = await client.contacts().list(undefined, 'alias', `^${name}$`); - // console.log("contacts.list", list); - if (list.length > 0) { - const contact = list[0]; - if (contact.oobi === oobi) { - // console.log("contacts.id", contact.id); - return contact.id; - } - } - let op = await client.oobis().resolve(oobi, name); - op = await waitOperation(client, op); - // console.log("oobis.resolve", op); - return op.response.i; -} diff --git a/test/app/registry.test.ts b/test/app/registry.test.ts index cff65027..44e26fcd 100644 --- a/test/app/registry.test.ts +++ b/test/app/registry.test.ts @@ -67,7 +67,7 @@ describe('registry', () => { const mockedClient = mock(SignifyClient); const mockedIdentifiers = mock(Identifier); - const hab = ({ + const hab = { prefix: 'hab prefix', state: { s: 0, d: 'a digest', c: ['EO'] } as unknown as KeyState, name: 'a name', @@ -78,7 +78,7 @@ describe('registry', () => { prxs: [], nxts: [], }, - } as unknown) as HabState; + } as unknown as HabState; when(mockedIdentifiers.get('a name')).thenResolve(hab); when(mockedClient.identifiers()).thenReturn( diff --git a/test/core/manager.test.ts b/test/core/manager.test.ts index 236e39b1..8a646e49 100644 --- a/test/core/manager.test.ts +++ b/test/core/manager.test.ts @@ -30,6 +30,8 @@ import { RandyKeyState, KeyState, HabState, + RandyHabState, + ExternHabState, } from '../../src/keri/core/keyState.ts'; import { randomUUID } from 'node:crypto'; From c5c0f7d6fc8123713539d468fe7995bc843f2cea Mon Sep 17 00:00:00 2001 From: Patrick Vu Date: Fri, 24 Oct 2025 17:51:39 +0700 Subject: [PATCH 6/6] fix conflicts and resolve review comments --- src/keri/app/contacting.ts | 10 +++--- src/keri/app/coring.ts | 12 +++---- src/types/keria-api-schema.ts | 47 +++++++++++++++++++------- test-integration/multisig-join.test.ts | 15 ++++---- test-integration/multisig.test.ts | 11 +++--- test-integration/singlesig-ixn.test.ts | 2 +- test-integration/singlesig-rot.test.ts | 2 +- test-integration/utils/test-util.ts | 3 +- 8 files changed, 65 insertions(+), 37 deletions(-) diff --git a/src/keri/app/contacting.ts b/src/keri/app/contacting.ts index cbe4a098..f05cce62 100644 --- a/src/keri/app/contacting.ts +++ b/src/keri/app/contacting.ts @@ -183,9 +183,9 @@ export class Challenges { * Mark challenge response as signed and accepted * @param source Prefix of the identifier that was challenged * @param said qb64 AID of exn message representing the signed response - * @returns {Promise>} A promise to the result + * @returns {Promise>} A promise to the result */ - async responded(source: string, said: string): Promise> { + async responded(source: string, said: string): Promise> { const path = `/challenges_verify/${source}`; const method = 'PUT'; const data = { @@ -194,12 +194,12 @@ export class Challenges { const res = await this.client.fetch(path, method, data); // Check for empty response if (res.status === 204 || res.headers.get('content-length') === '0') { - return {} as Operation; + return {} as Operation; } const text = await res.text(); if (!text) { - return {} as Operation; + return {} as Operation; } - return JSON.parse(text) as Operation; + return JSON.parse(text) as Operation; } } diff --git a/src/keri/app/coring.ts b/src/keri/app/coring.ts index f0683999..41fae8f4 100644 --- a/src/keri/app/coring.ts +++ b/src/keri/app/coring.ts @@ -37,7 +37,7 @@ export class Oobis { * Get the OOBI(s) for a managed indentifier for a given role * @param {string} name Name or alias of the identifier * @param {string} role Authorized role - * @returns {Promise} A promise to the OOBI(s) + * @returns {Promise} A promise to the OOBI(s) */ async get(name: string, role: string = 'agent'): Promise { const path = `/identifiers/${name}/oobis?role=${role}`; @@ -51,9 +51,9 @@ export class Oobis { * @async * @param {string} oobi The OOBI to be resolver * @param {string} [alias] Optional name or alias to link the OOBI resolution to a contact - * @returns {Promise>} A promise to the long-running operation + * @returns {Promise>} A promise to the long-running operation */ - async resolve(oobi: string, alias?: string): Promise> { + async resolve(oobi: string, alias?: string): Promise> { const path = `/oobis`; const data: any = { url: oobi, @@ -122,7 +122,7 @@ export class Operations { * @param {string} type Select operations by type * @returns {Promise} A list of operations */ - async list(type?: string): Promise[]> { + async list(type?: string): Promise[]> { const params = new URLSearchParams(); if (type !== undefined) { params.append('type', type); @@ -265,13 +265,13 @@ export class KeyStates { * @param {string} pre Identifier prefix * @param {number} [sn] Optional sequence number * @param {any} [anchor] Optional anchor - * @returns {Promise>} A promise to the long-running operation + * @returns {Promise>} A promise to the long-running operation */ async query( pre: string, sn?: string, anchor?: any - ): Promise> { + ): Promise> { const path = `/queries`; const data: any = { pre: pre, diff --git a/src/types/keria-api-schema.ts b/src/types/keria-api-schema.ts index d4592124..e940764f 100644 --- a/src/types/keria-api-schema.ts +++ b/src/types/keria-api-schema.ts @@ -329,18 +329,6 @@ export interface components { r: string; a: unknown; }; - XIP_V_2: { - v: string; - t: string; - d: string; - i: string; - dt: string; - r: string; - q: { - [key: string]: unknown; - }; - a: unknown; - }; EXN_V_1: { v: string; t: string; @@ -415,6 +403,41 @@ export interface components { }; dt: string; }; + XIP_V_2: { + v: string; + t: string; + d: string; + i: string; + dt: string; + r: string; + q: { + [key: string]: unknown; + }; + a: unknown; + }; + VCP_V_1: { + v: string; + t: string; + d: string; + i: string; + ii: string; + s: string; + c: string[]; + bt: string; + b: string[]; + n: string; + }; + VRT_V_1: { + v: string; + t: string; + d: string; + i: string; + p: string; + s: string; + bt: string; + br: string[]; + ba: string[]; + }; Credential: { sad: | components['schemas']['ACDC_V_1'] diff --git a/test-integration/multisig-join.test.ts b/test-integration/multisig-join.test.ts index 9968d893..7f6d65e1 100644 --- a/test-integration/multisig-join.test.ts +++ b/test-integration/multisig-join.test.ts @@ -1,4 +1,4 @@ -import signify, { Serder, SignifyClient } from 'signify-ts'; +import signify, { KeyState, Serder, SignifyClient } from 'signify-ts'; import { getOrCreateClient, getOrCreateIdentifier, @@ -213,8 +213,11 @@ describe('multisig-join', () => { waitOperation(client3, updates[5]), ]); - const states = [aid1State.response, aid2State.response]; - const rstates = [...states, aid3State.response]; + const states = [ + aid1State.response as KeyState, + aid2State.response as KeyState, + ]; + const rstates = [...states, aid3State.response as KeyState]; const rotateOperation1 = await client1 .identifiers() .rotate(nameMultisig, { states, rstates }); @@ -300,9 +303,9 @@ describe('multisig-join', () => { ]); const states = [ - aid1State.response, - aid2State.response, - aid3State.response, + aid1State.response as KeyState, + aid2State.response as KeyState, + aid3State.response as KeyState, ]; const rotateOperation1 = await client1 .identifiers() diff --git a/test-integration/multisig.test.ts b/test-integration/multisig.test.ts index e2ab2a76..e2d85b21 100644 --- a/test-integration/multisig.test.ts +++ b/test-integration/multisig.test.ts @@ -3,6 +3,7 @@ import signify, { SignifyClient, Serder, IssueCredentialResult, + KeyState, } from 'signify-ts'; import { resolveEnvironment } from './utils/resolve-env.ts'; import { @@ -108,14 +109,14 @@ test('multisig', async function run() { op1 = await client1.challenges().verify(aid2.prefix, words); op1 = await waitOperation(client1, op1); console.log('Member1 verified challenge response from member2'); - let exnwords = new Serder(op1.response.exn); + let exnwords = new Serder((op1.response as any)?.exn); op1 = await client1.challenges().responded(aid2.prefix, exnwords.sad.d); console.log('Member1 marked challenge response as accepted'); op1 = await client1.challenges().verify(aid3.prefix, words); op1 = await waitOperation(client1, op1); console.log('Member1 verified challenge response from member3'); - exnwords = new Serder(op1.response.exn); + exnwords = new Serder((op1.response as any)?.exn); op1 = await client1.challenges().responded(aid3.prefix, exnwords.sad.d); console.log('Member1 marked challenge response as accepted'); @@ -600,16 +601,16 @@ test('multisig', async function run() { // Update new key states op1 = await client1.keyStates().query(aid2.prefix, '1'); op1 = await waitOperation(client1, op1); - const aid2State = op1['response']; + const aid2State = op1['response'] as KeyState; op1 = await client1.keyStates().query(aid3.prefix, '1'); op1 = await waitOperation(client1, op1); - const aid3State = op1['response']; + const aid3State = op1['response'] as KeyState; op2 = await client2.keyStates().query(aid3.prefix, '1'); op2 = await waitOperation(client2, op2); op2 = await client2.keyStates().query(aid1.prefix, '1'); op2 = await waitOperation(client2, op2); - const aid1State = op2['response']; + const aid1State = op2['response'] as KeyState; op3 = await client3.keyStates().query(aid1.prefix, '1'); op3 = await waitOperation(client3, op3); diff --git a/test-integration/singlesig-ixn.test.ts b/test-integration/singlesig-ixn.test.ts index 0aca5f17..85bfffbd 100644 --- a/test-integration/singlesig-ixn.test.ts +++ b/test-integration/singlesig-ixn.test.ts @@ -71,7 +71,7 @@ describe('singlesig-ixn', () => { .keyStates() .query(contact1_id, keystate1.s, undefined); op = await waitOperation(client2, op); - const keystate3: signify.KeyState = op.response; + const keystate3: signify.KeyState = op.response as signify.KeyState; // local and remote keystate match assert.equal(keystate3.s, keystate1.s); }); diff --git a/test-integration/singlesig-rot.test.ts b/test-integration/singlesig-rot.test.ts index 6364a666..8bc55382 100644 --- a/test-integration/singlesig-rot.test.ts +++ b/test-integration/singlesig-rot.test.ts @@ -82,7 +82,7 @@ describe('singlesig-rot', () => { .keyStates() .query(contact1_id, keystate1.s, undefined); op = await waitOperation(client2, op); - const keystate3: signify.KeyState = op.response; + const keystate3: signify.KeyState = op.response as signify.KeyState; // local and remote keystate match assert.equal(keystate3.s, keystate1.s); assert.equal(keystate3.k[0], keystate1.k[0]); diff --git a/test-integration/utils/test-util.ts b/test-integration/utils/test-util.ts index 54dfb760..ba30ed5c 100644 --- a/test-integration/utils/test-util.ts +++ b/test-integration/utils/test-util.ts @@ -250,7 +250,8 @@ export async function getOrCreateContact( } let op = await client.oobis().resolve(oobi, name); op = await waitOperation(client, op); - return op.response.i; + const response = op.response as { i: string }; + return response.i; } /**