@icp-sdk/core 4.2.3 → 5.0.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 (456) 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 +7 -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 +19 -0
  12. package/lib/cjs/agent/agent/http/__certificates__/goldenCertificates.js.map +1 -0
  13. package/lib/cjs/agent/agent/http/index.d.ts +171 -0
  14. package/lib/cjs/agent/agent/http/index.d.ts.map +1 -0
  15. package/lib/cjs/agent/agent/http/index.js +1079 -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 +93 -0
  34. package/lib/cjs/agent/canisterStatus/index.d.ts.map +1 -0
  35. package/lib/cjs/agent/canisterStatus/index.js +301 -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 +228 -0
  42. package/lib/cjs/agent/certificate.d.ts.map +1 -0
  43. package/lib/cjs/agent/certificate.js +591 -0
  44. package/lib/cjs/agent/certificate.js.map +1 -0
  45. package/lib/cjs/agent/constants.d.ts +14 -0
  46. package/lib/cjs/agent/constants.d.ts.map +1 -0
  47. package/lib/cjs/agent/constants.js +18 -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 +380 -0
  54. package/lib/cjs/agent/errors.d.ts.map +1 -0
  55. package/lib/cjs/agent/errors.js +733 -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 +31 -1
  62. package/lib/cjs/agent/index.d.ts.map +1 -1
  63. package/lib/cjs/agent/index.js +59 -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/utils/bls.d.ts +10 -0
  90. package/lib/cjs/agent/utils/bls.d.ts.map +1 -0
  91. package/lib/cjs/agent/utils/bls.js +20 -0
  92. package/lib/cjs/agent/utils/bls.js.map +1 -0
  93. package/lib/cjs/agent/utils/buffer.d.ts +22 -0
  94. package/lib/cjs/agent/utils/buffer.d.ts.map +1 -0
  95. package/lib/cjs/agent/utils/buffer.js +55 -0
  96. package/lib/cjs/agent/utils/buffer.js.map +1 -0
  97. package/lib/cjs/agent/utils/expirableMap.d.ts +80 -0
  98. package/lib/cjs/agent/utils/expirableMap.d.ts.map +1 -0
  99. package/lib/cjs/agent/utils/expirableMap.js +148 -0
  100. package/lib/cjs/agent/utils/expirableMap.js.map +1 -0
  101. package/lib/cjs/agent/utils/leb.d.ts +3 -0
  102. package/lib/cjs/agent/utils/leb.d.ts.map +1 -0
  103. package/lib/cjs/agent/utils/leb.js +17 -0
  104. package/lib/cjs/agent/utils/leb.js.map +1 -0
  105. package/lib/cjs/agent/utils/random.d.ts +6 -0
  106. package/lib/cjs/agent/utils/random.d.ts.map +1 -0
  107. package/lib/cjs/agent/utils/random.js +29 -0
  108. package/lib/cjs/agent/utils/random.js.map +1 -0
  109. package/lib/cjs/candid/candid-core.d.ts +72 -0
  110. package/lib/cjs/candid/candid-core.d.ts.map +1 -0
  111. package/lib/cjs/candid/candid-core.js +251 -0
  112. package/lib/cjs/candid/candid-core.js.map +1 -0
  113. package/lib/cjs/candid/candid-ui.d.ts +35 -0
  114. package/lib/cjs/candid/candid-ui.d.ts.map +1 -0
  115. package/lib/cjs/candid/candid-ui.js +317 -0
  116. package/lib/cjs/candid/candid-ui.js.map +1 -0
  117. package/lib/cjs/candid/idl.d.ts +579 -0
  118. package/lib/cjs/candid/idl.d.ts.map +1 -0
  119. package/lib/cjs/candid/idl.js +2228 -0
  120. package/lib/cjs/candid/idl.js.map +1 -0
  121. package/lib/cjs/candid/index.d.ts +11 -1
  122. package/lib/cjs/candid/index.d.ts.map +1 -1
  123. package/lib/cjs/candid/index.js +33 -1
  124. package/lib/cjs/candid/index.js.map +1 -1
  125. package/lib/cjs/candid/types.d.ts +6 -0
  126. package/lib/cjs/candid/types.d.ts.map +1 -0
  127. package/lib/cjs/candid/types.js +4 -0
  128. package/lib/cjs/candid/types.js.map +1 -0
  129. package/lib/cjs/candid/utils/bigint-math.d.ts +14 -0
  130. package/lib/cjs/candid/utils/bigint-math.d.ts.map +1 -0
  131. package/lib/cjs/candid/utils/bigint-math.js +30 -0
  132. package/lib/cjs/candid/utils/bigint-math.js.map +1 -0
  133. package/lib/cjs/candid/utils/buffer.d.ts +86 -0
  134. package/lib/cjs/candid/utils/buffer.d.ts.map +1 -0
  135. package/lib/cjs/candid/utils/buffer.js +191 -0
  136. package/lib/cjs/candid/utils/buffer.js.map +1 -0
  137. package/lib/cjs/candid/utils/hash.d.ts +7 -0
  138. package/lib/cjs/candid/utils/hash.d.ts.map +1 -0
  139. package/lib/cjs/candid/utils/hash.js +33 -0
  140. package/lib/cjs/candid/utils/hash.js.map +1 -0
  141. package/lib/cjs/candid/utils/leb128.d.ts +65 -0
  142. package/lib/cjs/candid/utils/leb128.d.ts.map +1 -0
  143. package/lib/cjs/candid/utils/leb128.js +228 -0
  144. package/lib/cjs/candid/utils/leb128.js.map +1 -0
  145. package/lib/cjs/identity/identity/delegation.d.ts +164 -0
  146. package/lib/cjs/identity/identity/delegation.d.ts.map +1 -0
  147. package/lib/cjs/identity/identity/delegation.js +302 -0
  148. package/lib/cjs/identity/identity/delegation.js.map +1 -0
  149. package/lib/cjs/identity/identity/ecdsa.d.ts +62 -0
  150. package/lib/cjs/identity/identity/ecdsa.d.ts.map +1 -0
  151. package/lib/cjs/identity/identity/ecdsa.js +117 -0
  152. package/lib/cjs/identity/identity/ecdsa.js.map +1 -0
  153. package/lib/cjs/identity/identity/ed25519.d.ts +67 -0
  154. package/lib/cjs/identity/identity/ed25519.d.ts.map +1 -0
  155. package/lib/cjs/identity/identity/ed25519.js +200 -0
  156. package/lib/cjs/identity/identity/ed25519.js.map +1 -0
  157. package/lib/cjs/identity/identity/partial.d.ts +34 -0
  158. package/lib/cjs/identity/identity/partial.d.ts.map +1 -0
  159. package/lib/cjs/identity/identity/partial.js +54 -0
  160. package/lib/cjs/identity/identity/partial.js.map +1 -0
  161. package/lib/cjs/identity/identity/webauthn.d.ts +51 -0
  162. package/lib/cjs/identity/identity/webauthn.d.ts.map +1 -0
  163. package/lib/cjs/identity/identity/webauthn.js +197 -0
  164. package/lib/cjs/identity/identity/webauthn.js.map +1 -0
  165. package/lib/cjs/identity/index.d.ts +15 -1
  166. package/lib/cjs/identity/index.d.ts.map +1 -1
  167. package/lib/cjs/identity/index.js +24 -1
  168. package/lib/cjs/identity/index.js.map +1 -1
  169. package/lib/cjs/identity/secp256k1/der.d.ts +33 -0
  170. package/lib/cjs/identity/secp256k1/der.d.ts.map +1 -0
  171. package/lib/cjs/identity/secp256k1/der.js +165 -0
  172. package/lib/cjs/identity/secp256k1/der.js.map +1 -0
  173. package/lib/cjs/identity/secp256k1/index.d.ts +4 -1
  174. package/lib/cjs/identity/secp256k1/index.d.ts.map +1 -1
  175. package/lib/cjs/identity/secp256k1/index.js +4 -1
  176. package/lib/cjs/identity/secp256k1/index.js.map +1 -1
  177. package/lib/cjs/identity/secp256k1/pem.d.ts +7 -0
  178. package/lib/cjs/identity/secp256k1/pem.d.ts.map +1 -0
  179. package/lib/cjs/identity/secp256k1/pem.js +75 -0
  180. package/lib/cjs/identity/secp256k1/pem.js.map +1 -0
  181. package/lib/cjs/identity/secp256k1/secp256k1.d.ts +87 -0
  182. package/lib/cjs/identity/secp256k1/secp256k1.d.ts.map +1 -0
  183. package/lib/cjs/identity/secp256k1/secp256k1.js +260 -0
  184. package/lib/cjs/identity/secp256k1/secp256k1.js.map +1 -0
  185. package/lib/cjs/principal/index.d.ts +3 -1
  186. package/lib/cjs/principal/index.d.ts.map +1 -1
  187. package/lib/cjs/principal/index.js +7 -1
  188. package/lib/cjs/principal/index.js.map +1 -1
  189. package/lib/cjs/principal/principal.d.ts +50 -0
  190. package/lib/cjs/principal/principal.d.ts.map +1 -0
  191. package/lib/cjs/principal/principal.js +148 -0
  192. package/lib/cjs/principal/principal.js.map +1 -0
  193. package/lib/cjs/principal/utils/base32.d.ts +10 -0
  194. package/lib/cjs/principal/utils/base32.d.ts.map +1 -0
  195. package/lib/cjs/principal/utils/base32.js +90 -0
  196. package/lib/cjs/principal/utils/base32.js.map +1 -0
  197. package/lib/cjs/principal/utils/getCrc.d.ts +6 -0
  198. package/lib/cjs/principal/utils/getCrc.d.ts.map +1 -0
  199. package/lib/cjs/principal/utils/getCrc.js +53 -0
  200. package/lib/cjs/principal/utils/getCrc.js.map +1 -0
  201. package/lib/esm/agent/actor.d.ts +203 -0
  202. package/lib/esm/agent/actor.d.ts.map +1 -0
  203. package/lib/esm/agent/actor.js +337 -0
  204. package/lib/esm/agent/actor.js.map +1 -0
  205. package/lib/esm/agent/agent/api.d.ts +216 -0
  206. package/lib/esm/agent/agent/api.d.ts.map +1 -0
  207. package/lib/esm/agent/agent/api.js +34 -0
  208. package/lib/esm/agent/agent/api.js.map +1 -0
  209. package/lib/esm/agent/agent/http/__certificates__/goldenCertificates.d.ts +7 -0
  210. package/lib/esm/agent/agent/http/__certificates__/goldenCertificates.d.ts.map +1 -0
  211. package/lib/esm/agent/agent/http/__certificates__/goldenCertificates.js +16 -0
  212. package/lib/esm/agent/agent/http/__certificates__/goldenCertificates.js.map +1 -0
  213. package/lib/esm/agent/agent/http/index.d.ts +171 -0
  214. package/lib/esm/agent/agent/http/index.d.ts.map +1 -0
  215. package/lib/esm/agent/agent/http/index.js +1037 -0
  216. package/lib/esm/agent/agent/http/index.js.map +1 -0
  217. package/lib/esm/agent/agent/http/transforms.d.ts +54 -0
  218. package/lib/esm/agent/agent/http/transforms.d.ts.map +1 -0
  219. package/lib/esm/agent/agent/http/transforms.js +128 -0
  220. package/lib/esm/agent/agent/http/transforms.js.map +1 -0
  221. package/lib/esm/agent/agent/http/types.d.ts +81 -0
  222. package/lib/esm/agent/agent/http/types.d.ts.map +1 -0
  223. package/lib/esm/agent/agent/http/types.js +39 -0
  224. package/lib/esm/agent/agent/http/types.js.map +1 -0
  225. package/lib/esm/agent/agent/index.d.ts +3 -0
  226. package/lib/esm/agent/agent/index.d.ts.map +1 -0
  227. package/lib/esm/agent/agent/index.js +3 -0
  228. package/lib/esm/agent/agent/index.js.map +1 -0
  229. package/lib/esm/agent/auth.d.ts +91 -0
  230. package/lib/esm/agent/auth.d.ts.map +1 -0
  231. package/lib/esm/agent/auth.js +59 -0
  232. package/lib/esm/agent/auth.js.map +1 -0
  233. package/lib/esm/agent/canister-env/index.d.ts +110 -1
  234. package/lib/esm/agent/canister-env/index.d.ts.map +1 -1
  235. package/lib/esm/agent/canister-env/index.js +110 -1
  236. package/lib/esm/agent/canister-env/index.js.map +1 -1
  237. package/lib/esm/agent/canisterStatus/index.d.ts +93 -0
  238. package/lib/esm/agent/canisterStatus/index.d.ts.map +1 -0
  239. package/lib/esm/agent/canisterStatus/index.js +261 -0
  240. package/lib/esm/agent/canisterStatus/index.js.map +1 -0
  241. package/lib/esm/agent/cbor.d.ts +26 -0
  242. package/lib/esm/agent/cbor.d.ts.map +1 -0
  243. package/lib/esm/agent/cbor.js +54 -0
  244. package/lib/esm/agent/cbor.js.map +1 -0
  245. package/lib/esm/agent/certificate.d.ts +228 -0
  246. package/lib/esm/agent/certificate.d.ts.map +1 -0
  247. package/lib/esm/agent/certificate.js +545 -0
  248. package/lib/esm/agent/certificate.js.map +1 -0
  249. package/lib/esm/agent/constants.d.ts +14 -0
  250. package/lib/esm/agent/constants.d.ts.map +1 -0
  251. package/lib/esm/agent/constants.js +15 -0
  252. package/lib/esm/agent/constants.js.map +1 -0
  253. package/lib/esm/agent/der.d.ts +34 -0
  254. package/lib/esm/agent/der.d.ts.map +1 -0
  255. package/lib/esm/agent/der.js +166 -0
  256. package/lib/esm/agent/der.js.map +1 -0
  257. package/lib/esm/agent/errors.d.ts +380 -0
  258. package/lib/esm/agent/errors.d.ts.map +1 -0
  259. package/lib/esm/agent/errors.js +678 -0
  260. package/lib/esm/agent/errors.js.map +1 -0
  261. package/lib/esm/agent/fetch_candid.d.ts +9 -0
  262. package/lib/esm/agent/fetch_candid.d.ts.map +1 -0
  263. package/lib/esm/agent/fetch_candid.js +33 -0
  264. package/lib/esm/agent/fetch_candid.js.map +1 -0
  265. package/lib/esm/agent/index.d.ts +31 -1
  266. package/lib/esm/agent/index.d.ts.map +1 -1
  267. package/lib/esm/agent/index.js +31 -1
  268. package/lib/esm/agent/index.js.map +1 -1
  269. package/lib/esm/agent/observable.d.ts +24 -0
  270. package/lib/esm/agent/observable.d.ts.map +1 -0
  271. package/lib/esm/agent/observable.js +29 -0
  272. package/lib/esm/agent/observable.js.map +1 -0
  273. package/lib/esm/agent/polling/backoff.d.ts +50 -0
  274. package/lib/esm/agent/polling/backoff.d.ts.map +1 -0
  275. package/lib/esm/agent/polling/backoff.js +85 -0
  276. package/lib/esm/agent/polling/backoff.js.map +1 -0
  277. package/lib/esm/agent/polling/index.d.ts +63 -0
  278. package/lib/esm/agent/polling/index.d.ts.map +1 -0
  279. package/lib/esm/agent/polling/index.js +144 -0
  280. package/lib/esm/agent/polling/index.js.map +1 -0
  281. package/lib/esm/agent/polling/strategy.d.ts +52 -0
  282. package/lib/esm/agent/polling/strategy.d.ts.map +1 -0
  283. package/lib/esm/agent/polling/strategy.js +94 -0
  284. package/lib/esm/agent/polling/strategy.js.map +1 -0
  285. package/lib/esm/agent/public_key.d.ts +16 -0
  286. package/lib/esm/agent/public_key.d.ts.map +1 -0
  287. package/lib/esm/agent/public_key.js +48 -0
  288. package/lib/esm/agent/public_key.js.map +1 -0
  289. package/lib/esm/agent/request_id.d.ts +24 -0
  290. package/lib/esm/agent/request_id.d.ts.map +1 -0
  291. package/lib/esm/agent/request_id.js +83 -0
  292. package/lib/esm/agent/request_id.js.map +1 -0
  293. package/lib/esm/agent/utils/bls.d.ts +10 -0
  294. package/lib/esm/agent/utils/bls.d.ts.map +1 -0
  295. package/lib/esm/agent/utils/bls.js +17 -0
  296. package/lib/esm/agent/utils/bls.js.map +1 -0
  297. package/lib/esm/agent/utils/buffer.d.ts +22 -0
  298. package/lib/esm/agent/utils/buffer.d.ts.map +1 -0
  299. package/lib/esm/agent/utils/buffer.js +50 -0
  300. package/lib/esm/agent/utils/buffer.js.map +1 -0
  301. package/lib/esm/agent/utils/expirableMap.d.ts +80 -0
  302. package/lib/esm/agent/utils/expirableMap.d.ts.map +1 -0
  303. package/lib/esm/agent/utils/expirableMap.js +144 -0
  304. package/lib/esm/agent/utils/expirableMap.js.map +1 -0
  305. package/lib/esm/agent/utils/leb.d.ts +3 -0
  306. package/lib/esm/agent/utils/leb.d.ts.map +1 -0
  307. package/lib/esm/agent/utils/leb.js +12 -0
  308. package/lib/esm/agent/utils/leb.js.map +1 -0
  309. package/lib/esm/agent/utils/random.d.ts +6 -0
  310. package/lib/esm/agent/utils/random.d.ts.map +1 -0
  311. package/lib/esm/agent/utils/random.js +25 -0
  312. package/lib/esm/agent/utils/random.js.map +1 -0
  313. package/lib/esm/candid/candid-core.d.ts +72 -0
  314. package/lib/esm/candid/candid-core.d.ts.map +1 -0
  315. package/lib/esm/candid/candid-core.js +241 -0
  316. package/lib/esm/candid/candid-core.js.map +1 -0
  317. package/lib/esm/candid/candid-ui.d.ts +35 -0
  318. package/lib/esm/candid/candid-ui.d.ts.map +1 -0
  319. package/lib/esm/candid/candid-ui.js +272 -0
  320. package/lib/esm/candid/candid-ui.js.map +1 -0
  321. package/lib/esm/candid/idl.d.ts +579 -0
  322. package/lib/esm/candid/idl.d.ts.map +1 -0
  323. package/lib/esm/candid/idl.js +2189 -0
  324. package/lib/esm/candid/idl.js.map +1 -0
  325. package/lib/esm/candid/index.d.ts +11 -1
  326. package/lib/esm/candid/index.d.ts.map +1 -1
  327. package/lib/esm/candid/index.js +10 -1
  328. package/lib/esm/candid/index.js.map +1 -1
  329. package/lib/esm/candid/types.d.ts +6 -0
  330. package/lib/esm/candid/types.d.ts.map +1 -0
  331. package/lib/esm/candid/types.js +3 -0
  332. package/lib/esm/candid/types.js.map +1 -0
  333. package/lib/esm/candid/utils/bigint-math.d.ts +14 -0
  334. package/lib/esm/candid/utils/bigint-math.d.ts.map +1 -0
  335. package/lib/esm/candid/utils/bigint-math.js +26 -0
  336. package/lib/esm/candid/utils/bigint-math.js.map +1 -0
  337. package/lib/esm/candid/utils/buffer.d.ts +86 -0
  338. package/lib/esm/candid/utils/buffer.d.ts.map +1 -0
  339. package/lib/esm/candid/utils/buffer.js +182 -0
  340. package/lib/esm/candid/utils/buffer.js.map +1 -0
  341. package/lib/esm/candid/utils/hash.d.ts +7 -0
  342. package/lib/esm/candid/utils/hash.d.ts.map +1 -0
  343. package/lib/esm/candid/utils/hash.js +30 -0
  344. package/lib/esm/candid/utils/hash.js.map +1 -0
  345. package/lib/esm/candid/utils/leb128.d.ts +65 -0
  346. package/lib/esm/candid/utils/leb128.d.ts.map +1 -0
  347. package/lib/esm/candid/utils/leb128.js +216 -0
  348. package/lib/esm/candid/utils/leb128.js.map +1 -0
  349. package/lib/esm/identity/identity/delegation.d.ts +164 -0
  350. package/lib/esm/identity/identity/delegation.d.ts.map +1 -0
  351. package/lib/esm/identity/identity/delegation.js +294 -0
  352. package/lib/esm/identity/identity/delegation.js.map +1 -0
  353. package/lib/esm/identity/identity/ecdsa.d.ts +62 -0
  354. package/lib/esm/identity/identity/ecdsa.d.ts.map +1 -0
  355. package/lib/esm/identity/identity/ecdsa.js +112 -0
  356. package/lib/esm/identity/identity/ecdsa.js.map +1 -0
  357. package/lib/esm/identity/identity/ed25519.d.ts +67 -0
  358. package/lib/esm/identity/identity/ed25519.d.ts.map +1 -0
  359. package/lib/esm/identity/identity/ed25519.js +195 -0
  360. package/lib/esm/identity/identity/ed25519.js.map +1 -0
  361. package/lib/esm/identity/identity/partial.d.ts +34 -0
  362. package/lib/esm/identity/identity/partial.d.ts.map +1 -0
  363. package/lib/esm/identity/identity/partial.js +50 -0
  364. package/lib/esm/identity/identity/partial.js.map +1 -0
  365. package/lib/esm/identity/identity/webauthn.d.ts +51 -0
  366. package/lib/esm/identity/identity/webauthn.d.ts.map +1 -0
  367. package/lib/esm/identity/identity/webauthn.js +192 -0
  368. package/lib/esm/identity/identity/webauthn.js.map +1 -0
  369. package/lib/esm/identity/index.d.ts +15 -1
  370. package/lib/esm/identity/index.d.ts.map +1 -1
  371. package/lib/esm/identity/index.js +17 -1
  372. package/lib/esm/identity/index.js.map +1 -1
  373. package/lib/esm/identity/secp256k1/der.d.ts +33 -0
  374. package/lib/esm/identity/secp256k1/der.d.ts.map +1 -0
  375. package/lib/esm/identity/secp256k1/der.js +156 -0
  376. package/lib/esm/identity/secp256k1/der.js.map +1 -0
  377. package/lib/esm/identity/secp256k1/index.d.ts +4 -1
  378. package/lib/esm/identity/secp256k1/index.d.ts.map +1 -1
  379. package/lib/esm/identity/secp256k1/index.js +4 -1
  380. package/lib/esm/identity/secp256k1/index.js.map +1 -1
  381. package/lib/esm/identity/secp256k1/pem.d.ts +7 -0
  382. package/lib/esm/identity/secp256k1/pem.d.ts.map +1 -0
  383. package/lib/esm/identity/secp256k1/pem.js +39 -0
  384. package/lib/esm/identity/secp256k1/pem.js.map +1 -0
  385. package/lib/esm/identity/secp256k1/secp256k1.d.ts +87 -0
  386. package/lib/esm/identity/secp256k1/secp256k1.d.ts.map +1 -0
  387. package/lib/esm/identity/secp256k1/secp256k1.js +222 -0
  388. package/lib/esm/identity/secp256k1/secp256k1.js.map +1 -0
  389. package/lib/esm/principal/index.d.ts +3 -1
  390. package/lib/esm/principal/index.d.ts.map +1 -1
  391. package/lib/esm/principal/index.js +3 -1
  392. package/lib/esm/principal/index.js.map +1 -1
  393. package/lib/esm/principal/principal.d.ts +50 -0
  394. package/lib/esm/principal/principal.d.ts.map +1 -0
  395. package/lib/esm/principal/principal.js +144 -0
  396. package/lib/esm/principal/principal.js.map +1 -0
  397. package/lib/esm/principal/utils/base32.d.ts +10 -0
  398. package/lib/esm/principal/utils/base32.d.ts.map +1 -0
  399. package/lib/esm/principal/utils/base32.js +86 -0
  400. package/lib/esm/principal/utils/base32.js.map +1 -0
  401. package/lib/esm/principal/utils/getCrc.d.ts +6 -0
  402. package/lib/esm/principal/utils/getCrc.d.ts.map +1 -0
  403. package/lib/esm/principal/utils/getCrc.js +50 -0
  404. package/lib/esm/principal/utils/getCrc.js.map +1 -0
  405. package/package.json +17 -11
  406. package/src/agent/actor.ts +576 -0
  407. package/src/agent/agent/api.ts +262 -0
  408. package/src/agent/agent/http/index.ts +1405 -0
  409. package/src/agent/agent/http/transforms.ts +158 -0
  410. package/src/agent/agent/http/types.ts +126 -0
  411. package/src/agent/agent/index.ts +2 -0
  412. package/src/agent/auth.ts +147 -0
  413. package/src/agent/canister-env/index.ts +191 -1
  414. package/src/agent/canisterStatus/index.ts +412 -0
  415. package/src/agent/cbor.ts +63 -0
  416. package/src/agent/certificate.ts +841 -0
  417. package/src/agent/constants.ts +19 -0
  418. package/src/agent/der.ts +170 -0
  419. package/src/agent/errors.ts +868 -0
  420. package/src/agent/fetch_candid.ts +37 -0
  421. package/src/agent/index.ts +37 -1
  422. package/src/agent/observable.ts +49 -0
  423. package/src/agent/polling/backoff.ts +130 -0
  424. package/src/agent/polling/index.ts +250 -0
  425. package/src/agent/polling/strategy.ts +144 -0
  426. package/src/agent/public_key.ts +65 -0
  427. package/src/agent/request_id.ts +92 -0
  428. package/src/agent/utils/bls.ts +18 -0
  429. package/src/agent/utils/buffer.ts +60 -0
  430. package/src/agent/utils/expirableMap.ts +163 -0
  431. package/src/agent/utils/leb.ts +14 -0
  432. package/src/agent/utils/random.ts +30 -0
  433. package/src/candid/candid-core.ts +276 -0
  434. package/src/candid/candid-ui.ts +289 -0
  435. package/src/candid/idl.ts +2556 -0
  436. package/src/candid/index.ts +16 -1
  437. package/src/candid/types.ts +7 -0
  438. package/src/candid/utils/bigint-math.ts +26 -0
  439. package/src/candid/utils/buffer.ts +221 -0
  440. package/src/candid/utils/hash.ts +31 -0
  441. package/src/candid/utils/leb128.ts +234 -0
  442. package/src/identity/identity/delegation.ts +411 -0
  443. package/src/identity/identity/ecdsa.ts +158 -0
  444. package/src/identity/identity/ed25519.ts +239 -0
  445. package/src/identity/identity/partial.ts +60 -0
  446. package/src/identity/identity/webauthn.ts +265 -0
  447. package/src/identity/index.ts +19 -1
  448. package/src/identity/secp256k1/der.ts +156 -0
  449. package/src/identity/secp256k1/index.ts +5 -1
  450. package/src/identity/secp256k1/pem.ts +40 -0
  451. package/src/identity/secp256k1/secp256k1.ts +270 -0
  452. package/src/package.json +4 -0
  453. package/src/principal/index.ts +3 -1
  454. package/src/principal/principal.ts +171 -0
  455. package/src/principal/utils/base32.ts +101 -0
  456. package/src/principal/utils/getCrc.ts +52 -0
