keri 0.0.0-dev.0ddd65e

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 (49) hide show
  1. package/dist/cli/main.d.ts +2 -0
  2. package/dist/cli/main.js +72 -0
  3. package/dist/data-type.d.ts +9 -0
  4. package/dist/data-type.js +1 -0
  5. package/dist/db/event-store.d.ts +20 -0
  6. package/dist/db/event-store.js +1 -0
  7. package/dist/db/sqlite-db.d.ts +13 -0
  8. package/dist/db/sqlite-db.js +123 -0
  9. package/dist/events/common.d.ts +6 -0
  10. package/dist/events/common.js +1 -0
  11. package/dist/events/incept.d.ts +26 -0
  12. package/dist/events/incept.js +28 -0
  13. package/dist/events/interact.d.ts +17 -0
  14. package/dist/events/interact.js +21 -0
  15. package/dist/events/main.d.ts +4 -0
  16. package/dist/events/main.js +4 -0
  17. package/dist/events/reply.d.ts +15 -0
  18. package/dist/events/reply.js +20 -0
  19. package/dist/keri/habitat.d.ts +20 -0
  20. package/dist/keri/habitat.js +130 -0
  21. package/dist/keri/keri.d.ts +26 -0
  22. package/dist/keri/keri.js +43 -0
  23. package/dist/keystore/encrypt.d.ts +2 -0
  24. package/dist/keystore/encrypt.js +38 -0
  25. package/dist/keystore/keystore-fs.d.ts +13 -0
  26. package/dist/keystore/keystore-fs.js +50 -0
  27. package/dist/keystore/keystore-web.d.ts +12 -0
  28. package/dist/keystore/keystore-web.js +48 -0
  29. package/dist/keystore/keystore.d.ts +15 -0
  30. package/dist/keystore/keystore.js +1 -0
  31. package/dist/main-common.d.ts +9 -0
  32. package/dist/main-common.js +8 -0
  33. package/dist/main-web.d.ts +2 -0
  34. package/dist/main-web.js +2 -0
  35. package/dist/main.d.ts +2 -0
  36. package/dist/main.js +2 -0
  37. package/dist/parser/base64.d.ts +6 -0
  38. package/dist/parser/base64.js +74 -0
  39. package/dist/parser/buffered-reader.d.ts +5 -0
  40. package/dist/parser/buffered-reader.js +47 -0
  41. package/dist/parser/cesr-encoding.d.ts +34 -0
  42. package/dist/parser/cesr-encoding.js +158 -0
  43. package/dist/parser/codes.d.ts +143 -0
  44. package/dist/parser/codes.js +266 -0
  45. package/dist/parser/parser.d.ts +16 -0
  46. package/dist/parser/parser.js +161 -0
  47. package/dist/parser/version.d.ts +11 -0
  48. package/dist/parser/version.js +56 -0
  49. package/package.json +45 -0
