fix(core): update
This commit is contained in:
		
							
								
								
									
										13
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										13
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							| @@ -1125,9 +1125,9 @@ | ||||
|       } | ||||
|     }, | ||||
|     "@consentsoftware/interfaces": { | ||||
|       "version": "1.0.4", | ||||
|       "resolved": "https://verdaccio.lossless.one/@consentsoftware%2finterfaces/-/interfaces-1.0.4.tgz", | ||||
|       "integrity": "sha512-GovOjaywV+X9VW9AVOjIFIrue/6YXOMKjk/YBnxo52inYWit1v1HuUkjlG/AOqjipqoMB+aujKNXv70oeXa7xQ==", | ||||
|       "version": "1.0.5", | ||||
|       "resolved": "https://verdaccio.lossless.one/@consentsoftware%2finterfaces/-/interfaces-1.0.5.tgz", | ||||
|       "integrity": "sha512-IcdWxVfTznNaTs4tVCkrWpYr2NSewBkQIuoznDhnZaRhRrS6ni5VN5WsRqeZOy5QY4733Kr9aQ8i6FL6OCnpqA==", | ||||
|       "requires": { | ||||
|         "@apiglobal/typedrequest-interfaces": "^1.0.15" | ||||
|       } | ||||
| @@ -2049,10 +2049,11 @@ | ||||
|       } | ||||
|     }, | ||||
|     "@pushrocks/webstore": { | ||||
|       "version": "1.0.9", | ||||
|       "resolved": "https://verdaccio.lossless.one/@pushrocks%2fwebstore/-/webstore-1.0.9.tgz", | ||||
|       "integrity": "sha512-wfPRKAVxiD5XWuJwMlgB2VWByrdXIjfPejgnUFJh5IIMt6Y/NA+lh3nRuZVMzNUWfZQIKQn7MOOt0nPDGAEvMw==", | ||||
|       "version": "1.0.14", | ||||
|       "resolved": "https://verdaccio.lossless.one/@pushrocks%2fwebstore/-/webstore-1.0.14.tgz", | ||||
|       "integrity": "sha512-RmI6m1VOW92Vw6I+HUKSrDRJ8vyUBaHpusOoMv0QXraSiwyPlEudEFzi0Ji0nN4++i+ejKIxOuD/gh/jruA4NA==", | ||||
|       "requires": { | ||||
|         "@pushrocks/smartpromise": "^3.0.6", | ||||
|         "idb": "^5.0.6" | ||||
|       } | ||||
|     }, | ||||
|   | ||||
| @@ -21,8 +21,9 @@ | ||||
|   }, | ||||
|   "dependencies": { | ||||
|     "@apiglobal/typedrequest": "^1.0.43", | ||||
|     "@consentsoftware/interfaces": "^1.0.4", | ||||
|     "@pushrocks/webstore": "^1.0.9" | ||||
|     "@consentsoftware/interfaces": "^1.0.5", | ||||
|     "@pushrocks/smarttime": "^3.0.35", | ||||
|     "@pushrocks/webstore": "^1.0.14" | ||||
|   }, | ||||
|   "browserslist": [ | ||||
|     "last 1 chrome versions" | ||||
|   | ||||
							
								
								
									
										32
									
								
								test/test.browser.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								test/test.browser.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,32 @@ | ||||
| import { expect, tap } from '@pushrocks/tapbundle'; | ||||
| import * as webclient from '../ts/index'; | ||||
|  | ||||
| let testClient: webclient.CsWebclient; | ||||
|  | ||||
| tap.test('should create an instance of webclient', async () => { | ||||
|   testClient = new webclient.CsWebclient(); | ||||
|   expect(testClient).to.be.instanceOf(webclient.CsWebclient); | ||||
| }); | ||||
|  | ||||
| tap.test('should return false when asked for present settings', async () => { | ||||
|   const result = await testClient.isCookieLevelSet(); | ||||
|   expect(result).to.be.false; | ||||
| }); | ||||
|  | ||||
| tap.test('should create a cookielevel setting', async () => { | ||||
|   await testClient.setCookieLevels(['functional']); | ||||
|   const result = await testClient.getCookieLevels(); | ||||
|   expect(result).to.contain('functional'); | ||||
| }); | ||||
|  | ||||
| tap.test('should return true when asked for present settings', async () => { | ||||
|   const result = await testClient.isCookieLevelSet(); | ||||
|   expect(result).to.be.true; | ||||
| }); | ||||
|  | ||||
| tap.test('should validity for present settings', async () => { | ||||
|   const result = await testClient.isCookieLevelStillValid(); | ||||
|   expect(result).to.be.true; | ||||
| }); | ||||
|  | ||||
| tap.start(); | ||||
| @@ -1,8 +0,0 @@ | ||||
| import { expect, tap } from '@pushrocks/tapbundle'; | ||||
| import * as webclient from '../ts/index'; | ||||
|  | ||||
| tap.test('first test', async () => { | ||||
|   console.log(webclient.standardExport); | ||||
| }); | ||||
|  | ||||
| tap.start(); | ||||
							
								
								
									
										26
									
								
								ts/index.ts
									
									
									
									
									
								
							
							
						
						
									
										26
									
								
								ts/index.ts
									
									
									
									
									
								
							| @@ -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; | ||||
|   } | ||||
| } | ||||
| @@ -13,8 +13,10 @@ export { | ||||
| }; | ||||
|  | ||||
| // @pushrocks scope | ||||
| import * as smarttime from '@pushrocks/smarttime'; | ||||
| import * as webstore from '@pushrocks/webstore'; | ||||
|  | ||||
| export { | ||||
|   smarttime, | ||||
|   webstore | ||||
| }; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user