keri 0.0.0-dev.8b0703e

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 (41) hide show
  1. package/dist/data-type.d.ts +9 -0
  2. package/dist/data-type.js +1 -0
  3. package/dist/db/sqlite-db.d.ts +14 -0
  4. package/dist/db/sqlite-db.js +90 -0
  5. package/dist/events/common.d.ts +6 -0
  6. package/dist/events/common.js +1 -0
  7. package/dist/events/incept.d.ts +26 -0
  8. package/dist/events/incept.js +28 -0
  9. package/dist/events/interact.d.ts +14 -0
  10. package/dist/events/interact.js +20 -0
  11. package/dist/events/main.d.ts +4 -0
  12. package/dist/events/main.js +4 -0
  13. package/dist/events/reply.d.ts +15 -0
  14. package/dist/events/reply.js +20 -0
  15. package/dist/keri.d.ts +1 -0
  16. package/dist/keri.js +110 -0
  17. package/dist/keystore/encrypt.d.ts +2 -0
  18. package/dist/keystore/encrypt.js +38 -0
  19. package/dist/keystore/keystore-fs.d.ts +13 -0
  20. package/dist/keystore/keystore-fs.js +50 -0
  21. package/dist/keystore/keystore-web.d.ts +12 -0
  22. package/dist/keystore/keystore-web.js +48 -0
  23. package/dist/keystore/keystore.d.ts +15 -0
  24. package/dist/keystore/keystore.js +1 -0
  25. package/dist/main-common.d.ts +7 -0
  26. package/dist/main-common.js +7 -0
  27. package/dist/main-web.d.ts +2 -0
  28. package/dist/main-web.js +2 -0
  29. package/dist/main.d.ts +2 -0
  30. package/dist/main.js +2 -0
  31. package/dist/parser/base64.d.ts +6 -0
  32. package/dist/parser/base64.js +74 -0
  33. package/dist/parser/cesr-encoding.d.ts +34 -0
  34. package/dist/parser/cesr-encoding.js +158 -0
  35. package/dist/parser/codes.d.ts +143 -0
  36. package/dist/parser/codes.js +266 -0
  37. package/dist/parser/parser.d.ts +11 -0
  38. package/dist/parser/parser.js +150 -0
  39. package/dist/parser/version.d.ts +11 -0
  40. package/dist/parser/version.js +56 -0
  41. package/package.json +45 -0
