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.
Files changed (115) hide show
  1. package/README.md +96 -47
  2. package/dist/buffer-polyfill.d.ts +1 -0
  3. package/dist/exports.d.ts +40 -0
  4. package/dist/index.d.ts +4 -3
  5. package/dist/keri/app/aiding.d.ts +138 -0
  6. package/dist/keri/app/clienting.d.ts +182 -0
  7. package/dist/keri/app/contacting.d.ts +93 -0
  8. package/dist/keri/app/controller.d.ts +49 -0
  9. package/dist/keri/app/coring.d.ts +121 -0
  10. package/dist/keri/app/credentialing.d.ts +245 -0
  11. package/dist/keri/app/escrowing.d.ts +19 -0
  12. package/dist/keri/app/exchanging.d.ts +60 -0
  13. package/dist/keri/app/grouping.d.ts +44 -0
  14. package/dist/keri/app/habery.d.ts +48 -47
  15. package/dist/keri/app/notifying.d.ts +34 -0
  16. package/dist/keri/core/authing.d.ts +10 -9
  17. package/dist/keri/core/bexter.d.ts +7 -0
  18. package/dist/keri/core/cigar.d.ts +8 -8
  19. package/dist/keri/core/cipher.d.ts +5 -5
  20. package/dist/keri/core/core.d.ts +59 -53
  21. package/dist/keri/core/counter.d.ts +43 -43
  22. package/dist/keri/core/decrypter.d.ts +10 -10
  23. package/dist/keri/core/diger.d.ts +21 -21
  24. package/dist/keri/core/encrypter.d.ts +9 -9
  25. package/dist/keri/core/eventing.d.ts +54 -21
  26. package/dist/keri/core/httping.d.ts +44 -34
  27. package/dist/keri/core/indexer.d.ts +98 -88
  28. package/dist/keri/core/keeping.d.ts +103 -1
  29. package/dist/keri/core/kering.d.ts +5 -5
  30. package/dist/keri/core/manager.d.ts +174 -172
  31. package/dist/keri/core/matter.d.ts +116 -69
  32. package/dist/keri/core/number.d.ts +7 -6
  33. package/dist/keri/core/pather.d.ts +7 -0
  34. package/dist/keri/core/prefixer.d.ts +15 -15
  35. package/dist/keri/core/saider.d.ts +23 -23
  36. package/dist/keri/core/salter.d.ts +23 -23
  37. package/dist/keri/core/seqner.d.ts +15 -0
  38. package/dist/keri/core/serder.d.ts +31 -23
  39. package/dist/keri/core/siger.d.ts +18 -18
  40. package/dist/keri/core/signer.d.ts +34 -34
  41. package/dist/keri/core/tholder.d.ts +29 -14
  42. package/dist/keri/core/utils.d.ts +20 -15
  43. package/dist/keri/core/vdring.d.ts +16 -0
  44. package/dist/keri/core/verfer.d.ts +13 -12
  45. package/dist/keri/end/ending.d.ts +13 -13
  46. package/dist/math.d.ts +1 -0
  47. package/dist/ready.d.ts +1 -0
  48. package/dist/signify-ts.cjs +7842 -0
  49. package/dist/signify-ts.cjs.development.js +6369 -256
  50. package/dist/signify-ts.cjs.development.js.map +1 -1
  51. package/dist/signify-ts.cjs.map +7 -0
  52. package/dist/signify-ts.cjs.production.min.js +1 -1
  53. package/dist/signify-ts.cjs.production.min.js.map +1 -1
  54. package/dist/signify-ts.esm.js +6205 -229
  55. package/dist/signify-ts.esm.js.map +1 -1
  56. package/dist/signify-ts.mjs +7818 -0
  57. package/dist/signify-ts.mjs.map +7 -0
  58. package/package.json +49 -49
  59. package/src/buffer-polyfill.ts +5 -0
  60. package/src/exports.ts +44 -0
  61. package/src/index.ts +4 -5
  62. package/src/keri/app/aiding.ts +493 -0
  63. package/src/keri/app/clienting.ts +492 -0
  64. package/src/keri/app/contacting.ts +188 -0
  65. package/src/keri/app/controller.ts +372 -0
  66. package/src/keri/app/coring.ts +225 -0
  67. package/src/keri/app/credentialing.ts +841 -0
  68. package/src/keri/app/escrowing.ts +34 -0
  69. package/src/keri/app/exchanging.ts +220 -0
  70. package/src/keri/app/grouping.ts +90 -0
  71. package/src/keri/app/habery.ts +118 -85
  72. package/src/keri/app/notifying.ts +69 -0
  73. package/src/keri/core/authing.ts +73 -85
  74. package/src/keri/core/bexter.ts +138 -0
  75. package/src/keri/core/cigar.ts +10 -11
  76. package/src/keri/core/cipher.ts +23 -14
  77. package/src/keri/core/core.ts +223 -81
  78. package/src/keri/core/counter.ts +182 -116
  79. package/src/keri/core/decrypter.ts +48 -34
  80. package/src/keri/core/diger.ts +23 -22
  81. package/src/keri/core/encrypter.ts +37 -27
  82. package/src/keri/core/eventing.ts +468 -106
  83. package/src/keri/core/httping.ts +151 -105
  84. package/src/keri/core/indexer.ts +313 -211
  85. package/src/keri/core/keeping.ts +679 -3
  86. package/src/keri/core/kering.ts +4 -6
  87. package/src/keri/core/manager.ts +660 -499
  88. package/src/keri/core/matter.ts +382 -148
  89. package/src/keri/core/number.ts +56 -11
  90. package/src/keri/core/pather.ts +98 -0
  91. package/src/keri/core/prefixer.ts +122 -101
  92. package/src/keri/core/saider.ts +104 -76
  93. package/src/keri/core/salter.ts +71 -40
  94. package/src/keri/core/seqner.ts +46 -0
  95. package/src/keri/core/serder.ts +102 -38
  96. package/src/keri/core/siger.ts +19 -18
  97. package/src/keri/core/signer.ts +73 -53
  98. package/src/keri/core/tholder.ts +196 -30
  99. package/src/keri/core/utils.ts +121 -50
  100. package/src/keri/core/vdring.ts +94 -0
  101. package/src/keri/core/verfer.ts +22 -9
  102. package/src/keri/end/ending.ts +111 -101
  103. package/src/math.ts +3 -0
  104. package/src/ready.ts +5 -0
  105. package/dist/keri/app/accountant.d.ts +0 -10
  106. package/dist/keri/app/apping.d.ts +0 -1
  107. package/dist/keri/app/client.d.ts +0 -7
  108. package/dist/keri/app/signify.d.ts +0 -6
  109. package/src/keri/app/accountant.ts +0 -35
  110. package/src/keri/app/apping.ts +0 -12
  111. package/src/keri/app/client.ts +0 -30
  112. package/src/keri/app/signify.ts +0 -12
  113. package/src/keri/app/tsconfig.json +0 -100
  114. package/src/keri/core/tsconfig.json +0 -100
  115. package/src/keri/end/tsconfig.json +0 -100
