commit
c593bd2cb1
@ -0,0 +1,30 @@
|
||||
#!/bin/sh
|
||||
if [ -z "$husky_skip_init" ]; then
|
||||
debug () {
|
||||
[ "$HUSKY_DEBUG" = "1" ] && echo "husky (debug) - $1"
|
||||
}
|
||||
|
||||
readonly hook_name="$(basename "$0")"
|
||||
debug "starting $hook_name..."
|
||||
|
||||
if [ "$HUSKY" = "0" ]; then
|
||||
debug "HUSKY env variable is set to 0, skipping hook"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -f ~/.huskyrc ]; then
|
||||
debug "sourcing ~/.huskyrc"
|
||||
. ~/.huskyrc
|
||||
fi
|
||||
|
||||
export readonly husky_skip_init=1
|
||||
sh -e "$0" "$@"
|
||||
exitCode="$?"
|
||||
|
||||
if [ $exitCode != 0 ]; then
|
||||
echo "husky - $hook_name hook exited with code $exitCode (error)"
|
||||
exit $exitCode
|
||||
fi
|
||||
|
||||
exit 0
|
||||
fi
|
@ -0,0 +1,83 @@
|
||||
# Do not edit. File was generated by node-gyp's "configure" step
|
||||
{
|
||||
"target_defaults": {
|
||||
"cflags": [],
|
||||
"default_configuration": "Release",
|
||||
"defines": [],
|
||||
"include_dirs": [],
|
||||
"libraries": []
|
||||
},
|
||||
"variables": {
|
||||
"asan": 0,
|
||||
"build_v8_with_gn": "false",
|
||||
"coverage": "false",
|
||||
"dcheck_always_on": 0,
|
||||
"debug_nghttp2": "false",
|
||||
"debug_node": "false",
|
||||
"enable_lto": "false",
|
||||
"enable_pgo_generate": "false",
|
||||
"enable_pgo_use": "false",
|
||||
"error_on_warn": "false",
|
||||
"force_dynamic_crt": 0,
|
||||
"gas_version": "2.30",
|
||||
"host_arch": "x64",
|
||||
"icu_data_in": "../../deps/icu-tmp/icudt67l.dat",
|
||||
"icu_endianness": "l",
|
||||
"icu_gyp_path": "tools/icu/icu-generic.gyp",
|
||||
"icu_path": "deps/icu-small",
|
||||
"icu_small": "false",
|
||||
"icu_ver_major": "67",
|
||||
"is_debug": 0,
|
||||
"llvm_version": "0.0",
|
||||
"napi_build_version": "7",
|
||||
"node_byteorder": "little",
|
||||
"node_debug_lib": "false",
|
||||
"node_enable_d8": "false",
|
||||
"node_install_npm": "true",
|
||||
"node_module_version": 83,
|
||||
"node_no_browser_globals": "false",
|
||||
"node_prefix": "/",
|
||||
"node_release_urlbase": "https://nodejs.org/download/release/",
|
||||
"node_section_ordering_info": "",
|
||||
"node_shared": "false",
|
||||
"node_shared_brotli": "false",
|
||||
"node_shared_cares": "false",
|
||||
"node_shared_http_parser": "false",
|
||||
"node_shared_libuv": "false",
|
||||
"node_shared_nghttp2": "false",
|
||||
"node_shared_openssl": "false",
|
||||
"node_shared_zlib": "false",
|
||||
"node_tag": "",
|
||||
"node_target_type": "executable",
|
||||
"node_use_bundled_v8": "true",
|
||||
"node_use_dtrace": "false",
|
||||
"node_use_etw": "false",
|
||||
"node_use_node_code_cache": "true",
|
||||
"node_use_node_snapshot": "true",
|
||||
"node_use_openssl": "true",
|
||||
"node_use_v8_platform": "true",
|
||||
"node_with_ltcg": "false",
|
||||
"node_without_node_options": "false",
|
||||
"openssl_fips": "",
|
||||
"openssl_is_fips": "false",
|
||||
"ossfuzz": "false",
|
||||
"shlib_suffix": "so.83",
|
||||
"target_arch": "x64",
|
||||
"v8_enable_31bit_smis_on_64bit_arch": 0,
|
||||
"v8_enable_gdbjit": 0,
|
||||
"v8_enable_i18n_support": 1,
|
||||
"v8_enable_inspector": 1,
|
||||
"v8_enable_lite_mode": 0,
|
||||
"v8_enable_object_print": 1,
|
||||
"v8_enable_pointer_compression": 0,
|
||||
"v8_no_strict_aliasing": 1,
|
||||
"v8_optimized_debug": 1,
|
||||
"v8_promise_internal_field_count": 1,
|
||||
"v8_random_seed": 0,
|
||||
"v8_trace_maps": 0,
|
||||
"v8_use_siphash": 1,
|
||||
"want_separate_host_toolset": 0,
|
||||
"nodedir": "/home/warrick/.cache/node-gyp/14.16.0",
|
||||
"standalone_static_library": 1
|
||||
}
|
||||
}
|
@ -1,10 +1,8 @@
|
||||
{
|
||||
"seedNodeList": [
|
||||
{
|
||||
"ip_url": "http://127.0.0.1:22129/",
|
||||
"url": "http://localhost:22129/"
|
||||
}
|
||||
],
|
||||
"openDevTools": true,
|
||||
"defaultFileServer": "https://file-dev.getsession.org"
|
||||
"openDevTools": true
|
||||
}
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 2.4 KiB |
Binary file not shown.
After Width: | Height: | Size: 4.6 KiB |
@ -1,35 +0,0 @@
|
||||
/* global Whisper */
|
||||
|
||||
// eslint-disable-next-line func-names
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
window.Whisper = window.Whisper || {};
|
||||
|
||||
Whisper.SessionIDResetDialog = Whisper.View.extend({
|
||||
className: 'loki-dialog session-id-reset-dialog modal',
|
||||
initialize(options) {
|
||||
this.close = this.close.bind(this);
|
||||
this.theme = options.theme;
|
||||
this.render();
|
||||
},
|
||||
|
||||
render() {
|
||||
this.dialogView = new Whisper.ReactWrapperView({
|
||||
className: 'session-id-dialog-wrapper',
|
||||
Component: window.Signal.Components.SessionIDResetDialog,
|
||||
props: {
|
||||
onClose: this.close,
|
||||
theme: this.theme,
|
||||
},
|
||||
});
|
||||
|
||||
this.$el.append(this.dialogView.el);
|
||||
return this;
|
||||
},
|
||||
|
||||
close() {
|
||||
this.remove();
|
||||
},
|
||||
});
|
||||
})();
|
File diff suppressed because it is too large
Load Diff
@ -1,39 +0,0 @@
|
||||
// For reference: https://github.com/airbnb/javascript
|
||||
|
||||
module.exports = {
|
||||
env: {
|
||||
mocha: true,
|
||||
browser: true,
|
||||
},
|
||||
|
||||
globals: {
|
||||
assert: true,
|
||||
assertEqualArrayBuffers: true,
|
||||
clearDatabase: true,
|
||||
dcodeIO: true,
|
||||
getString: true,
|
||||
hexToArrayBuffer: true,
|
||||
PROTO_ROOT: true,
|
||||
stringToArrayBuffer: true,
|
||||
},
|
||||
|
||||
parserOptions: {
|
||||
sourceType: 'script',
|
||||
},
|
||||
|
||||
rules: {
|
||||
// We still get the value of this rule, it just allows for dev deps
|
||||
'import/no-extraneous-dependencies': [
|
||||
'error',
|
||||
{
|
||||
devDependencies: true,
|
||||
},
|
||||
],
|
||||
|
||||
// We want to keep each test structured the same, even if its contents are tiny
|
||||
'arrow-body-style': 'off',
|
||||
|
||||
strict: 'off',
|
||||
'more/no-then': 'off',
|
||||
},
|
||||
};
|
@ -1,89 +0,0 @@
|
||||
/* global chai, Whisper, _, Backbone */
|
||||
|
||||
mocha
|
||||
.setup('bdd')
|
||||
.fullTrace()
|
||||
.timeout(10000);
|
||||
window.assert = chai.assert;
|
||||
window.PROTO_ROOT = '../protos';
|
||||
|
||||
const OriginalReporter = mocha._reporter;
|
||||
|
||||
const SauceReporter = function Constructor(runner) {
|
||||
const failedTests = [];
|
||||
|
||||
runner.on('end', () => {
|
||||
window.mochaResults = runner.stats;
|
||||
window.mochaResults.reports = failedTests;
|
||||
});
|
||||
|
||||
runner.on('fail', (test, err) => {
|
||||
const flattenTitles = item => {
|
||||
const titles = [];
|
||||
while (item.parent.title) {
|
||||
titles.push(item.parent.title);
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
item = item.parent;
|
||||
}
|
||||
return titles.reverse();
|
||||
};
|
||||
failedTests.push({
|
||||
name: test.title,
|
||||
result: false,
|
||||
message: err.message,
|
||||
stack: err.stack,
|
||||
titles: flattenTitles(test),
|
||||
});
|
||||
});
|
||||
|
||||
// eslint-disable-next-line no-new
|
||||
new OriginalReporter(runner);
|
||||
};
|
||||
|
||||
SauceReporter.prototype = OriginalReporter.prototype;
|
||||
|
||||
mocha.reporter(SauceReporter);
|
||||
|
||||
// Override the database id.
|
||||
window.Whisper = window.Whisper || {};
|
||||
window.Whisper.Database = window.Whisper.Database || {};
|
||||
Whisper.Database.id = 'test';
|
||||
|
||||
/*
|
||||
* global helpers for tests
|
||||
*/
|
||||
window.assertEqualArrayBuffers = (ab1, ab2) => {
|
||||
assert.deepEqual(new Uint8Array(ab1), new Uint8Array(ab2));
|
||||
};
|
||||
|
||||
window.hexToArrayBuffer = str => {
|
||||
const ret = new ArrayBuffer(str.length / 2);
|
||||
const array = new Uint8Array(ret);
|
||||
for (let i = 0; i < str.length / 2; i += 1) {
|
||||
array[i] = parseInt(str.substr(i * 2, 2), 16);
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
function deleteIndexedDB() {
|
||||
return new Promise((resolve, reject) => {
|
||||
const idbReq = indexedDB.deleteDatabase('test');
|
||||
idbReq.onsuccess = resolve;
|
||||
idbReq.error = reject;
|
||||
});
|
||||
}
|
||||
|
||||
/* Delete the database before running any tests */
|
||||
before(async () => {
|
||||
await deleteIndexedDB();
|
||||
await window.Signal.Data.removeAll();
|
||||
await window.storage.fetch();
|
||||
});
|
||||
|
||||
window.clearDatabase = async () => {
|
||||
await window.Signal.Data.removeAll();
|
||||
await window.storage.fetch();
|
||||
};
|
||||
|
||||
window.Whisper = window.Whisper || {};
|
||||
window.Whisper.events = _.clone(Backbone.Events);
|
@ -1,12 +0,0 @@
|
||||
// For reference: https://github.com/airbnb/javascript
|
||||
|
||||
module.exports = {
|
||||
env: {
|
||||
mocha: true,
|
||||
browser: false,
|
||||
},
|
||||
|
||||
parserOptions: {
|
||||
sourceType: 'module',
|
||||
},
|
||||
};
|
@ -1,170 +0,0 @@
|
||||
[
|
||||
{
|
||||
"label": "Session",
|
||||
"submenu": [
|
||||
{
|
||||
"label": "About",
|
||||
"click": null
|
||||
},
|
||||
{
|
||||
"type": "separator"
|
||||
},
|
||||
{
|
||||
"type": "separator"
|
||||
},
|
||||
{
|
||||
"label": "Hide",
|
||||
"role": "hide"
|
||||
},
|
||||
{
|
||||
"label": "Hide Others",
|
||||
"role": "hideothers"
|
||||
},
|
||||
{
|
||||
"label": "Show All",
|
||||
"role": "unhide"
|
||||
},
|
||||
{
|
||||
"type": "separator"
|
||||
},
|
||||
{
|
||||
"label": "Quit Session",
|
||||
"role": "quit"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "&File"
|
||||
},
|
||||
{
|
||||
"label": "&Edit",
|
||||
"submenu": [
|
||||
{
|
||||
"label": "Undo",
|
||||
"role": "undo"
|
||||
},
|
||||
{
|
||||
"label": "Redo",
|
||||
"role": "redo"
|
||||
},
|
||||
{
|
||||
"type": "separator"
|
||||
},
|
||||
{
|
||||
"label": "Cut",
|
||||
"role": "cut"
|
||||
},
|
||||
{
|
||||
"label": "Copy",
|
||||
"role": "copy"
|
||||
},
|
||||
{
|
||||
"label": "Paste",
|
||||
"role": "paste"
|
||||
},
|
||||
{
|
||||
"label": "Paste and Match Style",
|
||||
"role": "pasteandmatchstyle"
|
||||
},
|
||||
{
|
||||
"label": "Delete",
|
||||
"role": "delete"
|
||||
},
|
||||
{
|
||||
"label": "Select all",
|
||||
"role": "selectall"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "&View",
|
||||
"submenu": [
|
||||
{
|
||||
"label": "Actual Size",
|
||||
"role": "resetzoom"
|
||||
},
|
||||
{
|
||||
"accelerator": "Command+=",
|
||||
"label": "Zoom In",
|
||||
"role": "zoomin"
|
||||
},
|
||||
{
|
||||
"label": "Zoom Out",
|
||||
"role": "zoomout"
|
||||
},
|
||||
{
|
||||
"type": "separator"
|
||||
},
|
||||
{
|
||||
"label": "Toggle Full Screen",
|
||||
"role": "togglefullscreen"
|
||||
},
|
||||
{
|
||||
"type": "separator"
|
||||
},
|
||||
{
|
||||
"label": "Debug Log",
|
||||
"click": null
|
||||
},
|
||||
{
|
||||
"type": "separator"
|
||||
},
|
||||
{
|
||||
"label": "Toggle Developer Tools",
|
||||
"role": "toggledevtools"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "&Window",
|
||||
"role": "window",
|
||||
"submenu": [
|
||||
{
|
||||
"label": "Close Window",
|
||||
"accelerator": "CmdOrCtrl+W",
|
||||
"role": "close"
|
||||
},
|
||||
{
|
||||
"label": "Minimize",
|
||||
"accelerator": "CmdOrCtrl+M",
|
||||
"role": "minimize"
|
||||
},
|
||||
{
|
||||
"label": "Zoom",
|
||||
"role": "zoom"
|
||||
},
|
||||
{
|
||||
"label": "Show",
|
||||
"click": null
|
||||
},
|
||||
{
|
||||
"type": "separator"
|
||||
},
|
||||
{
|
||||
"label": "Bring All to Front",
|
||||
"role": "front"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "&Help",
|
||||
"role": "help",
|
||||
"submenu": [
|
||||
{
|
||||
"label": "Go to Release Notes",
|
||||
"click": null
|
||||
},
|
||||
{
|
||||
"type": "separator"
|
||||
},
|
||||
{
|
||||
"label": "Go to Support Page",
|
||||
"click": null
|
||||
},
|
||||
{
|
||||
"label": "Report an Issue",
|
||||
"click": null
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
@ -1,167 +0,0 @@
|
||||
[
|
||||
{
|
||||
"label": "Session",
|
||||
"submenu": [
|
||||
{
|
||||
"label": "About",
|
||||
"click": null
|
||||
},
|
||||
{
|
||||
"type": "separator"
|
||||
},
|
||||
{
|
||||
"type": "separator"
|
||||
},
|
||||
{
|
||||
"label": "Hide",
|
||||
"role": "hide"
|
||||
},
|
||||
{
|
||||
"label": "Hide Others",
|
||||
"role": "hideothers"
|
||||
},
|
||||
{
|
||||
"label": "Show All",
|
||||
"role": "unhide"
|
||||
},
|
||||
{
|
||||
"type": "separator"
|
||||
},
|
||||
{
|
||||
"label": "Quit Session",
|
||||
"role": "quit"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "&Edit",
|
||||
"submenu": [
|
||||
{
|
||||
"label": "Undo",
|
||||
"role": "undo"
|
||||
},
|
||||
{
|
||||
"label": "Redo",
|
||||
"role": "redo"
|
||||
},
|
||||
{
|
||||
"type": "separator"
|
||||
},
|
||||
{
|
||||
"label": "Cut",
|
||||
"role": "cut"
|
||||
},
|
||||
{
|
||||
"label": "Copy",
|
||||
"role": "copy"
|
||||
},
|
||||
{
|
||||
"label": "Paste",
|
||||
"role": "paste"
|
||||
},
|
||||
{
|
||||
"label": "Paste and Match Style",
|
||||
"role": "pasteandmatchstyle"
|
||||
},
|
||||
{
|
||||
"label": "Delete",
|
||||
"role": "delete"
|
||||
},
|
||||
{
|
||||
"label": "Select all",
|
||||
"role": "selectall"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "&View",
|
||||
"submenu": [
|
||||
{
|
||||
"label": "Actual Size",
|
||||
"role": "resetzoom"
|
||||
},
|
||||
{
|
||||
"accelerator": "Command+=",
|
||||
"label": "Zoom In",
|
||||
"role": "zoomin"
|
||||
},
|
||||
{
|
||||
"label": "Zoom Out",
|
||||
"role": "zoomout"
|
||||
},
|
||||
{
|
||||
"type": "separator"
|
||||
},
|
||||
{
|
||||
"label": "Toggle Full Screen",
|
||||
"role": "togglefullscreen"
|
||||
},
|
||||
{
|
||||
"type": "separator"
|
||||
},
|
||||
{
|
||||
"label": "Debug Log",
|
||||
"click": null
|
||||
},
|
||||
{
|
||||
"type": "separator"
|
||||
},
|
||||
{
|
||||
"label": "Toggle Developer Tools",
|
||||
"role": "toggledevtools"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "&Window",
|
||||
"role": "window",
|
||||
"submenu": [
|
||||
{
|
||||
"label": "Close Window",
|
||||
"accelerator": "CmdOrCtrl+W",
|
||||
"role": "close"
|
||||
},
|
||||
{
|
||||
"label": "Minimize",
|
||||
"accelerator": "CmdOrCtrl+M",
|
||||
"role": "minimize"
|
||||
},
|
||||
{
|
||||
"label": "Zoom",
|
||||
"role": "zoom"
|
||||
},
|
||||
{
|
||||
"label": "Show",
|
||||
"click": null
|
||||
},
|
||||
{
|
||||
"type": "separator"
|
||||
},
|
||||
{
|
||||
"label": "Bring All to Front",
|
||||
"role": "front"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "&Help",
|
||||
"role": "help",
|
||||
"submenu": [
|
||||
{
|
||||
"label": "Go to Release Notes",
|
||||
"click": null
|
||||
},
|
||||
{
|
||||
"type": "separator"
|
||||
},
|
||||
{
|
||||
"label": "Go to Support Page",
|
||||
"click": null
|
||||
},
|
||||
{
|
||||
"label": "Report an Issue",
|
||||
"click": null
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
@ -1,134 +0,0 @@
|
||||
[
|
||||
{
|
||||
"label": "&File",
|
||||
"submenu": [
|
||||
{
|
||||
"type": "separator"
|
||||
},
|
||||
{
|
||||
"type": "separator"
|
||||
},
|
||||
{
|
||||
"label": "Quit Session",
|
||||
"role": "quit"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "&Edit",
|
||||
"submenu": [
|
||||
{
|
||||
"label": "Undo",
|
||||
"role": "undo"
|
||||
},
|
||||
{
|
||||
"label": "Redo",
|
||||
"role": "redo"
|
||||
},
|
||||
{
|
||||
"type": "separator"
|
||||
},
|
||||
{
|
||||
"label": "Cut",
|
||||
"role": "cut"
|
||||
},
|
||||
{
|
||||
"label": "Copy",
|
||||
"role": "copy"
|
||||
},
|
||||
{
|
||||
"label": "Paste",
|
||||
"role": "paste"
|
||||
},
|
||||
{
|
||||
"label": "Paste and Match Style",
|
||||
"role": "pasteandmatchstyle"
|
||||
},
|
||||
{
|
||||
"label": "Delete",
|
||||
"role": "delete"
|
||||
},
|
||||
{
|
||||
"label": "Select all",
|
||||
"role": "selectall"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "&View",
|
||||
"submenu": [
|
||||
{
|
||||
"label": "Actual Size",
|
||||
"role": "resetzoom"
|
||||
},
|
||||
{
|
||||
"accelerator": "Control+Plus",
|
||||
"label": "Zoom In",
|
||||
"role": "zoomin"
|
||||
},
|
||||
{
|
||||
"label": "Zoom Out",
|
||||
"role": "zoomout"
|
||||
},
|
||||
{
|
||||
"type": "separator"
|
||||
},
|
||||
{
|
||||
"label": "Toggle Full Screen",
|
||||
"role": "togglefullscreen"
|
||||
},
|
||||
{
|
||||
"type": "separator"
|
||||
},
|
||||
{
|
||||
"label": "Debug Log",
|
||||
"click": null
|
||||
},
|
||||
{
|
||||
"type": "separator"
|
||||
},
|
||||
{
|
||||
"label": "Toggle Developer Tools",
|
||||
"role": "toggledevtools"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "&Window",
|
||||
"role": "window",
|
||||
"submenu": [
|
||||
{
|
||||
"label": "Minimize",
|
||||
"role": "minimize"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "&Help",
|
||||
"role": "help",
|
||||
"submenu": [
|
||||
{
|
||||
"label": "Go to Release Notes",
|
||||
"click": null
|
||||
},
|
||||
{
|
||||
"type": "separator"
|
||||
},
|
||||
{
|
||||
"label": "Go to Support Page",
|
||||
"click": null
|
||||
},
|
||||
{
|
||||
"label": "Report an Issue",
|
||||
"click": null
|
||||
},
|
||||
{
|
||||
"type": "separator"
|
||||
},
|
||||
{
|
||||
"label": "About",
|
||||
"click": null
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
@ -1,131 +0,0 @@
|
||||
[
|
||||
{
|
||||
"label": "&File",
|
||||
"submenu": [
|
||||
{
|
||||
"type": "separator"
|
||||
},
|
||||
{
|
||||
"label": "Quit Session",
|
||||
"role": "quit"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "&Edit",
|
||||
"submenu": [
|
||||
{
|
||||
"label": "Undo",
|
||||
"role": "undo"
|
||||
},
|
||||
{
|
||||
"label": "Redo",
|
||||
"role": "redo"
|
||||
},
|
||||
{
|
||||
"type": "separator"
|
||||
},
|
||||
{
|
||||
"label": "Cut",
|
||||
"role": "cut"
|
||||
},
|
||||
{
|
||||
"label": "Copy",
|
||||
"role": "copy"
|
||||
},
|
||||
{
|
||||
"label": "Paste",
|
||||
"role": "paste"
|
||||
},
|
||||
{
|
||||
"label": "Paste and Match Style",
|
||||
"role": "pasteandmatchstyle"
|
||||
},
|
||||
{
|
||||
"label": "Delete",
|
||||
"role": "delete"
|
||||
},
|
||||
{
|
||||
"label": "Select all",
|
||||
"role": "selectall"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "&View",
|
||||
"submenu": [
|
||||
{
|
||||
"label": "Actual Size",
|
||||
"role": "resetzoom"
|
||||
},
|
||||
{
|
||||
"accelerator": "Control+Plus",
|
||||
"label": "Zoom In",
|
||||
"role": "zoomin"
|
||||
},
|
||||
{
|
||||
"label": "Zoom Out",
|
||||
"role": "zoomout"
|
||||
},
|
||||
{
|
||||
"type": "separator"
|
||||
},
|
||||
{
|
||||
"label": "Toggle Full Screen",
|
||||
"role": "togglefullscreen"
|
||||
},
|
||||
{
|
||||
"type": "separator"
|
||||
},
|
||||
{
|
||||
"label": "Debug Log",
|
||||
"click": null
|
||||
},
|
||||
{
|
||||
"type": "separator"
|
||||
},
|
||||
{
|
||||
"label": "Toggle Developer Tools",
|
||||
"role": "toggledevtools"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "&Window",
|
||||
"role": "window",
|
||||
"submenu": [
|
||||
{
|
||||
"label": "Minimize",
|
||||
"role": "minimize"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "&Help",
|
||||
"role": "help",
|
||||
"submenu": [
|
||||
{
|
||||
"label": "Go to Release Notes",
|
||||
"click": null
|
||||
},
|
||||
{
|
||||
"type": "separator"
|
||||
},
|
||||
{
|
||||
"label": "Go to Support Page",
|
||||
"click": null
|
||||
},
|
||||
{
|
||||
"label": "Report an Issue",
|
||||
"click": null
|
||||
},
|
||||
{
|
||||
"type": "separator"
|
||||
},
|
||||
{
|
||||
"label": "About",
|
||||
"click": null
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
@ -1,287 +0,0 @@
|
||||
// NOTE: Temporarily allow `then` until we convert the entire file to `async` / `await`:
|
||||
/* eslint-disable more/no-then */
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const tmp = require('tmp');
|
||||
const { expect } = require('chai');
|
||||
|
||||
const {
|
||||
eliminateOutOfDateFiles,
|
||||
eliminateOldEntries,
|
||||
isLineAfterDate,
|
||||
fetchLog,
|
||||
fetch,
|
||||
} = require('../../app/logging');
|
||||
|
||||
describe('app/logging', () => {
|
||||
let basePath;
|
||||
let tmpDir;
|
||||
|
||||
beforeEach(() => {
|
||||
tmpDir = tmp.dirSync({
|
||||
unsafeCleanup: true,
|
||||
});
|
||||
basePath = tmpDir.name;
|
||||
});
|
||||
|
||||
afterEach(done => {
|
||||
// we need the unsafe option to recursively remove the directory
|
||||
try {
|
||||
tmpDir.removeCallback(done);
|
||||
} catch (e) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('removeCallback failed with ', e);
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
describe('#isLineAfterDate', () => {
|
||||
it('returns false if falsy', () => {
|
||||
const actual = isLineAfterDate('', new Date());
|
||||
expect(actual).to.equal(false);
|
||||
});
|
||||
it('returns false if invalid JSON', () => {
|
||||
const actual = isLineAfterDate('{{}', new Date());
|
||||
expect(actual).to.equal(false);
|
||||
});
|
||||
it('returns false if date is invalid', () => {
|
||||
const line = JSON.stringify({ time: '2018-01-04T19:17:05.014Z' });
|
||||
const actual = isLineAfterDate(line, new Date('try6'));
|
||||
expect(actual).to.equal(false);
|
||||
});
|
||||
it('returns false if log time is invalid', () => {
|
||||
const line = JSON.stringify({ time: 'try7' });
|
||||
const date = new Date('2018-01-04T19:17:00.000Z');
|
||||
const actual = isLineAfterDate(line, date);
|
||||
expect(actual).to.equal(false);
|
||||
});
|
||||
it('returns false if date before provided date', () => {
|
||||
const line = JSON.stringify({ time: '2018-01-04T19:17:00.000Z' });
|
||||
const date = new Date('2018-01-04T19:17:05.014Z');
|
||||
const actual = isLineAfterDate(line, date);
|
||||
expect(actual).to.equal(false);
|
||||
});
|
||||
it('returns true if date is after provided date', () => {
|
||||
const line = JSON.stringify({ time: '2018-01-04T19:17:05.014Z' });
|
||||
const date = new Date('2018-01-04T19:17:00.000Z');
|
||||
const actual = isLineAfterDate(line, date);
|
||||
expect(actual).to.equal(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#eliminateOutOfDateFiles', () => {
|
||||
it('deletes an empty file', () => {
|
||||
const date = new Date();
|
||||
const log = '\n';
|
||||
const target = path.join(basePath, 'log.log');
|
||||
fs.writeFileSync(target, log);
|
||||
|
||||
return eliminateOutOfDateFiles(basePath, date).then(() => {
|
||||
expect(fs.existsSync(target)).to.equal(false);
|
||||
});
|
||||
});
|
||||
it('deletes a file with invalid JSON lines', () => {
|
||||
const date = new Date();
|
||||
const log = '{{}\n';
|
||||
const target = path.join(basePath, 'log.log');
|
||||
fs.writeFileSync(target, log);
|
||||
|
||||
return eliminateOutOfDateFiles(basePath, date).then(() => {
|
||||
expect(fs.existsSync(target)).to.equal(false);
|
||||
});
|
||||
});
|
||||
it('deletes a file with all dates before provided date', () => {
|
||||
const date = new Date('2018-01-04T19:17:05.014Z');
|
||||
const contents = [
|
||||
JSON.stringify({ time: '2018-01-04T19:17:00.014Z' }),
|
||||
JSON.stringify({ time: '2018-01-04T19:17:01.014Z' }),
|
||||
JSON.stringify({ time: '2018-01-04T19:17:02.014Z' }),
|
||||
JSON.stringify({ time: '2018-01-04T19:17:03.014Z' }),
|
||||
].join('\n');
|
||||
const target = path.join(basePath, 'log.log');
|
||||
fs.writeFileSync(target, contents);
|
||||
|
||||
return eliminateOutOfDateFiles(basePath, date).then(() => {
|
||||
expect(fs.existsSync(target)).to.equal(false);
|
||||
});
|
||||
});
|
||||
it('keeps a file with first line date before provided date', () => {
|
||||
const date = new Date('2018-01-04T19:16:00.000Z');
|
||||
const contents = [
|
||||
JSON.stringify({ time: '2018-01-04T19:17:00.014Z' }),
|
||||
JSON.stringify({ time: '2018-01-04T19:17:01.014Z' }),
|
||||
JSON.stringify({ time: '2018-01-04T19:17:02.014Z' }),
|
||||
JSON.stringify({ time: '2018-01-04T19:17:03.014Z' }),
|
||||
].join('\n');
|
||||
const target = path.join(basePath, 'log.log');
|
||||
fs.writeFileSync(target, contents);
|
||||
|
||||
return eliminateOutOfDateFiles(basePath, date).then(() => {
|
||||
expect(fs.existsSync(target)).to.equal(true);
|
||||
});
|
||||
});
|
||||
it('keeps a file with last line date before provided date', () => {
|
||||
const date = new Date('2018-01-04T19:17:01.000Z');
|
||||
const contents = [
|
||||
JSON.stringify({ time: '2018-01-04T19:17:00.014Z' }),
|
||||
JSON.stringify({ time: '2018-01-04T19:17:01.014Z' }),
|
||||
JSON.stringify({ time: '2018-01-04T19:17:02.014Z' }),
|
||||
JSON.stringify({ time: '2018-01-04T19:17:03.014Z' }),
|
||||
].join('\n');
|
||||
const target = path.join(basePath, 'log.log');
|
||||
fs.writeFileSync(target, contents);
|
||||
|
||||
return eliminateOutOfDateFiles(basePath, date).then(() => {
|
||||
expect(fs.existsSync(target)).to.equal(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('#eliminateOldEntries', () => {
|
||||
it('eliminates all non-parsing entries', () => {
|
||||
const date = new Date('2018-01-04T19:17:01.000Z');
|
||||
const contents = [
|
||||
'random line',
|
||||
JSON.stringify({ time: '2018-01-04T19:17:01.014Z' }),
|
||||
JSON.stringify({ time: '2018-01-04T19:17:02.014Z' }),
|
||||
JSON.stringify({ time: '2018-01-04T19:17:03.014Z' }),
|
||||
].join('\n');
|
||||
const expected = [
|
||||
JSON.stringify({ time: '2018-01-04T19:17:01.014Z' }),
|
||||
JSON.stringify({ time: '2018-01-04T19:17:02.014Z' }),
|
||||
JSON.stringify({ time: '2018-01-04T19:17:03.014Z' }),
|
||||
].join('\n');
|
||||
|
||||
const target = path.join(basePath, 'log.log');
|
||||
const files = [
|
||||
{
|
||||
path: target,
|
||||
},
|
||||
];
|
||||
|
||||
fs.writeFileSync(target, contents);
|
||||
|
||||
return eliminateOldEntries(files, date).then(() => {
|
||||
expect(fs.readFileSync(target, 'utf8')).to.equal(`${expected}\n`);
|
||||
});
|
||||
});
|
||||
it('preserves all lines if before target date', () => {
|
||||
const date = new Date('2018-01-04T19:17:03.000Z');
|
||||
const contents = [
|
||||
'random line',
|
||||
JSON.stringify({ time: '2018-01-04T19:17:01.014Z' }),
|
||||
JSON.stringify({ time: '2018-01-04T19:17:02.014Z' }),
|
||||
JSON.stringify({ time: '2018-01-04T19:17:03.014Z' }),
|
||||
].join('\n');
|
||||
const expected = [JSON.stringify({ time: '2018-01-04T19:17:03.014Z' })].join('\n');
|
||||
|
||||
const target = path.join(basePath, 'log.log');
|
||||
const files = [
|
||||
{
|
||||
path: target,
|
||||
},
|
||||
];
|
||||
|
||||
fs.writeFileSync(target, contents);
|
||||
|
||||
return eliminateOldEntries(files, date).then(() => {
|
||||
expect(fs.readFileSync(target, 'utf8')).to.equal(`${expected}\n`);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('#fetchLog', () => {
|
||||
it('returns error if file does not exist', () => {
|
||||
const target = 'random_file';
|
||||
return fetchLog(target).then(
|
||||
() => {
|
||||
throw new Error('Expected an error!');
|
||||
},
|
||||
error => {
|
||||
expect(error)
|
||||
.to.have.property('message')
|
||||
.that.match(/random_file/);
|
||||
}
|
||||
);
|
||||
});
|
||||
it('returns empty array if file has no valid JSON lines', () => {
|
||||
const contents = 'line 1\nline2\n';
|
||||
const expected = [];
|
||||
const target = path.join(basePath, 'test.log');
|
||||
|
||||
fs.writeFileSync(target, contents);
|
||||
|
||||
return fetchLog(target).then(result => {
|
||||
expect(result).to.deep.equal(expected);
|
||||
});
|
||||
});
|
||||
it('returns just three fields in each returned line', () => {
|
||||
const contents = [
|
||||
JSON.stringify({
|
||||
one: 1,
|
||||
two: 2,
|
||||
level: 1,
|
||||
time: 2,
|
||||
msg: 3,
|
||||
}),
|
||||
JSON.stringify({
|
||||
one: 1,
|
||||
two: 2,
|
||||
level: 2,
|
||||
time: 3,
|
||||
msg: 4,
|
||||
}),
|
||||
'',
|
||||
].join('\n');
|
||||
const expected = [
|
||||
{
|
||||
level: 1,
|
||||
time: 2,
|
||||
msg: 3,
|
||||
},
|
||||
{
|
||||
level: 2,
|
||||
time: 3,
|
||||
msg: 4,
|
||||
},
|
||||
];
|
||||
|
||||
const target = path.join(basePath, 'test.log');
|
||||
|
||||
fs.writeFileSync(target, contents);
|
||||
|
||||
return fetchLog(target).then(result => {
|
||||
expect(result).to.deep.equal(expected);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('#fetch', () => {
|
||||
it('returns single entry if no files', () => {
|
||||
return fetch(basePath).then(results => {
|
||||
expect(results).to.have.length(1);
|
||||
expect(results[0].msg).to.match(/Loaded this list/);
|
||||
});
|
||||
});
|
||||
it('returns sorted entries from all files', () => {
|
||||
const first = [JSON.stringify({ msg: 2, time: '2018-01-04T19:17:05.014Z' }), ''].join('\n');
|
||||
const second = [
|
||||
JSON.stringify({ msg: 1, time: '2018-01-04T19:17:00.014Z' }),
|
||||
JSON.stringify({ msg: 3, time: '2018-01-04T19:18:00.014Z' }),
|
||||
'',
|
||||
].join('\n');
|
||||
|
||||
fs.writeFileSync(path.join(basePath, 'first.log'), first);
|
||||
fs.writeFileSync(path.join(basePath, 'second.log'), second);
|
||||
|
||||
return fetch(basePath).then(results => {
|
||||
expect(results).to.have.length(4);
|
||||
expect(results[0].msg).to.equal(1);
|
||||
expect(results[1].msg).to.equal(2);
|
||||
expect(results[2].msg).to.equal(3);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
@ -1,73 +0,0 @@
|
||||
const { assert } = require('chai');
|
||||
|
||||
const SignalMenu = require('../../app/menu');
|
||||
const { load: loadLocale } = require('../../app/locale');
|
||||
|
||||
const PLATFORMS = [
|
||||
{
|
||||
label: 'macOS',
|
||||
platform: 'darwin',
|
||||
fixtures: {
|
||||
default: './fixtures/menu-mac-os',
|
||||
setup: './fixtures/menu-mac-os-setup',
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Windows',
|
||||
platform: 'win32',
|
||||
fixtures: {
|
||||
default: './fixtures/menu-windows-linux',
|
||||
setup: './fixtures/menu-windows-linux-setup',
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Linux',
|
||||
platform: 'linux',
|
||||
fixtures: {
|
||||
default: './fixtures/menu-windows-linux',
|
||||
setup: './fixtures/menu-windows-linux-setup',
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
const INCLUDE_SETUP_OPTIONS = [false, true];
|
||||
|
||||
describe('SignalMenu', () => {
|
||||
describe('createTemplate', () => {
|
||||
PLATFORMS.forEach(({ label, platform, fixtures }) => {
|
||||
context(label, () => {
|
||||
INCLUDE_SETUP_OPTIONS.forEach(includeSetup => {
|
||||
const prefix = includeSetup ? 'with' : 'without';
|
||||
context(`${prefix} setup options`, () => {
|
||||
it('should return correct template', () => {
|
||||
const logger = {
|
||||
error(message) {
|
||||
throw new Error(message);
|
||||
},
|
||||
};
|
||||
const options = {
|
||||
openNewBugForm: null,
|
||||
openReleaseNotes: null,
|
||||
openSupportPage: null,
|
||||
platform,
|
||||
includeSetup,
|
||||
showAbout: null,
|
||||
showDebugLog: null,
|
||||
showSettings: null,
|
||||
showWindow: null,
|
||||
};
|
||||
const appLocale = 'en';
|
||||
const { messages } = loadLocale({ appLocale, logger });
|
||||
|
||||
const actual = SignalMenu.createTemplate(options, messages);
|
||||
const fixturePath = includeSetup ? fixtures.setup : fixtures.default;
|
||||
// eslint-disable-next-line global-require, import/no-dynamic-require
|
||||
const fixture = require(fixturePath);
|
||||
assert.deepEqual(actual, fixture);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
@ -1,85 +0,0 @@
|
||||
const { expect } = require('chai');
|
||||
|
||||
const { _urlToPath } = require('../../app/protocol_filter');
|
||||
|
||||
describe('Protocol Filter', () => {
|
||||
describe('_urlToPath', () => {
|
||||
it('returns proper file path for unix style file URI with hash', () => {
|
||||
const path = 'file:///Users/someone/Development/signal/electron/background.html#first-page';
|
||||
const expected = '/Users/someone/Development/signal/electron/background.html';
|
||||
|
||||
const actual = _urlToPath(path);
|
||||
expect(actual).to.equal(expected);
|
||||
});
|
||||
|
||||
it('returns proper file path for unix style file URI with querystring', () => {
|
||||
const path =
|
||||
'file:///Users/someone/Development/signal/electron/background.html?name=Signal&locale=en&version=2.4.0';
|
||||
const expected = '/Users/someone/Development/signal/electron/background.html';
|
||||
|
||||
const actual = _urlToPath(path);
|
||||
expect(actual).to.equal(expected);
|
||||
});
|
||||
|
||||
it('returns proper file path for unix style file URI with hash and querystring', () => {
|
||||
const path =
|
||||
'file:///Users/someone/Development/signal/electron/background.html#somewhere?name=Signal';
|
||||
const expected = '/Users/someone/Development/signal/electron/background.html';
|
||||
|
||||
const actual = _urlToPath(path);
|
||||
expect(actual).to.equal(expected);
|
||||
});
|
||||
|
||||
it('returns proper file path for file URI on windows', () => {
|
||||
const path =
|
||||
'file:///C:/Users/Someone/dev/desktop/background.html?name=Signal&locale=en&version=2.4.0';
|
||||
const expected = 'C:/Users/Someone/dev/desktop/background.html';
|
||||
const isWindows = true;
|
||||
|
||||
const actual = _urlToPath(path, { isWindows });
|
||||
expect(actual).to.equal(expected);
|
||||
});
|
||||
|
||||
it('translates from URL format to filesystem format', () => {
|
||||
const path = 'file:///Users/someone/Development%20Files/signal/electron/background.html';
|
||||
const expected = '/Users/someone/Development Files/signal/electron/background.html';
|
||||
|
||||
const actual = _urlToPath(path);
|
||||
expect(actual).to.equal(expected);
|
||||
});
|
||||
|
||||
it('translates from URL format to filesystem format', () => {
|
||||
const path = 'file:///Users/someone/Development%20Files/signal/electron/background.html';
|
||||
const expected = '/Users/someone/Development Files/signal/electron/background.html';
|
||||
|
||||
const actual = _urlToPath(path);
|
||||
expect(actual).to.equal(expected);
|
||||
});
|
||||
|
||||
// this seems to be the only way to get a relative path through Electron
|
||||
it('handles SMB share path', () => {
|
||||
const path = 'file://relative/path';
|
||||
const expected = 'relative/path';
|
||||
|
||||
const actual = _urlToPath(path);
|
||||
expect(actual).to.equal(expected);
|
||||
});
|
||||
|
||||
it('handles SMB share path on windows', () => {
|
||||
const path = 'file://relative/path';
|
||||
const expected = 'elative/path';
|
||||
const isWindows = true;
|
||||
|
||||
const actual = _urlToPath(path, { isWindows });
|
||||
expect(actual).to.equal(expected);
|
||||
});
|
||||
|
||||
it('hands back a path with .. in it', () => {
|
||||
const path = 'file://../../..';
|
||||
const expected = '../../..';
|
||||
|
||||
const actual = _urlToPath(path);
|
||||
expect(actual).to.equal(expected);
|
||||
});
|
||||
});
|
||||
});
|
File diff suppressed because one or more lines are too long
@ -1,112 +0,0 @@
|
||||
/* global Signal, textsecure, libsignal */
|
||||
|
||||
'use strict';
|
||||
|
||||
describe('Crypto', () => {
|
||||
describe('symmetric encryption', () => {
|
||||
it('roundtrips', async () => {
|
||||
const message = 'this is my message';
|
||||
const plaintext = dcodeIO.ByteBuffer.wrap(message, 'binary').toArrayBuffer();
|
||||
const key = textsecure.crypto.getRandomBytes(32);
|
||||
|
||||
const encrypted = await Signal.Crypto.encryptSymmetric(key, plaintext);
|
||||
const decrypted = await Signal.Crypto.decryptSymmetric(key, encrypted);
|
||||
|
||||
const equal = Signal.Crypto.constantTimeEqual(plaintext, decrypted);
|
||||
if (!equal) {
|
||||
throw new Error('The output and input did not match!');
|
||||
}
|
||||
});
|
||||
|
||||
it('roundtrip fails if nonce is modified', async () => {
|
||||
const message = 'this is my message';
|
||||
const plaintext = dcodeIO.ByteBuffer.wrap(message, 'binary').toArrayBuffer();
|
||||
const key = textsecure.crypto.getRandomBytes(32);
|
||||
|
||||
const encrypted = await Signal.Crypto.encryptSymmetric(key, plaintext);
|
||||
const uintArray = new Uint8Array(encrypted);
|
||||
uintArray[2] += 2;
|
||||
|
||||
try {
|
||||
await Signal.Crypto.decryptSymmetric(key, uintArray.buffer);
|
||||
} catch (error) {
|
||||
assert.strictEqual(
|
||||
error.message,
|
||||
'decryptSymmetric: Failed to decrypt; MAC verification failed'
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
throw new Error('Expected error to be thrown');
|
||||
});
|
||||
|
||||
it('roundtrip fails if mac is modified', async () => {
|
||||
const message = 'this is my message';
|
||||
const plaintext = dcodeIO.ByteBuffer.wrap(message, 'binary').toArrayBuffer();
|
||||
const key = textsecure.crypto.getRandomBytes(32);
|
||||
|
||||
const encrypted = await Signal.Crypto.encryptSymmetric(key, plaintext);
|
||||
const uintArray = new Uint8Array(encrypted);
|
||||
uintArray[uintArray.length - 3] += 2;
|
||||
|
||||
try {
|
||||
await Signal.Crypto.decryptSymmetric(key, uintArray.buffer);
|
||||
} catch (error) {
|
||||
assert.strictEqual(
|
||||
error.message,
|
||||
'decryptSymmetric: Failed to decrypt; MAC verification failed'
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
throw new Error('Expected error to be thrown');
|
||||
});
|
||||
|
||||
it('roundtrip fails if encrypted contents are modified', async () => {
|
||||
const message = 'this is my message';
|
||||
const plaintext = dcodeIO.ByteBuffer.wrap(message, 'binary').toArrayBuffer();
|
||||
const key = textsecure.crypto.getRandomBytes(32);
|
||||
|
||||
const encrypted = await Signal.Crypto.encryptSymmetric(key, plaintext);
|
||||
const uintArray = new Uint8Array(encrypted);
|
||||
uintArray[35] += 9;
|
||||
|
||||
try {
|
||||
await Signal.Crypto.decryptSymmetric(key, uintArray.buffer);
|
||||
} catch (error) {
|
||||
assert.strictEqual(
|
||||
error.message,
|
||||
'decryptSymmetric: Failed to decrypt; MAC verification failed'
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
throw new Error('Expected error to be thrown');
|
||||
});
|
||||
});
|
||||
|
||||
describe('attachment encryption', () => {
|
||||
it('roundtrips', async () => {
|
||||
const staticKeyPair = await libsignal.KeyHelper.generateIdentityKeyPair();
|
||||
const message = 'this is my message';
|
||||
const plaintext = Signal.Crypto.bytesFromString(message);
|
||||
const path = 'fa/facdf99c22945b1c9393345599a276f4b36ad7ccdc8c2467f5441b742c2d11fa';
|
||||
|
||||
const encrypted = await Signal.Crypto.encryptAttachment(
|
||||
staticKeyPair.pubKey.slice(1),
|
||||
path,
|
||||
plaintext
|
||||
);
|
||||
const decrypted = await Signal.Crypto.decryptAttachment(
|
||||
staticKeyPair.privKey,
|
||||
path,
|
||||
encrypted
|
||||
);
|
||||
|
||||
const equal = Signal.Crypto.constantTimeEqual(plaintext, decrypted);
|
||||
if (!equal) {
|
||||
throw new Error('The output and input did not match!');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
@ -1,36 +0,0 @@
|
||||
/* global Whisper */
|
||||
|
||||
'use strict';
|
||||
|
||||
describe('Database', () => {
|
||||
describe('handleDOMException', () => {
|
||||
it('handles null, still calls reject', () => {
|
||||
let called = 0;
|
||||
const reject = () => {
|
||||
called += 1;
|
||||
};
|
||||
const error = null;
|
||||
const prefix = 'something';
|
||||
|
||||
Whisper.Database.handleDOMException(prefix, error, reject);
|
||||
|
||||
assert.strictEqual(called, 1);
|
||||
});
|
||||
|
||||
it('handles object code and message', () => {
|
||||
let called = 0;
|
||||
const reject = () => {
|
||||
called += 1;
|
||||
};
|
||||
const error = {
|
||||
code: 4,
|
||||
message: 'some cryptic error',
|
||||
};
|
||||
const prefix = 'something';
|
||||
|
||||
Whisper.Database.handleDOMException(prefix, error, reject);
|
||||
|
||||
assert.strictEqual(called, 1);
|
||||
});
|
||||
});
|
||||
});
|
File diff suppressed because it is too large
Load Diff
@ -1,34 +0,0 @@
|
||||
/* global $, textsecure, Whisper */
|
||||
|
||||
'use strict';
|
||||
|
||||
describe('Fixtures', () => {
|
||||
before(async () => {
|
||||
// NetworkStatusView checks this method every five seconds while showing
|
||||
|
||||
await clearDatabase();
|
||||
await textsecure.storage.user.setNumberAndDeviceId(
|
||||
'05123456789abcdef05123456789abcdef05123456789abcdef05123456789abcd',
|
||||
2,
|
||||
'testDevice'
|
||||
);
|
||||
|
||||
await window
|
||||
.getConversationController()
|
||||
.getOrCreateAndWait(window.libsession.Utils.UserUtils.getOurPubKeyStrFromCache(), 'private');
|
||||
});
|
||||
|
||||
it('renders', async () => {
|
||||
await Whisper.Fixtures().saveAll();
|
||||
|
||||
window.getConversationController().reset();
|
||||
await window.getConversationController().load();
|
||||
|
||||
let view = new Whisper.InboxView({ window });
|
||||
view.$el.prependTo($('#render-light-theme'));
|
||||
|
||||
view = new Whisper.InboxView({ window });
|
||||
view.$el.removeClass('light-theme').addClass('dark-theme');
|
||||
view.$el.prependTo($('#render-dark-theme'));
|
||||
});
|
||||
});
|
@ -1,27 +0,0 @@
|
||||
/* global i18n */
|
||||
|
||||
describe('i18n', () => {
|
||||
describe('i18n', () => {
|
||||
it('returns empty string for unknown string', () => {
|
||||
assert.strictEqual(i18n('random'), '');
|
||||
});
|
||||
it('returns message for given string', () => {
|
||||
assert.equal(i18n('reportIssue'), 'Report an issue');
|
||||
});
|
||||
it('returns message with single substitution', () => {
|
||||
const actual = i18n('attemptingReconnection', 5);
|
||||
assert.equal(actual, 'Attempting reconnect in 5 seconds');
|
||||
});
|
||||
it('returns message with multiple substitutions', () => {
|
||||
const actual = i18n('theyChangedTheTimer', ['Someone', '5 minutes']);
|
||||
assert.equal(actual, 'Someone set the disappearing message timer to 5 minutes');
|
||||
});
|
||||
});
|
||||
|
||||
describe('getLocale', () => {
|
||||
it('returns a string with length two or greater', () => {
|
||||
const locale = i18n.getLocale();
|
||||
assert.isAtLeast(locale.trim().length, 2);
|
||||
});
|
||||
});
|
||||
});
|
@ -1,63 +0,0 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>TextSecure test runner</title>
|
||||
<link rel="stylesheet" href="../node_modules/mocha/mocha.css" />
|
||||
<link rel="stylesheet" href="../stylesheets/manifest.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="mocha">
|
||||
</div>
|
||||
<div id="tests">
|
||||
</div>
|
||||
<div id="render-light-theme" class="index" style="width: 800; height: 500; margin:10px; border: solid 1px black;">
|
||||
</div>
|
||||
<div id="render-dark-theme" class="index" style="width: 800; height: 500; margin:10px; border: solid 1px black;">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript" src="../js/components.js"></script>
|
||||
<script type="text/javascript" src="test.js"></script>
|
||||
|
||||
<script type="text/javascript" src="../js/registration.js" data-cover></script>
|
||||
<script type="text/javascript" src="../js/chromium.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/libtextsecure.js" data-cover></script>
|
||||
|
||||
<script type="text/javascript" src="../js/expiring_messages.js" data-cover></script>
|
||||
<script type="text/javascript" src="../js/notifications.js" data-cover></script>
|
||||
<script type="text/javascript" src="../js/focus_listener.js"></script>
|
||||
|
||||
<script type="text/javascript" src="../js/chromium.js" data-cover></script>
|
||||
|
||||
<script type="text/javascript" src="../js/views/react_wrapper_view.js"></script>
|
||||
<script type="text/javascript" src="../js/views/whisper_view.js"></script>
|
||||
|
||||
<script type='text/javascript' src='../js/views/session_inbox_view.js'></script>
|
||||
<script type="text/javascript" src="../js/views/identicon_svg_view.js"></script>
|
||||
<script type="text/javascript" src="../js/views/session_registration_view.js"></script>
|
||||
<script type="text/javascript" src="../js/views/app_view.js"></script>
|
||||
|
||||
<!-- DIALOGS-->
|
||||
<script type="text/javascript" src="views/whisper_view_test.js"></script>
|
||||
|
||||
<script type="text/javascript" src="models/conversations_test.js"></script>
|
||||
<script type="text/javascript" src="models/messages_test.js"></script>
|
||||
|
||||
<script type="text/javascript" src="database_test.js"></script>
|
||||
<script type="text/javascript" src="i18n_test.js"></script>
|
||||
|
||||
<script type="text/javascript" src="fixtures.js"></script>
|
||||
<script type="text/javascript" src="fixtures_test.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
mocha.run();
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
@ -1,51 +0,0 @@
|
||||
Manual test script
|
||||
|
||||
Some things are very difficult to test programmatically. Also, if you don't have adequate test coverage, a good first step is a comprehensive manual test script! https://blog.scottnonnenberg.com/web-application-test-strategy/
|
||||
|
||||
Conversation view:
|
||||
Last seen indicator:
|
||||
(dismissed three ways: 1. sending a message 2. switching away from conversation and back again 3. clicking scroll down button when last seen indicator is off-screen above)
|
||||
|
||||
- Switch away from Signal app, but keep it visible
|
||||
- Receive messages to conversation out of focus, and the last seen indicator should move up the screen with each new message. When the number of new messages can no longer fit on the screen, the last seen indicator should stay at the top of the screen, and new messages will appear below. The scroll down button will turn blue to indicate new messages out of view.
|
||||
- Switch back to Signal app, and the last seen indicator and scroll down button should stay where they are.
|
||||
- Click the scroll down button to go to the bottom of the window, and the button should disappear.
|
||||
- Send a message, then scroll up. The last seen indicator should be gone.
|
||||
|
||||
- Switch to a different conversation, then receive messages on original conversation
|
||||
- Switch back to original conversation, and the last seen indicator should be visible
|
||||
- Switch away from conversation and back. The last seen indicator should be gone.
|
||||
|
||||
- Switch to a different conversation, then receive a lot of messages on original conversation
|
||||
- Switch back to original conversation, and the last seen indicator should be visible, along with the scroll down button.
|
||||
- Click the scroll down button to be taken to the newest message in the conversation
|
||||
|
||||
- Scroll up on a conversation then switch to another application, keeping the Signal application visible. Receive new messages on that conversation. Switch back to application. The scroll down button should be blue, and the conversation scroll location should stay where it was. There should be a last seen indicator visible above the new messages.
|
||||
|
||||
- Scroll to bottom of a conversation, then switch to another application, keeping Signal application visible. Receive new messages on that conversation. As new messages come in, the last seen indicator should march up the screen. Before it reaches the top, switch back to the application. This will mark those messages as read. Switch away from the application again, and receive new messages. The last seen indicator will scroll off the top of the screen as more and more new messages come in.
|
||||
|
||||
- ADVANCED: Set up an automated script (or friend) to send you repeated messages. You should see the right number of unread upon entry of the conversation, along with with the last seen indicator. While the conversation is focused, new messages should increment the last seen indicator until it is offscreen above. Click the scroll down button to eliminate the last seen indicator, then scroll up. New messages received while scrolled up should not scroll the conversation, but will add a new last seen indicator and scroll down button.
|
||||
|
||||
- ADVANCED: Set fetch limit to a low number, like 3 (in models/messages.js, fetchConversation function). Load the application, and don't select the conversation. Receive more than four new messages in that conversation. Select the conversation. The last seen indicator should reflect the total number of new messages and all of them should be visible.
|
||||
|
||||
Marking messages as unread:
|
||||
- Switch to a different conversation, then receive lots of messages on original conversation, more than would fill the screen
|
||||
- Note the count before clicking into the conversation. Count the number of visible messages and ensure that the conversation's unread count is decremented by the right amount.
|
||||
- Slowly scroll down so that one more message is visible. The conversation unread count should go down by one.
|
||||
- Click the scroll down button. All messages should be marked read - even if you skipped a couple screens to get to the bottom.
|
||||
|
||||
Scrolling:
|
||||
- If scrolled to bottom of a conversation, should stay there when a new message comes in
|
||||
- If scrolled to the middle of a conversation, should stay there when a new message comes in
|
||||
- When you've scrolled up an entire screen's worth, a scroll down button in the bottom right should appear.
|
||||
|
||||
Scroll-down button:
|
||||
- Clicking it takes you to the bottom of the conversation, makes the button disappear
|
||||
- If a new message comes in while it is already showing, it turns blue
|
||||
- If a new message comes in while not at the bottom of the conversation (but button is not already showing), it should appear, already blue.
|
||||
- If you've scrolled up higher than the last seen indicator, then clicking the scroll down button should take you to the last seen indicator. Once there, clicking the button will take you to the bottom of the conversation, at which point the button will disappear.
|
||||
|
||||
Electron window locations
|
||||
- Load app, move and resize window, close app. Start app. Window should be in the same place, with the same size.
|
||||
- (OSX) Load app, full-screen window, close app. Start app. Window should be full screen.
|
||||
- (Windows) Load app, maximize window, close app. Start app. Window should be maximized.
|
@ -1,129 +0,0 @@
|
||||
// /* global textsecure, Whisper */
|
||||
|
||||
// 'use strict';
|
||||
// FIXME audric enable back those test
|
||||
describe('ConversationCollection', () => {
|
||||
// textsecure.messaging = true;
|
||||
// before(clearDatabase);
|
||||
// after(clearDatabase);
|
||||
// it('should be ordered newest to oldest', () => {
|
||||
// const conversations = new window.models.Conversation.ConversationCollection();
|
||||
// // Timestamps
|
||||
// const today = new Date();
|
||||
// const tomorrow = new Date();
|
||||
// tomorrow.setDate(today.getDate() + 1);
|
||||
// // Add convos
|
||||
// conversations.add({ active_at: today });
|
||||
// conversations.add({ active_at: tomorrow });
|
||||
// const { models } = conversations;
|
||||
// const firstTimestamp = models[0].get('active_at').getTime();
|
||||
// const secondTimestamp = models[1].get('active_at').getTime();
|
||||
// // Compare timestamps
|
||||
// assert(firstTimestamp > secondTimestamp);
|
||||
// });
|
||||
// });
|
||||
// describe('Conversation', () => {
|
||||
// const attributes = {
|
||||
// type: 'private',
|
||||
// id: '051d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94ab',
|
||||
// };
|
||||
// before(async () => {
|
||||
// const convo = new window.models.Conversation.ConversationCollection().add(attributes);
|
||||
// await window.Signal.Data.saveConversation(convo.attributes, {
|
||||
// Conversation: window.models.Conversation.ConversationModel,
|
||||
// });
|
||||
// // const message = convo.messageCollection.add({
|
||||
// // body: 'hello world',
|
||||
// // conversationId: convo.id,
|
||||
// // type: 'outgoing',
|
||||
// // sent_at: Date.now(),
|
||||
// // received_at: Date.now(),
|
||||
// // });
|
||||
// // await message.commit(false);
|
||||
// });
|
||||
// after(clearDatabase);
|
||||
// it('contains its own messages', async () => {
|
||||
// const convo = new window.models.Conversation.ConversationCollection().add({
|
||||
// id: '051d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94ab',
|
||||
// });
|
||||
// await convo.fetchMessages();
|
||||
// assert.notEqual(convo.messageCollection.length, 0);
|
||||
// });
|
||||
// it('contains only its own messages', async () => {
|
||||
// const convo = new window.models.Conversation.ConversationCollection().add({
|
||||
// id: '052d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94ab',
|
||||
// });
|
||||
// await convo.fetchMessages();
|
||||
// assert.strictEqual(convo.messageCollection.length, 0);
|
||||
// });
|
||||
// it('adds conversation to message collection upon leaving group', async () => {
|
||||
// const convo = new window.models.Conversation.ConversationCollection().add({
|
||||
// type: 'group',
|
||||
// id: '052d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94ab',
|
||||
// });
|
||||
// await convo.leaveClosedGroup();
|
||||
// assert.notEqual(convo.messageCollection.length, 0);
|
||||
// });
|
||||
// it('has a title', () => {
|
||||
// const convos = new window.models.Conversation.ConversationCollection();
|
||||
// let convo = convos.add(attributes);
|
||||
// assert.equal(
|
||||
// convo.getTitle(),
|
||||
// '051d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94ab'
|
||||
// );
|
||||
// convo = convos.add({ type: '' });
|
||||
// assert.equal(convo.getTitle(), 'Unknown group');
|
||||
// convo = convos.add({ name: 'name' });
|
||||
// assert.equal(convo.getTitle(), 'name');
|
||||
// });
|
||||
// it('returns the number', () => {
|
||||
// const convos = new window.models.Conversation.ConversationCollection();
|
||||
// let convo = convos.add(attributes);
|
||||
// assert.equal(
|
||||
// convo.getNumber(),
|
||||
// '051d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94ab'
|
||||
// );
|
||||
// convo = convos.add({ type: '' });
|
||||
// assert.equal(convo.getNumber(), '');
|
||||
// });
|
||||
// describe('when set to private', () => {
|
||||
// it('correctly validates hex numbers', () => {
|
||||
// const regularId = new window.models.Conversation.ConversationModel({
|
||||
// type: 'private',
|
||||
// id:
|
||||
// '051d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94ab',
|
||||
// });
|
||||
// const invalidId = new window.models.Conversation.ConversationModel({
|
||||
// type: 'private',
|
||||
// id:
|
||||
// 'j71d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94ab',
|
||||
// });
|
||||
// assert.ok(regularId.isValid());
|
||||
// assert.notOk(invalidId.isValid());
|
||||
// });
|
||||
// it('correctly validates length', () => {
|
||||
// const regularId33 = new window.models.Conversation.ConversationModel({
|
||||
// type: 'private',
|
||||
// id:
|
||||
// '051d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94ab',
|
||||
// });
|
||||
// const regularId32 = new window.models.Conversation.ConversationModel({
|
||||
// type: 'private',
|
||||
// id: '1d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94ab',
|
||||
// });
|
||||
// const shortId = new window.models.Conversation.ConversationModel({
|
||||
// type: 'private',
|
||||
// id: '771d11d',
|
||||
// });
|
||||
// const longId = new window.models.Conversation.ConversationModel({
|
||||
// type: 'private',
|
||||
// id:
|
||||
// '771d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94abaa',
|
||||
// });
|
||||
// assert.ok(regularId33.isValid());
|
||||
// assert.ok(regularId32.isValid());
|
||||
// assert.notOk(shortId.isValid());
|
||||
// assert.notOk(longId.isValid());
|
||||
// });
|
||||
// });
|
||||
});
|
@ -1,154 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const attributes = {
|
||||
type: 'outgoing',
|
||||
body: 'hi',
|
||||
conversationId: 'foo',
|
||||
attachments: [],
|
||||
received_at: new Date().getTime(),
|
||||
};
|
||||
|
||||
const source = '+14155555555';
|
||||
|
||||
describe('MessageCollection', () => {
|
||||
before(async () => {
|
||||
await clearDatabase();
|
||||
window.getConversationController().reset();
|
||||
window.textsecure.storage.user.getNumber = () =>
|
||||
'051111111111111111111111111111111111111111111111111111111111111111';
|
||||
await window.getConversationController().load();
|
||||
});
|
||||
after(() => {
|
||||
return clearDatabase();
|
||||
});
|
||||
|
||||
it('gets outgoing contact', () => {
|
||||
const messages = new window.models.Message.MessageCollection();
|
||||
const message = messages.add(attributes);
|
||||
message.getContact();
|
||||
});
|
||||
|
||||
it('gets incoming contact', () => {
|
||||
const messages = new window.models.Message.MessageCollection();
|
||||
const message = messages.add({
|
||||
type: 'incoming',
|
||||
source,
|
||||
conversationId: 'conversationId',
|
||||
});
|
||||
message.getContact();
|
||||
});
|
||||
|
||||
it('should be ordered oldest to newest', () => {
|
||||
const messages = new window.models.Message.MessageCollection();
|
||||
// Timestamps
|
||||
const today = new Date();
|
||||
const tomorrow = new Date();
|
||||
tomorrow.setDate(today.getDate() + 1);
|
||||
|
||||
// Add threads
|
||||
messages.add({ received_at: today, conversationId: 'conversationId' });
|
||||
messages.add({ received_at: tomorrow, conversationId: 'conversationId' });
|
||||
|
||||
const { models } = messages;
|
||||
const firstTimestamp = models[0].get('received_at').getTime();
|
||||
const secondTimestamp = models[1].get('received_at').getTime();
|
||||
|
||||
// Compare timestamps
|
||||
assert(firstTimestamp < secondTimestamp);
|
||||
});
|
||||
|
||||
// it('checks if is incoming message', () => {
|
||||
// const messages = new window.models.Message.MessageCollection();
|
||||
// let message = messages.add(attributes);
|
||||
// assert.notOk(message.isIncoming());
|
||||
// message = messages.add({
|
||||
// type: 'incoming',
|
||||
// conversationId: 'conversationId',
|
||||
// });
|
||||
// assert.ok(message.isIncoming());
|
||||
// });
|
||||
|
||||
// it('checks if is outgoing message', () => {
|
||||
// const messages = new window.models.Message.MessageCollection();
|
||||
// let message = messages.add(attributes);
|
||||
// assert.ok(message.isOutgoing());
|
||||
// message = messages.add({
|
||||
// type: 'incoming',
|
||||
// conversationId: 'conversationId',
|
||||
// });
|
||||
// assert.notOk(message.isOutgoing());
|
||||
// });
|
||||
|
||||
it('checks if is group update', () => {
|
||||
const messages = new window.models.Message.MessageCollection();
|
||||
let message = messages.add(attributes);
|
||||
assert.notOk(message.isGroupUpdate());
|
||||
|
||||
message = messages.add({
|
||||
group_update: true,
|
||||
conversationId: 'conversationId',
|
||||
});
|
||||
assert.ok(message.isGroupUpdate());
|
||||
});
|
||||
|
||||
it('returns an accurate description', () => {
|
||||
const messages = new window.models.Message.MessageCollection();
|
||||
let message = messages.add(attributes);
|
||||
|
||||
assert.equal(
|
||||
message.getDescription(),
|
||||
'hi',
|
||||
'If no group updates or end session flags, return message body.'
|
||||
);
|
||||
|
||||
message = messages.add({
|
||||
group_update: { left: 'Alice' },
|
||||
conversationId: 'conversationId',
|
||||
});
|
||||
assert.equal(
|
||||
message.getDescription(),
|
||||
'Alice has left the group.',
|
||||
'Notes one person leaving the group.'
|
||||
);
|
||||
|
||||
message = messages.add({
|
||||
group_update: { name: 'blerg' },
|
||||
conversationId: 'conversationId',
|
||||
});
|
||||
assert.equal(
|
||||
message.getDescription(),
|
||||
"Group name is now 'blerg'.",
|
||||
'Returns a single notice if only group_updates.name changes.'
|
||||
);
|
||||
|
||||
message = messages.add({
|
||||
group_update: { joined: ['Bob'] },
|
||||
conversationId: 'conversationId',
|
||||
});
|
||||
assert.equal(
|
||||
message.getDescription(),
|
||||
'Bob joined the group.',
|
||||
'Returns a single notice if only group_updates.joined changes.'
|
||||
);
|
||||
|
||||
message = messages.add({
|
||||
group_update: { joined: ['Bob', 'Alice', 'Eve'] },
|
||||
conversationId: 'conversationId',
|
||||
});
|
||||
assert.equal(
|
||||
message.getDescription(),
|
||||
'Bob, Alice, Eve joined the group.',
|
||||
'Notes when >1 person joins the group.'
|
||||
);
|
||||
|
||||
message = messages.add({
|
||||
group_update: { joined: ['Bob'], name: 'blerg' },
|
||||
conversationId: 'conversationId',
|
||||
});
|
||||
assert.equal(
|
||||
message.getDescription(),
|
||||
"Group name is now 'blerg'. Bob joined the group.",
|
||||
'Notes when there are multiple changes to group_updates properties.'
|
||||
);
|
||||
});
|
||||
});
|
@ -1,30 +0,0 @@
|
||||
// For reference: https://github.com/airbnb/javascript
|
||||
|
||||
module.exports = {
|
||||
env: {
|
||||
mocha: true,
|
||||
browser: true,
|
||||
},
|
||||
|
||||
globals: {
|
||||
check: true,
|
||||
gen: true,
|
||||
},
|
||||
|
||||
parserOptions: {
|
||||
sourceType: 'module',
|
||||
},
|
||||
|
||||
rules: {
|
||||
// We still get the value of this rule, it just allows for dev deps
|
||||
'import/no-extraneous-dependencies': [
|
||||
'error',
|
||||
{
|
||||
devDependencies: true,
|
||||
},
|
||||
],
|
||||
|
||||
// We want to keep each test structured the same, even if its contents are tiny
|
||||
'arrow-body-style': 'off',
|
||||
},
|
||||
};
|
@ -1,161 +0,0 @@
|
||||
const path = require('path');
|
||||
|
||||
const { assert } = require('chai');
|
||||
|
||||
const Privacy = require('../../js/modules/privacy');
|
||||
|
||||
const APP_ROOT_PATH = path.join(__dirname, '..', '..', '..');
|
||||
|
||||
describe('Privacy', () => {
|
||||
describe('redactSessionID', () => {
|
||||
it('should redact all session IDs', () => {
|
||||
const text =
|
||||
'This is a log line with a session ID 0531032fc7415b7cc1b7516480ad121d391eddce3cfb2cee27dd5b215609c32827 and another one 05766049a70e725ad02f7fe61b10e461380a4d7433f98096b3cacbf0362d5cab62';
|
||||
|
||||
const actual = Privacy.redactSessionID(text);
|
||||
const expected = 'This is a log line with a session ID [REDACTED] and another one [REDACTED]';
|
||||
assert.equal(actual, expected);
|
||||
});
|
||||
|
||||
it('should not redact non session IDS', () => {
|
||||
const text =
|
||||
'This is a log line with a non-session ID sadsad0531032fc7415b7cc1b7516480ad121d391eddce3cfb2cee27dd5b215609c32827888 and another one 766049a70e725ad02f7fe61b10e461380a4d7433f98096b3cacbf0362d5cab6234';
|
||||
|
||||
const actual = Privacy.redactSessionID(text);
|
||||
assert.equal(actual, text);
|
||||
});
|
||||
});
|
||||
|
||||
describe('redactGroupIds', () => {
|
||||
it('should redact all group IDs', () => {
|
||||
const text = 'This is a log line with two group IDs: group(123456789) and group(abcdefghij)';
|
||||
|
||||
const actual = Privacy.redactGroupIds(text);
|
||||
const expected =
|
||||
'This is a log line with two group IDs: group([REDACTED]789) and group([REDACTED]hij)';
|
||||
assert.equal(actual, expected);
|
||||
});
|
||||
|
||||
it('should remove newlines from redacted group IDs', () => {
|
||||
const text =
|
||||
'This is a log line with two group IDs: group(12345678\n9)\nand group(abc\ndefghij)';
|
||||
|
||||
const actual = Privacy.redactGroupIds(text);
|
||||
const expected =
|
||||
'This is a log line with two group IDs: group([REDACTED]789)\n' +
|
||||
'and group([REDACTED]hij)';
|
||||
assert.equal(actual, expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('redactAll', () => {
|
||||
it('should redact all sensitive information', () => {
|
||||
const encodedAppRootPath = APP_ROOT_PATH.replace(/ /g, '%20');
|
||||
const text =
|
||||
'This is a log line with sensitive information:\n' +
|
||||
`path1 ${APP_ROOT_PATH}/main.js\n` +
|
||||
'phone1 0531032fc7415b7cc1b7516480ad121d391eddce3cfb2cee27dd5b215609c32827 ipsum\n' +
|
||||
'group 31032fc7415b7cc1b7516480ad121d391eddce3cfb2cee27dd5b215609c32827 eeee\n' +
|
||||
'group1 group(123456789) doloret\n' +
|
||||
`path2 file:///${encodedAppRootPath}/js/background.js.` +
|
||||
'phone2 0531033dc7415b7cc1b7516480ad121d391eddce3cfb2cee27dd5b215609c32827 lorem\n' +
|
||||
'group2 group(abcdefghij) doloret\n' +
|
||||
'url1 https://you-have-to-hide.me aaa\n' +
|
||||
'url1 http://you-have-to-hide.me bbb\n' +
|
||||
'url1 127.0.0.1:22021 ccc\n';
|
||||
|
||||
const actual = Privacy.redactAll(text);
|
||||
const expected =
|
||||
'This is a log line with sensitive information:\n' +
|
||||
'path1 [REDACTED]/main.js\n' +
|
||||
'phone1 [REDACTED] ipsum\n' +
|
||||
'group [REDACTED] eeee\n' +
|
||||
'group1 group([REDACTED]789) doloret\n' +
|
||||
'path2 file:///[REDACTED]/js/background.js.' +
|
||||
'phone2 [REDACTED] lorem\n' +
|
||||
'group2 group([REDACTED]hij) doloret\n' +
|
||||
'url1 [REDACTED] aaa\n' +
|
||||
'url1 [REDACTED] bbb\n' +
|
||||
'url1 [REDACTED]:22021 ccc\n';
|
||||
assert.equal(actual, expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('_redactPath', () => {
|
||||
it('should redact file paths', () => {
|
||||
const testPath = '/Users/meow/Library/Application Support/Signal Beta';
|
||||
const text =
|
||||
'This is a log line with sensitive information:\n' +
|
||||
`path1 ${testPath}/main.js\n` +
|
||||
'phone1 0531032fc7415b7cc1b7516480ad121d391eddce3cfb2cee27dd5b215609c32827 ipsum\n';
|
||||
|
||||
const actual = Privacy._redactPath(testPath)(text);
|
||||
const expected =
|
||||
'This is a log line with sensitive information:\n' +
|
||||
'path1 [REDACTED]/main.js\n' +
|
||||
'phone1 0531032fc7415b7cc1b7516480ad121d391eddce3cfb2cee27dd5b215609c32827 ipsum\n';
|
||||
assert.equal(actual, expected);
|
||||
});
|
||||
|
||||
it('should redact URL-encoded paths', () => {
|
||||
const testPath = '/Users/meow/Library/Application Support/Signal Beta';
|
||||
const encodedTestPath = encodeURI(testPath);
|
||||
const text =
|
||||
'This is a log line with sensitive information:\n' +
|
||||
`path1 ${testPath}/main.js\n` +
|
||||
'phone1 0531032fc7415b7cc1b7516480ad121d391eddce3cfb2cee27dd5b215609c32827 ipsum\n' +
|
||||
'group1 group(123456789) doloret\n' +
|
||||
`path2 file:///${encodedTestPath}/js/background.js.`;
|
||||
|
||||
const actual = Privacy._redactPath(testPath)(text);
|
||||
const expected =
|
||||
'This is a log line with sensitive information:\n' +
|
||||
'path1 [REDACTED]/main.js\n' +
|
||||
'phone1 0531032fc7415b7cc1b7516480ad121d391eddce3cfb2cee27dd5b215609c32827 ipsum\n' +
|
||||
'group1 group(123456789) doloret\n' +
|
||||
'path2 file:///[REDACTED]/js/background.js.';
|
||||
assert.equal(actual, expected);
|
||||
});
|
||||
|
||||
it('should redact stack traces with both forward and backslashes', () => {
|
||||
const testPath = 'C:/Users/Meow/AppData/Local/Programs/loki-messenger-beta';
|
||||
const modifiedTestPath = 'C:\\Users\\Meow\\AppData\\Local\\Programs\\loki-messenger-beta';
|
||||
const text =
|
||||
'This is a log line with sensitive information:\n' +
|
||||
`path1 ${testPath}\\main.js\n` +
|
||||
'phone1 +12223334455 ipsum\n' +
|
||||
'group1 group(123456789) doloret\n' +
|
||||
`path2 ${modifiedTestPath}\\js\\background.js.`;
|
||||
|
||||
const actual = Privacy._redactPath(testPath)(text);
|
||||
const expected =
|
||||
'This is a log line with sensitive information:\n' +
|
||||
'path1 [REDACTED]\\main.js\n' +
|
||||
'phone1 +12223334455 ipsum\n' +
|
||||
'group1 group(123456789) doloret\n' +
|
||||
'path2 [REDACTED]\\js\\background.js.';
|
||||
assert.equal(actual, expected);
|
||||
});
|
||||
|
||||
it('should redact stack traces with escaped backslashes', () => {
|
||||
const testPath = 'C:\\Users\\Meow\\AppData\\Local\\Programs\\loki-messenger-beta';
|
||||
const modifiedTestPath =
|
||||
'C:\\\\Users\\\\Meow\\\\AppData\\\\Local\\\\Programs\\\\loki-messenger-beta';
|
||||
const text =
|
||||
'This is a log line with sensitive information:\n' +
|
||||
`path1 ${testPath}\\main.js\n` +
|
||||
'phone1 +12223334455 ipsum\n' +
|
||||
'group1 group(123456789) doloret\n' +
|
||||
`path2 ${modifiedTestPath}\\js\\background.js.`;
|
||||
|
||||
const actual = Privacy._redactPath(testPath)(text);
|
||||
const expected =
|
||||
'This is a log line with sensitive information:\n' +
|
||||
'path1 [REDACTED]\\main.js\n' +
|
||||
'phone1 +12223334455 ipsum\n' +
|
||||
'group1 group(123456789) doloret\n' +
|
||||
'path2 [REDACTED]\\js\\background.js.';
|
||||
assert.equal(actual, expected);
|
||||
});
|
||||
});
|
||||
});
|
@ -1,226 +0,0 @@
|
||||
require('mocha-testcheck').install();
|
||||
|
||||
const { assert } = require('chai');
|
||||
|
||||
const Attachment = require('../../../js/modules/types/attachment');
|
||||
const { stringToArrayBuffer } = require('../../../js/modules/string_to_array_buffer');
|
||||
|
||||
describe('Attachment', () => {
|
||||
describe('replaceUnicodeOrderOverrides', () => {
|
||||
it('should sanitize left-to-right order override character', async () => {
|
||||
const input = {
|
||||
contentType: 'image/jpeg',
|
||||
fileName: 'test\u202Dfig.exe',
|
||||
size: 1111,
|
||||
};
|
||||
const expected = {
|
||||
contentType: 'image/jpeg',
|
||||
fileName: 'test\uFFFDfig.exe',
|
||||
size: 1111,
|
||||
};
|
||||
|
||||
const actual = await Attachment.replaceUnicodeOrderOverrides(input);
|
||||
assert.deepEqual(actual, expected);
|
||||
});
|
||||
|
||||
it('should sanitize right-to-left order override character', async () => {
|
||||
const input = {
|
||||
contentType: 'image/jpeg',
|
||||
fileName: 'test\u202Efig.exe',
|
||||
size: 1111,
|
||||
};
|
||||
const expected = {
|
||||
contentType: 'image/jpeg',
|
||||
fileName: 'test\uFFFDfig.exe',
|
||||
size: 1111,
|
||||
};
|
||||
|
||||
const actual = await Attachment.replaceUnicodeOrderOverrides(input);
|
||||
assert.deepEqual(actual, expected);
|
||||
});
|
||||
|
||||
it('should sanitize multiple override characters', async () => {
|
||||
const input = {
|
||||
contentType: 'image/jpeg',
|
||||
fileName: 'test\u202e\u202dlol\u202efig.exe',
|
||||
size: 1111,
|
||||
};
|
||||
const expected = {
|
||||
contentType: 'image/jpeg',
|
||||
fileName: 'test\uFFFD\uFFFDlol\uFFFDfig.exe',
|
||||
size: 1111,
|
||||
};
|
||||
|
||||
const actual = await Attachment.replaceUnicodeOrderOverrides(input);
|
||||
assert.deepEqual(actual, expected);
|
||||
});
|
||||
|
||||
const hasNoUnicodeOrderOverrides = value =>
|
||||
!value.includes('\u202D') && !value.includes('\u202E');
|
||||
|
||||
check.it(
|
||||
'should ignore non-order-override characters',
|
||||
gen.string.suchThat(hasNoUnicodeOrderOverrides),
|
||||
fileName => {
|
||||
const input = {
|
||||
contentType: 'image/jpeg',
|
||||
fileName,
|
||||
size: 1111,
|
||||
};
|
||||
|
||||
const actual = Attachment._replaceUnicodeOrderOverridesSync(input);
|
||||
assert.deepEqual(actual, input);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
describe('replaceUnicodeV2', () => {
|
||||
it('should remove all bad characters', async () => {
|
||||
const input = {
|
||||
size: 1111,
|
||||
fileName:
|
||||
'file\u202A\u202B\u202C\u202D\u202E\u2066\u2067\u2068\u2069\u200E\u200F\u061C.jpeg',
|
||||
};
|
||||
const expected = {
|
||||
fileName:
|
||||
'file\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD.jpeg',
|
||||
size: 1111,
|
||||
};
|
||||
|
||||
const actual = await Attachment.replaceUnicodeV2(input);
|
||||
assert.deepEqual(actual, expected);
|
||||
});
|
||||
|
||||
it('should should leave normal filename alone', async () => {
|
||||
const input = {
|
||||
fileName: 'normal.jpeg',
|
||||
size: 1111,
|
||||
};
|
||||
const expected = {
|
||||
fileName: 'normal.jpeg',
|
||||
size: 1111,
|
||||
};
|
||||
|
||||
const actual = await Attachment.replaceUnicodeV2(input);
|
||||
assert.deepEqual(actual, expected);
|
||||
});
|
||||
|
||||
it('should handle missing fileName', async () => {
|
||||
const input = {
|
||||
size: 1111,
|
||||
};
|
||||
const expected = {
|
||||
size: 1111,
|
||||
};
|
||||
|
||||
const actual = await Attachment.replaceUnicodeV2(input);
|
||||
assert.deepEqual(actual, expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('removeSchemaVersion', () => {
|
||||
it('should remove existing schema version', () => {
|
||||
const input = {
|
||||
contentType: 'image/jpeg',
|
||||
fileName: 'foo.jpg',
|
||||
size: 1111,
|
||||
schemaVersion: 1,
|
||||
};
|
||||
|
||||
const expected = {
|
||||
contentType: 'image/jpeg',
|
||||
fileName: 'foo.jpg',
|
||||
size: 1111,
|
||||
};
|
||||
|
||||
const actual = Attachment.removeSchemaVersion({
|
||||
attachment: input,
|
||||
logger: {
|
||||
error: () => null,
|
||||
},
|
||||
});
|
||||
assert.deepEqual(actual, expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('migrateDataToFileSystem', () => {
|
||||
it('should write data to disk and store relative path to it', async () => {
|
||||
const input = {
|
||||
contentType: 'image/jpeg',
|
||||
data: stringToArrayBuffer('Above us only sky'),
|
||||
fileName: 'foo.jpg',
|
||||
size: 1111,
|
||||
};
|
||||
|
||||
const expected = {
|
||||
contentType: 'image/jpeg',
|
||||
path: 'abc/abcdefgh123456789',
|
||||
fileName: 'foo.jpg',
|
||||
size: 1111,
|
||||
};
|
||||
|
||||
const expectedAttachmentData = stringToArrayBuffer('Above us only sky');
|
||||
const writeNewAttachmentData = async attachmentData => {
|
||||
assert.deepEqual(attachmentData, expectedAttachmentData);
|
||||
return 'abc/abcdefgh123456789';
|
||||
};
|
||||
|
||||
const actual = await Attachment.migrateDataToFileSystem(input, {
|
||||
writeNewAttachmentData,
|
||||
logger: {
|
||||
warn: () => null,
|
||||
},
|
||||
});
|
||||
assert.deepEqual(actual, expected);
|
||||
});
|
||||
|
||||
it('should skip over (invalid) attachments without data', async () => {
|
||||
const input = {
|
||||
contentType: 'image/jpeg',
|
||||
fileName: 'foo.jpg',
|
||||
size: 1111,
|
||||
};
|
||||
|
||||
const expected = {
|
||||
contentType: 'image/jpeg',
|
||||
fileName: 'foo.jpg',
|
||||
size: 1111,
|
||||
};
|
||||
|
||||
const writeNewAttachmentData = async () => 'abc/abcdefgh123456789';
|
||||
|
||||
const actual = await Attachment.migrateDataToFileSystem(input, {
|
||||
writeNewAttachmentData,
|
||||
logger: {
|
||||
warn: () => null,
|
||||
},
|
||||
});
|
||||
assert.deepEqual(actual, expected);
|
||||
});
|
||||
|
||||
it('should throw error if data is not valid', async () => {
|
||||
const input = {
|
||||
contentType: 'image/jpeg',
|
||||
data: 42,
|
||||
fileName: 'foo.jpg',
|
||||
size: 1111,
|
||||
};
|
||||
|
||||
const writeNewAttachmentData = async () => 'abc/abcdefgh123456789';
|
||||
|
||||
try {
|
||||
await Attachment.migrateDataToFileSystem(input, {
|
||||
writeNewAttachmentData,
|
||||
logger: {
|
||||
warn: () => null,
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
assert.strictEqual(error.message, 'Expected 42 to be an array buffer got: number');
|
||||
return;
|
||||
}
|
||||
|
||||
assert.fail('Unreachable');
|
||||
});
|
||||
});
|
||||
});
|
@ -1,37 +0,0 @@
|
||||
const Path = require('path');
|
||||
|
||||
const { assert } = require('chai');
|
||||
|
||||
const Errors = require('../../../js/modules/types/errors');
|
||||
|
||||
const APP_ROOT_PATH = Path.join(__dirname, '..', '..', '..');
|
||||
|
||||
describe('Errors', () => {
|
||||
describe('toLogFormat', () => {
|
||||
it('should return error stack trace if present', () => {
|
||||
const error = new Error('boom');
|
||||
assert.typeOf(error, 'Error');
|
||||
|
||||
const formattedError = Errors.toLogFormat(error);
|
||||
assert.include(formattedError, 'errors_test.js');
|
||||
assert.include(formattedError, APP_ROOT_PATH, 'Formatted stack has app path');
|
||||
});
|
||||
|
||||
it('should return error string representation if stack is missing', () => {
|
||||
const error = new Error('boom');
|
||||
error.stack = null;
|
||||
assert.typeOf(error, 'Error');
|
||||
assert.isNull(error.stack);
|
||||
|
||||
const formattedError = Errors.toLogFormat(error);
|
||||
assert.strictEqual(formattedError, 'Error: boom');
|
||||
});
|
||||
|
||||
[0, false, null, undefined].forEach(value => {
|
||||
it(`should return \`${value}\` argument`, () => {
|
||||
const formattedNonError = Errors.toLogFormat(value);
|
||||
assert.strictEqual(formattedNonError, value);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
@ -1,28 +0,0 @@
|
||||
const { assert } = require('chai');
|
||||
|
||||
const MIME = require('../../../ts/types/MIME');
|
||||
|
||||
describe('MIME', () => {
|
||||
describe('isJPEG', () => {
|
||||
it('should return true for `image/jpeg`', () => {
|
||||
assert.isTrue(MIME.isJPEG('image/jpeg'));
|
||||
});
|
||||
|
||||
[
|
||||
'jpg',
|
||||
'jpeg',
|
||||
'image/jpg', // invalid MIME type: https://stackoverflow.com/a/37266399/125305
|
||||
'image/gif',
|
||||
'image/tiff',
|
||||
'application/json',
|
||||
0,
|
||||
false,
|
||||
null,
|
||||
undefined,
|
||||
].forEach(value => {
|
||||
it(`should return false for \`${value}\``, () => {
|
||||
assert.isFalse(MIME.isJPEG(value));
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
@ -1,20 +0,0 @@
|
||||
require('mocha-testcheck').install();
|
||||
const { assert } = require('chai');
|
||||
|
||||
const SchemaVersion = require('../../../js/modules/types/schema_version');
|
||||
|
||||
describe('SchemaVersion', () => {
|
||||
describe('isValid', () => {
|
||||
check.it('should return true for positive integers', gen.posInt, input => {
|
||||
assert.isTrue(SchemaVersion.isValid(input));
|
||||
});
|
||||
|
||||
check.it(
|
||||
'should return false for any other value',
|
||||
gen.primitive.suchThat(value => typeof value !== 'number' || value < 0),
|
||||
input => {
|
||||
assert.isFalse(SchemaVersion.isValid(input));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
@ -1,38 +0,0 @@
|
||||
/* global Whisper */
|
||||
|
||||
describe('Whisper.View', () => {
|
||||
it('renders a template with render_attributes', () => {
|
||||
const ViewClass = Whisper.View.extend({
|
||||
template: '<div>{{ variable }}</div>',
|
||||
render_attributes: {
|
||||
variable: 'value',
|
||||
},
|
||||
});
|
||||
|
||||
const view = new ViewClass();
|
||||
view.render();
|
||||
assert.strictEqual(view.$el.html(), '<div>value</div>');
|
||||
});
|
||||
it('renders a template with no render_attributes', () => {
|
||||
const ViewClass = Whisper.View.extend({
|
||||
template: '<div>static text</div>',
|
||||
});
|
||||
|
||||
const view = new ViewClass();
|
||||
view.render();
|
||||
assert.strictEqual(view.$el.html(), '<div>static text</div>');
|
||||
});
|
||||
it('renders a template function with render_attributes function', () => {
|
||||
const ViewClass = Whisper.View.extend({
|
||||
template() {
|
||||
return '<div>{{ variable }}</div>';
|
||||
},
|
||||
render_attributes() {
|
||||
return { variable: 'value' };
|
||||
},
|
||||
});
|
||||
const view = new ViewClass();
|
||||
view.render();
|
||||
assert.strictEqual(view.$el.html(), '<div>value</div>');
|
||||
});
|
||||
});
|
@ -1,116 +0,0 @@
|
||||
import React from 'react';
|
||||
|
||||
import { Avatar, AvatarSize } from './Avatar';
|
||||
import { ContactName } from './conversation/ContactName';
|
||||
|
||||
import { FindAndFormatContactType, PropsForSearchResults } from '../state/ducks/conversations';
|
||||
|
||||
type PropsHousekeeping = {
|
||||
isSelected?: boolean;
|
||||
};
|
||||
|
||||
type Props = PropsForSearchResults & PropsHousekeeping;
|
||||
|
||||
const FromName = (props: { from: FindAndFormatContactType; to: FindAndFormatContactType }) => {
|
||||
const { from, to } = props;
|
||||
|
||||
if (from.isMe && to.isMe) {
|
||||
return (
|
||||
<span className="module-message-search-result__header__name">
|
||||
{window.i18n('noteToSelf')}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
if (from.isMe) {
|
||||
return <span className="module-message-search-result__header__name">{window.i18n('you')}</span>;
|
||||
}
|
||||
|
||||
return (
|
||||
// tslint:disable: use-simple-attributes
|
||||
<ContactName
|
||||
phoneNumber={from.phoneNumber}
|
||||
name={from.name || ''}
|
||||
profileName={from.profileName || ''}
|
||||
module="module-message-search-result__header__name"
|
||||
shouldShowPubkey={false}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
const From = (props: { from: FindAndFormatContactType; to: FindAndFormatContactType }) => {
|
||||
const { to, from } = props;
|
||||
const fromName = <FromName from={from} to={to} />;
|
||||
|
||||
if (!to.isMe) {
|
||||
return (
|
||||
<div className="module-message-search-result__header__from">
|
||||
{fromName} {window.i18n('to')}{' '}
|
||||
<span className="module-mesages-search-result__header__group">
|
||||
<ContactName
|
||||
phoneNumber={to.phoneNumber}
|
||||
name={to.name || ''}
|
||||
profileName={to.profileName || ''}
|
||||
shouldShowPubkey={false}
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return <div className="module-message-search-result__header__from">{fromName}</div>;
|
||||
};
|
||||
|
||||
const AvatarItem = (props: { from: FindAndFormatContactType }) => {
|
||||
const { from } = props;
|
||||
const userName = from.profileName || from.phoneNumber;
|
||||
|
||||
return (
|
||||
<Avatar
|
||||
avatarPath={from.avatarPath || ''}
|
||||
name={userName}
|
||||
size={AvatarSize.S}
|
||||
pubkey={from.phoneNumber}
|
||||
/>
|
||||
);
|
||||
};
|
||||
// export const MessageSearchResult = (props: Props) => {
|
||||
// const { from, id: messageId, isSelected, conversationId, receivedAt, snippet, to } = props;
|
||||
|
||||
// const dispatch = useDispatch();
|
||||
|
||||
// if (!from || !to) {
|
||||
// return null;
|
||||
// }
|
||||
|
||||
// return (
|
||||
// <div
|
||||
// role="button"
|
||||
// onClick={() => {
|
||||
// dispatch(
|
||||
// openConversationExternal({
|
||||
// id: conversationId,
|
||||
// messageId,
|
||||
// firstUnreadIdOnOpen: undefined,
|
||||
// })
|
||||
// );
|
||||
// }}
|
||||
// className={classNames(
|
||||
// 'module-message-search-result',
|
||||
// isSelected ? 'module-message-search-result--is-selected' : null
|
||||
// )}
|
||||
// >
|
||||
// <AvatarItem from={from} />
|
||||
// <div className="module-message-search-result__text">
|
||||
// <div className="module-message-search-result__header">
|
||||
// <From from={from} to={to} />
|
||||
// <div className="module-message-search-result__header__timestamp">
|
||||
// <Timestamp timestamp={receivedAt} />
|
||||
// </div>
|
||||
// </div>
|
||||
// <div className="module-message-search-result__body">
|
||||
// <MessageBodyHighlight text={snippet || ''} />
|
||||
// </div>
|
||||
// </div>
|
||||
// </div>
|
||||
// );
|
||||
// };
|
@ -1,40 +1,29 @@
|
||||
import React from 'react';
|
||||
import classNames from 'classnames';
|
||||
|
||||
interface Props {
|
||||
color?: string;
|
||||
}
|
||||
|
||||
export class TypingAnimation extends React.Component<Props> {
|
||||
public render() {
|
||||
const { color } = this.props;
|
||||
|
||||
return (
|
||||
<div className="module-typing-animation" title={window.i18n('typingAlt')}>
|
||||
<div
|
||||
className={classNames(
|
||||
'module-typing-animation__dot',
|
||||
'module-typing-animation__dot--first',
|
||||
color ? `module-typing-animation__dot--${color}` : null
|
||||
)}
|
||||
/>
|
||||
<div className="module-typing-animation__spacer" />
|
||||
<div
|
||||
className={classNames(
|
||||
'module-typing-animation__dot',
|
||||
'module-typing-animation__dot--second',
|
||||
color ? `module-typing-animation__dot--${color}` : null
|
||||
)}
|
||||
/>
|
||||
<div className="module-typing-animation__spacer" />
|
||||
<div
|
||||
className={classNames(
|
||||
'module-typing-animation__dot',
|
||||
'module-typing-animation__dot--third',
|
||||
color ? `module-typing-animation__dot--${color}` : null
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
export const TypingAnimation = () => {
|
||||
return (
|
||||
<div className="module-typing-animation" title={window.i18n('typingAlt')}>
|
||||
<div
|
||||
className={classNames(
|
||||
'module-typing-animation__dot',
|
||||
'module-typing-animation__dot--first'
|
||||
)}
|
||||
/>
|
||||
<div className="module-typing-animation__spacer" />
|
||||
<div
|
||||
className={classNames(
|
||||
'module-typing-animation__dot',
|
||||
'module-typing-animation__dot--second'
|
||||
)}
|
||||
/>
|
||||
<div className="module-typing-animation__spacer" />
|
||||
<div
|
||||
className={classNames(
|
||||
'module-typing-animation__dot',
|
||||
'module-typing-animation__dot--third'
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
@ -1,12 +0,0 @@
|
||||
import React from 'react';
|
||||
import styled from 'styled-components';
|
||||
|
||||
type Props = {
|
||||
date: string;
|
||||
direction: string;
|
||||
withImageNoCaption: boolean;
|
||||
};
|
||||
|
||||
export const MetadataDate = (props: Props) => {
|
||||
return <></>;
|
||||
};
|
@ -0,0 +1,204 @@
|
||||
import React, { useCallback, useState } from 'react';
|
||||
import { ed25519Str } from '../../session/onions/onionPath';
|
||||
import { forceNetworkDeletion } from '../../session/snode_api/SNodeAPI';
|
||||
import { forceSyncConfigurationNowIfNeeded } from '../../session/utils/syncUtils';
|
||||
import { updateConfirmModal, updateDeleteAccountModal } from '../../state/ducks/modalDialog';
|
||||
import { SpacerLG } from '../basic/Text';
|
||||
import { SessionButton, SessionButtonColor } from '../session/SessionButton';
|
||||
import { SessionHtmlRenderer } from '../session/SessionHTMLRenderer';
|
||||
import { SessionSpinner } from '../session/SessionSpinner';
|
||||
import { SessionWrapperModal } from '../session/SessionWrapperModal';
|
||||
|
||||
const deleteDbLocally = async () => {
|
||||
window?.log?.info('configuration message sent successfully. Deleting everything');
|
||||
window.persistStore?.purge();
|
||||
await window.Signal.Logs.deleteAll();
|
||||
await window.Signal.Data.removeAll();
|
||||
await window.Signal.Data.close();
|
||||
await window.Signal.Data.removeDB();
|
||||
await window.Signal.Data.removeOtherData();
|
||||
// 'unlink' => toast will be shown on app restart
|
||||
window.localStorage.setItem('restart-reason', 'delete-account');
|
||||
};
|
||||
|
||||
async function sendConfigMessageAndDeleteEverything() {
|
||||
try {
|
||||
// DELETE LOCAL DATA ONLY, NOTHING ON NETWORK
|
||||
window?.log?.info('DeleteAccount => Sending a last SyncConfiguration');
|
||||
|
||||
// be sure to wait for the message being effectively sent. Otherwise we won't be able to encrypt it for our devices !
|
||||
await forceSyncConfigurationNowIfNeeded(true);
|
||||
window?.log?.info('Last configuration message sent!');
|
||||
await deleteDbLocally();
|
||||
window.restart();
|
||||
} catch (error) {
|
||||
// if an error happened, it's not related to the delete everything on network logic as this is handled above.
|
||||
// this could be a last sync configuration message not being sent.
|
||||
// in all case, we delete everything, and restart
|
||||
window?.log?.error(
|
||||
'Something went wrong deleting all data:',
|
||||
error && error.stack ? error.stack : error
|
||||
);
|
||||
try {
|
||||
await deleteDbLocally();
|
||||
} catch (e) {
|
||||
window?.log?.error(e);
|
||||
} finally {
|
||||
window.restart();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteEverythingAndNetworkData() {
|
||||
try {
|
||||
// DELETE EVERYTHING ON NETWORK, AND THEN STUFF LOCALLY STORED
|
||||
// a bit of duplicate code below, but it's easier to follow every case like that (helped with returns)
|
||||
|
||||
// send deletion message to the network
|
||||
const potentiallyMaliciousSnodes = await forceNetworkDeletion();
|
||||
if (potentiallyMaliciousSnodes === null) {
|
||||
window?.log?.warn('DeleteAccount => forceNetworkDeletion failed');
|
||||
|
||||
// close this dialog
|
||||
window.inboxStore?.dispatch(updateDeleteAccountModal(null));
|
||||
window.inboxStore?.dispatch(
|
||||
updateConfirmModal({
|
||||
title: window.i18n('dialogClearAllDataDeletionFailedTitle'),
|
||||
message: window.i18n('dialogClearAllDataDeletionFailedDesc'),
|
||||
okTheme: SessionButtonColor.Danger,
|
||||
okText: window.i18n('deviceOnly'),
|
||||
onClickOk: async () => {
|
||||
await deleteDbLocally();
|
||||
window.restart();
|
||||
},
|
||||
})
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (potentiallyMaliciousSnodes.length > 0) {
|
||||
const snodeStr = potentiallyMaliciousSnodes.map(ed25519Str);
|
||||
window?.log?.warn(
|
||||
'DeleteAccount => forceNetworkDeletion Got some potentially malicious snodes',
|
||||
snodeStr
|
||||
);
|
||||
// close this dialog
|
||||
window.inboxStore?.dispatch(updateDeleteAccountModal(null));
|
||||
// open a new confirm dialog to ask user what to do
|
||||
window.inboxStore?.dispatch(
|
||||
updateConfirmModal({
|
||||
title: window.i18n('dialogClearAllDataDeletionFailedTitle'),
|
||||
message: window.i18n(
|
||||
'dialogClearAllDataDeletionFailedMultiple',
|
||||
potentiallyMaliciousSnodes.join(', ')
|
||||
),
|
||||
messageSub: window.i18n('dialogClearAllDataDeletionFailedTitleQuestion'),
|
||||
okTheme: SessionButtonColor.Danger,
|
||||
okText: window.i18n('deviceOnly'),
|
||||
onClickOk: async () => {
|
||||
await deleteDbLocally();
|
||||
window.restart();
|
||||
},
|
||||
})
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// We removed everything on the network successfully (no malicious node!). Now delete the stuff we got locally
|
||||
// without sending a last configuration message (otherwise this one will still be on the network)
|
||||
await deleteDbLocally();
|
||||
window.restart();
|
||||
} catch (error) {
|
||||
// if an error happened, it's not related to the delete everything on network logic as this is handled above.
|
||||
// this could be a last sync configuration message not being sent.
|
||||
// in all case, we delete everything, and restart
|
||||
window?.log?.error(
|
||||
'Something went wrong deleting all data:',
|
||||
error && error.stack ? error.stack : error
|
||||
);
|
||||
try {
|
||||
await deleteDbLocally();
|
||||
} catch (e) {
|
||||
window?.log?.error(e);
|
||||
}
|
||||
window.restart();
|
||||
}
|
||||
}
|
||||
|
||||
export const DeleteAccountModal = () => {
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
||||
const onDeleteEverythingLocallyOnly = async () => {
|
||||
setIsLoading(true);
|
||||
try {
|
||||
window.log.warn('Deleting everything excluding network data');
|
||||
|
||||
await sendConfigMessageAndDeleteEverything();
|
||||
} catch (e) {
|
||||
window.log.warn(e);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
|
||||
window.inboxStore?.dispatch(updateConfirmModal(null));
|
||||
};
|
||||
const onDeleteEverythingAndNetworkData = async () => {
|
||||
setIsLoading(true);
|
||||
try {
|
||||
window.log.warn('Deleting everything including network data');
|
||||
await deleteEverythingAndNetworkData();
|
||||
} catch (e) {
|
||||
window.log.warn(e);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Performs specified on close action then removes the modal.
|
||||
*/
|
||||
const onClickCancelHandler = useCallback(() => {
|
||||
window.inboxStore?.dispatch(updateDeleteAccountModal(null));
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<SessionWrapperModal
|
||||
title={window.i18n('clearAllData')}
|
||||
onClose={onClickCancelHandler}
|
||||
showExitIcon={true}
|
||||
>
|
||||
<SpacerLG />
|
||||
|
||||
<div className="session-modal__centered">
|
||||
<SessionHtmlRenderer
|
||||
tag="span"
|
||||
className="session-confirm-main-message"
|
||||
html={window.i18n('deleteAccountWarning')}
|
||||
/>
|
||||
<SessionHtmlRenderer
|
||||
tag="span"
|
||||
className="session-confirm-main-message"
|
||||
html={window.i18n('dialogClearAllDataDeletionQuestion')}
|
||||
/>
|
||||
<SpacerLG />
|
||||
<div className="session-modal__button-group">
|
||||
<SessionButton
|
||||
text={window.i18n('entireAccount')}
|
||||
buttonColor={SessionButtonColor.Danger}
|
||||
onClick={onDeleteEverythingAndNetworkData}
|
||||
disabled={isLoading}
|
||||
/>
|
||||
|
||||
<SessionButton
|
||||
text={window.i18n('deviceOnly')}
|
||||
buttonColor={SessionButtonColor.Primary}
|
||||
onClick={onDeleteEverythingLocallyOnly}
|
||||
disabled={isLoading}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<SessionSpinner loading={isLoading} />
|
||||
</div>
|
||||
</SessionWrapperModal>
|
||||
);
|
||||
};
|
@ -1,31 +1,26 @@
|
||||
import React from 'react';
|
||||
|
||||
import _ from 'lodash';
|
||||
|
||||
import { getTheme } from '../state/selectors/theme';
|
||||
|
||||
import Electron from 'electron';
|
||||
const { shell } = Electron;
|
||||
|
||||
import { useDispatch, useSelector } from 'react-redux';
|
||||
import { SessionIcon, SessionIconButton, SessionIconSize, SessionIconType } from './session/icon';
|
||||
|
||||
import { SessionWrapperModal } from './session/SessionWrapperModal';
|
||||
|
||||
import ip2country from 'ip2country';
|
||||
import countryLookup from 'country-code-lookup';
|
||||
import { useTheme } from 'styled-components';
|
||||
import { Snode } from '../data/data';
|
||||
import { onionPathModal } from '../state/ducks/modalDialog';
|
||||
import { Snode } from '../../data/data';
|
||||
import { onionPathModal } from '../../state/ducks/modalDialog';
|
||||
import {
|
||||
getFirstOnionPath,
|
||||
getFirstOnionPathLength,
|
||||
getIsOnline,
|
||||
getOnionPathsCount,
|
||||
} from '../state/selectors/onions';
|
||||
|
||||
import { SessionSpinner } from './session/SessionSpinner';
|
||||
import { Flex } from './basic/Flex';
|
||||
} from '../../state/selectors/onions';
|
||||
import { getTheme } from '../../state/selectors/theme';
|
||||
import { Flex } from '../basic/Flex';
|
||||
import { SessionIcon, SessionIconButton, SessionIconSize, SessionIconType } from '../session/icon';
|
||||
import { SessionSpinner } from '../session/SessionSpinner';
|
||||
import { SessionWrapperModal } from '../session/SessionWrapperModal';
|
||||
|
||||
export type StatusLightType = {
|
||||
glowStartDelay: number;
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue