Add test/local environment configurations and fix #147

This commit is contained in:
Max Myers
2021-10-19 14:26:19 -04:00
parent c6d1f69fd4
commit cfcf2f0890
15 changed files with 203 additions and 16 deletions
+6 -4
View File
@@ -1,6 +1,8 @@
import { app, protocol, ipcMain, Menu, MenuItemConstructorOptions, BrowserWindow, shell } from 'electron';
import { StateStorage, EnvironmentConfig } from './state-storage';
import { AppWindow } from './window';
import { getEnvCfg } from './env-config';
const path = require('path');
const { autoUpdater } = require('electron-updater');
const download = require('./download');
@@ -32,7 +34,7 @@ class ADB {
}
async checkAPK(updateStatus: (string) => void, filePath: string): Promise<boolean> {
const hash = await this.computeFileHash(updateStatus, filePath);
const url = `https://sdq.st/check-app-hash/${hash}`;
const url = `${getEnvCfg().shortenerUrl || 'https://sdq.st'}/check-app-hash/${hash}`;
updateStatus('Checking APK against blacklist...');
return new Promise((resolve, reject) => {
let options = {
@@ -41,7 +43,7 @@ class ADB {
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
Origin: 'https://sidequestvr.com',
Origin: getEnvCfg().web_url,
},
rejectUnauthorized: process.env.NODE_ENV !== 'dev',
};
@@ -102,12 +104,12 @@ class ADB {
}
installFromToken(token, cb, ecb) {
let options = {
url: 'https://api.sidequestvr.com/install-from-key',
url: `${getEnvCfg().http_url || 'https://api.sidequestvr.com'}/install-from-key`,
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
Origin: 'https://sidequestvr.com',
Origin: getEnvCfg().web_url || 'https://sidequestvr.com',
},
rejectUnauthorized: process.env.NODE_ENV !== 'dev',
json: { token: token },
+36
View File
@@ -0,0 +1,36 @@
export function getEnvCfg() {
switch (process.env['SQ_ENV_CFG']) {
case 'test':
return {
web_url: 'https://sidetestvr.com',
ws_url: 'wss://ws.sidetestvr.com',
http_url: 'https://api.sidetestvr.com',
cdnUrl: 'https://cdn.sidetestvr.com',
shortenerUrl: 'https://links.sidetestvr.com',
};
case 'test2':
return {
web_url: 'https://test.side.quest',
ws_url: 'wss://testws.side.quest',
http_url: 'https://testapi.side.quest',
cdnUrl: 'https://testcdn.sidequestvr.com',
shortenerUrl: 'https://testlinks.side.quest',
};
case 'local':
return {
web_url: 'https://sidequestvr.local',
ws_url: 'wss://ws.sidetestvr.local',
http_url: 'https://api.sidetestvr.local',
cdnUrl: 'https://cdn.sidetestvr.local',
shortenerUrl: 'https://links.sidetestvr.local',
};
default:
return {
web_url: 'https://sidequestvr.com',
ws_url: 'wss://ws.sidequestvr.com',
http_url: 'https://api.sidequestvr.com',
cdnUrl: 'https://cdn.sidequestvr.com',
shortenerUrl: 'https://sdq.st',
};
}
}