{"version":3,"sources":["../src/helpers/cookieManagement.ts"],"sourcesContent":["import { ServerOptions } from \"../types/cookieHandling\";\nimport { dependencyContainer } from \"../library/DependencyContainer\";\nimport { REMEMBER_ME_COOKIE_KEY } from \"../constants/rememberMeCookieKey\";\n\n/**\n * An object containing helper methods for interacting with the remember me cookie.\n */\nexport const rememberMeCookie = {\n\t/**\n\t * Gets the remember me cookie.\n\t *\n\t * @param {ServerOptions} [serverOptions] - An optional {@link ServerOptions} object containing the res and req objects for ServerResponse and IncomingMessage with cookies respectively. Required for server-side rendering session management.\n\t *\n\t * @returns {Promise<boolean>} A boolean indicating whether or not the user is to be remembered.\n\t */\n\tget: async function (serverOptions?: ServerOptions): Promise<boolean> {\n\t\tdependencyContainer().throwIfDINotConfigured();\n\t\tconst rememberMe = await dependencyContainer()\n\t\t\t.cookieHandler()\n\t\t\t.getCookie(REMEMBER_ME_COOKIE_KEY, serverOptions);\n\t\treturn !!rememberMe;\n\t},\n\t/**\n\t * Sets the remember me cookie.\n\t *\n\t * @param {boolean} rememberMe - The value in which to set the remember me cookie.\n\t * @param {ServerOptions} [serverOptions] - An optional {@link ServerOptions} object containing the res and req objects for ServerResponse and IncomingMessage with cookies respectively. Required for server-side rendering session management.\n\t *\n\t * @returns {Promise<void>} Void.\n\t */\n\tset: async function (\n\t\trememberMe: boolean,\n\t\tserverOptions?: ServerOptions\n\t): Promise<void> {\n\t\tdependencyContainer().throwIfDINotConfigured();\n\t\tif (rememberMe) {\n\t\t\tawait dependencyContainer()\n\t\t\t\t.cookieHandler()\n\t\t\t\t.setCookie(REMEMBER_ME_COOKIE_KEY, \"1\", serverOptions);\n\t\t} else {\n\t\t\tawait this.remove();\n\t\t}\n\t},\n\t/**\n\t * Removes the remember me cookie.\n\t *\n\t * @param {ServerOptions} [serverOptions] - An optional {@link ServerOptions} object containing the res and req objects for ServerResponse and IncomingMessage with cookies respectively. Required for server-side rendering session management.\n\t *\n\t * @returns {Promise<void>} Void.\n\t */\n\tremove: async function (serverOptions?: ServerOptions): Promise<void> {\n\t\tdependencyContainer().throwIfDINotConfigured();\n\t\tawait dependencyContainer()\n\t\t\t.cookieHandler()\n\t\t\t.deleteCookie(REMEMBER_ME_COOKIE_KEY, serverOptions);\n\t},\n};\n"],"mappings":";;;;;;;;AAOO,IAAM,mBAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ/B,KAAK,eAAgB,eAAiD;AACrE,wBAAoB,EAAE,uBAAuB;AAC7C,UAAM,aAAa,MAAM,oBAAoB,EAC3C,cAAc,EACd,UAAU,wBAAwB,aAAa;AACjD,WAAO,CAAC,CAAC;AAAA,EACV;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,KAAK,eACJ,YACA,eACgB;AAChB,wBAAoB,EAAE,uBAAuB;AAC7C,QAAI,YAAY;AACf,YAAM,oBAAoB,EACxB,cAAc,EACd,UAAU,wBAAwB,KAAK,aAAa;AAAA,IACvD,OAAO;AACN,YAAM,KAAK,OAAO;AAAA,IACnB;AAAA,EACD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,QAAQ,eAAgB,eAA8C;AACrE,wBAAoB,EAAE,uBAAuB;AAC7C,UAAM,oBAAoB,EACxB,cAAc,EACd,aAAa,wBAAwB,aAAa;AAAA,EACrD;AACD;","names":[]}