@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,200 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Ed25519KeyIdentity = exports.Ed25519PublicKey = void 0;
4
+ const _agent_1 = require("../../agent/index.js");
5
+ const _candid_1 = require("../../candid/index.js");
6
+ const ed25519_1 = require("@noble/curves/ed25519");
7
+ const utils_1 = require("@noble/hashes/utils");
8
+ function isObject(value) {
9
+ return value !== null && typeof value === 'object';
10
+ }
11
+ class Ed25519PublicKey {
12
+ /**
13
+ * Construct Ed25519PublicKey from an existing PublicKey
14
+ * @param {unknown} maybeKey - existing PublicKey, ArrayBuffer, DerEncodedPublicKey, or hex string
15
+ * @returns {Ed25519PublicKey} Instance of Ed25519PublicKey
16
+ */
17
+ static from(maybeKey) {
18
+ if (typeof maybeKey === 'string') {
19
+ const key = (0, utils_1.hexToBytes)(maybeKey);
20
+ return this.fromRaw(key);
21
+ }
22
+ else if (isObject(maybeKey)) {
23
+ const key = maybeKey;
24
+ if (isObject(key) && Object.hasOwnProperty.call(key, '__derEncodedPublicKey__')) {
25
+ return this.fromDer(key);
26
+ }
27
+ else if (ArrayBuffer.isView(key)) {
28
+ const view = key;
29
+ return this.fromRaw((0, _candid_1.uint8FromBufLike)(view.buffer));
30
+ }
31
+ else if (key instanceof ArrayBuffer) {
32
+ return this.fromRaw((0, _candid_1.uint8FromBufLike)(key));
33
+ }
34
+ else if ('rawKey' in key && key.rawKey instanceof Uint8Array) {
35
+ return this.fromRaw(key.rawKey);
36
+ }
37
+ else if ('derKey' in key) {
38
+ return this.fromDer(key.derKey);
39
+ }
40
+ else if ('toDer' in key) {
41
+ return this.fromDer(key.toDer());
42
+ }
43
+ }
44
+ throw new Error('Cannot construct Ed25519PublicKey from the provided key.');
45
+ }
46
+ static fromRaw(rawKey) {
47
+ return new Ed25519PublicKey(rawKey);
48
+ }
49
+ static fromDer(derKey) {
50
+ return new Ed25519PublicKey(this.derDecode(derKey));
51
+ }
52
+ // The length of Ed25519 public keys is always 32 bytes.
53
+ static { this.RAW_KEY_LENGTH = 32; }
54
+ static derEncode(publicKey) {
55
+ const key = (0, _agent_1.wrapDER)(publicKey, _agent_1.ED25519_OID);
56
+ key.__derEncodedPublicKey__ = undefined;
57
+ return key;
58
+ }
59
+ static derDecode(key) {
60
+ const unwrapped = (0, _agent_1.unwrapDER)(key, _agent_1.ED25519_OID);
61
+ if (unwrapped.length !== this.RAW_KEY_LENGTH) {
62
+ throw new Error('An Ed25519 public key must be exactly 32bytes long');
63
+ }
64
+ return unwrapped;
65
+ }
66
+ #rawKey;
67
+ get rawKey() {
68
+ return this.#rawKey;
69
+ }
70
+ #derKey;
71
+ get derKey() {
72
+ return this.#derKey;
73
+ }
74
+ // `fromRaw` and `fromDer` should be used for instantiation, not this constructor.
75
+ constructor(key) {
76
+ if (key.byteLength !== Ed25519PublicKey.RAW_KEY_LENGTH) {
77
+ throw new Error('An Ed25519 public key must be exactly 32bytes long');
78
+ }
79
+ this.#rawKey = key;
80
+ this.#derKey = Ed25519PublicKey.derEncode(key);
81
+ }
82
+ toDer() {
83
+ return this.derKey;
84
+ }
85
+ toRaw() {
86
+ return this.rawKey;
87
+ }
88
+ }
89
+ exports.Ed25519PublicKey = Ed25519PublicKey;
90
+ /**
91
+ * Ed25519KeyIdentity is an implementation of SignIdentity that uses Ed25519 keys. This class is used to sign and verify messages for an agent.
92
+ */
93
+ class Ed25519KeyIdentity extends _agent_1.SignIdentity {
94
+ /**
95
+ * Generate a new Ed25519KeyIdentity.
96
+ * @param seed a 32-byte seed for the private key. If not provided, a random seed will be generated.
97
+ * @returns Ed25519KeyIdentity
98
+ */
99
+ static generate(seed) {
100
+ if (seed && seed.length !== 32) {
101
+ throw new Error('Ed25519 Seed needs to be 32 bytes long.');
102
+ }
103
+ if (!seed)
104
+ seed = ed25519_1.ed25519.utils.randomPrivateKey();
105
+ // Check if the seed is all zeros
106
+ if ((0, _candid_1.uint8Equals)(seed, new Uint8Array(new Array(32).fill(0)))) {
107
+ console.warn('Seed is all zeros. This is not a secure seed. Please provide a seed with sufficient entropy if this is a production environment.');
108
+ }
109
+ const sk = new Uint8Array(32);
110
+ for (let i = 0; i < 32; i++) {
111
+ sk[i] = seed[i];
112
+ }
113
+ const pk = ed25519_1.ed25519.getPublicKey(sk);
114
+ return Ed25519KeyIdentity.fromKeyPair(pk, sk);
115
+ }
116
+ static fromParsedJson(obj) {
117
+ const [publicKeyDer, privateKeyRaw] = obj;
118
+ return new Ed25519KeyIdentity(Ed25519PublicKey.fromDer((0, utils_1.hexToBytes)(publicKeyDer)), (0, utils_1.hexToBytes)(privateKeyRaw));
119
+ }
120
+ static fromJSON(json) {
121
+ const parsed = JSON.parse(json);
122
+ if (Array.isArray(parsed)) {
123
+ if (typeof parsed[0] === 'string' && typeof parsed[1] === 'string') {
124
+ return this.fromParsedJson([parsed[0], parsed[1]]);
125
+ }
126
+ else {
127
+ throw new Error('Deserialization error: JSON must have at least 2 items.');
128
+ }
129
+ }
130
+ throw new Error(`Deserialization error: Invalid JSON type for string: ${JSON.stringify(json)}`);
131
+ }
132
+ static fromKeyPair(publicKey, privateKey) {
133
+ return new Ed25519KeyIdentity(Ed25519PublicKey.fromRaw(publicKey), privateKey);
134
+ }
135
+ static fromSecretKey(secretKey) {
136
+ const publicKey = ed25519_1.ed25519.getPublicKey(secretKey);
137
+ return Ed25519KeyIdentity.fromKeyPair(publicKey, secretKey);
138
+ }
139
+ #publicKey;
140
+ #privateKey;
141
+ // `fromRaw` and `fromDer` should be used for instantiation, not this constructor.
142
+ constructor(publicKey, privateKey) {
143
+ super();
144
+ this.#publicKey = Ed25519PublicKey.from(publicKey);
145
+ this.#privateKey = privateKey;
146
+ }
147
+ /**
148
+ * Serialize this key to JSON.
149
+ */
150
+ toJSON() {
151
+ return [(0, utils_1.bytesToHex)(this.#publicKey.toDer()), (0, utils_1.bytesToHex)(this.#privateKey)];
152
+ }
153
+ /**
154
+ * Return a copy of the key pair.
155
+ */
156
+ getKeyPair() {
157
+ return {
158
+ secretKey: this.#privateKey,
159
+ publicKey: this.#publicKey,
160
+ };
161
+ }
162
+ /**
163
+ * Return the public key.
164
+ */
165
+ getPublicKey() {
166
+ return this.#publicKey;
167
+ }
168
+ /**
169
+ * Signs a blob of data, with this identity's private key.
170
+ * @param challenge - challenge to sign with this identity's secretKey, producing a signature
171
+ */
172
+ async sign(challenge) {
173
+ // Some implementations of Ed25519 private keys append a public key to the end of the private key. We only want the private key.
174
+ const signature = ed25519_1.ed25519.sign(challenge, this.#privateKey.slice(0, 32));
175
+ // add { __signature__: void; } to the signature to make it compatible with the agent
176
+ Object.defineProperty(signature, '__signature__', {
177
+ enumerable: false,
178
+ value: undefined,
179
+ });
180
+ return signature;
181
+ }
182
+ /**
183
+ * Verify
184
+ * @param sig - signature to verify
185
+ * @param msg - message to verify
186
+ * @param pk - public key
187
+ * @returns - true if the signature is valid, false otherwise
188
+ */
189
+ static verify(sig, msg, pk) {
190
+ const [signature, message, publicKey] = [sig, msg, pk].map(x => {
191
+ if (typeof x === 'string') {
192
+ x = (0, utils_1.hexToBytes)(x);
193
+ }
194
+ return (0, _candid_1.uint8FromBufLike)(x);
195
+ });
196
+ return ed25519_1.ed25519.verify(signature, message, publicKey);
197
+ }
198
+ }
199
+ exports.Ed25519KeyIdentity = Ed25519KeyIdentity;
200
+ //# sourceMappingURL=ed25519.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ed25519.js","sourceRoot":"","sources":["../../../../src/identity/identity/ed25519.ts"],"names":[],"mappings":";;;AAAA,mCASgB;AAChB,qCAAwD;AACxD,mDAAgD;AAChD,+CAA6D;AAI7D,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,CA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CAAC;YACD,OAAO,IAAA,0BAAgB,EAAC,CAAC,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;QACH,OAAO,iBAAO,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;IACvD,CAAC;CACF;AA9HD,gDA8HC"}
@@ -0,0 +1,34 @@
1
+ import { type Identity, type PublicKey } from '../../agent/index.js';
2
+ import { Principal } from '../../principal/index.js';
3
+ /**
4
+ * A partial delegated identity, representing a delegation chain and the public key that it targets
5
+ */
6
+ export declare class PartialIdentity implements Identity {
7
+ #private;
8
+ /**
9
+ * The raw public key of this identity.
10
+ */
11
+ get rawKey(): Uint8Array | undefined;
12
+ /**
13
+ * The DER-encoded public key of this identity.
14
+ */
15
+ get derKey(): Uint8Array | undefined;
16
+ /**
17
+ * The DER-encoded public key of this identity.
18
+ */
19
+ toDer(): Uint8Array;
20
+ /**
21
+ * The inner {@link PublicKey} used by this identity.
22
+ */
23
+ getPublicKey(): PublicKey;
24
+ /**
25
+ * The {@link Principal} of this identity.
26
+ */
27
+ getPrincipal(): Principal;
28
+ /**
29
+ * Required for the Identity interface, but cannot implemented for just a public key.
30
+ */
31
+ transformRequest(): Promise<never>;
32
+ constructor(inner: PublicKey);
33
+ }
34
+ //# sourceMappingURL=partial.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"partial.d.ts","sourceRoot":"","sources":["../../../../src/identity/identity/partial.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC;;GAEG;AACH,qBAAa,eAAgB,YAAW,QAAQ;;IAG9C;;OAEG;IACH,IAAI,MAAM,IAAI,UAAU,GAAG,SAAS,CAEnC;IAED;;OAEG;IACH,IAAI,MAAM,IAAI,UAAU,GAAG,SAAS,CAEnC;IAED;;OAEG;IACI,KAAK,IAAI,UAAU;IAI1B;;OAEG;IACI,YAAY,IAAI,SAAS;IAIhC;;OAEG;IACI,YAAY,IAAI,SAAS;IAOhC;;OAEG;IACI,gBAAgB,IAAI,OAAO,CAAC,KAAK,CAAC;gBAM7B,KAAK,EAAE,SAAS;CAG7B"}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PartialIdentity = void 0;
4
+ const _principal_1 = require("../../principal/index.js");
5
+ /**
6
+ * A partial delegated identity, representing a delegation chain and the public key that it targets
7
+ */
8
+ class PartialIdentity {
9
+ #inner;
10
+ /**
11
+ * The raw public key of this identity.
12
+ */
13
+ get rawKey() {
14
+ return this.#inner.rawKey;
15
+ }
16
+ /**
17
+ * The DER-encoded public key of this identity.
18
+ */
19
+ get derKey() {
20
+ return this.#inner.derKey;
21
+ }
22
+ /**
23
+ * The DER-encoded public key of this identity.
24
+ */
25
+ toDer() {
26
+ return this.#inner.toDer();
27
+ }
28
+ /**
29
+ * The inner {@link PublicKey} used by this identity.
30
+ */
31
+ getPublicKey() {
32
+ return this.#inner;
33
+ }
34
+ /**
35
+ * The {@link Principal} of this identity.
36
+ */
37
+ getPrincipal() {
38
+ if (!this.#inner.rawKey) {
39
+ throw new Error('Cannot get principal from a public key without a raw key.');
40
+ }
41
+ return _principal_1.Principal.fromUint8Array(new Uint8Array(this.#inner.rawKey));
42
+ }
43
+ /**
44
+ * Required for the Identity interface, but cannot implemented for just a public key.
45
+ */
46
+ transformRequest() {
47
+ return Promise.reject('Not implemented. You are attempting to use a partial identity to sign calls, but this identity only has access to the public key.To sign calls, use a DelegationIdentity instead.');
48
+ }
49
+ constructor(inner) {
50
+ this.#inner = inner;
51
+ }
52
+ }
53
+ exports.PartialIdentity = PartialIdentity;
54
+ //# sourceMappingURL=partial.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"partial.js","sourceRoot":"","sources":["../../../../src/identity/identity/partial.ts"],"names":[],"mappings":";;;AACA,2CAAuC;AAEvC;;GAEG;AACH,MAAa,eAAe;IAC1B,MAAM,CAAY;IAElB;;OAEG;IACH,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC5B,CAAC;IAED;;OAEG;IACI,KAAK;QACV,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAC7B,CAAC;IAED;;OAEG;IACI,YAAY;QACjB,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED;;OAEG;IACI,YAAY;QACjB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;QAC/E,CAAC;QACD,OAAO,sBAAS,CAAC,cAAc,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IACtE,CAAC;IAED;;OAEG;IACI,gBAAgB;QACrB,OAAO,OAAO,CAAC,MAAM,CACnB,mLAAmL,CACpL,CAAC;IACJ,CAAC;IAED,YAAY,KAAgB;QAC1B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;CACF;AArDD,0CAqDC"}
@@ -0,0 +1,51 @@
1
+ import { type DerEncodedPublicKey, type PublicKey, type Signature, SignIdentity } from '../../agent/index.js';
2
+ export declare class CosePublicKey implements PublicKey {
3
+ protected _cose: Uint8Array;
4
+ protected _encodedKey: DerEncodedPublicKey;
5
+ constructor(_cose: Uint8Array);
6
+ toDer(): DerEncodedPublicKey;
7
+ getCose(): Uint8Array;
8
+ }
9
+ /**
10
+ * A SignIdentity that uses `navigator.credentials`. See https://webauthn.guide/ for
11
+ * more information about WebAuthentication.
12
+ */
13
+ export declare class WebAuthnIdentity extends SignIdentity {
14
+ readonly rawId: Uint8Array;
15
+ protected authenticatorAttachment: AuthenticatorAttachment | undefined;
16
+ /**
17
+ * Create an identity from a JSON serialization.
18
+ * @param json - json to parse
19
+ */
20
+ static fromJSON(json: string): WebAuthnIdentity;
21
+ /**
22
+ * Create an identity.
23
+ * @param credentialCreationOptions an optional CredentialCreationOptions Challenge
24
+ */
25
+ static create(credentialCreationOptions?: CredentialCreationOptions): Promise<WebAuthnIdentity>;
26
+ protected _publicKey: CosePublicKey;
27
+ constructor(rawId: Uint8Array, cose: Uint8Array, authenticatorAttachment: AuthenticatorAttachment | undefined);
28
+ getPublicKey(): PublicKey;
29
+ /**
30
+ * WebAuthn level 3 spec introduces a new attribute on successful WebAuthn interactions,
31
+ * see https://w3c.github.io/webauthn/#dom-publickeycredential-authenticatorattachment.
32
+ * This attribute is already implemented for Chrome, Safari and Edge.
33
+ *
34
+ * Given the attribute is only available after a successful interaction, the information is
35
+ * provided opportunistically and might also be `undefined`.
36
+ */
37
+ getAuthenticatorAttachment(): AuthenticatorAttachment | undefined;
38
+ sign(blob: Uint8Array): Promise<Signature>;
39
+ /**
40
+ * Allow for JSON serialization of all information needed to reuse this identity.
41
+ */
42
+ toJSON(): JsonnableWebAuthnIdentity;
43
+ }
44
+ /**
45
+ * ReturnType<WebAuthnIdentity.toJSON>
46
+ */
47
+ export interface JsonnableWebAuthnIdentity {
48
+ publicKey: string;
49
+ rawId: string;
50
+ }
51
+ //# sourceMappingURL=webauthn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webauthn.d.ts","sourceRoot":"","sources":["../../../../src/identity/identity/webauthn.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,SAAS,EACd,KAAK,SAAS,EACd,YAAY,EAIb,MAAM,QAAQ,CAAC;AAsChB,qBAAa,aAAc,YAAW,SAAS;IAG1B,SAAS,CAAC,KAAK,EAAE,UAAU;IAF9C,SAAS,CAAC,WAAW,EAAE,mBAAmB,CAAC;gBAEd,KAAK,EAAE,UAAU;IAIvC,KAAK,IAAI,mBAAmB;IAI5B,OAAO,IAAI,UAAU;CAG7B;AAwED;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,YAAY;aAgD9B,KAAK,EAAE,UAAU;IAEjC,SAAS,CAAC,uBAAuB,EAAE,uBAAuB,GAAG,SAAS;IAjDxE;;;OAGG;WACW,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB;IAUtD;;;OAGG;WACiB,MAAM,CACxB,yBAAyB,CAAC,EAAE,yBAAyB,GACpD,OAAO,CAAC,gBAAgB,CAAC;IAwB5B,SAAS,CAAC,UAAU,EAAE,aAAa,CAAC;gBAGlB,KAAK,EAAE,UAAU,EACjC,IAAI,EAAE,UAAU,EACN,uBAAuB,EAAE,uBAAuB,GAAG,SAAS;IAMjE,YAAY,IAAI,SAAS;IAIhC;;;;;;;OAOG;IACI,0BAA0B,IAAI,uBAAuB,GAAG,SAAS;IAI3D,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC;IAqCvD;;OAEG;IACI,MAAM,IAAI,yBAAyB;CAM3C;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IAExC,SAAS,EAAE,MAAM,CAAC;IAElB,KAAK,EAAE,MAAM,CAAC;CACf"}
@@ -0,0 +1,197 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WebAuthnIdentity = exports.CosePublicKey = void 0;
4
+ const _agent_1 = require("../../agent/index.js");
5
+ const utils_1 = require("@noble/hashes/utils");
6
+ const _candid_1 = require("../../candid/index.js");
7
+ function _coseToDerEncodedBlob(cose) {
8
+ return (0, _agent_1.wrapDER)(cose, _agent_1.DER_COSE_OID);
9
+ }
10
+ /**
11
+ * From the documentation;
12
+ * The authData is a byte array described in the spec. Parsing it will involve slicing bytes from
13
+ * the array and converting them into usable objects.
14
+ *
15
+ * See https://webauthn.guide/#registration (subsection "Example: Parsing the authenticator data").
16
+ * @param authData The authData field of the attestation response.
17
+ * @returns The COSE key of the authData.
18
+ */
19
+ function _authDataToCose(authData) {
20
+ const dataView = new DataView(new ArrayBuffer(2));
21
+ const idLenBytes = authData.slice(53, 55);
22
+ [...new Uint8Array(idLenBytes)].forEach((v, i) => dataView.setUint8(i, v));
23
+ const credentialIdLength = dataView.getUint16(0);
24
+ // Get the public key object.
25
+ return authData.slice(55 + credentialIdLength);
26
+ }
27
+ class CosePublicKey {
28
+ constructor(_cose) {
29
+ this._cose = _cose;
30
+ this._encodedKey = _coseToDerEncodedBlob(_cose);
31
+ }
32
+ toDer() {
33
+ return this._encodedKey;
34
+ }
35
+ getCose() {
36
+ return this._cose;
37
+ }
38
+ }
39
+ exports.CosePublicKey = CosePublicKey;
40
+ /**
41
+ * Create a challenge from a string or array. The default challenge is always the same
42
+ * because we don't need to verify the authenticity of the key on the server (we don't
43
+ * register our keys with the IC). Any challenge would do, even one per key, randomly
44
+ * generated.
45
+ * @param challenge The challenge to transform into a byte array. By default a hard
46
+ * coded string.
47
+ */
48
+ function _createChallengeBuffer(challenge = '<ic0.app>') {
49
+ if (typeof challenge === 'string') {
50
+ return Uint8Array.from(challenge, c => c.charCodeAt(0));
51
+ }
52
+ else {
53
+ return challenge;
54
+ }
55
+ }
56
+ /**
57
+ * Create a credentials to authenticate with a server. This is necessary in order in
58
+ * WebAuthn to get credentials IDs (which give us the public key and allow us to
59
+ * sign), but in the case of the Internet Computer, we don't actually need to register
60
+ * it, so we don't.
61
+ * @param credentialCreationOptions an optional CredentialCreationOptions object
62
+ */
63
+ async function _createCredential(credentialCreationOptions) {
64
+ const creds = (await navigator.credentials.create(credentialCreationOptions ?? {
65
+ publicKey: {
66
+ authenticatorSelection: {
67
+ userVerification: 'preferred',
68
+ },
69
+ attestation: 'direct',
70
+ challenge: _createChallengeBuffer(),
71
+ pubKeyCredParams: [{ type: 'public-key', alg: PubKeyCoseAlgo.ECDSA_WITH_SHA256 }],
72
+ rp: {
73
+ name: 'Internet Identity Service',
74
+ },
75
+ user: {
76
+ id: (0, utils_1.randomBytes)(16),
77
+ name: 'Internet Identity',
78
+ displayName: 'Internet Identity',
79
+ },
80
+ },
81
+ }));
82
+ if (creds === null) {
83
+ return null;
84
+ }
85
+ return {
86
+ // do _not_ use ...creds here, as creds is not enumerable in all cases
87
+ id: creds.id,
88
+ response: creds.response,
89
+ type: creds.type,
90
+ authenticatorAttachment: creds.authenticatorAttachment,
91
+ getClientExtensionResults: creds.getClientExtensionResults,
92
+ // Some password managers will return a Uint8Array, so we ensure we return an ArrayBuffer.
93
+ rawId: creds.rawId,
94
+ toJSON: creds.toJSON.bind(creds), // Ensure the toJSON method is included
95
+ };
96
+ }
97
+ // See https://www.iana.org/assignments/cose/cose.xhtml#algorithms for a complete
98
+ // list of these algorithms. We only list the ones we support here.
99
+ var PubKeyCoseAlgo;
100
+ (function (PubKeyCoseAlgo) {
101
+ PubKeyCoseAlgo[PubKeyCoseAlgo["ECDSA_WITH_SHA256"] = -7] = "ECDSA_WITH_SHA256";
102
+ })(PubKeyCoseAlgo || (PubKeyCoseAlgo = {}));
103
+ /**
104
+ * A SignIdentity that uses `navigator.credentials`. See https://webauthn.guide/ for
105
+ * more information about WebAuthentication.
106
+ */
107
+ class WebAuthnIdentity extends _agent_1.SignIdentity {
108
+ /**
109
+ * Create an identity from a JSON serialization.
110
+ * @param json - json to parse
111
+ */
112
+ static fromJSON(json) {
113
+ const { publicKey, rawId } = JSON.parse(json);
114
+ if (typeof publicKey !== 'string' || typeof rawId !== 'string') {
115
+ throw new Error('Invalid JSON string.');
116
+ }
117
+ return new this((0, utils_1.hexToBytes)(rawId), (0, utils_1.hexToBytes)(publicKey), undefined);
118
+ }
119
+ /**
120
+ * Create an identity.
121
+ * @param credentialCreationOptions an optional CredentialCreationOptions Challenge
122
+ */
123
+ static async create(credentialCreationOptions) {
124
+ const creds = await _createCredential(credentialCreationOptions);
125
+ if (!creds || creds.type !== 'public-key') {
126
+ throw new Error('Could not create credentials.');
127
+ }
128
+ const response = creds.response;
129
+ if (response.attestationObject === undefined) {
130
+ throw new Error('Was expecting an attestation response.');
131
+ }
132
+ // Parse the attestationObject as CBOR.
133
+ const attObject = _agent_1.Cbor.decode(new Uint8Array(response.attestationObject));
134
+ return new this((0, _candid_1.uint8FromBufLike)(creds.rawId), _authDataToCose(attObject.authData), creds.authenticatorAttachment ?? undefined);
135
+ }
136
+ constructor(rawId, cose, authenticatorAttachment) {
137
+ super();
138
+ this.rawId = rawId;
139
+ this.authenticatorAttachment = authenticatorAttachment;
140
+ this._publicKey = new CosePublicKey(cose);
141
+ }
142
+ getPublicKey() {
143
+ return this._publicKey;
144
+ }
145
+ /**
146
+ * WebAuthn level 3 spec introduces a new attribute on successful WebAuthn interactions,
147
+ * see https://w3c.github.io/webauthn/#dom-publickeycredential-authenticatorattachment.
148
+ * This attribute is already implemented for Chrome, Safari and Edge.
149
+ *
150
+ * Given the attribute is only available after a successful interaction, the information is
151
+ * provided opportunistically and might also be `undefined`.
152
+ */
153
+ getAuthenticatorAttachment() {
154
+ return this.authenticatorAttachment;
155
+ }
156
+ async sign(blob) {
157
+ const result = (await navigator.credentials.get({
158
+ publicKey: {
159
+ allowCredentials: [
160
+ {
161
+ type: 'public-key',
162
+ id: this.rawId,
163
+ },
164
+ ],
165
+ challenge: blob,
166
+ userVerification: 'preferred',
167
+ },
168
+ }));
169
+ if (result.authenticatorAttachment !== null) {
170
+ this.authenticatorAttachment = result.authenticatorAttachment;
171
+ }
172
+ const response = result.response;
173
+ const encoded = _agent_1.Cbor.encode({
174
+ authenticator_data: response.authenticatorData,
175
+ client_data_json: (0, utils_1.bytesToUtf8)(new Uint8Array(response.clientDataJSON)),
176
+ signature: response.signature,
177
+ });
178
+ if (!encoded) {
179
+ throw new Error('failed to encode cbor');
180
+ }
181
+ Object.assign(encoded, {
182
+ __signature__: undefined,
183
+ });
184
+ return encoded;
185
+ }
186
+ /**
187
+ * Allow for JSON serialization of all information needed to reuse this identity.
188
+ */
189
+ toJSON() {
190
+ return {
191
+ publicKey: (0, utils_1.bytesToHex)(this._publicKey.getCose()),
192
+ rawId: (0, utils_1.bytesToHex)(this.rawId),
193
+ };
194
+ }
195
+ }
196
+ exports.WebAuthnIdentity = WebAuthnIdentity;
197
+ //# sourceMappingURL=webauthn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webauthn.js","sourceRoot":"","sources":["../../../../src/identity/identity/webauthn.ts"],"names":[],"mappings":";;;AAAA,mCAQgB;AAChB,+CAAuF;AACvF,qCAA2C;AAE3C,SAAS,qBAAqB,CAAC,IAAgB;IAC7C,OAAO,IAAA,gBAAO,EAAC,IAAI,EAAE,qBAAY,CAAwB,CAAC;AAC5D,CAAC;AAaD;;;;;;;;GAQG;AACH,SAAS,eAAe,CAAC,QAAoB;IAC3C,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IAClD,MAAM,UAAU,GAAG,QAAQ,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IAC1C,CAAC,GAAG,IAAI,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC3E,MAAM,kBAAkB,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAEjD,6BAA6B;IAC7B,OAAO,QAAQ,CAAC,KAAK,CAAC,EAAE,GAAG,kBAAkB,CAAC,CAAC;AACjD,CAAC;AAED,MAAa,aAAa;IAGxB,YAA6B,KAAiB;QAAjB,UAAK,GAAL,KAAK,CAAY;QAC5C,IAAI,CAAC,WAAW,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAC;IAClD,CAAC;IAEM,KAAK;QACV,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAEM,OAAO;QACZ,OAAO,IAAI,CAAC,KAAK,CA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I,UAAU,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;YACtE,SAAS,EAAE,QAAQ,CAAC,SAAS;SAC9B,CAAC,CAAC;QAEH,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;QAC3C,CAAC;QAED,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE;YACrB,aAAa,EAAE,SAAS;SACzB,CAAC,CAAC;QAEH,OAAO,OAAoB,CAAC;IAC9B,CAAC;IAED;;OAEG;IACI,MAAM;QACX,OAAO;YACL,SAAS,EAAE,IAAA,kBAAU,EAAC,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;YAChD,KAAK,EAAE,IAAA,kBAAU,EAAC,IAAI,CAAC,KAAK,CAAC;SAC9B,CAAC;IACJ,CAAC;CACF;AAtHD,4CAsHC"}
@@ -1,2 +1,16 @@
1
- export * from '@dfinity/identity';
1
+ /**
2
+ * @module api
3
+ */
4
+ export * from './identity/ed25519.ts';
5
+ export * from './identity/ecdsa.ts';
6
+ export * from './identity/delegation.ts';
7
+ export * from './identity/partial.ts';
8
+ export { WebAuthnIdentity } from './identity/webauthn.ts';
9
+ export { wrapDER, unwrapDER, DER_COSE_OID, ED25519_OID } from '../agent/index.js';
10
+ /**
11
+ * @deprecated due to size of dependencies. Use `@icp-sdk/identity/secp256k1` instead.
12
+ */
13
+ export declare class Secp256k1KeyIdentity {
14
+ constructor();
15
+ }
2
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/identity/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/identity/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAEvE;;GAEG;AACH,qBAAa,oBAAoB;;CAIhC"}
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
+ /**
3
+ * @module api
4
+ */
2
5
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
6
  if (k2 === undefined) k2 = k;
4
7
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -14,5 +17,25 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
17
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
18
  };
16
19
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("@dfinity/identity"), exports);
20
+ exports.Secp256k1KeyIdentity = exports.ED25519_OID = exports.DER_COSE_OID = exports.unwrapDER = exports.wrapDER = exports.WebAuthnIdentity = void 0;
21
+ __exportStar(require("./identity/ed25519.js"), exports);
22
+ __exportStar(require("./identity/ecdsa.js"), exports);
23
+ __exportStar(require("./identity/delegation.js"), exports);
24
+ __exportStar(require("./identity/partial.js"), exports);
25
+ var webauthn_ts_1 = require("./identity/webauthn.js");
26
+ Object.defineProperty(exports, "WebAuthnIdentity", { enumerable: true, get: function () { return webauthn_ts_1.WebAuthnIdentity; } });
27
+ var _agent_1 = require("../agent/index.js");
28
+ Object.defineProperty(exports, "wrapDER", { enumerable: true, get: function () { return _agent_1.wrapDER; } });
29
+ Object.defineProperty(exports, "unwrapDER", { enumerable: true, get: function () { return _agent_1.unwrapDER; } });
30
+ Object.defineProperty(exports, "DER_COSE_OID", { enumerable: true, get: function () { return _agent_1.DER_COSE_OID; } });
31
+ Object.defineProperty(exports, "ED25519_OID", { enumerable: true, get: function () { return _agent_1.ED25519_OID; } });
32
+ /**
33
+ * @deprecated due to size of dependencies. Use `@icp-sdk/identity/secp256k1` instead.
34
+ */
35
+ class Secp256k1KeyIdentity {
36
+ constructor() {
37
+ throw new Error('Secp256k1KeyIdentity is available in @icp-sdk/identity/secp256k1');
38
+ }
39
+ }
40
+ exports.Secp256k1KeyIdentity = Secp256k1KeyIdentity;
18
41
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/identity/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/identity/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;AAEH,wDAAsC;AACtC,sDAAoC;AACpC,2DAAyC;AACzC,wDAAsC;AACtC,sDAA0D;AAAjD,+GAAA,gBAAgB,OAAA;AACzB,iCAAuE;AAA9D,iGAAA,OAAO,OAAA;AAAE,mGAAA,SAAS,OAAA;AAAE,sGAAA,YAAY,OAAA;AAAE,qGAAA,WAAW,OAAA;AAEtD;;GAEG;AACH,MAAa,oBAAoB;IAC/B;QACE,MAAM,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAC;IACtF,CAAC;CACF;AAJD,oDAIC"}