When the list of callsigns a key claims must change, you need to add a self-signed user ID to it
before that user ID can be certified, since no key server will accept a user ID that is not self-signed.
With OpenPGPjs the process of adding an extra user ID to a key is far from straightforward,
which is why this function is there.
To actually make this happen, we need to build a new key object using existing key material from
a given key, but with a completely new set of two userID objects on it. Bizarrely, this is the most
expedient way to create a new self-signed userID with OpenPGPjs.
Then we take the second user ID created this way (the first one is marked primary and
would result in a key with two primary IDs) on the newly produced key object and graft it back
into the structure of the original key. Once the key is serialized again, everything will be correct.
When the list of callsigns a key claims must change, you need to add a self-signed user ID to it before that user ID can be certified, since no key server will accept a user ID that is not self-signed. With OpenPGPjs the process of adding an extra user ID to a key is far from straightforward, which is why this function is there.
To actually make this happen, we need to build a new key object using existing key material from a given key, but with a completely new set of two userID objects on it. Bizarrely, this is the most expedient way to create a new self-signed userID with OpenPGPjs.
Then we take the second user ID created this way (the first one is marked primary and would result in a key with two primary IDs) on the newly produced key object and graft it back into the structure of the original key. Once the key is serialized again, everything will be correct.
Beware, this modifies the key in place.