Skip to content

Commit 11a03cb

Browse files
Vu Van DucVu Van Duc
authored andcommitted
chore: remove any type in app directory
1 parent 67cc8d0 commit 11a03cb

25 files changed

+214
-144
lines changed

src/keri/app/aiding.ts

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
import { b, Ilks, Serials, Vrsn_1_0 } from '../core/core.ts';
2-
import { incept, interact, reply, EndRoleAddAttributes, rotate } from '../core/eventing.ts';
2+
import {
3+
EndRoleAddAttributes,
4+
incept,
5+
interact,
6+
InteractEventData,
7+
InteractEventSAD,
8+
reply,
9+
rotate,
10+
} from '../core/eventing.ts';
311
import { parseRangeHeaders } from '../core/httping.ts';
4-
import { IdentifierManagerFactory } from '../core/keeping.ts';
5-
import { HabState } from '../core/keyState.ts';
12+
import { IdentifierManagerFactory, SignResult } from '../core/keeping.ts';
13+
import { HabState, KeyState } from '../core/keyState.ts';
614
import { Algos } from '../core/manager.ts';
715
import { MtrDex } from '../core/matter.ts';
816
import { Tier } from '../core/salter.ts';
@@ -19,13 +27,13 @@ export interface CreateIdentiferArgs {
1927
proxy?: string;
2028
delpre?: string;
2129
dcode?: string;
22-
data?: any;
30+
data?: Record<string, unknown>[];
2331
algo?: Algos;
2432
pre?: string;
25-
states?: any[];
26-
rstates?: any[];
27-
prxs?: any[];
28-
nxts?: any[];
33+
states?: KeyState[];
34+
rstates?: KeyState[];
35+
prxs?: string[];
36+
nxts?: string[];
2937
mhab?: HabState;
3038
keys?: string[];
3139
ndigs?: string[];
@@ -34,7 +42,7 @@ export interface CreateIdentiferArgs {
3442
ncount?: number;
3543
tier?: Tier;
3644
extern_type?: string;
37-
extern?: any;
45+
extern?: Record<string, unknown>;
3846
}
3947

4048
/** Arguments required to rotate an identfier */
@@ -48,8 +56,8 @@ export interface RotateIdentifierArgs {
4856
ncode?: string;
4957
ncount?: number;
5058
ncodes?: string[];
51-
states?: any[];
52-
rstates?: any[];
59+
states?: KeyState[];
60+
rstates?: KeyState[];
5361
}
5462

5563
/**
@@ -92,7 +100,15 @@ export class Identifier {
92100
* @param {number} [end=24] End index of list of notifications, defaults to 24
93101
* @returns {Promise<any>} A promise to the list of managed identifiers
94102
*/
95-
async list(start: number = 0, end: number = 24): Promise<any> {
103+
async list(
104+
start: number = 0,
105+
end: number = 24
106+
): Promise<{
107+
start: number;
108+
end: number;
109+
total: number;
110+
aids: any;
111+
}> {
96112
const extraHeaders = new Headers();
97113
extraHeaders.append('Range', `aids=${start}-${end}`);
98114

@@ -249,7 +265,7 @@ export class Identifier {
249265
}
250266

251267
const sigs = await keeper!.sign(b(serder.raw));
252-
const jsondata: any = {
268+
const jsondata: Record<string, unknown> = {
253269
name: name,
254270
icp: serder.sad,
255271
sigs: sigs,
@@ -277,7 +293,10 @@ export class Identifier {
277293
* @param {any} [data] Option data to be anchored in the interaction event
278294
* @returns {Promise<EventResult>} A promise to the interaction event result
279295
*/
280-
async interact(name: string, data?: any): Promise<EventResult> {
296+
async interact(
297+
name: string,
298+
data?: InteractEventData[] | InteractEventData
299+
): Promise<EventResult> {
281300
const { serder, sigs, jsondata } = await this.createInteract(
282301
name,
283302
data
@@ -293,16 +312,20 @@ export class Identifier {
293312

294313
async createInteract(
295314
name: string,
296-
data?: any
297-
): Promise<{ serder: any; sigs: any; jsondata: any }> {
315+
data?: InteractEventData[] | InteractEventData
316+
): Promise<{
317+
serder: Serder<InteractEventSAD>;
318+
sigs: SignResult;
319+
jsondata: Record<string, unknown>;
320+
}> {
298321
const hab = await this.get(name);
299322
const pre: string = hab.prefix;
300323

301324
const state = hab.state;
302325
const sn = parseInt(state.s, 16);
303326
const dig = state.d;
304327

305-
data = Array.isArray(data) ? data : [data];
328+
data = Array.isArray(data) ? data : ([data] as InteractEventData[]);
306329

307330
const serder = interact({
308331
pre: pre,
@@ -315,7 +338,7 @@ export class Identifier {
315338
const keeper = this.client!.manager!.get(hab);
316339
const sigs = await keeper.sign(b(serder.raw));
317340

318-
const jsondata: any = {
341+
const jsondata: Record<string, unknown> = {
319342
ixn: serder.sad,
320343
sigs: sigs,
321344
};
@@ -399,7 +422,7 @@ export class Identifier {
399422

400423
const sigs = await keeper.sign(b(serder.raw));
401424

402-
const jsondata: any = {
425+
const jsondata: Record<string, unknown> = {
403426
rot: serder.sad,
404427
sigs: sigs,
405428
smids:

src/keri/app/clienting.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { Authenticater } from '../core/authing.ts';
2+
import { InceptEventSAD } from '../core/eventing.ts';
23
import { HEADER_SIG_TIME } from '../core/httping.ts';
34
import { ExternalModule, IdentifierManagerFactory } from '../core/keeping.ts';
5+
import { KeyState } from '../core/keyState.ts';
46
import { Tier } from '../core/salter.ts';
57

68
import { Identifier } from './aiding.ts';
79
import { Challenges, Contacts } from './contacting.ts';
8-
import { Agent, Controller } from './controller.ts';
10+
import { Agent, Controller, RotateAID } from './controller.ts';
911
import { Config, KeyEvents, KeyStates, Oobis, Operations } from './coring.ts';
1012
import { Credentials, Ipex, Registries, Schemas } from './credentialing.ts';
1113
import { Delegations } from './delegating.ts';
@@ -16,9 +18,13 @@ import { Notifications } from './notifying.ts';
1618

1719
const DEFAULT_BOOT_URL = 'http://localhost:3903';
1820

19-
class State {
20-
agent: any | null;
21-
controller: any | null;
21+
export interface StateController {
22+
state: KeyState;
23+
ee: InceptEventSAD;
24+
}
25+
export class State {
26+
agent: KeyState | null;
27+
controller: StateController | null;
2228
ridx: number;
2329
pidx: number;
2430

@@ -141,7 +147,7 @@ export class SignifyClient {
141147
);
142148
this.controller.ridx = state.ridx !== undefined ? state.ridx : 0;
143149
// Create agent representing the AID of KERIA cloud agent
144-
this.agent = new Agent(state.agent);
150+
this.agent = new Agent(state.agent!);
145151
if (this.agent.anchor != this.controller.pre) {
146152
throw Error(
147153
'commitment to controller AID missing in agent inception event'
@@ -343,7 +349,7 @@ export class SignifyClient {
343349
* @param {Array<string>} aids List of managed AIDs to be rotated
344350
* @returns {Promise<Response>} A promise to the result of the rotation
345351
*/
346-
async rotate(nbran: string, aids: string[]): Promise<Response> {
352+
async rotate(nbran: string, aids: RotateAID[]): Promise<Response> {
347353
const data = this.controller.rotate(nbran, aids);
348354
return await fetch(this.url + '/agent/' + this.controller.pre, {
349355
method: 'PUT',

0 commit comments

Comments
 (0)