Using prettier to format

This commit is contained in:
Fabian Stamm 2020-03-11 13:54:13 +01:00
parent afd25f47d7
commit df017833a4
9 changed files with 551 additions and 552 deletions

View File

@ -5,7 +5,7 @@ indent_style = space
indent_size = 3 indent_size = 3
charset = utf-8 charset = utf-8
trim_trailing_whitespace = false trim_trailing_whitespace = false
insert_final_newline = false insert_final_newline = true
[*.svelte] [*.svelte]
indent_size = 2 indent_size = 2

3
.vscode/extensions.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"recommendations": ["esbenp.prettier-vscode"]
}

View File

@ -1,100 +1,99 @@
<script> <script>
// import { // import {
// onMount, // onMount,
// onDestroy // onDestroy
// } from "svelte"; // } from "svelte";
import { import { onMount, onDestroy } from "svelte";
onMount,
onDestroy
} from 'svelte';
const basetext = "Logged in. Redirecting"; const basetext = "Logged in. Redirecting";
let dots = 0; let dots = 0;
$: text = basetext + ".".repeat(dots); $: text = basetext + ".".repeat(dots);
let iv; let iv;
onMount(() => { onMount(() => {
console.log("Mounted"); console.log("Mounted");
iv = setInterval(() => { iv = setInterval(() => {
dots++; dots++;
if (dots > 3) if (dots > 3) dots = 0;
dots = 0; }, 500);
}, 500); });
});
onDestroy(() => { onDestroy(() => {
console.log("on Destroy") console.log("on Destroy");
clearInterval(iv) clearInterval(iv);
}); });
</script> </script>
<style>
.checkmark__circle {
stroke-dasharray: 166;
stroke-dashoffset: 166;
stroke-width: 2;
stroke-miterlimit: 10;
stroke: #7ac142;
fill: none;
animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}
.checkmark {
width: 56px;
height: 56px;
border-radius: 50%;
display: block;
stroke-width: 2;
stroke: #fff;
stroke-miterlimit: 10;
margin: 10% auto;
box-shadow: inset 0px 0px 0px #7ac142;
animation: fill 0.4s ease-in-out 0.4s forwards,
scale 0.3s ease-in-out 0.9s both;
}
.checkmark__check {
transform-origin: 50% 50%;
stroke-dasharray: 48;
stroke-dashoffset: 48;
animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.8s forwards;
}
@keyframes stroke {
100% {
stroke-dashoffset: 0;
}
}
@keyframes scale {
0%,
100% {
transform: none;
}
50% {
transform: scale3d(1.1, 1.1, 1);
}
}
@keyframes fill {
100% {
box-shadow: inset 0px 0px 0px 30px #7ac142;
}
}
.scale {
transform: scale(1.5);
}
</style>
<div class="scale"> <div class="scale">
<svg class="checkmark" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52"> <svg class="checkmark" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52">
<circle class="checkmark__circle" cx="26" cy="26" r="25" fill="none" /> <circle class="checkmark__circle" cx="26" cy="26" r="25" fill="none" />
<path class="checkmark__check" fill="none" d="M14.1 27.2l7.1 7.2 16.7-16.8" /> <path
</svg> class="checkmark__check"
fill="none"
d="M14.1 27.2l7.1 7.2 16.7-16.8" />
</svg>
</div> </div>
<!-- <div style="text-align: center;"> --> <!-- <div style="text-align: center;"> -->
<h3>{text}</h3> <h3>{text}</h3>
<!-- </div> --> <!-- </div> -->
<style>
.checkmark__circle {
stroke-dasharray: 166;
stroke-dashoffset: 166;
stroke-width: 2;
stroke-miterlimit: 10;
stroke: #7ac142;
fill: none;
animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}
.checkmark {
width: 56px;
height: 56px;
border-radius: 50%;
display: block;
stroke-width: 2;
stroke: #fff;
stroke-miterlimit: 10;
margin: 10% auto;
box-shadow: inset 0px 0px 0px #7ac142;
animation: fill .4s ease-in-out .4s forwards, scale .3s ease-in-out .9s both;
}
.checkmark__check {
transform-origin: 50% 50%;
stroke-dasharray: 48;
stroke-dashoffset: 48;
animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.8s forwards;
}
@keyframes stroke {
100% {
stroke-dashoffset: 0;
}
}
@keyframes scale {
0%,
100% {
transform: none;
}
50% {
transform: scale3d(1.1, 1.1, 1);
}
}
@keyframes fill {
100% {
box-shadow: inset 0px 0px 0px 30px #7ac142;
}
}
.scale {
transform: scale(1.5);
}
</style>

