···11<!doctype html>
22+<meta charset="utf-8" />
33+<title>great job!</title>
2433-<p>oh sick. hey {{ did }}. you can close this window now.</p>
55+<h1>oauth success!</h1>
66+<p>this window should automatically close itself (probably a bug if it hasn't)</p>
4758<script>
69// TODO: tie this back to its source...........
···1114 token: {{{json token}}},
1215 fetch_key: {{{json fetch_key}}},
1316}));
1717+// TODO: probably also wait for a reply from the frame and show an error if not
1418window.close();
1519</script>
+45-4
who-am-i/templates/hello.hbs
···44<div class="mini-content">
55 <div class="explain">
66 <p>This is a little identity-verifying service for microcosm demos.</p>
77+ <p>Only <strong>read access to your public data</strong> is required to connect: connecting does not grant any ability to modify your account or data.</p>
78 </div>
89910 {{#if did}}
···5051 } catch (e) {
5152 err(e, 'failed to clear session, sorry');
5253 }
5353- window.location.reload();
5454+ window.location.replace(location.pathname);
5555+ window.location.reload(); // backup, in case there is no query?
5456 });
5557 })();
5658···7173 }
7274 </script>
7375 {{else}}
7474- <p id="prompt" class="detail no">
7575- No identity connected.
7676- </p>
7676+7777+ <p class="hello-connect-plz">Connect your handle</p>
7878+7979+ {{#if is_auth_reload}}
8080+ {{#if no_cookie}}
8181+ <p id="prompt" class="detail no">
8282+ No identity connected. Your browser may be blocking access for connecting.
8383+ </p>
8484+ {{else}}
8585+ {{#if auth_failed}}
8686+ <p id="prompt" class="detail no">
8787+ No identity connected. Connecting failed or was denied.
8888+ </p>
8989+ {{else}}
9090+ <p id="prompt" class="detail no">
9191+ No identity connected.
9292+ </p>
9393+ {{/if}}
9494+ {{/if}}
9595+ {{/if}}
9696+9797+ <div id="user-info">
9898+ <form id="form-action" action="/auth" target="_blank" method="GET" class="action {{#if did}}hidden{{/if}}">
9999+ <label>
100100+ @<input id="handle-input" class="handle" name="handle" placeholder="example.bsky.social" />
101101+ </label>
102102+ <button id="connect" type="submit">connect</button>
103103+ </form>
104104+ </div>
77105 {{/if}}
106106+78107</div>
108108+<script>
109109+window.addEventListener('storage', e => {
110110+ console.log('eyyy got storage', e);
111111+ if (e.key !== 'who-am-i') return;
112112+ if (!e.newValue) return;
113113+ if (e.newValue.result === 'success') {
114114+ window.location = '/?auth_reload=1';
115115+ } else {
116116+ window.location = '/?auth_reload=1&auth_failed=1';
117117+ }
118118+});
119119+</script>
79120{{/inline}}
8012181122{{#> base-full}}{{/base-full}}
+18-1
who-am-i/templates/prompt.hbs
···2727 </div>
2828</div>
29293030+<div id="need-storage" class="hidden">
3131+ <p class="problem">Sorry, your browser is blocking access.</p>
3232+ <p>Try <a href="/" target="_blank">connecting directly</a> first (but no promises).</p>
3333+</div>
3434+303531363237<script>
···3944const formEl = document.getElementById('form-action'); // for anon
4045const allowEl = document.getElementById('handle-action'); // for known-did
4146const connectEl = document.getElementById('connect'); // for anon
4747+const needStorageEl = document.getElementById('need-storage'); // for safari/frame isolation
42484349function err(e, msg) {
4450 loaderEl.classList.add('hidden');
···6672 window.open(url, '_blank');
6773};
68747575+// check if we may be partitioned, preventing access after auth completion
7676+// this should only happen if on a browser that implements storage access api
7777+if ('hasStorageAccess' in document) {
7878+ document.hasStorageAccess().then((hasAccess) => {
7979+ if (!hasAccess) {
8080+ promptEl.classList.add('hidden');
8181+ infoEl.classList.add('hidden');
8282+ needStorageEl.classList.remove('hidden');
8383+ }
8484+ });
8585+}
8686+6987window.addEventListener('storage', async e => {
7088 // here's a fun minor vuln: we can't tell which flow triggers the storage event.
7189 // so if you have two flows going, it grants for both (or the first responder?) if you grant for either.
···7997 console.error("hmm, heard from localstorage but did not get DID", details, e);
8098 err('sorry, something went wrong getting your details');
8199 }
8282- localStorage.removeItem(e.key);
8310084101 let parsed;
85102 try {