first commit

This commit is contained in:
Gianmarco Pettinato 2021-09-23 15:45:12 +02:00
parent b2cd5d7c5c
commit 0edd12ebad
10 changed files with 15624 additions and 170 deletions

View File

@ -18,7 +18,7 @@
"rules": {
"indent": [
"error",
4
2
],
"linebreak-style": [
"error",

15753
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -10,10 +10,12 @@
"license": "ISC",
"dependencies": {
"body-parser": "^1.19.0",
"dcc-utils": "^0.2.0",
"express": "^4.17.1",
"typescript": "^4.4.3"
},
"devDependencies": {
"@types/express": "^4.17.13",
"@types/node": "^16.9.6",
"@typescript-eslint/eslint-plugin": "^4.31.2",
"@typescript-eslint/parser": "^4.31.2",

View File

@ -13,7 +13,7 @@ export class CertificateDownloader{
const savedData = JSON.parse(localStorage.getItem(this.keyStorage) || '{}');
if(savedData.lastupdateDate == null || Date.now() - savedData?.lastupdateDate > this.timeSpan){
this.getAllCertificate()
.then(() => { console.log('could not read the certificates from the local file'); return this.cerficateCollection })
.then(() => { console.log('could not read the certificates from the local file'); return this.cerficateCollection; })
.catch(console.error);
}
console.log('cerficates collection is valid loading from local source');
@ -36,7 +36,7 @@ export class CertificateDownloader{
this.cerficateCollection = await response.json();
console.log(response);
const lastupdateDate = Date.now();
localStorage.setItem(this.keyStorage, JSON.stringify({'certificates':this.cerficateCollection, lastupdateDate}))
localStorage.setItem(this.keyStorage, JSON.stringify({'certificates':this.cerficateCollection, lastupdateDate}));
// fs.writeFile('./cerificate_collection.json', JSON.stringify({'certificates':this.cerficateCollection, lastupdateDate}),'utf8',console.error);
}else{
throw new Error(response.statusText);

View File

@ -14,7 +14,7 @@ export class RuleDownloader {
const savedData = JSON.parse(localStorage.getItem(this.keyStorage) || '{}');
if(savedData.lastupdateDate == null || Date.now() - savedData?.lastupdateDate > this.timeSpan){
this.getSettings()
.then(() => { console.log('could not read the certificates from the local file'); return this.rules })
.then(() => { console.log('could not read the certificates from the local file'); return this.rules; })
.catch(console.error);
}
console.log('cerficates collection is valid loading from local source');

View File

@ -1,17 +1,16 @@
import { CertificateDownloader } from './CertificateDownloader';
import { RuleDownloader } from './RuleDownloader';
import {DCC} from 'dcc-utils';
import fs from 'fs';
export default class Verifier {
static certDownloader: CertificateDownloader;
static ruleDownloader: RuleDownloader;
static certificateList: any;
static certificateList: unknown;
static async setup():Promise<void> {
Verifier.certDownloader = CertificateDownloader.getCertificateDownloader();
Verifier.ruleDownloader = RuleDownloader.getRuleDownloader();
Verifier.certificateList = await Verifier.certDownloader.getCertificates()
Verifier.certificateList = await Verifier.certDownloader.getCertificates();
}
static async checkCertificate(certificate:string): Promise<unknown>{