Page MenuHomePhabricator

D10786.diff
No OneTemporary

D10786.diff

diff --git a/lib/components/keyserver-connection-handler.js b/lib/components/keyserver-connection-handler.js
--- a/lib/components/keyserver-connection-handler.js
+++ b/lib/components/keyserver-connection-handler.js
@@ -38,10 +38,9 @@
}
}, [callLogOut, hasConnectionIssue, dispatchActionPromise]);
- const identityClient = React.useContext(
- IdentityClientContext,
- )?.identityClient;
- invariant(identityClient, 'Identity client should be set');
+ const identityContext = React.useContext(IdentityClientContext);
+ invariant(identityContext, 'Identity context should be set');
+ const { identityClient } = identityContext;
const olmSessionCreator = React.useContext(OlmSessionCreatorContext);
invariant(olmSessionCreator, 'Olm session creator should be set');
diff --git a/lib/shared/identity-client-context.js b/lib/shared/identity-client-context.js
--- a/lib/shared/identity-client-context.js
+++ b/lib/shared/identity-client-context.js
@@ -4,8 +4,15 @@
import type { IdentityServiceClient } from '../types/identity-service-types.js';
+export type AuthMetadata = {
+ +deviceID: ?string,
+ +userID: ?string,
+ +accessToken: ?string,
+};
+
export type IdentityClientContextType = {
+identityClient: IdentityServiceClient,
+ +getAuthMetadata: () => Promise<AuthMetadata>,
};
const IdentityClientContext: React.Context<?IdentityClientContextType> =
diff --git a/native/identity-service/identity-service-context-provider.react.js b/native/identity-service/identity-service-context-provider.react.js
--- a/native/identity-service/identity-service-context-provider.react.js
+++ b/native/identity-service/identity-service-context-provider.react.js
@@ -228,8 +228,9 @@
const value = React.useMemo(
() => ({
identityClient: client,
+ getAuthMetadata,
}),
- [client],
+ [client, getAuthMetadata],
);
return (
diff --git a/web/grpc/identity-service-context-provider.react.js b/web/grpc/identity-service-context-provider.react.js
--- a/web/grpc/identity-service-context-provider.react.js
+++ b/web/grpc/identity-service-context-provider.react.js
@@ -2,7 +2,10 @@
import * as React from 'react';
-import { IdentityClientContext } from 'lib/shared/identity-client-context.js';
+import {
+ IdentityClientContext,
+ type AuthMetadata,
+} from 'lib/shared/identity-client-context.js';
import { IdentityServiceClientWrapper } from './identity-service-client-wrapper.js';
import { useSelector } from '../redux/redux-utils.js';
@@ -31,11 +34,21 @@
return new IdentityServiceClientWrapper(authLayer);
}, [accessToken, deviceID, userID]);
+ const getAuthMetadata = React.useCallback<() => Promise<AuthMetadata>>(
+ async () => ({
+ userID,
+ deviceID,
+ accessToken,
+ }),
+ [accessToken, deviceID, userID],
+ );
+
const value = React.useMemo(
() => ({
identityClient: client,
+ getAuthMetadata,
}),
- [client],
+ [client, getAuthMetadata],
);
return (

File Metadata

Mime Type
text/plain
Expires
Wed, Nov 27, 3:46 AM (21 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2587604
Default Alt Text
D10786.diff (2 KB)

Event Timeline