UNPKG

solid-auth-client

Version:
95 lines (83 loc) 3.56 kB
import _regeneratorRuntime from "@babel/runtime/regenerator"; import _defineProperty from "@babel/runtime/helpers/defineProperty"; import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator"; function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } import { getData, updateStorage } from './storage'; export function getSession(_x) { return _getSession.apply(this, arguments); } function _getSession() { _getSession = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(storage) { var data; return _regeneratorRuntime.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: _context2.next = 2; return getData(storage); case 2: data = _context2.sent; return _context2.abrupt("return", data.session || null); case 4: case "end": return _context2.stop(); } } }, _callee2); })); return _getSession.apply(this, arguments); } export function saveSession(storage) { return /*#__PURE__*/function () { var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(session) { var data; return _regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: _context.next = 2; return updateStorage(storage, function (data) { return _objectSpread(_objectSpread({}, data), {}, { session: session }); }); case 2: data = _context.sent; return _context.abrupt("return", data.session); case 4: case "end": return _context.stop(); } } }, _callee); })); return function (_x2) { return _ref.apply(this, arguments); }; }(); } export function clearSession(_x3) { return _clearSession.apply(this, arguments); } function _clearSession() { _clearSession = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(storage) { return _regeneratorRuntime.wrap(function _callee3$(_context3) { while (1) { switch (_context3.prev = _context3.next) { case 0: _context3.next = 2; return updateStorage(storage, function (data) { return _objectSpread(_objectSpread({}, data), {}, { session: null }); }); case 2: case "end": return _context3.stop(); } } }, _callee3); })); return _clearSession.apply(this, arguments); }