Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3506672
D9610.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
7 KB
Referenced Files
None
Subscribers
None
D9610.diff
View Options
diff --git a/native/root.react.js b/native/root.react.js
--- a/native/root.react.js
+++ b/native/root.react.js
@@ -24,6 +24,7 @@
import { ENSCacheProvider } from 'lib/components/ens-cache-provider.react.js';
import IntegrityHandler from 'lib/components/integrity-handler.react.js';
import { MediaCacheProvider } from 'lib/components/media-cache-provider.react.js';
+import { TunnelbrokerProvider } from 'lib/tunnelbroker/tunnelbroker-context.js';
import { actionLogger } from 'lib/utils/action-logger.js';
import { RegistrationContextProvider } from './account/registration/registration-context-provider.react.js';
@@ -64,6 +65,7 @@
import { DarkTheme, LightTheme } from './themes/navigation.js';
import ThemeHandler from './themes/theme-handler.react.js';
import { provider } from './utils/ethers-utils.js';
+import { useTunnelbrokerInitMessage } from './utils/tunnelbroker-utils.js';
// Add custom items to expo-dev-menu
import './dev-menu.js';
@@ -236,6 +238,8 @@
return undefined;
})();
+ const tunnelbrokerInitMessage = useTunnelbrokerInitMessage();
+
const gated: React.Node = (
<>
<LifecycleHandler />
@@ -273,51 +277,55 @@
return (
<GestureHandlerRootView style={styles.app}>
<StaffContextProvider>
- <FeatureFlagsProvider>
- <NavContext.Provider value={navContext}>
- <RootContext.Provider value={rootContext}>
- <InputStateContainer>
- <MessageEditingContextProvider>
- <SafeAreaProvider initialMetrics={initialWindowMetrics}>
- <ActionSheetProvider>
- <ENSCacheProvider provider={provider}>
- <MediaCacheProvider persistence={filesystemMediaCache}>
- <EditUserAvatarProvider>
- <NativeEditThreadAvatarProvider>
- <MarkdownContextProvider>
- <MessageSearchProvider>
- <BottomSheetProvider>
- <RegistrationContextProvider>
- <SQLiteDataHandler />
- <ConnectedStatusBar />
- <ReduxPersistGate
- persistor={getPersistor()}
- >
- {gated}
- </ReduxPersistGate>
- <PersistedStateGate>
- <Socket
- detectUnsupervisedBackgroundRef={
- detectUnsupervisedBackgroundRef
- }
- />
- </PersistedStateGate>
- {navigation}
- </RegistrationContextProvider>
- </BottomSheetProvider>
- </MessageSearchProvider>
- </MarkdownContextProvider>
- </NativeEditThreadAvatarProvider>
- </EditUserAvatarProvider>
- </MediaCacheProvider>
- </ENSCacheProvider>
- </ActionSheetProvider>
- </SafeAreaProvider>
- </MessageEditingContextProvider>
- </InputStateContainer>
- </RootContext.Provider>
- </NavContext.Provider>
- </FeatureFlagsProvider>
+ <TunnelbrokerProvider initMessage={tunnelbrokerInitMessage}>
+ <FeatureFlagsProvider>
+ <NavContext.Provider value={navContext}>
+ <RootContext.Provider value={rootContext}>
+ <InputStateContainer>
+ <MessageEditingContextProvider>
+ <SafeAreaProvider initialMetrics={initialWindowMetrics}>
+ <ActionSheetProvider>
+ <ENSCacheProvider provider={provider}>
+ <MediaCacheProvider
+ persistence={filesystemMediaCache}
+ >
+ <EditUserAvatarProvider>
+ <NativeEditThreadAvatarProvider>
+ <MarkdownContextProvider>
+ <MessageSearchProvider>
+ <BottomSheetProvider>
+ <RegistrationContextProvider>
+ <SQLiteDataHandler />
+ <ConnectedStatusBar />
+ <ReduxPersistGate
+ persistor={getPersistor()}
+ >
+ {gated}
+ </ReduxPersistGate>
+ <PersistedStateGate>
+ <Socket
+ detectUnsupervisedBackgroundRef={
+ detectUnsupervisedBackgroundRef
+ }
+ />
+ </PersistedStateGate>
+ {navigation}
+ </RegistrationContextProvider>
+ </BottomSheetProvider>
+ </MessageSearchProvider>
+ </MarkdownContextProvider>
+ </NativeEditThreadAvatarProvider>
+ </EditUserAvatarProvider>
+ </MediaCacheProvider>
+ </ENSCacheProvider>
+ </ActionSheetProvider>
+ </SafeAreaProvider>
+ </MessageEditingContextProvider>
+ </InputStateContainer>
+ </RootContext.Provider>
+ </NavContext.Provider>
+ </FeatureFlagsProvider>
+ </TunnelbrokerProvider>
</StaffContextProvider>
</GestureHandlerRootView>
);
@@ -338,4 +346,5 @@
</Provider>
);
}
+
export default AppRoot;
diff --git a/native/utils/tunnelbroker-utils.js b/native/utils/tunnelbroker-utils.js
new file mode 100644
--- /dev/null
+++ b/native/utils/tunnelbroker-utils.js
@@ -0,0 +1,36 @@
+// @flow
+
+import * as React from 'react';
+
+import type { ConnectionInitializationMessage } from 'lib/types/tunnelbroker/session-types.js';
+
+import { getContentSigningKey } from './crypto-utils.js';
+import { useSelector } from '../redux/redux-utils.js';
+
+function useTunnelbrokerInitMessage(): ?ConnectionInitializationMessage {
+ const [deviceID, setDeviceID] = React.useState<?string>();
+ const userID = useSelector(state => state.currentUserInfo?.id);
+ const accessToken = useSelector(state => state.commServicesAccessToken);
+
+ React.useEffect(() => {
+ (async () => {
+ const contentSigningKey = await getContentSigningKey();
+ setDeviceID(contentSigningKey);
+ })();
+ }, []);
+
+ return React.useMemo(() => {
+ if (!deviceID || !accessToken || !userID) {
+ return null;
+ }
+ return ({
+ type: 'ConnectionInitializationMessage',
+ deviceID,
+ accessToken,
+ userID,
+ deviceType: 'mobile',
+ }: ConnectionInitializationMessage);
+ }, [accessToken, deviceID, userID]);
+}
+
+export { useTunnelbrokerInitMessage };
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 21, 5:50 PM (20 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2688564
Default Alt Text
D9610.diff (7 KB)
Attached To
Mode
D9610: [native] create Tunnelbroker session
Attached
Detach File
Event Timeline
Log In to Comment