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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fedipod-bb",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "FediPod-BB: a forum website whose record lives on a Solid pod.",
5
5
  "license": "MIT",
6
6
  "author": "Jeff Zucker",
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.origin + location.pathname + location.search });
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 }) {