src/message.js
async function createVerificationObject(signature, literalDataList, keys, date=new Date()) {
  let primaryKey = null;
  let signingKey = null;
  await Promise.all(keys.map(async function(key) {
    // Look for the unique key that matches issuerKeyId of signature
    const result = await key.getSigningKey(signature.issuerKeyId, null);
    if (result) {
      primaryKey = key;
      signingKey = result;
    }
  }));

  const signaturePacket = signature.correspondingSig || signature;
  const verifiedSig = {
    keyid: signature.issuerKeyId,
    verified: (async () => {
      if (!signingKey) {
        return null;
      }
      const verified = await signature.verify(signingKey.keyPacket, signature.signatureType, literalDataList[0]);
      const sig = await signaturePacket;
      if (sig.isExpired(date) || !(
        sig.created >= signingKey.getCreationTime() &&
        sig.created < await (signingKey === primaryKey ?
          signingKey.getExpirationTime() :
          signingKey.getExpirationTime(primaryKey, date)
        )
      )) {
        return null;
      }
      return verified;
    })(),
    signature: (async () => {
      const sig = await signaturePacket;
      const packetlist = new packet.List();
      packetlist.push(sig);
      return new Signature(packetlist);
    })()
  };

  // Mark potential promise rejections as "handled". This is needed because in
  // some cases, we reject them before the user has a reasonable chance to
  // handle them (e.g. `await readToEnd(result.data); await result.verified` and
  // the data stream errors).
  verifiedSig.signature.catch(() => {});
  verifiedSig.verified.catch(() => {});

  return verifiedSig;
}
async function createVerificationObject(signature, literalDataList, keys, date=new Date()) {
  let primaryKey = null;
  let signingKey = null;
  await Promise.all(keys.map(async function(key) {
    // Look for the unique key that matches issuerKeyId of signature
    const result = await key.getSigningKey(signature.issuerKeyId, null);
    if (result) {
      primaryKey = key;
      signingKey = result;
    }
  }));

  const signaturePacket = signature.correspondingSig || signature;
  const verifiedSig = {
    keyid: signature.issuerKeyId,
    verified: (async () => {
      if (!signingKey) {
        return null;
      }
      const verified = await signature.verify(signingKey.keyPacket, signature.signatureType, literalDataList[0]);
      const sig = await signaturePacket;
      if (sig.isExpired(date) || !(
        sig.created >= signingKey.getCreationTime() &&
        sig.created < await (signingKey === primaryKey ?
          signingKey.getExpirationTime() :
          signingKey.getExpirationTime(primaryKey, date)
        )
      )) {
        return null;
      }
      return verified;
    })(),
    signature: (async () => {
      const sig = await signaturePacket;
      const packetlist = new packet.List();
      packetlist.push(sig);
      return new Signature(packetlist);
    })()
  };

  // Mark potential promise rejections as "handled". This is needed because in
  // some cases, we reject them before the user has a reasonable chance to
  // handle them (e.g. `await readToEnd(result.data); await result.verified` and
  // the data stream errors).
  verifiedSig.signature.catch(() => {});
  verifiedSig.verified.catch(() => {});

  return verifiedSig;
}
async function createVerificationObject ( signature , literalDataList , keys , date = new Date ( ) ) { let primaryKey = null ; let signingKey = null ; await Promise . all ( keys . map ( async function ( key ) { // Look for the unique key that matches issuerKeyId of signature const result = await key . getSigningKey ( signature . issuerKeyId , null ) ; if ( result ) { primaryKey = key ; signingKey = result ; } } ) ) ; const signaturePacket = signature . correspondingSig || signature ; const verifiedSig = { keyid : signature . issuerKeyId , verified : ( async ( ) => { if ( ! signingKey ) { return null ; } const verified = await signature . verify ( signingKey . keyPacket , signature . signatureType , literalDataList [ 0 ] ) ; const sig = await signaturePacket ; if ( sig . isExpired ( date ) || ! ( sig . created >= signingKey . getCreationTime ( ) && sig . created < await ( signingKey === primaryKey ? signingKey . getExpirationTime ( ) : signingKey . getExpirationTime ( primaryKey , date ) ) ) ) { return null ; } return verified ; } ) ( ) , signature : ( async ( ) => { const sig = await signaturePacket ; const packetlist = new packet . List ( ) ; packetlist . push ( sig ) ; return new Signature ( packetlist ) ; } ) ( ) } ; // Mark potential promise rejections as "handled". This is needed because in // some cases, we reject them before the user has a reasonable chance to // handle them (e.g. `await readToEnd(result.data); await result.verified` and // the data stream errors). verifiedSig . signature . catch ( ( ) => { } ) ; verifiedSig . verified . catch ( ( ) => { } ) ; return verifiedSig ; }
Create object containing signer's keyid and validity of signature
@param {module:packet.Signature} signature signature packets
@param {Array<module:packet.Literal>} literalDataList array of literal data packets
@param {Array<module:key.Key>} keys array of keys to verify signatures
@param {Date} date Verify the signature against the given date,
i.e. check signature creation time < date < expiration time
@returns {Promise<Array<{keyid: module:type/keyid,
valid: Boolean}>>} list of signer's keyid and validity of signature
@async
Create object containing signer s keyid and validity of signature