1"use strict"; 2Object.defineProperty(exports, "__esModule", { value: true }); 3exports.verifyTLogTimestamp = exports.verifyTSATimestamp = void 0; 4const error_1 = require("../error"); 5const checkpoint_1 = require("./checkpoint"); 6const merkle_1 = require("./merkle"); 7const set_1 = require("./set"); 8const tsa_1 = require("./tsa"); 9function verifyTSATimestamp(timestamp, data, timestampAuthorities) { 10 (0, tsa_1.verifyRFC3161Timestamp)(timestamp, data, timestampAuthorities); 11 return { 12 type: 'timestamp-authority', 13 logID: timestamp.signerSerialNumber, 14 timestamp: timestamp.signingTime, 15 }; 16} 17exports.verifyTSATimestamp = verifyTSATimestamp; 18function verifyTLogTimestamp(entry, tlogAuthorities) { 19 let inclusionVerified = false; 20 if (isTLogEntryWithInclusionPromise(entry)) { 21 (0, set_1.verifyTLogSET)(entry, tlogAuthorities); 22 inclusionVerified = true; 23 } 24 if (isTLogEntryWithInclusionProof(entry)) { 25 (0, merkle_1.verifyMerkleInclusion)(entry); 26 (0, checkpoint_1.verifyCheckpoint)(entry, tlogAuthorities); 27 inclusionVerified = true; 28 } 29 if (!inclusionVerified) { 30 throw new error_1.VerificationError({ 31 code: 'TLOG_MISSING_INCLUSION_ERROR', 32 message: 'inclusion could not be verified', 33 }); 34 } 35 return { 36 type: 'transparency-log', 37 logID: entry.logId.keyId, 38 timestamp: new Date(Number(entry.integratedTime) * 1000), 39 }; 40} 41exports.verifyTLogTimestamp = verifyTLogTimestamp; 42function isTLogEntryWithInclusionPromise(entry) { 43 return entry.inclusionPromise !== undefined; 44} 45function isTLogEntryWithInclusionProof(entry) { 46 return entry.inclusionProof !== undefined; 47} 48