You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
984 B
TypeScript
21 lines
984 B
TypeScript
import { LoadDictElement } from 'di-why/build/src/DiContainer';
|
|
import { CookieManager } from './CookieManager';
|
|
import { CookieConfig } from '../types/auth.types';
|
|
|
|
export const cookieManagerLDEGen = (config?: Partial<CookieConfig>): LoadDictElement<CookieManager> => ({
|
|
factory: ({ appConfig }) => {
|
|
return new CookieManager({
|
|
domain: config?.domain || appConfig.rpCookieDomain || appConfig.cookieDomain,
|
|
sessionName: config?.sessionName || appConfig.sessionCookieName || 'sid',
|
|
refreshName: config?.refreshName || appConfig.refreshCookieName || 'rid',
|
|
secureCookie: config?.secureCookie !== undefined ? config.secureCookie : true,
|
|
sameSite: config?.sameSite || 'lax',
|
|
httpOnly: config?.httpOnly !== undefined ? config.httpOnly : true,
|
|
sessionTTL: config?.sessionTTL || appConfig.sessionTTL || 7200,
|
|
refreshTTL: config?.refreshTTL || appConfig.refreshTTL || 604800
|
|
});
|
|
},
|
|
locateDeps: {
|
|
appConfig: 'appConfig'
|
|
}
|
|
}); |