@icp-sdk/core 5.0.0 → 5.2.0-beta.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 (331) hide show
  1. package/lib/cjs/agent/actor.d.ts +15 -1
  2. package/lib/cjs/agent/actor.d.ts.map +1 -1
  3. package/lib/cjs/agent/actor.js +37 -91
  4. package/lib/cjs/agent/actor.js.map +1 -1
  5. package/lib/cjs/agent/agent/api.d.ts +29 -6
  6. package/lib/cjs/agent/agent/api.d.ts.map +1 -1
  7. package/lib/cjs/agent/agent/api.js.map +1 -1
  8. package/lib/cjs/agent/agent/http/expiry.d.ts +36 -0
  9. package/lib/cjs/agent/agent/http/expiry.d.ts.map +1 -0
  10. package/lib/cjs/agent/agent/http/expiry.js +92 -0
  11. package/lib/cjs/agent/agent/http/expiry.js.map +1 -0
  12. package/lib/cjs/agent/agent/http/index.d.ts +28 -2
  13. package/lib/cjs/agent/agent/http/index.d.ts.map +1 -1
  14. package/lib/cjs/agent/agent/http/index.js +182 -90
  15. package/lib/cjs/agent/agent/http/index.js.map +1 -1
  16. package/lib/cjs/agent/agent/http/transforms.d.ts +1 -35
  17. package/lib/cjs/agent/agent/http/transforms.d.ts.map +1 -1
  18. package/lib/cjs/agent/agent/http/transforms.js +6 -90
  19. package/lib/cjs/agent/agent/http/transforms.js.map +1 -1
  20. package/lib/cjs/agent/agent/http/types.d.ts +1 -1
  21. package/lib/cjs/agent/agent/http/types.d.ts.map +1 -1
  22. package/lib/cjs/agent/auth.d.ts +1 -1
  23. package/lib/cjs/agent/auth.d.ts.map +1 -1
  24. package/lib/cjs/agent/canisterStatus/index.d.ts +5 -4
  25. package/lib/cjs/agent/canisterStatus/index.d.ts.map +1 -1
  26. package/lib/cjs/agent/canisterStatus/index.js +6 -10
  27. package/lib/cjs/agent/canisterStatus/index.js.map +1 -1
  28. package/lib/cjs/agent/cbor.js +2 -2
  29. package/lib/cjs/agent/cbor.js.map +1 -1
  30. package/lib/cjs/agent/certificate.d.ts +4 -4
  31. package/lib/cjs/agent/certificate.d.ts.map +1 -1
  32. package/lib/cjs/agent/certificate.js +6 -10
  33. package/lib/cjs/agent/certificate.js.map +1 -1
  34. package/lib/cjs/agent/constants.d.ts +4 -4
  35. package/lib/cjs/agent/constants.d.ts.map +1 -1
  36. package/lib/cjs/agent/der.d.ts.map +1 -1
  37. package/lib/cjs/agent/der.js +26 -21
  38. package/lib/cjs/agent/der.js.map +1 -1
  39. package/lib/cjs/agent/errors.d.ts +45 -19
  40. package/lib/cjs/agent/errors.d.ts.map +1 -1
  41. package/lib/cjs/agent/errors.js +58 -18
  42. package/lib/cjs/agent/errors.js.map +1 -1
  43. package/lib/cjs/agent/index.d.ts +1 -0
  44. package/lib/cjs/agent/index.d.ts.map +1 -1
  45. package/lib/cjs/agent/index.js.map +1 -1
  46. package/lib/cjs/agent/observable.d.ts +1 -1
  47. package/lib/cjs/agent/observable.d.ts.map +1 -1
  48. package/lib/cjs/agent/polling/backoff.d.ts +7 -7
  49. package/lib/cjs/agent/polling/backoff.d.ts.map +1 -1
  50. package/lib/cjs/agent/polling/backoff.js +3 -5
  51. package/lib/cjs/agent/polling/backoff.js.map +1 -1
  52. package/lib/cjs/agent/polling/index.d.ts +11 -10
  53. package/lib/cjs/agent/polling/index.d.ts.map +1 -1
  54. package/lib/cjs/agent/polling/index.js +8 -6
  55. package/lib/cjs/agent/polling/index.js.map +1 -1
  56. package/lib/cjs/agent/polling/strategy.d.ts +2 -5
  57. package/lib/cjs/agent/polling/strategy.d.ts.map +1 -1
  58. package/lib/cjs/agent/polling/strategy.js.map +1 -1
  59. package/lib/cjs/agent/polling/types.d.ts +18 -0
  60. package/lib/cjs/agent/polling/types.d.ts.map +1 -0
  61. package/lib/cjs/agent/polling/types.js +3 -0
  62. package/lib/cjs/agent/polling/types.js.map +1 -0
  63. package/lib/cjs/agent/public_key.d.ts +1 -1
  64. package/lib/cjs/agent/public_key.d.ts.map +1 -1
  65. package/lib/cjs/agent/request_id.d.ts.map +1 -1
  66. package/lib/cjs/agent/request_id.js +7 -7
  67. package/lib/cjs/agent/request_id.js.map +1 -1
  68. package/lib/cjs/agent/subnetStatus/index.d.ts +5 -4
  69. package/lib/cjs/agent/subnetStatus/index.d.ts.map +1 -1
  70. package/lib/cjs/agent/subnetStatus/index.js +6 -10
  71. package/lib/cjs/agent/subnetStatus/index.js.map +1 -1
  72. package/lib/cjs/agent/utils/buffer.d.ts.map +1 -1
  73. package/lib/cjs/agent/utils/buffer.js +4 -2
  74. package/lib/cjs/agent/utils/buffer.js.map +1 -1
  75. package/lib/cjs/agent/utils/certificateReject.d.ts +11 -0
  76. package/lib/cjs/agent/utils/certificateReject.d.ts.map +1 -0
  77. package/lib/cjs/agent/utils/certificateReject.js +19 -0
  78. package/lib/cjs/agent/utils/certificateReject.js.map +1 -0
  79. package/lib/cjs/agent/utils/createExpirableStore.d.ts +23 -0
  80. package/lib/cjs/agent/utils/createExpirableStore.d.ts.map +1 -0
  81. package/lib/cjs/agent/utils/createExpirableStore.js +18 -0
  82. package/lib/cjs/agent/utils/createExpirableStore.js.map +1 -0
  83. package/lib/cjs/agent/utils/expirableStore.d.ts +39 -0
  84. package/lib/cjs/agent/utils/expirableStore.d.ts.map +1 -0
  85. package/lib/cjs/agent/utils/expirableStore.js +14 -0
  86. package/lib/cjs/agent/utils/expirableStore.js.map +1 -0
  87. package/lib/cjs/agent/utils/inMemoryExpirableStore.d.ts +14 -0
  88. package/lib/cjs/agent/utils/inMemoryExpirableStore.d.ts.map +1 -0
  89. package/lib/cjs/agent/utils/inMemoryExpirableStore.js +46 -0
  90. package/lib/cjs/agent/utils/inMemoryExpirableStore.js.map +1 -0
  91. package/lib/cjs/agent/utils/indexedDBExpirableStore.d.ts +28 -0
  92. package/lib/cjs/agent/utils/indexedDBExpirableStore.d.ts.map +1 -0
  93. package/lib/cjs/agent/utils/indexedDBExpirableStore.js +139 -0
  94. package/lib/cjs/agent/utils/indexedDBExpirableStore.js.map +1 -0
  95. package/lib/cjs/agent/utils/readState.d.ts +3 -3
  96. package/lib/cjs/agent/utils/readState.d.ts.map +1 -1
  97. package/lib/cjs/candid/candid-core.d.ts +1 -1
  98. package/lib/cjs/candid/candid-core.d.ts.map +1 -1
  99. package/lib/cjs/candid/candid-core.js +7 -9
  100. package/lib/cjs/candid/candid-core.js.map +1 -1
  101. package/lib/cjs/candid/candid-ui.d.ts.map +1 -1
  102. package/lib/cjs/candid/candid-ui.js +8 -24
  103. package/lib/cjs/candid/candid-ui.js.map +1 -1
  104. package/lib/cjs/candid/idl.d.ts +14 -1
  105. package/lib/cjs/candid/idl.d.ts.map +1 -1
  106. package/lib/cjs/candid/idl.js +164 -125
  107. package/lib/cjs/candid/idl.js.map +1 -1
  108. package/lib/cjs/candid/utils/leb128.d.ts.map +1 -1
  109. package/lib/cjs/candid/utils/leb128.js +1 -3
  110. package/lib/cjs/candid/utils/leb128.js.map +1 -1
  111. package/lib/cjs/identity/identity/delegation.d.ts +4 -3
  112. package/lib/cjs/identity/identity/delegation.d.ts.map +1 -1
  113. package/lib/cjs/identity/identity/delegation.js +3 -3
  114. package/lib/cjs/identity/identity/delegation.js.map +1 -1
  115. package/lib/cjs/identity/identity/ecdsa.d.ts +2 -2
  116. package/lib/cjs/identity/identity/ecdsa.d.ts.map +1 -1
  117. package/lib/cjs/identity/identity/ecdsa.js +2 -4
  118. package/lib/cjs/identity/identity/ecdsa.js.map +1 -1
  119. package/lib/cjs/identity/identity/ed25519.d.ts.map +1 -1
  120. package/lib/cjs/identity/identity/ed25519.js +9 -10
  121. package/lib/cjs/identity/identity/ed25519.js.map +1 -1
  122. package/lib/cjs/identity/identity/partial.d.ts +1 -1
  123. package/lib/cjs/identity/identity/partial.d.ts.map +1 -1
  124. package/lib/cjs/identity/identity/webauthn.js +4 -5
  125. package/lib/cjs/identity/identity/webauthn.js.map +1 -1
  126. package/lib/cjs/identity/secp256k1/der.d.ts.map +1 -1
  127. package/lib/cjs/identity/secp256k1/der.js +27 -22
  128. package/lib/cjs/identity/secp256k1/der.js.map +1 -1
  129. package/lib/cjs/identity/secp256k1/pem.js +1 -1
  130. package/lib/cjs/identity/secp256k1/pem.js.map +1 -1
  131. package/lib/cjs/identity/secp256k1/secp256k1.d.ts.map +1 -1
  132. package/lib/cjs/identity/secp256k1/secp256k1.js +6 -6
  133. package/lib/cjs/identity/secp256k1/secp256k1.js.map +1 -1
  134. package/lib/cjs/principal/principal.d.ts +2 -2
  135. package/lib/cjs/principal/principal.d.ts.map +1 -1
  136. package/lib/cjs/principal/principal.js +10 -6
  137. package/lib/cjs/principal/principal.js.map +1 -1
  138. package/lib/esm/agent/actor.d.ts +15 -1
  139. package/lib/esm/agent/actor.d.ts.map +1 -1
  140. package/lib/esm/agent/actor.js +40 -94
  141. package/lib/esm/agent/actor.js.map +1 -1
  142. package/lib/esm/agent/agent/api.d.ts +29 -6
  143. package/lib/esm/agent/agent/api.d.ts.map +1 -1
  144. package/lib/esm/agent/agent/api.js.map +1 -1
  145. package/lib/esm/agent/agent/http/expiry.d.ts +36 -0
  146. package/lib/esm/agent/agent/http/expiry.d.ts.map +1 -0
  147. package/lib/esm/agent/agent/http/expiry.js +88 -0
  148. package/lib/esm/agent/agent/http/expiry.js.map +1 -0
  149. package/lib/esm/agent/agent/http/index.d.ts +28 -2
  150. package/lib/esm/agent/agent/http/index.d.ts.map +1 -1
  151. package/lib/esm/agent/agent/http/index.js +185 -93
  152. package/lib/esm/agent/agent/http/index.js.map +1 -1
  153. package/lib/esm/agent/agent/http/transforms.d.ts +1 -35
  154. package/lib/esm/agent/agent/http/transforms.d.ts.map +1 -1
  155. package/lib/esm/agent/agent/http/transforms.js +2 -87
  156. package/lib/esm/agent/agent/http/transforms.js.map +1 -1
  157. package/lib/esm/agent/agent/http/types.d.ts +1 -1
  158. package/lib/esm/agent/agent/http/types.d.ts.map +1 -1
  159. package/lib/esm/agent/auth.d.ts +1 -1
  160. package/lib/esm/agent/auth.d.ts.map +1 -1
  161. package/lib/esm/agent/canister-env/index.d.ts +2 -2
  162. package/lib/esm/agent/canister-env/index.d.ts.map +1 -1
  163. package/lib/esm/agent/canisterStatus/index.d.ts +5 -4
  164. package/lib/esm/agent/canisterStatus/index.d.ts.map +1 -1
  165. package/lib/esm/agent/canisterStatus/index.js +6 -10
  166. package/lib/esm/agent/canisterStatus/index.js.map +1 -1
  167. package/lib/esm/agent/cbor.js +1 -1
  168. package/lib/esm/agent/cbor.js.map +1 -1
  169. package/lib/esm/agent/certificate.d.ts +4 -4
  170. package/lib/esm/agent/certificate.d.ts.map +1 -1
  171. package/lib/esm/agent/certificate.js +6 -10
  172. package/lib/esm/agent/certificate.js.map +1 -1
  173. package/lib/esm/agent/constants.d.ts +4 -4
  174. package/lib/esm/agent/constants.d.ts.map +1 -1
  175. package/lib/esm/agent/der.d.ts.map +1 -1
  176. package/lib/esm/agent/der.js +26 -21
  177. package/lib/esm/agent/der.js.map +1 -1
  178. package/lib/esm/agent/errors.d.ts +45 -19
  179. package/lib/esm/agent/errors.d.ts.map +1 -1
  180. package/lib/esm/agent/errors.js +54 -16
  181. package/lib/esm/agent/errors.js.map +1 -1
  182. package/lib/esm/agent/index.d.ts +1 -0
  183. package/lib/esm/agent/index.d.ts.map +1 -1
  184. package/lib/esm/agent/index.js.map +1 -1
  185. package/lib/esm/agent/observable.d.ts +1 -1
  186. package/lib/esm/agent/observable.d.ts.map +1 -1
  187. package/lib/esm/agent/polling/backoff.d.ts +7 -7
  188. package/lib/esm/agent/polling/backoff.d.ts.map +1 -1
  189. package/lib/esm/agent/polling/backoff.js +3 -5
  190. package/lib/esm/agent/polling/backoff.js.map +1 -1
  191. package/lib/esm/agent/polling/index.d.ts +11 -10
  192. package/lib/esm/agent/polling/index.d.ts.map +1 -1
  193. package/lib/esm/agent/polling/index.js +9 -7
  194. package/lib/esm/agent/polling/index.js.map +1 -1
  195. package/lib/esm/agent/polling/strategy.d.ts +2 -5
  196. package/lib/esm/agent/polling/strategy.d.ts.map +1 -1
  197. package/lib/esm/agent/polling/strategy.js.map +1 -1
  198. package/lib/esm/agent/polling/types.d.ts +18 -0
  199. package/lib/esm/agent/polling/types.d.ts.map +1 -0
  200. package/lib/esm/agent/polling/types.js +2 -0
  201. package/lib/esm/agent/polling/types.js.map +1 -0
  202. package/lib/esm/agent/public_key.d.ts +1 -1
  203. package/lib/esm/agent/public_key.d.ts.map +1 -1
  204. package/lib/esm/agent/request_id.d.ts.map +1 -1
  205. package/lib/esm/agent/request_id.js +7 -7
  206. package/lib/esm/agent/request_id.js.map +1 -1
  207. package/lib/esm/agent/subnetStatus/index.d.ts +5 -4
  208. package/lib/esm/agent/subnetStatus/index.d.ts.map +1 -1
  209. package/lib/esm/agent/subnetStatus/index.js +6 -10
  210. package/lib/esm/agent/subnetStatus/index.js.map +1 -1
  211. package/lib/esm/agent/utils/buffer.d.ts.map +1 -1
  212. package/lib/esm/agent/utils/buffer.js +4 -2
  213. package/lib/esm/agent/utils/buffer.js.map +1 -1
  214. package/lib/esm/agent/utils/certificateReject.d.ts +11 -0
  215. package/lib/esm/agent/utils/certificateReject.d.ts.map +1 -0
  216. package/lib/esm/agent/utils/certificateReject.js +16 -0
  217. package/lib/esm/agent/utils/certificateReject.js.map +1 -0
  218. package/lib/esm/agent/utils/createExpirableStore.d.ts +23 -0
  219. package/lib/esm/agent/utils/createExpirableStore.d.ts.map +1 -0
  220. package/lib/esm/agent/utils/createExpirableStore.js +15 -0
  221. package/lib/esm/agent/utils/createExpirableStore.js.map +1 -0
  222. package/lib/esm/agent/utils/expirableStore.d.ts +39 -0
  223. package/lib/esm/agent/utils/expirableStore.d.ts.map +1 -0
  224. package/lib/esm/agent/utils/expirableStore.js +11 -0
  225. package/lib/esm/agent/utils/expirableStore.js.map +1 -0
  226. package/lib/esm/agent/utils/inMemoryExpirableStore.d.ts +14 -0
  227. package/lib/esm/agent/utils/inMemoryExpirableStore.d.ts.map +1 -0
  228. package/lib/esm/agent/utils/inMemoryExpirableStore.js +42 -0
  229. package/lib/esm/agent/utils/inMemoryExpirableStore.js.map +1 -0
  230. package/lib/esm/agent/utils/indexedDBExpirableStore.d.ts +28 -0
  231. package/lib/esm/agent/utils/indexedDBExpirableStore.d.ts.map +1 -0
  232. package/lib/esm/agent/utils/indexedDBExpirableStore.js +135 -0
  233. package/lib/esm/agent/utils/indexedDBExpirableStore.js.map +1 -0
  234. package/lib/esm/agent/utils/readState.d.ts +3 -3
  235. package/lib/esm/agent/utils/readState.d.ts.map +1 -1
  236. package/lib/esm/candid/candid-core.d.ts +1 -1
  237. package/lib/esm/candid/candid-core.d.ts.map +1 -1
  238. package/lib/esm/candid/candid-core.js +7 -9
  239. package/lib/esm/candid/candid-core.js.map +1 -1
  240. package/lib/esm/candid/candid-ui.d.ts.map +1 -1
  241. package/lib/esm/candid/candid-ui.js +7 -23
  242. package/lib/esm/candid/candid-ui.js.map +1 -1
  243. package/lib/esm/candid/idl.d.ts +14 -1
  244. package/lib/esm/candid/idl.d.ts.map +1 -1
  245. package/lib/esm/candid/idl.js +162 -124
  246. package/lib/esm/candid/idl.js.map +1 -1
  247. package/lib/esm/candid/utils/leb128.d.ts.map +1 -1
  248. package/lib/esm/candid/utils/leb128.js +1 -3
  249. package/lib/esm/candid/utils/leb128.js.map +1 -1
  250. package/lib/esm/identity/identity/delegation.d.ts +4 -3
  251. package/lib/esm/identity/identity/delegation.d.ts.map +1 -1
  252. package/lib/esm/identity/identity/delegation.js +3 -3
  253. package/lib/esm/identity/identity/delegation.js.map +1 -1
  254. package/lib/esm/identity/identity/ecdsa.d.ts +2 -2
  255. package/lib/esm/identity/identity/ecdsa.d.ts.map +1 -1
  256. package/lib/esm/identity/identity/ecdsa.js +2 -4
  257. package/lib/esm/identity/identity/ecdsa.js.map +1 -1
  258. package/lib/esm/identity/identity/ed25519.d.ts.map +1 -1
  259. package/lib/esm/identity/identity/ed25519.js +9 -10
  260. package/lib/esm/identity/identity/ed25519.js.map +1 -1
  261. package/lib/esm/identity/identity/partial.d.ts +1 -1
  262. package/lib/esm/identity/identity/partial.d.ts.map +1 -1
  263. package/lib/esm/identity/identity/webauthn.js +4 -5
  264. package/lib/esm/identity/identity/webauthn.js.map +1 -1
  265. package/lib/esm/identity/secp256k1/der.d.ts.map +1 -1
  266. package/lib/esm/identity/secp256k1/der.js +27 -22
  267. package/lib/esm/identity/secp256k1/der.js.map +1 -1
  268. package/lib/esm/identity/secp256k1/pem.js +1 -1
  269. package/lib/esm/identity/secp256k1/pem.js.map +1 -1
  270. package/lib/esm/identity/secp256k1/secp256k1.d.ts.map +1 -1
  271. package/lib/esm/identity/secp256k1/secp256k1.js +6 -6
  272. package/lib/esm/identity/secp256k1/secp256k1.js.map +1 -1
  273. package/lib/esm/principal/principal.d.ts +2 -2
  274. package/lib/esm/principal/principal.d.ts.map +1 -1
  275. package/lib/esm/principal/principal.js +10 -6
  276. package/lib/esm/principal/principal.js.map +1 -1
  277. package/package.json +14 -13
  278. package/src/agent/actor.ts +74 -126
  279. package/src/agent/agent/api.ts +36 -6
  280. package/src/agent/agent/http/expiry.ts +107 -0
  281. package/src/agent/agent/http/index.ts +262 -104
  282. package/src/agent/agent/http/transforms.ts +2 -106
  283. package/src/agent/agent/http/types.ts +1 -1
  284. package/src/agent/auth.ts +1 -1
  285. package/src/agent/canister-env/index.ts +2 -2
  286. package/src/agent/canisterStatus/index.ts +10 -12
  287. package/src/agent/cbor.ts +1 -1
  288. package/src/agent/certificate.ts +11 -13
  289. package/src/agent/der.ts +40 -19
  290. package/src/agent/errors.ts +85 -34
  291. package/src/agent/fetch_candid.ts +1 -1
  292. package/src/agent/index.ts +1 -0
  293. package/src/agent/observable.ts +1 -1
  294. package/src/agent/polling/backoff.ts +9 -10
  295. package/src/agent/polling/index.ts +14 -26
  296. package/src/agent/polling/strategy.ts +5 -9
  297. package/src/agent/polling/types.ts +28 -0
  298. package/src/agent/public_key.ts +1 -1
  299. package/src/agent/request_id.ts +15 -8
  300. package/src/agent/subnetStatus/index.ts +10 -12
  301. package/src/agent/utils/buffer.ts +6 -2
  302. package/src/agent/utils/certificateReject.ts +25 -0
  303. package/src/agent/utils/createExpirableStore.ts +31 -0
  304. package/src/agent/utils/expirableStore.ts +47 -0
  305. package/src/agent/utils/inMemoryExpirableStore.ts +49 -0
  306. package/src/agent/utils/indexedDBExpirableStore.ts +191 -0
  307. package/src/agent/utils/random.ts +2 -2
  308. package/src/agent/utils/readState.ts +3 -3
  309. package/src/candid/candid-core.ts +9 -11
  310. package/src/candid/candid-ui.ts +8 -16
  311. package/src/candid/idl.ts +210 -112
  312. package/src/candid/utils/leb128.ts +1 -2
  313. package/src/identity/identity/delegation.ts +5 -5
  314. package/src/identity/identity/ecdsa.ts +12 -8
  315. package/src/identity/identity/ed25519.ts +16 -9
  316. package/src/identity/identity/partial.ts +1 -1
  317. package/src/identity/identity/webauthn.ts +21 -21
  318. package/src/identity/secp256k1/der.ts +41 -20
  319. package/src/identity/secp256k1/pem.ts +1 -1
  320. package/src/identity/secp256k1/secp256k1.ts +12 -6
  321. package/src/principal/principal.ts +18 -8
  322. package/LICENSE +0 -201
  323. package/lib/cjs/agent/utils/expirableMap.d.ts +0 -80
  324. package/lib/cjs/agent/utils/expirableMap.d.ts.map +0 -1
  325. package/lib/cjs/agent/utils/expirableMap.js +0 -148
  326. package/lib/cjs/agent/utils/expirableMap.js.map +0 -1
  327. package/lib/esm/agent/utils/expirableMap.d.ts +0 -80
  328. package/lib/esm/agent/utils/expirableMap.d.ts.map +0 -1
  329. package/lib/esm/agent/utils/expirableMap.js +0 -144
  330. package/lib/esm/agent/utils/expirableMap.js.map +0 -1
  331. package/src/agent/utils/expirableMap.ts +0 -163
