signify-ts 0.3.0-rc2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,11 +3,12 @@ import { Algos } from '../core/manager.ts';
3
3
  import { Serder } from '../core/serder.ts';
4
4
  import { IdentifierManagerFactory } from '../core/keeping.ts';
5
5
  import { HabState } from '../core/keyState.ts';
6
+ import { components } from '../../types/keria-api-schema.ts';
6
7
  /** Arguments required to create an identfier */
7
8
  export interface CreateIdentiferArgs {
8
9
  transferable?: boolean;
9
- isith?: string | number | string[];
10
- nsith?: string | number | string[];
10
+ isith?: string | number | string[] | string[][];
11
+ nsith?: string | number | string[] | string[][];
11
12
  wits?: string[];
12
13
  toad?: number;
13
14
  proxy?: string;
@@ -58,6 +59,13 @@ export interface IdentifierDeps {
58
59
  export interface IdentifierInfo {
59
60
  name: string;
60
61
  }
62
+ export interface LocSchemeArgs {
63
+ url: string;
64
+ scheme?: string;
65
+ eid?: string;
66
+ stamp?: string;
67
+ }
68
+ export type GroupMembers = components['schemas']['GroupMember'];
61
69
  /** Identifier */
62
70
  export declare class Identifier {
63
71
  client: IdentifierDeps;
@@ -138,13 +146,21 @@ export declare class Identifier {
138
146
  * @returns {Serder} The reply message
139
147
  */
140
148
  private makeEndRole;
149
+ /**
150
+ * Authorises a new location scheme (endpoint) for a particular endpoint identifier.
151
+ * @param {LocSchemeArgs} args
152
+ * @param name Name or alias of the identifier to sign reply message
153
+ * @param args Arguments to create authorising reply message from
154
+ * @returns A promise to the result of the authorization
155
+ */
156
+ addLocScheme(name: string, args: LocSchemeArgs): Promise<EventResult>;
141
157
  /**
142
158
  * Get the members of a group identifier
143
159
  * @async
144
160
  * @param {string} name - Name or alias of the identifier
145
- * @returns {Promise<any>} - A promise to the list of members
161
+ * @returns {Promise<GroupMembers>} - A promise to the list of members
146
162
  */
147
- members(name: string): Promise<any>;
163
+ members(name: string): Promise<GroupMembers>;
148
164
  }
149
165
  /** Event Result */
150
166
  export declare class EventResult {
@@ -332,11 +332,36 @@ export class Identifier {
332
332
  const route = '/end/role/add';
333
333
  return reply(route, data, stamp, undefined, Serials.JSON);
334
334
  }
335
+ /**
336
+ * Authorises a new location scheme (endpoint) for a particular endpoint identifier.
337
+ * @param {LocSchemeArgs} args
338
+ * @param name Name or alias of the identifier to sign reply message
339
+ * @param args Arguments to create authorising reply message from
340
+ * @returns A promise to the result of the authorization
341
+ */
342
+ async addLocScheme(name, args) {
343
+ const { url, scheme, eid, stamp } = args;
344
+ const hab = await this.get(name);
345
+ const rpyData = {
346
+ eid: eid !== null && eid !== void 0 ? eid : hab.prefix,
347
+ url,
348
+ scheme: scheme !== null && scheme !== void 0 ? scheme : 'http',
349
+ };
350
+ const rpy = reply('/loc/scheme', rpyData, stamp, undefined, Serials.JSON);
351
+ const keeper = this.client.manager.get(hab);
352
+ const sigs = await keeper.sign(b(rpy.raw));
353
+ const jsondata = {
354
+ rpy: rpy.sad,
355
+ sigs: sigs,
356
+ };
357
+ const res = await this.client.fetch('/identifiers/' + name + '/locschemes', 'POST', jsondata);
358
+ return new EventResult(rpy, sigs, res);
359
+ }
335
360
  /**
336
361
  * Get the members of a group identifier
337
362
  * @async
338
363
  * @param {string} name - Name or alias of the identifier
339
- * @returns {Promise<any>} - A promise to the list of members
364
+ * @returns {Promise<GroupMembers>} - A promise to the list of members
340
365
  */
341
366
  async members(name) {
342
367
  const res = await this.client.fetch('/identifiers/' + name + '/members', 'GET', undefined);
@@ -1,3 +1,4 @@
1
+ import { components } from '../../types/keria-api-schema.ts';
1
2
  import { Authenticater } from '../core/authing.ts';
2
3
  import { ExternalModule, IdentifierManagerFactory } from '../core/keeping.ts';
3
4
  import { Tier } from '../core/salter.ts';
@@ -11,6 +12,7 @@ import { Escrows } from './escrowing.ts';
11
12
  import { Exchanges } from './exchanging.ts';
12
13
  import { Groups } from './grouping.ts';
13
14
  import { Notifications } from './notifying.ts';
15
+ export type AgentResourceResult = components['schemas']['AgentResourceResult'];
14
16
  declare class State {
15
17
  agent: any | null;
16
18
  controller: any | null;
@@ -104,7 +104,7 @@ export class SignifyClient {
104
104
  if (res.status == 404) {
105
105
  throw new Error(`agent does not exist for controller ${caid}`);
106
106
  }
107
- const data = await res.json();
107
+ const data = (await res.json());
108
108
  const state = new State();
109
109
  state.agent = (_b = data.agent) !== null && _b !== void 0 ? _b : {};
110
110
  state.controller = (_c = data.controller) !== null && _c !== void 0 ? _c : {};
@@ -1,11 +1,8 @@
1
1
  import { SignifyClient } from './clienting.ts';
2
- import { Operation } from './coring.ts';
3
- export interface Contact {
4
- alias: string;
5
- oobi: string;
6
- id: string;
7
- [key: string]: unknown;
8
- }
2
+ import { components } from '../../types/keria-api-schema.ts';
3
+ import { ChallengeOperation } from '../core/keyState.ts';
4
+ import { Exn } from './exchanging.ts';
5
+ export type Contact = components['schemas']['Contact'];
9
6
  export interface ContactInfo {
10
7
  [key: string]: unknown;
11
8
  }
@@ -59,9 +56,7 @@ export declare class Contacts {
59
56
  */
60
57
  update(pre: string, info: ContactInfo): Promise<Contact>;
61
58
  }
62
- export interface Challenge {
63
- words: string[];
64
- }
59
+ export type Challenge = components['schemas']['Challenge'];
65
60
  /**
66
61
  * Challenges
67
62
  */
@@ -76,7 +71,7 @@ export declare class Challenges {
76
71
  * Generate a random challenge word list based on BIP39
77
72
  * @async
78
73
  * @param {number} strength Integer representing the strength of the challenge. Typically 128 or 256
79
- * @returns {Promise<any>} A promise to the list of random words
74
+ * @returns {Promise<Challenge>} A promise to the generated challenge
80
75
  */
81
76
  generate(strength?: number): Promise<Challenge>;
82
77
  /**
@@ -85,16 +80,16 @@ export declare class Challenges {
85
80
  * @param name Name or alias of the identifier
86
81
  * @param recipient Prefix of the recipient of the response
87
82
  * @param words List of words to embed in the signed response
88
- * @returns A promise to the result of the response
83
+ * @returns {Promise<Exn>} A promise to the signed response exn message
89
84
  */
90
- respond(name: string, recipient: string, words: string[]): Promise<unknown>;
85
+ respond(name: string, recipient: string, words: string[]): Promise<Exn>;
91
86
  /**
92
87
  * Ask Agent to verify a given sender signed the provided words
93
88
  * @param source Prefix of the identifier that was challenged
94
89
  * @param words List of challenge words to check for
95
90
  * @returns A promise to the long running operation
96
91
  */
97
- verify(source: string, words: string[]): Promise<Operation<unknown>>;
92
+ verify(source: string, words: string[]): Promise<ChallengeOperation>;
98
93
  /**
99
94
  * Mark challenge response as signed and accepted
100
95
  * @param source Prefix of the identifier that was challenged
@@ -96,7 +96,7 @@ export class Challenges {
96
96
  * Generate a random challenge word list based on BIP39
97
97
  * @async
98
98
  * @param {number} strength Integer representing the strength of the challenge. Typically 128 or 256
99
- * @returns {Promise<any>} A promise to the list of random words
99
+ * @returns {Promise<Challenge>} A promise to the generated challenge
100
100
  */
101
101
  async generate(strength = 128) {
102
102
  const path = `/challenges?strength=${strength.toString()}`;
@@ -110,7 +110,7 @@ export class Challenges {
110
110
  * @param name Name or alias of the identifier
111
111
  * @param recipient Prefix of the recipient of the response
112
112
  * @param words List of words to embed in the signed response
113
- * @returns A promise to the result of the response
113
+ * @returns {Promise<Exn>} A promise to the signed response exn message
114
114
  */
115
115
  async respond(name, recipient, words) {
116
116
  const hab = await this.client.identifiers().get(name);
@@ -28,7 +28,7 @@ export class Agent {
28
28
  }
29
29
  parse(agent) {
30
30
  const [state, verfer] = this.event(agent);
31
- this.sn = new CesrNumber({}, undefined, state['s']).num;
31
+ this.sn = new CesrNumber({}, state['s']).num;
32
32
  this.said = state['d'];
33
33
  if (state['et'] !== Ilks.dip) {
34
34
  throw new Error(`invalid inception event type ${state['et']}`);
@@ -125,7 +125,7 @@ export class Controller {
125
125
  approveDelegation(_agent) {
126
126
  const seqner = new Seqner({ sn: _agent.sn });
127
127
  const anchor = { i: _agent.pre, s: seqner.snh, d: _agent.said };
128
- const sn = new CesrNumber({}, undefined, this.serder.sad['s']).num + 1;
128
+ const sn = new CesrNumber({}, this.serder.sad['s']).num + 1;
129
129
  this.serder = interact({
130
130
  pre: this.serder.pre,
131
131
  dig: this.serder.sad['d'],
@@ -1,5 +1,10 @@
1
1
  import { SignifyClient } from './clienting.ts';
2
2
  import { components } from '../../types/keria-api-schema.ts';
3
+ import { OOBIOperation, QueryOperation, EndRoleOperation, WitnessOperation, DelegationOperation, RegistryOperation, LocSchemeOperation, ChallengeOperation, ExchangeOperation, SubmitOperation, DoneOperation, CredentialOperation, GroupOperation, DelegatorOperation, CompletedOOBIOperation, CompletedQueryOperation, CompletedEndRoleOperation, CompletedWitnessOperation, CompletedDelegationOperation, CompletedRegistryOperation, CompletedLocSchemeOperation, CompletedChallengeOperation, CompletedExchangeOperation, CompletedSubmitOperation, CompletedDoneOperation, CompletedCredentialOperation, CompletedGroupOperation, CompletedDelegatorOperation, CompletedOperation } from '../core/keyState.ts';
4
+ type OOBI = components['schemas']['OOBI'];
5
+ type KeyState = components['schemas']['KeyStateRecord'];
6
+ type KeyEventRecord = components['schemas']['KeyEventRecord'];
7
+ type AgentConfig = components['schemas']['AgentConfig'];
3
8
  export declare function randomPasscode(): string;
4
9
  export declare function randomNonce(): string;
5
10
  export declare class Oobis {
@@ -13,31 +18,22 @@ export declare class Oobis {
13
18
  * Get the OOBI(s) for a managed indentifier for a given role
14
19
  * @param {string} name Name or alias of the identifier
15
20
  * @param {string} role Authorized role
16
- * @returns {Promise<any>} A promise to the OOBI(s)
21
+ * @returns {Promise<OOBI>} A promise to the OOBI(s)
17
22
  */
18
- get(name: string, role?: string): Promise<any>;
23
+ get(name: string, role?: string): Promise<OOBI>;
19
24
  /**
20
25
  * Resolve an OOBI
21
26
  * @async
22
27
  * @param {string} oobi The OOBI to be resolver
23
28
  * @param {string} [alias] Optional name or alias to link the OOBI resolution to a contact
24
- * @returns {Promise<any>} A promise to the long-running operation
29
+ * @returns {Promise<OOBIOperation>} A promise to the long-running operation
25
30
  */
26
- resolve(oobi: string, alias?: string): Promise<any>;
31
+ resolve(oobi: string, alias?: string): Promise<OOBIOperation>;
27
32
  }
28
- export type Operation<T = unknown> = Omit<components['schemas']['Operation'], 'response' | 'metadata'> & {
29
- response?: T;
30
- metadata?: {
31
- depends?: Operation;
32
- [property: string]: any;
33
- };
34
- };
33
+ export type Operation = OOBIOperation | QueryOperation | EndRoleOperation | WitnessOperation | DelegationOperation | RegistryOperation | LocSchemeOperation | ChallengeOperation | ExchangeOperation | SubmitOperation | DoneOperation | CredentialOperation | GroupOperation | DelegatorOperation;
35
34
  export interface OperationsDeps {
36
35
  fetch(pathname: string, method: string, body: unknown, headers?: Headers): Promise<Response>;
37
36
  }
38
- export interface AgentConfig {
39
- iurls?: string[];
40
- }
41
37
  /**
42
38
  * Operations
43
39
  * @remarks
@@ -50,20 +46,26 @@ export declare class Operations {
50
46
  * @param {SignifyClient} client
51
47
  */
52
48
  constructor(client: OperationsDeps);
49
+ private hasDepends;
50
+ /**
51
+ * Check if operation failed and throw error with details
52
+ * @throws {Error} If operation has an error
53
+ */
54
+ private throwIfFailed;
53
55
  /**
54
56
  * Get operation status
55
57
  * @async
56
58
  * @param {string} name Name of the operation
57
59
  * @returns {Promise<Operation>} A promise to the status of the operation
58
60
  */
59
- get<T = unknown>(name: string): Promise<Operation<T>>;
61
+ get(name: string): Promise<Operation>;
60
62
  /**
61
63
  * List operations
62
64
  * @async
63
65
  * @param {string} type Select operations by type
64
66
  * @returns {Promise<Operation[]>} A list of operations
65
67
  */
66
- list(type?: string): Promise<Operation<any>[]>;
68
+ list(type?: string): Promise<Operation[]>;
67
69
  /**
68
70
  * Delete operation
69
71
  * @async
@@ -73,12 +75,96 @@ export declare class Operations {
73
75
  /**
74
76
  * Poll for operation to become completed.
75
77
  */
76
- wait<T>(op: Operation<T>, options?: {
78
+ wait(op: OOBIOperation, options?: {
79
+ signal?: AbortSignal;
80
+ minSleep?: number;
81
+ maxSleep?: number;
82
+ increaseFactor?: number;
83
+ }): Promise<CompletedOOBIOperation>;
84
+ wait(op: QueryOperation, options?: {
85
+ signal?: AbortSignal;
86
+ minSleep?: number;
87
+ maxSleep?: number;
88
+ increaseFactor?: number;
89
+ }): Promise<CompletedQueryOperation>;
90
+ wait(op: EndRoleOperation, options?: {
91
+ signal?: AbortSignal;
92
+ minSleep?: number;
93
+ maxSleep?: number;
94
+ increaseFactor?: number;
95
+ }): Promise<CompletedEndRoleOperation>;
96
+ wait(op: WitnessOperation, options?: {
97
+ signal?: AbortSignal;
98
+ minSleep?: number;
99
+ maxSleep?: number;
100
+ increaseFactor?: number;
101
+ }): Promise<CompletedWitnessOperation>;
102
+ wait(op: DelegationOperation, options?: {
103
+ signal?: AbortSignal;
104
+ minSleep?: number;
105
+ maxSleep?: number;
106
+ increaseFactor?: number;
107
+ }): Promise<CompletedDelegationOperation>;
108
+ wait(op: RegistryOperation, options?: {
109
+ signal?: AbortSignal;
110
+ minSleep?: number;
111
+ maxSleep?: number;
112
+ increaseFactor?: number;
113
+ }): Promise<CompletedRegistryOperation>;
114
+ wait(op: LocSchemeOperation, options?: {
115
+ signal?: AbortSignal;
116
+ minSleep?: number;
117
+ maxSleep?: number;
118
+ increaseFactor?: number;
119
+ }): Promise<CompletedLocSchemeOperation>;
120
+ wait(op: ChallengeOperation, options?: {
121
+ signal?: AbortSignal;
122
+ minSleep?: number;
123
+ maxSleep?: number;
124
+ increaseFactor?: number;
125
+ }): Promise<CompletedChallengeOperation>;
126
+ wait(op: ExchangeOperation, options?: {
127
+ signal?: AbortSignal;
128
+ minSleep?: number;
129
+ maxSleep?: number;
130
+ increaseFactor?: number;
131
+ }): Promise<CompletedExchangeOperation>;
132
+ wait(op: SubmitOperation, options?: {
133
+ signal?: AbortSignal;
134
+ minSleep?: number;
135
+ maxSleep?: number;
136
+ increaseFactor?: number;
137
+ }): Promise<CompletedSubmitOperation>;
138
+ wait(op: DoneOperation, options?: {
139
+ signal?: AbortSignal;
140
+ minSleep?: number;
141
+ maxSleep?: number;
142
+ increaseFactor?: number;
143
+ }): Promise<CompletedDoneOperation>;
144
+ wait(op: CredentialOperation, options?: {
145
+ signal?: AbortSignal;
146
+ minSleep?: number;
147
+ maxSleep?: number;
148
+ increaseFactor?: number;
149
+ }): Promise<CompletedCredentialOperation>;
150
+ wait(op: GroupOperation, options?: {
77
151
  signal?: AbortSignal;
78
152
  minSleep?: number;
79
153
  maxSleep?: number;
80
154
  increaseFactor?: number;
81
- }): Promise<Operation<T>>;
155
+ }): Promise<CompletedGroupOperation>;
156
+ wait(op: DelegatorOperation, options?: {
157
+ signal?: AbortSignal;
158
+ minSleep?: number;
159
+ maxSleep?: number;
160
+ increaseFactor?: number;
161
+ }): Promise<CompletedDelegatorOperation>;
162
+ wait(op: Operation, options?: {
163
+ signal?: AbortSignal;
164
+ minSleep?: number;
165
+ maxSleep?: number;
166
+ increaseFactor?: number;
167
+ }): Promise<CompletedOperation>;
82
168
  }
83
169
  /**
84
170
  * KeyEvents
@@ -94,9 +180,9 @@ export declare class KeyEvents {
94
180
  * Retrieve key events for an identifier
95
181
  * @async
96
182
  * @param {string} pre Identifier prefix
97
- * @returns {Promise<any>} A promise to the key events
183
+ * @returns {Promise<KeyEventRecord[]>} A promise to the key events
98
184
  */
99
- get(pre: string): Promise<any>;
185
+ get(pre: string): Promise<KeyEventRecord[]>;
100
186
  }
101
187
  /**
102
188
  * KeyStates
@@ -112,25 +198,25 @@ export declare class KeyStates {
112
198
  * Retriene the key state for an identifier
113
199
  * @async
114
200
  * @param {string} pre Identifier prefix
115
- * @returns {Promise<any>} A promise to the key states
201
+ * @returns {Promise<KeyState[]>} A promise to the key states
116
202
  */
117
- get(pre: string): Promise<any>;
203
+ get(pre: string): Promise<KeyState[]>;
118
204
  /**
119
205
  * Retrieve the key state for a list of identifiers
120
206
  * @async
121
207
  * @param {Array<string>} pres List of identifier prefixes
122
208
  * @returns {Promise<any>} A promise to the key states
123
209
  */
124
- list(pres: string[]): Promise<any>;
210
+ list(pres: string[]): Promise<KeyState[]>;
125
211
  /**
126
212
  * Query the key state of an identifier for a given sequence number or anchor
127
213
  * @async
128
214
  * @param {string} pre Identifier prefix
129
215
  * @param {number} [sn] Optional sequence number
130
216
  * @param {any} [anchor] Optional anchor
131
- * @returns {Promise<any>} A promise to the long-running operation
217
+ * @returns {Promise<QueryOperation>} A promise to the long-running operation
132
218
  */
133
- query(pre: string, sn?: string, anchor?: any): Promise<any>;
219
+ query(pre: string, sn?: string, anchor?: any): Promise<QueryOperation>;
134
220
  }
135
221
  export declare class Config {
136
222
  client: SignifyClient;
@@ -141,3 +227,4 @@ export declare class Config {
141
227
  constructor(client: SignifyClient);
142
228
  get(): Promise<AgentConfig>;
143
229
  }
230
+ export {};
@@ -24,7 +24,7 @@ export class Oobis {
24
24
  * Get the OOBI(s) for a managed indentifier for a given role
25
25
  * @param {string} name Name or alias of the identifier
26
26
  * @param {string} role Authorized role
27
- * @returns {Promise<any>} A promise to the OOBI(s)
27
+ * @returns {Promise<OOBI>} A promise to the OOBI(s)
28
28
  */
29
29
  async get(name, role = 'agent') {
30
30
  const path = `/identifiers/${name}/oobis?role=${role}`;
@@ -37,7 +37,7 @@ export class Oobis {
37
37
  * @async
38
38
  * @param {string} oobi The OOBI to be resolver
39
39
  * @param {string} [alias] Optional name or alias to link the OOBI resolution to a contact
40
- * @returns {Promise<any>} A promise to the long-running operation
40
+ * @returns {Promise<OOBIOperation>} A promise to the long-running operation
41
41
  */
42
42
  async resolve(oobi, alias) {
43
43
  const path = `/oobis`;
@@ -65,6 +65,21 @@ export class Operations {
65
65
  constructor(client) {
66
66
  this.client = client;
67
67
  }
68
+ hasDepends(op) {
69
+ return op.metadata !== undefined && 'depends' in op.metadata;
70
+ }
71
+ /**
72
+ * Check if operation failed and throw error with details
73
+ * @throws {Error} If operation has an error
74
+ */
75
+ throwIfFailed(op) {
76
+ if ('error' in op && op.error !== null) {
77
+ const details = op.error.details
78
+ ? ` Details: ${JSON.stringify(op.error.details)}`
79
+ : '';
80
+ throw new Error(`Operation '${op.name}' failed [Code ${op.error.code}]: ${op.error.message}${details}`);
81
+ }
82
+ }
68
83
  /**
69
84
  * Get operation status
70
85
  * @async
@@ -106,30 +121,31 @@ export class Operations {
106
121
  const method = 'DELETE';
107
122
  await this.client.fetch(path, method, data);
108
123
  }
109
- /**
110
- * Poll for operation to become completed.
111
- */
112
124
  async wait(op, options = {}) {
113
- var _a, _b, _c, _d, _e, _f;
125
+ var _a, _b, _c, _d;
114
126
  const minSleep = (_a = options.minSleep) !== null && _a !== void 0 ? _a : 10;
115
127
  const maxSleep = (_b = options.maxSleep) !== null && _b !== void 0 ? _b : 10000;
116
128
  const increaseFactor = (_c = options.increaseFactor) !== null && _c !== void 0 ? _c : 50;
117
- if (((_e = (_d = op.metadata) === null || _d === void 0 ? void 0 : _d.depends) === null || _e === void 0 ? void 0 : _e.done) === false) {
129
+ if (this.hasDepends(op) &&
130
+ op.metadata.depends &&
131
+ !op.metadata.depends.done) {
118
132
  await this.wait(op.metadata.depends, options);
119
133
  }
120
134
  if (op.done === true) {
135
+ this.throwIfFailed(op);
121
136
  return op;
122
137
  }
123
138
  let retries = 0;
124
139
  while (true) {
125
140
  op = await this.get(op.name);
126
- const delay = Math.max(minSleep, Math.min(maxSleep, 2 ** retries * increaseFactor));
127
- retries++;
128
141
  if (op.done === true) {
142
+ this.throwIfFailed(op);
129
143
  return op;
130
144
  }
145
+ const delay = Math.max(minSleep, Math.min(maxSleep, 2 ** retries * increaseFactor));
146
+ retries++;
131
147
  await new Promise((resolve) => setTimeout(resolve, delay));
132
- (_f = options.signal) === null || _f === void 0 ? void 0 : _f.throwIfAborted();
148
+ (_d = options.signal) === null || _d === void 0 ? void 0 : _d.throwIfAborted();
133
149
  }
134
150
  }
135
151
  }
@@ -148,7 +164,7 @@ export class KeyEvents {
148
164
  * Retrieve key events for an identifier
149
165
  * @async
150
166
  * @param {string} pre Identifier prefix
151
- * @returns {Promise<any>} A promise to the key events
167
+ * @returns {Promise<KeyEventRecord[]>} A promise to the key events
152
168
  */
153
169
  async get(pre) {
154
170
  const path = `/events?pre=${pre}`;
@@ -173,7 +189,7 @@ export class KeyStates {
173
189
  * Retriene the key state for an identifier
174
190
  * @async
175
191
  * @param {string} pre Identifier prefix
176
- * @returns {Promise<any>} A promise to the key states
192
+ * @returns {Promise<KeyState[]>} A promise to the key states
177
193
  */
178
194
  async get(pre) {
179
195
  const path = `/states?pre=${pre}`;
@@ -201,7 +217,7 @@ export class KeyStates {
201
217
  * @param {string} pre Identifier prefix
202
218
  * @param {number} [sn] Optional sequence number
203
219
  * @param {any} [anchor] Optional anchor
204
- * @returns {Promise<any>} A promise to the long-running operation
220
+ * @returns {Promise<QueryOperation>} A promise to the long-running operation
205
221
  */
206
222
  async query(pre, sn, anchor) {
207
223
  const path = `/queries`;
@@ -1,8 +1,7 @@
1
1
  import { SignifyClient } from './clienting.ts';
2
2
  import { Dict } from '../core/core.ts';
3
3
  import { Serder } from '../core/serder.ts';
4
- import { Operation } from './coring.ts';
5
- import { HabState } from '../core/keyState.ts';
4
+ import { ExchangeOperation, CredentialOperation, GroupOperation, DelegationOperation, WitnessOperation, DoneOperation, HabState, RegistryOperation } from '../core/keyState.ts';
6
5
  import { components } from '../../types/keria-api-schema.ts';
7
6
  export type CredentialResult = components['schemas']['Credential'];
8
7
  export type Registry = components['schemas']['Registry'];
@@ -74,12 +73,12 @@ export interface IssueCredentialResult {
74
73
  acdc: Serder;
75
74
  anc: Serder;
76
75
  iss: Serder;
77
- op: Operation;
76
+ op: CredentialOperation;
78
77
  }
79
78
  export interface RevokeCredentialResult {
80
79
  anc: Serder;
81
80
  rev: Serder;
82
- op: Operation;
81
+ op: GroupOperation | DelegationOperation | WitnessOperation | DoneOperation;
83
82
  }
84
83
  export interface IpexApplyArgs {
85
84
  /**
@@ -218,6 +217,7 @@ export declare class Credentials {
218
217
  get(said: string): Promise<CredentialResult>;
219
218
  get(said: string, includeCESR: false): Promise<CredentialResult>;
220
219
  get(said: string, includeCESR: true): Promise<string>;
220
+ get(said: string, includeCESR: boolean): Promise<CredentialResult | string>;
221
221
  /**
222
222
  * Delete a credential from the DB
223
223
  * @async
@@ -264,7 +264,7 @@ export declare class RegistryResult {
264
264
  get regser(): any;
265
265
  get serder(): Serder;
266
266
  get sigs(): string[];
267
- op(): Promise<Registry>;
267
+ op(): Promise<RegistryOperation>;
268
268
  }
269
269
  /**
270
270
  * Registries
@@ -339,25 +339,25 @@ export declare class Ipex {
339
339
  * Create an IPEX apply EXN message
340
340
  */
341
341
  apply(args: IpexApplyArgs): Promise<[Serder, string[], string]>;
342
- submitApply(name: string, exn: Serder, sigs: string[], recp: string[]): Promise<any>;
342
+ submitApply(name: string, exn: Serder, sigs: string[], recp: string[]): Promise<ExchangeOperation>;
343
343
  /**
344
344
  * Create an IPEX offer EXN message
345
345
  */
346
346
  offer(args: IpexOfferArgs): Promise<[Serder, string[], string]>;
347
- submitOffer(name: string, exn: Serder, sigs: string[], atc: string, recp: string[]): Promise<any>;
347
+ submitOffer(name: string, exn: Serder, sigs: string[], atc: string, recp: string[]): Promise<ExchangeOperation>;
348
348
  /**
349
349
  * Create an IPEX agree EXN message
350
350
  */
351
351
  agree(args: IpexAgreeArgs): Promise<[Serder, string[], string]>;
352
- submitAgree(name: string, exn: Serder, sigs: string[], recp: string[]): Promise<any>;
352
+ submitAgree(name: string, exn: Serder, sigs: string[], recp: string[]): Promise<ExchangeOperation>;
353
353
  /**
354
354
  * Create an IPEX grant EXN message
355
355
  */
356
356
  grant(args: IpexGrantArgs): Promise<[Serder, string[], string]>;
357
- submitGrant(name: string, exn: Serder, sigs: string[], atc: string, recp: string[]): Promise<any>;
357
+ submitGrant(name: string, exn: Serder, sigs: string[], atc: string, recp: string[]): Promise<ExchangeOperation>;
358
358
  /**
359
359
  * Create an IPEX admit EXN message
360
360
  */
361
361
  admit(args: IpexAdmitArgs): Promise<[Serder, string[], string]>;
362
- submitAdmit(name: string, exn: Serder, sigs: string[], atc: string, recp: string[]): Promise<any>;
362
+ submitAdmit(name: string, exn: Serder, sigs: string[], atc: string, recp: string[]): Promise<ExchangeOperation>;
363
363
  }
@@ -1,4 +1,6 @@
1
1
  import { SignifyClient } from './clienting.ts';
2
+ import { components } from '../../types/keria-api-schema.ts';
3
+ export type Rpy = components['schemas']['Rpy'];
2
4
  /**
3
5
  * Escrows
4
6
  */
@@ -13,7 +15,7 @@ export declare class Escrows {
13
15
  * List replay messages
14
16
  * @async
15
17
  * @param {string} [route] Optional route in the replay message
16
- * @returns {Promise<any>} A promise to the list of replay messages
18
+ * @returns {Promise<Rpy[]>} A promise to the list of replay messages
17
19
  */
18
- listReply(route?: string): Promise<any>;
20
+ listReply(route?: string): Promise<Rpy[]>;
19
21
  }
@@ -13,7 +13,7 @@ export class Escrows {
13
13
  * List replay messages
14
14
  * @async
15
15
  * @param {string} [route] Optional route in the replay message
16
- * @returns {Promise<any>} A promise to the list of replay messages
16
+ * @returns {Promise<Rpy[]>} A promise to the list of replay messages
17
17
  */
18
18
  async listReply(route) {
19
19
  const params = new URLSearchParams();