var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.load=load;exports.reset=reset;exports.save=save;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator"));var ReactNativeKeychain=_interopRequireWildcard(require("react-native-keychain"));function _interopRequireWildcard(e,t){if("function"==typeof WeakMap)var r=new WeakMap(),n=new WeakMap();return(_interopRequireWildcard=function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var o,i,f={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return f;if(o=t?n:r){if(o.has(e))return o.get(e);o.set(e,f);}for(var _t in e)"default"!==_t&&{}.hasOwnProperty.call(e,_t)&&((i=(o=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,_t))&&(i.get||i.set)?o(f,_t,i):f[_t]=e[_t]);return f;})(e,t);}function save(username,password,server){return _regenerator.default.async(function(_context){while(1)switch(_context.prev=_context.next){case 0:if(!server){_context.next=2;break;}_context.next=1;return _regenerator.default.awrap(ReactNativeKeychain.setInternetCredentials(server,username,password));case 1:return _context.abrupt("return",true);case 2:return _context.abrupt("return",ReactNativeKeychain.setGenericPassword(username,password));case 3:case"end":return _context.stop();}},null,null,null,Promise);}function load(server){var creds,_creds;return _regenerator.default.async(function(_context2){while(1)switch(_context2.prev=_context2.next){case 0:if(!server){_context2.next=2;break;}_context2.next=1;return _regenerator.default.awrap(ReactNativeKeychain.getInternetCredentials(server));case 1:creds=_context2.sent;return _context2.abrupt("return",{username:creds?creds.username:null,password:creds?creds.password:null,server:server});case 2:_context2.next=3;return _regenerator.default.awrap(ReactNativeKeychain.getGenericPassword());case 3:_creds=_context2.sent;if(!(typeof _creds==="object")){_context2.next=4;break;}return _context2.abrupt("return",{username:_creds.username,password:_creds.password,server:null});case 4:return _context2.abrupt("return",{username:null,password:null,server:null});case 5:case"end":return _context2.stop();}},null,null,null,Promise);}function reset(server){var result;return _regenerator.default.async(function(_context3){while(1)switch(_context3.prev=_context3.next){case 0:if(!server){_context3.next=2;break;}_context3.next=1;return _regenerator.default.awrap(ReactNativeKeychain.resetInternetCredentials(server));case 1:return _context3.abrupt("return",true);case 2:_context3.next=3;return _regenerator.default.awrap(ReactNativeKeychain.resetGenericPassword());case 3:result=_context3.sent;return _context3.abrupt("return",result);case 4:case"end":return _context3.stop();}},null,null,null,Promise);}
//# sourceMappingURL=keychain.js.map