@metamask/keyring-api 11.1.0 → 13.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 (314) hide show
  1. package/CHANGELOG.md +25 -1
  2. package/dist/api/account.cjs +7 -4
  3. package/dist/api/account.cjs.map +1 -1
  4. package/dist/api/account.d.cts +6 -1
  5. package/dist/api/account.d.cts.map +1 -1
  6. package/dist/api/account.d.mts +6 -1
  7. package/dist/api/account.d.mts.map +1 -1
  8. package/dist/api/account.mjs +7 -4
  9. package/dist/api/account.mjs.map +1 -1
  10. package/dist/api/asset.cjs +5 -6
  11. package/dist/api/asset.cjs.map +1 -1
  12. package/dist/api/asset.d.cts +2 -2
  13. package/dist/api/asset.d.cts.map +1 -1
  14. package/dist/api/asset.d.mts +2 -2
  15. package/dist/api/asset.d.mts.map +1 -1
  16. package/dist/api/asset.mjs +1 -2
  17. package/dist/api/asset.mjs.map +1 -1
  18. package/dist/api/balance.cjs +3 -4
  19. package/dist/api/balance.cjs.map +1 -1
  20. package/dist/api/balance.d.cts.map +1 -1
  21. package/dist/api/balance.d.mts.map +1 -1
  22. package/dist/api/balance.mjs +1 -2
  23. package/dist/api/balance.mjs.map +1 -1
  24. package/dist/api/caip.cjs +3 -3
  25. package/dist/api/caip.cjs.map +1 -1
  26. package/dist/api/caip.d.cts.map +1 -1
  27. package/dist/api/caip.d.mts.map +1 -1
  28. package/dist/api/caip.mjs +1 -1
  29. package/dist/api/caip.mjs.map +1 -1
  30. package/dist/api/index.cjs +1 -0
  31. package/dist/api/index.cjs.map +1 -1
  32. package/dist/api/index.d.cts +1 -0
  33. package/dist/api/index.d.cts.map +1 -1
  34. package/dist/api/index.d.mts +1 -0
  35. package/dist/api/index.d.mts.map +1 -1
  36. package/dist/api/index.mjs +1 -0
  37. package/dist/api/index.mjs.map +1 -1
  38. package/dist/api/keyring.cjs +2 -0
  39. package/dist/api/keyring.cjs.map +1 -1
  40. package/dist/api/keyring.d.cts +1 -1
  41. package/dist/api/keyring.d.cts.map +1 -1
  42. package/dist/api/keyring.d.mts +1 -1
  43. package/dist/api/keyring.d.mts.map +1 -1
  44. package/dist/api/keyring.mjs +2 -0
  45. package/dist/api/keyring.mjs.map +1 -1
  46. package/dist/{utils → api}/pagination.cjs +3 -3
  47. package/dist/api/pagination.cjs.map +1 -0
  48. package/dist/{utils → api}/pagination.d.cts +1 -1
  49. package/dist/api/pagination.d.cts.map +1 -0
  50. package/dist/{utils → api}/pagination.d.mts +1 -1
  51. package/dist/api/pagination.d.mts.map +1 -0
  52. package/dist/{utils → api}/pagination.mjs +1 -1
  53. package/dist/api/pagination.mjs.map +1 -0
  54. package/dist/api/request.cjs +6 -7
  55. package/dist/api/request.cjs.map +1 -1
  56. package/dist/api/request.d.cts +5 -5
  57. package/dist/api/request.d.cts.map +1 -1
  58. package/dist/api/request.d.mts +5 -5
  59. package/dist/api/request.d.mts.map +1 -1
  60. package/dist/api/request.mjs +1 -2
  61. package/dist/api/request.mjs.map +1 -1
  62. package/dist/api/response.cjs +6 -6
  63. package/dist/api/response.cjs.map +1 -1
  64. package/dist/api/response.d.cts +1 -1
  65. package/dist/api/response.d.cts.map +1 -1
  66. package/dist/api/response.d.mts +1 -1
  67. package/dist/api/response.d.mts.map +1 -1
  68. package/dist/api/response.mjs +1 -1
  69. package/dist/api/response.mjs.map +1 -1
  70. package/dist/api/transaction.cjs +7 -8
  71. package/dist/api/transaction.cjs.map +1 -1
  72. package/dist/api/transaction.d.cts +65 -65
  73. package/dist/api/transaction.d.cts.map +1 -1
  74. package/dist/api/transaction.d.mts +65 -65
  75. package/dist/api/transaction.d.mts.map +1 -1
  76. package/dist/api/transaction.mjs +1 -2
  77. package/dist/api/transaction.mjs.map +1 -1
  78. package/dist/btc/constants.cjs +17 -0
  79. package/dist/btc/constants.cjs.map +1 -0
  80. package/dist/btc/constants.d.cts +12 -0
  81. package/dist/btc/constants.d.cts.map +1 -0
  82. package/dist/btc/constants.d.mts +12 -0
  83. package/dist/btc/constants.d.mts.map +1 -0
  84. package/dist/btc/constants.mjs +14 -0
  85. package/dist/btc/constants.mjs.map +1 -0
  86. package/dist/btc/index.cjs +1 -0
  87. package/dist/btc/index.cjs.map +1 -1
  88. package/dist/btc/index.d.cts +1 -0
  89. package/dist/btc/index.d.cts.map +1 -1
  90. package/dist/btc/index.d.mts +1 -0
  91. package/dist/btc/index.d.mts.map +1 -1
  92. package/dist/btc/index.mjs +1 -0
  93. package/dist/btc/index.mjs.map +1 -1
  94. package/dist/btc/types.cjs +2 -2
  95. package/dist/btc/types.cjs.map +1 -1
  96. package/dist/btc/types.d.cts +3 -1
  97. package/dist/btc/types.d.cts.map +1 -1
  98. package/dist/btc/types.d.mts +3 -1
  99. package/dist/btc/types.d.mts.map +1 -1
  100. package/dist/btc/types.mjs +2 -2
  101. package/dist/btc/types.mjs.map +1 -1
  102. package/dist/eth/constants.cjs +13 -0
  103. package/dist/eth/constants.cjs.map +1 -0
  104. package/dist/eth/constants.d.cts +8 -0
  105. package/dist/eth/constants.d.cts.map +1 -0
  106. package/dist/eth/constants.d.mts +8 -0
  107. package/dist/eth/constants.d.mts.map +1 -0
  108. package/dist/eth/constants.mjs +10 -0
  109. package/dist/eth/constants.mjs.map +1 -0
  110. package/dist/eth/erc4337/types.cjs +10 -11
  111. package/dist/eth/erc4337/types.cjs.map +1 -1
  112. package/dist/eth/erc4337/types.d.cts +5 -5
  113. package/dist/eth/erc4337/types.d.cts.map +1 -1
  114. package/dist/eth/erc4337/types.d.mts +5 -5
  115. package/dist/eth/erc4337/types.d.mts.map +1 -1
  116. package/dist/eth/erc4337/types.mjs +1 -2
  117. package/dist/eth/erc4337/types.mjs.map +1 -1
  118. package/dist/eth/index.cjs +1 -0
  119. package/dist/eth/index.cjs.map +1 -1
  120. package/dist/eth/index.d.cts +1 -0
  121. package/dist/eth/index.d.cts.map +1 -1
  122. package/dist/eth/index.d.mts +1 -0
  123. package/dist/eth/index.d.mts.map +1 -1
  124. package/dist/eth/index.mjs +1 -0
  125. package/dist/eth/index.mjs.map +1 -1
  126. package/dist/eth/types.cjs +11 -6
  127. package/dist/eth/types.cjs.map +1 -1
  128. package/dist/eth/types.d.cts +10 -2
  129. package/dist/eth/types.d.cts.map +1 -1
  130. package/dist/eth/types.d.mts +10 -2
  131. package/dist/eth/types.d.mts.map +1 -1
  132. package/dist/eth/types.mjs +7 -2
  133. package/dist/eth/types.mjs.map +1 -1
  134. package/dist/eth/utils.cjs.map +1 -1
  135. package/dist/eth/utils.d.cts.map +1 -1
  136. package/dist/eth/utils.d.mts.map +1 -1
  137. package/dist/eth/utils.mjs.map +1 -1
  138. package/dist/events.cjs +67 -1
  139. package/dist/events.cjs.map +1 -1
  140. package/dist/events.d.cts +169 -0
  141. package/dist/events.d.cts.map +1 -1
  142. package/dist/events.d.mts +169 -0
  143. package/dist/events.d.mts.map +1 -1
  144. package/dist/events.mjs +66 -0
  145. package/dist/events.mjs.map +1 -1
  146. package/dist/index.cjs +2 -8
  147. package/dist/index.cjs.map +1 -1
  148. package/dist/index.d.cts +3 -9
  149. package/dist/index.d.cts.map +1 -1
  150. package/dist/index.d.mts +3 -9
  151. package/dist/index.d.mts.map +1 -1
  152. package/dist/index.mjs +2 -8
  153. package/dist/index.mjs.map +1 -1
  154. package/dist/{internal/api.cjs → rpc.cjs} +71 -42
  155. package/dist/rpc.cjs.map +1 -0
  156. package/dist/{internal/api.d.cts → rpc.d.cts} +141 -104
  157. package/dist/rpc.d.cts.map +1 -0
  158. package/dist/{internal/api.d.mts → rpc.d.mts} +141 -104
  159. package/dist/rpc.d.mts.map +1 -0
  160. package/dist/{internal/api.mjs → rpc.mjs} +33 -5
  161. package/dist/rpc.mjs.map +1 -0
  162. package/dist/sol/constants.cjs +15 -0
  163. package/dist/sol/constants.cjs.map +1 -0
  164. package/dist/sol/constants.d.cts +10 -0
  165. package/dist/sol/constants.d.cts.map +1 -0
  166. package/dist/sol/constants.d.mts +10 -0
  167. package/dist/sol/constants.d.mts.map +1 -0
  168. package/dist/sol/constants.mjs +12 -0
  169. package/dist/sol/constants.mjs.map +1 -0
  170. package/dist/sol/index.cjs +1 -0
  171. package/dist/sol/index.cjs.map +1 -1
  172. package/dist/sol/index.d.cts +1 -0
  173. package/dist/sol/index.d.cts.map +1 -1
  174. package/dist/sol/index.d.mts +1 -0
  175. package/dist/sol/index.d.mts.map +1 -1
  176. package/dist/sol/index.mjs +1 -0
  177. package/dist/sol/index.mjs.map +1 -1
  178. package/dist/sol/types.cjs +3 -3
  179. package/dist/sol/types.cjs.map +1 -1
  180. package/dist/sol/types.d.cts +3 -1
  181. package/dist/sol/types.d.cts.map +1 -1
  182. package/dist/sol/types.d.mts +3 -1
  183. package/dist/sol/types.d.mts.map +1 -1
  184. package/dist/sol/types.mjs +1 -1
  185. package/dist/sol/types.mjs.map +1 -1
  186. package/package.json +11 -14
  187. package/dist/JsonRpcRequest.cjs +0 -13
  188. package/dist/JsonRpcRequest.cjs.map +0 -1
  189. package/dist/JsonRpcRequest.d.cts +0 -17
  190. package/dist/JsonRpcRequest.d.cts.map +0 -1
  191. package/dist/JsonRpcRequest.d.mts +0 -17
  192. package/dist/JsonRpcRequest.d.mts.map +0 -1
  193. package/dist/JsonRpcRequest.mjs +0 -10
  194. package/dist/JsonRpcRequest.mjs.map +0 -1
  195. package/dist/KeyringClient.cjs +0 -130
  196. package/dist/KeyringClient.cjs.map +0 -1
  197. package/dist/KeyringClient.d.cts +0 -31
  198. package/dist/KeyringClient.d.cts.map +0 -1
  199. package/dist/KeyringClient.d.mts +0 -31
  200. package/dist/KeyringClient.d.mts.map +0 -1
  201. package/dist/KeyringClient.mjs +0 -126
  202. package/dist/KeyringClient.mjs.map +0 -1
  203. package/dist/KeyringSnapRpcClient.cjs +0 -68
  204. package/dist/KeyringSnapRpcClient.cjs.map +0 -1
  205. package/dist/KeyringSnapRpcClient.d.cts +0 -40
  206. package/dist/KeyringSnapRpcClient.d.cts.map +0 -1
  207. package/dist/KeyringSnapRpcClient.d.mts +0 -40
  208. package/dist/KeyringSnapRpcClient.d.mts.map +0 -1
  209. package/dist/KeyringSnapRpcClient.mjs +0 -63
  210. package/dist/KeyringSnapRpcClient.mjs.map +0 -1
  211. package/dist/internal/api.cjs.map +0 -1
  212. package/dist/internal/api.d.cts.map +0 -1
  213. package/dist/internal/api.d.mts.map +0 -1
  214. package/dist/internal/api.mjs.map +0 -1
  215. package/dist/internal/eth/EthKeyring.cjs +0 -3
  216. package/dist/internal/eth/EthKeyring.cjs.map +0 -1
  217. package/dist/internal/eth/EthKeyring.d.cts +0 -34
  218. package/dist/internal/eth/EthKeyring.d.cts.map +0 -1
  219. package/dist/internal/eth/EthKeyring.d.mts +0 -34
  220. package/dist/internal/eth/EthKeyring.d.mts.map +0 -1
  221. package/dist/internal/eth/EthKeyring.mjs +0 -2
  222. package/dist/internal/eth/EthKeyring.mjs.map +0 -1
  223. package/dist/internal/eth/index.cjs +0 -3
  224. package/dist/internal/eth/index.cjs.map +0 -1
  225. package/dist/internal/eth/index.d.cts +0 -2
  226. package/dist/internal/eth/index.d.cts.map +0 -1
  227. package/dist/internal/eth/index.d.mts +0 -2
  228. package/dist/internal/eth/index.d.mts.map +0 -1
  229. package/dist/internal/eth/index.mjs +0 -2
  230. package/dist/internal/eth/index.mjs.map +0 -1
  231. package/dist/internal/events.cjs +0 -72
  232. package/dist/internal/events.cjs.map +0 -1
  233. package/dist/internal/events.d.cts +0 -162
  234. package/dist/internal/events.d.cts.map +0 -1
  235. package/dist/internal/events.d.mts +0 -162
  236. package/dist/internal/events.d.mts.map +0 -1
  237. package/dist/internal/events.mjs +0 -69
  238. package/dist/internal/events.mjs.map +0 -1
  239. package/dist/internal/index.cjs +0 -21
  240. package/dist/internal/index.cjs.map +0 -1
  241. package/dist/internal/index.d.cts +0 -6
  242. package/dist/internal/index.d.cts.map +0 -1
  243. package/dist/internal/index.d.mts +0 -6
  244. package/dist/internal/index.d.mts.map +0 -1
  245. package/dist/internal/index.mjs +0 -5
  246. package/dist/internal/index.mjs.map +0 -1
  247. package/dist/internal/rpc.cjs +0 -34
  248. package/dist/internal/rpc.cjs.map +0 -1
  249. package/dist/internal/rpc.d.cts +0 -27
  250. package/dist/internal/rpc.d.cts.map +0 -1
  251. package/dist/internal/rpc.d.mts +0 -27
  252. package/dist/internal/rpc.d.mts.map +0 -1
  253. package/dist/internal/rpc.mjs +0 -30
  254. package/dist/internal/rpc.mjs.map +0 -1
  255. package/dist/internal/types.cjs +0 -52
  256. package/dist/internal/types.cjs.map +0 -1
  257. package/dist/internal/types.d.cts +0 -392
  258. package/dist/internal/types.d.cts.map +0 -1
  259. package/dist/internal/types.d.mts +0 -392
  260. package/dist/internal/types.d.mts.map +0 -1
  261. package/dist/internal/types.mjs +0 -49
  262. package/dist/internal/types.mjs.map +0 -1
  263. package/dist/rpc-handler.cjs +0 -143
  264. package/dist/rpc-handler.cjs.map +0 -1
  265. package/dist/rpc-handler.d.cts +0 -30
  266. package/dist/rpc-handler.d.cts.map +0 -1
  267. package/dist/rpc-handler.d.mts +0 -30
  268. package/dist/rpc-handler.d.mts.map +0 -1
  269. package/dist/rpc-handler.mjs +0 -138
  270. package/dist/rpc-handler.mjs.map +0 -1
  271. package/dist/snap-utils.cjs +0 -20
  272. package/dist/snap-utils.cjs.map +0 -1
  273. package/dist/snap-utils.d.cts +0 -12
  274. package/dist/snap-utils.d.cts.map +0 -1
  275. package/dist/snap-utils.d.mts +0 -12
  276. package/dist/snap-utils.d.mts.map +0 -1
  277. package/dist/snap-utils.mjs +0 -17
  278. package/dist/snap-utils.mjs.map +0 -1
  279. package/dist/superstruct.cjs +0 -109
  280. package/dist/superstruct.cjs.map +0 -1
  281. package/dist/superstruct.d.cts +0 -102
  282. package/dist/superstruct.d.cts.map +0 -1
  283. package/dist/superstruct.d.mts +0 -102
  284. package/dist/superstruct.d.mts.map +0 -1
  285. package/dist/superstruct.mjs +0 -102
  286. package/dist/superstruct.mjs.map +0 -1
  287. package/dist/utils/index.cjs +0 -20
  288. package/dist/utils/index.cjs.map +0 -1
  289. package/dist/utils/index.d.cts +0 -4
  290. package/dist/utils/index.d.cts.map +0 -1
  291. package/dist/utils/index.d.mts +0 -4
  292. package/dist/utils/index.d.mts.map +0 -1
  293. package/dist/utils/index.mjs +0 -4
  294. package/dist/utils/index.mjs.map +0 -1
  295. package/dist/utils/pagination.cjs.map +0 -1
  296. package/dist/utils/pagination.d.cts.map +0 -1
  297. package/dist/utils/pagination.d.mts.map +0 -1
  298. package/dist/utils/pagination.mjs.map +0 -1
  299. package/dist/utils/types.cjs +0 -29
  300. package/dist/utils/types.cjs.map +0 -1
  301. package/dist/utils/types.d.cts +0 -42
  302. package/dist/utils/types.d.cts.map +0 -1
  303. package/dist/utils/types.d.mts +0 -42
  304. package/dist/utils/types.d.mts.map +0 -1
  305. package/dist/utils/types.mjs +0 -26
  306. package/dist/utils/types.mjs.map +0 -1
  307. package/dist/utils/typing.cjs +0 -20
  308. package/dist/utils/typing.cjs.map +0 -1
  309. package/dist/utils/typing.d.cts +0 -33
  310. package/dist/utils/typing.d.cts.map +0 -1
  311. package/dist/utils/typing.d.mts +0 -33
  312. package/dist/utils/typing.d.mts.map +0 -1
  313. package/dist/utils/typing.mjs +0 -17
  314. package/dist/utils/typing.mjs.map +0 -1
