@attocash/cli 0.1.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 (400) hide show
  1. package/LICENSE +28 -0
  2. package/README.md +707 -0
  3. package/dist/application/app.d.ts +138 -0
  4. package/dist/application/app.js +654 -0
  5. package/dist/application/operations.d.ts +9 -0
  6. package/dist/application/operations.js +96 -0
  7. package/dist/cli/cli.d.ts +1 -0
  8. package/dist/cli/cli.js +460 -0
  9. package/dist/cli/help.d.ts +4 -0
  10. package/dist/cli/help.js +49 -0
  11. package/dist/cli/main.d.ts +2 -0
  12. package/dist/cli/main.js +13 -0
  13. package/dist/cli/onboarding.d.ts +14 -0
  14. package/dist/cli/onboarding.js +144 -0
  15. package/dist/cli/output.d.ts +2 -0
  16. package/dist/cli/output.js +231 -0
  17. package/dist/cli/terminal.d.ts +6 -0
  18. package/dist/cli/terminal.js +92 -0
  19. package/dist/cli/update-check.d.ts +1 -0
  20. package/dist/cli/update-check.js +12 -0
  21. package/dist/cli/updates.d.ts +2 -0
  22. package/dist/cli/updates.js +98 -0
  23. package/dist/core.d.ts +14 -0
  24. package/dist/core.js +14 -0
  25. package/dist/doctor/credential-probe.d.ts +7 -0
  26. package/dist/doctor/credential-probe.js +49 -0
  27. package/dist/doctor/doctor.d.ts +4 -0
  28. package/dist/doctor/doctor.js +213 -0
  29. package/dist/doctor/keyring.d.ts +7 -0
  30. package/dist/doctor/keyring.js +150 -0
  31. package/dist/doctor/profile.d.ts +19 -0
  32. package/dist/doctor/profile.js +73 -0
  33. package/dist/doctor/types.d.ts +40 -0
  34. package/dist/doctor/types.js +1 -0
  35. package/dist/domain/amount.d.ts +6 -0
  36. package/dist/domain/amount.js +27 -0
  37. package/dist/domain/errors.d.ts +10 -0
  38. package/dist/domain/errors.js +16 -0
  39. package/dist/labels/directory.d.ts +87 -0
  40. package/dist/labels/directory.js +140 -0
  41. package/dist/labels/personal.d.ts +17 -0
  42. package/dist/labels/personal.js +56 -0
  43. package/dist/labels/presentation.d.ts +154 -0
  44. package/dist/labels/presentation.js +90 -0
  45. package/dist/network/reader.d.ts +31 -0
  46. package/dist/network/reader.js +370 -0
  47. package/dist/network/retry.d.ts +7 -0
  48. package/dist/network/retry.js +53 -0
  49. package/dist/network/work.d.ts +3 -0
  50. package/dist/network/work.js +66 -0
  51. package/dist/pricing/market.d.ts +29 -0
  52. package/dist/pricing/market.js +150 -0
  53. package/dist/pricing/terms.d.ts +6 -0
  54. package/dist/pricing/terms.js +12 -0
  55. package/dist/spending/destination.d.ts +16 -0
  56. package/dist/spending/destination.js +42 -0
  57. package/dist/spending/journal.d.ts +28 -0
  58. package/dist/spending/journal.js +69 -0
  59. package/dist/spending/ledger.d.ts +118 -0
  60. package/dist/spending/ledger.js +444 -0
  61. package/dist/spending/payments.d.ts +67 -0
  62. package/dist/spending/payments.js +424 -0
  63. package/dist/spending/pool.d.ts +13 -0
  64. package/dist/spending/pool.js +38 -0
  65. package/dist/spending/reconcile.d.ts +18 -0
  66. package/dist/spending/reconcile.js +64 -0
  67. package/dist/storage/profiles.d.ts +13 -0
  68. package/dist/storage/profiles.js +86 -0
  69. package/dist/storage/secrets.d.ts +16 -0
  70. package/dist/storage/secrets.js +104 -0
  71. package/dist/storage/state.d.ts +32 -0
  72. package/dist/storage/state.js +255 -0
  73. package/dist/wallet/auto-receive.d.ts +57 -0
  74. package/dist/wallet/auto-receive.js +140 -0
  75. package/dist/wallet/defaults.d.ts +3 -0
  76. package/dist/wallet/defaults.js +26 -0
  77. package/dist/wallet/signing.d.ts +17 -0
  78. package/dist/wallet/signing.js +128 -0
  79. package/dist/wallet/types.d.ts +65 -0
  80. package/dist/wallet/types.js +1 -0
  81. package/dist/wallet/work.d.ts +29 -0
  82. package/dist/wallet/work.js +154 -0
  83. package/dist/watches/manager.d.ts +75 -0
  84. package/dist/watches/manager.js +197 -0
  85. package/node_modules/@attocash/commons-core/Kotlin-DateTime-library-kotlinx-datetime.mjs +6678 -0
  86. package/node_modules/@attocash/commons-core/Kotlin-DateTime-library-kotlinx-datetime.mjs.map +1 -0
  87. package/node_modules/@attocash/commons-core/LICENSE +28 -0
  88. package/node_modules/@attocash/commons-core/README.md +118 -0
  89. package/node_modules/@attocash/commons-core/commons-commons-core.d.mts +1036 -0
  90. package/node_modules/@attocash/commons-core/commons-commons-core.mjs +7701 -0
  91. package/node_modules/@attocash/commons-core/commons-commons-core.mjs.map +1 -0
  92. package/node_modules/@attocash/commons-core/kotlin-kotlin-stdlib.mjs +17681 -0
  93. package/node_modules/@attocash/commons-core/kotlin-kotlin-stdlib.mjs.map +1 -0
  94. package/node_modules/@attocash/commons-core/kotlin_org_jetbrains_kotlin_kotlin_dom_api_compat.mjs +4 -0
  95. package/node_modules/@attocash/commons-core/kotlin_org_jetbrains_kotlin_kotlin_dom_api_compat.mjs.map +1 -0
  96. package/node_modules/@attocash/commons-core/kotlinx-io-kotlinx-io-bytestring.mjs +209 -0
  97. package/node_modules/@attocash/commons-core/kotlinx-io-kotlinx-io-bytestring.mjs.map +1 -0
  98. package/node_modules/@attocash/commons-core/kotlinx-io-kotlinx-io-core.mjs +2284 -0
  99. package/node_modules/@attocash/commons-core/kotlinx-io-kotlinx-io-core.mjs.map +1 -0
  100. package/node_modules/@attocash/commons-core/kotlinx-serialization-kotlinx-serialization-core.mjs +6042 -0
  101. package/node_modules/@attocash/commons-core/kotlinx-serialization-kotlinx-serialization-core.mjs.map +1 -0
  102. package/node_modules/@attocash/commons-core/kotlinx-serialization-kotlinx-serialization-json.mjs +5294 -0
  103. package/node_modules/@attocash/commons-core/kotlinx-serialization-kotlinx-serialization-json.mjs.map +1 -0
  104. package/node_modules/@attocash/commons-core/package.json +27 -0
  105. package/node_modules/@attocash/commons-node/LICENSE +28 -0
  106. package/node_modules/@attocash/commons-node/README.md +92 -0
  107. package/node_modules/@attocash/commons-node/commons-commons-node.d.mts +255 -0
  108. package/node_modules/@attocash/commons-node/commons-commons-node.mjs +2977 -0
  109. package/node_modules/@attocash/commons-node/commons-commons-node.mjs.map +1 -0
  110. package/node_modules/@attocash/commons-node/kotlin-logging.mjs +432 -0
  111. package/node_modules/@attocash/commons-node/kotlin-logging.mjs.map +1 -0
  112. package/node_modules/@attocash/commons-node/kotlinx-serialization-kotlinx-serialization-json.mjs +5294 -0
  113. package/node_modules/@attocash/commons-node/kotlinx-serialization-kotlinx-serialization-json.mjs.map +1 -0
  114. package/node_modules/@attocash/commons-node/package.json +29 -0
  115. package/node_modules/@attocash/commons-node-remote/LICENSE +28 -0
  116. package/node_modules/@attocash/commons-node-remote/README.md +61 -0
  117. package/node_modules/@attocash/commons-node-remote/commons-commons-node-remote.d.mts +122 -0
  118. package/node_modules/@attocash/commons-node-remote/commons-commons-node-remote.mjs +1810 -0
  119. package/node_modules/@attocash/commons-node-remote/commons-commons-node-remote.mjs.map +1 -0
  120. package/node_modules/@attocash/commons-node-remote/kotlin-logging.mjs +432 -0
  121. package/node_modules/@attocash/commons-node-remote/kotlin-logging.mjs.map +1 -0
  122. package/node_modules/@attocash/commons-node-remote/kotlinx-browser.mjs +8 -0
  123. package/node_modules/@attocash/commons-node-remote/kotlinx-browser.mjs.map +1 -0
  124. package/node_modules/@attocash/commons-node-remote/kotlinx-serialization-kotlinx-serialization-json-io.mjs +4 -0
  125. package/node_modules/@attocash/commons-node-remote/kotlinx-serialization-kotlinx-serialization-json-io.mjs.map +1 -0
  126. package/node_modules/@attocash/commons-node-remote/kotlinx-serialization-kotlinx-serialization-json.mjs +5294 -0
  127. package/node_modules/@attocash/commons-node-remote/kotlinx-serialization-kotlinx-serialization-json.mjs.map +1 -0
  128. package/node_modules/@attocash/commons-node-remote/package.json +31 -0
  129. package/node_modules/@attocash/commons-transport/LICENSE +28 -0
  130. package/node_modules/@attocash/commons-transport/README.md +5 -0
  131. package/node_modules/@attocash/commons-transport/commons-commons-transport.d.mts +64 -0
  132. package/node_modules/@attocash/commons-transport/commons-commons-transport.mjs +249 -0
  133. package/node_modules/@attocash/commons-transport/commons-commons-transport.mjs.map +1 -0
  134. package/node_modules/@attocash/commons-transport/kotlinx-atomicfu.mjs +263 -0
  135. package/node_modules/@attocash/commons-transport/kotlinx-atomicfu.mjs.map +1 -0
  136. package/node_modules/@attocash/commons-transport/kotlinx-browser.mjs +8 -0
  137. package/node_modules/@attocash/commons-transport/kotlinx-browser.mjs.map +1 -0
  138. package/node_modules/@attocash/commons-transport/kotlinx-coroutines-core.mjs +11604 -0
  139. package/node_modules/@attocash/commons-transport/kotlinx-coroutines-core.mjs.map +1 -0
  140. package/node_modules/@attocash/commons-transport/kotlinx-serialization-kotlinx-serialization-json-io.mjs +4 -0
  141. package/node_modules/@attocash/commons-transport/kotlinx-serialization-kotlinx-serialization-json-io.mjs.map +1 -0
  142. package/node_modules/@attocash/commons-transport/kotlinx-serialization-kotlinx-serialization-json.mjs +5294 -0
  143. package/node_modules/@attocash/commons-transport/kotlinx-serialization-kotlinx-serialization-json.mjs.map +1 -0
  144. package/node_modules/@attocash/commons-transport/ktor-ktor-client-content-negotiation.mjs +499 -0
  145. package/node_modules/@attocash/commons-transport/ktor-ktor-client-content-negotiation.mjs.map +1 -0
  146. package/node_modules/@attocash/commons-transport/ktor-ktor-client-core.mjs +6456 -0
  147. package/node_modules/@attocash/commons-transport/ktor-ktor-client-core.mjs.map +1 -0
  148. package/node_modules/@attocash/commons-transport/ktor-ktor-events.mjs +83 -0
  149. package/node_modules/@attocash/commons-transport/ktor-ktor-events.mjs.map +1 -0
  150. package/node_modules/@attocash/commons-transport/ktor-ktor-http-cio.mjs +1714 -0
  151. package/node_modules/@attocash/commons-transport/ktor-ktor-http-cio.mjs.map +1 -0
  152. package/node_modules/@attocash/commons-transport/ktor-ktor-http.mjs +3197 -0
  153. package/node_modules/@attocash/commons-transport/ktor-ktor-http.mjs.map +1 -0
  154. package/node_modules/@attocash/commons-transport/ktor-ktor-io.mjs +2290 -0
  155. package/node_modules/@attocash/commons-transport/ktor-ktor-io.mjs.map +1 -0
  156. package/node_modules/@attocash/commons-transport/ktor-ktor-serialization-kotlinx-json.mjs +46 -0
  157. package/node_modules/@attocash/commons-transport/ktor-ktor-serialization-kotlinx-json.mjs.map +1 -0
  158. package/node_modules/@attocash/commons-transport/ktor-ktor-serialization-kotlinx.mjs +482 -0
  159. package/node_modules/@attocash/commons-transport/ktor-ktor-serialization-kotlinx.mjs.map +1 -0
  160. package/node_modules/@attocash/commons-transport/ktor-ktor-serialization.mjs +165 -0
  161. package/node_modules/@attocash/commons-transport/ktor-ktor-serialization.mjs.map +1 -0
  162. package/node_modules/@attocash/commons-transport/ktor-ktor-sse.mjs +4 -0
  163. package/node_modules/@attocash/commons-transport/ktor-ktor-sse.mjs.map +1 -0
  164. package/node_modules/@attocash/commons-transport/ktor-ktor-utils.mjs +3222 -0
  165. package/node_modules/@attocash/commons-transport/ktor-ktor-utils.mjs.map +1 -0
  166. package/node_modules/@attocash/commons-transport/ktor-ktor-websocket-serialization.mjs +4 -0
  167. package/node_modules/@attocash/commons-transport/ktor-ktor-websocket-serialization.mjs.map +1 -0
  168. package/node_modules/@attocash/commons-transport/ktor-ktor-websockets.mjs +1485 -0
  169. package/node_modules/@attocash/commons-transport/ktor-ktor-websockets.mjs.map +1 -0
  170. package/node_modules/@attocash/commons-transport/package.json +29 -0
  171. package/node_modules/@attocash/commons-worker/LICENSE +28 -0
  172. package/node_modules/@attocash/commons-worker/README.md +48 -0
  173. package/node_modules/@attocash/commons-worker/commons-commons-worker.d.mts +73 -0
  174. package/node_modules/@attocash/commons-worker/commons-commons-worker.mjs +702 -0
  175. package/node_modules/@attocash/commons-worker/commons-commons-worker.mjs.map +1 -0
  176. package/node_modules/@attocash/commons-worker/kotlin-logging.mjs +432 -0
  177. package/node_modules/@attocash/commons-worker/kotlin-logging.mjs.map +1 -0
  178. package/node_modules/@attocash/commons-worker/kotlinx-serialization-kotlinx-serialization-json.mjs +5294 -0
  179. package/node_modules/@attocash/commons-worker/kotlinx-serialization-kotlinx-serialization-json.mjs.map +1 -0
  180. package/node_modules/@attocash/commons-worker/package.json +29 -0
  181. package/node_modules/@attocash/commons-worker-remote/LICENSE +28 -0
  182. package/node_modules/@attocash/commons-worker-remote/README.md +60 -0
  183. package/node_modules/@attocash/commons-worker-remote/commons-commons-worker-remote.d.mts +93 -0
  184. package/node_modules/@attocash/commons-worker-remote/commons-commons-worker-remote.mjs +289 -0
  185. package/node_modules/@attocash/commons-worker-remote/commons-commons-worker-remote.mjs.map +1 -0
  186. package/node_modules/@attocash/commons-worker-remote/kotlin-logging.mjs +432 -0
  187. package/node_modules/@attocash/commons-worker-remote/kotlin-logging.mjs.map +1 -0
  188. package/node_modules/@attocash/commons-worker-remote/kotlinx-browser.mjs +8 -0
  189. package/node_modules/@attocash/commons-worker-remote/kotlinx-browser.mjs.map +1 -0
  190. package/node_modules/@attocash/commons-worker-remote/kotlinx-serialization-kotlinx-serialization-json-io.mjs +4 -0
  191. package/node_modules/@attocash/commons-worker-remote/kotlinx-serialization-kotlinx-serialization-json-io.mjs.map +1 -0
  192. package/node_modules/@attocash/commons-worker-remote/kotlinx-serialization-kotlinx-serialization-json.mjs +5294 -0
  193. package/node_modules/@attocash/commons-worker-remote/kotlinx-serialization-kotlinx-serialization-json.mjs.map +1 -0
  194. package/node_modules/@attocash/commons-worker-remote/package.json +31 -0
  195. package/node_modules/@js-joda/core/CHANGELOG.md +363 -0
  196. package/node_modules/@js-joda/core/CheatSheet.md +947 -0
  197. package/node_modules/@js-joda/core/LICENSE +34 -0
  198. package/node_modules/@js-joda/core/README.md +155 -0
  199. package/node_modules/@js-joda/core/bower.json +21 -0
  200. package/node_modules/@js-joda/core/dist/js-joda.d.ts +2452 -0
  201. package/node_modules/@js-joda/core/dist/js-joda.esm.js +13564 -0
  202. package/node_modules/@js-joda/core/dist/js-joda.flow.js +949 -0
  203. package/node_modules/@js-joda/core/dist/js-joda.js +13630 -0
  204. package/node_modules/@js-joda/core/dist/js-joda.js.map +1 -0
  205. package/node_modules/@js-joda/core/dist/js-joda.min.js +5 -0
  206. package/node_modules/@js-joda/core/package.json +76 -0
  207. package/node_modules/@js-joda/core/src/Clock.js +330 -0
  208. package/node_modules/@js-joda/core/src/DayOfWeek.js +451 -0
  209. package/node_modules/@js-joda/core/src/Duration.js +1205 -0
  210. package/node_modules/@js-joda/core/src/Enum.js +30 -0
  211. package/node_modules/@js-joda/core/src/Instant.js +1012 -0
  212. package/node_modules/@js-joda/core/src/LocalDate.js +1703 -0
  213. package/node_modules/@js-joda/core/src/LocalDateTime.js +1686 -0
  214. package/node_modules/@js-joda/core/src/LocalTime.js +1415 -0
  215. package/node_modules/@js-joda/core/src/MathUtil.js +236 -0
  216. package/node_modules/@js-joda/core/src/Month.js +600 -0
  217. package/node_modules/@js-joda/core/src/MonthDay.js +730 -0
  218. package/node_modules/@js-joda/core/src/OffsetDateTime.js +757 -0
  219. package/node_modules/@js-joda/core/src/OffsetTime.js +621 -0
  220. package/node_modules/@js-joda/core/src/Period.js +933 -0
  221. package/node_modules/@js-joda/core/src/StringUtil.js +43 -0
  222. package/node_modules/@js-joda/core/src/Year.js +1015 -0
  223. package/node_modules/@js-joda/core/src/YearConstants.js +21 -0
  224. package/node_modules/@js-joda/core/src/YearMonth.js +1096 -0
  225. package/node_modules/@js-joda/core/src/ZoneId.js +236 -0
  226. package/node_modules/@js-joda/core/src/ZoneIdFactory.js +201 -0
  227. package/node_modules/@js-joda/core/src/ZoneOffset.js +486 -0
  228. package/node_modules/@js-joda/core/src/ZoneRegion.js +72 -0
  229. package/node_modules/@js-joda/core/src/ZonedDateTime.js +2007 -0
  230. package/node_modules/@js-joda/core/src/_init.js +68 -0
  231. package/node_modules/@js-joda/core/src/assert.js +33 -0
  232. package/node_modules/@js-joda/core/src/chrono/ChronoLocalDate.js +230 -0
  233. package/node_modules/@js-joda/core/src/chrono/ChronoLocalDateTime.js +130 -0
  234. package/node_modules/@js-joda/core/src/chrono/ChronoZonedDateTime.js +194 -0
  235. package/node_modules/@js-joda/core/src/chrono/IsoChronology.js +235 -0
  236. package/node_modules/@js-joda/core/src/convert.js +83 -0
  237. package/node_modules/@js-joda/core/src/errors.js +54 -0
  238. package/node_modules/@js-joda/core/src/format/DateTimeBuilder.js +535 -0
  239. package/node_modules/@js-joda/core/src/format/DateTimeFormatter.js +728 -0
  240. package/node_modules/@js-joda/core/src/format/DateTimeFormatterBuilder.js +1545 -0
  241. package/node_modules/@js-joda/core/src/format/DateTimeParseContext.js +297 -0
  242. package/node_modules/@js-joda/core/src/format/DateTimePrintContext.js +138 -0
  243. package/node_modules/@js-joda/core/src/format/DecimalStyle.js +113 -0
  244. package/node_modules/@js-joda/core/src/format/EnumMap.js +70 -0
  245. package/node_modules/@js-joda/core/src/format/ParsePosition.js +31 -0
  246. package/node_modules/@js-joda/core/src/format/ResolverStyle.js +93 -0
  247. package/node_modules/@js-joda/core/src/format/SignStyle.js +38 -0
  248. package/node_modules/@js-joda/core/src/format/StringBuilder.js +47 -0
  249. package/node_modules/@js-joda/core/src/format/TextStyle.js +114 -0
  250. package/node_modules/@js-joda/core/src/format/parser/CharLiteralPrinterParser.js +46 -0
  251. package/node_modules/@js-joda/core/src/format/parser/CompositePrinterParser.js +89 -0
  252. package/node_modules/@js-joda/core/src/format/parser/FractionPrinterParser.js +162 -0
  253. package/node_modules/@js-joda/core/src/format/parser/NumberPrinterParser.js +367 -0
  254. package/node_modules/@js-joda/core/src/format/parser/OffsetIdPrinterParser.js +177 -0
  255. package/node_modules/@js-joda/core/src/format/parser/PadPrinterParserDecorator.js +81 -0
  256. package/node_modules/@js-joda/core/src/format/parser/SettingsParser.js +44 -0
  257. package/node_modules/@js-joda/core/src/format/parser/StringLiteralPrinterParser.js +39 -0
  258. package/node_modules/@js-joda/core/src/format/parser/ZoneIdPrinterParser.js +218 -0
  259. package/node_modules/@js-joda/core/src/js-joda.js +210 -0
  260. package/node_modules/@js-joda/core/src/license-preamble.js +3 -0
  261. package/node_modules/@js-joda/core/src/temporal/ChronoField.js +470 -0
  262. package/node_modules/@js-joda/core/src/temporal/ChronoUnit.js +310 -0
  263. package/node_modules/@js-joda/core/src/temporal/DefaultInterfaceTemporal.js +118 -0
  264. package/node_modules/@js-joda/core/src/temporal/IsoFields.js +859 -0
  265. package/node_modules/@js-joda/core/src/temporal/NativeJsTemporal.js +105 -0
  266. package/node_modules/@js-joda/core/src/temporal/Temporal.js +346 -0
  267. package/node_modules/@js-joda/core/src/temporal/TemporalAccessor.js +125 -0
  268. package/node_modules/@js-joda/core/src/temporal/TemporalAdjuster.js +92 -0
  269. package/node_modules/@js-joda/core/src/temporal/TemporalAdjusters.js +464 -0
  270. package/node_modules/@js-joda/core/src/temporal/TemporalAmount.js +166 -0
  271. package/node_modules/@js-joda/core/src/temporal/TemporalField.js +248 -0
  272. package/node_modules/@js-joda/core/src/temporal/TemporalQueries.js +223 -0
  273. package/node_modules/@js-joda/core/src/temporal/TemporalQueriesFactory.js +77 -0
  274. package/node_modules/@js-joda/core/src/temporal/TemporalQuery.js +107 -0
  275. package/node_modules/@js-joda/core/src/temporal/TemporalUnit.js +179 -0
  276. package/node_modules/@js-joda/core/src/temporal/ValueRange.js +257 -0
  277. package/node_modules/@js-joda/core/src/use.js +20 -0
  278. package/node_modules/@js-joda/core/src/zone/SystemDefaultZoneId.js +31 -0
  279. package/node_modules/@js-joda/core/src/zone/SystemDefaultZoneRules.js +162 -0
  280. package/node_modules/@js-joda/core/src/zone/ZoneOffsetTransition.js +289 -0
  281. package/node_modules/@js-joda/core/src/zone/ZoneRules.js +464 -0
  282. package/node_modules/@js-joda/core/src/zone/ZoneRulesProvider.js +36 -0
  283. package/node_modules/@noble/hashes/LICENSE +21 -0
  284. package/node_modules/@noble/hashes/README.md +563 -0
  285. package/node_modules/@noble/hashes/_blake.d.ts +21 -0
  286. package/node_modules/@noble/hashes/_blake.d.ts.map +1 -0
  287. package/node_modules/@noble/hashes/_blake.js +52 -0
  288. package/node_modules/@noble/hashes/_blake.js.map +1 -0
  289. package/node_modules/@noble/hashes/_md.d.ts +99 -0
  290. package/node_modules/@noble/hashes/_md.d.ts.map +1 -0
  291. package/node_modules/@noble/hashes/_md.js +202 -0
  292. package/node_modules/@noble/hashes/_md.js.map +1 -0
  293. package/node_modules/@noble/hashes/_u64.d.ts +63 -0
  294. package/node_modules/@noble/hashes/_u64.d.ts.map +1 -0
  295. package/node_modules/@noble/hashes/_u64.js +84 -0
  296. package/node_modules/@noble/hashes/_u64.js.map +1 -0
  297. package/node_modules/@noble/hashes/argon2.d.ts +112 -0
  298. package/node_modules/@noble/hashes/argon2.d.ts.map +1 -0
  299. package/node_modules/@noble/hashes/argon2.js +517 -0
  300. package/node_modules/@noble/hashes/argon2.js.map +1 -0
  301. package/node_modules/@noble/hashes/blake1.d.ts +156 -0
  302. package/node_modules/@noble/hashes/blake1.d.ts.map +1 -0
  303. package/node_modules/@noble/hashes/blake1.js +560 -0
  304. package/node_modules/@noble/hashes/blake1.js.map +1 -0
  305. package/node_modules/@noble/hashes/blake2.d.ts +184 -0
  306. package/node_modules/@noble/hashes/blake2.d.ts.map +1 -0
  307. package/node_modules/@noble/hashes/blake2.js +501 -0
  308. package/node_modules/@noble/hashes/blake2.js.map +1 -0
  309. package/node_modules/@noble/hashes/blake3.d.ts +68 -0
  310. package/node_modules/@noble/hashes/blake3.d.ts.map +1 -0
  311. package/node_modules/@noble/hashes/blake3.js +284 -0
  312. package/node_modules/@noble/hashes/blake3.js.map +1 -0
  313. package/node_modules/@noble/hashes/eskdf.d.ts +92 -0
  314. package/node_modules/@noble/hashes/eskdf.d.ts.map +1 -0
  315. package/node_modules/@noble/hashes/eskdf.js +218 -0
  316. package/node_modules/@noble/hashes/eskdf.js.map +1 -0
  317. package/node_modules/@noble/hashes/hkdf.d.ts +64 -0
  318. package/node_modules/@noble/hashes/hkdf.d.ts.map +1 -0
  319. package/node_modules/@noble/hashes/hkdf.js +120 -0
  320. package/node_modules/@noble/hashes/hkdf.js.map +1 -0
  321. package/node_modules/@noble/hashes/hmac.d.ts +47 -0
  322. package/node_modules/@noble/hashes/hmac.d.ts.map +1 -0
  323. package/node_modules/@noble/hashes/hmac.js +93 -0
  324. package/node_modules/@noble/hashes/hmac.js.map +1 -0
  325. package/node_modules/@noble/hashes/index.d.ts +2 -0
  326. package/node_modules/@noble/hashes/index.d.ts.map +1 -0
  327. package/node_modules/@noble/hashes/index.js +35 -0
  328. package/node_modules/@noble/hashes/index.js.map +1 -0
  329. package/node_modules/@noble/hashes/legacy.d.ts +102 -0
  330. package/node_modules/@noble/hashes/legacy.d.ts.map +1 -0
  331. package/node_modules/@noble/hashes/legacy.js +327 -0
  332. package/node_modules/@noble/hashes/legacy.js.map +1 -0
  333. package/node_modules/@noble/hashes/package.json +97 -0
  334. package/node_modules/@noble/hashes/pbkdf2.d.ts +56 -0
  335. package/node_modules/@noble/hashes/pbkdf2.d.ts.map +1 -0
  336. package/node_modules/@noble/hashes/pbkdf2.js +135 -0
  337. package/node_modules/@noble/hashes/pbkdf2.js.map +1 -0
  338. package/node_modules/@noble/hashes/scrypt.d.ts +65 -0
  339. package/node_modules/@noble/hashes/scrypt.d.ts.map +1 -0
  340. package/node_modules/@noble/hashes/scrypt.js +257 -0
  341. package/node_modules/@noble/hashes/scrypt.js.map +1 -0
  342. package/node_modules/@noble/hashes/sha2.d.ts +249 -0
  343. package/node_modules/@noble/hashes/sha2.d.ts.map +1 -0
  344. package/node_modules/@noble/hashes/sha2.js +458 -0
  345. package/node_modules/@noble/hashes/sha2.js.map +1 -0
  346. package/node_modules/@noble/hashes/sha3-addons.d.ts +461 -0
  347. package/node_modules/@noble/hashes/sha3-addons.d.ts.map +1 -0
  348. package/node_modules/@noble/hashes/sha3-addons.js +783 -0
  349. package/node_modules/@noble/hashes/sha3-addons.js.map +1 -0
  350. package/node_modules/@noble/hashes/sha3.d.ts +199 -0
  351. package/node_modules/@noble/hashes/sha3.d.ts.map +1 -0
  352. package/node_modules/@noble/hashes/sha3.js +431 -0
  353. package/node_modules/@noble/hashes/sha3.js.map +1 -0
  354. package/node_modules/@noble/hashes/src/_blake.ts +57 -0
  355. package/node_modules/@noble/hashes/src/_md.ts +222 -0
  356. package/node_modules/@noble/hashes/src/_u64.ts +117 -0
  357. package/node_modules/@noble/hashes/src/argon2.ts +667 -0
  358. package/node_modules/@noble/hashes/src/blake1.ts +614 -0
  359. package/node_modules/@noble/hashes/src/blake2.ts +582 -0
  360. package/node_modules/@noble/hashes/src/blake3.ts +317 -0
  361. package/node_modules/@noble/hashes/src/eskdf.ts +259 -0
  362. package/node_modules/@noble/hashes/src/hkdf.ts +133 -0
  363. package/node_modules/@noble/hashes/src/hmac.ts +126 -0
  364. package/node_modules/@noble/hashes/src/index.ts +33 -0
  365. package/node_modules/@noble/hashes/src/legacy.ts +339 -0
  366. package/node_modules/@noble/hashes/src/pbkdf2.ts +175 -0
  367. package/node_modules/@noble/hashes/src/scrypt.ts +315 -0
  368. package/node_modules/@noble/hashes/src/sha2.ts +530 -0
  369. package/node_modules/@noble/hashes/src/sha3-addons.ts +983 -0
  370. package/node_modules/@noble/hashes/src/sha3.ts +485 -0
  371. package/node_modules/@noble/hashes/src/utils.ts +848 -0
  372. package/node_modules/@noble/hashes/src/webcrypto.ts +239 -0
  373. package/node_modules/@noble/hashes/utils.d.ts +519 -0
  374. package/node_modules/@noble/hashes/utils.d.ts.map +1 -0
  375. package/node_modules/@noble/hashes/utils.js +578 -0
  376. package/node_modules/@noble/hashes/utils.js.map +1 -0
  377. package/node_modules/@noble/hashes/webcrypto.d.ts +120 -0
  378. package/node_modules/@noble/hashes/webcrypto.d.ts.map +1 -0
  379. package/node_modules/@noble/hashes/webcrypto.js +165 -0
  380. package/node_modules/@noble/hashes/webcrypto.js.map +1 -0
  381. package/node_modules/ws/LICENSE +20 -0
  382. package/node_modules/ws/README.md +548 -0
  383. package/node_modules/ws/browser.js +8 -0
  384. package/node_modules/ws/index.js +22 -0
  385. package/node_modules/ws/lib/buffer-util.js +131 -0
  386. package/node_modules/ws/lib/constants.js +19 -0
  387. package/node_modules/ws/lib/event-target.js +292 -0
  388. package/node_modules/ws/lib/extension.js +203 -0
  389. package/node_modules/ws/lib/limiter.js +55 -0
  390. package/node_modules/ws/lib/permessage-deflate.js +530 -0
  391. package/node_modules/ws/lib/receiver.js +743 -0
  392. package/node_modules/ws/lib/sender.js +607 -0
  393. package/node_modules/ws/lib/stream.js +161 -0
  394. package/node_modules/ws/lib/subprotocol.js +62 -0
  395. package/node_modules/ws/lib/validation.js +152 -0
  396. package/node_modules/ws/lib/websocket-server.js +562 -0
  397. package/node_modules/ws/lib/websocket.js +1407 -0
  398. package/node_modules/ws/package.json +74 -0
  399. package/node_modules/ws/wrapper.mjs +21 -0
  400. package/package.json +53 -0
