Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3395765
D13090.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D13090.diff
View Options
diff --git a/keyserver/src/endpoints.js b/keyserver/src/endpoints.js
--- a/keyserver/src/endpoints.js
+++ b/keyserver/src/endpoints.js
@@ -7,6 +7,7 @@
import type { PolicyType } from 'lib/facts/policies.js';
import type { Endpoint } from 'lib/types/endpoints.js';
import { calendarQueryValidator } from 'lib/types/entry-types.js';
+import { recreateNotifsOlmSessionRequestValidator } from 'lib/types/keyserver-types.js';
import { sessionStateValidator } from 'lib/types/session-types.js';
import { endpointValidators } from 'lib/types/validators/endpoint-validators.js';
import { updateUserAvatarRequestValidator } from 'lib/utils/avatar-utils.js';
@@ -45,7 +46,10 @@
} from './responders/farcaster-channel-tag-responders.js';
import type { JSONResponder } from './responders/handlers.js';
import { createJSONResponder } from './responders/handlers.js';
-import { getOlmSessionInitializationDataResponder } from './responders/keys-responders.js';
+import {
+ getOlmSessionInitializationDataResponder,
+ recreateNotifsOlmSessionResponder,
+} from './responders/keys-responders.js';
import {
createOrUpdatePublicLinkResponder,
disableInviteLinkResponder,
@@ -486,6 +490,11 @@
inputValidator: ignoredArgumentValidator,
policies: [],
},
+ recreate_notifs_olm_session: {
+ responder: recreateNotifsOlmSessionResponder,
+ inputValidator: recreateNotifsOlmSessionRequestValidator,
+ policies: [],
+ },
version: {
responder: versionResponder,
inputValidator: ignoredArgumentValidator,
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
@@ -2,12 +2,15 @@
import type { Account as OlmAccount } from '@commapp/olm';
+import { type RecreateNotifsOlmSessionRequest } from 'lib/types/keyserver-types.js';
import type {
OlmSessionInitializationInfo,
GetOlmSessionInitializationDataResponse,
} from 'lib/types/request-types.js';
import { ServerError } from 'lib/utils/errors.js';
+import { createAndPersistOlmSession } from '../creators/olm-session-creator.js';
+import type { Viewer } from '../session/viewer.js';
import { fetchCallUpdateOlmAccount } from '../updaters/olm-account-updater.js';
type SessionInitializationKeysSet = {
@@ -96,4 +99,25 @@
};
}
-export { getOlmSessionInitializationDataResponder };
+async function recreateNotifsOlmSessionResponder(
+ viewer: Viewer,
+ request: RecreateNotifsOlmSessionRequest,
+): Promise<void> {
+ const {
+ initialEncryptedMessage,
+ identityKeysBlob: {
+ notificationIdentityPublicKeys: { curve25519 },
+ },
+ } = request;
+ await createAndPersistOlmSession(
+ initialEncryptedMessage,
+ 'notifications',
+ viewer.cookieID,
+ curve25519,
+ );
+}
+
+export {
+ getOlmSessionInitializationDataResponder,
+ recreateNotifsOlmSessionResponder,
+};
diff --git a/lib/actions/keyserver-actions.js b/lib/actions/keyserver-actions.js
--- a/lib/actions/keyserver-actions.js
+++ b/lib/actions/keyserver-actions.js
@@ -1,7 +1,39 @@
// @flow
+import { useKeyserverCall } from '../keyserver-conn/keyserver-call.js';
+import type { CallKeyserverEndpoint } from '../keyserver-conn/keyserver-conn-types.js';
+import type { RecreateNotifsOlmSessionRequest } from '../types/keyserver-types.js';
+
const addKeyserverActionType = 'ADD_KEYSERVER';
const removeKeyserverActionType = 'REMOVE_KEYSERVER';
-export { addKeyserverActionType, removeKeyserverActionType };
+const recreateNotifsOlmSession =
+ (
+ callKeyserverEndpoint: CallKeyserverEndpoint,
+ ): ((
+ input: $ReadOnly<{
+ ...RecreateNotifsOlmSessionRequest,
+ keyserverID: string,
+ }>,
+ ) => Promise<void>) =>
+ async input => {
+ const { keyserverID, ...request } = input;
+ const requests = { [keyserverID]: request };
+ await callKeyserverEndpoint('recreate_notifs_olm_session', requests);
+ };
+
+function useRecreateNotifsOlmSession(): (
+ input: $ReadOnly<{
+ ...RecreateNotifsOlmSessionRequest,
+ keyserverID: string,
+ }>,
+) => Promise<void> {
+ return useKeyserverCall(recreateNotifsOlmSession);
+}
+
+export {
+ addKeyserverActionType,
+ removeKeyserverActionType,
+ useRecreateNotifsOlmSession,
+};
diff --git a/lib/types/endpoints.js b/lib/types/endpoints.js
--- a/lib/types/endpoints.js
+++ b/lib/types/endpoints.js
@@ -111,6 +111,7 @@
UPLOAD_MEDIA_METADATA: 'upload_media_metadata',
SEARCH_MESSAGES: 'search_messages',
GET_OLM_SESSION_INITIALIZATION_DATA: 'get_olm_session_initialization_data',
+ RECREATE_NOTIFS_OLM_SESSION: 'recreate_notifs_olm_session',
VERSION: 'version',
FETCH_COMMUNITY_INFOS: 'fetch_community_infos',
CREATE_OR_UPDATE_FARCASTER_CHANNEL_TAG:
diff --git a/lib/types/keyserver-types.js b/lib/types/keyserver-types.js
--- a/lib/types/keyserver-types.js
+++ b/lib/types/keyserver-types.js
@@ -2,6 +2,10 @@
import t, { type TInterface } from 'tcomb';
+import {
+ type IdentityKeysBlob,
+ identityKeysBlobValidator,
+} from './crypto-types.js';
import type { Platform, PlatformDetails } from './device-types.js';
import {
calendarQueryValidator,
@@ -84,4 +88,15 @@
keyserverInfos: t.dict(t.String, keyserverInfoValidator),
});
+export type RecreateNotifsOlmSessionRequest = {
+ +initialEncryptedMessage: string,
+ +identityKeysBlob: IdentityKeysBlob,
+};
+
+export const recreateNotifsOlmSessionRequestValidator: TInterface<RecreateNotifsOlmSessionRequest> =
+ tShape<RecreateNotifsOlmSessionRequest>({
+ initialEncryptedMessage: t.String,
+ identityKeysBlob: identityKeysBlobValidator,
+ });
+
export { defaultKeyserverInfo };
diff --git a/lib/types/validators/endpoint-validators.js b/lib/types/validators/endpoint-validators.js
--- a/lib/types/validators/endpoint-validators.js
+++ b/lib/types/validators/endpoint-validators.js
@@ -172,6 +172,7 @@
get_olm_session_initialization_data: {
validator: getOlmSessionInitializationDataResponseValidator,
},
+ recreate_notifs_olm_session: { validator: t.Nil },
version: { validator: versionResponseValidator },
fetch_community_infos: { validator: fetchCommunityInfosResponseValidator },
create_or_update_farcaster_channel_tag: {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Dec 2, 7:30 AM (16 h, 50 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2607009
Default Alt Text
D13090.diff (6 KB)
Attached To
Mode
D13090: Implement new endpoint on the keyserver to create notifs olm session on client demand
Attached
Detach File
Event Timeline
Log In to Comment