serverless-ircd 0.5.0 → 0.7.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 (394) hide show
  1. package/.github/workflows/ci.yml +40 -3
  2. package/.github/workflows/deploy-aws.yml +1 -2
  3. package/.github/workflows/deploy-cf-tcp.yml +1 -5
  4. package/.github/workflows/deploy-cf.yml +1 -2
  5. package/.gitmodules +3 -0
  6. package/CHANGELOG.md +474 -0
  7. package/README.md +219 -22
  8. package/apps/aws-stack/README.md +33 -0
  9. package/apps/aws-stack/package.json +1 -1
  10. package/apps/aws-stack/src/aws-stack.ts +74 -9
  11. package/apps/aws-stack/tests/coverage-command.test.ts +155 -0
  12. package/apps/aws-stack/tests/stack.test.ts +2 -2
  13. package/apps/aws-stack/tests/synth-no-bundle.test.ts +129 -0
  14. package/apps/aws-stack/tests/vitest.setup.ts +18 -0
  15. package/apps/aws-stack/vitest.config.ts +3 -0
  16. package/apps/cf-tcp-container/package.json +1 -1
  17. package/apps/cf-tcp-container/src/config-loader.ts +6 -7
  18. package/apps/cf-tcp-container/src/container-server.ts +3 -0
  19. package/apps/cf-tcp-container/tests/config-loader.test.ts +10 -3
  20. package/apps/cf-tcp-container/wrangler.toml +1 -1
  21. package/apps/cf-worker/package.json +2 -1
  22. package/apps/cf-worker/src/origin-allowlist.ts +99 -0
  23. package/apps/cf-worker/src/worker.ts +89 -9
  24. package/apps/cf-worker/tests/fixtures/web-dist/app/index.html +18 -0
  25. package/apps/cf-worker/tests/fixtures/web-dist/index.html +18 -0
  26. package/apps/cf-worker/tests/origin-allowlist.test.ts +101 -0
  27. package/apps/cf-worker/tests/smoke.test.ts +28 -2
  28. package/apps/cf-worker/tests/ws-origin.test.ts +89 -0
  29. package/apps/cf-worker/vitest.config.ts +1 -1
  30. package/apps/cf-worker/wrangler.test.toml +23 -0
  31. package/apps/cf-worker/wrangler.toml +59 -3
  32. package/apps/local-cli/package.json +1 -1
  33. package/apps/local-cli/src/config-loader.ts +6 -6
  34. package/apps/local-cli/src/main.ts +20 -0
  35. package/apps/local-cli/src/server.ts +9 -7
  36. package/apps/local-cli/tests/e2e.test.ts +112 -28
  37. package/apps/local-cli/tests/tcp.test.ts +71 -19
  38. package/apps/local-cli/tests/ws-subprotocol.test.ts +12 -7
  39. package/apps/web/landing/index.html +217 -0
  40. package/apps/web/package.json +28 -0
  41. package/apps/web/scripts/build.mjs +125 -0
  42. package/apps/web/src/build-env.ts +43 -0
  43. package/apps/web/src/config-schema.ts +138 -0
  44. package/apps/web/static/config.json +28 -0
  45. package/apps/web/static/config.prod.json +28 -0
  46. package/apps/web/static/config.staging.json +28 -0
  47. package/apps/web/tests/build-env.test.ts +63 -0
  48. package/apps/web/tests/build-smoke.test.ts +103 -0
  49. package/apps/web/tests/config-schema.test.ts +432 -0
  50. package/apps/web/tests/workspace.test.ts +12 -0
  51. package/apps/web/tsconfig.json +10 -0
  52. package/apps/web/upstream/.browserslistrc +3 -0
  53. package/apps/web/upstream/.editorconfig +9 -0
  54. package/apps/web/upstream/.eslintignore +3 -0
  55. package/apps/web/upstream/.eslintrc.js +90 -0
  56. package/apps/web/upstream/.github/FUNDING.yml +12 -0
  57. package/apps/web/upstream/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
  58. package/apps/web/upstream/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  59. package/apps/web/upstream/.github/workflows/push.yml +26 -0
  60. package/apps/web/upstream/.github/workflows/release.yml +33 -0
  61. package/apps/web/upstream/.github/workflows/release_manual.yml +55 -0
  62. package/apps/web/upstream/.prettierrc.js +9 -0
  63. package/apps/web/upstream/.stylelintignore +5 -0
  64. package/apps/web/upstream/.stylelintrc.js +21 -0
  65. package/apps/web/upstream/LICENSE +201 -0
  66. package/apps/web/upstream/README.md +76 -0
  67. package/apps/web/upstream/babel.config.js +25 -0
  68. package/apps/web/upstream/crowdin.yml +3 -0
  69. package/apps/web/upstream/index.html +35 -0
  70. package/apps/web/upstream/jest.config.js +7 -0
  71. package/apps/web/upstream/jsdoc.json +22 -0
  72. package/apps/web/upstream/package.json +80 -0
  73. package/apps/web/upstream/scripts/pre-commit +43 -0
  74. package/apps/web/upstream/src/components/App.vue +516 -0
  75. package/apps/web/upstream/src/components/AppSettings.vue +587 -0
  76. package/apps/web/upstream/src/components/AutoComplete.vue +284 -0
  77. package/apps/web/upstream/src/components/Avatar.vue +105 -0
  78. package/apps/web/upstream/src/components/AwayStatusIndicator.vue +77 -0
  79. package/apps/web/upstream/src/components/BufferKey.vue +121 -0
  80. package/apps/web/upstream/src/components/BufferSettings.vue +97 -0
  81. package/apps/web/upstream/src/components/Captcha.vue +85 -0
  82. package/apps/web/upstream/src/components/ChannelBanlist.vue +96 -0
  83. package/apps/web/upstream/src/components/ChannelInfo.vue +159 -0
  84. package/apps/web/upstream/src/components/ChannelInvitelist.vue +276 -0
  85. package/apps/web/upstream/src/components/ChannelList.vue +345 -0
  86. package/apps/web/upstream/src/components/Container.vue +401 -0
  87. package/apps/web/upstream/src/components/ContainerHeader.vue +522 -0
  88. package/apps/web/upstream/src/components/ControlInput.vue +1016 -0
  89. package/apps/web/upstream/src/components/LoadingAnimation.vue +104 -0
  90. package/apps/web/upstream/src/components/MediaViewer.vue +199 -0
  91. package/apps/web/upstream/src/components/MessageInfo.vue +192 -0
  92. package/apps/web/upstream/src/components/MessageList.vue +1028 -0
  93. package/apps/web/upstream/src/components/MessageListAvatar.vue +20 -0
  94. package/apps/web/upstream/src/components/MessageListMessageCompact.vue +361 -0
  95. package/apps/web/upstream/src/components/MessageListMessageInline.vue +257 -0
  96. package/apps/web/upstream/src/components/MessageListMessageModern.vue +430 -0
  97. package/apps/web/upstream/src/components/NetworkSettings.vue +528 -0
  98. package/apps/web/upstream/src/components/Nicklist.vue +309 -0
  99. package/apps/web/upstream/src/components/NicklistUser.vue +181 -0
  100. package/apps/web/upstream/src/components/NotConnected.vue +271 -0
  101. package/apps/web/upstream/src/components/SelfUser.vue +283 -0
  102. package/apps/web/upstream/src/components/ServerSelector.vue +162 -0
  103. package/apps/web/upstream/src/components/ServerView.vue +126 -0
  104. package/apps/web/upstream/src/components/SettingsAdvanced.vue +232 -0
  105. package/apps/web/upstream/src/components/SettingsAliases.vue +121 -0
  106. package/apps/web/upstream/src/components/Sidebar.vue +429 -0
  107. package/apps/web/upstream/src/components/SidebarAboutBuffer.vue +288 -0
  108. package/apps/web/upstream/src/components/SidebarState.vue +145 -0
  109. package/apps/web/upstream/src/components/StartupError.vue +35 -0
  110. package/apps/web/upstream/src/components/StateBrowser.vue +420 -0
  111. package/apps/web/upstream/src/components/StateBrowserBuffer.vue +124 -0
  112. package/apps/web/upstream/src/components/StateBrowserNetwork.vue +823 -0
  113. package/apps/web/upstream/src/components/StateBrowserUsermenu.vue +162 -0
  114. package/apps/web/upstream/src/components/TypingStatusIndicator.vue +34 -0
  115. package/apps/web/upstream/src/components/TypingUsersList.vue +56 -0
  116. package/apps/web/upstream/src/components/UrlEmbed.vue +149 -0
  117. package/apps/web/upstream/src/components/UserBox.vue +728 -0
  118. package/apps/web/upstream/src/components/inputtools/Emoji.vue +67 -0
  119. package/apps/web/upstream/src/components/inputtools/TextStyle.vue +142 -0
  120. package/apps/web/upstream/src/components/startups/CommonLayout.vue +208 -0
  121. package/apps/web/upstream/src/components/startups/CustomServer.vue +495 -0
  122. package/apps/web/upstream/src/components/startups/KiwiBnc.vue +361 -0
  123. package/apps/web/upstream/src/components/startups/Personal.vue +317 -0
  124. package/apps/web/upstream/src/components/startups/Welcome.vue +544 -0
  125. package/apps/web/upstream/src/components/startups/ZncLogin.vue +229 -0
  126. package/apps/web/upstream/src/components/utils/InputConfirm.vue +68 -0
  127. package/apps/web/upstream/src/components/utils/InputPrompt.vue +118 -0
  128. package/apps/web/upstream/src/components/utils/InputText.vue +172 -0
  129. package/apps/web/upstream/src/components/utils/IrcInput.vue +579 -0
  130. package/apps/web/upstream/src/components/utils/PluginWrapper.vue +26 -0
  131. package/apps/web/upstream/src/components/utils/TabbedView.vue +149 -0
  132. package/apps/web/upstream/src/components/utils/TransitionExpand.vue +97 -0
  133. package/apps/web/upstream/src/helpers/Colours.js +128 -0
  134. package/apps/web/upstream/src/helpers/IrcdDiffs.js +26 -0
  135. package/apps/web/upstream/src/helpers/Md5.js +193 -0
  136. package/apps/web/upstream/src/helpers/Misc.js +401 -0
  137. package/apps/web/upstream/src/helpers/TextFormatting.js +237 -0
  138. package/apps/web/upstream/src/libs/AliasRewriter.js +157 -0
  139. package/apps/web/upstream/src/libs/AudioManager.js +60 -0
  140. package/apps/web/upstream/src/libs/BouncerMiddleware.js +247 -0
  141. package/apps/web/upstream/src/libs/BouncerProvider.js +551 -0
  142. package/apps/web/upstream/src/libs/ChathistoryMiddleware.js +153 -0
  143. package/apps/web/upstream/src/libs/ConfigLoader.js +94 -0
  144. package/apps/web/upstream/src/libs/EmojiProvider.js +46 -0
  145. package/apps/web/upstream/src/libs/GlobalApi.js +346 -0
  146. package/apps/web/upstream/src/libs/IPC.js +51 -0
  147. package/apps/web/upstream/src/libs/InputHandler.js +921 -0
  148. package/apps/web/upstream/src/libs/IrcClient.js +1506 -0
  149. package/apps/web/upstream/src/libs/Logger.js +71 -0
  150. package/apps/web/upstream/src/libs/Message.js +169 -0
  151. package/apps/web/upstream/src/libs/MessageFormatter.js +364 -0
  152. package/apps/web/upstream/src/libs/MessageParser.js +249 -0
  153. package/apps/web/upstream/src/libs/Notifications.js +78 -0
  154. package/apps/web/upstream/src/libs/ServerConnection.js +270 -0
  155. package/apps/web/upstream/src/libs/ServerSession.js +102 -0
  156. package/apps/web/upstream/src/libs/SoundBleep.js +20 -0
  157. package/apps/web/upstream/src/libs/StatePersistence.js +90 -0
  158. package/apps/web/upstream/src/libs/ThemeManager.js +128 -0
  159. package/apps/web/upstream/src/libs/TypingMiddleware.js +105 -0
  160. package/apps/web/upstream/src/libs/WindowTitle.js +63 -0
  161. package/apps/web/upstream/src/libs/batchedAdd.js +74 -0
  162. package/apps/web/upstream/src/libs/bufferTools.js +177 -0
  163. package/apps/web/upstream/src/libs/polyfill/Element.closest.js +18 -0
  164. package/apps/web/upstream/src/libs/renderers/Html.js +113 -0
  165. package/apps/web/upstream/src/libs/settingTools.js +31 -0
  166. package/apps/web/upstream/src/libs/state/BufferState.js +703 -0
  167. package/apps/web/upstream/src/libs/state/NetworkState.js +158 -0
  168. package/apps/web/upstream/src/libs/state/UserState.js +89 -0
  169. package/apps/web/upstream/src/libs/state/common.js +26 -0
  170. package/apps/web/upstream/src/libs/state.js +961 -0
  171. package/apps/web/upstream/src/libs/storage/Local.js +51 -0
  172. package/apps/web/upstream/src/main.js +566 -0
  173. package/apps/web/upstream/src/res/autocompleteCommands.js +31 -0
  174. package/apps/web/upstream/src/res/configTemplates.js +373 -0
  175. package/apps/web/upstream/src/res/globalStyle.css +277 -0
  176. package/apps/web/upstream/src/res/kiwiLoadingLogo.png +0 -0
  177. package/apps/web/upstream/src/res/locales/app.af-ZA.po +1145 -0
  178. package/apps/web/upstream/src/res/locales/app.ar-SA.po +1145 -0
  179. package/apps/web/upstream/src/res/locales/app.bg-BG.po +1145 -0
  180. package/apps/web/upstream/src/res/locales/app.bs-BA.po +1145 -0
  181. package/apps/web/upstream/src/res/locales/app.ca-ES.po +1145 -0
  182. package/apps/web/upstream/src/res/locales/app.cs-CZ.po +1145 -0
  183. package/apps/web/upstream/src/res/locales/app.da-DK.po +1145 -0
  184. package/apps/web/upstream/src/res/locales/app.de-DE.po +1145 -0
  185. package/apps/web/upstream/src/res/locales/app.dev.po +1246 -0
  186. package/apps/web/upstream/src/res/locales/app.el-GR.po +1145 -0
  187. package/apps/web/upstream/src/res/locales/app.en-US.po +1145 -0
  188. package/apps/web/upstream/src/res/locales/app.es-419.po +1145 -0
  189. package/apps/web/upstream/src/res/locales/app.es-AR.po +1145 -0
  190. package/apps/web/upstream/src/res/locales/app.es-EM.po +536 -0
  191. package/apps/web/upstream/src/res/locales/app.es-ES.po +1145 -0
  192. package/apps/web/upstream/src/res/locales/app.es-US.po +1145 -0
  193. package/apps/web/upstream/src/res/locales/app.eu-ES.po +1145 -0
  194. package/apps/web/upstream/src/res/locales/app.fi-FI.po +1145 -0
  195. package/apps/web/upstream/src/res/locales/app.fr-FR.po +1145 -0
  196. package/apps/web/upstream/src/res/locales/app.gl-ES.po +1145 -0
  197. package/apps/web/upstream/src/res/locales/app.he-IL.po +1145 -0
  198. package/apps/web/upstream/src/res/locales/app.hi-IN.po +1145 -0
  199. package/apps/web/upstream/src/res/locales/app.hu-HU.po +1145 -0
  200. package/apps/web/upstream/src/res/locales/app.id-ID.po +1145 -0
  201. package/apps/web/upstream/src/res/locales/app.it-IT.po +1145 -0
  202. package/apps/web/upstream/src/res/locales/app.ja-JP.po +1145 -0
  203. package/apps/web/upstream/src/res/locales/app.ko-KR.po +1145 -0
  204. package/apps/web/upstream/src/res/locales/app.nl-NL.po +1145 -0
  205. package/apps/web/upstream/src/res/locales/app.no-NO.po +1145 -0
  206. package/apps/web/upstream/src/res/locales/app.pl-PL.po +1145 -0
  207. package/apps/web/upstream/src/res/locales/app.pt-BR.po +1145 -0
  208. package/apps/web/upstream/src/res/locales/app.pt-PT.po +1145 -0
  209. package/apps/web/upstream/src/res/locales/app.ro-RO.po +1145 -0
  210. package/apps/web/upstream/src/res/locales/app.ru-RU.po +1145 -0
  211. package/apps/web/upstream/src/res/locales/app.sl-SI.po +1145 -0
  212. package/apps/web/upstream/src/res/locales/app.sq-AL.po +1145 -0
  213. package/apps/web/upstream/src/res/locales/app.sr-SP.po +1145 -0
  214. package/apps/web/upstream/src/res/locales/app.sv-SE.po +1145 -0
  215. package/apps/web/upstream/src/res/locales/app.tr-TR.po +1145 -0
  216. package/apps/web/upstream/src/res/locales/app.uk-UA.po +1145 -0
  217. package/apps/web/upstream/src/res/locales/app.vi-VN.po +1145 -0
  218. package/apps/web/upstream/src/res/locales/app.zh-CN.po +1145 -0
  219. package/apps/web/upstream/src/res/locales/app.zh-TW.po +1145 -0
  220. package/apps/web/upstream/src/res/localesList.json +27 -0
  221. package/apps/web/upstream/src/res/logo.png +0 -0
  222. package/apps/web/upstream/src/thirdparty/about.html +43 -0
  223. package/apps/web/upstream/src/thirdparty/index.js +5 -0
  224. package/apps/web/upstream/src/thirdparty/kiwiirccom.vue +185 -0
  225. package/apps/web/upstream/static/config.json +28 -0
  226. package/apps/web/upstream/static/emoticons/smile.png +0 -0
  227. package/apps/web/upstream/static/favicon.png +0 -0
  228. package/apps/web/upstream/static/highlight.mp3 +0 -0
  229. package/apps/web/upstream/static/highlight.ogg +0 -0
  230. package/apps/web/upstream/static/locales/.gitignore +2 -0
  231. package/apps/web/upstream/static/plugins/customise.html.example +10 -0
  232. package/apps/web/upstream/static/themes/coffee/theme.css +145 -0
  233. package/apps/web/upstream/static/themes/common/base.css +1064 -0
  234. package/apps/web/upstream/static/themes/dark/theme.css +196 -0
  235. package/apps/web/upstream/static/themes/default/theme.css +92 -0
  236. package/apps/web/upstream/static/themes/elite/theme.css +248 -0
  237. package/apps/web/upstream/static/themes/grayfox/theme.css +143 -0
  238. package/apps/web/upstream/static/themes/nightswatch/theme.css +367 -0
  239. package/apps/web/upstream/static/themes/osprey/theme.css +115 -0
  240. package/apps/web/upstream/static/themes/radioactive/theme.css +1211 -0
  241. package/apps/web/upstream/static/themes/sky/theme.css +107 -0
  242. package/apps/web/upstream/tests/unit/BatchAdd.spec.js +174 -0
  243. package/apps/web/upstream/tests/unit/MessageParser.spec.js +125 -0
  244. package/apps/web/upstream/tests/unit/Misc.spec.js +24 -0
  245. package/apps/web/upstream/tests/unit/NetworkState.spec.js +58 -0
  246. package/apps/web/upstream/tests/unit/StartupError.spec.js +20 -0
  247. package/apps/web/upstream/vue.config.js +150 -0
  248. package/apps/web/upstream/yarn.lock +9767 -0
  249. package/apps/web/vitest.config.ts +13 -0
  250. package/biome.json +2 -0
  251. package/docs/ADR-001-pure-reducers-and-effect-system.md +74 -0
  252. package/docs/ADR-002-location-of-authority.md +82 -0
  253. package/docs/ADR-003-durable-object-sharding.md +110 -0
  254. package/docs/ADR-004-dynamodb-schema.md +96 -0
  255. package/docs/ADR-005-wss-only-transport-v1.md +83 -0
  256. package/docs/ADR-006-sasl-mechanism-scope.md +96 -0
  257. package/docs/ADR-007-deterministic-ports.md +82 -0
  258. package/docs/ADR-008-monorepo-tooling.md +60 -0
  259. package/docs/ADR-009-dual-transport-wss-and-irc-tls.md +138 -0
  260. package/docs/ADR-Index.md +15 -0
  261. package/docs/AWS-Adapter-Architecture.md +496 -0
  262. package/docs/AWS-Deployment.md +1275 -0
  263. package/docs/AWS-TCP-Deployment.md +410 -0
  264. package/docs/Cloudflare-Deployment-Guide.md +719 -0
  265. package/docs/Cloudflare-TCP-Deployment.md +510 -0
  266. package/docs/Home.md +16 -0
  267. package/docs/Observability.md +87 -0
  268. package/docs/PlanExtensions.md +812 -0
  269. package/docs/PlanIRCv3Websocket.md +503 -0
  270. package/docs/PlanWebClient.md +451 -0
  271. package/docs/Release-Process.md +443 -0
  272. package/docs/WebClientGuide.md +535 -0
  273. package/package.json +2 -2
  274. package/packages/aws-adapter/package.json +1 -1
  275. package/packages/aws-adapter/src/handlers/default.ts +3 -0
  276. package/packages/aws-adapter/src/handlers/nlb-stream.ts +9 -0
  277. package/packages/aws-adapter/src/serialize.ts +29 -1
  278. package/packages/aws-adapter/tests/account-store-dynamo.test.ts +49 -8
  279. package/packages/aws-adapter/tests/account-store.test.ts +4 -7
  280. package/packages/aws-adapter/tests/aws-harness.ts +5 -2
  281. package/packages/aws-adapter/tests/aws-integration.test.ts +8 -4
  282. package/packages/aws-adapter/tests/aws-runtime.test.ts +79 -0
  283. package/packages/aws-adapter/tests/config-loader.test.ts +11 -2
  284. package/packages/aws-adapter/tests/connect.test.ts +9 -9
  285. package/packages/aws-adapter/tests/disconnect-fanout.test.ts +3 -4
  286. package/packages/aws-adapter/tests/global-setup.ts +55 -30
  287. package/packages/aws-adapter/tests/gone-exception.test.ts +4 -9
  288. package/packages/aws-adapter/tests/handlers.test.ts +90 -4
  289. package/packages/aws-adapter/tests/message-store.test.ts +6 -5
  290. package/packages/aws-adapter/tests/nlb-stream.test.ts +60 -8
  291. package/packages/cf-adapter/package.json +2 -1
  292. package/packages/cf-adapter/src/connection-do.ts +3 -0
  293. package/packages/cf-adapter/src/serialize.ts +25 -4
  294. package/packages/cf-adapter/tests/cf-harness.ts +12 -1
  295. package/packages/cf-adapter/tests/cf-runtime.test.ts +269 -0
  296. package/packages/cf-adapter/tests/channel-do.test.ts +117 -0
  297. package/packages/cf-adapter/tests/config-loader.test.ts +49 -0
  298. package/packages/cf-adapter/tests/connection-do-pure.test.ts +91 -0
  299. package/packages/cf-adapter/tests/d1-account-store.test.ts +48 -0
  300. package/packages/cf-adapter/tests/registry-do.test.ts +104 -0
  301. package/packages/cf-adapter/tests/serialize.test.ts +308 -0
  302. package/packages/cf-adapter/vitest.config.ts +1 -1
  303. package/packages/in-memory-runtime/package.json +1 -1
  304. package/packages/irc-core/package.json +1 -1
  305. package/packages/irc-core/reports/mutation/mutation.html +342 -0
  306. package/packages/irc-core/src/caps/capabilities.ts +37 -3
  307. package/packages/irc-core/src/caps/index.ts +1 -0
  308. package/packages/irc-core/src/caps/sts.ts +84 -0
  309. package/packages/irc-core/src/commands/account-notify.ts +53 -0
  310. package/packages/irc-core/src/commands/away.ts +9 -3
  311. package/packages/irc-core/src/commands/cap.ts +23 -5
  312. package/packages/irc-core/src/commands/chathistory.ts +40 -11
  313. package/packages/irc-core/src/commands/index.ts +34 -0
  314. package/packages/irc-core/src/commands/isupport.ts +53 -0
  315. package/packages/irc-core/src/commands/mode.ts +8 -1
  316. package/packages/irc-core/src/commands/monitor.ts +327 -0
  317. package/packages/irc-core/src/commands/multiline.ts +256 -0
  318. package/packages/irc-core/src/commands/pre-away.ts +112 -0
  319. package/packages/irc-core/src/commands/privmsg.ts +19 -12
  320. package/packages/irc-core/src/commands/read-marker.ts +108 -0
  321. package/packages/irc-core/src/commands/registration.ts +8 -0
  322. package/packages/irc-core/src/commands/sasl.ts +24 -1
  323. package/packages/irc-core/src/commands/tagmsg.ts +71 -1
  324. package/packages/irc-core/src/commands/whois.ts +5 -0
  325. package/packages/irc-core/src/config.ts +65 -10
  326. package/packages/irc-core/src/effects.ts +14 -0
  327. package/packages/irc-core/src/ports.ts +389 -0
  328. package/packages/irc-core/src/protocol/index.ts +14 -0
  329. package/packages/irc-core/src/protocol/labeled-response.ts +133 -0
  330. package/packages/irc-core/src/protocol/numerics.ts +15 -0
  331. package/packages/irc-core/src/protocol/outbound.ts +16 -1
  332. package/packages/irc-core/src/protocol/standard-replies.ts +277 -0
  333. package/packages/irc-core/src/state/connection.ts +32 -1
  334. package/packages/irc-core/src/types.ts +112 -0
  335. package/packages/irc-core/stryker.commands.conf.json +1 -2
  336. package/packages/irc-core/tests/away-store.test.ts +73 -0
  337. package/packages/irc-core/tests/batch.test.ts +15 -0
  338. package/packages/irc-core/tests/caps/capabilities.test.ts +119 -2
  339. package/packages/irc-core/tests/caps/sts.test.ts +123 -0
  340. package/packages/irc-core/tests/commands/account-notify.test.ts +171 -0
  341. package/packages/irc-core/tests/commands/away.test.ts +85 -2
  342. package/packages/irc-core/tests/commands/cap.test.ts +165 -0
  343. package/packages/irc-core/tests/commands/chathistory.test.ts +148 -1
  344. package/packages/irc-core/tests/commands/echo-message.test.ts +9 -3
  345. package/packages/irc-core/tests/commands/isupport.test.ts +80 -0
  346. package/packages/irc-core/tests/commands/mode.test.ts +72 -0
  347. package/packages/irc-core/tests/commands/monitor.test.ts +411 -0
  348. package/packages/irc-core/tests/commands/multiline.test.ts +428 -0
  349. package/packages/irc-core/tests/commands/pre-away.test.ts +241 -0
  350. package/packages/irc-core/tests/commands/privmsg.test.ts +154 -3
  351. package/packages/irc-core/tests/commands/read-marker.test.ts +211 -0
  352. package/packages/irc-core/tests/commands/registration.test.ts +64 -0
  353. package/packages/irc-core/tests/commands/sasl.test.ts +116 -2
  354. package/packages/irc-core/tests/commands/tagmsg.test.ts +357 -0
  355. package/packages/irc-core/tests/commands/whois.test.ts +34 -0
  356. package/packages/irc-core/tests/config.test.ts +103 -13
  357. package/packages/irc-core/tests/labeled-response.test.ts +181 -0
  358. package/packages/irc-core/tests/message-tags.test.ts +114 -0
  359. package/packages/irc-core/tests/monitor-store.test.ts +200 -0
  360. package/packages/irc-core/tests/numerics.test.ts +13 -0
  361. package/packages/irc-core/tests/parser.test.ts +109 -0
  362. package/packages/irc-core/tests/read-marker-store.test.ts +108 -0
  363. package/packages/irc-core/tests/standard-replies.test.ts +412 -0
  364. package/packages/irc-core/tests/types.test.ts +27 -0
  365. package/packages/irc-server/package.json +1 -1
  366. package/packages/irc-server/src/actor.ts +450 -3
  367. package/packages/irc-server/src/dispatch.ts +108 -16
  368. package/packages/irc-server/tests/actor.test.ts +1432 -39
  369. package/packages/irc-server/tests/dispatch.test.ts +263 -2
  370. package/packages/irc-test-support/package.json +1 -1
  371. package/packages/irc-test-support/src/index.ts +6 -0
  372. package/packages/irc-test-support/src/scenarios.ts +24 -2
  373. package/packages/irc-test-support/src/test-config.ts +54 -0
  374. package/packages/irc-test-support/tests/test-config.test.ts +51 -0
  375. package/tools/ci-hardening/package.json +1 -1
  376. package/tools/ci-hardening/tests/ddb-local.test.ts +82 -0
  377. package/tools/load-test/package.json +33 -0
  378. package/tools/load-test/src/client.ts +351 -0
  379. package/tools/load-test/src/config.ts +313 -0
  380. package/tools/load-test/src/harness.ts +116 -0
  381. package/tools/load-test/src/main.ts +120 -0
  382. package/tools/load-test/src/metrics.ts +168 -0
  383. package/tools/load-test/src/report.ts +106 -0
  384. package/tools/load-test/tests/client.test.ts +212 -0
  385. package/tools/load-test/tests/config.test.ts +152 -0
  386. package/tools/load-test/tests/framing.test.ts +37 -0
  387. package/tools/load-test/tests/harness.test.ts +165 -0
  388. package/tools/load-test/tests/metrics.test.ts +174 -0
  389. package/tools/load-test/tests/report.test.ts +161 -0
  390. package/tools/load-test/tests/smoke.test.ts +67 -0
  391. package/tools/load-test/tsconfig.build.json +12 -0
  392. package/tools/load-test/tsconfig.test.json +10 -0
  393. package/tools/load-test/vitest.config.ts +29 -0
  394. package/tools/tcp-ws-forwarder/package.json +1 -1
