Page MenuHomePhabricator

D11022.diff
No OneTemporary

D11022.diff

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
@@ -2,6 +2,7 @@
import { Login } from '@commapp/opaque-ke-wasm';
+import { setAccessTokenActionType } from 'lib/actions/user-actions.js';
import identityServiceConfig from 'lib/facts/identity-service.js';
import {
type IdentityServiceAuthLayer,
@@ -14,6 +15,7 @@
identityDeviceTypes,
identityAuthResultValidator,
} from 'lib/types/identity-service-types.js';
+import { type Dispatch } from 'lib/types/redux-types.js';
import { getMessageForException } from 'lib/utils/errors.js';
import { assertWithValidator } from 'lib/utils/validation-utils.js';
@@ -36,10 +38,12 @@
authClient: ?IdentityAuthClient.IdentityClientServicePromiseClient;
unauthClient: IdentityUnauthClient.IdentityClientServicePromiseClient;
getDeviceKeyUpload: () => Promise<IdentityDeviceKeyUpload>;
+ dispatch: Dispatch;
constructor(
authLayer: ?IdentityServiceAuthLayer,
getDeviceKeyUpload: () => Promise<IdentityDeviceKeyUpload>,
+ dispatch: Dispatch,
) {
if (authLayer) {
this.authClient =
@@ -47,6 +51,7 @@
}
this.unauthClient = IdentityServiceClientWrapper.createUnauthClient();
this.getDeviceKeyUpload = getDeviceKeyUpload;
+ this.dispatch = dispatch;
}
static determineSocketAddr(): string {
@@ -280,7 +285,17 @@
const accessToken = loginFinishResponse.getAccessToken();
const identityAuthResult = { accessToken, userID, username };
- return assertWithValidator(identityAuthResult, identityAuthResultValidator);
+ const validatedResult = assertWithValidator(
+ identityAuthResult,
+ identityAuthResultValidator,
+ );
+
+ this.dispatch({
+ type: setAccessTokenActionType,
+ payload: validatedResult.accessToken,
+ });
+
+ return validatedResult;
};
logInWalletUser: (
@@ -312,7 +327,17 @@
const accessToken = loginResponse.getAccessToken();
const identityAuthResult = { accessToken, userID, username: walletAddress };
- return assertWithValidator(identityAuthResult, identityAuthResultValidator);
+ const validatedResult = assertWithValidator(
+ identityAuthResult,
+ identityAuthResultValidator,
+ );
+
+ this.dispatch({
+ type: setAccessTokenActionType,
+ payload: validatedResult.accessToken,
+ });
+
+ return validatedResult;
};
generateNonce: () => Promise<string> = async () => {
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 { useDispatch } from 'lib/utils/redux-utils.js';
import { IdentityServiceClientWrapper } from './identity-service-client-wrapper.js';
import { useGetDeviceKeyUpload } from '../account/account-hooks.js';
@@ -23,6 +24,7 @@
state => state.cryptoStore?.primaryIdentityKeys.ed25519,
);
const getDeviceKeyUpload = useGetDeviceKeyUpload();
+ const dispatch = useDispatch();
const client = React.useMemo(() => {
let authLayer = null;
@@ -33,8 +35,12 @@
commServicesAccessToken: accessToken,
};
}
- return new IdentityServiceClientWrapper(authLayer, getDeviceKeyUpload);
- }, [accessToken, deviceID, getDeviceKeyUpload, userID]);
+ return new IdentityServiceClientWrapper(
+ authLayer,
+ getDeviceKeyUpload,
+ dispatch,
+ );
+ }, [accessToken, deviceID, dispatch, getDeviceKeyUpload, userID]);
const getAuthMetadata = React.useCallback<() => Promise<AuthMetadata>>(
async () => ({

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 17, 9:41 PM (20 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2531974
Default Alt Text
D11022.diff (3 KB)

Event Timeline