Move SignalProtocolStore to TypeScript
This commit is contained in:
parent
5de4babc0d
commit
7e629edd21
14 changed files with 1291 additions and 1066 deletions
|
@ -329,7 +329,6 @@
|
||||||
<script type='text/javascript' src='js/reliable_trigger.js'></script>
|
<script type='text/javascript' src='js/reliable_trigger.js'></script>
|
||||||
<script type='text/javascript' src='js/database.js'></script>
|
<script type='text/javascript' src='js/database.js'></script>
|
||||||
<script type='text/javascript' src='js/storage.js'></script>
|
<script type='text/javascript' src='js/storage.js'></script>
|
||||||
<script type='text/javascript' src='js/signal_protocol_store.js'></script>
|
|
||||||
<script type='text/javascript' src='js/libtextsecure.js'></script>
|
<script type='text/javascript' src='js/libtextsecure.js'></script>
|
||||||
|
|
||||||
<script type='text/javascript' src='js/notifications.js'></script>
|
<script type='text/javascript' src='js/notifications.js'></script>
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -523,6 +523,7 @@ try {
|
||||||
require('./ts/backbone/views/whisper_view');
|
require('./ts/backbone/views/whisper_view');
|
||||||
require('./ts/backbone/views/toast_view');
|
require('./ts/backbone/views/toast_view');
|
||||||
require('./ts/views/conversation_view');
|
require('./ts/views/conversation_view');
|
||||||
|
require('./ts/LibSignalStore');
|
||||||
require('./ts/background');
|
require('./ts/background');
|
||||||
|
|
||||||
function wrapWithPromise(fn) {
|
function wrapWithPromise(fn) {
|
||||||
|
|
|
@ -339,7 +339,6 @@
|
||||||
|
|
||||||
<script type="text/javascript" src="../js/database.js" data-cover></script>
|
<script type="text/javascript" src="../js/database.js" data-cover></script>
|
||||||
<script type="text/javascript" src="../js/storage.js" data-cover></script>
|
<script type="text/javascript" src="../js/storage.js" data-cover></script>
|
||||||
<script type="text/javascript" src="../js/signal_protocol_store.js" data-cover></script>
|
|
||||||
<script type="text/javascript" src="../js/libtextsecure.js" data-cover></script>
|
<script type="text/javascript" src="../js/libtextsecure.js" data-cover></script>
|
||||||
|
|
||||||
<script type="text/javascript" src="../js/libphonenumber-util.js"></script>
|
<script type="text/javascript" src="../js/libphonenumber-util.js"></script>
|
||||||
|
@ -351,8 +350,6 @@
|
||||||
<script type='text/javascript' src='../js/notifications.js' data-cover></script>
|
<script type='text/javascript' src='../js/notifications.js' data-cover></script>
|
||||||
|
|
||||||
<script type='text/javascript' src='../js/views/react_wrapper_view.js'></script>
|
<script type='text/javascript' src='../js/views/react_wrapper_view.js'></script>
|
||||||
<script type='text/javascript' src='../js/views/whisper_view.js' data-cover></script>
|
|
||||||
<script type='text/javascript' src='../js/views/toast_view.js' data-cover></script>
|
|
||||||
<script type='text/javascript' src='../js/views/list_view.js' data-cover></script>
|
<script type='text/javascript' src='../js/views/list_view.js' data-cover></script>
|
||||||
<script type='text/javascript' src='../js/views/contact_list_view.js' data-cover></script>
|
<script type='text/javascript' src='../js/views/contact_list_view.js' data-cover></script>
|
||||||
<script type='text/javascript' src='../js/views/key_verification_view.js' data-cover></script>
|
<script type='text/javascript' src='../js/views/key_verification_view.js' data-cover></script>
|
||||||
|
|
1233
ts/LibSignalStore.ts
Normal file
1233
ts/LibSignalStore.ts
Normal file
File diff suppressed because it is too large
Load diff
2
ts/libsignal.d.ts
vendored
2
ts/libsignal.d.ts
vendored
|
@ -201,7 +201,7 @@ declare class SessionBuilderClass {
|
||||||
export declare class SessionCipherClass {
|
export declare class SessionCipherClass {
|
||||||
constructor(
|
constructor(
|
||||||
storage: StorageType,
|
storage: StorageType,
|
||||||
remoteAddress: SignalProtocolAddressClass,
|
remoteAddress: SignalProtocolAddressClass | string,
|
||||||
options?: { messageKeysLimit?: number | boolean }
|
options?: { messageKeysLimit?: number | boolean }
|
||||||
);
|
);
|
||||||
closeOpenSessionForDevice: () => Promise<void>;
|
closeOpenSessionForDevice: () => Promise<void>;
|
||||||
|
|
|
@ -1226,7 +1226,7 @@ async function updateUnprocessedsWithData(array: Array<UnprocessedType>) {
|
||||||
await channels.updateUnprocessedsWithData(array);
|
await channels.updateUnprocessedsWithData(array);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function removeUnprocessed(id: string) {
|
async function removeUnprocessed(id: string | Array<string>) {
|
||||||
await channels.removeUnprocessed(id);
|
await channels.removeUnprocessed(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,7 @@ export type DataInterface = {
|
||||||
arrayOfUnprocessed: Array<UnprocessedType>,
|
arrayOfUnprocessed: Array<UnprocessedType>,
|
||||||
options?: { forceSave?: boolean }
|
options?: { forceSave?: boolean }
|
||||||
) => Promise<void>;
|
) => Promise<void>;
|
||||||
removeUnprocessed: (id: string) => Promise<void>;
|
removeUnprocessed: (id: string | Array<string>) => Promise<void>;
|
||||||
removeAllUnprocessed: () => Promise<void>;
|
removeAllUnprocessed: () => Promise<void>;
|
||||||
|
|
||||||
getNextAttachmentDownloadJobs: (
|
getNextAttachmentDownloadJobs: (
|
||||||
|
|
|
@ -3410,7 +3410,7 @@ async function getAllUnprocessed() {
|
||||||
return rows;
|
return rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function removeUnprocessed(id: string) {
|
async function removeUnprocessed(id: string | Array<string>) {
|
||||||
const db = getInstance();
|
const db = getInstance();
|
||||||
|
|
||||||
if (!Array.isArray(id)) {
|
if (!Array.isArray(id)) {
|
||||||
|
|
24
ts/test-both/util/isNotNil_test.ts
Normal file
24
ts/test-both/util/isNotNil_test.ts
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
// Copyright 2021 Signal Messenger, LLC
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
import { assert } from 'chai';
|
||||||
|
|
||||||
|
import { isNotNil } from '../../util/isNotNil';
|
||||||
|
|
||||||
|
describe('isNotNil', () => {
|
||||||
|
it('returns false if provided null value', () => {
|
||||||
|
assert.isFalse(isNotNil(null));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns false is provided undefined value', () => {
|
||||||
|
assert.isFalse(isNotNil(undefined));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns false is provided any other value', () => {
|
||||||
|
assert.isTrue(isNotNil(0));
|
||||||
|
assert.isTrue(isNotNil(4));
|
||||||
|
assert.isTrue(isNotNil(''));
|
||||||
|
assert.isTrue(isNotNil('string value'));
|
||||||
|
assert.isTrue(isNotNil({}));
|
||||||
|
});
|
||||||
|
});
|
1
ts/textsecure.d.ts
vendored
1
ts/textsecure.d.ts
vendored
|
@ -147,6 +147,7 @@ export type StorageProtocolType = StorageType & {
|
||||||
publicKey?: ArrayBuffer
|
publicKey?: ArrayBuffer
|
||||||
) => Promise<void>;
|
) => Promise<void>;
|
||||||
removeSignedPreKey: (keyId: number) => Promise<void>;
|
removeSignedPreKey: (keyId: number) => Promise<void>;
|
||||||
|
removeAllSessions: (identifier: string) => Promise<void>;
|
||||||
removeAllData: () => Promise<void>;
|
removeAllData: () => Promise<void>;
|
||||||
on: (key: string, callback: () => void) => WhatIsThis;
|
on: (key: string, callback: () => void) => WhatIsThis;
|
||||||
removeAllConfiguration: () => Promise<void>;
|
removeAllConfiguration: () => Promise<void>;
|
||||||
|
|
9
ts/util/isNotNil.ts
Normal file
9
ts/util/isNotNil.ts
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
// Copyright 2021 Signal Messenger, LLC
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
export function isNotNil<T>(value: T | null | undefined): value is T {
|
||||||
|
if (value === null || value === undefined) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
|
@ -281,14 +281,6 @@
|
||||||
"updated": "2020-08-21T11:29:29.636Z",
|
"updated": "2020-08-21T11:29:29.636Z",
|
||||||
"reasonDetail": "Interacting with already-existing DOM nodes"
|
"reasonDetail": "Interacting with already-existing DOM nodes"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"rule": "jQuery-load(",
|
|
||||||
"path": "js/signal_protocol_store.js",
|
|
||||||
"line": " await ConversationController.load();",
|
|
||||||
"lineNumber": 1035,
|
|
||||||
"reasonCategory": "falseMatch",
|
|
||||||
"updated": "2020-06-12T14:20:09.936Z"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"rule": "DOM-innerHTML",
|
"rule": "DOM-innerHTML",
|
||||||
"path": "js/views/app_view.js",
|
"path": "js/views/app_view.js",
|
||||||
|
@ -14326,6 +14318,22 @@
|
||||||
"reasonCategory": "falseMatch",
|
"reasonCategory": "falseMatch",
|
||||||
"updated": "2020-07-21T18:34:59.251Z"
|
"updated": "2020-07-21T18:34:59.251Z"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"rule": "jQuery-load(",
|
||||||
|
"path": "ts/LibSignalStore.js",
|
||||||
|
"line": " await window.ConversationController.load();",
|
||||||
|
"lineNumber": 810,
|
||||||
|
"reasonCategory": "falseMatch",
|
||||||
|
"updated": "2021-02-27T00:48:49.313Z"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"rule": "jQuery-load(",
|
||||||
|
"path": "ts/LibSignalStore.ts",
|
||||||
|
"line": " await window.ConversationController.load();",
|
||||||
|
"lineNumber": 1221,
|
||||||
|
"reasonCategory": "falseMatch",
|
||||||
|
"updated": "2021-02-27T00:48:49.313Z"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"rule": "DOM-innerHTML",
|
"rule": "DOM-innerHTML",
|
||||||
"path": "ts/backbone/views/Lightbox.js",
|
"path": "ts/backbone/views/Lightbox.js",
|
||||||
|
|
3
ts/window.d.ts
vendored
3
ts/window.d.ts
vendored
|
@ -93,6 +93,7 @@ import { Quote } from './components/conversation/Quote';
|
||||||
import { StagedLinkPreview } from './components/conversation/StagedLinkPreview';
|
import { StagedLinkPreview } from './components/conversation/StagedLinkPreview';
|
||||||
import { MIMEType } from './types/MIME';
|
import { MIMEType } from './types/MIME';
|
||||||
import { ElectronLocaleType } from './util/mapToSupportLocale';
|
import { ElectronLocaleType } from './util/mapToSupportLocale';
|
||||||
|
import { SignalProtocolStore } from './LibSignalStore';
|
||||||
|
|
||||||
export { Long } from 'long';
|
export { Long } from 'long';
|
||||||
|
|
||||||
|
@ -238,6 +239,7 @@ declare global {
|
||||||
removeBlockedGroup: (group: string) => void;
|
removeBlockedGroup: (group: string) => void;
|
||||||
removeBlockedNumber: (number: string) => void;
|
removeBlockedNumber: (number: string) => void;
|
||||||
removeBlockedUuid: (uuid: string) => void;
|
removeBlockedUuid: (uuid: string) => void;
|
||||||
|
reset: () => void;
|
||||||
};
|
};
|
||||||
systemTheme: WhatIsThis;
|
systemTheme: WhatIsThis;
|
||||||
textsecure: TextSecureType;
|
textsecure: TextSecureType;
|
||||||
|
@ -512,6 +514,7 @@ declare global {
|
||||||
ConversationController: ConversationController;
|
ConversationController: ConversationController;
|
||||||
Events: WhatIsThis;
|
Events: WhatIsThis;
|
||||||
MessageController: MessageControllerType;
|
MessageController: MessageControllerType;
|
||||||
|
SignalProtocolStore: typeof SignalProtocolStore;
|
||||||
WebAPI: WebAPIConnectType;
|
WebAPI: WebAPIConnectType;
|
||||||
Whisper: WhisperType;
|
Whisper: WhisperType;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue