       hostname        : String
       owner           : String
 
-  @create = secure (client, data, callback)->
-    {delegate} = client.connection
+  @create = secure (client, data, callback) ->
+    { delegate } = client.connection
     key = new JKodingKey
       key     : data.key
       hostname: data.hostname
       owner   : delegate._id
-    key.save (err)->
+    key.save (err) ->
       if err
         callback err
       else
         callback null, key
 
-  @fetchAll = secure ({connection:{delegate}}, options, callback)->
+  @fetchAll = secure ({ connection:{ delegate } }, options, callback) ->
     JKodingKey.all
       owner : delegate.getId()
-    , (err, keys)->
+    , (err, keys) ->
       callback err, keys
 
-  @fetchByKey = secure ({connection:{delegate}}, options, callback)->
+  @fetchByKey = secure ({ connection:{ delegate } }, options, callback) ->
     JKodingKey.all
       owner : delegate.getId()
       key   : options.key
-    , (err, keys)->
+    , (err, keys) ->
       callback err, keys
 
-  @checkKey = (options, callback)->
-    {key} = options
-    return new KodingError "Key is not valid" unless key and @authCheckKey key
+  @checkKey = (options, callback) ->
+    { key } = options
+    return new KodingError 'Key is not valid' unless key and @authCheckKey key
     JKodingKey.one
       key   : options.key
-    , (err, key)->
+    , (err, key) ->
       return callback err, no if err
       return callback null, no unless key
       callback null, yes
 
-  @createKeyByUser = (options, callback)->
+  @createKeyByUser = (options, callback) ->
     JAccount.one
       'profile.nickname': options.username
-    , (err, account)->
+    , (err, account) ->
       if err then callback err
       else if not account
         callback null, null

        return callback error

      # if not created before, create here
      JKodingKey.createKeyByUser {username, hostname, key}, (err, data)->
        if err
          console.warn "Error occurred while creating koding key - Err: #{err}, "
          return callback new KodingError "An error occurred while saving your key, please try again later"
        return callback null, "Authentication is successfull! Using id: #{data.hostname}"

# coffeelint: disable=no_implicit_braces
jraphical = require 'jraphical'
JAccount  = require './account'
KodingError = require '../error'

module.exports = class JKodingKey extends jraphical.Module

  { Relationship } = jraphical

  { Base, secure, race, signature } = require 'bongo'

  @share()

