pub fn vapid_authorization(
endpoint: &str,
subject: &str,
keys: &VapidKeys,
now: i64,
) -> Result<String>Expand description
The Authorization header of a push to endpoint (VAPID, RFC 8292):
vapid t=<JWT signed with ES256>, k=<public key>, valid 12 hours.
§Errors
Error::Internal when the private key is not 32 bytes of URL-safe
base64, or endpoint is not an https:// (or, for local fakes, http://) URL.
§Examples
let keys = ocre::push::VapidKeys::generate();
let header = ocre::push::vapid_authorization("https://push.example/send/1", "mailto:ops@example.com", &keys, 1_790_000_000).unwrap();
assert!(header.starts_with("vapid t=eyJ"));
assert!(header.ends_with(&format!(", k={}", keys.public_key)));