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,273 +0,0 @@
1
- import { Codex, Sizage } from './matter';
2
- import { b, b64ToInt, d, intToB64 } from './core';
3
-
4
- export interface CounterArgs {
5
- code?: string;
6
- count?: number;
7
- countB64?: string;
8
- qb64b?: Uint8Array;
9
- qb64?: string;
10
- qb2?: Uint8Array;
11
- strip?: boolean;
12
- }
13
-
14
- export class CounterCodex extends Codex {
15
- public ControllerIdxSigs: string = '-A'; // Qualified Base64 Indexed Signature.
16
- public WitnessIdxSigs: string = '-B'; // Qualified Base64 Indexed Signature.
17
- public NonTransReceiptCouples: string = '-C'; // Composed Base64 Couple, pre+cig.
18
- public TransReceiptQuadruples: string = '-D'; // Composed Base64 Quadruple, pre+snu+dig+sig.
19
- public FirstSeenReplayCouples: string = '-E'; // Composed Base64 Couple, fnu+dts.
20
- public TransIdxSigGroups: string = '-F'; // Composed Base64 Group, pre+snu+dig+ControllerIdxSigs group.
21
- public SealSourceCouples: string = '-G'; // Composed Base64 couple, snu+dig of given delegators or issuers event
22
- public TransLastIdxSigGroups: string = '-H'; // Composed Base64 Group, pre+ControllerIdxSigs group.
23
- public SealSourceTriples: string = '-I'; // Composed Base64 triple, pre+snu+dig of anchoring source event
24
- public SadPathSig: string = '-J'; // Composed Base64 Group path+TransIdxSigGroup of SAID of content
25
- public SadPathSigGroup: string = '-K'; // Composed Base64 Group, root(path)+SaidPathCouples
26
- public PathedMaterialQuadlets: string = '-L'; // Composed Grouped Pathed Material Quadlet (4 char each)
27
- public AttachedMaterialQuadlets: string = '-V'; // Composed Grouped Attached Material Quadlet (4 char each)
28
- public BigAttachedMaterialQuadlets: string = '-0V'; // Composed Grouped Attached Material Quadlet (4 char each)
29
- public KERIProtocolStack: string = '--AAA'; // KERI ACDC Protocol Stack CESR Version
30
- }
31
-
32
- export const CtrDex = new CounterCodex();
33
-
34
- export class Counter {
35
- static Sizes = new Map(
36
- Object.entries({
37
- '-A': new Sizage(2, 2, 4, 0),
38
- '-B': new Sizage(2, 2, 4, 0),
39
- '-C': new Sizage(2, 2, 4, 0),
40
- '-D': new Sizage(2, 2, 4, 0),
41
- '-E': new Sizage(2, 2, 4, 0),
42
- '-F': new Sizage(2, 2, 4, 0),
43
- '-G': new Sizage(2, 2, 4, 0),
44
- '-H': new Sizage(2, 2, 4, 0),
45
- '-I': new Sizage(2, 2, 4, 0),
46
- '-J': new Sizage(2, 2, 4, 0),
47
- '-K': new Sizage(2, 2, 4, 0),
48
- '-L': new Sizage(2, 2, 4, 0),
49
- '-V': new Sizage(2, 2, 4, 0),
50
- '-0V': new Sizage(3, 5, 8, 0),
51
- '--AAA': new Sizage(5, 3, 8, 0),
52
- })
53
- );
54
-
55
- static Hards = new Map<string, number>([
56
- ['-A', 2],
57
- ['-B', 2],
58
- ['-C', 2],
59
- ['-D', 2],
60
- ['-E', 2],
61
- ['-F', 2],
62
- ['-G', 2],
63
- ['-H', 2],
64
- ['-I', 2],
65
- ['-J', 2],
66
- ['-K', 2],
67
- ['-L', 2],
68
- ['-M', 2],
69
- ['-N', 2],
70
- ['-O', 2],
71
- ['-P', 2],
72
- ['-Q', 2],
73
- ['-R', 2],
74
- ['-S', 2],
75
- ['-T', 2],
76
- ['-U', 2],
77
- ['-V', 2],
78
- ['-W', 2],
79
- ['-X', 2],
80
- ['-Y', 2],
81
- ['-Z', 2],
82
- ['-a', 2],
83
- ['-b', 2],
84
- ['-c', 2],
85
- ['-d', 2],
86
- ['-e', 2],
87
- ['-f', 2],
88
- ['-g', 2],
89
- ['-h', 2],
90
- ['-i', 2],
91
- ['-j', 2],
92
- ['-k', 2],
93
- ['-l', 2],
94
- ['-m', 2],
95
- ['-n', 2],
96
- ['-o', 2],
97
- ['-p', 2],
98
- ['-q', 2],
99
- ['-r', 2],
100
- ['-s', 2],
101
- ['-t', 2],
102
- ['-u', 2],
103
- ['-v', 2],
104
- ['-w', 2],
105
- ['-x', 2],
106
- ['-y', 2],
107
- ['-z', 2],
108
- ['-0', 3],
109
- ['--', 5],
110
- ]);
111
-
112
- private _code: string = '';
113
- private _count: number = -1;
114
-
115
- constructor({ code, count, countB64, qb64b, qb64, qb2 }: CounterArgs) {
116
- if (code != undefined) {
117
- if (!Counter.Sizes.has(code)) {
118
- throw new Error(`"Unsupported code=${code}.`);
119
- }
120
-
121
- const sizage = Counter.Sizes.get(code)!;
122
- const cs = sizage.hs + sizage.ss;
123
- if (sizage.fs != cs || cs % 4 != 0) {
124
- throw new Error(
125
- `Whole code size not full size or not multiple of 4. cs=${cs} fs=${sizage.fs}.`
126
- );
127
- }
128
-
129
- if (count == undefined) {
130
- count = countB64 == undefined ? 1 : b64ToInt(countB64);
131
- }
132
-
133
- if (count < 0 || count > 64 ** sizage.ss - 1) {
134
- throw new Error(`Invalid count=${count} for code=${code}.`);
135
- }
136
-
137
- this._code = code;
138
- this._count = count;
139
- } else if (qb64b != undefined) {
140
- const qb64 = d(qb64b);
141
- this._exfil(qb64);
142
- } else if (qb64 != undefined) {
143
- this._exfil(qb64);
144
- } else if (qb2 != undefined) {
145
- } else {
146
- throw new Error(
147
- `Improper initialization need either (code and count) or qb64b or qb64 or qb2.`
148
- );
149
- }
150
- }
151
-
152
- get code(): string {
153
- return this._code;
154
- }
155
-
156
- get count() {
157
- return this._count;
158
- }
159
-
160
- get qb64() {
161
- return this._infil();
162
- }
163
-
164
- get qb64b() {
165
- return b(this.qb64);
166
- }
167
-
168
- countToB64(l?: number): string {
169
- if (l == undefined) {
170
- const sizage = Counter.Sizes.get(this.code)!;
171
- l = sizage.ss;
172
- }
173
- return intToB64(this.count, l);
174
- }
175
-
176
- static semVerToB64(
177
- version: string = '',
178
- major: number = 0,
179
- minor: number = 0,
180
- patch: number = 0
181
- ): string {
182
- let parts = [major, minor, patch];
183
- if (version != '') {
184
- const ssplits = version.split('.');
185
- const splits = ssplits.map((x) => {
186
- if (x == '') return 0;
187
- return parseInt(x);
188
- });
189
-
190
- const off = splits.length;
191
- const x = 3 - off;
192
- for (let i = 0; i < x; i++) {
193
- splits.push(parts[i + off]);
194
- }
195
- parts = splits;
196
- }
197
-
198
- parts.forEach((p) => {
199
- if (p < 0 || p > 63) {
200
- throw new Error(
201
- `Out of bounds semantic version. Part=${p} is < 0 or > 63.`
202
- );
203
- }
204
- });
205
-
206
- return parts
207
- .map((p) => {
208
- return intToB64(p, 1);
209
- })
210
- .join('');
211
- }
212
-
213
- private _infil(): string {
214
- const code = this.code;
215
- const count = this.count;
216
-
217
- const sizage = Counter.Sizes.get(code)!;
218
- const cs = sizage.hs + sizage.ss;
219
- if (sizage.fs != cs || cs % 4 != 0) {
220
- throw new Error(
221
- `Whole code size not full size or not multiple of 4. cs=${cs} fs=${sizage.fs}.`
222
- );
223
- }
224
-
225
- if (count < 0 || count > 64 ** sizage.ss - 1) {
226
- throw new Error(`Invalid count=${count} for code=${code}.`);
227
- }
228
-
229
- const both = `${code}${intToB64(count, sizage.ss)}`;
230
-
231
- if (both.length % 4) {
232
- throw new Error(
233
- `Invalid size = ${both.length} of ${both} not a multiple of 4.`
234
- );
235
- }
236
-
237
- return both;
238
- }
239
-
240
- private _exfil(qb64: string) {
241
- if (qb64.length == 0) {
242
- throw new Error('Empty Material');
243
- }
244
-
245
- const first = qb64.slice(0, 2);
246
- if (!Counter.Hards.has(first)) {
247
- throw new Error(`Unexpected code ${first}`);
248
- }
249
-
250
- const hs = Counter.Hards.get(first)!;
251
- if (qb64.length < hs) {
252
- throw new Error(`Need ${hs - qb64.length} more characters.`);
253
- }
254
-
255
- const hard = qb64.slice(0, hs);
256
- if (!Counter.Sizes.has(hard)) {
257
- throw new Error(`Unsupported code ${hard}`);
258
- }
259
-
260
- const sizage = Counter.Sizes.get(hard)!;
261
- const cs = sizage!.hs + sizage!.ss;
262
-
263
- if (qb64.length < cs) {
264
- throw new Error(`Need ${cs - qb64.length} more chars.`);
265
- }
266
-
267
- const scount = qb64.slice(sizage.hs, sizage.hs + sizage.ss);
268
- const count = b64ToInt(scount);
269
-
270
- this._code = hard;
271
- this._count = count;
272
- }
273
- }