Skip to content

Commit

Permalink
fix: Unifying debug messages
Browse files Browse the repository at this point in the history
  • Loading branch information
simonas-notcat committed Dec 12, 2019
1 parent dc52b55 commit efb4f3b
Show file tree
Hide file tree
Showing 20 changed files with 26 additions and 127 deletions.
2 changes: 1 addition & 1 deletion packages/daf-cli/src/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { DataStore } from 'daf-data-store'
import ws from 'ws'

import Debug from 'debug'
const debug = Debug('main')
const debug = Debug('daf:cli')

const defaultPath = process.env.HOME + '/.daf'

Expand Down
87 changes: 0 additions & 87 deletions packages/daf-core/src/old-service-manager.ts

This file was deleted.

19 changes: 4 additions & 15 deletions packages/daf-data-store/src/migrations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { second } from './002.second'
import { DbDriver } from '../types'
import Debug from 'debug'

const debug = Debug('db-migrations')
const debug = Debug('daf:data-store:db-migrations')

const availableMigrations = [initial, second]

Expand All @@ -16,23 +16,12 @@ export const insertLastMigrationId = (db: DbDriver, id: number) => {
export const runMigrations = async (db: DbDriver) => {
debug('Running migrations...')

await db.run(
'CREATE TABLE IF NOT EXISTS migrations (migrationId TEXT, timestamp TEXT)',
[],
)
const rows = await db.rows(
'SELECT * FROM migrations ORDER BY migrationId DESC LIMIT 1',
[],
)
await db.run('CREATE TABLE IF NOT EXISTS migrations (migrationId TEXT, timestamp TEXT)', [])
const rows = await db.rows('SELECT * FROM migrations ORDER BY migrationId DESC LIMIT 1', [])

let lastMigrationId = -1
if (rows[0] && rows[0].migrationId) {
debug(
'Latest migrationId:' +
rows[0].migrationId +
' finished at:' +
rows[0].timestamp,
)
debug('Latest migrationId:' + rows[0].migrationId + ' finished at:' + rows[0].timestamp)
lastMigrationId = parseInt(rows[0].migrationId, 10)
}

Expand Down
2 changes: 1 addition & 1 deletion packages/daf-debug/src/action-handler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Core, AbstractActionHandler, Types } from 'daf-core'

import Debug from 'debug'
const debug = Debug('action')
const debug = Debug('daf:debug:action-handler')

export class ActionHandler extends AbstractActionHandler {
public async handleAction(action: Types.Action, core: Core) {
Expand Down
2 changes: 1 addition & 1 deletion packages/daf-debug/src/message-validator.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Core, AbstractMessageValidator, Message } from 'daf-core'

import Debug from 'debug'
const debug = Debug('message')
const debug = Debug('daf:debug:message-validator')

export class MessageValidator extends AbstractMessageValidator {
async validate(message: Message, core: Core): Promise<Message> {
Expand Down
2 changes: 1 addition & 1 deletion packages/daf-did-comm/src/action-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { DIDComm } from 'DIDComm-js'
import uuid from 'uuid'
import Debug from 'debug'

const debug = Debug('did-comm-action-handler')
const debug = Debug('daf:did-comm:action-handler')

export const ActionTypes = {
sendJwt: 'action.sendJwt',
Expand Down
2 changes: 1 addition & 1 deletion packages/daf-did-comm/src/message-validator.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Core, AbstractMessageValidator, Message } from 'daf-core'
import { DIDComm } from 'DIDComm-js'
import Debug from 'debug'
const debug = Debug('did-comm-message-validator')
const debug = Debug('daf:did-comm:message-validator')

export class MessageValidator extends AbstractMessageValidator {
private didcomm: DIDComm
Expand Down
2 changes: 1 addition & 1 deletion packages/daf-did-jwt/src/message-validator.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Core, AbstractMessageValidator, Message, Resolver } from 'daf-core'
import { verifyJWT, decodeJWT } from 'did-jwt'
import Debug from 'debug'
const debug = Debug('did-jwt-validator')
const debug = Debug('daf:did-jwt:message-validator')

export class MessageValidator extends AbstractMessageValidator {
async validate(message: Message, core: Core): Promise<Message> {
Expand Down
2 changes: 1 addition & 1 deletion packages/daf-ethr-did-fs/src/identity-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { IdentityController, Issuer } from 'daf-core'
const EthrDID = require('ethr-did')
const fs = require('fs')
import Debug from 'debug'
const debug = Debug('fs-ethr-did-controller')
const debug = Debug('daf:ethr-did-fs:identity-controller')

interface Identity {
address: string
Expand Down
2 changes: 1 addition & 1 deletion packages/daf-ethr-did-react-native/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { IdentityController, Issuer } from 'daf-core'
import { RNUportHDSigner, getSignerForHDPath } from 'react-native-uport-signer'

import Debug from 'debug'
const debug = Debug('ethr-did-controller')
const debug = Debug('daf:ethr-did-react-native:identity-controller')

// ANDROID OPTIONS
//
Expand Down
2 changes: 1 addition & 1 deletion packages/daf-node-sqlite3/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import sqlite3 from 'sqlite3'
import { Types } from 'daf-data-store'

import Debug from 'debug'
const debug = Debug('daf-node-sqlite3')
const debug = Debug('daf:node-sqlite3')

export class NodeSqlite3 implements Types.DbDriver {
private db: any
Expand Down
2 changes: 1 addition & 1 deletion packages/daf-react-native-sqlite3/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { openDatabase } from 'react-native-sqlite-storage'
import { Types } from 'daf-data-store'
import Debug from 'debug'

const debug = Debug('rn-sqlite3')
const debug = Debug('daf:react-native-sqlite3')

class RnSqlite3 implements Types.DbDriver {
private db: any
Expand Down
2 changes: 1 addition & 1 deletion packages/daf-resolver-universal/src/resolver.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'cross-fetch/polyfill'
import Debug from 'debug'

const debug = Debug('resolver-universal')
const debug = Debug('daf:resolver-universal')

interface Options {
url: string
Expand Down
6 changes: 3 additions & 3 deletions packages/daf-resolver/src/resolver.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Resolver } from 'did-resolver'
import { getResolver as ethrDidResolver } from 'ethr-did-resolver'
import { resolver as naclDidResolver } from 'nacl-did'
import { getResolver as webDidResolver} from 'web-did-resolver'
import { getResolver as webDidResolver } from 'web-did-resolver'
import Debug from 'debug'

const debug = Debug('resolver')
const debug = Debug('daf:resolver')

interface Options {
infuraProjectId: string
Expand All @@ -19,7 +19,7 @@ export class DafResolver {
rpcUrl: 'https://mainnet.infura.io/v3/' + options.infuraProjectId,
}),
...webDidResolver(),
nacl: naclDidResolver
nacl: naclDidResolver,
})
}

Expand Down
2 changes: 1 addition & 1 deletion packages/daf-selective-disclosure/src/action-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Core, AbstractActionHandler, Types } from 'daf-core'
import { createJWT } from 'did-jwt'
import Debug from 'debug'

const debug = Debug('sdr-action-handler')
const debug = Debug('daf:selective-disclosure:action-handler')

export const ActionTypes = {
signSdr: 'action.sign.sdr',
Expand Down
2 changes: 1 addition & 1 deletion packages/daf-selective-disclosure/src/message-validator.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Core, AbstractMessageValidator, Message } from 'daf-core'

import Debug from 'debug'
const debug = Debug('daf:sdr-validator')
const debug = Debug('daf:daf:selective-disclosure:message-validator')

export const MessageTypes = {
sdr: 'sdr',
Expand Down
4 changes: 2 additions & 2 deletions packages/daf-sodium-fs/src/encryption-key-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import sodium from 'libsodium-wrappers'
const fs = require('fs')

import Debug from 'debug'
const debug = Debug('sodium-fs-encryption-key-manager')
const debug = Debug('daf:sodium-fs-encryption-key-manager')

interface DidKeyPairMap {
[did: string]: KeyPair
Expand All @@ -23,7 +23,7 @@ export class SodiumFsEncryptionKeyManager implements EncryptionKeyManager {
if (fs.existsSync(this.fileName)) {
const raw = fs.readFileSync(this.fileName)
const parsed = JSON.parse(raw)

Object.keys(parsed).forEach(did => {
const i = parsed[did]
this.didKeyPairMap[did] = {
Expand Down
2 changes: 1 addition & 1 deletion packages/daf-trust-graph/src/action-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Core, AbstractActionHandler, Types, Message } from 'daf-core'
import { ServiceController } from './service-controller'

import Debug from 'debug'
const debug = Debug('trust-graph-action-handler')
const debug = Debug('daf:trust-graph:action-handler')

export const ActionTypes = {
sendJwt: 'action.sendJwt',
Expand Down
7 changes: 2 additions & 5 deletions packages/daf-w3c/src/action-handler.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import { Core, AbstractActionHandler, Types } from 'daf-core'
import { createVerifiableCredential, createPresentation } from 'did-jwt-vc'
import {
PresentationPayload,
VerifiableCredentialPayload,
} from 'did-jwt-vc/src/types'
import { PresentationPayload, VerifiableCredentialPayload } from 'did-jwt-vc/src/types'

import Debug from 'debug'
const debug = Debug('w3c-action-handler')
const debug = Debug('daf:w3c:action-handler')

export const ActionTypes = {
signVc: 'action.sign.w3c.vc',
Expand Down
2 changes: 1 addition & 1 deletion packages/daf-w3c/src/message-validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from 'did-jwt-vc'

import Debug from 'debug'
const debug = Debug('w3c-validator')
const debug = Debug('daf:w3c:message-validator')

export const MessageTypes = {
vc: 'w3c.vc',
Expand Down

0 comments on commit efb4f3b

Please sign in to comment.