Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3386566
D5603.id18337.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D5603.id18337.diff
View Options
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
@@ -7,6 +7,8 @@
LogInResult,
RegisterResult,
RegisterInfo,
+ SIWEServerCall,
+ SIWEResult,
UpdateUserSettingsRequest,
} from '../types/account-types';
import type { GetSessionPublicKeysArgs } from '../types/request-types';
@@ -91,6 +93,31 @@
};
};
+const siweActionTypes = Object.freeze({
+ started: 'SIWE_STARTED',
+ success: 'SIWE_SUCCESS',
+ failed: 'SIWE_FAILED',
+});
+const siwe = (
+ callServerEndpoint: CallServerEndpoint,
+): ((siweInfo: SIWEServerCall) => Promise<SIWEResult>) => async siweInfo => {
+ const response = await callServerEndpoint(
+ 'siwe',
+ {
+ ...siweInfo,
+ platformDetails: getConfig().platformDetails,
+ },
+ registerCallServerEndpointOptions,
+ );
+ return {
+ currentUserInfo: response.currentUserInfo,
+ rawMessageInfos: response.rawMessageInfos,
+ threadInfos: response.cookieChange.threadInfos,
+ userInfos: response.cookieChange.userInfos,
+ calendarQuery: siweInfo.calendarQuery,
+ };
+};
+
function mergeUserInfos(...userInfoArrays: UserInfo[][]): UserInfo[] {
const merged = {};
for (const userInfoArray of userInfoArrays) {
@@ -238,6 +265,8 @@
searchUsersActionTypes,
setUserSettings,
setUserSettingsActionTypes,
+ siwe,
+ siweActionTypes,
updateSubscription,
updateSubscriptionActionTypes,
};
diff --git a/lib/types/account-types.js b/lib/types/account-types.js
--- a/lib/types/account-types.js
+++ b/lib/types/account-types.js
@@ -140,6 +140,24 @@
+logInActionSource: LogInActionSource,
};
+export type SIWERequest = {
+ +address: string,
+ +message: string,
+ +signature: string,
+};
+
+export type SIWEServerCall = {
+ ...SIWERequest,
+ ...LogInExtraInfo,
+};
+
+export type SIWEResponse = {
+ ...RegisterResponse,
+};
+
+export type SIWEResult = {
+ ...RegisterResult,
+};
export type UpdatePasswordRequest = {
code: string,
password: string,
diff --git a/lib/types/endpoints.js b/lib/types/endpoints.js
--- a/lib/types/endpoints.js
+++ b/lib/types/endpoints.js
@@ -24,6 +24,7 @@
CREATE_ACCOUNT: 'create_account',
LOG_IN: 'log_in',
UPDATE_PASSWORD: 'update_password',
+ SIWE: 'siwe',
});
type SessionChangingEndpoint = $Values<typeof sessionChangingEndpoints>;
diff --git a/lib/types/redux-types.js b/lib/types/redux-types.js
--- a/lib/types/redux-types.js
+++ b/lib/types/redux-types.js
@@ -7,6 +7,7 @@
LogInResult,
RegisterResult,
DefaultNotificationPayload,
+ SIWEResult,
} from './account-types';
import type {
ActivityUpdateSuccessPayload,
@@ -818,6 +819,22 @@
+error: true,
+payload: Error,
+loadingInfo: LoadingInfo,
+ }
+ | {
+ +type: 'SIWE_STARTED',
+ +payload?: void,
+ +loadingInfo: LoadingInfo,
+ }
+ | {
+ +type: 'SIWE_SUCCESS',
+ +payload: SIWEResult,
+ +loadingInfo: LoadingInfo,
+ }
+ | {
+ +type: 'SIWE_FAILED',
+ +error: true,
+ +payload: Error,
+ +loadingInfo: LoadingInfo,
};
export type ActionPayload = ?(Object | Array<*> | $ReadOnlyArray<*> | string);
diff --git a/native/account/siwe-panel.react.js b/native/account/siwe-panel.react.js
--- a/native/account/siwe-panel.react.js
+++ b/native/account/siwe-panel.react.js
@@ -3,11 +3,11 @@
import Animated from 'react-native-reanimated';
import WebView from 'react-native-webview';
-import { registerActionTypes, register } from 'lib/actions/user-actions';
+import { siweActionTypes, siwe } from 'lib/actions/user-actions';
import type {
- RegisterInfo,
+ SIWEServerCall,
+ SIWEResult,
LogInExtraInfo,
- RegisterResult,
LogInStartingPayload,
} from 'lib/types/account-types';
import {
@@ -35,23 +35,24 @@
// Redux dispatch functions
+dispatchActionPromise: DispatchActionPromise,
// async functions that hit server APIs
- +registerAction: (registerInfo: RegisterInfo) => Promise<RegisterResult>,
+ +siweAction: (siweInfo: SIWEServerCall) => Promise<SIWEResult>,
};
function SIWEPanel({
logInExtraInfo,
dispatchActionPromise,
- registerAction,
+ siweAction,
}: Props) {
const handleSIWE = React.useCallback(
- ({ address, signature }) => {
+ ({ address, message, signature }) => {
// this is all mocked from register-panel
const extraInfo = logInExtraInfo();
dispatchActionPromise(
- registerActionTypes,
- registerAction({
- username: address,
- password: signature,
+ siweActionTypes,
+ siweAction({
+ address,
+ message,
+ signature,
...extraInfo,
}),
undefined,
@@ -59,16 +60,16 @@
);
setNativeCredentials({ username: address, password: signature });
},
- [logInExtraInfo, dispatchActionPromise, registerAction],
+ [logInExtraInfo, dispatchActionPromise, siweAction],
);
const handleMessage = React.useCallback(
event => {
const {
nativeEvent: { data },
} = event;
- const { address, signature } = JSON.parse(data);
+ const { address, message, signature } = JSON.parse(data);
if (address && signature) {
- handleSIWE({ address, signature });
+ handleSIWE({ address, message, signature });
}
},
[handleSIWE],
@@ -87,14 +88,14 @@
);
const dispatchActionPromise = useDispatchActionPromise();
- const callRegister = useServerCall(register);
+ const callSiwe = useServerCall(siwe);
return (
<SIWEPanel
{...props}
logInExtraInfo={logInExtraInfo}
dispatchActionPromise={dispatchActionPromise}
- registerAction={callRegister}
+ siweAction={callSiwe}
/>
);
},
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 30, 5:05 AM (19 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2599711
Default Alt Text
D5603.id18337.diff (5 KB)
Attached To
Mode
D5603: [keyserver/types] SIWE endpoint: types & native server call
Attached
Detach File
Event Timeline
Log In to Comment