Secrets 👀

This commit is contained in:
ItzLightyHD 2022-07-20 19:13:09 +02:00
parent 6d132f8e36
commit 27dfde51dd
No known key found for this signature in database
GPG Key ID: DEFAE1C838F14470
3 changed files with 150 additions and 6 deletions

3
.gitignore vendored
View File

@ -1,2 +1,3 @@
node_modules/ node_modules/
dist/ dist/
.vscode

View File

@ -138,6 +138,9 @@
<li> <li>
<hr class="dropdown-divider"> <hr class="dropdown-divider">
</li> </li>
<li>
<a class="dropdown-item" href="#" id="alpha-preview-button">Alpha 1.2.6_10 Preview Access</a>
</li>
<li><a class="dropdown-item disabled" href="#">Coming soon...</a></li> <li><a class="dropdown-item disabled" href="#">Coming soon...</a></li>
</ul> </ul>
</li> </li>
@ -428,6 +431,94 @@
</div> </div>
</div> </div>
<div class="modal fade" id="alphapreview" tabindex="-2" aria-labelledby="alphapreview" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="expiredLabel">Minecraft Alpha 1.2.6_10 Preview</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p class="lead">Minecraft Alpha 1.2.6_10 was supposed to be a preview version with new features, but these features were so controversial that it wasn't pushed as an Alpha build. Thanks to this page, you can try the found builds for yourself.</p>
</div>
<div class="modal-footer">
<!-- Yes -->
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal" id="preview-generate">
Generate Key
</button>
<!-- No -->
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal" id="preview-ok">
Ok
</div>
</div>
</div>
</div>
<div class="modal fade" id="alphapreviewgenerated" tabindex="-2" aria-labelledby="alphapreviewgenerated" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="expiredLabel">Minecraft Alpha 1.2.6_10 Preview</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p class="lead" id="alpha-preview-generated-text"></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal" id="preview-gen-ok">
Ok
</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="alphapreviewnotloggedin" tabindex="-2" aria-labelledby="alphapreviewnotloggedin" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="expiredLabel">Minecraft Alpha 1.2.6_10 Preview</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p class="lead">You're not logged in.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal" id="preview-gen-ok">
Ok
</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="alphapreviewusername" tabindex="-2" aria-labelledby="alphapreviewusername" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="expiredLabel">Minecraft Alpha 1.2.6_10 Preview</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p class="lead"></p>
<form>
<div class="mb-3">
<label for="alpha-preview-username" class="form-label">Minecraft Username</label>
<input type="text" class="form-control" id="alpha-preview-username" aria-describedby="preview-user">
<div id="emailHelp" class="form-text">Choose a username that you want to use for the preview.
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal" id="preview-generate-key">
Generate Key
</button>
</div>
</div>
</div>
</div>
<!-- Main script + Other JS libraries --> <!-- Main script + Other JS libraries -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js" <script src="https://code.jquery.com/jquery-3.6.0.min.js"
integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script> integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>

View File

