From 6885fe7f0e56431b2f92aa6aa6771e1045e6d41b Mon Sep 17 00:00:00 2001 From: CatAClock Date: Tue, 22 Apr 2025 13:37:58 -0700 Subject: [PATCH] got the code --- HTML/mail.html | 2 ++ JS/ActivityPub.js | 2 ++ JS/mail.js | 16 ++++++++++++++++ 3 files changed, 20 insertions(+) create mode 100644 JS/mail.js diff --git a/HTML/mail.html b/HTML/mail.html index b96c089..dd5ad1b 100644 --- a/HTML/mail.html +++ b/HTML/mail.html @@ -4,6 +4,7 @@ The Fediverse + @@ -11,6 +12,7 @@

Mail

Just go back. It ain't ready yet...

+

Login

OK

diff --git a/JS/ActivityPub.js b/JS/ActivityPub.js index 26566bc..5efd8a1 100644 --- a/JS/ActivityPub.js +++ b/JS/ActivityPub.js @@ -1,3 +1,5 @@ +export const Scopes = "read write follow push"; + export async function GetPublicTimeline(Local = false, Remote = false) { let Timeline; if (Local == true && Remote == true) { diff --git a/JS/mail.js b/JS/mail.js new file mode 100644 index 0000000..2d30acf --- /dev/null +++ b/JS/mail.js @@ -0,0 +1,16 @@ +import * as ActivityPub from "./ActivityPub.js"; + +let LoginButton = document.getElementsByClassName("Login")[0]; + +LoginButton.onclick = (event) => { + HandleLogin(); +} + +async function HandleLogin() { + let Origin = window.location.origin + "/HTML/mail"; + let InstanceData = await fetch("https://wetdry.world/api/v1/apps?client_name=Channel Viewer&redirect_uris=" + Origin + "&scopes=" + ActivityPub.Scopes, {method: "POST"}) + .then((response) => response.json()); + let InstanceInfo = await fetch("https://wetdry.world/api/v1/instance", {method: "GET"}) + .then((response) => response.json()); + document.location.href = "https://wetdry.world/oauth/authorize?client_id=" + InstanceData.client_id + "&redirect_uri=" + Origin + "&response_type=code&scope=" + ActivityPub.Scopes; +}