Repository navigation
Expand file tree
/
Copy pathbpauth.html
More file actions
39 lines (39 loc) · 1.47 KB
/
Copy pathbpauth.html
File metadata and controls
39 lines (39 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>BrowserPod sign in</title>
<style>
body { background: #404040; color: #f3f4f6; font-family: sans-serif; display: flex; align-items: center; justify-content: center; height: 100vh; margin: 0; }
</style>
</head>
<body>
<p id="message">Signing in...</p>
<script>
// Where the console sends the popup once GitHub is done. This page is
// same-origin with WebVM, which is the point: WebVM is cross-origin
// isolated, so the popup it opened has no window.opener to post to, and
// the key has to come home over a channel that is scoped to the origin
// rather than to the browsing context group.
const fragment = new URLSearchParams(location.hash.slice(1));
const sessionToken = fragment.get("sessionToken");
// The nonce of the request this answers, which WebVM checks before
// taking the key
const nonce = fragment.get("nonce");
// Drop the key from the URL before anything else, so it does not sit in
// this window's history entry.
history.replaceState(null, "", location.pathname);
const message = document.getElementById("message");
if(sessionToken)
{
new BroadcastChannel("browserpod-login").postMessage({ type: "AUTH_SUCCESS", sessionToken, nonce });
message.textContent = "Signed in. You can close this window.";
setTimeout(() => window.close(), 200);
}
else
{
message.textContent = "No session key was returned.";
}
</script>
</body>
</html>