@icp-sdk/core 4.2.2 → 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,294 @@
1
+ import { requestIdOf, SignIdentity, IC_REQUEST_DOMAIN_SEPARATOR, IC_REQUEST_AUTH_DELEGATION_DOMAIN_SEPARATOR, } from '../../agent/index.js';
2
+ import { Principal } from '../../principal/index.js';
3
+ import { PartialIdentity } from "./partial.js";
4
+ import { bytesToHex, hexToBytes } from '@noble/hashes/utils';
5
+ /**
6
+ * Safe wrapper around bytesToHex that handles ArrayBuffer/Uint8Array type conversion.
7
+ * Required because @noble/hashes v1.8+ strictly expects Uint8Array inputs.
8
+ * @param data The binary data to convert to hexadecimal string (ArrayBuffer, Uint8Array, or ArrayLike<number>)
9
+ */
10
+ function safeBytesToHex(data) {
11
+ if (data instanceof Uint8Array) {
12
+ return bytesToHex(data);
13
+ }
14
+ return bytesToHex(new Uint8Array(data));
15
+ }
16
+ function _parseBlob(value) {
17
+ if (typeof value !== 'string' || value.length < 64) {
18
+ throw new Error('Invalid public key.');
19
+ }
20
+ return hexToBytes(value);
21
+ }
22
+ /**
23
+ * A single delegation object that is signed by a private key. This is constructed by
24
+ * `DelegationChain.create()`.
25
+ *
26
+ * {@see DelegationChain}
27
+ */
28
+ export class Delegation {
29
+ constructor(pubkey, expiration, targets) {
30
+ this.pubkey = pubkey;
31
+ this.expiration = expiration;
32
+ this.targets = targets;
33
+ }
34
+ toCborValue() {
35
+ return {
36
+ pubkey: this.pubkey,
37
+ expiration: this.expiration,
38
+ ...(this.targets && {
39
+ targets: this.targets,
40
+ }),
41
+ };
42
+ }
43
+ toJSON() {
44
+ // every string should be hex and once-de-hexed,
45
+ // discoverable what it is (e.g. de-hex to get JSON with a 'type' property, or de-hex to DER
46
+ // with an OID). After de-hex, if it's not obvious what it is, it's an ArrayBuffer.
47
+ return {
48
+ expiration: this.expiration.toString(16),
49
+ pubkey: safeBytesToHex(this.pubkey),
50
+ ...(this.targets && { targets: this.targets.map(p => p.toHex()) }),
51
+ };
52
+ }
53
+ }
54
+ /**
55
+ * Sign a single delegation object for a period of time.
56
+ * @param from The identity that lends its delegation.
57
+ * @param to The identity that receives the delegation.
58
+ * @param expiration An expiration date for this delegation.
59
+ * @param targets Limit this delegation to the target principals.
60
+ */
61
+ async function _createSingleDelegation(from, to, expiration, targets) {
62
+ const delegation = new Delegation(to.toDer(), BigInt(+expiration) * BigInt(1000000), // In nanoseconds.
63
+ targets);
64
+ // The signature is calculated by signing the concatenation of the domain separator
65
+ // and the message.
66
+ // Note: To ensure Safari treats this as a user gesture, ensure to not use async methods
67
+ // besides the actualy webauthn functionality (such as `sign`). Safari will de-register
68
+ // a user gesture if you await an async call thats not fetch, xhr, or setTimeout.
69
+ const challenge = new Uint8Array([
70
+ ...IC_REQUEST_AUTH_DELEGATION_DOMAIN_SEPARATOR,
71
+ ...new Uint8Array(requestIdOf({ ...delegation })),
72
+ ]);
73
+ const signature = await from.sign(challenge);
74
+ return {
75
+ delegation,
76
+ signature,
77
+ };
78
+ }
79
+ /**
80
+ * A chain of delegations. This is JSON Serializable.
81
+ * This is the object to serialize and pass to a DelegationIdentity. It does not keep any
82
+ * private keys.
83
+ */
84
+ export class DelegationChain {
85
+ /**
86
+ * Create a delegation chain between two (or more) keys. By default, the expiration time
87
+ * will be very short (15 minutes).
88
+ *
89
+ * To build a chain of more than 2 identities, this function needs to be called multiple times,
90
+ * passing the previous delegation chain into the options argument. For example:
91
+ * @example
92
+ * const rootKey = createKey();
93
+ * const middleKey = createKey();
94
+ * const bottomeKey = createKey();
95
+ *
96
+ * const rootToMiddle = await DelegationChain.create(
97
+ * root, middle.getPublicKey(), Date.parse('2100-01-01'),
98
+ * );
99
+ * const middleToBottom = await DelegationChain.create(
100
+ * middle, bottom.getPublicKey(), Date.parse('2100-01-01'), { previous: rootToMiddle },
101
+ * );
102
+ *
103
+ * // We can now use a delegation identity that uses the delegation above:
104
+ * const identity = DelegationIdentity.fromDelegation(bottomKey, middleToBottom);
105
+ * @param from The identity that will delegate.
106
+ * @param to The identity that gets delegated. It can now sign messages as if it was the
107
+ * identity above.
108
+ * @param expiration The length the delegation is valid. By default, 15 minutes from calling
109
+ * this function.
110
+ * @param options A set of options for this delegation. expiration and previous
111
+ * @param options.previous - Another DelegationChain that this chain should start with.
112
+ * @param options.targets - targets that scope the delegation (e.g. Canister Principals)
113
+ */
114
+ static async create(from, to, expiration = new Date(Date.now() + 15 * 60 * 1000), options = {}) {
115
+ const delegation = await _createSingleDelegation(from, to, expiration, options.targets);
116
+ return new DelegationChain([...(options.previous?.delegations || []), delegation], options.previous?.publicKey || from.getPublicKey().toDer());
117
+ }
118
+ /**
119
+ * Creates a DelegationChain object from a JSON string.
120
+ * @param json The JSON string to parse.
121
+ */
122
+ static fromJSON(json) {
123
+ const { publicKey, delegations } = typeof json === 'string' ? JSON.parse(json) : json;
124
+ if (!Array.isArray(delegations)) {
125
+ throw new Error('Invalid delegations.');
126
+ }
127
+ const parsedDelegations = delegations.map(signedDelegation => {
128
+ const { delegation, signature } = signedDelegation;
129
+ const { pubkey, expiration, targets } = delegation;
130
+ if (targets !== undefined && !Array.isArray(targets)) {
131
+ throw new Error('Invalid targets.');
132
+ }
133
+ return {
134
+ delegation: new Delegation(_parseBlob(pubkey), BigInt('0x' + expiration), // expiration in JSON is an hexa string (See toJSON() below).
135
+ targets &&
136
+ targets.map((t) => {
137
+ if (typeof t !== 'string') {
138
+ throw new Error('Invalid target.');
139
+ }
140
+ return Principal.fromHex(t);
141
+ })),
142
+ signature: _parseBlob(signature),
143
+ };
144
+ });
145
+ return new this(parsedDelegations, _parseBlob(publicKey));
146
+ }
147
+ /**
148
+ * Creates a DelegationChain object from a list of delegations and a DER-encoded public key.
149
+ * @param delegations The list of delegations.
150
+ * @param publicKey The DER-encoded public key of the key-pair signing the first delegation.
151
+ */
152
+ static fromDelegations(delegations, publicKey) {
153
+ return new this(delegations, publicKey);
154
+ }
155
+ constructor(delegations, publicKey) {
156
+ this.delegations = delegations;
157
+ this.publicKey = publicKey;
158
+ }
159
+ toJSON() {
160
+ return {
161
+ delegations: this.delegations.map(signedDelegation => {
162
+ const { delegation, signature } = signedDelegation;
163
+ const { targets } = delegation;
164
+ return {
165
+ delegation: {
166
+ expiration: delegation.expiration.toString(16),
167
+ pubkey: safeBytesToHex(delegation.pubkey),
168
+ ...(targets && {
169
+ targets: targets.map(t => t.toHex()),
170
+ }),
171
+ },
172
+ signature: safeBytesToHex(signature),
173
+ };
174
+ }),
175
+ publicKey: safeBytesToHex(this.publicKey),
176
+ };
177
+ }
178
+ }
179
+ /**
180
+ * An Identity that adds delegation to a request. Everywhere in this class, the name
181
+ * innerKey refers to the SignIdentity that is being used to sign the requests, while
182
+ * originalKey is the identity that is being borrowed. More identities can be used
183
+ * in the middle to delegate.
184
+ */
185
+ export class DelegationIdentity extends SignIdentity {
186
+ /**
187
+ * Create a delegation without having access to delegateKey.
188
+ * @param key The key used to sign the requests.
189
+ * @param delegation A delegation object created using `createDelegation`.
190
+ */
191
+ static fromDelegation(key, delegation) {
192
+ return new this(key, delegation);
193
+ }
194
+ constructor(_inner, _delegation) {
195
+ super();
196
+ this._inner = _inner;
197
+ this._delegation = _delegation;
198
+ }
199
+ getDelegation() {
200
+ return this._delegation;
201
+ }
202
+ getPublicKey() {
203
+ return {
204
+ derKey: this._delegation.publicKey,
205
+ toDer: () => this._delegation.publicKey,
206
+ };
207
+ }
208
+ sign(blob) {
209
+ return this._inner.sign(blob);
210
+ }
211
+ async transformRequest(request) {
212
+ const { body, ...fields } = request;
213
+ const requestId = await requestIdOf(body);
214
+ return {
215
+ ...fields,
216
+ body: {
217
+ content: body,
218
+ sender_sig: await this.sign(new Uint8Array([...IC_REQUEST_DOMAIN_SEPARATOR, ...new Uint8Array(requestId)])),
219
+ sender_delegation: this._delegation.delegations,
220
+ sender_pubkey: this._delegation.publicKey,
221
+ },
222
+ };
223
+ }
224
+ }
225
+ /**
226
+ * A partial delegated identity, representing a delegation chain and the public key that it targets
227
+ */
228
+ export class PartialDelegationIdentity extends PartialIdentity {
229
+ #delegation;
230
+ /**
231
+ * The Delegation Chain of this identity.
232
+ */
233
+ get delegation() {
234
+ return this.#delegation;
235
+ }
236
+ constructor(inner, delegation) {
237
+ super(inner);
238
+ this.#delegation = delegation;
239
+ }
240
+ /**
241
+ * Create a {@link PartialDelegationIdentity} from a {@link PublicKey} and a {@link DelegationChain}.
242
+ * @param key The {@link PublicKey} to delegate to.
243
+ * @param delegation a {@link DelegationChain} targeting the inner key.
244
+ */
245
+ static fromDelegation(key, delegation) {
246
+ return new PartialDelegationIdentity(key, delegation);
247
+ }
248
+ }
249
+ /**
250
+ * Analyze a DelegationChain and validate that it's valid, ie. not expired and apply to the
251
+ * scope.
252
+ * @param chain The chain to validate.
253
+ * @param checks Various checks to validate on the chain.
254
+ */
255
+ export function isDelegationValid(chain, checks) {
256
+ // Verify that the no delegation is expired. If any are in the chain, returns false.
257
+ for (const { delegation } of chain.delegations) {
258
+ // prettier-ignore
259
+ if (+new Date(Number(delegation.expiration / BigInt(1000000))) <= +Date.now()) {
260
+ return false;
261
+ }
262
+ }
263
+ // Check the scopes.
264
+ const scopes = [];
265
+ const maybeScope = checks?.scope;
266
+ if (maybeScope) {
267
+ if (Array.isArray(maybeScope)) {
268
+ scopes.push(...maybeScope.map(s => (typeof s === 'string' ? Principal.fromText(s) : s)));
269
+ }
270
+ else {
271
+ scopes.push(typeof maybeScope === 'string' ? Principal.fromText(maybeScope) : maybeScope);
272
+ }
273
+ }
274
+ for (const s of scopes) {
275
+ const scope = s.toText();
276
+ for (const { delegation } of chain.delegations) {
277
+ if (delegation.targets === undefined) {
278
+ continue;
279
+ }
280
+ let none = true;
281
+ for (const target of delegation.targets) {
282
+ if (target.toText() === scope) {
283
+ none = false;
284
+ break;
285
+ }
286
+ }
287
+ if (none) {
288
+ return false;
289
+ }
290
+ }
291
+ }
292
+ return true;
293
+ }
294
+ //# sourceMappingURL=delegation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delegation.js","sourceRoot":"","sources":["../../../../src/identity/identity/delegation.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,WAAW,EAEX,YAAY,EACZ,2BAA2B,EAC3B,2CAA2C,GAE5C,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAE7D;;;;GAIG;AACH,SAAS,cAAc,CAAC,IAAkD;IACxE,IAAI,IAAI,YAAY,UAAU,EAAE,CAAC;QAC/B,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IACD,OAAO,UAAU,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;AAC1C,CAAC;AAED,SAAS,UAAU,CAAC,KAAc;IAChC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;QACnD,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACzC,CAAC;IAED,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC;AAC3B,CAAC;AAED;;;;;GAKG;AACH,MAAM,OAAO,UAAU;IACrB,YACkB,MAAkB,EAClB,UAAkB,EAClB,OAAqB;QAFrB,WAAM,GAAN,MAAM,CAAY;QAClB,eAAU,GAAV,UAAU,CAAQ;QAClB,YAAO,GAAP,OAAO,CAAc;IACpC,CAAC;IAEG,WAAW;QAChB,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,GAAG,CAAC,IAAI,CAAC,OAAO,IAAI;gBAClB,OAAO,EAAE,IAAI,CAAC,OAAO;aACtB,CAAC;SAC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AAC,CAAC,CAAC,CAAC;QAC3F,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,IAAI,CAAC,OAAO,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;QAC5F,CAAC;IACH,CAAC;IAED,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;QACvB,MAAM,KAAK,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC;QACzB,KAAK,MAAM,EAAE,UAAU,EAAE,IAAI,KAAK,CAAC,WAAW,EAAE,CAAC;YAC/C,IAAI,UAAU,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;gBACrC,SAAS;YACX,CAAC;YAED,IAAI,IAAI,GAAG,IAAI,CAAC;YAChB,KAAK,MAAM,MAAM,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC;gBACxC,IAAI,MAAM,CAAC,MAAM,EAAE,KAAK,KAAK,EAAE,CAAC;oBAC9B,IAAI,GAAG,KAAK,CAAC;oBACb,MAAM;gBACR,CAAC;YACH,CAAC;YACD,IAAI,IAAI,EAAE,CAAC;gBACT,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,62 @@
1
+ import { type DerEncodedPublicKey, type PublicKey, type Signature, SignIdentity } from '../../agent/index.js';
2
+ /**
3
+ * Options used in a {@link ECDSAKeyIdentity}
4
+ */
5
+ export type CryptoKeyOptions = {
6
+ extractable?: boolean;
7
+ keyUsages?: KeyUsage[];
8
+ subtleCrypto?: SubtleCrypto;
9
+ };
10
+ export declare class CryptoError extends Error {
11
+ readonly message: string;
12
+ constructor(message: string);
13
+ }
14
+ export interface DerCryptoKey extends CryptoKey {
15
+ toDer: () => DerEncodedPublicKey;
16
+ }
17
+ /**
18
+ * An identity interface that wraps an ECDSA keypair using the P-256 named curve. Supports DER-encoding and decoding for agent calls
19
+ */
20
+ export declare class ECDSAKeyIdentity extends SignIdentity {
21
+ /**
22
+ * Generates a randomly generated identity for use in calls to the Internet Computer.
23
+ * @param {CryptoKeyOptions} options optional settings
24
+ * @param {CryptoKeyOptions['extractable']} options.extractable - whether the key should allow itself to be used. Set to false for maximum security.
25
+ * @param {CryptoKeyOptions['keyUsages']} options.keyUsages - a list of key usages that the key can be used for
26
+ * @param {CryptoKeyOptions['subtleCrypto']} options.subtleCrypto interface
27
+ * @returns a {@link ECDSAKeyIdentity}
28
+ */
29
+ static generate(options?: CryptoKeyOptions): Promise<ECDSAKeyIdentity>;
30
+ /**
31
+ * generates an identity from a public and private key. Please ensure that you are generating these keys securely and protect the user's private key
32
+ * @param keyPair a CryptoKeyPair
33
+ * @param subtleCrypto - a SubtleCrypto interface in case one is not available globally
34
+ * @returns an {@link ECDSAKeyIdentity}
35
+ */
36
+ static fromKeyPair(keyPair: CryptoKeyPair | {
37
+ privateKey: CryptoKey;
38
+ publicKey: CryptoKey;
39
+ }, subtleCrypto?: SubtleCrypto): Promise<ECDSAKeyIdentity>;
40
+ protected _derKey: DerEncodedPublicKey;
41
+ protected _keyPair: CryptoKeyPair;
42
+ protected _subtleCrypto: SubtleCrypto;
43
+ protected constructor(keyPair: CryptoKeyPair, derKey: DerEncodedPublicKey, subtleCrypto: SubtleCrypto);
44
+ /**
45
+ * Return the internally-used key pair.
46
+ * @returns a CryptoKeyPair
47
+ */
48
+ getKeyPair(): CryptoKeyPair;
49
+ /**
50
+ * Return the public key.
51
+ * @returns an {@link PublicKey & DerCryptoKey}
52
+ */
53
+ getPublicKey(): PublicKey & DerCryptoKey;
54
+ /**
55
+ * Signs a blob of data, with this identity's private key.
56
+ * @param {Uint8Array} challenge - challenge to sign with this identity's secretKey, producing a signature
57
+ * @returns {Promise<Signature>} signature
58
+ */
59
+ sign(challenge: Uint8Array): Promise<Signature>;
60
+ }
61
+ export default ECDSAKeyIdentity;
62
+ //# sourceMappingURL=ecdsa.d.ts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CAAC,SAAS,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC;CAe7D;AAED,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,112 @@
1
+ import { SignIdentity } from '../../agent/index.js';
2
+ import { uint8FromBufLike } from '../../candid/index.js';
3
+ export class CryptoError extends Error {
4
+ constructor(message) {
5
+ super(message);
6
+ this.message = message;
7
+ Object.setPrototypeOf(this, CryptoError.prototype);
8
+ }
9
+ }
10
+ /**
11
+ * Utility method to ensure that a subtleCrypto implementation is provided or is available in the global context
12
+ * @param subtleCrypto SubtleCrypto implementation
13
+ * @returns subleCrypto
14
+ */
15
+ function _getEffectiveCrypto(subtleCrypto) {
16
+ if (typeof global !== 'undefined' && global['crypto'] && global['crypto']['subtle']) {
17
+ return global['crypto']['subtle'];
18
+ }
19
+ if (subtleCrypto) {
20
+ return subtleCrypto;
21
+ }
22
+ else if (typeof crypto !== 'undefined' && crypto['subtle']) {
23
+ return crypto.subtle;
24
+ }
25
+ else {
26
+ throw new CryptoError('Global crypto was not available and none was provided. Please inlcude a SubtleCrypto implementation. See https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto');
27
+ }
28
+ }
29
+ /**
30
+ * An identity interface that wraps an ECDSA keypair using the P-256 named curve. Supports DER-encoding and decoding for agent calls
31
+ */
32
+ export class ECDSAKeyIdentity extends SignIdentity {
33
+ /**
34
+ * Generates a randomly generated identity for use in calls to the Internet Computer.
35
+ * @param {CryptoKeyOptions} options optional settings
36
+ * @param {CryptoKeyOptions['extractable']} options.extractable - whether the key should allow itself to be used. Set to false for maximum security.
37
+ * @param {CryptoKeyOptions['keyUsages']} options.keyUsages - a list of key usages that the key can be used for
38
+ * @param {CryptoKeyOptions['subtleCrypto']} options.subtleCrypto interface
39
+ * @returns a {@link ECDSAKeyIdentity}
40
+ */
41
+ static async generate(options) {
42
+ const { extractable = false, keyUsages = ['sign', 'verify'], subtleCrypto } = options ?? {};
43
+ const effectiveCrypto = _getEffectiveCrypto(subtleCrypto);
44
+ const keyPair = await effectiveCrypto.generateKey({
45
+ name: 'ECDSA',
46
+ namedCurve: 'P-256',
47
+ }, extractable, keyUsages);
48
+ const derKey = uint8FromBufLike(await effectiveCrypto.exportKey('spki', keyPair.publicKey));
49
+ Object.assign(derKey, {
50
+ __derEncodedPublicKey__: undefined,
51
+ });
52
+ return new this(keyPair, derKey, effectiveCrypto);
53
+ }
54
+ /**
55
+ * generates an identity from a public and private key. Please ensure that you are generating these keys securely and protect the user's private key
56
+ * @param keyPair a CryptoKeyPair
57
+ * @param subtleCrypto - a SubtleCrypto interface in case one is not available globally
58
+ * @returns an {@link ECDSAKeyIdentity}
59
+ */
60
+ static async fromKeyPair(keyPair, subtleCrypto) {
61
+ const effectiveCrypto = _getEffectiveCrypto(subtleCrypto);
62
+ const derKey = uint8FromBufLike(await effectiveCrypto.exportKey('spki', keyPair.publicKey));
63
+ Object.assign(derKey, {
64
+ __derEncodedPublicKey__: undefined,
65
+ });
66
+ return new ECDSAKeyIdentity(keyPair, derKey, effectiveCrypto);
67
+ }
68
+ // `fromKeyPair` and `generate` should be used for instantiation, not this constructor.
69
+ constructor(keyPair, derKey, subtleCrypto) {
70
+ super();
71
+ this._keyPair = keyPair;
72
+ this._derKey = derKey;
73
+ this._subtleCrypto = subtleCrypto;
74
+ }
75
+ /**
76
+ * Return the internally-used key pair.
77
+ * @returns a CryptoKeyPair
78
+ */
79
+ getKeyPair() {
80
+ return this._keyPair;
81
+ }
82
+ /**
83
+ * Return the public key.
84
+ * @returns an {@link PublicKey & DerCryptoKey}
85
+ */
86
+ getPublicKey() {
87
+ const derKey = this._derKey;
88
+ const key = Object.create(this._keyPair.publicKey);
89
+ key.toDer = function () {
90
+ return derKey;
91
+ };
92
+ return key;
93
+ }
94
+ /**
95
+ * Signs a blob of data, with this identity's private key.
96
+ * @param {Uint8Array} challenge - challenge to sign with this identity's secretKey, producing a signature
97
+ * @returns {Promise<Signature>} signature
98
+ */
99
+ async sign(challenge) {
100
+ const params = {
101
+ name: 'ECDSA',
102
+ hash: { name: 'SHA-256' },
103
+ };
104
+ const signature = uint8FromBufLike(await this._subtleCrypto.sign(params, this._keyPair.privateKey, challenge));
105
+ Object.assign(signature, {
106
+ __signature__: undefined,
107
+ });
108
+ return signature;
109
+ }
110
+ }
111
+ export default ECDSAKeyIdentity;
112
+ //# sourceMappingURL=ecdsa.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ecdsa.js","sourceRoot":"","sources":["../../../../src/identity/identity/ecdsa.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4D,YAAY,EAAE,MAAM,QAAQ,CAAC;AAChG,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAW3C,MAAM,OAAO,WAAY,SAAQ,KAAK;IACpC,YAA4B,OAAe;QACzC,KAAK,CAAC,OAAO,CAAC,CAAC;QADW,YAAO,GAAP,OAAO,CAAQ;QAEzC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IACrD,CAAC;CACF;AAMD;;;;GAIG;AACH,SAAS,mBAAmB,CAAC,YAA8C;IACzE,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC;QACpF,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAC;IACpC,CAAC;IACD,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO,YAAY,CAAC;IACtB,CAAC;SAAM,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC7D,OAAO,MAAM,CAAC,MAAM,CAAC;IACvB,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,WAAW,CACnB,wKAAwK,CACzK,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,YAAY;IAChD;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CAAC;QACxB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;IACpC,CAAC;IAED;;;OAGG;IACI,UAAU;QACf,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED;;;OAGG;IACI,YAAY;QACjB,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,MAAM,GAAG,GAAiB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QACjE,GAAG,CAAC,KAAK,GAAG;YACV,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC;QAEF,OAAO,GAAG,CAAC;IACb,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,IAAI,CAAC,SAAqB;QACrC,MAAM,MAAM,GAAgB;YAC1B,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;SAC1B,CAAC;QACF,MAAM,SAAS,GAAG,gBAAgB,CAChC,MAAM,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC,CAC3E,CAAC;QAEF,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE;YACvB,aAAa,EAAE,SAAS;SACzB,CAAC,CAAC;QAEH,OAAO,SAAsB,CAAC;IAChC,CAAC;CACF;AAED,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,67 @@
1
+ import { type DerEncodedPublicKey, type KeyPair, type PublicKey, type Signature, SignIdentity } from '../../agent/index.js';
2
+ export declare class Ed25519PublicKey implements PublicKey {
3
+ #private;
4
+ /**
5
+ * Construct Ed25519PublicKey from an existing PublicKey
6
+ * @param {unknown} maybeKey - existing PublicKey, ArrayBuffer, DerEncodedPublicKey, or hex string
7
+ * @returns {Ed25519PublicKey} Instance of Ed25519PublicKey
8
+ */
9
+ static from(maybeKey: unknown): Ed25519PublicKey;
10
+ static fromRaw(rawKey: Uint8Array): Ed25519PublicKey;
11
+ static fromDer(derKey: DerEncodedPublicKey): Ed25519PublicKey;
12
+ private static RAW_KEY_LENGTH;
13
+ private static derEncode;
14
+ private static derDecode;
15
+ get rawKey(): Uint8Array;
16
+ get derKey(): DerEncodedPublicKey;
17
+ private constructor();
18
+ toDer(): DerEncodedPublicKey;
19
+ toRaw(): Uint8Array;
20
+ }
21
+ /**
22
+ * Ed25519KeyIdentity is an implementation of SignIdentity that uses Ed25519 keys. This class is used to sign and verify messages for an agent.
23
+ */
24
+ export declare class Ed25519KeyIdentity extends SignIdentity {
25
+ #private;
26
+ /**
27
+ * Generate a new Ed25519KeyIdentity.
28
+ * @param seed a 32-byte seed for the private key. If not provided, a random seed will be generated.
29
+ * @returns Ed25519KeyIdentity
30
+ */
31
+ static generate(seed?: Uint8Array): Ed25519KeyIdentity;
32
+ static fromParsedJson(obj: JsonnableEd25519KeyIdentity): Ed25519KeyIdentity;
33
+ static fromJSON(json: string): Ed25519KeyIdentity;
34
+ static fromKeyPair(publicKey: Uint8Array, privateKey: Uint8Array): Ed25519KeyIdentity;
35
+ static fromSecretKey(secretKey: Uint8Array): Ed25519KeyIdentity;
36
+ protected constructor(publicKey: PublicKey, privateKey: Uint8Array);
37
+ /**
38
+ * Serialize this key to JSON.
39
+ */
40
+ toJSON(): JsonnableEd25519KeyIdentity;
41
+ /**
42
+ * Return a copy of the key pair.
43
+ */
44
+ getKeyPair(): KeyPair;
45
+ /**
46
+ * Return the public key.
47
+ */
48
+ getPublicKey(): Required<PublicKey>;
49
+ /**
50
+ * Signs a blob of data, with this identity's private key.
51
+ * @param challenge - challenge to sign with this identity's secretKey, producing a signature
52
+ */
53
+ sign(challenge: Uint8Array): Promise<Signature>;
54
+ /**
55
+ * Verify
56
+ * @param sig - signature to verify
57
+ * @param msg - message to verify
58
+ * @param pk - public key
59
+ * @returns - true if the signature is valid, false otherwise
60
+ */
61
+ static verify(sig: ArrayBuffer | Uint8Array | string, msg: ArrayBuffer | Uint8Array | string, pk: ArrayBuffer | Uint8Array | string): boolean;
62
+ }
63
+ type PublicKeyHex = string;
64
+ type SecretKeyHex = string;
65
+ export type JsonnableEd25519KeyIdentity = [PublicKeyHex, SecretKeyHex];
66
+ export {};
67
+ //# sourceMappingURL=ed25519.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ed25519.d.ts","sourceRoot":"","sources":["../../../../src/identity/identity/ed25519.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,OAAO,EACZ,KAAK,SAAS,EACd,KAAK,SAAS,EACd,YAAY,EAIb,MAAM,QAAQ,CAAC;AAWhB,qBAAa,gBAAiB,YAAW,SAAS;;IAChD;;;;OAIG;WACW,IAAI,CAAC,QAAQ,EAAE,OAAO,GAAG,gBAAgB;WAwBzC,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;IAMxB,OAAO,CAAC,MAAM,CAAC,SAAS;IAUxB,IAAW,MAAM,IAAI,UAAU,CAE9B;IAID,IAAW,MAAM,IAAI,mBAAmB,CAEvC;IAGD,OAAO;IAQA,KAAK,IAAI,mBAAmB;IAI5B,KAAK,IAAI,UAAU;CAG3B;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,YAAY;;IAClD;;;;OAIG;WACW,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,GAAG,kBAAkB;WAoB/C,cAAc,CAAC,GAAG,EAAE,2BAA2B,GAAG,kBAAkB;WAQpE,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB;WAY1C,WAAW,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,GAAG,kBAAkB;WAI9E,aAAa,CAAC,SAAS,EAAE,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