signify-ts 0.2.1 → 0.3.0-dev.e31e78d

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.
Files changed (129) hide show
  1. package/README.md +104 -34
  2. package/dist/exports.d.ts +40 -40
  3. package/dist/exports.js +40 -0
  4. package/dist/index.d.ts +2 -3
  5. package/dist/index.js +3 -8
  6. package/dist/keri/app/aiding.d.ts +54 -18
  7. package/{src/keri/app/aiding.ts → dist/keri/app/aiding.js} +130 -236
  8. package/dist/keri/app/clienting.d.ts +59 -22
  9. package/{src/keri/app/clienting.ts → dist/keri/app/clienting.js} +146 -235
  10. package/dist/keri/app/contacting.d.ts +30 -23
  11. package/{src/keri/app/contacting.ts → dist/keri/app/contacting.js} +26 -63
  12. package/dist/keri/app/controller.d.ts +49 -6
  13. package/{src/keri/app/controller.ts → dist/keri/app/controller.js} +80 -186
  14. package/dist/keri/app/coring.d.ts +134 -25
  15. package/{src/keri/app/coring.ts → dist/keri/app/coring.js} +83 -56
  16. package/dist/keri/app/credentialing.d.ts +187 -69
  17. package/dist/keri/app/credentialing.js +540 -0
  18. package/dist/keri/app/delegating.d.ts +18 -0
  19. package/dist/keri/app/delegating.js +24 -0
  20. package/dist/keri/app/escrowing.d.ts +5 -3
  21. package/{src/keri/app/escrowing.ts → dist/keri/app/escrowing.js} +3 -9
  22. package/dist/keri/app/exchanging.d.ts +243 -11
  23. package/dist/keri/app/exchanging.js +242 -0
  24. package/dist/keri/app/grouping.d.ts +11 -9
  25. package/{src/keri/app/grouping.ts → dist/keri/app/grouping.js} +10 -29
  26. package/dist/keri/app/habery.d.ts +2 -2
  27. package/dist/keri/app/habery.js +117 -0
  28. package/dist/keri/app/notifying.d.ts +2 -2
  29. package/{src/keri/app/notifying.ts → dist/keri/app/notifying.js} +7 -17
  30. package/dist/keri/core/authing.d.ts +2 -2
  31. package/{src/keri/core/authing.ts → dist/keri/core/authing.js} +26 -42
  32. package/dist/keri/core/base64.d.ts +2 -0
  33. package/dist/keri/core/base64.js +16 -0
  34. package/dist/keri/core/bexter.d.ts +1 -1
  35. package/{src/keri/core/bexter.ts → dist/keri/core/bexter.js} +18 -32
  36. package/dist/keri/core/cigar.d.ts +2 -2
  37. package/dist/keri/core/cigar.js +13 -0
  38. package/dist/keri/core/cipher.d.ts +1 -1
  39. package/{src/keri/core/cipher.ts → dist/keri/core/cipher.js} +10 -19
  40. package/dist/keri/core/core.d.ts +117 -9
  41. package/dist/keri/core/core.js +385 -0
  42. package/dist/keri/core/counter.d.ts +2 -2
  43. package/dist/keri/core/counter.js +221 -0
  44. package/dist/keri/core/decrypter.d.ts +4 -4
  45. package/{src/keri/core/decrypter.ts → dist/keri/core/decrypter.js} +23 -40
  46. package/dist/keri/core/diger.d.ts +3 -3
  47. package/{src/keri/core/diger.ts → dist/keri/core/diger.js} +18 -33
  48. package/dist/keri/core/encrypter.d.ts +2 -2
  49. package/{src/keri/core/encrypter.ts → dist/keri/core/encrypter.js} +18 -38
  50. package/dist/keri/core/eventing.d.ts +6 -6
  51. package/dist/keri/core/eventing.js +383 -0
  52. package/dist/keri/core/httping.d.ts +11 -4
  53. package/{src/keri/core/httping.ts → dist/keri/core/httping.js} +36 -101
  54. package/dist/keri/core/indexer.d.ts +1 -1
  55. package/dist/keri/core/indexer.js +407 -0
  56. package/dist/keri/core/keeping.d.ts +113 -46
  57. package/dist/keri/core/keeping.js +347 -0
  58. package/{src/keri/core/kering.ts → dist/keri/core/kering.js} +1 -3
  59. package/dist/keri/core/keyState.d.ts +98 -0
  60. package/dist/keri/core/manager.d.ts +147 -12
  61. package/dist/keri/core/manager.js +880 -0
  62. package/dist/keri/core/matter.d.ts +1 -1
  63. package/dist/keri/core/matter.js +460 -0
  64. package/dist/keri/core/number.d.ts +2 -2
  65. package/{src/keri/core/number.ts → dist/keri/core/number.js} +26 -32
  66. package/dist/keri/core/pather.d.ts +2 -2
  67. package/{src/keri/core/pather.ts → dist/keri/core/pather.js} +12 -27
  68. package/dist/keri/core/prefixer.d.ts +10 -10
  69. package/dist/keri/core/prefixer.js +182 -0
  70. package/dist/keri/core/saider.d.ts +2 -12
  71. package/dist/keri/core/saider.js +107 -0
  72. package/dist/keri/core/salter.d.ts +44 -9
  73. package/dist/keri/core/salter.js +110 -0
  74. package/dist/keri/core/seqner.d.ts +1 -1
  75. package/{src/keri/core/seqner.ts → dist/keri/core/seqner.js} +20 -21
  76. package/dist/keri/core/serder.d.ts +25 -12
  77. package/dist/keri/core/serder.js +133 -0
  78. package/dist/keri/core/siger.d.ts +2 -2
  79. package/{src/keri/core/siger.ts → dist/keri/core/siger.js} +4 -14
  80. package/dist/keri/core/signer.d.ts +4 -4
  81. package/dist/keri/core/signer.js +84 -0
  82. package/{src/keri/core/tholder.ts → dist/keri/core/tholder.js} +69 -94
  83. package/dist/keri/core/utils.d.ts +1 -1
  84. package/{src/keri/core/utils.ts → dist/keri/core/utils.js} +30 -60
  85. package/dist/keri/core/vdring.d.ts +2 -2
  86. package/dist/keri/core/vdring.js +61 -0
  87. package/dist/keri/core/verfer.d.ts +2 -6
  88. package/dist/keri/core/verfer.js +37 -0
  89. package/dist/keri/end/ending.d.ts +10 -8
  90. package/dist/keri/end/ending.js +136 -0
  91. package/{src/ready.ts → dist/ready.js} +1 -2
  92. package/dist/types/keria-api-schema.d.ts +1158 -0
  93. package/dist/types/keria-api-schema.js +34 -0
  94. package/package.json +53 -52
  95. package/dist/math.d.ts +0 -1
  96. package/dist/signify-ts.cjs +0 -7842
  97. package/dist/signify-ts.cjs.development.js +0 -9501
  98. package/dist/signify-ts.cjs.development.js.map +0 -1
  99. package/dist/signify-ts.cjs.map +0 -7
  100. package/dist/signify-ts.cjs.production.min.js +0 -2
  101. package/dist/signify-ts.cjs.production.min.js.map +0 -1
  102. package/dist/signify-ts.esm.js +0 -9345
  103. package/dist/signify-ts.esm.js.map +0 -1
  104. package/dist/signify-ts.mjs +0 -7818
  105. package/dist/signify-ts.mjs.map +0 -7
  106. package/src/buffer-polyfill.ts +0 -5
  107. package/src/exports.ts +0 -44
  108. package/src/index.ts +0 -4
  109. package/src/keri/app/credentialing.ts +0 -841
  110. package/src/keri/app/exchanging.ts +0 -220
  111. package/src/keri/app/habery.ts +0 -185
  112. package/src/keri/core/cigar.ts +0 -18
  113. package/src/keri/core/core.ts +0 -326
  114. package/src/keri/core/counter.ts +0 -273
  115. package/src/keri/core/eventing.ts +0 -581
  116. package/src/keri/core/indexer.ts +0 -509
  117. package/src/keri/core/keeping.ts +0 -684
  118. package/src/keri/core/manager.ts +0 -1183
  119. package/src/keri/core/matter.ts +0 -521
  120. package/src/keri/core/prefixer.ts +0 -233
  121. package/src/keri/core/saider.ts +0 -186
  122. package/src/keri/core/salter.ts +0 -120
  123. package/src/keri/core/serder.ts +0 -163
  124. package/src/keri/core/signer.ts +0 -133
  125. package/src/keri/core/vdring.ts +0 -94
  126. package/src/keri/core/verfer.ts +0 -47
  127. package/src/keri/end/ending.ts +0 -170
  128. package/src/math.ts +0 -3
  129. /package/dist/{buffer-polyfill.d.ts → keri/core/keyState.js} +0 -0
