Last active
December 16, 2023 05:58
-
-
Save vdhanan/411cb1ded583b1c00e1a98a3528427e5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/webpack/shared.cjs b/lib/webpack/shared.cjs | |
index f31e32f8f..3b77cf051 100644 | |
--- a/lib/webpack/shared.cjs | |
+++ b/lib/webpack/shared.cjs | |
@@ -98,19 +98,23 @@ function createBaseBrowserConfig(baseConfig) { | |
} | |
async function getConfigs() { | |
- const [alchemySecret, walletConnectSecret] = await Promise.all([ | |
- getConfig({ folder: 'secrets', name: 'alchemy' }), | |
- getConfig({ folder: 'secrets', name: 'walletconnect' }), | |
- ]); | |
+ const [alchemySecret, walletConnectSecret, identityServiceConfig] = | |
+ await Promise.all([ | |
+ getConfig({ folder: 'secrets', name: 'alchemy' }), | |
+ getConfig({ folder: 'secrets', name: 'walletconnect' }), | |
+ getConfig({ folder: 'secrets', name: 'identity_service_config' }), | |
+ ]); | |
const alchemyKey = alchemySecret?.key; | |
const walletConnectKey = walletConnectSecret?.key; | |
- return { alchemyKey, walletConnectKey }; | |
+ const identitySocketAddr = identityServiceConfig?.identitySocketAddr; | |
+ return { alchemyKey, walletConnectKey, identitySocketAddr }; | |
} | |
-async function createProdBrowserConfig(baseConfig, babelConfig, envVars) { | |
+async function createProdBrowserConfig(baseConfig, babelConfig) { | |
const browserConfig = createBaseBrowserConfig(baseConfig); | |
const babelRule = getBrowserBabelRule(babelConfig); | |
- const { alchemyKey, walletConnectKey } = await getConfigs(); | |
+ const { alchemyKey, walletConnectKey, identitySocketAddr } = | |
+ await getConfigs(); | |
return { | |
...browserConfig, | |
mode: 'production', | |
@@ -122,7 +126,7 @@ async function createProdBrowserConfig(baseConfig, babelConfig, envVars) { | |
BROWSER: true, | |
COMM_ALCHEMY_KEY: JSON.stringify(alchemyKey), | |
COMM_WALLETCONNECT_KEY: JSON.stringify(walletConnectKey), | |
- ...envVars, | |
+ IDENTITY_SOCKET_ADDR: JSON.stringify(identitySocketAddr), | |
}, | |
}), | |
new MiniCssExtractPlugin({ | |
@@ -176,10 +180,11 @@ async function createProdBrowserConfig(baseConfig, babelConfig, envVars) { | |
}; | |
} | |
-async function createDevBrowserConfig(baseConfig, babelConfig, envVars) { | |
+async function createDevBrowserConfig(baseConfig, babelConfig) { | |
const browserConfig = createBaseBrowserConfig(baseConfig); | |
const babelRule = getBrowserBabelRule(babelConfig); | |
- const { alchemyKey, walletConnectKey } = await getConfigs(); | |
+ const { alchemyKey, walletConnectKey, identitySocketAddr } = | |
+ await getConfigs(); | |
return { | |
...browserConfig, | |
mode: 'development', | |
@@ -191,7 +196,7 @@ async function createDevBrowserConfig(baseConfig, babelConfig, envVars) { | |
BROWSER: true, | |
COMM_ALCHEMY_KEY: JSON.stringify(alchemyKey), | |
COMM_WALLETCONNECT_KEY: JSON.stringify(walletConnectKey), | |
- ...envVars, | |
+ IDENTITY_SOCKET_ADDR: JSON.stringify(identitySocketAddr), | |
}, | |
}), | |
new ReactRefreshWebpackPlugin(), | |
diff --git a/web/grpc/identity-service-client-wrapper.js b/web/grpc/identity-service-client-wrapper.js | |
index e6b81cb0b..9bb44589a 100644 | |
--- a/web/grpc/identity-service-client-wrapper.js | |
+++ b/web/grpc/identity-service-client-wrapper.js | |
@@ -1,7 +1,5 @@ | |
// @flow | |
-import invariant from 'invariant'; | |
- | |
import identityServiceConfig from 'lib/facts/identity-service.js'; | |
import type { IdentityServiceAuthLayer } from 'lib/types/identity-service-types.js'; | |
@@ -20,18 +18,7 @@ class IdentityServiceClientWrapper { | |
} | |
determineSocketAddr(): string { | |
- let identitySocketAddr; | |
- const identityServiceConfigRaw = process.env.IDENTITY_SERVICE_CONFIG; | |
- | |
- if (identityServiceConfigRaw !== null) { | |
- invariant( | |
- typeof identityServiceConfigRaw === 'object', | |
- 'identityServiceConfigRaw should be an object', | |
- ); | |
- identitySocketAddr = identityServiceConfigRaw.identitySocketAddr; | |
- } | |
- | |
- return identitySocketAddr || identityServiceConfig.defaultURL; | |
+ return process.env.IDENTITY_SOCKET_ADDR ?? identityServiceConfig.defaultURL; | |
} | |
async initAuthClient(authLayer: IdentityServiceAuthLayer): Promise<void> { | |
diff --git a/web/root.js b/web/root.js | |
index 56e7b49af..1f23199ca 100644 | |
--- a/web/root.js | |
+++ b/web/root.js | |
@@ -11,6 +11,7 @@ import thunk from 'redux-thunk'; | |
import IntegrityHandler from 'lib/components/integrity-handler.react.js'; | |
import KeyserverConnectionsHandler from 'lib/components/keyserver-connections-handler.js'; | |
+import identityServiceConfig from 'lib/facts/identity-service.js'; | |
import { reduxLoggerMiddleware } from 'lib/utils/action-logger.js'; | |
import { | |
@@ -28,6 +29,12 @@ import { type AppState, type Action, reducer } from './redux/redux-setup.js'; | |
import history from './router-history.js'; | |
import Socket from './socket.react.js'; | |
+console.log( | |
+ `ashoat ${ | |
+ process.env.IDENTITY_SOCKET_ADDR ?? identityServiceConfig.defaultURL | |
+ }`, | |
+); | |
+ | |
localforage.config(localforageConfig); | |
const persistedReducer = persistReducer(persistConfig, reducer); | |
diff --git a/web/webpack.config.cjs b/web/webpack.config.cjs | |
index 2c57435b8..38d0a5588 100644 | |
--- a/web/webpack.config.cjs | |
+++ b/web/webpack.config.cjs | |
@@ -11,14 +11,6 @@ const { | |
const babelConfig = require('./babel.config.cjs'); | |
-async function getConfig(configName) { | |
- const { getCommConfig } = await import( | |
- // eslint-disable-next-line monorepo/no-relative-import | |
- '../keyserver/dist/lib/utils/comm-config.js' | |
- ); | |
- return await getCommConfig(configName); | |
-} | |
- | |
const baseBrowserConfig = { | |
entry: { | |
browser: ['./script.js'], | |
@@ -188,16 +180,9 @@ const prodWebWorkersPlugins = [ | |
]; | |
module.exports = async function (env) { | |
- const identityServiceConfig = await getConfig({ | |
- folder: 'secrets', | |
- name: 'identity_service_config', | |
- }); | |
- const envVars = { | |
- IDENTITY_SERVICE_CONFIG: JSON.stringify(identityServiceConfig), | |
- }; | |
const browserConfigPromise = env.prod | |
- ? createProdBrowserConfig(baseProdBrowserConfig, babelConfig, envVars) | |
- : createDevBrowserConfig(baseDevBrowserConfig, babelConfig, envVars); | |
+ ? createProdBrowserConfig(baseProdBrowserConfig, babelConfig) | |
+ : createDevBrowserConfig(baseDevBrowserConfig, babelConfig); | |
const nodeConfigPromise = createNodeServerRenderingConfig( | |
baseNodeServerRenderingConfig, | |
babelConfig, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment