Skip to content

Commit

Permalink
Merge branch 'development' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
natsu-anon committed Apr 24, 2021
2 parents 0fa63cb + f9ade8a commit b27b0a6
Show file tree
Hide file tree
Showing 68 changed files with 8,739 additions and 1,841 deletions.
8 changes: 8 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"presets": [
[ "@babel/preset-env",
{
"shippedProposals": true
}]
]
}
54 changes: 54 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"env": {
"browser": false,
"es2021": true,
"node": true
},
"parser": "@babel/eslint-parser",
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module"
},
"rules": {
"getter-return": "error",
"no-cond-assign": "error",
"no-constant-condition": "error",
"no-dupe-args": "error",
"no-dupe-else-if": "error",
"no-dupe-keys": "error",
"no-duplicate-case": "error",
"no-empty": "warn",
"no-extra-boolean-cast": "warn",
"no-func-assign": "error",
"no-import-assign": "error",
"no-setter-return": "error",
"no-sparse-arrays": "warn",
"no-unreachable": "warn",
"no-unsafe-finally": "warn",
"no-unsafe-negation": "error",
"use-isnan": "error",
"eqeqeq": [ "warn", "smart" ],
"no-multi-spaces": "warn",
"no-redeclare": "error",
"no-useless-escape": "warn",
"no-with": "error",
"no-undef": "error",
"no-unused-vars": [ "warn", { "vars": "local", "args": "all" }],
"wrap-iife": ["warn", "inside"],
"object-curly-spacing": ["warn", "always"],
"quotes": ["warn", "single", { "avoidEscape": true, "allowTemplateLiterals": true }],
"semi": ["error", "always"],
"no-const-assign": "error",
"arrow-spacing": "warn",
"no-confusing-arrow": "warn",
"no-dupe-class-members": "error",
"no-duplicate-imports": "warn",
"no-var": "warn",
"no-confusing-arrow": "warn",
"constructor-super": "error",
"no-this-before-super": "error",
"prefer-const": "warn",
"require-yield": "warn",
"arrow-parens": ["warn", "as-needed"]
}
}
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# the DO_NOT_SHARE dir
DO_NOT_SHARE/

# testing stuff
_test*

# the revocation certificate
stowaway.revoke

# discord bot token
token*

Expand Down
61 changes: 61 additions & 0 deletions blessed-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
/* NOTE: IMPOSSIBLE TO DISCENERN SHIFT+ENTER FROM ENTER :^(
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

const blessed = require('blessed');

const screen = blessed.screen({
smartcsr: true,
autopadding: true,
tabSize: 2,
// debug: true,
dockborders: true,
fullunicode: true, // allows for meme double-wide characters
});

const box = blessed.box({
parent: screen,
top: 0,
left: 0,
width: '100%',
height: '100%',
content: 'press keys...'
});

screen.on('keypress', (char, key) => {
let temp = `character: ${char}`;
for (const val in key) {
temp += `\nkey.${val}: ${key[val]}`;
}
// box.setContent(`character: ${char}, full: ${key.full}`);
box.setContent(temp);
screen.render();
});

/*
screen.key(['delete', 'backspace'], () => {
box.setContent('DELETE/BACKSPACE');
screen.render();
});
*/

/*
const input = blessed.textbox({
parent: screen,
top: 0,
left: 0,
width: '100%',
height: '100%',
inputOnFocus: true
});
input.focus();
input.on('submit', () => {
input.clearValue();
screen.render();
});
input.onceKey('C-c', () => { process.exit(0); });
*/


screen.onceKey('C-c', () => { process.exit(0); });
screen.render();
7 changes: 7 additions & 0 deletions config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
; stuffo

[DISCORD]
; set comment to include in all discord messages, or comment out following with
comment: https://github.com/natsu-anon/STOWAWAY

[COLORS]
87 changes: 87 additions & 0 deletions controls.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
STATES:
navigation state
read state
write state
help state
member state (for signing & seeing whomstve signed whose key)
revoke sequence
NOTE: leave room for sessions
NOTE: maybe leave room for event log

