Skip to content

Commit fa0c2ca

Browse files
update TS types after changing End of these files: delegating.py, grouping.py, ipexing.py, notifying.py, exchanging.py
1 parent bc7e842 commit fa0c2ca

File tree

11 files changed

+255
-57
lines changed

11 files changed

+255
-57
lines changed

src/keri/app/contacting.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,7 @@ export class Challenges {
189189
async responded(source: string, said: string): Promise<Operation<any>> {
190190
const path = `/challenges_verify/${source}`;
191191
const method = 'PUT';
192-
const data = {
193-
said: said,
194-
};
192+
const data = { said: said };
195193
const res = await this.client.fetch(path, method, data);
196194
// Check for empty response
197195
if (res.status === 204 || res.headers.get('content-length') === '0') {

src/keri/app/credentialing.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ export class Ipex {
772772
exn: Serder,
773773
sigs: string[],
774774
recp: string[]
775-
): Promise<any> {
775+
): Promise<Operation<any>> {
776776
const body = {
777777
exn: exn.sad,
778778
sigs,
@@ -816,7 +816,7 @@ export class Ipex {
816816
sigs: string[],
817817
atc: string,
818818
recp: string[]
819-
): Promise<any> {
819+
): Promise<Operation<any>> {
820820
const body = {
821821
exn: exn.sad,
822822
sigs,
@@ -860,7 +860,7 @@ export class Ipex {
860860
exn: Serder,
861861
sigs: string[],
862862
recp: string[]
863-
): Promise<any> {
863+
): Promise<Operation<any>> {
864864
const body = {
865865
exn: exn.sad,
866866
sigs,
@@ -928,7 +928,7 @@ export class Ipex {
928928
sigs: string[],
929929
atc: string,
930930
recp: string[]
931-
): Promise<any> {
931+
): Promise<Operation<any>> {
932932
const body = {
933933
exn: exn.sad,
934934
sigs: sigs,
@@ -973,7 +973,7 @@ export class Ipex {
973973
sigs: string[],
974974
atc: string,
975975
recp: string[]
976-
): Promise<any> {
976+
): Promise<Operation<any>> {
977977
const body = {
978978
exn: exn.sad,
979979
sigs: sigs,

src/keri/app/exchanging.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ import { Pather } from '../core/pather.ts';
66
import { Counter, CtrDex } from '../core/counter.ts';
77
import { Saider } from '../core/saider.ts';
88
import { HabState } from '../core/keyState.ts';
9+
import { Exn } from './grouping.ts';
10+
import { components } from '../../types/keria-api-schema.ts';
11+
12+
13+
export type ExchangeResource = components["schemas"]["ExchangeResource"];
914

1015
/**
1116
* Exchanges
@@ -101,7 +106,7 @@ export class Exchanges {
101106
/**
102107
* Send exn messaget to list of recipients
103108
* @async
104-
* @returns {Promise<any>} A promise to the list of replay messages
109+
* @returns {Promise<Exn>} A promise to the list of replay messages
105110
* @param name
106111
* @param topic
107112
* @param exn
@@ -137,7 +142,7 @@ export class Exchanges {
137142
* @returns A promise to the exn message
138143
* @param said The said of the exn message
139144
*/
140-
async get(said: string): Promise<any> {
145+
async get(said: string): Promise<ExchangeResource> {
141146
const path = `/exchanges/${said}`;
142147
const method = 'GET';
143148
const res = await this.client.fetch(path, method, null);

src/keri/app/grouping.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import { SignifyClient } from './clienting.ts';
22
import { Dict } from '../core/core.ts';
3+
import { Operation } from './coring.ts';
4+
import { components } from '../../types/keria-api-schema.ts';
5+
6+
7+
export type Exn = components['schemas']['Exn'];
8+
export type ExnMultisig = components['schemas']['ExnMultisig'];
39

410
/**
511
* Groups
@@ -19,9 +25,9 @@ export class Groups {
1925
* Get group request messages
2026
* @async
2127
* @param {string} [said] SAID of exn message to load
22-
* @returns {Promise<any>} A promise to the list of replay messages
28+
* @returns {Promise<ExnMultisig[]>} A promise to the list of replay messages
2329
*/
24-
async getRequest(said: string): Promise<any> {
30+
async getRequest(said: string): Promise<ExnMultisig[]> {
2531
const path = `/multisig/request/` + said;
2632
const method = 'GET';
2733
const res = await this.client.fetch(path, method, null);
@@ -35,14 +41,14 @@ export class Groups {
3541
* @param {Dict<any>} [exn] exn message to send to other members
3642
* @param {string[]} [sigs] signature of the participant over the exn
3743
* @param {string} [atc] additional attachments from embedded events in exn
38-
* @returns {Promise<any>} A promise to the list of replay messages
44+
* @returns {Promise<Exn>} A promise to the list of replay messages
3945
*/
4046
async sendRequest(
4147
name: string,
4248
exn: Dict<any>,
4349
sigs: string[],
4450
atc: string
45-
): Promise<any> {
51+
): Promise<Exn> {
4652
const path = `/identifiers/${name}/multisig/request`;
4753
const method = 'POST';
4854
const data = {
@@ -64,7 +70,7 @@ export class Groups {
6470
* @param {string} [gid] prefix
6571
* @param {string[]} [smids] array of particpants
6672
* @param {string[]} [rmids] array of particpants
67-
* @returns {Promise<any>} A promise to the list of replay messages
73+
* @returns {Promise<Operation<any>} A promise to the list of replay messages
6874
*/
6975
async join(
7076
name: string,
@@ -73,7 +79,7 @@ export class Groups {
7379
gid: string,
7480
smids: string[],
7581
rmids: string[]
76-
): Promise<any> {
82+
): Promise<Operation<any>> {
7783
const path = `/identifiers/${name}/multisig/join`;
7884
const method = 'POST';
7985
const data = {

src/keri/core/keyState.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,9 @@ export type HabState =
4747
| GroupHabState
4848
| ExternHabState;
4949

50+
export type Icp = components['schemas']['IcpV1'] | components['schemas']['IcpV2'];
51+
export type Ixn = components['schemas']['IxnV1'] | components['schemas']['IxnV2'];
52+
export type ExnV1 = components['schemas']['IxnV1'] | components['schemas']['ExnV2'];
53+
export type MultisigExnEmbeds = components['schemas']['MultisigExnEmbeds'];
54+
export type MultisigInceptEmbeds = components['schemas']['MultisigInceptEmbeds'];
55+
export type MultisigRpyEmbeds = components['schemas']['MultisigRpyEmbeds'];

src/types/keria-api-schema.ts

Lines changed: 79 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ export interface components {
204204
b?: string[];
205205
c?: string[];
206206
a?: unknown;
207+
/** @default */
208+
di: string;
207209
};
208210
RotV1: {
209211
/** @default */
@@ -425,10 +427,10 @@ export interface components {
425427
q?: {
426428
[key: string]: unknown;
427429
};
428-
a?: unknown;
429-
e?: {
430+
a?: {
430431
[key: string]: unknown;
431432
};
433+
e?: components["schemas"]["ExnEmbeds"];
432434
};
433435
IssV1: {
434436
/** @default */
@@ -524,6 +526,8 @@ export interface components {
524526
b?: string[];
525527
c?: string[];
526528
a?: unknown;
529+
/** @default */
530+
di: string;
527531
};
528532
RotV2: {
529533
/** @default */
@@ -735,7 +739,9 @@ export interface components {
735739
q?: {
736740
[key: string]: unknown;
737741
};
738-
a?: unknown;
742+
a?: {
743+
[key: string]: unknown;
744+
};
739745
};
740746
StateEERecord: {
741747
/** @default 0 */
@@ -936,6 +942,76 @@ export interface components {
936942
AgentConfig: {
937943
iurls?: string[];
938944
};
945+
Exn: components["schemas"]["ExnV1"] | components["schemas"]["ExnV2"];
946+
Icp: components["schemas"]["IcpV1"] | components["schemas"]["IcpV2"];
947+
Rot: components["schemas"]["RotV1"] | components["schemas"]["RotV2"];
948+
Vcp: components["schemas"]["VcpV1"];
949+
Iss: components["schemas"]["IssV1"];
950+
Ixn: components["schemas"]["IxnV1"] | components["schemas"]["IxnV2"];
951+
NotificationData: {
952+
r: string;
953+
/** @default null */
954+
d: string | null;
955+
/** @default null */
956+
m: string | null;
957+
};
958+
Notification: {
959+
i: string;
960+
dt: string;
961+
r: boolean;
962+
a: components["schemas"]["NotificationData"];
963+
};
964+
ExchangeResource: {
965+
exn: components["schemas"]["Exn"];
966+
pathed: {
967+
[key: string]: unknown;
968+
};
969+
};
970+
MultisigInceptEmbeds: {
971+
icp: components["schemas"]["Icp"];
972+
rot?: components["schemas"]["Rot"];
973+
};
974+
MultisigRotateEmbeds: {
975+
rot: unknown;
976+
};
977+
MultisigInteractEmbeds: {
978+
ixn: components["schemas"]["Ixn"];
979+
};
980+
MultisigRegistryInceptEmbeds: {
981+
vcp: components["schemas"]["Vcp"];
982+
anc: components["schemas"]["ANC"];
983+
};
984+
MultisigIssueEmbeds: {
985+
acdc: components["schemas"]["ACDC"];
986+
iss: components["schemas"]["Iss"];
987+
anc: components["schemas"]["ANC"];
988+
};
989+
MultisigRevokeEmbeds: {
990+
rev: components["schemas"]["RevV1"];
991+
anc: components["schemas"]["ANC"];
992+
};
993+
MultisigRpyEmbeds: {
994+
rpy: components["schemas"]["Rpy"];
995+
};
996+
MultisigExnEmbeds: {
997+
exn: components["schemas"]["Exn"];
998+
};
999+
ExnEmbeds: {
1000+
d: string;
1001+
} & (components["schemas"]["MultisigInceptEmbeds"] | components["schemas"]["MultisigRotateEmbeds"] | components["schemas"]["MultisigInteractEmbeds"] | components["schemas"]["MultisigRegistryInceptEmbeds"] | components["schemas"]["MultisigIssueEmbeds"] | components["schemas"]["MultisigRevokeEmbeds"] | components["schemas"]["MultisigRpyEmbeds"] | components["schemas"]["MultisigExnEmbeds"]);
1002+
ExnMultisig: {
1003+
exn: components["schemas"]["Exn"];
1004+
paths: {
1005+
[key: string]: unknown;
1006+
};
1007+
e: components["schemas"]["ExnEmbeds"];
1008+
/** @default null */
1009+
groupName: string | null;
1010+
/** @default null */
1011+
memberName: string | null;
1012+
/** @default null */
1013+
sender: string | null;
1014+
};
9391015
};
9401016
responses: never;
9411017
parameters: never;

test-integration/credentials.test.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,9 @@ test('single signature credentials', { timeout: 90000 }, async () => {
344344
const apply = await holderClient.exchanges().get(holderApplyNote.a.d);
345345
applySaid = apply.exn.d;
346346

347-
const filter: { [x: string]: any } = { '-s': apply.exn.a.s };
348-
for (const key in apply.exn.a.a) {
349-
filter[`-a-${key}`] = apply.exn.a.a[key];
347+
const filter: { [x: string]: any } = { '-s': (apply.exn.a as any).s };
348+
for (const key in (apply.exn.a as any).a) {
349+
filter[`-a-${key}`] = (apply.exn.a as any).a[key];
350350
}
351351

352352
const matchingCreds = await holderClient.credentials().list({ filter });
@@ -385,6 +385,18 @@ test('single signature credentials', { timeout: 90000 }, async () => {
385385
offerSaid = offer.exn.d;
386386

387387
assert.strictEqual(offer.exn.p, applySaid);
388+
assert(
389+
'e' in offer.exn &&
390+
offer.exn.e &&
391+
typeof offer.exn.e === 'object' &&
392+
'acdc' in offer.exn.e &&
393+
offer.exn.e.acdc &&
394+
typeof offer.exn.e.acdc === 'object' &&
395+
'a' in offer.exn.e.acdc &&
396+
offer.exn.e.acdc.a &&
397+
typeof offer.exn.e.acdc.a === 'object' &&
398+
'LEI' in offer.exn.e.acdc.a
399+
);
388400
assert.strictEqual(offer.exn.e.acdc.a.LEI, '5493001KJTIIGC8Y1R17');
389401

390402
await markAndRemoveNotification(verifierClient, verifierOfferNote);

test-integration/multisig-holder.test.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -378,9 +378,20 @@ test('multisig', async function run() {
378378
exnRes.exn.i,
379379
recp
380380
);
381-
console.log(
382-
`Member1 admitted credential with SAID : ${exnRes.exn.e.acdc.d}`
383-
);
381+
382+
if (
383+
'e' in exnRes.exn &&
384+
exnRes.exn.e &&
385+
'acdc' in exnRes.exn.e &&
386+
exnRes.exn.e.acdc &&
387+
'd' in exnRes.exn.e.acdc
388+
) {
389+
console.log(
390+
`Member1 admitted credential with SAID : ${exnRes.exn.e.acdc.d}`
391+
);
392+
} else {
393+
throw new Error('Expected property "e.acdc.d" not found on exnRes.exn');
394+
}
384395

385396
const grantMsgSaid2 = await waitAndMarkNotification(
386397
client2,

test-integration/multisig-join.test.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,11 @@ describe('multisig-join', () => {
9898
const msgSaid = await waitAndMarkNotification(client2, '/multisig/icp');
9999

100100
const response = await client2.groups().getRequest(msgSaid);
101-
const icp = response[0].exn.e.icp;
101+
const exn = response[0].exn;
102+
if (!('e' in exn) || !exn.e || !('icp' in exn.e) || !exn.e.icp) {
103+
throw new Error('exn.e.icp is missing from the group inception response');
104+
}
105+
const icp = exn.e.icp;
102106

103107
const icpResult2 = await client2.identifiers().create(nameMultisig, {
104108
algo: signify.Algos.group,
@@ -331,13 +335,26 @@ describe('multisig-join', () => {
331335
.getRequest(rotationNotification3);
332336

333337
const exn3 = response[0].exn;
338+
if (!('e' in exn3) || !exn3.e || !('rot' in exn3.e) || !exn3.e.rot) {
339+
throw new Error('exn3.e.rot is missing from the group rotation response');
340+
}
341+
if (!exn3.a || typeof (exn3.a as any).gid !== 'string') {
342+
throw new Error('exn3.a.gid is missing or not a string');
343+
}
334344
const serder3 = new Serder(exn3.e.rot);
335345
const keeper3 = await client3.manager!.get(aid3);
336346
const sigs3 = keeper3.sign(signify.b(serder3.raw));
337347

338348
const joinOperation = await client3
339349
.groups()
340-
.join(nameMultisig, serder3, sigs3, exn3.a.gid, smids, rmids);
350+
.join(
351+
nameMultisig,
352+
serder3,
353+
sigs3,
354+
(exn3.a as { gid: string }).gid,
355+
smids,
356+
rmids
357+
);
341358

342359
await waitOperation(client3, joinOperation);
343360

0 commit comments

Comments
 (0)