Skip to content

Commit

Permalink
v0.3.2 bump.
Browse files Browse the repository at this point in the history
  • Loading branch information
brannondorsey committed Sep 25, 2018
1 parent e605c87 commit 72a375f
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Pre-releases

## v0.3.2

- Validate that if `conf.signingkey` exists it has a matching private key before executing `chat` subcommand.

## v0.3.1

- Add details about the TypeScript implementation of the protocol
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Chattervox

![Travis CI Build Image](https://travis-ci.com/brannondorsey/chattervox.svg?branch=master) [![Coverage Status](https://coveralls.io/repos/github/brannondorsey/chattervox/badge.svg?branch=master)](https://coveralls.io/github/brannondorsey/chattervox?branch=master)
[![Travis CI Build Image](https://travis-ci.com/brannondorsey/chattervox.svg?branch=master)](https://travis-ci.com/brannondorsey/chattervox) [![Coverage Status](https://coveralls.io/repos/github/brannondorsey/chattervox/badge.svg?branch=master)](https://coveralls.io/github/brannondorsey/chattervox?branch=master)

An AX.25 packet radio chat protocol with support for digital signatures and binary compression. Like IRC over radio waves 📡.

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chattervox",
"version": "0.3.1",
"version": "0.3.2",
"description": "An AX.25 packet radio chat protocol with support for digital signatures and binary compression. Like IRC over radio waves 📡〰.",
"main": "build/main.js",
"bin": {
Expand Down
3 changes: 2 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ export function validate(config: Config): void {
} else if (typeof config.keystoreFile !== 'string') {
throw TypeError('keystoreFile must be a string type')
} else if (typeof config.signingKey !== 'undefined'
&& config.signingKey != null
&& typeof config.signingKey !== 'string') {
throw TypeError('signingKey must be a string if it is defined')
throw TypeError('signingKey must be a string or null if it is defined')
}
}

Expand Down
43 changes: 41 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ArgumentParser, SubParser } from 'argparse'
import * as fs from 'fs'
import * as path from 'path'
import * as config from './config'
import { Keystore } from './Keystore'
import { Keystore, Key } from './Keystore'
import * as chat from './subcommands/chat'
import * as addkey from './subcommands/addkey'
import * as removekey from './subcommands/removekey'
Expand Down Expand Up @@ -88,6 +88,37 @@ function validateArgs(args: any): void {
}
}

// not sure if we should add this here...
// function validateKeystoreFile(conf: config.Config): void {

// if (!fs.existsSync(conf.keystoreFile)) {
// console.error(`No keystoreFile exists at location "${conf.keystoreFile}".`)
// process.exit(1)
// } else {
// try {
// JSON.parse(fs.readFileSync(conf.keystoreFile).toString('utf8'))
// } catch (err) {
// console.error(`Error loading keystoreFile file from "${conf.keystoreFile}".`)
// console.error(err.message)
// process.exit(1)
// }
// }
// }

function validateSigningKeyExists(conf: config.Config, ks: Keystore): void {
// if there is a signing in the config but it doesn't exist in the keystore
if (conf.signingKey != null) {
const signing = ks.getKeyPairs(conf.callsign).filter((key: Key) => {
return key.public === conf.signingKey
})

if (signing.length < 1) {
console.error(`Default signing key has no matching private key found in the keystore.`)
process.exit(1)
}
}
}

async function main() {

const args = parseArgs()
Expand All @@ -99,7 +130,7 @@ async function main() {
if (args.config === config.defaultConfigPath) {
await interactiveInit()
} else {
console.error(`No config file exists at "${args.config}". Exiting.`)
console.error(`No config file exists at "${args.config}".`)
process.exit(1)
}
}
Expand All @@ -112,8 +143,16 @@ async function main() {
console.error(err.message)
process.exit(1)
}

// validate that keystore file exists
// validateKeystoreFile(conf)
const ks: Keystore = new Keystore(conf.keystoreFile)

// if this subcommand is any of the commands that signs something
if (['chat'].includes(args.subcommand)) {
validateSigningKeyExists(conf, ks)
}

let code = null
switch (args.subcommand) {
case 'chat': code = await chat.main(args, conf, ks); break
Expand Down

0 comments on commit 72a375f

Please sign in to comment.