serverless-ircd 0.6.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 (247) hide show
  1. package/.github/workflows/ci.yml +6 -1
  2. package/.gitmodules +3 -0
  3. package/CHANGELOG.md +214 -0
  4. package/README.md +110 -23
  5. package/apps/aws-stack/package.json +1 -1
  6. package/apps/cf-tcp-container/package.json +1 -1
  7. package/apps/cf-worker/package.json +1 -1
  8. package/apps/cf-worker/src/origin-allowlist.ts +99 -0
  9. package/apps/cf-worker/src/worker.ts +89 -9
  10. package/apps/cf-worker/tests/fixtures/web-dist/app/index.html +18 -0
  11. package/apps/cf-worker/tests/fixtures/web-dist/index.html +18 -0
  12. package/apps/cf-worker/tests/origin-allowlist.test.ts +101 -0
  13. package/apps/cf-worker/tests/smoke.test.ts +28 -2
  14. package/apps/cf-worker/tests/ws-origin.test.ts +89 -0
  15. package/apps/cf-worker/wrangler.test.toml +23 -0
  16. package/apps/cf-worker/wrangler.toml +54 -0
  17. package/apps/local-cli/package.json +1 -1
  18. package/apps/web/landing/index.html +217 -0
  19. package/apps/web/package.json +28 -0
  20. package/apps/web/scripts/build.mjs +125 -0
  21. package/apps/web/src/build-env.ts +43 -0
  22. package/apps/web/src/config-schema.ts +138 -0
  23. package/apps/web/static/config.json +28 -0
  24. package/apps/web/static/config.prod.json +28 -0
  25. package/apps/web/static/config.staging.json +28 -0
  26. package/apps/web/tests/build-env.test.ts +63 -0
  27. package/apps/web/tests/build-smoke.test.ts +103 -0
  28. package/apps/web/tests/config-schema.test.ts +432 -0
  29. package/apps/web/tests/workspace.test.ts +12 -0
  30. package/apps/web/tsconfig.json +10 -0
  31. package/apps/web/upstream/.browserslistrc +3 -0
  32. package/apps/web/upstream/.editorconfig +9 -0
  33. package/apps/web/upstream/.eslintignore +3 -0
  34. package/apps/web/upstream/.eslintrc.js +90 -0
  35. package/apps/web/upstream/.github/FUNDING.yml +12 -0
  36. package/apps/web/upstream/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
  37. package/apps/web/upstream/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  38. package/apps/web/upstream/.github/workflows/push.yml +26 -0
  39. package/apps/web/upstream/.github/workflows/release.yml +33 -0
  40. package/apps/web/upstream/.github/workflows/release_manual.yml +55 -0
  41. package/apps/web/upstream/.prettierrc.js +9 -0
  42. package/apps/web/upstream/.stylelintignore +5 -0
  43. package/apps/web/upstream/.stylelintrc.js +21 -0
  44. package/apps/web/upstream/LICENSE +201 -0
  45. package/apps/web/upstream/README.md +76 -0
  46. package/apps/web/upstream/babel.config.js +25 -0
  47. package/apps/web/upstream/crowdin.yml +3 -0
  48. package/apps/web/upstream/index.html +35 -0
  49. package/apps/web/upstream/jest.config.js +7 -0
  50. package/apps/web/upstream/jsdoc.json +22 -0
  51. package/apps/web/upstream/package.json +80 -0
  52. package/apps/web/upstream/scripts/pre-commit +43 -0
  53. package/apps/web/upstream/src/components/App.vue +516 -0
  54. package/apps/web/upstream/src/components/AppSettings.vue +587 -0
  55. package/apps/web/upstream/src/components/AutoComplete.vue +284 -0
  56. package/apps/web/upstream/src/components/Avatar.vue +105 -0
  57. package/apps/web/upstream/src/components/AwayStatusIndicator.vue +77 -0
  58. package/apps/web/upstream/src/components/BufferKey.vue +121 -0
  59. package/apps/web/upstream/src/components/BufferSettings.vue +97 -0
  60. package/apps/web/upstream/src/components/Captcha.vue +85 -0
  61. package/apps/web/upstream/src/components/ChannelBanlist.vue +96 -0
  62. package/apps/web/upstream/src/components/ChannelInfo.vue +159 -0
  63. package/apps/web/upstream/src/components/ChannelInvitelist.vue +276 -0
  64. package/apps/web/upstream/src/components/ChannelList.vue +345 -0
  65. package/apps/web/upstream/src/components/Container.vue +401 -0
  66. package/apps/web/upstream/src/components/ContainerHeader.vue +522 -0
  67. package/apps/web/upstream/src/components/ControlInput.vue +1016 -0
  68. package/apps/web/upstream/src/components/LoadingAnimation.vue +104 -0
  69. package/apps/web/upstream/src/components/MediaViewer.vue +199 -0
  70. package/apps/web/upstream/src/components/MessageInfo.vue +192 -0
  71. package/apps/web/upstream/src/components/MessageList.vue +1028 -0
  72. package/apps/web/upstream/src/components/MessageListAvatar.vue +20 -0
  73. package/apps/web/upstream/src/components/MessageListMessageCompact.vue +361 -0
  74. package/apps/web/upstream/src/components/MessageListMessageInline.vue +257 -0
  75. package/apps/web/upstream/src/components/MessageListMessageModern.vue +430 -0
  76. package/apps/web/upstream/src/components/NetworkSettings.vue +528 -0
  77. package/apps/web/upstream/src/components/Nicklist.vue +309 -0
  78. package/apps/web/upstream/src/components/NicklistUser.vue +181 -0
  79. package/apps/web/upstream/src/components/NotConnected.vue +271 -0
  80. package/apps/web/upstream/src/components/SelfUser.vue +283 -0
  81. package/apps/web/upstream/src/components/ServerSelector.vue +162 -0
  82. package/apps/web/upstream/src/components/ServerView.vue +126 -0
  83. package/apps/web/upstream/src/components/SettingsAdvanced.vue +232 -0
  84. package/apps/web/upstream/src/components/SettingsAliases.vue +121 -0
  85. package/apps/web/upstream/src/components/Sidebar.vue +429 -0
  86. package/apps/web/upstream/src/components/SidebarAboutBuffer.vue +288 -0
  87. package/apps/web/upstream/src/components/SidebarState.vue +145 -0
  88. package/apps/web/upstream/src/components/StartupError.vue +35 -0
  89. package/apps/web/upstream/src/components/StateBrowser.vue +420 -0
  90. package/apps/web/upstream/src/components/StateBrowserBuffer.vue +124 -0
  91. package/apps/web/upstream/src/components/StateBrowserNetwork.vue +823 -0
  92. package/apps/web/upstream/src/components/StateBrowserUsermenu.vue +162 -0
  93. package/apps/web/upstream/src/components/TypingStatusIndicator.vue +34 -0
  94. package/apps/web/upstream/src/components/TypingUsersList.vue +56 -0
  95. package/apps/web/upstream/src/components/UrlEmbed.vue +149 -0
  96. package/apps/web/upstream/src/components/UserBox.vue +728 -0
  97. package/apps/web/upstream/src/components/inputtools/Emoji.vue +67 -0
  98. package/apps/web/upstream/src/components/inputtools/TextStyle.vue +142 -0
  99. package/apps/web/upstream/src/components/startups/CommonLayout.vue +208 -0
  100. package/apps/web/upstream/src/components/startups/CustomServer.vue +495 -0
  101. package/apps/web/upstream/src/components/startups/KiwiBnc.vue +361 -0
  102. package/apps/web/upstream/src/components/startups/Personal.vue +317 -0
  103. package/apps/web/upstream/src/components/startups/Welcome.vue +544 -0
  104. package/apps/web/upstream/src/components/startups/ZncLogin.vue +229 -0
  105. package/apps/web/upstream/src/components/utils/InputConfirm.vue +68 -0
  106. package/apps/web/upstream/src/components/utils/InputPrompt.vue +118 -0
  107. package/apps/web/upstream/src/components/utils/InputText.vue +172 -0
  108. package/apps/web/upstream/src/components/utils/IrcInput.vue +579 -0
  109. package/apps/web/upstream/src/components/utils/PluginWrapper.vue +26 -0
  110. package/apps/web/upstream/src/components/utils/TabbedView.vue +149 -0
  111. package/apps/web/upstream/src/components/utils/TransitionExpand.vue +97 -0
  112. package/apps/web/upstream/src/helpers/Colours.js +128 -0
  113. package/apps/web/upstream/src/helpers/IrcdDiffs.js +26 -0
  114. package/apps/web/upstream/src/helpers/Md5.js +193 -0
  115. package/apps/web/upstream/src/helpers/Misc.js +401 -0
  116. package/apps/web/upstream/src/helpers/TextFormatting.js +237 -0
  117. package/apps/web/upstream/src/libs/AliasRewriter.js +157 -0
  118. package/apps/web/upstream/src/libs/AudioManager.js +60 -0
  119. package/apps/web/upstream/src/libs/BouncerMiddleware.js +247 -0
  120. package/apps/web/upstream/src/libs/BouncerProvider.js +551 -0
  121. package/apps/web/upstream/src/libs/ChathistoryMiddleware.js +153 -0
  122. package/apps/web/upstream/src/libs/ConfigLoader.js +94 -0
  123. package/apps/web/upstream/src/libs/EmojiProvider.js +46 -0
  124. package/apps/web/upstream/src/libs/GlobalApi.js +346 -0
  125. package/apps/web/upstream/src/libs/IPC.js +51 -0
  126. package/apps/web/upstream/src/libs/InputHandler.js +921 -0
  127. package/apps/web/upstream/src/libs/IrcClient.js +1506 -0
  128. package/apps/web/upstream/src/libs/Logger.js +71 -0
  129. package/apps/web/upstream/src/libs/Message.js +169 -0
  130. package/apps/web/upstream/src/libs/MessageFormatter.js +364 -0
  131. package/apps/web/upstream/src/libs/MessageParser.js +249 -0
  132. package/apps/web/upstream/src/libs/Notifications.js +78 -0
  133. package/apps/web/upstream/src/libs/ServerConnection.js +270 -0
  134. package/apps/web/upstream/src/libs/ServerSession.js +102 -0
  135. package/apps/web/upstream/src/libs/SoundBleep.js +20 -0
  136. package/apps/web/upstream/src/libs/StatePersistence.js +90 -0
  137. package/apps/web/upstream/src/libs/ThemeManager.js +128 -0
  138. package/apps/web/upstream/src/libs/TypingMiddleware.js +105 -0
  139. package/apps/web/upstream/src/libs/WindowTitle.js +63 -0
  140. package/apps/web/upstream/src/libs/batchedAdd.js +74 -0
  141. package/apps/web/upstream/src/libs/bufferTools.js +177 -0
  142. package/apps/web/upstream/src/libs/polyfill/Element.closest.js +18 -0
  143. package/apps/web/upstream/src/libs/renderers/Html.js +113 -0
  144. package/apps/web/upstream/src/libs/settingTools.js +31 -0
  145. package/apps/web/upstream/src/libs/state/BufferState.js +703 -0
  146. package/apps/web/upstream/src/libs/state/NetworkState.js +158 -0
  147. package/apps/web/upstream/src/libs/state/UserState.js +89 -0
  148. package/apps/web/upstream/src/libs/state/common.js +26 -0
  149. package/apps/web/upstream/src/libs/state.js +961 -0
  150. package/apps/web/upstream/src/libs/storage/Local.js +51 -0
  151. package/apps/web/upstream/src/main.js +566 -0
  152. package/apps/web/upstream/src/res/autocompleteCommands.js +31 -0
  153. package/apps/web/upstream/src/res/configTemplates.js +373 -0
  154. package/apps/web/upstream/src/res/globalStyle.css +277 -0
  155. package/apps/web/upstream/src/res/kiwiLoadingLogo.png +0 -0
  156. package/apps/web/upstream/src/res/locales/app.af-ZA.po +1145 -0
  157. package/apps/web/upstream/src/res/locales/app.ar-SA.po +1145 -0
  158. package/apps/web/upstream/src/res/locales/app.bg-BG.po +1145 -0
  159. package/apps/web/upstream/src/res/locales/app.bs-BA.po +1145 -0
  160. package/apps/web/upstream/src/res/locales/app.ca-ES.po +1145 -0
  161. package/apps/web/upstream/src/res/locales/app.cs-CZ.po +1145 -0
  162. package/apps/web/upstream/src/res/locales/app.da-DK.po +1145 -0
  163. package/apps/web/upstream/src/res/locales/app.de-DE.po +1145 -0
  164. package/apps/web/upstream/src/res/locales/app.dev.po +1246 -0
  165. package/apps/web/upstream/src/res/locales/app.el-GR.po +1145 -0
  166. package/apps/web/upstream/src/res/locales/app.en-US.po +1145 -0
  167. package/apps/web/upstream/src/res/locales/app.es-419.po +1145 -0
  168. package/apps/web/upstream/src/res/locales/app.es-AR.po +1145 -0
  169. package/apps/web/upstream/src/res/locales/app.es-EM.po +536 -0
  170. package/apps/web/upstream/src/res/locales/app.es-ES.po +1145 -0
  171. package/apps/web/upstream/src/res/locales/app.es-US.po +1145 -0
  172. package/apps/web/upstream/src/res/locales/app.eu-ES.po +1145 -0
  173. package/apps/web/upstream/src/res/locales/app.fi-FI.po +1145 -0
  174. package/apps/web/upstream/src/res/locales/app.fr-FR.po +1145 -0
  175. package/apps/web/upstream/src/res/locales/app.gl-ES.po +1145 -0
  176. package/apps/web/upstream/src/res/locales/app.he-IL.po +1145 -0
  177. package/apps/web/upstream/src/res/locales/app.hi-IN.po +1145 -0
  178. package/apps/web/upstream/src/res/locales/app.hu-HU.po +1145 -0
  179. package/apps/web/upstream/src/res/locales/app.id-ID.po +1145 -0
  180. package/apps/web/upstream/src/res/locales/app.it-IT.po +1145 -0
  181. package/apps/web/upstream/src/res/locales/app.ja-JP.po +1145 -0
  182. package/apps/web/upstream/src/res/locales/app.ko-KR.po +1145 -0
  183. package/apps/web/upstream/src/res/locales/app.nl-NL.po +1145 -0
  184. package/apps/web/upstream/src/res/locales/app.no-NO.po +1145 -0
  185. package/apps/web/upstream/src/res/locales/app.pl-PL.po +1145 -0
  186. package/apps/web/upstream/src/res/locales/app.pt-BR.po +1145 -0
  187. package/apps/web/upstream/src/res/locales/app.pt-PT.po +1145 -0
  188. package/apps/web/upstream/src/res/locales/app.ro-RO.po +1145 -0
  189. package/apps/web/upstream/src/res/locales/app.ru-RU.po +1145 -0
  190. package/apps/web/upstream/src/res/locales/app.sl-SI.po +1145 -0
  191. package/apps/web/upstream/src/res/locales/app.sq-AL.po +1145 -0
  192. package/apps/web/upstream/src/res/locales/app.sr-SP.po +1145 -0
  193. package/apps/web/upstream/src/res/locales/app.sv-SE.po +1145 -0
  194. package/apps/web/upstream/src/res/locales/app.tr-TR.po +1145 -0
  195. package/apps/web/upstream/src/res/locales/app.uk-UA.po +1145 -0
  196. package/apps/web/upstream/src/res/locales/app.vi-VN.po +1145 -0
  197. package/apps/web/upstream/src/res/locales/app.zh-CN.po +1145 -0
  198. package/apps/web/upstream/src/res/locales/app.zh-TW.po +1145 -0
  199. package/apps/web/upstream/src/res/localesList.json +27 -0
  200. package/apps/web/upstream/src/res/logo.png +0 -0
  201. package/apps/web/upstream/src/thirdparty/about.html +43 -0
  202. package/apps/web/upstream/src/thirdparty/index.js +5 -0
  203. package/apps/web/upstream/src/thirdparty/kiwiirccom.vue +185 -0
  204. package/apps/web/upstream/static/config.json +28 -0
  205. package/apps/web/upstream/static/emoticons/smile.png +0 -0
  206. package/apps/web/upstream/static/favicon.png +0 -0
  207. package/apps/web/upstream/static/highlight.mp3 +0 -0
  208. package/apps/web/upstream/static/highlight.ogg +0 -0
  209. package/apps/web/upstream/static/locales/.gitignore +2 -0
  210. package/apps/web/upstream/static/plugins/customise.html.example +10 -0
  211. package/apps/web/upstream/static/themes/coffee/theme.css +145 -0
  212. package/apps/web/upstream/static/themes/common/base.css +1064 -0
  213. package/apps/web/upstream/static/themes/dark/theme.css +196 -0
  214. package/apps/web/upstream/static/themes/default/theme.css +92 -0
  215. package/apps/web/upstream/static/themes/elite/theme.css +248 -0
  216. package/apps/web/upstream/static/themes/grayfox/theme.css +143 -0
  217. package/apps/web/upstream/static/themes/nightswatch/theme.css +367 -0
  218. package/apps/web/upstream/static/themes/osprey/theme.css +115 -0
  219. package/apps/web/upstream/static/themes/radioactive/theme.css +1211 -0
  220. package/apps/web/upstream/static/themes/sky/theme.css +107 -0
  221. package/apps/web/upstream/tests/unit/BatchAdd.spec.js +174 -0
  222. package/apps/web/upstream/tests/unit/MessageParser.spec.js +125 -0
  223. package/apps/web/upstream/tests/unit/Misc.spec.js +24 -0
  224. package/apps/web/upstream/tests/unit/NetworkState.spec.js +58 -0
  225. package/apps/web/upstream/tests/unit/StartupError.spec.js +20 -0
  226. package/apps/web/upstream/vue.config.js +150 -0
  227. package/apps/web/upstream/yarn.lock +9767 -0
  228. package/apps/web/vitest.config.ts +13 -0
  229. package/biome.json +1 -0
  230. package/docs/Home.md +1 -0
  231. package/docs/WebClientGuide.md +535 -0
  232. package/package.json +2 -2
  233. package/packages/aws-adapter/package.json +1 -1
  234. package/packages/cf-adapter/package.json +1 -1
  235. package/packages/cf-adapter/tests/cf-harness.ts +12 -1
  236. package/packages/in-memory-runtime/package.json +1 -1
  237. package/packages/irc-core/package.json +1 -1
  238. package/packages/irc-core/reports/mutation/mutation.html +342 -0
  239. package/packages/irc-core/tests/batch.test.ts +15 -0
  240. package/packages/irc-core/tests/numerics.test.ts +13 -0
  241. package/packages/irc-core/tests/parser.test.ts +109 -0
  242. package/packages/irc-server/package.json +1 -1
  243. package/packages/irc-test-support/package.json +1 -1
  244. package/packages/irc-test-support/src/scenarios.ts +24 -2
  245. package/tools/ci-hardening/package.json +1 -1
  246. package/tools/load-test/package.json +1 -1
  247. package/tools/tcp-ws-forwarder/package.json +1 -1
