signify-ts 0.1.1 → 0.2.1
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.
- package/README.md +96 -47
- package/dist/buffer-polyfill.d.ts +1 -0
- package/dist/exports.d.ts +40 -0
- package/dist/index.d.ts +4 -3
- package/dist/keri/app/aiding.d.ts +138 -0
- package/dist/keri/app/clienting.d.ts +182 -0
- package/dist/keri/app/contacting.d.ts +93 -0
- package/dist/keri/app/controller.d.ts +49 -0
- package/dist/keri/app/coring.d.ts +121 -0
- package/dist/keri/app/credentialing.d.ts +245 -0
- package/dist/keri/app/escrowing.d.ts +19 -0
- package/dist/keri/app/exchanging.d.ts +60 -0
- package/dist/keri/app/grouping.d.ts +44 -0
- package/dist/keri/app/habery.d.ts +48 -47
- package/dist/keri/app/notifying.d.ts +34 -0
- package/dist/keri/core/authing.d.ts +10 -9
- package/dist/keri/core/bexter.d.ts +7 -0
- package/dist/keri/core/cigar.d.ts +8 -8
- package/dist/keri/core/cipher.d.ts +5 -5
- package/dist/keri/core/core.d.ts +59 -53
- package/dist/keri/core/counter.d.ts +43 -43
- package/dist/keri/core/decrypter.d.ts +10 -10
- package/dist/keri/core/diger.d.ts +21 -21
- package/dist/keri/core/encrypter.d.ts +9 -9
- package/dist/keri/core/eventing.d.ts +54 -21
- package/dist/keri/core/httping.d.ts +44 -34
- package/dist/keri/core/indexer.d.ts +98 -88
- package/dist/keri/core/keeping.d.ts +103 -1
- package/dist/keri/core/kering.d.ts +5 -5
- package/dist/keri/core/manager.d.ts +174 -172
- package/dist/keri/core/matter.d.ts +116 -69
- package/dist/keri/core/number.d.ts +7 -6
- package/dist/keri/core/pather.d.ts +7 -0
- package/dist/keri/core/prefixer.d.ts +15 -15
- package/dist/keri/core/saider.d.ts +23 -23
- package/dist/keri/core/salter.d.ts +23 -23
- package/dist/keri/core/seqner.d.ts +15 -0
- package/dist/keri/core/serder.d.ts +31 -23
- package/dist/keri/core/siger.d.ts +18 -18
- package/dist/keri/core/signer.d.ts +34 -34
- package/dist/keri/core/tholder.d.ts +29 -14
- package/dist/keri/core/utils.d.ts +20 -15
- package/dist/keri/core/vdring.d.ts +16 -0
- package/dist/keri/core/verfer.d.ts +13 -12
- package/dist/keri/end/ending.d.ts +13 -13
- package/dist/math.d.ts +1 -0
- package/dist/ready.d.ts +1 -0
- package/dist/signify-ts.cjs +7842 -0
- package/dist/signify-ts.cjs.development.js +6369 -256
- package/dist/signify-ts.cjs.development.js.map +1 -1
- package/dist/signify-ts.cjs.map +7 -0
- package/dist/signify-ts.cjs.production.min.js +1 -1
- package/dist/signify-ts.cjs.production.min.js.map +1 -1
- package/dist/signify-ts.esm.js +6205 -229
- package/dist/signify-ts.esm.js.map +1 -1
- package/dist/signify-ts.mjs +7818 -0
- package/dist/signify-ts.mjs.map +7 -0
- package/package.json +49 -49
- package/src/buffer-polyfill.ts +5 -0
- package/src/exports.ts +44 -0
- package/src/index.ts +4 -5
- package/src/keri/app/aiding.ts +493 -0
- package/src/keri/app/clienting.ts +492 -0
- package/src/keri/app/contacting.ts +188 -0
- package/src/keri/app/controller.ts +372 -0
- package/src/keri/app/coring.ts +225 -0
- package/src/keri/app/credentialing.ts +841 -0
- package/src/keri/app/escrowing.ts +34 -0
- package/src/keri/app/exchanging.ts +220 -0
- package/src/keri/app/grouping.ts +90 -0
- package/src/keri/app/habery.ts +118 -85
- package/src/keri/app/notifying.ts +69 -0
- package/src/keri/core/authing.ts +73 -85
- package/src/keri/core/bexter.ts +138 -0
- package/src/keri/core/cigar.ts +10 -11
- package/src/keri/core/cipher.ts +23 -14
- package/src/keri/core/core.ts +223 -81
- package/src/keri/core/counter.ts +182 -116
- package/src/keri/core/decrypter.ts +48 -34
- package/src/keri/core/diger.ts +23 -22
- package/src/keri/core/encrypter.ts +37 -27
- package/src/keri/core/eventing.ts +468 -106
- package/src/keri/core/httping.ts +151 -105
- package/src/keri/core/indexer.ts +313 -211
- package/src/keri/core/keeping.ts +679 -3
- package/src/keri/core/kering.ts +4 -6
- package/src/keri/core/manager.ts +660 -499
- package/src/keri/core/matter.ts +382 -148
- package/src/keri/core/number.ts +56 -11
- package/src/keri/core/pather.ts +98 -0
- package/src/keri/core/prefixer.ts +122 -101
- package/src/keri/core/saider.ts +104 -76
- package/src/keri/core/salter.ts +71 -40
- package/src/keri/core/seqner.ts +46 -0
- package/src/keri/core/serder.ts +102 -38
- package/src/keri/core/siger.ts +19 -18
- package/src/keri/core/signer.ts +73 -53
- package/src/keri/core/tholder.ts +196 -30
- package/src/keri/core/utils.ts +121 -50
- package/src/keri/core/vdring.ts +94 -0
- package/src/keri/core/verfer.ts +22 -9
- package/src/keri/end/ending.ts +111 -101
- package/src/math.ts +3 -0
- package/src/ready.ts +5 -0
- package/dist/keri/app/accountant.d.ts +0 -10
- package/dist/keri/app/apping.d.ts +0 -1
- package/dist/keri/app/client.d.ts +0 -7
- package/dist/keri/app/signify.d.ts +0 -6
- package/src/keri/app/accountant.ts +0 -35
- package/src/keri/app/apping.ts +0 -12
- package/src/keri/app/client.ts +0 -30
- package/src/keri/app/signify.ts +0 -12
- package/src/keri/app/tsconfig.json +0 -100
- package/src/keri/core/tsconfig.json +0 -100
- package/src/keri/end/tsconfig.json +0 -100
package/src/keri/core/core.ts
CHANGED
|
@@ -1,25 +1,23 @@
|
|
|
1
|
-
import {TextEncoder, TextDecoder} from 'util'
|
|
2
|
-
|
|
3
1
|
export enum Serials {
|
|
4
|
-
JSON =
|
|
2
|
+
JSON = 'JSON',
|
|
5
3
|
}
|
|
6
4
|
|
|
7
5
|
export enum Ident {
|
|
8
|
-
KERI =
|
|
6
|
+
KERI = 'KERI',
|
|
7
|
+
ACDC = 'ACDC',
|
|
9
8
|
}
|
|
10
9
|
|
|
11
10
|
export class Version {
|
|
12
|
-
public major: number
|
|
13
|
-
public minor: number
|
|
11
|
+
public major: number;
|
|
12
|
+
public minor: number;
|
|
14
13
|
|
|
15
14
|
constructor(major: number = 1, minor: number = 0) {
|
|
16
|
-
this.major = major
|
|
17
|
-
this.minor = minor
|
|
15
|
+
this.major = major;
|
|
16
|
+
this.minor = minor;
|
|
18
17
|
}
|
|
19
18
|
}
|
|
20
19
|
|
|
21
|
-
export const Versionage = new Version()
|
|
22
|
-
|
|
20
|
+
export const Versionage = new Version();
|
|
23
21
|
|
|
24
22
|
export const Ilks = {
|
|
25
23
|
icp: 'icp',
|
|
@@ -29,27 +27,97 @@ export const Ilks = {
|
|
|
29
27
|
drt: 'drt',
|
|
30
28
|
rct: 'rct',
|
|
31
29
|
vrc: 'vrc',
|
|
30
|
+
rpy: 'rpy',
|
|
31
|
+
exn: 'exn',
|
|
32
|
+
vcp: 'vcp',
|
|
33
|
+
iss: 'iss',
|
|
34
|
+
rev: 'rev',
|
|
32
35
|
};
|
|
33
36
|
|
|
34
|
-
export const IcpLabels = [
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
37
|
+
export const IcpLabels = [
|
|
38
|
+
'v',
|
|
39
|
+
'i',
|
|
40
|
+
's',
|
|
41
|
+
't',
|
|
42
|
+
'kt',
|
|
43
|
+
'k',
|
|
44
|
+
'n',
|
|
45
|
+
'bt',
|
|
46
|
+
'b',
|
|
47
|
+
'c',
|
|
48
|
+
'a',
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
export const DipLabels = [
|
|
52
|
+
'v',
|
|
53
|
+
'i',
|
|
54
|
+
's',
|
|
55
|
+
't',
|
|
56
|
+
'kt',
|
|
57
|
+
'k',
|
|
58
|
+
'n',
|
|
59
|
+
'bt',
|
|
60
|
+
'b',
|
|
61
|
+
'c',
|
|
62
|
+
'a',
|
|
63
|
+
'di',
|
|
64
|
+
];
|
|
65
|
+
|
|
66
|
+
export const RotLabels = [
|
|
67
|
+
'v',
|
|
68
|
+
'i',
|
|
69
|
+
's',
|
|
70
|
+
't',
|
|
71
|
+
'p',
|
|
72
|
+
'kt',
|
|
73
|
+
'k',
|
|
74
|
+
'n',
|
|
75
|
+
'bt',
|
|
76
|
+
'br',
|
|
77
|
+
'ba',
|
|
78
|
+
'a',
|
|
79
|
+
];
|
|
80
|
+
export const DrtLabels = [
|
|
81
|
+
'v',
|
|
82
|
+
'i',
|
|
83
|
+
's',
|
|
84
|
+
't',
|
|
85
|
+
'p',
|
|
86
|
+
'kt',
|
|
87
|
+
'k',
|
|
88
|
+
'n',
|
|
89
|
+
'bt',
|
|
90
|
+
'br',
|
|
91
|
+
'ba',
|
|
92
|
+
'a',
|
|
93
|
+
];
|
|
94
|
+
export const IxnLabels = ['v', 'i', 's', 't', 'p', 'a'];
|
|
95
|
+
|
|
96
|
+
export const KsnLabels = [
|
|
97
|
+
'v',
|
|
98
|
+
'i',
|
|
99
|
+
's',
|
|
100
|
+
't',
|
|
101
|
+
'p',
|
|
102
|
+
'd',
|
|
103
|
+
'f',
|
|
104
|
+
'dt',
|
|
105
|
+
'et',
|
|
106
|
+
'kt',
|
|
107
|
+
'k',
|
|
108
|
+
'n',
|
|
109
|
+
'bt',
|
|
110
|
+
'b',
|
|
111
|
+
'c',
|
|
112
|
+
'ee',
|
|
113
|
+
'di',
|
|
114
|
+
'r',
|
|
115
|
+
];
|
|
116
|
+
|
|
117
|
+
export const RpyLabels = ['v', 't', 'd', 'dt', 'r', 'a'];
|
|
118
|
+
|
|
119
|
+
const encoder = new TextEncoder();
|
|
120
|
+
const decoder = new TextDecoder();
|
|
53
121
|
|
|
54
122
|
export const VERFULLSIZE = 17;
|
|
55
123
|
export const MINSNIFFSIZE = 12 + VERFULLSIZE;
|
|
@@ -60,7 +128,7 @@ export const MINSIGSIZE = 4;
|
|
|
60
128
|
// const version_pattern1 = `KERI\(\?P<major>\[0\-9a\-f\]\)\(\?P<minor>\[0\-9a\-f\]\)\
|
|
61
129
|
// (\?P<kind>\[A\-Z\]\{4\}\)\(\?P<size>\[0\-9a\-f\]\{6\}\)_`
|
|
62
130
|
|
|
63
|
-
export const VEREX = 'KERI([0-9a-f])([0-9a-f])([A-Z]{4})([0-9a-f]{6})_';
|
|
131
|
+
export const VEREX = '(KERI|ACDC)([0-9a-f])([0-9a-f])([A-Z]{4})([0-9a-f]{6})_';
|
|
64
132
|
|
|
65
133
|
export interface Dict<TValue> {
|
|
66
134
|
[id: string]: TValue;
|
|
@@ -72,12 +140,15 @@ export interface Dict<TValue> {
|
|
|
72
140
|
* @description This function is use to deversify the version
|
|
73
141
|
* Here we will use regex to to validate and extract serialization kind,size and version
|
|
74
142
|
* @param {string} versionString version string
|
|
75
|
-
* @return {Object} contaning kind of serialization like cbor,json,mgpk
|
|
143
|
+
* @return {Object} contaning prototol (KERI or ACDC), kind of serialization like cbor,json,mgpk
|
|
76
144
|
* version = version of object ,size = raw size integer
|
|
77
145
|
*/
|
|
78
|
-
export function deversify(
|
|
146
|
+
export function deversify(
|
|
147
|
+
versionString: string
|
|
148
|
+
): [Ident, Serials, Version, string] {
|
|
79
149
|
let kind;
|
|
80
150
|
let size;
|
|
151
|
+
let proto;
|
|
81
152
|
const version = Versionage;
|
|
82
153
|
|
|
83
154
|
// we need to identify how to match the buffers pattern ,like we do regex matching for strings
|
|
@@ -86,99 +157,170 @@ export function deversify(versionString: string): [Serials, Version, string] {
|
|
|
86
157
|
const match = re.exec(versionString);
|
|
87
158
|
|
|
88
159
|
if (match) {
|
|
89
|
-
[version.major, version.minor, kind, size] = [
|
|
90
|
-
|
|
160
|
+
[proto, version.major, version.minor, kind, size] = [
|
|
161
|
+
match[1],
|
|
91
162
|
+match[2],
|
|
92
|
-
match[3],
|
|
163
|
+
+match[3],
|
|
93
164
|
match[4],
|
|
165
|
+
match[5],
|
|
94
166
|
];
|
|
95
167
|
if (!Object.values(Serials).includes(kind as Serials)) {
|
|
96
168
|
throw new Error(`Invalid serialization kind = ${kind}`);
|
|
97
169
|
}
|
|
170
|
+
if (!Object.values(Ident).includes(proto as Ident)) {
|
|
171
|
+
throw new Error(`Invalid serialization kind = ${kind}`);
|
|
172
|
+
}
|
|
98
173
|
|
|
99
|
-
|
|
100
|
-
kind = Serials[ta]
|
|
174
|
+
const ta = kind as keyof typeof Serials;
|
|
175
|
+
kind = Serials[ta];
|
|
176
|
+
const pa = proto as keyof typeof Ident;
|
|
177
|
+
proto = Ident[pa];
|
|
101
178
|
|
|
102
|
-
return [kind, version, size];
|
|
179
|
+
return [proto, kind, version, size];
|
|
103
180
|
}
|
|
104
181
|
throw new Error(`Invalid version string = ${versionString}`);
|
|
105
182
|
}
|
|
106
183
|
|
|
107
|
-
export function versify(
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
184
|
+
export function versify(
|
|
185
|
+
ident: Ident = Ident.KERI,
|
|
186
|
+
version?: Version,
|
|
187
|
+
kind: Serials = Serials.JSON,
|
|
188
|
+
size: number = 0
|
|
189
|
+
) {
|
|
190
|
+
version = version == undefined ? Versionage : version;
|
|
191
|
+
|
|
192
|
+
return `${ident}${version.major.toString(
|
|
193
|
+
16
|
|
194
|
+
)}${version.minor.toString()}${kind}${size.toString(16).padStart(6, '0')}_`;
|
|
111
195
|
}
|
|
112
196
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
[
|
|
116
|
-
[
|
|
117
|
-
[
|
|
118
|
-
[
|
|
119
|
-
[
|
|
120
|
-
[
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
197
|
+
export const B64ChrByIdx = new Map<number, string>([
|
|
198
|
+
[0, 'A'],
|
|
199
|
+
[1, 'B'],
|
|
200
|
+
[2, 'C'],
|
|
201
|
+
[3, 'D'],
|
|
202
|
+
[4, 'E'],
|
|
203
|
+
[5, 'F'],
|
|
204
|
+
[6, 'G'],
|
|
205
|
+
[7, 'H'],
|
|
206
|
+
[8, 'I'],
|
|
207
|
+
[9, 'J'],
|
|
208
|
+
[10, 'K'],
|
|
209
|
+
[11, 'L'],
|
|
210
|
+
[12, 'M'],
|
|
211
|
+
[13, 'N'],
|
|
212
|
+
[14, 'O'],
|
|
213
|
+
[15, 'P'],
|
|
214
|
+
[16, 'Q'],
|
|
215
|
+
[17, 'R'],
|
|
216
|
+
[18, 'S'],
|
|
217
|
+
[19, 'T'],
|
|
218
|
+
[20, 'U'],
|
|
219
|
+
[21, 'V'],
|
|
220
|
+
[22, 'W'],
|
|
221
|
+
[23, 'X'],
|
|
222
|
+
[24, 'Y'],
|
|
223
|
+
[25, 'Z'],
|
|
224
|
+
[26, 'a'],
|
|
225
|
+
[27, 'b'],
|
|
226
|
+
[28, 'c'],
|
|
227
|
+
[29, 'd'],
|
|
228
|
+
[30, 'e'],
|
|
229
|
+
[31, 'f'],
|
|
230
|
+
[32, 'g'],
|
|
231
|
+
[33, 'h'],
|
|
232
|
+
[34, 'i'],
|
|
233
|
+
[35, 'j'],
|
|
234
|
+
[36, 'k'],
|
|
235
|
+
[37, 'l'],
|
|
236
|
+
[38, 'm'],
|
|
237
|
+
[39, 'n'],
|
|
238
|
+
[40, 'o'],
|
|
239
|
+
[41, 'p'],
|
|
240
|
+
[42, 'q'],
|
|
241
|
+
[43, 'r'],
|
|
242
|
+
[44, 's'],
|
|
243
|
+
[45, 't'],
|
|
244
|
+
[46, 'u'],
|
|
245
|
+
[47, 'v'],
|
|
246
|
+
[48, 'w'],
|
|
247
|
+
[49, 'x'],
|
|
248
|
+
[50, 'y'],
|
|
249
|
+
[51, 'z'],
|
|
250
|
+
[52, '0'],
|
|
251
|
+
[53, '1'],
|
|
252
|
+
[54, '2'],
|
|
253
|
+
[55, '3'],
|
|
254
|
+
[56, '4'],
|
|
255
|
+
[57, '5'],
|
|
256
|
+
[58, '6'],
|
|
257
|
+
[59, '7'],
|
|
258
|
+
[60, '8'],
|
|
259
|
+
[61, '9'],
|
|
260
|
+
[62, '-'],
|
|
261
|
+
[63, '_'],
|
|
262
|
+
]);
|
|
263
|
+
|
|
264
|
+
export const B64IdxByChr = new Map<string, number>(
|
|
265
|
+
Array.from(B64ChrByIdx, (entry) => [entry[1], entry[0]])
|
|
266
|
+
);
|
|
267
|
+
|
|
268
|
+
export function intToB64(i: number, l = 1): string {
|
|
269
|
+
let out = '';
|
|
270
|
+
while (l != 0) {
|
|
271
|
+
out = B64ChrByIdx.get(i % 64) + out;
|
|
272
|
+
i = Math.floor(i / 64);
|
|
130
273
|
if (i == 0) {
|
|
131
|
-
break
|
|
274
|
+
break;
|
|
132
275
|
}
|
|
133
276
|
}
|
|
134
277
|
|
|
135
|
-
|
|
136
|
-
for(let i = 0; i < x; i++) {
|
|
137
|
-
out =
|
|
278
|
+
const x = l - out.length;
|
|
279
|
+
for (let i = 0; i < x; i++) {
|
|
280
|
+
out = 'A' + out;
|
|
138
281
|
}
|
|
139
282
|
|
|
140
|
-
return out
|
|
283
|
+
return out;
|
|
141
284
|
}
|
|
142
285
|
|
|
143
286
|
export function intToB64b(n: number, l: number = 1): Uint8Array {
|
|
144
|
-
|
|
145
|
-
return b(s)
|
|
287
|
+
const s = intToB64(n, l);
|
|
288
|
+
return b(s);
|
|
146
289
|
}
|
|
147
290
|
|
|
148
291
|
export function b64ToInt(s: string): number {
|
|
149
292
|
if (s.length == 0) {
|
|
150
|
-
throw new Error(
|
|
293
|
+
throw new Error('Empty string, conversion undefined.');
|
|
151
294
|
}
|
|
152
295
|
|
|
153
|
-
let i = 0
|
|
154
|
-
|
|
296
|
+
let i = 0;
|
|
297
|
+
const rev = s.split('').reverse();
|
|
155
298
|
rev.forEach((c: string, e: number) => {
|
|
156
|
-
i |= B64IdxByChr.get(c)! << (e * 6)
|
|
157
|
-
})
|
|
299
|
+
i |= B64IdxByChr.get(c)! << (e * 6);
|
|
300
|
+
});
|
|
158
301
|
|
|
159
|
-
return i
|
|
302
|
+
return i;
|
|
160
303
|
}
|
|
161
304
|
|
|
162
305
|
export function b(s?: string): Uint8Array {
|
|
163
|
-
return encoder.encode(s)
|
|
306
|
+
return encoder.encode(s);
|
|
164
307
|
}
|
|
165
308
|
|
|
166
|
-
export function d(u
|
|
167
|
-
return decoder.decode(u)
|
|
309
|
+
export function d(u?: Uint8Array): string {
|
|
310
|
+
return decoder.decode(u);
|
|
168
311
|
}
|
|
169
312
|
|
|
170
313
|
export function concat(one: Uint8Array, two: Uint8Array): Uint8Array {
|
|
171
|
-
|
|
172
|
-
out.set(one)
|
|
173
|
-
out.set(two, one.length)
|
|
174
|
-
return out
|
|
314
|
+
const out = new Uint8Array(one.length + two.length);
|
|
315
|
+
out.set(one);
|
|
316
|
+
out.set(two, one.length);
|
|
317
|
+
return out;
|
|
175
318
|
}
|
|
176
319
|
|
|
177
|
-
|
|
178
320
|
export function readInt(array: Uint8Array) {
|
|
179
321
|
let value = 0;
|
|
180
322
|
for (let i = 0; i < array.length; i++) {
|
|
181
|
-
value =
|
|
323
|
+
value = value * 256 + array[i];
|
|
182
324
|
}
|
|
183
325
|
return value;
|
|
184
326
|
}
|