@@ -1,185 +1,272 @@
1
- import {EmptyMaterialError} from "./kering";
2
- import {b, b64ToInt, d, intToB64, readInt} from "./core";
3
- import Base64 from "urlsafe-base64"
1
+ import { EmptyMaterialError } from './kering';
2
+ import { b, b64ToInt, d, intToB64, readInt } from './core';
3
+ import Base64 from 'urlsafe-base64';
4
4
  import { Buffer } from 'buffer';
5
5
 
6
6
  export class IndexerCodex {
7
- Ed25519_Sig: string = 'A' // Ed25519 sig appears same in both lists if any.
8
- Ed25519_Crt_Sig: string = 'B' // Ed25519 sig appears in current list only.
9
- ECDSA_256k1_Sig: string = 'C' // ECDSA secp256k1 sig appears same in both lists if any.
10
- ECDSA_256k1_Crt_Sig: string = 'D' // ECDSA secp256k1 sig appears in current list.
11
- Ed448_Sig: string = '0A' // Ed448 signature appears in both lists.
12
- Ed448_Crt_Sig: string = '0B' // Ed448 signature appears in current list only.
13
- Ed25519_Big_Sig: string = '2A' // Ed25519 sig appears in both lists.
14
- Ed25519_Big_Crt_Sig: string = '2B' // Ed25519 sig appears in current list only.
15
- ECDSA_256k1_Big_Sig: string = '2C' // ECDSA secp256k1 sig appears in both lists.
16
- ECDSA_256k1_Big_Crt_Sig: string = '2D' // ECDSA secp256k1 sig appears in current list only.
17
- Ed448_Big_Sig: string = '3A' // Ed448 signature appears in both lists.
18
- Ed448_Big_Crt_Sig: string = '3B' // Ed448 signature appears in current list only.
19
-
7
+ Ed25519_Sig: string = 'A'; // Ed25519 sig appears same in both lists if any.
8
+ Ed25519_Crt_Sig: string = 'B'; // Ed25519 sig appears in current list only.
9
+ ECDSA_256k1_Sig: string = 'C'; // ECDSA secp256k1 sig appears same in both lists if any.
10
+ ECDSA_256k1_Crt_Sig: string = 'D'; // ECDSA secp256k1 sig appears in current list.
11
+ ECDSA_256r1_Sig: string = 'E'; // ECDSA secp256r1 sig appears same in both lists if any.
12
+ ECDSA_256r1_Crt_Sig: string = 'F'; // ECDSA secp256r1 sig appears in current list.
13
+ Ed448_Sig: string = '0A'; // Ed448 signature appears in both lists.
14
+ Ed448_Crt_Sig: string = '0B'; // Ed448 signature appears in current list only.
15
+ Ed25519_Big_Sig: string = '2A'; // Ed25519 sig appears in both lists.
16
+ Ed25519_Big_Crt_Sig: string = '2B'; // Ed25519 sig appears in current list only.
17
+ ECDSA_256k1_Big_Sig: string = '2C'; // ECDSA secp256k1 sig appears in both lists.
18
+ ECDSA_256k1_Big_Crt_Sig: string = '2D'; // ECDSA secp256k1 sig appears in current list only.
19
+ ECDSA_256r1_Big_Sig: string = '2E'; // ECDSA secp256r1 sig appears in both lists.
20
+ ECDSA_256r1_Big_Crt_Sig: string = '2F'; // ECDSA secp256r1 sig appears in current list only.
21
+ Ed448_Big_Sig: string = '3A'; // Ed448 signature appears in both lists.
22
+ Ed448_Big_Crt_Sig: string = '3B'; // Ed448 signature appears in current list only.
20
23
  }
21
24
 
22
- export const IdrDex = new IndexerCodex()
25
+ export const IdrDex = new IndexerCodex();
23
26
 
