Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Commit

Permalink
Merge pull request #188 from SkynetLabs/mysky-autologin-stored-settin…
Browse files Browse the repository at this point in the history
…gs-and-logout

Mysky autologin stored settings and logout
  • Loading branch information
mrcnski committed Feb 15, 2022
2 parents 3083442 + c951e5c commit ff8b549
Show file tree
Hide file tree
Showing 29 changed files with 1,063 additions and 321 deletions.
6 changes: 3 additions & 3 deletions html/seed-display.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ <h2 class="mt-6 text-center text-3xl font-extrabold text-gray-900">
<!-- Signup form -->
<div class="mt-8 sm:mx-auto sm:w-full sm:max-w-md">
<div class="bg-white py-8 px-4 shadow sm:rounded-lg sm:px-10">
<form class="space-y-6" action="#" onsubmit="window.signUp()">
<form class="space-y-6" action="#" onsubmit="window.signUp(event)">
<!-- Passphrase container -->
<div>
<!-- Passphrase label -->
Expand Down Expand Up @@ -231,7 +231,7 @@ <h2 class="mt-6 text-center text-3xl font-extrabold text-gray-900">
}

function showPassword() {
if (seedInput.type === "password") {
if (uiSigninPassphraseText.type === "password") {
uiSigninPassphraseText.type = "text";
uiShowSeedText.textContent = "Hide passphrase";
uiShowSeedOn.classList.add("hidden");
Expand All @@ -245,7 +245,7 @@ <h2 class="mt-6 text-center text-3xl font-extrabold text-gray-900">
}

function confirmStoredPassphrase() {
if (seedConfirm.checked) {
if (uiSeedConfirm.checked) {
uiSignupSubmit.removeAttribute("disabled")
} else {
uiSignupSubmit.setAttribute("disabled", "disabled")
Expand Down
4 changes: 3 additions & 1 deletion html/signin-connect.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ <h2 class="mt-6 text-center text-3xl font-extrabold text-gray-900">
<div class="relative flex justify-center text-sm">
<span class="px-2 bg-white">
<a href="#" class="text-primary inline-flex items-center" onclick="window.continue()">
<span class="ml-1">not now</span>
<span id="connect-not-now" class="ml-1">not now</span>
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="currentColor" class="bi bi-arrow-right-short" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M4 8a.5.5 0 0 1 .5-.5h5.793L8.146 5.354a.5.5 0 1 1 .708-.708l3 3a.5.5 0 0 1 0 .708l-3 3a.5.5 0 0 1-.708-.708L10.293 8.5H4.5A.5.5 0 0 1 4 8z"/>
</svg>
Expand All @@ -65,5 +65,7 @@ <h2 class="mt-6 text-center text-3xl font-extrabold text-gray-900">
</div>
</div>
</div>

<script async src="signin-connect.js"></script>
</body>
</html>
112 changes: 27 additions & 85 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,14 @@
"dependencies": {
"buffer": "^6.0.3",
"confusables": "^1.1.0",
"core-js": "^3.20.2",
"crypto-browserify": "^3.12.0",
"idb-keyval": "^6.1.0",
"mustache": "^4.2.0",
"post-me": "^0.4.5",
"punycode": "^2.1.1",
"randombytes": "^2.1.0",
"skynet-js": "^4.0.21-beta",
"skynet-js": "^4.0.22-beta",
"skynet-mysky-utils": "^0.3.0",
"stream-browserify": "^3.0.0",
"tweetnacl": "^1.0.3",
Expand Down
2 changes: 1 addition & 1 deletion scripts/permissions-display.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ let parentConnection: Connection | null = null;
// ======

window.onerror = function (error: any) {
console.log(error);
console.warn(error);
if (parentConnection) {
if (typeof error === "string") {
void parentConnection.remoteHandle().call("catchError", error);
Expand Down
2 changes: 1 addition & 1 deletion scripts/permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const methods = {
// ======

self.onerror = function (error: any) {
console.log(error);
console.warn(error);
if (parentConnection) {
if (typeof error === "string") {
void parentConnection.remoteHandle().call("catchError", error);
Expand Down
8 changes: 6 additions & 2 deletions scripts/seed-display.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ let parentConnection: Connection | null = null;
// ======

window.onerror = function (error: any) {
console.log(error);
console.warn(error);
if (parentConnection) {
if (typeof error === "string") {
void parentConnection.remoteHandle().call("catchError", error);
Expand Down Expand Up @@ -71,6 +71,7 @@ window.onload = async () => {
};

(window as any).signIn = (event: Event) => {
// Prevent making unnecessary request.
event.preventDefault();

const phraseValue = uiSigninPassphraseText.value;
Expand All @@ -86,7 +87,10 @@ window.onload = async () => {
handleResponse({ seed, email: null, action: "signin" });
};

(window as any).signUp = () => {
(window as any).signUp = (event: Event) => {
// Prevent making unnecessary request.
event.preventDefault();

if (uiSeedConfirm.checked === false) return;

const seed = phraseToSeed(uiSignupPassphraseText.value);
Expand Down
2 changes: 1 addition & 1 deletion scripts/seed-selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let parentConnection: Connection | null = null;
// ======

window.onerror = function (error: any) {
console.log(error);
console.warn(error);
if (parentConnection) {
if (typeof error === "string") {
void parentConnection.remoteHandle().call("catchError", error);
Expand Down
14 changes: 10 additions & 4 deletions scripts/signin-connect.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { ChildHandshake, Connection, WindowMessenger } from "post-me";

import { log } from "../src/util";

const uiConnectEmailText = <HTMLInputElement>document.getElementById("connect-email-text")!;

let readyEmail: string | null = null;
Expand All @@ -11,7 +13,7 @@ let parentConnection: Connection | null = null;
// ======

window.onerror = function (error: any) {
console.log(error);
console.warn(error);
if (parentConnection) {
if (typeof error === "string") {
void parentConnection.remoteHandle().call("catchError", error);
Expand All @@ -37,7 +39,7 @@ window.onload = async () => {
};

(window as any).continue = () => {
handleEmail(null);
handleEmail("");
};

// ==========
Expand All @@ -48,6 +50,8 @@ window.onload = async () => {
* Initialize the communication with the UI.
*/
async function init(): Promise<void> {
log("Entered init");

// Establish handshake with parent window.

const messenger = new WindowMessenger({
Expand All @@ -67,11 +71,13 @@ async function init(): Promise<void> {
* @returns - The email, if set.
*/
async function getEmail(): Promise<string | null> {
log("Entered getEmail");

const checkInterval = 100;

return new Promise((resolve) => {
const checkFunc = () => {
if (readyEmail) {
if (readyEmail !== null) {
resolve(readyEmail);
}
};
Expand All @@ -85,7 +91,7 @@ async function getEmail(): Promise<string | null> {
*
* @param email - The email.
*/
function handleEmail(email: string | null): void {
function handleEmail(email: string): void {
// Set `readyEmail`, triggering `getEmail`.
readyEmail = email;
}
Loading

0 comments on commit ff8b549

Please sign in to comment.