signify-ts 0.2.1 → 0.3.0-rc2

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 (128) 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 +34 -14
  7. package/{src/keri/app/aiding.ts → dist/keri/app/aiding.js} +104 -235
  8. package/dist/keri/app/clienting.d.ts +57 -22
  9. package/{src/keri/app/clienting.ts → dist/keri/app/clienting.js} +145 -234
  10. package/dist/keri/app/contacting.d.ts +33 -21
  11. package/{src/keri/app/contacting.ts → dist/keri/app/contacting.js} +25 -62
  12. package/dist/keri/app/controller.d.ts +49 -6
  13. package/{src/keri/app/controller.ts → dist/keri/app/controller.js} +79 -185
  14. package/dist/keri/app/coring.d.ts +30 -8
  15. package/{src/keri/app/coring.ts → dist/keri/app/coring.js} +62 -51
  16. package/dist/keri/app/credentialing.d.ts +183 -65
  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 +1 -1
  21. package/{src/keri/app/escrowing.ts → dist/keri/app/escrowing.js} +2 -8
  22. package/dist/keri/app/exchanging.d.ts +7 -6
  23. package/{src/keri/app/exchanging.ts → dist/keri/app/exchanging.js} +33 -110
  24. package/dist/keri/app/grouping.d.ts +2 -2
  25. package/{src/keri/app/grouping.ts → dist/keri/app/grouping.js} +6 -25
  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 +4 -4
  51. package/{src/keri/core/eventing.ts → dist/keri/core/eventing.js} +134 -321
  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 +98 -46
  57. package/dist/keri/core/keeping.js +365 -0
  58. package/{src/keri/core/kering.ts → dist/keri/core/kering.js} +1 -3
  59. package/dist/keri/core/keyState.d.ts +85 -0
  60. package/dist/keri/core/keyState.js +1 -0
  61. package/dist/keri/core/manager.d.ts +147 -12
  62. package/dist/keri/core/manager.js +880 -0
  63. package/dist/keri/core/matter.d.ts +1 -1
  64. package/dist/keri/core/matter.js +460 -0
  65. package/dist/keri/core/number.d.ts +1 -1
  66. package/{src/keri/core/number.ts → dist/keri/core/number.js} +21 -30
  67. package/dist/keri/core/pather.d.ts +2 -2
  68. package/{src/keri/core/pather.ts → dist/keri/core/pather.js} +12 -27
  69. package/dist/keri/core/prefixer.d.ts +10 -10
  70. package/dist/keri/core/prefixer.js +182 -0
  71. package/dist/keri/core/saider.d.ts +2 -12
  72. package/dist/keri/core/saider.js +107 -0
  73. package/dist/keri/core/salter.d.ts +45 -3
  74. package/dist/keri/core/salter.js +117 -0
  75. package/dist/keri/core/seqner.d.ts +1 -1
  76. package/{src/keri/core/seqner.ts → dist/keri/core/seqner.js} +20 -21
  77. package/dist/keri/core/serder.d.ts +25 -12
  78. package/dist/keri/core/serder.js +133 -0
  79. package/dist/keri/core/siger.d.ts +2 -2
  80. package/{src/keri/core/siger.ts → dist/keri/core/siger.js} +4 -14
  81. package/dist/keri/core/signer.d.ts +4 -4
  82. package/dist/keri/core/signer.js +84 -0
  83. package/{src/keri/core/tholder.ts → dist/keri/core/tholder.js} +69 -94
  84. package/dist/keri/core/utils.d.ts +1 -1
  85. package/{src/keri/core/utils.ts → dist/keri/core/utils.js} +30 -60
  86. package/dist/keri/core/vdring.d.ts +2 -2
  87. package/dist/keri/core/vdring.js +61 -0
  88. package/dist/keri/core/verfer.d.ts +2 -6
  89. package/dist/keri/core/verfer.js +37 -0
  90. package/dist/keri/end/ending.d.ts +10 -8
  91. package/dist/keri/end/ending.js +136 -0
  92. package/{src/ready.ts → dist/ready.js} +1 -2
  93. package/dist/types/keria-api-schema.d.ts +304 -0
  94. package/dist/types/keria-api-schema.js +2 -0
  95. package/package.json +53 -50
  96. package/dist/buffer-polyfill.d.ts +0 -1
  97. package/dist/math.d.ts +0 -1
  98. package/dist/signify-ts.cjs +0 -7842
  99. package/dist/signify-ts.cjs.development.js +0 -9501
  100. package/dist/signify-ts.cjs.development.js.map +0 -1
  101. package/dist/signify-ts.cjs.map +0 -7
  102. package/dist/signify-ts.cjs.production.min.js +0 -2
  103. package/dist/signify-ts.cjs.production.min.js.map +0 -1
  104. package/dist/signify-ts.esm.js +0 -9345
  105. package/dist/signify-ts.esm.js.map +0 -1
  106. package/dist/signify-ts.mjs +0 -7818
  107. package/dist/signify-ts.mjs.map +0 -7
  108. package/src/buffer-polyfill.ts +0 -5
  109. package/src/exports.ts +0 -44
  110. package/src/index.ts +0 -4
  111. package/src/keri/app/credentialing.ts +0 -841
  112. package/src/keri/app/habery.ts +0 -185
  113. package/src/keri/core/cigar.ts +0 -18
  114. package/src/keri/core/core.ts +0 -326
  115. package/src/keri/core/counter.ts +0 -273
  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
