diff --git a/index.html b/index.html index 4f88e87..5427cbd 100644 --- a/index.html +++ b/index.html @@ -59,10 +59,13 @@
+ required="required" oninput="HandlePasswordInput();"> + required="required" oninput="HandlePasswordInput();"> +
+ @@ -72,7 +75,7 @@ required="required"> - + @@ -91,6 +94,7 @@ + \ No newline at end of file diff --git a/static/script.js b/static/script.js index e69de29..7d6fe9b 100644 --- a/static/script.js +++ b/static/script.js @@ -0,0 +1,50 @@ +async function handleSubmit() { + var nonce_request = await fetch("https://matrix-reg.test.lauka.dev/_synapse/admin/v1/register", { + method: 'GET', + redirect: 'follow', + mode: "cors" + }) + var nonce = await nonce_request.json() + + var username = document.getElementById("username").value + var password = document.getElementById("password").value + var sharedsecret = document.getElementById("sharedsecret").value + var admin = "notadmin" + + var string = `${nonce.nonce}\0${username}\0${password}\0${admin}` + + + const hash = new jsSHA("SHA-1", "TEXT", { hmacKey : { value : sharedsecret, format: "TEXT" }}) +} + +function HandlePasswordInput() { + var info = document.getElementById("password-info") + var button = document.getElementById("submit-button") + + var messages = [] + + var password = document.getElementById("password").value + var passwordrepeat = document.getElementById("password-repeat").value + + if (password.length < 20) { + messages.push("Password must be 20 letters or more.") + } + + if (!(password === passwordrepeat)) { + messages.push("Passwords must match.") + } + + if (messages.length == 0) { + info.style.display = 'none' + button.removeAttribute('disabled') + } else if (messages.length == 1) { + info.style.display = 'block' + info.innerHTML = messages[0] + button.setAttribute('disabled','disabled'); + } else { + info.style.display = 'block' + string = messages.join("
") + info.innerHTML = string + button.setAttribute('disabled','disabled'); + } +} \ No newline at end of file diff --git a/static/sha1.js b/static/sha1.js new file mode 100644 index 0000000..9b933ea --- /dev/null +++ b/static/sha1.js @@ -0,0 +1,21 @@ +/** + * A JavaScript implementation of the SHA family of hashes - defined in FIPS PUB 180-4, FIPS PUB 202, + * and SP 800-185 - as well as the corresponding HMAC implementation as defined in FIPS PUB 198-1. + * + * Copyright 2008-2022 Brian Turek, 1998-2009 Paul Johnston & Contributors + * Distributed under the BSD License + * See http://caligatio.github.com/jsSHA/ for more information + * + * Two ECMAScript polyfill functions carry the following license: + * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, + * INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, + * MERCHANTABLITY OR NON-INFRINGEMENT. + * + * See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. + */ +!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(t="undefined"!=typeof globalThis?globalThis:t||self).jsSHA=r()}(this,(function(){"use strict";var t=function(r,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])},t(r,n)};var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n="ARRAYBUFFER not supported by this environment",i="UINT8ARRAY not supported by this environment";function e(t,r,n,i){var e,o,u,s=r||[0],f=(n=n||0)>>>3,h=-1===i?3:0;for(e=0;e>>2,s.length<=o&&s.push(0),s[o]|=t[e]<<8*(h+i*(u%4));return{value:s,binLen:8*t.length+n}}function o(t,o,u){switch(o){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw new Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":return function(t,r,n){return function(t,r,n,i){var e,o,u,s;if(0!=t.length%2)throw new Error("String of HEX type must be in byte increments");var f=r||[0],h=(n=n||0)>>>3,a=-1===i?3:0;for(e=0;e>>1)+h)>>>2;f.length<=u;)f.push(0);f[u]|=o<<8*(a+i*(s%4))}return{value:f,binLen:4*t.length+n}}(t,r,n,u)};case"TEXT":return function(t,r,n){return function(t,r,n,i,e){var o,u,s,f,h,a,c,w,E=0,v=n||[0],l=(i=i||0)>>>3;if("UTF8"===r)for(c=-1===e?3:0,s=0;s(o=t.charCodeAt(s))?u.push(o):2048>o?(u.push(192|o>>>6),u.push(128|63&o)):55296>o||57344<=o?u.push(224|o>>>12,128|o>>>6&63,128|63&o):(s+=1,o=65536+((1023&o)<<10|1023&t.charCodeAt(s)),u.push(240|o>>>18,128|o>>>12&63,128|o>>>6&63,128|63&o)),f=0;f>>2;v.length<=h;)v.push(0);v[h]|=u[f]<<8*(c+e*(a%4)),E+=1}else for(c=-1===e?2:0,w="UTF16LE"===r&&1!==e||"UTF16LE"!==r&&1===e,s=0;s>>8),h=(a=E+l)>>>2;v.length<=h;)v.push(0);v[h]|=o<<8*(c+e*(a%4)),E+=2}return{value:v,binLen:8*E+i}}(t,o,r,n,u)};case"B64":return function(t,n,i){return function(t,n,i,e){var o,u,s,f,h,a,c=0,w=n||[0],E=(i=i||0)>>>3,v=-1===e?3:0,l=t.indexOf("=");if(-1===t.search(/^[a-zA-Z0-9=+/]+$/))throw new Error("Invalid character in base-64 string");if(t=t.replace(/=/g,""),-1!==l&&l