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
13
if (localStorage.getItem("did") && (await getAuth().then((x) => !!x[0])))
14
14
window.location.assign("/");
15
15
16
16
+
const authorize = async (handle: string) => {
17
17
+
const target = handle.startsWith("did:")
18
18
+
? (handle as `did:${string}:${string}`)
19
19
+
: handle.startsWith("https://")
20
20
+
? (handle as `https://${string}`)
21
21
+
: (handle as `${string}.${string}`);
22
22
+
23
23
+
const authUrl = await createAuthorizationUrl({
24
24
+
target: !handle.startsWith("https://")
25
25
+
? {
26
26
+
type: "account",
27
27
+
identifier: target as
28
28
+
| `did:${string}:${string}`
29
29
+
| `${string}.${string}`,
30
30
+
}
31
31
+
: {
32
32
+
type: "pds",
33
33
+
serviceUrl: target,
34
34
+
},
35
35
+
scope: metadata.scope,
36
36
+
}).catch((err) => {
37
37
+
alert(`Error: ${err}`);
38
38
+
console.error(err);
39
39
+
throw err;
40
40
+
});
41
41
+
42
42
+
window.location.assign(authUrl);
43
43
+
};
44
44
+
16
45
const submit = document.getElementById(
17
46
"submit",
18
47
) as HTMLButtonElement | null;
···
28
57
const handle = unameEl.value;
29
58
submit.disabled = true;
30
59
31
31
-
const authUrl = await createAuthorizationUrl({
32
32
-
target: {
33
33
-
type: "account",
34
34
-
identifier: handle as `${string}.${string}`,
35
35
-
},
36
36
-
scope: metadata.scope,
37
37
-
}).catch((err) => {
60
60
+
await authorize(handle).catch(() => {
38
61
submit.disabled = false;
39
39
-
alert(`Error: ${err}`);
40
40
-
console.error(err);
41
41
-
throw err;
42
62
});
63
63
+
});
43
64
44
44
-
await new Promise((res) => setTimeout(res, 200)); // let browser persist local storage
45
45
-
window.location.assign(authUrl);
46
46
-
});
65
65
+
const target = new URLSearchParams(window.location.search).get("target");
66
66
+
if (target) await authorize(target);
47
67
</script>
48
68
<style>
49
69
:global(html, body) {