first commit
This commit is contained in:
parent
b2cd5d7c5c
commit
0edd12ebad
@ -18,7 +18,7 @@
|
|||||||
"rules": {
|
"rules": {
|
||||||
"indent": [
|
"indent": [
|
||||||
"error",
|
"error",
|
||||||
4
|
2
|
||||||
],
|
],
|
||||||
"linebreak-style": [
|
"linebreak-style": [
|
||||||
"error",
|
"error",
|
||||||
|
15753
package-lock.json
generated
15753
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -10,10 +10,12 @@
|
|||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"body-parser": "^1.19.0",
|
"body-parser": "^1.19.0",
|
||||||
|
"dcc-utils": "^0.2.0",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"typescript": "^4.4.3"
|
"typescript": "^4.4.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@types/express": "^4.17.13",
|
||||||
"@types/node": "^16.9.6",
|
"@types/node": "^16.9.6",
|
||||||
"@typescript-eslint/eslint-plugin": "^4.31.2",
|
"@typescript-eslint/eslint-plugin": "^4.31.2",
|
||||||
"@typescript-eslint/parser": "^4.31.2",
|
"@typescript-eslint/parser": "^4.31.2",
|
||||||
|
@ -13,7 +13,7 @@ export class CertificateDownloader{
|
|||||||
const savedData = JSON.parse(localStorage.getItem(this.keyStorage) || '{}');
|
const savedData = JSON.parse(localStorage.getItem(this.keyStorage) || '{}');
|
||||||
if(savedData.lastupdateDate == null || Date.now() - savedData?.lastupdateDate > this.timeSpan){
|
if(savedData.lastupdateDate == null || Date.now() - savedData?.lastupdateDate > this.timeSpan){
|
||||||
this.getAllCertificate()
|
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);
|
.catch(console.error);
|
||||||
}
|
}
|
||||||
console.log('cerficates collection is valid loading from local source');
|
console.log('cerficates collection is valid loading from local source');
|
||||||
@ -36,7 +36,7 @@ export class CertificateDownloader{
|
|||||||
this.cerficateCollection = await response.json();
|
this.cerficateCollection = await response.json();
|
||||||
console.log(response);
|
console.log(response);
|
||||||
const lastupdateDate = Date.now();
|
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);
|
// fs.writeFile('./cerificate_collection.json', JSON.stringify({'certificates':this.cerficateCollection, lastupdateDate}),'utf8',console.error);
|
||||||
}else{
|
}else{
|
||||||
throw new Error(response.statusText);
|
throw new Error(response.statusText);
|
||||||
|
@ -14,7 +14,7 @@ export class RuleDownloader {
|
|||||||
const savedData = JSON.parse(localStorage.getItem(this.keyStorage) || '{}');
|
const savedData = JSON.parse(localStorage.getItem(this.keyStorage) || '{}');
|
||||||
if(savedData.lastupdateDate == null || Date.now() - savedData?.lastupdateDate > this.timeSpan){
|
if(savedData.lastupdateDate == null || Date.now() - savedData?.lastupdateDate > this.timeSpan){
|
||||||
this.getSettings()
|
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);
|
.catch(console.error);
|
||||||
}
|
}
|
||||||
console.log('cerficates collection is valid loading from local source');
|
console.log('cerficates collection is valid loading from local source');
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
import { CertificateDownloader } from './CertificateDownloader';
|
import { CertificateDownloader } from './CertificateDownloader';
|
||||||
import { RuleDownloader } from './RuleDownloader';
|
import { RuleDownloader } from './RuleDownloader';
|
||||||
import {DCC} from 'dcc-utils';
|
import {DCC} from 'dcc-utils';
|
||||||
import fs from 'fs';
|
|
||||||
|
|
||||||
export default class Verifier {
|
export default class Verifier {
|
||||||
static certDownloader: CertificateDownloader;
|
static certDownloader: CertificateDownloader;
|
||||||
static ruleDownloader: RuleDownloader;
|
static ruleDownloader: RuleDownloader;
|
||||||
static certificateList: any;
|
static certificateList: unknown;
|
||||||
|
|
||||||
static async setup():Promise<void> {
|
static async setup():Promise<void> {
|
||||||
Verifier.certDownloader = CertificateDownloader.getCertificateDownloader();
|
Verifier.certDownloader = CertificateDownloader.getCertificateDownloader();
|
||||||
Verifier.ruleDownloader = RuleDownloader.getRuleDownloader();
|
Verifier.ruleDownloader = RuleDownloader.getRuleDownloader();
|
||||||
Verifier.certificateList = await Verifier.certDownloader.getCertificates()
|
Verifier.certificateList = await Verifier.certDownloader.getCertificates();
|
||||||
}
|
}
|
||||||
|
|
||||||
static async checkCertificate(certificate:string): Promise<unknown>{
|
static async checkCertificate(certificate:string): Promise<unknown>{
|
||||||
|
Loading…
Reference in New Issue
Block a user