diff --git a/README.md b/README.md index ad39cc8..957caac 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ tags: [intro] # Introduction -Hello there, I am Security Hammer. I will guide and help you to setup various modules of mine (`Verification`, `Moderation` etc). In case, if something is unclear, feel free to ask in Support Server. Let's get started. +Hello there, I am Security Hammer. I will guide and help you to setup various modules of mine (`Verification`, `Moderation` etc). In case, if something is unclear, feel free to ask in [Support Server](https://api.shbot.tk/discord). Let's get started. ### Inviting Me @@ -32,6 +32,6 @@ Slash commands are not yet implemented. ### Guides -[!ref icon="shield-check" text="Verification Setup"](../guides/Verification) +[!ref icon="shield-check" text="Verification Setup"](./guides/Verification) -More to be come :sad: \ No newline at end of file +More under progress :+1: \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..3d797c7 --- /dev/null +++ b/build.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +CYANBG="46m" +CYAN="\e[96m" +RED="\e[31m" +GREEN="\e[32m" +END="\e[0m" +BOLDCYAN="\e[1;${CYANBG}" +WORKSPACE="${BOLDCYAN}[Docs]${END}" +BUILDMSG="${WORKSPACE} ${CYAN}Starting to build the project...${END}" +BUILDSUCCESS="${WORKSPACE} ${GREEN}Build success.${END}" +MOVING="${WORKSPACE} ${CYAN}Moving service worker to root from /resources${END}" +INJECTING="${WORKSPACE} ${CYAN}Injecting Service Worker Registry${END}" +INJECTINGSUCCESS="${WORKSPACE} ${GREEN}Injecting success.${END}" +STARTING="${WORKSPACE} ${CYAN}Starting to serve the files.${END}" +ERROR="${WORKSPACE} ${RED}There was error. EXITING${END}" + +echo -e "${BUILDMSG}" +(npx retype build && echo -e "${BUILDSUCCESS}") || ( echo -e "${ERROR}" && sleep 3 && exit 1) +exitcode=$? +if [ $exitcode != 0 ]; then exit $exitcode; fi + + +echo -e "${MOVING}" +mv build/resources/js/service-worker.js build +echo -e "${INJECTING}" +node prebuilder.mjs +echo -e "${INJECTINGSUCCESS}" +echo -e "${STARTING}" +# npx retype run \ No newline at end of file diff --git a/guides/Verification.md b/guides/Verification.md index 0fbb507..ff7a673 100644 --- a/guides/Verification.md +++ b/guides/Verification.md @@ -9,5 +9,46 @@ tags: [verification] # Verification -!!!danger In Progress -This section is being written. \ No newline at end of file +!!!danger Work In Progress +This section is being written. +!!! +## Introduction +Alright, lets get started setting up without wasting time. Before you setup, it's important to know how I work. + +- [X] User joins the server is given `Unverified Role` +- [X] They clicks verify button in `Verification Channel`. +- [X] I will then try to DM them captcha and if fail to DM, I will reply the error in channel. +- [X] They will type the given captcha in my DM. +- [X] On correct captcha within given `Time`, they will be verified and + - `Unverified Role` will be removed from them. + - `Verified Role` will be added to them. +- [X] If they fail to do so, they will undergo `Action` set by you. +- [X] If they don't click the verify button, + - I will wait for `Idle Time` hoping they will click the button. + - If they don't do so in given time, `Idle Action` will be taken on them, again set by you. + +Okay that's lots of confusing :sparkles: terms :sparkles:. Don't worry, I am here to explain one by one :) + +!!!danger Before we start... +I really hope you know how to manage roles, channels and most importantly dealing with their permission. If you don't, refer this video by [!badge text="Y0ken's Domain"](https://www.youtube.com/channel/UC4negHehVJxHKwnxX5dck5g). + +[!button variant="info" target="blank" icon="link-external" text="Youtube"](https://www.youtube.com/watch?v=X1MGtTJWytg) +!!! + +## Unverified Role +When a user joins your server, they will be given `Unverified Role` which will restrict them to see channels and their content. I will shortly discuss how to set them up. But you might be wondering now, what if I have *Membership Gating* which will be bypassed if user is given role? That's correct, that's why I will auto-adapt if there is any sort of gating. So, if there is one I will wait for them to complete the membership, and then give them unverified role otherwise I will add the role directly. + +### Setting up Unverified Role +Here comes the important part that is setting up. I will break this in few steps. +- **Step 1:** + Create a role which you want to be given to unverified users or use an existing one, let's call it `Unverified Role`. +- **Step 2:** + Next step is setting permission for `Unverified Role`. All you have to do is select channel/category, go to settings, and then select `Permissions` tab. +- **Step 3:** + Select the `Unverified Role` from *Step 1*. Find the `Read Messages` permission and set it to `Deny` (you can refer the screenshot below). Save and it's done!!! + +| ![Unverified Role](../resources/images/UnverifiedRole.png) | +|:--:| +| *Setting Unverified Role's Permission in Category* | + +In short, it is role given to new users joining which will prevent them from seeing the channels. \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 19788a6..6503e1c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,17 +1,21 @@ { "name": "docs", + "version": "0.0.1-beta", "lockfileVersion": 2, "requires": true, "packages": { "": { + "name": "docs", + "version": "0.0.1-beta", + "license": "SEE LICENSE IN LICENSE", "dependencies": { - "retypeapp": "^1.10.0" + "retypeapp": "^1.11.0" } }, "node_modules/retypeapp": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/retypeapp/-/retypeapp-1.10.0.tgz", - "integrity": "sha512-TyGnSl1e29yXW42c5VXrkeXKHavkmaRjwQydlkZTdA2p8fHSKEQS7FGYW4OOSjK/tPQ1FTfX7lmogF+4KEZZ4g==", + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/retypeapp/-/retypeapp-1.11.0.tgz", + "integrity": "sha512-YMUjry/0w/1+YJSkBJoiK53KIIDl450kYztCcG7h9ueGnA2PCeXecRalDpBBYsJ0j28QWBCrCVmEYF+bs/FpGQ==", "bin": { "retype": "retype.js" } @@ -19,9 +23,9 @@ }, "dependencies": { "retypeapp": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/retypeapp/-/retypeapp-1.10.0.tgz", - "integrity": "sha512-TyGnSl1e29yXW42c5VXrkeXKHavkmaRjwQydlkZTdA2p8fHSKEQS7FGYW4OOSjK/tPQ1FTfX7lmogF+4KEZZ4g==" + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/retypeapp/-/retypeapp-1.11.0.tgz", + "integrity": "sha512-YMUjry/0w/1+YJSkBJoiK53KIIDl450kYztCcG7h9ueGnA2PCeXecRalDpBBYsJ0j28QWBCrCVmEYF+bs/FpGQ==" } } } diff --git a/package.json b/package.json index 84205ec..ffafe72 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,14 @@ { "dependencies": { - "retypeapp": "^1.10.0" + "retypeapp": "^1.11.0" }, "name": "docs", "description": "Documentation/guide for Security Hammer.", "version": "0.0.1-beta", "main": "", - "devDependencies": {}, "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "test": "echo \"Error: no test specified\" && exit 1", + "dev": "npx retype build & move build\\resources\\js\\service-worker.js build & node prebuilder.mjs & npx retype run" }, "repository": { "type": "git", diff --git a/prebuilder.mjs b/prebuilder.mjs new file mode 100644 index 0000000..a093d68 --- /dev/null +++ b/prebuilder.mjs @@ -0,0 +1,12 @@ +import { writeFile } from 'fs/promises'; + +/*if ('serviceWorker' in navigator) { + console.log('[Service Worker] Registering the worker.'); + navigator.serviceWorker.register('./service-worker.js', {scope: '/'}).then(() => console.log('CLIENT: service worker registration complete.'), err => + console.log('CLIENT: service worker registration failure.' + err)); + } else { + console.log('CLIENT: service worker is not supported.'); + }*/ +const data = '"serviceWorker"in navigator?(console.log("[Service Worker] Registering the worker."),navigator.serviceWorker.register("../service-worker.js").then(()=>console.log("[Service Worker] Registration complete."),e=>console.log("[Service Worker] Coudn\'t register because "+e))):console.log("[Service Worker] Browser not supported.");'; + +writeFile('./build/resources/js/retype.js', data, { flag: 'a'}) \ No newline at end of file diff --git a/resources/images/UnverifiedRole.png b/resources/images/UnverifiedRole.png new file mode 100644 index 0000000..999f3b5 Binary files /dev/null and b/resources/images/UnverifiedRole.png differ diff --git a/resources/js/service-worker.js b/resources/js/service-worker.js new file mode 100644 index 0000000..069c061 --- /dev/null +++ b/resources/js/service-worker.js @@ -0,0 +1,51 @@ +const CacheVersion = 'v0.0.1' + +files = [ + '/', + '/404', + '/resources/css/retype.css', + '/resources/js/config.js', + '/resources/js/lunr.js', + '/resorces/js/retype.js', + '/resources/js/search.json', + '/resources/images/unverifiedrole.png', + '/guides/verification/' +] + +self.addEventListener("install", e => { + console.log('[SW]: Installing and caching resources.'); + e.waitUntil(caches.open(CacheVersion + '-cache').then(cache => { + return cache.addAll(files) + }) + .then(function() { + console.log('[SW]: Installated Successfully!'); + }) + ); +}); + +self.addEventListener("activate", e => { + console.log('[SW] Validating the cache and activating.'); + + e.waitUntil(caches.keys().then(function (keys) { + return Promise.all( + keys.filter(function (key) { + return !key.startsWith(CacheVersion); + }) + .map(function (key) { + return caches.delete(key); + }) + ); + }) + .then(function() { + console.log('[SW]: Validated and Activated.'); + }) + ); + }); + + self.addEventListener('fetch', function(event) { + event.respondWith( + caches.match(event.request).then(function(response) { + return response || fetch(event.request); + }) + ); + }); \ No newline at end of file diff --git a/retype.yml b/retype.yml index bdf26d3..5b7c81f 100644 --- a/retype.yml +++ b/retype.yml @@ -1,9 +1,9 @@ input: . output: ./build -url: https://shbot.onrender.com +url: https://shguide.onrender.com branding: title: Security Hammer - label: v2.0 + label: beta edit: repo: https://github.com/Security-Hammer/docs label: Edit on Github