signify-ts 0.1.0 → 0.2.0

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