24
27
  export class IndexedSigCodex {
25
- Ed25519_Sig: string = 'A' // Ed25519 sig appears same in both lists if any.
26
- Ed25519_Crt_Sig: string = 'B' // Ed25519 sig appears in current list only.
27
- ECDSA_256k1_Sig: string = 'C' // ECDSA secp256k1 sig appears same in both lists if any.
28
- ECDSA_256k1_Crt_Sig: string = 'D' // ECDSA secp256k1 sig appears in current list.
29
- Ed448_Sig: string = '0A' // Ed448 signature appears in both lists.
30
- Ed448_Crt_Sig: string = '0B' // Ed448 signature appears in current list only.
31
- Ed25519_Big_Sig: string = '2A' // Ed25519 sig appears in both lists.
32
- Ed25519_Big_Crt_Sig: string = '2B' // Ed25519 sig appears in current list only.
33
- ECDSA_256k1_Big_Sig: string = '2C' // ECDSA secp256k1 sig appears in both lists.
34
- ECDSA_256k1_Big_Crt_Sig: string = '2D' // ECDSA secp256k1 sig appears in current list only.
35
- Ed448_Big_Sig: string = '3A' // Ed448 signature appears in both lists.
36
- Ed448_Big_Crt_Sig: string = '3B' // Ed448 signature appears in current list only.
28
+ Ed25519_Sig: string = 'A'; // Ed25519 sig appears same in both lists if any.
29
+ Ed25519_Crt_Sig: string = 'B'; // Ed25519 sig appears in current list only.
30
+ ECDSA_256k1_Sig: string = 'C'; // ECDSA secp256k1 sig appears same in both lists if any.
31
+ ECDSA_256k1_Crt_Sig: string = 'D'; // ECDSA secp256k1 sig appears in current list.
32
+ ECDSA_256r1_Sig: string = 'E'; // ECDSA secp256r1 sig appears same in both lists if any.
33
+ ECDSA_256r1_Crt_Sig: string = 'F'; // ECDSA secp256r1 sig appears in current list.
34
+ Ed448_Sig: string = '0A'; // Ed448 signature appears in both lists.
35
+ Ed448_Crt_Sig: string = '0B'; // Ed448 signature appears in current list only.
36
+ Ed25519_Big_Sig: string = '2A'; // Ed25519 sig appears in both lists.
37
+ Ed25519_Big_Crt_Sig: string = '2B'; // Ed25519 sig appears in current list only.
38
+ ECDSA_256k1_Big_Sig: string = '2C'; // ECDSA secp256k1 sig appears in both lists.
39
+ ECDSA_256k1_Big_Crt_Sig: string = '2D'; // ECDSA secp256k1 sig appears in current list only.
40
+ ECDSA_256r1_Big_Sig: string = '2E'; // ECDSA secp256r1 sig appears in both lists.
41
+ ECDSA_256r1_Big_Crt_Sig: string = '2F'; // ECDSA secp256r1 sig appears in current list only.
42
+ Ed448_Big_Sig: string = '3A'; // Ed448 signature appears in both lists.
43
+ Ed448_Big_Crt_Sig: string = '3B'; // Ed448 signature appears in current list only.
37
44
 
38
45
  has(prop: string): boolean {
39
- let m = new Map(Array.from(Object.entries(this), (v) => [v[1], v[0]]))
40
- return m.has(prop)
46
+ const m = new Map(
47
+ Array.from(Object.entries(this), (v) => [v[1], v[0]])
48
+ );
49
+ return m.has(prop);
41
50
  }
42
51
  }
43
52
 
44
- export const IdxSigDex = new IndexedSigCodex()
53
+ export const IdxSigDex = new IndexedSigCodex();
45
54
 
46
55
  export class IndexedCurrentSigCodex {
47
- Ed25519_Crt_Sig: string = 'B' // Ed25519 sig appears in current list only.
48
- ECDSA_256k1_Crt_Sig: string = 'D' // ECDSA secp256k1 sig appears in current list only.
49
- Ed448_Crt_Sig: string = '0B' // Ed448 signature appears in current list only.
50
- Ed25519_Big_Crt_Sig: string = '2B' // Ed25519 sig appears in current list only.
51
- ECDSA_256k1_Big_Crt_Sig: string = '2D' // ECDSA secp256k1 sig appears in current list only.
52
- Ed448_Big_Crt_Sig: string = '3B' // Ed448 signature appears in current list only.
56
+ Ed25519_Crt_Sig: string = 'B'; // Ed25519 sig appears in current list only.
57
+ ECDSA_256k1_Crt_Sig: string = 'D'; // ECDSA secp256k1 sig appears in current list only.
58
+ ECDSA_256r1_Crt_Sig: string = 'F'; // ECDSA secp256r1 sig appears in current list.
59
+ Ed448_Crt_Sig: string = '0B'; // Ed448 signature appears in current list only.
60
+ Ed25519_Big_Crt_Sig: string = '2B'; // Ed25519 sig appears in current list only.
61
+ ECDSA_256k1_Big_Crt_Sig: string = '2D'; // ECDSA secp256k1 sig appears in current list only.
62
+ ECDSA_256r1_Big_Crt_Sig: string = '2F'; // ECDSA secp256r1 sig appears in current list only.
63
+ Ed448_Big_Crt_Sig: string = '3B'; // Ed448 signature appears in current list only.
53
64
 
54
65
  has(prop: string): boolean {
55
- let m = new Map(Array.from(Object.entries(this), (v) => [v[1], v[0]]))
56
- return m.has(prop)
66
+ const m = new Map(
67
+ Array.from(Object.entries(this), (v) => [v[1], v[0]])
68
+ );
69
+ return m.has(prop);
57
70
  }
58
71
  }
