diff --git a/src/lib/commands/daemon.js b/src/lib/commands/daemon.js index e4b7f0d..e457811 100644 --- a/src/lib/commands/daemon.js +++ b/src/lib/commands/daemon.js @@ -1,4 +1,5 @@ import Orbiter from '../orbiter.js' +import { Access } from './authentication.js' export default async (argv) => { const options = {} diff --git a/src/lib/commands/init.js b/src/lib/commands/init.js index ea8bf9f..5d668e8 100644 --- a/src/lib/commands/init.js +++ b/src/lib/commands/init.js @@ -10,12 +10,12 @@ import { orbiter, controller, orbiterPath, controllerPath } from '../utils/id.js export default async (argv) => { const id = orbiter - + const directory = orbiterPath(argv.directory) const path = join(directory, 'keystore') const keystore = await KeyStore({ path }) const identities = await Identities({ keystore }) - const identity = await identities.createIdentity({ id }) + await identities.createIdentity({ id }) const blockstore = new LevelBlockstore(join(directory, 'ipfs', 'blocks')) const datastore = new LevelDatastore(join(directory, 'ipfs', 'data')) @@ -25,19 +25,19 @@ export default async (argv) => { const orbitdb = await createOrbitDB({ ipfs, directory, identities, id }) const addresses = libp2p.getMultiaddrs() - + const controllerPubKey = await initController({ addresses, rootDir: argv.directory }) - + const config = await orbitdb.open('config', { type: 'keyvalue' }) await config.put('controller-pubkey', controllerPubKey) await orbitdb.stop() - + return { addresses } } const initController = async ({ addresses, rootDir }) => { const id = controller - + const directory = controllerPath(rootDir) const path = join(directory, 'keystore') const keystore = await KeyStore({ path }) diff --git a/src/lib/controller/handlers/index.js b/src/lib/controller/handlers/index.js index 30d086f..ec7624a 100644 --- a/src/lib/controller/handlers/index.js +++ b/src/lib/controller/handlers/index.js @@ -14,7 +14,7 @@ export const handleControllerRequest = (orbiter) => source => { const { auth, orbitdb } = orbiter const config = await orbitdb.open('config', { type: 'keyvalue' }) - const controllerPubKey = await config.get('controller-pubkey') + const controllerPubKey = await config.get('controller-pubkey') await config.close() // check that the user is authorized to store their dbs on this orbiter. @@ -36,10 +36,11 @@ export const handleControllerRequest = (orbiter) => source => { await handleAuthDelRequest({ auth, addresses }) response = createResponseMessage(Responses.OK) break - case ControllerRequests.AUTH_LIST: + case ControllerRequests.AUTH_LIST: { const list = await handleAuthListRequest({ auth }) response = createResponseMessage(Responses.OK, list) break + } default: throw Object.assign(new Error(`unknown message type ${type}`), { type: Responses.E_INTERNAL_ERROR }) } diff --git a/src/lib/orbiter.js b/src/lib/orbiter.js index 9173501..6e6cd3d 100644 --- a/src/lib/orbiter.js +++ b/src/lib/orbiter.js @@ -24,7 +24,7 @@ export default async ({ directory, verbose, defaultAccess } = {}) => { if (verbose > 0) { enable('orbitdb:voyager:orbiter' + (verbose > 1 ? '*' : ':error')) } - + log('app:', app) log('id:', id) log('directory:', directory) diff --git a/src/lib/utils/id.js b/src/lib/utils/id.js index 94b17df..5154d6c 100644 --- a/src/lib/utils/id.js +++ b/src/lib/utils/id.js @@ -13,4 +13,3 @@ export const controllerPath = (rootDir) => { rootDir = rootDir || '.' return join(rootDir, app, controller) } -