fix(core): update

This commit is contained in:
2020-09-19 15:18:28 +00:00
parent dc9bb6a4a7
commit cf7e064074
6 changed files with 67 additions and 19 deletions

View File

@ -1,10 +1,10 @@
import * as plugins from './webclient.plugins';
export class CsWebclient {
webstore: plugins.webstore.WebStore;
webstore: plugins.webstore.WebStore<plugins.csInterfaces.IWebclientSettings>;
constructor() {
this.webstore = new plugins.webstore.WebStore({
this.webstore = new plugins.webstore.WebStore<plugins.csInterfaces.IWebclientSettings>({
dbName: 'consentsoftware',
storeName: 'webclient'
});
@ -15,7 +15,27 @@ export class CsWebclient {
return !!result;
}
public async setCookieLevels(cookieLevels ): Promise<boolean> {
public async setCookieLevels(cookieLevelsArg: plugins.csInterfaces.TCookieLevel[]): Promise<boolean> {
await this.webstore.set('acceptedCookieLevels', {
acceptanceTimestamp: Date.now(),
acceptedCookieLevels: cookieLevelsArg
});
return true;
}
public async getCookieLevels(): Promise<plugins.csInterfaces.IWebclientSettings['acceptedCookieLevels']> {
const result = await this.webstore.get('acceptedCookieLevels');
return result.acceptedCookieLevels;
}
public async isCookieLevelStillValid(): Promise<boolean> {
if(!this.isCookieLevelSet) {
return false;
}
const result = await this.webstore.get('acceptedCookieLevels');
if (result.acceptanceTimestamp < (Date.now() - plugins.smarttime.getMilliSecondsFromUnits({months: 3}))) {
return false;
}
return true;
}
}

View File

@ -13,8 +13,10 @@ export {
};
// @pushrocks scope
import * as smarttime from '@pushrocks/smarttime';
import * as webstore from '@pushrocks/webstore';
export {
smarttime,
webstore
};