diff --git a/apps/web/src/connectors/utils/callbackUri.ts b/apps/web/src/connectors/utils/callbackUri.ts index f3d4e9931a0..ca487c6573d 100644 --- a/apps/web/src/connectors/utils/callbackUri.ts +++ b/apps/web/src/connectors/utils/callbackUri.ts @@ -1,13 +1,21 @@ +declare const __PM_6962_NATIVE_MOBILE_APPS_CLIENT_UPDATES__: boolean; const SELF_HOSTED = (process.env.SELF_HOSTED || "false").toLowerCase() === "true"; function appLinkHost(): string { const h = window.location.hostname || ""; - if (h.endsWith("bitwarden.eu")) {return "bitwarden.eu";} - if (h.endsWith("bitwarden.pw")) {return "bitwarden.pw";} + if (h.endsWith("bitwarden.eu")) { + return "bitwarden.eu"; + } + if (h.endsWith("bitwarden.pw")) { + return "bitwarden.pw"; + } return "bitwarden.com"; } export function buildMobileCallbackUri(kind: "sso" | "duo" | "webauthn"): string { const path = `${kind}-callback`; - return SELF_HOSTED ? `bitwarden://${path}` : `https://${appLinkHost()}/${path}`; + if (!SELF_HOSTED && __PM_6962_NATIVE_MOBILE_APPS_CLIENT_UPDATES__) { + return `https://${appLinkHost()}/${path}`; + } + return `bitwarden://${path}`; } diff --git a/apps/web/webpack.base.js b/apps/web/webpack.base.js index c2554603c9c..b93d5ef88ae 100644 --- a/apps/web/webpack.base.js +++ b/apps/web/webpack.base.js @@ -224,6 +224,15 @@ module.exports.buildConfig = function buildConfig(params) { DEV_FLAGS: NODE_ENV === "development" ? envConfig["devFlags"] : {}, ADDITIONAL_REGIONS: envConfig["additionalRegions"] ?? [], }), + // compile‑time constant for so that at compile time logic branches can be pruned that aren't + // possible. + new webpack.DefinePlugin({ + __PM_6962_NATIVE_MOBILE_APPS_CLIENT_UPDATES__: JSON.stringify( + (process.env.PM_6962_NATIVE_MOBILE_APPS_CLIENT_UPDATES + ? process.env.PM_6962_NATIVE_MOBILE_APPS_CLIENT_UPDATES.toLowerCase() === "true" + : ENV !== "selfhosted") === true, + ), + }), new AngularWebpackPlugin({ tsconfig: params.tsConfig, entryModule: params.app.entryModule,