/* Hello! Welcome to the sample functions for ignite-keychain.
This file provides functions to store credentials for an external
authentication server - a very common use case.

Futher functions available in the keychain readme:
https://github.com/oblador/react-native-keychain

Thanx @oblador!
*/
import * as Keychain from 'react-native-keychain'

// This function stores the credentials you got from
// the authentication server. Parameters are examples.
// url: The site youre authenticating against.
// client: a client ID (you might not always have this)
// token: the access token
// uid: the autentication server's user ID for this user (if any)
// expiry: When the token expires. Assumes integer representation.

export function storeAuth (url, client, token, uid, expiry) {
  let out = [client, token, expiry].join()
  return Keychain.setInternetCredentials(url, uid, out)
    .then(function () {
      return { ok: true, error: null }
    })
    .catch(function () {
      return { ok: false, error: 'Failed to get credentials!' }
    })
}

// Retrieves the credentials from the keychain that you stored in storeAuth.
// You might want to call this function when you're about to interact
// with your API endpoint.

export function fetchAuth (url) {
  return Keychain.getInternetCredentials(url)
    .then(function (credentials) {
      // You might want to parse the credentials that you get
      // out of the keychain here before returning them.
      return { ok: true, credentials: credentials }
    })
    .catch(function () {
      return { error: 'Failed to get credentials!' }
    })
}

// Removes the credentials from the keychain.
// Use this when a user logs out or deregisters from your service.

export function deleteAuth (url) {
  return Keychain.resetInternetCredentials(url)
    .then(function () {
      return { ok: true, error: null }
    })
    .catch(error => {
      return { ok: false, error: error }
    })
}

@@ -889,36 +889,22 @@
 hen(
-function () %7B%0A      return %7B
+() =%3E (%7B%0A     
  ok:
@@ -901,32 +901,38 @@
 %0A      ok: true,
+%0A     
  error: null %7D%0A 
@@ -923,33 +923,32 @@
  error: null
- %7D
 %0A    %7D)
+)
 %0A    .catch(
@@ -951,36 +951,22 @@
 tch(
-function () %7B%0A      return %7B
+() =%3E (%7B%0A     
  ok:
@@ -964,32 +964,38 @@
       ok: false,
+%0A     
  error: 'Failed 
@@ -1010,33 +1010,32 @@
 redentials!'
- %7D
 %0A    %7D)
+)
 %0A%7D%0A%0A// Retri
@@ -1290,26 +1290,16 @@
    .then
-(function 
 (credent
@@ -1302,22 +1302,23 @@
 dentials
-) %7B%0A  
+ =%3E (%7B%0A
     // Y
@@ -1369,18 +1369,16 @@
 you get%0A
-  
     // o
@@ -1425,33 +1425,24 @@
  them.%0A     
- return %7B
  ok: true, c
@@ -1439,16 +1439,22 @@
 k: true,
+%0A     
  credent
@@ -1470,25 +1470,24 @@
 dentials
- %7D
 %0A    %7D)
+)
 %0A    .ca
@@ -1494,36 +1494,39 @@
 tch(
-function () %7B%0A      return %7B
+() =%3E (%7B%0A      ok: false,%0A     
  err
@@ -1557,25 +1557,24 @@
 ntials!'
- %7D
 %0A    %7D)
+)
 %0A%7D%0A%0A// R
@@ -1780,36 +1780,22 @@
 hen(
-function () %7B%0A      return %7B
+() =%3E (%7B%0A     
  ok:
@@ -1800,16 +1800,22 @@
 k: true,
+%0A     
  error: 
@@ -1818,25 +1818,24 @@
 or: null
- %7D
 %0A    %7D)
+)
 %0A    .ca
@@ -1842,33 +1842,22 @@
 tch(
-error
+()
  =%3E 
+(
 %7B%0A     
- return %7B
  ok:
@@ -1863,24 +1863,30 @@
 : false,
+%0A     
  error: 
 error %7D%0A
@@ -1881,21 +1881,46 @@
 or: 
-error %7D
+'Failed to delete credentials!'
 %0A    %7D)
+)
 %0A%7D%0A

Use ES6 syntax in Keychain.js, and fix lint errors