@@ -1,82 +1,18 @@
1
- import { Tier } from '../core/salter';
2
- import { Algos } from '../core/manager';
3
- import { incept, interact, reply, rotate } from '../core/eventing';
4
- import { b, Ilks, Serials, Versionage } from '../core/core';
5
- import { Tholder } from '../core/tholder';
6
- import { MtrDex } from '../core/matter';
7
- import { Serder } from '../core/serder';
8
- import { parseRangeHeaders } from '../core/httping';
9
- import { KeyManager } from '../core/keeping';
10
-
11
- /** Arguments required to create an identfier */
12
- export interface CreateIdentiferArgs {
13
- transferable?: boolean;
14
- isith?: string | number | string[];
15
- nsith?: string | number | string[];
16
- wits?: string[];
17
- toad?: number;
18
- proxy?: string;
19
- delpre?: string;
20
- dcode?: string;
21
- data?: any;
22
- algo?: Algos;
23
- pre?: string;
24
- states?: any[];
25
- rstates?: any[];
26
- prxs?: any[];
27
- nxts?: any[];
28
- mhab?: any;
29
- keys?: any[];
30
- ndigs?: any[];
31
- bran?: string;
32
- count?: number;
33
- ncount?: number;
34
- tier?: Tier;
35
- extern_type?: string;
36
- extern?: any;
37
- }
38
-
39
- /** Arguments required to rotate an identfier */
40
- export interface RotateIdentifierArgs {
41
- transferable?: boolean;
42
- nsith?: string | number | string[];
43
- toad?: number;
44
- cuts?: string[];
45
- adds?: string[];
46
- data?: Array<object>;
47
- ncode?: string;
48
- ncount?: number;
49
- ncodes?: string[];
50
- states?: any[];
51
- rstates?: any[];
52
- }
53
-
54
- /**
55
- * Reducing the SignifyClient dependencies used by Identifier class
56
- */
57
- export interface IdentifierDeps {
58
- fetch(
59
- pathname: string,
60
- method: string,
61
- body: unknown,
62
- headers?: Headers
63
- ): Promise<Response>;
64
- pidx: number;
65
- manager: KeyManager | null;
66
- }
67
-
1
+ import { Algos } from "../core/manager.js";
2
+ import { incept, interact, reply, rotate } from "../core/eventing.js";
3
+ import { b, Ilks, Serials, Vrsn_1_0 } from "../core/core.js";
4
+ import { Tholder } from "../core/tholder.js";
5
+ import { MtrDex } from "../core/matter.js";
6
+ import { parseRangeHeaders } from "../core/httping.js";
68
7
  /** Identifier */