@@ -0,0 +1,74 @@
1
+ const ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
2
+ const B64_URL_MAP = ALPHABET.split("");
3
+ const B64_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");
4
+ export function encodeBase64(uint8) {
5
+ // CREDIT: https://github.com/denoland/std/blob/main/encoding/base64.ts
6
+ // CREDIT: https://gist.github.com/enepomnyaschih/72c423f727d395eeaa09697058238727
7
+ let result = "";
8
+ let i;
9
+ const l = uint8.length;
10
+ for (i = 2; i < l; i += 3) {
11
+ result += B64_ALPHABET[uint8[i - 2] >> 2];
12
+ result += B64_ALPHABET[((uint8[i - 2] & 0x03) << 4) | (uint8[i - 1] >> 4)];
13
+ result += B64_ALPHABET[((uint8[i - 1] & 0x0f) << 2) | (uint8[i] >> 6)];
14
+ result += B64_ALPHABET[uint8[i] & 0x3f];
15
+ }
16
+ if (i === l + 1) {
17
+ // 1 octet yet to write
18
+ result += B64_ALPHABET[uint8[i - 2] >> 2];
19
+ result += B64_ALPHABET[(uint8[i - 2] & 0x03) << 4];
20
+ result += "==";
21
+ }
22
+ if (i === l) {
23
+ // 2 octets yet to write
24
+ result += B64_ALPHABET[uint8[i - 2] >> 2];
25
+ result += B64_ALPHABET[((uint8[i - 2] & 0x03) << 4) | (uint8[i - 1] >> 4)];
26
+ result += B64_ALPHABET[(uint8[i - 1] & 0x0f) << 2];
27
+ result += "=";
28
+ }
29
+ return result;
30
+ }
31
+ export function decodeBase64(b64) {
32
+ // CREDIT: https://github.com/denoland/std/blob/main/encoding/base64.ts
33
+ const binString = atob(b64);
34
+ const size = binString.length;
35
+ const bytes = new Uint8Array(size);
36
+ for (let i = 0; i < size; i++) {
37
+ bytes[i] = binString.charCodeAt(i);
38
+ }
39
+ return bytes;
40
+ }
41
+ export function decodeBase64Int(value) {
42
+ return value
43
+ .split("")
44
+ .reverse()
45
+ .reduce((result, character, index) => {
46
+ const value = ALPHABET.indexOf(character);
47
+ const factor = 64 ** index;
48
+ return result + value * factor;
49
+ }, 0);
50
+ }
51
+ export function encodeBase64Int(value, length = 1) {
52
+ let current = value;
53
+ let result = "";
54
+ while (length != 0) {
55
+ result = B64_URL_MAP[current % 64] + result;
56
+ current = Math.floor(current / 64);
57
+ if (current == 0) {
58
+ break;
59
+ }
60
+ }
61
+ return result.padStart(length, "A");
62
+ }
63
+ export function encodeBase64Url(buffer) {
64
+ return encodeBase64(buffer).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+/, "");
65
+ }
66
+ export function decodeBase64Url(input) {
67
+ if (!(typeof input === "string")) {
68
+ throw new TypeError("`input` must be a string.");
69
+ }
70
+ const n = input.length % 4;
71
+ const padded = input + "=".repeat(n > 0 ? 4 - n : n);
72
+ const base64String = padded.replace(/-/g, "+").replace(/_/g, "/");
73
+ return decodeBase64(base64String);
74
+ }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Represents the Raw domain
3
+ */
4
+ export interface Raw {
5
+ code: string;
6
+ buffer: Uint8Array;
7
+ }
8
+ export declare function decode(text: string): Raw;
9
+ export declare function encodeDate(date: Date): string;
10
+ export declare function encode(code: string, raw: Uint8Array): string;
11
+ /**
12
+ * Converts a cryptographic primitive to indexed material
13
+ */
14
+ export declare function index(text: string, index: number): string;
15
+ export interface Indexed {
16
+ value: string;
17
+ index: number;
18
+ }
19
+ /**
20
+ * Converts indexed material to primitive and index
21
+ */
22
+ export declare function deindex(text: string): Indexed;
23
+ export declare function sign(message: Uint8Array, privateKey: Uint8Array, curve: "ed25519"): string;
24
+ export declare function verify(message: Uint8Array, publicKey: string, signature: string): boolean;
25
+ declare const cesr: {
26
+ encode: typeof encode;
27
+ decode: typeof decode;
28
+ sign: typeof sign;
29
+ verify: typeof verify;
30
+ index: typeof index;
31
+ deindex: typeof deindex;
32
+ encodeDate: typeof encodeDate;
33
+ };
34
+ export default cesr;
@@ -0,0 +1,158 @@
1
+ import { ed25519 } from "@noble/curves/ed25519";
2
+ import { decodeBase64Int, decodeBase64Url, encodeBase64Int, encodeBase64Url } from "./base64.js";
3
+ import { IndexerCode, IndexerCodeTable, MatterCode, MatterCodeTable } from "./codes.js";
4
+ function padNumber(num, length) {
5
+ return num.toString().padStart(length, "0");
6
+ }
7
+ function findPrimitiveCode(text) {
8
+ let i = 0;
9
+ let code = "";
10
+ let size = null;
11
+ while (!size && i <= 4) {
12
+ code = text.slice(0, i);
13
+ size = MatterCodeTable[text.slice(0, i)];
14
+ ++i;
15
+ }
16
+ if (!size) {
17
+ throw new Error(`Unable to find code table for ${text}`);
18
+ }
19
+ return [code, size];
20
+ }
21
+ function findIndexCode(text) {
22
+ let i = 0;
23
+ let code = "";
24
+ let size = null;
25
+ while (!size && i <= 4) {
26
+ code = text.slice(0, i);
27
+ size = IndexerCodeTable[text.slice(0, i)];
28
+ ++i;
29
+ }
30
+ if (!size) {
31
+ throw new Error(`Unable to find code table for ${text}`);
32
+ }
33
+ return [code, size];
34
+ }
35
+ export function decode(text) {
36
+ const [code, size] = findPrimitiveCode(text);
37
+ if (!size) {
38
+ throw new Error(`Unable to find code table for ${text}`);
39
+ }
40
+ const padSize = (size.hs + size.ss) % 4;
41
+ const padding = "A".repeat(padSize);
42
+ const paw = decodeBase64Url(padding + text.substring(size.hs + size.ss));
43
+ const buffer = paw.slice(padSize + (size.ls ?? 0));
44
+ return { code, buffer };
45
+ }
46
+ export function encodeDate(date) {
47
+ if (date.toString() === "Invalid Date") {
48
+ throw new Error("Invalid date");
49
+ }
50
+ const YYYY = date.getFullYear();
51
+ const MM = padNumber(date.getUTCMonth() + 1, 2);
52
+ const dd = padNumber(date.getUTCDate(), 2);
53
+ const hh = padNumber(date.getUTCHours(), 2);
54
+ const mm = padNumber(date.getUTCMinutes(), 2);
55
+ const ss = padNumber(date.getUTCSeconds(), 2);
56
+ const ms = padNumber(date.getMilliseconds(), 3);
57
+ const format = `${YYYY}-${MM}-${dd}T${hh}c${mm}c${ss}d${ms}000p00c00`;
58
+ return `${MatterCode.DateTime}${format}`;
59
+ }
60
+ export function encode(code, raw) {
61
+ const both = code;
62
+ const rs = raw.byteLength;
63
+ const size = MatterCodeTable[code];
64
+ if (!size) {
65
+ throw new Error(`Unable to find code table for ${code}`);
66
+ }
67
+ const { hs, ss, xs, fs } = size;
68
+ const ls = size.ls ?? 0;
69
+ const cs = hs + ss;
70
+ let full;
71
+ if (!fs) {
72
+ if ((ls + rs) % 3 !== 0 || cs % 4 !== 0) {
73
+ throw new Error(`Invalid full code=${both} with variable raw size=${rs} given cs=${cs}, hs=${hs}, ss=${ss}, fs=${fs}, and ls=${ls}.`);
74
+ }
75
+ const paddedRaw = new Uint8Array(ls + rs);
76
+ paddedRaw.set(raw, ls);
77
+ full = both + encodeBase64Url(paddedRaw);
78
+ }
79
+ else {
80
+ const ps = (3 - ((rs + ls) % 3)) % 3;
81
+ if (ps !== cs % 4) {
82
+ throw new Error(`Invalid full code=${both} with fixed raw size=${rs} given cs=${cs}, hs=${hs}, ss=${ss}, fs=${fs}, and ls=${ls}.`);
83
+ }
84
+ const paddedRaw = new Uint8Array(ps + ls + rs);
85
+ paddedRaw.set(raw, ps + ls);
86
+ full = both + encodeBase64Url(paddedRaw).slice(ps);
87
+ }
88
+ if (full.length % 4 !== 0 || (fs && full.length !== fs)) {
89
+ throw new Error(`Invalid full size given code=${both} with raw size=${rs}, cs=${cs}, hs=${hs}, ss=${ss}, xs=${xs}, fs=${fs}, and ls=${ls}.`);
90
+ }
91
+ return full;
92
+ }
93
+ function resolveIndexCode(primitiveCode) {
94
+ switch (primitiveCode) {
95
+ case MatterCode.Ed25519_Sig:
96
+ return [IndexerCode.Ed25519_Sig, IndexerCodeTable[IndexerCode.Ed25519_Sig]];
97
+ case MatterCode.Ed448_Sig:
98
+ return [IndexerCode.Ed448_Sig, IndexerCodeTable[IndexerCode.Ed448_Sig]];
99
+ }
100
+ throw new Error(`Unable to find indexed code for '${primitiveCode}'`);
101
+ }
102
+ function resolvePrimitiveCode(indexCode) {
103
+ switch (indexCode) {
104
+ case IndexerCode.Ed25519_Sig:
105
+ return [MatterCode.Ed25519_Sig, MatterCodeTable[IndexerCode.Ed25519_Sig]];
106
+ case IndexerCode.Ed448_Sig:
107
+ return [MatterCode.Ed448_Sig, MatterCodeTable[IndexerCode.Ed448_Sig]];
108
+ }
109
+ throw new Error(`Unable to find primitive code for '${indexCode}'`);
110
+ }
111
+ /**
112
+ * Converts a cryptographic primitive to indexed material
113
+ */
114
+ export function index(text, index) {
115
+ const [code, size] = findPrimitiveCode(text);
116
+ const [indexCode, indexCodeSize] = resolveIndexCode(code);
117
+ return indexCode + encodeBase64Int(index, indexCodeSize.ss) + text.slice(size.hs + size.ss);
118
+ }
119
+ /**
120
+ * Converts indexed material to primitive and index
121
+ */
122
+ export function deindex(text) {
123
+ const [indexCode, indexCodeSize] = findIndexCode(text);
124
+ const [primitiveCode] = resolvePrimitiveCode(indexCode);
125
+ const index = decodeBase64Int(text.slice(indexCodeSize.hs, indexCodeSize.ss));
126
+ const value = primitiveCode + text.slice(indexCodeSize.hs + indexCodeSize.ss);
127
+ return {
128
+ index,
129
+ value,
130
+ };
131
+ }
132
+ export function sign(message, privateKey, curve) {
133
+ switch (curve) {
134
+ case "ed25519":
135
+ return cesr.encode(MatterCode.Ed25519_Sig, ed25519.sign(message, privateKey));
136
+ default:
137
+ throw new Error(`Unsupported curve ${curve}`);
138
+ }
139
+ }
140
+ export function verify(message, publicKey, signature) {
141
+ const decodedPublicKey = cesr.decode(publicKey);
142
+ const decodedSignature = cesr.decode(signature);
143
+ switch (decodedSignature.code) {
144
+ case MatterCode.Ed25519_Sig:
145
+ return ed25519.verify(decodedSignature.buffer, message, decodedPublicKey.buffer);
146
+ }
147
+ throw new Error(`Unsupported signature code ${decodedSignature.code}`);
148
+ }
149
+ const cesr = {
150
+ encode,
151
+ decode,
152
+ sign,
153
+ verify,
154
+ index,
155
+ deindex,
156
+ encodeDate,
157
+ };
158
+ export default cesr;
@@ -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,11 @@
1
+ import type { KeyEvent } from "../events/main.ts";
2
+ export declare class Parser {
3
+ #private;
4
+ parse(data: Uint8Array): string[];
5
+ }
6
+ export declare function parse(data: Uint8Array): string[];
7
+ export declare function parseStream(stream: ReadableStream<Uint8Array>): AsyncIterableIterator<Message>;
8
+ export interface Message {
9
+ payload: KeyEvent;
10
+ attachments: string[];
11
+ }