mirror of
				https://github.com/MaximilianGT500/testflight-watcher.git
				synced 2025-11-04 10:28:53 +01:00 
			
		
		
		
	Version 0.0.2 - FIxed delete-url
This commit is contained in:
		
							parent
							
								
									fdaeee4cd7
								
							
						
					
					
						commit
						7b829ce606
					
				@ -70,7 +70,7 @@ PUSHOVER_APP_TOKEN=dein_pushover_app_token
 | 
				
			|||||||
TESTFLIGHT_URLS='[{"name":"App 1", "url":"https://testflight.apple.com/join/abcd1234"}]'
 | 
					TESTFLIGHT_URLS='[{"name":"App 1", "url":"https://testflight.apple.com/join/abcd1234"}]'
 | 
				
			||||||
OTP_SECRET=AendereDiesenString
 | 
					OTP_SECRET=AendereDiesenString
 | 
				
			||||||
OTP_VALIDITY=300
 | 
					OTP_VALIDITY=300
 | 
				
			||||||
USER_AGENT=Testflight-Watcher/0.0.1
 | 
					USER_AGENT=Testflight-Watcher/0.0.2
 | 
				
			||||||
PORT=3000
 | 
					PORT=3000
 | 
				
			||||||
HTTP_URL=http://localhost:3000
 | 
					HTTP_URL=http://localhost:3000
 | 
				
			||||||
PUSHOVER_PRIORITY=1
 | 
					PUSHOVER_PRIORITY=1
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										18
									
								
								index.js
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								index.js
									
									
									
									
									
								
							@ -9,21 +9,21 @@ const crypto = require("crypto");
 | 
				
			|||||||
const path = require("path");
 | 
					const path = require("path");
 | 
				
			||||||
const express = require("express");
 | 
					const express = require("express");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const CURRENT_VERSION = "0.0.1";
 | 
					const CURRENT_VERSION = "0.0.2";
 | 
				
			||||||
const UPDATE_CHECK_URL =
 | 
					const UPDATE_CHECK_URL =
 | 
				
			||||||
  "https://git.lunoxia.net/MaximilianGT500/testflight-watcher/raw/branch/main/version.json";
 | 
					  "https://git.lunoxia.net/MaximilianGT500/testflight-watcher/raw/branch/main/version.json";
 | 
				
			||||||
const SETUP_FILE_NAME = process.env.SETUP_FILE_NAME || "setup.js";
 | 
					const SETUP_FILE_NAME = process.env.SETUP_FILE_NAME || "setup.js";
 | 
				
			||||||
const SERVER_FILE_NAME = process.env.SERVER_FILE_NAME || "index.js";
 | 
					const SERVER_FILE_NAME = process.env.SERVER_FILE_NAME || "index.js";
 | 
				
			||||||
const USER_AGENT =
 | 
					const USER_AGENT =
 | 
				
			||||||
  process.env.USER_AGENT || "Testflight-Watcher/0.0.1 (Monitoring Script)";
 | 
					  process.env.USER_AGENT || "Testflight-Watcher/0.0.2 (Monitoring Script)";
 | 
				
			||||||
const OTP_SECRET = process.env.OTP_SECRET || "AendereDiesenString";
 | 
					const OTP_SECRET = process.env.OTP_SECRET || "AendereDiesenString";
 | 
				
			||||||
const OTP_VALIDITY = process.env.OTP_VALIDITY || "300";
 | 
					const OTP_VALIDITY = process.env.OTP_VALIDITY || "5 * 60 * 1000";
 | 
				
			||||||
const PORT = process.env.PORT || "3000";
 | 
					const PORT = process.env.PORT || "3000";
 | 
				
			||||||
const HTTP_URL = process.env.HTTP_URL || `http://localhost:${PORT}`;
 | 
					const HTTP_URL = process.env.HTTP_URL || `http://localhost:${PORT}`;
 | 
				
			||||||
const PUSHOVER_PRIORITY = process.env.PUSHOVER_PRIORITY || `1`;
 | 
					const PUSHOVER_PRIORITY = process.env.PUSHOVER_PRIORITY || `1`;
 | 
				
			||||||
const CHECK_INTERVAL = process.env.CHECK_INTERVAL || `30`;
 | 
					const CHECK_INTERVAL = process.env.CHECK_INTERVAL || `30`;
 | 
				
			||||||
let TESTFLIGHT_URLS = [];
 | 
					let TESTFLIGHT_URLS = [];
 | 
				
			||||||
