@spacelr/sdk 0.5.1 → 0.5.2

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.d.mts CHANGED
@@ -1285,9 +1285,15 @@ declare class DatabaseModule {
1285
1285
  collection<T = Record<string, unknown>>(name: string): CollectionRef<T>;
1286
1286
  }
1287
1287
 
1288
+ /**
1289
+ * Push subscription platform. `web` = VAPID WebPush; `android`/`ios` = native
1290
+ * device tokens; `web-fcm` = a web Firebase Cloud Messaging registration token.
1291
+ * Defined locally so `@spacelr/sdk` stays a standalone, dependency-free package.
1292
+ */
1293
+ type PushPlatform = 'web' | 'android' | 'ios' | 'web-fcm';
1288
1294
  interface PushSubscriptionInfo {
1289
1295
  id: string;
1290
- platform: 'web' | 'android' | 'ios';
1296
+ platform: PushPlatform;
1291
1297
  endpoint?: string;
1292
1298
  deviceToken?: string;
1293
1299
  deviceId?: string;
@@ -1318,9 +1324,9 @@ declare class NotificationsModule {
1318
1324
  private detectDeviceName;
1319
1325
  /** Get the VAPID public key for Web Push setup */
1320
1326
  getVapidPublicKey(): Promise<VapidKeyResponse>;
1321
- /** Register a push subscription (web, android, or ios) */
1327
+ /** Register a push subscription (web, android, ios, or web-fcm) */
1322
1328
  subscribe(subscription: {
1323
- platform: 'web' | 'android' | 'ios';
1329
+ platform: PushPlatform;
1324
1330
  endpoint?: string;
1325
1331
  keys?: {
1326
1332
  p256dh: string;
@@ -1329,7 +1335,7 @@ declare class NotificationsModule {
1329
1335
  deviceToken?: string;
1330
1336
  }, deviceName?: string): Promise<PushSubscriptionInfo>;
1331
1337
  /** Unregister a push subscription */
1332
- unsubscribe(platform: 'web' | 'android' | 'ios', identifier: string): Promise<{
1338
+ unsubscribe(platform: PushPlatform, identifier: string): Promise<{
1333
1339
  deleted: boolean;
1334
1340
  }>;
1335
1341
  /** Get all subscriptions for the current user */
@@ -1344,6 +1350,12 @@ declare class NotificationsModule {
1344
1350
  * Helper: Register a mobile device push token (FCM or APNs).
1345
1351
  */
1346
1352
  registerDevicePush(deviceToken: string, platform: 'android' | 'ios', deviceName?: string): Promise<PushSubscriptionInfo>;
1353
+ /**
1354
+ * Registers a web Firebase Cloud Messaging registration token (obtained via
1355
+ * the Firebase JS SDK `getToken()`), so `notifications.send` delivers to this
1356
+ * browser through the project's FCM provider instead of VAPID WebPush.
1357
+ */
1358
+ registerWebFcm(fcmToken: string, deviceName?: string): Promise<PushSubscriptionInfo>;
1347
1359
  private urlBase64ToUint8Array;
1348
1360
  }
1349
1361
 
package/dist/index.d.ts CHANGED
@@ -1285,9 +1285,15 @@ declare class DatabaseModule {
1285
1285
  collection<T = Record<string, unknown>>(name: string): CollectionRef<T>;
1286
1286
  }
1287
1287
 
1288
+ /**
1289
+ * Push subscription platform. `web` = VAPID WebPush; `android`/`ios` = native
1290
+ * device tokens; `web-fcm` = a web Firebase Cloud Messaging registration token.
1291
+ * Defined locally so `@spacelr/sdk` stays a standalone, dependency-free package.
1292
+ */
1293
+ type PushPlatform = 'web' | 'android' | 'ios' | 'web-fcm';
1288
1294
  interface PushSubscriptionInfo {
1289
1295
  id: string;
1290
- platform: 'web' | 'android' | 'ios';
1296
+ platform: PushPlatform;
1291
1297
  endpoint?: string;
1292
1298
  deviceToken?: string;
1293
1299
  deviceId?: string;
@@ -1318,9 +1324,9 @@ declare class NotificationsModule {
1318
1324
  private detectDeviceName;
1319
1325
  /** Get the VAPID public key for Web Push setup */
1320
1326
  getVapidPublicKey(): Promise<VapidKeyResponse>;
1321
- /** Register a push subscription (web, android, or ios) */
1327
+ /** Register a push subscription (web, android, ios, or web-fcm) */
1322
1328
  subscribe(subscription: {
1323
- platform: 'web' | 'android' | 'ios';
1329
+ platform: PushPlatform;
1324
1330
  endpoint?: string;
1325
1331
  keys?: {
1326
1332
  p256dh: string;
@@ -1329,7 +1335,7 @@ declare class NotificationsModule {
1329
1335
  deviceToken?: string;
1330
1336
  }, deviceName?: string): Promise<PushSubscriptionInfo>;
1331
1337
  /** Unregister a push subscription */
1332
- unsubscribe(platform: 'web' | 'android' | 'ios', identifier: string): Promise<{
1338
+ unsubscribe(platform: PushPlatform, identifier: string): Promise<{
1333
1339
  deleted: boolean;
1334
1340
  }>;
1335
1341
  /** Get all subscriptions for the current user */
@@ -1344,6 +1350,12 @@ declare class NotificationsModule {
1344
1350
  * Helper: Register a mobile device push token (FCM or APNs).
1345
1351
  */
1346
1352
  registerDevicePush(deviceToken: string, platform: 'android' | 'ios', deviceName?: string): Promise<PushSubscriptionInfo>;
1353
+ /**
1354
+ * Registers a web Firebase Cloud Messaging registration token (obtained via
1355
+ * the Firebase JS SDK `getToken()`), so `notifications.send` delivers to this
1356
+ * browser through the project's FCM provider instead of VAPID WebPush.
1357
+ */
1358
+ registerWebFcm(fcmToken: string, deviceName?: string): Promise<PushSubscriptionInfo>;
1347
1359
  private urlBase64ToUint8Array;
1348
1360
  }
1349
1361
 
package/dist/index.js CHANGED
@@ -2747,7 +2747,7 @@ var NotificationsModule = class {
2747
2747
  authenticated: true
2748
2748
  });
2749
2749
  }
2750
- /** Register a push subscription (web, android, or ios) */
2750
+ /** Register a push subscription (web, android, ios, or web-fcm) */
2751
2751
  async subscribe(subscription, deviceName) {
2752
2752
  return this.http.request({
2753
2753
  method: "POST",
@@ -2833,6 +2833,20 @@ var NotificationsModule = class {
2833
2833
  deviceName
2834
2834
  );
2835
2835
  }
2836
+ /**
2837
+ * Registers a web Firebase Cloud Messaging registration token (obtained via
2838
+ * the Firebase JS SDK `getToken()`), so `notifications.send` delivers to this
2839
+ * browser through the project's FCM provider instead of VAPID WebPush.
2840
+ */
2841
+ async registerWebFcm(fcmToken, deviceName) {
2842
+ return this.subscribe(
2843
+ {
2844
+ platform: "web-fcm",
2845
+ deviceToken: fcmToken
2846
+ },
2847
+ deviceName
2848
+ );
2849
+ }
2836
2850
  urlBase64ToUint8Array(base64String) {
2837
2851
  const padding = "=".repeat((4 - base64String.length % 4) % 4);
2838
2852
  const base64 = (base64String + padding).replace(/-/g, "+").replace(/_/g, "/");