diff --git a/lib/types/tunnelbroker/notif-types.js b/lib/types/tunnelbroker/notif-types.js
--- a/lib/types/tunnelbroker/notif-types.js
+++ b/lib/types/tunnelbroker/notif-types.js
@@ -23,7 +23,15 @@
+payload: string,
};
+export type TunnelbrokerWNSNotif = {
+ +type: 'WNSNotif',
+ +clientMessageID: string,
+ +deviceID: string,
+ +payload: string,
+};
+
export type TunnelbrokerNotif =
| TunnelbrokerAPNsNotif
| TunnelbrokerFCMNotif
- | TunnelbrokerWebPushNotif;
+ | TunnelbrokerWebPushNotif
+ | TunnelbrokerWNSNotif;
diff --git a/services/tunnelbroker/src/notifs/mod.rs b/services/tunnelbroker/src/notifs/mod.rs
--- a/services/tunnelbroker/src/notifs/mod.rs
+++ b/services/tunnelbroker/src/notifs/mod.rs
@@ -14,7 +14,7 @@
APNs,
FCM,
WebPush,
- WNs,
+ WNS,
}
impl NotifClientType {
@@ -25,7 +25,7 @@
}
NotifClientType::FCM => platform == Platform::Android,
NotifClientType::WebPush => platform == Platform::Web,
- NotifClientType::WNs => platform == Platform::Windows,
+ NotifClientType::WNS => platform == Platform::Windows,
}
}
}
diff --git a/services/tunnelbroker/src/notifs/wns/error.rs b/services/tunnelbroker/src/notifs/wns/error.rs
--- a/services/tunnelbroker/src/notifs/wns/error.rs
+++ b/services/tunnelbroker/src/notifs/wns/error.rs
@@ -12,4 +12,18 @@
ReadLock,
#[display(fmt = "Failed to acquire write lock")]
WriteLock,
+ #[display(fmt = "WNS Notification Error: {}", _0)]
+ WNSNotification(WNSNotificationError),
+ #[display(fmt = "Missing WNS ID")]
+ MissingWNSID,
}
+
+#[derive(Debug, Display)]
+pub enum WNSNotificationError {
+ #[display(fmt = "HTTP Error: {}", _0)]
+ Http(reqwest::Error),
+ #[display(fmt = "Unknown Error: {}", _0)]
+ Unknown(String),
+}
+
+impl std::error::Error for WNSNotificationError {}
diff --git a/services/tunnelbroker/src/notifs/wns/mod.rs b/services/tunnelbroker/src/notifs/wns/mod.rs
--- a/services/tunnelbroker/src/notifs/wns/mod.rs
+++ b/services/tunnelbroker/src/notifs/wns/mod.rs
@@ -13,6 +13,12 @@
expires: SystemTime,
}
+#[derive(Debug, Clone)]
+pub struct WNSNotif {
+ pub device_token: String,
+ pub payload: String,
+}
+
#[derive(Clone)]
pub struct WNSClient {
http_client: reqwest::Client,
@@ -30,9 +36,48 @@
})
}
- pub async fn get_wns_token(
- &mut self,
- ) -> Result