News Security
This commit is contained in:
parent
4cb68127d6
commit
2d159c9dc8
@ -4,6 +4,7 @@
|
||||
// Requirements
|
||||
const cp = require('child_process')
|
||||
const crypto = require('crypto')
|
||||
const request = require('request')
|
||||
const {URL} = require('url')
|
||||
|
||||
// Internal Requirements
|
||||
@ -1163,11 +1164,70 @@ document.getElementById('settingsFileSystemButton').onclick = () => {
|
||||
shell.openPath(CACHE_SETTINGS_MODS_DIR)
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch Notion URL
|
||||
*/
|
||||
(async function () {
|
||||
function joinSession(uuid, accessToken, serverId) {
|
||||
return new Promise((resolve, reject) => {
|
||||
request.post('https://sessionserver.mojang.com/session/minecraft/join',
|
||||
{
|
||||
json: true,
|
||||
body: {
|
||||
selectedProfile: uuid,
|
||||
accessToken,
|
||||
serverId
|
||||
}
|
||||
},
|
||||
function (error, response, body) {
|
||||
if (error) {
|
||||
logger.error('Error during validation.', error)
|
||||
reject(error)
|
||||
} else {
|
||||
if (response.statusCode === 403) {
|
||||
resolve(false)
|
||||
} else {
|
||||
// 204 if valid
|
||||
resolve(true)
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function fetchNotionURL(uuid, username) {
|
||||
return new Promise((resolve, reject) => {
|
||||
request.post('https://asia-northeast1-kuncraft.cloudfunctions.net/numalauncher-news',
|
||||
{
|
||||
json: true,
|
||||
body: {
|
||||
uuid,
|
||||
username
|
||||
}
|
||||
},
|
||||
function (error, response, body) {
|
||||
if (error) {
|
||||
logger.error('Error during validation.', error)
|
||||
reject(error)
|
||||
} else {
|
||||
resolve(body.url)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const serverId = 'numalauncher-news'
|
||||
const {uuid, displayName, accessToken} = ConfigManager.getSelectedAccount()
|
||||
if (await joinSession(uuid, accessToken, serverId)) {
|
||||
notion.src = await fetchNotionURL(uuid, displayName)
|
||||
}
|
||||
})()
|
||||
|
||||
/**
|
||||
* Notion injection
|
||||
*/
|
||||
notion.contentWindow.localStorage.setItem('theme','{"mode":"dark"}')
|
||||
notion.contentWindow.addEventListener('DOMContentLoaded', event => {
|
||||
notion.onload = (() => {
|
||||
const notionDoc = notion.contentWindow.document
|
||||
|
||||
// CSS
|
||||
|
@ -10,7 +10,7 @@
|
||||
<div id="notionContainer">
|
||||
<iframe
|
||||
id="notion"
|
||||
src="https://www.notion.so/teamkun/News-be3a005c2c0c461389da5329bba85055"
|
||||
src="about:blank"
|
||||
allowtransparency="allowtransparency"
|
||||
>
|
||||
</iframe>
|
||||
|
Loading…
Reference in New Issue
Block a user