59
72
 
60
- export const IdxCrtSigDex = new IndexedCurrentSigCodex()
73
+ export const IdxCrtSigDex = new IndexedCurrentSigCodex();
61
74
 
62
75
  export class IndexedBothSigCodex {
63
- Ed25519_Sig: string = 'A' // Ed25519 sig appears same in both lists if any.
64
- ECDSA_256k1_Sig: string = 'C' // ECDSA secp256k1 sig appears same in both lists if any.
65
- Ed448_Sig: string = '0A' // Ed448 signature appears in both lists.
66
- Ed25519_Big_Sig: string = '2A' // Ed25519 sig appears in both listsy.
67
- ECDSA_256k1_Big_Sig: string = '2C' // ECDSA secp256k1 sig appears in both lists.
68
- Ed448_Big_Sig: string = '3A' // Ed448 signature appears in both lists.
76
+ Ed25519_Sig: string = 'A'; // Ed25519 sig appears same in both lists if any.
77
+ ECDSA_256k1_Sig: string = 'C'; // ECDSA secp256k1 sig appears same in both lists if any.
78
+ Ed448_Sig: string = '0A'; // Ed448 signature appears in both lists.
79
+ Ed25519_Big_Sig: string = '2A'; // Ed25519 sig appears in both listsy.
80
+ ECDSA_256k1_Big_Sig: string = '2C'; // ECDSA secp256k1 sig appears in both lists.
81
+ Ed448_Big_Sig: string = '3A'; // Ed448 signature appears in both lists.
69
82
 
70
83
  has(prop: string): boolean {
71
- let m = new Map(Array.from(Object.entries(this), (v) => [v[1], v[0]]))
72
- return m.has(prop)
84
+ const m = new Map(
85
+ Array.from(Object.entries(this), (v) => [v[1], v[0]])
86
+ );
87
+ return m.has(prop);
73
88
  }
74
89
  }
75
90
 
76
- export const IdxBthSigDex = new IndexedBothSigCodex()
91
+ export const IdxBthSigDex = new IndexedBothSigCodex();
77
92
 
