UNPKG

@shift-code/cli

Version:

Redeem Gearbox SHiFT codes automatically

63 lines 2.37 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.clearCodeCache = exports.appendCodeCache = exports.saveCodeCache = exports.clearAccountSession = exports.saveAccount = exports.saveAccountSession = exports.saveAccountCache = exports.loadAccountCache = exports.accountCacheExists = void 0; const store_1 = require("../store"); async function accountCacheExists(accountID) { const exists = await (0, store_1.storeExists)(store_1.ACCOUNT_CACHE, accountID); return exists; } exports.accountCacheExists = accountCacheExists; async function loadAccountCache(accountID) { const cache = await (0, store_1.loadContents)(store_1.ACCOUNT_CACHE, accountID, {}); return cache; } exports.loadAccountCache = loadAccountCache; async function saveAccountCache(accountID, data) { await (0, store_1.storeContents)(store_1.ACCOUNT_CACHE, accountID, data); } exports.saveAccountCache = saveAccountCache; async function saveAccountSession(accountID, session) { const cache = await loadAccountCache(accountID); await saveAccountCache(accountID, { ...cache, session }); } exports.saveAccountSession = saveAccountSession; async function saveAccount(accountID, account) { const cache = await loadAccountCache(accountID); await saveAccountCache(accountID, { ...cache, account }); } exports.saveAccount = saveAccount; async function clearAccountSession(accountID) { const cache = await loadAccountCache(accountID); delete cache?.session; await saveAccountCache(accountID, cache); } exports.clearAccountSession = clearAccountSession; async function saveCodeCache(accountID, codes) { const cache = await loadAccountCache(accountID); await saveAccountCache(accountID, { ...cache, codes }); } exports.saveCodeCache = saveCodeCache; async function appendCodeCache(accountID, code) { const cache = await loadAccountCache(accountID); if (!cache.codes) cache.codes = []; cache.codes.push(code); await saveAccountCache(accountID, cache); } exports.appendCodeCache = appendCodeCache; async function clearCodeCache(accountID) { const cache = await loadAccountCache(accountID); delete cache?.codes; await saveAccountCache(accountID, cache); } exports.clearCodeCache = clearCodeCache; //# sourceMappingURL=account.js.map