@@ -0,0 +1,149 @@
1
+ <template>
2
+ <div class="u-tabbed-view">
3
+ <div :key="prefixID + a" class="u-tabbed-view-tabs">
4
+ <a
5
+ v-for="c in tabs"
6
+ :key="c.name || c.header"
7
+ :class="{
8
+ 'u-tabbed-view-tab': true,
9
+ 'u-tabbed-view-tab--active': c.active
10
+ }"
11
+ @click="setActive(c)"
12
+ >{{ c.header }}</a>
13
+ </div>
14
+ <slot />
15
+ </div>
16
+ </template>
17
+
18
+ <script>
19
+ 'kiwi public';
20
+
21
+ let Vue = require('vue');
22
+
23
+ Vue.component('tabbed-tab', {
24
+ props: {
25
+ header: { status: String },
26
+ focus: { status: Boolean },
27
+ name: { status: String },
28
+ },
29
+ data: function data() {
30
+ return { active: false };
31
+ },
32
+ template: '<div v-if="active" class="u-tabbed-content"><slot></slot></div>',
33
+ });
34
+
35
+ export default Vue.component('tabbed-view', {
36
+ data: function data() {
37
+ return {
38
+ // We increment this when we need to re-render the tabs.
39
+ // Vue doesn't pick up on the $children changes all the time so we handle
40
+ // it ourselves.
41
+ a: 1,
42
+ prefixID: Math.floor(Math.random() * 100000).toString(36),
43
+ };
44
+ },
45
+ computed: {
46
+ tabs: function computedtabs() {
47
+ return this.$children;
48
+ },
49
+ },
50
+ mounted() {
51
+ this.setActiveCheck();
52
+ },
53
+ methods: {
54
+ getActive: function getActive() {
55
+ let foundChild = null;
56
+ this.$children.forEach((child) => {
57
+ if (child.active) {
58
+ foundChild = child;
59
+ }
60
+ });
61
+
62
+ return foundChild;
63
+ },
64
+ setActive: function setActive(c) {
65
+ this.$children.forEach((child) => {
66
+ if (child !== c) {
67
+ child.active = false;
68
+ }
69
+ });
70
+ c.active = true;
71
+
72
+ // Without this, vue doesnt update itself with the new $children :(
73
+ this.a++;
74
+ this.$emit('changed', c.name);
75
+ },
76
+ setActiveByName: function setActiveByName(name) {
77
+ this.$children.forEach((child) => {
78
+ if (child.name === name) {
79
+ this.setActive(child);
80
+ }
81
+ });
82
+ },
83
+ setActiveCheck: function setActiveCheck() {
84
+ this.$children.forEach((t) => {
85
+ if (t.focus) {
86
+ this.setActive(t);
87
+ }
88
+ });
89
+ },
90
+ },
91
+ });
92
+ </script>
93
+
94
+ <style>
95
+ .u-tabbed-view {
96
+ display: flex;
97
+ flex-direction: column;
98
+ height: 100%;
99
+ }
100
+
101
+ .u-tabbed-view-tabs {
102
+ padding-top: 15px;
103
+ }
104
+
105
+ .u-tabbed-view-tab {
106
+ display: inline-block;
107
+ cursor: pointer;
108
+ border-width: 0;
109
+ border-style: solid;
110
+ background: #fff;
111
+ font-weight: 600;
112
+ opacity: 1;
113
+ z-index: 1;
114
+ margin-bottom: -3px;
115
+ position: relative;
116
+ width: auto;
117
+ text-align: left;
118
+ box-sizing: border-box;
119
+ padding: 0.5em 1em;
120
+ border-bottom: 3px solid rgba(0, 0, 0, 0.1);
121
+ transition: border 0.3s;
122
+ }
123
+
124
+ .u-tabbed-view-tab:hover,
125
+ .u-tabbed-view-tab--active {
126
+ border-bottom-width: 3px;
127
+ }
128
+
129
+ .u-tabbed-view-tab:last-of-type {
130
+ z-index: 1;
131
+ border-radius: 0 4px 0 0;
132
+ }
133
+
134
+ .u-tabbed-content {
135
+ overflow: auto;
136
+ height: 100%;
137
+ }
138
+
139
+ @media screen and (max-width: 769px) {
140
+ .u-tabbed-view-tabs {
141
+ padding-top: 0;
142
+ }
143
+
144
+ .u-tabbed-view-tab {
145
+ padding: 10px 20px;
146
+ width: auto;
147
+ }
148
+ }
149
+ </style>
@@ -0,0 +1,97 @@
1
+ <template>
2
+ <transition
3
+ name="u-transition-expand"
4
+ @enter="enter"
5
+ @after-enter="afterEnter"
6
+ @leave="leave"
7
+ >
8
+ <div v-if="$slots.default"><slot /></div>
9
+ </transition>
10
+ </template>
11
+
12
+ <script>
13
+ 'kiwi public';
14
+
15
+ const Vue = require('vue');
16
+
17
+ // Code created from https://markus.oberlehner.net/blog/transition-to-height-auto-with-vue/
18
+
19
+ export default Vue.component('transition-expand', {
20
+ name: 'TransitionExpand',
21
+ methods: {
22
+ enter(element) {
23
+ const width = getComputedStyle(element).width;
24
+
25
+ element.style.width = width;
26
+ element.style.position = 'absolute';
27
+ element.style.visibility = 'hidden';
28
+ element.style.height = 'auto';
29
+
30
+ const height = getComputedStyle(element).height;
31
+
32
+ element.style.width = null;
33
+ element.style.position = null;
34
+ element.style.visibility = null;
35
+ element.style.height = 0;
36
+
37
+ // Force repaint to make sure the
38
+ // animation is triggered correctly.
39
+ // eslint-disable-next-line no-unused-expressions
40
+ getComputedStyle(element).height;
41
+
42
+ // Trigger the animation.
43
+ // We use `requestAnimationFrame` because we need
44
+ // to make sure the browser has finished
45
+ // painting after setting the `height`
46
+ // to `0` in the line above.
47
+ requestAnimationFrame(() => {
48
+ element.style.height = height;
49
+ });
50
+ },
51
+ afterEnter(element) {
52
+ element.style.height = 'auto';
53
+ },
54
+ leave(element) {
55
+ const height = getComputedStyle(element).height;
56
+
57
+ element.style.height = height;
58
+
59
+ // Force repaint to make sure the
60
+ // animation is triggered correctly.
61
+ // eslint-disable-next-line no-unused-expressions
62
+ getComputedStyle(element).height;
63
+
64
+ requestAnimationFrame(() => {
65
+ element.style.height = 0;
66
+ });
67
+ },
68
+ },
69
+ });
70
+ </script>
71
+
72
+ <style>
73
+ .u-transition-expand-enter-active,
74
+ .u-transition-expand-leave-active {
75
+ transition: height 0.2s, opacity 0.2s;
76
+ overflow: hidden;
77
+ }
78
+
79
+ .u-transition-expand-enter,
80
+ .u-transition-expand-leave-to {
81
+ opacity: 0;
82
+ height: 0;
83
+ }
84
+ </style>
85
+
86
+ <style scoped>
87
+ /*
88
+ try to force the browser into optimizing the animation
89
+ using hardware acceleration
90
+ */
91
+ * {
92
+ will-change: height;
93
+ transform: translateZ(0);
94
+ backface-visibility: hidden;
95
+ perspective: 1000px;
96
+ }
97
+ </style>
@@ -0,0 +1,128 @@
1
+ 'kiwi public';
2
+
3
+ /** @module */
4
+
5
+ /**
6
+ * Converts a hex CSS color value to RGB.
7
+ * Adapted from http://stackoverflow.com/a/5624139.
8
+ *
9
+ * @param {String} _hex The hexadecimal color value
10
+ * @return {Object} The RGB representation
11
+ */
12
+ export function hex2rgb(_hex) {
13
+ // Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF")
14
+ let shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
15
+ let hex = _hex.replace(shorthandRegex, (m, r, g, b) => r + r + g + g + b + b);
16
+
17
+ let result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
18
+ return result ? {
19
+ r: parseInt(result[1], 16),
20
+ g: parseInt(result[2], 16),
21
+ b: parseInt(result[3], 16),
22
+ } : null;
23
+ }
24
+
25
+ /**
26
+ * Converts an RGB color value to a hex string.
27
+ * @param {Object} rgb RGB as r, g, and b keys
28
+ * @return {String} Hex color string
29
+ */
30
+ export function rgb2hex(rgb) {
31
+ return '#' + ['r', 'g', 'b']
32
+ .map((key) => ('0' + rgb[key].toString(16)).slice(-2))
33
+ .join('');
34
+ }
35
+
36
+ /**
37
+ * Converts an RGB color value to HSL. Conversion formula adapted from
38
+ * http://en.wikipedia.org/wiki/HSL_color_space. This function adapted
39
+ * from http://stackoverflow.com/a/9493060.
40
+ * Assumes r, g, and b are contained in the set [0, 255] and
41
+ * returns h, s, and l in the set [0, 1].
42
+ *
43
+ * @param Object rgb RGB as r, g, and b keys
44
+ * @return Object HSL as h, s, and l keys
45
+ */
46
+ export function rgb2hsl(rgb) {
47
+ let r = rgb.r;
48
+ let g = rgb.g;
49
+ let b = rgb.b;
50
+
51
+ r /= 255;
52
+ g /= 255;
53
+ b /= 255;
54
+
55
+ let max = Math.max(r, g, b);
56
+ let min = Math.min(r, g, b);
57
+ let h = 0;
58
+ let s = 0;
59
+ let l = (max + min) / 2;
60
+
61
+ if (max === min) {
62
+ h = s = 0; // achromatic
63
+ } else {
64
+ let d = max - min;
65
+ s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
66
+ if (max === r) {
67
+ h = (g - b) / d + (g < b ? 6 : 0);
68
+ } else if (max === g) {
69
+ h = (b - r) / d + 2;
70
+ } else if (max === b) {
71
+ h = (r - g) / d + 4;
72
+ }
73
+ h /= 6;
74
+ }
75
+
76
+ return { h, s, l };
77
+ }
78
+
79
+ /**
80
+ * Converts an HSL color value to RGB. Conversion formula adapted from
81
+ * http://en.wikipedia.org/wiki/HSL_color_space. This function adapted
82
+ * from http://stackoverflow.com/a/9493060.
83
+ * Assumes h, s, and l are contained in the set [0, 1] and
84
+ * returns r, g, and b in the set [0, 255].
85
+ *
86
+ * @param Object hsl HSL as h, s, and l keys
87
+ * @return Object RGB as r, g, and b values
88
+ */
89
+ export function hsl2rgb(hsl) {
90
+ function hue2rgb(_p, _q, _t) {
91
+ let p = _p;
92
+ let q = _q;
93
+ let t = _t;
94
+ if (t < 0) t += 1;
95
+ if (t > 1) t -= 1;
96
+ if (t < 1 / 6) return p + (q - p) * 6 * t;
97
+ if (t < 1 / 2) return q;
98
+ if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
99
+ return p;
100
+ }
101
+
102
+ let h = hsl.h;
103
+ let s = hsl.s;
104
+ let l = hsl.l;
105
+ let r = 0;
106
+ let g = 0;
107
+ let b = 0;
108
+
109
+ if (s === 0) {
110
+ r = g = b = l; // achromatic
111
+ } else {
112
+ let q = l < 0.5 ? l * (1 + s) : l + s - l * s;
113
+ let p = 2 * l - q;
114
+ r = hue2rgb(p, q, h + 1 / 3);
115
+ g = hue2rgb(p, q, h);
116
+ b = hue2rgb(p, q, h - 1 / 3);
117
+ }
118
+
119
+ return {
120
+ r: Math.round(r * 255),
121
+ g: Math.round(g * 255),
122
+ b: Math.round(b * 255),
123
+ };
124
+ }
125
+
126
+ export function rgb2rgbString(rgb) {
127
+ return 'rgb(' + [rgb.r, rgb.g, rgb.b].join(',') + ')';
128
+ }
@@ -0,0 +1,26 @@
1
+ 'kiwi public';
2
+
3
+ export function extbanAccount(network) {
4
+ // Eg. InspIRCd-2.0
5
+ // Eg. UnrealIRCd-4.0.17
6
+ // Eg. ircd-seven-1.1.7
7
+ // Eg. u2.10.12.10+snircd(1.3.4a)
8
+ let ircdType = network.ircd.toLowerCase();
9
+
10
+ // Eg. ~,qjncrRa
11
+ // Eg. ,qjncrRa
12
+ let extban = network.ircClient.network.supports('EXTBAN') || '';
13
+ if (!extban) {
14
+ return '';
15
+ }
16
+
17
+ let prefix = extban.split(',')[0];
18
+ let type = 'a';
19
+
20
+ // https://docs.inspircd.org/3/modules/services_account/#extended-bans
21
+ if (ircdType.indexOf('inspircd') > -1) {
22
+ type = 'R';
23
+ }
24
+
25
+ return prefix + type;
26
+ }
@@ -0,0 +1,193 @@
1
+ 'kiwi public';
2
+
3
+ /** @module */
4
+
5
+ /* eslint-disable */
6
+ // http://www.myersdaily.org/joseph/javascript/md5-text.html
7
+
8
+ function md5cycle(x, k) {
9
+ var a = x[0], b = x[1], c = x[2], d = x[3];
10
+
11
+ a = ff(a, b, c, d, k[0], 7, -680876936);
12
+ d = ff(d, a, b, c, k[1], 12, -389564586);
13
+ c = ff(c, d, a, b, k[2], 17, 606105819);
14
+ b = ff(b, c, d, a, k[3], 22, -1044525330);
15
+ a = ff(a, b, c, d, k[4], 7, -176418897);
16
+ d = ff(d, a, b, c, k[5], 12, 1200080426);
17
+ c = ff(c, d, a, b, k[6], 17, -1473231341);
18
+ b = ff(b, c, d, a, k[7], 22, -45705983);
19
+ a = ff(a, b, c, d, k[8], 7, 1770035416);
20
+ d = ff(d, a, b, c, k[9], 12, -1958414417);
21
+ c = ff(c, d, a, b, k[10], 17, -42063);
22
+ b = ff(b, c, d, a, k[11], 22, -1990404162);
23
+ a = ff(a, b, c, d, k[12], 7, 1804603682);
24
+ d = ff(d, a, b, c, k[13], 12, -40341101);
25
+ c = ff(c, d, a, b, k[14], 17, -1502002290);
26
+ b = ff(b, c, d, a, k[15], 22, 1236535329);
27
+
28
+ a = gg(a, b, c, d, k[1], 5, -165796510);
29
+ d = gg(d, a, b, c, k[6], 9, -1069501632);
30
+ c = gg(c, d, a, b, k[11], 14, 643717713);
31
+ b = gg(b, c, d, a, k[0], 20, -373897302);
32
+ a = gg(a, b, c, d, k[5], 5, -701558691);
33
+ d = gg(d, a, b, c, k[10], 9, 38016083);
34
+ c = gg(c, d, a, b, k[15], 14, -660478335);
35
+ b = gg(b, c, d, a, k[4], 20, -405537848);
36
+ a = gg(a, b, c, d, k[9], 5, 568446438);
37
+ d = gg(d, a, b, c, k[14], 9, -1019803690);
38
+ c = gg(c, d, a, b, k[3], 14, -187363961);
39
+ b = gg(b, c, d, a, k[8], 20, 1163531501);
40
+ a = gg(a, b, c, d, k[13], 5, -1444681467);
41
+ d = gg(d, a, b, c, k[2], 9, -51403784);
42
+ c = gg(c, d, a, b, k[7], 14, 1735328473);
43
+ b = gg(b, c, d, a, k[12], 20, -1926607734);
44
+
45
+ a = hh(a, b, c, d, k[5], 4, -378558);
46
+ d = hh(d, a, b, c, k[8], 11, -2022574463);
47
+ c = hh(c, d, a, b, k[11], 16, 1839030562);
48
+ b = hh(b, c, d, a, k[14], 23, -35309556);
49
+ a = hh(a, b, c, d, k[1], 4, -1530992060);
50
+ d = hh(d, a, b, c, k[4], 11, 1272893353);
51
+ c = hh(c, d, a, b, k[7], 16, -155497632);
52
+ b = hh(b, c, d, a, k[10], 23, -1094730640);
53
+ a = hh(a, b, c, d, k[13], 4, 681279174);
54
+ d = hh(d, a, b, c, k[0], 11, -358537222);
55
+ c = hh(c, d, a, b, k[3], 16, -722521979);
56
+ b = hh(b, c, d, a, k[6], 23, 76029189);
57
+ a = hh(a, b, c, d, k[9], 4, -640364487);
58
+ d = hh(d, a, b, c, k[12], 11, -421815835);
59
+ c = hh(c, d, a, b, k[15], 16, 530742520);
60
+ b = hh(b, c, d, a, k[2], 23, -995338651);
61
+
62
+ a = ii(a, b, c, d, k[0], 6, -198630844);
63
+ d = ii(d, a, b, c, k[7], 10, 1126891415);
64
+ c = ii(c, d, a, b, k[14], 15, -1416354905);
65
+ b = ii(b, c, d, a, k[5], 21, -57434055);
66
+ a = ii(a, b, c, d, k[12], 6, 1700485571);
67
+ d = ii(d, a, b, c, k[3], 10, -1894986606);
68
+ c = ii(c, d, a, b, k[10], 15, -1051523);
69
+ b = ii(b, c, d, a, k[1], 21, -2054922799);
70
+ a = ii(a, b, c, d, k[8], 6, 1873313359);
71
+ d = ii(d, a, b, c, k[15], 10, -30611744);
72
+ c = ii(c, d, a, b, k[6], 15, -1560198380);
73
+ b = ii(b, c, d, a, k[13], 21, 1309151649);
74
+ a = ii(a, b, c, d, k[4], 6, -145523070);
75
+ d = ii(d, a, b, c, k[11], 10, -1120210379);
76
+ c = ii(c, d, a, b, k[2], 15, 718787259);
77
+ b = ii(b, c, d, a, k[9], 21, -343485551);
78
+
79
+ x[0] = add32(a, x[0]);
80
+ x[1] = add32(b, x[1]);
81
+ x[2] = add32(c, x[2]);
82
+ x[3] = add32(d, x[3]);
83
+
84
+ }
85
+
86
+ function cmn(q, a, b, x, s, t) {
87
+ a = add32(add32(a, q), add32(x, t));
88
+ return add32((a << s) | (a >>> (32 - s)), b);
89
+ }
90
+
91
+ function ff(a, b, c, d, x, s, t) {
92
+ return cmn((b & c) | ((~b) & d), a, b, x, s, t);
93
+ }
94
+
95
+ function gg(a, b, c, d, x, s, t) {
96
+ return cmn((b & d) | (c & (~d)), a, b, x, s, t);
97
+ }
98
+
99
+ function hh(a, b, c, d, x, s, t) {
100
+ return cmn(b ^ c ^ d, a, b, x, s, t);
101
+ }
102
+
103
+ function ii(a, b, c, d, x, s, t) {
104
+ return cmn(c ^ (b | (~d)), a, b, x, s, t);
105
+ }
106
+
107
+ function md51(s) {
108
+ //txt = '';
109
+ var n = s.length,
110
+ state = [1732584193, -271733879, -1732584194, 271733878], i;
111
+ for (i=64; i<=s.length; i+=64) {
112
+ md5cycle(state, md5blk(s.substring(i-64, i)));
113
+ }
114
+ s = s.substring(i-64);
115
+ var tail = [0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0];
116
+ for (i=0; i<s.length; i++)
117
+ tail[i>>2] |= s.charCodeAt(i) << ((i%4) << 3);
118
+ tail[i>>2] |= 0x80 << ((i%4) << 3);
119
+ if (i > 55) {
120
+ md5cycle(state, tail);
121
+ for (i=0; i<16; i++) tail[i] = 0;
122
+ }
123
+ tail[14] = n*8;
124
+ md5cycle(state, tail);
125
+ return state;
126
+ }
127
+
128
+ /* there needs to be support for Unicode here,
129
+ * unless we pretend that we can redefine the MD-5
130
+ * algorithm for multi-byte characters (perhaps
131
+ * by adding every four 16-bit characters and
132
+ * shortening the sum to 32 bits). Otherwise
133
+ * I suggest performing MD-5 as if every character
134
+ * was two bytes--e.g., 0040 0025 = @%--but then
135
+ * how will an ordinary MD-5 sum be matched?
136
+ * There is no way to standardize text to something
137
+ * like UTF-8 before transformation; speed cost is
138
+ * utterly prohibitive. The JavaScript standard
139
+ * itself needs to look at this: it should start
140
+ * providing access to strings as preformed UTF-8
141
+ * 8-bit unsigned value arrays.
142
+ */
143
+ function md5blk(s) { /* I figured global was faster. */
144
+ var md5blks = [], i; /* Andy King said do it this way. */
145
+ for (i=0; i<64; i+=4) {
146
+ md5blks[i>>2] = s.charCodeAt(i)
147
+ + (s.charCodeAt(i+1) << 8)
148
+ + (s.charCodeAt(i+2) << 16)
149
+ + (s.charCodeAt(i+3) << 24);
150
+ }
151
+ return md5blks;
152
+ }
153
+
154
+ var hex_chr = '0123456789abcdef'.split('');
155
+
156
+ function rhex(n){
157
+ var s='', j=0;
158
+ for(; j<4; j++)
159
+ s += hex_chr[(n >> (j * 8 + 4)) & 0x0F]
160
+ + hex_chr[(n >> (j * 8)) & 0x0F];
161
+ return s;
162
+ }
163
+
164
+ function hex(x) {
165
+ for (var i=0; i<x.length; i++)
166
+ x[i] = rhex(x[i]);
167
+ return x.join('');
168
+ }
169
+
170
+ function md5(s) {
171
+ return hex(md51(s));
172
+ }
173
+
174
+ /* this function is much faster,
175
+ so if possible we use it. Some IEs
176
+ are the only ones I know of that
177
+ need the idiotic second function,
178
+ generated by an if clause. */
179
+
180
+ function add32(a, b) {
181
+ return (a + b) & 0xFFFFFFFF;
182
+ }
183
+
184
+ if (md5('hello') != '5d41402abc4b2a76b9719d911017c592') {
185
+ function add32(x, y) {
186
+ var lsw = (x & 0xFFFF) + (y & 0xFFFF),
187
+ msw = (x >> 16) + (y >> 16) + (lsw >> 16);
188
+ return (msw << 16) | (lsw & 0xFFFF);
189
+ }
190
+ }
191
+
192
+
193
+ export {md5};