View File

@ -1,35 +1,33 @@
<script> <script>
import Cleave from "../../cleave" import Cleave from "../../cleave";
import { import { onMount } from "svelte";
onMount
} from 'svelte';
export let error; export let error;
export let label; export let label;
export let value; export let value;
export let length = 6; export let length = 6;
let input; let input;
onMount(() => { onMount(() => {
const cleaveCustom = new Cleave(input, { const cleaveCustom = new Cleave(input, {
blocks: [length / 2, length / 2], blocks: [length / 2, length / 2],
delimiter: ' ', delimiter: " ",
numericOnly: true numericOnly: true
}); });
}) });
</script> </script>
<style> <style>
.error { .error {
color: var(--error); color: var(--error);
margin-top: 4px; margin-top: 4px;
} }
</style> </style>
<div class="floating group"> <div class="floating group">
<input bind:this={input} autofocus bind:value={value}> <input bind:this={input} autofocus bind:value />
<span class="highlight"></span> <span class="highlight" />
<span class="bar"></span> <span class="bar" />
<label>Code</label> <label>Code</label>
<div class="error" style={!error ? "display: none;" : "" }>{error}</div> <div class="error" style={!error ? 'display: none;' : ''}>{error}</div>
</div> </div>

View File

@ -1,393 +1,392 @@
<script> <script>
import ToList from "./toList.svelte"; import ToList from "./toList.svelte";
let error = ""; let error = "";
let code = ""; let code = "";
export let device = "Handy01"; export let device = "Handy01";
export let deviceId = ""; export let deviceId = "";
export let finish; export let finish;
async function requestPush() { async function requestPush() {
// Push Request
// Push Request }
}
</script> </script>
<style> <style>
.error { .error {
color: var(--error); color: var(--error);
} }
.windows8 { .windows8 {
position: relative; position: relative;
width: 56px; width: 56px;
height: 56px; height: 56px;
margin: 2rem auto; margin: 2rem auto;
} }
.windows8 .wBall { .windows8 .wBall {
position: absolute; position: absolute;
width: 53px; width: 53px;
height: 53px; height: 53px;
opacity: 0;
transform: rotate(225deg);
-o-transform: rotate(225deg);
-ms-transform: rotate(225deg);
-webkit-transform: rotate(225deg);
-moz-transform: rotate(225deg);
animation: orbit 5.7425s infinite;
-o-animation: orbit 5.7425s infinite;
-ms-animation: orbit 5.7425s infinite;
-webkit-animation: orbit 5.7425s infinite;
-moz-animation: orbit 5.7425s infinite;
}
.windows8 .wBall .wInnerBall {
position: absolute;
width: 7px;
height: 7px;
background: rgb(0, 140, 255);
left: 0px;
top: 0px;
border-radius: 7px;
}
.windows8 #wBall_1 {
animation-delay: 1.256s;
-o-animation-delay: 1.256s;
-ms-animation-delay: 1.256s;
-webkit-animation-delay: 1.256s;
-moz-animation-delay: 1.256s;
}
.windows8 #wBall_2 {
animation-delay: 0.243s;
-o-animation-delay: 0.243s;
-ms-animation-delay: 0.243s;
-webkit-animation-delay: 0.243s;
-moz-animation-delay: 0.243s;
}
.windows8 #wBall_3 {
animation-delay: 0.5065s;
-o-animation-delay: 0.5065s;
-ms-animation-delay: 0.5065s;
-webkit-animation-delay: 0.5065s;
-moz-animation-delay: 0.5065s;
}
.windows8 #wBall_4 {
animation-delay: 0.7495s;
-o-animation-delay: 0.7495s;
-ms-animation-delay: 0.7495s;
-webkit-animation-delay: 0.7495s;
-moz-animation-delay: 0.7495s;
}
.windows8 #wBall_5 {
animation-delay: 1.003s;
-o-animation-delay: 1.003s;
-ms-animation-delay: 1.003s;
-webkit-animation-delay: 1.003s;
-moz-animation-delay: 1.003s;
}
@keyframes orbit {
0% {
opacity: 1;
z-index: 99;
transform: rotate(180deg);
animation-timing-function: ease-out;
}
7% {
opacity: 1;
transform: rotate(300deg);
animation-timing-function: linear;
origin: 0%;
}
30% {
opacity: 1;
transform: rotate(410deg);
animation-timing-function: ease-in-out;
origin: 7%;
}
39% {
opacity: 1;
transform: rotate(645deg);
animation-timing-function: linear;
origin: 30%;
}
70% {
opacity: 1;
transform: rotate(770deg);
animation-timing-function: ease-out;
origin: 39%;
}
75% {
opacity: 1;
transform: rotate(900deg);
animation-timing-function: ease-out;
origin: 70%;
}
76% {
opacity: 0; opacity: 0;
transform: rotate(225deg); transform: rotate(900deg);
-o-transform: rotate(225deg); }
-ms-transform: rotate(225deg);
-webkit-transform: rotate(225deg);
-moz-transform: rotate(225deg);
animation: orbit 5.7425s infinite;
-o-animation: orbit 5.7425s infinite;
-ms-animation: orbit 5.7425s infinite;
-webkit-animation: orbit 5.7425s infinite;
-moz-animation: orbit 5.7425s infinite;
}
.windows8 .wBall .wInnerBall { 100% {
position: absolute; opacity: 0;
width: 7px; transform: rotate(900deg);
height: 7px; }
background: rgb(0, 140, 255); }
left: 0px;
top: 0px;
border-radius: 7px;
}
.windows8 #wBall_1 { @-o-keyframes orbit {
animation-delay: 1.256s; 0% {
-o-animation-delay: 1.256s; opacity: 1;
-ms-animation-delay: 1.256s; z-index: 99;
-webkit-animation-delay: 1.256s; -o-transform: rotate(180deg);
-moz-animation-delay: 1.256s; -o-animation-timing-function: ease-out;
} }
.windows8 #wBall_2 { 7% {
animation-delay: 0.243s; opacity: 1;
-o-animation-delay: 0.243s; -o-transform: rotate(300deg);
-ms-animation-delay: 0.243s; -o-animation-timing-function: linear;
-webkit-animation-delay: 0.243s; -o-origin: 0%;
-moz-animation-delay: 0.243s; }
}
.windows8 #wBall_3 { 30% {
animation-delay: 0.5065s; opacity: 1;
-o-animation-delay: 0.5065s; -o-transform: rotate(410deg);
-ms-animation-delay: 0.5065s; -o-animation-timing-function: ease-in-out;
-webkit-animation-delay: 0.5065s; -o-origin: 7%;
-moz-animation-delay: 0.5065s; }
}
.windows8 #wBall_4 { 39% {
animation-delay: 0.7495s; opacity: 1;
-o-animation-delay: 0.7495s; -o-transform: rotate(645deg);
-ms-animation-delay: 0.7495s; -o-animation-timing-function: linear;
-webkit-animation-delay: 0.7495s; -o-origin: 30%;
-moz-animation-delay: 0.7495s; }
}
.windows8 #wBall_5 { 70% {
animation-delay: 1.003s; opacity: 1;
-o-animation-delay: 1.003s; -o-transform: rotate(770deg);
-ms-animation-delay: 1.003s; -o-animation-timing-function: ease-out;
-webkit-animation-delay: 1.003s; -o-origin: 39%;
-moz-animation-delay: 1.003s; }
}
75% {
opacity: 1;
-o-transform: rotate(900deg);
-o-animation-timing-function: ease-out;
-o-origin: 70%;
}
76% {
opacity: 0;
-o-transform: rotate(900deg);
}
@keyframes orbit { 100% {
0% { opacity: 0;
opacity: 1; -o-transform: rotate(900deg);
z-index: 99; }
transform: rotate(180deg); }
animation-timing-function: ease-out;
}
7% { @-ms-keyframes orbit {
opacity: 1; 0% {
transform: rotate(300deg); opacity: 1;
animation-timing-function: linear; z-index: 99;
origin: 0%; -ms-transform: rotate(180deg);
} -ms-animation-timing-function: ease-out;
}
30% { 7% {
opacity: 1; opacity: 1;
transform: rotate(410deg); -ms-transform: rotate(300deg);
animation-timing-function: ease-in-out; -ms-animation-timing-function: linear;
origin: 7%; -ms-origin: 0%;
} }
39% { 30% {
opacity: 1; opacity: 1;
transform: rotate(645deg); -ms-transform: rotate(410deg);
animation-timing-function: linear; -ms-animation-timing-function: ease-in-out;
origin: 30%; -ms-origin: 7%;
} }
70% { 39% {
opacity: 1; opacity: 1;
transform: rotate(770deg); -ms-transform: rotate(645deg);
animation-timing-function: ease-out; -ms-animation-timing-function: linear;
origin: 39%; -ms-origin: 30%;
} }
75% { 70% {
opacity: 1; opacity: 1;
transform: rotate(900deg); -ms-transform: rotate(770deg);
animation-timing-function: ease-out; -ms-animation-timing-function: ease-out;
origin: 70%; -ms-origin: 39%;
} }
76% { 75% {
opacity: 0; opacity: 1;
transform: rotate(900deg); -ms-transform: rotate(900deg);
} -ms-animation-timing-function: ease-out;
-ms-origin: 70%;
}
100% { 76% {
opacity: 0; opacity: 0;
transform: rotate(900deg); -ms-transform: rotate(900deg);
} }
}
@-o-keyframes orbit { 100% {
0% { opacity: 0;
opacity: 1; -ms-transform: rotate(900deg);
z-index: 99; }
-o-transform: rotate(180deg); }
-o-animation-timing-function: ease-out;
}
7% { @-webkit-keyframes orbit {
opacity: 1; 0% {
-o-transform: rotate(300deg); opacity: 1;
-o-animation-timing-function: linear; z-index: 99;
-o-origin: 0%; -webkit-transform: rotate(180deg);
} -webkit-animation-timing-function: ease-out;
}
30% { 7% {
opacity: 1; opacity: 1;
-o-transform: rotate(410deg); -webkit-transform: rotate(300deg);
-o-animation-timing-function: ease-in-out; -webkit-animation-timing-function: linear;
-o-origin: 7%; -webkit-origin: 0%;
} }
39% { 30% {
opacity: 1; opacity: 1;
-o-transform: rotate(645deg); -webkit-transform: rotate(410deg);
-o-animation-timing-function: linear; -webkit-animation-timing-function: ease-in-out;
-o-origin: 30%; -webkit-origin: 7%;
} }
70% { 39% {
opacity: 1; opacity: 1;
-o-transform: rotate(770deg); -webkit-transform: rotate(645deg);
-o-animation-timing-function: ease-out; -webkit-animation-timing-function: linear;
-o-origin: 39%; -webkit-origin: 30%;
} }
75% { 70% {
opacity: 1; opacity: 1;
-o-transform: rotate(900deg); -webkit-transform: rotate(770deg);
-o-animation-timing-function: ease-out; -webkit-animation-timing-function: ease-out;
-o-origin: 70%; -webkit-origin: 39%;
} }
76% { 75% {
opacity: 0; opacity: 1;
-o-transform: rotate(900deg); -webkit-transform: rotate(900deg);
} -webkit-animation-timing-function: ease-out;
-webkit-origin: 70%;
}
100% { 76% {
opacity: 0; opacity: 0;
-o-transform: rotate(900deg); -webkit-transform: rotate(900deg);
} }
}
@-ms-keyframes orbit { 100% {
0% { opacity: 0;
opacity: 1; -webkit-transform: rotate(900deg);
z-index: 99; }
-ms-transform: rotate(180deg); }
-ms-animation-timing-function: ease-out;
}
7% { @-moz-keyframes orbit {
opacity: 1; 0% {
-ms-transform: rotate(300deg); opacity: 1;
-ms-animation-timing-function: linear; z-index: 99;
-ms-origin: 0%; -moz-transform: rotate(180deg);
} -moz-animation-timing-function: ease-out;
}
30% { 7% {
opacity: 1; opacity: 1;
-ms-transform: rotate(410deg); -moz-transform: rotate(300deg);
-ms-animation-timing-function: ease-in-out; -moz-animation-timing-function: linear;
-ms-origin: 7%; -moz-origin: 0%;
} }
39% { 30% {
opacity: 1; opacity: 1;
-ms-transform: rotate(645deg); -moz-transform: rotate(410deg);
-ms-animation-timing-function: linear; -moz-animation-timing-function: ease-in-out;
-ms-origin: 30%; -moz-origin: 7%;
} }
70% { 39% {
opacity: 1; opacity: 1;
-ms-transform: rotate(770deg); -moz-transform: rotate(645deg);
-ms-animation-timing-function: ease-out; -moz-animation-timing-function: linear;
-ms-origin: 39%; -moz-origin: 30%;
} }
75% { 70% {
opacity: 1; opacity: 1;
-ms-transform: rotate(900deg); -moz-transform: rotate(770deg);
-ms-animation-timing-function: ease-out; -moz-animation-timing-function: ease-out;
-ms-origin: 70%; -moz-origin: 39%;
} }
76% { 75% {
opacity: 0; opacity: 1;
-ms-transform: rotate(900deg); -moz-transform: rotate(900deg);
} -moz-animation-timing-function: ease-out;
-moz-origin: 70%;
}
100% { 76% {
opacity: 0; opacity: 0;
-ms-transform: rotate(900deg); -moz-transform: rotate(900deg);
} }
}
@-webkit-keyframes orbit { 100% {
0% { opacity: 0;
opacity: 1; -moz-transform: rotate(900deg);
z-index: 99; }
-webkit-transform: rotate(180deg); }
-webkit-animation-timing-function: ease-out;
}
7% {
opacity: 1;
-webkit-transform: rotate(300deg);
-webkit-animation-timing-function: linear;
-webkit-origin: 0%;
}
30% {
opacity: 1;
-webkit-transform: rotate(410deg);
-webkit-animation-timing-function: ease-in-out;
-webkit-origin: 7%;
}
39% {
opacity: 1;
-webkit-transform: rotate(645deg);
-webkit-animation-timing-function: linear;
-webkit-origin: 30%;
}
70% {
opacity: 1;
-webkit-transform: rotate(770deg);
-webkit-animation-timing-function: ease-out;
-webkit-origin: 39%;
}
75% {
opacity: 1;
-webkit-transform: rotate(900deg);
-webkit-animation-timing-function: ease-out;
-webkit-origin: 70%;
}
76% {
opacity: 0;
-webkit-transform: rotate(900deg);
}
100% {
opacity: 0;
-webkit-transform: rotate(900deg);
}
}
@-moz-keyframes orbit {
0% {
opacity: 1;
z-index: 99;
-moz-transform: rotate(180deg);
-moz-animation-timing-function: ease-out;
}
7% {
opacity: 1;
-moz-transform: rotate(300deg);
-moz-animation-timing-function: linear;
-moz-origin: 0%;
}
30% {
opacity: 1;
-moz-transform: rotate(410deg);
-moz-animation-timing-function: ease-in-out;
-moz-origin: 7%;
}
39% {
opacity: 1;
-moz-transform: rotate(645deg);
-moz-animation-timing-function: linear;
-moz-origin: 30%;
}
70% {
opacity: 1;
-moz-transform: rotate(770deg);
-moz-animation-timing-function: ease-out;
-moz-origin: 39%;
}
75% {
opacity: 1;
-moz-transform: rotate(900deg);
-moz-animation-timing-function: ease-out;
-moz-origin: 70%;
}
76% {
opacity: 0;
-moz-transform: rotate(900deg);
}
100% {
opacity: 0;
-moz-transform: rotate(900deg);
}
}
</style> </style>
<h3>SMS</h3> <h3>SMS</h3>
<p>A code was sent to your Device <b>{device}</b></p> <p>
A code was sent to your Device
<b>{device}</b>
</p>
<div class="windows8"> <div class="windows8">
<div class="wBall" id="wBall_1"> <div class="wBall" id="wBall_1">
<div class="wInnerBall"></div> <div class="wInnerBall" />
</div> </div>
<div class="wBall" id="wBall_2"> <div class="wBall" id="wBall_2">
<div class="wInnerBall"></div> <div class="wInnerBall" />
</div> </div>
<div class="wBall" id="wBall_3"> <div class="wBall" id="wBall_3">
<div class="wInnerBall"></div> <div class="wInnerBall" />
</div> </div>
<div class="wBall" id="wBall_4"> <div class="wBall" id="wBall_4">
<div class="wInnerBall"></div> <div class="wInnerBall" />
</div> </div>
<div class="wBall" id="wBall_5"> <div class="wBall" id="wBall_5">
<div class="wInnerBall"></div> <div class="wInnerBall" />
</div> </div>
</div> </div>
<div class="error">{error}</div> <div class="error">{error}</div>
<ToList {finish} /> <ToList {finish} />

