@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
@@ -0,0 +1,52 @@
1
+ import { Principal } from '../../principal/index.js';
2
+ import { RequestStatusResponseStatus } from '../agent/index.ts';
3
+ import { type PollStrategy } from './index.ts';
4
+ import { type RequestId } from '../request_id.ts';
5
+ export type Predicate<T> = (canisterId: Principal, requestId: RequestId, status: RequestStatusResponseStatus) => Promise<T>;
6
+ /**
7
+ * A best practices polling strategy: wait 2 seconds before the first poll, then 1 second
8
+ * with an exponential backoff factor of 1.2. Timeout after 5 minutes.
9
+ *
10
+ * Note that calling this function will create the strategy chain described above and already start the 5 minutes timeout.
11
+ * You should only call this function when you want to start the polling, and not before, to avoid exhausting the 5 minutes timeout in advance.
12
+ */
13
+ export declare function defaultStrategy(): PollStrategy;
14
+ /**
15
+ * Predicate that returns true once.
16
+ */
17
+ export declare function once(): Predicate<boolean>;
18
+ /**
19
+ * Delay the polling once.
20
+ * @param condition A predicate that indicates when to delay.
21
+ * @param timeInMsec The amount of time to delay.
22
+ */
23
+ export declare function conditionalDelay(condition: Predicate<boolean>, timeInMsec: number): PollStrategy;
24
+ /**
25
+ * Error out after a maximum number of polling has been done.
26
+ * @param count The maximum attempts to poll.
27
+ */
28
+ export declare function maxAttempts(count: number): PollStrategy;
29
+ /**
30
+ * Throttle polling.
31
+ * @param throttleInMsec Amount in millisecond to wait between each polling.
32
+ */
33
+ export declare function throttle(throttleInMsec: number): PollStrategy;
34
+ /**
35
+ * Reject a call after a certain amount of time.
36
+ * @param timeInMsec Time in milliseconds before the polling should be rejected.
37
+ */
38
+ export declare function timeout(timeInMsec: number): PollStrategy;
39
+ /**
40
+ * A strategy that throttle, but using an exponential backoff strategy.
41
+ * @param startingThrottleInMsec The throttle in milliseconds to start with.
42
+ * @param backoffFactor The factor to multiple the throttle time between every poll. For
43
+ * example if using 2, the throttle will double between every run.
44
+ */
45
+ export declare function backoff(startingThrottleInMsec: number, backoffFactor: number): PollStrategy;
46
+ /**
47
+ * Chain multiple polling strategy. This _chains_ the strategies, so if you pass in,
48
+ * say, two throttling strategy of 1 second, it will result in a throttle of 2 seconds.
49
+ * @param strategies A strategy list to chain.
50
+ */
51
+ export declare function chain(...strategies: PollStrategy[]): PollStrategy;
52
+ //# sourceMappingURL=strategy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strategy.d.ts","sourceRoot":"","sources":["../../../../src/agent/polling/strategy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAGlD,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CACzB,UAAU,EAAE,SAAS,EACrB,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,2BAA2B,KAChC,OAAO,CAAC,CAAC,CAAC,CAAC;AAIhB;;;;;;GAMG;AACH,wBAAgB,eAAe,IAAI,YAAY,CAE9C;AAED;;GAEG;AACH,wBAAgB,IAAI,IAAI,SAAS,CAAC,OAAO,CAAC,CASzC;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,SAAS,CAAC,OAAO,CAAC,EAAE,UAAU,EAAE,MAAM,GAAG,YAAY,CAUhG;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAiBvD;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,cAAc,EAAE,MAAM,GAAG,YAAY,CAE7D;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,YAAY,CAiBxD;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,sBAAsB,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,YAAY,CAU3F;AAED;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,GAAG,UAAU,EAAE,YAAY,EAAE,GAAG,YAAY,CAUjE"}
@@ -0,0 +1,94 @@
1
+ import { ProtocolError, TimeoutWaitingForResponseErrorCode } from "../errors.js";
2
+ const FIVE_MINUTES_IN_MSEC = 5 * 60 * 1000;
3
+ /**
4
+ * A best practices polling strategy: wait 2 seconds before the first poll, then 1 second
5
+ * with an exponential backoff factor of 1.2. Timeout after 5 minutes.
6
+ *
7
+ * Note that calling this function will create the strategy chain described above and already start the 5 minutes timeout.
8
+ * You should only call this function when you want to start the polling, and not before, to avoid exhausting the 5 minutes timeout in advance.
9
+ */
10
+ export function defaultStrategy() {
11
+ return chain(conditionalDelay(once(), 1000), backoff(1000, 1.2), timeout(FIVE_MINUTES_IN_MSEC));
12
+ }
13
+ /**
14
+ * Predicate that returns true once.
15
+ */
16
+ export function once() {
17
+ let first = true;
18
+ return async () => {
19
+ if (first) {
20
+ first = false;
21
+ return true;
22
+ }
23
+ return false;
24
+ };
25
+ }
26
+ /**
27
+ * Delay the polling once.
28
+ * @param condition A predicate that indicates when to delay.
29
+ * @param timeInMsec The amount of time to delay.
30
+ */
31
+ export function conditionalDelay(condition, timeInMsec) {
32
+ return async (canisterId, requestId, status) => {
33
+ if (await condition(canisterId, requestId, status)) {
34
+ return new Promise(resolve => setTimeout(resolve, timeInMsec));
35
+ }
36
+ };
37
+ }
38
+ /**
39
+ * Error out after a maximum number of polling has been done.
40
+ * @param count The maximum attempts to poll.
41
+ */
42
+ export function maxAttempts(count) {
43
+ let attempts = count;
44
+ return async (_canisterId, requestId, status) => {
45
+ if (--attempts <= 0) {
46
+ throw ProtocolError.fromCode(new TimeoutWaitingForResponseErrorCode(`Failed to retrieve a reply for request after ${count} attempts`, requestId, status));
47
+ }
48
+ };
49
+ }
50
+ /**
51
+ * Throttle polling.
52
+ * @param throttleInMsec Amount in millisecond to wait between each polling.
53
+ */
54
+ export function throttle(throttleInMsec) {
55
+ return () => new Promise(resolve => setTimeout(resolve, throttleInMsec));
56
+ }
57
+ /**
58
+ * Reject a call after a certain amount of time.
59
+ * @param timeInMsec Time in milliseconds before the polling should be rejected.
60
+ */
61
+ export function timeout(timeInMsec) {
62
+ const end = Date.now() + timeInMsec;
63
+ return async (_canisterId, requestId, status) => {
64
+ if (Date.now() > end) {
65
+ throw ProtocolError.fromCode(new TimeoutWaitingForResponseErrorCode(`Request timed out after ${timeInMsec} msec`, requestId, status));
66
+ }
67
+ };
68
+ }
69
+ /**
70
+ * A strategy that throttle, but using an exponential backoff strategy.
71
+ * @param startingThrottleInMsec The throttle in milliseconds to start with.
72
+ * @param backoffFactor The factor to multiple the throttle time between every poll. For
73
+ * example if using 2, the throttle will double between every run.
74
+ */
75
+ export function backoff(startingThrottleInMsec, backoffFactor) {
76
+ let currentThrottling = startingThrottleInMsec;
77
+ return () => new Promise(resolve => setTimeout(() => {
78
+ currentThrottling *= backoffFactor;
79
+ resolve();
80
+ }, currentThrottling));
81
+ }
82
+ /**
83
+ * Chain multiple polling strategy. This _chains_ the strategies, so if you pass in,
84
+ * say, two throttling strategy of 1 second, it will result in a throttle of 2 seconds.
85
+ * @param strategies A strategy list to chain.
86
+ */
87
+ export function chain(...strategies) {
88
+ return async (canisterId, requestId, status) => {
89
+ for (const a of strategies) {
90
+ await a(canisterId, requestId, status);
91
+ }
92
+ };
93
+ }
94
+ //# sourceMappingURL=strategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strategy.js","sourceRoot":"","sources":["../../../../src/agent/polling/strategy.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,kCAAkC,EAAE,MAAM,cAAc,CAAC;AAQjF,MAAM,oBAAoB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAE3C;;;;;;GAMG;AACH,MAAM,UAAU,eAAe;IAC7B,OAAO,KAAK,CAAC,gBAAgB,CAAC,IAAI,EAAE,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC;AAClG,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,IAAI;IAClB,IAAI,KAAK,GAAG,IAAI,CAAC;IACjB,OAAO,KAAK,IAAI,EAAE;QAChB,IAAI,KAAK,EAAE,CAAC;YACV,KAAK,GAAG,KAAK,CAAC;YACd,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,SAA6B,EAAE,UAAkB;IAChF,OAAO,KAAK,EACV,UAAqB,EACrB,SAAoB,EACpB,MAAmC,EACnC,EAAE;QACF,IAAI,MAAM,SAAS,CAAC,UAAU,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,CAAC;YACnD,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC;QACjE,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,KAAa;IACvC,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,OAAO,KAAK,EACV,WAAsB,EACtB,SAAoB,EACpB,MAAmC,EACnC,EAAE;QACF,IAAI,EAAE,QAAQ,IAAI,CAAC,EAAE,CAAC;YACpB,MAAM,aAAa,CAAC,QAAQ,CAC1B,IAAI,kCAAkC,CACpC,gDAAgD,KAAK,WAAW,EAChE,SAAS,EACT,MAAM,CACP,CACF,CAAC;QACJ,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,cAAsB;IAC7C,OAAO,GAAG,EAAE,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC;AAC3E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,UAAkB;IACxC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,UAAU,CAAC;IACpC,OAAO,KAAK,EACV,WAAsB,EACtB,SAAoB,EACpB,MAAmC,EACnC,EAAE;QACF,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,GAAG,EAAE,CAAC;YACrB,MAAM,aAAa,CAAC,QAAQ,CAC1B,IAAI,kCAAkC,CACpC,2BAA2B,UAAU,OAAO,EAC5C,SAAS,EACT,MAAM,CACP,CACF,CAAC;QACJ,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAC,sBAA8B,EAAE,aAAqB;IAC3E,IAAI,iBAAiB,GAAG,sBAAsB,CAAC;IAE/C,OAAO,GAAG,EAAE,CACV,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CACpB,UAAU,CAAC,GAAG,EAAE;QACd,iBAAiB,IAAI,aAAa,CAAC;QACnC,OAAO,EAAE,CAAC;IACZ,CAAC,EAAE,iBAAiB,CAAC,CACtB,CAAC;AACN,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,KAAK,CAAC,GAAG,UAA0B;IACjD,OAAO,KAAK,EACV,UAAqB,EACrB,SAAoB,EACpB,MAAmC,EACnC,EAAE;QACF,KAAK,MAAM,CAAC,IAAI,UAAU,EAAE,CAAC;YAC3B,MAAM,CAAC,CAAC,UAAU,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;QACzC,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { type DerEncodedPublicKey, type PublicKey } from './auth.ts';
2
+ export declare class Ed25519PublicKey implements PublicKey {
3
+ #private;
4
+ static from(key: PublicKey): Ed25519PublicKey;
5
+ static fromRaw(rawKey: Uint8Array): Ed25519PublicKey;
6
+ static fromDer(derKey: DerEncodedPublicKey): Ed25519PublicKey;
7
+ private static RAW_KEY_LENGTH;
8
+ private static derEncode;
9
+ private static derDecode;
10
+ get rawKey(): Uint8Array;
11
+ get derKey(): DerEncodedPublicKey;
12
+ private constructor();
13
+ toDer(): DerEncodedPublicKey;
14
+ toRaw(): Uint8Array;
15
+ }
16
+ //# sourceMappingURL=public_key.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public_key.d.ts","sourceRoot":"","sources":["../../../src/agent/public_key.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,mBAAmB,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAIrE,qBAAa,gBAAiB,YAAW,SAAS;;WAClC,IAAI,CAAC,GAAG,EAAE,SAAS,GAAG,gBAAgB;WAItC,OAAO,CAAC,MAAM,EAAE,UAAU,GAAG,gBAAgB;WAI7C,OAAO,CAAC,MAAM,EAAE,mBAAmB,GAAG,gBAAgB;IAKpE,OAAO,CAAC,MAAM,CAAC,cAAc,CAAM;IAEnC,OAAO,CAAC,MAAM,CAAC,SAAS;IAIxB,OAAO,CAAC,MAAM,CAAC,SAAS;IAYxB,IAAW,MAAM,IAAI,UAAU,CAE9B;IAID,IAAW,MAAM,IAAI,mBAAmB,CAEvC;IAGD,OAAO;IAUA,KAAK,IAAI,mBAAmB;IAI5B,KAAK,IAAI,UAAU;CAG3B"}
@@ -0,0 +1,48 @@
1
+ import { ED25519_OID, unwrapDER, wrapDER } from "./der.js";
2
+ import { DerDecodeErrorCode, InputError } from "./errors.js";
3
+ export class Ed25519PublicKey {
4
+ static from(key) {
5
+ return this.fromDer(key.toDer());
6
+ }
7
+ static fromRaw(rawKey) {
8
+ return new Ed25519PublicKey(rawKey);
9
+ }
10
+ static fromDer(derKey) {
11
+ return new Ed25519PublicKey(this.derDecode(derKey));
12
+ }
13
+ // The length of Ed25519 public keys is always 32 bytes.
14
+ static { this.RAW_KEY_LENGTH = 32; }
15
+ static derEncode(publicKey) {
16
+ return wrapDER(publicKey, ED25519_OID);
17
+ }
18
+ static derDecode(key) {
19
+ const unwrapped = unwrapDER(key, ED25519_OID);
20
+ if (unwrapped.length !== this.RAW_KEY_LENGTH) {
21
+ throw InputError.fromCode(new DerDecodeErrorCode('An Ed25519 public key must be exactly 32 bytes long'));
22
+ }
23
+ return unwrapped;
24
+ }
25
+ #rawKey;
26
+ get rawKey() {
27
+ return this.#rawKey;
28
+ }
29
+ #derKey;
30
+ get derKey() {
31
+ return this.#derKey;
32
+ }
33
+ // `fromRaw` and `fromDer` should be used for instantiation, not this constructor.
34
+ constructor(key) {
35
+ if (key.byteLength !== Ed25519PublicKey.RAW_KEY_LENGTH) {
36
+ throw InputError.fromCode(new DerDecodeErrorCode('An Ed25519 public key must be exactly 32 bytes long'));
37
+ }
38
+ this.#rawKey = key;
39
+ this.#derKey = Ed25519PublicKey.derEncode(key);
40
+ }
41
+ toDer() {
42
+ return this.derKey;
43
+ }
44
+ toRaw() {
45
+ return this.rawKey;
46
+ }
47
+ }
48
+ //# sourceMappingURL=public_key.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public_key.js","sourceRoot":"","sources":["../../../src/agent/public_key.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE7D,MAAM,OAAO,gBAAgB;IACpB,MAAM,CAAC,IAAI,CAAC,GAAc;QAC/B,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC;IACnC,CAAC;IAEM,MAAM,CAAC,OAAO,CAAC,MAAkB;QACtC,OAAO,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;IAEM,MAAM,CAAC,OAAO,CAAC,MAA2B;QAC/C,OAAO,IAAI,gBAAgB,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;IACtD,CAAC;IAED,wDAAwD;aACzC,mBAAc,GAAG,EAAE,CAAC;IAE3B,MAAM,CAAC,SAAS,CAAC,SAAqB;QAC5C,OAAO,OAAO,CAAC,SAAS,EAAE,WAAW,CAAwB,CAAC;IAChE,CAAC;IAEO,MAAM,CAAC,SAAS,CAAC,GAAwB;QAC/C,MAAM,SAAS,GAAG,SAAS,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;QAC9C,IAAI,SAAS,CAAC,MAAM,KAAK,IAAI,CAAC,cAAc,EAAE,CAAC;YAC7C,MAAM,UAAU,CAAC,QAAQ,CACvB,IAAI,kBAAkB,CAAC,qDAAqD,CAAC,CAC9E,CAAC;QACJ,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,CAAa;IAEpB,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,OAAO,CAAsB;IAE7B,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,kFAAkF;IAClF,YAAoB,GAAe;QACjC,IAAI,GAAG,CAAC,UAAU,KAAK,gBAAgB,CAAC,cAAc,EAAE,CAAC;YACvD,MAAM,UAAU,CAAC,QAAQ,CACvB,IAAI,kBAAkB,CAAC,qDAAqD,CAAC,CAC9E,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC;QACnB,IAAI,CAAC,OAAO,GAAG,gBAAgB,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IACjD,CAAC;IAEM,KAAK;QACV,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAEM,KAAK;QACV,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC"}
@@ -0,0 +1,24 @@
1
+ export type RequestId = Uint8Array & {
2
+ __requestId__: void;
3
+ };
4
+ /**
5
+ *
6
+ * @param value unknown value
7
+ * @returns Uint8Array
8
+ */
9
+ export declare function hashValue(value: unknown): Uint8Array;
10
+ /**
11
+ * Get the RequestId of the provided ic-ref request.
12
+ * RequestId is the result of the representation-independent-hash function.
13
+ * https://sdk.dfinity.org/docs/interface-spec/index.html#hash-of-map
14
+ * @param request - ic-ref request to hash into RequestId
15
+ */
16
+ export declare function requestIdOf(request: Record<string, unknown>): RequestId;
17
+ /**
18
+ * Hash a map into a Uint8Array using the representation-independent-hash function.
19
+ * https://sdk.dfinity.org/docs/interface-spec/index.html#hash-of-map
20
+ * @param map - Any non-nested object
21
+ * @returns Uint8Array
22
+ */
23
+ export declare function hashOfMap(map: Record<string, unknown>): Uint8Array;
24
+ //# sourceMappingURL=request_id.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request_id.d.ts","sourceRoot":"","sources":["../../../src/agent/request_id.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG;IAAE,aAAa,EAAE,IAAI,CAAA;CAAE,CAAC;AAM7D;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,CA+BpD;AAOD;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAEvE;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,UAAU,CAmBlE"}
@@ -0,0 +1,83 @@
1
+ import { lebEncode, compare } from '../candid/index.js';
2
+ import { HashValueErrorCode, InputError } from "./errors.js";
3
+ import { uint8FromBufLike } from "./utils/buffer.js";
4
+ import { concatBytes } from '@noble/hashes/utils';
5
+ import { sha256 } from '@noble/hashes/sha2';
6
+ /**
7
+ *
8
+ * @param value unknown value
9
+ * @returns Uint8Array
10
+ */
11
+ export function hashValue(value) {
12
+ if (typeof value === 'string') {
13
+ return hashString(value);
14
+ }
15
+ else if (typeof value === 'number') {
16
+ return sha256(lebEncode(value));
17
+ }
18
+ else if (value instanceof Uint8Array || ArrayBuffer.isView(value)) {
19
+ return sha256(uint8FromBufLike(value));
20
+ }
21
+ else if (Array.isArray(value)) {
22
+ const vals = value.map(hashValue);
23
+ return sha256(concatBytes(...vals));
24
+ }
25
+ else if (value && typeof value === 'object' && value._isPrincipal) {
26
+ return sha256(value.toUint8Array());
27
+ }
28
+ else if (typeof value === 'object' &&
29
+ value !== null &&
30
+ typeof value.toHash === 'function') {
31
+ return hashValue(value.toHash());
32
+ // TODO This should be move to a specific async method as the webauthn flow required
33
+ // the flow to be synchronous to ensure Safari touch id works.
34
+ // } else if (value instanceof Promise) {
35
+ // return value.then(x => hashValue(x));
36
+ }
37
+ else if (typeof value === 'object') {
38
+ return hashOfMap(value);
39
+ }
40
+ else if (typeof value === 'bigint') {
41
+ // Do this check much later than the other bigint check because this one is much less
42
+ // type-safe.
43
+ // So we want to try all the high-assurance type guards before this 'probable' one.
44
+ return sha256(lebEncode(value));
45
+ }
46
+ throw InputError.fromCode(new HashValueErrorCode(value));
47
+ }
48
+ const hashString = (value) => {
49
+ const encoded = new TextEncoder().encode(value);
50
+ return sha256(encoded);
51
+ };
52
+ /**
53
+ * Get the RequestId of the provided ic-ref request.
54
+ * RequestId is the result of the representation-independent-hash function.
55
+ * https://sdk.dfinity.org/docs/interface-spec/index.html#hash-of-map
56
+ * @param request - ic-ref request to hash into RequestId
57
+ */
58
+ export function requestIdOf(request) {
59
+ return hashOfMap(request);
60
+ }
61
+ /**
62
+ * Hash a map into a Uint8Array using the representation-independent-hash function.
63
+ * https://sdk.dfinity.org/docs/interface-spec/index.html#hash-of-map
64
+ * @param map - Any non-nested object
65
+ * @returns Uint8Array
66
+ */
67
+ export function hashOfMap(map) {
68
+ const hashed = Object.entries(map)
69
+ .filter(([, value]) => value !== undefined)
70
+ .map(([key, value]) => {
71
+ const hashedKey = hashString(key);
72
+ const hashedValue = hashValue(value);
73
+ return [hashedKey, hashedValue];
74
+ });
75
+ const traversed = hashed;
76
+ const sorted = traversed.sort(([k1], [k2]) => {
77
+ return compare(k1, k2);
78
+ });
79
+ const concatenated = concatBytes(...sorted.map(x => concatBytes(...x)));
80
+ const result = sha256(concatenated);
81
+ return result;
82
+ }
83
+ //# sourceMappingURL=request_id.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request_id.js","sourceRoot":"","sources":["../../../src/agent/request_id.ts"],"names":[],"mappings":"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"}
@@ -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"}