formacao
This commit is contained in:
+20
-10
@@ -46,17 +46,22 @@ class Verifier {
|
||||
}
|
||||
// Checks that all of the timestamps in the entity are valid and returns them
|
||||
verifyTimestamps(entity) {
|
||||
let timestampCount = 0;
|
||||
const timestamps = entity.timestamps.map((timestamp) => {
|
||||
const timestamps = [];
|
||||
for (const timestamp of entity.timestamps) {
|
||||
switch (timestamp.$case) {
|
||||
case 'timestamp-authority':
|
||||
timestampCount++;
|
||||
return (0, timestamp_1.getTSATimestamp)(timestamp.timestamp, entity.signature.signature, this.trustMaterial.timestampAuthorities);
|
||||
case 'transparency-log':
|
||||
timestampCount++;
|
||||
return (0, timestamp_1.getTLogTimestamp)(timestamp.tlogEntry);
|
||||
timestamps.push((0, timestamp_1.getTSATimestamp)(timestamp.timestamp, entity.signature.signature, this.trustMaterial.timestampAuthorities));
|
||||
break;
|
||||
case 'transparency-log': {
|
||||
const result = (0, timestamp_1.getTLogTimestamp)(timestamp.tlogEntry);
|
||||
/* istanbul ignore else */
|
||||
if (result) {
|
||||
timestamps.push(result);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
// Check for duplicate timestamps
|
||||
if (containsDupes(timestamps)) {
|
||||
throw new error_1.VerificationError({
|
||||
@@ -64,10 +69,10 @@ class Verifier {
|
||||
message: 'duplicate timestamp',
|
||||
});
|
||||
}
|
||||
if (timestampCount < this.options.timestampThreshold) {
|
||||
if (timestamps.length < this.options.timestampThreshold) {
|
||||
throw new error_1.VerificationError({
|
||||
code: 'TIMESTAMP_ERROR',
|
||||
message: `expected ${this.options.timestampThreshold} timestamps, got ${timestampCount}`,
|
||||
message: `expected ${this.options.timestampThreshold} timestamps, got ${timestamps.length}`,
|
||||
});
|
||||
}
|
||||
return timestamps.map((t) => t.timestamp);
|
||||
@@ -133,6 +138,11 @@ class Verifier {
|
||||
if (policy.extensions) {
|
||||
(0, policy_1.verifyExtensions)(policy.extensions, identity.extensions);
|
||||
}
|
||||
// Check that the OIDs of the signer match the policy
|
||||
/* istanbul ignore if */
|
||||
if (policy.oids) {
|
||||
(0, policy_1.verifyOIDs)(policy.oids, identity.oids);
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.Verifier = Verifier;
|
||||
|
||||
Reference in New Issue
Block a user