Skip to content

Commit

Permalink
Add Peer Discovery Code
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-cronin committed Jun 9, 2020
1 parent 80639ab commit 30056bd
Show file tree
Hide file tree
Showing 78 changed files with 3,550 additions and 174 deletions.
22 changes: 18 additions & 4 deletions bin/initPolykey.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import fs from 'fs'
import os from 'os'
import zxcvbn from 'zxcvbn'
import inquirer from 'inquirer'
import PolyKey from '../src/Polykey'
import Configstore from 'configstore'
import { KeyManager } from '../src/KeyManager'
import { actionRunner } from './polykey'
import PolyKey from '@polykey/Polykey'
import KeyManager from '@polykey/KeyManager'
import { actionRunner, pkLogger, PKMessageType } from './polykey'
const cliProgress = require('cli-progress')

const configStore = new Configstore('PolyKeyConfig')

Expand Down Expand Up @@ -157,7 +159,19 @@ async function initPolyKey(): Promise<PolyKey> {
const keyGenerationName = configStore.get('keyGenerationName')
const keyGenerationEmail = configStore.get('keyGenerationEmail')
const keyGenerationPassphrase = configStore.get('keyGenerationPassphrase')
await keyManager.generateKeyPair(keyGenerationName, keyGenerationEmail, keyGenerationPassphrase)

// Validate passphrase
const passValidation = zxcvbn(keyGenerationPassphrase)
// The following is an arbitrary delineation of desirable scores
if (passValidation.score < 2) {
pkLogger('passphrase score for new keypair is below 2!', PKMessageType.WARNING)
}

const bar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic)
bar.start(200, 0)
bar.update(100)
bar.stop()
await keyManager.generateKeyPair(keyGenerationName, keyGenerationEmail, keyGenerationPassphrase, true)

// Store the keys in the key manager's storePath
const storePath = `${resolveTilde(keyManager.storePath)}/.keypair`
Expand Down
4 changes: 2 additions & 2 deletions bin/keymanager/KeyManager.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import commander from 'commander'
import { actionRunner, pkLogger, PKMessageType } from '../polykey'
import initPolyKey from '../initPolykey'
import { actionRunner, pkLogger, PKMessageType } from '../polykey'

function makeDeriveKeyCommand() {
return new commander.Command('derive')
Expand All @@ -11,7 +11,7 @@ function makeDeriveKeyCommand() {
const keyName = options.keyName
const keyPassphrase = options.keyPassphrase
const pk = await initPolyKey()
pk.km.generateKeySync(keyPassphrase, keyName)
pk.keyManager.generateKeySync(keyPassphrase, keyName)
pkLogger(`'${keyName}' was added to the Key Manager`, PKMessageType.SUCCESS)
}))
}
Expand Down
1 change: 0 additions & 1 deletion bin/secrets/Secrets.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import chalk from 'chalk'
import fs from 'fs'
import initPolyKey from "../initPolykey"
import commander from 'commander'
Expand Down
1 change: 0 additions & 1 deletion bin/vaults/Vaults.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import chalk from 'chalk'
import fs from 'fs'
import initPolyKey from "../initPolykey"
import commander from 'commander'
import { actionRunner, pkLogger, PKMessageType } from '../polykey'
Expand Down
175 changes: 175 additions & 0 deletions dist/P2P/MulticastPeerDiscovery.js

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

1 change: 1 addition & 0 deletions dist/P2P/MulticastPeerDiscovery.js.map

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

38 changes: 38 additions & 0 deletions dist/PeerStore/PeerInfo.js

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

1 change: 1 addition & 0 deletions dist/PeerStore/PeerInfo.js.map

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

51 changes: 51 additions & 0 deletions dist/PeerStore/PeerStore.js

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

1 change: 1 addition & 0 deletions dist/PeerStore/PeerStore.js.map

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

Loading

0 comments on commit 30056bd

Please sign in to comment.