standardizing key generation

This commit is contained in:
sairaj mote 2023-02-13 23:26:31 +05:30
parent db0b67e8a7
commit 7428f3bcf9
4 changed files with 96 additions and 81 deletions

View File

@ -740,46 +740,32 @@ ol li::before {
width: 100%;
}
#sign_in,
#sign_up {
#sign_in {
justify-items: center;
align-content: center;
padding: 1.5rem;
margin: 0;
}
#sign_in section,
#sign_up section {
#sign_in section {
margin-top: -8rem;
width: min(26rem, 100%);
}
#sign_in sm-form,
#sign_up sm-form {
#sign_in sm-form {
margin: 2rem 0;
}
#sign_up {
justify-items: center;
align-content: center;
}
#sign_up keys-generator {
width: min(26rem, 100%);
margin-top: -4rem;
}
#sign_up .h2 {
margin-bottom: 0.5rem;
}
.generated-keys-wrapper {
padding: 1rem;
background-color: rgba(var(--foreground-color), 1);
border-radius: 0.5rem;
}
#flo_id_warning {
padding-bottom: 1.5rem;
}
#flo_id_warning .icon {
height: 3rem;
width: 3rem;
padding: 0.8rem;
overflow: visible;
background-color: #ffc107;
border-radius: 3rem;
fill: rgba(0, 0, 0, 0.8);
}
.tip {
font-size: 0.9rem;
color: rgba(var(--text-color), 0.8);

2
css/main.min.css vendored

File diff suppressed because one or more lines are too long

View File

@ -762,8 +762,7 @@ ol {
width: 100%;
}
#sign_in,
#sign_up {
#sign_in {
justify-items: center;
align-content: center;
padding: 1.5rem;
@ -779,27 +778,16 @@ ol {
}
#sign_up {
justify-items: center;
align-content: center;
keys-generator {
width: min(26rem, 100%);
margin-top: -4rem;
}
.h2 {
margin-bottom: 0.5rem;
}
}
.generated-keys-wrapper {
padding: 1rem;
background-color: rgba(var(--foreground-color), 1);
border-radius: 0.5rem;
}
#flo_id_warning {
padding-bottom: 1.5rem;
.icon {
height: 3rem;
width: 3rem;
padding: 0.8rem;
overflow: visible;
background-color: #ffc107;
border-radius: 3rem;
fill: rgba(0, 0, 0, 0.8);
}
}
.tip {
font-size: 0.9rem;

View File

@ -182,37 +182,7 @@
</section>
</article>
<article id="sign_up" class="inner-page hidden">
<section class="grid gap-1-5">
<div id="flo_id_warning" class="flex gap-1">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px"
fill="#000000">
<path d="M0 0h24v24H0z" fill="none" />
<path d="M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z" />
</svg>
<div class="grid gap-0-5">
<strong>
<h3>
Keep your keys safe!
</h3>
</strong>
<p>Don't share with anyone. Once lost private key can't be
recovered.</p>
</div>
</div>
<div class="grid gap-1-5 generated-keys-wrapper">
<div class="grid gap-0-5">
<h5>FLO address</h5>
<sm-copy id="generated_flo_address"></sm-copy>
</div>
<div class="grid gap-0-5">
<h5>Private key</h5>
<sm-copy id="generated_private_key"></sm-copy>
</div>
</div>
<button id="sign_up_button" class="button button--primary w-100">Sign in with these credentials</button>
<p class="margin-top-1">You can use these FLO credentials with other RanchiMall apps
too. </p>
</section>
<keys-generator id="keys_generator"></keys-generator>
</article>
<div id="loading" class="inner-page hidden">
<svg class="page__loader" viewBox="0 0 512 512">
@ -1773,9 +1743,7 @@
}, 0);
break;
case 'sign_up':
const { floID, privKey } = floCrypto.generateNewID()
getRef('generated_flo_address').value = floID
getRef('generated_private_key').value = privKey
getRef('keys_generator').generateKeys()
break;
case 'chat_page':
if (subPageId1 && params.floId) {
@ -2304,8 +2272,8 @@
routeTo('loading');
};
getRef('sign_up_button').onclick = () => {
resolve(getRef('generated_private_key').value.trim());
getRef('generated_private_key').value = '';
resolve(getRef('keys_generator').keys.privKey);
getRef('keys_generator').clearKeys();
routeTo('loading');
};
}
@ -2332,6 +2300,79 @@
}
});
}
const generateKeys = document.createElement('template')
generateKeys.innerHTML = `
<style>
:host{
display: flex;
justify-content: center;
}
.generated-keys-wrapper {
padding: 1rem;
background-color: rgba(var(--foreground-color), 1);
border-radius: 0.5rem;
}
#flo_id_warning{
padding-bottom: 1.5rem;
}
#flo_id_warning .icon {
height: 3rem;
width: 3rem;
padding: 0.8rem;
overflow: visible;
background-color: #ffc107;
border-radius: 3rem;
fill: rgba(0, 0, 0, 0.8);
}
</style>
<section class="grid gap-1-5">
<div id="flo_id_warning" class="flex gap-1">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"> <path d="M0 0h24v24H0z" fill="none" /> <path d="M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z" /> </svg>
<div class="grid gap-0-5">
<strong>
<h3> Keep your keys safe! </h3>
</strong>
<p>Don't share with anyone. Once lost private key can't be recovered.</p>
</div>
</div>
<div class="grid gap-1-5 generated-keys-wrapper">
<div class="grid gap-0-5">
<h5>FLO address</h5>
<sm-copy id="generated_flo_address"></sm-copy>
</div>
<div class="grid gap-0-5">
<h5>Private key</h5>
<sm-copy id="generated_private_key"></sm-copy>
</div>
</div>
<button id="sign_up_button" class="button button--primary w-100">Sign in with these credentials</button>
<p class="margin-top-1">You can use these FLO credentials with other RanchiMall apps too. </p>
</section>
`
window.customElements.define('keys-generator', class extends HTMLElement {
constructor() {
super();
this.appendChild(generateKeys.content.cloneNode(true));
}
get keys() {
return {
floID: this.querySelector('#generated_flo_address').value,
privKey: this.querySelector('#generated_private_key').value
}
}
generateKeys() {
const { floID, privKey } = floCrypto.generateNewID()
this.querySelector('#generated_flo_address').value = floID
this.querySelector('#generated_private_key').value = privKey
}
clearKeys() {
this.querySelector('#generated_flo_address').value = ''
this.querySelector('#generated_private_key').value = ''
}
});
</script>
<script>