diff --git a/keyserver/src/responders/website-responders.js b/keyserver/src/responders/website-responders.js --- a/keyserver/src/responders/website-responders.js +++ b/keyserver/src/responders/website-responders.js @@ -100,6 +100,23 @@ } } +let pushApiPublicKey: ?string = null; +async function getPushApiPublicKey() { + if (pushApiPublicKey) { + return pushApiPublicKey; + } + + try { + const keysString = await readFile('secrets/web_push_config.json', 'utf8'); + const keys = JSON.parse(keysString); + pushApiPublicKey = keys.publicKey; + } catch { + return null; + } + + return pushApiPublicKey; +} + let webpackCompiledRootComponent: ?React.ComponentType<{}> = null; async function getWebpackCompiledRootComponentForSSR() { if (webpackCompiledRootComponent) { @@ -301,6 +318,8 @@ return hasNotAcknowledgedPolicies ? 0 : initialTime; })(); + const pushApiPublicKeyPromise = getPushApiPublicKey(); + const { jsURL, fontsURL, cssInclude } = await assetInfoPromise; // prettier-ignore @@ -386,6 +405,7 @@ windowActive: true, userPolicies: {}, primaryIdentityPublicKey: null, + pushApiPublicKey: pushApiPublicKeyPromise, _persist: null, }); const jsonStream = streamJSON(res, initialReduxState); diff --git a/lib/types/redux-types.js b/lib/types/redux-types.js --- a/lib/types/redux-types.js +++ b/lib/types/redux-types.js @@ -121,6 +121,7 @@ deviceToken?: void, cookie?: void, primaryIdentityPublicKey: ?string, + pushApiPublicKey: ?string, ... }; export type AppState = NativeAppState | WebAppState; diff --git a/web/redux/redux-setup.js b/web/redux/redux-setup.js --- a/web/redux/redux-setup.js +++ b/web/redux/redux-setup.js @@ -72,6 +72,7 @@ windowActive: boolean, userPolicies: UserPolicies, primaryIdentityPublicKey: ?string, + pushApiPublicKey: ?string, _persist: ?PersistState, };