@@ -0,0 +1,540 @@
1
+ import { interact, messagize } from "../core/eventing.js";
2
+ import { vdr } from "../core/vdring.js";
3
+ import { b, d, Protocols, Ilks, Serials, versify, Vrsn_1_0, } from "../core/core.js";
4
+ import { Saider } from "../core/saider.js";
5
+ import { Serder } from "../core/serder.js";
6
+ import { Siger } from "../core/siger.js";
7
+ import { TraitDex } from "./habery.js";
8
+ import { serializeACDCAttachment, serializeIssExnAttachment, } from "../core/utils.js";
9
+ /** Types of credentials */
10
+ export class CredentialTypes {
11
+ }
12
+ CredentialTypes.issued = 'issued';
13
+ CredentialTypes.received = 'received';
14
+ /**
15
+ * Credentials
16
+ */
17
+ export class Credentials {
18
+ /**
19
+ * Credentials
20
+ * @param {SignifyClient} client
21
+ */
22
+ constructor(client) {
23
+ this.client = client;
24
+ }
25
+ /**
26
+ * List credentials
27
+ * @async
28
+ * @param {CredentialFilter} [kargs] Optional parameters to filter the credentials
29
+ * @returns {Promise<CredentialResult[]>} A promise to the list of credentials
30
+ */
31
+ async list(kargs = {}) {
32
+ const path = `/credentials/query`;
33
+ const filtr = kargs.filter === undefined ? {} : kargs.filter;
34
+ const sort = kargs.sort === undefined ? [] : kargs.sort;
35
+ const limit = kargs.limit === undefined ? 25 : kargs.limit;
36
+ const skip = kargs.skip === undefined ? 0 : kargs.skip;
37
+ const data = {
38
+ filter: filtr,
39
+ sort: sort,
40
+ skip: skip,
41
+ limit: limit,
42
+ };
43
+ const method = 'POST';
44
+ const res = await this.client.fetch(path, method, data, undefined);
45
+ return await res.json();
46
+ }
47
+ async get(said, includeCESR = false) {
48
+ const path = `/credentials/${said}`;
49
+ const method = 'GET';
50
+ const headers = includeCESR
51
+ ? new Headers({ Accept: 'application/json+cesr' })
52
+ : new Headers({ Accept: 'application/json' });
53
+ const res = await this.client.fetch(path, method, null, headers);
54
+ return includeCESR ? await res.text() : await res.json();
55
+ }
56
+ /**
57
+ * Delete a credential from the DB
58
+ * @async
59
+ * @param {string} said - SAID of the credential
60
+ * @returns {Promise<void>}
61
+ */
62
+ async delete(said) {
63
+ const path = `/credentials/${said}`;
64
+ const method = 'DELETE';
65
+ await this.client.fetch(path, method, undefined);
66
+ }
67
+ /**
68
+ * Get the state of a credential
69
+ * @async
70
+ * @param {string} ri - management registry identifier
71
+ * @param {string} said - SAID of the credential
72
+ * @returns {Promise<CredentialState>} A promise to the credential registry state
73
+ */
74
+ async state(ri, said) {
75
+ const path = `/registries/${ri}/${said}`;
76
+ const method = 'GET';
77
+ const res = await this.client.fetch(path, method, null);
78
+ return res.json();
79
+ }
80
+ /**
81
+ * Creates a credential in the specified registry to be GRANTed with IPEX to the intended recipient
82
+ */
83
+ async issue(name, args) {
84
+ var _a, _b;
85
+ const hab = await this.client.identifiers().get(name);
86
+ const estOnly = hab.state.c !== undefined && hab.state.c.includes('EO');
87
+ if (estOnly) {
88
+ // TODO implement rotation event
89
+ throw new Error('Establishment only not implemented');
90
+ }
91
+ if (!this.client.manager) {
92
+ throw new Error('No manager on client');
93
+ }
94
+ const keeper = this.client.manager.get(hab);
95
+ const [, subject] = Saider.saidify(Object.assign(Object.assign({ d: '' }, args.a), { dt: (_a = args.a.dt) !== null && _a !== void 0 ? _a : new Date().toISOString().replace('Z', '000+00:00') }));
96
+ const [, acdc] = Saider.saidify({
97
+ v: versify(Protocols.ACDC, undefined, Serials.JSON, 0),
98
+ d: '',
99
+ u: args.u,
100
+ i: (_b = args.i) !== null && _b !== void 0 ? _b : hab.prefix,
101
+ ri: args.ri,
102
+ s: args.s,
103
+ a: subject,
104
+ e: args.e,
105
+ r: args.r,
106
+ });
107
+ const [, iss] = Saider.saidify({
108
+ v: versify(Protocols.KERI, undefined, Serials.JSON, 0),
109
+ t: Ilks.iss,
110
+ d: '',
111
+ i: acdc.d,
112
+ s: '0',
113
+ ri: args.ri,
114
+ dt: subject.dt,
115
+ });
116
+ const sn = parseInt(hab.state.s, 16);
117
+ const anc = interact({
118
+ pre: hab.prefix,
119
+ sn: sn + 1,
120
+ data: [
121
+ {
122
+ i: iss.i,
123
+ s: iss.s,
124
+ d: iss.d,
125
+ },
126
+ ],
127
+ dig: hab.state.d,
128
+ version: undefined,
129
+ kind: undefined,
130
+ });
131
+ const sigs = await keeper.sign(b(anc.raw));
132
+ const path = `/identifiers/${hab.name}/credentials`;
133
+ const method = 'POST';
134
+ const body = {
135
+ acdc: acdc,
136
+ iss: iss,
137
+ ixn: anc.sad,
138
+ sigs,
139
+ [keeper.algo]: keeper.params(),
140
+ };
141
+ const res = await this.client.fetch(path, method, body);
142
+ const op = await res.json();
143
+ return {
144
+ acdc: new Serder(acdc),
145
+ iss: new Serder(iss),
146
+ anc,
147
+ op,
148
+ };
149
+ }
150
+ /**
151
+ * Revoke credential
152
+ * @async
153
+ * @param {string} name Name or alias of the identifier
154
+ * @param {string} said SAID of the credential
155
+ * @param {string} datetime date time of revocation
156
+ * @returns {Promise<RevokeCredentialResult>} A promise to the long-running operation
157
+ */
158
+ async revoke(name, said, datetime) {
159
+ const hab = await this.client.identifiers().get(name);
160
+ const pre = hab.prefix;
161
+ const vs = versify(Protocols.KERI, undefined, Serials.JSON, 0);
162
+ const dt = datetime !== null && datetime !== void 0 ? datetime : new Date().toISOString().replace('Z', '000+00:00');
163
+ const cred = await this.get(said);
164
+ let registryId;
165
+ if ('ri' in cred.sad && cred.sad.ri !== undefined) {
166
+ registryId = cred.sad.ri;
167
+ }
168
+ else if ('rd' in cred.sad && cred.sad.rd !== undefined) {
169
+ registryId = cred.sad.rd;
170
+ }
171
+ else {
172
+ throw new Error('Neither ri nor rd property found in credential');
173
+ }
174
+ // Create rev
175
+ const _rev = {
176
+ v: vs,
177
+ t: Ilks.rev,
178
+ d: '',
179
+ i: said,
180
+ s: '1',
181
+ ri: registryId,
182
+ p: cred.status.d,
183
+ dt: dt,
184
+ };
185
+ const [, rev] = Saider.saidify(_rev);
186
+ // create ixn
187
+ let ixn = {};
188
+ let sigs = [];
189
+ const state = hab.state;
190
+ if (state.c !== undefined && state.c.includes('EO')) {
191
+ var estOnly = true;
192
+ }
193
+ else {
194
+ var estOnly = false;
195
+ }
196
+ const sn = parseInt(state.s, 16);
197
+ const dig = state.d;
198
+ const data = [
199
+ {
200
+ i: rev.i,
201
+ s: rev.s,
202
+ d: rev.d,
203
+ },
204
+ ];
205
+ const keeper = this.client.manager.get(hab);
206
+ if (estOnly) {
207
+ // TODO implement rotation event
208
+ throw new Error('Establishment only not implemented');
209
+ }
210
+ else {
211
+ const serder = interact({
212
+ pre: pre,
213
+ sn: sn + 1,
214
+ data: data,
215
+ dig: dig,
216
+ version: undefined,
217
+ kind: undefined,
218
+ });
219
+ sigs = await keeper.sign(b(serder.raw));
220
+ ixn = serder.sad;
221
+ }
222
+ const body = {
223
+ rev: rev,
224
+ ixn: ixn,
225
+ sigs: sigs,
226
+ [keeper.algo]: keeper.params(),
227
+ };
228
+ const path = `/identifiers/${name}/credentials/${said}`;
229
+ const method = 'DELETE';
230
+ const res = await this.client.fetch(path, method, body);
231
+ const op = await res.json();
232
+ return {
233
+ rev: new Serder(rev),
234
+ anc: new Serder(ixn),
235
+ op,
236
+ };
237
+ }
238
+ }
239
+ export class RegistryResult {
240
+ constructor(regser, serder, sigs, promise) {
241
+ this._regser = regser;
242
+ this._serder = serder;
243
+ this._sigs = sigs;
244
+ this.promise = promise;
245
+ }
246
+ get regser() {
247
+ return this._regser;
248
+ }
249
+ get serder() {
250
+ return this._serder;
251
+ }
252
+ get sigs() {
253
+ return this._sigs;
254
+ }
255
+ async op() {
256
+ const res = await this.promise;
257
+ return await res.json();
258
+ }
259
+ }
260
+ /**
261
+ * Registries
262
+ */
263
+ export class Registries {
264
+ /**
265
+ * Registries
266
+ * @param {SignifyClient} client
267
+ */
268
+ constructor(client) {
269
+ this.client = client;
270
+ }
271
+ /**
272
+ * List registries
273
+ * @async
274
+ * @param {string} name Name or alias of the identifier
275
+ * @returns {Promise<Registry[]>} A promise to the list of registries
276
+ */
277
+ async list(name) {
278
+ const path = `/identifiers/${name}/registries`;
279
+ const method = 'GET';
280
+ const res = await this.client.fetch(path, method, null);
281
+ return await res.json();
282
+ }
283
+ /**
284
+ * Create a registry
285
+ * @async
286
+ * @param {CreateRegistryArgs}
287
+ * @returns {Promise<[any, Serder, any[], object]> } A promise to the long-running operation
288
+ */
289
+ async create({ name, registryName, noBackers = true, toad = 0, baks = [], nonce, }) {
290
+ const hab = await this.client.identifiers().get(name);
291
+ const pre = hab.prefix;
292
+ const cnfg = [];
293
+ if (noBackers) {
294
+ cnfg.push(TraitDex.NoBackers);
295
+ }
296
+ const state = hab.state;
297
+ const estOnly = state.c !== undefined && state.c.includes('EO');
298
+ if (estOnly) {
299
+ cnfg.push(TraitDex.EstOnly);
300
+ }
301
+ const regser = vdr.incept({ pre, baks, toad, nonce, cnfg });
302
+ if (estOnly) {
303
+ throw new Error('establishment only not implemented');
304
+ }
305
+ else {
306
+ const state = hab.state;
307
+ const sn = parseInt(state.s, 16);
308
+ const dig = state.d;
309
+ const data = [
310
+ {
311
+ i: regser.pre,
312
+ s: '0',
313
+ d: regser.pre,
314
+ },
315
+ ];
316
+ const serder = interact({
317
+ pre: pre,
318
+ sn: sn + 1,
319
+ data: data,
320
+ dig: dig,
321
+ version: Vrsn_1_0,
322
+ kind: Serials.JSON,
323
+ });
324
+ const keeper = this.client.manager.get(hab);
325
+ const sigs = await keeper.sign(b(serder.raw));
326
+ const res = this.createFromEvents(hab, name, registryName, regser.sad, serder.sad, sigs);
327
+ return new RegistryResult(regser, serder, sigs, res);
328
+ }
329
+ }
330
+ createFromEvents(hab, name, registryName, vcp, ixn, sigs) {
331
+ const path = `/identifiers/${name}/registries`;
332
+ const method = 'POST';
333
+ const data = {
334
+ name: registryName,
335
+ vcp: vcp,
336
+ ixn: ixn,
337
+ sigs: sigs,
338
+ };
339
+ const keeper = this.client.manager.get(hab);
340
+ data[keeper.algo] = keeper.params();
341
+ return this.client.fetch(path, method, data);
342
+ }
343
+ /**
344
+ * Rename a registry
345
+ * @async
346
+ * @param {string} name Name or alias of the identifier
347
+ * @param {string} registryName Current registry name
348
+ * @param {string} newName New registry name
349
+ * @returns {Promise<Registry>} A promise to the registry record
350
+ */
351
+ async rename(name, registryName, newName) {
352
+ const path = `/identifiers/${name}/registries/${registryName}`;
353
+ const method = 'PUT';
354
+ const data = {
355
+ name: newName,
356
+ };
357
+ const res = await this.client.fetch(path, method, data);
358
+ return await res.json();
359
+ }
360
+ }
361
+ /**
362
+ * Schemas
363
+ */
364
+ export class Schemas {
365
+ /**
366
+ * Schemas
367
+ * @param {SignifyClient} client
368
+ */
369
+ constructor(client) {
370
+ this.client = client;
371
+ }
372
+ /**
373
+ * Get a schema
374
+ * @async
375
+ * @param {string} said SAID of the schema
376
+ * @returns {Promise<Schema>} A promise to the schema
377
+ */
378
+ async get(said) {
379
+ const path = `/schema/${said}`;
380
+ const method = 'GET';
381
+ const res = await this.client.fetch(path, method, null);
382
+ return await res.json();
383
+ }
384
+ /**
385
+ * List schemas
386
+ * @async
387
+ * @returns {Promise<Schema[]>} A promise to the list of schemas
388
+ */
389
+ async list() {
390
+ const path = `/schema`;
391
+ const method = 'GET';
392
+ const res = await this.client.fetch(path, method, null);
393
+ return await res.json();
394
+ }
395
+ }
396
+ /**
397
+ * Ipex
398
+ */
399
+ export class Ipex {
400
+ /**
401
+ * Schemas
402
+ * @param {SignifyClient} client
403
+ */
404
+ constructor(client) {
405
+ this.client = client;
406
+ }
407
+ /**
408
+ * Create an IPEX apply EXN message
409
+ */
410
+ async apply(args) {
411
+ var _a, _b;
412
+ const hab = await this.client.identifiers().get(args.senderName);
413
+ const data = {
414
+ m: (_a = args.message) !== null && _a !== void 0 ? _a : '',
415
+ s: args.schemaSaid,
416
+ a: (_b = args.attributes) !== null && _b !== void 0 ? _b : {},
417
+ };
418
+ return this.client
419
+ .exchanges()
420
+ .createExchangeMessage(hab, '/ipex/apply', data, {}, args.recipient, args.datetime, undefined);
421
+ }
422
+ async submitApply(name, exn, sigs, recp) {
423
+ const body = {
424
+ exn: exn.sad,
425
+ sigs,
426
+ rec: recp,
427
+ };
428
+ const response = await this.client.fetch(`/identifiers/${name}/ipex/apply`, 'POST', body);
429
+ return response.json();
430
+ }
431
+ /**
432
+ * Create an IPEX offer EXN message
433
+ */
434
+ async offer(args) {
435
+ var _a;
436
+ const hab = await this.client.identifiers().get(args.senderName);
437
+ const data = {
438
+ m: (_a = args.message) !== null && _a !== void 0 ? _a : '',
439
+ };
440
+ return this.client
441
+ .exchanges()
442
+ .createExchangeMessage(hab, '/ipex/offer', data, { acdc: [args.acdc, undefined] }, args.recipient, args.datetime, args.applySaid);
443
+ }
444
+ async submitOffer(name, exn, sigs, atc, recp) {
445
+ const body = {
446
+ exn: exn.sad,
447
+ sigs,
448
+ atc,
449
+ rec: recp,
450
+ };
451
+ const response = await this.client.fetch(`/identifiers/${name}/ipex/offer`, 'POST', body);
452
+ return response.json();
453
+ }
454
+ /**
455
+ * Create an IPEX agree EXN message
456
+ */
457
+ async agree(args) {
458
+ var _a;
459
+ const hab = await this.client.identifiers().get(args.senderName);
460
+ const data = {
461
+ m: (_a = args.message) !== null && _a !== void 0 ? _a : '',
462
+ };
463
+ return this.client
464
+ .exchanges()
465
+ .createExchangeMessage(hab, '/ipex/agree', data, {}, args.recipient, args.datetime, args.offerSaid);
466
+ }
467
+ async submitAgree(name, exn, sigs, recp) {
468
+ const body = {
469
+ exn: exn.sad,
470
+ sigs,
471
+ rec: recp,
472
+ };
473
+ const response = await this.client.fetch(`/identifiers/${name}/ipex/agree`, 'POST', body);
474
+ return response.json();
475
+ }
476
+ /**
477
+ * Create an IPEX grant EXN message
478
+ */
479
+ async grant(args) {
480
+ var _a;
481
+ const hab = await this.client.identifiers().get(args.senderName);
482
+ const data = {
483
+ m: (_a = args.message) !== null && _a !== void 0 ? _a : '',
484
+ };
485
+ let atc = args.ancAttachment;
486
+ if (atc === undefined) {
487
+ const keeper = this.client.manager.get(hab);
488
+ const sigs = await keeper.sign(b(args.anc.raw));
489
+ const sigers = sigs.map((sig) => new Siger({ qb64: sig }));
490
+ const ims = d(messagize(args.anc, sigers));
491
+ atc = ims.substring(args.anc.size);
492
+ }
493
+ const acdcAtc = args.acdcAttachment === undefined
494
+ ? d(serializeACDCAttachment(args.iss))
495
+ : args.acdcAttachment;
496
+ const issAtc = args.issAttachment === undefined
497
+ ? d(serializeIssExnAttachment(args.anc))
498
+ : args.issAttachment;
499
+ const embeds = {
500
+ acdc: [args.acdc, acdcAtc],
501
+ iss: [args.iss, issAtc],
502
+ anc: [args.anc, atc],
503
+ };
504
+ return this.client
505
+ .exchanges()
506
+ .createExchangeMessage(hab, '/ipex/grant', data, embeds, args.recipient, args.datetime, args.agreeSaid);
507
+ }
508
+ async submitGrant(name, exn, sigs, atc, recp) {
509
+ const body = {
510
+ exn: exn.sad,
511
+ sigs: sigs,
512
+ atc: atc,
513
+ rec: recp,
514
+ };
515
+ const response = await this.client.fetch(`/identifiers/${name}/ipex/grant`, 'POST', body);
516
+ return response.json();
517
+ }
518
+ /**
519
+ * Create an IPEX admit EXN message
520
+ */
521
+ async admit(args) {
522
+ const hab = await this.client.identifiers().get(args.senderName);
523
+ const data = {
524
+ m: args.message,
525
+ };
526
+ return this.client
527
+ .exchanges()
528
+ .createExchangeMessage(hab, '/ipex/admit', data, {}, args.recipient, args.datetime, args.grantSaid);
529
+ }
530
+ async submitAdmit(name, exn, sigs, atc, recp) {
531
+ const body = {
532
+ exn: exn.sad,
533
+ sigs: sigs,
534
+ atc: atc,
535
+ rec: recp,
536
+ };
537
+ const response = await this.client.fetch(`/identifiers/${name}/ipex/admit`, 'POST', body);
538
+ return response.json();
539
+ }
540
+ }
@@ -0,0 +1,18 @@
1
+ import { EventResult } from './aiding.ts';
2
+ import { SignifyClient } from './clienting.ts';
3
+ export declare class Delegations {
4
+ client: SignifyClient;
5
+ /**
6
+ * Delegations
7
+ * @param {SignifyClient} client
8
+ */
9
+ constructor(client: SignifyClient);
10
+ /**
11
+ * Approve the delegation via interaction event
12
+ * @async
13
+ * @param {string} name Name or alias of the identifier
14
+ * @param {any} [data] The anchoring interaction event
15
+ * @returns {Promise<EventResult>} A promise to the delegated approval result
16
+ */
17
+ approve(name: string, data?: any): Promise<EventResult>;
18
+ }
@@ -0,0 +1,24 @@
1
+ import { EventResult } from "./aiding.js";
2
+ export class Delegations {
3
+ /**
4
+ * Delegations
5
+ * @param {SignifyClient} client
6
+ */
7
+ constructor(client) {
8
+ this.client = client;
9
+ }
10
+ /**
11
+ * Approve the delegation via interaction event
12
+ * @async
13
+ * @param {string} name Name or alias of the identifier
14
+ * @param {any} [data] The anchoring interaction event
15
+ * @returns {Promise<EventResult>} A promise to the delegated approval result
16
+ */
17
+ async approve(name, data) {
18
+ const { serder, sigs, jsondata } = await this.client
19
+ .identifiers()
20
+ .createInteract(name, data);
21
+ const res = await this.client.fetch('/identifiers/' + name + '/delegation', 'POST', jsondata);
22
+ return new EventResult(serder, sigs, res);
23
+ }
24
+ }
@@ -1,4 +1,6 @@
1
- import { SignifyClient } from './clienting';
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
  }
@@ -1,31 +1,25 @@
1
- import { SignifyClient } from './clienting';
2
-
3
1
  /**
4
2
  * Escrows
5
3
  */
6
4
  export class Escrows {
7
- client: SignifyClient;
8
-
9
5
  /**
10
6
  * Escrows
11
7
  * @param {SignifyClient} client
12
8
  */
13
- constructor(client: SignifyClient) {
9
+ constructor(client) {
14
10
  this.client = client;
15
11
  }
16
-
17
12
  /**
18
13
  * List replay messages
19
14
  * @async
20
15
  * @param {string} [route] Optional route in the replay message
21
- * @returns {Promise<any>} A promise to the list of replay messages
16
+ * @returns {Promise<Rpy[]>} A promise to the list of replay messages
22
17
  */
23
- async listReply(route?: string): Promise<any> {
18
+ async listReply(route) {
24
19
  const params = new URLSearchParams();
25
20
  if (route !== undefined) {
26
21
  params.append('route', route);
27
22
  }
28
-
29
23
  const path = `/escrows/rpy` + '?' + params.toString();
30
24
  const method = 'GET';
31
25
  const res = await this.client.fetch(path, method, null);