Files
minisrv/zefie_wtvp_minisrv/ServiceVault/wtv-head-waiter/login.js
zefie df472ab91f v0.9.13
- wtv-cookie support
 - further development will be in dev branch (may rebase alot)
 - compression not yet ready, leave it disabled
 - update: do not delete WTVSec on last socket, instead recreate on prereg
 - update: clean up SSID session data only if client is not seen for 3 minutes
 - update: add shouldWeCompress() function
 - update: tweak lzpf (still corrupted)
 - update: rename wtv-setup:/get to wtv-setup:/get-settings
 - update: add additional headers to wtv-setup:/get-settings
 - update: add initial blank wtv-music:/get-playlist
 - update wtv-tricks system
   - Info now shows Guest Mode or Subscriber Info
   - Implemented wtv-tricks:/unregister
   - Implemented wtv-tricks:/register
   - Show correct link in wtv-tricks:/tricks based on Guest Mode status
 - config.json: enable compression by default
 - WTVP does not use \r, so swapping the internal header's usage for now. May remove internal header in future update
 - lzpf: this doesn't fix anything but doesn't break it more either :)
  - renamed some functions
  - fixed some param documentation
  - added ConvertToBuffer function
 - WTVSec Updates
  - optimize WordArray to Buffer functions
  - update documentation in WTVSec
  - update WTVSec barrowed function in WTVLzpf
  - removed NewRC4Session, was a pointless alias to SecureOn
2022-11-29 08:27:52 -05:00

72 lines
2.4 KiB
JavaScript

var challenge_response, challenge_header = "";
var gourl = "wtv-head-waiter:/login-stage-two?";
if (request_headers.query.relogin) gourl += "relogin=true";
else if (request_headers.query.reconnect) gourl += "reconnect=true";
if (request_headers.query.guest_login) {
if (request_headers.query.relogin || request_headers.query.reconnect) gourl += "&";
gourl += "guest_login=true";
if (request_headers.query.skip_splash) gourl += "&skip_splash=true";
}
var send_to_relogin = true;
if (socket.ssid) {
if (ssid_sessions[socket.ssid]) {
if (request_headers["wtv-ticket"]) {
if (ssid_sessions[socket.ssid].data_store.wtvsec_login.ticket_b64 == null) {
if (request_headers["wtv-ticket"].length > 8) {
ssid_sessions[socket.ssid].data_store.wtvsec_login.DecodeTicket(request_headers["wtv-ticket"]);
ssid_sessions[socket.ssid].data_store.wtvsec_login.ticket_b64 = request_headers["wtv-ticket"];
send_to_relogin = false;
}
}
} else {
if (ssid_sessions[socket.ssid].data_store.wtvsec_login) {
var client_challenge_response = request_headers["wtv-challenge-response"] || null;
if (challenge_response && client_challenge_response) {
if (challenge_response.toString(CryptoJS.enc.Base64).substring(0, 85) == client_challenge_response.substring(0, 85)) {
console.log(" * wtv-challenge-response success for " + socket.ssid);
ssid_sessions[socket.ssid].data_store.wtvsec_login.PrepareTicket();
send_to_relogin = false;
} else {
challenge_header = "wtv-challenge: " + ssid_sessions[socket.ssid].data_store.wtvsec_login.IssueChallenge();
send_to_relogin = false;
}
} else {
challenge_header = "wtv-challenge: " + ssid_sessions[socket.ssid].data_store.wtvsec_login.IssueChallenge();
send_to_relogin = false;
}
}
}
}
}
if (!send_to_relogin) {
headers = `200 OK
Connection: Keep-Alive
Expires: Wed, 09 Oct 1991 22:00:00 GMT
wtv-expire-all: wtv-head-waiter:
`+ getServiceString('wtv-log') + `
wtv-log-url: wtv-log:/log`;
if (challenge_header != "") headers += "\n" + challenge_header;
headers += `
wtv-relogin-url: wtv-1800:/preregister?relogin=true
wtv-reconnect-url: wtv-1800:/preregister?reconnect=true
wtv-visit: ${gourl}
Content-type: text/html`;
data = '';
} else {
headers = `200 OK
Connection: Keep-Alive
Expires: Wed, 09 Oct 1991 22:00:00 GMT
wtv-expire-all: wtv-head-waiter:
wtv-expire-all: wtv-1800:
wtv-visit: wtv-1800:/preregister?relogin=true
Content-type: text/html`;
data = '';
}