@@ -0,0 +1,85 @@
1
+ <template>
2
+ <div>
3
+ <div v-if="showCaptcha" ref="captchacontainer" />
4
+ </div>
5
+ </template>
6
+
7
+ <script>
8
+
9
+ 'kiwi public';
10
+
11
+ export default {
12
+ props: ['network'],
13
+ data() {
14
+ return {
15
+ recaptchaUrl: '',
16
+ recaptchaSiteId: '',
17
+ recaptchaResponse: '',
18
+ showCaptcha: false,
19
+ };
20
+ },
21
+ created() {
22
+ let options = this.$state.settings.startupOptions;
23
+ this.recaptchaSiteId = options.recaptchaSiteId || '';
24
+ this.recaptchaUrl = options.recaptchaUrl || 'https://www.google.com/recaptcha/api.js';
25
+
26
+ this.listen(this.$state, 'network.connecting', (event) => {
27
+ event.network.ircClient.once('socket connected', () => {
28
+ if (this.recaptchaResponse) {
29
+ event.network.ircClient.raw('CAPTCHA', this.recaptchaResponse);
30
+ }
31
+ });
32
+ });
33
+
34
+ this.listen(this.$state, 'irc.raw.CAPTCHA', (command, event, network) => {
35
+ if (network !== this.network) {
36
+ return;
37
+ }
38
+
39
+ if (event.params[0] === 'NEEDED') {
40
+ this.loadRecaptcha();
41
+ }
42
+ });
43
+ },
44
+ methods: {
45
+ loadRecaptcha() {
46
+ if (window.grecaptcha) {
47
+ this.recaptchaShow();
48
+ return;
49
+ }
50
+
51
+ // Recaptcha calls this callback once it's loaded and ready to be used
52
+ window.recaptchaLoaded = () => {
53
+ this.recaptchaShow();
54
+ };
55
+
56
+ let scr = document.createElement('script');
57
+ scr.src = this.recaptchaUrl + '?onload=recaptchaLoaded&render=explicit';
58
+ scr.defer = true;
59
+ document.head.appendChild(scr);
60
+ },
61
+ recaptchaShow() {
62
+ this.showCaptcha = true;
63
+ this.$nextTick(() => {
64
+ window.grecaptcha.render(this.$refs.captchacontainer, {
65
+ 'sitekey': this.recaptchaSiteId,
66
+ 'callback': this.recaptchaSuccess,
67
+ 'expired-callback': this.recaptchaExpired,
68
+ });
69
+ });
70
+ },
71
+ recaptchaSuccess(response) {
72
+ this.recaptchaResponse = response;
73
+
74
+ // If we have a network instance already, send the captcha response
75
+ if (this.network && this.network.state === 'connecting') {
76
+ this.network.ircClient.raw('CAPTCHA', response);
77
+ }
78
+ this.showCaptcha = false;
79
+ },
80
+ recaptchaExpired() {
81
+ this.recaptchaResponse = '';
82
+ },
83
+ },
84
+ };
85
+ </script>
@@ -0,0 +1,96 @@
1
+ <template>
2
+ <div class="kiwi-channelbanlist">
3
+ <form class="u-form kiwi-channelbanlist" @submit.prevent="">
4
+ <a class="u-link" @click="updateBanlist">{{ $t('bans_refresh') }}</a>
5
+
6
+ <table v-if="banlist.length > 0" class="kiwi-channelbanlist-table">
7
+ <tr>
8
+ <th>{{ $t('bans_user') }}</th>
9
+ <th />
10
+ <th />
11
+ </tr>
12
+ <tr v-for="ban in banlist" :key="ban.banned" :title="'By ' + ban.banned_by">
13
+ <td class="kiwi-channelbanlist-table-mask">{{ ban.banned }}</td>
14
+ <td class="kiwi-channelbanlist-table-bannedat">
15
+ {{ (new Date(ban.banned_at * 1000)).toDateString() }}
16
+ </td>
17
+ <td class="kiwi-channelbanlist-table-actions">
18
+ <i class="fa fa-trash" aria-hidden="true" @click="removeBan(ban.banned)" />
19
+ </td>
20
+ </tr>
21
+ </table>
22
+ <div v-else-if="is_refreshing">
23
+ {{ $t('bans_refreshing') }}
24
+ </div>
25
+ <div v-else class="kiwi-channelbanlist-empty">
26
+ {{ $t('bans_nobody') }}
27
+ </div>
28
+ </form>
29
+ </div>
30
+ </template>
31
+
32
+ <script>
33
+ 'kiwi public';
34
+
35
+ export default {
36
+ props: ['buffer'],
37
+ data: function data() {
38
+ return {
39
+ banlist: [],
40
+ is_refreshing: false,
41
+ };
42
+ },
43
+ created: function created() {
44
+ this.updateBanlist();
45
+ },
46
+ methods: {
47
+ updateBanlist: function updateBanlist() {
48
+ if (this.buffer.getNetwork().state !== 'connected' || this.is_refreshing) {
49
+ return;
50
+ }
51
+
52
+ let channelName = this.buffer.name;
53
+ this.is_refreshing = true;
54
+ this.buffer.getNetwork().ircClient.banlist(channelName, (banEvent) => {
55
+ this.banlist = banEvent.bans;
56
+ this.is_refreshing = false;
57
+ });
58
+ },
59
+ removeBan: function removeBan(mask) {
60
+ let channelName = this.buffer.name;
61
+ this.buffer.getNetwork().ircClient.unban(channelName, mask);
62
+ this.banlist = this.banlist.filter((ban) => ban.banned !== mask);
63
+ },
64
+ },
65
+ };
66
+ </script>
67
+
68
+ <style lang="less">
69
+ .kiwi-channelbanlist-table {
70
+ width: 100%;
71
+ border-collapse: collapse;
72
+ line-height: 20px;
73
+ margin-top: 10px;
74
+ }
75
+
76
+ .kiwi-channelbanlist-table tr {
77
+ border-bottom: 1px solid;
78
+ }
79
+
80
+ .kiwi-channelbanlist-table-mask {
81
+ word-break: break-all;
82
+ }
83
+
84
+ .kiwi-channelbanlist-table-bannedat {
85
+ min-width: 150px;
86
+ }
87
+
88
+ .kiwi-channelbanlist-table-actions {
89
+ min-width: 50px;
90
+ text-align: center;
91
+ cursor: pointer;
92
+ position: relative;
93
+ transition: all 0.3s;
94
+ z-index: 1;
95
+ }
96
+ </style>
@@ -0,0 +1,159 @@
1
+ <template>
2
+ <div class="kiwi-channelinfo">
3
+ <form class="u-form kiwi-channelinfo-basicmodes" @submit.prevent="">
4
+ <label class="kiwi-channelinfo-topic">
5
+ <span>{{ $t('channel_topic') }}</span>
6
+ <textarea v-model.lazy="topic" rows="2" />
7
+ </label>
8
+
9
+ <div v-if="buffer.topics.length > 1" class="kiwi-channelinfo-previoustopics">
10
+ <a class="u-link" @click="showPrevTopics = !showPrevTopics">
11
+ Previous topics
12
+ <i :class="'fa fa-caret-' + (showPrevTopics ? 'up' : 'down')" />
13
+ </a>
14
+ <ul v-if="showPrevTopics">
15
+ <li v-for="(topicText, idx) in prevTopics" :key="idx">
16
+ <span>{{ topicText.trim() }}</span>
17
+ </li>
18
+ </ul>
19
+ </div>
20
+
21
+ <label class="u-checkbox-wrapper">
22
+ <span>{{ $t('channel_moderated') }}</span>
23
+ <input v-model="modeM" type="checkbox">
24
+ </label>
25
+ <label class="u-checkbox-wrapper">
26
+ <span>{{ $t('channel_invite') }}</span>
27
+ <input v-model="modeI" type="checkbox">
28
+ </label>
29
+ <label class="u-checkbox-wrapper">
30
+ <span>{{ $t('channel_secret') }}</span>
31
+ <input v-model="modeS" type="checkbox">
32
+ </label>
33
+ <label class="u-checkbox-wrapper">
34
+ <span>{{ $t('channel_moderated_topic') }}</span>
35
+ <input v-model="modeT" type="checkbox">
36
+ </label>
37
+ <label class="u-checkbox-wrapper">
38
+ <span>{{ $t('channel_external') }}</span>
39
+ <input v-model="modeN" type="checkbox">
40
+ </label>
41
+ <label>
42
+ <span>{{ $t('password') }}</span>
43
+ <input v-model.lazy="modeK" type="text" class="u-input">
44
+ </label>
45
+ </form>
46
+ </div>
47
+ </template>
48
+
49
+ <script>
50
+ 'kiwi public';
51
+
52
+ // Helper to generate Vues computed methods for simple channel modes.
53
+ // Eg. +i, +n, etc
54
+ function generateComputedMode(mode) {
55
+ return {
56
+ get: function computedModeGet() {
57
+ return this.modeVal(mode);
58
+ },
59
+ set: function computedModeSet(newVal) {
60
+ return this.setMode((newVal ? '+' : '-') + mode);
61
+ },
62
+ };
63
+ }
64
+
65
+ // Helper to generate Vues computed methods for channel modes with a parameter
66
+ // Eg. "+k key"
67
+ function generateComputedModeWithParam(mode) {
68
+ return {
69
+ get: function computedModeWithParamGet() {
70
+ let val = this.modeVal(mode);
71
+ return val === false ?
72
+ '' :
73
+ val;
74
+ },
75
+ set: function computedModeWithParamSet(newVal) {
76
+ if (newVal) {
77
+ this.setMode('+' + mode, newVal);
78
+ } else {
79
+ this.setMode('-' + mode, this.modeVal(mode));
80
+ }
81
+ },
82
+ };
83
+ }
84
+
85
+ export default {
86
+ props: ['buffer'],
87
+ data: function data() {
88
+ return {
89
+ showPrevTopics: false,
90
+ };
91
+ },
92
+ computed: {
93
+ modeM: generateComputedMode('m'),
94
+ modeI: generateComputedMode('i'),
95
+ modeS: generateComputedMode('s'),
96
+ modeT: generateComputedMode('t'),
97
+ modeN: generateComputedMode('n'),
98
+ modeK: generateComputedModeWithParam('k'),
99
+ topic: {
100
+ get: function computedTopicGet() {
101
+ return this.buffer.topic;
102
+ },
103
+ set: function computedTopicSet(newVal) {
104
+ let newTopic = newVal.replace('\n', ' ');
105
+ // TODO: Update irc-framework to insert a trailing : if the last argument is an
106
+ // empty string. The trailing : makes a difference between things like
107
+ // requesting a topic and changing to an empty topic
108
+ if (!newTopic.trim()) {
109
+ this.buffer.getNetwork().ircClient.raw(`TOPIC ${this.buffer.name} :`);
110
+ } else {
111
+ this.buffer.getNetwork().ircClient.setTopic(this.buffer.name, newTopic);
112
+ }
113
+ },
114
+ },
115
+ prevTopics() {
116
+ return this.buffer.topics.filter((topic) => topic.trim());
117
+ },
118
+ },
119
+ methods: {
120
+ updateBanList: function updateBanList() {
121
+ this.buffer.getNetwork().ircClient.raw('MODE', this.buffer.name, '+b');
122
+ },
123
+ setMode: function setMode(mode, param) {
124
+ this.buffer.getNetwork().ircClient.raw('MODE', this.buffer.name, mode, param);
125
+ },
126
+ modeVal: function modeVal(mode) {
127
+ let val = false;
128
+
129
+ if (typeof this.buffer.modes[mode] === 'undefined') {
130
+ // Specifically undefined = mode not set
131
+ val = false;
132
+ } else if (!this.buffer.modes[mode]) {
133
+ // Falsy value = mode set without value
134
+ val = true;
135
+ } else {
136
+ // Anything else = mode set with a value
137
+ val = this.buffer.modes[mode];
138
+ }
139
+
140
+ return val;
141
+ },
142
+ areWeAnOp: function areWeAnOp() {
143
+ return this.buffer.isUserAnOp(this.buffer.getNetwork().nick);
144
+ },
145
+ },
146
+ };
147
+ </script>
148
+
149
+ <style>
150
+
151
+ .kiwi-channelinfo-previoustopics {
152
+ margin: 0 10px 15px 10px;
153
+ }
154
+
155
+ .kiwi-channelinfo-previoustopics ul {
156
+ margin-top: 0;
157
+ }
158
+
159
+ </style>
@@ -0,0 +1,276 @@
1
+ <template>
2
+ <div class="kiwi-invitelist">
3
+ <form class="u-form kiwi-invitelist" @submit.prevent="">
4
+ <a class="u-link" @click="updateInvitelist">{{ $t('invites_refresh') }}</a>
5
+
6
+ <div v-if="!channelIsInviteOnly" class="kiwi-invitelist-inviteonly-status">
7
+ {{ $t('invite_public_channel') }}
8
+ <a
9
+ v-if="areWeAnOp"
10
+ class="u-link"
11
+ @click="setInviteOnly"
12
+ >{{ $t('invite_set_private') }}</a>
13
+ </div>
14
+ <div v-else class="kiwi-invitelist-inviteonly-status">
15
+ {{ $t('invite_private_channel') }}
16
+ <a
17
+ v-if="areWeAnOp"
18
+ class="u-link"
19
+ @click="removeInviteOnly"
20
+ >{{ $t('invite_set_public') }}</a>
21
+ </div>
22
+
23
+ <span v-if="anyRegisteredUserCanJoin">{{ $t('invite_registered_only') }}</span>
24
+
25
+ <div>
26
+ <div v-if="supportsAccounts && areWeAnOp">
27
+ <template v-if="knownAccounts.length > 0">
28
+ <select ref="addInviteList">
29
+ <option
30
+ v-for="user in knownAccounts"
31
+ :key="user.key" :value="user.account"
32
+ >{{ user.account }}</option>
33
+ </select>
34
+ <button type="button" @click="addAccountInvite($refs.addInviteList.value)">
35
+ {{ $t('invite_add_invite') }}
36
+ </button>
37
+ </template>
38
+ </div>
39
+ <div v-if="!supportsAccounts && areWeAnOp" class="kiwi-invitelist-addmask">
40
+ <input ref="addInviteText" type="text" class="u-input">
41
+ <button type="button" @click="addInvite($refs.addInviteText.value)">
42
+ {{ $t('invite_add_invite') }}
43
+ </button>
44
+ </div>
45
+
46
+ <table v-if="inviteList.length > 0" class="kiwi-invitelist-table">
47
+ <tr>
48
+ <th>{{ $t('invites_user') }}</th>
49
+ <th>{{ $t('invites_by') }}</th>
50
+ <th />
51
+ <th />
52
+ </tr>
53
+ <tr v-for="invite in inviteListAccounts" :key="invite.invited">
54
+ <td class="kiwi-invitelist-table-mask">
55
+ {{ displayMask(invite) }}
56
+ </td>
57
+ <td class="kiwi-invitelist-table-invitedby">
58
+ {{ invite.invited_by }}
59
+ </td>
60
+ <td class="kiwi-invitelist-table-invitedat">
61
+ {{ (new Date(invite.invited_at * 1000)).toDateString() }}
62
+ </td>
63
+ <td class="kiwi-invitelist-table-actions">
64
+ <i
65
+ v-if="areWeAnOp"
66
+ class="fa fa-trash"
67
+ aria-hidden="true"
68
+ @click="removeInvite(invite.invited)"
69
+ />
70
+ </td>
71
+ </tr>
72
+ <tr v-for="invite in inviteListNonAccounts" :key="invite.invited">
73
+ <td class="kiwi-invitelist-table-mask">
74
+ {{ displayMask(invite) }}
75
+ </td>
76
+ <td class="kiwi-invitelist-table-invitedby">
77
+ {{ invite.invited_by }}
78
+ </td>
79
+ <td class="kiwi-invitelist-table-invitedat">
80
+ {{ (new Date(invite.invited_at * 1000)).toDateString() }}
81
+ </td>
82
+ <td class="kiwi-invitelist-table-actions">
83
+ <i
84
+ v-if="areWeAnOp"
85
+ class="fa fa-trash"
86
+ aria-hidden="true"
87
+ @click="removeInvite(invite.invited)"
88
+ />
89
+ </td>
90
+ </tr>
91
+ </table>
92
+ </div>
93
+
94
+ <div v-if="is_refreshing">
95
+ {{ $t('invites_refreshing') }}
96
+ </div>
97
+ </form>
98
+ </div>
99
+ </template>
100
+ <script>
101
+
102
+ import _ from 'lodash';
103
+ import * as IrcdDiffs from '@/helpers/IrcdDiffs';
104
+
105
+ function inviteListSorter(a, b) {
106
+ let aMask = a.invited.toUpperCase();
107
+ let bMask = b.invited.toUpperCase();
108
+
109
+ if (aMask < bMask) {
110
+ return -1;
111
+ }
112
+ if (aMask > bMask) {
113
+ return 1;
114
+ }
115
+
116
+ return 0;
117
+ }
118
+
119
+ export default {
120
+ props: ['buffer'],
121
+ data() {
122
+ return {
123
+ inviteList: [],
124
+ is_refreshing: false,
125
+ };
126
+ },
127
+ computed: {
128
+ supportsAccounts() {
129
+ return !!this.extban;
130
+ },
131
+ extban() {
132
+ return IrcdDiffs.extbanAccount(this.buffer.getNetwork());
133
+ },
134
+ inviteListAccounts() {
135
+ let accounts = this.inviteList.filter((i) => i.invited.indexOf(this.extban) === 0);
136
+ accounts.sort(inviteListSorter);
137
+ return accounts;
138
+ },
139
+ inviteListNonAccounts() {
140
+ let invites = [];
141
+
142
+ // If the ircd doesn't support accounts extban type, consider every invex non-account
143
+ if (!this.supportsAccounts) {
144
+ invites = this.inviteList;
145
+ } else {
146
+ invites = this.inviteList.filter((i) => i.invited.indexOf(this.extban) !== 0);
147
+ }
148
+
149
+ invites.sort(inviteListSorter);
150
+ return invites;
151
+ },
152
+ channelIsInviteOnly() {
153
+ return typeof this.buffer.modes.i !== 'undefined';
154
+ },
155
+ anyRegisteredUserCanJoin() {
156
+ if (!this.supportsAccounts) {
157
+ return false;
158
+ }
159
+
160
+ if (!this.channelIsInviteOnly) {
161
+ return false;
162
+ }
163
+
164
+ let extban = this.extban;
165
+ // Find any invite that only consists of the extban and nothing else. Eg. '~a:'
166
+ return !!this.inviteListAccounts.find((invite) => invite.invited === extban + ':');
167
+ },
168
+ areWeAnOp() {
169
+ return this.buffer.isUserAnOp(this.buffer.getNetwork().nick);
170
+ },
171
+ knownAccounts() {
172
+ // Get an array of every account name we're aware of on the network, excluding
173
+ // the ones we already have in our invite list
174
+ let users = this.buffer.getNetwork().users;
175
+ let extban = this.extban;
176
+ let inviteAccountNames = this.inviteListAccounts.map((i) => {
177
+ let mask = i.invited;
178
+ return mask.replace(extban + ':', '');
179
+ });
180
+
181
+ let accountUsers = [];
182
+ Object.values(users).forEach((user) => {
183
+ if (user.account && inviteAccountNames.indexOf(user.account) === -1) {
184
+ accountUsers.push(user);
185
+ }
186
+ });
187
+
188
+ return _.orderBy(accountUsers, ['account', 'nick']);
189
+ },
190
+ },
191
+ created() {
192
+ this.updateInvitelist();
193
+ },
194
+ methods: {
195
+ displayMask(invite) {
196
+ let display = invite.invited.replace(this.extban + ':', '');
197
+ display = display || this.$t('invite_any_registered');
198
+ return display;
199
+ },
200
+ updateInvitelist() {
201
+ if (this.buffer.getNetwork().state !== 'connected' || this.is_refreshing) {
202
+ return;
203
+ }
204
+ let channelName = this.buffer.name;
205
+ this.is_refreshing = true;
206
+ this.buffer.getNetwork().ircClient.inviteList(channelName, (inviteEvent) => {
207
+ if (inviteEvent) {
208
+ this.inviteList = inviteEvent.invites;
209
+ } else {
210
+ this.inviteList = [];
211
+ }
212
+
213
+ this.is_refreshing = false;
214
+ });
215
+ },
216
+ removeInvite(mask) {
217
+ let channelName = this.buffer.name;
218
+ this.buffer.getNetwork().ircClient.removeInvite(channelName, mask);
219
+ this.inviteList = this.inviteList.filter((invite) => invite.invited !== mask);
220
+ },
221
+ addAccountInvite(accountName) {
222
+ if (!accountName) {
223
+ return;
224
+ }
225
+
226
+ let network = this.buffer.getNetwork();
227
+ network.ircClient.addInvite(this.buffer.name, `${this.extban}:${accountName}`);
228
+ this.updateInvitelist();
229
+ },
230
+ addInvite(mask) {
231
+ let network = this.buffer.getNetwork();
232
+ network.ircClient.addInvite(this.buffer.name, mask);
233
+ this.updateInvitelist();
234
+ },
235
+ setInviteOnly() {
236
+ this.buffer.getNetwork().ircClient.mode(this.buffer.name, '+i');
237
+ },
238
+ removeInviteOnly() {
239
+ this.buffer.getNetwork().ircClient.mode(this.buffer.name, '-i');
240
+ },
241
+ },
242
+ };
243
+ </script>
244
+ <style lang="less">
245
+ .kiwi-invitelist-inviteonly-status {
246
+ margin-top: 10px;
247
+ }
248
+
249
+ .kiwi-invitelist-table {
250
+ width: 100%;
251
+ border-collapse: collapse;
252
+ line-height: 20px;
253
+ margin-top: 10px;
254
+ }
255
+
256
+ .kiwi-invitelist-table-invitedat {
257
+ min-width: 150px;
258
+ }
259
+
260
+ .kiwi-invitelist-table-actions {
261
+ min-width: 50px;
262
+ text-align: center;
263
+ cursor: pointer;
264
+ position: relative;
265
+ transition: all 0.3s;
266
+ z-index: 1;
267
+ }
268
+
269
+ .kiwi-invitelist-addmask {
270
+ display: flex;
271
+ }
272
+
273
+ .kiwi-invitelist-addmask > button {
274
+ flex-shrink: 0;
275
+ }
276
+ </style>