diff --git a/.changeset/honest-plants-heal.md b/.changeset/honest-plants-heal.md new file mode 100644 index 0000000000000..ae8ba7e943fa0 --- /dev/null +++ b/.changeset/honest-plants-heal.md @@ -0,0 +1,5 @@ +--- +'@rocket.chat/meteor': patch +--- + +Remove oauthRedirectUri override (dead code after Meteor OAuth stack removal) diff --git a/.changeset/tame-falcons-watch.md b/.changeset/tame-falcons-watch.md new file mode 100644 index 0000000000000..99f0629fb4fb9 --- /dev/null +++ b/.changeset/tame-falcons-watch.md @@ -0,0 +1,5 @@ +--- +'@rocket.chat/meteor': patch +--- + +Remove useCorsSSLConfig hook and absoluteUrl startup patch (dead code after Meteor DDP removal) diff --git a/apps/meteor/client/meteor/overrides/index.ts b/apps/meteor/client/meteor/overrides/index.ts index f3370db0592f5..941901d8964bf 100644 --- a/apps/meteor/client/meteor/overrides/index.ts +++ b/apps/meteor/client/meteor/overrides/index.ts @@ -1,6 +1,5 @@ import './ddpOverREST'; import './desktopInjection'; -import './oauthRedirectUri'; import './settings'; import './totpOnCall'; import './unstoreLoginToken'; diff --git a/apps/meteor/client/meteor/overrides/oauthRedirectUri.ts b/apps/meteor/client/meteor/overrides/oauthRedirectUri.ts deleted file mode 100644 index c9900ff69a417..0000000000000 --- a/apps/meteor/client/meteor/overrides/oauthRedirectUri.ts +++ /dev/null @@ -1,30 +0,0 @@ -// TODO: remove this override together with the Meteor auth/DDP layer — it -// monkey-patches meteor/oauth for backwards compatibility with pre-2.3 -// clients. Once Meteor's OAuth stack is gone, this file goes with it. -import { OAuth } from 'meteor/oauth'; - -declare module 'meteor/oauth' { - // eslint-disable-next-line @typescript-eslint/no-namespace - namespace OAuth { - function _redirectUri(serviceName: string, config: any, params: any, absoluteUrlOptions: any): string; - } -} - -const { _redirectUri } = OAuth; - -OAuth._redirectUri = (serviceName: string, config: any, params: unknown, absoluteUrlOptions: unknown): string => { - const ret = _redirectUri(serviceName, config, params, absoluteUrlOptions); - - // DEPRECATED: Remove in v5.0.0 - // Meteor 2.3 removed ?close from redirect uri so we need to add it back to not break old oauth clients - // https://github.com/meteor/meteor/commit/b5b7306bedc3e8eb241e64efb1e281925aa75dd3#diff-59244f4e0176cb1beed2e287924e97dc7ae2c0cc51494ce121a85d8937d116a5L11 - if (!config?.loginStyle && !ret.includes('close')) { - console.warn( - `Automatically added ?close to 'redirect_uri' for ${serviceName}, this behavior will be removed in v5.0.0.\n` + - "Please update your OAuth config to accept both with and without ?close as the 'redirect_uri'.", - ); - return `${ret + (ret.includes('?') ? '&' : '?')}close`; - } - - return ret; -}; diff --git a/apps/meteor/client/meteor/startup/absoluteUrl.ts b/apps/meteor/client/meteor/startup/absoluteUrl.ts deleted file mode 100644 index a1fe3938e06f7..0000000000000 --- a/apps/meteor/client/meteor/startup/absoluteUrl.ts +++ /dev/null @@ -1,11 +0,0 @@ -// TODO: remove this file together with the Meteor webapp/DDP layer — it only -// exists to patch Meteor.absoluteUrl's rootUrl, which no longer has a caller -// once DDP is gone. -import { Meteor } from 'meteor/meteor'; - -import { _relativeToSiteRootUrl, absoluteUrl } from '../../lib/absoluteUrl'; - -Object.assign(Meteor, { - absoluteUrl, - _relativeToSiteRootUrl, -}); diff --git a/apps/meteor/client/meteor/startup/index.ts b/apps/meteor/client/meteor/startup/index.ts index 286913b22c6a4..7e86a46fb0578 100644 --- a/apps/meteor/client/meteor/startup/index.ts +++ b/apps/meteor/client/meteor/startup/index.ts @@ -1,2 +1 @@ -import './absoluteUrl'; import './accounts'; diff --git a/apps/meteor/client/views/root/AppLayout.tsx b/apps/meteor/client/views/root/AppLayout.tsx index b355d9c7b44f2..af47bd1df7de5 100644 --- a/apps/meteor/client/views/root/AppLayout.tsx +++ b/apps/meteor/client/views/root/AppLayout.tsx @@ -15,7 +15,6 @@ import { useAnalytics } from './hooks/useAnalytics'; import { useAnalyticsEventTracking } from './hooks/useAnalyticsEventTracking'; import { useAutoupdate } from './hooks/useAutoupdate'; import { useCodeHighlight } from './hooks/useCodeHighlight'; -import { useCorsSSLConfig } from './hooks/useCorsSSLConfig'; import { useDesktopFavicon } from './hooks/useDesktopFavicon'; import { useDesktopTitle } from './hooks/useDesktopTitle'; import { useEmojiOne } from './hooks/useEmojiOne'; @@ -66,7 +65,6 @@ const AppLayout = () => { useAppleOAuth(); useWordPressOAuth(); useCustomOAuth(); - useCorsSSLConfig(); useAutoupdate(); useCodeHighlight(); useLoginViaQuery(); diff --git a/apps/meteor/client/views/root/hooks/useCorsSSLConfig.ts b/apps/meteor/client/views/root/hooks/useCorsSSLConfig.ts deleted file mode 100644 index f506f655af12d..0000000000000 --- a/apps/meteor/client/views/root/hooks/useCorsSSLConfig.ts +++ /dev/null @@ -1,15 +0,0 @@ -// TODO: remove this hook together with the Meteor webapp/DDP layer — it only -// patches Meteor.absoluteUrl's `secure` default, which has no consumers once -// Meteor.absoluteUrl is gone. -import { useSetting } from '@rocket.chat/ui-contexts'; -import { useEffect } from 'react'; - -import { absoluteUrl } from '../../../lib/absoluteUrl'; - -export const useCorsSSLConfig = () => { - const forceSSlSetting = useSetting('Force_SSL'); - - useEffect(() => { - absoluteUrl.defaultOptions.secure = Boolean(forceSSlSetting); - }, [forceSSlSetting]); -};