I have added two helper methods for importing / exporting keys in PEM format. It is useful for interoperability between different libraries and services that store or use the keys in different formats. For example it is useful in order to use this library if you already have existing keys in PEM format. It is also useful if you want to store your keys in PEM format, which is a de facto standard for keys.
# example import (from PEM to base64)
vapid_key = Webpush::VapidKey.from_pem "YOUR PEM GOES HERE"
vapid_key.public_key
vapid_key.private_key
# example export (to PEM)
vapid_key = Webpush.generate_key
vapid_key.to_pem
I have added two helper methods for importing / exporting keys in PEM format. It is useful for interoperability between different libraries and services that store or use the keys in different formats. For example it is useful in order to use this library if you already have existing keys in PEM format. It is also useful if you want to store your keys in PEM format, which is a de facto standard for keys.