tangled
alpha
login
or
join now
tokono.ma
/
diffuse
5
fork
atom
A music player that connects to your cloud/distributed storage.
5
fork
atom
overview
issues
4
pulls
pipelines
fix: one more oauth attempt
Steven Vandevelde
3 weeks ago
2e7bec2e
c3e73283
+10
-17
2 changed files
expand all
collapse all
unified
split
src
components
output
raw
atproto
oauth.js
oauth
callback
index.js
+6
-9
src/components/output/raw/atproto/oauth.js
···
1
1
-
import QS from "query-string";
2
1
import { configureOAuth } from "@atcute/oauth-browser-client";
3
2
4
3
import metadata from "../../../../oauth-client-metadata.json" with {
···
44
43
const isLocalDev = redirect_uri.startsWith("http://127.0.0.1");
45
44
46
45
if (!isLocalDev) {
47
47
-
const url = new URL(location.href);
48
48
-
const params = Object.fromEntries(Array.from(url.searchParams.entries()));
49
49
-
50
50
-
redirect_uri = location.origin + "/oauth/callback?" + QS.stringify({
51
51
-
...params,
52
52
-
redirect_path: location.pathname,
53
53
-
variant: url.pathname.replace(/(^\/+|\/+$)/g, "").split("/")[0],
54
54
-
});
46
46
+
redirect_uri = location.origin + "/oauth/callback";
55
47
}
56
48
57
49
configureOAuth({
···
94
86
location.href.replace("http://localhost:", "http://127.0.0.1:"),
95
87
);
96
88
}
89
89
+
90
90
+
sessionStorage.setItem(
91
91
+
"diffuse/output/raw/atproto/oauth/redirect_path",
92
92
+
location.pathname + location.search,
93
93
+
);
97
94
98
95
const authUrl = await createAuthorizationUrl({
99
96
target: { type: "account", identifier: /** @type {any} */ (handle) },
+4
-8
src/oauth/callback/index.js
···
1
1
-
const url = new URL(document.location.href);
2
2
-
const redirect_path = url.searchParams.get("redirect_path") ?? "";
3
3
-
4
4
-
url.searchParams.delete("redirect_path");
5
5
-
url.searchParams.delete("variant");
1
1
+
const prefix = "diffuse/output/raw/atproto/oauth";
2
2
+
const redirect_path = sessionStorage.getItem(`${prefix}/redirect_path`) ?? "/";
6
3
7
7
-
location.assign(
8
8
-
`${redirect_path}?${url.searchParams.toString()}${url.hash}`,
9
9
-
);
4
4
+
sessionStorage.removeItem(`${prefix}/redirect_path`);
5
5
+
location.assign(`${redirect_path}${location.hash}`);