stable result

This commit is contained in:
cyber-dream 2025-01-29 12:40:06 +03:00
parent 588801ea06
commit 088ec70928
18 changed files with 388 additions and 69 deletions

8
.idea/.gitignore generated vendored
View File

@ -1,8 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@ -1,4 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<module type="WEB_MODULE" version="4">
<component name="Go" enabled="true" />
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -1,5 +1,6 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<option name="LINE_SEPARATOR" value="&#13;&#10;" />
<JSCodeStyleSettings version="0">
<option name="USE_SEMICOLON_AFTER_STATEMENT" value="false" />
<option name="FORCE_SEMICOLON_STYLE" value="true" />

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptLibraryMappings">
<includedPredefinedLibrary name="Node.js Core" />
</component>
</project>

104
.idea/workspace.xml generated Normal file
View File

@ -0,0 +1,104 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="ALL" />
</component>
<component name="ChangeListManager">
<list default="true" id="efee9cb0-966d-4623-845a-f3b0398ae3ab" name="Changes" comment="">
<change afterPath="$PROJECT_DIR$/app/assets/js/scripts/skirda/auth/telegram.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/app/loginSkirdaTelegram.ejs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/.gitignore" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/SkirdaElectronLauncher.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/SkirdaElectronLauncher.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/codeStyles/Project.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/codeStyles/Project.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/jsLibraryMappings.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/app/app.ejs" beforeDir="false" afterPath="$PROJECT_DIR$/app/app.ejs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/assets/js/authmanager.js" beforeDir="false" afterPath="$PROJECT_DIR$/app/assets/js/authmanager.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/assets/js/configmanager.js" beforeDir="false" afterPath="$PROJECT_DIR$/app/assets/js/configmanager.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/assets/js/distromanager.js" beforeDir="false" afterPath="$PROJECT_DIR$/app/assets/js/distromanager.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/assets/js/scripts/landing.js" beforeDir="false" afterPath="$PROJECT_DIR$/app/assets/js/scripts/landing.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/assets/js/scripts/loginOptions.js" beforeDir="false" afterPath="$PROJECT_DIR$/app/assets/js/scripts/loginOptions.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/assets/js/scripts/loginSkirdaDiscord.js" beforeDir="false" afterPath="$PROJECT_DIR$/app/assets/js/scripts/loginSkirdaDiscord.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/assets/js/scripts/settings.js" beforeDir="false" afterPath="$PROJECT_DIR$/app/assets/js/scripts/settings.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/assets/js/scripts/uibinder.js" beforeDir="false" afterPath="$PROJECT_DIR$/app/assets/js/scripts/uibinder.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/loginOptions.ejs" beforeDir="false" afterPath="$PROJECT_DIR$/app/loginOptions.ejs" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="JavaScript File" />
</list>
</option>
</component>
<component name="GOROOT" url="file:///usr/lib/go" />
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="ProjectColorInfo">{
&quot;customColor&quot;: &quot;&quot;,
&quot;associatedIndex&quot;: 6
}</component>
<component name="ProjectId" id="2s9MOcrLwV3Eo1Om9BlW30GzkjW" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.git.unshallow": "true",
"RunOnceActivity.go.formatter.settings.were.checked": "true",
"RunOnceActivity.go.migrated.go.modules.settings": "true",
"RunOnceActivity.go.modules.go.list.on.any.changes.was.set": "true",
"git-widget-placeholder": "offline-mode",
"go.import.settings.migrated": "true",
"go.sdk.automatically.set": "true",
"last_opened_file_path": "/home/dart/repo/skirda/SkirdaElectronLauncher",
"node.js.detected.package.eslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"nodejs_package_manager_path": "npm",
"npm.start.executor": "Debug",
"ts.external.directory.path": "/opt/goland/plugins/javascript-plugin/jsLanguageServicesImpl/external"
}
}]]></component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/app" />
</key>
<key name="MoveFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/app/assets/js/scripts/skirda/auth" />
<recent name="$PROJECT_DIR$/app/assets/js/scripts" />
</key>
</component>
<component name="RunManager">
<configuration name="start" type="js.build_tools.npm" nameIsGenerated="true">
<package-json value="$PROJECT_DIR$/package.json" />
<command value="run" />
<scripts>
<script value="start" />
</scripts>
<node-interpreter value="project" />
<envs />
<method v="2" />
</configuration>
</component>
<component name="SharedIndexes">
<attachedChunks>
<set>
<option value="bundled-gosdk-d297c17c1fbd-85c80fddc9a6-org.jetbrains.plugins.go.sharedIndexes.bundled-GO-243.23654.119" />
<option value="bundled-js-predefined-d6986cc7102b-822845ee3bb5-JavaScript-GO-243.23654.119" />
</set>
</attachedChunks>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="VgoProject">
<settings-migrated>true</settings-migrated>
</component>
</project>

