@metamask/utils 6.1.0 → 7.0.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 (170) hide show
  1. package/CHANGELOG.md +19 -1
  2. package/dist/cjs/assert.js +116 -0
  3. package/dist/cjs/assert.js.map +1 -0
  4. package/dist/cjs/base64.js +32 -0
  5. package/dist/cjs/base64.js.map +1 -0
  6. package/dist/cjs/bytes.js +255 -0
  7. package/dist/cjs/bytes.js.map +1 -0
  8. package/dist/cjs/checksum.js +17 -0
  9. package/dist/cjs/checksum.js.map +1 -0
  10. package/dist/cjs/coercers.js +96 -0
  11. package/dist/cjs/coercers.js.map +1 -0
  12. package/dist/cjs/collections.js +157 -0
  13. package/dist/cjs/collections.js.map +1 -0
  14. package/dist/cjs/encryption-types.js +6 -0
  15. package/dist/cjs/encryption-types.js.map +1 -0
  16. package/dist/cjs/hex.js +107 -0
  17. package/dist/cjs/hex.js.map +1 -0
  18. package/dist/cjs/index.js +36 -0
  19. package/dist/cjs/index.js.map +1 -0
  20. package/dist/cjs/json.js +263 -0
  21. package/dist/cjs/json.js.map +1 -0
  22. package/dist/cjs/keyring.js +6 -0
  23. package/dist/cjs/keyring.js.map +1 -0
  24. package/dist/cjs/logging.js +33 -0
  25. package/dist/cjs/logging.js.map +1 -0
  26. package/dist/cjs/misc.js +111 -0
  27. package/dist/cjs/misc.js.map +1 -0
  28. package/dist/cjs/number.js +52 -0
  29. package/dist/cjs/number.js.map +1 -0
  30. package/dist/cjs/opaque.js +8 -0
  31. package/dist/cjs/opaque.js.map +1 -0
  32. package/dist/cjs/time.js +63 -0
  33. package/dist/cjs/time.js.map +1 -0
  34. package/dist/cjs/transaction-types.js +6 -0
  35. package/dist/cjs/transaction-types.js.map +1 -0
  36. package/dist/cjs/versions.js +79 -0
  37. package/dist/cjs/versions.js.map +1 -0
  38. package/dist/{assert.js → esm/assert.js} +30 -35
  39. package/dist/esm/assert.js.map +1 -0
  40. package/dist/{base64.js → esm/base64.js} +10 -16
  41. package/dist/esm/base64.js.map +1 -0
  42. package/dist/{bytes.js → esm/bytes.js} +50 -93
  43. package/dist/esm/bytes.js.map +1 -0
  44. package/dist/esm/checksum.js +7 -0
  45. package/dist/esm/checksum.js.map +1 -0
  46. package/dist/{coercers.js → esm/coercers.js} +43 -52
  47. package/dist/esm/coercers.js.map +1 -0
  48. package/dist/esm/collections.js +140 -0
  49. package/dist/esm/collections.js.map +1 -0
  50. package/dist/esm/encryption-types.js +3 -0
  51. package/dist/esm/encryption-types.js.map +1 -0
  52. package/dist/esm/hex.js +108 -0
  53. package/dist/esm/hex.js.map +1 -0
  54. package/dist/{index.d.ts → esm/index.js} +2 -0
  55. package/dist/esm/index.js.map +1 -0
  56. package/dist/esm/json.js +301 -0
  57. package/dist/esm/json.js.map +1 -0
  58. package/dist/esm/keyring.js +3 -0
  59. package/dist/esm/keyring.js.map +1 -0
  60. package/dist/{logging.js → esm/logging.js} +5 -14
  61. package/dist/esm/logging.js.map +1 -0
  62. package/dist/{misc.js → esm/misc.js} +37 -42
  63. package/dist/esm/misc.js.map +1 -0
  64. package/dist/{number.js → esm/number.js} +18 -28
  65. package/dist/esm/number.js.map +1 -0
  66. package/dist/esm/opaque.js +5 -0
  67. package/dist/esm/opaque.js.map +1 -0
  68. package/dist/esm/package.json +1 -0
  69. package/dist/esm/time.js +53 -0
  70. package/dist/esm/time.js.map +1 -0
  71. package/dist/esm/transaction-types.js +3 -0
  72. package/dist/esm/transaction-types.js.map +1 -0
  73. package/dist/esm/versions.js +78 -0
  74. package/dist/esm/versions.js.map +1 -0
  75. package/dist/{assert.d.ts → types/assert.d.ts} +3 -2
  76. package/dist/types/assert.d.ts.map +1 -0
  77. package/dist/{base64.d.ts → types/base64.d.ts} +3 -2
  78. package/dist/types/base64.d.ts.map +1 -0
  79. package/dist/{bytes.d.ts → types/bytes.d.ts} +2 -1
  80. package/dist/types/bytes.d.ts.map +1 -0
  81. package/dist/{checksum.d.ts → types/checksum.d.ts} +1 -0
  82. package/dist/types/checksum.d.ts.map +1 -0
  83. package/dist/{coercers.d.ts → types/coercers.d.ts} +3 -2
  84. package/dist/types/coercers.d.ts.map +1 -0
  85. package/dist/{collections.d.ts → types/collections.d.ts} +1 -0
  86. package/dist/types/collections.d.ts.map +1 -0
  87. package/dist/{encryption-types.d.ts → types/encryption-types.d.ts} +1 -0
  88. package/dist/types/encryption-types.d.ts.map +1 -0
  89. package/dist/{hex.d.ts → types/hex.d.ts} +28 -1
  90. package/dist/types/hex.d.ts.map +1 -0
  91. package/dist/types/hex.test-d.d.ts +2 -0
  92. package/dist/types/hex.test-d.d.ts.map +1 -0
  93. package/dist/types/index.d.ts +18 -0
  94. package/dist/types/index.d.ts.map +1 -0
  95. package/dist/{json.d.ts → types/json.d.ts} +3 -2
  96. package/dist/types/json.d.ts.map +1 -0
  97. package/dist/types/json.test-d.d.ts +2 -0
  98. package/dist/types/json.test-d.d.ts.map +1 -0
  99. package/dist/{keyring.d.ts → types/keyring.d.ts} +3 -2
  100. package/dist/types/keyring.d.ts.map +1 -0
  101. package/dist/{logging.d.ts → types/logging.d.ts} +2 -1
  102. package/dist/types/logging.d.ts.map +1 -0
  103. package/dist/{misc.d.ts → types/misc.d.ts} +13 -0
  104. package/dist/types/misc.d.ts.map +1 -0
  105. package/dist/types/misc.test-d.d.ts +2 -0
  106. package/dist/types/misc.test-d.d.ts.map +1 -0
  107. package/dist/{number.d.ts → types/number.d.ts} +1 -0
  108. package/dist/types/number.d.ts.map +1 -0
  109. package/dist/{opaque.d.ts → types/opaque.d.ts} +1 -0
  110. package/dist/types/opaque.d.ts.map +1 -0
  111. package/dist/{time.d.ts → types/time.d.ts} +1 -0
  112. package/dist/types/time.d.ts.map +1 -0
  113. package/dist/{transaction-types.d.ts → types/transaction-types.d.ts} +3 -2
  114. package/dist/types/transaction-types.d.ts.map +1 -0
  115. package/dist/{versions.d.ts → types/versions.d.ts} +3 -2
  116. package/dist/types/versions.d.ts.map +1 -0
  117. package/package.json +41 -20
  118. package/dist/__fixtures__/bytes.d.ts +0 -25
  119. package/dist/__fixtures__/bytes.js +0 -234
  120. package/dist/__fixtures__/bytes.js.map +0 -1
  121. package/dist/__fixtures__/coercions.d.ts +0 -5
  122. package/dist/__fixtures__/coercions.js +0 -22
  123. package/dist/__fixtures__/coercions.js.map +0 -1
  124. package/dist/__fixtures__/index.d.ts +0 -4
  125. package/dist/__fixtures__/index.js +0 -21
  126. package/dist/__fixtures__/index.js.map +0 -1
  127. package/dist/__fixtures__/json.d.ts +0 -1226
  128. package/dist/__fixtures__/json.js +0 -1491
  129. package/dist/__fixtures__/json.js.map +0 -1
  130. package/dist/__fixtures__/numbers.d.ts +0 -5
  131. package/dist/__fixtures__/numbers.js +0 -56
  132. package/dist/__fixtures__/numbers.js.map +0 -1
  133. package/dist/assert.js.map +0 -1
  134. package/dist/base64.js.map +0 -1
  135. package/dist/bytes.js.map +0 -1
  136. package/dist/checksum.js +0 -7
  137. package/dist/checksum.js.map +0 -1
  138. package/dist/coercers.js.map +0 -1
  139. package/dist/collections.js +0 -109
  140. package/dist/collections.js.map +0 -1
  141. package/dist/encryption-types.js +0 -3
  142. package/dist/encryption-types.js.map +0 -1
  143. package/dist/hex.js +0 -81
  144. package/dist/hex.js.map +0 -1
  145. package/dist/hex.test-d.d.ts +0 -1
  146. package/dist/hex.test-d.js +0 -16
  147. package/dist/hex.test-d.js.map +0 -1
  148. package/dist/index.js +0 -34
  149. package/dist/index.js.map +0 -1
  150. package/dist/json.js +0 -346
  151. package/dist/json.js.map +0 -1
  152. package/dist/json.test-d.d.ts +0 -1
  153. package/dist/json.test-d.js +0 -62
  154. package/dist/json.test-d.js.map +0 -1
  155. package/dist/keyring.js +0 -3
  156. package/dist/keyring.js.map +0 -1
  157. package/dist/logging.js.map +0 -1
  158. package/dist/misc.js.map +0 -1
  159. package/dist/misc.test-d.d.ts +0 -1
  160. package/dist/misc.test-d.js +0 -97
  161. package/dist/misc.test-d.js.map +0 -1
  162. package/dist/number.js.map +0 -1
  163. package/dist/opaque.js +0 -3
  164. package/dist/opaque.js.map +0 -1
  165. package/dist/time.js +0 -67
  166. package/dist/time.js.map +0 -1
  167. package/dist/transaction-types.js +0 -3
  168. package/dist/transaction-types.js.map +0 -1
  169. package/dist/versions.js +0 -95
  170. package/dist/versions.js.map +0 -1