@@ -0,0 +1,143 @@
1
+ export interface CodeSize {
2
+ hs: number;
3
+ ss: number;
4
+ xs: number | null;
5
+ fs: number | null;
6
+ ls: number | null;
7
+ }
8
+ export declare const MatterCode: {
9
+ Big: string;
10
+ Blake2b_256: string;
11
+ Blake2b_512: string;
12
+ Blake2s_256: string;
13
+ Blake3_256: string;
14
+ Blake3_512: string;
15
+ Blind: string;
16
+ Bytes_Big_L0: string;
17
+ Bytes_Big_L1: string;
18
+ Bytes_Big_L2: string;
19
+ Bytes_L0: string;
20
+ Bytes_L1: string;
21
+ Bytes_L2: string;
22
+ DateTime: string;
23
+ ECDSA_256k1: string;
24
+ ECDSA_256k1N: string;
25
+ ECDSA_256k1_Seed: string;
26
+ ECDSA_256k1_Sig: string;
27
+ ECDSA_256r1: string;
28
+ ECDSA_256r1N: string;
29
+ ECDSA_256r1_Seed: string;
30
+ ECDSA_256r1_Sig: string;
31
+ Ed25519: string;
32
+ Ed25519N: string;
33
+ Ed25519_Seed: string;
34
+ Ed25519_Sig: string;
35
+ Ed448: string;
36
+ Ed448N: string;
37
+ Ed448_Seed: string;
38
+ Ed448_Sig: string;
39
+ Great: string;
40
+ Label1: string;
41
+ Label2: string;
42
+ Large: string;
43
+ Long: string;
44
+ No: string;
45
+ Null: string;
46
+ SHA2_256: string;
47
+ SHA2_512: string;
48
+ SHA3_256: string;
49
+ SHA3_512: string;
50
+ Salt_128: string;
51
+ Short: string;
52
+ StrB64_Big_L0: string;
53
+ StrB64_Big_L1: string;
54
+ StrB64_Big_L2: string;
55
+ StrB64_L0: string;
56
+ StrB64_L1: string;
57
+ StrB64_L2: string;
58
+ TBD0: string;
59
+ TBD0S: string;
60
+ TBD1: string;
61
+ TBD1S: string;
62
+ TBD2: string;
63
+ TBD2S: string;
64
+ Tag1: string;
65
+ Tag10: string;
66
+ Tag2: string;
67
+ Tag3: string;
68
+ Tag4: string;
69
+ Tag5: string;
70
+ Tag6: string;
71
+ Tag7: string;
72
+ Tag8: string;
73
+ Tag9: string;
74
+ Tall: string;
75
+ Vast: string;
76
+ X25519: string;
77
+ X25519_Cipher_Big_L0: string;
78
+ X25519_Cipher_Big_L1: string;
79
+ X25519_Cipher_Big_L2: string;
80
+ X25519_Cipher_L0: string;
81
+ X25519_Cipher_L1: string;
82
+ X25519_Cipher_L2: string;
83
+ X25519_Cipher_QB2_Big_L0: string;
84
+ X25519_Cipher_QB2_Big_L1: string;
85
+ X25519_Cipher_QB2_Big_L2: string;
86
+ X25519_Cipher_QB2_L0: string;
87
+ X25519_Cipher_QB2_L1: string;
88
+ X25519_Cipher_QB2_L2: string;
89
+ X25519_Cipher_QB64_Big_L0: string;
90
+ X25519_Cipher_QB64_Big_L1: string;
91
+ X25519_Cipher_QB64_Big_L2: string;
92
+ X25519_Cipher_QB64_L0: string;
93
+ X25519_Cipher_QB64_L1: string;
94
+ X25519_Cipher_QB64_L2: string;
95
+ X25519_Cipher_Salt: string;
96
+ X25519_Cipher_Seed: string;
97
+ X25519_Private: string;
98
+ X448: string;
99
+ Yes: string;
100
+ };
101
+ export declare const MatterCodeTable: Record<string, CodeSize>;
102
+ export declare const IndexerCode: {
103
+ ECDSA_256k1_Big_Crt_Sig: string;
104
+ ECDSA_256k1_Big_Sig: string;
105
+ ECDSA_256k1_Crt_Sig: string;
106
+ ECDSA_256k1_Sig: string;
107
+ ECDSA_256r1_Big_Crt_Sig: string;
108
+ ECDSA_256r1_Big_Sig: string;
109
+ ECDSA_256r1_Crt_Sig: string;
110
+ ECDSA_256r1_Sig: string;
111
+ Ed25519_Big_Crt_Sig: string;
112
+ Ed25519_Big_Sig: string;
113
+ Ed25519_Crt_Sig: string;
114
+ Ed25519_Sig: string;
115
+ Ed448_Big_Crt_Sig: string;
116
+ Ed448_Big_Sig: string;
117
+ Ed448_Crt_Sig: string;
118
+ Ed448_Sig: string;
119
+ TBD0: string;
120
+ TBD1: string;
121
+ TBD4: string;
122
+ };
123
+ export declare const IndexerCodeTable: Record<string, CodeSize>;
124
+ export declare const CounterCode: {
125
+ AttachmentGroup: string;
126
+ BigAttachmentGroup: string;
127
+ BigPathedMaterialGroup: string;
128
+ ControllerIdxSigs: string;
129
+ ESSRPayloadGroup: string;
130
+ FirstSeenReplayCouples: string;
131
+ KERIACDCGenusVersion: string;
132
+ NonTransReceiptCouples: string;
133
+ PathedMaterialGroup: string;
134
+ RootSadPathSigGroups: string;
135
+ SadPathSigGroups: string;
136
+ SealSourceCouples: string;
137
+ SealSourceTriples: string;
138
+ TransIdxSigGroups: string;
139
+ TransLastIdxSigGroups: string;
140
+ TransReceiptQuadruples: string;
141
+ WitnessIdxSigs: string;
142
+ };
143
+ export declare const CounterCodeTable: Record<string, CodeSize>;
@@ -0,0 +1,266 @@
1
+ export const MatterCode = {
2
+ Big: "N",
3
+ Blake2b_256: "F",
4
+ Blake2b_512: "0E",
5
+ Blake2s_256: "G",
6
+ Blake3_256: "E",
7
+ Blake3_512: "0D",
8
+ Blind: "Z",
9
+ Bytes_Big_L0: "7AAB",
10
+ Bytes_Big_L1: "8AAB",
11
+ Bytes_Big_L2: "9AAB",
12
+ Bytes_L0: "4B",
13
+ Bytes_L1: "5B",
14
+ Bytes_L2: "6B",
15
+ DateTime: "1AAG",
16
+ ECDSA_256k1: "1AAB",
17
+ ECDSA_256k1N: "1AAA",
18
+ ECDSA_256k1_Seed: "J",
19
+ ECDSA_256k1_Sig: "0C",
20
+ ECDSA_256r1: "1AAJ",
21
+ ECDSA_256r1N: "1AAI",
22
+ ECDSA_256r1_Seed: "Q",
23
+ ECDSA_256r1_Sig: "0I",
24
+ Ed25519: "D",
25
+ Ed25519N: "B",
26
+ Ed25519_Seed: "A",
27
+ Ed25519_Sig: "0B",
28
+ Ed448: "1AAD",
29
+ Ed448N: "1AAC",
30
+ Ed448_Seed: "K",
31
+ Ed448_Sig: "1AAE",
32
+ Great: "T",
33
+ Label1: "V",
34
+ Label2: "W",
35
+ Large: "S",
36
+ Long: "0H",
37
+ No: "1AAL",
38
+ Null: "1AAK",
39
+ SHA2_256: "I",
40
+ SHA2_512: "0G",
41
+ SHA3_256: "H",
42
+ SHA3_512: "0F",
43
+ Salt_128: "0A",
44
+ Short: "M",
45
+ StrB64_Big_L0: "7AAA",
46
+ StrB64_Big_L1: "8AAA",
47
+ StrB64_Big_L2: "9AAA",
48
+ StrB64_L0: "4A",
49
+ StrB64_L1: "5A",
50
+ StrB64_L2: "6A",
51
+ TBD0: "1___",
52
+ TBD0S: "1__-",
53
+ TBD1: "2___",
54
+ TBD1S: "2__-",
55
+ TBD2: "3___",
56
+ TBD2S: "3__-",
57
+ Tag1: "0J",
58
+ Tag10: "0O",
59
+ Tag2: "0K",
60
+ Tag3: "X",
61
+ Tag4: "1AAF",
62
+ Tag5: "0L",
63
+ Tag6: "0M",
64
+ Tag7: "Y",
65
+ Tag8: "1AAN",
66
+ Tag9: "0N",
67
+ Tall: "R",
68
+ Vast: "U",
69
+ X25519: "C",
70
+ X25519_Cipher_Big_L0: "7AAC",
71
+ X25519_Cipher_Big_L1: "8AAC",
72
+ X25519_Cipher_Big_L2: "9AAC",
73
+ X25519_Cipher_L0: "4C",
74
+ X25519_Cipher_L1: "5C",
75
+ X25519_Cipher_L2: "6C",
76
+ X25519_Cipher_QB2_Big_L0: "7AAE",
77
+ X25519_Cipher_QB2_Big_L1: "8AAE",
78
+ X25519_Cipher_QB2_Big_L2: "9AAE",
79
+ X25519_Cipher_QB2_L0: "4E",
80
+ X25519_Cipher_QB2_L1: "5E",
81
+ X25519_Cipher_QB2_L2: "6E",
82
+ X25519_Cipher_QB64_Big_L0: "7AAD",
83
+ X25519_Cipher_QB64_Big_L1: "8AAD",
84
+ X25519_Cipher_QB64_Big_L2: "9AAD",
85
+ X25519_Cipher_QB64_L0: "4D",
86
+ X25519_Cipher_QB64_L1: "5D",
87
+ X25519_Cipher_QB64_L2: "6D",
88
+ X25519_Cipher_Salt: "1AAH",
89
+ X25519_Cipher_Seed: "P",
90
+ X25519_Private: "O",
91
+ X448: "L",
92
+ Yes: "1AAM",
93
+ };
94
+ export const MatterCodeTable = {
95
+ ["N"]: { hs: 1, ss: 0, xs: 0, fs: 12, ls: 0 },
96
+ ["F"]: { hs: 1, ss: 0, xs: 0, fs: 44, ls: 0 },
97
+ ["0E"]: { hs: 2, ss: 0, xs: 0, fs: 88, ls: 0 },
98
+ ["G"]: { hs: 1, ss: 0, xs: 0, fs: 44, ls: 0 },
99
+ ["E"]: { hs: 1, ss: 0, xs: 0, fs: 44, ls: 0 },
100
+ ["0D"]: { hs: 2, ss: 0, xs: 0, fs: 88, ls: 0 },
101
+ ["Z"]: { hs: 1, ss: 0, xs: 0, fs: 44, ls: 0 },
102
+ ["7AAB"]: { hs: 4, ss: 4, xs: 0, fs: null, ls: 0 },
103
+ ["8AAB"]: { hs: 4, ss: 4, xs: 0, fs: null, ls: 1 },
104
+ ["9AAB"]: { hs: 4, ss: 4, xs: 0, fs: null, ls: 2 },
105
+ ["4B"]: { hs: 2, ss: 2, xs: 0, fs: null, ls: 0 },
106
+ ["5B"]: { hs: 2, ss: 2, xs: 0, fs: null, ls: 1 },
107
+ ["6B"]: { hs: 2, ss: 2, xs: 0, fs: null, ls: 2 },
108
+ ["1AAG"]: { hs: 4, ss: 0, xs: 0, fs: 36, ls: 0 },
109
+ ["1AAB"]: { hs: 4, ss: 0, xs: 0, fs: 48, ls: 0 },
110
+ ["1AAA"]: { hs: 4, ss: 0, xs: 0, fs: 48, ls: 0 },
111
+ ["J"]: { hs: 1, ss: 0, xs: 0, fs: 44, ls: 0 },
112
+ ["0C"]: { hs: 2, ss: 0, xs: 0, fs: 88, ls: 0 },
113
+ ["1AAJ"]: { hs: 4, ss: 0, xs: 0, fs: 48, ls: 0 },
114
+ ["1AAI"]: { hs: 4, ss: 0, xs: 0, fs: 48, ls: 0 },
115
+ ["Q"]: { hs: 1, ss: 0, xs: 0, fs: 44, ls: 0 },
116
+ ["0I"]: { hs: 2, ss: 0, xs: 0, fs: 88, ls: 0 },
117
+ ["D"]: { hs: 1, ss: 0, xs: 0, fs: 44, ls: 0 },
118
+ ["B"]: { hs: 1, ss: 0, xs: 0, fs: 44, ls: 0 },
119
+ ["A"]: { hs: 1, ss: 0, xs: 0, fs: 44, ls: 0 },
120
+ ["0B"]: { hs: 2, ss: 0, xs: 0, fs: 88, ls: 0 },
121
+ ["1AAD"]: { hs: 4, ss: 0, xs: 0, fs: 80, ls: 0 },
122
+ ["1AAC"]: { hs: 4, ss: 0, xs: 0, fs: 80, ls: 0 },
123
+ ["K"]: { hs: 1, ss: 0, xs: 0, fs: 76, ls: 0 },
124
+ ["1AAE"]: { hs: 4, ss: 0, xs: 0, fs: 56, ls: 0 },
125
+ ["T"]: { hs: 1, ss: 0, xs: 0, fs: 20, ls: 0 },
126
+ ["V"]: { hs: 1, ss: 0, xs: 0, fs: 4, ls: 1 },
127
+ ["W"]: { hs: 1, ss: 0, xs: 0, fs: 4, ls: 0 },
128
+ ["S"]: { hs: 1, ss: 0, xs: 0, fs: 16, ls: 0 },
129
+ ["0H"]: { hs: 2, ss: 0, xs: 0, fs: 8, ls: 0 },
130
+ ["1AAL"]: { hs: 4, ss: 0, xs: 0, fs: 4, ls: 0 },
131
+ ["1AAK"]: { hs: 4, ss: 0, xs: 0, fs: 4, ls: 0 },
132
+ ["I"]: { hs: 1, ss: 0, xs: 0, fs: 44, ls: 0 },
133
+ ["0G"]: { hs: 2, ss: 0, xs: 0, fs: 88, ls: 0 },
134
+ ["H"]: { hs: 1, ss: 0, xs: 0, fs: 44, ls: 0 },
135
+ ["0F"]: { hs: 2, ss: 0, xs: 0, fs: 88, ls: 0 },
136
+ ["0A"]: { hs: 2, ss: 0, xs: 0, fs: 24, ls: 0 },
137
+ ["M"]: { hs: 1, ss: 0, xs: 0, fs: 4, ls: 0 },
138
+ ["7AAA"]: { hs: 4, ss: 4, xs: 0, fs: null, ls: 0 },
139
+ ["8AAA"]: { hs: 4, ss: 4, xs: 0, fs: null, ls: 1 },
140
+ ["9AAA"]: { hs: 4, ss: 4, xs: 0, fs: null, ls: 2 },
141
+ ["4A"]: { hs: 2, ss: 2, xs: 0, fs: null, ls: 0 },
142
+ ["5A"]: { hs: 2, ss: 2, xs: 0, fs: null, ls: 1 },
143
+ ["6A"]: { hs: 2, ss: 2, xs: 0, fs: null, ls: 2 },
144
+ ["1___"]: { hs: 4, ss: 0, xs: 0, fs: 8, ls: 0 },
145
+ ["1__-"]: { hs: 4, ss: 2, xs: 0, fs: 12, ls: 0 },
146
+ ["2___"]: { hs: 4, ss: 0, xs: 0, fs: 8, ls: 1 },
147
+ ["2__-"]: { hs: 4, ss: 2, xs: 1, fs: 12, ls: 1 },
148
+ ["3___"]: { hs: 4, ss: 0, xs: 0, fs: 8, ls: 2 },
149
+ ["3__-"]: { hs: 4, ss: 2, xs: 0, fs: 12, ls: 2 },
150
+ ["0J"]: { hs: 2, ss: 2, xs: 1, fs: 4, ls: 0 },
151
+ ["0O"]: { hs: 2, ss: 10, xs: 0, fs: 12, ls: 0 },
152
+ ["0K"]: { hs: 2, ss: 2, xs: 0, fs: 4, ls: 0 },
153
+ ["X"]: { hs: 1, ss: 3, xs: 0, fs: 4, ls: 0 },
154
+ ["1AAF"]: { hs: 4, ss: 4, xs: 0, fs: 8, ls: 0 },
155
+ ["0L"]: { hs: 2, ss: 6, xs: 1, fs: 8, ls: 0 },
156
+ ["0M"]: { hs: 2, ss: 6, xs: 0, fs: 8, ls: 0 },
157
+ ["Y"]: { hs: 1, ss: 7, xs: 0, fs: 8, ls: 0 },
158
+ ["1AAN"]: { hs: 4, ss: 8, xs: 0, fs: 12, ls: 0 },
159
+ ["0N"]: { hs: 2, ss: 10, xs: 1, fs: 12, ls: 0 },
160
+ ["R"]: { hs: 1, ss: 0, xs: 0, fs: 8, ls: 0 },
161
+ ["U"]: { hs: 1, ss: 0, xs: 0, fs: 24, ls: 0 },
162
+ ["C"]: { hs: 1, ss: 0, xs: 0, fs: 44, ls: 0 },
163
+ ["7AAC"]: { hs: 4, ss: 4, xs: 0, fs: null, ls: 0 },
164
+ ["8AAC"]: { hs: 4, ss: 4, xs: 0, fs: null, ls: 1 },
165
+ ["9AAC"]: { hs: 4, ss: 4, xs: 0, fs: null, ls: 2 },
166
+ ["4C"]: { hs: 2, ss: 2, xs: 0, fs: null, ls: 0 },
167
+ ["5C"]: { hs: 2, ss: 2, xs: 0, fs: null, ls: 1 },
168
+ ["6C"]: { hs: 2, ss: 2, xs: 0, fs: null, ls: 2 },
169
+ ["7AAE"]: { hs: 4, ss: 4, xs: 0, fs: null, ls: 0 },
170
+ ["8AAE"]: { hs: 4, ss: 4, xs: 0, fs: null, ls: 1 },
171
+ ["9AAE"]: { hs: 4, ss: 4, xs: 0, fs: null, ls: 2 },
172
+ ["4E"]: { hs: 2, ss: 2, xs: 0, fs: null, ls: 0 },
173
+ ["5E"]: { hs: 2, ss: 2, xs: 0, fs: null, ls: 1 },
174
+ ["6E"]: { hs: 2, ss: 2, xs: 0, fs: null, ls: 2 },
175
+ ["7AAD"]: { hs: 4, ss: 4, xs: 0, fs: null, ls: 0 },
176
+ ["8AAD"]: { hs: 4, ss: 4, xs: 0, fs: null, ls: 1 },
177
+ ["9AAD"]: { hs: 4, ss: 4, xs: 0, fs: null, ls: 2 },
178
+ ["4D"]: { hs: 2, ss: 2, xs: 0, fs: null, ls: 0 },
179
+ ["5D"]: { hs: 2, ss: 2, xs: 0, fs: null, ls: 1 },
180
+ ["6D"]: { hs: 2, ss: 2, xs: 0, fs: null, ls: 2 },
181
+ ["1AAH"]: { hs: 4, ss: 0, xs: 0, fs: 100, ls: 0 },
182
+ ["P"]: { hs: 1, ss: 0, xs: 0, fs: 124, ls: 0 },
183
+ ["O"]: { hs: 1, ss: 0, xs: 0, fs: 44, ls: 0 },
184
+ ["L"]: { hs: 1, ss: 0, xs: 0, fs: 76, ls: 0 },
185
+ ["1AAM"]: { hs: 4, ss: 0, xs: 0, fs: 4, ls: 0 },
186
+ };
187
+ export const IndexerCode = {
188
+ ECDSA_256k1_Big_Crt_Sig: "2D",
189
+ ECDSA_256k1_Big_Sig: "2C",
190
+ ECDSA_256k1_Crt_Sig: "D",
191
+ ECDSA_256k1_Sig: "C",
192
+ ECDSA_256r1_Big_Crt_Sig: "2F",
193
+ ECDSA_256r1_Big_Sig: "2E",
194
+ ECDSA_256r1_Crt_Sig: "F",
195
+ ECDSA_256r1_Sig: "E",
196
+ Ed25519_Big_Crt_Sig: "2B",
197
+ Ed25519_Big_Sig: "2A",
198
+ Ed25519_Crt_Sig: "B",
199
+ Ed25519_Sig: "A",
200
+ Ed448_Big_Crt_Sig: "3B",
201
+ Ed448_Big_Sig: "3A",
202
+ Ed448_Crt_Sig: "0B",
203
+ Ed448_Sig: "0A",
204
+ TBD0: "0z",
205
+ TBD1: "1z",
206
+ TBD4: "4z",
207
+ };
208
+ export const IndexerCodeTable = {
209
+ ["2D"]: { hs: 2, ss: 4, xs: null, fs: 92, ls: 0 },
210
+ ["2C"]: { hs: 2, ss: 4, xs: null, fs: 92, ls: 0 },
211
+ ["D"]: { hs: 1, ss: 1, xs: null, fs: 88, ls: 0 },
212
+ ["C"]: { hs: 1, ss: 1, xs: null, fs: 88, ls: 0 },
213
+ ["2F"]: { hs: 2, ss: 4, xs: null, fs: 92, ls: 0 },
214
+ ["2E"]: { hs: 2, ss: 4, xs: null, fs: 92, ls: 0 },
215
+ ["F"]: { hs: 1, ss: 1, xs: null, fs: 88, ls: 0 },
216
+ ["E"]: { hs: 1, ss: 1, xs: null, fs: 88, ls: 0 },
217
+ ["2B"]: { hs: 2, ss: 4, xs: null, fs: 92, ls: 0 },
218
+ ["2A"]: { hs: 2, ss: 4, xs: null, fs: 92, ls: 0 },
219
+ ["B"]: { hs: 1, ss: 1, xs: null, fs: 88, ls: 0 },
220
+ ["A"]: { hs: 1, ss: 1, xs: null, fs: 88, ls: 0 },
221
+ ["3B"]: { hs: 2, ss: 6, xs: null, fs: 160, ls: 0 },
222
+ ["3A"]: { hs: 2, ss: 6, xs: null, fs: 160, ls: 0 },
223
+ ["0B"]: { hs: 2, ss: 2, xs: null, fs: 156, ls: 0 },
224
+ ["0A"]: { hs: 2, ss: 2, xs: null, fs: 156, ls: 0 },
225
+ ["0z"]: { hs: 2, ss: 2, xs: null, fs: null, ls: 0 },
226
+ ["1z"]: { hs: 2, ss: 2, xs: null, fs: 76, ls: 1 },
227
+ ["4z"]: { hs: 2, ss: 6, xs: null, fs: 80, ls: 1 },
228
+ };
229
+ export const CounterCode = {
230
+ AttachmentGroup: "-V",
231
+ BigAttachmentGroup: "-0V",
232
+ BigPathedMaterialGroup: "-0L",
233
+ ControllerIdxSigs: "-A",
234
+ ESSRPayloadGroup: "-Z",
235
+ FirstSeenReplayCouples: "-E",
236
+ KERIACDCGenusVersion: "--AAA",
237
+ NonTransReceiptCouples: "-C",
238
+ PathedMaterialGroup: "-L",
239
+ RootSadPathSigGroups: "-K",
240
+ SadPathSigGroups: "-J",
241
+ SealSourceCouples: "-G",
242
+ SealSourceTriples: "-I",
243
+ TransIdxSigGroups: "-F",
244
+ TransLastIdxSigGroups: "-H",
245
+ TransReceiptQuadruples: "-D",
246
+ WitnessIdxSigs: "-B",
247
+ };
248
+ export const CounterCodeTable = {
249
+ ["-V"]: { hs: 2, ss: 2, xs: null, fs: 4, ls: null },
250
+ ["-0V"]: { hs: 3, ss: 5, xs: null, fs: 8, ls: null },
251
+ ["-0L"]: { hs: 3, ss: 5, xs: null, fs: 8, ls: null },
252
+ ["-A"]: { hs: 2, ss: 2, xs: null, fs: 4, ls: null },
253
+ ["-Z"]: { hs: 2, ss: 2, xs: null, fs: 4, ls: null },
254
+ ["-E"]: { hs: 2, ss: 2, xs: null, fs: 4, ls: null },
255
+ ["--AAA"]: { hs: 5, ss: 3, xs: null, fs: 8, ls: null },
256
+ ["-C"]: { hs: 2, ss: 2, xs: null, fs: 4, ls: null },
257
+ ["-L"]: { hs: 2, ss: 2, xs: null, fs: 4, ls: null },
258
+ ["-K"]: { hs: 2, ss: 2, xs: null, fs: 4, ls: null },
259
+ ["-J"]: { hs: 2, ss: 2, xs: null, fs: 4, ls: null },
260
+ ["-G"]: { hs: 2, ss: 2, xs: null, fs: 4, ls: null },
261
+ ["-I"]: { hs: 2, ss: 2, xs: null, fs: 4, ls: null },
262
+ ["-F"]: { hs: 2, ss: 2, xs: null, fs: 4, ls: null },
263
+ ["-H"]: { hs: 2, ss: 2, xs: null, fs: 4, ls: null },
264
+ ["-D"]: { hs: 2, ss: 2, xs: null, fs: 4, ls: null },
265
+ ["-B"]: { hs: 2, ss: 2, xs: null, fs: 4, ls: null },
266
+ };
@@ -0,0 +1,16 @@
1
+ import type { KeyEvent } from "../events/main.ts";
2
+ export declare class Parser {
3
+ #private;
4
+ constructor(stream: AsyncIterableIterator<Uint8Array>);
5
+ readOne(): Promise<string | null>;
6
+ }
7
+ export declare function decode(input: AsyncIterable<Uint8Array>): AsyncIterableIterator<string>;
8
+ export interface Message {
9
+ payload: KeyEvent;
10
+ attachments: string[];
11
+ }
12
+ export declare function parse(input: AsyncIterable<Uint8Array>): AsyncIterableIterator<Message>;
13
+ export interface Message {
14
+ payload: KeyEvent;
15
+ attachments: string[];
16
+ }
@@ -0,0 +1,161 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _Parser_instances, _Parser_decoder, _Parser_countContext, _Parser_stream, _Parser_buffer, _Parser_readBytes, _Parser_readCharacters;
13
+ import { parseVersion } from "./version.js";
14
+ import { decodeBase64Int } from "./base64.js";
15
+ import { CounterCode, CounterCodeTable, IndexerCodeTable, MatterCodeTable } from "./codes.js";
16
+ function concat(a, b) {
17
+ if (a.length === 0) {
18
+ return b;
19
+ }
20
+ if (b.length === 0) {
21
+ return a;
22
+ }
23
+ const merged = new Uint8Array(a.length + b.length);
24
+ merged.set(a);
25
+ merged.set(b, a.length);
26
+ return merged;
27
+ }
28
+ export class Parser {
29
+ constructor(stream) {
30
+ _Parser_instances.add(this);
31
+ _Parser_decoder.set(this, new TextDecoder());
32
+ _Parser_countContext.set(this, void 0);
33
+ _Parser_stream.set(this, void 0);
34
+ _Parser_buffer.set(this, void 0);
35
+ __classPrivateFieldSet(this, _Parser_stream, stream, "f");
36
+ }
37
+ async readOne() {
38
+ let code = "";
39
+ while (code.length < 4) {
40
+ const next = await __classPrivateFieldGet(this, _Parser_instances, "m", _Parser_readBytes).call(this, 1);
41
+ if (next === null) {
42
+ return null;
43
+ }
44
+ code += __classPrivateFieldGet(this, _Parser_decoder, "f").decode(next);
45
+ if (code === "{") {
46
+ const prefix = code + (await __classPrivateFieldGet(this, _Parser_instances, "m", _Parser_readCharacters).call(this, 22));
47
+ const version = parseVersion(prefix);
48
+ return prefix + (await __classPrivateFieldGet(this, _Parser_instances, "m", _Parser_readCharacters).call(this, version.size - prefix.length));
49
+ }
50
+ if (code.startsWith("-") && code in CounterCodeTable) {
51
+ const size = CounterCodeTable[code];
52
+ if (size && size.fs !== null) {
53
+ const qb64 = await __classPrivateFieldGet(this, _Parser_instances, "m", _Parser_readCharacters).call(this, size.fs - size.hs);
54
+ const count = decodeBase64Int(qb64);
55
+ if (code === CounterCode.AttachmentGroup || code === CounterCode.BigAttachmentGroup) {
56
+ // Attachment group, currently no need to keep track of the count
57
+ }
58
+ else {
59
+ // Stores the counter and expected count so we know what to expect next
60
+ __classPrivateFieldSet(this, _Parser_countContext, {
61
+ code,
62
+ count,
63
+ }, "f");
64
+ }
65
+ return code + qb64;
66
+ }
67
+ else if (!size || size.fs === null) {
68
+ throw new Error(`Variable length currently not supported code=${code}`);
69
+ }
70
+ }
71
+ else if (__classPrivateFieldGet(this, _Parser_countContext, "f") &&
72
+ __classPrivateFieldGet(this, _Parser_countContext, "f").count > 0 &&
73
+ [
74
+ CounterCode.ControllerIdxSigs,
75
+ CounterCode.WitnessIdxSigs,
76
+ CounterCode.TransIdxSigGroups,
77
+ CounterCode.TransLastIdxSigGroups,
78
+ ].includes(__classPrivateFieldGet(this, _Parser_countContext, "f").code)) {
79
+ if (code in IndexerCodeTable) {
80
+ const size = IndexerCodeTable[code];
81
+ if (size && size.fs) {
82
+ __classPrivateFieldGet(this, _Parser_countContext, "f").count--;
83
+ const qb64 = await __classPrivateFieldGet(this, _Parser_instances, "m", _Parser_readCharacters).call(this, size.fs - size.hs);
84
+ return code + qb64;
85
+ }
86
+ else if (size) {
87
+ throw new Error(`Variable length currently not supported code=${code}`);
88
+ }
89
+ }
90
+ }
91
+ else if (code in MatterCodeTable) {
92
+ const size = MatterCodeTable[code];
93
+ if (size && size.fs) {
94
+ const qb64 = await __classPrivateFieldGet(this, _Parser_instances, "m", _Parser_readCharacters).call(this, size.fs - size.hs);
95
+ return code + qb64;
96
+ }
97
+ else if (size) {
98
+ throw new Error(`Variable length currently not supported code=${code}`);
99
+ }
100
+ }
101
+ }
102
+ throw new Error(`Unknown code in ${code}`);
103
+ }
104
+ }
105
+ _Parser_decoder = new WeakMap(), _Parser_countContext = new WeakMap(), _Parser_stream = new WeakMap(), _Parser_buffer = new WeakMap(), _Parser_instances = new WeakSet(), _Parser_readBytes = async function _Parser_readBytes(size) {
106
+ if (typeof size !== "number") {
107
+ throw new Error(`Size must be a number, got '${size}'`);
108
+ }
109
+ while (!__classPrivateFieldGet(this, _Parser_buffer, "f") || __classPrivateFieldGet(this, _Parser_buffer, "f").length < size) {
110
+ const result = await __classPrivateFieldGet(this, _Parser_stream, "f").next();
111
+ if (result.done) {
112
+ return null;
113
+ }
114
+ __classPrivateFieldSet(this, _Parser_buffer, concat(__classPrivateFieldGet(this, _Parser_buffer, "f") ?? new Uint8Array(0), result.value), "f");
115
+ }
116
+ const chunk = __classPrivateFieldGet(this, _Parser_buffer, "f").slice(0, size);
117
+ __classPrivateFieldSet(this, _Parser_buffer, __classPrivateFieldGet(this, _Parser_buffer, "f").slice(size), "f");
118
+ return chunk;
119
+ }, _Parser_readCharacters = async function _Parser_readCharacters(count) {
120
+ const chunk = await __classPrivateFieldGet(this, _Parser_instances, "m", _Parser_readBytes).call(this, count);
121
+ return __classPrivateFieldGet(this, _Parser_decoder, "f").decode(chunk);
122
+ };
123
+ async function* iter(iterator) {
124
+ for await (const item of iterator) {
125
+ yield item;
126
+ }
127
+ }
128
+ export async function* decode(input) {
129
+ const decoder = new Parser(iter(input));
130
+ while (true) {
131
+ const frame = await decoder.readOne();
132
+ if (frame === null) {
133
+ return;
134
+ }
135
+ yield frame;
136
+ }
137
+ }
138
+ export async function* parse(input) {
139
+ let payload = null;
140
+ let attachments = [];
141
+ function reset() {
142
+ const result = { payload, attachments };
143
+ payload = null;
144
+ attachments = [];
145
+ return result;
146
+ }
147
+ for await (const frame of decode(input)) {
148
+ if (frame.startsWith("{")) {
149
+ if (payload) {
150
+ yield reset();
151
+ }
152
+ payload = JSON.parse(frame);
153
+ }
154
+ else {
155
+ attachments.push(frame);
156
+ }
157
+ }
158
+ if (payload) {
159
+ yield reset();
160
+ }
161
+ }
@@ -0,0 +1,11 @@
1
+ import { type DataObject } from "../data-type.ts";
2
+ export interface Version {
3
+ protocol: string;
4
+ format: string;
5
+ version: string;
6
+ size: number;
7
+ }
8
+ export declare function parseVersion(data: Uint8Array | string): Version;
9
+ export declare function versify<T extends DataObject>(data: T): T & {
10
+ v: string;
11
+ };
@@ -0,0 +1,56 @@
1
+ import { decodeBase64Int } from "./base64.js";
2
+ // PPPPvvKKKKllllll_
3
+ const LEGACY_MATCH = /^[A-Z]{4}[0-9]{2}[A-Z]{4}.*$/;
4
+ // PPPPVVVKKKKBBBB.
5
+ const MATCH = /^[A-Z]{4}[0-9]{3}[A-Z]{4}.*$/;
6
+ export function parseVersion(data) {
7
+ if (typeof data !== "string") {
8
+ return parseVersion(new TextDecoder().decode(data));
9
+ }
10
+ const value = data.slice(6);
11
+ if (LEGACY_MATCH.test(value)) {
12
+ const protocol = value.slice(0, 4);
13
+ const version = value.slice(4, 6);
14
+ const format = value.slice(6, 10);
15
+ const size = parseInt(value.slice(10, 16), 16);
16
+ return {
17
+ protocol,
18
+ version,
19
+ format,
20
+ size,
21
+ };
22
+ }
23
+ else if (MATCH.test(value)) {
24
+ const protocol = value.slice(0, 4);
25
+ const version = value.slice(4, 7);
26
+ const format = value.slice(7, 11);
27
+ const size = decodeBase64Int(value.slice(12, 15));
28
+ return {
29
+ protocol,
30
+ version,
31
+ format,
32
+ size,
33
+ };
34
+ }
35
+ throw new Error(`Unexpected version string ${value}`);
36
+ }
37
+ function formatSize(size) {
38
+ return size.toString(16).padStart(6, "0");
39
+ }
40
+ function formatVersion(label, size) {
41
+ return `${label}JSON${formatSize(size)}_`;
42
+ }
43
+ // const DUMMY_VERSION = "PPPPVVVKKKKBBBB.";
44
+ // const DUMMY_LEGACY_VERSION = "PPPPvvKKKKllllll_";
45
+ export function versify(data) {
46
+ const encoder = new TextEncoder();
47
+ const str = encoder.encode(JSON.stringify({
48
+ v: formatVersion("KERI10", 0),
49
+ ...data,
50
+ }));
51
+ const version = formatVersion("KERI10", str.byteLength);
52
+ return {
53
+ v: version,
54
+ ...data,
55
+ };
56
+ }