@@ -1,13 +1,13 @@
1
- import { type RequestId } from '../request_id.ts';
1
+ import type { RequestId } from '../request_id.ts';
2
2
  import {
3
3
  type CreateCertificateOptions,
4
4
  Certificate,
5
5
  lookupResultToBuffer,
6
6
  } from '../certificate.ts';
7
- import { type Agent, type ReadStateResponse } from '../agent/api.ts';
8
- import { Principal } from '#principal';
7
+ import { readCertifiedReject } from '../utils/certificateReject.ts';
8
+ import type { Agent, ReadStateResponse } from '../agent/api.ts';
9
+ import type { Principal } from '#principal';
9
10
  import {
10
- CertifiedRejectErrorCode,
11
11
  ExternalError,
12
12
  InputError,
13
13
  InvalidReadStateRequestErrorCode,
@@ -20,16 +20,12 @@ import {
20
20
 
21
21
  export * as strategy from './strategy.ts';
22
22
  import { defaultStrategy } from './strategy.ts';
23
+ import type { PollStrategy, PollForResponseResult } from './types.ts';
23
24
  import { ReadRequestType, type ReadStateRequest } from '../agent/http/types.ts';
24
- import { RequestStatusResponseStatus } from '../agent/index.ts';
25
+ import { RequestStatusResponseStatus } from '../agent/http/index.ts';
25
26
  import { utf8ToBytes } from '@noble/hashes/utils';
26
27
  export { defaultStrategy } from './strategy.ts';
27
-
28
- export type PollStrategy = (
29
- canisterId: Principal,
30
- requestId: RequestId,
31
- status: RequestStatusResponseStatus,
32
- ) => Promise<void>;
28
+ export type { PollStrategy, PollForResponseResult } from './types.ts';
33
29
 
34
30
  interface SignedReadStateRequestWithExpiry extends ReadStateRequest {
35
31
  body: {
@@ -122,16 +118,17 @@ function isSignedReadStateRequestWithExpiry(
122
118
  * @param canisterId The effective canister ID.
123
119
  * @param requestId The Request ID to poll status for.
124
120
  * @param options polling options to control behavior
121
+ * @returns The certificate, reply bytes, and raw certificate bytes for the request.
122
+ * @throws {ExternalError} If the agent's root key is not available.
123
+ * @throws {RejectError} If the request was rejected by the canister.
124
+ * @throws {UnknownError} If the request reached `done` status without a reply.
125
125
  */
126
126
  export async function pollForResponse(
127
127
  agent: Agent,
128
128
  canisterId: Principal,
129
129
  requestId: RequestId,
130
130
  options: PollingOptions = {},
131
- ): Promise<{
132
- certificate: Certificate;
133
- reply: Uint8Array;
134
- }> {
131
+ ): Promise<PollForResponseResult> {
135
132
  const path = [utf8ToBytes('request_status'), requestId];
136
133
 
137
134
  let state: ReadStateResponse;
@@ -175,6 +172,7 @@ export async function pollForResponse(
175
172
  return {
176
173
  reply: lookupResultToBuffer(cert.lookup_path([...path, 'reply']))!,
177
174
  certificate: cert,
175
+ rawCertificate: state.certificate,
178
176
  };
179
177
  }
180
178
 
@@ -194,17 +192,7 @@ export async function pollForResponse(
194
192
  }
195
193
 
196
194
  case RequestStatusResponseStatus.Rejected: {
197
- const rejectCode = new Uint8Array(
198
- lookupResultToBuffer(cert.lookup_path([...path, 'reject_code']))!,
199
- )[0];
200
- const rejectMessage = new TextDecoder().decode(
201
- lookupResultToBuffer(cert.lookup_path([...path, 'reject_message']))!,
202
- );
203
- const errorCodeBuf = lookupResultToBuffer(cert.lookup_path([...path, 'error_code']));
204
- const errorCode = errorCodeBuf ? new TextDecoder().decode(errorCodeBuf) : undefined;
205
- throw RejectError.fromCode(
206
- new CertifiedRejectErrorCode(requestId, rejectCode, rejectMessage, errorCode),
207
- );
195
+ throw RejectError.fromCode(readCertifiedReject(cert, path, requestId));
208
196
  }
209
197
 
210
198
  case RequestStatusResponseStatus.Done:
@@ -1,14 +1,10 @@
1
- import { Principal } from '#principal';
2
- import { RequestStatusResponseStatus } from '../agent/index.ts';
3
- import { type PollStrategy } from './index.ts';
4
- import { type RequestId } from '../request_id.ts';
1
+ import type { Principal } from '#principal';
2
+ import type { RequestStatusResponseStatus } from '../agent/http/index.ts';
3
+ import type { RequestId } from '../request_id.ts';
5
4
  import { ProtocolError, TimeoutWaitingForResponseErrorCode } from '../errors.ts';
6
5
 
7
- export type Predicate<T> = (
8
- canisterId: Principal,
9
- requestId: RequestId,
10
- status: RequestStatusResponseStatus,
11
- ) => Promise<T>;
6
+ import type { PollStrategy, Predicate } from './types.ts';
7
+ export type { PollStrategy, Predicate } from './types.ts';
12
8
 
13
9
  const FIVE_MINUTES_IN_MSEC = 5 * 60 * 1000;
14
10
 
@@ -0,0 +1,28 @@
1
+ import type { Certificate } from '../certificate.ts';
2
+ import type { Principal } from '#principal';
3
+ import type { RequestStatusResponseStatus } from '../agent/http/index.ts';
4
+ import type { RequestId } from '../request_id.ts';
5
+
6
+ export type PollStrategy = (
7
+ canisterId: Principal,
8
+ requestId: RequestId,
9
+ status: RequestStatusResponseStatus,
10
+ ) => Promise<void>;
11
+
12
+ export type Predicate<T> = (
13
+ canisterId: Principal,
14
+ requestId: RequestId,
15
+ status: RequestStatusResponseStatus,
16
+ ) => Promise<T>;
17
+
18
+ /**
19
+ * The result of polling for a response, including the certificate, reply bytes, and raw certificate bytes.
20
+ */
21
+ export interface PollForResponseResult {
22
+ /** The certificate for the request, which can be used to verify the reply. */
23
+ certificate: Certificate;
24
+ /** The reply bytes for the request. */
25
+ reply: Uint8Array;
26
+ /** The raw certificate bytes for the request. */
27
+ rawCertificate: Uint8Array;
28
+ }
@@ -1,4 +1,4 @@
1
- import { type DerEncodedPublicKey, type PublicKey } from './auth.ts';
1
+ import type { DerEncodedPublicKey, PublicKey } from './auth.ts';
2
2
  import { ED25519_OID, unwrapDER, wrapDER } from './der.ts';
3
3
  import { DerDecodeErrorCode, InputError } from './errors.ts';
4
4
 
@@ -1,5 +1,5 @@
1
1
  import { lebEncode, compare } from '#candid';
2
- import { Principal } from '#principal';
2
+ import type { Principal } from '#principal';
3
3
  import { HashValueErrorCode, InputError } from './errors.ts';
4
4
  import { uint8FromBufLike } from './utils/buffer.ts';
5
5
  import { concatBytes } from '@noble/hashes/utils';
@@ -19,16 +19,21 @@ interface ToHashable {
19
19
  export function hashValue(value: unknown): Uint8Array {
20
20
  if (typeof value === 'string') {
21
21
  return hashString(value);
22
- } else if (typeof value === 'number') {
22
+ }
23
+ if (typeof value === 'number') {
23
24
  return sha256(lebEncode(value));
24
- } else if (value instanceof Uint8Array || ArrayBuffer.isView(value)) {
25
+ }
26
+ if (value instanceof Uint8Array || ArrayBuffer.isView(value)) {
25
27
  return sha256(uint8FromBufLike(value));
26
- } else if (Array.isArray(value)) {
28
+ }
29
+ if (Array.isArray(value)) {
27
30
  const vals = value.map(hashValue);
28
31
  return sha256(concatBytes(...vals));
29
- } else if (value && typeof value === 'object' && (value as Principal)._isPrincipal) {
32
+ }
33
+ if (value && typeof value === 'object' && (value as Principal)._isPrincipal) {
30
34
  return sha256((value as Principal).toUint8Array());
31
- } else if (
35
+ }
36
+ if (
32
37
  typeof value === 'object' &&
33
38
  value !== null &&
34
39
  typeof (value as ToHashable).toHash === 'function'
@@ -38,9 +43,11 @@ export function hashValue(value: unknown): Uint8Array {
38
43
  // the flow to be synchronous to ensure Safari touch id works.
39
44
  // } else if (value instanceof Promise) {
40
45
  // return value.then(x => hashValue(x));
41
- } else if (typeof value === 'object') {
46
+ }
47
+ if (typeof value === 'object') {
42
48
  return hashOfMap(value as Record<string, unknown>);
43
- } else if (typeof value === 'bigint') {
49
+ }
50
+ if (typeof value === 'bigint') {
44
51
  // Do this check much later than the other bigint check because this one is much less
45
52
  // type-safe.
46
53
  // So we want to try all the high-assurance type guards before this 'probable' one.
@@ -10,7 +10,7 @@ import {
10
10
  ProtocolError,
11
11
  LookupErrorCode,
12
12
  } from '../errors.ts';
13
- import { HttpAgent } from '../agent/http/index.ts';
13
+ import type { HttpAgent } from '../agent/http/index.ts';
14
14
  import {
15
15
  type Cert,
16
16
  type CanisterRanges,
@@ -23,11 +23,11 @@ import {
23
23
  import * as cbor from '../cbor.ts';
24
24
  import { decodeTime } from '../utils/leb.ts';
25
25
  import { utf8ToBytes } from '@noble/hashes/utils';
26
+ import type { CustomPath } from '../utils/readState.ts';
26
27
  import {
27
28
  type BaseStatus,
28
29
  type BaseSubnetStatus,
29
30
  type SubnetNodeKeys,
30
- CustomPath,
31
31
  decodeValue,
32
32
  isCustomPath,
33
33
  lookupNodeKeysFromCertificate,
@@ -53,7 +53,7 @@ export type Path = 'time' | 'canisterRanges' | 'publicKey' | 'nodeKeys' | Custom
53
53
 
54
54
  export type StatusMap = Map<Path | string, Status>;
55
55
 
56
- export type SubnetStatusOptions = {
56
+ export interface SubnetStatusOptions {
57
57
  /**
58
58
  * The subnet ID to query. Use {@link IC_ROOT_SUBNET_ID} for the IC mainnet root subnet.
59
59
  * You can use {@link HttpAgent.getSubnetIdFromCanister} to get a subnet ID from a canister.
@@ -73,7 +73,7 @@ export type SubnetStatusOptions = {
73
73
  * @default false
74
74
  */
75
75
  disableCertificateTimeVerification?: boolean;
76
- };
76
+ }
77
77
 
78
78
  /**
79
79
  * Requests information from a subnet's `read_state` endpoint.
@@ -129,12 +129,11 @@ export async function request(options: SubnetStatusOptions): Promise<StatusMap>
129
129
  path: lookupPath,
130
130
  data,
131
131
  };
132
- } else {
133
- return {
134
- path: lookupPath,
135
- data: lookupResultToBuffer(cert.lookup_path(encodedPath)),
136
- };
137
132
  }
133
+ return {
134
+ path: lookupPath,
135
+ data: lookupResultToBuffer(cert.lookup_path(encodedPath)),
136
+ };
138
137
  };
139
138
 
140
139
  const { path, data } = lookup(certificate, uniquePaths[index]);
@@ -250,10 +249,9 @@ export function encodePath(path: Path, subnetId: Principal): Uint8Array[] {
250
249
  const encoded =
251
250
  typeof path['path'] === 'string' ? utf8ToBytes(path['path']) : path['path'];
252
251
  return [utf8ToBytes('subnet'), subnetUint8Array, encoded];
253
- } else {
254
- // For non-simple paths, return the provided custom path
255
- return path['path'];
256
252
  }
253
+ // For non-simple paths, return the provided custom path
254
+ return path['path'];
257
255
  }
258
256
  }
259
257
  }
@@ -52,9 +52,13 @@ export function uint8ToBuf(arr: Uint8Array): ArrayBuffer {
52
52
  * @returns True if the Uint8Arrays are equal, false otherwise.
53
53
  */
54
54
  export function uint8Equals(a: Uint8Array, b: Uint8Array): boolean {
55
- if (a.length !== b.length) return false;
55
+ if (a.length !== b.length) {
56
+ return false;
57
+ }
56
58
  for (let i = 0; i < a.length; i++) {
57
- if (a[i] !== b[i]) return false;
59
+ if (a[i] !== b[i]) {
60
+ return false;
61
+ }
58
62
  }
59
63
  return true;
60
64
  }
@@ -0,0 +1,25 @@
1
+ import { type Certificate, type NodePath, lookupResultToBuffer } from '../certificate.ts';
2
+ import { CertifiedRejectErrorCode } from '../errors.ts';
3
+ import type { RequestId } from '../request_id.ts';
4
+
5
+ /**
6
+ * Read certified reject details from a certificate at the given request status path.
7
+ * @param certificate The certificate to read reject details from.
8
+ * @param path The lookup path prefix (e.g. `['request_status', requestId]`).
9
+ * @param requestId The request ID associated with the rejection.
10
+ */
11
+ export function readCertifiedReject(
12
+ certificate: Certificate,
13
+ path: NodePath,
14
+ requestId: RequestId,
15
+ ): CertifiedRejectErrorCode {
16
+ const rejectCode = new Uint8Array(
17
+ lookupResultToBuffer(certificate.lookup_path([...path, 'reject_code']))!,
18
+ )[0];
19
+ const rejectMessage = new TextDecoder().decode(
20
+ lookupResultToBuffer(certificate.lookup_path([...path, 'reject_message']))!,
21
+ );
22
+ const errorCodeBuf = lookupResultToBuffer(certificate.lookup_path([...path, 'error_code']));
23
+ const errorCode = errorCodeBuf ? new TextDecoder().decode(errorCodeBuf) : undefined;
24
+ return new CertifiedRejectErrorCode(requestId, rejectCode, rejectMessage, errorCode);
25
+ }
@@ -0,0 +1,31 @@
1
+ import type { ExpirableStore } from './expirableStore.ts';
2
+ import { IndexedDBExpirableStore } from './indexedDBExpirableStore.ts';
3
+ import { InMemoryExpirableStore } from './inMemoryExpirableStore.ts';
4
+
5
+ export interface CreateExpirableStoreOptions {
6
+ /**
7
+ * Name of the IndexedDB database (used when IndexedDB is available).
8
+ */
9
+ dbName: string;
10
+ /**
11
+ * Name of the IndexedDB object store (used when IndexedDB is available).
12
+ */
13
+ storeName: string;
14
+ /**
15
+ * Time in milliseconds after which entries expire.
16
+ */
17
+ expirationTime: number;
18
+ }
19
+
20
+ /**
21
+ * Creates an {@link ExpirableStore} with automatic runtime detection.
22
+ * Uses {@link IndexedDBExpirableStore} in browser environments (when IndexedDB is available),
23
+ * falls back to {@link InMemoryExpirableStore} otherwise.
24
+ * @param options - Configuration for the store (dbName, storeName, and expirationTime).
25
+ */
26
+ export function createExpirableStore<V>(options: CreateExpirableStoreOptions): ExpirableStore<V> {
27
+ if (typeof globalThis.indexedDB !== 'undefined') {
28
+ return new IndexedDBExpirableStore<V>(options);
29
+ }
30
+ return new InMemoryExpirableStore<V>({ expirationTime: options.expirationTime });
31
+ }
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Generic interface for a key-value store with time-based expiration.
3
+ * Keys are strings, values are of type V.
4
+ * Implementations must handle expiration internally.
5
+ */
6
+ export interface ExpirableStore<V> {
7
+ /**
8
+ * Time in milliseconds after which entries expire.
9
+ */
10
+ readonly expirationTime: number;
11
+
12
+ /**
13
+ * Get the value for a key.
14
+ * Returns undefined if the key is not present or has expired.
15
+ */
16
+ get(key: string): Promise<V | undefined>;
17
+
18
+ /**
19
+ * Store a value for a key.
20
+ * Prunes expired entries before inserting.
21
+ */
22
+ set(key: string, value: V): Promise<void>;
23
+
24
+ /**
25
+ * Delete the entry for a key.
26
+ */
27
+ delete(key: string): Promise<void>;
28
+ }
29
+
30
+ export interface ExpirableStoreOptions {
31
+ /**
32
+ * Time in milliseconds after which entries expire.
33
+ * Must be a positive finite number.
34
+ */
35
+ expirationTime: number;
36
+ }
37
+
38
+ /**
39
+ * Validates that expirationTime is a positive finite number.
40
+ * @param expirationTime - Time in milliseconds after which entries expire.
41
+ * @throws {Error} if expirationTime is not valid.
42
+ */
43
+ export function validateExpirationTime(expirationTime: number): void {
44
+ if (!Number.isFinite(expirationTime) || expirationTime <= 0) {
45
+ throw new Error(`expirationTime must be a positive finite number, got ${expirationTime}`);
46
+ }
47
+ }
@@ -0,0 +1,49 @@
1
+ import { validateExpirationTime } from './expirableStore.ts';
2
+ import type { ExpirableStore, ExpirableStoreOptions } from './expirableStore.ts';
3
+
4
+ /**
5
+ * In-memory key-value store with timestamp-based expiration.
6
+ * Prunes all expired entries on every {@link set} call.
7
+ */
8
+ export class InMemoryExpirableStore<V> implements ExpirableStore<V> {
9
+ readonly expirationTime: number;
10
+ readonly #entries: Map<string, { value: V; timestamp: number }>;
11
+
12
+ constructor(options: ExpirableStoreOptions) {
13
+ validateExpirationTime(options.expirationTime);
14
+ this.expirationTime = options.expirationTime;
15
+ this.#entries = new Map();
16
+ }
17
+
18
+ get(key: string): Promise<V | undefined> {
19
+ const entry = this.#entries.get(key);
20
+ if (!entry) {
21
+ return Promise.resolve(undefined);
22
+ }
23
+ if (Date.now() - entry.timestamp > this.expirationTime) {
24
+ this.#entries.delete(key);
25
+ return Promise.resolve(undefined);
26
+ }
27
+ return Promise.resolve(entry.value);
28
+ }
29
+
30
+ set(key: string, value: V): Promise<void> {
31
+ this.#prune();
32
+ this.#entries.set(key, { value, timestamp: Date.now() });
33
+ return Promise.resolve();
34
+ }
35
+
36
+ delete(key: string): Promise<void> {
37
+ this.#entries.delete(key);
38
+ return Promise.resolve();
39
+ }
40
+
41
+ #prune(): void {
42
+ const now = Date.now();
43
+ for (const [key, entry] of this.#entries) {
44
+ if (now - entry.timestamp > this.expirationTime) {
45
+ this.#entries.delete(key);
46
+ }
47
+ }
48
+ }
49
+ }
@@ -0,0 +1,191 @@
1
+ import { validateExpirationTime } from './expirableStore.ts';
2
+ import type { ExpirableStore } from './expirableStore.ts';
3
+
4
+ interface ExpirableRecord {
5
+ key: string;
6
+ value: unknown;
7
+ timestamp: number;
8
+ }
9
+
10
+ export interface IndexedDBExpirableStoreOptions {
11
+ /**
12
+ * Name of the IndexedDB database.
13
+ */
14
+ dbName: string;
15
+ /**
16
+ * Name of the IndexedDB object store.
17
+ */
18
+ storeName: string;
19
+ /**
20
+ * Time in milliseconds after which entries expire.
21
+ */
22
+ expirationTime: number;
23
+ }
24
+
25
+ /**
26
+ * Key-value store backed by IndexedDB with time-based expiration.
27
+ * Enables sharing cached data across multiple instances and page reloads.
28
+ */
29
+ export class IndexedDBExpirableStore<V> implements ExpirableStore<V> {
30
+ readonly expirationTime: number;
31
+ readonly #dbName: string;
32
+ readonly #storeName: string;
33
+ #dbPromise: Promise<IDBDatabase> | null = null;
34
+
35
+ constructor(options: IndexedDBExpirableStoreOptions) {
36
+ if (typeof globalThis.indexedDB === 'undefined') {
37
+ throw new Error(
38
+ 'IndexedDBExpirableStore requires IndexedDB, which is not available in this environment',
39
+ );
40
+ }
41
+ validateExpirationTime(options.expirationTime);
42
+ this.#dbName = options.dbName;
43
+ this.#storeName = options.storeName;
44
+ this.expirationTime = options.expirationTime;
45
+ }
46
+
47
+ #getDb(): Promise<IDBDatabase> {
48
+ if (!this.#dbPromise) {
49
+ this.#dbPromise = this.#openDb().catch((error) => {
50
+ // Reset the cached promise so future calls can retry opening the DB
51
+ this.#dbPromise = null;
52
+ throw error;
53
+ });
54
+ }
55
+ return this.#dbPromise;
56
+ }
57
+
58
+ async #openDb(): Promise<IDBDatabase> {
59
+ const db = await this.#openRequest();
60
+
61
+ if (db.objectStoreNames.contains(this.#storeName)) {
62
+ return db;
63
+ }
64
+
65
+ // Object store is missing — close and reopen with a bumped version
66
+ // to trigger onupgradeneeded.
67
+ const nextVersion = db.version + 1;
68
+ db.close();
69
+ return this.#openRequest(nextVersion);
70
+ }
71
+
72
+ #openRequest(version?: number): Promise<IDBDatabase> {
73
+ const storeName = this.#storeName;
74
+
75
+ return new Promise<IDBDatabase>((resolve, reject) => {
76
+ const request = globalThis.indexedDB.open(this.#dbName, version);
77
+
78
+ request.onupgradeneeded = () => {
79
+ const db = request.result;
80
+ if (!db.objectStoreNames.contains(storeName)) {
81
+ db.createObjectStore(storeName, { keyPath: 'key' });
82
+ }
83
+ };
84
+
85
+ request.onsuccess = () => {
86
+ const db = request.result;
87
+
88
+ // Cooperatively close when another instance (or this store with a
89
+ // different storeName) requests a version upgrade. The next
90
+ // operation will re-acquire the connection via #getDb().
91
+ db.onversionchange = () => {
92
+ db.close();
93
+ this.#dbPromise = null;
94
+ };
95
+
96
+ resolve(db);
97
+ };
98
+
99
+ request.onerror = () => reject(request.error);
100
+ });
101
+ }
102
+
103
+ async get(key: string): Promise<V | undefined> {
104
+ const db = await this.#getDb();
105
+
106
+ return new Promise<V | undefined>((resolve, reject) => {
107
+ const tx = db.transaction(this.#storeName, 'readonly');
108
+ const store = tx.objectStore(this.#storeName);
109
+ const request = store.get(key);
110
+
111
+ request.onsuccess = () => {
112
+ const record = request.result as ExpirableRecord | undefined;
113
+ if (!record) {
114
+ resolve(undefined);
115
+ return;
116
+ }
117
+
118
+ if (Date.now() - record.timestamp > this.expirationTime) {
119
+ // Lazy expiration: delete expired entry and return undefined
120
+ this.delete(key).then(
121
+ () => resolve(undefined),
122
+ () => resolve(undefined),
123
+ );
124
+ return;
125
+ }
126
+
127
+ resolve(record.value as V);
128
+ };
129
+
130
+ request.onerror = () => reject(request.error);
131
+ });
132
+ }
133
+
134
+ async set(key: string, value: V): Promise<void> {
135
+ await this.#prune();
136
+ const db = await this.#getDb();
137
+
138
+ return new Promise<void>((resolve, reject) => {
139
+ const tx = db.transaction(this.#storeName, 'readwrite');
140
+ const store = tx.objectStore(this.#storeName);
141
+
142
+ const record: ExpirableRecord = {
143
+ key,
144
+ value,
145
+ timestamp: Date.now(),
146
+ };
147
+
148
+ store.put(record);
149
+ tx.oncomplete = () => resolve();
150
+ tx.onerror = () => reject(tx.error);
151
+ });
152
+ }
153
+
154
+ async delete(key: string): Promise<void> {
155
+ const db = await this.#getDb();
156
+
157
+ return new Promise<void>((resolve, reject) => {
158
+ const tx = db.transaction(this.#storeName, 'readwrite');
159
+ const store = tx.objectStore(this.#storeName);
160
+ store.delete(key);
161
+ tx.oncomplete = () => resolve();
162
+ tx.onerror = () => reject(tx.error);
163
+ });
164
+ }
165
+
166
+ async #prune(): Promise<void> {
167
+ const db = await this.#getDb();
168
+ const now = Date.now();
169
+
170
+ return new Promise<void>((resolve, reject) => {
171
+ const tx = db.transaction(this.#storeName, 'readwrite');
172
+ const store = tx.objectStore(this.#storeName);
173
+ const request = store.openCursor();
174
+
175
+ request.onsuccess = () => {
176
+ const cursor = request.result;
177
+ if (!cursor) {
178
+ return;
179
+ }
180
+ const record = cursor.value as ExpirableRecord;
181
+ if (now - record.timestamp > this.expirationTime) {
182
+ cursor.delete();
183
+ }
184
+ cursor.continue();
185
+ };
186
+
187
+ tx.oncomplete = () => resolve();
188
+ tx.onerror = () => reject(tx.error);
189
+ });
190
+ }
191
+ }
@@ -16,9 +16,9 @@ export const randomNumber = (): number => {
16
16
  return array[0];
17
17
  }
18
18
 
19
- type nodeCrypto = {
19
+ interface nodeCrypto {
20
20
  randomInt: (min: number, max: number) => number;
21
- };
21
+ }
22
22
 
23
23
  // determine whether node crypto is available
24
24
  if (typeof crypto !== 'undefined' && (crypto as unknown as nodeCrypto).randomInt) {
@@ -2,7 +2,7 @@ import { Principal } from '#principal';
2
2
  import * as cbor from '../cbor.ts';
3
3
  import { decodeLeb128 } from '../utils/leb.ts';
4
4
  import { bytesToHex, utf8ToBytes } from '@noble/hashes/utils';
5
- import { type DerEncodedPublicKey } from '../auth.ts';
5
+ import type { DerEncodedPublicKey } from '../auth.ts';
6
6
  import {
7
7
  type Cert,
8
8
  flatten_forks,
@@ -32,7 +32,7 @@ export type SubnetNodeKeys = Map<string, DerEncodedPublicKey>;
32
32
  /**
33
33
  * Represents the useful information about a subnet
34
34
  */
35
- export type BaseSubnetStatus = {
35
+ export interface BaseSubnetStatus {
36
36
  /**
37
37
  * The subnet ID
38
38
  */
@@ -45,7 +45,7 @@ export type BaseSubnetStatus = {
45
45
  * Not supported
46
46
  */
47
47
  metrics?: never;
48
- };
48
+ }
49
49
 
50
50
  /**
51
51
  * Base types of an entry on the status map.