@@ -0,0 +1,157 @@
1
+ /**
2
+ * A {@link ReadonlyMap} that cannot be modified after instantiation.
3
+ * The implementation uses an inner map hidden via a private field, and the
4
+ * immutability guarantee relies on it being impossible to get a reference
5
+ * to this map.
6
+ */ "use strict";
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ function _export(target, all) {
11
+ for(var name in all)Object.defineProperty(target, name, {
12
+ enumerable: true,
13
+ get: all[name]
14
+ });
15
+ }
16
+ _export(exports, {
17
+ FrozenMap: function() {
18
+ return FrozenMap;
19
+ },
20
+ FrozenSet: function() {
21
+ return FrozenSet;
22
+ }
23
+ });
24
+ function _check_private_redeclaration(obj, privateCollection) {
25
+ if (privateCollection.has(obj)) {
26
+ throw new TypeError("Cannot initialize the same private elements twice on an object");
27
+ }
28
+ }
29
+ function _class_apply_descriptor_get(receiver, descriptor) {
30
+ if (descriptor.get) {
31
+ return descriptor.get.call(receiver);
32
+ }
33
+ return descriptor.value;
34
+ }
35
+ function _class_apply_descriptor_set(receiver, descriptor, value) {
36
+ if (descriptor.set) {
37
+ descriptor.set.call(receiver, value);
38
+ } else {
39
+ if (!descriptor.writable) {
40
+ throw new TypeError("attempted to set read only private field");
41
+ }
42
+ descriptor.value = value;
43
+ }
44
+ }
45
+ function _class_extract_field_descriptor(receiver, privateMap, action) {
46
+ if (!privateMap.has(receiver)) {
47
+ throw new TypeError("attempted to " + action + " private field on non-instance");
48
+ }
49
+ return privateMap.get(receiver);
50
+ }
51
+ function _class_private_field_get(receiver, privateMap) {
52
+ var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
53
+ return _class_apply_descriptor_get(receiver, descriptor);
54
+ }
55
+ function _class_private_field_init(obj, privateMap, value) {
56
+ _check_private_redeclaration(obj, privateMap);
57
+ privateMap.set(obj, value);
58
+ }
59
+ function _class_private_field_set(receiver, privateMap, value) {
60
+ var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
61
+ _class_apply_descriptor_set(receiver, descriptor, value);
62
+ return value;
63
+ }
64
+ var _map = /*#__PURE__*/ new WeakMap();
65
+ let _Symbol_iterator = Symbol.iterator;
66
+ class FrozenMap {
67
+ get size() {
68
+ return _class_private_field_get(this, _map).size;
69
+ }
70
+ [_Symbol_iterator]() {
71
+ return _class_private_field_get(this, _map)[Symbol.iterator]();
72
+ }
73
+ entries() {
74
+ return _class_private_field_get(this, _map).entries();
75
+ }
76
+ forEach(callbackfn, thisArg) {
77
+ // We have to wrap the specified callback in order to prevent it from
78
+ // receiving a reference to the inner map.
79
+ return _class_private_field_get(this, _map).forEach((value, key, _map)=>callbackfn.call(thisArg, value, key, this));
80
+ }
81
+ get(key) {
82
+ return _class_private_field_get(this, _map).get(key);
83
+ }
84
+ has(key) {
85
+ return _class_private_field_get(this, _map).has(key);
86
+ }
87
+ keys() {
88
+ return _class_private_field_get(this, _map).keys();
89
+ }
90
+ values() {
91
+ return _class_private_field_get(this, _map).values();
92
+ }
93
+ toString() {
94
+ return `FrozenMap(${this.size}) {${this.size > 0 ? ` ${[
95
+ ...this.entries()
96
+ ].map(([key, value])=>`${String(key)} => ${String(value)}`).join(', ')} ` : ''}}`;
97
+ }
98
+ constructor(entries){
99
+ _class_private_field_init(this, _map, {
100
+ writable: true,
101
+ value: void 0
102
+ });
103
+ _class_private_field_set(this, _map, new Map(entries));
104
+ Object.freeze(this);
105
+ }
106
+ }
107
+ var _set = /*#__PURE__*/ new WeakMap();
108
+ let _Symbol_iterator1 = Symbol.iterator;
109
+ /**
110
+ * A {@link ReadonlySet} that cannot be modified after instantiation.
111
+ * The implementation uses an inner set hidden via a private field, and the
112
+ * immutability guarantee relies on it being impossible to get a reference
113
+ * to this set.
114
+ */ class FrozenSet {
115
+ get size() {
116
+ return _class_private_field_get(this, _set).size;
117
+ }
118
+ [_Symbol_iterator1]() {
119
+ return _class_private_field_get(this, _set)[Symbol.iterator]();
120
+ }
121
+ entries() {
122
+ return _class_private_field_get(this, _set).entries();
123
+ }
124
+ forEach(callbackfn, thisArg) {
125
+ // We have to wrap the specified callback in order to prevent it from
126
+ // receiving a reference to the inner set.
127
+ return _class_private_field_get(this, _set).forEach((value, value2, _set)=>callbackfn.call(thisArg, value, value2, this));
128
+ }
129
+ has(value) {
130
+ return _class_private_field_get(this, _set).has(value);
131
+ }
132
+ keys() {
133
+ return _class_private_field_get(this, _set).keys();
134
+ }
135
+ values() {
136
+ return _class_private_field_get(this, _set).values();
137
+ }
138
+ toString() {
139
+ return `FrozenSet(${this.size}) {${this.size > 0 ? ` ${[
140
+ ...this.values()
141
+ ].map((member)=>String(member)).join(', ')} ` : ''}}`;
142
+ }
143
+ constructor(values){
144
+ _class_private_field_init(this, _set, {
145
+ writable: true,
146
+ value: void 0
147
+ });
148
+ _class_private_field_set(this, _set, new Set(values));
149
+ Object.freeze(this);
150
+ }
151
+ }
152
+ Object.freeze(FrozenMap);
153
+ Object.freeze(FrozenMap.prototype);
154
+ Object.freeze(FrozenSet);
155
+ Object.freeze(FrozenSet.prototype);
156
+
157
+ //# sourceMappingURL=collections.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/collections.ts"],"sourcesContent":["/**\n * A {@link ReadonlyMap} that cannot be modified after instantiation.\n * The implementation uses an inner map hidden via a private field, and the\n * immutability guarantee relies on it being impossible to get a reference\n * to this map.\n */\nclass FrozenMap<Key, Value> implements ReadonlyMap<Key, Value> {\n readonly #map: Map<Key, Value>;\n\n public get size() {\n return this.#map.size;\n }\n\n public [Symbol.iterator]() {\n return this.#map[Symbol.iterator]();\n }\n\n constructor(entries?: readonly (readonly [Key, Value])[] | null) {\n this.#map = new Map<Key, Value>(entries);\n Object.freeze(this);\n }\n\n public entries() {\n return this.#map.entries();\n }\n\n public forEach(\n callbackfn: (value: Value, key: Key, map: this) => void,\n thisArg?: any,\n ): void {\n // We have to wrap the specified callback in order to prevent it from\n // receiving a reference to the inner map.\n return this.#map.forEach((value: Value, key: Key, _map: unknown) =>\n callbackfn.call(thisArg, value, key, this),\n );\n }\n\n public get(key: Key) {\n return this.#map.get(key);\n }\n\n public has(key: Key) {\n return this.#map.has(key);\n }\n\n public keys() {\n return this.#map.keys();\n }\n\n public values() {\n return this.#map.values();\n }\n\n public toString(): string {\n return `FrozenMap(${this.size}) {${\n this.size > 0\n ? ` ${[...this.entries()]\n .map(([key, value]) => `${String(key)} => ${String(value)}`)\n .join(', ')} `\n : ''\n }}`;\n }\n}\n\n/**\n * A {@link ReadonlySet} that cannot be modified after instantiation.\n * The implementation uses an inner set hidden via a private field, and the\n * immutability guarantee relies on it being impossible to get a reference\n * to this set.\n */\nclass FrozenSet<Value> implements ReadonlySet<Value> {\n readonly #set: Set<Value>;\n\n public get size() {\n return this.#set.size;\n }\n\n public [Symbol.iterator]() {\n return this.#set[Symbol.iterator]();\n }\n\n constructor(values?: readonly Value[] | null) {\n this.#set = new Set<Value>(values);\n Object.freeze(this);\n }\n\n public entries() {\n return this.#set.entries();\n }\n\n public forEach(\n callbackfn: (value: Value, value2: Value, set: this) => void,\n thisArg?: any,\n ): void {\n // We have to wrap the specified callback in order to prevent it from\n // receiving a reference to the inner set.\n return this.#set.forEach((value: Value, value2: Value, _set: unknown) =>\n callbackfn.call(thisArg, value, value2, this),\n );\n }\n\n public has(value: Value) {\n return this.#set.has(value);\n }\n\n public keys() {\n return this.#set.keys();\n }\n\n public values() {\n return this.#set.values();\n }\n\n public toString(): string {\n return `FrozenSet(${this.size}) {${\n this.size > 0\n ? ` ${[...this.values()].map((member) => String(member)).join(', ')} `\n : ''\n }}`;\n }\n}\n\nObject.freeze(FrozenMap);\nObject.freeze(FrozenMap.prototype);\n\nObject.freeze(FrozenSet);\nObject.freeze(FrozenSet.prototype);\n\nexport { FrozenMap, FrozenSet };\n"],"names":["FrozenMap","FrozenSet","Symbol","iterator","size","map","entries","forEach","callbackfn","thisArg","value","key","_map","call","get","has","keys","values","toString","String","join","constructor","Map","Object","freeze","set","value2","_set","member","Set","prototype"],"mappings":"AAAA;;;;;CAKC;;;;;;;;;;;IA2HQA,SAAS;eAATA;;IAAWC,SAAS;eAATA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAzHT;IAMDC,mBAAAA,OAAOC,QAAQ;AAPzB,MAAMH;IAGJ,IAAWI,OAAO;QAChB,OAAO,yBAAA,IAAI,EAAEC,MAAID,IAAI;IACvB;IAEO,CAACF,iBAAgB,GAAG;QACzB,OAAO,yBAAA,IAAI,EAAEG,KAAG,CAACH,OAAOC,QAAQ,CAAC;IACnC;IAOOG,UAAU;QACf,OAAO,yBAAA,IAAI,EAAED,MAAIC,OAAO;IAC1B;IAEOC,QACLC,UAAuD,EACvDC,OAAa,EACP;QACN,qEAAqE;QACrE,0CAA0C;QAC1C,OAAO,yBAAA,IAAI,EAAEJ,MAAIE,OAAO,CAAC,CAACG,OAAcC,KAAUC,OAChDJ,WAAWK,IAAI,CAACJ,SAASC,OAAOC,KAAK,IAAI;IAE7C;IAEOG,IAAIH,GAAQ,EAAE;QACnB,OAAO,yBAAA,IAAI,EAAEN,MAAIS,GAAG,CAACH;IACvB;IAEOI,IAAIJ,GAAQ,EAAE;QACnB,OAAO,yBAAA,IAAI,EAAEN,MAAIU,GAAG,CAACJ;IACvB;IAEOK,OAAO;QACZ,OAAO,yBAAA,IAAI,EAAEX,MAAIW,IAAI;IACvB;IAEOC,SAAS;QACd,OAAO,yBAAA,IAAI,EAAEZ,MAAIY,MAAM;IACzB;IAEOC,WAAmB;QACxB,OAAO,CAAC,UAAU,EAAE,IAAI,CAACd,IAAI,CAAC,GAAG,EAC/B,IAAI,CAACA,IAAI,GAAG,IACR,CAAC,CAAC,EAAE;eAAI,IAAI,CAACE,OA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ACuB,SAAWT,OAAOS,SAASR,IAAI,CAAC,MAAM,CAAC,CAAC,GACpE,GACL,CAAC,CAAC;IACL;IAtCAC,YAAYJ,MAAgC,CAAE;QAV9C,gCAAS;;mBAAT,KAAA;;uCAWQQ,MAAM,IAAII,IAAWZ;QAC3BM,OAAOC,MAAM,CAAC,IAAI;IACpB;AAoCF;AAEAD,OAAOC,MAAM,CAACxB;AACduB,OAAOC,MAAM,CAACxB,UAAU8B,SAAS;AAEjCP,OAAOC,MAAM,CAACvB;AACdsB,OAAOC,MAAM,CAACvB,UAAU6B,SAAS"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+
6
+ //# sourceMappingURL=encryption-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/encryption-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ HexStruct: function() {
13
+ return HexStruct;
14
+ },
15
+ StrictHexStruct: function() {
16
+ return StrictHexStruct;
17
+ },
18
+ HexAddressStruct: function() {
19
+ return HexAddressStruct;
20
+ },
21
+ HexChecksumAddressStruct: function() {
22
+ return HexChecksumAddressStruct;
23
+ },
24
+ isHexString: function() {
25
+ return isHexString;
26
+ },
27
+ isStrictHexString: function() {
28
+ return isStrictHexString;
29
+ },
30
+ assertIsHexString: function() {
31
+ return assertIsHexString;
32
+ },
33
+ assertIsStrictHexString: function() {
34
+ return assertIsStrictHexString;
35
+ },
36
+ isValidHexAddress: function() {
37
+ return isValidHexAddress;
38
+ },
39
+ getChecksumAddress: function() {
40
+ return getChecksumAddress;
41
+ },
42
+ isValidChecksumAddress: function() {
43
+ return isValidChecksumAddress;
44
+ },
45
+ add0x: function() {
46
+ return add0x;
47
+ },
48
+ remove0x: function() {
49
+ return remove0x;
50
+ }
51
+ });
52
+ const _sha3 = require("@noble/hashes/sha3");
53
+ const _superstruct = require("superstruct");
54
+ const _assert = require("./assert");
55
+ const _bytes = require("./bytes");
56
+ const HexStruct = (0, _superstruct.pattern)((0, _superstruct.string)(), /^(?:0x)?[0-9a-f]+$/iu);
57
+ const StrictHexStruct = (0, _superstruct.pattern)((0, _superstruct.string)(), /^0x[0-9a-f]+$/iu);
58
+ const HexAddressStruct = (0, _superstruct.pattern)((0, _superstruct.string)(), /^0x[0-9a-f]{40}$/u);
59
+ const HexChecksumAddressStruct = (0, _superstruct.pattern)((0, _superstruct.string)(), /^0x[0-9a-fA-F]{40}$/u);
60
+ function isHexString(value) {
61
+ return (0, _superstruct.is)(value, HexStruct);
62
+ }
63
+ function isStrictHexString(value) {
64
+ return (0, _superstruct.is)(value, StrictHexStruct);
65
+ }
66
+ function assertIsHexString(value) {
67
+ (0, _assert.assert)(isHexString(value), 'Value must be a hexadecimal string.');
68
+ }
69
+ function assertIsStrictHexString(value) {
70
+ (0, _assert.assert)(isStrictHexString(value), 'Value must be a hexadecimal string, starting with "0x".');
71
+ }
72
+ function isValidHexAddress(possibleAddress) {
73
+ return (0, _superstruct.is)(possibleAddress, HexAddressStruct) || isValidChecksumAddress(possibleAddress);
74
+ }
75
+ function getChecksumAddress(address) {
76
+ (0, _assert.assert)((0, _superstruct.is)(address, HexChecksumAddressStruct), 'Invalid hex address.');
77
+ const unPrefixed = remove0x(address.toLowerCase());
78
+ const unPrefixedHash = remove0x((0, _bytes.bytesToHex)((0, _sha3.keccak_256)(unPrefixed)));
79
+ return `0x${unPrefixed.split('').map((character, nibbleIndex)=>{
80
+ const hashCharacter = unPrefixedHash[nibbleIndex];
81
+ (0, _assert.assert)((0, _superstruct.is)(hashCharacter, (0, _superstruct.string)()), 'Hash shorter than address.');
82
+ return parseInt(hashCharacter, 16) > 7 ? character.toUpperCase() : character;
83
+ }).join('')}`;
84
+ }
85
+ function isValidChecksumAddress(possibleChecksum) {
86
+ if (!(0, _superstruct.is)(possibleChecksum, HexChecksumAddressStruct)) {
87
+ return false;
88
+ }
89
+ return getChecksumAddress(possibleChecksum) === possibleChecksum;
90
+ }
91
+ function add0x(hexadecimal) {
92
+ if (hexadecimal.startsWith('0x')) {
93
+ return hexadecimal;
94
+ }
95
+ if (hexadecimal.startsWith('0X')) {
96
+ return `0x${hexadecimal.substring(2)}`;
97
+ }
98
+ return `0x${hexadecimal}`;
99
+ }
100
+ function remove0x(hexadecimal) {
101
+ if (hexadecimal.startsWith('0x') || hexadecimal.startsWith('0X')) {
102
+ return hexadecimal.substring(2);
103
+ }
104
+ return hexadecimal;
105
+ }
106
+
107
+ //# sourceMappingURL=hex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/hex.ts"],"sourcesContent":["import { keccak_256 as keccak256 } from '@noble/hashes/sha3';\nimport type { Struct } from 'superstruct';\nimport { is, pattern, string } from 'superstruct';\n\nimport { assert } from './assert';\nimport { bytesToHex } from './bytes';\n\nexport type Hex = `0x${string}`;\n\nexport const HexStruct = pattern(string(), /^(?:0x)?[0-9a-f]+$/iu);\nexport const StrictHexStruct = pattern(string(), /^0x[0-9a-f]+$/iu) as Struct<\n Hex,\n null\n>;\nexport const HexAddressStruct = pattern(\n string(),\n /^0x[0-9a-f]{40}$/u,\n) as Struct<Hex, null>;\nexport const HexChecksumAddressStruct = pattern(\n string(),\n /^0x[0-9a-fA-F]{40}$/u,\n) as Struct<Hex, null>;\n\n/**\n * Check if a string is a valid hex string.\n *\n * @param value - The value to check.\n * @returns Whether the value is a valid hex string.\n */\nexport function isHexString(value: unknown): value is string {\n return is(value, HexStruct);\n}\n\n/**\n * Strictly check if a string is a valid hex string. A valid hex string must\n * start with the \"0x\"-prefix.\n *\n * @param value - The value to check.\n * @returns Whether the value is a valid hex string.\n */\nexport function isStrictHexString(value: unknown): value is Hex {\n return is(value, StrictHexStruct);\n}\n\n/**\n * Assert that a value is a valid hex string.\n *\n * @param value - The value to check.\n * @throws If the value is not a valid hex string.\n */\nexport function assertIsHexString(value: unknown): asserts value is string {\n assert(isHexString(value), 'Value must be a hexadecimal string.');\n}\n\n/**\n * Assert that a value is a valid hex string. A valid hex string must start with\n * the \"0x\"-prefix.\n *\n * @param value - The value to check.\n * @throws If the value is not a valid hex string.\n */\nexport function assertIsStrictHexString(value: unknown): asserts value is Hex {\n assert(\n isStrictHexString(value),\n 'Value must be a hexadecimal string, starting with \"0x\".',\n );\n}\n\n/**\n * Validate that the passed prefixed hex string is an all-lowercase\n * hex address, or a valid mixed-case checksum address.\n *\n * @param possibleAddress - Input parameter to check against.\n * @returns Whether or not the input is a valid hex address.\n */\nexport function isValidHexAddress(possibleAddress: Hex) {\n return (\n is(possibleAddress, HexAddressStruct) ||\n isValidChecksumAddress(possibleAddress)\n );\n}\n\n/**\n * Encode a passed hex string as an ERC-55 mixed-case checksum address.\n *\n * @param address - The hex address to encode.\n * @returns The address encoded according to ERC-55.\n * @see https://eips.ethereum.org/EIPS/eip-55\n */\nexport function getChecksumAddress(address: Hex) {\n assert(is(address, HexChecksumAddressStruct), 'Invalid hex address.');\n const unPrefixed = remove0x(address.toLowerCase());\n const unPrefixedHash = remove0x(bytesToHex(keccak256(unPrefixed)));\n return `0x${unPrefixed\n .split('')\n .map((character, nibbleIndex) => {\n const hashCharacter = unPrefixedHash[nibbleIndex];\n assert(is(hashCharacter, string()), 'Hash shorter than address.');\n return parseInt(hashCharacter, 16) > 7\n ? character.toUpperCase()\n : character;\n })\n .join('')}`;\n}\n\n/**\n * Validate that the passed hex string is a valid ERC-55 mixed-case\n * checksum address.\n *\n * @param possibleChecksum - The hex address to check.\n * @returns True if the address is a checksum address.\n */\nexport function isValidChecksumAddress(possibleChecksum: Hex) {\n if (!is(possibleChecksum, HexChecksumAddressStruct)) {\n return false;\n }\n\n return getChecksumAddress(possibleChecksum) === possibleChecksum;\n}\n\n/**\n * Add the `0x`-prefix to a hexadecimal string. If the string already has the\n * prefix, it is returned as-is.\n *\n * @param hexadecimal - The hexadecimal string to add the prefix to.\n * @returns The prefixed hexadecimal string.\n */\nexport function add0x(hexadecimal: string): Hex {\n if (hexadecimal.startsWith('0x')) {\n return hexadecimal as Hex;\n }\n\n if (hexadecimal.startsWith('0X')) {\n return `0x${hexadecimal.substring(2)}`;\n }\n\n return `0x${hexadecimal}`;\n}\n\n/**\n * Remove the `0x`-prefix from a hexadecimal string. If the string doesn't have\n * the prefix, it is returned as-is.\n *\n * @param hexadecimal - The hexadecimal string to remove the prefix from.\n * @returns The un-prefixed hexadecimal string.\n */\nexport function remove0x(hexadecimal: string): string {\n if (hexadecimal.startsWith('0x') || hexadecimal.startsWith('0X')) {\n return hexadecimal.substring(2);\n }\n\n return hexadecimal;\n}\n"],"names":["HexStruct","StrictHexStruct","HexAddressStruct","HexChecksumAddressStruct","isHexString","isStrictHexString","assertIsHexString","assertIsStrictHexString","isValidHexAddress","getChecksumAddress","isValidChecksumAddress","add0x","remove0x","pattern","string","value","is","assert","possibleAddress","address","unPrefixed","toLowerCase","unPrefixedHash","bytesToHex","keccak256","split","map","character","nibbleIndex","hashCharacter","parseInt","toUpperCase","join","possibleChecksum","hexadecimal","startsWith","substring"],"mappings":";;;;;;;;;;;IASaA,SAAS;eAATA;;IACAC,eAAe;eAAfA;;IAIAC,gBAAgB;eAAhBA;;IAIAC,wBAAwB;eAAxBA;;IAWGC,WAAW;eAAXA;;IAWAC,iBAAiB;eAAjBA;;IAUAC,iBAAiB;eAAjBA;;IAWAC,uBAAuB;eAAvBA;;IAcAC,iBAAiB;eAAjBA;;IAcAC,kBAAkB;eAAlBA;;IAuBAC,sBAAsB;eAAtBA;;IAeAC,KAAK;eAALA;;IAmBAC,QAAQ;eAARA;;;sBAlJwB;6BAEJ;wBAEb;uBACI;AAIpB,MAAMZ,YAAYa,IAAAA,oBAAO,EAACC,IAAAA,mBAAM,KAAI;AACpC,MAAMb,kBAAkBY,IAAAA,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;IACvC,IAAIA,YAAYC,UAAU,CAAC,OAAO;QAChC,OAAOD;IACT;IAEA,IAAIA,YAAYC,UAAU,CAAC,OAAO;QAChC,OAAO,CAAC,EAAE,EAAED,YAAYE,SAAS,CAAC,GAAG,CAAC;IACxC;IAEA,OAAO,CAAC,EAAE,EAAEF,YAAY,CAAC;AAC3B;AASO,SAAStB,SAASsB,WAAmB;IAC1C,IAAIA,YAAYC,UAAU,CAAC,SAASD,YAAYC,UAAU,CAAC,OAAO;QAChE,OAAOD,YAAYE,SAAS,CAAC;IAC/B;IAEA,OAAOF;AACT"}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ _export_star(require("./assert"), exports);
6
+ _export_star(require("./base64"), exports);
7
+ _export_star(require("./bytes"), exports);
8
+ _export_star(require("./checksum"), exports);
9
+ _export_star(require("./coercers"), exports);
10
+ _export_star(require("./collections"), exports);
11
+ _export_star(require("./encryption-types"), exports);
12
+ _export_star(require("./hex"), exports);
13
+ _export_star(require("./json"), exports);
14
+ _export_star(require("./keyring"), exports);
15
+ _export_star(require("./logging"), exports);
16
+ _export_star(require("./misc"), exports);
17
+ _export_star(require("./number"), exports);
18
+ _export_star(require("./opaque"), exports);
19
+ _export_star(require("./time"), exports);
20
+ _export_star(require("./transaction-types"), exports);
21
+ _export_star(require("./versions"), exports);
22
+ function _export_star(from, to) {
23
+ Object.keys(from).forEach(function(k) {
24
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
25
+ Object.defineProperty(to, k, {
26
+ enumerable: true,
27
+ get: function() {
28
+ return from[k];
29
+ }
30
+ });
31
+ }
32
+ });
33
+ return from;
34
+ }
35
+
36
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from './assert';\nexport * from './base64';\nexport * from './bytes';\nexport * from './checksum';\nexport * from './coercers';\nexport * from './collections';\nexport * from './encryption-types';\nexport * from './hex';\nexport * from './json';\nexport * from './keyring';\nexport * from './logging';\nexport * from './misc';\nexport * from './number';\nexport * from './opaque';\nexport * from './time';\nexport * from './transaction-types';\nexport * from './versions';\n"],"names":[],"mappings":";;;;qBAAc;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA"}
@@ -0,0 +1,263 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ UnsafeJsonStruct: function() {
13
+ return UnsafeJsonStruct;
14
+ },
15
+ JsonStruct: function() {
16
+ return JsonStruct;
17
+ },
18
+ isValidJson: function() {
19
+ return isValidJson;
20
+ },
21
+ getSafeJson: function() {
22
+ return getSafeJson;
23
+ },
24
+ getJsonSize: function() {
25
+ return getJsonSize;
26
+ },
27
+ jsonrpc2: function() {
28
+ return jsonrpc2;
29
+ },
30
+ JsonRpcVersionStruct: function() {
31
+ return JsonRpcVersionStruct;
32
+ },
33
+ JsonRpcIdStruct: function() {
34
+ return JsonRpcIdStruct;
35
+ },
36
+ JsonRpcErrorStruct: function() {
37
+ return JsonRpcErrorStruct;
38
+ },
39
+ JsonRpcParamsStruct: function() {
40
+ return JsonRpcParamsStruct;
41
+ },
42
+ JsonRpcRequestStruct: function() {
43
+ return JsonRpcRequestStruct;
44
+ },
45
+ JsonRpcNotificationStruct: function() {
46
+ return JsonRpcNotificationStruct;
47
+ },
48
+ isJsonRpcNotification: function() {
49
+ return isJsonRpcNotification;
50
+ },
51
+ assertIsJsonRpcNotification: function() {
52
+ return assertIsJsonRpcNotification;
53
+ },
54
+ isJsonRpcRequest: function() {
55
+ return isJsonRpcRequest;
56
+ },
57
+ assertIsJsonRpcRequest: function() {
58
+ return assertIsJsonRpcRequest;
59
+ },
60
+ PendingJsonRpcResponseStruct: function() {
61
+ return PendingJsonRpcResponseStruct;
62
+ },
63
+ JsonRpcSuccessStruct: function() {
64
+ return JsonRpcSuccessStruct;
65
+ },
66
+ JsonRpcFailureStruct: function() {
67
+ return JsonRpcFailureStruct;
68
+ },
69
+ JsonRpcResponseStruct: function() {
70
+ return JsonRpcResponseStruct;
71
+ },
72
+ isPendingJsonRpcResponse: function() {
73
+ return isPendingJsonRpcResponse;
74
+ },
75
+ assertIsPendingJsonRpcResponse: function() {
76
+ return assertIsPendingJsonRpcResponse;
77
+ },
78
+ isJsonRpcResponse: function() {
79
+ return isJsonRpcResponse;
80
+ },
81
+ assertIsJsonRpcResponse: function() {
82
+ return assertIsJsonRpcResponse;
83
+ },
84
+ isJsonRpcSuccess: function() {
85
+ return isJsonRpcSuccess;
86
+ },
87
+ assertIsJsonRpcSuccess: function() {
88
+ return assertIsJsonRpcSuccess;
89
+ },
90
+ isJsonRpcFailure: function() {
91
+ return isJsonRpcFailure;
92
+ },
93
+ assertIsJsonRpcFailure: function() {
94
+ return assertIsJsonRpcFailure;
95
+ },
96
+ isJsonRpcError: function() {
97
+ return isJsonRpcError;
98
+ },
99
+ assertIsJsonRpcError: function() {
100
+ return assertIsJsonRpcError;
101
+ },
102
+ getJsonRpcIdValidator: function() {
103
+ return getJsonRpcIdValidator;
104
+ }
105
+ });
106
+ const _superstruct = require("superstruct");
107
+ const _assert = require("./assert");
108
+ /**
109
+ * A struct to check if the given value is finite number. Superstruct's
110
+ * `number()` struct does not check if the value is finite.
111
+ *
112
+ * @returns A struct to check if the given value is finite number.
113
+ */ const finiteNumber = ()=>(0, _superstruct.define)('finite number', (value)=>{
114
+ return (0, _superstruct.is)(value, (0, _superstruct.number)()) && Number.isFinite(value);
115
+ });
116
+ const UnsafeJsonStruct = (0, _superstruct.union)([
117
+ (0, _superstruct.literal)(null),
118
+ (0, _superstruct.boolean)(),
119
+ finiteNumber(),
120
+ (0, _superstruct.string)(),
121
+ (0, _superstruct.array)((0, _superstruct.lazy)(()=>UnsafeJsonStruct)),
122
+ (0, _superstruct.record)((0, _superstruct.string)(), (0, _superstruct.lazy)(()=>UnsafeJsonStruct))
123
+ ]);
124
+ const JsonStruct = (0, _superstruct.coerce)(UnsafeJsonStruct, (0, _superstruct.any)(), (value)=>{
125
+ (0, _assert.assertStruct)(value, UnsafeJsonStruct);
126
+ return JSON.parse(JSON.stringify(value, (propKey, propValue)=>{
127
+ // Strip __proto__ and constructor properties to prevent prototype pollution.
128
+ if (propKey === '__proto__' || propKey === 'constructor') {
129
+ return undefined;
130
+ }
131
+ return propValue;
132
+ }));
133
+ });
134
+ function isValidJson(value) {
135
+ try {
136
+ getSafeJson(value);
137
+ return true;
138
+ } catch {
139
+ return false;
140
+ }
141
+ }
142
+ function getSafeJson(value) {
143
+ return (0, _superstruct.create)(value, JsonStruct);
144
+ }
145
+ function getJsonSize(value) {
146
+ (0, _assert.assertStruct)(value, JsonStruct, 'Invalid JSON value');
147
+ const json = JSON.stringify(value);
148
+ return new TextEncoder().encode(json).byteLength;
149
+ }
150
+ const jsonrpc2 = '2.0';
151
+ const JsonRpcVersionStruct = (0, _superstruct.literal)(jsonrpc2);
152
+ const JsonRpcIdStruct = (0, _superstruct.nullable)((0, _superstruct.union)([
153
+ (0, _superstruct.number)(),
154
+ (0, _superstruct.string)()
155
+ ]));
156
+ const JsonRpcErrorStruct = (0, _superstruct.object)({
157
+ code: (0, _superstruct.integer)(),
158
+ message: (0, _superstruct.string)(),
159
+ data: (0, _superstruct.optional)(JsonStruct),
160
+ stack: (0, _superstruct.optional)((0, _superstruct.string)())
161
+ });
162
+ const JsonRpcParamsStruct = (0, _superstruct.optional)((0, _superstruct.union)([
163
+ (0, _superstruct.record)((0, _superstruct.string)(), JsonStruct),
164
+ (0, _superstruct.array)(JsonStruct)
165
+ ]));
166
+ const JsonRpcRequestStruct = (0, _superstruct.object)({
167
+ id: JsonRpcIdStruct,
168
+ jsonrpc: JsonRpcVersionStruct,
169
+ method: (0, _superstruct.string)(),
170
+ params: JsonRpcParamsStruct
171
+ });
172
+ const JsonRpcNotificationStruct = (0, _superstruct.omit)(JsonRpcRequestStruct, [
173
+ 'id'
174
+ ]);
175
+ function isJsonRpcNotification(value) {
176
+ return (0, _superstruct.is)(value, JsonRpcNotificationStruct);
177
+ }
178
+ function assertIsJsonRpcNotification(value, // eslint-disable-next-line @typescript-eslint/naming-convention
179
+ ErrorWrapper) {
180
+ (0, _assert.assertStruct)(value, JsonRpcNotificationStruct, 'Invalid JSON-RPC notification', ErrorWrapper);
181
+ }
182
+ function isJsonRpcRequest(value) {
183
+ return (0, _superstruct.is)(value, JsonRpcRequestStruct);
184
+ }
185
+ function assertIsJsonRpcRequest(value, // eslint-disable-next-line @typescript-eslint/naming-convention
186
+ ErrorWrapper) {
187
+ (0, _assert.assertStruct)(value, JsonRpcRequestStruct, 'Invalid JSON-RPC request', ErrorWrapper);
188
+ }
189
+ const PendingJsonRpcResponseStruct = (0, _superstruct.object)({
190
+ id: JsonRpcIdStruct,
191
+ jsonrpc: JsonRpcVersionStruct,
192
+ result: (0, _superstruct.optional)((0, _superstruct.unknown)()),
193
+ error: (0, _superstruct.optional)(JsonRpcErrorStruct)
194
+ });
195
+ const JsonRpcSuccessStruct = (0, _superstruct.object)({
196
+ id: JsonRpcIdStruct,
197
+ jsonrpc: JsonRpcVersionStruct,
198
+ result: JsonStruct
199
+ });
200
+ const JsonRpcFailureStruct = (0, _superstruct.object)({
201
+ id: JsonRpcIdStruct,
202
+ jsonrpc: JsonRpcVersionStruct,
203
+ error: JsonRpcErrorStruct
204
+ });
205
+ const JsonRpcResponseStruct = (0, _superstruct.union)([
206
+ JsonRpcSuccessStruct,
207
+ JsonRpcFailureStruct
208
+ ]);
209
+ function isPendingJsonRpcResponse(response) {
210
+ return (0, _superstruct.is)(response, PendingJsonRpcResponseStruct);
211
+ }
212
+ function assertIsPendingJsonRpcResponse(response, // eslint-disable-next-line @typescript-eslint/naming-convention
213
+ ErrorWrapper) {
214
+ (0, _assert.assertStruct)(response, PendingJsonRpcResponseStruct, 'Invalid pending JSON-RPC response', ErrorWrapper);
215
+ }
216
+ function isJsonRpcResponse(response) {
217
+ return (0, _superstruct.is)(response, JsonRpcResponseStruct);
218
+ }
219
+ function assertIsJsonRpcResponse(value, // eslint-disable-next-line @typescript-eslint/naming-convention
220
+ ErrorWrapper) {
221
+ (0, _assert.assertStruct)(value, JsonRpcResponseStruct, 'Invalid JSON-RPC response', ErrorWrapper);
222
+ }
223
+ function isJsonRpcSuccess(value) {
224
+ return (0, _superstruct.is)(value, JsonRpcSuccessStruct);
225
+ }
226
+ function assertIsJsonRpcSuccess(value, // eslint-disable-next-line @typescript-eslint/naming-convention
227
+ ErrorWrapper) {
228
+ (0, _assert.assertStruct)(value, JsonRpcSuccessStruct, 'Invalid JSON-RPC success response', ErrorWrapper);
229
+ }
230
+ function isJsonRpcFailure(value) {
231
+ return (0, _superstruct.is)(value, JsonRpcFailureStruct);
232
+ }
233
+ function assertIsJsonRpcFailure(value, // eslint-disable-next-line @typescript-eslint/naming-convention
234
+ ErrorWrapper) {
235
+ (0, _assert.assertStruct)(value, JsonRpcFailureStruct, 'Invalid JSON-RPC failure response', ErrorWrapper);
236
+ }
237
+ function isJsonRpcError(value) {
238
+ return (0, _superstruct.is)(value, JsonRpcErrorStruct);
239
+ }
240
+ function assertIsJsonRpcError(value, // eslint-disable-next-line @typescript-eslint/naming-convention
241
+ ErrorWrapper) {
242
+ (0, _assert.assertStruct)(value, JsonRpcErrorStruct, 'Invalid JSON-RPC error', ErrorWrapper);
243
+ }
244
+ function getJsonRpcIdValidator(options) {
245
+ const { permitEmptyString, permitFractions, permitNull } = {
246
+ permitEmptyString: true,
247
+ permitFractions: false,
248
+ permitNull: true,
249
+ ...options
250
+ };
251
+ /**
252
+ * Type guard for {@link JsonRpcId}.
253
+ *
254
+ * @param id - The JSON-RPC ID value to check.
255
+ * @returns Whether the given ID is valid per the options given to the
256
+ * factory.
257
+ */ const isValidJsonRpcId = (id)=>{
258
+ return Boolean(typeof id === 'number' && (permitFractions || Number.isInteger(id)) || typeof id === 'string' && (permitEmptyString || id.length > 0) || permitNull && id === null);
259
+ };
260
+ return isValidJsonRpcId;
261
+ }
262
+
263
+ //# sourceMappingURL=json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/json.ts"],"sourcesContent":["import type { Infer, Struct } from 'superstruct';\nimport {\n any,\n array,\n boolean,\n coerce,\n create,\n define,\n integer,\n is,\n lazy,\n literal,\n nullable,\n number,\n object,\n omit,\n optional,\n record,\n string,\n union,\n unknown,\n} from 'superstruct';\n\nimport type { AssertionErrorConstructor } from './assert';\nimport { assertStruct } from './assert';\n\n/**\n * Any JSON-compatible value.\n */\nexport type Json =\n | null\n | boolean\n | number\n | string\n | Json[]\n | { [prop: string]: Json };\n\n/**\n * A struct to check if the given value is finite number. Superstruct's\n * `number()` struct does not check if the value is finite.\n *\n * @returns A struct to check if the given value is finite number.\n */\nconst finiteNumber = () =>\n define<number>('finite number', (value) => {\n return is(value, number()) && Number.isFinite(value);\n });\n\n/**\n * A struct to check if the given value is a valid JSON-serializable value.\n *\n * Note that this struct is unsafe. For safe validation, use {@link JsonStruct}.\n */\n// We cannot infer the type of the struct, because it is recursive.\nexport const UnsafeJsonStruct: Struct<Json> = union([\n literal(null),\n boolean(),\n finiteNumber(),\n string(),\n array(lazy(() => UnsafeJsonStruct)),\n record(\n string(),\n lazy(() => UnsafeJsonStruct),\n ),\n]);\n\n/**\n * A struct to check if the given value is a valid JSON-serializable value.\n *\n * This struct sanitizes the value before validating it, so that it is safe to\n * use with untrusted input.\n */\nexport const JsonStruct = coerce(UnsafeJsonStruct, any(), (value) => {\n assertStruct(value, UnsafeJsonStruct);\n return JSON.parse(\n JSON.stringify(value, (propKey, propValue) => {\n // Strip __proto__ and constructor properties to prevent prototype pollution.\n if (propKey === '__proto__' || propKey === 'constructor') {\n return undefined;\n }\n return propValue;\n }),\n );\n});\n\n/**\n * Check if the given value is a valid {@link Json} value, i.e., a value that is\n * serializable to JSON.\n *\n * @param value - The value to check.\n * @returns Whether the value is a valid {@link Json} value.\n */\nexport function isValidJson(value: unknown): value is Json {\n try {\n getSafeJson(value);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Validate and return sanitized JSON.\n *\n * Note:\n * This function uses sanitized JsonStruct for validation\n * that applies stringify and then parse of a value provided\n * to ensure that there are no getters which can have side effects\n * that can cause security issues.\n *\n * @param value - JSON structure to be processed.\n * @returns Sanitized JSON structure.\n */\nexport function getSafeJson<Type extends Json = Json>(value: unknown): Type {\n return create(value, JsonStruct) as Type;\n}\n\n/**\n * Get the size of a JSON value in bytes. This also validates the value.\n *\n * @param value - The JSON value to get the size of.\n * @returns The size of the JSON value in bytes.\n */\nexport function getJsonSize(value: unknown): number {\n assertStruct(value, JsonStruct, 'Invalid JSON value');\n\n const json = JSON.stringify(value);\n return new TextEncoder().encode(json).byteLength;\n}\n\n/**\n * The string '2.0'.\n */\nexport const jsonrpc2 = '2.0' as const;\nexport const JsonRpcVersionStruct = literal(jsonrpc2);\n\n/**\n * A String specifying the version of the JSON-RPC protocol.\n * MUST be exactly \"2.0\".\n */\nexport type JsonRpcVersion2 = typeof jsonrpc2;\n\nexport const JsonRpcIdStruct = nullable(union([number(), string()]));\n\n/**\n * An identifier established by the Client that MUST contain a String, Number,\n * or NULL value if included. If it is not included it is assumed to be a\n * notification. The value SHOULD normally not be Null and Numbers SHOULD\n * NOT contain fractional parts.\n */\nexport type JsonRpcId = Infer<typeof JsonRpcIdStruct>;\n\nexport const JsonRpcErrorStruct = object({\n code: integer(),\n message: string(),\n data: optional(JsonStruct),\n stack: optional(string()),\n});\n\n/**\n * Mark a certain key of a type as optional.\n */\nexport type OptionalField<\n Type extends Record<string, unknown>,\n Key extends keyof Type,\n> = Omit<Type, Key> & Partial<Pick<Type, Key>>;\n\n/**\n * A JSON-RPC error object.\n *\n * Note that TypeScript infers `unknown | undefined` as `unknown`, meaning that\n * the `data` field is not optional. To make it optional, we use the\n * `OptionalField` helper, to explicitly make it optional.\n */\nexport type JsonRpcError = OptionalField<\n Infer<typeof JsonRpcErrorStruct>,\n 'data'\n>;\n\nexport const JsonRpcParamsStruct = optional(\n union([record(string(), JsonStruct), array(JsonStruct)]),\n);\nexport type JsonRpcParams = Infer<typeof JsonRpcParamsStruct>;\n\nexport const JsonRpcRequestStruct = object({\n id: JsonRpcIdStruct,\n jsonrpc: JsonRpcVersionStruct,\n method: string(),\n params: JsonRpcParamsStruct,\n});\n\nexport type InferWithParams<\n Type extends Struct<any>,\n Params extends JsonRpcParams,\n> = Omit<Infer<Type>, 'params'> &\n (keyof Params extends undefined\n ? {\n params?: Params;\n }\n : {\n params: Params;\n });\n\n/**\n * A JSON-RPC request object.\n */\nexport type JsonRpcRequest<Params extends JsonRpcParams = JsonRpcParams> =\n InferWithParams<typeof JsonRpcRequestStruct, Params>;\n\nexport const JsonRpcNotificationStruct = omit(JsonRpcRequestStruct, ['id']);\n\n/**\n * A JSON-RPC notification object.\n */\nexport type JsonRpcNotification<Params extends JsonRpcParams = JsonRpcParams> =\n InferWithParams<typeof JsonRpcNotificationStruct, Params>;\n\n/**\n * Check if the given value is a valid {@link JsonRpcNotification} object.\n *\n * @param value - The value to check.\n * @returns Whether the given value is a valid {@link JsonRpcNotification}\n * object.\n */\nexport function isJsonRpcNotification(\n value: unknown,\n): value is JsonRpcNotification {\n return is(value, JsonRpcNotificationStruct);\n}\n\n/**\n * Assert that the given value is a valid {@link JsonRpcNotification} object.\n *\n * @param value - The value to check.\n * @param ErrorWrapper - The error class to throw if the assertion fails.\n * Defaults to {@link AssertionError}.\n * @throws If the given value is not a valid {@link JsonRpcNotification} object.\n */\nexport function assertIsJsonRpcNotification(\n value: unknown,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n ErrorWrapper?: AssertionErrorConstructor,\n): asserts value is JsonRpcNotification {\n assertStruct(\n value,\n JsonRpcNotificationStruct,\n 'Invalid JSON-RPC notification',\n ErrorWrapper,\n );\n}\n\n/**\n * Check if the given value is a valid {@link JsonRpcRequest} object.\n *\n * @param value - The value to check.\n * @returns Whether the given value is a valid {@link JsonRpcRequest} object.\n */\nexport function isJsonRpcRequest(value: unknown): value is JsonRpcRequest {\n return is(value, JsonRpcRequestStruct);\n}\n\n/**\n * Assert that the given value is a valid {@link JsonRpcRequest} object.\n *\n * @param value - The JSON-RPC request or notification to check.\n * @param ErrorWrapper - The error class to throw if the assertion fails.\n * Defaults to {@link AssertionError}.\n * @throws If the given value is not a valid {@link JsonRpcRequest} object.\n */\nexport function assertIsJsonRpcRequest(\n value: unknown,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n ErrorWrapper?: AssertionErrorConstructor,\n): asserts value is JsonRpcRequest {\n assertStruct(\n value,\n JsonRpcRequestStruct,\n 'Invalid JSON-RPC request',\n ErrorWrapper,\n );\n}\n\nexport const PendingJsonRpcResponseStruct = object({\n id: JsonRpcIdStruct,\n jsonrpc: JsonRpcVersionStruct,\n result: optional(unknown()),\n error: optional(JsonRpcErrorStruct),\n});\n\n/**\n * A JSON-RPC response object that has not yet been resolved.\n */\nexport type PendingJsonRpcResponse<Result extends Json> = Omit<\n Infer<typeof PendingJsonRpcResponseStruct>,\n 'result'\n> & {\n result?: Result;\n};\n\nexport const JsonRpcSuccessStruct = object({\n id: JsonRpcIdStruct,\n jsonrpc: JsonRpcVersionStruct,\n result: JsonStruct,\n});\n\n/**\n * A successful JSON-RPC response object.\n */\nexport type JsonRpcSuccess<Result extends Json> = Omit<\n Infer<typeof JsonRpcSuccessStruct>,\n 'result'\n> & {\n result: Result;\n};\n\nexport const JsonRpcFailureStruct = object({\n id: JsonRpcIdStruct,\n jsonrpc: JsonRpcVersionStruct,\n error: JsonRpcErrorStruct as Struct<JsonRpcError>,\n});\n\n/**\n * A failed JSON-RPC response object.\n */\nexport type JsonRpcFailure = Infer<typeof JsonRpcFailureStruct>;\n\nexport const JsonRpcResponseStruct = union([\n JsonRpcSuccessStruct,\n JsonRpcFailureStruct,\n]);\n\n/**\n * A JSON-RPC response object. Must be checked to determine whether it's a\n * success or failure.\n *\n * @template Result - The type of the result.\n */\nexport type JsonRpcResponse<Result extends Json> =\n | JsonRpcSuccess<Result>\n | JsonRpcFailure;\n\n/**\n * Type guard to check whether specified JSON-RPC response is a\n * {@link PendingJsonRpcResponse}.\n *\n * @param response - The JSON-RPC response to check.\n * @returns Whether the specified JSON-RPC response is pending.\n */\nexport function isPendingJsonRpcResponse(\n response: unknown,\n): response is PendingJsonRpcResponse<Json> {\n return is(response, PendingJsonRpcResponseStruct);\n}\n\n/**\n * Assert that the given value is a valid {@link PendingJsonRpcResponse} object.\n *\n * @param response - The JSON-RPC response to check.\n * @param ErrorWrapper - The error class to throw if the assertion fails.\n * Defaults to {@link AssertionError}.\n * @throws If the given value is not a valid {@link PendingJsonRpcResponse}\n * object.\n */\nexport function assertIsPendingJsonRpcResponse(\n response: unknown,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n ErrorWrapper?: AssertionErrorConstructor,\n): asserts response is PendingJsonRpcResponse<Json> {\n assertStruct(\n response,\n PendingJsonRpcResponseStruct,\n 'Invalid pending JSON-RPC response',\n ErrorWrapper,\n );\n}\n\n/**\n * Type guard to check if a value is a {@link JsonRpcResponse}.\n *\n * @param response - The object to check.\n * @returns Whether the object is a JsonRpcResponse.\n */\nexport function isJsonRpcResponse(\n response: unknown,\n): response is JsonRpcResponse<Json> {\n return is(response, JsonRpcResponseStruct);\n}\n\n/**\n * Assert that the given value is a valid {@link JsonRpcResponse} object.\n *\n * @param value - The value to check.\n * @param ErrorWrapper - The error class to throw if the assertion fails.\n * Defaults to {@link AssertionError}.\n * @throws If the given value is not a valid {@link JsonRpcResponse} object.\n */\nexport function assertIsJsonRpcResponse(\n value: unknown,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n ErrorWrapper?: AssertionErrorConstructor,\n): asserts value is JsonRpcResponse<Json> {\n assertStruct(\n value,\n JsonRpcResponseStruct,\n 'Invalid JSON-RPC response',\n ErrorWrapper,\n );\n}\n\n/**\n * Check if the given value is a valid {@link JsonRpcSuccess} object.\n *\n * @param value - The value to check.\n * @returns Whether the given value is a valid {@link JsonRpcSuccess} object.\n */\nexport function isJsonRpcSuccess(\n value: unknown,\n): value is JsonRpcSuccess<Json> {\n return is(value, JsonRpcSuccessStruct);\n}\n\n/**\n * Assert that the given value is a valid {@link JsonRpcSuccess} object.\n *\n * @param value - The value to check.\n * @param ErrorWrapper - The error class to throw if the assertion fails.\n * Defaults to {@link AssertionError}.\n * @throws If the given value is not a valid {@link JsonRpcSuccess} object.\n */\nexport function assertIsJsonRpcSuccess(\n value: unknown,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n ErrorWrapper?: AssertionErrorConstructor,\n): asserts value is JsonRpcSuccess<Json> {\n assertStruct(\n value,\n JsonRpcSuccessStruct,\n 'Invalid JSON-RPC success response',\n ErrorWrapper,\n );\n}\n\n/**\n * Check if the given value is a valid {@link JsonRpcFailure} object.\n *\n * @param value - The value to check.\n * @returns Whether the given value is a valid {@link JsonRpcFailure} object.\n */\nexport function isJsonRpcFailure(value: unknown): value is JsonRpcFailure {\n return is(value, JsonRpcFailureStruct);\n}\n\n/**\n * Assert that the given value is a valid {@link JsonRpcFailure} object.\n *\n * @param value - The value to check.\n * @param ErrorWrapper - The error class to throw if the assertion fails.\n * Defaults to {@link AssertionError}.\n * @throws If the given value is not a valid {@link JsonRpcFailure} object.\n */\nexport function assertIsJsonRpcFailure(\n value: unknown,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n ErrorWrapper?: AssertionErrorConstructor,\n): asserts value is JsonRpcFailure {\n assertStruct(\n value,\n JsonRpcFailureStruct,\n 'Invalid JSON-RPC failure response',\n ErrorWrapper,\n );\n}\n\n/**\n * Check if the given value is a valid {@link JsonRpcError} object.\n *\n * @param value - The value to check.\n * @returns Whether the given value is a valid {@link JsonRpcError} object.\n */\nexport function isJsonRpcError(value: unknown): value is JsonRpcError {\n return is(value, JsonRpcErrorStruct);\n}\n\n/**\n * Assert that the given value is a valid {@link JsonRpcError} object.\n *\n * @param value - The value to check.\n * @param ErrorWrapper - The error class to throw if the assertion fails.\n * Defaults to {@link AssertionError}.\n * @throws If the given value is not a valid {@link JsonRpcError} object.\n */\nexport function assertIsJsonRpcError(\n value: unknown,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n ErrorWrapper?: AssertionErrorConstructor,\n): asserts value is JsonRpcError {\n assertStruct(\n value,\n JsonRpcErrorStruct,\n 'Invalid JSON-RPC error',\n ErrorWrapper,\n );\n}\n\ntype JsonRpcValidatorOptions = {\n permitEmptyString?: boolean;\n permitFractions?: boolean;\n permitNull?: boolean;\n};\n\n/**\n * Gets a function for validating JSON-RPC request / response `id` values.\n *\n * By manipulating the options of this factory, you can control the behavior\n * of the resulting validator for some edge cases. This is useful because e.g.\n * `null` should sometimes but not always be permitted.\n *\n * Note that the empty string (`''`) is always permitted by the JSON-RPC\n * specification, but that kind of sucks and you may want to forbid it in some\n * instances anyway.\n *\n * For more details, see the\n * [JSON-RPC Specification](https://www.jsonrpc.org/specification).\n *\n * @param options - An options object.\n * @param options.permitEmptyString - Whether the empty string (i.e. `''`)\n * should be treated as a valid ID. Default: `true`\n * @param options.permitFractions - Whether fractional numbers (e.g. `1.2`)\n * should be treated as valid IDs. Default: `false`\n * @param options.permitNull - Whether `null` should be treated as a valid ID.\n * Default: `true`\n * @returns The JSON-RPC ID validator function.\n */\nexport function getJsonRpcIdValidator(options?: JsonRpcValidatorOptions) {\n const { permitEmptyString, permitFractions, permitNull } = {\n permitEmptyString: true,\n permitFractions: false,\n permitNull: true,\n ...options,\n };\n\n /**\n * Type guard for {@link JsonRpcId}.\n *\n * @param id - The JSON-RPC ID value to check.\n * @returns Whether the given ID is valid per the options given to the\n * factory.\n */\n const isValidJsonRpcId = (id: unknown): id is JsonRpcId => {\n return Boolean(\n (typeof id === 'number' && (permitFractions || Number.isInteger(id))) ||\n (typeof id === 'string' && (permitEmptyString || id.length > 0)) ||\n (permitNull && id === null),\n );\n };\n\n return isValidJsonRpcId;\n}\n"],"names":["UnsafeJsonStruct","JsonStruct","isValidJson","getSafeJson","getJsonSize","jsonrpc2","JsonRpcVersionStruct","JsonRpcIdStruct","JsonRpcErrorStruct","JsonRpcParamsStruct","JsonRpcRequestStruct","JsonRpcNotificationStruct","isJsonRpcNotification","assertIsJsonRpcNotification","isJsonRpcRequest","assertIsJsonRpcRequest","PendingJsonRpcResponseStruct","JsonRpcSuccessStruct","JsonRpcFailureStruct","JsonRpcResponseStruct","isPendingJsonRpcResponse","assertIsPendingJsonRpcResponse","isJsonRpcResponse","assertIsJsonRpcResponse","isJsonRpcSuccess","assertIsJsonRpcSuccess","isJsonRpcFailure","assertIsJsonRpcFailure","isJsonRpcError","assertIsJsonRpcError","getJsonRpcIdValidator","finiteNumber","define","value","is","number","Number","isFinite","union","literal","boolean","string","array","lazy","record","coerce","any","assertStruct","JSON","parse","stringify","propKey","propValue","undefined","create","json","TextEncoder","encode","byteLength","nullable","object","code","integer","message","data","optional","stack","id","jsonrpc","method","params","omit","ErrorWrapper","result","unknown","error","response","options","permitEmptyString","permitFractions","permitNull","isValidJsonRpcId","Boolean","isInteger","length"],"mappings":";;;;;;;;;;;IAsDaA,gBAAgB;eAAhBA;;IAkBAC,UAAU;eAAVA;;IAoBGC,WAAW;eAAXA;;IAqBAC,WAAW;eAAXA;;IAUAC,WAAW;eAAXA;;IAUHC,QAAQ;eAARA;;IACAC,oBAAoB;eAApBA;;IAQAC,eAAe;eAAfA;;IAUAC,kBAAkB;eAAlBA;;IA2BAC,mBAAmB;eAAnBA;;IAKAC,oBAAoB;eAApBA;;IAyBAC,yBAAyB;eAAzBA;;IAeGC,qBAAqB;eAArBA;;IAcAC,2BAA2B;eAA3BA;;IAmBAC,gBAAgB;eAAhBA;;IAYAC,sBAAsB;eAAtBA;;IAaHC,4BAA4B;eAA5BA;;IAiBAC,oBAAoB;eAApBA;;IAgBAC,oBAA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A,qCACAsD;AAEJ;AAQO,SAAS5C,eAAeK,KAAc;IAC3C,OAAOC,IAAAA,eAAE,EAACD,OAAOzB;AACnB;AAUO,SAASqB,qBACdI,KAAc,EACd,gEAAgE;AAChEuC,YAAwC;IAExCzB,IAAAA,oBAAY,EACVd,OACAzB,oBACA,0BACAgE;AAEJ;AA+BO,SAAS1C,sBAAsB+C,OAAiC;IACrE,MAAM,EAAEC,iBAAiB,EAAEC,eAAe,EAAEC,UAAU,EAAE,GAAG;QACzDF,mBAAmB;QACnBC,iBAAiB;QACjBC,YAAY;QACZ,GAAGH,OAAO;IACZ;IAEA;;;;;;GAMC,GACD,MAAMI,mBAAmB,CAACd;QACxB,OAAOe,QACL,AAAC,OAAOf,OAAO,YAAaY,CAAAA,mBAAmB3C,OAAO+C,SAAS,CAAChB,GAAE,KAC/D,OAAOA,OAAO,YAAaW,CAAAA,qBAAqBX,GAAGiB,MAAM,GAAG,CAAA,KAC5DJ,cAAcb,OAAO;IAE5B;IAEA,OAAOc;AACT"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+
6
+ //# sourceMappingURL=keyring.js.map