Skip to content

Instantly share code, notes, and snippets.

View marcinwasowicz's full-sized avatar

marcinwasowicz

View GitHub Profile
@marcinwasowicz
marcinwasowicz / gist:7f04bd592dd4a800adbc96b720e200b7
Created December 14, 2023 13:05
Temporary testing for CSA Metadata event emitter.
diff --git a/native/cpp/CommonCpp/NativeModules/DraftStoreOperations.h b/native/cpp/CommonCpp/NativeModules/DraftStoreOperations.h
index 4ae8b8e3a..2d6d6dff3 100644
--- a/native/cpp/CommonCpp/NativeModules/DraftStoreOperations.h
+++ b/native/cpp/CommonCpp/NativeModules/DraftStoreOperations.h
@@ -1,5 +1,6 @@
#pragma once
+#include "CommServicesAuthMetadataEmitter.h"
#include "DatabaseManager.h"
#include <jsi/jsi.h>
@marcinwasowicz
marcinwasowicz / gist:24851a362628e863553870fdc04d9c72
Created December 7, 2023 15:52
Final testing of Windows encrypted notifications
diff --git a/keyserver/src/creators/message-creator.js b/keyserver/src/creators/message-creator.js
index 9bf966ce4..e7dc91425 100644
--- a/keyserver/src/creators/message-creator.js
+++ b/keyserver/src/creators/message-creator.js
@@ -483,14 +483,21 @@ async function postMessageSend(
return undefined;
}
+ const messageInfos1 = [];
+ const messageDatas1 = [];
@marcinwasowicz
marcinwasowicz / gist:2455e66424dbbc7cd30f07df78f89757
Created November 29, 2023 17:09
Desktop encrypted notifications final testing task
diff --git a/keyserver/src/creators/message-creator.js b/keyserver/src/creators/message-creator.js
index 84fe5c48d..473d2b4f8 100644
--- a/keyserver/src/creators/message-creator.js
+++ b/keyserver/src/creators/message-creator.js
@@ -484,14 +484,21 @@ async function postMessageSend(
return undefined;
}
+ const messageInfos1 = [];
+ const messageDatas1 = [];
@marcinwasowicz
marcinwasowicz / gist:3f1478ede2702b8e96d168b5d8a52b2c
Created November 27, 2023 11:54
Fix invalid use of `CryptoKey` type in newer flow version.
diff --git a/lib/flow-typed/web-crypto-common.js b/lib/flow-typed/web-crypto-common.js
index 571e479ba..70dd21d90 100644
--- a/lib/flow-typed/web-crypto-common.js
+++ b/lib/flow-typed/web-crypto-common.js
@@ -20,7 +20,16 @@ type CryptoKey$Usages =
| 'wrapKey'
| 'unwrapKey';
-declare type CryptoKey = SubtleCrypto$JsonWebKey;
+declare type CryptoKey = {
diff --git a/keyserver/src/session/cookies.js b/keyserver/src/session/cookies.js
index 9bc7f7910..0ca3e4373 100644
--- a/keyserver/src/session/cookies.js
+++ b/keyserver/src/session/cookies.js
@@ -833,10 +833,12 @@ async function isCookieMissingOlmNotificationsSession(
!viewer.platformDetails ||
(viewer.platformDetails.platform !== 'ios' &&
viewer.platformDetails.platform !== 'android' &&
- !(viewer.platformDetails.platform === 'web' && isStaffOrDev)) ||
+ !(viewer.platformDetails.platform === 'web' && isStaffOrDev) &&
@marcinwasowicz
marcinwasowicz / gist:673b62b70998588a7e6f4be31bddd2c8
Created November 23, 2023 17:06
Artificially generate multiple out of order notifications by duplicating `sendPushNotifs` promise for a single notification.
diff --git a/keyserver/src/creators/message-creator.js b/keyserver/src/creators/message-creator.js
index db71a26ed..18caecf3e 100644
--- a/keyserver/src/creators/message-creator.js
+++ b/keyserver/src/creators/message-creator.js
@@ -476,14 +476,21 @@ async function postMessageSend(
return undefined;
}
+ const messageInfos1 = [];
+ const messageDatas1 = [];
@marcinwasowicz
marcinwasowicz / gist:2df9c9bd4491862173241744d54a016f
Created November 23, 2023 16:38
Dirt code: encrypt MacOS notitications on the keyserver
diff --git a/keyserver/src/push/send.js b/keyserver/src/push/send.js
index 8eeeb2967..487c882c8 100644
--- a/keyserver/src/push/send.js
+++ b/keyserver/src/push/send.js
@@ -895,9 +895,11 @@ async function prepareAPNsNotification(
platformDetails.codeVersion && platformDetails.codeVersion >= 267;
const shouldBeEncrypted =
- platformDetails.platform === 'ios' &&
- (canDecryptAllNotifTypes ||
@marcinwasowicz
marcinwasowicz / gist:8a7f5d9171d3d2df7408f26176639be4
Created November 16, 2023 18:09
Simulate concurrent `sendPushNotifs` promises at the same time.
diff --git a/keyserver/src/creators/message-creator.js b/keyserver/src/creators/message-creator.js
index db71a26ed..18caecf3e 100644
--- a/keyserver/src/creators/message-creator.js
+++ b/keyserver/src/creators/message-creator.js
@@ -476,14 +476,21 @@ async function postMessageSend(
return undefined;
}
+ const messageInfos1 = [];
+ const messageDatas1 = [];
@marcinwasowicz
marcinwasowicz / gist:a62c3e2c571d791c52538c5dcd5e730f
Created November 7, 2023 14:33
Sort notifications to match encryption order.
diff --git a/keyserver/src/push/crypto.js b/keyserver/src/push/crypto.js
index c4c1b6aae..e8ca7b733 100644
--- a/keyserver/src/push/crypto.js
+++ b/keyserver/src/push/crypto.js
@@ -221,24 +221,27 @@ async function encryptAndroidNotificationRescind(
async function encryptWebNotification(
cookieID: string,
notification: PlainTextWebNotification,
-): Promise<WebNotification> {
+): Promise<{ notif: WebNotification, +version?: number }> {
@marcinwasowicz
marcinwasowicz / gist:039d35ce01414f3cfafa0d5b54cdea0c
Created November 3, 2023 10:54
Test encrypted web notifications
diff --git a/keyserver/src/push/send.js b/keyserver/src/push/send.js
index c75f2c248..44ea265e8 100644
--- a/keyserver/src/push/send.js
+++ b/keyserver/src/push/send.js
@@ -361,15 +361,24 @@ async function sendPushNotif(input: {
};
const deliveryPromise: Promise<PushResult> = (async () => {
- const targetedNotifications = await prepareWebNotification(
- {