OpenAuth_server/FrontendLegacy/out/login/login.html

3218 lines
127 KiB
HTML

<html>
<head>
<title>{{i18n "Login"}}</title>
<meta charset="utf8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<style>
.mdc-touch-target-wrapper {
display: inline;
}
.mdc-elevation-overlay {
position: absolute;
border-radius: inherit;
opacity: 0;
pointer-events: none;
transition: opacity 280ms cubic-bezier(0.4, 0, 0.2, 1);
background-color: #fff;
}
.mdc-button {
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
font-family: Roboto, sans-serif;
font-family: var(
--mdc-typography-button-font-family,
var(--mdc-typography-font-family, Roboto, sans-serif)
);
font-size: 0.875rem;
font-size: var(--mdc-typography-button-font-size, 0.875rem);
line-height: 2.25rem;
line-height: var(--mdc-typography-button-line-height, 2.25rem);
font-weight: 500;
font-weight: var(--mdc-typography-button-font-weight, 500);
letter-spacing: 0.0892857143em;
letter-spacing: var(
--mdc-typography-button-letter-spacing,
0.0892857143em
);
text-decoration: none;
text-decoration: var(--mdc-typography-button-text-decoration, none);
text-transform: uppercase;
text-transform: var(
--mdc-typography-button-text-transform,
uppercase
);
padding: 0 8px 0 8px;
position: relative;
display: inline-flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
min-width: 64px;
border: none;
outline: none;
line-height: inherit;
user-select: none;
-webkit-appearance: none;
overflow: visible;
vertical-align: middle;
border-radius: 4px;
}
.mdc-button .mdc-elevation-overlay {
width: 100%;
height: 100%;
top: 0;
left: 0;
}
.mdc-button::-moz-focus-inner {
padding: 0;
border: 0;
}
.mdc-button:active {
outline: none;
}
.mdc-button:hover {
cursor: pointer;
}
.mdc-button:disabled {
cursor: default;
pointer-events: none;
}
.mdc-button .mdc-button__ripple {
border-radius: 4px;
}
.mdc-button:not(:disabled) {
background-color: transparent;
}
.mdc-button:disabled {
background-color: transparent;
}
.mdc-button .mdc-button__icon {
margin-left: 0;
margin-right: 8px;
display: inline-block;
width: 18px;
height: 18px;
font-size: 18px;
vertical-align: top;
}
[dir="rtl"] .mdc-button .mdc-button__icon,
.mdc-button .mdc-button__icon[dir="rtl"] {
margin-left: 8px;
margin-right: 0;
}
.mdc-button .mdc-button__touch {
position: absolute;
top: 50%;
right: 0;
height: 48px;
left: 0;
transform: translateY(-50%);
}
.mdc-button:not(:disabled) {
color: #6200ee;
color: var(--mdc-theme-primary, #6200ee);
}
.mdc-button:disabled {
color: rgba(0, 0, 0, 0.38);
}
.mdc-button__label + .mdc-button__icon {
margin-left: 8px;
margin-right: 0;
}
[dir="rtl"] .mdc-button__label + .mdc-button__icon,
.mdc-button__label + .mdc-button__icon[dir="rtl"] {
margin-left: 0;
margin-right: 8px;
}
svg.mdc-button__icon {
fill: currentColor;
}
.mdc-button--raised .mdc-button__icon,
.mdc-button--unelevated .mdc-button__icon,
.mdc-button--outlined .mdc-button__icon {
margin-left: -4px;
margin-right: 8px;
}
[dir="rtl"] .mdc-button--raised .mdc-button__icon,
.mdc-button--raised .mdc-button__icon[dir="rtl"],
[dir="rtl"] .mdc-button--unelevated .mdc-button__icon,
.mdc-button--unelevated .mdc-button__icon[dir="rtl"],
[dir="rtl"] .mdc-button--outlined .mdc-button__icon,
.mdc-button--outlined .mdc-button__icon[dir="rtl"] {
margin-left: 8px;
margin-right: -4px;
}
.mdc-button--raised .mdc-button__label + .mdc-button__icon,
.mdc-button--unelevated .mdc-button__label + .mdc-button__icon,
.mdc-button--outlined .mdc-button__label + .mdc-button__icon {
margin-left: 8px;
margin-right: -4px;
}
[dir="rtl"] .mdc-button--raised .mdc-button__label + .mdc-button__icon,
.mdc-button--raised .mdc-button__label + .mdc-button__icon[dir="rtl"],
[dir="rtl"]
.mdc-button--unelevated
.mdc-button__label
+ .mdc-button__icon,
.mdc-button--unelevated
.mdc-button__label
+ .mdc-button__icon[dir="rtl"],
[dir="rtl"]
.mdc-button--outlined
.mdc-button__label
+ .mdc-button__icon,
.mdc-button--outlined
.mdc-button__label
+ .mdc-button__icon[dir="rtl"] {
margin-left: -4px;
margin-right: 8px;
}
.mdc-button--raised,
.mdc-button--unelevated {
padding: 0 16px 0 16px;
}
.mdc-button--raised:not(:disabled),
.mdc-button--unelevated:not(:disabled) {
background-color: #6200ee;
background-color: var(--mdc-theme-primary, #6200ee);
}
.mdc-button--raised:not(:disabled),
.mdc-button--unelevated:not(:disabled) {
color: #fff;
color: var(--mdc-theme-on-primary, #fff);
}
.mdc-button--raised:disabled,
.mdc-button--unelevated:disabled {
background-color: rgba(0, 0, 0, 0.12);
}
.mdc-button--raised:disabled,
.mdc-button--unelevated:disabled {
color: rgba(0, 0, 0, 0.38);
}
.mdc-button--raised {
box-shadow: 0px 3px 1px -2px rgba(0, 0, 0, 0.2),
0px 2px 2px 0px rgba(0, 0, 0, 0.14),
0px 1px 5px 0px rgba(0, 0, 0, 0.12);
transition: box-shadow 280ms cubic-bezier(0.4, 0, 0.2, 1);
}
.mdc-button--raised:hover,
.mdc-button--raised:focus {
box-shadow: 0px 2px 4px -1px rgba(0, 0, 0, 0.2),
0px 4px 5px 0px rgba(0, 0, 0, 0.14),
0px 1px 10px 0px rgba(0, 0, 0, 0.12);
}
.mdc-button--raised:active {
box-shadow: 0px 5px 5px -3px rgba(0, 0, 0, 0.2),
0px 8px 10px 1px rgba(0, 0, 0, 0.14),
0px 3px 14px 2px rgba(0, 0, 0, 0.12);
}
.mdc-button--raised:disabled {
box-shadow: 0px 0px 0px 0px rgba(0, 0, 0, 0.2),
0px 0px 0px 0px rgba(0, 0, 0, 0.14),
0px 0px 0px 0px rgba(0, 0, 0, 0.12);
}
.mdc-button--outlined {
padding: 0 15px 0 15px;
border-width: 1px;
border-style: solid;
}
.mdc-button--outlined .mdc-button__ripple {
top: -1px;
left: -1px;
border: 1px solid transparent;
}
.mdc-button--outlined:not(:disabled) {
border-color: rgba(0, 0, 0, 0.12);
}
.mdc-button--outlined:disabled {
border-color: rgba(0, 0, 0, 0.12);
}
.mdc-button--touch {
margin-top: 6px;
margin-bottom: 6px;
}
@keyframes mdc-ripple-fg-radius-in {
from {
animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
transform: translate(var(--mdc-ripple-fg-translate-start, 0))
scale(1);
}
to {
transform: translate(var(--mdc-ripple-fg-translate-end, 0))
scale(var(--mdc-ripple-fg-scale, 1));
}
}
@keyframes mdc-ripple-fg-opacity-in {
from {
animation-timing-function: linear;
opacity: 0;
}
to {
opacity: var(--mdc-ripple-fg-opacity, 0);
}
}
@keyframes mdc-ripple-fg-opacity-out {
from {
animation-timing-function: linear;
opacity: var(--mdc-ripple-fg-opacity, 0);
}
to {
opacity: 0;
}
}
.mdc-button {
--mdc-ripple-fg-size: 0;
--mdc-ripple-left: 0;
--mdc-ripple-top: 0;
--mdc-ripple-fg-scale: 1;
--mdc-ripple-fg-translate-end: 0;
--mdc-ripple-fg-translate-start: 0;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
.mdc-button .mdc-button__ripple::before,
.mdc-button .mdc-button__ripple::after {
position: absolute;
border-radius: 50%;
opacity: 0;
pointer-events: none;
content: "";
}
.mdc-button .mdc-button__ripple::before {
transition: opacity 15ms linear, background-color 15ms linear;
z-index: 1;
}
.mdc-button.mdc-ripple-upgraded .mdc-button__ripple::before {
transform: scale(var(--mdc-ripple-fg-scale, 1));
}
.mdc-button.mdc-ripple-upgraded .mdc-button__ripple::after {
top: 0;
left: 0;
transform: scale(0);
transform-origin: center center;
}
.mdc-button.mdc-ripple-upgraded--unbounded .mdc-button__ripple::after {
top: var(--mdc-ripple-top, 0);
left: var(--mdc-ripple-left, 0);
}
.mdc-button.mdc-ripple-upgraded--foreground-activation
.mdc-button__ripple::after {
animation: mdc-ripple-fg-radius-in 225ms forwards,
mdc-ripple-fg-opacity-in 75ms forwards;
}
.mdc-button.mdc-ripple-upgraded--foreground-deactivation
.mdc-button__ripple::after {
animation: mdc-ripple-fg-opacity-out 150ms;
transform: translate(var(--mdc-ripple-fg-translate-end, 0))
scale(var(--mdc-ripple-fg-scale, 1));
}
.mdc-button .mdc-button__ripple::before,
.mdc-button .mdc-button__ripple::after {
top: calc(50% - 100%);
left: calc(50% - 100%);
width: 200%;
height: 200%;
}
.mdc-button.mdc-ripple-upgraded .mdc-button__ripple::after {
width: var(--mdc-ripple-fg-size, 100%);
height: var(--mdc-ripple-fg-size, 100%);
}
.mdc-button .mdc-button__ripple::before,
.mdc-button .mdc-button__ripple::after {
background-color: #6200ee;
background-color: var(--mdc-theme-primary, #6200ee);
}
.mdc-button:hover .mdc-button__ripple::before {
opacity: 0.04;
}
.mdc-button.mdc-ripple-upgraded--background-focused
.mdc-button__ripple::before,
.mdc-button:not(.mdc-ripple-upgraded):focus
.mdc-button__ripple::before {
transition-duration: 75ms;
opacity: 0.12;
}
.mdc-button:not(.mdc-ripple-upgraded) .mdc-button__ripple::after {
transition: opacity 150ms linear;
}
.mdc-button:not(.mdc-ripple-upgraded):active
.mdc-button__ripple::after {
transition-duration: 75ms;
opacity: 0.12;
}
.mdc-button.mdc-ripple-upgraded {
--mdc-ripple-fg-opacity: 0.12;
}
.mdc-button .mdc-button__ripple {
position: absolute;
box-sizing: content-box;
width: 100%;
height: 100%;
overflow: hidden;
}
.mdc-button:not(.mdc-button--outlined) .mdc-button__ripple {
top: 0;
left: 0;
}
.mdc-button--raised .mdc-button__ripple::before,
.mdc-button--raised .mdc-button__ripple::after,
.mdc-button--unelevated .mdc-button__ripple::before,
.mdc-button--unelevated .mdc-button__ripple::after {
background-color: #fff;
background-color: var(--mdc-theme-on-primary, #fff);
}
.mdc-button--raised:hover .mdc-button__ripple::before,
.mdc-button--unelevated:hover .mdc-button__ripple::before {
opacity: 0.08;
}
.mdc-button--raised.mdc-ripple-upgraded--background-focused
.mdc-button__ripple::before,
.mdc-button--raised:not(.mdc-ripple-upgraded):focus
.mdc-button__ripple::before,
.mdc-button--unelevated.mdc-ripple-upgraded--background-focused
.mdc-button__ripple::before,
.mdc-button--unelevated:not(.mdc-ripple-upgraded):focus
.mdc-button__ripple::before {
transition-duration: 75ms;
opacity: 0.24;
}
.mdc-button--raised:not(.mdc-ripple-upgraded)
.mdc-button__ripple::after,
.mdc-button--unelevated:not(.mdc-ripple-upgraded)
.mdc-button__ripple::after {
transition: opacity 150ms linear;
}
.mdc-button--raised:not(.mdc-ripple-upgraded):active
.mdc-button__ripple::after,
.mdc-button--unelevated:not(.mdc-ripple-upgraded):active
.mdc-button__ripple::after {
transition-duration: 75ms;
opacity: 0.24;
}
.mdc-button--raised.mdc-ripple-upgraded,
.mdc-button--unelevated.mdc-ripple-upgraded {
--mdc-ripple-fg-opacity: 0.24;
}
.mdc-button {
height: 36px;
}
.btn-primary {
color: #fff !important;
background-color: #1e88e5 !important;
}
.group {
position: relative;
margin-bottom: 24px;
min-height: 45px;
}
.floating > input {
font-size: 18px;
padding: 10px 10px 10px 5px;
appearance: none;
-webkit-appearance: none;
display: block;
background: #fafafa;
color: #636363;
width: 100%;
border: none;
border-radius: 0;
border-bottom: 1px solid #757575;
}
.floating > input:focus {
outline: none;
}
.floating > label {
color: #999;
font-size: 18px;
font-weight: normal;
position: absolute;
pointer-events: none;
left: 5px;
top: 10px;
transition: all 0.2s ease;
}
.floating > input:focus ~ label,
.floating > input.used ~ label {
top: -0.75em;
transform: scale(0.75);
left: -2px;
color: #1e88e5;
transform-origin: left;
}
.bar {
position: relative;
display: block;
width: 100%;
}
.bar:before,
.bar:after {
content: "";
height: 2px;
width: 0;
bottom: 1px;
position: absolute;
background: #1e88e5;
transition: all 0.2s ease;
}
.bar:before {
left: 50%;
}
.bar:after {
right: 50%;
}
.floating > input:focus ~ .bar:before,
.floating > input:focus ~ .bar:after {
width: 50%;
}
.highlight {
position: absolute;
height: 60%;
width: 100px;
top: 25%;
left: 0;
pointer-events: none;
opacity: 0.5;
}
.floating > input:focus ~ .highlight {
animation: inputHighlighter 0.3s ease;
}
@keyframes inputHighlighter {
from {
background: #1e88e5;
}
to {
width: 0;
background: transparent;
}
}
.btn-primary {
color: #fff !important;
background-color: #1e88e5 !important;
}
.spanned-btn {
width: 100%;
background: #1e88e5 !important;
}
* {
box-sizing: border-box;
}
body {
font-family: Helvetica;
background: #eee;
-webkit-font-smoothing: antialiased;
}
header {
text-align: center;
margin-top: 4em;
}
h1,
h3 {
font-weight: 300;
}
h1 {
color: #636363;
}
h3 {
color: #1e88e5;
}
form {
max-width: 380px;
margin: 4em auto;
padding: 3em 2em 2em 2em;
background: #fafafa;
border: 1px solid #ebebeb;
box-shadow: rgba(0, 0, 0, 0.14902) 0px 1px 1px 0px,
rgba(0, 0, 0, 0.09804) 0px 1px 2px 0px;
position: relative;
}
.loader_box {
width: 64px;
height: 64px;
margin: auto;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
}
.loader {
display: inline-block;
position: relative;
z-index: 100;
}
.loader:after {
content: " ";
display: block;
width: 46px;
height: 46px;
margin: 1px;
border-radius: 50%;
border: 5px solid #000;
border-color: #000 transparent #000 transparent;
animation: loader 1.2s linear infinite;
}
@keyframes loader {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
footer {
text-align: center;
}
footer p {
color: #888;
font-size: 13px;
letter-spacing: 0.4px;
}
footer a {
color: #1e88e5;
text-decoration: none;
transition: all 0.2s ease;
}
footer a:hover {
color: #666;
text-decoration: underline;
}
footer img {
width: 80px;
transition: all 0.2s ease;
}
footer img:hover {
opacity: 0.83;
}
footer img:focus,
footer a:focus {
outline: none;
}
.invisible {
display: none;
}
.errorColor {
background: #ff2f00 !important;
}
.error {
color: #ff2f00;
margin-top: 5px;
font-size: 13px;
}
</style>
</head>
<body>
<div id="content"></div>
{{!--
<hgroup><h1>{{i18n "Login"}}</h1></hgroup>
<form action="JavaScript:void(0)">
<div class="loader_box" id="loader"><div class="loader"></div></div>
<div id="container">
<div id="usernamegroup">
<div class="floating group">
<input type="text" id="username" autofocus />
<span class="highlight"></span> <span class="bar"></span>
<label>{{i18n "Username or Email"}}</label>
<div class="error invisible" id="uerrorfield"></div>
</div>
<button
type="button"
id="nextbutton"
class="mdc-button mdc-button--raised"
>
{{i18n "Next"}}
</button>
</div>
<div id="passwordgroup">
<div class="floating group invisible" id="passwordgroup">
<input type="password" id="password" />
<span class="highlight"></span> <span class="bar"></span>
<label>{{i18n "Password"}}</label>
<div class="error invisible" id="perrorfield"></div>
</div>
<button
type="button"
id="loginbutton"
class="mdc-button mdc-button--raised"
>
{{i18n "Login"}}
</button>
</div>
<div id="twofactorgroup">
<ul id="tflist"></ul>
<div id="tfinput"></div>
</div>
</div>
</form>
<footer><p>Powered by {{appname}}</p></footer>
--}}
<script>
(function () {
"use strict" /*! *****************************************************************************
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.
***************************************************************************** */;
/* global Reflect, Promise */
var extendStatics = function (d, b) {
extendStatics =
Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array &&
function (d, b) {
d.__proto__ = b;
}) ||
function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
};
return extendStatics(d, b);
};
function __extends(d, b) {
extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype =
b === null
? Object.create(b)
: ((__.prototype = b.prototype), new __());
}
function __awaiter(thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
}
function rejected(value) {
try {
step(generator["throw"](value));
} catch (e) {
reject(e);
}
}
function step(result) {
result.done
? resolve(result.value)
: new P(function (resolve) {
resolve(result.value);
}).then(fulfilled, rejected);
}
step(
(generator = generator.apply(
thisArg,
_arguments || []
)).next()
);
});
}
function __generator(thisArg, body) {
var _ = {
label: 0,
sent: function () {
if (t[0] & 1) throw t[1];
return t[1];
},
trys: [],
ops: [],
},
f,
y,
t,
g;
return (
(g = { next: verb(0), throw: verb(1), return: verb(2) }),
typeof Symbol === "function" &&
(g[Symbol.iterator] = function () {
return this;
}),
g
);
function verb(n) {
return function (v) {
return step([n, v]);
};
}
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_)
try {
if (
((f = 1),
y &&
(t =
op[0] & 2
? y["return"]
: op[0]
? y["throw"] ||
((t = y["return"]) && t.call(y), 0)
: y.next) &&
!(t = t.call(y, op[1])).done)
)
return t;
if (((y = 0), t)) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0:
case 1:
t = op;
break;
case 4:
_.label++;
return { value: op[1], done: false };
case 5:
_.label++;
y = op[1];
op = [0];
continue;
case 7:
op = _.ops.pop();
_.trys.pop();
continue;
default:
if (
!((t = _.trys),
(t = t.length > 0 && t[t.length - 1])) &&
(op[0] === 6 || op[0] === 2)
) {
_ = 0;
continue;
}
if (
op[0] === 3 &&
(!t || (op[1] > t[0] && op[1] < t[3]))
) {
_.label = op[1];
break;
}
if (op[0] === 6 && _.label < t[1]) {
_.label = t[1];
t = op;
break;
}
if (t && _.label < t[2]) {
_.label = t[2];
_.ops.push(op);
break;
}
if (t[2]) _.ops.pop();
_.trys.pop();
continue;
}
op = body.call(thisArg, _);
} catch (e) {
op = [6, e];
y = 0;
} finally {
f = t = 0;
}
if (op[0] & 5) throw op[1];
return { value: op[0] ? op[1] : void 0, done: true };
}
}
var n,
u,
i,
t,
o,
r,
f = {},
e = [],
c = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord/i;
function s(n, l) {
for (var u in l) n[u] = l[u];
return n;
}
function a(n) {
var l = n.parentNode;
l && l.removeChild(n);
}
function v(n, l, u) {
var i,
t = arguments,
o = {};
for (i in l) "key" !== i && "ref" !== i && (o[i] = l[i]);
if (arguments.length > 3)
for (u = [u], i = 3; i < arguments.length; i++) u.push(t[i]);
if (
(null != u && (o.children = u),
"function" == typeof n && null != n.defaultProps)
)
for (i in n.defaultProps)
void 0 === o[i] && (o[i] = n.defaultProps[i]);
return h(n, o, l && l.key, l && l.ref);
}
function h(l, u, i, t) {
var o = {
type: l,
props: u,
key: i,
ref: t,
__k: null,
__: null,
__b: 0,
__e: null,
__d: void 0,
__c: null,
constructor: void 0,
};
return n.vnode && n.vnode(o), o;
}
function d(n) {
return n.children;
}
function y(n, l) {
(this.props = n), (this.context = l);
}
function m(n, l) {
if (null == l)
return n.__ ? m(n.__, n.__.__k.indexOf(n) + 1) : null;
for (var u; l < n.__k.length; l++)
if (null != (u = n.__k[l]) && null != u.__e) return u.__e;
return "function" == typeof n.type ? m(n) : null;
}
function w(n) {
var l, u;
if (null != (n = n.__) && null != n.__c) {
for (n.__e = n.__c.base = null, l = 0; l < n.__k.length; l++)
if (null != (u = n.__k[l]) && null != u.__e) {
n.__e = n.__c.base = u.__e;
break;
}
return w(n);
}
}
function g(l) {
((!l.__d && (l.__d = !0) && 1 === u.push(l)) ||
t !== n.debounceRendering) &&
((t = n.debounceRendering) || i)(k);
}
function k() {
var n, l, i, t, o, r, f;
for (
u.sort(function (n, l) {
return l.__v.__b - n.__v.__b;
});
(n = u.pop());
)
n.__d &&
((i = void 0),
(t = void 0),
(r = (o = (l = n).__v).__e),
(f = l.__P) &&
((i = []),
(t = z(
f,
o,
s({}, o),
l.__n,
void 0 !== f.ownerSVGElement,
null,
i,
null == r ? m(o) : r
)),
A(i, o),
t != r && w(o)));
}
function _(n, l, u, i, t, o, r, c, s) {
var v,
h,
p,
d,
y,
w,
g,
k = (u && u.__k) || e,
_ = k.length;
if (
(c == f && (c = null != o ? o[0] : _ ? m(u, 0) : null),
(v = 0),
(l.__k = b(l.__k, function (u) {
if (null != u) {
if (
((u.__ = l),
(u.__b = l.__b + 1),
null === (p = k[v]) ||
(p && u.key == p.key && u.type === p.type))
)
k[v] = void 0;
else
for (h = 0; h < _; h++) {
if (
(p = k[h]) &&
u.key == p.key &&
u.type === p.type
) {
k[h] = void 0;
break;
}
p = null;
}
if (
((d = z(n, u, (p = p || f), i, t, o, r, c, s)),
(h = u.ref) &&
p.ref != h &&
(g || (g = []),
p.ref && g.push(p.ref, null, u),
g.push(h, u.__c || d, u)),
null != d)
) {
var e;
if ((null == w && (w = d), void 0 !== u.__d))
(e = u.__d), (u.__d = void 0);
else if (o == p || d != c || null == d.parentNode) {
n: if (null == c || c.parentNode !== n)
n.appendChild(d), (e = null);
else {
for (
y = c, h = 0;
(y = y.nextSibling) && h < _;
h += 2
)
if (y == d) break n;
n.insertBefore(d, c), (e = c);
}
"option" == l.type && (n.value = "");
}
(c = void 0 !== e ? e : d.nextSibling),
"function" == typeof l.type && (l.__d = c);
} else
c && p.__e == c && c.parentNode != n && (c = m(p));
}
return v++, u;
})),
(l.__e = w),
null != o && "function" != typeof l.type)
)
for (v = o.length; v--; ) null != o[v] && a(o[v]);
for (v = _; v--; ) null != k[v] && j(k[v], k[v]);
if (g) for (v = 0; v < g.length; v++) $(g[v], g[++v], g[++v]);
}
function b(n, l, u) {
if ((null == u && (u = []), null == n || "boolean" == typeof n))
l && u.push(l(null));
else if (Array.isArray(n))
for (var i = 0; i < n.length; i++) b(n[i], l, u);
else
u.push(
l
? l(
"string" == typeof n || "number" == typeof n
? h(null, n, null, null)
: null != n.__e || null != n.__c
? h(n.type, n.props, n.key, null)
: n
)
: n
);
return u;
}
function x(n, l, u, i, t) {
var o;
for (o in u) o in l || C(n, o, null, u[o], i);
for (o in l)
(t && "function" != typeof l[o]) ||
"value" === o ||
"checked" === o ||
u[o] === l[o] ||
C(n, o, l[o], u[o], i);
}
function P(n, l, u) {
"-" === l[0]
? n.setProperty(l, u)
: (n[l] =
"number" == typeof u && !1 === c.test(l)
? u + "px"
: null == u
? ""
: u);
}
function C(n, l, u, i, t) {
var o, r, f, e, c;
if (
(t
? "className" === l && (l = "class")
: "class" === l && (l = "className"),
"key" === l || "children" === l)
);
else if ("style" === l)
if (((o = n.style), "string" == typeof u)) o.cssText = u;
else {
if (
("string" == typeof i && ((o.cssText = ""), (i = null)),
i)
)
for (r in i) (u && r in u) || P(o, r, "");
if (u) for (f in u) (i && u[f] === i[f]) || P(o, f, u[f]);
}
else
"o" === l[0] && "n" === l[1]
? ((e = l !== (l = l.replace(/Capture$/, ""))),
(c = l.toLowerCase()),
(l = (c in n ? c : l).slice(2)),
u
? (i || n.addEventListener(l, N, e),
((n.l || (n.l = {}))[l] = u))
: n.removeEventListener(l, N, e))
: "list" !== l &&
"tagName" !== l &&
"form" !== l &&
"type" !== l &&
"size" !== l &&
!t &&
l in n
? (n[l] = null == u ? "" : u)
: "function" != typeof u &&
"dangerouslySetInnerHTML" !== l &&
(l !== (l = l.replace(/^xlink:?/, ""))
? null == u || !1 === u
? n.removeAttributeNS(
"http://www.w3.org/1999/xlink",
l.toLowerCase()
)
: n.setAttributeNS(
"http://www.w3.org/1999/xlink",
l.toLowerCase(),
u
)
: null == u || (!1 === u && !/^ar/.test(l))
? n.removeAttribute(l)
: n.setAttribute(l, u));
}
function N(l) {
this.l[l.type](n.event ? n.event(l) : l);
}
function z(l, u, i, t, o, r, f, e, c) {
var a,
v,
h,
p,
m,
w,
g,
k,
b,
x,
P = u.type;
if (void 0 !== u.constructor) return null;
(a = n.__b) && a(u);
try {
n: if ("function" == typeof P) {
if (
((k = u.props),
(b = (a = P.contextType) && t[a.__c]),
(x = a ? (b ? b.props.value : a.__) : t),
i.__c
? (g = (v = u.__c = i.__c).__ = v.__E)
: ("prototype" in P && P.prototype.render
? (u.__c = v = new P(k, x))
: ((u.__c = v = new y(k, x)),
(v.constructor = P),
(v.render = D)),
b && b.sub(v),
(v.props = k),
v.state || (v.state = {}),
(v.context = x),
(v.__n = t),
(h = v.__d = !0),
(v.__h = [])),
null == v.__s && (v.__s = v.state),
null != P.getDerivedStateFromProps &&
(v.__s == v.state && (v.__s = s({}, v.__s)),
s(v.__s, P.getDerivedStateFromProps(k, v.__s))),
(p = v.props),
(m = v.state),
h)
)
null == P.getDerivedStateFromProps &&
null != v.componentWillMount &&
v.componentWillMount(),
null != v.componentDidMount &&
v.__h.push(v.componentDidMount);
else {
if (
(null == P.getDerivedStateFromProps &&
k !== p &&
null != v.componentWillReceiveProps &&
v.componentWillReceiveProps(k, x),
!v.__e &&
null != v.shouldComponentUpdate &&
!1 === v.shouldComponentUpdate(k, v.__s, x))
) {
for (
v.props = k,
v.state = v.__s,
v.__d = !1,
v.__v = u,
u.__e = i.__e,
u.__k = i.__k,
v.__h.length && f.push(v),
a = 0;
a < u.__k.length;
a++
)
u.__k[a] && (u.__k[a].__ = u);
break n;
}
null != v.componentWillUpdate &&
v.componentWillUpdate(k, v.__s, x),
null != v.componentDidUpdate &&
v.__h.push(function () {
v.componentDidUpdate(p, m, w);
});
}
(v.context = x),
(v.props = k),
(v.state = v.__s),
(a = n.__r) && a(u),
(v.__d = !1),
(v.__v = u),
(v.__P = l),
(a = v.render(v.props, v.state, v.context)),
(u.__k =
null != a && a.type == d && null == a.key
? a.props.children
: Array.isArray(a)
? a
: [a]),
null != v.getChildContext &&
(t = s(s({}, t), v.getChildContext())),
h ||
null == v.getSnapshotBeforeUpdate ||
(w = v.getSnapshotBeforeUpdate(p, m)),
_(l, u, i, t, o, r, f, e, c),
(v.base = u.__e),
v.__h.length && f.push(v),
g && (v.__E = v.__ = null),
(v.__e = !1);
} else u.__e = T(i.__e, u, i, t, o, r, f, c);
(a = n.diffed) && a(u);
} catch (l) {
n.__e(l, u, i);
}
return u.__e;
}
function A(l, u) {
n.__c && n.__c(u, l),
l.some(function (u) {
try {
(l = u.__h),
(u.__h = []),
l.some(function (n) {
n.call(u);
});
} catch (l) {
n.__e(l, u.__v);
}
});
}
function T(n, l, u, i, t, o, r, c) {
var s,
a,
v,
h,
p,
d = u.props,
y = l.props;
if (((t = "svg" === l.type || t), null != o))
for (s = 0; s < o.length; s++)
if (
null != (a = o[s]) &&
((null === l.type
? 3 === a.nodeType
: a.localName === l.type) ||
n == a)
) {
(n = a), (o[s] = null);
break;
}
if (null == n) {
if (null === l.type) return document.createTextNode(y);
(n = t
? document.createElementNS(
"http://www.w3.org/2000/svg",
l.type
)
: document.createElement(l.type, y.is && { is: y.is })),
(o = null);
}
if (null === l.type) d !== y && n.data != y && (n.data = y);
else if (l !== u) {
if (
(null != o && (o = e.slice.call(n.childNodes)),
(v = (d = u.props || f).dangerouslySetInnerHTML),
(h = y.dangerouslySetInnerHTML),
!c)
) {
if (d === f)
for (d = {}, p = 0; p < n.attributes.length; p++)
d[n.attributes[p].name] = n.attributes[p].value;
(h || v) &&
((h && v && h.__html == v.__html) ||
(n.innerHTML = (h && h.__html) || ""));
}
x(n, y, d, t, c),
(l.__k = l.props.children),
h ||
_(
n,
l,
u,
i,
"foreignObject" !== l.type && t,
o,
r,
f,
c
),
c ||
("value" in y &&
void 0 !== y.value &&
y.value !== n.value &&
(n.value = null == y.value ? "" : y.value),
"checked" in y &&
void 0 !== y.checked &&
y.checked !== n.checked &&
(n.checked = y.checked));
}
return n;
}
function $(l, u, i) {
try {
"function" == typeof l ? l(u) : (l.current = u);
} catch (l) {
n.__e(l, i);
}
}
function j(l, u, i) {
var t, o, r;
if (
(n.unmount && n.unmount(l),
(t = l.ref) &&
((t.current && t.current !== l.__e) || $(t, null, u)),
i || "function" == typeof l.type || (i = null != (o = l.__e)),
(l.__e = l.__d = void 0),
null != (t = l.__c))
) {
if (t.componentWillUnmount)
try {
t.componentWillUnmount();
} catch (l) {
n.__e(l, u);
}
t.base = t.__P = null;
}
if ((t = l.__k))
for (r = 0; r < t.length; r++) t[r] && j(t[r], u, i);
null != o && a(o);
}
function D(n, l, u) {
return this.constructor(n, u);
}
function E(l, u, i) {
var t, r, c;
n.__ && n.__(l, u),
(r = (t = i === o) ? null : (i && i.__k) || u.__k),
(l = v(d, null, [l])),
(c = []),
z(
u,
((t ? u : i || u).__k = l),
r || f,
f,
void 0 !== u.ownerSVGElement,
i && !t ? [i] : r ? null : e.slice.call(u.childNodes),
c,
i || f,
t
),
A(c, l);
}
(n = {
__e: function (n, l) {
for (var u, i; (l = l.__); )
if ((u = l.__c) && !u.__)
try {
if (
(u.constructor &&
null !=
u.constructor.getDerivedStateFromError &&
((i = !0),
u.setState(
u.constructor.getDerivedStateFromError(n)
)),
null != u.componentDidCatch &&
((i = !0), u.componentDidCatch(n)),
i)
)
return g((u.__E = u));
} catch (l) {
n = l;
}
throw n;
},
}),
(y.prototype.setState = function (n, l) {
var u;
(u =
this.__s !== this.state
? this.__s
: (this.__s = s({}, this.state))),
"function" == typeof n && (n = n(u, this.props)),
n && s(u, n),
null != n && this.__v && (l && this.__h.push(l), g(this));
}),
(y.prototype.forceUpdate = function (n) {
this.__v && ((this.__e = !0), n && this.__h.push(n), g(this));
}),
(y.prototype.render = d),
(u = []),
(i =
"function" == typeof Promise
? Promise.prototype.then.bind(Promise.resolve())
: setTimeout),
(o = f),
(r = 0);
(() => {
const run = () => {
document.querySelectorAll(".floating>input").forEach((e) => {
function checkState() {
if (e.value !== "") {
if (e.classList.contains("used")) return;
e.classList.add("used");
} else {
if (e.classList.contains("used"))
e.classList.remove("used");
}
}
e.addEventListener("change", () => checkState());
checkState();
});
};
run();
var mutationObserver = new MutationObserver(() => {
run();
});
mutationObserver.observe(document.documentElement, {
attributes: false,
characterData: false,
childList: true,
subtree: true,
});
window.addEventListener("DOMNodeInserted", () => run());
})(); //Copyright 2014-2015 Google Inc. All rights reserved.
// NECESSARY CHANGE: wrap the whole file in a closure
(function () {
// NECESSARY CHANGE: detect UA to avoid clobbering other browser's U2F API.
var isChrome =
"chrome" in window &&
window.navigator.userAgent.indexOf("Edge") < 0;
if ("u2f" in window || !isChrome) {
return;
}
/**
* Namespace for the U2F api.
* @type {Object}
*/
// NECESSARY CHANGE: define the window.u2f API.
var u2f = (window.u2f = {});
/**
* FIDO U2F Javascript API Version
* @number
*/
var js_api_version;
/**
* The U2F extension id
* @const {string}
*/
// The Chrome packaged app extension ID.
// Uncomment this if you want to deploy a server instance that uses
// the package Chrome app and does not require installing the U2F Chrome extension.
u2f.EXTENSION_ID = "kmendfapggjehodndflmmgagdbamhnfd";
// The U2F Chrome extension ID.
// Uncomment this if you want to deploy a server instance that uses
// the U2F Chrome extension to authenticate.
// u2f.EXTENSION_ID = 'pfboblefjcgdjicmnffhdgionmgcdmne';
/**
* Message types for messsages to/from the extension
* @const
* @enum {string}
*/
u2f.MessageTypes = {
U2F_REGISTER_REQUEST: "u2f_register_request",
U2F_REGISTER_RESPONSE: "u2f_register_response",
U2F_SIGN_REQUEST: "u2f_sign_request",
U2F_SIGN_RESPONSE: "u2f_sign_response",
U2F_GET_API_VERSION_REQUEST: "u2f_get_api_version_request",
U2F_GET_API_VERSION_RESPONSE: "u2f_get_api_version_response",
};
/**
* Response status codes
* @const
* @enum {number}
*/
u2f.ErrorCodes = {
OK: 0,
OTHER_ERROR: 1,
BAD_REQUEST: 2,
CONFIGURATION_UNSUPPORTED: 3,
DEVICE_INELIGIBLE: 4,
TIMEOUT: 5,
};
//Low level MessagePort API support
/**
* Sets up a MessagePort to the U2F extension using the
* available mechanisms.
* @param {function((MessagePort|u2f.WrappedChromeRuntimePort_))} callback
*/
u2f.getMessagePort = function (callback) {
if (typeof chrome != "undefined" && chrome.runtime) {
// The actual message here does not matter, but we need to get a reply
// for the callback to run. Thus, send an empty signature request
// in order to get a failure response.
var msg = {
type: u2f.MessageTypes.U2F_SIGN_REQUEST,
signRequests: [],
};
chrome.runtime.sendMessage(
u2f.EXTENSION_ID,
msg,
function () {
if (!chrome.runtime.lastError) {
// We are on a whitelisted origin and can talk directly
// with the extension.
u2f.getChromeRuntimePort_(callback);
} else {
// chrome.runtime was available, but we couldn't message
// the extension directly, use iframe
u2f.getIframePort_(callback);
}
}
);
} else if (u2f.isAndroidChrome_()) {
u2f.getAuthenticatorPort_(callback);
} else if (u2f.isIosChrome_()) {
u2f.getIosPort_(callback);
} else {
// chrome.runtime was not available at all, which is normal
// when this origin doesn't have access to any extensions.
u2f.getIframePort_(callback);
}
};
/**
* Detect chrome running on android based on the browser's useragent.
* @private
*/
u2f.isAndroidChrome_ = function () {
var userAgent = navigator.userAgent;
return (
userAgent.indexOf("Chrome") != -1 &&
userAgent.indexOf("Android") != -1
);
};
/**
* Detect chrome running on iOS based on the browser's platform.
* @private
*/
u2f.isIosChrome_ = function () {
return (
["iPhone", "iPad", "iPod"].indexOf(navigator.platform) > -1
);
};
/**
* Connects directly to the extension via chrome.runtime.connect.
* @param {function(u2f.WrappedChromeRuntimePort_)} callback
* @private
*/
u2f.getChromeRuntimePort_ = function (callback) {
var port = chrome.runtime.connect(u2f.EXTENSION_ID, {
includeTlsChannelId: true,
});
setTimeout(function () {
callback(new u2f.WrappedChromeRuntimePort_(port));
}, 0);
};
/**
* Return a 'port' abstraction to the Authenticator app.
* @param {function(u2f.WrappedAuthenticatorPort_)} callback
* @private
*/
u2f.getAuthenticatorPort_ = function (callback) {
setTimeout(function () {
callback(new u2f.WrappedAuthenticatorPort_());
}, 0);
};
/**
* Return a 'port' abstraction to the iOS client app.
* @param {function(u2f.WrappedIosPort_)} callback
* @private
*/
u2f.getIosPort_ = function (callback) {
setTimeout(function () {
callback(new u2f.WrappedIosPort_());
}, 0);
};
/**
* A wrapper for chrome.runtime.Port that is compatible with MessagePort.
* @param {Port} port
* @constructor
* @private
*/
u2f.WrappedChromeRuntimePort_ = function (port) {
this.port_ = port;
};
/**
* Format and return a sign request compliant with the JS API version supported by the extension.
* @param {Array<u2f.SignRequest>} signRequests
* @param {number} timeoutSeconds
* @param {number} reqId
* @return {Object}
*/
u2f.formatSignRequest_ = function (
appId,
challenge,
registeredKeys,
timeoutSeconds,
reqId
) {
if (js_api_version === undefined || js_api_version < 1.1) {
// Adapt request to the 1.0 JS API
var signRequests = [];
for (var i = 0; i < registeredKeys.length; i++) {
signRequests[i] = {
version: registeredKeys[i].version,
challenge: challenge,
keyHandle: registeredKeys[i].keyHandle,
appId: appId,
};
}
return {
type: u2f.MessageTypes.U2F_SIGN_REQUEST,
signRequests: signRequests,
timeoutSeconds: timeoutSeconds,
requestId: reqId,
};
}
// JS 1.1 API
return {
type: u2f.MessageTypes.U2F_SIGN_REQUEST,
appId: appId,
challenge: challenge,
registeredKeys: registeredKeys,
timeoutSeconds: timeoutSeconds,
requestId: reqId,
};
};
/**
* Format and return a register request compliant with the JS API version supported by the extension..
* @param {Array<u2f.SignRequest>} signRequests
* @param {Array<u2f.RegisterRequest>} signRequests
* @param {number} timeoutSeconds
* @param {number} reqId
* @return {Object}
*/
u2f.formatRegisterRequest_ = function (
appId,
registeredKeys,
registerRequests,
timeoutSeconds,
reqId
) {
if (js_api_version === undefined || js_api_version < 1.1) {
// Adapt request to the 1.0 JS API
for (var i = 0; i < registerRequests.length; i++) {
registerRequests[i].appId = appId;
}
var signRequests = [];
for (var i = 0; i < registeredKeys.length; i++) {
signRequests[i] = {
version: registeredKeys[i].version,
challenge: registerRequests[0],
keyHandle: registeredKeys[i].keyHandle,
appId: appId,
};
}
return {
type: u2f.MessageTypes.U2F_REGISTER_REQUEST,
signRequests: signRequests,
registerRequests: registerRequests,
timeoutSeconds: timeoutSeconds,
requestId: reqId,
};
}
// JS 1.1 API
return {
type: u2f.MessageTypes.U2F_REGISTER_REQUEST,
appId: appId,
registerRequests: registerRequests,
registeredKeys: registeredKeys,
timeoutSeconds: timeoutSeconds,
requestId: reqId,
};
};
/**
* Posts a message on the underlying channel.
* @param {Object} message
*/
u2f.WrappedChromeRuntimePort_.prototype.postMessage = function (
message
) {
this.port_.postMessage(message);
};
/**
* Emulates the HTML 5 addEventListener interface. Works only for the
* onmessage event, which is hooked up to the chrome.runtime.Port.onMessage.
* @param {string} eventName
* @param {function({data: Object})} handler
*/
u2f.WrappedChromeRuntimePort_.prototype.addEventListener = function (
eventName,
handler
) {
var name = eventName.toLowerCase();
if (name == "message" || name == "onmessage") {
this.port_.onMessage.addListener(function (message) {
// Emulate a minimal MessageEvent object
handler({ data: message });
});
} else {
console.error(
"WrappedChromeRuntimePort only supports onMessage"
);
}
};
/**
* Wrap the Authenticator app with a MessagePort interface.
* @constructor
* @private
*/
u2f.WrappedAuthenticatorPort_ = function () {
this.requestId_ = -1;
this.requestObject_ = null;
};
/**
* Launch the Authenticator intent.
* @param {Object} message
*/
u2f.WrappedAuthenticatorPort_.prototype.postMessage = function (
message
) {
var intentUrl =
u2f.WrappedAuthenticatorPort_.INTENT_URL_BASE_ +
";S.request=" +
encodeURIComponent(JSON.stringify(message)) +
";end";
document.location = intentUrl;
};
/**
* Tells what type of port this is.
* @return {String} port type
*/
u2f.WrappedAuthenticatorPort_.prototype.getPortType = function () {
return "WrappedAuthenticatorPort_";
};
/**
* Emulates the HTML 5 addEventListener interface.
* @param {string} eventName
* @param {function({data: Object})} handler
*/
u2f.WrappedAuthenticatorPort_.prototype.addEventListener = function (
eventName,
handler
) {
var name = eventName.toLowerCase();
if (name == "message") {
var self = this;
/* Register a callback to that executes when
* chrome injects the response. */
window.addEventListener(
"message",
self.onRequestUpdate_.bind(self, handler),
false
);
} else {
console.error(
"WrappedAuthenticatorPort only supports message"
);
}
};
/**
* Callback invoked when a response is received from the Authenticator.
* @param function({data: Object}) callback
* @param {Object} message message Object
*/
u2f.WrappedAuthenticatorPort_.prototype.onRequestUpdate_ = function (
callback,
message
) {
var messageObject = JSON.parse(message.data);
var intentUrl = messageObject["intentURL"];
var errorCode = messageObject["errorCode"];
var responseObject = null;
if (messageObject.hasOwnProperty("data")) {
responseObject = /** @type {Object} */ (JSON.parse(
messageObject["data"]
));
}
callback({ data: responseObject });
};
/**
* Base URL for intents to Authenticator.
* @const
* @private
*/
u2f.WrappedAuthenticatorPort_.INTENT_URL_BASE_ =
"intent:#Intent;action=com.google.android.apps.authenticator.AUTHENTICATE";
/**
* Wrap the iOS client app with a MessagePort interface.
* @constructor
* @private
*/
u2f.WrappedIosPort_ = function () {};
/**
* Launch the iOS client app request
* @param {Object} message
*/
u2f.WrappedIosPort_.prototype.postMessage = function (message) {
var str = JSON.stringify(message);
var url = "u2f://auth?" + encodeURI(str);
location.replace(url);
};
/**
* Tells what type of port this is.
* @return {String} port type
*/
u2f.WrappedIosPort_.prototype.getPortType = function () {
return "WrappedIosPort_";
};
/**
* Emulates the HTML 5 addEventListener interface.
* @param {string} eventName
* @param {function({data: Object})} handler
*/
u2f.WrappedIosPort_.prototype.addEventListener = function (
eventName,
handler
) {
var name = eventName.toLowerCase();
if (name !== "message") {
console.error("WrappedIosPort only supports message");
}
};
/**
* Sets up an embedded trampoline iframe, sourced from the extension.
* @param {function(MessagePort)} callback
* @private
*/
u2f.getIframePort_ = function (callback) {
// Create the iframe
var iframeOrigin = "chrome-extension://" + u2f.EXTENSION_ID;
var iframe = document.createElement("iframe");
iframe.src = iframeOrigin + "/u2f-comms.html";
iframe.setAttribute("style", "display:none");
document.body.appendChild(iframe);
var channel = new MessageChannel();
var ready = function (message) {
if (message.data == "ready") {
channel.port1.removeEventListener("message", ready);
callback(channel.port1);
} else {
console.error(
'First event on iframe port was not "ready"'
);
}
};
channel.port1.addEventListener("message", ready);
channel.port1.start();
iframe.addEventListener("load", function () {
// Deliver the port to the iframe and initialize
iframe.contentWindow.postMessage("init", iframeOrigin, [
channel.port2,
]);
});
};
//High-level JS API
/**
* Default extension response timeout in seconds.
* @const
*/
u2f.EXTENSION_TIMEOUT_SEC = 30;
/**
* A singleton instance for a MessagePort to the extension.
* @type {MessagePort|u2f.WrappedChromeRuntimePort_}
* @private
*/
u2f.port_ = null;
/**
* Callbacks waiting for a port
* @type {Array<function((MessagePort|u2f.WrappedChromeRuntimePort_))>}
* @private
*/
u2f.waitingForPort_ = [];
/**
* A counter for requestIds.
* @type {number}
* @private
*/
u2f.reqCounter_ = 0;
/**
* A map from requestIds to client callbacks
* @type {Object.<number,(function((u2f.Error|u2f.RegisterResponse))
* |function((u2f.Error|u2f.SignResponse)))>}
* @private
*/
u2f.callbackMap_ = {};
/**
* Creates or retrieves the MessagePort singleton to use.
* @param {function((MessagePort|u2f.WrappedChromeRuntimePort_))} callback
* @private
*/
u2f.getPortSingleton_ = function (callback) {
if (u2f.port_) {
callback(u2f.port_);
} else {
if (u2f.waitingForPort_.length == 0) {
u2f.getMessagePort(function (port) {
u2f.port_ = port;
u2f.port_.addEventListener(
"message",
/** @type {function(Event)} */ (u2f.responseHandler_)
);
// Careful, here be async callbacks. Maybe.
while (u2f.waitingForPort_.length)
u2f.waitingForPort_.shift()(u2f.port_);
});
}
u2f.waitingForPort_.push(callback);
}
};
/**
* Handles response messages from the extension.
* @param {MessageEvent.<u2f.Response>} message
* @private
*/
u2f.responseHandler_ = function (message) {
var response = message.data;
var reqId = response["requestId"];
if (!reqId || !u2f.callbackMap_[reqId]) {
console.error("Unknown or missing requestId in response.");
return;
}
var cb = u2f.callbackMap_[reqId];
delete u2f.callbackMap_[reqId];
cb(response["responseData"]);
};
/**
* Dispatches an array of sign requests to available U2F tokens.
* If the JS API version supported by the extension is unknown, it first sends a
* message to the extension to find out the supported API version and then it sends
* the sign request.
* @param {string=} appId
* @param {string=} challenge
* @param {Array<u2f.RegisteredKey>} registeredKeys
* @param {function((u2f.Error|u2f.SignResponse))} callback
* @param {number=} opt_timeoutSeconds
*/
u2f.sign = function (
appId,
challenge,
registeredKeys,
callback,
opt_timeoutSeconds
) {
if (js_api_version === undefined) {
// Send a message to get the extension to JS API version, then send the actual sign request.
u2f.getApiVersion(function (response) {
js_api_version =
response["js_api_version"] === undefined
? 0
: response["js_api_version"];
console.log(
"Extension JS API Version: ",
js_api_version
);
u2f.sendSignRequest(
appId,
challenge,
registeredKeys,
callback,
opt_timeoutSeconds
);
});
} else {
// We know the JS API version. Send the actual sign request in the supported API version.
u2f.sendSignRequest(
appId,
challenge,
registeredKeys,
callback,
opt_timeoutSeconds
);
}
};
/**
* Dispatches an array of sign requests to available U2F tokens.
* @param {string=} appId
* @param {string=} challenge
* @param {Array<u2f.RegisteredKey>} registeredKeys
* @param {function((u2f.Error|u2f.SignResponse))} callback
* @param {number=} opt_timeoutSeconds
*/
u2f.sendSignRequest = function (
appId,
challenge,
registeredKeys,
callback,
opt_timeoutSeconds
) {
u2f.getPortSingleton_(function (port) {
var reqId = ++u2f.reqCounter_;
u2f.callbackMap_[reqId] = callback;
var timeoutSeconds =
typeof opt_timeoutSeconds !== "undefined"
? opt_timeoutSeconds
: u2f.EXTENSION_TIMEOUT_SEC;
var req = u2f.formatSignRequest_(
appId,
challenge,
registeredKeys,
timeoutSeconds,
reqId
);
port.postMessage(req);
});
};
/**
* Dispatches register requests to available U2F tokens. An array of sign
* requests identifies already registered tokens.
* If the JS API version supported by the extension is unknown, it first sends a
* message to the extension to find out the supported API version and then it sends
* the register request.
* @param {string=} appId
* @param {Array<u2f.RegisterRequest>} registerRequests
* @param {Array<u2f.RegisteredKey>} registeredKeys
* @param {function((u2f.Error|u2f.RegisterResponse))} callback
* @param {number=} opt_timeoutSeconds
*/
u2f.register = function (
appId,
registerRequests,
registeredKeys,
callback,
opt_timeoutSeconds
) {
if (js_api_version === undefined) {
// Send a message to get the extension to JS API version, then send the actual register request.
u2f.getApiVersion(function (response) {
js_api_version =
response["js_api_version"] === undefined
? 0
: response["js_api_version"];
console.log(
"Extension JS API Version: ",
js_api_version
);
u2f.sendRegisterRequest(
appId,
registerRequests,
registeredKeys,
callback,
opt_timeoutSeconds
);
});
} else {
// We know the JS API version. Send the actual register request in the supported API version.
u2f.sendRegisterRequest(
appId,
registerRequests,
registeredKeys,
callback,
opt_timeoutSeconds
);
}
};
/**
* Dispatches register requests to available U2F tokens. An array of sign
* requests identifies already registered tokens.
* @param {string=} appId
* @param {Array<u2f.RegisterRequest>} registerRequests
* @param {Array<u2f.RegisteredKey>} registeredKeys
* @param {function((u2f.Error|u2f.RegisterResponse))} callback
* @param {number=} opt_timeoutSeconds
*/
u2f.sendRegisterRequest = function (
appId,
registerRequests,
registeredKeys,
callback,
opt_timeoutSeconds
) {
u2f.getPortSingleton_(function (port) {
var reqId = ++u2f.reqCounter_;
u2f.callbackMap_[reqId] = callback;
var timeoutSeconds =
typeof opt_timeoutSeconds !== "undefined"
? opt_timeoutSeconds
: u2f.EXTENSION_TIMEOUT_SEC;
var req = u2f.formatRegisterRequest_(
appId,
registeredKeys,
registerRequests,
timeoutSeconds,
reqId
);
port.postMessage(req);
});
};
/**
* Dispatches a message to the extension to find out the supported
* JS API version.
* If the user is on a mobile phone and is thus using Google Authenticator instead
* of the Chrome extension, don't send the request and simply return 0.
* @param {function((u2f.Error|u2f.GetJsApiVersionResponse))} callback
* @param {number=} opt_timeoutSeconds
*/
u2f.getApiVersion = function (callback, opt_timeoutSeconds) {
u2f.getPortSingleton_(function (port) {
// If we are using Android Google Authenticator or iOS client app,
// do not fire an intent to ask which JS API version to use.
if (port.getPortType) {
var apiVersion;
switch (port.getPortType()) {
case "WrappedIosPort_":
case "WrappedAuthenticatorPort_":
apiVersion = 1.1;
break;
default:
apiVersion = 0;
break;
}
callback({ js_api_version: apiVersion });
return;
}
var reqId = ++u2f.reqCounter_;
u2f.callbackMap_[reqId] = callback;
var req = {
type: u2f.MessageTypes.U2F_GET_API_VERSION_REQUEST,
timeoutSeconds:
typeof opt_timeoutSeconds !== "undefined"
? opt_timeoutSeconds
: u2f.EXTENSION_TIMEOUT_SEC,
requestId: reqId,
};
port.postMessage(req);
});
};
})();
var b$1;
if (!(b$1 = t$1)) {
var w$1 = Math,
y$1 = {},
B = (y$1.p = {}),
aa = function () {},
C$1 = (B.A = {
extend: function (o) {
aa.prototype = this;
var _ = new aa();
return o && _.u(o), (_.z = this), _;
},
create: function () {
var o = this.extend();
return o.h.apply(o, arguments), o;
},
h: function () {},
u: function (o) {
for (var _ in o)
o.hasOwnProperty(_) && (this[_] = o[_]);
o.hasOwnProperty("toString") &&
(this.toString = o.toString);
},
e: function () {
return this.z.extend(this);
},
}),
D$1 = (B.i = C$1.extend({
h: function (o, _) {
(o = this.d = o || []),
(this.c = void 0 == _ ? 4 * o.length : _);
},
toString: function (o) {
return (o || ba).stringify(this);
},
concat: function (o) {
var _ = this.d,
Da = o.d,
Ea = this.c,
o = o.c;
if ((this.t(), Ea % 4))
for (var Fa = 0; Fa < o; Fa++)
_[(Ea + Fa) >>> 2] |=
(255 &
(Da[Fa >>> 2] >>> (24 - 8 * (Fa % 4)))) <<
(24 - 8 * ((Ea + Fa) % 4));
else if (65535 < Da.length)
for (Fa = 0; Fa < o; Fa += 4)
_[(Ea + Fa) >>> 2] = Da[Fa >>> 2];
else _.push.apply(_, Da);
return (this.c += o), this;
},
t: function () {
var o = this.d,
_ = this.c;
(o[_ >>> 2] &= 4294967295 << (32 - 8 * (_ % 4))),
(o.length = w$1.ceil(_ / 4));
},
e: function () {
var o = C$1.e.call(this);
return (o.d = this.d.slice(0)), o;
},
random: function (o) {
for (var _ = [], Da = 0; Da < o; Da += 4)
_.push(0 | (4294967296 * w$1.random()));
return D$1.create(_, o);
},
})),
ca = (y$1.O = {}),
ba = (ca.K = {
stringify: function (o) {
for (
var Fa, _ = o.d, o = o.c, Da = [], Ea = 0;
Ea < o;
Ea++
)
(Fa = 255 & (_[Ea >>> 2] >>> (24 - 8 * (Ea % 4)))),
Da.push((Fa >>> 4).toString(16)),
Da.push((15 & Fa).toString(16));
return Da.join("");
},
parse: function (o) {
for (var _ = o.length, Da = [], Ea = 0; Ea < _; Ea += 2)
Da[Ea >>> 3] |=
parseInt(o.substr(Ea, 2), 16) <<
(24 - 4 * (Ea % 8));
return D$1.create(Da, _ / 2);
},
}),
da = (ca.M = {
stringify: function (o) {
for (
var _ = o.d, o = o.c, Da = [], Ea = 0;
Ea < o;
Ea++
)
Da.push(
String.fromCharCode(
255 & (_[Ea >>> 2] >>> (24 - 8 * (Ea % 4)))
)
);
return Da.join("");
},
parse: function (o) {
for (var _ = o.length, Da = [], Ea = 0; Ea < _; Ea++)
Da[Ea >>> 2] |=
(255 & o.charCodeAt(Ea)) << (24 - 8 * (Ea % 4));
return D$1.create(Da, _);
},
}),
ea = (ca.N = {
stringify: function (o) {
try {
return decodeURIComponent(escape(da.stringify(o)));
} catch (_) {
throw Error("Malformed UTF-8 data");
}
},
parse: function (o) {
return da.parse(unescape(encodeURIComponent(o)));
},
}),
ia = (B.I = C$1.extend({
reset: function () {
(this.g = D$1.create()), (this.j = 0);
},
l: function (o) {
"string" == typeof o && (o = ea.parse(o)),
this.g.concat(o),
(this.j += o.c);
},
m: function (o) {
var _ = this.g,
Da = _.d,
Ea = _.c,
Fa = this.n,
Ga = Ea / (4 * Fa),
Ga = o
? w$1.ceil(Ga)
: w$1.max((0 | Ga) - this.r, 0),
o = Ga * Fa,
Ea = w$1.min(4 * o, Ea);
if (o) {
for (var Ha = 0; Ha < o; Ha += Fa) this.H(Da, Ha);
(Ha = Da.splice(0, o)), (_.c -= Ea);
}
return D$1.create(Ha, Ea);
},
e: function () {
var o = C$1.e.call(this);
return (o.g = this.g.e()), o;
},
r: 0,
}));
B.B = ia.extend({
h: function () {
this.reset();
},
reset: function () {
ia.reset.call(this), this.q();
},
update: function (o) {
return this.l(o), this.m(), this;
},
o: function (o) {
return o && this.l(o), this.G(), this.f;
},
e: function () {
var o = ia.e.call(this);
return (o.f = this.f.e()), o;
},
n: 16,
D: function (o) {
return function (_, Da) {
return o.create(Da).o(_);
};
},
F: function (o) {
return function (_, Da) {
return ja.J.create(o, Da).o(_);
};
},
});
var ja = (y$1.s = {});
b$1 = y$1;
}
var t$1 = b$1,
K = t$1,
ka = K.p,
la = ka.A,
va = ka.i,
K = (K.w = {});
(K.C = la.extend({
h: function (o, _) {
(this.a = o), (this.b = _);
},
})),
(K.i = la.extend({
h: function (o, _) {
(o = this.d = o || []),
(this.c = void 0 == _ ? 8 * o.length : _);
},
v: function () {
for (
var Fa, o = this.d, _ = o.length, Da = [], Ea = 0;
Ea < _;
Ea++
)
(Fa = o[Ea]), Da.push(Fa.a), Da.push(Fa.b);
return va.create(Da, this.c);
},
e: function () {
for (
var o = la.e.call(this),
_ = (o.d = this.d.slice(0)),
Da = _.length,
Ea = 0;
Ea < Da;
Ea++
)
_[Ea] = _[Ea].e();
return o;
},
}));
function L() {
return wa.create.apply(wa, arguments);
}
for (
var xa = t$1.p.B,
M = t$1.w,
wa = M.C,
ya = M.i,
M = t$1.s,
za = [
L(1116352408, 3609767458),
L(1899447441, 602891725),
L(3049323471, 3964484399),
L(3921009573, 2173295548),
L(961987163, 4081628472),
L(1508970993, 3053834265),
L(2453635748, 2937671579),
L(2870763221, 3664609560),
L(3624381080, 2734883394),
L(310598401, 1164996542),
L(607225278, 1323610764),
L(1426881987, 3590304994),
L(1925078388, 4068182383),
L(2162078206, 991336113),
L(2614888103, 633803317),
L(3248222580, 3479774868),
L(3835390401, 2666613458),
L(4022224774, 944711139),
L(264347078, 2341262773),
L(604807628, 2007800933),
L(770255983, 1495990901),
L(1249150122, 1856431235),
L(1555081692, 3175218132),
L(1996064986, 2198950837),
L(2554220882, 3999719339),
L(2821834349, 766784016),
L(2952996808, 2566594879),
L(3210313671, 3203337956),
L(3336571891, 1034457026),
L(3584528711, 2466948901),
L(113926993, 3758326383),
L(338241895, 168717936),
L(666307205, 1188179964),
L(773529912, 1546045734),
L(1294757372, 1522805485),
L(1396182291, 2643833823),
L(1695183700, 2343527390),
L(1986661051, 1014477480),
L(2177026350, 1206759142),
L(2456956037, 344077627),
L(2730485921, 1290863460),
L(2820302411, 3158454273),
L(3259730800, 3505952657),
L(3345764771, 106217008),
L(3516065817, 3606008344),
L(3600352804, 1432725776),
L(4094571909, 1467031594),
L(275423344, 851169720),
L(430227734, 3100823752),
L(506948616, 1363258195),
L(659060556, 3750685593),
L(883997877, 3785050280),
L(958139571, 3318307427),
L(1322822218, 3812723403),
L(1537002063, 2003034995),
L(1747873779, 3602036899),
L(1955562222, 1575990012),
L(2024104815, 1125592928),
L(2227730452, 2716904306),
L(2361852424, 442776044),
L(2428436474, 593698344),
L(2756734187, 3733110249),
L(3204031479, 2999351573),
L(3329325298, 3815920427),
L(3391569614, 3928383900),
L(3515267271, 566280711),
L(3940187606, 3454069534),
L(4118630271, 4000239992),
L(116418474, 1914138554),
L(174292421, 2731055270),
L(289380356, 3203993006),
L(460393269, 320620315),
L(685471733, 587496836),
L(852142971, 1086792851),
L(1017036298, 365543100),
L(1126000580, 2618297676),
L(1288033470, 3409855158),
L(1501505948, 4234509866),
L(1607167915, 987167468),
L(1816402316, 1246189591),
],
$$1 = [],
Aa = 0;
80 > Aa;
Aa++
)
$$1[Aa] = L();
(M = M.k = xa.extend({
q: function () {
this.f = ya.create([
L(1779033703, 4089235720),
L(3144134277, 2227873595),
L(1013904242, 4271175723),
L(2773480762, 1595750129),
L(1359893119, 2917565137),
L(2600822924, 725511199),
L(528734635, 4215389547),
L(1541459225, 327033209),
]);
},
H: function (o, _) {
for (
var qb,
Da = this.f.d,
Ea = Da[0],
Fa = Da[1],
Ga = Da[2],
Ha = Da[3],
Ia = Da[4],
Ja = Da[5],
Ka = Da[6],
Da = Da[7],
La = Ea.a,
Ma = Ea.b,
Na = Fa.a,
Oa = Fa.b,
Pa = Ga.a,
Qa = Ga.b,
Ra = Ha.a,
Sa = Ha.b,
Ta = Ia.a,
Ua = Ia.b,
Va = Ja.a,
Wa = Ja.b,
Xa = Ka.a,
Ya = Ka.b,
Za = Da.a,
$a = Da.b,
_a = La,
ab = Ma,
bb = Na,
cb = Oa,
db = Pa,
eb = Qa,
fb = Ra,
gb = Sa,
hb = Ta,
ib = Ua,
jb = Va,
kb = Wa,
lb = Xa,
mb = Ya,
nb = Za,
ob = $a,
pb = 0;
80 > pb;
pb++
) {
if (((qb = $$1[pb]), 16 > pb))
var rb = (qb.a = 0 | o[_ + 2 * pb]),
sb = (qb.b = 0 | o[_ + 2 * pb + 1]);
else {
var rb = $$1[pb - 15],
sb = rb.a,
tb = rb.b,
rb =
((tb << 31) | (sb >>> 1)) ^
((tb << 24) | (sb >>> 8)) ^
(sb >>> 7),
tb =
((sb << 31) | (tb >>> 1)) ^
((sb << 24) | (tb >>> 8)) ^
((sb << 25) | (tb >>> 7)),
ub = $$1[pb - 2],
sb = ub.a,
vb = ub.b,
ub =
((vb << 13) | (sb >>> 19)) ^
((sb << 3) | (vb >>> 29)) ^
(sb >>> 6),
vb =
((sb << 13) | (vb >>> 19)) ^
((vb << 3) | (sb >>> 29)) ^
((sb << 26) | (vb >>> 6)),
sb = $$1[pb - 7],
wb = sb.a,
xb = $$1[pb - 16],
yb = xb.a,
xb = xb.b,
sb = tb + sb.b,
rb = rb + wb + (sb >>> 0 < tb >>> 0 ? 1 : 0),
sb = sb + vb,
rb = rb + ub + (sb >>> 0 < vb >>> 0 ? 1 : 0),
sb = sb + xb,
rb = rb + yb + (sb >>> 0 < xb >>> 0 ? 1 : 0);
(qb.a = rb), (qb.b = sb);
}
var wb = (hb & jb) ^ (~hb & lb),
xb = (ib & kb) ^ (~ib & mb),
qb = (_a & bb) ^ (_a & db) ^ (bb & db),
tb =
((ab << 4) | (_a >>> 28)) ^
((_a << 30) | (ab >>> 2)) ^
((_a << 25) | (ab >>> 7)),
ub =
((_a << 4) | (ab >>> 28)) ^
((ab << 30) | (_a >>> 2)) ^
((ab << 25) | (_a >>> 7)),
vb = za[pb],
Ab = vb.a,
Bb = vb.b,
vb =
ob +
(((hb << 18) | (ib >>> 14)) ^
((hb << 14) | (ib >>> 18)) ^
((ib << 23) | (hb >>> 9))),
yb =
nb +
(((ib << 18) | (hb >>> 14)) ^
((ib << 14) | (hb >>> 18)) ^
((hb << 23) | (ib >>> 9))) +
(vb >>> 0 < ob >>> 0 ? 1 : 0),
vb = vb + xb,
yb = yb + wb + (vb >>> 0 < xb >>> 0 ? 1 : 0),
vb = vb + Bb,
yb = yb + Ab + (vb >>> 0 < Bb >>> 0 ? 1 : 0),
vb = vb + sb,
yb = yb + rb + (vb >>> 0 < sb >>> 0 ? 1 : 0),
sb = ub + ((ab & cb) ^ (ab & eb) ^ (cb & eb)),
qb = tb + qb + (sb >>> 0 < ub >>> 0 ? 1 : 0),
nb = lb,
ob = mb,
lb = jb,
mb = kb,
jb = hb,
kb = ib,
ib = 0 | (gb + vb),
hb = 0 | (fb + yb + (ib >>> 0 < gb >>> 0 ? 1 : 0)),
fb = db,
gb = eb,
db = bb,
eb = cb,
bb = _a,
cb = ab,
ab = 0 | (vb + sb),
_a = 0 | (yb + qb + (ab >>> 0 < vb >>> 0 ? 1 : 0));
}
(Ma = Ea.b = 0 | (Ma + ab)),
(Ea.a = 0 | (La + _a + (Ma >>> 0 < ab >>> 0 ? 1 : 0))),
(Oa = Fa.b = 0 | (Oa + cb)),
(Fa.a = 0 | (Na + bb + (Oa >>> 0 < cb >>> 0 ? 1 : 0))),
(Qa = Ga.b = 0 | (Qa + eb)),
(Ga.a = 0 | (Pa + db + (Qa >>> 0 < eb >>> 0 ? 1 : 0))),
(Sa = Ha.b = 0 | (Sa + gb)),
(Ha.a = 0 | (Ra + fb + (Sa >>> 0 < gb >>> 0 ? 1 : 0))),
(Ua = Ia.b = 0 | (Ua + ib)),
(Ia.a = 0 | (Ta + hb + (Ua >>> 0 < ib >>> 0 ? 1 : 0))),
(Wa = Ja.b = 0 | (Wa + kb)),
(Ja.a = 0 | (Va + jb + (Wa >>> 0 < kb >>> 0 ? 1 : 0))),
(Ya = Ka.b = 0 | (Ya + mb)),
(Ka.a = 0 | (Xa + lb + (Ya >>> 0 < mb >>> 0 ? 1 : 0))),
($a = Da.b = 0 | ($a + ob)),
(Da.a = 0 | (Za + nb + ($a >>> 0 < ob >>> 0 ? 1 : 0)));
},
G: function () {
var o = this.g,
_ = o.d,
Da = 8 * this.j,
Ea = 8 * o.c;
(_[Ea >>> 5] |= 128 << (24 - (Ea % 32))),
(_[(((Ea + 128) >>> 10) << 5) + 31] = Da),
(o.c = 4 * _.length),
this.m(),
(this.f = this.f.v());
},
n: 32,
})),
(t$1.k = xa.D(M)),
(t$1.L = xa.F(M));
function sha512(o) {
return t$1.k(o) + "";
}
function setCookie(cname, cvalue, exdate) {
var expires = exdate ? `;expires=${exdate}` : "";
document.cookie = `${cname}=${cvalue}${expires}`;
}
function getCookie(cname) {
var name = cname + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.split(";");
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == " ") {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
var appname = "test";
function Loader() {
return v(
"div",
{ class: "loader_box", id: "loader" },
v("div", { class: "loader" })
);
}
var Username = /** @class */ (function (_super) {
__extends(Username, _super);
function Username() {
var _this = _super.call(this) || this;
_this.state = { error: undefined, loading: false };
return _this;
}
Username.prototype.onClick = function () {
return __awaiter(this, void 0, void 0, function () {
var res, salt, err_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
this.setState({ loading: true });
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
return [
4 /*yield*/,
fetch(
"/api/user/login?type=username&username=" +
this.username_input.value,
{
method: "POST",
}
)
.then(function (e) {
if (e.status !== 200)
throw new Error(e.statusText);
return e.json();
})
.then(function (data) {
if (data.error) {
return Promise.reject(
new Error(data.error)
);
}
return data;
}),
];
case 2:
res = _a.sent();
salt = res.salt;
this.props.onNext(
this.username_input.value,
salt
);
return [3 /*break*/, 4];
case 3:
err_1 = _a.sent();
this.setState({
error: err_1.message,
});
return [3 /*break*/, 4];
case 4:
this.setState({ loading: false });
return [2 /*return*/];
}
});
});
};
Username.prototype.render = function () {
var _this = this;
if (this.state.loading) return v(Loader, null);
return v(
"div",
null,
v(
"div",
{ class: "floating group" },
v("input", {
onKeyDown: function (e) {
var k = e.keyCode | e.which;
if (k === 13) _this.onClick();
_this.setState({ error: undefined });
},
type: "text",
value: this.username_input
? this.username_input.value
: this.props.username,
autofocus: true,
ref: function (elm) {
return elm
? (_this.username_input = elm)
: undefined;
},
}),
v("span", { class: "highlight" }),
v("span", { class: "bar" }),
v("label", null, "Username or Email"),
this.state.error
? v("div", { class: "error" }, " ", this.state.error)
: undefined
),
v(
"button",
{
type: "button",
class: "mdc-button mdc-button--raised spanned-btn",
onClick: function () {
return _this.onClick();
},
},
"Next"
)
);
};
return Username;
})(y);
var TFATypes;
(function (TFATypes) {
TFATypes[(TFATypes["OTC"] = 0)] = "OTC";
TFATypes[(TFATypes["BACKUP_CODE"] = 1)] = "BACKUP_CODE";
TFATypes[(TFATypes["YUBI_KEY"] = 2)] = "YUBI_KEY";
TFATypes[(TFATypes["APP_ALLOW"] = 3)] = "APP_ALLOW";
})(TFATypes || (TFATypes = {}));
var Password = /** @class */ (function (_super) {
__extends(Password, _super);
function Password() {
var _this = _super.call(this) || this;
_this.state = { error: undefined, loading: false };
return _this;
}
Password.prototype.onClick = function () {
return __awaiter(this, void 0, void 0, function () {
var pw, _a, login, special, tfa, err_2;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
this.setState({
loading: true,
});
_b.label = 1;
case 1:
_b.trys.push([1, 3, , 4]);
pw = sha512(
this.props.salt + this.password_input.value
);
return [
4 /*yield*/,
fetch("/api/user/login?type=password", {
method: "POST",
body: JSON.stringify({
username: this.props.username,
password: pw,
}),
headers: {
"content-type": "application/json",
},
})
.then(function (e) {
if (e.status !== 200)
throw new Error(e.statusText);
return e.json();
})
.then(function (data) {
if (data.error) {
return Promise.reject(
new Error(data.error)
);
}
return data;
}),
];
case 2:
(_a = _b.sent()),
(login = _a.login),
(special = _a.special),
(tfa = _a.tfa);
this.props.onNext(login, special, tfa);
return [3 /*break*/, 4];
case 3:
err_2 = _b.sent();
this.setState({ error: err_2.messagae });
return [3 /*break*/, 4];
case 4:
this.setState({ loading: false });
return [2 /*return*/];
}
});
});
};
Password.prototype.render = function () {
var _this = this;
if (this.state.loading) return v(Loader, null);
return v(
"div",
null,
v(
"div",
{ class: "floating group" },
v("input", {
onKeyDown: function (e) {
var k = e.keyCode | e.which;
if (k === 13) _this.onClick();
_this.setState({ error: undefined });
},
type: "password",
ref: function (elm) {
if (elm) {
_this.password_input = elm;
setTimeout(function () {
return elm.focus();
}, 200);
// elm.focus();
}
},
}),
v("span", { class: "highlight" }),
v("span", { class: "bar" }),
v("label", null, "Password"),
this.state.error
? v("div", { class: "error" }, " ", this.state.error)
: undefined
),
v(
"button",
{
type: "button",
class: "mdc-button mdc-button--raised spanned-btn",
onClick: function () {
return _this.onClick();
},
},
"Login"
)
);
};
return Password;
})(y);
var TwoFactor = /** @class */ (function (_super) {
__extends(TwoFactor, _super);
function TwoFactor() {
return (
(_super !== null && _super.apply(this, arguments)) || this
);
}
TwoFactor.prototype.render = function () {
var _this = this;
var tfs = this.props.twofactors.map(function (fac) {
var name;
switch (fac.type) {
case TFATypes.OTC:
name = "Authenticator";
break;
case TFATypes.BACKUP_CODE:
name = "Backup code";
break;
case TFATypes.APP_ALLOW:
name = "Use App: %s";
break;
case TFATypes.YUBI_KEY:
name = "Use Yubikey: %s";
break;
}
name = name.replace("%s", fac.name ? fac.name : "");
return v(
"li",
{
onClick: function () {
console.log("Click on Solution");
_this.props.next(fac.id, fac.type);
},
},
name
);
});
return v(
"div",
null,
v("h1", null, "Select one"),
v("ul", null, tfs)
);
};
return TwoFactor;
})(y);
// class TFA_YubiKey extends Component<{ id: string, login: Token, special: Token, next: (login: Token, special: Token) => void }, {}> {
// render() {
// }
// }
var Page;
(function (Page) {
Page[(Page["username"] = 0)] = "username";
Page[(Page["password"] = 1)] = "password";
Page[(Page["twofactor"] = 2)] = "twofactor";
Page[(Page["yubikey"] = 3)] = "yubikey";
})(Page || (Page = {}));
function apiRequest(endpoint, method, body) {
if (method === void 0) {
method = "GET";
}
if (body === void 0) {
body = undefined;
}
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [
2 /*return*/,
fetch(endpoint, {
method: method,
body: body,
credentials: "same-origin",
headers: {
"content-type": "application/json",
},
})
.then(function (e) {
if (e.status !== 200)
throw new Error(e.statusText);
return e.json();
})
.then(function (data) {
if (data.error) {
return Promise.reject(new Error(data.error));
}
return data;
}),
];
});
});
}
var App = /** @class */ (function (_super) {
__extends(App, _super);
function App() {
var _this = _super.call(this) || this;
_this.state = {
page: Page.username,
username: getCookie("username"),
salt: undefined,
twofactor: [],
twofactor_id: null,
};
return _this;
}
App.prototype.setCookies = function () {
setCookie(
"login",
this.login.token,
new Date(this.login.expires).toUTCString()
);
setCookie(
"special",
this.special.token,
new Date(this.special.expires).toUTCString()
);
};
App.prototype.finish = function () {
this.setCookies();
var d = new Date();
d.setTime(d.getTime() + 30 * 24 * 60 * 60 * 1000); //Keep the username 30 days
setCookie("username", this.state.username, d.toUTCString());
var url = new URL(window.location.href);
var state = url.searchParams.get("state");
var red = "/";
if (state) {
var base64 = url.searchParams.get("base64");
if (base64) red = atob(state);
else red = state;
}
window.location.href = red;
};
App.prototype.render = function () {
var _this = this;
var cont;
switch (this.state.page) {
case Page.username:
cont = v(Username, {
username: this.state.username,
onNext: function (username, salt) {
_this.setState({
username: username,
salt: salt,
page: Page.password,
});
localStorage.setItem("username", username);
},
});
break;
case Page.password:
cont = v(Password, {
username: this.state.username,
salt: this.state.salt,
onNext: function (login, special, twofactor) {
_this.login = login;
_this.special = special;
_this.setCookies();
if (!twofactor) {
_this.finish();
} else {
_this.setState({
twofactor: twofactor,
page: Page.twofactor,
});
}
},
});
break;
case Page.twofactor:
cont = v(TwoFactor, {
twofactors: this.state.twofactor,
next: function (id, type) {
return __awaiter(
_this,
void 0,
void 0,
function () {
var request;
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!(type === TFATypes.YUBI_KEY))
return [3 /*break*/, 2];
return [
4 /*yield*/,
apiRequest(
"/api/user/twofactor/yubikey",
"GET"
),
];
case 1:
request = _a.sent().request;
console.log(request);
window.u2f.sign(
request.appId,
[request.challenge],
[request],
function (response) {
return __awaiter(
_this,
void 0,
void 0,
function () {
var res;
return __generator(
this,
function (_a) {
switch (
_a.label
) {
case 0:
return [
4 /*yield*/,
apiRequest(
"/api/user/twofactor/yubikey",
"PUT",
JSON.stringify(
{
response: response,
}
)
),
];
case 1:
res = _a.sent();
if (
res.success
) {
this.login.expires =
res.login_exp;
this.special.expires =
res.special_exp;
this.finish();
}
return [
2 /*return*/,
];
}
}
);
}
);
}
);
_a.label = 2;
case 2:
return [2 /*return*/];
}
});
}
);
},
});
break;
// case Page.yubikey:
// cont = <TFA_YubiKey id={this.state.twofactor_id} login={this.login} special={this.special} next={(login, special) => {
// this.login = login;
// this.special = special;
// this.finish()
// }} />
// break;
}
return v(
"div",
null,
v("header", null, v("h1", null, "Login")),
v("form", { action: "JavaScript:void(0)" }, cont),
v("footer", null, v("p", null, "Powered by ", appname))
);
};
return App;
})(y);
document.addEventListener(
"DOMContentLoaded",
function () {
E(v(App, null), document.body.querySelector("#content"));
},
false
);
})();
</script>
</body>
</html>