@@ -1,102 +0,0 @@
1
- import { Struct, assert, define, object as stObject } from "@metamask/superstruct";
2
- /**
3
- * Change the return type of a superstruct object struct to support exact
4
- * optional properties.
5
- *
6
- * @param schema - The object schema.
7
- * @returns A struct representing an object with a known set of properties.
8
- */
9
- export function object(schema) {
10
- return stObject(schema);
11
- }
12
- /**
13
- * Check if the current property is present in its parent object.
14
- *
15
- * @param ctx - The context to check.
16
- * @returns `true` if the property is present, `false` otherwise.
17
- */
18
- function hasOptional(ctx) {
19
- const property = ctx.path[ctx.path.length - 1];
20
- const parent = ctx.branch[ctx.branch.length - 2];
21
- return property in parent;
22
- }
23
- /**
24
- * Augment a struct to allow exact-optional values. Exact-optional values can
25
- * be omitted but cannot be `undefined`.
26
- *
27
- * ```ts
28
- * const foo = object({ bar: exactOptional(string()) });
29
- * type Foo = Infer<typeof foo>;
30
- * // Foo = { bar?: string }
31
- * ```
32
- *
33
- * @param struct - The struct to augment.
34
- * @returns The augmented struct.
35
- */
36
- export function exactOptional(struct) {
37
- return new Struct({
38
- ...struct,
39
- validator: (value, ctx) => !hasOptional(ctx) || struct.validator(value, ctx),
40
- refiner: (value, ctx) => !hasOptional(ctx) || struct.refiner(value, ctx),
41
- });
42
- }
43
- /**
44
- * Defines a new string-struct matching a regular expression.
45
- *
46
- * Example:
47
- *
48
- * ```ts
49
- * const EthAddressStruct = definePattern('EthAddress', /^0x[0-9a-f]{40}$/iu);
50
- * ```
51
- *
52
- * @param name - Type name.
53
- * @param pattern - Regular expression to match.
54
- * @returns A new string-struct that matches the given pattern.
55
- */
56
- export function definePattern(name, pattern) {
57
- return define(name, (value) => typeof value === 'string' && pattern.test(value));
58
- }
59
- /**
60
- * Assert that a value is valid according to a struct.
61
- *
62
- * It is similar to superstruct's mask function, but it does not ignore extra
63
- * properties.
64
- *
65
- * @param value - Value to check.
66
- * @param struct - Struct to validate the value against.
67
- * @param message - Error message to throw if the value is not valid.
68
- * @returns The value if it is valid.
69
- */
70
- export function strictMask(value, struct, message) {
71
- assert(value, struct, message);
72
- return value;
73
- }
74
- /**
75
- * Create a custom union struct that uses a `selector` function for choosing
76
- * the validation path.
77
- *
78
- * @param selector - The selector function choosing the struct to validate with.
79
- * @returns The `superstruct` struct, which validates that the value satisfies
80
- * one of the structs.
81
- */
82
- export function selectiveUnion(selector) {
83
- return new Struct({
84
- type: 'union',
85
- schema: null,
86
- *entries(value, context) {
87
- yield* selector(value).entries(value, context);
88
- },
89
- *refiner(value, context) {
90
- yield* selector(value).refiner(value, context);
91
- },
92
- coercer(value, context) {
93
- return selector(value).coercer(value, context);
94
- },
95
- validator(value, context) {
96
- // This only validates the root of the struct, entries does the rest of
97
- // the work.
98
- return selector(value).validator(value, context);
99
- },
100
- });
101
- }
102
- //# sourceMappingURL=superstruct.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"superstruct.mjs","sourceRoot":"","sources":["../src/superstruct.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,MAAM,EACN,MAAM,EACN,MAAM,IAAI,QAAQ,EACnB,8BAA8B;AAwD/B;;;;;;GAMG;AACH,MAAM,UAAU,MAAM,CACpB,MAAc;IAEd,OAAO,QAAQ,CAAC,MAAM,CAAQ,CAAC;AACjC,CAAC;AAED;;;;;GAKG;AACH,SAAS,WAAW,CAAC,GAAY;IAC/B,MAAM,QAAQ,GAAW,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACvD,MAAM,MAAM,GAA4B,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAE1E,OAAO,QAAQ,IAAI,MAAM,CAAC;AAC5B,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,aAAa,CAC3B,MAA4B;IAE5B,OAAO,IAAI,MAAM,CAAC;QAChB,GAAG,MAAM;QAET,SAAS,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CACxB,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC;QAEnD,OAAO,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CACtB,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAa,EAAE,GAAG,CAAC;KAC1D,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,aAAa,CAC3B,IAAY,EACZ,OAAe;IAEf,OAAO,MAAM,CACX,IAAI,EACJ,CAAC,KAAc,EAAW,EAAE,CAC1B,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CACnD,CAAC;AACJ,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,UAAU,CACxB,KAAc,EACd,MAA4B,EAC5B,OAAgB;IAEhB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,OAAO,KAAK,CAAC;AACf,CAAC;AAgBD;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc,CAC5B,QAAkB;IAElB,OAAO,IAAI,MAAM,CAAC;QAChB,IAAI,EAAE,OAAO;QACb,MAAM,EAAE,IAAI;QAEZ,CAAC,OAAO,CAAC,KAAU,EAAE,OAAY;YAC/B,KAAK,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QACjD,CAAC;QAED,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO;YACrB,KAAK,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QACjD,CAAC;QAED,OAAO,CAAC,KAAK,EAAE,OAAO;YACpB,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QACjD,CAAC;QAED,SAAS,CAAC,KAAK,EAAE,OAAO;YACtB,uEAAuE;YACvE,YAAY;YACZ,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QACnD,CAAC;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n Struct,\n assert,\n define,\n object as stObject,\n} from '@metamask/superstruct';\nimport type {\n Infer,\n Context,\n ObjectSchema,\n OmitBy,\n Optionalize,\n PickBy,\n Simplify,\n AnyStruct,\n} from '@metamask/superstruct';\n\nimport type { Equals } from './utils';\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\ndeclare const ExactOptionalSymbol: unique symbol;\n\nexport type ExactOptionalTag = {\n type: typeof ExactOptionalSymbol;\n};\n\n/**\n * Exclude type `Type` from the properties of `Obj`.\n *\n * ```ts\n * type Foo = { a: string | null; b: number };\n * type Bar = ExcludeType<Foo, null>;\n * // Bar = { a: string, b: number }\n * ```\n */\nexport type ExcludeType<Obj, Type> = {\n [K in keyof Obj]: Exclude<Obj[K], Type>;\n};\n\n/**\n * Make optional all properties that have the `ExactOptionalTag` type.\n *\n * ```ts\n * type Foo = { a: string | ExactOptionalTag; b: number};\n * type Bar = ExactOptionalize<Foo>;\n * // Bar = { a?: string; b: number}\n * ```\n */\nexport type ExactOptionalize<Schema extends object> = OmitBy<\n Schema,\n ExactOptionalTag\n> &\n Partial<ExcludeType<PickBy<Schema, ExactOptionalTag>, ExactOptionalTag>>;\n\n/**\n * Infer a type from an superstruct object schema.\n */\nexport type ObjectType<Schema extends ObjectSchema> = Simplify<\n ExactOptionalize<Optionalize<{ [K in keyof Schema]: Infer<Schema[K]> }>>\n>;\n\n/**\n * Change the return type of a superstruct object struct to support exact\n * optional properties.\n *\n * @param schema - The object schema.\n * @returns A struct representing an object with a known set of properties.\n */\nexport function object<Schema extends ObjectSchema>(\n schema: Schema,\n): Struct<ObjectType<Schema>, Schema> {\n return stObject(schema) as any;\n}\n\n/**\n * Check if the current property is present in its parent object.\n *\n * @param ctx - The context to check.\n * @returns `true` if the property is present, `false` otherwise.\n */\nfunction hasOptional(ctx: Context): boolean {\n const property: string = ctx.path[ctx.path.length - 1];\n const parent: Record<string, unknown> = ctx.branch[ctx.branch.length - 2];\n\n return property in parent;\n}\n\n/**\n * Augment a struct to allow exact-optional values. Exact-optional values can\n * be omitted but cannot be `undefined`.\n *\n * ```ts\n * const foo = object({ bar: exactOptional(string()) });\n * type Foo = Infer<typeof foo>;\n * // Foo = { bar?: string }\n * ```\n *\n * @param struct - The struct to augment.\n * @returns The augmented struct.\n */\nexport function exactOptional<Type, Schema>(\n struct: Struct<Type, Schema>,\n): Struct<Type | ExactOptionalTag, Schema> {\n return new Struct({\n ...struct,\n\n validator: (value, ctx) =>\n !hasOptional(ctx) || struct.validator(value, ctx),\n\n refiner: (value, ctx) =>\n !hasOptional(ctx) || struct.refiner(value as Type, ctx),\n });\n}\n\n/**\n * Defines a new string-struct matching a regular expression.\n *\n * Example:\n *\n * ```ts\n * const EthAddressStruct = definePattern('EthAddress', /^0x[0-9a-f]{40}$/iu);\n * ```\n *\n * @param name - Type name.\n * @param pattern - Regular expression to match.\n * @returns A new string-struct that matches the given pattern.\n */\nexport function definePattern(\n name: string,\n pattern: RegExp,\n): Struct<string, null> {\n return define<string>(\n name,\n (value: unknown): boolean =>\n typeof value === 'string' && pattern.test(value),\n );\n}\n\n/**\n * Assert that a value is valid according to a struct.\n *\n * It is similar to superstruct's mask function, but it does not ignore extra\n * properties.\n *\n * @param value - Value to check.\n * @param struct - Struct to validate the value against.\n * @param message - Error message to throw if the value is not valid.\n * @returns The value if it is valid.\n */\nexport function strictMask<Type, Schema>(\n value: unknown,\n struct: Struct<Type, Schema>,\n message?: string,\n): Type {\n assert(value, struct, message);\n return value;\n}\n\n/**\n * Extracts the type from a struct definition and asserts that it matches the\n * expected type. If the types do not match, the type `never` is returned.\n *\n * @param StructType - The struct type to infer.\n * @param ExpectedType - The expected type.\n */\nexport type InferEquals<\n StructType extends Struct<any, any>,\n ExpectedType,\n> = Equals<Infer<StructType>, ExpectedType> extends true\n ? Infer<StructType>\n : never;\n\n/**\n * Create a custom union struct that uses a `selector` function for choosing\n * the validation path.\n *\n * @param selector - The selector function choosing the struct to validate with.\n * @returns The `superstruct` struct, which validates that the value satisfies\n * one of the structs.\n */\nexport function selectiveUnion<Selector extends (value: any) => AnyStruct>(\n selector: Selector,\n): Struct<Infer<ReturnType<Selector>>, null> {\n return new Struct({\n type: 'union',\n schema: null,\n\n *entries(value: any, context: any): ReturnType<Struct['entries']> {\n yield* selector(value).entries(value, context);\n },\n\n *refiner(value, context): ReturnType<Struct['refiner']> {\n yield* selector(value).refiner(value, context);\n },\n\n coercer(value, context): ReturnType<Struct['coercer']> {\n return selector(value).coercer(value, context);\n },\n\n validator(value, context): ReturnType<Struct['validator']> {\n // This only validates the root of the struct, entries does the rest of\n // the work.\n return selector(value).validator(value, context);\n },\n });\n}\n"]}
@@ -1,20 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./pagination.cjs"), exports);
18
- __exportStar(require("./types.cjs"), exports);
19
- __exportStar(require("./typing.cjs"), exports);
20
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAA6B;AAC7B,8CAAwB;AACxB,+CAAyB","sourcesContent":["export * from './pagination';\nexport * from './types';\nexport * from './typing';\n"]}
@@ -1,4 +0,0 @@
1
- export * from "./pagination.cjs";
2
- export * from "./types.cjs";
3
- export * from "./typing.cjs";
4
- //# sourceMappingURL=index.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,iCAA6B;AAC7B,4BAAwB;AACxB,6BAAyB"}
@@ -1,4 +0,0 @@
1
- export * from "./pagination.mjs";
2
- export * from "./types.mjs";
3
- export * from "./typing.mjs";
4
- //# sourceMappingURL=index.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,iCAA6B;AAC7B,4BAAwB;AACxB,6BAAyB"}
@@ -1,4 +0,0 @@
1
- export * from "./pagination.mjs";
2
- export * from "./types.mjs";
3
- export * from "./typing.mjs";
4
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,iCAA6B;AAC7B,4BAAwB;AACxB,6BAAyB","sourcesContent":["export * from './pagination';\nexport * from './types';\nexport * from './typing';\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"pagination.cjs","sourceRoot":"","sources":["../../src/utils/pagination.ts"],"names":[],"mappings":";;;AACA,uDAAiE;AAEjE,oDAAuD;AAEvD;;;;;;;;;;;GAWG;AACU,QAAA,gBAAgB,GAAG,IAAA,oBAAM,EAAC;IACrC;;OAEG;IACH,KAAK,EAAE,IAAA,oBAAM,GAAE;IAEf;;OAEG;IACH,IAAI,EAAE,IAAA,2BAAa,EAAC,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC,CAAC;CACxC,CAAC,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport { nullable, number, string } from '@metamask/superstruct';\n\nimport { exactOptional, object } from '../superstruct';\n\n/**\n * Pagination struct. This struct is used to specify the limit of items to\n * return and the next cursor to iterate over the results.\n *\n * @example\n * ```ts\n * {\n * limit: 10,\n * next: 'c3y1Q6QtqtstbxKX+oqVdEW6',\n * }\n * ```\n */\nexport const PaginationStruct = object({\n /**\n * Maximum number of items to return.\n */\n limit: number(),\n\n /**\n * Next cursor to iterate over the results.\n */\n next: exactOptional(nullable(string())),\n});\n\n/**\n * Pagination object.\n *\n * See {@link PaginationStruct}.\n */\nexport type Pagination = Infer<typeof PaginationStruct>;\n\n/**\n * Page of results. It includes the data and the next cursor to iterate over\n * the results.\n *\n * @example\n * ```ts\n * {\n * data: [\n * {\n * // Item object\n * }\n * ],\n * next: 'c3y1Q6QtqtstbxKX+oqVdEW6',\n * }\n * ```\n */\nexport type Paginated<Type> = {\n /**\n * The list of items for this page.\n */\n data: Type[];\n\n /**\n * Next cursor to iterate over the results if any, will be `null` otherwise.\n */\n next: string | null;\n};\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"pagination.d.cts","sourceRoot":"","sources":["../../src/utils/pagination.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAKnD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gBAAgB;;;;IAC3B;;OAEG;;IAGH;;OAEG;;EAEH,CAAC;AAEH;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAExD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,SAAS,CAAC,IAAI,IAAI;IAC5B;;OAEG;IACH,IAAI,EAAE,IAAI,EAAE,CAAC;IAEb;;OAEG;IACH,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"pagination.d.mts","sourceRoot":"","sources":["../../src/utils/pagination.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAKnD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gBAAgB;;;;IAC3B;;OAEG;;IAGH;;OAEG;;EAEH,CAAC;AAEH;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAExD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,SAAS,CAAC,IAAI,IAAI;IAC5B;;OAEG;IACH,IAAI,EAAE,IAAI,EAAE,CAAC;IAEb;;OAEG;IACH,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"pagination.mjs","sourceRoot":"","sources":["../../src/utils/pagination.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,8BAA8B;AAEjE,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,2BAAuB;AAEvD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC;IACrC;;OAEG;IACH,KAAK,EAAE,MAAM,EAAE;IAEf;;OAEG;IACH,IAAI,EAAE,aAAa,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;CACxC,CAAC,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport { nullable, number, string } from '@metamask/superstruct';\n\nimport { exactOptional, object } from '../superstruct';\n\n/**\n * Pagination struct. This struct is used to specify the limit of items to\n * return and the next cursor to iterate over the results.\n *\n * @example\n * ```ts\n * {\n * limit: 10,\n * next: 'c3y1Q6QtqtstbxKX+oqVdEW6',\n * }\n * ```\n */\nexport const PaginationStruct = object({\n /**\n * Maximum number of items to return.\n */\n limit: number(),\n\n /**\n * Next cursor to iterate over the results.\n */\n next: exactOptional(nullable(string())),\n});\n\n/**\n * Pagination object.\n *\n * See {@link PaginationStruct}.\n */\nexport type Pagination = Infer<typeof PaginationStruct>;\n\n/**\n * Page of results. It includes the data and the next cursor to iterate over\n * the results.\n *\n * @example\n * ```ts\n * {\n * data: [\n * {\n * // Item object\n * }\n * ],\n * next: 'c3y1Q6QtqtstbxKX+oqVdEW6',\n * }\n * ```\n */\nexport type Paginated<Type> = {\n /**\n * The list of items for this page.\n */\n data: Type[];\n\n /**\n * Next cursor to iterate over the results if any, will be `null` otherwise.\n */\n next: string | null;\n};\n"]}
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StringNumberStruct = exports.UrlStruct = exports.UuidStruct = void 0;
4
- const superstruct_1 = require("@metamask/superstruct");
5
- const superstruct_2 = require("../superstruct.cjs");
6
- /**
7
- * UUIDv4 struct.
8
- */
9
- exports.UuidStruct = (0, superstruct_2.definePattern)('UuidV4', /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu);
10
- /**
11
- * Validates if a given value is a valid URL.
12
- *
13
- * @param value - The value to be validated.
14
- * @returns A boolean indicating if the value is a valid URL.
15
- */
16
- exports.UrlStruct = (0, superstruct_1.define)('Url', (value) => {
17
- try {
18
- const url = new URL(value);
19
- return url.protocol === 'http:' || url.protocol === 'https:';
20
- }
21
- catch {
22
- return false;
23
- }
24
- });
25
- /**
26
- * A string which contains a positive float number.
27
- */
28
- exports.StringNumberStruct = (0, superstruct_2.definePattern)('StringNumber', /^\d+(\.\d+)?$/u);
29
- //# sourceMappingURL=types.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":";;;AAAA,uDAA2D;AAE3D,oDAA+C;AAE/C;;GAEG;AACU,QAAA,UAAU,GAAG,IAAA,2BAAa,EACrC,QAAQ,EACR,yEAAyE,CAC1E,CAAC;AAEF;;;;;GAKG;AACU,QAAA,SAAS,GAAG,IAAA,oBAAM,EAAS,KAAK,EAAE,CAAC,KAAc,EAAE,EAAE;IAChE,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAe,CAAC,CAAC;QACrC,OAAO,GAAG,CAAC,QAAQ,KAAK,OAAO,IAAI,GAAG,CAAC,QAAQ,KAAK,QAAQ,CAAC;IAC/D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,CAAC,CAAC;AAEH;;GAEG;AACU,QAAA,kBAAkB,GAAG,IAAA,2BAAa,EAC7C,cAAc,EACd,gBAAgB,CACjB,CAAC","sourcesContent":["import { define, type Infer } from '@metamask/superstruct';\n\nimport { definePattern } from '../superstruct';\n\n/**\n * UUIDv4 struct.\n */\nexport const UuidStruct = definePattern(\n 'UuidV4',\n /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu,\n);\n\n/**\n * Validates if a given value is a valid URL.\n *\n * @param value - The value to be validated.\n * @returns A boolean indicating if the value is a valid URL.\n */\nexport const UrlStruct = define<string>('Url', (value: unknown) => {\n try {\n const url = new URL(value as string);\n return url.protocol === 'http:' || url.protocol === 'https:';\n } catch {\n return false;\n }\n});\n\n/**\n * A string which contains a positive float number.\n */\nexport const StringNumberStruct = definePattern(\n 'StringNumber',\n /^\\d+(\\.\\d+)?$/u,\n);\nexport type StringNumber = Infer<typeof StringNumberStruct>;\n\n/**\n * This is a helper type used by the {@link Equals} type.\n */\ntype EqualsHelper<Type> = <Dummy>() => Dummy extends Type ? 1 : 2;\n\n/**\n * A utility type that checks whether two types are exactly the same.\n *\n * This type evaluates to `true` if `TypeA` and `TypeB` are identical,\n * otherwise it evaluates to `false`.\n *\n * @template TypeA - The first type to compare.\n * @template TypeB - The second type to compare.\n *\n * @example\n * ```ts\n * // Example usage:\n * type Test1 = Equals<number, number>; // true\n * type Test2 = Equals<number, string>; // false\n * type Test3 = Equals<{ a: string }, { a: string }>; // true\n * type Test4 = Equals<{ a: string }, { a: number }>; // false\n * ```\n */\nexport type Equals<TypeA, TypeB> =\n EqualsHelper<TypeA> extends EqualsHelper<TypeB> ? true : false;\n"]}
@@ -1,42 +0,0 @@
1
- import { type Infer } from "@metamask/superstruct";
2
- /**
3
- * UUIDv4 struct.
4
- */
5
- export declare const UuidStruct: import("@metamask/superstruct").Struct<string, null>;
6
- /**
7
- * Validates if a given value is a valid URL.
8
- *
9
- * @param value - The value to be validated.
10
- * @returns A boolean indicating if the value is a valid URL.
11
- */
12
- export declare const UrlStruct: import("@metamask/superstruct").Struct<string, null>;
13
- /**
14
- * A string which contains a positive float number.
15
- */
16
- export declare const StringNumberStruct: import("@metamask/superstruct").Struct<string, null>;
17
- export type StringNumber = Infer<typeof StringNumberStruct>;
18
- /**
19
- * This is a helper type used by the {@link Equals} type.
20
- */
21
- type EqualsHelper<Type> = <Dummy>() => Dummy extends Type ? 1 : 2;
22
- /**
23
- * A utility type that checks whether two types are exactly the same.
24
- *
25
- * This type evaluates to `true` if `TypeA` and `TypeB` are identical,
26
- * otherwise it evaluates to `false`.
27
- *
28
- * @template TypeA - The first type to compare.
29
- * @template TypeB - The second type to compare.
30
- *
31
- * @example
32
- * ```ts
33
- * // Example usage:
34
- * type Test1 = Equals<number, number>; // true
35
- * type Test2 = Equals<number, string>; // false
36
- * type Test3 = Equals<{ a: string }, { a: string }>; // true
37
- * type Test4 = Equals<{ a: string }, { a: number }>; // false
38
- * ```
39
- */
40
- export type Equals<TypeA, TypeB> = EqualsHelper<TypeA> extends EqualsHelper<TypeB> ? true : false;
41
- export {};
42
- //# sourceMappingURL=types.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,KAAK,EAAE,8BAA8B;AAI3D;;GAEG;AACH,eAAO,MAAM,UAAU,sDAGtB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,SAAS,sDAOpB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,kBAAkB,sDAG9B,CAAC;AACF,MAAM,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE5D;;GAEG;AACH,KAAK,YAAY,CAAC,IAAI,IAAI,CAAC,KAAK,OAAO,KAAK,SAAS,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;AAElE;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,MAAM,CAAC,KAAK,EAAE,KAAK,IAC7B,YAAY,CAAC,KAAK,CAAC,SAAS,YAAY,CAAC,KAAK,CAAC,GAAG,IAAI,GAAG,KAAK,CAAC"}
@@ -1,42 +0,0 @@
1
- import { type Infer } from "@metamask/superstruct";
2
- /**
3
- * UUIDv4 struct.
4
- */
5
- export declare const UuidStruct: import("@metamask/superstruct").Struct<string, null>;
6
- /**
7
- * Validates if a given value is a valid URL.
8
- *
9
- * @param value - The value to be validated.
10
- * @returns A boolean indicating if the value is a valid URL.
11
- */
12
- export declare const UrlStruct: import("@metamask/superstruct").Struct<string, null>;
13
- /**
14
- * A string which contains a positive float number.
15
- */
16
- export declare const StringNumberStruct: import("@metamask/superstruct").Struct<string, null>;
17
- export type StringNumber = Infer<typeof StringNumberStruct>;
18
- /**
19
- * This is a helper type used by the {@link Equals} type.
20
- */
21
- type EqualsHelper<Type> = <Dummy>() => Dummy extends Type ? 1 : 2;
22
- /**
23
- * A utility type that checks whether two types are exactly the same.
24
- *
25
- * This type evaluates to `true` if `TypeA` and `TypeB` are identical,
26
- * otherwise it evaluates to `false`.
27
- *
28
- * @template TypeA - The first type to compare.
29
- * @template TypeB - The second type to compare.
30
- *
31
- * @example
32
- * ```ts
33
- * // Example usage:
34
- * type Test1 = Equals<number, number>; // true
35
- * type Test2 = Equals<number, string>; // false
36
- * type Test3 = Equals<{ a: string }, { a: string }>; // true
37
- * type Test4 = Equals<{ a: string }, { a: number }>; // false
38
- * ```
39
- */
40
- export type Equals<TypeA, TypeB> = EqualsHelper<TypeA> extends EqualsHelper<TypeB> ? true : false;
41
- export {};
42
- //# sourceMappingURL=types.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,KAAK,EAAE,8BAA8B;AAI3D;;GAEG;AACH,eAAO,MAAM,UAAU,sDAGtB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,SAAS,sDAOpB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,kBAAkB,sDAG9B,CAAC;AACF,MAAM,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE5D;;GAEG;AACH,KAAK,YAAY,CAAC,IAAI,IAAI,CAAC,KAAK,OAAO,KAAK,SAAS,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;AAElE;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,MAAM,CAAC,KAAK,EAAE,KAAK,IAC7B,YAAY,CAAC,KAAK,CAAC,SAAS,YAAY,CAAC,KAAK,CAAC,GAAG,IAAI,GAAG,KAAK,CAAC"}
@@ -1,26 +0,0 @@
1
- import { define } from "@metamask/superstruct";
2
- import { definePattern } from "../superstruct.mjs";
3
- /**
4
- * UUIDv4 struct.
5
- */
6
- export const UuidStruct = definePattern('UuidV4', /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu);
7
- /**
8
- * Validates if a given value is a valid URL.
9
- *
10
- * @param value - The value to be validated.
11
- * @returns A boolean indicating if the value is a valid URL.
12
- */
13
- export const UrlStruct = define('Url', (value) => {
14
- try {
15
- const url = new URL(value);
16
- return url.protocol === 'http:' || url.protocol === 'https:';
17
- }
18
- catch {
19
- return false;
20
- }
21
- });
22
- /**
23
- * A string which contains a positive float number.
24
- */
25
- export const StringNumberStruct = definePattern('StringNumber', /^\d+(\.\d+)?$/u);
26
- //# sourceMappingURL=types.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAc,8BAA8B;AAE3D,OAAO,EAAE,aAAa,EAAE,2BAAuB;AAE/C;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CACrC,QAAQ,EACR,yEAAyE,CAC1E,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAS,KAAK,EAAE,CAAC,KAAc,EAAE,EAAE;IAChE,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAe,CAAC,CAAC;QACrC,OAAO,GAAG,CAAC,QAAQ,KAAK,OAAO,IAAI,GAAG,CAAC,QAAQ,KAAK,QAAQ,CAAC;IAC/D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,aAAa,CAC7C,cAAc,EACd,gBAAgB,CACjB,CAAC","sourcesContent":["import { define, type Infer } from '@metamask/superstruct';\n\nimport { definePattern } from '../superstruct';\n\n/**\n * UUIDv4 struct.\n */\nexport const UuidStruct = definePattern(\n 'UuidV4',\n /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu,\n);\n\n/**\n * Validates if a given value is a valid URL.\n *\n * @param value - The value to be validated.\n * @returns A boolean indicating if the value is a valid URL.\n */\nexport const UrlStruct = define<string>('Url', (value: unknown) => {\n try {\n const url = new URL(value as string);\n return url.protocol === 'http:' || url.protocol === 'https:';\n } catch {\n return false;\n }\n});\n\n/**\n * A string which contains a positive float number.\n */\nexport const StringNumberStruct = definePattern(\n 'StringNumber',\n /^\\d+(\\.\\d+)?$/u,\n);\nexport type StringNumber = Infer<typeof StringNumberStruct>;\n\n/**\n * This is a helper type used by the {@link Equals} type.\n */\ntype EqualsHelper<Type> = <Dummy>() => Dummy extends Type ? 1 : 2;\n\n/**\n * A utility type that checks whether two types are exactly the same.\n *\n * This type evaluates to `true` if `TypeA` and `TypeB` are identical,\n * otherwise it evaluates to `false`.\n *\n * @template TypeA - The first type to compare.\n * @template TypeB - The second type to compare.\n *\n * @example\n * ```ts\n * // Example usage:\n * type Test1 = Equals<number, number>; // true\n * type Test2 = Equals<number, string>; // false\n * type Test3 = Equals<{ a: string }, { a: string }>; // true\n * type Test4 = Equals<{ a: string }, { a: number }>; // false\n * ```\n */\nexport type Equals<TypeA, TypeB> =\n EqualsHelper<TypeA> extends EqualsHelper<TypeB> ? true : false;\n"]}
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.expectTrue = expectTrue;
4
- /**
5
- * Assert that a type extends `true`. It can be used, for example, to assert
6
- * that a given type extends another type.
7
- *
8
- * @example
9
- * ```ts
10
- * expectTrue<Extends<{a: string, b: string}, {a: string}>>(); // Ok
11
- * expectTrue<Extends<{a: string}, {a: string, b: string}>>(); // Error
12
- * ```
13
- *
14
- * This function follows the naming pattern used on `tsd`.
15
- */
16
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
17
- function expectTrue() {
18
- // Intentionally empty
19
- }
20
- //# sourceMappingURL=typing.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"typing.cjs","sourceRoot":"","sources":["../../src/utils/typing.ts"],"names":[],"mappings":";;AAoCA,gCAEC;AAfD;;;;;;;;;;;GAWG;AACH,6DAA6D;AAC7D,SAAgB,UAAU;IACxB,sBAAsB;AACxB,CAAC","sourcesContent":["/**\n * Omit keys from a union type.\n *\n * The normal `Omit` type does not distribute over unions. So we use this\n * workaround that applies `Omit` to each member of the union.\n *\n * See: <https://github.com/microsoft/TypeScript/issues/31501#issuecomment-1280579305>\n */\nexport type OmitUnion<Type, Key extends keyof any> = Type extends any\n ? Omit<Type, Key>\n : never;\n\n/**\n * Type that resolves to `true` if `Child` extends `Base`, otherwise `false`.\n *\n * @example\n * ```ts\n * type A = Extends<{a: string, b: string}, {a: string}>; // true\n * type B = Extends<{a: string}, {a: string, b: string}>; // false\n * ```\n */\nexport type Extends<Child, Base> = Child extends Base ? true : false;\n\n/**\n * Assert that a type extends `true`. It can be used, for example, to assert\n * that a given type extends another type.\n *\n * @example\n * ```ts\n * expectTrue<Extends<{a: string, b: string}, {a: string}>>(); // Ok\n * expectTrue<Extends<{a: string}, {a: string, b: string}>>(); // Error\n * ```\n *\n * This function follows the naming pattern used on `tsd`.\n */\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function expectTrue<Type extends true>(): void {\n // Intentionally empty\n}\n"]}
@@ -1,33 +0,0 @@
1
- /**
2
- * Omit keys from a union type.
3
- *
4
- * The normal `Omit` type does not distribute over unions. So we use this
5
- * workaround that applies `Omit` to each member of the union.
6
- *
7
- * See: <https://github.com/microsoft/TypeScript/issues/31501#issuecomment-1280579305>
8
- */
9
- export type OmitUnion<Type, Key extends keyof any> = Type extends any ? Omit<Type, Key> : never;
10
- /**
11
- * Type that resolves to `true` if `Child` extends `Base`, otherwise `false`.
12
- *
13
- * @example
14
- * ```ts
15
- * type A = Extends<{a: string, b: string}, {a: string}>; // true
16
- * type B = Extends<{a: string}, {a: string, b: string}>; // false
17
- * ```
18
- */
19
- export type Extends<Child, Base> = Child extends Base ? true : false;
20
- /**
21
- * Assert that a type extends `true`. It can be used, for example, to assert
22
- * that a given type extends another type.
23
- *
24
- * @example
25
- * ```ts
26
- * expectTrue<Extends<{a: string, b: string}, {a: string}>>(); // Ok
27
- * expectTrue<Extends<{a: string}, {a: string, b: string}>>(); // Error
28
- * ```
29
- *
30
- * This function follows the naming pattern used on `tsd`.
31
- */
32
- export declare function expectTrue<Type extends true>(): void;
33
- //# sourceMappingURL=typing.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"typing.d.cts","sourceRoot":"","sources":["../../src/utils/typing.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,MAAM,SAAS,CAAC,IAAI,EAAE,GAAG,SAAS,MAAM,GAAG,IAAI,IAAI,SAAS,GAAG,GACjE,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,GACf,KAAK,CAAC;AAEV;;;;;;;;GAQG;AACH,MAAM,MAAM,OAAO,CAAC,KAAK,EAAE,IAAI,IAAI,KAAK,SAAS,IAAI,GAAG,IAAI,GAAG,KAAK,CAAC;AAErE;;;;;;;;;;;GAWG;AAEH,wBAAgB,UAAU,CAAC,IAAI,SAAS,IAAI,KAAK,IAAI,CAEpD"}
@@ -1,33 +0,0 @@
1
- /**
2
- * Omit keys from a union type.
3
- *
4
- * The normal `Omit` type does not distribute over unions. So we use this
5
- * workaround that applies `Omit` to each member of the union.
6
- *
7
- * See: <https://github.com/microsoft/TypeScript/issues/31501#issuecomment-1280579305>
8
- */
9
- export type OmitUnion<Type, Key extends keyof any> = Type extends any ? Omit<Type, Key> : never;
10
- /**
11
- * Type that resolves to `true` if `Child` extends `Base`, otherwise `false`.
12
- *
13
- * @example
14
- * ```ts
15
- * type A = Extends<{a: string, b: string}, {a: string}>; // true
16
- * type B = Extends<{a: string}, {a: string, b: string}>; // false
17
- * ```
18
- */
19
- export type Extends<Child, Base> = Child extends Base ? true : false;
20
- /**
21
- * Assert that a type extends `true`. It can be used, for example, to assert
22
- * that a given type extends another type.
23
- *
24
- * @example
25
- * ```ts
26
- * expectTrue<Extends<{a: string, b: string}, {a: string}>>(); // Ok
27
- * expectTrue<Extends<{a: string}, {a: string, b: string}>>(); // Error
28
- * ```
29
- *
30
- * This function follows the naming pattern used on `tsd`.
31
- */
32
- export declare function expectTrue<Type extends true>(): void;
33
- //# sourceMappingURL=typing.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"typing.d.mts","sourceRoot":"","sources":["../../src/utils/typing.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,MAAM,SAAS,CAAC,IAAI,EAAE,GAAG,SAAS,MAAM,GAAG,IAAI,IAAI,SAAS,GAAG,GACjE,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,GACf,KAAK,CAAC;AAEV;;;;;;;;GAQG;AACH,MAAM,MAAM,OAAO,CAAC,KAAK,EAAE,IAAI,IAAI,KAAK,SAAS,IAAI,GAAG,IAAI,GAAG,KAAK,CAAC;AAErE;;;;;;;;;;;GAWG;AAEH,wBAAgB,UAAU,CAAC,IAAI,SAAS,IAAI,KAAK,IAAI,CAEpD"}
@@ -1,17 +0,0 @@
1
- /**
2
- * Assert that a type extends `true`. It can be used, for example, to assert
3
- * that a given type extends another type.
4
- *
5
- * @example
6
- * ```ts
7
- * expectTrue<Extends<{a: string, b: string}, {a: string}>>(); // Ok
8
- * expectTrue<Extends<{a: string}, {a: string, b: string}>>(); // Error
9
- * ```
10
- *
11
- * This function follows the naming pattern used on `tsd`.
12
- */
13
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
14
- export function expectTrue() {
15
- // Intentionally empty
16
- }
17
- //# sourceMappingURL=typing.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"typing.mjs","sourceRoot":"","sources":["../../src/utils/typing.ts"],"names":[],"mappings":"AAuBA;;;;;;;;;;;GAWG;AACH,6DAA6D;AAC7D,MAAM,UAAU,UAAU;IACxB,sBAAsB;AACxB,CAAC","sourcesContent":["/**\n * Omit keys from a union type.\n *\n * The normal `Omit` type does not distribute over unions. So we use this\n * workaround that applies `Omit` to each member of the union.\n *\n * See: <https://github.com/microsoft/TypeScript/issues/31501#issuecomment-1280579305>\n */\nexport type OmitUnion<Type, Key extends keyof any> = Type extends any\n ? Omit<Type, Key>\n : never;\n\n/**\n * Type that resolves to `true` if `Child` extends `Base`, otherwise `false`.\n *\n * @example\n * ```ts\n * type A = Extends<{a: string, b: string}, {a: string}>; // true\n * type B = Extends<{a: string}, {a: string, b: string}>; // false\n * ```\n */\nexport type Extends<Child, Base> = Child extends Base ? true : false;\n\n/**\n * Assert that a type extends `true`. It can be used, for example, to assert\n * that a given type extends another type.\n *\n * @example\n * ```ts\n * expectTrue<Extends<{a: string, b: string}, {a: string}>>(); // Ok\n * expectTrue<Extends<{a: string}, {a: string, b: string}>>(); // Error\n * ```\n *\n * This function follows the naming pattern used on `tsd`.\n */\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function expectTrue<Type extends true>(): void {\n // Intentionally empty\n}\n"]}