@icp-sdk/core 4.2.3 → 5.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (474) hide show
  1. package/lib/cjs/agent/actor.d.ts +203 -0
  2. package/lib/cjs/agent/actor.d.ts.map +1 -0
  3. package/lib/cjs/agent/actor.js +341 -0
  4. package/lib/cjs/agent/actor.js.map +1 -0
  5. package/lib/cjs/agent/agent/api.d.ts +216 -0
  6. package/lib/cjs/agent/agent/api.d.ts.map +1 -0
  7. package/lib/cjs/agent/agent/api.js +39 -0
  8. package/lib/cjs/agent/agent/api.js.map +1 -0
  9. package/lib/cjs/agent/agent/http/__certificates__/goldenCertificates.d.ts +37 -0
  10. package/lib/cjs/agent/agent/http/__certificates__/goldenCertificates.d.ts.map +1 -0
  11. package/lib/cjs/agent/agent/http/__certificates__/goldenCertificates.js +51 -0
  12. package/lib/cjs/agent/agent/http/__certificates__/goldenCertificates.js.map +1 -0
  13. package/lib/cjs/agent/agent/http/index.d.ts +190 -0
  14. package/lib/cjs/agent/agent/http/index.d.ts.map +1 -0
  15. package/lib/cjs/agent/agent/http/index.js +1159 -0
  16. package/lib/cjs/agent/agent/http/index.js.map +1 -0
  17. package/lib/cjs/agent/agent/http/transforms.d.ts +54 -0
  18. package/lib/cjs/agent/agent/http/transforms.d.ts.map +1 -0
  19. package/lib/cjs/agent/agent/http/transforms.js +135 -0
  20. package/lib/cjs/agent/agent/http/transforms.js.map +1 -0
  21. package/lib/cjs/agent/agent/http/types.d.ts +81 -0
  22. package/lib/cjs/agent/agent/http/types.d.ts.map +1 -0
  23. package/lib/cjs/agent/agent/http/types.js +43 -0
  24. package/lib/cjs/agent/agent/http/types.js.map +1 -0
  25. package/lib/cjs/agent/agent/index.d.ts +3 -0
  26. package/lib/cjs/agent/agent/index.d.ts.map +1 -0
  27. package/lib/cjs/agent/agent/index.js +19 -0
  28. package/lib/cjs/agent/agent/index.js.map +1 -0
  29. package/lib/cjs/agent/auth.d.ts +91 -0
  30. package/lib/cjs/agent/auth.d.ts.map +1 -0
  31. package/lib/cjs/agent/auth.js +65 -0
  32. package/lib/cjs/agent/auth.js.map +1 -0
  33. package/lib/cjs/agent/canisterStatus/index.d.ts +61 -0
  34. package/lib/cjs/agent/canisterStatus/index.d.ts.map +1 -0
  35. package/lib/cjs/agent/canisterStatus/index.js +239 -0
  36. package/lib/cjs/agent/canisterStatus/index.js.map +1 -0
  37. package/lib/cjs/agent/cbor.d.ts +26 -0
  38. package/lib/cjs/agent/cbor.d.ts.map +1 -0
  39. package/lib/cjs/agent/cbor.js +93 -0
  40. package/lib/cjs/agent/cbor.js.map +1 -0
  41. package/lib/cjs/agent/certificate.d.ts +286 -0
  42. package/lib/cjs/agent/certificate.d.ts.map +1 -0
  43. package/lib/cjs/agent/certificate.js +762 -0
  44. package/lib/cjs/agent/certificate.js.map +1 -0
  45. package/lib/cjs/agent/constants.d.ts +18 -0
  46. package/lib/cjs/agent/constants.d.ts.map +1 -0
  47. package/lib/cjs/agent/constants.js +22 -0
  48. package/lib/cjs/agent/constants.js.map +1 -0
  49. package/lib/cjs/agent/der.d.ts +34 -0
  50. package/lib/cjs/agent/der.d.ts.map +1 -0
  51. package/lib/cjs/agent/der.js +175 -0
  52. package/lib/cjs/agent/der.js.map +1 -0
  53. package/lib/cjs/agent/errors.d.ts +386 -0
  54. package/lib/cjs/agent/errors.d.ts.map +1 -0
  55. package/lib/cjs/agent/errors.js +745 -0
  56. package/lib/cjs/agent/errors.js.map +1 -0
  57. package/lib/cjs/agent/fetch_candid.d.ts +9 -0
  58. package/lib/cjs/agent/fetch_candid.d.ts.map +1 -0
  59. package/lib/cjs/agent/fetch_candid.js +69 -0
  60. package/lib/cjs/agent/fetch_candid.js.map +1 -0
  61. package/lib/cjs/agent/index.d.ts +125 -1
  62. package/lib/cjs/agent/index.d.ts.map +1 -1
  63. package/lib/cjs/agent/index.js +142 -1
  64. package/lib/cjs/agent/index.js.map +1 -1
  65. package/lib/cjs/agent/observable.d.ts +24 -0
  66. package/lib/cjs/agent/observable.d.ts.map +1 -0
  67. package/lib/cjs/agent/observable.js +34 -0
  68. package/lib/cjs/agent/observable.js.map +1 -0
  69. package/lib/cjs/agent/polling/backoff.d.ts +50 -0
  70. package/lib/cjs/agent/polling/backoff.d.ts.map +1 -0
  71. package/lib/cjs/agent/polling/backoff.js +90 -0
  72. package/lib/cjs/agent/polling/backoff.js.map +1 -0
  73. package/lib/cjs/agent/polling/index.d.ts +63 -0
  74. package/lib/cjs/agent/polling/index.d.ts.map +1 -0
  75. package/lib/cjs/agent/polling/index.js +183 -0
  76. package/lib/cjs/agent/polling/index.js.map +1 -0
  77. package/lib/cjs/agent/polling/strategy.d.ts +52 -0
  78. package/lib/cjs/agent/polling/strategy.d.ts.map +1 -0
  79. package/lib/cjs/agent/polling/strategy.js +104 -0
  80. package/lib/cjs/agent/polling/strategy.js.map +1 -0
  81. package/lib/cjs/agent/public_key.d.ts +16 -0
  82. package/lib/cjs/agent/public_key.d.ts.map +1 -0
  83. package/lib/cjs/agent/public_key.js +52 -0
  84. package/lib/cjs/agent/public_key.js.map +1 -0
  85. package/lib/cjs/agent/request_id.d.ts +24 -0
  86. package/lib/cjs/agent/request_id.d.ts.map +1 -0
  87. package/lib/cjs/agent/request_id.js +88 -0
  88. package/lib/cjs/agent/request_id.js.map +1 -0
  89. package/lib/cjs/agent/subnetStatus/index.d.ts +70 -0
  90. package/lib/cjs/agent/subnetStatus/index.d.ts.map +1 -0
  91. package/lib/cjs/agent/subnetStatus/index.js +224 -0
  92. package/lib/cjs/agent/subnetStatus/index.js.map +1 -0
  93. package/lib/cjs/agent/utils/bls.d.ts +10 -0
  94. package/lib/cjs/agent/utils/bls.d.ts.map +1 -0
  95. package/lib/cjs/agent/utils/bls.js +20 -0
  96. package/lib/cjs/agent/utils/bls.js.map +1 -0
  97. package/lib/cjs/agent/utils/buffer.d.ts +22 -0
  98. package/lib/cjs/agent/utils/buffer.d.ts.map +1 -0
  99. package/lib/cjs/agent/utils/buffer.js +55 -0
  100. package/lib/cjs/agent/utils/buffer.js.map +1 -0
  101. package/lib/cjs/agent/utils/expirableMap.d.ts +80 -0
  102. package/lib/cjs/agent/utils/expirableMap.d.ts.map +1 -0
  103. package/lib/cjs/agent/utils/expirableMap.js +148 -0
  104. package/lib/cjs/agent/utils/expirableMap.js.map +1 -0
  105. package/lib/cjs/agent/utils/leb.d.ts +3 -0
  106. package/lib/cjs/agent/utils/leb.d.ts.map +1 -0
  107. package/lib/cjs/agent/utils/leb.js +17 -0
  108. package/lib/cjs/agent/utils/leb.js.map +1 -0
  109. package/lib/cjs/agent/utils/random.d.ts +6 -0
  110. package/lib/cjs/agent/utils/random.d.ts.map +1 -0
  111. package/lib/cjs/agent/utils/random.js +29 -0
  112. package/lib/cjs/agent/utils/random.js.map +1 -0
  113. package/lib/cjs/agent/utils/readState.d.ts +84 -0
  114. package/lib/cjs/agent/utils/readState.d.ts.map +1 -0
  115. package/lib/cjs/agent/utils/readState.js +149 -0
  116. package/lib/cjs/agent/utils/readState.js.map +1 -0
  117. package/lib/cjs/candid/candid-core.d.ts +72 -0
  118. package/lib/cjs/candid/candid-core.d.ts.map +1 -0
  119. package/lib/cjs/candid/candid-core.js +251 -0
  120. package/lib/cjs/candid/candid-core.js.map +1 -0
  121. package/lib/cjs/candid/candid-ui.d.ts +35 -0
  122. package/lib/cjs/candid/candid-ui.d.ts.map +1 -0
  123. package/lib/cjs/candid/candid-ui.js +317 -0
  124. package/lib/cjs/candid/candid-ui.js.map +1 -0
  125. package/lib/cjs/candid/idl.d.ts +579 -0
  126. package/lib/cjs/candid/idl.d.ts.map +1 -0
  127. package/lib/cjs/candid/idl.js +2228 -0
  128. package/lib/cjs/candid/idl.js.map +1 -0
  129. package/lib/cjs/candid/index.d.ts +30 -1
  130. package/lib/cjs/candid/index.d.ts.map +1 -1
  131. package/lib/cjs/candid/index.js +52 -1
  132. package/lib/cjs/candid/index.js.map +1 -1
  133. package/lib/cjs/candid/types.d.ts +6 -0
  134. package/lib/cjs/candid/types.d.ts.map +1 -0
  135. package/lib/cjs/candid/types.js +4 -0
  136. package/lib/cjs/candid/types.js.map +1 -0
  137. package/lib/cjs/candid/utils/bigint-math.d.ts +14 -0
  138. package/lib/cjs/candid/utils/bigint-math.d.ts.map +1 -0
  139. package/lib/cjs/candid/utils/bigint-math.js +30 -0
  140. package/lib/cjs/candid/utils/bigint-math.js.map +1 -0
  141. package/lib/cjs/candid/utils/buffer.d.ts +86 -0
  142. package/lib/cjs/candid/utils/buffer.d.ts.map +1 -0
  143. package/lib/cjs/candid/utils/buffer.js +191 -0
  144. package/lib/cjs/candid/utils/buffer.js.map +1 -0
  145. package/lib/cjs/candid/utils/hash.d.ts +7 -0
  146. package/lib/cjs/candid/utils/hash.d.ts.map +1 -0
  147. package/lib/cjs/candid/utils/hash.js +33 -0
  148. package/lib/cjs/candid/utils/hash.js.map +1 -0
  149. package/lib/cjs/candid/utils/leb128.d.ts +65 -0
  150. package/lib/cjs/candid/utils/leb128.d.ts.map +1 -0
  151. package/lib/cjs/candid/utils/leb128.js +228 -0
  152. package/lib/cjs/candid/utils/leb128.js.map +1 -0
  153. package/lib/cjs/identity/identity/delegation.d.ts +164 -0
  154. package/lib/cjs/identity/identity/delegation.d.ts.map +1 -0
  155. package/lib/cjs/identity/identity/delegation.js +302 -0
  156. package/lib/cjs/identity/identity/delegation.js.map +1 -0
  157. package/lib/cjs/identity/identity/ecdsa.d.ts +62 -0
  158. package/lib/cjs/identity/identity/ecdsa.d.ts.map +1 -0
  159. package/lib/cjs/identity/identity/ecdsa.js +117 -0
  160. package/lib/cjs/identity/identity/ecdsa.js.map +1 -0
  161. package/lib/cjs/identity/identity/ed25519.d.ts +67 -0
  162. package/lib/cjs/identity/identity/ed25519.d.ts.map +1 -0
  163. package/lib/cjs/identity/identity/ed25519.js +200 -0
  164. package/lib/cjs/identity/identity/ed25519.js.map +1 -0
  165. package/lib/cjs/identity/identity/partial.d.ts +34 -0
  166. package/lib/cjs/identity/identity/partial.d.ts.map +1 -0
  167. package/lib/cjs/identity/identity/partial.js +54 -0
  168. package/lib/cjs/identity/identity/partial.js.map +1 -0
  169. package/lib/cjs/identity/identity/webauthn.d.ts +51 -0
  170. package/lib/cjs/identity/identity/webauthn.d.ts.map +1 -0
  171. package/lib/cjs/identity/identity/webauthn.js +197 -0
  172. package/lib/cjs/identity/identity/webauthn.js.map +1 -0
  173. package/lib/cjs/identity/index.d.ts +38 -1
  174. package/lib/cjs/identity/index.d.ts.map +1 -1
  175. package/lib/cjs/identity/index.js +44 -1
  176. package/lib/cjs/identity/index.js.map +1 -1
  177. package/lib/cjs/identity/secp256k1/der.d.ts +33 -0
  178. package/lib/cjs/identity/secp256k1/der.d.ts.map +1 -0
  179. package/lib/cjs/identity/secp256k1/der.js +165 -0
  180. package/lib/cjs/identity/secp256k1/der.js.map +1 -0
  181. package/lib/cjs/identity/secp256k1/index.d.ts +51 -1
  182. package/lib/cjs/identity/secp256k1/index.d.ts.map +1 -1
  183. package/lib/cjs/identity/secp256k1/index.js +51 -1
  184. package/lib/cjs/identity/secp256k1/index.js.map +1 -1
  185. package/lib/cjs/identity/secp256k1/pem.d.ts +7 -0
  186. package/lib/cjs/identity/secp256k1/pem.d.ts.map +1 -0
  187. package/lib/cjs/identity/secp256k1/pem.js +75 -0
  188. package/lib/cjs/identity/secp256k1/pem.js.map +1 -0
  189. package/lib/cjs/identity/secp256k1/secp256k1.d.ts +87 -0
  190. package/lib/cjs/identity/secp256k1/secp256k1.d.ts.map +1 -0
  191. package/lib/cjs/identity/secp256k1/secp256k1.js +260 -0
  192. package/lib/cjs/identity/secp256k1/secp256k1.js.map +1 -0
  193. package/lib/cjs/principal/index.d.ts +18 -1
  194. package/lib/cjs/principal/index.d.ts.map +1 -1
  195. package/lib/cjs/principal/index.js +22 -1
  196. package/lib/cjs/principal/index.js.map +1 -1
  197. package/lib/cjs/principal/principal.d.ts +50 -0
  198. package/lib/cjs/principal/principal.d.ts.map +1 -0
  199. package/lib/cjs/principal/principal.js +148 -0
  200. package/lib/cjs/principal/principal.js.map +1 -0
  201. package/lib/cjs/principal/utils/base32.d.ts +10 -0
  202. package/lib/cjs/principal/utils/base32.d.ts.map +1 -0
  203. package/lib/cjs/principal/utils/base32.js +90 -0
  204. package/lib/cjs/principal/utils/base32.js.map +1 -0
  205. package/lib/cjs/principal/utils/getCrc.d.ts +6 -0
  206. package/lib/cjs/principal/utils/getCrc.d.ts.map +1 -0
  207. package/lib/cjs/principal/utils/getCrc.js +53 -0
  208. package/lib/cjs/principal/utils/getCrc.js.map +1 -0
  209. package/lib/esm/agent/actor.d.ts +203 -0
  210. package/lib/esm/agent/actor.d.ts.map +1 -0
  211. package/lib/esm/agent/actor.js +337 -0
  212. package/lib/esm/agent/actor.js.map +1 -0
  213. package/lib/esm/agent/agent/api.d.ts +216 -0
  214. package/lib/esm/agent/agent/api.d.ts.map +1 -0
  215. package/lib/esm/agent/agent/api.js +34 -0
  216. package/lib/esm/agent/agent/api.js.map +1 -0
  217. package/lib/esm/agent/agent/http/__certificates__/goldenCertificates.d.ts +37 -0
  218. package/lib/esm/agent/agent/http/__certificates__/goldenCertificates.d.ts.map +1 -0
  219. package/lib/esm/agent/agent/http/__certificates__/goldenCertificates.js +48 -0
  220. package/lib/esm/agent/agent/http/__certificates__/goldenCertificates.js.map +1 -0
  221. package/lib/esm/agent/agent/http/index.d.ts +190 -0
  222. package/lib/esm/agent/agent/http/index.d.ts.map +1 -0
  223. package/lib/esm/agent/agent/http/index.js +1117 -0
  224. package/lib/esm/agent/agent/http/index.js.map +1 -0
  225. package/lib/esm/agent/agent/http/transforms.d.ts +54 -0
  226. package/lib/esm/agent/agent/http/transforms.d.ts.map +1 -0
  227. package/lib/esm/agent/agent/http/transforms.js +128 -0
  228. package/lib/esm/agent/agent/http/transforms.js.map +1 -0
  229. package/lib/esm/agent/agent/http/types.d.ts +81 -0
  230. package/lib/esm/agent/agent/http/types.d.ts.map +1 -0
  231. package/lib/esm/agent/agent/http/types.js +39 -0
  232. package/lib/esm/agent/agent/http/types.js.map +1 -0
  233. package/lib/esm/agent/agent/index.d.ts +3 -0
  234. package/lib/esm/agent/agent/index.d.ts.map +1 -0
  235. package/lib/esm/agent/agent/index.js +3 -0
  236. package/lib/esm/agent/agent/index.js.map +1 -0
  237. package/lib/esm/agent/auth.d.ts +91 -0
  238. package/lib/esm/agent/auth.d.ts.map +1 -0
  239. package/lib/esm/agent/auth.js +59 -0
  240. package/lib/esm/agent/auth.js.map +1 -0
  241. package/lib/esm/agent/canister-env/index.d.ts +111 -1
  242. package/lib/esm/agent/canister-env/index.d.ts.map +1 -1
  243. package/lib/esm/agent/canister-env/index.js +111 -1
  244. package/lib/esm/agent/canister-env/index.js.map +1 -1
  245. package/lib/esm/agent/canisterStatus/index.d.ts +61 -0
  246. package/lib/esm/agent/canisterStatus/index.d.ts.map +1 -0
  247. package/lib/esm/agent/canisterStatus/index.js +199 -0
  248. package/lib/esm/agent/canisterStatus/index.js.map +1 -0
  249. package/lib/esm/agent/cbor.d.ts +26 -0
  250. package/lib/esm/agent/cbor.d.ts.map +1 -0
  251. package/lib/esm/agent/cbor.js +54 -0
  252. package/lib/esm/agent/cbor.js.map +1 -0
  253. package/lib/esm/agent/certificate.d.ts +286 -0
  254. package/lib/esm/agent/certificate.d.ts.map +1 -0
  255. package/lib/esm/agent/certificate.js +712 -0
  256. package/lib/esm/agent/certificate.js.map +1 -0
  257. package/lib/esm/agent/constants.d.ts +18 -0
  258. package/lib/esm/agent/constants.d.ts.map +1 -0
  259. package/lib/esm/agent/constants.js +19 -0
  260. package/lib/esm/agent/constants.js.map +1 -0
  261. package/lib/esm/agent/der.d.ts +34 -0
  262. package/lib/esm/agent/der.d.ts.map +1 -0
  263. package/lib/esm/agent/der.js +166 -0
  264. package/lib/esm/agent/der.js.map +1 -0
  265. package/lib/esm/agent/errors.d.ts +386 -0
  266. package/lib/esm/agent/errors.d.ts.map +1 -0
  267. package/lib/esm/agent/errors.js +689 -0
  268. package/lib/esm/agent/errors.js.map +1 -0
  269. package/lib/esm/agent/fetch_candid.d.ts +9 -0
  270. package/lib/esm/agent/fetch_candid.d.ts.map +1 -0
  271. package/lib/esm/agent/fetch_candid.js +33 -0
  272. package/lib/esm/agent/fetch_candid.js.map +1 -0
  273. package/lib/esm/agent/index.d.ts +125 -1
  274. package/lib/esm/agent/index.d.ts.map +1 -1
  275. package/lib/esm/agent/index.js +125 -1
  276. package/lib/esm/agent/index.js.map +1 -1
  277. package/lib/esm/agent/observable.d.ts +24 -0
  278. package/lib/esm/agent/observable.d.ts.map +1 -0
  279. package/lib/esm/agent/observable.js +29 -0
  280. package/lib/esm/agent/observable.js.map +1 -0
  281. package/lib/esm/agent/polling/backoff.d.ts +50 -0
  282. package/lib/esm/agent/polling/backoff.d.ts.map +1 -0
  283. package/lib/esm/agent/polling/backoff.js +85 -0
  284. package/lib/esm/agent/polling/backoff.js.map +1 -0
  285. package/lib/esm/agent/polling/index.d.ts +63 -0
  286. package/lib/esm/agent/polling/index.d.ts.map +1 -0
  287. package/lib/esm/agent/polling/index.js +144 -0
  288. package/lib/esm/agent/polling/index.js.map +1 -0
  289. package/lib/esm/agent/polling/strategy.d.ts +52 -0
  290. package/lib/esm/agent/polling/strategy.d.ts.map +1 -0
  291. package/lib/esm/agent/polling/strategy.js +94 -0
  292. package/lib/esm/agent/polling/strategy.js.map +1 -0
  293. package/lib/esm/agent/public_key.d.ts +16 -0
  294. package/lib/esm/agent/public_key.d.ts.map +1 -0
  295. package/lib/esm/agent/public_key.js +48 -0
  296. package/lib/esm/agent/public_key.js.map +1 -0
  297. package/lib/esm/agent/request_id.d.ts +24 -0
  298. package/lib/esm/agent/request_id.d.ts.map +1 -0
  299. package/lib/esm/agent/request_id.js +83 -0
  300. package/lib/esm/agent/request_id.js.map +1 -0
  301. package/lib/esm/agent/subnetStatus/index.d.ts +70 -0
  302. package/lib/esm/agent/subnetStatus/index.d.ts.map +1 -0
  303. package/lib/esm/agent/subnetStatus/index.js +183 -0
  304. package/lib/esm/agent/subnetStatus/index.js.map +1 -0
  305. package/lib/esm/agent/utils/bls.d.ts +10 -0
  306. package/lib/esm/agent/utils/bls.d.ts.map +1 -0
  307. package/lib/esm/agent/utils/bls.js +17 -0
  308. package/lib/esm/agent/utils/bls.js.map +1 -0
  309. package/lib/esm/agent/utils/buffer.d.ts +22 -0
  310. package/lib/esm/agent/utils/buffer.d.ts.map +1 -0
  311. package/lib/esm/agent/utils/buffer.js +50 -0
  312. package/lib/esm/agent/utils/buffer.js.map +1 -0
  313. package/lib/esm/agent/utils/expirableMap.d.ts +80 -0
  314. package/lib/esm/agent/utils/expirableMap.d.ts.map +1 -0
  315. package/lib/esm/agent/utils/expirableMap.js +144 -0
  316. package/lib/esm/agent/utils/expirableMap.js.map +1 -0
  317. package/lib/esm/agent/utils/leb.d.ts +3 -0
  318. package/lib/esm/agent/utils/leb.d.ts.map +1 -0
  319. package/lib/esm/agent/utils/leb.js +12 -0
  320. package/lib/esm/agent/utils/leb.js.map +1 -0
  321. package/lib/esm/agent/utils/random.d.ts +6 -0
  322. package/lib/esm/agent/utils/random.d.ts.map +1 -0
  323. package/lib/esm/agent/utils/random.js +25 -0
  324. package/lib/esm/agent/utils/random.js.map +1 -0
  325. package/lib/esm/agent/utils/readState.d.ts +84 -0
  326. package/lib/esm/agent/utils/readState.d.ts.map +1 -0
  327. package/lib/esm/agent/utils/readState.js +107 -0
  328. package/lib/esm/agent/utils/readState.js.map +1 -0
  329. package/lib/esm/candid/candid-core.d.ts +72 -0
  330. package/lib/esm/candid/candid-core.d.ts.map +1 -0
  331. package/lib/esm/candid/candid-core.js +241 -0
  332. package/lib/esm/candid/candid-core.js.map +1 -0
  333. package/lib/esm/candid/candid-ui.d.ts +35 -0
  334. package/lib/esm/candid/candid-ui.d.ts.map +1 -0
  335. package/lib/esm/candid/candid-ui.js +272 -0
  336. package/lib/esm/candid/candid-ui.js.map +1 -0
  337. package/lib/esm/candid/idl.d.ts +579 -0
  338. package/lib/esm/candid/idl.d.ts.map +1 -0
  339. package/lib/esm/candid/idl.js +2189 -0
  340. package/lib/esm/candid/idl.js.map +1 -0
  341. package/lib/esm/candid/index.d.ts +30 -1
  342. package/lib/esm/candid/index.d.ts.map +1 -1
  343. package/lib/esm/candid/index.js +29 -1
  344. package/lib/esm/candid/index.js.map +1 -1
  345. package/lib/esm/candid/types.d.ts +6 -0
  346. package/lib/esm/candid/types.d.ts.map +1 -0
  347. package/lib/esm/candid/types.js +3 -0
  348. package/lib/esm/candid/types.js.map +1 -0
  349. package/lib/esm/candid/utils/bigint-math.d.ts +14 -0
  350. package/lib/esm/candid/utils/bigint-math.d.ts.map +1 -0
  351. package/lib/esm/candid/utils/bigint-math.js +26 -0
  352. package/lib/esm/candid/utils/bigint-math.js.map +1 -0
  353. package/lib/esm/candid/utils/buffer.d.ts +86 -0
  354. package/lib/esm/candid/utils/buffer.d.ts.map +1 -0
  355. package/lib/esm/candid/utils/buffer.js +182 -0
  356. package/lib/esm/candid/utils/buffer.js.map +1 -0
  357. package/lib/esm/candid/utils/hash.d.ts +7 -0
  358. package/lib/esm/candid/utils/hash.d.ts.map +1 -0
  359. package/lib/esm/candid/utils/hash.js +30 -0
  360. package/lib/esm/candid/utils/hash.js.map +1 -0
  361. package/lib/esm/candid/utils/leb128.d.ts +65 -0
  362. package/lib/esm/candid/utils/leb128.d.ts.map +1 -0
  363. package/lib/esm/candid/utils/leb128.js +216 -0
  364. package/lib/esm/candid/utils/leb128.js.map +1 -0
  365. package/lib/esm/identity/identity/delegation.d.ts +164 -0
  366. package/lib/esm/identity/identity/delegation.d.ts.map +1 -0
  367. package/lib/esm/identity/identity/delegation.js +294 -0
  368. package/lib/esm/identity/identity/delegation.js.map +1 -0
  369. package/lib/esm/identity/identity/ecdsa.d.ts +62 -0
  370. package/lib/esm/identity/identity/ecdsa.d.ts.map +1 -0
  371. package/lib/esm/identity/identity/ecdsa.js +112 -0
  372. package/lib/esm/identity/identity/ecdsa.js.map +1 -0
  373. package/lib/esm/identity/identity/ed25519.d.ts +67 -0
  374. package/lib/esm/identity/identity/ed25519.d.ts.map +1 -0
  375. package/lib/esm/identity/identity/ed25519.js +195 -0
  376. package/lib/esm/identity/identity/ed25519.js.map +1 -0
  377. package/lib/esm/identity/identity/partial.d.ts +34 -0
  378. package/lib/esm/identity/identity/partial.d.ts.map +1 -0
  379. package/lib/esm/identity/identity/partial.js +50 -0
  380. package/lib/esm/identity/identity/partial.js.map +1 -0
  381. package/lib/esm/identity/identity/webauthn.d.ts +51 -0
  382. package/lib/esm/identity/identity/webauthn.d.ts.map +1 -0
  383. package/lib/esm/identity/identity/webauthn.js +192 -0
  384. package/lib/esm/identity/identity/webauthn.js.map +1 -0
  385. package/lib/esm/identity/index.d.ts +38 -1
  386. package/lib/esm/identity/index.d.ts.map +1 -1
  387. package/lib/esm/identity/index.js +38 -1
  388. package/lib/esm/identity/index.js.map +1 -1
  389. package/lib/esm/identity/secp256k1/der.d.ts +33 -0
  390. package/lib/esm/identity/secp256k1/der.d.ts.map +1 -0
  391. package/lib/esm/identity/secp256k1/der.js +156 -0
  392. package/lib/esm/identity/secp256k1/der.js.map +1 -0
  393. package/lib/esm/identity/secp256k1/index.d.ts +51 -1
  394. package/lib/esm/identity/secp256k1/index.d.ts.map +1 -1
  395. package/lib/esm/identity/secp256k1/index.js +51 -1
  396. package/lib/esm/identity/secp256k1/index.js.map +1 -1
  397. package/lib/esm/identity/secp256k1/pem.d.ts +7 -0
  398. package/lib/esm/identity/secp256k1/pem.d.ts.map +1 -0
  399. package/lib/esm/identity/secp256k1/pem.js +39 -0
  400. package/lib/esm/identity/secp256k1/pem.js.map +1 -0
  401. package/lib/esm/identity/secp256k1/secp256k1.d.ts +87 -0
  402. package/lib/esm/identity/secp256k1/secp256k1.d.ts.map +1 -0
  403. package/lib/esm/identity/secp256k1/secp256k1.js +222 -0
  404. package/lib/esm/identity/secp256k1/secp256k1.js.map +1 -0
  405. package/lib/esm/principal/index.d.ts +18 -1
  406. package/lib/esm/principal/index.d.ts.map +1 -1
  407. package/lib/esm/principal/index.js +18 -1
  408. package/lib/esm/principal/index.js.map +1 -1
  409. package/lib/esm/principal/principal.d.ts +50 -0
  410. package/lib/esm/principal/principal.d.ts.map +1 -0
  411. package/lib/esm/principal/principal.js +144 -0
  412. package/lib/esm/principal/principal.js.map +1 -0
  413. package/lib/esm/principal/utils/base32.d.ts +10 -0
  414. package/lib/esm/principal/utils/base32.d.ts.map +1 -0
  415. package/lib/esm/principal/utils/base32.js +86 -0
  416. package/lib/esm/principal/utils/base32.js.map +1 -0
  417. package/lib/esm/principal/utils/getCrc.d.ts +6 -0
  418. package/lib/esm/principal/utils/getCrc.d.ts.map +1 -0
  419. package/lib/esm/principal/utils/getCrc.js +50 -0
  420. package/lib/esm/principal/utils/getCrc.js.map +1 -0
  421. package/package.json +17 -11
  422. package/src/agent/actor.ts +576 -0
  423. package/src/agent/agent/api.ts +262 -0
  424. package/src/agent/agent/http/index.ts +1518 -0
  425. package/src/agent/agent/http/transforms.ts +158 -0
  426. package/src/agent/agent/http/types.ts +126 -0
  427. package/src/agent/agent/index.ts +2 -0
  428. package/src/agent/auth.ts +147 -0
  429. package/src/agent/canister-env/index.ts +192 -1
  430. package/src/agent/canisterStatus/index.ts +267 -0
  431. package/src/agent/cbor.ts +63 -0
  432. package/src/agent/certificate.ts +1060 -0
  433. package/src/agent/constants.ts +24 -0
  434. package/src/agent/der.ts +170 -0
  435. package/src/agent/errors.ts +881 -0
  436. package/src/agent/fetch_candid.ts +37 -0
  437. package/src/agent/index.ts +131 -1
  438. package/src/agent/observable.ts +49 -0
  439. package/src/agent/polling/backoff.ts +130 -0
  440. package/src/agent/polling/index.ts +250 -0
  441. package/src/agent/polling/strategy.ts +144 -0
  442. package/src/agent/public_key.ts +65 -0
  443. package/src/agent/request_id.ts +92 -0
  444. package/src/agent/subnetStatus/index.ts +270 -0
  445. package/src/agent/utils/bls.ts +18 -0
  446. package/src/agent/utils/buffer.ts +60 -0
  447. package/src/agent/utils/expirableMap.ts +163 -0
  448. package/src/agent/utils/leb.ts +14 -0
  449. package/src/agent/utils/random.ts +30 -0
  450. package/src/agent/utils/readState.ts +180 -0
  451. package/src/candid/candid-core.ts +276 -0
  452. package/src/candid/candid-ui.ts +289 -0
  453. package/src/candid/idl.ts +2556 -0
  454. package/src/candid/index.ts +35 -1
  455. package/src/candid/types.ts +7 -0
  456. package/src/candid/utils/bigint-math.ts +26 -0
  457. package/src/candid/utils/buffer.ts +221 -0
  458. package/src/candid/utils/hash.ts +31 -0
  459. package/src/candid/utils/leb128.ts +234 -0
  460. package/src/identity/identity/delegation.ts +411 -0
  461. package/src/identity/identity/ecdsa.ts +158 -0
  462. package/src/identity/identity/ed25519.ts +239 -0
  463. package/src/identity/identity/partial.ts +60 -0
  464. package/src/identity/identity/webauthn.ts +265 -0
  465. package/src/identity/index.ts +39 -1
  466. package/src/identity/secp256k1/der.ts +156 -0
  467. package/src/identity/secp256k1/index.ts +52 -1
  468. package/src/identity/secp256k1/pem.ts +40 -0
  469. package/src/identity/secp256k1/secp256k1.ts +270 -0
  470. package/src/package.json +4 -0
  471. package/src/principal/index.ts +19 -1
  472. package/src/principal/principal.ts +171 -0
  473. package/src/principal/utils/base32.ts +101 -0
  474. package/src/principal/utils/getCrc.ts +52 -0
