Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3376192
D8196.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
10 KB
Referenced Files
None
Subscribers
None
D8196.diff
View Options
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,7 +7,10 @@
logInActionSources,
} from '../types/account-types.js';
import type { SIWEAuthServerCall } from '../types/siwe-types.js';
-import type { CallServerEndpoint } from '../utils/call-server-endpoint.js';
+import type {
+ CallServerEndpoint,
+ CallServerEndpointOptions,
+} from '../utils/call-server-endpoint.js';
import { getConfig } from '../utils/config.js';
const getSIWENonceActionTypes = Object.freeze({
@@ -31,8 +34,11 @@
const siweAuth =
(
callServerEndpoint: CallServerEndpoint,
- ): ((siweAuthPayload: SIWEAuthServerCall) => Promise<LogInResult>) =>
- async siweAuthPayload => {
+ ): ((
+ siweAuthPayload: SIWEAuthServerCall,
+ options?: ?CallServerEndpointOptions,
+ ) => Promise<LogInResult>) =>
+ async (siweAuthPayload, options) => {
const watchedIDs = threadWatcher.getWatchedIDs();
const response = await callServerEndpoint(
'siwe_auth',
@@ -41,7 +47,10 @@
watchedIDs,
platformDetails: getConfig().platformDetails,
},
- siweAuthCallServerEndpointOptions,
+ {
+ ...siweAuthCallServerEndpointOptions,
+ ...options,
+ },
);
const userInfos = mergeUserInfos(
response.userInfos,
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
@@ -31,7 +31,10 @@
SubscriptionUpdateResult,
} from '../types/subscription-types.js';
import type { UserInfo, PasswordUpdate } from '../types/user-types.js';
-import type { CallServerEndpoint } from '../utils/call-server-endpoint.js';
+import type {
+ CallServerEndpoint,
+ CallServerEndpointOptions,
+} from '../utils/call-server-endpoint.js';
import { getConfig } from '../utils/config.js';
import sleep from '../utils/sleep.js';
@@ -85,15 +88,21 @@
const register =
(
callServerEndpoint: CallServerEndpoint,
- ): ((registerInfo: RegisterInfo) => Promise<RegisterResult>) =>
- async registerInfo => {
+ ): ((
+ registerInfo: RegisterInfo,
+ options?: CallServerEndpointOptions,
+ ) => Promise<RegisterResult>) =>
+ async (registerInfo, options) => {
const response = await callServerEndpoint(
'create_account',
{
...registerInfo,
platformDetails: getConfig().platformDetails,
},
- registerCallServerEndpointOptions,
+ {
+ ...registerCallServerEndpointOptions,
+ ...options,
+ },
);
return {
currentUserInfo: response.currentUserInfo,
@@ -268,9 +277,15 @@
const getOlmSessionInitializationData =
(
callServerEndpoint: CallServerEndpoint,
- ): (() => Promise<GetOlmSessionInitializationDataResponse>) =>
- async () => {
- return await callServerEndpoint('get_olm_session_initialization_data', {});
+ ): ((
+ options?: ?CallServerEndpointOptions,
+ ) => Promise<GetOlmSessionInitializationDataResponse>) =>
+ async options => {
+ return await callServerEndpoint(
+ 'get_olm_session_initialization_data',
+ {},
+ options,
+ );
};
const policyAcknowledgmentActionTypes = Object.freeze({
diff --git a/lib/utils/call-server-endpoint.js b/lib/utils/call-server-endpoint.js
--- a/lib/utils/call-server-endpoint.js
+++ b/lib/utils/call-server-endpoint.js
@@ -37,6 +37,8 @@
+onProgress: (percent: number) => void,
// abortHandler will receive an abort function once the upload starts
+abortHandler: (abort: () => void) => void,
+ // Overrides urlPrefix in Redux
+ +urlPrefixOverride: string,
}>;
export type CallServerEndpointResultInfoInterface = 'socket' | 'REST';
@@ -121,7 +123,8 @@
throw new SocketOffline('socket_offline');
}
- const url = urlPrefix ? `${urlPrefix}/${endpoint}` : endpoint;
+ const resolvedURLPrefix = options?.urlPrefixOverride ?? urlPrefix;
+ const url = resolvedURLPrefix ? `${resolvedURLPrefix}/${endpoint}` : endpoint;
let json;
if (options && options.blobUpload) {
diff --git a/native/account/registration/registration-server-call.js b/native/account/registration/registration-server-call.js
--- a/native/account/registration/registration-server-call.js
+++ b/native/account/registration/registration-server-call.js
@@ -65,15 +65,23 @@
const callRegister = useServerCall(register);
const registerUsernameAccount = React.useCallback(
- async (accountSelection: UsernameAccountSelection) => {
+ async (
+ accountSelection: UsernameAccountSelection,
+ keyserverURL: string,
+ ) => {
const extraInfo = await logInExtraInfo();
const registerPromise = (async () => {
try {
- const result = await callRegister({
- ...extraInfo,
- username: accountSelection.username,
- password: accountSelection.password,
- });
+ const result = await callRegister(
+ {
+ ...extraInfo,
+ username: accountSelection.username,
+ password: accountSelection.password,
+ },
+ {
+ urlPrefixOverride: keyserverURL,
+ },
+ );
await setNativeCredentials({
username: result.currentUserInfo.username,
password: accountSelection.password,
@@ -135,11 +143,13 @@
if (currentStep.step !== 'inactive') {
return;
}
- const { accountSelection, avatarData } = input;
+ const { accountSelection, avatarData, keyserverURL } = input;
if (accountSelection.accountType === 'username') {
- await registerUsernameAccount(accountSelection);
+ await registerUsernameAccount(accountSelection, keyserverURL);
} else {
- await siweServerCall(accountSelection);
+ await siweServerCall(accountSelection, {
+ urlPrefixOverride: keyserverURL,
+ });
}
setCurrentStep({
step: 'waiting_for_registration_call',
diff --git a/native/account/siwe-hooks.js b/native/account/siwe-hooks.js
--- a/native/account/siwe-hooks.js
+++ b/native/account/siwe-hooks.js
@@ -8,6 +8,7 @@
useServerCall,
useDispatchActionPromise,
} from 'lib/utils/action-utils.js';
+import type { CallServerEndpointOptions } from 'lib/utils/call-server-endpoint.js';
import { NavContext } from '../navigation/navigation-context.js';
import { useSelector } from '../redux/redux-utils.js';
@@ -24,19 +25,22 @@
};
function useSIWEServerCall(
params: UseSIWEServerCallParams,
-): SIWEServerCallParams => Promise<void> {
+): (SIWEServerCallParams, ?CallServerEndpointOptions) => Promise<void> {
const { onFailure } = params;
const siweAuthCall = useServerCall(siweAuth);
const callSIWE = React.useCallback(
- async (message, signature, extraInfo) => {
+ async (message, signature, extraInfo, options) => {
try {
- return await siweAuthCall({
- message,
- signature,
- ...extraInfo,
- });
+ return await siweAuthCall(
+ {
+ message,
+ signature,
+ ...extraInfo,
+ },
+ options,
+ );
} catch (e) {
onFailure();
throw e;
@@ -58,15 +62,20 @@
const dispatchActionPromise = useDispatchActionPromise();
return React.useCallback(
- async ({ message, signature }) => {
+ async ({ message, signature }, options) => {
const extraInfo = await logInExtraInfo();
const initialNotificationsEncryptedMessage =
- await getInitialNotificationsEncryptedMessage();
+ await getInitialNotificationsEncryptedMessage(options);
- const siwePromise = callSIWE(message, signature, {
- ...extraInfo,
- initialNotificationsEncryptedMessage,
- });
+ const siwePromise = callSIWE(
+ message,
+ signature,
+ {
+ ...extraInfo,
+ initialNotificationsEncryptedMessage,
+ },
+ options,
+ );
dispatchActionPromise(
siweAuthActionTypes,
diff --git a/native/utils/crypto-utils.js b/native/utils/crypto-utils.js
--- a/native/utils/crypto-utils.js
+++ b/native/utils/crypto-utils.js
@@ -10,38 +10,46 @@
useServerCall,
useDispatchActionPromise,
} from 'lib/utils/action-utils.js';
+import type { CallServerEndpointOptions } from 'lib/utils/call-server-endpoint.js';
import { commCoreModule } from '../native-modules.js';
-function useInitialNotificationsEncryptedMessage(): () => Promise<string> {
+function useInitialNotificationsEncryptedMessage(): (
+ callServerEndpointOptions?: ?CallServerEndpointOptions,
+) => Promise<string> {
const callGetOlmSessionInitializationData = useServerCall(
getOlmSessionInitializationData,
);
const dispatchActionPromise = useDispatchActionPromise();
- return React.useCallback(async () => {
- const olmSessionDataPromise = callGetOlmSessionInitializationData();
-
- dispatchActionPromise(
- getOlmSessionInitializationDataActionTypes,
- olmSessionDataPromise,
- );
-
- const { signedIdentityKeysBlob, notifInitializationInfo } =
- await olmSessionDataPromise;
-
- const { notificationIdentityPublicKeys } = JSON.parse(
- signedIdentityKeysBlob.payload,
- );
-
- const { prekey, prekeySignature, oneTimeKey } = notifInitializationInfo;
- return await commCoreModule.initializeNotificationsSession(
- JSON.stringify(notificationIdentityPublicKeys),
- prekey,
- prekeySignature,
- oneTimeKey,
- );
- }, [callGetOlmSessionInitializationData, dispatchActionPromise]);
+ return React.useCallback(
+ async callServerEndpointOptions => {
+ const olmSessionDataPromise = callGetOlmSessionInitializationData(
+ callServerEndpointOptions,
+ );
+
+ dispatchActionPromise(
+ getOlmSessionInitializationDataActionTypes,
+ olmSessionDataPromise,
+ );
+
+ const { signedIdentityKeysBlob, notifInitializationInfo } =
+ await olmSessionDataPromise;
+
+ const { notificationIdentityPublicKeys } = JSON.parse(
+ signedIdentityKeysBlob.payload,
+ );
+
+ const { prekey, prekeySignature, oneTimeKey } = notifInitializationInfo;
+ return await commCoreModule.initializeNotificationsSession(
+ JSON.stringify(notificationIdentityPublicKeys),
+ prekey,
+ prekeySignature,
+ oneTimeKey,
+ );
+ },
+ [callGetOlmSessionInitializationData, dispatchActionPromise],
+ );
}
export { useInitialNotificationsEncryptedMessage };
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Nov 27, 10:34 PM (21 h, 46 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2591946
Default Alt Text
D8196.diff (10 KB)
Attached To
Mode
D8196: [native] Part 2: use user's keyserver selection in registration flow
Attached
Detach File
Event Timeline
Log In to Comment