78
93
  export class Xizage {
79
- public hs: number
80
- public ss: number
81
- public os: number
82
- public fs?: number
83
- public ls: number
84
-
85
- constructor(hs:number, ss: number, os: number, fs?: number, ls?: number) {
86
- this.hs = hs
87
- this.ss = ss
88
- this.os = os
89
- this.fs = fs
90
- this.ls = ls!
94
+ public hs: number;
95
+ public ss: number;
96
+ public os: number;
97
+ public fs?: number;
98
+ public ls: number;
99
+
100
+ constructor(hs: number, ss: number, os: number, fs?: number, ls?: number) {
101
+ this.hs = hs;
102
+ this.ss = ss;
103
+ this.os = os;
104
+ this.fs = fs;
105
+ this.ls = ls!;
91
106
  }
92
107
  }
93
108
 
94
109
  export interface IndexerArgs {
95
- raw?: Uint8Array | undefined,
96
- code?: string | undefined
97
- index?: number,
98
- ondex?: number,
99
- qb64b?: Uint8Array | undefined,
100
- qb64?: string | undefined,
101
- qb2?: Uint8Array | undefined,
110
+ raw?: Uint8Array | undefined;
111
+ code?: string | undefined;
112
+ index?: number;
113
+ ondex?: number;
114
+ qb64b?: Uint8Array | undefined;
115
+ qb64?: string | undefined;
116
+ qb2?: Uint8Array | undefined;
102
117
  }
103
118
 
104
119
  export class Indexer {
105
- public Codex = IdrDex
106
-
107
- static Hards = new Map<string, number>([['A', 1], ['B', 1], ['C', 1], ['D', 1], ['E', 1], ['F', 1], ['G', 1], ['H', 1],
108
- ['I', 1], ['J', 1], ['K', 1], ['L', 1], ['M', 1], ['N', 1], ['O', 1], ['P', 1], ['Q', 1], ['R', 1], ['S', 1],
109
- ['T', 1], ['U', 1], ['V', 1], ['W', 1], ['X', 1], ['Y', 1], ['Z', 1], ['a', 1], ['b', 1], ['c', 1], ['d', 1],
110
- ['e', 1], ['f', 1], ['g', 1], ['h', 1], ['i', 1], ['j', 1], ['k', 1], ['l', 1], ['m', 1], ['n', 1], ['o', 1],
111
- ['p', 1], ['q', 1], ['r', 1], ['s', 1], ['t', 1], ['u', 1], ['v', 1], ['w', 1], ['x', 1], ['y', 1], ['z', 1],
112
- ['0', 2], ['1', 2], ['2', 2], ['3', 2], ['4', 2]]
113
- )
114
-
115
- static Sizes = new Map(Object.entries({
116
- 'A': new Xizage(1, 1, 0, 88, 0),
117
- 'B': new Xizage(1, 1, 0, 88, 0),
118
- 'C': new Xizage(1, 1, 0, 88, 0),
119
- 'D': new Xizage(1, 1, 0, 88, 0),
120
- '0A': new Xizage(2, 2, 1, 156, 0),
121
- '0B': new Xizage(2, 2, 1, 156, 0),
122
-
123
- '2A': new Xizage(2, 4, 2, 92, 0),
124
- '2B': new Xizage(2, 4, 2, 92, 0),
125
- '2C': new Xizage(2, 4, 2, 92, 0),
126
- '2D': new Xizage(2, 4, 2, 92, 0),
127
-
128
- '3A': new Xizage(2, 6, 3, 160, 0),
129
- '3B': new Xizage(2, 6, 3, 160, 0),
130
-
131
- '0z': new Xizage(2, 2, 0, undefined, 0),
132
- '1z': new Xizage(2, 2, 1, 76, 1),
133
- '4z': new Xizage(2, 6, 3, 80, 1),
134
- }))
135
-
136
- private _code: string = "";
120
+ public Codex = IdrDex;
121
+
122
+ static Hards = new Map<string, number>([
123
+ ['A', 1],
124
+ ['B', 1],
125
+ ['C', 1],
126
+ ['D', 1],
127
+ ['E', 1],
128
+ ['F', 1],
129
+ ['G', 1],
130
+ ['H', 1],
131
+ ['I', 1],
132
+ ['J', 1],
133
+ ['K', 1],
134
+ ['L', 1],
135
+ ['M', 1],
136
+ ['N', 1],
137
+ ['O', 1],
138
+ ['P', 1],
139
+ ['Q', 1],
140
+ ['R', 1],
141
+ ['S', 1],
142
+ ['T', 1],
143
+ ['U', 1],
144
+ ['V', 1],
145
+ ['W', 1],
146
+ ['X', 1],
147
+ ['Y', 1],
148
+ ['Z', 1],
149
+ ['a', 1],
150
+ ['b', 1],
151
+ ['c', 1],
152
+ ['d', 1],
153
+ ['e', 1],
154
+ ['f', 1],
155
+ ['g', 1],
156
+ ['h', 1],
157
+ ['i', 1],
158
+ ['j', 1],
159
+ ['k', 1],
160
+ ['l', 1],
161
+ ['m', 1],
162
+ ['n', 1],
163
+ ['o', 1],
164
+ ['p', 1],
165
+ ['q', 1],
166
+ ['r', 1],
167
+ ['s', 1],
168
+ ['t', 1],
169
+ ['u', 1],
170
+ ['v', 1],
171
+ ['w', 1],
172
+ ['x', 1],
173
+ ['y', 1],
174
+ ['z', 1],
175
+ ['0', 2],
176
+ ['1', 2],
177
+ ['2', 2],
178
+ ['3', 2],
179
+ ['4', 2],
180
+ ]);
181
+
182
+ static Sizes = new Map(
183
+ Object.entries({
184
+ A: new Xizage(1, 1, 0, 88, 0),
185
+ B: new Xizage(1, 1, 0, 88, 0),
186
+ C: new Xizage(1, 1, 0, 88, 0),
187
+ D: new Xizage(1, 1, 0, 88, 0),
188
+ E: new Xizage(1, 1, 0, 88, 0),
189
+ F: new Xizage(1, 1, 0, 88, 0),
190
+ '0A': new Xizage(2, 2, 1, 156, 0),
191
+ '0B': new Xizage(2, 2, 1, 156, 0),
192
+
193
+ '2A': new Xizage(2, 4, 2, 92, 0),
194
+ '2B': new Xizage(2, 4, 2, 92, 0),
195
+ '2C': new Xizage(2, 4, 2, 92, 0),
196
+ '2D': new Xizage(2, 4, 2, 92, 0),
197
+ '2E': new Xizage(2, 4, 2, 92, 0),
198
+ '2F': new Xizage(2, 4, 2, 92, 0),
199
+
200
+ '3A': new Xizage(2, 6, 3, 160, 0),
201
+ '3B': new Xizage(2, 6, 3, 160, 0),
202
+
203
+ '0z': new Xizage(2, 2, 0, undefined, 0),
204
+ '1z': new Xizage(2, 2, 1, 76, 1),
205
+ '4z': new Xizage(2, 6, 3, 80, 1),
206
+ })
207
+ );
208
+
209
+ private _code: string = '';
137
210
  private _index: number = -1;
138
211
  private _ondex: number | undefined;
139
212
  private _raw: Uint8Array = new Uint8Array(0);
140
213
 
141
- constructor({raw = undefined, code = IdrDex.Ed25519_Sig, index = 0, ondex = undefined,
142
- qb64b = undefined, qb64 = undefined, qb2 = undefined}: IndexerArgs) {
143
-
214
+ constructor({
215
+ raw = undefined,
216
+ code = IdrDex.Ed25519_Sig,
217
+ index = 0,
218
+ ondex = undefined,
219
+ qb64b = undefined,
220
+ qb64 = undefined,
221
+ qb2 = undefined,
222
+ }: IndexerArgs) {
144
223
  if (raw != undefined) {
145
224
  if (code == undefined) {
146
- throw new EmptyMaterialError(`Improper initialization need either (raw and code) or qb64b or qb64 or qb2.`)
225
+ throw new EmptyMaterialError(
226
+ `Improper initialization need either (raw and code) or qb64b or qb64 or qb2.`
227
+ );
147
228
  }
148
229
 
149
230
  if (!Indexer.Sizes.has(code)) {
150
- throw new Error(`Unsupported code=${code}.`)
231
+ throw new Error(`Unsupported code=${code}.`);
151
232
  }
152
233
 
153
- let xizage = Indexer.Sizes.get(code)!
154
- let os = xizage.os
155
- let fs = xizage.fs
156
- let cs = xizage.hs + xizage.ss
157
- let ms = xizage.ss - xizage.os
234
+ const xizage = Indexer.Sizes.get(code)!;
235
+ const os = xizage.os;
236
+ const fs = xizage.fs;
237
+ const cs = xizage.hs + xizage.ss;
238
+ const ms = xizage.ss - xizage.os;
158
239
 
159
- if (!Number.isInteger(index) || index < 0 || index > (64 ** ms - 1)) {
160
- throw new Error(`Invalid index=${index} for code=${code}.`)
240
+ if (!Number.isInteger(index) || index < 0 || index > 64 ** ms - 1) {
241
+ throw new Error(`Invalid index=${index} for code=${code}.`);
161
242
  }
162
243
 
163
- if (ondex != undefined && xizage.os != 0 && !(ondex >= 0 && ondex <= (64 ** os - 1))) {
164
- throw new Error(`Invalid ondex=${ondex} for code=${code}.`)
244
+ if (
245
+ ondex != undefined &&
246
+ xizage.os != 0 &&
247
+ !(ondex >= 0 && ondex <= 64 ** os - 1)
248
+ ) {
249
+ throw new Error(`Invalid ondex=${ondex} for code=${code}.`);
165
250
  }
166
251
 
167
252
  if (IdxCrtSigDex.has(code) && ondex != undefined) {
168
- throw new Error(`Non None ondex=${ondex} for code=${code}.`)
253
+ throw new Error(`Non None ondex=${ondex} for code=${code}.`);
169
254
  }
170
255
 
171
256
  if (IdxBthSigDex.has(code)) {
172
257
  if (ondex == undefined) {
173
- ondex = index
258
+ ondex = index;
174
259
  } else {
175
260
  if (ondex != index && os == 0) {
176
- throw new Error(`Non matching ondex=${ondex} and index=${index} for code=${code}.`)
261
+ throw new Error(
262
+ `Non matching ondex=${ondex} and index=${index} for code=${code}.`
263
+ );
177
264
  }
178
265
  }
179
266
  }
180
267
 
181
268
  if (fs == undefined) {
182
- throw new Error("variable length unsupported")
269
+ throw new Error('variable length unsupported');
183
270
  }
184
271
  // TODO: Don't support this code
185
272
  // if not fs: # compute fs from index
@@ -190,75 +277,76 @@ export class Indexer {
190
277
  // raise InvalidCodeSizeError(f"Non-zero other index size for "
191
278
  // f"variable length material. os={os}.")
192
279
  // fs = (index * 4) + cs
193
- let rawsize = Math.floor((fs - cs) * 3 / 4)
194
- raw = raw.slice(0, rawsize)
280
+ const rawsize = Math.floor(((fs - cs) * 3) / 4);
281
+ raw = raw.slice(0, rawsize);
195
282
 
196
283
  if (raw.length != rawsize) {
197
- throw new Error(`Not enougth raw bytes for code=${code} and index=${index} ,expected ${rawsize} got ${raw.length}.`)
284
+ throw new Error(
285
+ `Not enougth raw bytes for code=${code} and index=${index} ,expected ${rawsize} got ${raw.length}.`
286
+ );
198
287
  }
199
288
 
200
- this._code = code
201
- this._index = index
202
- this._ondex = ondex
203
- this._raw = raw
204
-
289
+ this._code = code;
290
+ this._index = index;
291
+ this._ondex = ondex;
292
+ this._raw = raw;
205
293
  } else if (qb64b != undefined) {
206
- let qb64 = d(qb64b)
207
- this._exfil(qb64)
208
-
294
+ const qb64 = d(qb64b);
295
+ this._exfil(qb64);
209
296
  } else if (qb64 != undefined) {
210
- this._exfil(qb64)
297
+ this._exfil(qb64);
211
298
  } else if (qb2 != undefined) {
212
- this._bexfil(qb2)
299
+ this._bexfil(qb2);
213
300
  } else {
214
- throw new EmptyMaterialError(`Improper initialization need either (raw and code and index) or qb64b or qb64 or qb2.`)
301
+ throw new EmptyMaterialError(
302
+ `Improper initialization need either (raw and code and index) or qb64b or qb64 or qb2.`
303
+ );
215
304
  }
216
305
  }
217
306
 
218
307
  private _bexfil(qb2: Uint8Array) {
219
- throw new Error(`qb2 not yet supported: ${qb2}`)
308
+ throw new Error(`qb2 not yet supported: ${qb2}`);
220
309
  }
221
310
 
222
311
  public static _rawSize(code: string) {
223
- let xizage = Indexer.Sizes.get(code)!
224
- return Math.floor(xizage.fs! - (xizage.hs + xizage.ss) * 3 / 4)
312
+ const xizage = Indexer.Sizes.get(code)!;
313
+ return Math.floor(xizage.fs! - ((xizage.hs + xizage.ss) * 3) / 4);
225
314
  }
226
315
 
227
316
  get code(): string {
228
- return this._code
317
+ return this._code;
229
318
  }
230
319
 
231
320
  get raw(): Uint8Array {
232
- return this._raw
321
+ return this._raw;
233
322
  }
234
323
 
235
324
  get index(): number {
236
- return this._index
325
+ return this._index;
237
326
  }
238
327
 
239
328
  get ondex(): number | undefined {
240
- return this._ondex
329
+ return this._ondex;
241
330
  }
242
331
 
243
- get qb64(): string{
332
+ get qb64(): string {
244
333
  return this._infil();
245
334
  }
246
335
 
247
336
  get qb64b() {
248
- return b(this.qb64)
337
+ return b(this.qb64);
249
338
  }
250
339
 
251
-
252
340
  private _infil(): string {
253
- let code = this.code
254
- let index = this.index
255
- let ondex = this.ondex
256
- let raw = this.raw
341
+ const code = this.code;
342
+ const index = this.index;
343
+ const ondex = this.ondex;
344
+ const raw = this.raw;
257
345
 
258
- let ps = (3 - (raw.length % 3)) % 3
259
- let xizage = Indexer.Sizes.get(code)!
260
- let cs = xizage.hs + xizage.ss
261
- let ms = xizage.ss - xizage.os
346
+ const ps = (3 - (raw.length % 3)) % 3;
347
+ const xizage = Indexer.Sizes.get(code)!;
348
+ const cs = xizage.hs + xizage.ss;
349
+ const ms = xizage.ss - xizage.os;
262
350
 
263
351
  // TODO: don't support this code
264
352
  // if not fs: # compute fs from index
@@ -270,87 +358,101 @@ export class Indexer {
270
358
  // f"variable length material. os={os}.")
271
359
  // fs = (index * 4) + cs
272
360
 
273
- if (index < 0 || index > (64 ** ms -1)) {
274
- throw new Error(`Invalid index=${index} for code=${code}.`)
361
+ if (index < 0 || index > 64 ** ms - 1) {
362
+ throw new Error(`Invalid index=${index} for code=${code}.`);
275
363
  }
276
364
 
277
- if (ondex != undefined && xizage.os != 0 && !(ondex >= 0 && ondex <= (64 ** xizage.os - 1))) {
278
- throw new Error(`Invalid ondex=${ondex} for os=${xizage.os} and code=${code}.`)
365
+ if (
366
+ ondex != undefined &&
367
+ xizage.os != 0 &&
368
+ !(ondex >= 0 && ondex <= 64 ** xizage.os - 1)
369
+ ) {
370
+ throw new Error(
371
+ `Invalid ondex=${ondex} for os=${xizage.os} and code=${code}.`
372
+ );
279
373
  }
280
374
 
281
- let both = `${code}${intToB64(index, ms)}${intToB64(ondex == undefined ? 0 : ondex, xizage.os)}`
375
+ const both = `${code}${intToB64(index, ms)}${intToB64(
376
+ ondex == undefined ? 0 : ondex,
377
+ xizage.os
378
+ )}`;
282
379
 
283
380
  if (both.length != cs) {
284
- throw new Error(`Mismatch code size = ${cs} with table = ${both.length}.`)
381
+ throw new Error(
382
+ `Mismatch code size = ${cs} with table = ${both.length}.`
383
+ );
285
384
  }
286
385
 
287
- if ((cs % 4) != ps - xizage.ls) {
288
- throw new Error(`Invalid code=${both} for converted raw pad size=${ps}.`)
386
+ if (cs % 4 != ps - xizage.ls) {
387
+ throw new Error(
388
+ `Invalid code=${both} for converted raw pad size=${ps}.`
389
+ );
289
390
  }
290
391
 
291
- let bytes = new Uint8Array(ps + raw.length);
392
+ const bytes = new Uint8Array(ps + raw.length);
292
393
  for (let i = 0; i < ps; i++) {
293
394
  bytes[i] = 0;
294
395
  }
295
396
  for (let i = 0; i < raw.length; i++) {
296
- let odx = i + ps
397
+ const odx = i + ps;
297
398
  bytes[odx] = raw[i];
298
399
  }
299
400
 
300
- let full = both + Base64.encode(Buffer.from(bytes)).slice(ps - xizage.ls)
401
+ const full =
402
+ both + Base64.encode(Buffer.from(bytes)).slice(ps - xizage.ls);
301
403
  if (full.length != xizage.fs) {
302
- throw new Error(`Invalid code=${both} for raw size=${raw.length}.`)
404
+ throw new Error(`Invalid code=${both} for raw size=${raw.length}.`);
303
405
  }
304
406
 
305
- return full
407
+ return full;
306
408
  }
307
409
 
308
410
  _exfil(qb64: string) {
309
411
  if (qb64.length == 0) {
310
- throw new Error("Empty Material")
412
+ throw new Error('Empty Material');
311
413
  }
312
414
 
313
- let first = qb64[0];
415
+ const first = qb64[0];
314
416
  if (!Array.from(Indexer.Hards.keys()).includes(first)) {
315
- throw new Error(`Unexpected code ${first}`)
417
+ throw new Error(`Unexpected code ${first}`);
316
418
  }
317
419
 
318
- let hs = Indexer.Hards.get(first)!
319
- if ((qb64.length) < hs) {
320
- throw new Error(`Need ${hs - qb64.length} more characters.`)
420
+ const hs = Indexer.Hards.get(first)!;
421
+ if (qb64.length < hs) {
422
+ throw new Error(`Need ${hs - qb64.length} more characters.`);
321
423
  }
322
424
 
323
- let hard = qb64.slice(0, hs)
425
+ const hard = qb64.slice(0, hs);
324
426
  if (!Array.from(Indexer.Sizes.keys()).includes(hard)) {
325
- throw new Error(`Unsupported code ${hard}`)
427
+ throw new Error(`Unsupported code ${hard}`);
326
428
  }
327
429
 
328
- let xizage = Indexer.Sizes.get(hard)!
329
- let cs = xizage.hs + xizage.ss // both hard + soft code size
330
- let ms = xizage.ss - xizage.os
430
+ const xizage = Indexer.Sizes.get(hard)!;
431
+ const cs = xizage.hs + xizage.ss; // both hard + soft code size
432
+ const ms = xizage.ss - xizage.os;
331
433
 
332
434
  if (qb64.length < cs) {
333
- throw new Error(`Need ${cs - qb64.length} more characters.`)
435
+ throw new Error(`Need ${cs - qb64.length} more characters.`);
334
436
  }
335
437
 
336
- let sindex = qb64.slice(hs, hs+ms)
337
- let index = b64ToInt(sindex)
438
+ const sindex = qb64.slice(hs, hs + ms);
439
+ const index = b64ToInt(sindex);
338
440
 
339
- let sondex = qb64.slice(hs+ms, hs+ms+xizage.os)
340
- let ondex
441
+ const sondex = qb64.slice(hs + ms, hs + ms + xizage.os);
442
+ let ondex;
341
443
  if (IdxCrtSigDex.has(hard)) {
342
- ondex = xizage.os != 0 ? b64ToInt(sondex) : undefined
444
+ ondex = xizage.os != 0 ? b64ToInt(sondex) : undefined;
343
445
  if (ondex != 0 && ondex != undefined) {
344
- throw new Error(`Invalid ondex=${ondex} for code=${hard}.`)
446
+ throw new Error(`Invalid ondex=${ondex} for code=${hard}.`);
345
447
  } else {
346
- ondex = undefined
448
+ ondex = undefined;
347
449
  }
348
450
  } else {
349
- ondex = xizage.os != 0 ? b64ToInt(sondex) : index
451
+ ondex = xizage.os != 0 ? b64ToInt(sondex) : index;
350
452
  }
351
453
 
352
454
  if (xizage.fs == undefined) {
353
- throw new Error("variable length not supported")
455
+ throw new Error('variable length not supported');
354
456
  }
355
457
  // TODO: support variable length
356
458
  // if not fs: # compute fs from index which means variable length
@@ -363,45 +465,45 @@ export class Indexer {
363
465
  // fs = (index * 4) + cs
364
466
 
365
467
  if (qb64.length < xizage.fs) {
366
- throw new Error(`Need ${xizage.fs - qb64.length} more chars.`)
468
+ throw new Error(`Need ${xizage.fs - qb64.length} more chars.`);
367
469
  }
368
470
 
369
- qb64 = qb64.slice(0, xizage.fs)
370
- let ps = cs % 4
371
- let pbs = 2 * ps != 0 ? ps : xizage.ls
372
- let raw
471
+ qb64 = qb64.slice(0, xizage.fs);
472
+ const ps = cs % 4;
473
+ const pbs = 2 * ps != 0 ? ps : xizage.ls;
474
+ let raw;
373
475
  if (ps != 0) {
374
- let base = new Array(ps + 1).join('A') + qb64.slice(cs);
375
- let paw = Base64.decode(base) // decode base to leave prepadded raw
376
- let pi = (readInt(paw.slice(0, ps))) // prepad as int
377
- if (pi & (2 ** pbs - 1)) { // masked pad bits non-zero
378
- throw new Error(`Non zeroed prepad bits = {pi & (2 ** pbs - 1 ):<06b} in {qb64b[cs:cs+1]}.`)
476
+ const base = new Array(ps + 1).join('A') + qb64.slice(cs);
477
+ const paw = Base64.decode(base); // decode base to leave prepadded raw
478
+ const pi = readInt(paw.slice(0, ps)); // prepad as int
479
+ if (pi & (2 ** pbs - 1)) {
480
+ // masked pad bits non-zero
481
+ throw new Error(
482
+ `Non zeroed prepad bits = {pi & (2 ** pbs - 1 ):<06b} in {qb64b[cs:cs+1]}.`
483
+ );
379
484
  }
380
- raw = paw.slice(ps) // strip off ps prepad paw bytes
485
+ raw = paw.slice(ps); // strip off ps prepad paw bytes
381
486
  } else {
382
- let base = qb64.slice(cs);
383
- let paw = Base64.decode(base);
384
- let li = readInt(paw.slice(0, xizage!.ls))
487
+ const base = qb64.slice(cs);
488
+ const paw = Base64.decode(base);
489
+ const li = readInt(paw.slice(0, xizage!.ls));
385
490
  if (li != 0) {
386
491
  if (li == 1) {
387
- throw new Error(`Non zeroed lead byte = 0x{li:02x}.`)
492
+ throw new Error(`Non zeroed lead byte = 0x{li:02x}.`);
388
493
  } else {
389
- throw new Error(`Non zeroed lead bytes = 0x{li:04x}`)
494
+ throw new Error(`Non zeroed lead bytes = 0x{li:04x}`);
390
495
  }
391
496
  }
392
- raw = paw.slice(xizage!.ls)
497
+ raw = paw.slice(xizage!.ls);
393
498
  }
394
499
 
395
- if (raw.length != Math.floor((qb64.length - cs) * 3 / 4)) {
396
- throw new Error(`Improperly qualified material = ${qb64}`)
500
+ if (raw.length != Math.floor(((qb64.length - cs) * 3) / 4)) {
501
+ throw new Error(`Improperly qualified material = ${qb64}`);
397
502
  }
398
503
 
399
- this._code = hard
400
- this._index = index
401
- this._ondex = ondex
402
- this._raw = new Uint8Array(raw) // must be bytes for crpto opts and immutable not bytearray
504
+ this._code = hard;
505
+ this._index = index;
506
+ this._ondex = ondex;
507
+ this._raw = new Uint8Array(raw); // must be bytes for crpto opts and immutable not bytearray
403
508
  }
404
509
  }
405
-
406
-
407
-