@@ -1,2 +1,111 @@
1
- export * from '@dfinity/agent/canister-env';
1
+ /**
2
+ * @experimental
3
+ * @module canister-env/api
4
+ */
5
+ /**
6
+ * The environment variables served by the asset canister that hosts the frontend.
7
+ * You can extend the `CanisterEnv` interface to add your own environment variables
8
+ * and have strong typing for them.
9
+ * @see The {@link https://js.icp.build/core/latest/canister-environment/ | Canister Environment Guide} for more details on how to use the canister environment in a frontend application
10
+ * @experimental
11
+ * @example
12
+ * Extend the global `CanisterEnv` interface to add your own environment variables:
13
+ * ```ts title="index.ts"
14
+ * // You can declare the interface to have strong typing
15
+ * // for your own environment variables across your codebase
16
+ * declare module '@icp-sdk/core/agent/canister-env' {
17
+ * interface CanisterEnv {
18
+ * readonly ['PUBLIC_CANISTER_ID:backend']: string;
19
+ * readonly PUBLIC_API_URL: string;
20
+ * }
21
+ * }
22
+ *
23
+ * const env = getCanisterEnv();
24
+ *
25
+ * console.log(env.IC_ROOT_KEY); // by default served by the asset canister
26
+ * console.log(env['PUBLIC_CANISTER_ID:backend']); // ✅ TS passes
27
+ * console.log(env.PUBLIC_API_URL); // ✅ TS passes
28
+ * console.log(env['PUBLIC_CANISTER_ID:another']); // ❌ TS will show an error
29
+ * ```
30
+ * @example
31
+ * Alternatively, use the generic parameter to specify additional properties:
32
+ * ```ts title="index.ts"
33
+ * const env = getCanisterEnv<{ readonly ['PUBLIC_CANISTER_ID:backend']: string }>();
34
+ *
35
+ * console.log(env.IC_ROOT_KEY); // by default served by the asset canister
36
+ * console.log(env['PUBLIC_CANISTER_ID:backend']); // ✅ from generic parameter, TS passes
37
+ * console.log(env['PUBLIC_CANISTER_ID:frontend']); // ❌ TS will show an error
38
+ * ```
39
+ */
40
+ export interface CanisterEnv {
41
+ /**
42
+ * The root key of the IC network where the asset canister is deployed.
43
+ * Served by default by the asset canister that hosts the frontend.
44
+ */
45
+ readonly IC_ROOT_KEY: Uint8Array;
46
+ }
47
+ /**
48
+ * Options for the {@link getCanisterEnv} function
49
+ * @experimental
50
+ */
51
+ export type GetCanisterEnvOptions = {
52
+ /**
53
+ * The name of the cookie to get the environment variables from.
54
+ * @default 'ic_env'
55
+ */
56
+ cookieName?: string;
57
+ };
58
+ /**
59
+ * Get the environment variables served by the asset canister via the cookie.
60
+ *
61
+ * The returned object always includes `IC_ROOT_KEY` property.
62
+ * You can extend the global `CanisterEnv` interface to add your own environment variables
63
+ * and have strong typing for them.
64
+ *
65
+ * In Node.js environment (or any other environment where `globalThis.document` is not available), this function will throw an error.
66
+ * Use {@link safeGetCanisterEnv} if you need a function that returns `undefined` instead of throwing errors.
67
+ * @param options The options for loading the canister environment variables
68
+ * @returns The environment variables for the asset canister, always including `IC_ROOT_KEY`
69
+ * @throws {TypeError} When `globalThis.document` is not available
70
+ * @throws {InputError} When the cookie is not found
71
+ * @throws {InputError} When the `IC_ROOT_KEY` is missing or has an invalid length
72
+ * @see The {@link https://js.icp.build/core/latest/canister-environment/ | Canister Environment Guide} for more details on how to use the canister environment in a frontend application
73
+ * @experimental
74
+ * @example
75
+ * ```ts
76
+ * type MyCanisterEnv = {
77
+ * readonly ['PUBLIC_CANISTER_ID:backend']: string;
78
+ * };
79
+ *
80
+ * const env = getCanisterEnv<MyCanisterEnv>();
81
+ *
82
+ * console.log(env.IC_ROOT_KEY); // always available (Uint8Array)
83
+ * console.log(env['PUBLIC_CANISTER_ID:backend']); // ✅ from generic parameter, TS passes
84
+ * console.log(env['PUBLIC_CANISTER_ID:frontend']); // ❌ TS will show an error
85
+ * ```
86
+ * Have a look at {@link CanisterEnv} for more details on how to extend the interface
87
+ */
88
+ export declare function getCanisterEnv<T = Record<string, never>>(options?: GetCanisterEnvOptions): CanisterEnv & T;
89
+ /**
90
+ * Safe version of {@link getCanisterEnv} that returns `undefined` instead of throwing errors.
91
+ * @param options The options for loading the asset canister environment variables
92
+ * @returns The environment variables for the asset canister, or `undefined` if any error occurs
93
+ * @see The {@link https://js.icp.build/core/latest/canister-environment/ | Canister Environment Guide} for more details on how to use the canister environment in a frontend application
94
+ * @experimental
95
+ * @example
96
+ * ```ts
97
+ * // in a browser environment with valid cookie
98
+ * const env = safeGetCanisterEnv();
99
+ * console.log(env); // { IC_ROOT_KEY: Uint8Array, ... }
100
+ *
101
+ * // in a Node.js environment
102
+ * const env = safeGetCanisterEnv();
103
+ * console.log(env); // undefined
104
+ *
105
+ * // in a browser without the environment cookie
106
+ * const env = safeGetCanisterEnv();
107
+ * console.log(env); // undefined
108
+ * ```
109
+ */
110
+ export declare function safeGetCanisterEnv<T = Record<string, never>>(options?: GetCanisterEnvOptions): (CanisterEnv & T) | undefined;
2
111
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/agent/canister-env/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/agent/canister-env/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAqBH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,WAAW,WAAW;IAC1B;;;OAGG;IACH,QAAQ,CAAC,WAAW,EAAE,UAAU,CAAC;CAClC;AAED;;;GAGG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,cAAc,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EACtD,OAAO,GAAE,qBAA0B,GAClC,WAAW,GAAG,CAAC,CAoBjB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAC1D,OAAO,GAAE,qBAA0B,GAClC,CAAC,WAAW,GAAG,CAAC,CAAC,GAAG,SAAS,CAM/B"}
@@ -1,2 +1,111 @@
1
- export * from '@dfinity/agent/canister-env';
1
+ /**
2
+ * @experimental
3
+ * @module canister-env/api
4
+ */
5
+ import { hexToBytes } from '@noble/hashes/utils';
6
+ import { InputError, InvalidRootKeyErrorCode, EmptyCookieErrorCode, MissingRootKeyErrorCode, MissingCookieErrorCode, } from "../errors.js";
7
+ const IC_ENV_COOKIE_NAME = 'ic_env';
8
+ const ENV_VAR_SEPARATOR = '&';
9
+ const ENV_VAR_ASSIGNMENT_SYMBOL = '=';
10
+ const IC_ROOT_KEY_VALUE_NAME = 'ic_root_key';
11
+ const IC_ROOT_KEY_ENV_NAME = 'IC_ROOT_KEY'; // the value must be the same as the `CanisterEnv.IC_ROOT_KEY` property name
12
+ const IC_ROOT_KEY_BYTES_LENGTH = 133;
13
+ /**
14
+ * Get the environment variables served by the asset canister via the cookie.
15
+ *
16
+ * The returned object always includes `IC_ROOT_KEY` property.
17
+ * You can extend the global `CanisterEnv` interface to add your own environment variables
18
+ * and have strong typing for them.
19
+ *
20
+ * In Node.js environment (or any other environment where `globalThis.document` is not available), this function will throw an error.
21
+ * Use {@link safeGetCanisterEnv} if you need a function that returns `undefined` instead of throwing errors.
22
+ * @param options The options for loading the canister environment variables
23
+ * @returns The environment variables for the asset canister, always including `IC_ROOT_KEY`
24
+ * @throws {TypeError} When `globalThis.document` is not available
25
+ * @throws {InputError} When the cookie is not found
26
+ * @throws {InputError} When the `IC_ROOT_KEY` is missing or has an invalid length
27
+ * @see The {@link https://js.icp.build/core/latest/canister-environment/ | Canister Environment Guide} for more details on how to use the canister environment in a frontend application
28
+ * @experimental
29
+ * @example
30
+ * ```ts
31
+ * type MyCanisterEnv = {
32
+ * readonly ['PUBLIC_CANISTER_ID:backend']: string;
33
+ * };
34
+ *
35
+ * const env = getCanisterEnv<MyCanisterEnv>();
36
+ *
37
+ * console.log(env.IC_ROOT_KEY); // always available (Uint8Array)
38
+ * console.log(env['PUBLIC_CANISTER_ID:backend']); // ✅ from generic parameter, TS passes
39
+ * console.log(env['PUBLIC_CANISTER_ID:frontend']); // ❌ TS will show an error
40
+ * ```
41
+ * Have a look at {@link CanisterEnv} for more details on how to extend the interface
42
+ */
43
+ export function getCanisterEnv(options = {}) {
44
+ const { cookieName = IC_ENV_COOKIE_NAME } = options;
45
+ const cookie = getCookie(cookieName);
46
+ if (!cookie) {
47
+ throw InputError.fromCode(new MissingCookieErrorCode(cookieName));
48
+ }
49
+ const cookieValue = cookie.split('=')[1].trim();
50
+ if (!cookieValue) {
51
+ throw InputError.fromCode(new EmptyCookieErrorCode(cookieName));
52
+ }
53
+ const decodedCookieValue = decodeURIComponent(cookieValue);
54
+ const envVars = parseEnvVars(decodedCookieValue);
55
+ if (!envVars.IC_ROOT_KEY) {
56
+ throw InputError.fromCode(new MissingRootKeyErrorCode());
57
+ }
58
+ return envVars;
59
+ }
60
+ /**
61
+ * Safe version of {@link getCanisterEnv} that returns `undefined` instead of throwing errors.
62
+ * @param options The options for loading the asset canister environment variables
63
+ * @returns The environment variables for the asset canister, or `undefined` if any error occurs
64
+ * @see The {@link https://js.icp.build/core/latest/canister-environment/ | Canister Environment Guide} for more details on how to use the canister environment in a frontend application
65
+ * @experimental
66
+ * @example
67
+ * ```ts
68
+ * // in a browser environment with valid cookie
69
+ * const env = safeGetCanisterEnv();
70
+ * console.log(env); // { IC_ROOT_KEY: Uint8Array, ... }
71
+ *
72
+ * // in a Node.js environment
73
+ * const env = safeGetCanisterEnv();
74
+ * console.log(env); // undefined
75
+ *
76
+ * // in a browser without the environment cookie
77
+ * const env = safeGetCanisterEnv();
78
+ * console.log(env); // undefined
79
+ * ```
80
+ */
81
+ export function safeGetCanisterEnv(options = {}) {
82
+ try {
83
+ return getCanisterEnv(options);
84
+ }
85
+ catch {
86
+ return undefined;
87
+ }
88
+ }
89
+ function getCookie(cookieName) {
90
+ return globalThis.document.cookie
91
+ .split(';')
92
+ .find(cookie => cookie.trim().startsWith(`${cookieName}=`));
93
+ }
94
+ function parseEnvVars(decoded) {
95
+ const entries = decoded.split(ENV_VAR_SEPARATOR).map(v => {
96
+ // we only want to split at the first occurrence of the assignment symbol
97
+ const symbolIndex = v.indexOf(ENV_VAR_ASSIGNMENT_SYMBOL);
98
+ const key = v.slice(0, symbolIndex);
99
+ const value = v.substring(symbolIndex + 1);
100
+ if (key === IC_ROOT_KEY_VALUE_NAME) {
101
+ const rootKey = hexToBytes(value);
102
+ if (rootKey.length !== IC_ROOT_KEY_BYTES_LENGTH) {
103
+ throw InputError.fromCode(new InvalidRootKeyErrorCode(rootKey, IC_ROOT_KEY_BYTES_LENGTH));
104
+ }
105
+ return [IC_ROOT_KEY_ENV_NAME, rootKey];
106
+ }
107
+ return [key, value];
108
+ });
109
+ return Object.fromEntries(entries);
110
+ }
2
111
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/agent/canister-env/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/agent/canister-env/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EACL,UAAU,EACV,uBAAuB,EACvB,oBAAoB,EACpB,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,cAAc,CAAC;AAEtB,MAAM,kBAAkB,GAAG,QAAQ,CAAC;AAEpC,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAC9B,MAAM,yBAAyB,GAAG,GAAG,CAAC;AAEtC,MAAM,sBAAsB,GAAG,aAAa,CAAC;AAC7C,MAAM,oBAAoB,GAAG,aAAa,CAAC,CAAC,4EAA4E;AAExH,MAAM,w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E,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC,CAAC,CAAC;AAChE,CAAC;AAED,SAAS,YAAY,CAA4B,OAAe;IAC9D,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;QACvD,yEAAyE;QACzE,MAAM,WAAW,GAAG,CAAC,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC;QAEzD,MAAM,GAAG,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC;QACpC,MAAM,KAAK,GAAG,CAAC,CAAC,SAAS,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC;QAE3C,IAAI,GAAG,KAAK,sBAAsB,EAAE,CAAC;YACnC,MAAM,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;YAClC,IAAI,OAAO,CAAC,MAAM,KAAK,wBAAwB,EAAE,CAAC;gBAChD,MAAM,UAAU,CAAC,QAAQ,CAAC,IAAI,uBAAuB,CAAC,OAAO,EAAE,wBAAwB,CAAC,CAAC,CAAC;YAC5F,CAAC;YACD,OAAO,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC;QACzC,CAAC;QAED,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACtB,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC"}
@@ -0,0 +1,93 @@
1
+ import { Principal } from '../../principal/index.js';
2
+ import { HttpAgent } from '../agent/http/index.ts';
3
+ import { type DerEncodedPublicKey } from '../auth.ts';
4
+ /**
5
+ * Represents the useful information about a subnet
6
+ * @param {string} subnetId the principal id of the canister's subnet
7
+ * @param {string[]} nodeKeys the keys of the individual nodes in the subnet
8
+ */
9
+ export type SubnetStatus = {
10
+ subnetId: string;
11
+ nodeKeys: Map<string, DerEncodedPublicKey>;
12
+ metrics?: {
13
+ num_canisters: bigint;
14
+ canister_state_bytes: bigint;
15
+ consumed_cycles_total: {
16
+ current: bigint;
17
+ deleted: bigint;
18
+ };
19
+ update_transactions_total: bigint;
20
+ };
21
+ };
22
+ /**
23
+ * Types of an entry on the canisterStatus map.
24
+ * An entry of null indicates that the request failed, due to lack of permissions or the result being missing.
25
+ */
26
+ export type Status = string | Uint8Array | Date | Uint8Array[] | Principal[] | SubnetStatus | bigint | null;
27
+ /**
28
+ * Interface to define a custom path. Nested paths will be represented as individual buffers, and can be created from text using TextEncoder.
29
+ * @param {string} key the key to use to access the returned value in the canisterStatus map
30
+ * @param {Uint8Array[]} path the path to the desired value, represented as an array of buffers
31
+ * @param {string} decodeStrategy the strategy to use to decode the returned value
32
+ */
33
+ export declare class CustomPath implements CustomPath {
34
+ key: string;
35
+ path: Uint8Array[] | string;
36
+ decodeStrategy: 'cbor' | 'hex' | 'leb128' | 'utf-8' | 'raw';
37
+ constructor(key: string, path: Uint8Array[] | string, decodeStrategy: 'cbor' | 'hex' | 'leb128' | 'utf-8' | 'raw');
38
+ }
39
+ /**
40
+ * @deprecated Use {@link CustomPath} instead
41
+ * @param {string} key the key to use to access the returned value in the canisterStatus map
42
+ * @param {string} path the path to the desired value, represented as a string
43
+ * @param {string} decodeStrategy the strategy to use to decode the returned value
44
+ */
45
+ export interface MetaData {
46
+ kind: 'metadata';
47
+ key: string;
48
+ path: string | Uint8Array;
49
+ decodeStrategy: 'cbor' | 'hex' | 'leb128' | 'utf-8' | 'raw';
50
+ }
51
+ /**
52
+ * Pre-configured fields for canister status paths
53
+ */
54
+ export type Path = 'time' | 'controllers' | 'subnet' | 'module_hash' | 'candid' | MetaData | CustomPath;
55
+ export type StatusMap = Map<Path | string, Status>;
56
+ export type CanisterStatusOptions = {
57
+ /**
58
+ * The effective canister ID to use in the underlying {@link HttpAgent.readState} call.
59
+ */
60
+ canisterId: Principal;
61
+ /**
62
+ * The agent to use to make the canister request. Must be authenticated.
63
+ */
64
+ agent: HttpAgent;
65
+ /**
66
+ * The paths to request.
67
+ * @default []
68
+ */
69
+ paths?: Path[] | Set<Path>;
70
+ /**
71
+ * Whether to disable the certificate freshness checks.
72
+ * @default false
73
+ */
74
+ disableCertificateTimeVerification?: boolean;
75
+ };
76
+ /**
77
+ * Requests information from a canister's `read_state` endpoint.
78
+ * Can be used to request information about the canister's controllers, time, module hash, candid interface, and more.
79
+ * @param {CanisterStatusOptions} options The configuration for the canister status request.
80
+ * @see {@link CanisterStatusOptions} for detailed options.
81
+ * @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.
82
+ * @example
83
+ * const status = await canisterStatus({
84
+ * paths: ['controllers', 'candid'],
85
+ * ...options
86
+ * });
87
+ *
88
+ * const controllers = status.get('controllers');
89
+ */
90
+ export declare const request: (options: CanisterStatusOptions) => Promise<StatusMap>;
91
+ export declare const fetchNodeKeys: (certificate: Uint8Array, canisterId: Principal, root_key?: Uint8Array) => SubnetStatus;
92
+ export declare const encodePath: (path: Path, canisterId: Principal) => Uint8Array[];
93
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/agent/canisterStatus/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAiBvC,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAenD,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAGtD;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG;IAEzB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IAC3C,OAAO,CAAC,EAAE;QACR,aAAa,EAAE,MAAM,CAAC;QACtB,oBAAoB,EAAE,MAAM,CAAC;QAC7B,qBAAqB,EAAE;YACrB,OAAO,EAAE,MAA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AAC,CAAC;IAC3B;;;OAGG;IACH,kCAAkC,CAAC,EAAE,OAAO,CAAC;CAC9C,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,OAAO,GAAU,SAAS,qBAAqB,KAAG,OAAO,CAAC,SAAS,CAkI/E,CAAC;AAEF,eAAO,MAAM,aAAa,GACxB,aAAa,UAAU,EACvB,YAAY,SAAS,EACrB,WAAW,UAAU,KACpB,YAyEF,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,MAAM,IAAI,EAAE,YAAY,SAAS,KAAG,UAAU,EAwCxE,CAAC"}
@@ -0,0 +1,261 @@
1
+ import { Principal } from '../../principal/index.js';
2
+ import { CertificateVerificationErrorCode, MissingRootKeyErrorCode, CertificateNotAuthorizedErrorCode, LookupErrorCode, DerKeyLengthMismatchErrorCode, ExternalError, ProtocolError, TrustError, AgentError, UnknownError, HashTreeDecodeErrorCode, UnexpectedErrorCode, InputError, CertificateTimeErrorCode, } from "../errors.js";
3
+ import { Certificate, flatten_forks, check_canister_ranges, LookupPathStatus, lookup_path, lookupResultToBuffer, lookup_subtree, LookupSubtreeStatus, } from "../certificate.js";
4
+ import * as cbor from "../cbor.js";
5
+ import { decodeLeb128, decodeTime } from "../utils/leb.js";
6
+ import { utf8ToBytes, bytesToHex } from '@noble/hashes/utils';
7
+ /**
8
+ * Interface to define a custom path. Nested paths will be represented as individual buffers, and can be created from text using TextEncoder.
9
+ * @param {string} key the key to use to access the returned value in the canisterStatus map
10
+ * @param {Uint8Array[]} path the path to the desired value, represented as an array of buffers
11
+ * @param {string} decodeStrategy the strategy to use to decode the returned value
12
+ */
13
+ export class CustomPath {
14
+ constructor(key, path, decodeStrategy) {
15
+ this.key = key;
16
+ this.path = path;
17
+ this.decodeStrategy = decodeStrategy;
18
+ }
19
+ }
20
+ /**
21
+ * Requests information from a canister's `read_state` endpoint.
22
+ * Can be used to request information about the canister's controllers, time, module hash, candid interface, and more.
23
+ * @param {CanisterStatusOptions} options The configuration for the canister status request.
24
+ * @see {@link CanisterStatusOptions} for detailed options.
25
+ * @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.
26
+ * @example
27
+ * const status = await canisterStatus({
28
+ * paths: ['controllers', 'candid'],
29
+ * ...options
30
+ * });
31
+ *
32
+ * const controllers = status.get('controllers');
33
+ */
34
+ export const request = async (options) => {
35
+ const { agent, paths, disableCertificateTimeVerification = false } = options;
36
+ const canisterId = Principal.from(options.canisterId);
37
+ const uniquePaths = [...new Set(paths)];
38
+ const status = new Map();
39
+ const promises = uniquePaths.map((path, index) => {
40
+ const encodedPath = encodePath(path, canisterId);
41
+ return (async () => {
42
+ try {
43
+ if (agent.rootKey === null) {
44
+ throw ExternalError.fromCode(new MissingRootKeyErrorCode());
45
+ }
46
+ const rootKey = agent.rootKey;
47
+ const response = await agent.readState(canisterId, {
48
+ paths: [encodedPath],
49
+ });
50
+ const certificate = await Certificate.create({
51
+ certificate: response.certificate,
52
+ rootKey,
53
+ canisterId,
54
+ disableTimeVerification: disableCertificateTimeVerification,
55
+ agent,
56
+ });
57
+ const lookup = (cert, path) => {
58
+ if (path === 'subnet') {
59
+ const data = fetchNodeKeys(response.certificate, canisterId, rootKey);
60
+ return {
61
+ path,
62
+ data,
63
+ };
64
+ }
65
+ else {
66
+ return {
67
+ path,
68
+ data: lookupResultToBuffer(cert.lookup_path(encodedPath)),
69
+ };
70
+ }
71
+ };
72
+ // must pass in the rootKey if we have no delegation
73
+ const { path, data } = lookup(certificate, uniquePaths[index]);
74
+ if (!data) {
75
+ // Typically, the cert lookup will throw
76
+ console.warn(`Expected to find result for path ${path}, but instead found nothing.`);
77
+ if (typeof path === 'string') {
78
+ status.set(path, null);
79
+ }
80
+ else {
81
+ status.set(path.key, null);
82
+ }
83
+ }
84
+ else {
85
+ switch (path) {
86
+ case 'time': {
87
+ status.set(path, decodeTime(data));
88
+ break;
89
+ }
90
+ case 'controllers': {
91
+ status.set(path, decodeControllers(data));
92
+ break;
93
+ }
94
+ case 'module_hash': {
95
+ status.set(path, bytesToHex(data));
96
+ break;
97
+ }
98
+ case 'subnet': {
99
+ status.set(path, data);
100
+ break;
101
+ }
102
+ case 'candid': {
103
+ status.set(path, new TextDecoder().decode(data));
104
+ break;
105
+ }
106
+ default: {
107
+ // Check for CustomPath signature
108
+ if (typeof path !== 'string' && 'key' in path && 'path' in path) {
109
+ switch (path.decodeStrategy) {
110
+ case 'raw':
111
+ status.set(path.key, data);
112
+ break;
113
+ case 'leb128': {
114
+ status.set(path.key, decodeLeb128(data));
115
+ break;
116
+ }
117
+ case 'cbor': {
118
+ status.set(path.key, cbor.decode(data));
119
+ break;
120
+ }
121
+ case 'hex': {
122
+ status.set(path.key, bytesToHex(data));
123
+ break;
124
+ }
125
+ case 'utf-8': {
126
+ status.set(path.key, new TextDecoder().decode(data));
127
+ }
128
+ }
129
+ }
130
+ }
131
+ }
132
+ }
133
+ }
134
+ catch (error) {
135
+ // Throw on certificate errors
136
+ if (error instanceof AgentError &&
137
+ (error.hasCode(CertificateVerificationErrorCode) ||
138
+ error.hasCode(CertificateTimeErrorCode))) {
139
+ throw error;
140
+ }
141
+ if (typeof path !== 'string' && 'key' in path && 'path' in path) {
142
+ status.set(path.key, null);
143
+ }
144
+ else {
145
+ status.set(path, null);
146
+ }
147
+ console.group();
148
+ console.warn(`Expected to find result for path ${path}, but instead found nothing.`);
149
+ console.warn(error);
150
+ console.groupEnd();
151
+ }
152
+ })();
153
+ });
154
+ // Fetch all values separately, as each option can fail
155
+ await Promise.all(promises);
156
+ return status;
157
+ };
158
+ export const fetchNodeKeys = (certificate, canisterId, root_key) => {
159
+ if (!canisterId._isPrincipal) {
160
+ throw InputError.fromCode(new UnexpectedErrorCode('Invalid canisterId'));
161
+ }
162
+ const cert = cbor.decode(certificate);
163
+ const tree = cert.tree;
164
+ let delegation = cert.delegation;
165
+ let subnetId;
166
+ if (delegation && delegation.subnet_id) {
167
+ subnetId = Principal.fromUint8Array(new Uint8Array(delegation.subnet_id));
168
+ }
169
+ // On local replica, with System type subnet, there is no delegation
170
+ else if (!delegation && typeof root_key !== 'undefined') {
171
+ subnetId = Principal.selfAuthenticating(new Uint8Array(root_key));
172
+ delegation = {
173
+ subnet_id: subnetId.toUint8Array(),
174
+ certificate: new Uint8Array(0),
175
+ };
176
+ }
177
+ // otherwise use default NNS subnet id
178
+ else {
179
+ subnetId = Principal.selfAuthenticating(Principal.fromText('tdb26-jop6k-aogll-7ltgs-eruif-6kk7m-qpktf-gdiqx-mxtrf-vb5e6-eqe').toUint8Array());
180
+ delegation = {
181
+ subnet_id: subnetId.toUint8Array(),
182
+ certificate: new Uint8Array(0),
183
+ };
184
+ }
185
+ const canisterInRange = check_canister_ranges({ canisterId, subnetId, tree });
186
+ if (!canisterInRange) {
187
+ throw TrustError.fromCode(new CertificateNotAuthorizedErrorCode(canisterId, subnetId));
188
+ }
189
+ const subnetLookupResult = lookup_subtree(['subnet', delegation.subnet_id, 'node'], tree);
190
+ if (subnetLookupResult.status !== LookupSubtreeStatus.Found) {
191
+ throw ProtocolError.fromCode(new LookupErrorCode('Node not found', subnetLookupResult.status));
192
+ }
193
+ if (subnetLookupResult.value instanceof Uint8Array) {
194
+ throw UnknownError.fromCode(new HashTreeDecodeErrorCode('Invalid node tree'));
195
+ }
196
+ // The forks are all labeled trees with the <node_id> label
197
+ const nodeForks = flatten_forks(subnetLookupResult.value);
198
+ const nodeKeys = new Map();
199
+ nodeForks.forEach(fork => {
200
+ const node_id = Principal.from(fork[1]).toText();
201
+ const publicKeyLookupResult = lookup_path(['public_key'], fork[2]);
202
+ if (publicKeyLookupResult.status !== LookupPathStatus.Found) {
203
+ throw ProtocolError.fromCode(new LookupErrorCode('Public key not found', publicKeyLookupResult.status));
204
+ }
205
+ const derEncodedPublicKey = publicKeyLookupResult.value;
206
+ if (derEncodedPublicKey.byteLength !== 44) {
207
+ throw ProtocolError.fromCode(new DerKeyLengthMismatchErrorCode(44, derEncodedPublicKey.byteLength));
208
+ }
209
+ else {
210
+ nodeKeys.set(node_id, derEncodedPublicKey);
211
+ }
212
+ });
213
+ return {
214
+ subnetId: Principal.fromUint8Array(new Uint8Array(delegation.subnet_id)).toText(),
215
+ nodeKeys,
216
+ };
217
+ };
218
+ export const encodePath = (path, canisterId) => {
219
+ const canisterUint8Array = canisterId.toUint8Array();
220
+ switch (path) {
221
+ case 'time':
222
+ return [utf8ToBytes('time')];
223
+ case 'controllers':
224
+ return [utf8ToBytes('canister'), canisterUint8Array, utf8ToBytes('controllers')];
225
+ case 'module_hash':
226
+ return [utf8ToBytes('canister'), canisterUint8Array, utf8ToBytes('module_hash')];
227
+ case 'subnet':
228
+ return [utf8ToBytes('subnet')];
229
+ case 'candid':
230
+ return [
231
+ utf8ToBytes('canister'),
232
+ canisterUint8Array,
233
+ utf8ToBytes('metadata'),
234
+ utf8ToBytes('candid:service'),
235
+ ];
236
+ default: {
237
+ // Check for CustomPath signature
238
+ if ('key' in path && 'path' in path) {
239
+ // For simplified metadata queries
240
+ if (typeof path['path'] === 'string' || path['path'] instanceof Uint8Array) {
241
+ const metaPath = path.path;
242
+ const encoded = typeof metaPath === 'string' ? utf8ToBytes(metaPath) : metaPath;
243
+ return [utf8ToBytes('canister'), canisterUint8Array, utf8ToBytes('metadata'), encoded];
244
+ // For non-metadata, return the provided custompath
245
+ }
246
+ else {
247
+ return path['path'];
248
+ }
249
+ }
250
+ }
251
+ }
252
+ throw UnknownError.fromCode(new UnexpectedErrorCode(`Error while encoding your path for canister status. Please ensure that your path ${path} was formatted correctly.`));
253
+ };
254
+ // Controllers are CBOR-encoded buffers
255
+ const decodeControllers = (buf) => {
256
+ const controllersRaw = cbor.decode(buf);
257
+ return controllersRaw.map(buf => {
258
+ return Principal.fromUint8Array(buf);
259
+ });
260
+ };
261
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/agent/canisterStatus/index.ts"],"names":[],"mappings":"A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uC;AACvC,MAAM,iBAAiB,GAAG,CAAC,GAAe,EAAe,EAAE;IACzD,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM,CAAe,GAAG,CAAC,CAAC;IACtD,OAAO,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;QAC9B,OAAO,SAAS,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
@@ -0,0 +1,26 @@
1
+ import * as cbor from '@dfinity/cbor';
2
+ /**
3
+ * Used to extend classes that need to provide a custom value for the CBOR encoding process.
4
+ */
5
+ export declare abstract class ToCborValue {
6
+ /**
7
+ * Returns a value that can be encoded with CBOR. Typically called in the replacer function of the {@link encode} function.
8
+ */
9
+ abstract toCborValue(): cbor.CborValue;
10
+ }
11
+ /**
12
+ * Encode a JavaScript value into CBOR. If the value is an instance of {@link ToCborValue},
13
+ * the {@link ToCborValue.toCborValue} method will be called to get the value to encode.
14
+ * @param value The value to encode
15
+ */
16
+ export declare function encode(value: unknown): Uint8Array;
17
+ /**
18
+ * Decode a CBOR encoded value into a JavaScript value.
19
+ * @param input The CBOR encoded value
20
+ */
21
+ export declare function decode<T>(input: Uint8Array): T;
22
+ export declare const Cbor: {
23
+ encode: typeof encode;
24
+ decode: typeof decode;
25
+ };
26
+ //# sourceMappingURL=cbor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cbor.d.ts","sourceRoot":"","sources":["../../../src/agent/cbor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AAItC;;GAEG;AACH,8BAAsB,WAAW;IAC/B;;OAEG;aACa,WAAW,IAAI,IAAI,CAAC,SAAS;CAC9C;AAMD;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,CAoBjD;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,GAAG,CAAC,CAM9C;AAGD,eAAO,MAAM,IAAI;;;CAGhB,CAAC"}