Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3365896
D11177.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
19 KB
Referenced Files
None
Subscribers
None
D11177.diff
View Options
diff --git a/keyserver/src/creators/one-time-keys-creator.js b/keyserver/src/creators/one-time-keys-creator.js
deleted file mode 100644
--- a/keyserver/src/creators/one-time-keys-creator.js
+++ /dev/null
@@ -1,26 +0,0 @@
-// @flow
-
-import { dbQuery, SQL } from '../database/database.js';
-import type { Viewer } from '../session/viewer.js';
-
-async function saveOneTimeKeys(
- viewer: Viewer,
- oneTimeKeys: $ReadOnlyArray<string>,
-): Promise<void> {
- if (oneTimeKeys.length === 0) {
- return;
- }
-
- const insertData = oneTimeKeys.map(oneTimeKey => [
- viewer.session,
- oneTimeKey,
- ]);
-
- const query = SQL`
- INSERT INTO one_time_keys(session, one_time_key)
- VALUES ${insertData}
- `;
- await dbQuery(query);
-}
-
-export { saveOneTimeKeys };
diff --git a/keyserver/src/database/migration-config.js b/keyserver/src/database/migration-config.js
--- a/keyserver/src/database/migration-config.js
+++ b/keyserver/src/database/migration-config.js
@@ -743,6 +743,7 @@
);
},
],
+ [59, () => dbQuery(SQL`DROP TABLE one_time_keys`)],
]);
const newDatabaseVersion: number = Math.max(...migrations.keys());
diff --git a/keyserver/src/database/setup-db.js b/keyserver/src/database/setup-db.js
--- a/keyserver/src/database/setup-db.js
+++ b/keyserver/src/database/setup-db.js
@@ -215,11 +215,6 @@
status tinyint(1) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
- CREATE TABLE one_time_keys (
- session bigint(20) NOT NULL,
- one_time_key char(43) NOT NULL
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
CREATE TABLE user_messages (
recipient varchar(255) CHARSET latin1 COLLATE latin1_bin NOT NULL,
thread bigint(20) NOT NULL,
diff --git a/keyserver/src/endpoints.js b/keyserver/src/endpoints.js
--- a/keyserver/src/endpoints.js
+++ b/keyserver/src/endpoints.js
@@ -47,12 +47,7 @@
} from './responders/entry-responders.js';
import type { JSONResponder } from './responders/handlers.js';
import { createJSONResponder } from './responders/handlers.js';
-import {
- getSessionPublicKeysResponder,
- getOlmSessionInitializationDataResponder,
- getSessionPublicKeysInputValidator,
- getSessionPublicKeysResponseValidator,
-} from './responders/keys-responders.js';
+import { getOlmSessionInitializationDataResponder } from './responders/keys-responders.js';
import {
createOrUpdatePublicLinkResponder,
disableInviteLinkResponder,
@@ -370,12 +365,6 @@
initialReduxStateValidator,
[],
),
- get_session_public_keys: createJSONResponder(
- getSessionPublicKeysResponder,
- getSessionPublicKeysInputValidator,
- getSessionPublicKeysResponseValidator,
- baseLegalPolicies,
- ),
join_thread: createJSONResponder(
threadJoinResponder,
joinThreadRequestInputValidator,
diff --git a/keyserver/src/fetchers/key-fetchers.js b/keyserver/src/fetchers/key-fetchers.js
deleted file mode 100644
--- a/keyserver/src/fetchers/key-fetchers.js
+++ /dev/null
@@ -1,53 +0,0 @@
-// @flow
-
-import type { SessionPublicKeys } from 'lib/types/session-types.js';
-import { minimumOneTimeKeysRequired } from 'lib/utils/crypto-utils.js';
-import { ServerError } from 'lib/utils/errors.js';
-
-import { dbQuery, SQL } from '../database/database.js';
-import { deleteOneTimeKey } from '../deleters/one-time-key-deleters.js';
-
-async function checkIfSessionHasEnoughOneTimeKeys(
- session: string,
-): Promise<boolean> {
- const query = SQL`
- SELECT COUNT(*) AS count
- FROM one_time_keys
- WHERE session = ${session}
- `;
- const [queryResult] = await dbQuery(query);
- if (!queryResult.length || queryResult[0].count === undefined) {
- throw new ServerError('internal_error');
- }
- const [{ count }] = queryResult;
- return count >= minimumOneTimeKeysRequired;
-}
-
-async function fetchSessionPublicKeys(
- session: string,
-): Promise<SessionPublicKeys | null> {
- const query = SQL`
- SELECT s.public_key, otk.one_time_key
- FROM sessions s
- LEFT JOIN one_time_keys otk ON otk.session = s.id
- WHERE s.id = ${session}
- LIMIT 1
- `;
- const [queryResult] = await dbQuery(query);
- if (!queryResult.length) {
- return null;
- }
- const [result] = queryResult;
-
- if (!result.public_key) {
- return null;
- }
-
- const oneTimeKey = result.one_time_key;
- const identityKey = result.public_key;
- await deleteOneTimeKey(session, oneTimeKey);
-
- return { identityKey, oneTimeKey };
-}
-
-export { fetchSessionPublicKeys, checkIfSessionHasEnoughOneTimeKeys };
diff --git a/keyserver/src/responders/keys-responders.js b/keyserver/src/responders/keys-responders.js
--- a/keyserver/src/responders/keys-responders.js
+++ b/keyserver/src/responders/keys-responders.js
@@ -1,22 +1,13 @@
// @flow
import type { Account as OlmAccount } from '@commapp/olm';
-import t, { type TUnion, type TInterface } from 'tcomb';
import type {
OlmSessionInitializationInfo,
GetOlmSessionInitializationDataResponse,
- GetSessionPublicKeysArgs,
} from 'lib/types/request-types.js';
-import {
- type SessionPublicKeys,
- sessionPublicKeysValidator,
-} from 'lib/types/session-types.js';
import { ServerError } from 'lib/utils/errors.js';
-import { tShape, tNull } from 'lib/utils/validation-utils.js';
-import { fetchSessionPublicKeys } from '../fetchers/key-fetchers.js';
-import type { Viewer } from '../session/viewer.js';
import { fetchCallUpdateOlmAccount } from '../updaters/olm-account-updater.js';
type SessionInitializationKeysSet = {
@@ -24,25 +15,6 @@
...OlmSessionInitializationInfo,
};
-export const getSessionPublicKeysInputValidator: TInterface<GetSessionPublicKeysArgs> =
- tShape<GetSessionPublicKeysArgs>({
- session: t.String,
- });
-
-type GetSessionPublicKeysResponse = SessionPublicKeys | null;
-export const getSessionPublicKeysResponseValidator: TUnion<GetSessionPublicKeysResponse> =
- t.union([sessionPublicKeysValidator, tNull]);
-
-async function getSessionPublicKeysResponder(
- viewer: Viewer,
- request: GetSessionPublicKeysArgs,
-): Promise<GetSessionPublicKeysResponse> {
- if (!viewer.loggedIn) {
- return null;
- }
- return await fetchSessionPublicKeys(request.session);
-}
-
function retrieveSessionInitializationKeysSet(
account: OlmAccount,
): SessionInitializationKeysSet {
@@ -124,7 +96,4 @@
};
}
-export {
- getSessionPublicKeysResponder,
- getOlmSessionInitializationDataResponder,
-};
+export { getOlmSessionInitializationDataResponder };
diff --git a/keyserver/src/responders/responder-validators.test.js b/keyserver/src/responders/responder-validators.test.js
--- a/keyserver/src/responders/responder-validators.test.js
+++ b/keyserver/src/responders/responder-validators.test.js
@@ -13,7 +13,6 @@
deltaEntryInfosResultValidator,
restoreEntryResponseValidator,
} from './entry-responders.js';
-import { getSessionPublicKeysResponseValidator } from './keys-responders.js';
import {
inviteLinkVerificationResponseValidator,
fetchInviteLinksResponseValidator,
@@ -433,24 +432,6 @@
});
});
-describe('keys responder', () => {
- it('should validate get session public keys response', () => {
- const response = {
- identityKey: 'key',
- oneTimeKey: 'key',
- };
-
- expect(getSessionPublicKeysResponseValidator.is(response)).toBe(true);
- expect(getSessionPublicKeysResponseValidator.is(null)).toBe(true);
- expect(
- getSessionPublicKeysResponseValidator.is({
- ...response,
- identityKey: undefined,
- }),
- ).toBe(false);
- });
-});
-
describe('siwe nonce responders', () => {
it('should validate siwe nonce response', () => {
const response = { nonce: 'nonce' };
diff --git a/keyserver/src/socket/session-utils.js b/keyserver/src/socket/session-utils.js
--- a/keyserver/src/socket/session-utils.js
+++ b/keyserver/src/socket/session-utils.js
@@ -39,10 +39,8 @@
} from 'lib/utils/validation-utils.js';
import { createAndPersistOlmSession } from '../creators/olm-session-creator.js';
-import { saveOneTimeKeys } from '../creators/one-time-keys-creator.js';
import createReport from '../creators/report-creator.js';
import { fetchEntriesForSession } from '../fetchers/entry-fetchers.js';
-import { checkIfSessionHasEnoughOneTimeKeys } from '../fetchers/key-fetchers.js';
import { activityUpdatesInputValidator } from '../responders/activity-responders.js';
import {
threadInconsistencyReportValidatorShape,
@@ -104,13 +102,6 @@
),
activityUpdates: activityUpdatesInputValidator,
}),
- tShape({
- type: t.irreducible(
- 'serverRequestTypes.MORE_ONE_TIME_KEYS',
- x => x === serverRequestTypes.MORE_ONE_TIME_KEYS,
- ),
- keys: t.list(t.String),
- }),
tShape({
type: t.irreducible(
'serverRequestTypes.SIGNED_IDENTITY_KEYS_BLOB',
@@ -194,9 +185,6 @@
invalidKeys.length > 0
? { status: 'state_invalid', invalidKeys }
: { status: 'state_validated' };
- } else if (clientResponse.type === serverRequestTypes.MORE_ONE_TIME_KEYS) {
- invariant(clientResponse.keys, 'keys expected in client response');
- ignorePromiseRejections(saveOneTimeKeys(viewer, clientResponse.keys));
} else if (
clientResponse.type === serverRequestTypes.SIGNED_IDENTITY_KEYS_BLOB
) {
@@ -254,22 +242,9 @@
const serverRequests: Array<ServerServerRequest> = [];
- const checkOneTimeKeysPromise = (async () => {
- if (!viewer.loggedIn) {
- return;
- }
- const enoughOneTimeKeys = await checkIfSessionHasEnoughOneTimeKeys(
- viewer.session,
- );
- if (!enoughOneTimeKeys) {
- serverRequests.push({ type: serverRequestTypes.MORE_ONE_TIME_KEYS });
- }
- })();
-
const { activityUpdateResult } = await promiseAll({
all: Promise.all(promises),
activityUpdateResult: activityUpdatePromise,
- checkOneTimeKeysPromise,
});
if (
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
@@ -39,18 +39,12 @@
RawMessageInfo,
MessageTruncationStatuses,
} from '../types/message-types.js';
-import type {
- GetSessionPublicKeysArgs,
- GetOlmSessionInitializationDataResponse,
-} from '../types/request-types.js';
+import type { GetOlmSessionInitializationDataResponse } from '../types/request-types.js';
import type {
UserSearchResult,
ExactUserSearchResult,
} from '../types/search-types.js';
-import type {
- SessionPublicKeys,
- PreRequestUserState,
-} from '../types/session-types.js';
+import type { PreRequestUserState } from '../types/session-types.js';
import type {
SubscriptionUpdateRequest,
SubscriptionUpdateResult,
@@ -743,14 +737,6 @@
return useKeyserverCall(setUserSettings);
}
-const getSessionPublicKeys =
- (
- callSingleKeyserverEndpoint: CallSingleKeyserverEndpoint,
- ): ((data: GetSessionPublicKeysArgs) => Promise<SessionPublicKeys | null>) =>
- async data => {
- return await callSingleKeyserverEndpoint('get_session_public_keys', data);
- };
-
const getOlmSessionInitializationDataActionTypes = Object.freeze({
started: 'GET_OLM_SESSION_INITIALIZATION_DATA_STARTED',
success: 'GET_OLM_SESSION_INITIALIZATION_DATA_SUCCESS',
@@ -827,7 +813,6 @@
useClaimUsername,
useDeleteKeyserverAccount,
deleteKeyserverAccountActionTypes,
- getSessionPublicKeys,
getOlmSessionInitializationDataActionTypes,
getOlmSessionInitializationData,
mergeUserInfos,
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
@@ -24,10 +24,8 @@
type ClientClientResponse,
} 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';
const baseOpenSocketSelector: (
@@ -98,7 +96,6 @@
keyserverID: string,
) => (
calendarActive: boolean,
- oneTimeKeyGenerator: ?OneTimeKeyGenerator,
getSignedIdentityKeysBlob: () => Promise<SignedIdentityKeysBlob>,
getInitialNotificationsEncryptedMessage: ?(
keyserverID: string,
@@ -116,7 +113,6 @@
) => {
return async (
calendarActive: boolean,
- oneTimeKeyGenerator: ?OneTimeKeyGenerator,
getSignedIdentityKeysBlob: () => Promise<SignedIdentityKeysBlob>,
getInitialNotificationsEncryptedMessage: ?(
keyserverID: string,
@@ -192,18 +188,6 @@
type: serverRequestTypes.CHECK_STATE,
hashResults,
});
- } else if (
- serverRequest.type === serverRequestTypes.MORE_ONE_TIME_KEYS &&
- oneTimeKeyGenerator
- ) {
- const keys: string[] = [];
- for (let i = 0; i < minimumOneTimeKeysRequired; ++i) {
- keys.push(oneTimeKeyGenerator(i));
- }
- clientResponses.push({
- type: serverRequestTypes.MORE_ONE_TIME_KEYS,
- keys,
- });
} else if (
serverRequest.type === serverRequestTypes.SIGNED_IDENTITY_KEYS_BLOB
) {
diff --git a/lib/types/request-types.js b/lib/types/request-types.js
--- a/lib/types/request-types.js
+++ b/lib/types/request-types.js
@@ -40,7 +40,7 @@
ENTRY_INCONSISTENCY: 5,
CHECK_STATE: 6,
INITIAL_ACTIVITY_UPDATES: 7,
- MORE_ONE_TIME_KEYS: 8,
+ // MORE_ONE_TIME_KEYS: 8, (DEPRECATED)
SIGNED_IDENTITY_KEYS_BLOB: 9,
INITIAL_NOTIFICATIONS_ENCRYPTED_MESSAGE: 10,
});
@@ -55,7 +55,6 @@
serverRequestType === 5 ||
serverRequestType === 6 ||
serverRequestType === 7 ||
- serverRequestType === 8 ||
serverRequestType === 9 ||
serverRequestType === 10,
'number is not ServerRequestType enum',
@@ -153,14 +152,6 @@
+activityUpdates: $ReadOnlyArray<ActivityUpdate>,
};
-type MoreOneTimeKeysServerRequest = {
- +type: 8,
-};
-const moreOneTimeKeysServerRequestValidator =
- tShape<MoreOneTimeKeysServerRequest>({
- type: tNumber(serverRequestTypes.MORE_ONE_TIME_KEYS),
- });
-
type MoreOneTimeKeysClientResponse = {
+type: 8,
+keys: $ReadOnlyArray<string>,
@@ -196,7 +187,6 @@
| PlatformServerRequest
| PlatformDetailsServerRequest
| ServerCheckStateServerRequest
- | MoreOneTimeKeysServerRequest
| SignedIdentityKeysBlobServerRequest
| InitialNotificationsEncryptedMessageServerRequest;
export const serverServerRequestValidator: TUnion<ServerServerRequest> =
@@ -204,7 +194,6 @@
platformServerRequestValidator,
platformDetailsServerRequestValidator,
serverCheckStateServerRequestValidator,
- moreOneTimeKeysServerRequestValidator,
signedIdentityKeysBlobServerRequestValidator,
initialNotificationsEncryptedMessageServerRequestValidator,
]);
@@ -242,7 +231,6 @@
| PlatformServerRequest
| PlatformDetailsServerRequest
| ClientCheckStateServerRequest
- | MoreOneTimeKeysServerRequest
| SignedIdentityKeysBlobServerRequest
| InitialNotificationsEncryptedMessageServerRequest;
@@ -282,10 +270,6 @@
+payload: ProcessServerRequestsPayload,
};
-export type GetSessionPublicKeysArgs = {
- +session: string,
-};
-
export type OlmSessionInitializationInfo = {
+prekey: string,
+prekeySignature: string,
diff --git a/lib/types/session-types.js b/lib/types/session-types.js
--- a/lib/types/session-types.js
+++ b/lib/types/session-types.js
@@ -1,7 +1,5 @@
// @flow
-import t, { type TInterface } from 'tcomb';
-
import type { LogInActionSource } from './account-types.js';
import type { CalendarQuery } from './entry-types.js';
import type { MixedRawThreadInfos } from './thread-types.js';
@@ -10,7 +8,6 @@
type CurrentUserInfo,
type LoggedOutUserInfo,
} from './user-types.js';
-import { tShape } from '../utils/validation-utils.js';
export const cookieLifetime = 30 * 24 * 60 * 60 * 1000; // in milliseconds
// Interval the server waits after a state check before starting a new one
@@ -101,14 +98,3 @@
cookie: ?string,
sessionID: ?string,
}>;
-
-export type SessionPublicKeys = {
- +identityKey: string,
- +oneTimeKey?: string,
-};
-
-export const sessionPublicKeysValidator: TInterface<SessionPublicKeys> =
- tShape<SessionPublicKeys>({
- identityKey: t.String,
- oneTimeKey: t.maybe(t.String),
- });
diff --git a/lib/utils/crypto-utils.js b/lib/utils/crypto-utils.js
--- a/lib/utils/crypto-utils.js
+++ b/lib/utils/crypto-utils.js
@@ -11,8 +11,6 @@
SignedIdentityKeysBlob,
} from '../types/crypto-types';
-const minimumOneTimeKeysRequired = 10;
-
const signedIdentityKeysBlobValidator: TInterface<SignedIdentityKeysBlob> =
tShape({
payload: t.String,
@@ -29,8 +27,4 @@
notificationIdentityPublicKeys: olmIdentityKeysValidator,
});
-export {
- minimumOneTimeKeysRequired,
- signedIdentityKeysBlobValidator,
- identityKeysBlobValidator,
-};
+export { signedIdentityKeysBlobValidator, identityKeysBlobValidator };
diff --git a/native/selectors/socket-selectors.js b/native/selectors/socket-selectors.js
--- a/native/selectors/socket-selectors.js
+++ b/native/selectors/socket-selectors.js
@@ -17,7 +17,6 @@
SessionIdentification,
SessionState,
} from 'lib/types/session-types.js';
-import type { OneTimeKeyGenerator } from 'lib/types/socket-types.js';
import { commCoreModule } from '../native-modules.js';
import { calendarActiveSelector } from '../navigation/nav-selectors.js';
@@ -38,17 +37,6 @@
baseSessionIdentificationSelector,
);
-function oneTimeKeyGenerator(inc: number): string {
- // todo replace this hard code with something like
- // commCoreModule.generateOneTimeKeys()
- let str = Date.now().toString() + '_' + inc.toString() + '_';
- while (str.length < 43) {
- str += Math.random().toString(36).substr(2, 5);
- }
- str = str.substr(0, 43);
- return str;
-}
-
async function getSignedIdentityKeysBlob(): Promise<SignedIdentityKeysBlob> {
await commCoreModule.initializeCryptoAccount();
const { blobPayload, signature } = await commCoreModule.getUserPublicKey();
@@ -81,7 +69,6 @@
(
getClientResponsesFunc: (
calendarActive: boolean,
- oneTimeKeyGenerator: ?OneTimeKeyGenerator,
getSignedIdentityKeysBlob: () => Promise<SignedIdentityKeysBlob>,
getInitialNotificationsEncryptedMessage: ?(
keyserverID: string,
@@ -96,7 +83,6 @@
(serverRequests: $ReadOnlyArray<ClientServerRequest>) =>
getClientResponsesFunc(
calendarActive,
- oneTimeKeyGenerator,
getSignedIdentityKeysBlob,
getInitialNotificationsEncryptedMessage,
serverRequests,
diff --git a/web/selectors/socket-selectors.js b/web/selectors/socket-selectors.js
--- a/web/selectors/socket-selectors.js
+++ b/web/selectors/socket-selectors.js
@@ -20,7 +20,6 @@
SessionIdentification,
SessionState,
} from 'lib/types/session-types.js';
-import type { OneTimeKeyGenerator } from 'lib/types/socket-types.js';
import type { AppState } from '../redux/redux-setup.js';
@@ -67,7 +66,6 @@
(
getClientResponsesFunc: (
calendarActive: boolean,
- oneTimeKeyGenerator: ?OneTimeKeyGenerator,
getSignedIdentityKeysBlob: () => Promise<SignedIdentityKeysBlob>,
getInitialNotificationsEncryptedMessage: (
keyserverID: string,
@@ -83,7 +81,6 @@
(serverRequests: $ReadOnlyArray<ClientServerRequest>) =>
getClientResponsesFunc(
calendarActive,
- null,
getSignedIdentityKeysBlob,
getInitialNotificationsEncryptedMessage,
serverRequests,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 26, 8:18 AM (9 h, 36 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2579282
Default Alt Text
D11177.diff (19 KB)
Attached To
Mode
D11177: [lib][keyserver] Delete MORE_ONE_TIME_KEYS mechanism
Attached
Detach File
Event Timeline
Log In to Comment