Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3500514
D5977.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D5977.diff
View Options
diff --git a/keyserver/src/responders/landing-handler.js b/keyserver/src/responders/landing-handler.js
--- a/keyserver/src/responders/landing-handler.js
+++ b/keyserver/src/responders/landing-handler.js
@@ -103,6 +103,7 @@
const { renderToNodeStream } = ReactDOMServer;
async function landingResponder(req: $Request, res: $Response) {
+ const siweNonce = req.header('siwe-nonce');
const [{ jsURL, fontURLs, cssInclude }, LandingSSR] = await Promise.all([
getAssetInfo(),
getWebpackCompiledRootComponentForSSR(),
@@ -159,14 +160,20 @@
const routerBasename = basePath.replace(/\/$/, '');
const clientPath = routerBasename + req.url;
const reactStream = renderToNodeStream(
- <LandingSSR url={clientPath} basename={routerBasename} />,
+ <LandingSSR
+ url={clientPath}
+ basename={routerBasename}
+ siweNonce={siweNonce}
+ />,
);
reactStream.pipe(res, { end: false });
await waitForStream(reactStream);
+ const siweNonceString = siweNonce ? `"${siweNonce}"` : 'null';
// prettier-ignore
res.end(html`</div>
<script>var routerBasename = "${routerBasename}";</script>
+ <script>var siweNonce = ${siweNonceString};</script>
<script src="${jsURL}"></script>
</body>
</html>
diff --git a/landing/landing-ssr.react.js b/landing/landing-ssr.react.js
--- a/landing/landing-ssr.react.js
+++ b/landing/landing-ssr.react.js
@@ -4,17 +4,28 @@
import { StaticRouter } from 'react-router';
import Landing from './landing.react';
+import { SIWENonceContext } from './siwe-nonce-context';
export type LandingSSRProps = {
+url: string,
+basename: string,
+ +siweNonce: ?string,
};
function LandingSSR(props: LandingSSRProps): React.Node {
- const { url, basename } = props;
+ const { url, basename, siweNonce } = props;
+
+ const siweNonceContextValue = React.useMemo(
+ () => ({
+ siweNonce,
+ }),
+ [siweNonce],
+ );
const routerContext = React.useMemo(() => ({}), []);
return (
<StaticRouter location={url} basename={basename} context={routerContext}>
- <Landing />
+ <SIWENonceContext.Provider value={siweNonceContextValue}>
+ <Landing />
+ </SIWENonceContext.Provider>
</StaticRouter>
);
}
diff --git a/landing/root.js b/landing/root.js
--- a/landing/root.js
+++ b/landing/root.js
@@ -4,13 +4,23 @@
import { BrowserRouter } from 'react-router-dom';
import Landing from './landing.react';
+import { SIWENonceContext } from './siwe-nonce-context.js';
declare var routerBasename: string;
+declare var siweNonce: ?string;
function RootComponent(): React.Node {
+ const siweNonceContextValue = React.useMemo(
+ () => ({
+ siweNonce,
+ }),
+ [],
+ );
return (
<BrowserRouter basename={routerBasename}>
- <Landing />
+ <SIWENonceContext.Provider value={siweNonceContextValue}>
+ <Landing />
+ </SIWENonceContext.Provider>
</BrowserRouter>
);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 21, 1:52 AM (17 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2684543
Default Alt Text
D5977.diff (2 KB)
Attached To
Mode
D5977: [keyserver] Capture `siwe-nonce` header and make available to `SIWE` component
Attached
Detach File
Event Timeline
Log In to Comment