-jraphical      = require 'jraphical'
+hat       = require 'hat'
+jraphical = require 'jraphical'
 
 module.exports = class JCredential extends jraphical.Module
 

        credential = new JCredential _data

        credential.save (err) ->
          return  if failed err, callback, credData

          delegate.addCredential credential, { as: 'owner' }, (err) ->
            return  if failed err, callback, credential, credData



  @fetchByIdentifier = (client, identifier, callback) ->

        callback new KodingError 'Provider is not supported'
        return

      CredentialStore.create client, { meta, originId }, (err, identifier) ->
        return  if failed err, callback

        _data = { provider, title, identifier, originId }

        if provider in ['custom', 'userInput']
          _data.fields   = (Object.keys meta) or []