let OTP_STOREAGE = {};
 | 
					let OTP_STORAGE = {};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function loadConfig() {
 | 
					function loadConfig() {
 | 
				
			||||||
  if (!fs.existsSync(".env")) {
 | 
					  if (!fs.existsSync(".env")) {
 | 
				
			||||||
@ -146,7 +146,7 @@ async function checkTestFlight(app, pushoverAPI) {
 | 
				
			|||||||
      return clc.red(`❌ ${app.name}: Beta akzeptiert keine neuen Tester.`);
 | 
					      return clc.red(`❌ ${app.name}: Beta akzeptiert keine neuen Tester.`);
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      const otp = generateOTP(app.url);
 | 
					      const otp = generateOTP(app.url);
 | 
				
			||||||
      OTP_STOREAGE[app.url] = otp;
 | 
					      OTP_STORAGE[app.url] = otp;
 | 
				
			||||||
      await sendPushoverNotification(
 | 
					      await sendPushoverNotification(
 | 
				
			||||||
        pushoverAPI,
 | 
					        pushoverAPI,
 | 
				
			||||||
        `🎉 TestFlight Beta verfügbar für ${app.name}!`,
 | 
					        `🎉 TestFlight Beta verfügbar für ${app.name}!`,
 | 
				
			||||||
@ -176,7 +176,7 @@ async function sendPushoverNotification(pushoverAPI, title, message) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function generateOTP(url) {
 | 
					function generateOTP(url) {
 | 
				
			||||||
  const timeWindow = Math.floor((Date.now() / OTP_VALIDITY) * 1000);
 | 
					  const timeWindow = Math.floor(Date.now() / OTP_VALIDITY);
 | 
				
			||||||
  return crypto
 | 
					  return crypto
 | 
				
			||||||
    .createHmac("sha256", OTP_SECRET)
 | 
					    .createHmac("sha256", OTP_SECRET)
 | 
				
			||||||
    .update(`${timeWindow}-${url}`)
 | 
					    .update(`${timeWindow}-${url}`)
 | 
				
			||||||
@ -185,15 +185,15 @@ function generateOTP(url) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function verifyOTP(otp, url) {
 | 
					function verifyOTP(otp, url) {
 | 
				
			||||||
  const timeWindow = Math.floor((Date.now() / OTP_VALIDITY) * 1000);
 | 
					  const timeWindow = Math.floor(Date.now() / OTP_VALIDITY);
 | 
				
			||||||
  const validOTP = crypto
 | 
					  const validOTP = crypto
 | 
				
			||||||
    .createHmac("sha256", OTP_SECRET)
 | 
					    .createHmac("sha256", OTP_SECRET)
 | 
				
			||||||
    .update(`${timeWindow}-${url}`)
 | 
					    .update(`${timeWindow}-${url}`)
 | 
				
			||||||
    .digest("hex")
 | 
					    .digest("hex")
 | 
				
			||||||
    .slice(0, 6);
 | 
					    .slice(0, 6);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (otp === validOTP && OTP_STOREAGE[url] === otp) {
 | 
					  if (otp === validOTP && OTP_STORAGE[url] === otp) {
 | 
				
			||||||
    delete OTP_STOREAGE[url];
 | 
					    delete OTP_STORAGE[url];
 | 
				
			||||||
    return true;
 | 
					    return true;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  return false;
 | 
					  return false;
 | 
				
			||||||
 | 
				
			|||||||
@ -8,7 +8,7 @@
 | 
				
			|||||||
    "nodemon": "^3.1.7"
 | 
					    "nodemon": "^3.1.7"
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  "name": "testflight-watcher",
 | 
					  "name": "testflight-watcher",
 | 
				
			||||||
  "version": "0.0.1",
 | 
					  "version": "0.0.2",
 | 
				
			||||||
  "description": "Dies ist ein einfacher TestFlight-Watcher, der alle 30 Sekunden die Website auf verfügbare Plätze überprüft. Sobald ein Platz frei wird, erfolgt eine Benachrichtigung über Pushover.",
 | 
					  "description": "Dies ist ein einfacher TestFlight-Watcher, der alle 30 Sekunden die Website auf verfügbare Plätze überprüft. Sobald ein Platz frei wird, erfolgt eine Benachrichtigung über Pushover.",
 | 
				
			||||||
  "main": "index.js",
 | 
					  "main": "index.js",
 | 
				
			||||||
  "scripts": {
 | 
					  "scripts": {
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										24
									
								
								setup.js
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								setup.js
									
									
									
									
									
								
							@ -184,6 +184,7 @@ async function sendPushoverNotification(userKey, appToken, title, message) {
 | 
				
			|||||||
    throw err;
 | 
					    throw err;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
async function configureEnvironment() {
 | 
					async function configureEnvironment() {
 | 
				
			||||||
  const env = loadEnv();
 | 
					  const env = loadEnv();
 | 
				
			||||||
  displayMessage("\n🎉 Willkommen zum Setup!\n", "info");
 | 
					  displayMessage("\n🎉 Willkommen zum Setup!\n", "info");
 | 
				
			||||||
@ -197,9 +198,8 @@ async function configureEnvironment() {
 | 
				
			|||||||
    },
 | 
					    },
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      key: "OTP_VALIDITY",
 | 
					      key: "OTP_VALIDITY",
 | 
				
			||||||
      prompt:
 | 
					      prompt: 'Gültigkeitsdauer für das OTP in Minuten (z.B. "5" für 5 Min.)',
 | 
				
			||||||
        'Gültigkeitsdauer für das OTP in Sekunden (z.B. "300" für 5 Min.)',
 | 
					      defaultValue: "5 * 60 * 1000",
 | 
				
			||||||
      defaultValue: "300",
 | 
					 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      key: "SETUP_FILE_NAME",
 | 
					      key: "SETUP_FILE_NAME",
 | 
				
			||||||
@ -208,7 +208,7 @@ async function configureEnvironment() {
 | 
				
			|||||||
    },
 | 
					    },
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      key: "SERVER_FILE_NAME",
 | 
					      key: "SERVER_FILE_NAME",
 | 
				
			||||||
      prompt: "Name der Server-Datei (Fals Du ihn angepasst hast)",
 | 
					      prompt: "Name der Server-Datei (Falls Du ihn angepasst hast)",
 | 
				
			||||||
      defaultValue: "index.js",
 | 
					      defaultValue: "index.js",
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
@ -225,7 +225,7 @@ async function configureEnvironment() {
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
      key: "USER_AGENT",
 | 
					      key: "USER_AGENT",
 | 
				
			||||||
      prompt: "User-Agent für Anfragen",
 | 
					      prompt: "User-Agent für Anfragen",
 | 
				
			||||||
      defaultValue: "Testflight-Watcher/0.0.1 (Monitoring Script)",
 | 
					      defaultValue: "Testflight-Watcher/0.0.2 (Monitoring Script)",
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      key: "PUSHOVER_PRIORITY",
 | 
					      key: "PUSHOVER_PRIORITY",
 | 
				
			||||||
@ -236,7 +236,7 @@ async function configureEnvironment() {
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
      key: "CHECK_INTERVAL",
 | 
					      key: "CHECK_INTERVAL",
 | 
				
			||||||
      prompt:
 | 
					      prompt:
 | 
				
			||||||
        "In welchen Abstand soll das Script nach einen neuen Platz prüfen in Sekunden (z.B. 30)",
 | 
					        "In welchem Abstand soll das Script nach einem neuen Platz prüfen in Sekunden (z.B. 30)",
 | 
				
			||||||
      defaultValue: "30",
 | 
					      defaultValue: "30",
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
  ];
 | 
					  ];
 | 
				
			||||||
@ -250,11 +250,19 @@ async function configureEnvironment() {
 | 
				
			|||||||
      continue;
 | 
					      continue;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const currentValue = defaultValue;
 | 
					    let currentValue = defaultValue;
 | 
				
			||||||
    const answer = await prompt(
 | 
					    const answer = await prompt(
 | 
				
			||||||
      clc.cyan(`${question} [Standard: ${currentValue}]: `)
 | 
					      clc.cyan(`${question} [Standard: ${currentValue}]: `)
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
    env[key] = answer || currentValue;
 | 
					
 | 
				
			||||||
 | 
					    if (key === "OTP_VALIDITY") {
 | 
				
			||||||
 | 
					      const minutes = parseFloat(answer || "5");
 | 
				
			||||||
 | 
					      currentValue = `${minutes} * 60 * 1000`;
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					      currentValue = answer || currentValue;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    env[key] = currentValue;
 | 
				
			||||||
    saveEnv(env);
 | 
					    saveEnv(env);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -1,3 +1,3 @@
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    "version": "0.0.1"
 | 
					    "version": "0.0.2"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user