Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make PacketList a valid subtype of Array and update Packet.tag type accessor #1289

Merged
merged 8 commits into from Apr 29, 2021

Conversation

larabr
Copy link
Collaborator

@larabr larabr commented Apr 20, 2021

Changes:

  • Implementation:
    • Remove PacketList.prototype.concat and push (we solely rely on Array.push instead).
    • Fix filterByTag check never throws due to List() truthyness #907 by correctly handling result of filterByTag.
    • Implement write() method for Trust and Marker packets, to make them compatible with the BasePacket interface
  • Types:
    • Simplified and updated PacketList type definitions
    • Fix type accessor for Packet.tag, which is static since Use consistent name casing #1268
    • Prevent passing SubkeyPackets where KeyPackets are expected, and vice versa

src/packet/packetlist.js Outdated Show resolved Hide resolved
@larabr larabr changed the title Make PacketList a valid subtype of Array Make PacketList a valid subtype of Array and update Packet.tag type accessor Apr 20, 2021
@larabr larabr marked this pull request as draft April 21, 2021 07:59
@larabr larabr marked this pull request as ready for review April 21, 2021 17:52
openpgp.d.ts Show resolved Hide resolved
src/key/key.js Outdated Show resolved Hide resolved
@@ -81,7 +81,7 @@ async function makeKeyValid() {
pusersig.readSubPackets(fake.writeHashedSubPackets(), false);
// reconstruct the modified key
const newlist = new PacketList();
newlist.concat([pubkey, puser, pusersig]);
newlist.push(...[pubkey, puser, pusersig]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is then very nitpicky but you can just do:

Suggested change
newlist.push(...[pubkey, puser, pusersig]);
newlist.push(pubkey, puser, pusersig);

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this is fixed in the next PR 🙃

@@ -56,7 +56,7 @@ async function testSubkeyTrust() {
fakeBindingSignature.keyFlags = [enums.keyFlags.signData];
await fakeBindingSignature.sign(attackerPrivKey.keyPacket, dataToSign);
const newList = new PacketList();
newList.concat([
newList.push(...[
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And similarly here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

filterByTag check never throws due to List() truthyness
2 participants