From f4a286d9c7118fe080168a591eb40f3913fcc59f Mon Sep 17 00:00:00 2001 From: Andrey Goncharov Date: Thu, 21 Sep 2023 03:15:10 -0700 Subject: [PATCH] Override intern graph calls in flipper-ui-core Summary: > "Hi, kids, do you like violence?" Alrighty, in flipper-frontend-core we have the **base** implmenetation of flipperLib (the thing exposed to the plugins). This base implementation is never used directly by the plugins, rather it is shared code used by the real consumers - flipper-ui-core (regular Flipper with UI) and flipper-server-companion (the thing that allows hosting plugins on the server). These real consumers actually run the plugins and expose flipperLib to the plugins. In flipper-ui-core we have a more sophisticated logic of calling the intern graph - we check for VPN connection and authn. Therefore, to expose the same way of handling intern graph requests we **override** intern graph calls provided by flipper-frontend-core. *Ideally*, we should move checking for VPN connection and authn to flipper-frontend-core, but currently it is a lot of effort for very little gains: 1. flipper-frontend-core does not have a notion of a user 2. Even if we move the authn-related logic there the only real consumer of that effort if flipper-server-companion that is used only by UIQR (which in its turn is barely used in the headless mode and do not require authn-related logic). Thus, we just override intern graph request on the flipper-ui-core side since it is the simplest and the most impactful thing to do at the moment. Reviewed By: LukeDefeo Differential Revision: D49494922 fbshipit-source-id: 6f1d521af7ca5bd50549b7bc328d6b8fcab98389 --- .../src/utils/flipperLibImplementation/index.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/desktop/flipper-ui-core/src/utils/flipperLibImplementation/index.tsx b/desktop/flipper-ui-core/src/utils/flipperLibImplementation/index.tsx index 6889f7a0e..91ce6f342 100644 --- a/desktop/flipper-ui-core/src/utils/flipperLibImplementation/index.tsx +++ b/desktop/flipper-ui-core/src/utils/flipperLibImplementation/index.tsx @@ -17,7 +17,12 @@ import {addNotification} from '../../reducers/notifications'; import {deconstructPluginKey} from 'flipper-common'; import {RenderHost} from 'flipper-frontend-core'; import {setMenuEntries} from '../../reducers/connections'; -import {currentUser, isConnected} from '../../fb-stubs/user'; +import { + currentUser, + internGraphGETAPIRequest, + internGraphPOSTAPIRequest, + isConnected, +} from '../../fb-stubs/user'; export function initializeFlipperLibImplementation( renderHost: RenderHost, @@ -29,6 +34,8 @@ export function initializeFlipperLibImplementation( ...base, intern: { ...base.intern, + graphGet: internGraphGETAPIRequest, + graphPost: internGraphPOSTAPIRequest, currentUser, isConnected, },