Page MenuHomePhabricator

D11006.diff
No OneTemporary

D11006.diff

diff --git a/lib/actions/link-actions.js b/lib/actions/link-actions.js
--- a/lib/actions/link-actions.js
+++ b/lib/actions/link-actions.js
@@ -12,10 +12,10 @@
DisableInviteLinkRequest,
DisableInviteLinkPayload,
} from '../types/link-types.js';
+import { authoritativeKeyserverID } from '../utils/authoritative-keyserver.js';
import type { CallSingleKeyserverEndpoint } from '../utils/call-single-keyserver-endpoint.js';
import { useKeyserverCall } from '../utils/keyserver-call.js';
import { useSelector } from '../utils/redux-utils.js';
-import { ashoatKeyserverID } from '../utils/validation-utils.js';
const verifyInviteLinkActionTypes = Object.freeze({
started: 'VERIFY_INVITE_LINK_STARTED',
@@ -58,7 +58,8 @@
): (
request: InviteLinkVerificationRequest,
) => Promise<InviteLinkVerificationResponse> {
- const keyserverID = keyserverOverride?.keyserverID ?? ashoatKeyserverID;
+ const keyserverID =
+ keyserverOverride?.keyserverID ?? authoritativeKeyserverID();
const isKeyserverKnown = useSelector(
state => !!state.keyserverStore.keyserverInfos[keyserverID],
);
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,
};
};
@@ -547,7 +547,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(
@@ -622,14 +622,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;
@@ -166,7 +166,7 @@
e,
);
- if (!dataLoaded && keyserverID === ashoatKeyserverID) {
+ if (!dataLoaded && keyserverID === authoritativeKeyserverID()) {
await dispatchActionPromise(logOutActionTypes, callLogOut());
}
} finally {
@@ -224,7 +224,7 @@
cancelPendingAuth.current = cancel;
}, [authInProgress, hasAccessToken, isUserAuthenticated, performAuth]);
- if (keyserverID !== ashoatKeyserverID) {
+ if (keyserverID !== authoritativeKeyserverID()) {
return null;
}
return <Socket {...socketProps} />;
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,14 @@
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 +24,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
@@ -47,11 +47,11 @@
} 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 { getMessageForException } from '../utils/errors.js';
import { assertObjectsAreEqual } from '../utils/objects.js';
import { setURLPrefix } from '../utils/url-utils.js';
-import { ashoatKeyserverID } from '../utils/validation-utils.js';
function assertKeyserverStoresAreEqual(
processedKeyserverStore: KeyserverInfos,
@@ -304,9 +304,9 @@
const operation: ReplaceKeyserverOperation = {
type: 'replace_keyserver',
payload: {
- id: ashoatKeyserverID,
+ id: authoritativeKeyserverID(),
keyserverInfo: {
- ...state.keyserverInfos[ashoatKeyserverID],
+ ...state.keyserverInfos[authoritativeKeyserverID()],
urlPrefix: action.payload,
},
},
@@ -335,9 +335,9 @@
const operation: ReplaceKeyserverOperation = {
type: 'replace_keyserver',
payload: {
- id: ashoatKeyserverID,
+ id: authoritativeKeyserverID(),
keyserverInfo: {
- ...state.keyserverInfos[ashoatKeyserverID],
+ ...state.keyserverInfos[authoritativeKeyserverID()],
lastCommunicatedPlatformDetails: getConfig().platformDetails,
},
},
@@ -455,16 +455,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,
@@ -487,14 +488,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/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/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,20 @@
+// @flow
+
+import invariant from 'invariant';
+
+import { getConfig, hasConfig } from './config.js';
+import { ashoatKeyserverID } from './validation-utils.js';
+
+const authoritativeKeyserverID: () => string = () => {
+ invariant(
+ !process.env['KEYSERVER'],
+ 'keyserver should not use authoritativeKeyserverID',
+ );
+ if (!hasConfig()) {
+ // When running jest, config is not registered
+ return ashoatKeyserverID;
+ }
+ return getConfig().authoritativeKeyserverID;
+};
+
+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/keyserver-store-utils.js b/lib/utils/keyserver-store-utils.js
--- a/lib/utils/keyserver-store-utils.js
+++ b/lib/utils/keyserver-store-utils.js
@@ -1,14 +1,14 @@
// @flow
-import { ashoatKeyserverID } from './validation-utils.js';
+import { authoritativeKeyserverID } from './authoritative-keyserver.js';
import type { KeyserverStore } from '../types/keyserver-types.js';
function wipeKeyserverStore(oldStore: KeyserverStore): KeyserverStore {
const keyserverInfos = {
- [ashoatKeyserverID]: {
- ...oldStore.keyserverInfos[ashoatKeyserverID],
+ [authoritativeKeyserverID()]: {
+ ...oldStore.keyserverInfos[authoritativeKeyserverID()],
connection: {
- ...oldStore.keyserverInfos[ashoatKeyserverID].connection,
+ ...oldStore.keyserverInfos[authoritativeKeyserverID()].connection,
connectionIssue: null,
queuedActivityUpdates: [],
lateResponses: [],
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
Tue, Nov 26, 6:52 PM (20 h, 55 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2585811
Default Alt Text
D11006.diff (30 KB)

Event Timeline