Page MenuHomePhabricator

D11006.id36929.diff
No OneTemporary

D11006.id36929.diff

diff --git a/lib/actions/siwe-actions.js b/lib/actions/siwe-actions.js
--- a/lib/actions/siwe-actions.js
+++ b/lib/actions/siwe-actions.js
@@ -7,12 +7,12 @@
logInActionSources,
} from '../types/account-types.js';
import type { SIWEAuthServerCall } from '../types/siwe-types.js';
+import { authoritativeKeyserverID } from '../utils/authoritative-keyserver.js';
import type {
CallSingleKeyserverEndpoint,
CallSingleKeyserverEndpointOptions,
} from '../utils/call-single-keyserver-endpoint.js';
import { getConfig } from '../utils/config.js';
-import { ashoatKeyserverID } from '../utils/validation-utils.js';
const getSIWENonceActionTypes = Object.freeze({
started: 'GET_SIWE_NONCE_STARTED',
@@ -44,7 +44,7 @@
async (siweAuthPayload, options) => {
const watchedIDs = threadWatcher.getWatchedIDs();
const deviceTokenUpdateRequest =
- siweAuthPayload.deviceTokenUpdateRequest[ashoatKeyserverID];
+ siweAuthPayload.deviceTokenUpdateRequest[authoritativeKeyserverID];
const response = await callSingleKeyserverEndpoint(
'siwe_auth',
@@ -74,10 +74,10 @@
messageInfos: response.rawMessageInfos,
truncationStatus: response.truncationStatuses,
watchedIDsAtRequestTime: watchedIDs,
- currentAsOf: { [ashoatKeyserverID]: response.serverTime },
+ currentAsOf: { [authoritativeKeyserverID]: response.serverTime },
},
userInfos,
- updatesCurrentAsOf: { [ashoatKeyserverID]: response.serverTime },
+ updatesCurrentAsOf: { [authoritativeKeyserverID]: response.serverTime },
logInActionSource: logInActionSources.logInFromNativeSIWE,
notAcknowledgedPolicies: response.notAcknowledgedPolicies,
};
diff --git a/lib/actions/user-actions.js b/lib/actions/user-actions.js
--- a/lib/actions/user-actions.js
+++ b/lib/actions/user-actions.js
@@ -62,6 +62,7 @@
PasswordUpdate,
LoggedOutUserInfo,
} from '../types/user-types.js';
+import { authoritativeKeyserverID } from '../utils/authoritative-keyserver.js';
import type {
CallSingleKeyserverEndpoint,
CallSingleKeyserverEndpointOptions,
@@ -71,7 +72,6 @@
import { useSelector } from '../utils/redux-utils.js';
import { usingCommServicesAccessToken } from '../utils/services-utils.js';
import sleep from '../utils/sleep.js';
-import { ashoatKeyserverID } from '../utils/validation-utils.js';
const loggedOutUserInfo: LoggedOutUserInfo = {
anonymous: true,
@@ -153,11 +153,11 @@
callKeyserverEndpoint: CallKeyserverEndpoint,
): (() => Promise<ClaimUsernameResponse>) =>
async () => {
- const requests = { [ashoatKeyserverID]: {} };
+ const requests = { [authoritativeKeyserverID]: {} };
const responses = await callKeyserverEndpoint('claim_username', requests, {
...claimUsernameCallSingleKeyserverEndpointOptions,
});
- const response = responses[ashoatKeyserverID];
+ const response = responses[authoritativeKeyserverID];
return {
message: response.message,
signature: response.signature,
@@ -271,7 +271,7 @@
) => Promise<RegisterResult>) =>
async (registerInfo, options) => {
const deviceTokenUpdateRequest =
- registerInfo.deviceTokenUpdateRequest[ashoatKeyserverID];
+ registerInfo.deviceTokenUpdateRequest[authoritativeKeyserverID];
const response = await callSingleKeyserverEndpoint(
'create_account',
@@ -399,14 +399,14 @@
return {
threadInfos,
- currentUserInfo: responses[ashoatKeyserverID].currentUserInfo,
+ currentUserInfo: responses[authoritativeKeyserverID].currentUserInfo,
calendarResult,
messagesResult,
userInfos,
updatesCurrentAsOf,
logInActionSource: keyserverAuthInfo.logInActionSource,
notAcknowledgedPolicies:
- responses[ashoatKeyserverID].notAcknowledgedPolicies,
+ responses[authoritativeKeyserverID].notAcknowledgedPolicies,
preRequestUserInfo,
};
};
@@ -541,7 +541,7 @@
// Eventually the list of keyservers will be fetched from the
// identity service
- const keyserverIDs = inputKeyserverIDs ?? [ashoatKeyserverID];
+ const keyserverIDs = inputKeyserverIDs ?? [authoritativeKeyserverID];
const watchedIDsPerKeyserver = sortThreadIDsPerKeyserver(watchedIDs);
const calendarQueryPerKeyserver = sortCalendarQueryPerKeyserver(
@@ -616,14 +616,14 @@
return {
threadInfos,
- currentUserInfo: responses[ashoatKeyserverID].currentUserInfo,
+ currentUserInfo: responses[authoritativeKeyserverID].currentUserInfo,
calendarResult,
messagesResult,
userInfos,
updatesCurrentAsOf,
logInActionSource: logInInfo.logInActionSource,
notAcknowledgedPolicies:
- responses[ashoatKeyserverID].notAcknowledgedPolicies,
+ responses[authoritativeKeyserverID].notAcknowledgedPolicies,
};
};
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
@@ -21,11 +21,11 @@
import { OlmSessionCreatorContext } from '../shared/olm-session-creator-context.js';
import type { BaseSocketProps } from '../socket/socket.react.js';
import { logInActionSources } from '../types/account-types.js';
+import { authoritativeKeyserverID } from '../utils/authoritative-keyserver.js';
import { useDispatchActionPromise } from '../utils/redux-promise-utils.js';
import { useSelector } from '../utils/redux-utils.js';
import { usingCommServicesAccessToken } from '../utils/services-utils.js';
import sleep from '../utils/sleep.js';
-import { ashoatKeyserverID } from '../utils/validation-utils.js';
type Props = {
...BaseSocketProps,
@@ -55,7 +55,7 @@
// try to use it. In worst case it is invalid and our push-handler will try
// to fix it.
const ashoatKeyserverDeviceToken = useSelector(
- deviceTokenSelector(ashoatKeyserverID),
+ deviceTokenSelector(authoritativeKeyserverID),
);
const deviceToken = keyserverDeviceToken ?? ashoatKeyserverDeviceToken;
@@ -165,7 +165,7 @@
e,
);
- if (!dataLoaded && keyserverID === ashoatKeyserverID) {
+ if (!dataLoaded && keyserverID === authoritativeKeyserverID) {
await dispatchActionPromise(logOutActionTypes, callLogOut());
}
} finally {
@@ -223,7 +223,7 @@
cancelPendingAuth.current = cancel;
}, [authInProgress, hasAccessToken, isUserAuthenticated, performAuth]);
- if (keyserverID !== ashoatKeyserverID) {
+ if (keyserverID !== authoritativeKeyserverID) {
return null;
}
return <Socket {...rest} />;
diff --git a/lib/hooks/keyserver-reachability.js b/lib/hooks/keyserver-reachability.js
--- a/lib/hooks/keyserver-reachability.js
+++ b/lib/hooks/keyserver-reachability.js
@@ -6,12 +6,12 @@
import { updateKeyserverReachabilityActionType } from '../keyserver-conn/keyserver-conn-types.js';
import { connectionSelector } from '../selectors/keyserver-selectors.js';
import type { ConnectionStatus } from '../types/socket-types.js';
+import { authoritativeKeyserverID } from '../utils/authoritative-keyserver.js';
import { useSelector, useDispatch } from '../utils/redux-utils.js';
-import { ashoatKeyserverID } from '../utils/validation-utils.js';
function useKeyserverReachabilityHandler(networkConnected: boolean): void {
const dispatch = useDispatch();
- const connection = useSelector(connectionSelector(ashoatKeyserverID));
+ const connection = useSelector(connectionSelector(authoritativeKeyserverID));
invariant(connection, 'keyserver missing from keyserverStore');
const disconnected = connection.unreachable;
@@ -22,7 +22,10 @@
}
dispatch({
type: updateKeyserverReachabilityActionType,
- payload: { visible: newDisconnected, keyserverID: ashoatKeyserverID },
+ payload: {
+ visible: newDisconnected,
+ keyserverID: authoritativeKeyserverID,
+ },
});
},
[disconnected, dispatch],
diff --git a/lib/reducers/data-loaded-reducer.js b/lib/reducers/data-loaded-reducer.js
--- a/lib/reducers/data-loaded-reducer.js
+++ b/lib/reducers/data-loaded-reducer.js
@@ -8,8 +8,8 @@
} from '../actions/user-actions.js';
import { setNewSessionActionType } from '../keyserver-conn/keyserver-conn-types.js';
import type { BaseAction } from '../types/redux-types.js';
+import { authoritativeKeyserverID } from '../utils/authoritative-keyserver.js';
import { usingCommServicesAccessToken } from '../utils/services-utils.js';
-import { ashoatKeyserverID } from '../utils/validation-utils.js';
export default function reduceDataLoaded(
state: boolean,
@@ -29,7 +29,7 @@
} else if (action.type === logOutActionTypes.started) {
return false;
} else if (action.type === keyserverAuthActionTypes.success) {
- if (ashoatKeyserverID in action.payload.updatesCurrentAsOf) {
+ if (authoritativeKeyserverID in action.payload.updatesCurrentAsOf) {
return true;
}
}
diff --git a/lib/reducers/keyserver-reducer.js b/lib/reducers/keyserver-reducer.js
--- a/lib/reducers/keyserver-reducer.js
+++ b/lib/reducers/keyserver-reducer.js
@@ -43,9 +43,9 @@
} from '../types/socket-types.js';
import { updateTypes } from '../types/update-types-enum.js';
import { processUpdatesActionType } from '../types/update-types.js';
+import { authoritativeKeyserverID } from '../utils/authoritative-keyserver.js';
import { getConfig } from '../utils/config.js';
import { setURLPrefix } from '../utils/url-utils.js';
-import { ashoatKeyserverID } from '../utils/validation-utils.js';
const { processStoreOperations: processStoreOps } = keyserverStoreOpsHandlers;
@@ -272,9 +272,9 @@
const operation: ReplaceKeyserverOperation = {
type: 'replace_keyserver',
payload: {
- id: ashoatKeyserverID,
+ id: authoritativeKeyserverID,
keyserverInfo: {
- ...state.keyserverInfos[ashoatKeyserverID],
+ ...state.keyserverInfos[authoritativeKeyserverID],
urlPrefix: action.payload,
},
},
@@ -303,9 +303,9 @@
const operation: ReplaceKeyserverOperation = {
type: 'replace_keyserver',
payload: {
- id: ashoatKeyserverID,
+ id: authoritativeKeyserverID,
keyserverInfo: {
- ...state.keyserverInfos[ashoatKeyserverID],
+ ...state.keyserverInfos[authoritativeKeyserverID],
lastCommunicatedPlatformDetails: getConfig().platformDetails,
},
},
@@ -423,16 +423,17 @@
action.type === deleteAccountActionTypes.success
) {
// We want to remove all keyservers but Ashoat's keyserver
- const oldConnection = state.keyserverInfos[ashoatKeyserverID].connection;
+ const oldConnection =
+ state.keyserverInfos[authoritativeKeyserverID].connection;
const operations: KeyserverStoreOperation[] = [
{ type: 'remove_all_keyservers' },
];
operations.push({
type: 'replace_keyserver',
payload: {
- id: ashoatKeyserverID,
+ id: authoritativeKeyserverID,
keyserverInfo: {
- ...state.keyserverInfos[ashoatKeyserverID],
+ ...state.keyserverInfos[authoritativeKeyserverID],
connection: {
...oldConnection,
connectionIssue: null,
@@ -455,14 +456,15 @@
payload: { ids: action.payload.keyserverIDs },
},
];
- if (action.payload.keyserverIDs.includes(ashoatKeyserverID)) {
- const oldConnection = state.keyserverInfos[ashoatKeyserverID].connection;
+ if (action.payload.keyserverIDs.includes(authoritativeKeyserverID)) {
+ const oldConnection =
+ state.keyserverInfos[authoritativeKeyserverID].connection;
operations.push({
type: 'replace_keyserver',
payload: {
- id: ashoatKeyserverID,
+ id: authoritativeKeyserverID,
keyserverInfo: {
- ...state.keyserverInfos[ashoatKeyserverID],
+ ...state.keyserverInfos[authoritativeKeyserverID],
connection: {
...oldConnection,
connectionIssue: null,
diff --git a/lib/reducers/keyserver-reducer.test.js b/lib/reducers/keyserver-reducer.test.js
--- a/lib/reducers/keyserver-reducer.test.js
+++ b/lib/reducers/keyserver-reducer.test.js
@@ -3,7 +3,7 @@
import reduceKeyserverStore from './keyserver-reducer.js';
import { deleteKeyserverAccountActionTypes } from '../actions/user-actions.js';
import { defaultKeyserverInfo } from '../types/keyserver-types.js';
-import { ashoatKeyserverID } from '../utils/validation-utils.js';
+import { authoritativeKeyserverID } from '../utils/authoritative-keyserver.js';
describe('reduceKeyserverStore', () => {
it('removes from the store keyservers the user has disconnected from', () => {
@@ -40,11 +40,11 @@
.keyserverStore,
).toEqual({ keyserverInfos: { ['0']: defaultKeyserverInfo('url1') } });
});
- it('update keyserverInfo with ashoatKeyserverID', () => {
+ it('update keyserverInfo with authoritativeKeyserverID', () => {
const defaultAshoatKeyserverInfo = defaultKeyserverInfo('url1');
const oldKeyserverStore = {
keyserverInfos: {
- [ashoatKeyserverID]: {
+ [authoritativeKeyserverID]: {
...defaultAshoatKeyserverInfo,
connection: {
...defaultAshoatKeyserverInfo.connection,
@@ -65,7 +65,7 @@
username: 'test',
},
},
- keyserverIDs: [ashoatKeyserverID],
+ keyserverIDs: [authoritativeKeyserverID],
},
loadingInfo: {
fetchIndex: 1,
@@ -76,16 +76,16 @@
expect(
reduceKeyserverStore(oldKeyserverStore, deleteAccountAction)
- .keyserverStore.keyserverInfos[ashoatKeyserverID].connection
+ .keyserverStore.keyserverInfos[authoritativeKeyserverID].connection
.connectionIssue,
).toEqual(null);
});
- it('return the same keyserverInfo with ashoatKeyserverID', () => {
+ it('return the same keyserverInfo with authoritativeKeyserverID', () => {
const defaultAshoatKeyserverInfo = defaultKeyserverInfo('url1');
const oldKeyserverStore = {
keyserverInfos: {
- [ashoatKeyserverID]: {
+ [authoritativeKeyserverID]: {
...defaultAshoatKeyserverInfo,
connection: {
...defaultAshoatKeyserverInfo.connection,
@@ -117,7 +117,7 @@
expect(
reduceKeyserverStore(oldKeyserverStore, deleteAccountAction)
- .keyserverStore.keyserverInfos[ashoatKeyserverID].connection
+ .keyserverStore.keyserverInfos[authoritativeKeyserverID].connection
.connectionIssue,
).toEqual('not_logged_in_error');
});
diff --git a/lib/reducers/message-reducer.test.js b/lib/reducers/message-reducer.test.js
--- a/lib/reducers/message-reducer.test.js
+++ b/lib/reducers/message-reducer.test.js
@@ -7,7 +7,7 @@
import { messageTypes } from '../types/message-types-enum.js';
import type { MessageStore } from '../types/message-types.js';
import { threadTypes } from '../types/thread-types-enum.js';
-import { ashoatKeyserverID } from '../utils/validation-utils.js';
+import { authoritativeKeyserverID } from '../utils/authoritative-keyserver.js';
const messageStoreBeforeMediaUpdate: MessageStore = {
messages: {
@@ -45,7 +45,7 @@
},
},
local: {},
- currentAsOf: { [ashoatKeyserverID]: 1639522292174 },
+ currentAsOf: { [authoritativeKeyserverID]: 1639522292174 },
};
describe('UPDATE_MULTIMEDIA_MESSAGE_MEDIA', () => {
@@ -277,7 +277,7 @@
messages: {},
threads: {},
local: {},
- currentAsOf: { [ashoatKeyserverID]: 1234567890123 },
+ currentAsOf: { [authoritativeKeyserverID]: 1234567890123 },
},
{
type: 'SET_CLIENT_DB_STORE',
diff --git a/lib/reducers/user-reducer.js b/lib/reducers/user-reducer.js
--- a/lib/reducers/user-reducer.js
+++ b/lib/reducers/user-reducer.js
@@ -45,10 +45,10 @@
UserInfos,
UserStore,
} from '../types/user-types.js';
+import { authoritativeKeyserverID } from '../utils/authoritative-keyserver.js';
import { getMessageForException } from '../utils/errors.js';
import { assertObjectsAreEqual } from '../utils/objects.js';
import { usingCommServicesAccessToken } from '../utils/services-utils.js';
-import { ashoatKeyserverID } from '../utils/validation-utils.js';
function reduceCurrentUserInfo(
state: ?CurrentUserInfo,
@@ -67,7 +67,7 @@
} else if (
action.type === setNewSessionActionType &&
action.payload.sessionChange.currentUserInfo &&
- action.payload.keyserverID === ashoatKeyserverID
+ action.payload.keyserverID === authoritativeKeyserverID
) {
const { sessionChange } = action.payload;
if (!_isEqual(sessionChange.currentUserInfo)(state)) {
diff --git a/lib/selectors/socket-selectors.js b/lib/selectors/socket-selectors.js
--- a/lib/selectors/socket-selectors.js
+++ b/lib/selectors/socket-selectors.js
@@ -25,10 +25,10 @@
} from '../types/request-types.js';
import type { SessionState } from '../types/session-types.js';
import type { OneTimeKeyGenerator } from '../types/socket-types.js';
+import { authoritativeKeyserverID } from '../utils/authoritative-keyserver.js';
import { getConfig } from '../utils/config.js';
import { minimumOneTimeKeysRequired } from '../utils/crypto-utils.js';
import { values } from '../utils/objects.js';
-import { ashoatKeyserverID } from '../utils/validation-utils.js';
const baseOpenSocketSelector: (
keyserverID: string,
@@ -214,7 +214,9 @@
getInitialNotificationsEncryptedMessage
) {
const initialNotificationsEncryptedMessage =
- await getInitialNotificationsEncryptedMessage(ashoatKeyserverID);
+ await getInitialNotificationsEncryptedMessage(
+ authoritativeKeyserverID,
+ );
clientResponses.push({
type: serverRequestTypes.INITIAL_NOTIFICATIONS_ENCRYPTED_MESSAGE,
initialNotificationsEncryptedMessage,
diff --git a/lib/shared/avatar-utils.js b/lib/shared/avatar-utils.js
--- a/lib/shared/avatar-utils.js
+++ b/lib/shared/avatar-utils.js
@@ -22,8 +22,8 @@
} from '../types/minimally-encoded-thread-permissions-types.js';
import { threadTypes } from '../types/thread-types-enum.js';
import type { UserInfos } from '../types/user-types.js';
+import { authoritativeKeyserverID } from '../utils/authoritative-keyserver.js';
import { useSelector } from '../utils/redux-utils.js';
-import { ashoatKeyserverID } from '../utils/validation-utils.js';
const defaultAnonymousUserEmojiAvatar: ClientEmojiAvatar = {
color: selectedThreadColors[4],
@@ -248,8 +248,8 @@
function getDefaultAvatar(hashKey: string, color?: string): ClientEmojiAvatar {
let key = hashKey;
- if (key.startsWith(`${ashoatKeyserverID}|`)) {
- key = key.slice(`${ashoatKeyserverID}|`.length);
+ if (key.startsWith(`${authoritativeKeyserverID}|`)) {
+ key = key.slice(`${authoritativeKeyserverID}|`.length);
}
const avatarIndex = stringHash(key) % defaultEmojiAvatars.length;
diff --git a/lib/shared/session-utils.js b/lib/shared/session-utils.js
--- a/lib/shared/session-utils.js
+++ b/lib/shared/session-utils.js
@@ -16,8 +16,8 @@
IdentityCallPreRequestUserState,
} from '../types/session-types.js';
import type { CurrentUserInfo } from '../types/user-types.js';
+import { authoritativeKeyserverID } from '../utils/authoritative-keyserver.js';
import { usingCommServicesAccessToken } from '../utils/services-utils.js';
-import { ashoatKeyserverID } from '../utils/validation-utils.js';
function invalidSessionDowngrade(
currentReduxState: AppState,
@@ -59,7 +59,7 @@
currentReduxState,
actionCurrentUserInfo,
preRequestUserState,
- ashoatKeyserverID,
+ authoritativeKeyserverID,
);
}
// If this action represents a session downgrade - oldState has a loggedIn
diff --git a/lib/shared/state-sync/entries-state-sync-spec.js b/lib/shared/state-sync/entries-state-sync-spec.js
--- a/lib/shared/state-sync/entries-state-sync-spec.js
+++ b/lib/shared/state-sync/entries-state-sync-spec.js
@@ -16,11 +16,11 @@
} from '../../types/report-types.js';
import type { ProcessServerRequestAction } from '../../types/request-types.js';
import { actionLogger } from '../../utils/action-logger.js';
+import { authoritativeKeyserverID } from '../../utils/authoritative-keyserver.js';
import { getConfig } from '../../utils/config.js';
import { values, combineUnorderedHashes, hash } from '../../utils/objects.js';
import { generateReportID } from '../../utils/report-utils.js';
import { sanitizeActionSecrets } from '../../utils/sanitization.js';
-import { ashoatKeyserverID } from '../../utils/validation-utils.js';
import {
filterRawEntryInfosByCalendarQuery,
serverEntryInfosObject,
@@ -36,7 +36,8 @@
(state: AppState) => state.entryStore.entryInfos,
(entryInfos: RawEntryInfos) => ({
...entriesStateSyncSpec,
- getInfoHash: (id: string) => hash(entryInfos[`${ashoatKeyserverID}|${id}`]),
+ getInfoHash: (id: string) =>
+ hash(entryInfos[`${authoritativeKeyserverID}|${id}`]),
getAllInfosHash: (calendarQuery: CalendarQuery) =>
getEntryInfosHash(entryInfos, calendarQuery),
getIDs: (calendarQuery: CalendarQuery) =>
diff --git a/lib/shared/state-sync/threads-state-sync-spec.js b/lib/shared/state-sync/threads-state-sync-spec.js
--- a/lib/shared/state-sync/threads-state-sync-spec.js
+++ b/lib/shared/state-sync/threads-state-sync-spec.js
@@ -16,11 +16,11 @@
type LegacyRawThreadInfo,
} from '../../types/thread-types.js';
import { actionLogger } from '../../utils/action-logger.js';
+import { authoritativeKeyserverID } from '../../utils/authoritative-keyserver.js';
import { getConfig } from '../../utils/config.js';
import { combineUnorderedHashes, values } from '../../utils/objects.js';
import { generateReportID } from '../../utils/report-utils.js';
import { sanitizeActionSecrets } from '../../utils/sanitization.js';
-import { ashoatKeyserverID } from '../../utils/validation-utils.js';
const selector: (
state: AppState,
@@ -33,7 +33,8 @@
(state: AppState) => state.integrityStore.threadHashingStatus === 'completed',
(threadHashes: { +[string]: number }, threadHashingComplete: boolean) => ({
...threadsStateSyncSpec,
- getInfoHash: (id: string) => threadHashes[`${ashoatKeyserverID}|${id}`],
+ getInfoHash: (id: string) =>
+ threadHashes[`${authoritativeKeyserverID}|${id}`],
getAllInfosHash: threadHashingComplete
? () => combineUnorderedHashes(values(threadHashes))
: () => null,
diff --git a/lib/socket/activity-handler.react.js b/lib/socket/activity-handler.react.js
--- a/lib/socket/activity-handler.react.js
+++ b/lib/socket/activity-handler.react.js
@@ -15,9 +15,9 @@
type ActivityUpdate,
} from '../types/activity-types.js';
import type { ConnectionStatus } from '../types/socket-types.js';
+import { authoritativeKeyserverID } from '../utils/authoritative-keyserver.js';
import { useDispatchActionPromise } from '../utils/redux-promise-utils.js';
import { useSelector, useDispatch } from '../utils/redux-utils.js';
-import { ashoatKeyserverID } from '../utils/validation-utils.js';
type Props = {
+activeThread: ?string,
@@ -32,7 +32,7 @@
}, [activeThread]);
const prevActiveThread = prevActiveThreadRef.current;
- const connection = useSelector(connectionSelector(ashoatKeyserverID));
+ const connection = useSelector(connectionSelector(authoritativeKeyserverID));
invariant(connection, 'keyserver missing from keyserverStore');
const connectionStatus = connection.status;
const prevConnectionStatusRef = React.useRef<?ConnectionStatus>();
@@ -109,7 +109,7 @@
if (activityUpdates.length > 0) {
dispatch({
type: queueActivityUpdatesActionType,
- payload: { activityUpdates, keyserverID: ashoatKeyserverID },
+ payload: { activityUpdates, keyserverID: authoritativeKeyserverID },
});
}
diff --git a/lib/socket/api-request-handler.react.js b/lib/socket/api-request-handler.react.js
--- a/lib/socket/api-request-handler.react.js
+++ b/lib/socket/api-request-handler.react.js
@@ -14,9 +14,9 @@
type ConnectionInfo,
type APIResponseServerSocketMessage,
} from '../types/socket-types.js';
+import { authoritativeKeyserverID } from '../utils/authoritative-keyserver.js';
import { SocketOffline } from '../utils/errors.js';
import { useSelector } from '../utils/redux-utils.js';
-import { ashoatKeyserverID } from '../utils/validation-utils.js';
type BaseProps = {
+inflightRequests: ?InflightRequests,
@@ -96,7 +96,9 @@
const ConnectedAPIRequestHandler: React.ComponentType<BaseProps> =
React.memo<BaseProps>(function ConnectedAPIRequestHandler(props) {
- const connection = useSelector(connectionSelector(ashoatKeyserverID));
+ const connection = useSelector(
+ connectionSelector(authoritativeKeyserverID),
+ );
invariant(connection, 'keyserver missing from keyserverStore');
return <APIRequestHandler {...props} connection={connection} />;
});
diff --git a/lib/socket/calendar-query-handler.react.js b/lib/socket/calendar-query-handler.react.js
--- a/lib/socket/calendar-query-handler.react.js
+++ b/lib/socket/calendar-query-handler.react.js
@@ -18,12 +18,12 @@
CalendarQueryUpdateStartingPayload,
} from '../types/entry-types.js';
import { type ConnectionInfo } from '../types/socket-types.js';
+import { authoritativeKeyserverID } from '../utils/authoritative-keyserver.js';
import {
type DispatchActionPromise,
useDispatchActionPromise,
} from '../utils/redux-promise-utils.js';
import { useSelector } from '../utils/redux-utils.js';
-import { ashoatKeyserverID } from '../utils/validation-utils.js';
type BaseProps = {
+currentCalendarQuery: () => CalendarQuery,
@@ -128,7 +128,9 @@
const ConnectedCalendarQueryHandler: React.ComponentType<BaseProps> =
React.memo<BaseProps>(function ConnectedCalendarQueryHandler(props) {
- const connection = useSelector(connectionSelector(ashoatKeyserverID));
+ const connection = useSelector(
+ connectionSelector(authoritativeKeyserverID),
+ );
invariant(connection, 'keyserver missing from keyserverStore');
const lastUserInteractionCalendar = useSelector(
state => state.entryStore.lastUserInteractionCalendar,
diff --git a/lib/socket/request-response-handler.react.js b/lib/socket/request-response-handler.react.js
--- a/lib/socket/request-response-handler.react.js
+++ b/lib/socket/request-response-handler.react.js
@@ -21,9 +21,9 @@
type SocketListener,
type ConnectionInfo,
} from '../types/socket-types.js';
+import { authoritativeKeyserverID } from '../utils/authoritative-keyserver.js';
import { ServerError, SocketTimeout } from '../utils/errors.js';
import { useSelector, useDispatch } from '../utils/redux-utils.js';
-import { ashoatKeyserverID } from '../utils/validation-utils.js';
type BaseProps = {
+inflightRequests: ?InflightRequests,
@@ -139,7 +139,9 @@
const ConnectedRequestResponseHandler: React.ComponentType<BaseProps> =
React.memo<BaseProps>(function ConnectedRequestResponseHandler(props) {
- const connection = useSelector(connectionSelector(ashoatKeyserverID));
+ const connection = useSelector(
+ connectionSelector(authoritativeKeyserverID),
+ );
invariant(connection, 'keyserver missing from keyserverStore');
const dispatch = useDispatch();
diff --git a/lib/socket/socket.react.js b/lib/socket/socket.react.js
--- a/lib/socket/socket.react.js
+++ b/lib/socket/socket.react.js
@@ -69,12 +69,12 @@
type PongServerSocketMessage,
} from '../types/socket-types.js';
import { actionLogger } from '../utils/action-logger.js';
+import { authoritativeKeyserverID } from '../utils/authoritative-keyserver.js';
import { getConfig } from '../utils/config.js';
import { ServerError, SocketTimeout, SocketOffline } from '../utils/errors.js';
import { promiseAll } from '../utils/promises.js';
import type { DispatchActionPromise } from '../utils/redux-promise-utils.js';
import sleep from '../utils/sleep.js';
-import { ashoatKeyserverID } from '../utils/validation-utils.js';
const remainingTimeAfterVisualTimeout =
clientRequestSocketTimeout - clientRequestVisualTimeout;
@@ -163,7 +163,7 @@
}
this.props.dispatch({
type: updateConnectionStatusActionType,
- payload: { status: newStatus, keyserverID: ashoatKeyserverID },
+ payload: { status: newStatus, keyserverID: authoritativeKeyserverID },
});
const socket = this.props.openSocket();
@@ -214,7 +214,7 @@
markSocketInitialized() {
this.props.dispatch({
type: updateConnectionStatusActionType,
- payload: { status: 'connected', keyserverID: ashoatKeyserverID },
+ payload: { status: 'connected', keyserverID: authoritativeKeyserverID },
});
this.resetPing();
}
@@ -235,7 +235,10 @@
this.stopPing();
this.props.dispatch({
type: updateConnectionStatusActionType,
- payload: { status: 'disconnecting', keyserverID: ashoatKeyserverID },
+ payload: {
+ status: 'disconnecting',
+ keyserverID: authoritativeKeyserverID,
+ },
});
if (!activityUpdatePending) {
this.finishClosingSocket();
@@ -250,7 +253,7 @@
type: updateConnectionStatusActionType,
payload: {
status: 'forcedDisconnecting',
- keyserverID: ashoatKeyserverID,
+ keyserverID: authoritativeKeyserverID,
},
});
}
@@ -275,7 +278,10 @@
if (this.props.connection.status !== 'disconnected') {
this.props.dispatch({
type: updateConnectionStatusActionType,
- payload: { status: 'disconnected', keyserverID: ashoatKeyserverID },
+ payload: {
+ status: 'disconnected',
+ keyserverID: authoritativeKeyserverID,
+ },
});
}
if (this.reopenConnectionAfterClosing) {
@@ -358,7 +364,7 @@
sendMessage={this.sendMessageWithoutID}
addListener={this.addListener}
removeListener={this.removeListener}
- keyserverID={ashoatKeyserverID}
+ keyserverID={authoritativeKeyserverID}
/>
<MessageHandler
addListener={this.addListener}
@@ -491,7 +497,7 @@
cookie,
this.props.urlPrefix,
logInActionSources.socketAuthErrorResolutionAttempt,
- ashoatKeyserverID,
+ authoritativeKeyserverID,
this.props.getInitialNotificationsEncryptedMessage,
);
@@ -509,7 +515,7 @@
error: null,
logInActionSource:
logInActionSources.socketAuthErrorResolutionAttempt,
- keyserverID: ashoatKeyserverID,
+ keyserverID: authoritativeKeyserverID,
},
});
}
@@ -537,7 +543,10 @@
if (!handled && status !== 'disconnected') {
this.props.dispatch({
type: updateConnectionStatusActionType,
- payload: { status: 'disconnected', keyserverID: ashoatKeyserverID },
+ payload: {
+ status: 'disconnected',
+ keyserverID: authoritativeKeyserverID,
+ },
});
}
};
@@ -608,7 +617,7 @@
type: updateLastCommunicatedPlatformDetailsActionType,
payload: {
platformDetails: getConfig().platformDetails,
- keyserverID: ashoatKeyserverID,
+ keyserverID: authoritativeKeyserverID,
},
});
}
@@ -617,7 +626,9 @@
this.props.dispatch({
type: updateActivityActionTypes.success,
payload: {
- activityUpdates: { [ashoatKeyserverID]: queuedActivityUpdates },
+ activityUpdates: {
+ [authoritativeKeyserverID]: queuedActivityUpdates,
+ },
result: activityUpdateMessage.payload,
},
});
@@ -630,7 +641,7 @@
payload: {
...actionPayload,
calendarQuery: sessionState.calendarQuery,
- keyserverID: ashoatKeyserverID,
+ keyserverID: authoritativeKeyserverID,
},
});
if (sessionID !== null && sessionID !== undefined) {
@@ -645,7 +656,7 @@
preRequestUserState: this.initializedWithUserState,
error: null,
logInActionSource: undefined,
- keyserverID: ashoatKeyserverID,
+ keyserverID: authoritativeKeyserverID,
},
});
}
@@ -656,7 +667,7 @@
payload: {
...actionPayload,
calendarQuery: sessionState.calendarQuery,
- keyserverID: ashoatKeyserverID,
+ keyserverID: authoritativeKeyserverID,
},
});
}
@@ -696,7 +707,7 @@
this.props.dispatch({
type: setConnectionIssueActionType,
payload: {
- keyserverID: ashoatKeyserverID,
+ keyserverID: authoritativeKeyserverID,
connectionIssue: 'policy_acknowledgement_socket_crash_loop',
},
});
@@ -721,7 +732,7 @@
this.props.dispatch({
type: setConnectionIssueActionType,
payload: {
- keyserverID: ashoatKeyserverID,
+ keyserverID: authoritativeKeyserverID,
connectionIssue: 'not_logged_in_error',
},
});
@@ -779,7 +790,7 @@
) => {
this.props.dispatch({
type: setLateResponseActionType,
- payload: { messageID, isLate, keyserverID: ashoatKeyserverID },
+ payload: { messageID, isLate, keyserverID: authoritativeKeyserverID },
});
};
@@ -814,7 +825,7 @@
}
this.props.dispatch({
type: unsupervisedBackgroundActionType,
- payload: { keyserverID: ashoatKeyserverID },
+ payload: { keyserverID: authoritativeKeyserverID },
});
return true;
};
diff --git a/lib/socket/update-handler.react.js b/lib/socket/update-handler.react.js
--- a/lib/socket/update-handler.react.js
+++ b/lib/socket/update-handler.react.js
@@ -13,8 +13,8 @@
clientSocketMessageTypes,
} from '../types/socket-types.js';
import { processUpdatesActionType } from '../types/update-types.js';
+import { authoritativeKeyserverID } from '../utils/authoritative-keyserver.js';
import { useSelector, useDispatch } from '../utils/redux-utils.js';
-import { ashoatKeyserverID } from '../utils/validation-utils.js';
type Props = {
+sendMessage: (message: ClientSocketMessageWithoutID) => number,
@@ -26,7 +26,7 @@
const { addListener, removeListener, sendMessage, keyserverID } = props;
const dispatch = useDispatch();
- const connection = useSelector(connectionSelector(ashoatKeyserverID));
+ const connection = useSelector(connectionSelector(authoritativeKeyserverID));
invariant(connection, 'keyserver missing from keyserverStore');
const connectionStatus = connection.status;
const onMessage = React.useCallback(
diff --git a/lib/utils/action-utils.js b/lib/utils/action-utils.js
--- a/lib/utils/action-utils.js
+++ b/lib/utils/action-utils.js
@@ -3,8 +3,8 @@
import invariant from 'invariant';
import * as React from 'react';
+import { authoritativeKeyserverID } from './authoritative-keyserver.js';
import { useSelector, useDispatch } from './redux-utils.js';
-import { ashoatKeyserverID } from './validation-utils.js';
import {
type ServerCallSelectorParams,
useCallKeyserverEndpointContext,
@@ -22,17 +22,18 @@
} = useCallKeyserverEndpointContext();
const cachedNonOverridenBoundServerCall = React.useMemo(
- () => getBoundSingleKeyserverActionFunc(ashoatKeyserverID, serverCall),
+ () =>
+ getBoundSingleKeyserverActionFunc(authoritativeKeyserverID, serverCall),
[getBoundSingleKeyserverActionFunc, serverCall],
);
const customSelector = React.useMemo(
- () => createCallSingleKeyserverEndpointSelector(ashoatKeyserverID),
+ () => createCallSingleKeyserverEndpointSelector(authoritativeKeyserverID),
[createCallSingleKeyserverEndpointSelector],
);
const dispatch = useDispatch();
const serverCallState = useSelector(
- serverCallStateSelector(ashoatKeyserverID),
+ serverCallStateSelector(authoritativeKeyserverID),
);
return React.useMemo(() => {
diff --git a/lib/utils/authoritative-keyserver.js b/lib/utils/authoritative-keyserver.js
new file mode 100644
--- /dev/null
+++ b/lib/utils/authoritative-keyserver.js
@@ -0,0 +1,18 @@
+// @flow
+
+import { getConfig, hasConfig } from './config.js';
+import { ashoatKeyserverID } from './validation-utils.js';
+
+const getAuthoritativeKeyserverID: () => string = () => {
+ if (!hasConfig()) {
+ // When running jest or the keyserver, config is not registered
+ // Keyserver shouldn't use authoritativeKeyserverID,
+ // but keyserver depends on web, which uses authoritativeKeyserverID
+ return ashoatKeyserverID;
+ }
+ return getConfig().authoritativeKeyserverID;
+};
+
+const authoritativeKeyserverID: string = getAuthoritativeKeyserverID();
+
+export { authoritativeKeyserverID };
diff --git a/lib/utils/config.js b/lib/utils/config.js
--- a/lib/utils/config.js
+++ b/lib/utils/config.js
@@ -40,4 +40,8 @@
return registeredConfig;
};
-export { registerConfig, getConfig };
+const hasConfig = (): boolean => {
+ return !!registeredConfig;
+};
+
+export { registerConfig, getConfig, hasConfig };
diff --git a/lib/utils/migration-utils.js b/lib/utils/migration-utils.js
--- a/lib/utils/migration-utils.js
+++ b/lib/utils/migration-utils.js
@@ -2,9 +2,9 @@
import invariant from 'invariant';
+import { authoritativeKeyserverID } from './authoritative-keyserver.js';
import type { TranslatedThreadMessageInfos } from './message-ops-utils.js';
import { entries } from './objects.js';
-import { ashoatKeyserverID } from './validation-utils.js';
import {
convertRawMessageInfoToNewIDSchema,
convertRawThreadInfoToNewIDSchema,
@@ -29,7 +29,10 @@
function convertDraftKeyToNewIDSchema(key: string): string {
const threadID = key.slice(0, -draftKeySuffix.length);
- const convertedThreadID = convertIDToNewSchema(threadID, ashoatKeyserverID);
+ const convertedThreadID = convertIDToNewSchema(
+ threadID,
+ authoritativeKeyserverID,
+ );
return `${convertedThreadID}${draftKeySuffix}`;
}
@@ -62,7 +65,7 @@
): TranslatedThreadMessageInfos {
return Object.fromEntries(
entries(messageStoreThreads).map(([id, translatedThreadMessageInfo]) => [
- `${ashoatKeyserverID}|` + id,
+ `${authoritativeKeyserverID}|` + id,
translatedThreadMessageInfo,
]),
);
@@ -78,7 +81,7 @@
`threadInfo during ID schema migration shouldn't be minimallyEncoded`,
);
return [
- `${ashoatKeyserverID}|` + id,
+ `${authoritativeKeyserverID}|` + id,
convertRawThreadInfoToNewIDSchema(threadInfo),
];
}),
diff --git a/lib/utils/reducers-utils.test.js b/lib/utils/reducers-utils.test.js
--- a/lib/utils/reducers-utils.test.js
+++ b/lib/utils/reducers-utils.test.js
@@ -1,8 +1,8 @@
// @flow
+import { authoritativeKeyserverID } from './authoritative-keyserver.js';
import { defaultNotifPermissionAlertInfo } from './push-alerts.js';
import { resetUserSpecificState } from './reducers-utils.js';
-import { ashoatKeyserverID } from './validation-utils.js';
import { defaultWebEnabledApps } from '../types/enabled-apps.js';
import { defaultCalendarFilters } from '../types/filter-types.js';
import { defaultKeyserverInfo } from '../types/keyserver-types.js';
@@ -36,7 +36,7 @@
messages: {},
threads: {},
local: {},
- currentAsOf: { [ashoatKeyserverID]: 0 },
+ currentAsOf: { [authoritativeKeyserverID]: 0 },
},
windowActive: true,
pushApiPublicKey: null,
@@ -71,7 +71,7 @@
communityPickerStore: { chat: null, calendar: null },
keyserverStore: {
keyserverInfos: {
- [ashoatKeyserverID]: defaultKeyserverInfo('url'),
+ [authoritativeKeyserverID]: defaultKeyserverInfo('url'),
},
},
threadActivityStore: {},

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 23, 2:53 PM (19 h, 18 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2571192
Default Alt Text
D11006.id36929.diff (39 KB)

Event Timeline