69
8
  export class Identifier {
70
- public client: IdentifierDeps;
71
-
72
9
  /**
73
10
  * Identifier
74
11
  * @param {IdentifierDeps} client
75
12
  */
76
- constructor(client: IdentifierDeps) {
13
+ constructor(client) {
77
14
  this.client = client;
78
15
  }
79
-
80
16
  /**
81
17
  * List managed identifiers
82
18
  * @async
@@ -84,19 +20,16 @@ export class Identifier {
84
20
  * @param {number} [end=24] End index of list of notifications, defaults to 24
85
21
  * @returns {Promise<any>} A promise to the list of managed identifiers
86
22
  */
87
- async list(start: number = 0, end: number = 24): Promise<any> {
23
+ async list(start = 0, end = 24) {
88
24
  const extraHeaders = new Headers();
89
25
  extraHeaders.append('Range', `aids=${start}-${end}`);
90
-
91
26
  const path = `/identifiers`;
92
27
  const data = null;
93
28
  const method = 'GET';
94
29
  const res = await this.client.fetch(path, method, data, extraHeaders);
95
-
96
30
  const cr = res.headers.get('content-range');
97
31
  const range = parseRangeHeaders(cr, 'aids');
98
32
  const aids = await res.json();
99
-
100
33
  return {
101
34
  start: range.start,
102
35
  end: range.end,
@@ -104,21 +37,32 @@ export class Identifier {
104
37
  aids: aids,
105
38
  };
106
39
  }
107
-
108
40
  /**
109
41
  * Get information for a managed identifier
110
42
  * @async
111
- * @param {string} name Name or alias of the identifier
112
- * @returns {Promise<any>} A promise to the identifier information
43
+ * @param {string} name Prefix or alias of the identifier
44
+ * @returns {Promise<HabState>} A promise to the identifier information
113
45
  */
114
- async get(name: string): Promise<any> {
115
- const path = `/identifiers/${name}`;
46
+ async get(name) {
47
+ const path = `/identifiers/${encodeURIComponent(name)}`;
116
48
  const data = null;
117
49
  const method = 'GET';
118
50
  const res = await this.client.fetch(path, method, data);
119
51
  return await res.json();
120
52
  }
121
-
53
+ /**
54
+ * Update managed identifier
55
+ * @async
56
+ * @param {string} name Prefix or alias of the identifier
57
+ * @param {IdentifierInfo} info Information to update for the given identifier
58
+ * @returns {Promise<HabState>} A promise to the identifier information after updating
59
+ */
60
+ async update(name, info) {
61
+ const path = `/identifiers/${name}`;
62
+ const method = 'PUT';
63
+ const res = await this.client.fetch(path, method, info);
64
+ return await res.json();
65
+ }
122
66
  /**
123
67
  * Create a managed identifier
124
68
  * @async
@@ -126,18 +70,15 @@ export class Identifier {
126
70
  * @param {CreateIdentiferArgs} [kargs] Optional parameters to create the identifier
127
71
  * @returns {EventResult} The inception result
128
72
  */
129
- async create(
130
- name: string,
131
- kargs: CreateIdentiferArgs = {}
132
- ): Promise<EventResult> {
73
+ async create(name, kargs = {}) {
74
+ var _a, _b, _c, _d, _e, _f;
133
75
  const algo = kargs.algo == undefined ? Algos.salty : kargs.algo;
134
-
135
- const transferable = kargs.transferable ?? true;
136
- const isith = kargs.isith ?? '1';
137
- const nsith = kargs.nsith ?? '1';
138
- let wits = kargs.wits ?? [];
139
- const toad = kargs.toad ?? 0;
140
- const dcode = kargs.dcode ?? MtrDex.Blake3_256;
76
+ const transferable = (_a = kargs.transferable) !== null && _a !== void 0 ? _a : true;
77
+ const isith = (_b = kargs.isith) !== null && _b !== void 0 ? _b : '1';
78
+ let nsith = (_c = kargs.nsith) !== null && _c !== void 0 ? _c : '1';
79
+ let wits = (_d = kargs.wits) !== null && _d !== void 0 ? _d : [];
80
+ const toad = (_e = kargs.toad) !== null && _e !== void 0 ? _e : 0;
81
+ let dcode = (_f = kargs.dcode) !== null && _f !== void 0 ? _f : MtrDex.Blake3_256;
141
82
  const proxy = kargs.proxy;
142
83
  const delpre = kargs.delpre;
143
84
  const data = kargs.data != undefined ? [kargs.data] : [];
@@ -151,11 +92,15 @@ export class Identifier {
151
92
  const _ndigs = kargs.ndigs;
152
93
  const bran = kargs.bran;
153
94
  const count = kargs.count;
154
- const ncount = kargs.ncount;
95
+ let ncount = kargs.ncount;
155
96
  const tier = kargs.tier;
156
97
  const extern_type = kargs.extern_type;
157
98
  const extern = kargs.extern;
158
-
99
+ if (!transferable) {
100
+ ncount = 0;
101
+ nsith = 0;
102
+ dcode = MtrDex.Ed25519N;
103
+ }
159
104
  const xargs = {
160
105
  transferable: transferable,
161
106
  isith: isith,
@@ -182,14 +127,13 @@ export class Identifier {
182
127
  extern_type: extern_type,
183
128
  extern: extern,
184
129
  };
185
-
186
- const keeper = this.client.manager!.new(algo, this.client.pidx, xargs);
187
- const [keys, ndigs] = await keeper!.incept(transferable);
130
+ const keeper = this.client.manager.new(algo, this.client.pidx, xargs);
131
+ const [keys, ndigs] = await keeper.incept(transferable);
188
132
  wits = wits !== undefined ? wits : [];
189
- let serder: Serder | undefined = undefined;
133
+ let serder = undefined;
190
134
  if (delpre == undefined) {
191
135
  serder = incept({
192
- keys: keys!,
136
+ keys: keys,
193
137
  isith: isith,
194
138
  ndigs: ndigs,
195
139
  nsith: nsith,
@@ -197,14 +141,15 @@ export class Identifier {
197
141
  wits: wits,
198
142
  cnfg: [],
199
143
  data: data,
200
- version: Versionage,
144
+ version: Vrsn_1_0,
201
145
  kind: Serials.JSON,
202
146
  code: dcode,
203
147
  intive: false,
204
148
  });
205
- } else {
149
+ }
150
+ else {
206
151
  serder = incept({
207
- keys: keys!,
152
+ keys: keys,
208
153
  isith: isith,
209
154
  ndigs: ndigs,
210
155
  nsith: nsith,
@@ -212,55 +157,50 @@ export class Identifier {
212
157
  wits: wits,
213
158
  cnfg: [],
214
159
  data: data,
215
- version: Versionage,
160
+ version: Vrsn_1_0,
216
161
  kind: Serials.JSON,
217
162
  code: dcode,
218
163
  intive: false,
219
164
  delpre: delpre,
220
165
  });
221
166
  }
222
-
223
- const sigs = await keeper!.sign(b(serder.raw));
224
- const jsondata: any = {
167
+ const sigs = await keeper.sign(b(serder.raw));
168
+ const jsondata = {
225
169
  name: name,
226
- icp: serder.ked,
170
+ icp: serder.sad,
227
171
  sigs: sigs,
228
172
  proxy: proxy,
229
- smids:
230
- states != undefined
231
- ? states.map((state) => state.i)
232
- : undefined,
233
- rmids:
234
- rstates != undefined
235
- ? rstates.map((state) => state.i)
236
- : undefined,
173
+ smids: states != undefined
174
+ ? states.map((state) => state.i)
175
+ : undefined,
176
+ rmids: rstates != undefined
177
+ ? rstates.map((state) => state.i)
178
+ : undefined,
237
179
  };
238
180
  jsondata[algo] = keeper.params();
239
-
240
181
  this.client.pidx = this.client.pidx + 1;
241
- const res = this.client.fetch('/identifiers', 'POST', jsondata);
182
+ const res = await this.client.fetch('/identifiers', 'POST', jsondata);
242
183
  return new EventResult(serder, sigs, res);
243
184
  }
244
-
245
185
  /**
246
186
  * Generate an interaction event in a managed identifier
247
187
  * @async
248
- * @param {string} name Name or alias of the identifier
188
+ * @param {string} name Prefix or alias of the identifier
249
189
  * @param {any} [data] Option data to be anchored in the interaction event
250
190
  * @returns {Promise<EventResult>} A promise to the interaction event result
251
191
  */
252
- async interact(name: string, data?: any): Promise<EventResult> {
192
+ async interact(name, data) {
193
+ const { serder, sigs, jsondata } = await this.createInteract(name, data);
194
+ const res = await this.client.fetch('/identifiers/' + name + '/events', 'POST', jsondata);
195
+ return new EventResult(serder, sigs, res);
196
+ }
197
+ async createInteract(name, data) {
253
198
  const hab = await this.get(name);
254
- const pre: string = hab.prefix;
255
-
199
+ const pre = hab.prefix;
256
200
  const state = hab.state;
257
- const sn = Number(state.s);
201
+ const sn = parseInt(state.s, 16);
258
202
  const dig = state.d;
259
-
260
- data = Array.isArray(data) ? data : [data];
261
-
262
203
  data = Array.isArray(data) ? data : [data];
263
-
264
204
  const serder = interact({
265
205
  pre: pre,
266
206
  sn: sn + 1,
@@ -269,81 +209,56 @@ export class Identifier {
269
209
  version: undefined,
270
210
  kind: undefined,
271
211
  });
272
- const keeper = this.client!.manager!.get(hab);
212
+ const keeper = this.client.manager.get(hab);
273
213
  const sigs = await keeper.sign(b(serder.raw));
274
-
275
- const jsondata: any = {
276
- ixn: serder.ked,
214
+ const jsondata = {
215
+ ixn: serder.sad,
277
216
  sigs: sigs,
278
217
  };
279
218
  jsondata[keeper.algo] = keeper.params();
280
-
281
- const res = await this.client.fetch(
282
- '/identifiers/' + name + '?type=ixn',
283
- 'PUT',
284
- jsondata
285
- );
286
- return new EventResult(serder, sigs, res);
219
+ return { serder, sigs, jsondata };
287
220
  }
288
-
289
221
  /**
290
222
  * Generate a rotation event in a managed identifier
291
223
  * @param {string} name Name or alias of the identifier
292
224
  * @param {RotateIdentifierArgs} [kargs] Optional parameters requiered to generate the rotation event
293
225
  * @returns {Promise<EventResult>} A promise to the rotation event result
294
226
  */
295
- async rotate(
296
- name: string,
297
- kargs: RotateIdentifierArgs = {}
298
- ): Promise<EventResult> {
299
- const transferable = kargs.transferable ?? true;
300
- const ncode = kargs.ncode ?? MtrDex.Ed25519_Seed;
301
- const ncount = kargs.ncount ?? 1;
302
-
227
+ async rotate(name, kargs = {}) {
228
+ var _a, _b, _c, _d, _e, _f, _g;
229
+ const transferable = (_a = kargs.transferable) !== null && _a !== void 0 ? _a : true;
230
+ const ncode = (_b = kargs.ncode) !== null && _b !== void 0 ? _b : MtrDex.Ed25519_Seed;
231
+ const ncount = (_c = kargs.ncount) !== null && _c !== void 0 ? _c : 1;
303
232
  const hab = await this.get(name);
304
233
  const pre = hab.prefix;
305
234
  const delegated = hab.state.di !== '';
306
-
307
235
  const state = hab.state;
308
236
  const count = state.k.length;
309
237
  const dig = state.d;
310
- const ridx = Number(state.s) + 1;
238
+ const ridx = parseInt(state.s, 16) + 1;
311
239
  const wits = state.b;
312
240
  let isith = state.nt;
313
-
314
- let nsith = kargs.nsith ?? isith;
315
-
241
+ let nsith = (_d = kargs.nsith) !== null && _d !== void 0 ? _d : isith;
316
242
  // if isith is None: # compute default from newly rotated verfers above
317
243
  if (isith == undefined)
318
244
  isith = `${Math.max(1, Math.ceil(count / 2)).toString(16)}`;
319
-
320
245
  // if nsith is None: # compute default from newly rotated digers above
321
246
  if (nsith == undefined)
322
247
  nsith = `${Math.max(1, Math.ceil(ncount / 2)).toString(16)}`;
323
-
324
248
  const cst = new Tholder({ sith: isith }).sith; // current signing threshold
325
249
  const nst = new Tholder({ sith: nsith }).sith; // next signing threshold
326
-
327
250
  // Regenerate next keys to sign rotation event
328
- const keeper = this.client.manager!.get(hab);
251
+ const keeper = this.client.manager.get(hab);
329
252
  // Create new keys for next digests
330
- const ncodes = kargs.ncodes ?? new Array(ncount).fill(ncode);
331
-
253
+ const ncodes = (_e = kargs.ncodes) !== null && _e !== void 0 ? _e : new Array(ncount).fill(ncode);
332
254
  const states = kargs.states == undefined ? [] : kargs.states;
333
255
  const rstates = kargs.rstates == undefined ? [] : kargs.rstates;
334
- const [keys, ndigs] = await keeper!.rotate(
335
- ncodes,
336
- transferable,
337
- states,
338
- rstates
339
- );
340
-
341
- const cuts = kargs.cuts ?? [];
342
- const adds = kargs.adds ?? [];
256
+ const [keys, ndigs] = await keeper.rotate(ncodes, transferable, states, rstates);
257
+ const cuts = (_f = kargs.cuts) !== null && _f !== void 0 ? _f : [];
258
+ const adds = (_g = kargs.adds) !== null && _g !== void 0 ? _g : [];
343
259
  const data = kargs.data != undefined ? [kargs.data] : [];
344
260
  const toad = kargs.toad;
345
261
  const ilk = delegated ? Ilks.drt : Ilks.rot;
346
-
347
262
  const serder = rotate({
348
263
  pre: pre,
349
264
  ilk: ilk,
@@ -359,31 +274,21 @@ export class Identifier {
359
274
  adds: adds,
360
275
  data: data,
361
276
  });
362
-
363
277
  const sigs = await keeper.sign(b(serder.raw));
364
-
365
- const jsondata: any = {
366
- rot: serder.ked,
278
+ const jsondata = {
279
+ rot: serder.sad,
367
280
  sigs: sigs,
368
- smids:
369
- states != undefined
370
- ? states.map((state) => state.i)
371
- : undefined,
372
- rmids:
373
- rstates != undefined
374
- ? rstates.map((state) => state.i)
375
- : undefined,
281
+ smids: states != undefined
282
+ ? states.map((state) => state.i)
283
+ : undefined,
284
+ rmids: rstates != undefined
285
+ ? rstates.map((state) => state.i)
286
+ : undefined,
376
287
  };
377
288
  jsondata[keeper.algo] = keeper.params();
378
-
379
- const res = await this.client.fetch(
380
- '/identifiers/' + name,
381
- 'PUT',
382
- jsondata
383
- );
289
+ const res = await this.client.fetch('/identifiers/' + name + '/events', 'POST', jsondata);
384
290
  return new EventResult(serder, sigs, res);
385
291
  }
386
-
387
292
  /**
388
293
  * Authorize an endpoint provider in a given role for a managed identifier
389
294
  * @remarks
@@ -395,32 +300,19 @@ export class Identifier {
395
300
  * @param {string} [stamp=now] Optional date-time-stamp RFC-3339 profile of iso8601 datetime. Now is the default if not provided
396
301
  * @returns {Promise<EventResult>} A promise to the result of the authorization
397
302
  */
398
- async addEndRole(
399
- name: string,
400
- role: string,
401
- eid?: string,
402
- stamp?: string
403
- ): Promise<EventResult> {
303
+ async addEndRole(name, role, eid, stamp) {
404
304
  const hab = await this.get(name);
405
305
  const pre = hab.prefix;
406
-
407
306
  const rpy = this.makeEndRole(pre, role, eid, stamp);
408
- const keeper = this.client.manager!.get(hab);
307
+ const keeper = this.client.manager.get(hab);
409
308
  const sigs = await keeper.sign(b(rpy.raw));
410
-
411
309
  const jsondata = {
412
- rpy: rpy.ked,
310
+ rpy: rpy.sad,
413
311
  sigs: sigs,
414
312
  };
415
-
416
- const res = this.client.fetch(
417
- '/identifiers/' + name + '/endroles',
418
- 'POST',
419
- jsondata
420
- );
313
+ const res = await this.client.fetch('/identifiers/' + name + '/endroles', 'POST', jsondata);
421
314
  return new EventResult(rpy, sigs, res);
422
315
  }
423
-
424
316
  /**
425
317
  * Generate an /end/role/add reply message
426
318
  * @param {string} pre Prefix of the identifier
@@ -429,13 +321,8 @@ export class Identifier {
429
321
  * @param {string} [stamp=now] Optional date-time-stamp RFC-3339 profile of iso8601 datetime. Now is the default if not provided
430
322
  * @returns {Serder} The reply message
431
323
  */
432
- private makeEndRole(
433
- pre: string,
434
- role: string,
435
- eid?: string,
436
- stamp?: string
437
- ): Serder {
438
- const data: any = {
324
+ makeEndRole(pre, role, eid, stamp) {
325
+ const data = {
439
326
  cid: pre,
440
327
  role: role,
441
328
  };
@@ -445,49 +332,31 @@ export class Identifier {
445
332
  const route = '/end/role/add';
446
333
  return reply(route, data, stamp, undefined, Serials.JSON);
447
334
  }
448
-
449
335
  /**
450
336
  * Get the members of a group identifier
451
337
  * @async
452
338
  * @param {string} name - Name or alias of the identifier
453
339
  * @returns {Promise<any>} - A promise to the list of members
454
340
  */
455
- async members(name: string): Promise<any> {
456
- const res = await this.client.fetch(
457
- '/identifiers/' + name + '/members',
458
- 'GET',
459
- undefined
460
- );
341
+ async members(name) {
342
+ const res = await this.client.fetch('/identifiers/' + name + '/members', 'GET', undefined);
461
343
  return await res.json();
462
344
  }
463
345
  }
464
-
465
346
  /** Event Result */
466
347
  export class EventResult {
467
- private readonly _serder: Serder;
468
- private readonly _sigs: string[];
469
- private readonly promise: Promise<Response> | Response;
470
-
471
- constructor(
472
- serder: Serder,
473
- sigs: string[],
474
- promise: Promise<Response> | Response
475
- ) {
348
+ constructor(serder, sigs, response) {
476
349
  this._serder = serder;
477
350
  this._sigs = sigs;
478
- this.promise = promise;
351
+ this.response = response;
479
352
  }
480
-
481
353
  get serder() {
482
354
  return this._serder;
483
355
  }
484
-
485
356
  get sigs() {
486
357
  return this._sigs;
487
358
  }
488
-
489
- async op(): Promise<any> {
490
- const res = await this.promise;
491
- return await res.json();
359
+ async op() {
360
+ return await this.response.json();
492
361
  }
493
362
  }
@@ -1,15 +1,16 @@
1
- import { Agent, Controller } from './controller';
2
- import { Tier } from '../core/salter';
3
- import { Authenticater } from '../core/authing';
4
- import { ExternalModule, KeyManager } from '../core/keeping';
5
- import { Identifier } from './aiding';
6
- import { Contacts, Challenges } from './contacting';
7
- import { Oobis, Operations, KeyEvents, KeyStates } from './coring';
8
- import { Credentials, Ipex, Registries, Schemas } from './credentialing';
9
- import { Notifications } from './notifying';
10
- import { Escrows } from './escrowing';
11
- import { Groups } from './grouping';
12
- import { Exchanges } from './exchanging';
1
+ import { Authenticater } from '../core/authing.ts';
2
+ import { ExternalModule, IdentifierManagerFactory } from '../core/keeping.ts';
3
+ import { Tier } from '../core/salter.ts';
4
+ import { Identifier } from './aiding.ts';
5
+ import { Contacts, Challenges } from './contacting.ts';
6
+ import { Agent, Controller } from './controller.ts';
7
+ import { Oobis, Operations, KeyEvents, KeyStates, Config } from './coring.ts';
8
+ import { Credentials, Ipex, Registries, Schemas } from './credentialing.ts';
9
+ import { Delegations } from './delegating.ts';
10
+ import { Escrows } from './escrowing.ts';
11
+ import { Exchanges } from './exchanging.ts';
12
+ import { Groups } from './grouping.ts';
13
+ import { Notifications } from './notifying.ts';
13
14
  declare class State {
14
15
  agent: any | null;
15
16
  controller: any | null;
@@ -17,7 +18,10 @@ declare class State {
17
18
  pidx: number;
18
19
  constructor();
19
20
  }
20
- /** SignifyClient */
21
+ /**
22
+ * An in-memory key manager that can connect to a KERIA Agent and use it to
23
+ * receive messages and act as a proxy for multi-signature operations and delegation operations.
24
+ */
21
25
  export declare class SignifyClient {
22
26
  controller: Controller;
23
27
  url: string;
@@ -25,10 +29,27 @@ export declare class SignifyClient {
25
29
  pidx: number;
26
30
  agent: Agent | null;
27
31
  authn: Authenticater | null;
28
- manager: KeyManager | null;
32
+ manager: IdentifierManagerFactory | null;
29
33
  tier: Tier;
30
34
  bootUrl: string;
31
35
  exteralModules: ExternalModule[];
36
+ private _identifiers;
37
+ private _operations;
38
+ private _keyEvents;
39
+ private _keyStates;
40
+ private _oobis;
41
+ private _config;
42
+ private _delegations;
43
+ private _exchanges;
44
+ private _groups;
45
+ private _escrows;
46
+ private _credentials;
47
+ private _registries;
48
+ private _ipex;
49
+ private _notifications;
50
+ private _contacts;
51
+ private _challenges;
52
+ private _schemas;
32
53
  /**
33
54
  * SignifyClient constructor
34
55
  * @param {string} url KERIA admin interface URL
@@ -66,16 +87,20 @@ export declare class SignifyClient {
66
87
  */
67
88
  fetch(path: string, method: string, data: any, extraHeaders?: Headers): Promise<Response>;
68
89
  /**
69
- * Fetch a resource from from an external URL with headers signed by an AID
90
+ * Create a Signed Request to fetch a resource from an external URL with headers signed by an AID
70
91
  * @async
71
- * @param {string} url URL of the resource
72
- * @param {string} path Path to the resource
73
- * @param {string} method HTTP method
74
- * @param {any} data Data to be sent in the body of the resource
75
92
  * @param {string} aidName Name or alias of the AID to be used for signing
76
- * @returns {Promise<Response>} A promise to the result of the fetch
77
- */
78
- signedFetch(url: string, path: string, method: string, data: any, aidName: string): Promise<Response>;
93
+ * @param {string} url URL of the requested resource
94
+ * @param {RequestInit} req Request options should include:
95
+ * - method: HTTP method
96
+ * - data Data to be sent in the body of the resource.
97
+ * If the data is a CESR JSON string then you should also set contentType to 'application/json+cesr'
98
+ * If the data is a FormData object then you should not set the contentType and the browser will set it to 'multipart/form-data'
99
+ * If the data is an object then you should use JSON.stringify to convert it to a string and set the contentType to 'application/json'
100
+ * - contentType Content type of the request.
101
+ * @returns {Promise<Request>} A promise to the created Request
102
+ */
103
+ createSignedRequest(aidName: string, url: string, req: RequestInit): Promise<Request>;
79
104
  /**
80
105
  * Approve the delegation of the client AID to the KERIA agent
81
106
  * @async
@@ -178,5 +203,15 @@ export declare class SignifyClient {
178
203
  * @returns {Exchanges}
179
204
  */
180
205
  exchanges(): Exchanges;
206
+ /**
207
+ * Get delegations resource
208
+ * @returns {Delegations}
209
+ */
210
+ delegations(): Delegations;
211
+ /**
212
+ * Get agent config resource
213
+ * @returns {Config}
214
+ */
215
+ config(): Config;
181
216
  }
182
217
  export {};