UNPKG

@kinde-oss/kinde-nodejs-sdk

Version:

Kinde Nodejs SDK allows integrate with Express server using middleware, helpers function

85 lines (78 loc) 2.44 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; /** * Create a session store object. * @returns {Object} The session store object. */ var createSessionStore = function createSessionStore() { var store = {}; /** * Get data from the session store based on sessionId. * @param {string} sessionId - The session ID. * @returns {any} The data associated with the sessionId. */ var getData = function getData(sessionId) { return store[sessionId]; }; /** * Set data in the session store for a specific sessionId. * @param {string} sessionId - The session ID. * @param {any} data - The data to be stored. */ var setData = function setData(sessionId, data) { store[sessionId] = data; }; /** * Get data from the session store based on sessionId and key. * @param {string} sessionId - The session ID. * @param {string} key - The key to retrieve specific data. * @returns {any} The data associated with the sessionId and key. */ var getDataByKey = function getDataByKey(sessionId, key) { return store[sessionId] ? store[sessionId][key] : undefined; }; /** * Set data in the session store for a specific sessionId and key. * @param {string} sessionId - The session ID. * @param {string} key - The key to store the data. * @param {any} data - The data to be stored. */ var setDataByKey = function setDataByKey(sessionId, key, data) { if (!store[sessionId]) { store[sessionId] = {}; } store[sessionId][key] = data; }; /** * Remove data in the session store for a specific sessionId and key. * @param {string} sessionId - The session ID. * @param {string} key - The key to store the data. */ var removeDataByKey = function removeDataByKey(sessionId, key) { if (store[sessionId] && store[sessionId][key]) { delete store[sessionId][key]; } }; /** * Remove data from the session store for a specific sessionId. * @param {string} sessionId - The session ID. */ var removeData = function removeData(sessionId) { if (store[sessionId]) { delete store[sessionId]; } }; return { getData: getData, setData: setData, getDataByKey: getDataByKey, setDataByKey: setDataByKey, removeDataByKey: removeDataByKey, removeData: removeData }; }; var _default = createSessionStore(); exports["default"] = _default;