View File

@ -35,6 +35,7 @@
<%- include('loginOptions') %>
<%- include('loginOffline') %>
<%- include('loginSkirdaDiscord') %>
<%- include('loginSkirdaTelegram') %>
<%- include('settings') %>
<%- include('landing') %>
</div>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 240.1 240.1">
<linearGradient id="Oval_1_" gradientUnits="userSpaceOnUse" x1="-838.041" y1="660.581" x2="-838.041" y2="660.3427" gradientTransform="matrix(1000 0 0 -1000 838161 660581)">
<stop offset="0" style="stop-color:#2AABEE"/>
<stop offset="1" style="stop-color:#229ED9"/>
</linearGradient>
<circle fill-rule="evenodd" clip-rule="evenodd" fill="url(#Oval_1_)" cx="120.1" cy="120.1" r="120.1"/>
<path fill-rule="evenodd" clip-rule="evenodd" fill="#FFFFFF" d="M54.3,118.8c35-15.2,58.3-25.3,70-30.2 c33.3-13.9,40.3-16.3,44.8-16.4c1,0,3.2,0.2,4.7,1.4c1.2,1,1.5,2.3,1.7,3.3s0.4,3.1,0.2,4.7c-1.8,19-9.6,65.1-13.6,86.3 c-1.7,9-5,12-8.2,12.3c-7,0.6-12.3-4.6-19-9c-10.6-6.9-16.5-11.2-26.8-18c-11.9-7.8-4.2-12.1,2.6-19.1c1.8-1.8,32.5-29.8,33.1-32.3 c0.1-0.3,0.1-1.5-0.6-2.1c-0.7-0.6-1.7-0.4-2.5-0.2c-1.1,0.2-17.9,11.4-50.6,33.5c-4.8,3.3-9.1,4.9-13,4.8 c-4.3-0.1-12.5-2.4-18.7-4.4c-7.5-2.4-13.5-3.7-13-7.9C45.7,123.3,48.7,121.1,54.3,118.8z"/>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -188,7 +188,6 @@ exports.addSkirdaAccount = async function(uuid, accessToken, username, displayNa
}
exports.addOfflineAccount = async function(usernameOffline){
//TODO: check for forbidden symbols and lenght!!
ConfigManager.addOfflineAccount(usernameOffline)
}
@ -207,7 +206,7 @@ const AUTH_MODE = { FULL: 0, MS_REFRESH: 1, MC_REFRESH: 2 }
*/
async function fullMicrosoftAuthFlow(entryCode, authMode) {
try {
console.error("try auth from ms")
console.error('try auth from ms')
return Promise.reject(microsoftErrorDisplayable(MicrosoftErrorCode.UNKNOWN))
let accessTokenRaw
let accessToken
@ -405,7 +404,6 @@ async function validateSelectedMojangAccount(){
}
}
// require('./scripts/loginSkirdaDiscord')
/**
* Validate the selected account with Skirda's authserver. If the account is not valid,
* we will attempt to refresh the access token and update that value. If that fails, a
@ -414,30 +412,19 @@ async function validateSelectedMojangAccount(){
* @returns {Promise.<boolean>} Promise which resolves to true if the access token is valid,
* otherwise false.
*/
const auth_api_url = 'https://skirda.brzezinski.ru'
async function validateSelectedSkirdaAccount(){
const current = ConfigManager.getSelectedAccount()
const result = await SkirdaDiscordAuth.ValidateAccount(current.accessToken)
// const response = await MojangRestAPI.validate(current.accessToken, ConfigManager.getClientToken())
// const isValid = response.data
if(!result){
const refreshResponse = await MojangRestAPI.refresh(current.accessToken, ConfigManager.getClientToken())
if(refreshResponse.responseStatus === RestResponseStatus.SUCCESS) {
const session = refreshResponse.data
ConfigManager.updateMojangAuthAccount(current.uuid, session.accessToken)
ConfigManager.save()
} else {
log.error('Error while validating selected profile:', refreshResponse.error)
log.info('Account access token is invalid.')
return false
const resp = await fetch(`${auth_api_url}/auth/refresh`, {
headers: {
'Content-Type': 'application/json',
'Authorization': current.accessToken,
}
log.info('Account access token validated.')
return true
} else {
log.info('Account access token validated.')
return true
}
})
console.log(resp)
return resp.status === 200
}
/**

View File

@ -365,6 +365,7 @@ exports.addOfflineAccount = function(usernameOffline){
}
exports.addSkirdaAccount = function(uuid, accessToken, username, displayName, skirdaToken){
console.log(username)
config.selectedAccount = uuid
config.authenticationDatabase[uuid] = {
type: 'skirda',
@ -372,7 +373,7 @@ exports.addSkirdaAccount = function(uuid, accessToken, username, displayName, sk
username: username.trim(),
uuid: uuid.trim(),
displayName: displayName.trim(),
skirdaJWT: skirdaToken
skirdaJWT: skirdaToken.trim()
}
return config.authenticationDatabase[uuid]
}

View File

@ -2,8 +2,9 @@ const {DistributionAPI} = require('helios-core/common')
const ConfigManager = require('./configmanager')
// Old WesterosCraft url.
exports.REMOTE_DISTRO_URL = 'http://mc.westeroscraft.com/WesterosCraftLauncher/distribution.json'
exports.REMOTE_DISTRO_URL = 'https://helios-files.geekcorner.eu.org/distribution.json'
// exports.REMOTE_DISTRO_URL = 'http://mc.westeroscraft.com/WesterosCraftLauncher/distribution.json'
exports.REMOTE_DISTRO_URL = 'http://localhost:8090/distribution.json'
// exports.REMOTE_DISTRO_URL = 'https://helios-files.geekcorner.eu.org/distribution.json'
// exports.REMOTE_DISTRO_URL = 'https://skirda-minecraft-distribution.brzezinski.ru/distribution.json'
// exports.REMOTE_DISTRO_URL = 'https://helios-files.geekcorner.eu.org/distribution.json'
// exports.REMOTE_DISTRO_URL = 'http://192.168.88.10:8081/distribution/manifest'

View File

@ -144,7 +144,7 @@ document.getElementById('avatarOverlay').onclick = async e => {
// Bind selected account
function updateSelectedAccount(authUser){
let username = Lang.queryJS('landing.selectedAccount.noAccountSelected')
console.log(authUser)
// console.log(authUser)
if(authUser != null){
if(authUser.displayName != null){
username = authUser.displayName

View File

@ -3,6 +3,7 @@ const loginOptionMicrosoft = document.getElementById('loginOptionMicrosoft')
const loginOptionMojang = document.getElementById('loginOptionMojang')
const loginOptionOffline = document.getElementById('loginOptionOffline')
const loginOptionSkirdaDiskord = document.getElementById('loginOptionSkirdaDiscord')
const loginOptionSkirdaTelegram = document.getElementById('loginOptionSkirdaTelegram')
const loginOptionsCancelButton = document.getElementById('loginOptionCancelButton')
let loginOptionsCancellable = false
@ -47,7 +48,7 @@ loginOptionOffline.onclick = (e) => {
})
}
loginOptionSkirdaDiscord.onclick = (e) => {
loginOptionSkirdaDiskord.onclick = (e) => {
InitSkirdaDiscordLogin()
switchView(getCurrentView(), VIEWS.loginSkirdaDiscord, 500, 500, () => {
loginViewOnSuccess = loginOptionsViewOnLoginSuccess
@ -56,6 +57,15 @@ loginOptionSkirdaDiscord.onclick = (e) => {
})
}
loginOptionSkirdaTelegram.onclick = (e) => {
InitSkirdaTelegramAuth()
switchView(getCurrentView(), VIEWS.loginSkirdaTelegram, 500, 500, () => {
loginViewOnSuccess = loginOptionsViewOnLoginSuccess
loginViewOnCancel = loginOptionsViewOnLoginCancel
// loginCancelEnabled(true)
})
}
loginOptionsCancelButton.onclick = (e) => {
switchView(getCurrentView(), loginOptionsViewOnCancel, 500, 500, () => {
// Clear login values (Mojang login)

View File

@ -3,14 +3,18 @@
// const {addSkirdaAccount} = require('configmanager')
// const auth_api_url = 'http://192.168.88.10:8083'
// const auth_api_url = 'http://localhost:8083'
const auth_api_url = 'http://skirda-auth.brzezinski.ru'
const ConfigManager = require('../configmanager')
const {MojangRestAPI} = require('helios-core/mojang')
const {RestResponseStatus} = require('helios-core/common')
const auth_api_url = 'http://skirda.brzezinski.ru'
function uuidv4() {
return '10000000-1000-4000-8000-100000000000'.replace(/[018]/g, c =>
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
)
}
class SkirdaDiscordAuth{
class SkirdaAuth {
/**
* @typedef {Object} DiscordRedirectAuth
* @property {string} redirectUrl how the person is called
@ -19,10 +23,11 @@ class SkirdaDiscordAuth{
* @return {Promise<DiscordRedirectAuth | string>}
* */
static temp_installId = uuidv4()
static async Init(){
const resp = await fetch(`${auth_api_url}/v1/auth/discord/init?installId=${SkirdaDiscordAuth.temp_installId}`)
if (resp.statusCode !== 200){
static async Init() {
const resp = await fetch(`${auth_api_url}/v1/auth/discord/init?installId=${SkirdaAuth.temp_installId}`)
if (resp.statusCode !== 200) {
return await resp.text()
}
@ -34,13 +39,13 @@ class SkirdaDiscordAuth{
// * @param timeout {number} Timeout to poll in seconds
* @return {SkirdaUserResp | string} Result of OAuth login
*/
static async CyclePolling(requestId){
static async CyclePolling(requestId) {
for (let i = 0; i < 15; i++) {
const resp = await SkirdaDiscordAuth._poll(requestId)
const resp = await SkirdaAuth._poll(requestId)
switch (resp.status){
switch (resp.status) {
case 204:
await SkirdaDiscordAuth._sleep(4000)
await SkirdaAuth._sleep(4000)
continue
case 200:
return await resp.json()
@ -64,15 +69,15 @@ class SkirdaDiscordAuth{
* @param jwtToken {string} JWT Token for auth
* @return {YggProfile | string} Result of auth
*/
static async YggdrasilAuth(jwtToken){
static async YggdrasilAuth(jwtToken) {
const resp = await fetch(`${auth_api_url}/yggdrasil/skirda/authenticate`, {
headers:{
headers: {
'Content-Type': 'application/json',
'Authorization': jwtToken
}
})
if (resp.statusCode !== 200){
if (resp.statusCode !== 200) {
return await resp.text()
}
@ -89,11 +94,12 @@ class SkirdaDiscordAuth{
* @param requestId {string}
* @return {Response}
* */
static async _poll(requestId){
return await fetch(`${auth_api_url}/v1/auth/discord/periodicPolling?installId=${SkirdaDiscordAuth.temp_installId}&requestId=${requestId}`)
static async _poll(requestId) {
return await fetch(`${auth_api_url}/v1/auth/discord/periodicPolling?installId=${SkirdaAuth.temp_installId}&requestId=${requestId}`)
}
static _sleepSetTimeout_ctrl
/**
* @param ms {number}
* @return {boolean}
@ -104,8 +110,8 @@ class SkirdaDiscordAuth{
}
static async ValidateAccount(jwtToken) {
const resp = await fetch(`${auth_api_url}/v1/auth/refresh`,{
headers:{
const resp = await fetch(`${auth_api_url}/auth/refresh`, {
headers: {
'Content-Type': 'application/json',
'Authorization': jwtToken
}
@ -113,18 +119,58 @@ class SkirdaDiscordAuth{
// console.log(resp, resp.statusCode)
return resp.status === 200
}
static async ValidateSelected() {
const current = ConfigManager.getSelectedAccount()
if (current === null) {
return false
}
const resp = await fetch(`${auth_api_url}/auth/refresh`, {
headers: {
'Content-Type': 'application/json',
'Authorization': jwtToken
}
})
if (resp.status !== 200) {
return false
}
const result = await resp.json()
return result !== null
// const response = await MojangRestAPI.validate(current.accessToken, ConfigManager.getClientToken())
// const isValid = response.data
// if (!result) {
// const refreshResponse = await MojangRestAPI.refresh(current.accessToken, ConfigManager.getClientToken())
// if (refreshResponse.responseStatus === RestResponseStatus.SUCCESS) {
// const session = refreshResponse.data
// ConfigManager.updateMojangAuthAccount(current.uuid, session.accessToken)
// ConfigManager.save()
// } else {
// log.error('Error while validating selected profile:', refreshResponse.error)
// log.info('Account access token is invalid.')
// return false
// }
// log.info('Account access token validated.')
// return true
// } else {
// log.info('Account access token validated.')
// return true
// }
}
}
// const skAuth = new SkirdaDiscordAuth()
const loginSkirdaDiscordButton = document.getElementById('loginSkirdaDiscordInitAuth')
const loginSkirdaDiscordButton = document.getElementById('loginSkirdaDiscordInitAuth')
/**
* @return boolean
* */
async function InitSkirdaDiscordLogin (){
const res = await SkirdaDiscordAuth.Init()
async function InitSkirdaDiscordLogin() {
const res = await SkirdaAuth.Init()
let redir
try {
redir = JSON.parse(res)
@ -137,16 +183,16 @@ async function InitSkirdaDiscordLogin (){
const resOpenUrl = await shell.openExternal(redir.redirectUrl)
const skirdaAuth = await SkirdaDiscordAuth.CyclePolling(redir.requestId)
const skirdaAuth = await SkirdaAuth.CyclePolling(redir.requestId)
//TODO validate resp
// console.log(skirdaAuth)
if (typeof skirdaAuth.token !== 'string'){
if (typeof skirdaAuth.token !== 'string') {
SpawnError(Lang.queryJS('login.error.unknown'))
return
}
const yggAuth = await SkirdaDiscordAuth.YggdrasilAuth(skirdaAuth.token)
const yggAuth = await SkirdaAuth.YggdrasilAuth(skirdaAuth.token)
let yggAuthRes
try {
yggAuthRes = JSON.parse(yggAuth)
@ -167,7 +213,7 @@ async function InitSkirdaDiscordLogin (){
}, 1000)
}
function SpawnError(actualDisplayableError){
function SpawnError(actualDisplayableError) {
setOverlayContent(actualDisplayableError.title, actualDisplayableError.desc, Lang.queryJS('login.tryAgain'))
setOverlayHandler(() => {
formDisabled(false)

View File

@ -354,6 +354,8 @@ document.getElementById('settingsAddMojangAccount').onclick = (e) => {
document.getElementById('settingsAddSkirdaDiscord').onclick = (e) => {
// console.log("kekekekekek")
switchView(getCurrentView(), VIEWS.loginSkirdaDiscord, 500, 500, () => {
loginViewOnCancel = VIEWS.settings
loginViewOnSuccess = VIEWS.settings
})
}

View File

@ -0,0 +1,109 @@
const sk_tg_auth_api_url = 'https://skirda.brzezinski.ru/auth'
/**@typedef {Object} SkirdaTelegramAuthInitResponse
* @property {string} redirect_url
* @property {string} subscribe_url
* */
/** @typedef {Object} SkirdaTelegramAuthResultResponse
* @property {string} name
* @property {string} sk_user_id
* @property {string} token
**/
/**@typedef {Object} YggdrasilProfile
* @property {string} id
* @property {string} name
*/
/**@typedef {Object} SkirdaYggdrasilAuthResponse
* @property {YggdrasilProfile} profile
*/
class skirdaTelegramAuth {
/**
* @return SkirdaTelegramAuthInitResponse
* */
async init() {
const resp = await fetch(`${sk_tg_auth_api_url}/telegram/init`, {})
try {
if (!resp.ok) {
throw new Error(`Response status: ${resp.status}`)
}
// console.log(await resp.json())
return await resp.json()
} catch (error) {
console.error(error.message)
return null
}
}
/**
* @param {string} in_sub_url
* @return SkirdaTelegramAuthResultResponse
* */
async subscribe(in_sub_url) {
const resp = await fetch(in_sub_url, {})
try {
if (!resp.ok) {
throw new Error(`Response status: ${resp.status}`)
}
return await resp.json()
} catch (error) {
console.error(error.message)
return null
}
}
/**
* @param {string} jwtToken
* @return SkirdaYggdrasilAuthResponse
* */
async yggdrasilAuth(jwtToken) {
const ygg_auth_api_url = 'https://skirda.brzezinski.ru'
const resp = await fetch(`${ygg_auth_api_url}/yggdrasil/skirda/authenticate`, {
headers: {
// 'Content-Type': 'application/json',
'Authorization': jwtToken
}
})
try {
return await resp.json()
} catch (error) {
console.error(error.message)
}
}
}
async function InitSkirdaTelegramAuth() {
const auth = new skirdaTelegramAuth()
const initResp = await auth.init()
if (initResp === null) {
console.error('tg auth init failed')
return
}
console.log(initResp)
await shell.openExternal(initResp.redirect_url)
const authResult = await auth.subscribe(initResp.subscribe_url)
console.log(authResult)
const yggResp = await auth.yggdrasilAuth(authResult.token)
// console.log(yggResp)
// console.log(yggResp.profile)
AuthManager.addSkirdaAccount(yggResp.profile.id, authResult.token, authResult.name, authResult.name, authResult.token).then((value) => {
console.log(value)
updateSelectedAccount(value)
}).then((value) => {
switchView(VIEWS.loginSkirdaTelegram, VIEWS.landing, 500, 500, async () => {
})
})
}

View File

@ -19,6 +19,7 @@ const VIEWS = {
loginOptions: '#loginOptionsContainer',
login: '#loginContainer',
loginSkirdaDiscord: '#loginSkirdaDiscordContainer',
loginSkirdaTelegram: '#loginSkirdaTelegramContainer',
loginOffline: '#loginOfflineContainer',
settings: '#settingsContainer',
welcome: '#welcomeContainer',

View File

@ -4,6 +4,19 @@
<h2><%- lang('loginOptions.loginOptionsTitle') %></h2>
<div class="loginOptionActions">
<!-- Отключенные авторизации -->
<div class="loginOptionButtonContainer">
<button id="loginOptionSkirdaTelegram" class="loginOptionButton">
<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 23 23">
<path fill="#f35325" d="M1 1h10v10H1z" />
<path fill="#81bc06" d="M12 1h10v10H12z" />
<path fill="#05a6f0" d="M1 12h10v10H1z" />
<path fill="#ffba08" d="M12 12h10v10H12z" />
</svg>
<!-- FIXME -->
<!-- <span><%- lang('loginOptions.loginWithSkirdaTelegram') %></span>-->
<span>Telegram</span>
</button>
</div>
<div class="loginOptionButtonContainer" style="display: none;">
<button id="loginOptionMicrosoft" class="loginOptionButton">
<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 23 23">
@ -25,7 +38,8 @@
<span><%- lang('loginOptions.loginWithMojang') %></span>
</button>
</div>
<div class="loginOptionButtonContainer" style="display: none;">
<div class="loginOptionButtonContainer">
<!-- <div class="loginOptionButtonContainer" style="display: none;">-->
<button id="loginOptionOffline" class="loginOptionButton">
<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 9.677 9.667">
<path d="M-26.332-12.098h2.715c-1.357.18-2.574 1.23-2.715 2.633z" fill="#fff" />

View File

@ -0,0 +1,42 @@
<div id="loginSkirdaTelegramContainer" style="display: none;" class="Centered">
<!--Окно открытия браузера (ожидание ответа)-->
<div id="loginSkirdaAuthorizationWindow">
<div id="settingsAboutCurrentContent" class="Centered">
<div id="settingsAboutCurrentHeadline">
<img id="settingsAboutLogo" src="./assets/images/SealCircle.png">
<span id="settingsAboutTitle">Authorize through Skirda Discord</span>
</div>
<div id="settingsAboutCurrentVersion" class="Centered">
<span>Мы открыли браузер для дальнейшей авторизации через DiscordAAAAAAAAAAA</span>
</div>
</div>
<div id="settingsAboutButtons">
<span id="loginSkirdaAuthorizationNote">В случае, если это не произошло, откройте его самостоятельно</span>
</div>
</div>
<!--Ошибка-->
<!-- <div id="loginSkirdaAuthorizationWindow">-->
<!-- <div id="settingsAboutCurrentContent" class="Centered">-->
<!-- <div id="settingsAboutCurrentHeadline">-->
<!-- <img id="settingsAboutLogo" src="./assets/images/SealCircle.png">-->
<!-- <span id="settingsAboutTitle">Authorize through Skirda Discord</span>-->
<!-- </div>-->
<!-- <div id="settingsAboutCurrentVersion" class="Centered">-->
<!-- <span>Ошибка при авторизации :(</span>-->
<!-- </div>-->
<!-- <div class="settingsAboutCurrentContent">-->
<!-- <button id="loginSkirdaAuthorizationRetryButton">Повторить</button>-->
<!-- <button class="settingsAuthAccountLogOut" style="opacity: 100%;">Отменить</button>-->
<!-- </div>-->
<!-- </div>-->
<!-- <div id="settingsAboutButtons">-->
<!-- <span id="loginSkirdaAuthorizationNote">Не получается? Обратитесь к администрации проекта за помощью</span>-->
<!-- </div> -->
<!-- </div>-->
</div>
<script src="./assets/js/scripts/skirda/auth/telegram.js"></script>