fedipod-bb 0.4.2 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/site/bb.js +2 -2
- package/site/masto.mjs +9 -0
package/package.json
CHANGED
package/site/bb.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// #/ #/c/<slug> #/t/<slug>/<tid>
|
|
12
12
|
|
|
13
13
|
import { reader, placeOf, authorLabel, cacheKey, categoryBase, cleanHtml } from './read.mjs';
|
|
14
|
-
import { MastoLogin, hostOfHandle, serverKind, actorOfHandle } from './masto.mjs';
|
|
14
|
+
import { MastoLogin, hostOfHandle, serverKind, actorOfHandle, returnAddress } from './masto.mjs';
|
|
15
15
|
import * as pod from './pod.mjs';
|
|
16
16
|
import { mine as keptByReader } from './mine.mjs';
|
|
17
17
|
import { readState } from './seen.mjs';
|
|
@@ -47,7 +47,7 @@ let freshRead = false;
|
|
|
47
47
|
const readerFetch = (url, init = {}) => fetch(url, freshRead ? { ...init, cache: 'reload' } : init);
|
|
48
48
|
const makeReader = (session = null) => reader({ session, fetch: readerFetch });
|
|
49
49
|
let read = makeReader();
|
|
50
|
-
const login = new MastoLogin({ storage: localStorage, redirectUri: location.
|
|
50
|
+
const login = new MastoLogin({ storage: localStorage, redirectUri: returnAddress(location.href) });
|
|
51
51
|
// What this reader has already read. Theirs, in their own browser: a public
|
|
52
52
|
// forum has nowhere to keep it and no business keeping it.
|
|
53
53
|
const seen = base ? readState({ storage: localStorage, forum: base }) : null;
|
package/site/masto.mjs
CHANGED
|
@@ -54,6 +54,15 @@ export async function serverKind(host, front, f = globalThis.fetch.bind(globalTh
|
|
|
54
54
|
} catch { return { kind: 'unknown', host }; }
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
// Where Mastodon sends the reader back: this page, without the sign-in's own
|
|
58
|
+
// code and state. Mastodon hands out the key only for the address it approved,
|
|
59
|
+
// and the page comes back with those two added, so both legs name it this way.
|
|
60
|
+
export function returnAddress(href) {
|
|
61
|
+
const u = new URL(href);
|
|
62
|
+
for (const k of ['code', 'state', 'iss']) u.searchParams.delete(k);
|
|
63
|
+
return u.origin + u.pathname + u.search;
|
|
64
|
+
}
|
|
65
|
+
|
|
57
66
|
export class MastoLogin {
|
|
58
67
|
// `storage` is localStorage-shaped; `fetch` is the page's.
|
|
59
68
|
constructor({ fetch: f = globalThis.fetch.bind(globalThis), storage, redirectUri }) {
|