@@ -0,0 +1,183 @@
1
+ import { Principal } from '../../principal/index.js';
2
+ import { CertificateVerificationErrorCode, MissingRootKeyErrorCode, ExternalError, AgentError, UnknownError, UnexpectedErrorCode, CertificateTimeErrorCode, ProtocolError, LookupErrorCode, } from "../errors.js";
3
+ import { Certificate, lookupResultToBuffer, decodeCanisterRanges, lookup_path, LookupPathStatus, } from "../certificate.js";
4
+ import * as cbor from "../cbor.js";
5
+ import { decodeTime } from "../utils/leb.js";
6
+ import { utf8ToBytes } from '@noble/hashes/utils';
7
+ import { decodeValue, isCustomPath, lookupNodeKeysFromCertificate, } from "../utils/readState.js";
8
+ // Re-export shared types and functions
9
+ export { CustomPath, IC_ROOT_SUBNET_ID } from "../utils/readState.js";
10
+ /**
11
+ * Requests information from a subnet's `read_state` endpoint.
12
+ * Can be used to request information about the subnet's time, canister ranges, public key, node keys, and metrics.
13
+ * @param {SubnetStatusOptions} options The configuration for the subnet status request.
14
+ * @see {@link SubnetStatusOptions} for detailed options.
15
+ * @returns {Promise<StatusMap>} A map populated with data from the requested paths. Each path is a key in the map, and the value is the data obtained from the certificate for that path.
16
+ * @example
17
+ * const status = await subnetStatus.request({
18
+ * subnetId: IC_ROOT_SUBNET_ID,
19
+ * paths: ['time', 'nodeKeys'],
20
+ * agent,
21
+ * });
22
+ *
23
+ * const time = status.get('time');
24
+ * const nodeKeys = status.get('nodeKeys');
25
+ */
26
+ export async function request(options) {
27
+ const { agent, paths, disableCertificateTimeVerification = false } = options;
28
+ const subnetId = Principal.from(options.subnetId);
29
+ const uniquePaths = [...new Set(paths)];
30
+ const status = new Map();
31
+ const promises = uniquePaths.map((path, index) => {
32
+ const encodedPath = encodePath(path, subnetId);
33
+ return (async () => {
34
+ try {
35
+ if (agent.rootKey === null) {
36
+ throw ExternalError.fromCode(new MissingRootKeyErrorCode());
37
+ }
38
+ const rootKey = agent.rootKey;
39
+ const response = await agent.readSubnetState(subnetId, {
40
+ paths: [encodedPath],
41
+ });
42
+ const certificate = await Certificate.create({
43
+ certificate: response.certificate,
44
+ rootKey,
45
+ principal: { subnetId },
46
+ disableTimeVerification: disableCertificateTimeVerification,
47
+ agent,
48
+ });
49
+ const lookup = (cert, lookupPath) => {
50
+ if (lookupPath === 'nodeKeys') {
51
+ // For node keys, we need to parse the certificate directly
52
+ const data = lookupNodeKeysFromCertificate(cert.cert, subnetId);
53
+ return {
54
+ path: lookupPath,
55
+ data,
56
+ };
57
+ }
58
+ else {
59
+ return {
60
+ path: lookupPath,
61
+ data: lookupResultToBuffer(cert.lookup_path(encodedPath)),
62
+ };
63
+ }
64
+ };
65
+ const { path, data } = lookup(certificate, uniquePaths[index]);
66
+ if (!data) {
67
+ console.warn(`Expected to find result for path ${path}, but instead found nothing.`);
68
+ if (typeof path === 'string') {
69
+ status.set(path, null);
70
+ }
71
+ else {
72
+ status.set(path.key, null);
73
+ }
74
+ }
75
+ else {
76
+ switch (path) {
77
+ case 'time': {
78
+ status.set(path, decodeTime(data));
79
+ break;
80
+ }
81
+ case 'canisterRanges': {
82
+ status.set(path, decodeCanisterRanges(data));
83
+ break;
84
+ }
85
+ case 'publicKey': {
86
+ status.set(path, data);
87
+ break;
88
+ }
89
+ case 'nodeKeys': {
90
+ status.set(path, data);
91
+ break;
92
+ }
93
+ default: {
94
+ // Check for CustomPath signature
95
+ if (isCustomPath(path)) {
96
+ status.set(path.key, decodeValue(data, path.decodeStrategy));
97
+ }
98
+ }
99
+ }
100
+ }
101
+ }
102
+ catch (error) {
103
+ // Throw on certificate errors
104
+ if (error instanceof AgentError &&
105
+ (error.hasCode(CertificateVerificationErrorCode) ||
106
+ error.hasCode(CertificateTimeErrorCode))) {
107
+ throw error;
108
+ }
109
+ if (isCustomPath(path)) {
110
+ status.set(path.key, null);
111
+ }
112
+ else {
113
+ status.set(path, null);
114
+ }
115
+ console.group();
116
+ console.warn(`Expected to find result for path ${path}, but instead found nothing.`);
117
+ console.warn(error);
118
+ console.groupEnd();
119
+ }
120
+ })();
121
+ });
122
+ // Fetch all values separately, as each option can fail
123
+ await Promise.all(promises);
124
+ return status;
125
+ }
126
+ /**
127
+ * Fetch subnet info including node keys from a certificate
128
+ * @param certificate the certificate bytes
129
+ * @param subnetId the subnet ID
130
+ * @returns SubnetStatus with subnet ID and node keys
131
+ */
132
+ export function lookupSubnetInfo(certificate, subnetId) {
133
+ const cert = cbor.decode(certificate);
134
+ const nodeKeys = lookupNodeKeysFromCertificate(cert, subnetId);
135
+ const publicKey = lookupSubnetPublicKey(cert, subnetId);
136
+ return {
137
+ subnetId: subnetId.toText(),
138
+ nodeKeys,
139
+ publicKey,
140
+ };
141
+ }
142
+ function lookupSubnetPublicKey(certificate, subnetId) {
143
+ const subnetLookupResult = lookup_path(['subnet', subnetId.toUint8Array(), 'public_key'], certificate.tree);
144
+ if (subnetLookupResult.status !== LookupPathStatus.Found) {
145
+ throw ProtocolError.fromCode(new LookupErrorCode('Public key not found', subnetLookupResult.status));
146
+ }
147
+ return subnetLookupResult.value;
148
+ }
149
+ /**
150
+ * Encode a path for subnet state queries
151
+ * @param path the path to encode
152
+ * @param subnetId the subnet ID
153
+ * @returns the encoded path as an array of Uint8Arrays
154
+ */
155
+ export function encodePath(path, subnetId) {
156
+ const subnetUint8Array = subnetId.toUint8Array();
157
+ switch (path) {
158
+ case 'time':
159
+ return [utf8ToBytes('time')];
160
+ case 'canisterRanges':
161
+ return [utf8ToBytes('canister_ranges'), subnetUint8Array];
162
+ case 'publicKey':
163
+ return [utf8ToBytes('subnet'), subnetUint8Array, utf8ToBytes('public_key')];
164
+ case 'nodeKeys':
165
+ return [utf8ToBytes('subnet'), subnetUint8Array, utf8ToBytes('node')];
166
+ default: {
167
+ // Check for CustomPath signature
168
+ if (isCustomPath(path)) {
169
+ if (typeof path['path'] === 'string' || path['path'] instanceof Uint8Array) {
170
+ // For string paths, treat as a subnet path segment
171
+ const encoded = typeof path['path'] === 'string' ? utf8ToBytes(path['path']) : path['path'];
172
+ return [utf8ToBytes('subnet'), subnetUint8Array, encoded];
173
+ }
174
+ else {
175
+ // For non-simple paths, return the provided custom path
176
+ return path['path'];
177
+ }
178
+ }
179
+ }
180
+ }
181
+ throw UnknownError.fromCode(new UnexpectedErrorCode(`Error while encoding your path for subnet status. Please ensure that your path ${path} was formatted correctly.`));
182
+ }
183
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/agent/subnetStatus/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EACL,gCAAgC,EAChC,uBAAuB,EACvB,aAAa,EACb,UAAU,EACV,YAAY,EAC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zB,IAAI,mBAAmB,CACrB,kFAAkF,IAAI,2BAA2B,CAClH,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,10 @@
1
+ export declare let verify: (pk: Uint8Array, sig: Uint8Array, msg: Uint8Array) => boolean;
2
+ /**
3
+ *
4
+ * @param pk primary key: Uint8Array
5
+ * @param sig signature: Uint8Array
6
+ * @param msg message: Uint8Array
7
+ * @returns boolean
8
+ */
9
+ export declare function blsVerify(pk: Uint8Array, sig: Uint8Array, msg: Uint8Array): boolean;
10
+ //# sourceMappingURL=bls.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bls.d.ts","sourceRoot":"","sources":["../../../../src/agent/utils/bls.ts"],"names":[],"mappings":"AAGA,eAAO,IAAI,MAAM,EAAE,CAAC,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,KAAK,OAAO,CAAC;AAEjF;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAKnF"}
@@ -0,0 +1,17 @@
1
+ import { bls12_381 } from '@noble/curves/bls12-381';
2
+ import { bytesToHex } from '@noble/hashes/utils';
3
+ export let verify;
4
+ /**
5
+ *
6
+ * @param pk primary key: Uint8Array
7
+ * @param sig signature: Uint8Array
8
+ * @param msg message: Uint8Array
9
+ * @returns boolean
10
+ */
11
+ export function blsVerify(pk, sig, msg) {
12
+ const primaryKey = typeof pk === 'string' ? pk : bytesToHex(pk);
13
+ const signature = typeof sig === 'string' ? sig : bytesToHex(sig);
14
+ const message = typeof msg === 'string' ? msg : bytesToHex(msg);
15
+ return bls12_381.verifyShortSignature(signature, message, primaryKey);
16
+ }
17
+ //# sourceMappingURL=bls.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bls.js","sourceRoot":"","sources":["../../../../src/agent/utils/bls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,MAAM,CAAC,IAAI,MAAqE,CAAC;AAEjF;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,EAAc,EAAE,GAAe,EAAE,GAAe;IACxE,MAAM,UAAU,GAAG,OAAO,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IAChE,MAAM,SAAS,GAAG,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IAClE,MAAM,OAAO,GAAG,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IAChE,OAAO,SAAS,CAAC,oBAAoB,CAAC,SAAS,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;AACxE,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Returns a true Uint8Array from an ArrayBufferLike object.
3
+ * @param bufLike a buffer-like object
4
+ * @returns Uint8Array
5
+ */
6
+ export declare function uint8FromBufLike(bufLike: ArrayBuffer | Uint8Array | DataView | ArrayBufferView | ArrayBufferLike | [number] | number[] | {
7
+ buffer: ArrayBuffer;
8
+ }): Uint8Array;
9
+ /**
10
+ * Returns a true ArrayBuffer from a Uint8Array, as Uint8Array.buffer is unsafe.
11
+ * @param {Uint8Array} arr Uint8Array to convert
12
+ * @returns ArrayBuffer
13
+ */
14
+ export declare function uint8ToBuf(arr: Uint8Array): ArrayBuffer;
15
+ /**
16
+ * Compares two Uint8Arrays for equality.
17
+ * @param a The first Uint8Array.
18
+ * @param b The second Uint8Array.
19
+ * @returns True if the Uint8Arrays are equal, false otherwise.
20
+ */
21
+ export declare function uint8Equals(a: Uint8Array, b: Uint8Array): boolean;
22
+ //# sourceMappingURL=buffer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buffer.d.ts","sourceRoot":"","sources":["../../../../src/agent/utils/buffer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EACH,WAAW,GACX,UAAU,GACV,QAAQ,GACR,eAAe,GACf,eAAe,GACf,CAAC,MAAM,CAAC,GACR,MAAM,EAAE,GACR;IAAE,MAAM,EAAE,WAAW,CAAA;CAAE,GAC1B,UAAU,CAkBZ;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,UAAU,GAAG,WAAW,CAKvD;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,GAAG,OAAO,CAMjE"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Returns a true Uint8Array from an ArrayBufferLike object.
3
+ * @param bufLike a buffer-like object
4
+ * @returns Uint8Array
5
+ */
6
+ export function uint8FromBufLike(bufLike) {
7
+ if (!bufLike) {
8
+ throw new Error('Input cannot be null or undefined');
9
+ }
10
+ if (bufLike instanceof Uint8Array) {
11
+ return bufLike;
12
+ }
13
+ if (bufLike instanceof ArrayBuffer) {
14
+ return new Uint8Array(bufLike);
15
+ }
16
+ if (Array.isArray(bufLike)) {
17
+ return new Uint8Array(bufLike);
18
+ }
19
+ if ('buffer' in bufLike) {
20
+ return uint8FromBufLike(bufLike.buffer);
21
+ }
22
+ return new Uint8Array(bufLike);
23
+ }
24
+ /**
25
+ * Returns a true ArrayBuffer from a Uint8Array, as Uint8Array.buffer is unsafe.
26
+ * @param {Uint8Array} arr Uint8Array to convert
27
+ * @returns ArrayBuffer
28
+ */
29
+ export function uint8ToBuf(arr) {
30
+ const buf = new ArrayBuffer(arr.byteLength);
31
+ const view = new Uint8Array(buf);
32
+ view.set(arr);
33
+ return buf;
34
+ }
35
+ /**
36
+ * Compares two Uint8Arrays for equality.
37
+ * @param a The first Uint8Array.
38
+ * @param b The second Uint8Array.
39
+ * @returns True if the Uint8Arrays are equal, false otherwise.
40
+ */
41
+ export function uint8Equals(a, b) {
42
+ if (a.length !== b.length)
43
+ return false;
44
+ for (let i = 0; i < a.length; i++) {
45
+ if (a[i] !== b[i])
46
+ return false;
47
+ }
48
+ return true;
49
+ }
50
+ //# sourceMappingURL=buffer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buffer.js","sourceRoot":"","sources":["../../../../src/agent/utils/buffer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAC9B,OAQ2B;IAE3B,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IACvD,CAAC;IAED,IAAI,OAAO,YAAY,UAAU,EAAE,CAAC;QAClC,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,IAAI,OAAO,YAAY,WAAW,EAAE,CAAC;QACnC,OAAO,IAAI,UAAU,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3B,OAAO,IAAI,UAAU,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IACD,IAAI,QAAQ,IAAI,OAAO,EAAE,CAAC;QACxB,OAAO,gBAAgB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,IAAI,UAAU,CAAC,OAAO,CAAC,CAAC;AACjC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,GAAe;IACxC,MAAM,GAAG,GAAG,IAAI,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC5C,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC;IACjC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACd,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,CAAa,EAAE,CAAa;IACtD,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IACxC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAClC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAAE,OAAO,KAAK,CAAC;IAClC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,80 @@
1
+ export type ExpirableMapOptions<K, V> = {
2
+ source?: Iterable<[K, V]>;
3
+ expirationTime?: number;
4
+ };
5
+ /**
6
+ * A map that expires entries after a given time.
7
+ * Defaults to 10 minutes.
8
+ */
9
+ export declare class ExpirableMap<K, V> implements Map<K, V> {
10
+ #private;
11
+ [Symbol.iterator]: () => MapIterator<[K, V]>;
12
+ [Symbol.toStringTag]: string;
13
+ /**
14
+ * Create a new ExpirableMap.
15
+ * @param {ExpirableMapOptions<any, any>} options - options for the map.
16
+ * @param {Iterable<[any, any]>} options.source - an optional source of entries to initialize the map with.
17
+ * @param {number} options.expirationTime - the time in milliseconds after which entries will expire.
18
+ */
19
+ constructor(options?: ExpirableMapOptions<K, V>);
20
+ /**
21
+ * Prune removes all expired entries.
22
+ */
23
+ prune(): this;
24
+ /**
25
+ * Set the value for the given key. Prunes expired entries.
26
+ * @param key for the entry
27
+ * @param value of the entry
28
+ * @returns this
29
+ */
30
+ set(key: K, value: V): this;
31
+ /**
32
+ * Get the value associated with the key, if it exists and has not expired.
33
+ * @param key K
34
+ * @returns the value associated with the key, or undefined if the key is not present or has expired.
35
+ */
36
+ get(key: K): V | undefined;
37
+ /**
38
+ * Clear all entries.
39
+ */
40
+ clear(): void;
41
+ /**
42
+ * Entries returns the entries of the map, without the expiration time.
43
+ * @returns an iterator over the entries of the map.
44
+ */
45
+ entries(): MapIterator<[K, V]>;
46
+ /**
47
+ * Values returns the values of the map, without the expiration time.
48
+ * @returns an iterator over the values of the map.
49
+ */
50
+ values(): MapIterator<V>;
51
+ /**
52
+ * Keys returns the keys of the map
53
+ * @returns an iterator over the keys of the map.
54
+ */
55
+ keys(): MapIterator<K>;
56
+ /**
57
+ * forEach calls the callbackfn on each entry of the map.
58
+ * @param callbackfn to call on each entry
59
+ * @param thisArg to use as this when calling the callbackfn
60
+ */
61
+ forEach(callbackfn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: ExpirableMap<K, V>): void;
62
+ /**
63
+ * has returns true if the key exists and has not expired.
64
+ * @param key K
65
+ * @returns true if the key exists and has not expired.
66
+ */
67
+ has(key: K): boolean;
68
+ /**
69
+ * delete the entry for the given key.
70
+ * @param key K
71
+ * @returns true if the key existed and has been deleted.
72
+ */
73
+ delete(key: K): boolean;
74
+ /**
75
+ * get size of the map.
76
+ * @returns the size of the map.
77
+ */
78
+ get size(): number;
79
+ }
80
+ //# sourceMappingURL=expirableMap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expirableMap.d.ts","sourceRoot":"","sources":["../../../../src/agent/utils/expirableMap.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,CAAC,CAAC,EAAE,CAAC,IAAI;IACtC,MAAM,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF;;;GAGG;AACH,qBAAa,YAAY,CAAC,CAAC,EAAE,CAAC,CAAE,YAAW,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;;IAKlD,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAA2B;IACvE,CAAC,MAAM,CAAC,WAAW,CAAC,SAAkB;IAEtC;;;;;OAKG;gBACS,OAAO,GAAE,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAM;IASnD;;OAEG;IACH,KAAK;IAYL;;;;;OAKG;IACH,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC;IAWpB;;;;OAIG;IACH,GAAG,CAAC,GAAG,EAAE,CAAC;IAYV;;OAEG;IACH,KAAK;IAIL;;;OAGG;IACH,OAAO,IAAI,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAW9B;;;OAGG;IACH,MAAM,IAAI,WAAW,CAAC,CAAC,CAAC;IAWxB;;;OAGG;IACH,IAAI,IAAI,WAAW,CAAC,CAAC,CAAC;IAItB;;;;OAIG;IACH,OAAO,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,IAAI,EAAE,OAAO,CAAC,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC;IAM5F;;;;OAIG;IACH,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO;IAIpB;;;;OAIG;IACH,MAAM,CAAC,GAAG,EAAE,CAAC;IAIb;;;OAGG;IACH,IAAI,IAAI,WAEP;CACF"}
@@ -0,0 +1,144 @@
1
+ var _a, _b;
2
+ /**
3
+ * A map that expires entries after a given time.
4
+ * Defaults to 10 minutes.
5
+ */
6
+ export class ExpirableMap {
7
+ static { _a = Symbol.iterator, _b = Symbol.toStringTag; }
8
+ // Internals
9
+ #inner;
10
+ #expirationTime;
11
+ /**
12
+ * Create a new ExpirableMap.
13
+ * @param {ExpirableMapOptions<any, any>} options - options for the map.
14
+ * @param {Iterable<[any, any]>} options.source - an optional source of entries to initialize the map with.
15
+ * @param {number} options.expirationTime - the time in milliseconds after which entries will expire.
16
+ */
17
+ constructor(options = {}) {
18
+ this[_a] = this.entries.bind(this);
19
+ this[_b] = 'ExpirableMap';
20
+ const { source = [], expirationTime = 10 * 60 * 1000 } = options;
21
+ const currentTime = Date.now();
22
+ this.#inner = new Map([...source].map(([key, value]) => [key, { value, timestamp: currentTime }]));
23
+ this.#expirationTime = expirationTime;
24
+ }
25
+ /**
26
+ * Prune removes all expired entries.
27
+ */
28
+ prune() {
29
+ const currentTime = Date.now();
30
+ for (const [key, entry] of this.#inner.entries()) {
31
+ if (currentTime - entry.timestamp > this.#expirationTime) {
32
+ this.#inner.delete(key);
33
+ }
34
+ }
35
+ return this;
36
+ }
37
+ // Implementing the Map interface
38
+ /**
39
+ * Set the value for the given key. Prunes expired entries.
40
+ * @param key for the entry
41
+ * @param value of the entry
42
+ * @returns this
43
+ */
44
+ set(key, value) {
45
+ this.prune();
46
+ const entry = {
47
+ value,
48
+ timestamp: Date.now(),
49
+ };
50
+ this.#inner.set(key, entry);
51
+ return this;
52
+ }
53
+ /**
54
+ * Get the value associated with the key, if it exists and has not expired.
55
+ * @param key K
56
+ * @returns the value associated with the key, or undefined if the key is not present or has expired.
57
+ */
58
+ get(key) {
59
+ const entry = this.#inner.get(key);
60
+ if (entry === undefined) {
61
+ return undefined;
62
+ }
63
+ if (Date.now() - entry.timestamp > this.#expirationTime) {
64
+ this.#inner.delete(key);
65
+ return undefined;
66
+ }
67
+ return entry.value;
68
+ }
69
+ /**
70
+ * Clear all entries.
71
+ */
72
+ clear() {
73
+ this.#inner.clear();
74
+ }
75
+ /**
76
+ * Entries returns the entries of the map, without the expiration time.
77
+ * @returns an iterator over the entries of the map.
78
+ */
79
+ entries() {
80
+ const iterator = this.#inner.entries();
81
+ const generator = function* () {
82
+ for (const [key, value] of iterator) {
83
+ yield [key, value.value];
84
+ }
85
+ return undefined;
86
+ };
87
+ return generator();
88
+ }
89
+ /**
90
+ * Values returns the values of the map, without the expiration time.
91
+ * @returns an iterator over the values of the map.
92
+ */
93
+ values() {
94
+ const iterator = this.#inner.values();
95
+ const generator = function* () {
96
+ for (const value of iterator) {
97
+ yield value.value;
98
+ }
99
+ return undefined;
100
+ };
101
+ return generator();
102
+ }
103
+ /**
104
+ * Keys returns the keys of the map
105
+ * @returns an iterator over the keys of the map.
106
+ */
107
+ keys() {
108
+ return this.#inner.keys();
109
+ }
110
+ /**
111
+ * forEach calls the callbackfn on each entry of the map.
112
+ * @param callbackfn to call on each entry
113
+ * @param thisArg to use as this when calling the callbackfn
114
+ */
115
+ forEach(callbackfn, thisArg) {
116
+ for (const [key, value] of this.#inner.entries()) {
117
+ callbackfn.call(thisArg, value.value, key, this);
118
+ }
119
+ }
120
+ /**
121
+ * has returns true if the key exists and has not expired.
122
+ * @param key K
123
+ * @returns true if the key exists and has not expired.
124
+ */
125
+ has(key) {
126
+ return this.#inner.has(key);
127
+ }
128
+ /**
129
+ * delete the entry for the given key.
130
+ * @param key K
131
+ * @returns true if the key existed and has been deleted.
132
+ */
133
+ delete(key) {
134
+ return this.#inner.delete(key);
135
+ }
136
+ /**
137
+ * get size of the map.
138
+ * @returns the size of the map.
139
+ */
140
+ get size() {
141
+ return this.#inner.size;
142
+ }
143
+ }
144
+ //# sourceMappingURL=expirableMap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expirableMap.js","sourceRoot":"","sources":["../../../../src/agent/utils/expirableMap.ts"],"names":[],"mappings":";AAKA;;;GAGG;AACH,MAAM,OAAO,YAAY;kBAKtB,MAAM,CAAC,QAAQ,OACf,MAAM,CAAC,WAAW;IALnB,YAAY;IACZ,MAAM,CAA0C;IAChD,eAAe,CAAS;IAKxB;;;;;OAKG;IACH,YAAY,UAAqC,EAAE;QATnD,QAAiB,GAA8B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvE,QAAoB,GAAG,cAAc,CAAC;QASpC,MAAM,EAAE,MAAM,GAAG,EAAE,EAAE,cAAc,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;QACjE,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC/B,IA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CAAC;QACnD,CAAC;IACH,CAAC;IAED;;;;OAIG;IACH,GAAG,CAAC,GAAM;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC9B,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,GAAM;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACjC,CAAC;IAED;;;OAGG;IACH,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IAC1B,CAAC;CACF"}
@@ -0,0 +1,3 @@
1
+ export declare const decodeLeb128: (buf: Uint8Array) => bigint;
2
+ export declare const decodeTime: (buf: Uint8Array) => Date;
3
+ //# sourceMappingURL=leb.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"leb.d.ts","sourceRoot":"","sources":["../../../../src/agent/utils/leb.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,YAAY,GAAI,KAAK,UAAU,KAAG,MAE9C,CAAC;AAGF,eAAO,MAAM,UAAU,GAAI,KAAK,UAAU,KAAG,IAI5C,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { PipeArrayBuffer, lebDecode } from '../../candid/index.js';
2
+ const MILLISECOND_TO_NANOSECONDS = BigInt(1_000_000);
3
+ export const decodeLeb128 = (buf) => {
4
+ return lebDecode(new PipeArrayBuffer(buf));
5
+ };
6
+ // time is a LEB128-encoded Nat
7
+ export const decodeTime = (buf) => {
8
+ const timestampNs = decodeLeb128(buf);
9
+ const timestampMs = timestampNs / MILLISECOND_TO_NANOSECONDS;
10
+ return new Date(Number(timestampMs));
11
+ };
12
+ //# sourceMappingURL=leb.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"leb.js","sourceRoot":"","sources":["../../../../src/agent/utils/leb.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAErD,MAAM,0BAA0B,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;AAErD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,GAAe,EAAU,EAAE;IACtD,OAAO,SAAS,CAAC,IAAI,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC;AAC7C,CAAC,CAAC;AAEF,+BAA+B;AAC/B,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,GAAe,EAAQ,EAAE;IAClD,MAAM,WAAW,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;IACtC,MAAM,WAAW,GAAG,WAAW,GAAG,0BAA0B,CAAC;IAC7D,OAAO,IAAI,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC;AACvC,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Generates a random unsigned 32-bit integer between 0 and 0xffffffff
3
+ * @returns {number} a random number
4
+ */
5
+ export declare const randomNumber: () => number;
6
+ //# sourceMappingURL=random.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"random.d.ts","sourceRoot":"","sources":["../../../../src/agent/utils/random.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,YAAY,QAAO,MAyB/B,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Generates a random unsigned 32-bit integer between 0 and 0xffffffff
3
+ * @returns {number} a random number
4
+ */
5
+ export const randomNumber = () => {
6
+ // determine whether browser crypto is available
7
+ if (typeof window !== 'undefined' && !!window.crypto && !!window.crypto.getRandomValues) {
8
+ const array = new Uint32Array(1);
9
+ window.crypto.getRandomValues(array);
10
+ return array[0];
11
+ }
12
+ // A second check for webcrypto, in case it is loaded under global instead of window
13
+ if (typeof crypto !== 'undefined' && crypto.getRandomValues) {
14
+ const array = new Uint32Array(1);
15
+ crypto.getRandomValues(array);
16
+ return array[0];
17
+ }
18
+ // determine whether node crypto is available
19
+ if (typeof crypto !== 'undefined' && crypto.randomInt) {
20
+ return crypto.randomInt(0, 0xffffffff);
21
+ }
22
+ // fall back to Math.random
23
+ return Math.floor(Math.random() * 0xffffffff);
24
+ };
25
+ //# sourceMappingURL=random.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"random.js","sourceRoot":"","sources":["../../../../src/agent/utils/random.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,GAAW,EAAE;IACvC,gDAAgD;IAChD,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,CAAC,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE,CAAC;QACxF,MAAM,KAAK,GAAG,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC;QACjC,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;QACrC,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IACD,oFAAoF;IACpF,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,eAAe,EAAE,CAAC;QAC5D,MAAM,KAAK,GAAG,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC;QACjC,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;QAC9B,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAMD,6CAA6C;IAC7C,IAAI,OAAO,MAAM,KAAK,WAAW,IAAK,MAAgC,CAAC,SAAS,EAAE,CAAC;QACjF,OAAQ,MAAgC,CAAC,SAAS,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;IACpE,CAAC;IAED,2BAA2B;IAC3B,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,UAAU,CAAC,CAAC;AAChD,CAAC,CAAC"}