tangled
alpha
login
or
join now
vielle.dev
/
dnd-astral-powers
0
fork
atom
this repo has no description
0
fork
atom
overview
issues
pulls
pipelines
support pds urls and ?target login
vielle.dev
1 month ago
d3d9a94f
cbc3962b
verified
This commit was signed with the committer's
known signature
.
vielle.dev
SSH Key Fingerprint:
SHA256:EoUuRRBFQKUfYh74C568g83i9g4fVi5OTtOENMSfa+0=
+33
-13
1 changed file
expand all
collapse all
unified
split
src
pages
atproto
login.astro
+33
-13
src/pages/atproto/login.astro
···
13
if (localStorage.getItem("did") && (await getAuth().then((x) => !!x[0])))
14
window.location.assign("/");
15
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
16
const submit = document.getElementById(
17
"submit",
18
) as HTMLButtonElement | null;
···
28
const handle = unameEl.value;
29
submit.disabled = true;
30
31
-
const authUrl = await createAuthorizationUrl({
32
-
target: {
33
-
type: "account",
34
-
identifier: handle as `${string}.${string}`,
35
-
},
36
-
scope: metadata.scope,
37
-
}).catch((err) => {
38
submit.disabled = false;
39
-
alert(`Error: ${err}`);
40
-
console.error(err);
41
-
throw err;
42
});
0
43
44
-
await new Promise((res) => setTimeout(res, 200)); // let browser persist local storage
45
-
window.location.assign(authUrl);
46
-
});
47
</script>
48
<style>
49
:global(html, body) {
···
13
if (localStorage.getItem("did") && (await getAuth().then((x) => !!x[0])))
14
window.location.assign("/");
15
16
+
const authorize = async (handle: string) => {
17
+
const target = handle.startsWith("did:")
18
+
? (handle as `did:${string}:${string}`)
19
+
: handle.startsWith("https://")
20
+
? (handle as `https://${string}`)
21
+
: (handle as `${string}.${string}`);
22
+
23
+
const authUrl = await createAuthorizationUrl({
24
+
target: !handle.startsWith("https://")
25
+
? {
26
+
type: "account",
27
+
identifier: target as
28
+
| `did:${string}:${string}`
29
+
| `${string}.${string}`,
30
+
}
31
+
: {
32
+
type: "pds",
33
+
serviceUrl: target,
34
+
},
35
+
scope: metadata.scope,
36
+
}).catch((err) => {
37
+
alert(`Error: ${err}`);
38
+
console.error(err);
39
+
throw err;
40
+
});
41
+
42
+
window.location.assign(authUrl);
43
+
};
44
+
45
const submit = document.getElementById(
46
"submit",
47
) as HTMLButtonElement | null;
···
57
const handle = unameEl.value;
58
submit.disabled = true;
59
60
+
await authorize(handle).catch(() => {
0
0
0
0
0
0
61
submit.disabled = false;
0
0
0
62
});
63
+
});
64
65
+
const target = new URLSearchParams(window.location.search).get("target");
66
+
if (target) await authorize(target);
0
67
</script>
68
<style>
69
:global(html, body) {