Skip to content

Commit

Permalink
Merge 9fd553a into 1af8ce8
Browse files Browse the repository at this point in the history
  • Loading branch information
javisantos committed Mar 12, 2020
2 parents 1af8ce8 + 9fd553a commit a7071f5
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 130 deletions.
137 changes: 50 additions & 87 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -22,9 +22,9 @@
"@lorena-ssi/matrix-lib": "^1.0.7",
"@lorena-ssi/zenroom-lib": "lorena-ssi/zenroom-lib#v1.3.3",
"axios": "^0.19.2",
"chalk": "^3.0.0",
"chalk-pipe": "^3.0.0",
"inquirer": "^7.0.4"
"debug": "^4.1.1",
"inquirer": "^7.1.0"
},
"directories": {
"example": "examples"
Expand Down
15 changes: 9 additions & 6 deletions src/index.js
@@ -1,11 +1,14 @@
const Matrix = require('@lorena-ssi/matrix-lib')
const Zen = require('@lorena-ssi/zenroom-lib')
const Logger = require('./logger')
const logger = new Logger()
const debug = require('debug')('lorena:cli')
const DEFAULT_SERVER = process.env.SERVER ? process.env.SERVER : 'https://matrix.caelumlabs.com'
const { EventEmitter } = require('events')

class Lorena extends EventEmitter {
constructor (serverPath = 'https://matrix.caelumlabs.com') {
constructor (serverPath, options = {}) {
if (typeof serverPath === 'object') options = serverPath
if (typeof serverPath !== 'string') serverPath = DEFAULT_SERVER
if (options.debug) debug.enabled = true
super()
this.matrixUser = ''
this.matrixPass = ''
Expand Down Expand Up @@ -39,7 +42,7 @@ class Lorena extends EventEmitter {
const keyPair = await this.zenroom.z.newKeyPair(username)
this.zenroom.keypair = keyPair[username].keypair
} catch (error) {
logger.log(error)
debug('%O', error)
this.emit('error', error)
throw new Error('Could not create user')
}
Expand All @@ -55,7 +58,7 @@ class Lorena extends EventEmitter {
this.matrixUser = client[0]
this.matrixPass = client[1]
this.did = client[2]
logger.key('Login matrix user', this.matrixUser)
debug('Login matrix user %o', this.matrixUser)
try {
await this.matrix.connect(this.matrixUser, this.matrixPass)

Expand All @@ -70,7 +73,7 @@ class Lorena extends EventEmitter {
this.loop()
return true
} catch (error) {
logger.log(error)
debug('%O', error)
this.emit('error', error)
throw error
}
Expand Down
33 changes: 0 additions & 33 deletions src/logger.js

This file was deleted.

0 comments on commit a7071f5

Please sign in to comment.