@spacelr/sdk 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -2704,7 +2704,7 @@ var NotificationsModule = class {
2704
2704
  authenticated: true
2705
2705
  });
2706
2706
  }
2707
- /** Register a push subscription (web, android, or ios) */
2707
+ /** Register a push subscription (web, android, ios, or web-fcm) */
2708
2708
  async subscribe(subscription, deviceName) {
2709
2709
  return this.http.request({
2710
2710
  method: "POST",
@@ -2732,6 +2732,19 @@ var NotificationsModule = class {
2732
2732
  authenticated: true
2733
2733
  });
2734
2734
  }
2735
+ /**
2736
+ * Unregister a push subscription by its `id` (as returned by
2737
+ * {@link getSubscriptions}). Robust regardless of platform — use this to
2738
+ * remove a listed device (e.g. web-fcm rows whose raw token is not returned
2739
+ * by the listing and so cannot be passed to {@link unsubscribe}).
2740
+ */
2741
+ async unsubscribeById(subscriptionId) {
2742
+ return this.http.request({
2743
+ method: "DELETE",
2744
+ path: `/notifications/subscriptions/${encodeURIComponent(subscriptionId)}`,
2745
+ authenticated: true
2746
+ });
2747
+ }
2735
2748
  /** Get all subscriptions for the current user */
2736
2749
  async getSubscriptions() {
2737
2750
  return this.http.request({
@@ -2790,6 +2803,25 @@ var NotificationsModule = class {
2790
2803
  deviceName
2791
2804
  );
2792
2805
  }
2806
+ /**
2807
+ * Registers a web Firebase Cloud Messaging registration token (obtained via
2808
+ * the Firebase JS SDK `getToken()`), so `notifications.send` delivers to this
2809
+ * browser through the project's FCM provider instead of VAPID WebPush.
2810
+ */
2811
+ async registerWebFcm(fcmToken, deviceName) {
2812
+ if (/^https?:\/\//i.test(fcmToken)) {
2813
+ console.warn(
2814
+ "[spacelr] registerWebFcm received what looks like a Web Push endpoint URL, not a Firebase FCM registration token. A web-fcm token must come from getToken(getMessaging(app), { vapidKey, serviceWorkerRegistration }). For plain (non-FCM) Web Push, use registerBrowserPush instead."
2815
+ );
2816
+ }
2817
+ return this.subscribe(
2818
+ {
2819
+ platform: "web-fcm",
2820
+ deviceToken: fcmToken
2821
+ },
2822
+ deviceName
2823
+ );
2824
+ }
2793
2825
  urlBase64ToUint8Array(base64String) {
2794
2826
  const padding = "=".repeat((4 - base64String.length % 4) % 4);
2795
2827
  const base64 = (base64String + padding).replace(/-/g, "+").replace(/_/g, "/");