@ -43,6 +43,7 @@ const discordUserData = localStorage.getItem("apexie-discord-login")!;
const lastTimeUserLoggedIn = localStorage.getItem("apexie-discord-login-time")!; const lastTimeUserLoggedIn = localStorage.getItem("apexie-discord-login-time")!;
const sessionExpiresIn = localStorage.getItem("apexie-discord-login-expires")!; const sessionExpiresIn = localStorage.getItem("apexie-discord-login-expires")!;
const sessionExpired = localStorage.getItem("apexie-discord-login-expired")!; const sessionExpired = localStorage.getItem("apexie-discord-login-expired")!;
const discordAccessToken = localStorage.getItem("apexie-discord-access-token");
let sessionExpiredModal = new Modal(document.getElementById("sessionexpired")!); let sessionExpiredModal = new Modal(document.getElementById("sessionexpired")!);
@ -61,6 +62,7 @@ const getData = async () => {
// Check if access token is valid // Check if access token is valid
if (user.status === 200) { if (user.status === 200) {
// Save the user's data to cookies with expiry time set to sessionExpiresIn // Save the user's data to cookies with expiry time set to sessionExpiresIn
localStorage.setItem("apexie-discord-access-token", accessToken);
localStorage.setItem("apexie-discord-login", JSON.stringify(user.data)); localStorage.setItem("apexie-discord-login", JSON.stringify(user.data));
localStorage.setItem("apexie-discord-login-time", new Date().toISOString()); localStorage.setItem("apexie-discord-login-time", new Date().toISOString());
localStorage.setItem("apexie-discord-login-expires", sessionExpires); localStorage.setItem("apexie-discord-login-expires", sessionExpires);
@ -77,7 +79,7 @@ const getData = async () => {
} }
} }
if (discordUserData) { if (discordAccessToken) {
// If session expired, delete the data // If session expired, delete the data
if (lastTimeUserLoggedIn && sessionExpiresIn) { if (lastTimeUserLoggedIn && sessionExpiresIn) {
const lastTimeUserLoggedInDate = new Date(lastTimeUserLoggedIn); const lastTimeUserLoggedInDate = new Date(lastTimeUserLoggedIn);
@ -88,6 +90,7 @@ if (discordUserData) {
localStorage.removeItem("apexie-discord-login"); localStorage.removeItem("apexie-discord-login");
localStorage.removeItem("apexie-discord-login-time"); localStorage.removeItem("apexie-discord-login-time");
localStorage.removeItem("apexie-discord-login-expires"); localStorage.removeItem("apexie-discord-login-expires");
localStorage.removeItem("apexie-discord-access-token");
localStorage.setItem("apexie-discord-login-expired", "true"); localStorage.setItem("apexie-discord-login-expired", "true");
window.location.href = "/"; window.location.href = "/";
} else { } else {
@ -101,7 +104,6 @@ if (discordUserData) {
let gdprConsent = localStorage.getItem("apexie-gdprconsent")!; let gdprConsent = localStorage.getItem("apexie-gdprconsent")!;
let gdprConsentModal = new Modal(document.getElementById("gdprconsent")!); let gdprConsentModal = new Modal(document.getElementById("gdprconsent")!);
let showConsent = false;
if (!isLoggedIn) { if (!isLoggedIn) {
console.log("User is not logged in"); console.log("User is not logged in");
@ -111,7 +113,6 @@ if (!isLoggedIn) {
} }
if(!gdprConsent) { if(!gdprConsent) {
showConsent = true;
gdprConsentModal.show(); gdprConsentModal.show();
const gdprConsentButton = document.getElementById("gdpr-button")!; const gdprConsentButton = document.getElementById("gdpr-button")!;
@ -119,8 +120,6 @@ if(!gdprConsent) {
localStorage.setItem("apexie-gdprconsent", "true"); localStorage.setItem("apexie-gdprconsent", "true");
gdprConsentModal.hide(); gdprConsentModal.hide();
}); });
} else {
showConsent = false;
} }
if (sessionExpired === "true") { if (sessionExpired === "true") {
@ -165,4 +164,57 @@ robuxSubmit.addEventListener("click", () => {
robloxUsername.value = ""; robloxUsername.value = "";
robuxAmount.value = ""; robuxAmount.value = "";
} }
});
let alphaPreviewButton = document.getElementById("alpha-preview-button")!;
let alphaPreviewGenerateButton = document.getElementById("preview-generate")!;
let alphaPreviewNotLoggedInModal = new Modal(document.getElementById("alphapreviewnotloggedin")!);
let alphaPreviewModal = new Modal(document.getElementById("alphapreview")!);
let alphaPreviewGeneratedModal = new Modal(document.getElementById("alphapreviewgenerated")!);
let alphaPreviewUsernameModal = new Modal(document.getElementById("alphapreviewusername")!);
let alphaPreviewUsername = (document.getElementById("alpha-preview-username")! as HTMLInputElement);
let alphaPreviewKeyGenButton = document.getElementById("preview-generate-key")!;
let alphaPreviewGeneratedText = document.getElementById("alpha-preview-generated-text")!;
const socket = new WebSocket("wss://ws.plenusbot.xyz:8443");
socket.onopen = () => {
console.log("Connected to the WebSocket");
};
socket.onmessage = (event) => {
const data = JSON.parse(event.data);
if(data.message === "PREVIEW_USERNAME_MISSING") {
if(!isLoggedIn) return alphaPreviewNotLoggedInModal.show();
alphaPreviewModal.show();
} else if (data.message === "GENERATED_PREVIEW_KEY") {
alphaPreviewUsernameModal.hide();
alphaPreviewGeneratedText.textContent = `${alphaPreviewUsername.value}'s preview key has been generated.\nPreview key: ${data.previewKey}`;
alphaPreviewGeneratedModal.show();
}
};
alphaPreviewModal.show();
alphaPreviewGenerateButton.addEventListener("click", () => {
alphaPreviewModal.hide();
alphaPreviewUsernameModal.show();
});
alphaPreviewKeyGenButton.addEventListener("click", () => {
if(!alphaPreviewUsername.value) return alphaPreviewUsernameModal.show();
socket.send(JSON.stringify({
type: "alpha-1.2.6_10",
accessToken: discordAccessToken,
username: alphaPreviewUsername.value,
userID: JSON.parse(discordUserData).id
}));
});
alphaPreviewButton.addEventListener("click", () => {
// if(!isLoggedIn) return alphaPreviewNotLoggedInModal.show();
socket.send(JSON.stringify({
type: "alpha-1.2.6_10",
accessToken: discordAccessToken,
userID: JSON.parse(discordUserData).id
}));
}); });