View File

@ -1,49 +1,49 @@
<script> <script>
import ToList from "./toList.svelte"; import ToList from "./toList.svelte";
const states = { const states = {
approve: 1, approve: 1,
enter: 2 enter: 2
} };
let state = states.approve; let state = states.approve;
let error = ""; let error = "";
let code = ""; let code = "";
export let number = "+4915...320"; export let number = "+4915...320";
//export let finish; //export let finish;
function validateCode() { function validateCode() {}
} function sendCode() {
// Send request to Server
function sendCode() { state = states.enter;
// Send request to Server //finish()
state = states.enter; }
//finish()
}
</script> </script>
<style> <style>
:root { :root {
--error: red; --error: red;
} }
.error { .error {
color: var(--error); color: var(--error);
} }
</style> </style>
<h3>SMS</h3> <h3>SMS</h3>
{#if state === states.approve} {#if state === states.approve}
<p>Send SMS to {number}</p> <p>Send SMS to {number}</p>
<button class="btn" on:click={sendCode}>Send</button> <button class="btn" on:click={sendCode}>Send</button>
{:else} {:else}
<p>A code was sent to you. Please enter</p> <p>A code was sent to you. Please enter</p>
<input type="number" placeholder="Code" bind:value={code} /> <input type="number" placeholder="Code" bind:value={code} />
<button on:click={validateCode}>Send</button><br> <button on:click={validateCode}>Send</button>
<a href="# " on:click|preventDefault={() => state = states.approve}>Not received?</a> <br />
<a href="# " on:click|preventDefault={() => (state = states.approve)}>
Not received?
</a>
{/if} {/if}
<div class="error">{error}</div> <div class="error">{error}</div>
<ToList {finish}/> <ToList {finish} />

View File

@ -1,13 +1,16 @@
<script> <script>
export let finish = () => {}; export let finish = () => {};
</script> </script>
<style> <style>
a { a {
color: var(--primary); color: var(--primary);
text-decoration: none; text-decoration: none;
} }
</style> </style>
<p> <p>
<a href="# " on:click={evt=>evt.preventDefault() || finish(false)}>Choose another Method</a> <a href="# " on:click={evt => evt.preventDefault() || finish(false)}>
</p> Choose another Method
</a>
</p>

View File

@ -1,72 +1,69 @@
<script> <script>
import ToList from "./toList.svelte"; import ToList from "./toList.svelte";
export let finish; export let finish;
const states = { const states = {
getChallenge: 0, getChallenge: 0,
requestUser: 1, requestUser: 1,
sendChallenge: 2, sendChallenge: 2,
error: 3 error: 3
} };
let state = states.getChallenge; let state = states.getChallenge;
let error = ""; let error = "";
const onError = err => { const onError = err => {
state = states.error; state = states.error;
error = err.message; error = err.message;
}; };
let challenge; let challenge;
async function requestUser() { async function requestUser() {
state = states.requestUser; state = states.requestUser;
let res = await window.navigator.credentials.get({ let res = await window.navigator.credentials.get({
publicKey: challenge publicKey: challenge
}) });
state = states.sendChallenge(); state = states.sendChallenge();
let r = res.response; let r = res.response;
let data = encode({ let data = encode({
authenticatorData: r.authenticatorData, authenticatorData: r.authenticatorData,
clientDataJSON: r.clientDataJSON, clientDataJSON: r.clientDataJSON,
signature: r.signature, signature: r.signature,
userHandle: r.userHandle userHandle: r.userHandle
}); });
let { let { success } = fetch("https://localhost:8444/auth", {
success body: data,
} = fetch("https://localhost:8444/auth", { method: "POST"
body: data, }).then(res => res.json());
method: "POST" if (success) {
}).then(res => res.json()) finish(true);
if (success) { }
finish(true); }
}
}
async function getChallenge() { async function getChallenge() {
state = states.getChallenge; state = states.getChallenge;
challenge = await fetch("https://localhost:8444/auth") challenge = await fetch("https://localhost:8444/auth")
.then(res => res.arrayBuffer()) .then(res => res.arrayBuffer())
.then(data => decode(MessagePack.Buffer.from(data))); .then(data => decode(MessagePack.Buffer.from(data)));
requestUser().catch(onError); requestUser().catch(onError);
} }
getChallenge().catch(onError) getChallenge().catch(onError);
</script> </script>
<style> <style>
:root { :root {
--error: red; --error: red;
} }
.error { .error {
color: var(--error); color: var(--error);
} }
</style> </style>
<h3>U2F Security Key</h3> <h3>U2F Security Key</h3>
<h4>This Method is currently not supported. Please choose another one!</h4> <h4>This Method is currently not supported. Please choose another one!</h4>
<ToList {finish} /> <ToList {finish} />

View File

@ -4,7 +4,7 @@ import { getCookie } from "./cookie";
// const baseURL = "http://localhost:3000"; // const baseURL = "http://localhost:3000";
const baseURL = ""; const baseURL = "";
export default async function request(endpoint: string, parameters: { [key: string]: string } = {}, method: "GET" | "POST" | "DELETE" | "PUT" = "GET", body?: any, authInParam = false) { export default async function request(endpoint: string, parameters: { [key: string]: string } = {}, method: "GET" | "POST" | "DELETE" | "PUT" = "GET", body?: any, authInParam = false, redirect = false) {
let pairs = []; let pairs = [];
if (authInParam) { if (authInParam) {
@ -33,9 +33,9 @@ export default async function request(endpoint: string, parameters: { [key: stri
return e.json() return e.json()
}).then(data => { }).then(data => {
if (data.error) { if (data.error) {
if (data.additional && data.additional.auth) { if (redirect && data.additional && data.additional.auth) {
let state = btoa(window.location.pathname + window.location.hash); let state = btoa(window.location.pathname + window.location.hash);
// window.location.href = `/login?state=${state}&base64=true`; window.location.href = `/login?state=${state}&base64=true`;
} }
return Promise.reject(new Error(data.error)) return Promise.reject(new Error(data.error))
} }