Page MenuHomePhabricator

D11273.id38135.diff
No OneTemporary

D11273.id38135.diff

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

Mime Type
text/plain
Expires
Tue, Nov 26, 3:31 AM (22 h, 3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2581892
Default Alt Text
D11273.id38135.diff (5 KB)

Event Timeline