@@ -0,0 +1,218 @@
1
+ /**
2
+ * Experimental KDF for AES.
3
+ * @module
4
+ */
5
+ import { hkdf } from "./hkdf.js";
6
+ import { pbkdf2 as _pbkdf2 } from "./pbkdf2.js";
7
+ import { scrypt as _scrypt } from "./scrypt.js";
8
+ import { sha256 } from "./sha2.js";
9
+ import { abytes, bytesToHex, clean, createView, hexToBytes, kdfInputToBytes, } from "./utils.js";
10
+ // A tiny KDF for various applications like AES key-gen.
11
+ // Uses HKDF in a non-standard way, so it's not "KDF-secure", only "PRF-secure".
12
+ // Which is good enough: assume sha2-256 retained preimage resistance.
13
+ // Fixed ESKDF scrypt work factor: interactive-latency target with about 512 MiB RAM per derivation.
14
+ const SCRYPT_FACTOR = /* @__PURE__ */ (() => 2 ** 19)();
15
+ // Fixed ESKDF PBKDF2 work factor: CPU-only companion branch in the same rough
16
+ // interactive-latency range.
17
+ const PBKDF2_FACTOR = /* @__PURE__ */ (() => 2 ** 17)();
18
+ /**
19
+ * Scrypt KDF with the fixed ESKDF policy tuple `{ N: 2^19, r: 8, p: 1, dkLen: 32 }`.
20
+ * @param password - user password string, UTF-8 encoded before entering RFC 7914
21
+ * @param salt - unique salt string, UTF-8 encoded before entering RFC 7914
22
+ * @returns Derived 32-byte key.
23
+ * @example
24
+ * Derive the 32-byte scrypt key used by ESKDF.
25
+ * ```ts
26
+ * scrypt('password123', 'user@example.com');
27
+ * ```
28
+ */
29
+ export function scrypt(password, salt) {
30
+ return _scrypt(password, salt, { N: SCRYPT_FACTOR, r: 8, p: 1, dkLen: 32 });
31
+ }
32
+ /**
33
+ * PBKDF2-HMAC-SHA256 with the fixed ESKDF policy tuple `{ sha256, c: 2^17, dkLen: 32 }`.
34
+ * @param password - user password string, UTF-8 encoded before entering PBKDF2-HMAC-SHA-256
35
+ * @param salt - unique salt string, UTF-8 encoded before entering PBKDF2-HMAC-SHA-256
36
+ * @returns Derived 32-byte key.
37
+ * @example
38
+ * Derive the 32-byte PBKDF2 key used by ESKDF.
39
+ * ```ts
40
+ * pbkdf2('password123', 'user@example.com');
41
+ * ```
42
+ */
43
+ export function pbkdf2(password, salt) {
44
+ return _pbkdf2(sha256, password, salt, { c: PBKDF2_FACTOR, dkLen: 32 });
45
+ }
46
+ // Combines two 32-byte byte arrays into a fresh 32-byte result without aliasing either input.
47
+ function xor32(a, b) {
48
+ abytes(a, 32);
49
+ abytes(b, 32);
50
+ const arr = new Uint8Array(32);
51
+ for (let i = 0; i < 32; i++) {
52
+ arr[i] = a[i] ^ b[i];
53
+ }
54
+ return arr;
55
+ }
56
+ // All local string length checks are in JS UTF-16 code units, not UTF-8 bytes.
57
+ function strHasLength(str, min, max) {
58
+ return typeof str === 'string' && str.length >= min && str.length <= max;
59
+ }
60
+ /**
61
+ * Derives main seed. Takes a lot of time; prefer the higher-level `eskdf(...)`
62
+ * flow unless you specifically need the raw main seed.
63
+ * Derives the main seed by xor'ing two branches:
64
+ * the scrypt branch uses a `0x01` separator byte on username/password,
65
+ * and the PBKDF2 branch uses `0x02`.
66
+ * Username and password strings are encoded by the underlying KDFs after the
67
+ * local separator bytes are appended.
68
+ * @param username - account identifier used as public salt
69
+ * @param password - user password string
70
+ * @returns Main 32-byte seed for the account.
71
+ * @throws If the username or password length is invalid. {@link Error}
72
+ * @example
73
+ * Derive the main ESKDF seed from username and password.
74
+ * ```ts
75
+ * deriveMainSeed('example-user', 'example-password');
76
+ * ```
77
+ */
78
+ export function deriveMainSeed(username, password) {
79
+ if (!strHasLength(username, 8, 255))
80
+ throw new Error('invalid username');
81
+ if (!strHasLength(password, 8, 255))
82
+ throw new Error('invalid password');
83
+ // Keep the protocol separators as the literal bytes 0x01 / 0x02 even after minification.
84
+ // Embedding them as non-printable characters directly can be awkward across
85
+ // JS tooling and environments.
86
+ const codes = { _1: 1, _2: 2 };
87
+ const sep = { s: String.fromCharCode(codes._1), p: String.fromCharCode(codes._2) };
88
+ const scr = scrypt(password + sep.s, username + sep.s);
89
+ const pbk = pbkdf2(password + sep.p, username + sep.p);
90
+ const res = xor32(scr, pbk);
91
+ clean(scr, pbk);
92
+ return res;
93
+ }
94
+ /**
95
+ * Converts protocol & accountId pair to HKDF params:
96
+ * `info` is UTF-8 protocol bytes, numeric ids become 4-byte BE `salt`,
97
+ * and string ids become UTF-8 `salt` bytes.
98
+ */
99
+ function getSaltInfo(protocol, accountId = 0) {
100
+ // Note that length here also repeats two lines below
101
+ // We do an additional length check here to reduce the scope of DoS attacks
102
+ if (!(strHasLength(protocol, 3, 15) && /^[a-z0-9]{3,15}$/.test(protocol))) {
103
+ throw new Error('invalid protocol');
104
+ }
105
+ // Exact-match only: substring matches like `assh` / `mentor` must not widen the public whitelist.
106
+ const allowsStr = /^(password\d{0,3}|ssh|tor|file)$/.test(protocol);
107
+ let salt; // Assigned below: either 4-byte BE account bytes or UTF-8 account bytes.
108
+ if (typeof accountId === 'string') {
109
+ if (!allowsStr)
110
+ throw new Error('accountId must be a number');
111
+ if (!strHasLength(accountId, 1, 255))
112
+ throw new Error('accountId must be string of length 1..255');
113
+ salt = kdfInputToBytes(accountId);
114
+ }
115
+ else if (Number.isSafeInteger(accountId)) {
116
+ if (accountId < 0 || accountId > Math.pow(2, 32) - 1)
117
+ throw new Error('invalid accountId');
118
+ // Convert to Big Endian Uint32
119
+ salt = new Uint8Array(4);
120
+ createView(salt).setUint32(0, accountId, false);
121
+ }
122
+ else {
123
+ throw new Error('accountId must be a number' + (allowsStr ? ' or string' : ''));
124
+ }
125
+ const info = kdfInputToBytes(protocol);
126
+ return { salt, info };
127
+ }
128
+ // Local modulus-size helper, not a general bigint-byte-length primitive:
129
+ // `<= 128n` is rejected by ESKDF policy.
130
+ function countBytes(num) {
131
+ if (typeof num !== 'bigint' || num <= BigInt(128))
132
+ throw new Error('invalid number');
133
+ return Math.ceil(num.toString(2).length / 8);
134
+ }
135
+ /**
136
+ * Parses keyLength and modulus options to extract length of result key.
137
+ * If modulus is used, adds 64 bits to it per the FIPS 186-5 Appendix A.3.1 /
138
+ * A.4.1 extra-bits guidance.
139
+ */
140
+ function getKeyLength(options) {
141
+ if (!options || typeof options !== 'object')
142
+ return 32;
143
+ const hasLen = 'keyLength' in options;
144
+ const hasMod = 'modulus' in options;
145
+ if (hasLen && hasMod)
146
+ throw new Error('cannot combine keyLength and modulus options');
147
+ if (!hasLen && !hasMod)
148
+ throw new Error('must have either keyLength or modulus option');
149
+ // FIPS 186-5 Appendix A.3.1 / A.4.1 calls for at least 64 extra bits.
150
+ const l = hasMod ? countBytes(options.modulus) + 8 : options.keyLength;
151
+ if (!(typeof l === 'number' && l >= 16 && l <= 8192))
152
+ throw new Error('invalid keyLength');
153
+ return l;
154
+ }
155
+ /**
156
+ * Converts key to bigint and divides it by modulus. Big Endian.
157
+ * Adapts FIPS 186-5 Appendix A.4.1: `getKeyLength()` already requested the
158
+ * extra 64-bit margin, and this step maps the result into `1..modulus-1`.
159
+ */
160
+ function modReduceKey(key, modulus) {
161
+ const _1 = BigInt(1);
162
+ const num = BigInt('0x' + bytesToHex(key)); // check for ui8a, then bytesToNumber()
163
+ const res = (num % (modulus - _1)) + _1; // Remove 0 from output
164
+ if (res < _1)
165
+ throw new Error('expected positive number'); // Guard against bad values
166
+ // Strip the extra 64-bit margin that `getKeyLength()` requested
167
+ // for bias reduction.
168
+ const len = key.length - 8;
169
+ const hex = res.toString(16).padStart(len * 2, '0'); // numberToHex()
170
+ const bytes = hexToBytes(hex);
171
+ if (bytes.length !== len)
172
+ throw new Error('invalid length of result key');
173
+ return bytes;
174
+ }
175
+ /**
176
+ * ESKDF
177
+ * @param username - username, email, or identifier, min: 8 characters, should have enough entropy
178
+ * @param password - password, min: 8 characters, should have enough entropy
179
+ * @returns Frozen API that derives child keys and exposes the account fingerprint.
180
+ * @throws If the username or password length is invalid. {@link Error}
181
+ * @example
182
+ * Derive account-specific child keys from the main ESKDF seed.
183
+ * ```ts
184
+ * const kdf = await eskdf('example-university', 'beginning-new-example');
185
+ * const key = kdf.deriveChildKey('aes', 0);
186
+ * const fingerprint = kdf.fingerprint;
187
+ * kdf.expire();
188
+ * ```
189
+ */
190
+ export async function eskdf(username, password) {
191
+ // We are using closure + object instead of class because
192
+ // we want to make `seed` non-accessible for any external function.
193
+ let seed = deriveMainSeed(username, password);
194
+ function deriveCK(protocol, accountId = 0, options) {
195
+ // Reject expired instances before deriving any HKDF inputs from the closure-held seed.
196
+ abytes(seed, 32);
197
+ const { salt, info } = getSaltInfo(protocol, accountId); // validate protocol & accountId
198
+ // Validate option shape and coarse length bounds;
199
+ // `hkdf()` still rejects non-integer lengths.
200
+ const keyLength = getKeyLength(options);
201
+ const key = hkdf(sha256, seed, salt, info, keyLength);
202
+ // Modulus has already been validated
203
+ return options && 'modulus' in options ? modReduceKey(key, options.modulus) : key;
204
+ }
205
+ function expire() {
206
+ // Overwrite the closure-held seed before dropping the reference.
207
+ if (seed)
208
+ seed.fill(1);
209
+ seed = undefined;
210
+ }
211
+ // prettier-ignore
212
+ const fingerprint = Array.from(deriveCK('fingerprint', 0))
213
+ .slice(0, 6)
214
+ .map((char) => char.toString(16).padStart(2, '0').toUpperCase())
215
+ .join(':');
216
+ return Object.freeze({ deriveChildKey: deriveCK, expire, fingerprint });
217
+ }
218
+ //# sourceMappingURL=eskdf.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eskdf.js","sourceRoot":"","sources":["src/e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{ type CHash, type TArg, type TRet } from './utils.ts';
2
+ /**
3
+ * HKDF-extract from spec. Less important part. `HKDF-Extract(IKM, salt) -> PRK`
4
+ * Arguments position differs from spec (IKM is first one, since it is not optional)
5
+ * Local validation only checks `hash`; `ikm` / `salt` byte validation is delegated to `hmac()`.
6
+ * @param hash - hash function that would be used (e.g. sha256)
7
+ * @param ikm - input keying material, the initial key
8
+ * @param salt - optional salt value (a non-secret random value)
9
+ * @returns Pseudorandom key derived from input keying material.
10
+ * @example
11
+ * Run the HKDF extract step.
12
+ * ```ts
13
+ * import { extract } from '@noble/hashes/hkdf.js';
14
+ * import { sha256 } from '@noble/hashes/sha2.js';
15
+ * extract(sha256, new Uint8Array([1, 2, 3]), new Uint8Array([4, 5, 6]));
16
+ * ```
17
+ */
18
+ export declare function extract(hash: TArg<CHash>, ikm: TArg<Uint8Array>, salt?: TArg<Uint8Array>): TRet<Uint8Array>;
19
+ /**
20
+ * HKDF-expand from the spec. The most important part. `HKDF-Expand(PRK, info, L) -> OKM`
21
+ * @param hash - hash function that would be used (e.g. sha256)
22
+ * @param prk - a pseudorandom key of at least HashLen octets
23
+ * (usually, the output from the extract step)
24
+ * @param info - optional context and application specific information (can be a zero-length string)
25
+ * @param length - length of output keying material in bytes.
26
+ * RFC 5869 §2.3 allows `0..255*HashLen`, so `0` returns an empty OKM.
27
+ * @returns Output keying material with the requested length.
28
+ * @throws If the requested output length exceeds the HKDF limit
29
+ * for the selected hash. {@link Error}
30
+ * @example
31
+ * Run the HKDF expand step.
32
+ * ```ts
33
+ * import { expand } from '@noble/hashes/hkdf.js';
34
+ * import { sha256 } from '@noble/hashes/sha2.js';
35
+ * expand(sha256, new Uint8Array(32), new Uint8Array([1, 2, 3]), 16);
36
+ * ```
37
+ */
38
+ export declare function expand(hash: TArg<CHash>, prk: TArg<Uint8Array>, info?: TArg<Uint8Array>, length?: number): TRet<Uint8Array>;
39
+ /**
40
+ * HKDF (RFC 5869): derive keys from an initial input.
41
+ * Combines hkdf_extract + hkdf_expand in one step
42
+ * @param hash - hash function that would be used (e.g. sha256)
43
+ * @param ikm - input keying material, the initial key
44
+ * @param salt - optional salt value (a non-secret random value)
45
+ * @param info - optional context and application specific information bytes
46
+ * @param length - length of output keying material in bytes.
47
+ * RFC 5869 §2.3 allows `0..255*HashLen`, so `0` returns an empty OKM.
48
+ * @returns Output keying material derived from the input key.
49
+ * @throws If the requested output length exceeds the HKDF limit
50
+ * for the selected hash. {@link Error}
51
+ * @example
52
+ * HKDF (RFC 5869): derive keys from an initial input.
53
+ * ```ts
54
+ * import { hkdf } from '@noble/hashes/hkdf.js';
55
+ * import { sha256 } from '@noble/hashes/sha2.js';
56
+ * import { randomBytes, utf8ToBytes } from '@noble/hashes/utils.js';
57
+ * const inputKey = randomBytes(32);
58
+ * const salt = randomBytes(32);
59
+ * const info = utf8ToBytes('application-key');
60
+ * const okm = hkdf(sha256, inputKey, salt, info, 32);
61
+ * ```
62
+ */
63
+ export declare const hkdf: (hash: TArg<CHash>, ikm: TArg<Uint8Array>, salt: TArg<Uint8Array | undefined>, info: TArg<Uint8Array | undefined>, length: number) => TRet<Uint8Array>;
64
+ //# sourceMappingURL=hkdf.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hkdf.d.ts","sourceRoot":"","sources":["src/hkdf.ts"],"names":[],"mappings":"AAMA,OAAO,EAA0B,KAAK,KAAK,EAAS,KAAK,IAAI,EAAE,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAE7F;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,OAAO,CACrB,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,EACjB,GAAG,EAAE,IAAI,CAAC,UAAU,CAAC,EACrB,IAAI,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,GACtB,IAAI,CAAC,UAAU,CAAC,CAOlB;AAQD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,MAAM,CACpB,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,EACjB,GAAG,EAAE,IAAI,CAAC,UAAU,CAAC,EACrB,IAAI,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,EACvB,MAAM,GAAE,MAAW,GAClB,IAAI,CAAC,UAAU,CAAC,CAiClB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,IAAI,GACf,MAAM,IAAI,CAAC,KAAK,CAAC,EACjB,KAAK,IAAI,CAAC,UAAU,CAAC,EACrB,MAAM,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC,EAClC,MAAM,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC,EAClC,QAAQ,MAAM,KACb,IAAI,CAAC,UAAU,CAAyD,CAAC"}
@@ -0,0 +1,120 @@
1
+ /**
2
+ * HKDF (RFC 5869): extract + expand in one step.
3
+ * See {@link https://soatok.blog/2021/11/17/understanding-hkdf/}.
4
+ * @module
5
+ */
6
+ import { hmac } from "./hmac.js";
7
+ import { abytes, ahash, anumber, clean } from "./utils.js";
8
+ /**
9
+ * HKDF-extract from spec. Less important part. `HKDF-Extract(IKM, salt) -> PRK`
10
+ * Arguments position differs from spec (IKM is first one, since it is not optional)
11
+ * Local validation only checks `hash`; `ikm` / `salt` byte validation is delegated to `hmac()`.
12
+ * @param hash - hash function that would be used (e.g. sha256)
13
+ * @param ikm - input keying material, the initial key
14
+ * @param salt - optional salt value (a non-secret random value)
15
+ * @returns Pseudorandom key derived from input keying material.
16
+ * @example
17
+ * Run the HKDF extract step.
18
+ * ```ts
19
+ * import { extract } from '@noble/hashes/hkdf.js';
20
+ * import { sha256 } from '@noble/hashes/sha2.js';
21
+ * extract(sha256, new Uint8Array([1, 2, 3]), new Uint8Array([4, 5, 6]));
22
+ * ```
23
+ */
24
+ export function extract(hash, ikm, salt) {
25
+ ahash(hash);
26
+ // NOTE: some libraries treat zero-length array as 'not provided';
27
+ // we don't, since we have undefined as 'not provided'
28
+ // https://github.com/RustCrypto/KDFs/issues/15
29
+ if (salt === undefined)
30
+ salt = new Uint8Array(hash.outputLen);
31
+ return hmac(hash, salt, ikm);
32
+ }
33
+ // Shared mutable scratch byte for the RFC 5869 block counter `N`.
34
+ // Safe to reuse because `expand()` is synchronous and resets it with `clean(...)` before returning.
35
+ const HKDF_COUNTER = /* @__PURE__ */ Uint8Array.of(0);
36
+ // Shared RFC 5869 empty string for both `info === undefined` and the first-block `T(0)` input.
37
+ const EMPTY_BUFFER = /* @__PURE__ */ Uint8Array.of();
38
+ /**
39
+ * HKDF-expand from the spec. The most important part. `HKDF-Expand(PRK, info, L) -> OKM`
40
+ * @param hash - hash function that would be used (e.g. sha256)
41
+ * @param prk - a pseudorandom key of at least HashLen octets
42
+ * (usually, the output from the extract step)
43
+ * @param info - optional context and application specific information (can be a zero-length string)
44
+ * @param length - length of output keying material in bytes.
45
+ * RFC 5869 §2.3 allows `0..255*HashLen`, so `0` returns an empty OKM.
46
+ * @returns Output keying material with the requested length.
47
+ * @throws If the requested output length exceeds the HKDF limit
48
+ * for the selected hash. {@link Error}
49
+ * @example
50
+ * Run the HKDF expand step.
51
+ * ```ts
52
+ * import { expand } from '@noble/hashes/hkdf.js';
53
+ * import { sha256 } from '@noble/hashes/sha2.js';
54
+ * expand(sha256, new Uint8Array(32), new Uint8Array([1, 2, 3]), 16);
55
+ * ```
56
+ */
57
+ export function expand(hash, prk, info, length = 32) {
58
+ ahash(hash);
59
+ anumber(length, 'length');
60
+ abytes(prk, undefined, 'prk');
61
+ const olen = hash.outputLen;
62
+ // RFC 5869 §2.3: PRK is "a pseudorandom key of at least HashLen octets".
63
+ if (prk.length < olen)
64
+ throw new Error('"prk" must be at least HashLen octets');
65
+ // RFC 5869 §2.3 only bounds `L` by `<= 255*HashLen`; `L=0` is valid and yields empty OKM.
66
+ if (length > 255 * olen)
67
+ throw new Error('Length must be <= 255*HashLen');
68
+ const blocks = Math.ceil(length / olen);
69
+ if (info === undefined)
70
+ info = EMPTY_BUFFER;
71
+ else
72
+ abytes(info, undefined, 'info');
73
+ // first L(ength) octets of T
74
+ const okm = new Uint8Array(blocks * olen);
75
+ // Re-use HMAC instance between blocks
76
+ const HMAC = hmac.create(hash, prk);
77
+ const HMACTmp = HMAC._cloneInto();
78
+ const T = new Uint8Array(HMAC.outputLen);
79
+ for (let counter = 0; counter < blocks; counter++) {
80
+ HKDF_COUNTER[0] = counter + 1;
81
+ // T(0) = empty string (zero length)
82
+ // T(N) = HMAC-Hash(PRK, T(N-1) | info | N)
83
+ HMACTmp.update(counter === 0 ? EMPTY_BUFFER : T)
84
+ .update(info)
85
+ .update(HKDF_COUNTER)
86
+ .digestInto(T);
87
+ okm.set(T, olen * counter);
88
+ HMAC._cloneInto(HMACTmp);
89
+ }
90
+ HMAC.destroy();
91
+ HMACTmp.destroy();
92
+ clean(T, HKDF_COUNTER);
93
+ return okm.slice(0, length);
94
+ }
95
+ /**
96
+ * HKDF (RFC 5869): derive keys from an initial input.
97
+ * Combines hkdf_extract + hkdf_expand in one step
98
+ * @param hash - hash function that would be used (e.g. sha256)
99
+ * @param ikm - input keying material, the initial key
100
+ * @param salt - optional salt value (a non-secret random value)
101
+ * @param info - optional context and application specific information bytes
102
+ * @param length - length of output keying material in bytes.
103
+ * RFC 5869 §2.3 allows `0..255*HashLen`, so `0` returns an empty OKM.
104
+ * @returns Output keying material derived from the input key.
105
+ * @throws If the requested output length exceeds the HKDF limit
106
+ * for the selected hash. {@link Error}
107
+ * @example
108
+ * HKDF (RFC 5869): derive keys from an initial input.
109
+ * ```ts
110
+ * import { hkdf } from '@noble/hashes/hkdf.js';
111
+ * import { sha256 } from '@noble/hashes/sha2.js';
112
+ * import { randomBytes, utf8ToBytes } from '@noble/hashes/utils.js';
113
+ * const inputKey = randomBytes(32);
114
+ * const salt = randomBytes(32);
115
+ * const info = utf8ToBytes('application-key');
116
+ * const okm = hkdf(sha256, inputKey, salt, info, 32);
117
+ * ```
118
+ */
119
+ export const hkdf = (hash, ikm, salt, info, length) => expand(hash, extract(hash, ikm, salt), info, length);
120
+ //# sourceM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B,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAqB,CAAC;AAClD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAClB,IAAiB,EACjB,GAAqB,EACrB,IAAkC,EAClC,IAAkC,EAClC,MAAc,EACI,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * HMAC: RFC2104 message authentication code.
3
+ * @module
4
+ */
5
+ import { type CHash, type Hash, type TArg, type TRet } from './utils.ts';
6
+ /**
7
+ * Internal class for HMAC.
8
+ * Accepts any byte key, although RFC 2104 §3 recommends keys at least
9
+ * `HashLen` bytes long.
10
+ */
11
+ export declare class _HMAC<T extends Hash<T>> implements Hash<_HMAC<T>> {
12
+ oHash: T;
13
+ iHash: T;
14
+ blockLen: number;
15
+ outputLen: number;
16
+ canXOF: boolean;
17
+ private finished;
18
+ private destroyed;
19
+ constructor(hash: TArg<CHash>, key: TArg<Uint8Array>);
20
+ update(buf: TArg<Uint8Array>): this;
21
+ digestInto(out: TArg<Uint8Array>): void;
22
+ digest(): TRet<Uint8Array>;
23
+ _cloneInto(to?: _HMAC<T>): _HMAC<T>;
24
+ clone(): _HMAC<T>;
25
+ destroy(): void;
26
+ }
27
+ /**
28
+ * HMAC: RFC2104 message authentication code.
29
+ * @param hash - function that would be used e.g. sha256
30
+ * @param key - authentication key bytes
31
+ * @param message - message bytes to authenticate
32
+ * @returns Authentication tag bytes.
33
+ * @example
34
+ * Compute an RFC 2104 HMAC.
35
+ * ```ts
36
+ * import { hmac } from '@noble/hashes/hmac.js';
37
+ * import { sha256 } from '@noble/hashes/sha2.js';
38
+ * const mac = hmac(sha256, new Uint8Array([1, 2, 3]), new Uint8Array([4, 5, 6]));
39
+ * ```
40
+ */
41
+ type HmacFn = {
42
+ (hash: TArg<CHash>, key: TArg<Uint8Array>, message: TArg<Uint8Array>): TRet<Uint8Array>;
43
+ create(hash: TArg<CHash>, key: TArg<Uint8Array>): TRet<_HMAC<any>>;
44
+ };
45
+ export declare const hmac: TRet<HmacFn>;
46
+ export {};
47
+ //# sourceMappingURL=hmac.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hmac.d.ts","sourceRoot":"","sources":["src/hmac.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAML,KAAK,KAAK,EACV,KAAK,IAAI,EACT,KAAK,IAAI,EACT,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;AAEpB;;;;GAIG;AACH,qBAAa,KAAK,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,CAAC,CAAE,YAAW,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC7D,KAAK,EAAE,CAAC,CAAC;IACT,KAAK,EAAE,CAAC,CAAC;IACT,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,UAAS;IACf,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,SAAS,CAAS;gBAEd,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,UAAU,CAAC;IAsBpD,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,UAAU,CAAC,GAAG,IAAI;IAKnC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,UAAU,CAAC,GAAG,IAAI;IAYvC,MAAM,IAAI,IAAI,CAAC,UAAU,CAAC;IAK1B,UAAU,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;IAcnC,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC;IAGjB,OAAO,IAAI,IAAI;CAKhB;AAED;;;;;;;;;;;;;GAaG;AACH,KAAK,MAAM,GAAG;IACZ,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC;IACxF,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;CACpE,CAAC;AACF,eAAO,MAAM,IAAI,EAAE,IAAI,CAAC,MAAM,CAS1B,CAAC"}
@@ -0,0 +1,93 @@
1
+ /**
2
+ * HMAC: RFC2104 message authentication code.
3
+ * @module
4
+ */
5
+ import { abytes, aexists, ahash, aoutput, clean, } from "./utils.js";
6
+ /**
7
+ * Internal class for HMAC.
8
+ * Accepts any byte key, although RFC 2104 §3 recommends keys at least
9
+ * `HashLen` bytes long.
10
+ */
11
+ export class _HMAC {
12
+ oHash;
13
+ iHash;
14
+ blockLen;
15
+ outputLen;
16
+ canXOF = false;
17
+ finished = false;
18
+ destroyed = false;
19
+ constructor(hash, key) {
20
+ ahash(hash);
21
+ abytes(key, undefined, 'key');
22
+ this.iHash = hash.create();
23
+ if (typeof this.iHash.update !== 'function')
24
+ throw new Error('Expected instance of class which extends utils.Hash');
25
+ this.blockLen = this.iHash.blockLen;
26
+ this.outputLen = this.iHash.outputLen;
27
+ const blockLen = this.blockLen;
28
+ const pad = new Uint8Array(blockLen);
29
+ // blockLen can be bigger than outputLen
30
+ pad.set(key.length > blockLen ? hash.create().update(key).digest() : key);
31
+ for (let i = 0; i < pad.length; i++)
32
+ pad[i] ^= 0x36;
33
+ this.iHash.update(pad);
34
+ // By doing update (processing of the first block) of the outer hash here,
35
+ // we can re-use it between multiple calls via clone.
36
+ this.oHash = hash.create();
37
+ // Undo internal XOR && apply outer XOR
38
+ for (let i = 0; i < pad.length; i++)
39
+ pad[i] ^= 0x36 ^ 0x5c;
40
+ this.oHash.update(pad);
41
+ clean(pad);
42
+ }
43
+ update(buf) {
44
+ aexists(this);
45
+ this.iHash.update(buf);
46
+ return this;
47
+ }
48
+ digestInto(out) {
49
+ aexists(this);
50
+ aoutput(out, this);
51
+ this.finished = true;
52
+ const buf = out.subarray(0, this.outputLen);
53
+ // Reuse the first outputLen bytes for the inner digest; the outer hash consumes them before
54
+ // overwriting that same prefix with the final tag, leaving any oversized tail untouched.
55
+ this.iHash.digestInto(buf);
56
+ this.oHash.update(buf);
57
+ this.oHash.digestInto(buf);
58
+ this.destroy();
59
+ }
60
+ digest() {
61
+ const out = new Uint8Array(this.oHash.outputLen);
62
+ this.digestInto(out);
63
+ return out;
64
+ }
65
+ _cloneInto(to) {
66
+ // Create new instance without calling constructor since the key
67
+ // is already in state and we don't know it.
68
+ to ||= Object.create(Object.getPrototypeOf(this), {});
69
+ const { oHash, iHash, finished, destroyed, blockLen, outputLen } = this;
70
+ to = to;
71
+ to.finished = finished;
72
+ to.destroyed = destroyed;
73
+ to.blockLen = blockLen;
74
+ to.outputLen = outputLen;
75
+ to.oHash = oHash._cloneInto(to.oHash);
76
+ to.iHash = iHash._cloneInto(to.iHash);
77
+ return to;
78
+ }
79
+ clone() {
80
+ return this._cloneInto();
81
+ }
82
+ destroy() {
83
+ this.destroyed = true;
84
+ this.oHash.destroy();
85
+ this.iHash.destroy();
86
+ }
87
+ }
88
+ export const hmac = /* @__PURE__ */ (() => {
89
+ const hmac_ = ((hash, key, message) => new _HMAC(hash, key).update(message).digest());
90
+ hmac_.create = (hash, key) => new _HMAC(hash, key);
91
+ return hmac_;
92
+ })();
93
+ //# sourceMappingURL=hmac.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hmac.js","sourceRoot":"","sources":["src/hmac.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,MAAM,EACN,OAAO,EACP,KAAK,EACL,OAAO,EACP,KAAK,GAKN,MAAM,YAAY,CAAC;AAEp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@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Audited & minimal JS implementation of hash functions, MACs, and KDFs.
3
+ * Check out individual modules.
4
+ * @module
5
+ * @example
6
+ ```js
7
+ import {
8
+ sha256, sha384, sha512, sha224, sha512_224, sha512_256
9
+ } from '@noble/hashes/sha2.js';
10
+ import {
11
+ sha3_224, sha3_256, sha3_384, sha3_512,
12
+ keccak_224, keccak_256, keccak_384, keccak_512,
13
+ shake128, shake256
14
+ } from '@noble/hashes/sha3.js';
15
+ import {
16
+ cshake128, cshake256,
17
+ turboshake128, turboshake256,
18
+ kt128, kt256,
19
+ kmac128, kmac256,
20
+ tuplehash256, parallelhash256,
21
+ keccakprg
22
+ } from '@noble/hashes/sha3-addons.js';
23
+ import { blake3 } from '@noble/hashes/blake3.js';
24
+ import { blake2b, blake2s } from '@noble/hashes/blake2.js';
25
+ import { hmac } from '@noble/hashes/hmac.js';
26
+ import { hkdf } from '@noble/hashes/hkdf.js';
27
+ import { pbkdf2, pbkdf2Async } from '@noble/hashes/pbkdf2.js';
28
+ import { scrypt, scryptAsync } from '@noble/hashes/scrypt.js';
29
+ import { md5, ripemd160, sha1 } from '@noble/hashes/legacy.js';
30
+ import * as utils from '@noble/hashes/utils.js';
31
+ ```
32
+ */
33
+ throw new Error('root module cannot be imported: import submodules instead. Check out README');
34
+ export {};
35
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,IAAI,KAAK,CAAC,6EAA6E,CAAC,CAAC"}