Page MenuHomePhorge

D9873.1768870532.diff
No OneTemporary

Size
5 KB
Referenced Files
None
Subscribers
None

D9873.1768870532.diff

diff --git a/keyserver/src/push/crypto.js b/keyserver/src/push/crypto.js
--- a/keyserver/src/push/crypto.js
+++ b/keyserver/src/push/crypto.js
@@ -1,5 +1,6 @@
// @flow
+import type { EncryptResult } from '@commapp/olm';
import apn from '@parse/node-apn';
import crypto from 'crypto';
import invariant from 'invariant';
@@ -58,7 +59,11 @@
let dbPersistCondition;
if (notificationSizeValidator) {
- dbPersistCondition = ({ serializedPayload }) => {
+ dbPersistCondition = ({
+ serializedPayload,
+ }: {
+ +[string]: EncryptResult,
+ }) => {
const notifCopy = _cloneDeep(encryptedNotification);
notifCopy.payload.encryptedPayload = serializedPayload.body;
return notificationSizeValidator(notifCopy);
@@ -140,8 +145,11 @@
let dbPersistCondition;
if (payloadSizeValidator) {
- dbPersistCondition = ({ serializedPayload }) =>
- payloadSizeValidator({ encryptedPayload: serializedPayload.body });
+ dbPersistCondition = ({
+ serializedPayload,
+ }: {
+ +[string]: EncryptResult,
+ }) => payloadSizeValidator({ encryptedPayload: serializedPayload.body });
}
const {
diff --git a/keyserver/src/push/send.js b/keyserver/src/push/send.js
--- a/keyserver/src/push/send.js
+++ b/keyserver/src/push/send.js
@@ -59,6 +59,7 @@
TargetedAndroidNotification,
TargetedWebNotification,
TargetedWNSNotification,
+ AndroidNotification,
} from './types.js';
import {
apnPush,
@@ -950,7 +951,7 @@
messageInfos,
};
- const notificationSizeValidator = notif =>
+ const notificationSizeValidator = (notif: apn.Notification) =>
notif.length() <= apnMaxNotificationPayloadByteSize;
if (!shouldBeEncrypted) {
@@ -1129,7 +1130,7 @@
}));
}
- const notificationsSizeValidator = notif => {
+ const notificationsSizeValidator = (notif: AndroidNotification) => {
const serializedNotif = JSON.stringify(notif);
return (
!serializedNotif ||
diff --git a/keyserver/src/scripts/generate-converter-from-validator.js b/keyserver/src/scripts/generate-converter-from-validator.js
--- a/keyserver/src/scripts/generate-converter-from-validator.js
+++ b/keyserver/src/scripts/generate-converter-from-validator.js
@@ -216,7 +216,7 @@
const validator = rawThreadInfoValidator;
const typeName = 'RawThreadInfo';
const validatorToBeConverted = tID;
-const conversionExpressionString = inputName =>
+const conversionExpressionString = (inputName: string) =>
`'${ashoatKeyserverID}|' + ${inputName}`;
main([
async () => {
diff --git a/keyserver/src/socket/socket.js b/keyserver/src/socket/socket.js
--- a/keyserver/src/socket/socket.js
+++ b/keyserver/src/socket/socket.js
@@ -193,7 +193,7 @@
onMessage = async (
messageString: string | Buffer | ArrayBuffer | Array<Buffer>,
- ) => {
+ ): Promise<void> => {
invariant(typeof messageString === 'string', 'message should be string');
let clientSocketMessage: ?ClientSocketMessage;
try {
@@ -803,12 +803,12 @@
// The Socket will timeout by calling this.ws.terminate()
// serverRequestSocketTimeout milliseconds after the last
// time resetTimeout is called
- resetTimeout = _debounce(
+ resetTimeout: { +cancel: () => void } & (() => void) = _debounce(
() => this.ws.terminate(),
serverRequestSocketTimeout,
);
- debouncedAfterActivity = _debounce(
+ debouncedAfterActivity: { +cancel: () => void } & (() => void) = _debounce(
() => this.setStateCheckConditions({ activityRecentlyOccurred: false }),
stateCheckInactivityActivationInterval,
);
@@ -837,7 +837,7 @@
this.handleStateCheckConditionsUpdate();
}
- get stateCheckCanStart() {
+ get stateCheckCanStart(): boolean {
return Object.values(this.stateCheckConditions).every(cond => !cond);
}
diff --git a/keyserver/src/utils/depth-queue.js b/keyserver/src/utils/depth-queue.js
--- a/keyserver/src/utils/depth-queue.js
+++ b/keyserver/src/utils/depth-queue.js
@@ -18,7 +18,7 @@
this.mergeFunction = mergeFunction;
}
- addInfo(info: T) {
+ addInfo(info: T): void {
const depth = this.getDepth(info);
if (depth <= this.maxDequeuedDepth) {
throw new Error(
diff --git a/keyserver/src/utils/olm-utils.test.js b/keyserver/src/utils/olm-utils.test.js
--- a/keyserver/src/utils/olm-utils.test.js
+++ b/keyserver/src/utils/olm-utils.test.js
@@ -8,13 +8,13 @@
const alphabet =
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ';
- const randomString = length =>
+ const randomString = (length: number) =>
Array.from(
{ length },
() => alphabet[Math.floor(Math.random() * alphabet.length)],
).join('');
- const initAccount = (mark_prekey_published = true) => {
+ const initAccount = (mark_prekey_published: boolean = true) => {
const account = new olm.Account();
account.create();
account.generate_prekey();
@@ -26,12 +26,12 @@
};
const createSession = (
- aliceSession,
- aliceAccount,
- bobAccount,
- regen = false,
- forget = false,
- invalid_sign = false,
+ aliceSession: olm.Session,
+ aliceAccount: olm.Account,
+ bobAccount: olm.Account,
+ regen: boolean = false,
+ forget: boolean = false,
+ invalid_sign: boolean = false,
) => {
const bobOneTimeKeys = JSON.parse(bobAccount.one_time_keys()).curve25519;
bobAccount.mark_keys_as_published();
@@ -86,7 +86,12 @@
return aliceSession;
};
- const testRatchet = (aliceSession, bobSession, bobAccount, num_msg = 1) => {
+ const testRatchet = (
+ aliceSession: olm.Session,
+ bobSession: olm.Session,
+ bobAccount: olm.Account,
+ num_msg: number = 1,
+ ) => {
let test_text = randomString(40);
let encrypted = aliceSession.encrypt(test_text);
expect(encrypted.type).toEqual(0);

File Metadata

Mime Type
text/plain
Expires
Tue, Jan 20, 12:55 AM (15 h, 41 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5958869
Default Alt Text
D9873.1768870532.diff (5 KB)

Event Timeline