From 651d0f24c76a7c61b63155acf8a24119a59ad9cd Mon Sep 17 00:00:00 2001 From: pennae Date: Sun, 7 Aug 2022 01:47:07 +0200 Subject: fenix login is actually a lot simpler but it *must* be done over https with trusted certificates --- README.md | 11 ++++++++--- web/index.html | 56 +------------------------------------------------------- web/js/main.js | 48 ++++++++++++------------------------------------ 3 files changed, 21 insertions(+), 94 deletions(-) diff --git a/README.md b/README.md index 5279994..040f7a0 100644 --- a/README.md +++ b/README.md @@ -58,9 +58,14 @@ changes to take effect, then create an account or log in as usual. # configuring firefox android -this is a sufficiently involved process that the web interface has a -dedicated guide. just open the url of your server in firefox on android -and follow the guide. ("just". we're so sorry.) +go to the settings menu, from there to the About page, tap the logo a lot until +the debug menu is enabled. go back to the settings menu, scroll all the way to +the top, enter your minor-skulk url as the custom account server. once +configured thusly firefox will exit. restart it, select "sign in to sync", and +use the email option. (QR code pairing is not yet implemented) + +**NOTE**: the account server *must* run over https and with a certificate +firefox trusts, or logins will not function. # license diff --git a/web/index.html b/web/index.html index d3291f0..f7e8fe1 100644 --- a/web/index.html +++ b/web/index.html @@ -108,13 +108,6 @@ } - - - - diff --git a/web/js/main.js b/web/js/main.js index 3c1f23a..27d3a1a 100644 --- a/web/js/main.js +++ b/web/js/main.js @@ -13,7 +13,7 @@ class Channel { window.addEventListener( 'WebChannelMessageToContent', ev => { - if (ev.detail.message.error) { + if (ev.detail && ev.detail.message.error) { for (const wait in this.waiting) { this.waiting[wait].reject(new Error(ev.detail.message.error)); } @@ -80,6 +80,15 @@ class Channel { }); } + loadOauthCredentials(code, state) { + this._send('account_updates', 'fxaccounts:oauth_login', { + code, + state, + redirect: "urn:ietf:wg:oauth:2.0:oob:oauth-redirect-webchannel", + action: "signin" + }); + } + passwordChanged(email, uid) { this._send('account_updates', 'fxaccounts:change_password', { email, @@ -717,21 +726,6 @@ customElements.define('do-generate-invite', GenerateInvite); ////////////////////////////////////////// class FenixSignin extends HTMLElement { - constructor(session) { - super(); - const shadow = this.attachShadow({mode: 'open'}); - shadow.replaceChildren( - $("styles").cloneNode(true), - $("tpl-fenix-signin-warning").content.cloneNode(true)); - shadow.querySelector("#signin").onclick = wrapHandler(async ev => { - ev.preventDefault(); - switchTo(new FenixSigninEnter()); - }); - } -} -customElements.define('do-fenix-signin', FenixSignin); - -class FenixSigninEnter extends HTMLElement { constructor(session) { super(); const shadow = this.attachShadow({mode: 'open'}); @@ -787,21 +781,7 @@ class FenixSigninEnter extends HTMLElement { code_challenge: param("code_challenge"), }); - console.log(`browser.tabs.executeScript({code: \` - port = browser.runtime.connectNative("mozacWebchannel"); - port.postMessage({ - id: "account_updates", - message: { - command: "fxaccounts:oauth_login", - data: { - "code": "${code.code}", - "state": "${code.state}", - "redirect": "urn:ietf:wg:oauth:2.0:oob:oauth-redirect-webchannel", - "action": "signin" - }, - messageId: 1, - }}); - \`});`); + channel.loadOauthCredentials(code.code, code.state); switchTo(new FenixSignin()); } finally { @@ -809,7 +789,7 @@ class FenixSigninEnter extends HTMLElement { } } } -customElements.define('do-fenix-signin-enter', FenixSigninEnter); +customElements.define('do-fenix-signin', FenixSignin); ////////////////////////////////////////// // initialization @@ -822,10 +802,6 @@ const isAndroid = /Android/.test(navigator.userAgent); document.body.onload = async () => { showMessage("Loading ...", "animate"); - if (isAndroid) { - document.head.appendChild($("tpl-fenix-style").content); - } - try { let resp = await fetch("/.well-known/fxa-client-configuration"); if (!resp.ok) throw new Error(resp.statusText); -- cgit v1.2.3