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,347 @@
1
+ import { Algos, SaltyCreator, RandyCreator } from "./manager.js";
2
+ import { MtrDex } from "./matter.js";
3
+ import { Tier } from "./salter.js";
4
+ import { Encrypter } from "../core/encrypter.js";
5
+ import { Decrypter } from "./decrypter.js";
6
+ import { b } from "./core.js";
7
+ import { Cipher } from "./cipher.js";
8
+ import { Diger } from "./diger.js";
9
+ import { Prefixer } from "./prefixer.js";
10
+ /**
11
+ * Creates IdentifierManager instances based on the algorithm and key indexes.
12
+ */
13
+ export class IdentifierManagerFactory {
14
+ /**
15
+ * Creates a factory for generating IdentifierManagers. Requires a salt to be specified.
16
+ * Allows external key management modules to be configured.
17
+ * @param salter
18
+ * @param externalModules
19
+ */
20
+ constructor(salter, externalModules = []) {
21
+ this.salter = salter;
22
+ this.modules = {};
23
+ this.salter = salter;
24
+ for (const mod of externalModules) {
25
+ this.modules[mod.type] = mod.module;
26
+ }
27
+ }
28
+ /**
29
+ *
30
+ * @param algo
31
+ * @param pidx
32
+ * @param kargs
33
+ */
34
+ new(algo, pidx, kargs) {
35
+ switch (algo) {
36
+ case Algos.salty:
37
+ return new SaltyIdentifierManager(this.salter, pidx, kargs['kidx'], kargs['tier'], kargs['transferable'], kargs['stem'], kargs['code'], kargs['count'], kargs['icodes'], kargs['ncode'], kargs['ncount'], kargs['ncodes'], kargs['dcode'], kargs['bran'], kargs['sxlt']);
38
+ case Algos.randy:
39
+ return new RandyIdentifierManager(this.salter, kargs['code'], kargs['count'], kargs['icodes'], kargs['transferable'], kargs['ncode'], kargs['ncount'], kargs['ncodes'], kargs['dcode'], kargs['prxs'], kargs['nxts']);
40
+ case Algos.group:
41
+ return new GroupIdentifierManager(this, kargs['mhab'], kargs['states'], kargs['rstates'], kargs['keys'], kargs['ndigs']);
42
+ case Algos.extern: {
43
+ const ModuleConstructor = this.modules[kargs.extern_type];
44
+ if (!ModuleConstructor) {
45
+ throw new Error(`unsupported external module type ${kargs.extern_type}`);
46
+ }
47
+ return new ModuleConstructor(pidx, kargs);
48
+ }
49
+ default:
50
+ throw new Error('Unknown algo');
51
+ }
52
+ }
53
+ /**
54
+ * Generates an algorithm-specific IdentifierManager instance with correct keys based on
55
+ * the indexes provided by the HabState.
56
+ * @param aid HabState with the algorithm and key indexes
57
+ * @returns IdentifierManager instance
58
+ */
59
+ get(aid) {
60
+ if (Algos.salty in aid) {
61
+ return new SaltyIdentifierManager(this.salter, aid.salty.pidx, aid.salty.kidx, aid.salty.tier, aid.salty.transferable, aid.salty.stem, undefined, undefined, aid.salty.icodes, undefined, undefined, aid.salty.ncodes, aid.salty.dcode, undefined, aid.salty.sxlt);
62
+ }
63
+ else if (Algos.randy in aid) {
64
+ return new RandyIdentifierManager(this.salter, undefined, undefined, undefined, new Prefixer({ qb64: aid['prefix'] }).transferable, undefined, undefined, [], undefined, aid.randy.prxs, aid.randy.nxts);
65
+ }
66
+ else if (Algos.group in aid) {
67
+ return new GroupIdentifierManager(this, aid.group.mhab, undefined, undefined, aid.group.keys, aid.group.ndigs);
68
+ }
69
+ else if (Algos.extern in aid) {
70
+ const typ = aid.extern.extern_type;
71
+ if (typ in this.modules) {
72
+ const mod = new this.modules[typ](aid.extern.pidx, aid.extern);
73
+ return mod;
74
+ }
75
+ else {
76
+ throw new Error(`unsupported external module type ${typ}`);
77
+ }
78
+ }
79
+ else {
80
+ throw new Error('No algo specified');
81
+ }
82
+ }
83
+ }
84
+ export class SaltyIdentifierManager {
85
+ constructor(salter, pidx, kidx = 0, tier = Tier.low, transferable = false, stem = undefined, code = MtrDex.Ed25519_Seed, count = 1, icodes = undefined, ncode = MtrDex.Ed25519_Seed, ncount = 1, ncodes = undefined, dcode = MtrDex.Blake3_256, bran = undefined, sxlt = undefined) {
86
+ this.algo = Algos.salty;
87
+ // # Salter is the entered passcode and used for enc/dec of salts for each AID
88
+ this.salter = salter;
89
+ const signer = this.salter.signer(code, transferable, undefined, tier);
90
+ this.aeid = signer.verfer.qb64;
91
+ this.encrypter = new Encrypter({}, b(this.aeid));
92
+ this.decrypter = new Decrypter({}, signer.qb64b);
93
+ this.code = code;
94
+ this.ncode = ncode;
95
+ this.tier = tier;
96
+ this.icodes =
97
+ icodes == undefined ? new Array(count).fill(code) : icodes;
98
+ this.ncodes =
99
+ ncodes == undefined
100
+ ? new Array(ncount).fill(ncode)
101
+ : ncodes;
102
+ this.dcode = dcode;
103
+ this.pidx = pidx;
104
+ this.kidx = kidx;
105
+ this.transferable = transferable;
106
+ this.count = count;
107
+ this.ncount = ncount;
108
+ this.stem = stem == undefined ? 'signify:aid' : stem;
109
+ if (bran != undefined) {
110
+ this.bran = MtrDex.Salt_128 + 'A' + bran.slice(0, 21);
111
+ this.creator = new SaltyCreator(this.bran, this.tier, this.stem);
112
+ this.sxlt = this.encrypter.encrypt(b(this.creator.salt)).qb64;
113
+ }
114
+ else if (sxlt == undefined) {
115
+ this.creator = new SaltyCreator(undefined, this.tier, this.stem);
116
+ this.sxlt = this.encrypter.encrypt(b(this.creator.salt)).qb64;
117
+ }
118
+ else {
119
+ this.sxlt = sxlt;
120
+ const ciph = new Cipher({ qb64: this.sxlt });
121
+ this.creator = new SaltyCreator(this.decrypter.decrypt(null, ciph).qb64, tier, this.stem);
122
+ }
123
+ this.signers = this.creator.create(this.icodes, this.ncount, this.ncode, this.transferable, this.pidx, 0, this.kidx, false).signers;
124
+ }
125
+ params() {
126
+ return {
127
+ sxlt: this.sxlt,
128
+ pidx: this.pidx,
129
+ kidx: this.kidx,
130
+ stem: this.stem,
131
+ tier: this.tier,
132
+ icodes: this.icodes,
133
+ ncodes: this.ncodes,
134
+ dcode: this.dcode,
135
+ transferable: this.transferable,
136
+ };
137
+ }
138
+ async incept(transferable) {
139
+ var _a;
140
+ this.transferable = transferable;
141
+ this.kidx = 0;
142
+ const signers = this.creator.create(this.icodes, this.count, this.code, this.transferable, this.pidx, 0, this.kidx, false);
143
+ const verfers = signers.signers.map((signer) => signer.verfer.qb64);
144
+ const nsigners = this.creator.create(this.ncodes, this.ncount, this.ncode, this.transferable, this.pidx, 0, (_a = this.icodes) === null || _a === void 0 ? void 0 : _a.length, false);
145
+ const digers = nsigners.signers.map((nsigner) => new Diger({ code: this.dcode }, nsigner.verfer.qb64b).qb64);
146
+ return [verfers, digers];
147
+ }
148
+ async rotate(ncodes, transferable) {
149
+ this.ncodes = ncodes;
150
+ this.transferable = transferable;
151
+ const signers = this.creator.create(this.ncodes, this.ncount, this.ncode, this.transferable, this.pidx, 0, this.kidx + this.icodes.length, false);
152
+ const verfers = signers.signers.map((signer) => signer.verfer.qb64);
153
+ this.kidx = this.kidx + this.icodes.length;
154
+ const nsigners = this.creator.create(this.ncodes, this.ncount, this.ncode, this.transferable, this.pidx, 0, this.kidx + this.icodes.length, false);
155
+ const digers = nsigners.signers.map((nsigner) => new Diger({ code: this.dcode }, nsigner.verfer.qb64b).qb64);
156
+ return [verfers, digers];
157
+ }
158
+ async sign(ser, indexed = true, indices = undefined, ondices = undefined) {
159
+ const signers = this.creator.create(this.icodes, this.ncount, this.ncode, this.transferable, this.pidx, 0, this.kidx, false);
160
+ if (indexed) {
161
+ const sigers = [];
162
+ let i = 0;
163
+ for (const [j, signer] of signers.signers.entries()) {
164
+ if (indices != undefined) {
165
+ i = indices[j];
166
+ if (typeof i != 'number' || i < 0) {
167
+ throw new Error(`Invalid signing index = ${i}, not whole number.`);
168
+ }
169
+ }
170
+ else {
171
+ i = j;
172
+ }
173
+ let o = 0;
174
+ if (ondices != undefined) {
175
+ o = ondices[j];
176
+ if ((o == undefined ||
177
+ (typeof o == 'number' &&
178
+ typeof o != 'number' &&
179
+ o >= 0))) {
180
+ throw new Error(`Invalid ondex = ${o}, not whole number.`);
181
+ }
182
+ }
183
+ else {
184
+ o = i;
185
+ }
186
+ sigers.push(signer.sign(ser, i, o == undefined ? true : false, o));
187
+ }
188
+ return sigers.map((siger) => siger.qb64);
189
+ }
190
+ else {
191
+ const cigars = [];
192
+ for (const [, signer] of signers.signers.entries()) {
193
+ cigars.push(signer.sign(ser));
194
+ }
195
+ return cigars.map((cigar) => cigar.qb64);
196
+ }
197
+ }
198
+ }
199
+ export class RandyIdentifierManager {
200
+ constructor(salter, code = MtrDex.Ed25519_Seed, count = 1, icodes = undefined, transferable = false, ncode = MtrDex.Ed25519_Seed, ncount = 1, ncodes, dcode = MtrDex.Blake3_256, prxs = undefined, nxts = undefined) {
201
+ this.algo = Algos.randy;
202
+ this.salter = salter;
203
+ this.icodes =
204
+ icodes == undefined ? new Array(count).fill(code) : icodes;
205
+ this.ncodes =
206
+ ncodes == undefined
207
+ ? new Array(ncount).fill(ncode)
208
+ : ncodes;
209
+ this.code = code;
210
+ this.ncode = ncode;
211
+ this.count = count;
212
+ this.ncount = ncount;
213
+ const signer = this.salter.signer(code, transferable);
214
+ this.aeid = signer.verfer.qb64;
215
+ this.encrypter = new Encrypter({}, b(this.aeid));
216
+ this.decrypter = new Decrypter({}, signer.qb64b);
217
+ this.nxts = nxts !== null && nxts !== void 0 ? nxts : [];
218
+ this.prxs = prxs !== null && prxs !== void 0 ? prxs : [];
219
+ this.transferable = transferable;
220
+ this.icodes = icodes;
221
+ this.ncodes = ncodes;
222
+ this.dcode = dcode;
223
+ this.creator = new RandyCreator();
224
+ this.signers = this.prxs.map((prx) => this.decrypter.decrypt(new Cipher({ qb64: prx }).qb64b, undefined, this.transferable));
225
+ }
226
+ params() {
227
+ return {
228
+ nxts: this.nxts,
229
+ prxs: this.prxs,
230
+ transferable: this.transferable,
231
+ };
232
+ }
233
+ async incept(transferable) {
234
+ this.transferable = transferable;
235
+ const signers = this.creator.create(this.icodes, this.count, this.code, this.transferable);
236
+ this.prxs = signers.signers.map((signer) => this.encrypter.encrypt(undefined, signer).qb64);
237
+ const verfers = signers.signers.map((signer) => signer.verfer.qb64);
238
+ const nsigners = this.creator.create(this.ncodes, this.ncount, this.ncode, this.transferable);
239
+ this.nxts = nsigners.signers.map((signer) => this.encrypter.encrypt(undefined, signer).qb64);
240
+ const digers = nsigners.signers.map((nsigner) => new Diger({ code: this.dcode }, nsigner.verfer.qb64b).qb64);
241
+ return [verfers, digers];
242
+ }
243
+ async rotate(ncodes, transferable) {
244
+ this.ncodes = ncodes;
245
+ this.transferable = transferable;
246
+ this.prxs = this.nxts;
247
+ const signers = this.nxts.map((nxt) => this.decrypter.decrypt(undefined, new Cipher({ qb64: nxt }), this.transferable));
248
+ const verfers = signers.map((signer) => signer.verfer.qb64);
249
+ const nsigners = this.creator.create(this.ncodes, this.ncount, this.ncode, this.transferable);
250
+ this.nxts = nsigners.signers.map((signer) => this.encrypter.encrypt(undefined, signer).qb64);
251
+ const digers = nsigners.signers.map((nsigner) => new Diger({ code: this.dcode }, nsigner.verfer.qb64b).qb64);
252
+ return [verfers, digers];
253
+ }
254
+ async sign(ser, indexed = true, indices = undefined, ondices = undefined) {
255
+ const signers = this.prxs.map((prx) => this.decrypter.decrypt(new Cipher({ qb64: prx }).qb64b, undefined, this.transferable));
256
+ if (indexed) {
257
+ const sigers = [];
258
+ let i = 0;
259
+ for (const [j, signer] of signers.entries()) {
260
+ if (indices != undefined) {
261
+ i = indices[j];
262
+ if (typeof i != 'number' || i < 0) {
263
+ throw new Error(`Invalid signing index = ${i}, not whole number.`);
264
+ }
265
+ }
266
+ else {
267
+ i = j;
268
+ }
269
+ let o = 0;
270
+ if (ondices != undefined) {
271
+ o = ondices[j];
272
+ if ((o == undefined ||
273
+ (typeof o == 'number' &&
274
+ typeof o != 'number' &&
275
+ o >= 0))) {
276
+ throw new Error(`Invalid ondex = ${o}, not whole number.`);
277
+ }
278
+ }
279
+ else {
280
+ o = i;
281
+ }
282
+ sigers.push(signer.sign(ser, i, o == undefined ? true : false, o));
283
+ }
284
+ return sigers.map((siger) => siger.qb64);
285
+ }
286
+ else {
287
+ const cigars = [];
288
+ for (const [, signer] of signers.entries()) {
289
+ cigars.push(signer.sign(ser));
290
+ }
291
+ return cigars.map((cigar) => cigar.qb64);
292
+ }
293
+ }
294
+ }
295
+ export class GroupIdentifierManager {
296
+ constructor(manager, mhab, states = undefined, rstates = undefined, keys = [], ndigs = []) {
297
+ var _a, _b;
298
+ this.gkeys = [];
299
+ this.gdigs = [];
300
+ this.algo = Algos.group;
301
+ this.manager = manager;
302
+ if (states != undefined) {
303
+ keys = states.map((state) => state['k'][0]);
304
+ }
305
+ if (rstates != undefined) {
306
+ ndigs = rstates.map((state) => state['n'][0]);
307
+ }
308
+ this.gkeys = (_a = states === null || states === void 0 ? void 0 : states.map((state) => state['k'][0])) !== null && _a !== void 0 ? _a : keys;
309
+ this.gdigs = (_b = rstates === null || rstates === void 0 ? void 0 : rstates.map((state) => state['n'][0])) !== null && _b !== void 0 ? _b : ndigs;
310
+ this.mhab = mhab;
311
+ this.signers = [];
312
+ }
313
+ async incept() {
314
+ return [this.gkeys, this.gdigs];
315
+ }
316
+ /**
317
+ * Performs a multisig rotation
318
+ * @param _ncodes
319
+ * @param _transferable
320
+ * @param states
321
+ * @param rstates key state records for the prior establishment event indicating next key digests.
322
+ * You should pass in the current key
323
+ */
324
+ async rotate(_ncodes, _transferable, states, rstates) {
325
+ this.gkeys = states.map((state) => state['k'][0]);
326
+ this.gdigs = rstates.map((state) => state['n'][0]);
327
+ return [this.gkeys, this.gdigs];
328
+ }
329
+ async sign(ser, indexed = true) {
330
+ if (!this.mhab.state) {
331
+ throw new Error(`No state in mhab`);
332
+ }
333
+ const key = this.mhab['state']['k'][0];
334
+ const ndig = this.mhab['state']['n'][0];
335
+ const csi = this.gkeys.indexOf(key); // csi = current signing index (from current rotation event)
336
+ const pni = this.gdigs.indexOf(ndig); // pni = prior next index (from last establishment event)
337
+ const mkeeper = this.manager.get(this.mhab);
338
+ return await mkeeper.sign(ser, indexed, [csi], [pni]);
339
+ }
340
+ params() {
341
+ return {
342
+ mhab: this.mhab,
343
+ keys: this.gkeys,
344
+ ndigs: this.gdigs,
345
+ };
346
+ }
347
+ }
@@ -1,9 +1,7 @@
1
1
  export class EmptyMaterialError {
2
- private readonly _err: Error;
3
- constructor(err: string) {
2
+ constructor(err) {
4
3
  this._err = new Error(err);
5
4
  }
6
-
7
5
  get err() {
8
6
  return this._err;
9
7
  }
@@ -0,0 +1,98 @@
1
+ import { components } from '../../types/keria-api-schema.ts';
2
+ export type KeyState = components['schemas']['KeyStateRecord'];
3
+ export type EstablishmentState = components['schemas']['StateEERecord'];
4
+ /**
5
+ * Marker interface for state configuring an IdentifierManager.
6
+ */
7
+ export interface IdentifierManagerState {
8
+ }
9
+ /**
10
+ * Defining configuration parameters for a specified, deterministic salt of an IdentifierManager.
11
+ */
12
+ export type SaltyKeyState = components['schemas']['SaltyState'];
13
+ /**
14
+ * Defining configuration parameters for a random seed identifier manager.
15
+ */
16
+ export type RandyKeyState = components['schemas']['RandyKeyState'];
17
+ /**
18
+ * Defining properties a multi-signature group identifier manager.
19
+ */
20
+ export type GroupKeyState = components['schemas']['GroupKeyState'];
21
+ /**
22
+ * Defining properties for an external module identifier manager that uses externally managed keys such as in an HSM or a KMS system.
23
+ */
24
+ export type ExternState = components['schemas']['ExternState'];
25
+ /**
26
+ * Defining properties of an identifier habitat, know as a Hab in KERIpy.
27
+ */
28
+ export type HabState = components['schemas']['HabState'];
29
+ export type Icp = components['schemas']['ICP_V_1'] | components['schemas']['ICP_V_2'];
30
+ export type Ixn = components['schemas']['IXN_V_1'] | components['schemas']['IXN_V_2'];
31
+ export type ExnV1 = components['schemas']['EXN_V_1'];
32
+ export type Dip = components['schemas']['DIP_V_1'] | components['schemas']['DIP_V_2'];
33
+ export type Rot = components['schemas']['ROT_V_1'] | components['schemas']['ROT_V_2'];
34
+ export type ExnEmbeds = components['schemas']['ExnEmbeds'];
35
+ export type MultisigRpyEmbeds = components['schemas']['MultisigRpyEmbeds'];
36
+ /**
37
+ * Defining Operation types
38
+ */
39
+ export type OOBIOperation = components['schemas']['OOBIOperation'];
40
+ export type QueryOperation = components['schemas']['QueryOperation'];
41
+ export type EndRoleOperation = components['schemas']['EndRoleOperation'];
42
+ export type WitnessOperation = components['schemas']['WitnessOperation'];
43
+ export type DelegationOperation = components['schemas']['DelegationOperation'];
44
+ export type RegistryOperation = components['schemas']['RegistryOperation'];
45
+ export type LocSchemeOperation = components['schemas']['LocSchemeOperation'];
46
+ export type ChallengeOperation = components['schemas']['ChallengeOperation'];
47
+ export type ExchangeOperation = components['schemas']['ExchangeOperation'];
48
+ export type SubmitOperation = components['schemas']['SubmitOperation'];
49
+ export type DoneOperation = components['schemas']['DoneOperation'];
50
+ export type CredentialOperation = components['schemas']['CredentialOperation'];
51
+ export type GroupOperation = components['schemas']['GroupOperation'];
52
+ export type DelegatorOperation = components['schemas']['DelegatorOperation'];
53
+ export type PendingOOBIOperation = components['schemas']['PendingOOBIOperation'];
54
+ export type PendingQueryOperation = components['schemas']['PendingQueryOperation'];
55
+ export type PendingEndRoleOperation = components['schemas']['PendingEndRoleOperation'];
56
+ export type PendingWitnessOperation = components['schemas']['PendingWitnessOperation'];
57
+ export type PendingDelegationOperation = components['schemas']['PendingDelegationOperation'];
58
+ export type PendingRegistryOperation = components['schemas']['PendingRegistryOperation'];
59
+ export type PendingLocSchemeOperation = components['schemas']['PendingLocSchemeOperation'];
60
+ export type PendingChallengeOperation = components['schemas']['PendingChallengeOperation'];
61
+ export type PendingExchangeOperation = components['schemas']['PendingExchangeOperation'];
62
+ export type PendingSubmitOperation = components['schemas']['PendingSubmitOperation'];
63
+ export type PendingDoneOperation = components['schemas']['PendingDoneOperation'];
64
+ export type PendingCredentialOperation = components['schemas']['PendingCredentialOperation'];
65
+ export type PendingGroupOperation = components['schemas']['PendingGroupOperation'];
66
+ export type PendingDelegatorOperation = components['schemas']['PendingDelegatorOperation'];
67
+ export type PendingOperation = PendingOOBIOperation | PendingQueryOperation | PendingEndRoleOperation | PendingWitnessOperation | PendingDelegationOperation | PendingRegistryOperation | PendingLocSchemeOperation | PendingChallengeOperation | PendingExchangeOperation | PendingSubmitOperation | PendingDoneOperation | PendingCredentialOperation | PendingGroupOperation | PendingDelegatorOperation;
68
+ export type CompletedWitnessOperation = components['schemas']['CompletedWitnessOperation'];
69
+ export type CompletedEndRoleOperation = components['schemas']['CompletedEndRoleOperation'];
70
+ export type CompletedOOBIOperation = components['schemas']['CompletedOOBIOperation'];
71
+ export type CompletedDelegationOperation = components['schemas']['CompletedDelegationOperation'];
72
+ export type CompletedRegistryOperation = components['schemas']['CompletedRegistryOperation'];
73
+ export type CompletedLocSchemeOperation = components['schemas']['CompletedLocSchemeOperation'];
74
+ export type CompletedChallengeOperation = components['schemas']['CompletedChallengeOperation'];
75
+ export type CompletedExchangeOperation = components['schemas']['CompletedExchangeOperation'];
76
+ export type CompletedSubmitOperation = components['schemas']['CompletedSubmitOperation'];
77
+ export type CompletedDoneOperation = components['schemas']['CompletedDoneOperation'];
78
+ export type CompletedCredentialOperation = components['schemas']['CompletedCredentialOperation'];
79
+ export type CompletedGroupOperation = components['schemas']['CompletedGroupOperation'];
80
+ export type CompletedDelegatorOperation = components['schemas']['CompletedDelegatorOperation'];
81
+ export type CompletedQueryOperation = components['schemas']['CompletedQueryOperation'];
82
+ export type CompletedOperation = CompletedOOBIOperation | CompletedEndRoleOperation | CompletedWitnessOperation | CompletedDelegationOperation | CompletedRegistryOperation | CompletedLocSchemeOperation | CompletedChallengeOperation | CompletedExchangeOperation | CompletedSubmitOperation | CompletedDoneOperation | CompletedCredentialOperation | CompletedGroupOperation | CompletedDelegatorOperation | CompletedQueryOperation;
83
+ export type FailedOOBIOperation = components['schemas']['FailedOOBIOperation'];
84
+ export type FailedQueryOperation = components['schemas']['FailedQueryOperation'];
85
+ export type FailedEndRoleOperation = components['schemas']['FailedEndRoleOperation'];
86
+ export type FailedWitnessOperation = components['schemas']['FailedWitnessOperation'];
87
+ export type FailedDelegationOperation = components['schemas']['FailedDelegationOperation'];
88
+ export type FailedRegistryOperation = components['schemas']['FailedRegistryOperation'];
89
+ export type FailedLocSchemeOperation = components['schemas']['FailedLocSchemeOperation'];
90
+ export type FailedChallengeOperation = components['schemas']['FailedChallengeOperation'];
91
+ export type FailedExchangeOperation = components['schemas']['FailedExchangeOperation'];
92
+ export type FailedSubmitOperation = components['schemas']['FailedSubmitOperation'];
93
+ export type FailedDoneOperation = components['schemas']['FailedDoneOperation'];
94
+ export type FailedCredentialOperation = components['schemas']['FailedCredentialOperation'];
95
+ export type FailedGroupOperation = components['schemas']['FailedGroupOperation'];
96
+ export type FailedDelegatorOperation = components['schemas']['FailedDelegatorOperation'];
97
+ export type FailedOperation = FailedOOBIOperation | FailedQueryOperation | FailedEndRoleOperation | FailedWitnessOperation | FailedDelegationOperation | FailedRegistryOperation | FailedLocSchemeOperation | FailedChallengeOperation | FailedExchangeOperation | FailedSubmitOperation | FailedDoneOperation | FailedCredentialOperation | FailedGroupOperation | FailedDelegatorOperation;
98
+ export type GenericOperation = OOBIOperation | QueryOperation | EndRoleOperation | WitnessOperation | DelegationOperation | RegistryOperation | LocSchemeOperation | ChallengeOperation | ExchangeOperation | SubmitOperation | DoneOperation | CredentialOperation | GroupOperation | DelegatorOperation;