Page MenuHomePhabricator

D5634.id18586.diff
No OneTemporary

D5634.id18586.diff

diff --git a/keyserver/src/creators/account-creator.js b/keyserver/src/creators/account-creator.js
--- a/keyserver/src/creators/account-creator.js
+++ b/keyserver/src/creators/account-creator.js
@@ -71,7 +71,7 @@
WHERE LCASE(username) = LCASE(${request.username})
`;
const promises = [dbQuery(usernameQuery)];
- const { calendarQuery } = request;
+ const { calendarQuery, publicKey, socialProof } = request;
if (calendarQuery) {
promises.push(verifyCalendarQueryThreadIDs(calendarQuery));
}
@@ -103,6 +103,8 @@
createNewUserCookie(id, {
platformDetails: request.platformDetails,
deviceToken,
+ publicKey,
+ socialProof,
}),
deleteCookie(viewer.cookieID),
dbQuery(newUserQuery),
diff --git a/keyserver/src/responders/user-responders.js b/keyserver/src/responders/user-responders.js
--- a/keyserver/src/responders/user-responders.js
+++ b/keyserver/src/responders/user-responders.js
@@ -201,7 +201,7 @@
const calendarQuery = request.calendarQuery
? normalizeCalendarQuery(request.calendarQuery)
: null;
-
+ const { publicKey, socialProof } = request;
const newServerTime = Date.now();
const deviceToken = request.deviceTokenUpdateRequest
? request.deviceTokenUpdateRequest.deviceToken
@@ -210,6 +210,8 @@
createNewUserCookie(userId, {
platformDetails: request.platformDetails,
deviceToken,
+ publicKey,
+ socialProof,
}),
deleteCookie(viewer.cookieID),
]);
diff --git a/keyserver/src/session/cookies.js b/keyserver/src/session/cookies.js
--- a/keyserver/src/session/cookies.js
+++ b/keyserver/src/session/cookies.js
@@ -644,6 +644,8 @@
type UserCookieCreationParams = {
platformDetails: PlatformDetails,
deviceToken?: ?string,
+ publicKey?: ?string,
+ socialProof?: ?string,
};
// The result of this function should never be passed directly to the Viewer
@@ -657,7 +659,7 @@
userID: string,
params: UserCookieCreationParams,
): Promise<UserViewerData> {
- const { platformDetails, deviceToken } = params;
+ const { platformDetails, deviceToken, publicKey, socialProof } = params;
const { platform, ...versions } = platformDetails || defaultPlatformDetails;
const versionsString =
Object.keys(versions).length > 0 ? JSON.stringify(versions) : null;
@@ -679,10 +681,12 @@
time,
deviceToken,
versionsString,
+ publicKey,
+ socialProof,
];
const query = SQL`
INSERT INTO cookies(id, hash, user, platform, creation_time, last_used,
- device_token, versions)
+ device_token, versions, public_key, social_proof)
VALUES ${[cookieRow]}
`;
await dbQuery(query);
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
@@ -51,6 +51,8 @@
+deviceTokenUpdateRequest?: ?DeviceTokenUpdateRequest,
+platformDetails: PlatformDetails,
+address?: ?string,
+ +publicKey?: ?string,
+ +socialProof?: ?string,
};
export type RegisterResponse = {
@@ -116,6 +118,8 @@
+platformDetails: PlatformDetails,
+watchedIDs: $ReadOnlyArray<string>,
+source?: LogInActionSource,
+ +publicKey?: ?string,
+ +socialProof?: ?string,
};
export type LogInResponse = {
@@ -149,12 +153,16 @@
+deviceTokenUpdateRequest?: ?DeviceTokenUpdateRequest,
+platformDetails: PlatformDetails,
+watchedIDs: $ReadOnlyArray<string>,
+ +publicKey?: ?string,
+ +socialProof?: ?string,
};
export type SIWEServerCall = {
- +address: string,
- +message: string,
- +signature: string,
+ address: string,
+ message: string,
+ signature: string,
+ publicKey: string,
+ socialProof?: ?string,
...LogInExtraInfo,
};
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
@@ -16,11 +16,11 @@
type DispatchActionPromise,
} from 'lib/utils/action-utils';
+import { commCoreModule } from '../native-modules';
import { NavContext } from '../navigation/navigation-context';
import { useSelector } from '../redux/redux-utils';
import { nativeLogInExtraInfoSelector } from '../selectors/account-selectors';
import { defaultLandingURLPrefix } from '../utils/url-utils';
-
const commSIWE = `${defaultLandingURLPrefix}/siwe`;
type BaseProps = {
@@ -43,15 +43,17 @@
siweAction,
}: Props) {
const handleSIWE = React.useCallback(
- ({ address, message, signature }) => {
- // this is all mocked from register-panel
+ async ({ address, message, signature }) => {
const extraInfo = logInExtraInfo();
+ await commCoreModule.initializeCryptoAccount(address);
+ const { ed25519 } = await commCoreModule.getUserPublicKey();
dispatchActionPromise(
siweActionTypes,
siweAction({
address,
message,
signature,
+ publicKey: ed25519,
...extraInfo,
}),
undefined,
diff --git a/native/schema/CommCoreModuleSchema.js b/native/schema/CommCoreModuleSchema.js
--- a/native/schema/CommCoreModuleSchema.js
+++ b/native/schema/CommCoreModuleSchema.js
@@ -18,6 +18,10 @@
+key: string,
+text: string,
};
+type ClientPublicKeys = {
+ +curve25519: string,
+ +ed25519: string,
+};
export interface Spec extends TurboModule {
+getDraft: (key: string) => Promise<string>;
@@ -42,7 +46,7 @@
operations: $ReadOnlyArray<ClientDBThreadStoreOperation>,
) => void;
+initializeCryptoAccount: (userId: string) => Promise<string>;
- +getUserPublicKey: () => Promise<string>;
+ +getUserPublicKey: () => Promise<ClientPublicKeys>;
+getUserOneTimeKeys: () => Promise<string>;
+openSocket: (endpoint: string) => Object;
+getCodeVersion: () => number;

File Metadata

Mime Type
text/plain
Expires
Wed, Nov 27, 6:03 AM (20 h, 19 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2588377
Default Alt Text
D5634.id18586.diff (5 KB)

Event Timeline