diff --git a/keyserver/addons/rust-node-addon/rust-binding-types.js b/keyserver/addons/rust-node-addon/rust-binding-types.js --- a/keyserver/addons/rust-node-addon/rust-binding-types.js +++ b/keyserver/addons/rust-node-addon/rust-binding-types.js @@ -15,34 +15,12 @@ publish(toDeviceId: string, payload: string): Promise; } -type UserComparisonResult = { - +usersMissingFromKeyserver: $ReadOnlyArray, - +usersMissingFromIdentity: $ReadOnlyArray, -}; - type RustNativeBindingAPI = { +registerUser: ( username: string, password: string, signedIdentityKeysBlob: SignedIdentityKeysBlob, ) => Promise, - +loginUserPake: ( - userId: string, - signingPublicKey: string, - password: string, - sessionInitializationInfo: SignedIdentityKeysBlob, - ) => Promise, - +loginUserWallet: ( - siweMessage: string, - siweSignature: string, - signedIdentityKeysBlob: SignedIdentityKeysBlob, - socialProof: ?string, - ) => Promise, - +deleteUser: (userId: string) => Promise, - +updateUser: (userId: string, password: string) => Promise, - +compareUsers: ( - userIds: $ReadOnlyArray, - ) => Promise, +TunnelbrokerClient: Class, }; 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 @@ -1,7 +1,6 @@ // @flow import invariant from 'invariant'; -import { getRustAPI } from 'rust-node-addon'; import bcrypt from 'twin-bcrypt'; import ashoat from 'lib/facts/ashoat.js'; @@ -46,7 +45,6 @@ fetchKnownUserInfos, } from '../fetchers/user-fetchers.js'; import { verifyCalendarQueryThreadIDs } from '../responders/entry-responders.js'; -import { handleAsyncPromise } from '../responders/handlers.js'; import { createNewUserCookie, setNewSession } from '../session/cookies.js'; import { createScriptViewer } from '../session/scripts.js'; import type { Viewer } from '../session/viewer.js'; @@ -193,19 +191,6 @@ ...messageInfos, ]; - if (signedIdentityKeysBlob) { - handleAsyncPromise( - (async () => { - const rustAPI = await getRustAPI(); - await rustAPI.registerUser( - request.username, - request.password, - signedIdentityKeysBlob, - ); - })(), - ); - } - return { id, rawMessageInfos, diff --git a/keyserver/src/cron/compare-users.js b/keyserver/src/cron/compare-users.js deleted file mode 100644 --- a/keyserver/src/cron/compare-users.js +++ /dev/null @@ -1,41 +0,0 @@ -// @flow -import { getRustAPI } from 'rust-node-addon'; - -import { deleteCookies } from '../deleters/cookie-deleters.js'; -import { fetchCookieIDsToInvalidateToPopulateIdentityService } from '../fetchers/cookie-fetchers.js'; -import { fetchAllUserIDs } from '../fetchers/user-fetchers.js'; - -async function compareMySQLUsersToIdentityService(): Promise { - const [allUserIDs, rustAPI] = await Promise.all([ - fetchAllUserIDs(), - getRustAPI(), - ]); - const userComparisonResult = await rustAPI.compareUsers(allUserIDs); - const { usersMissingFromKeyserver, usersMissingFromIdentity } = - userComparisonResult; - - if (usersMissingFromKeyserver.length > 0) { - console.warn( - "found users in identity service that aren't in MySQL! " + - JSON.stringify(usersMissingFromKeyserver), - ); - } - if (usersMissingFromIdentity.length === 0) { - return; - } - const cookieIDs = await fetchCookieIDsToInvalidateToPopulateIdentityService( - usersMissingFromIdentity, - ); - if (cookieIDs.length === 0) { - return; - } - - // By deleting a cookie associated with a user's device, we trigger an - // auto-log-in from that device, which lets us access the user's password. We - // need the password in order to double-write user data to the identity - // service. We only delete cookies associated with native devices because we - // don't cache passwords on other platforms. - await deleteCookies(cookieIDs); -} - -export { compareMySQLUsersToIdentityService }; diff --git a/keyserver/src/cron/cron.js b/keyserver/src/cron/cron.js --- a/keyserver/src/cron/cron.js +++ b/keyserver/src/cron/cron.js @@ -4,7 +4,6 @@ import schedule from 'node-schedule'; import { backupDB } from './backups.js'; -import { compareMySQLUsersToIdentityService } from './compare-users.js'; import { createDailyUpdatesThread } from './daily-updates.js'; import { updateAndReloadGeoipDB } from './update-geoip-db.js'; import { deleteOrphanedActivity } from '../deleters/activity-deleters.js'; @@ -91,18 +90,4 @@ } }, ); - schedule.scheduleJob( - '0 5 * * *', // every day at 5:00 AM in the keyserver's timezone - async () => { - try { - await compareMySQLUsersToIdentityService(); - } catch (e) { - console.warn( - 'encountered error while trying to compare users table with ' + - 'identity service', - e, - ); - } - }, - ); } diff --git a/keyserver/src/deleters/account-deleters.js b/keyserver/src/deleters/account-deleters.js --- a/keyserver/src/deleters/account-deleters.js +++ b/keyserver/src/deleters/account-deleters.js @@ -1,6 +1,5 @@ // @flow -import { getRustAPI } from 'rust-node-addon'; import bcrypt from 'twin-bcrypt'; import type { @@ -101,12 +100,6 @@ }); } const { anonymousViewerData } = await promiseAll(promises); - handleAsyncPromise( - (async () => { - const rustAPI = await getRustAPI(); - await rustAPI.deleteUser(deletedUserID); - })(), - ); if (anonymousViewerData) { viewer.setNewCookie(anonymousViewerData); } 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 @@ -2,7 +2,6 @@ import type { Utility as OlmUtility } from '@commapp/olm'; import invariant from 'invariant'; -import { getRustAPI } from 'rust-node-addon'; import { ErrorTypes, SiweMessage } from 'siwe'; import t from 'tcomb'; import bcrypt from 'twin-bcrypt'; @@ -75,7 +74,6 @@ normalizeCalendarQuery, verifyCalendarQueryThreadIDs, } from './entry-responders.js'; -import { handleAsyncPromise } from './handlers.js'; import { createAccount, processSIWEAccountCreation, @@ -431,33 +429,6 @@ const id = userRow.id.toString(); - if (identityKeys && signedIdentityKeysBlob) { - const constIdentityKeys = identityKeys; - handleAsyncPromise( - (async () => { - const rustAPI = await getRustAPI(); - try { - await rustAPI.loginUserPake( - id, - constIdentityKeys.primaryIdentityPublicKeys.ed25519, - request.password, - signedIdentityKeysBlob, - ); - } catch (e) { - if (e.code === 'InvalidArg' && e.message === 'user not found') { - await rustAPI.registerUser( - username, - request.password, - signedIdentityKeysBlob, - ); - } else { - throw e; - } - } - })(), - ); - } - return await processSuccessfulLogin({ viewer, input, @@ -591,22 +562,7 @@ ); } - // 9. Try to double-write SIWE account info to the Identity service. - if (identityKeys && signedIdentityKeysBlob) { - handleAsyncPromise( - (async () => { - const rustAPI = await getRustAPI(); - await rustAPI.loginUserWallet( - siweMessage.toMessage(), - signature, - signedIdentityKeysBlob, - JSON.stringify(socialProof), - ); - })(), - ); - } - - // 10. Complete login with call to `processSuccessfulLogin(...)`. + // 9. Complete login with call to `processSuccessfulLogin(...)`. return await processSuccessfulLogin({ viewer, input, diff --git a/keyserver/src/updaters/account-updaters.js b/keyserver/src/updaters/account-updaters.js --- a/keyserver/src/updaters/account-updaters.js +++ b/keyserver/src/updaters/account-updaters.js @@ -1,6 +1,5 @@ // @flow -import { getRustAPI } from 'rust-node-addon'; import bcrypt from 'twin-bcrypt'; import type { @@ -19,7 +18,6 @@ import { createUpdates } from '../creators/update-creator.js'; import { dbQuery, SQL } from '../database/database.js'; -import { handleAsyncPromise } from '../responders/handlers.js'; import type { Viewer } from '../session/viewer.js'; async function accountUpdater( @@ -54,12 +52,6 @@ UPDATE users SET ${changedFields} WHERE id = ${viewer.userID} `; await dbQuery(saveQuery); - handleAsyncPromise( - (async () => { - const rustApi = await getRustAPI(); - await rustApi.updateUser(viewer.userID, newPassword); - })(), - ); const updateDatas = [ {