Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | 3x 3x 3x 29x 3x 26x 26x | import type { Blockcerts, UnsignedBlockcerts } from '../../models/Blockcerts';
import type { BlockcertsV3 } from '../../models/BlockcertsV3';
import { deepCopy } from '../../helpers/object';
function deleteMerkleProof2019From (certificate: BlockcertsV3): Blockcerts {
const copy = deepCopy<BlockcertsV3>(certificate);
if (!Array.isArray(certificate.proof)) {
delete copy.proof;
return copy;
}
// TODO: this assumes that the merkle proof is always ChainedProof2021, which it shouldn't
const initialSignature = certificate.proof.find(p => p.type !== 'ChainedProof2021');
copy.proof = initialSignature;
return copy;
}
export default function retrieveUnsignedBlockcerts (certificateJson: Blockcerts): UnsignedBlockcerts {
const certificateCopy: Blockcerts = deepCopy<Blockcerts>(certificateJson);
if ('proof' in certificateCopy) {
return deleteMerkleProof2019From(certificateCopy);
} else if ('signature' in certificateCopy) {
delete certificateCopy.signature;
}
return certificateCopy;
}
|