diff options
| author | Owen Jacobson <owen@grimoire.ca> | 2025-07-24 22:32:27 -0400 |
|---|---|---|
| committer | Owen Jacobson <owen@grimoire.ca> | 2025-07-24 22:32:27 -0400 |
| commit | b63380b251d04dd92f06aa5bbc22a72ca3e4bf8e (patch) | |
| tree | 3956ec457131ce049fd91f2f53309bc0620fffe2 /src/push/vapid.rs | |
| parent | 2e42057694851b82574e0a406ded429fb95a07fa (diff) | |
wip: 83B78D40-D7CB-4419-9FE7-E7D858909443
Diffstat (limited to 'src/push/vapid.rs')
| -rw-r--r-- | src/push/vapid.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/push/vapid.rs b/src/push/vapid.rs new file mode 100644 index 0000000..b13a00c --- /dev/null +++ b/src/push/vapid.rs @@ -0,0 +1,28 @@ +use std::fmt; + +use web_push::{PartialVapidSignatureBuilder, VapidSignatureBuilder, WebPushError}; + +#[derive(Clone)] +pub struct PrivateKey(String); + +impl PrivateKey { + pub fn as_signature_builder(&self) -> Result<PartialVapidSignatureBuilder, WebPushError> { + let Self(key) = self; + VapidSignatureBuilder::from_base64_no_sub(key) + } +} + +impl fmt::Debug for PrivateKey { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_tuple("PrivateKey").field(&"********").finish() + } +} + +impl<S> From<S> for PrivateKey +where + S: Into<String>, +{ + fn from(value: S) -> Self { + Self(value.into()) + } +} |
