Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3384047
D11273.id38118.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D11273.id38118.diff
View Options
diff --git a/web/crypto/opaque-utils.js b/web/crypto/opaque-utils.js
--- a/web/crypto/opaque-utils.js
+++ b/web/crypto/opaque-utils.js
@@ -6,12 +6,13 @@
let opaqueKeLoadingState: void | true | Promise<mixed>;
-function initOpaque(): Promise<mixed> {
+function initOpaque(overrideOpaqueURL?: ?string): Promise<mixed> {
+ const finalOpaqueURL = overrideOpaqueURL ?? opaqueURL;
if (opaqueKeLoadingState === true) {
return Promise.resolve();
}
if (!opaqueKeLoadingState) {
- opaqueKeLoadingState = initOpaqueKe(opaqueURL);
+ opaqueKeLoadingState = initOpaqueKe(finalOpaqueURL);
}
return opaqueKeLoadingState;
}
diff --git a/web/grpc/identity-service-client-wrapper.js b/web/grpc/identity-service-client-wrapper.js
--- a/web/grpc/identity-service-client-wrapper.js
+++ b/web/grpc/identity-service-client-wrapper.js
@@ -7,6 +7,7 @@
OneTimeKeysResultValues,
SignedPrekeys,
} from 'lib/types/crypto-types.js';
+import type { PlatformDetails } from 'lib/types/device-types.js';
import {
type IdentityServiceAuthLayer,
type IdentityServiceClient,
@@ -41,19 +42,26 @@
import * as IdentityUnauthClient from '../protobufs/identity-unauth.cjs';
class IdentityServiceClientWrapper implements IdentityServiceClient {
+ overridedOpaqueFilepath: ?string;
authClient: ?IdentityAuthClient.IdentityClientServicePromiseClient;
unauthClient: IdentityUnauthClient.IdentityClientServicePromiseClient;
getDeviceKeyUpload: () => Promise<IdentityDeviceKeyUpload>;
constructor(
+ platformDetails: PlatformDetails,
+ overridedOpaqueFilepath: ?string,
authLayer: ?IdentityServiceAuthLayer,
getDeviceKeyUpload: () => Promise<IdentityDeviceKeyUpload>,
) {
+ this.overridedOpaqueFilepath = overridedOpaqueFilepath;
if (authLayer) {
- this.authClient =
- IdentityServiceClientWrapper.createAuthClient(authLayer);
+ this.authClient = IdentityServiceClientWrapper.createAuthClient(
+ platformDetails,
+ authLayer,
+ );
}
- this.unauthClient = IdentityServiceClientWrapper.createUnauthClient();
+ this.unauthClient =
+ IdentityServiceClientWrapper.createUnauthClient(platformDetails);
this.getDeviceKeyUpload = getDeviceKeyUpload;
}
@@ -62,6 +70,7 @@
}
static createAuthClient(
+ platformDetails: PlatformDetails,
authLayer: IdentityServiceAuthLayer,
): IdentityAuthClient.IdentityClientServicePromiseClient {
const { userID, deviceID, commServicesAccessToken } = authLayer;
@@ -69,7 +78,9 @@
const identitySocketAddr =
IdentityServiceClientWrapper.determineSocketAddr();
- const versionInterceptor = new VersionInterceptor<Request, Response>();
+ const versionInterceptor = new VersionInterceptor<Request, Response>(
+ platformDetails,
+ );
const authInterceptor = new AuthInterceptor<Request, Response>(
userID,
deviceID,
@@ -87,11 +98,15 @@
);
}
- static createUnauthClient(): IdentityUnauthClient.IdentityClientServicePromiseClient {
+ static createUnauthClient(
+ platformDetails: PlatformDetails,
+ ): IdentityUnauthClient.IdentityClientServicePromiseClient {
const identitySocketAddr =
IdentityServiceClientWrapper.determineSocketAddr();
- const versionInterceptor = new VersionInterceptor<Request, Response>();
+ const versionInterceptor = new VersionInterceptor<Request, Response>(
+ platformDetails,
+ );
const unauthClientOpts = {
unaryInterceptors: [versionInterceptor],
@@ -329,7 +344,7 @@
const [identityDeviceKeyUpload] = await Promise.all([
this.getDeviceKeyUpload(),
- initOpaque(),
+ initOpaque(this.overridedOpaqueFilepath),
]);
const opaqueLogin = new Login();
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
@@ -6,6 +6,7 @@
IdentityClientContext,
type AuthMetadata,
} from 'lib/shared/identity-client-context.js';
+import { getConfig } from 'lib/utils/config.js';
import { IdentityServiceClientWrapper } from './identity-service-client-wrapper.js';
import { useGetDeviceKeyUpload } from '../account/account-hooks.js';
@@ -33,7 +34,12 @@
commServicesAccessToken: accessToken,
};
}
- return new IdentityServiceClientWrapper(authLayer, getDeviceKeyUpload);
+ return new IdentityServiceClientWrapper(
+ getConfig().platformDetails,
+ null,
+ authLayer,
+ getDeviceKeyUpload,
+ );
}, [accessToken, deviceID, getDeviceKeyUpload, userID]);
const getAuthMetadata = React.useCallback<() => Promise<AuthMetadata>>(
diff --git a/web/grpc/interceptor.js b/web/grpc/interceptor.js
--- a/web/grpc/interceptor.js
+++ b/web/grpc/interceptor.js
@@ -2,9 +2,15 @@
import * as grpcWeb from 'grpc-web';
-import { getConfig } from 'lib/utils/config.js';
+import type { PlatformDetails } from 'lib/types/device-types.js';
class VersionInterceptor<Request, Response> {
+ platformDetails: PlatformDetails;
+
+ constructor(platformDetails: PlatformDetails) {
+ this.platformDetails = platformDetails;
+ }
+
intercept(
request: grpcWeb.Request<Request, Response>,
invoker: (
@@ -12,9 +18,8 @@
) => Promise<grpcWeb.UnaryResponse<Request, Response>>,
): Promise<grpcWeb.UnaryResponse<Request, Response>> {
const metadata = request.getMetadata();
- const config = getConfig();
- const codeVersion = config.platformDetails.codeVersion;
- const deviceType = config.platformDetails.platform;
+ const codeVersion = this.platformDetails.codeVersion;
+ const deviceType = this.platformDetails.platform;
if (codeVersion) {
metadata['code_version'] = codeVersion.toString();
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 29, 7:09 PM (21 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2597860
Default Alt Text
D11273.id38118.diff (5 KB)
Attached To
Mode
D11273: [web] Make identity service client runnable on shared worker
Attached
Detach File
Event Timeline
Log In to Comment