all states:
[Ctrl-C] quit
[Ctrl-R] initiate revoke sequence (except self)
[Ctrl-A] about (except self)
[Ctrl-K] to show controls/basic gestalt for current state (except self) -- CTRL-H is BACKSPACE -- GONNA BE USING THAT
[`] to jump to notification item (except write & if there is any


navigation state:
- NOTE: only show handshaked channels -- don't bother with category channels
- NOTE: saved channels are green w/ jump number to the side
- NOTE: currently selected channel is inverted w/ > to the side
[Enter] begin reading selected channel
[W/S] navigate to prev/next channel (or server if at first/last channel of current server)
[A/D] navigate to first channel of prev/next server (loops)
[H] enter handshake state
[M] enter member state
[Ctrl + Number] to save a jump to curently selected channel
[Backspace/Delete] remove favorite of currently selected channel (if any)
[Tab] enter read state
[Number] jump to previously saved channel (if unavailable do nothing) & enter read state

handshake state:
- NOTE: unavaible channels are shown in red w/ reason why in parens. unable to handshake
[Enter] handshake selected channel, then enter read state w/ newly handshaked channel
[Escape] return to previous state (navigate)
[W/S] scroll to prev/next channel (loops)
[A/D] scroll to first channel of prev/next server (loops)
[tab] to go to read state
[M] go to member state (if possible);

read state:
- NOTE: unverified messages are entirely yellow
- NOTE: messages from signed keys have sender & date underlined
[W/S] scroll up/down
[A/D] jump to top/bottom
[H] enter handshake state
[M] enter member view for channel
[Enter] begin writing public message
[Ctrl + Number] favorite current channel
[Backspace/Delete] remove favorite from current channel (if possible)
[Ctrl-Enter] begin writing trusted message (only to signed keys)
[Tab] enter navigation state
[Number] jump to previously saved channel (if unavailable do nothing)
[`] to jump to notification item (if there is any)

write state:
- NOTE: the write box element itself only appears when viewing a channel
- NOTE: height should increase as needed
[escape] stop writing & clearout the text
[enter] send message

keybind state:
- NOTE: popup window that covers majority (but not all) of screen
[W/S] scroll up/down (if needed)
[escape] return to previous state

about state:
- NOTE: popup window that covers majority (but not all) of screen
[W/S] scroll up/down (if needed)
[escape] return to previous state

member state
- NOTE: restrict to known members
[W/S] scroll up/down - show known signers in a sidebar, highlight those whose key you have also signed
[escape] return to previous state (read state)
[enter] sign currently selected (unless already signed)
[tab] to go to read state
[H] go to handshake state

revoke sequence:
- NOTE: WARN THAT THIS IS IRREVOCABLE & SHOULD ONLY BE USED IF YOU:
1) think someone else has your private key
2) think someone else knows your passphrase
3) both of the above
- NOTE: make user enter "randomly" generated phrase to revoke key
[Escape] end revoke sequence & return to previous state
30 changes: 30 additions & 0 deletions deadhead.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const process = require('process');
const { Stowaway } = require('./src/stowaway.js');
const Datastore = require('nedb');
const { clientLogin, genKey, loadKey } = require('./test.js');
const { token1, keyPath1, db1, channels1 } = require('./test-data.js');

async function launch (freshFlag) {
const VERSION = '1.0.0-daemon';
const db = freshFlag ? new Datastore() : new Datastore({ filename: db1, autoload: true });
db.persistence.setAutocompactionInterval(10000);
const client = await clientLogin(token1);
const { key } = freshFlag ? await genKey() : await loadKey(keyPath1);
const stowaway = new Stowaway(db, keyPath1, VERSION);
stowaway.on('notify', (color, text) => {
console.log(`\t${client.user.tag} ${color}: ${text}`);
});
stowaway.on('error', text => {
console.error(`${client.user.tag}: ${text}`);
});
stowaway.launch(client, key);
let channel;
console.log(`${freshFlag ? 'fresh' : 'cached'} deadhead: ${client.user.tag}`);
for (let i = 0; i < channels1.length; i++) {
channel = await stowaway.loadChannel(await client.channels.fetch(channels1[i]));
console.log(`\tdeadheading: ${channel.guild.name} #${channel.name}`);
}
}

launch(process.argv.length > 2 ? process.argv[2] === '--fresh' : false);

13 changes: 13 additions & 0 deletions example.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
a=fooooo
b=2
c=some string
;d=this should be ignored
[foo]
;sections also are ignored -- keys must have unique names
e=something
f=something else
[bar=ignore this pls]
g=0
h=1
;h=0
;discard latest value
4 changes: 4 additions & 0 deletions ini-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
parse = require('./src/ini-parser.js');

const ini = parse('./example.ini');
console.log(ini);
Loading

0 comments on commit b27b0a6

Please sign in to comment.