Node-forge store rsa.keyPair

Hello,

I am developing a Ionic app which use node-forge and in the specific I need to generate rsa key pair (forge.pki.rsa.KeyPair) and make sign and verify.

I obtained the key pair and I can sign and verify but I have a problem when I have to store in local storage my KeyPair.

I could convert the PrivateKey into json before the store and then parse the json when I retrieve but there is no way to obtain again a forge.pki.rsa.PrivateKey to use the sign function.

I could convert the PrivateKey into PEM but then when I try to get the privateKey back from the PEM I could just obtain a forge.pki.PrivateKey which doesn’t provide the sign function.

What do you suggest to me?