@loyalytics/swan-react-native-sdk 2.0.1

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.
Files changed (204) hide show
  1. package/LICENSE +55 -0
  2. package/README.md +67 -0
  3. package/docs/IOS_NOTIFICATION_EXTENSION_SETUP.md +335 -0
  4. package/ios/README.md +64 -0
  5. package/ios/SwanNotificationServiceExtension/Info.plist +31 -0
  6. package/ios/SwanNotificationServiceExtension/NotificationService.swift +337 -0
  7. package/ios/SwanNotificationServiceExtension/SwanNotificationServiceExtension.entitlements +10 -0
  8. package/lib/commonjs/components/FooterView.js +125 -0
  9. package/lib/commonjs/components/FooterView.js.map +1 -0
  10. package/lib/commonjs/components/FullScreenView.js +172 -0
  11. package/lib/commonjs/components/FullScreenView.js.map +1 -0
  12. package/lib/commonjs/components/HeaderView.js +205 -0
  13. package/lib/commonjs/components/HeaderView.js.map +1 -0
  14. package/lib/commonjs/components/PopUpView.js +186 -0
  15. package/lib/commonjs/components/PopUpView.js.map +1 -0
  16. package/lib/commonjs/config/BatchConfig.js +53 -0
  17. package/lib/commonjs/config/BatchConfig.js.map +1 -0
  18. package/lib/commonjs/constants/ApiUrls.js +56 -0
  19. package/lib/commonjs/constants/ApiUrls.js.map +1 -0
  20. package/lib/commonjs/core/EventQueueManager.js +345 -0
  21. package/lib/commonjs/core/EventQueueManager.js.map +1 -0
  22. package/lib/commonjs/core/FlushManager.js +245 -0
  23. package/lib/commonjs/core/FlushManager.js.map +1 -0
  24. package/lib/commonjs/core/NetworkMonitor.js +97 -0
  25. package/lib/commonjs/core/NetworkMonitor.js.map +1 -0
  26. package/lib/commonjs/index.js +3506 -0
  27. package/lib/commonjs/index.js.map +1 -0
  28. package/lib/commonjs/providers/FirebasePushProvider.js +130 -0
  29. package/lib/commonjs/providers/FirebasePushProvider.js.map +1 -0
  30. package/lib/commonjs/providers/NullPushProvider.js +59 -0
  31. package/lib/commonjs/providers/NullPushProvider.js.map +1 -0
  32. package/lib/commonjs/providers/PushNotificationProvider.js +30 -0
  33. package/lib/commonjs/providers/PushNotificationProvider.js.map +1 -0
  34. package/lib/commonjs/services/DeviceRegistrationService.js +248 -0
  35. package/lib/commonjs/services/DeviceRegistrationService.js.map +1 -0
  36. package/lib/commonjs/services/PushTokenService.js +284 -0
  37. package/lib/commonjs/services/PushTokenService.js.map +1 -0
  38. package/lib/commonjs/state/AuthStateMachine.js +161 -0
  39. package/lib/commonjs/state/AuthStateMachine.js.map +1 -0
  40. package/lib/commonjs/state/DeviceStateMachine.js +104 -0
  41. package/lib/commonjs/state/DeviceStateMachine.js.map +1 -0
  42. package/lib/commonjs/state/PushStateMachine.js +129 -0
  43. package/lib/commonjs/state/PushStateMachine.js.map +1 -0
  44. package/lib/commonjs/types/EventQueue.js +50 -0
  45. package/lib/commonjs/types/EventQueue.js.map +1 -0
  46. package/lib/commonjs/types/SDK.js +2 -0
  47. package/lib/commonjs/types/SDK.js.map +1 -0
  48. package/lib/commonjs/utils/FirebaseNotificationManager.js +492 -0
  49. package/lib/commonjs/utils/FirebaseNotificationManager.js.map +1 -0
  50. package/lib/commonjs/utils/Logger.js +56 -0
  51. package/lib/commonjs/utils/Logger.js.map +1 -0
  52. package/lib/commonjs/utils/SharedCredentialsManager.js +146 -0
  53. package/lib/commonjs/utils/SharedCredentialsManager.js.map +1 -0
  54. package/lib/commonjs/version.js +12 -0
  55. package/lib/commonjs/version.js.map +1 -0
  56. package/lib/module/components/FooterView.js +121 -0
  57. package/lib/module/components/FooterView.js.map +1 -0
  58. package/lib/module/components/FullScreenView.js +167 -0
  59. package/lib/module/components/FullScreenView.js.map +1 -0
  60. package/lib/module/components/HeaderView.js +199 -0
  61. package/lib/module/components/HeaderView.js.map +1 -0
  62. package/lib/module/components/PopUpView.js +181 -0
  63. package/lib/module/components/PopUpView.js.map +1 -0
  64. package/lib/module/config/BatchConfig.js +49 -0
  65. package/lib/module/config/BatchConfig.js.map +1 -0
  66. package/lib/module/constants/ApiUrls.js +52 -0
  67. package/lib/module/constants/ApiUrls.js.map +1 -0
  68. package/lib/module/core/EventQueueManager.js +340 -0
  69. package/lib/module/core/EventQueueManager.js.map +1 -0
  70. package/lib/module/core/FlushManager.js +240 -0
  71. package/lib/module/core/FlushManager.js.map +1 -0
  72. package/lib/module/core/NetworkMonitor.js +92 -0
  73. package/lib/module/core/NetworkMonitor.js.map +1 -0
  74. package/lib/module/index.js +3494 -0
  75. package/lib/module/index.js.map +1 -0
  76. package/lib/module/providers/FirebasePushProvider.js +124 -0
  77. package/lib/module/providers/FirebasePushProvider.js.map +1 -0
  78. package/lib/module/providers/NullPushProvider.js +53 -0
  79. package/lib/module/providers/NullPushProvider.js.map +1 -0
  80. package/lib/module/providers/PushNotificationProvider.js +26 -0
  81. package/lib/module/providers/PushNotificationProvider.js.map +1 -0
  82. package/lib/module/services/DeviceRegistrationService.js +243 -0
  83. package/lib/module/services/DeviceRegistrationService.js.map +1 -0
  84. package/lib/module/services/PushTokenService.js +278 -0
  85. package/lib/module/services/PushTokenService.js.map +1 -0
  86. package/lib/module/state/AuthStateMachine.js +155 -0
  87. package/lib/module/state/AuthStateMachine.js.map +1 -0
  88. package/lib/module/state/DeviceStateMachine.js +98 -0
  89. package/lib/module/state/DeviceStateMachine.js.map +1 -0
  90. package/lib/module/state/PushStateMachine.js +123 -0
  91. package/lib/module/state/PushStateMachine.js.map +1 -0
  92. package/lib/module/types/EventQueue.js +46 -0
  93. package/lib/module/types/EventQueue.js.map +1 -0
  94. package/lib/module/types/SDK.js +2 -0
  95. package/lib/module/types/SDK.js.map +1 -0
  96. package/lib/module/utils/FirebaseNotificationManager.js +486 -0
  97. package/lib/module/utils/FirebaseNotificationManager.js.map +1 -0
  98. package/lib/module/utils/Logger.js +52 -0
  99. package/lib/module/utils/Logger.js.map +1 -0
  100. package/lib/module/utils/SharedCredentialsManager.js +140 -0
  101. package/lib/module/utils/SharedCredentialsManager.js.map +1 -0
  102. package/lib/module/version.js +8 -0
  103. package/lib/module/version.js.map +1 -0
  104. package/lib/typescript/commonjs/package.json +1 -0
  105. package/lib/typescript/commonjs/src/components/FooterView.d.ts +3 -0
  106. package/lib/typescript/commonjs/src/components/FooterView.d.ts.map +1 -0
  107. package/lib/typescript/commonjs/src/components/FullScreenView.d.ts +3 -0
  108. package/lib/typescript/commonjs/src/components/FullScreenView.d.ts.map +1 -0
  109. package/lib/typescript/commonjs/src/components/HeaderView.d.ts +3 -0
  110. package/lib/typescript/commonjs/src/components/HeaderView.d.ts.map +1 -0
  111. package/lib/typescript/commonjs/src/components/PopUpView.d.ts +3 -0
  112. package/lib/typescript/commonjs/src/components/PopUpView.d.ts.map +1 -0
  113. package/lib/typescript/commonjs/src/config/BatchConfig.d.ts +7 -0
  114. package/lib/typescript/commonjs/src/config/BatchConfig.d.ts.map +1 -0
  115. package/lib/typescript/commonjs/src/constants/ApiUrls.d.ts +56 -0
  116. package/lib/typescript/commonjs/src/constants/ApiUrls.d.ts.map +1 -0
  117. package/lib/typescript/commonjs/src/core/EventQueueManager.d.ts +63 -0
  118. package/lib/typescript/commonjs/src/core/EventQueueManager.d.ts.map +1 -0
  119. package/lib/typescript/commonjs/src/core/FlushManager.d.ts +63 -0
  120. package/lib/typescript/commonjs/src/core/FlushManager.d.ts.map +1 -0
  121. package/lib/typescript/commonjs/src/core/NetworkMonitor.d.ts +38 -0
  122. package/lib/typescript/commonjs/src/core/NetworkMonitor.d.ts.map +1 -0
  123. package/lib/typescript/commonjs/src/index.d.ts +663 -0
  124. package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
  125. package/lib/typescript/commonjs/src/providers/FirebasePushProvider.d.ts +28 -0
  126. package/lib/typescript/commonjs/src/providers/FirebasePushProvider.d.ts.map +1 -0
  127. package/lib/typescript/commonjs/src/providers/NullPushProvider.d.ts +25 -0
  128. package/lib/typescript/commonjs/src/providers/NullPushProvider.d.ts.map +1 -0
  129. package/lib/typescript/commonjs/src/providers/PushNotificationProvider.d.ts +105 -0
  130. package/lib/typescript/commonjs/src/providers/PushNotificationProvider.d.ts.map +1 -0
  131. package/lib/typescript/commonjs/src/services/DeviceRegistrationService.d.ts +60 -0
  132. package/lib/typescript/commonjs/src/services/DeviceRegistrationService.d.ts.map +1 -0
  133. package/lib/typescript/commonjs/src/services/PushTokenService.d.ts +82 -0
  134. package/lib/typescript/commonjs/src/services/PushTokenService.d.ts.map +1 -0
  135. package/lib/typescript/commonjs/src/state/AuthStateMachine.d.ts +61 -0
  136. package/lib/typescript/commonjs/src/state/AuthStateMachine.d.ts.map +1 -0
  137. package/lib/typescript/commonjs/src/state/DeviceStateMachine.d.ts +51 -0
  138. package/lib/typescript/commonjs/src/state/DeviceStateMachine.d.ts.map +1 -0
  139. package/lib/typescript/commonjs/src/state/PushStateMachine.d.ts +61 -0
  140. package/lib/typescript/commonjs/src/state/PushStateMachine.d.ts.map +1 -0
  141. package/lib/typescript/commonjs/src/types/EventQueue.d.ts +85 -0
  142. package/lib/typescript/commonjs/src/types/EventQueue.d.ts.map +1 -0
  143. package/lib/typescript/commonjs/src/types/SDK.d.ts +54 -0
  144. package/lib/typescript/commonjs/src/types/SDK.d.ts.map +1 -0
  145. package/lib/typescript/commonjs/src/utils/FirebaseNotificationManager.d.ts +169 -0
  146. package/lib/typescript/commonjs/src/utils/FirebaseNotificationManager.d.ts.map +1 -0
  147. package/lib/typescript/commonjs/src/utils/Logger.d.ts +32 -0
  148. package/lib/typescript/commonjs/src/utils/Logger.d.ts.map +1 -0
  149. package/lib/typescript/commonjs/src/utils/SharedCredentialsManager.d.ts +54 -0
  150. package/lib/typescript/commonjs/src/utils/SharedCredentialsManager.d.ts.map +1 -0
  151. package/lib/typescript/commonjs/src/version.d.ts +2 -0
  152. package/lib/typescript/commonjs/src/version.d.ts.map +1 -0
  153. package/lib/typescript/module/package.json +1 -0
  154. package/lib/typescript/module/src/components/FooterView.d.ts +3 -0
  155. package/lib/typescript/module/src/components/FooterView.d.ts.map +1 -0
  156. package/lib/typescript/module/src/components/FullScreenView.d.ts +3 -0
  157. package/lib/typescript/module/src/components/FullScreenView.d.ts.map +1 -0
  158. package/lib/typescript/module/src/components/HeaderView.d.ts +3 -0
  159. package/lib/typescript/module/src/components/HeaderView.d.ts.map +1 -0
  160. package/lib/typescript/module/src/components/PopUpView.d.ts +3 -0
  161. package/lib/typescript/module/src/components/PopUpView.d.ts.map +1 -0
  162. package/lib/typescript/module/src/config/BatchConfig.d.ts +7 -0
  163. package/lib/typescript/module/src/config/BatchConfig.d.ts.map +1 -0
  164. package/lib/typescript/module/src/constants/ApiUrls.d.ts +56 -0
  165. package/lib/typescript/module/src/constants/ApiUrls.d.ts.map +1 -0
  166. package/lib/typescript/module/src/core/EventQueueManager.d.ts +63 -0
  167. package/lib/typescript/module/src/core/EventQueueManager.d.ts.map +1 -0
  168. package/lib/typescript/module/src/core/FlushManager.d.ts +63 -0
  169. package/lib/typescript/module/src/core/FlushManager.d.ts.map +1 -0
  170. package/lib/typescript/module/src/core/NetworkMonitor.d.ts +38 -0
  171. package/lib/typescript/module/src/core/NetworkMonitor.d.ts.map +1 -0
  172. package/lib/typescript/module/src/index.d.ts +663 -0
  173. package/lib/typescript/module/src/index.d.ts.map +1 -0
  174. package/lib/typescript/module/src/providers/FirebasePushProvider.d.ts +28 -0
  175. package/lib/typescript/module/src/providers/FirebasePushProvider.d.ts.map +1 -0
  176. package/lib/typescript/module/src/providers/NullPushProvider.d.ts +25 -0
  177. package/lib/typescript/module/src/providers/NullPushProvider.d.ts.map +1 -0
  178. package/lib/typescript/module/src/providers/PushNotificationProvider.d.ts +105 -0
  179. package/lib/typescript/module/src/providers/PushNotificationProvider.d.ts.map +1 -0
  180. package/lib/typescript/module/src/services/DeviceRegistrationService.d.ts +60 -0
  181. package/lib/typescript/module/src/services/DeviceRegistrationService.d.ts.map +1 -0
  182. package/lib/typescript/module/src/services/PushTokenService.d.ts +82 -0
  183. package/lib/typescript/module/src/services/PushTokenService.d.ts.map +1 -0
  184. package/lib/typescript/module/src/state/AuthStateMachine.d.ts +61 -0
  185. package/lib/typescript/module/src/state/AuthStateMachine.d.ts.map +1 -0
  186. package/lib/typescript/module/src/state/DeviceStateMachine.d.ts +51 -0
  187. package/lib/typescript/module/src/state/DeviceStateMachine.d.ts.map +1 -0
  188. package/lib/typescript/module/src/state/PushStateMachine.d.ts +61 -0
  189. package/lib/typescript/module/src/state/PushStateMachine.d.ts.map +1 -0
  190. package/lib/typescript/module/src/types/EventQueue.d.ts +85 -0
  191. package/lib/typescript/module/src/types/EventQueue.d.ts.map +1 -0
  192. package/lib/typescript/module/src/types/SDK.d.ts +54 -0
  193. package/lib/typescript/module/src/types/SDK.d.ts.map +1 -0
  194. package/lib/typescript/module/src/utils/FirebaseNotificationManager.d.ts +169 -0
  195. package/lib/typescript/module/src/utils/FirebaseNotificationManager.d.ts.map +1 -0
  196. package/lib/typescript/module/src/utils/Logger.d.ts +32 -0
  197. package/lib/typescript/module/src/utils/Logger.d.ts.map +1 -0
  198. package/lib/typescript/module/src/utils/SharedCredentialsManager.d.ts +54 -0
  199. package/lib/typescript/module/src/utils/SharedCredentialsManager.d.ts.map +1 -0
  200. package/lib/typescript/module/src/version.d.ts +2 -0
  201. package/lib/typescript/module/src/version.d.ts.map +1 -0
  202. package/package.json +230 -0
  203. package/scripts/generate-version.js +25 -0
  204. package/scripts/setup-ios-extension.js +275 -0
@@ -0,0 +1,28 @@
1
+ import { type PushNotificationProvider, type PushEventCallback } from './PushNotificationProvider';
2
+ /**
3
+ * FirebasePushProvider
4
+ *
5
+ * Adapter that wraps FirebaseNotificationManager to implement
6
+ * the PushNotificationProvider interface.
7
+ *
8
+ * This provides a clean abstraction layer between the SDK and Firebase,
9
+ * making it easier to swap providers in the future.
10
+ */
11
+ export declare class FirebasePushProvider implements PushNotificationProvider {
12
+ private firebaseManager;
13
+ private eventMappings;
14
+ constructor();
15
+ initialize(): Promise<boolean>;
16
+ getToken(): Promise<string | null>;
17
+ requestPermission(): Promise<boolean>;
18
+ hasPermission(): Promise<boolean>;
19
+ addEventListener(eventName: string, callback: PushEventCallback): void;
20
+ removeEventListener(eventName: string, callback: PushEventCallback): void;
21
+ deleteToken(): Promise<boolean>;
22
+ cleanup(): void;
23
+ getBadgeCount(): Promise<number>;
24
+ setBadgeCount(count: number): Promise<boolean>;
25
+ createNotificationChannel(channelId: string, channelName: string, importance?: number, description?: string): Promise<string | null>;
26
+ deleteNotificationChannel(channelId: string): Promise<boolean>;
27
+ }
28
+ //# sourceMappingURL=FirebasePushProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FirebasePushProvider.d.ts","sourceRoot":"","sources":["../../../../../src/providers/FirebasePushProvider.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,wBAAwB,EAE7B,KAAK,iBAAiB,EACvB,MAAM,4BAA4B,CAAC;AAEpC;;;;;;;;GAQG;AACH,qBAAa,oBAAqB,YAAW,wBAAwB;IACnE,OAAO,CAAC,eAAe,CAA8B;IACrD,OAAO,CAAC,aAAa,CAAsB;;IA8BrC,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC;IAmB9B,QAAQ,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAUlC,iBAAiB,IAAI,OAAO,CAAC,OAAO,CAAC;IAarC,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC;IAUvC,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,iBAAiB,GAAG,IAAI;IAMtE,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,iBAAiB,GAAG,IAAI;IAMnE,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAUrC,OAAO,IAAI,IAAI;IAIT,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAUhC,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAU9C,yBAAyB,CAC7B,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,UAAU,GAAE,MAAU,EACtB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAkBnB,yBAAyB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAarE"}
@@ -0,0 +1,25 @@
1
+ import { type PushNotificationProvider, type PushEventCallback } from './PushNotificationProvider';
2
+ /**
3
+ * NullPushProvider
4
+ *
5
+ * No-op implementation of PushNotificationProvider.
6
+ * Used when push notifications are disabled in SDK config.
7
+ *
8
+ * This allows the rest of the SDK to work normally without
9
+ * needing to check "if (pushProvider)" everywhere.
10
+ */
11
+ export declare class NullPushProvider implements PushNotificationProvider {
12
+ initialize(): Promise<boolean>;
13
+ getToken(): Promise<string | null>;
14
+ requestPermission(): Promise<boolean>;
15
+ hasPermission(): Promise<boolean>;
16
+ addEventListener(_eventName: string, _callback: PushEventCallback): void;
17
+ removeEventListener(_eventName: string, _callback: PushEventCallback): void;
18
+ deleteToken(): Promise<boolean>;
19
+ cleanup(): void;
20
+ getBadgeCount(): Promise<number>;
21
+ setBadgeCount(_count: number): Promise<boolean>;
22
+ createNotificationChannel(_channelId: string, _channelName: string, _importance?: number, _description?: string): Promise<string | null>;
23
+ deleteNotificationChannel(_channelId: string): Promise<boolean>;
24
+ }
25
+ //# sourceMappingURL=NullPushProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NullPushProvider.d.ts","sourceRoot":"","sources":["../../../../../src/providers/NullPushProvider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,wBAAwB,EAAE,KAAK,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAEnG;;;;;;;;GAQG;AACH,qBAAa,gBAAiB,YAAW,wBAAwB;IACzD,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC;IAK9B,QAAQ,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAIlC,iBAAiB,IAAI,OAAO,CAAC,OAAO,CAAC;IAKrC,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC;IAIvC,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,iBAAiB,GAAG,IAAI;IAIxE,mBAAmB,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,iBAAiB,GAAG,IAAI;IAIrE,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAIrC,OAAO,IAAI,IAAI;IAIT,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAIhC,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAI/C,yBAAyB,CAC7B,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EACpB,WAAW,CAAC,EAAE,MAAM,EACpB,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAInB,yBAAyB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAGtE"}
@@ -0,0 +1,105 @@
1
+ /**
2
+ * PushNotificationProvider Interface
3
+ *
4
+ * Abstract interface for push notification providers (Firebase, OneSignal, custom, etc.)
5
+ * This allows the SDK to work with different push providers without tight coupling.
6
+ */
7
+ export interface RemoteMessage {
8
+ messageId?: string;
9
+ notification?: {
10
+ title?: string;
11
+ body?: string;
12
+ android?: {
13
+ channelId?: string;
14
+ imageUrl?: string;
15
+ [key: string]: any;
16
+ };
17
+ ios?: {
18
+ [key: string]: any;
19
+ };
20
+ [key: string]: any;
21
+ };
22
+ data?: {
23
+ [key: string]: any;
24
+ };
25
+ sentTime?: number;
26
+ from?: string;
27
+ [key: string]: any;
28
+ }
29
+ export interface PushNotificationEvents {
30
+ TOKEN_RECEIVED: string;
31
+ TOKEN_REFRESH: string;
32
+ NOTIFICATION_RECEIVED: string;
33
+ NOTIFICATION_OPENED: string;
34
+ PERMISSION_CHANGED: string;
35
+ }
36
+ export type PushEventCallback = (data: any) => void;
37
+ /**
38
+ * Push Notification Provider Interface
39
+ *
40
+ * Providers must implement all methods to be compatible with the SDK.
41
+ */
42
+ export interface PushNotificationProvider {
43
+ /**
44
+ * Initialize the push provider
45
+ * @returns true if initialization successful, false otherwise
46
+ */
47
+ initialize(): Promise<boolean>;
48
+ /**
49
+ * Get the current push token
50
+ * @returns push token string or null if not available
51
+ */
52
+ getToken(): Promise<string | null>;
53
+ /**
54
+ * Request push notification permission from user
55
+ * @returns true if permission granted, false otherwise
56
+ */
57
+ requestPermission(): Promise<boolean>;
58
+ /**
59
+ * Check if push notification permission is granted
60
+ * @returns true if permission granted, false otherwise
61
+ */
62
+ hasPermission(): Promise<boolean>;
63
+ /**
64
+ * Add event listener for push notifications
65
+ * @param eventName - Event name to listen for
66
+ * @param callback - Callback function
67
+ */
68
+ addEventListener(eventName: string, callback: PushEventCallback): void;
69
+ /**
70
+ * Remove event listener
71
+ * @param eventName - Event name
72
+ * @param callback - Callback function to remove
73
+ */
74
+ removeEventListener(eventName: string, callback: PushEventCallback): void;
75
+ /**
76
+ * Delete push token (optional - used when user revokes permission)
77
+ * @returns true if deletion successful
78
+ */
79
+ deleteToken?(): Promise<boolean>;
80
+ /**
81
+ * Cleanup resources when provider is destroyed
82
+ */
83
+ cleanup?(): void;
84
+ /**
85
+ * Get badge count (iOS/Android)
86
+ */
87
+ getBadgeCount?(): Promise<number>;
88
+ /**
89
+ * Set badge count (iOS/Android)
90
+ */
91
+ setBadgeCount?(count: number): Promise<boolean>;
92
+ /**
93
+ * Create notification channel (Android)
94
+ */
95
+ createNotificationChannel?(channelId: string, channelName: string, importance?: number, description?: string): Promise<string | null>;
96
+ /**
97
+ * Delete notification channel (Android)
98
+ */
99
+ deleteNotificationChannel?(channelId: string): Promise<boolean>;
100
+ }
101
+ /**
102
+ * Standard event names for push notifications
103
+ */
104
+ export declare const PUSH_NOTIFICATION_EVENTS: PushNotificationEvents;
105
+ //# sourceMappingURL=PushNotificationProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PushNotificationProvider.d.ts","sourceRoot":"","sources":["../../../../../src/providers/PushNotificationProvider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE;YACR,SAAS,CAAC,EAAE,MAAM,CAAC;YACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;YAClB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;SACpB,CAAC;QACF,GAAG,CAAC,EAAE;YACJ,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;SACpB,CAAC;QACF,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC;IACF,IAAI,CAAC,EAAE;QACL,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC;IACF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,sBAAsB;IACrC,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,MAAM,iBAAiB,GAAG,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;AAEpD;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAE/B;;;OAGG;IACH,QAAQ,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAEnC;;;OAGG;IACH,iBAAiB,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAEtC;;;OAGG;IACH,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAElC;;;;OAIG;IACH,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAEvE;;;;OAIG;IACH,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAE1E;;;OAGG;IACH,WAAW,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAEjC;;OAEG;IACH,OAAO,CAAC,IAAI,IAAI,CAAC;IAEjB;;OAEG;IACH,aAAa,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAElC;;OAEG;IACH,aAAa,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEhD;;OAEG;IACH,yBAAyB,CAAC,CACxB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,UAAU,CAAC,EAAE,MAAM,EACnB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAE1B;;OAEG;IACH,yBAAyB,CAAC,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACjE;AAED;;GAEG;AACH,eAAO,MAAM,wBAAwB,EAAE,sBAMtC,CAAC"}
@@ -0,0 +1,60 @@
1
+ import type { DeviceCredentials } from '../state/DeviceStateMachine';
2
+ /**
3
+ * DeviceRegistrationService
4
+ *
5
+ * Handles device registration WITHOUT push token logic.
6
+ * This service is responsible for:
7
+ * - Creating/retrieving device IDs
8
+ * - Managing anonymous profiles (generatedCDID)
9
+ * - Registering devices with the backend
10
+ * - Storing device credentials
11
+ *
12
+ * KEY: This service does NOT handle push tokens.
13
+ * Push token management is handled separately by PushTokenService.
14
+ */
15
+ export declare class DeviceRegistrationService {
16
+ private appId;
17
+ private deviceId;
18
+ private isProduction;
19
+ private sendToSwanFn;
20
+ private getDeviceLocationFn;
21
+ constructor(appId: string, isProduction: 'STAGE' | 'PROD', sendToSwanFn: (url: string, data: any, encode: boolean) => Promise<any>, getDeviceLocationFn: () => Promise<any>);
22
+ /**
23
+ * Register device with backend.
24
+ * If device already registered, returns cached credentials.
25
+ * Otherwise, creates new device registration.
26
+ *
27
+ * NO PUSH TOKEN LOGIC - device registration is independent of push tokens.
28
+ */
29
+ registerDevice(): Promise<DeviceCredentials>;
30
+ /**
31
+ * Get stored device credentials
32
+ */
33
+ getStoredCredentials(key?: string): Promise<DeviceCredentials | null>;
34
+ /**
35
+ * Save device credentials
36
+ */
37
+ private saveCredentials;
38
+ /**
39
+ * Update stored credentials (partial update)
40
+ */
41
+ updateStoredCredentials(updates: Partial<DeviceCredentials>): Promise<void>;
42
+ /**
43
+ * Register new device with backend
44
+ * NO PUSH TOKEN PARAMETER - device registration is independent
45
+ */
46
+ private registerNewDevice;
47
+ /**
48
+ * Update device location on backend
49
+ */
50
+ updateLocation(): Promise<void>;
51
+ /**
52
+ * Update device on backend (for push token updates and location updates)
53
+ */
54
+ private updateDeviceOnBackend;
55
+ /**
56
+ * Get device ID
57
+ */
58
+ getDeviceId(): string | null;
59
+ }
60
+ //# sourceMappingURL=DeviceRegistrationService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeviceRegistrationService.d.ts","sourceRoot":"","sources":["../../../../../src/services/DeviceRegistrationService.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAIrE;;;;;;;;;;;;GAYG;AACH,qBAAa,yBAAyB;IACpC,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,YAAY,CAA6B;IAGjD,OAAO,CAAC,YAAY,CAA4D;IAChF,OAAO,CAAC,mBAAmB,CAAqB;gBAG9C,KAAK,EAAE,MAAM,EACb,YAAY,EAAE,OAAO,GAAG,MAAM,EAC9B,YAAY,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,KAAK,OAAO,CAAC,GAAG,CAAC,EACvE,mBAAmB,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC;IAQzC;;;;;;OAMG;IACG,cAAc,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAuDlD;;OAEG;IACG,oBAAoB,CAAC,GAAG,SAAoB,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAatF;;OAEG;YACW,eAAe;IAsB7B;;OAEG;IACG,uBAAuB,CAAC,OAAO,EAAE,OAAO,CAAC,iBAAiB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAUjF;;;OAGG;YACW,iBAAiB;IA6C/B;;OAEG;IACG,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IA2BrC;;OAEG;YACW,qBAAqB;IA2BnC;;OAEG;IACH,WAAW,IAAI,MAAM,GAAG,IAAI;CAG7B"}
@@ -0,0 +1,82 @@
1
+ import type { DeviceRegistrationService } from './DeviceRegistrationService';
2
+ import type { PushNotificationProvider } from '../providers/PushNotificationProvider';
3
+ type EventCallback = (data: any) => void;
4
+ /**
5
+ * PushTokenService
6
+ *
7
+ * Manages push token lifecycle:
8
+ * - Initializes push provider (Firebase, etc.)
9
+ * - Handles token generation and refresh
10
+ * - Updates device with token when available
11
+ * - Manages permission requests
12
+ *
13
+ * This service is INDEPENDENT of device registration.
14
+ * Tokens are managed separately and can arrive at any time.
15
+ */
16
+ export declare class PushTokenService {
17
+ private provider;
18
+ private eventListeners;
19
+ constructor(provider: PushNotificationProvider, _deviceService: DeviceRegistrationService);
20
+ /**
21
+ * Initialize push notification provider
22
+ */
23
+ initialize(): Promise<boolean>;
24
+ /**
25
+ * Request push notification permission
26
+ */
27
+ requestPermission(): Promise<boolean>;
28
+ /**
29
+ * Check if permission is granted
30
+ */
31
+ hasPermission(): Promise<boolean>;
32
+ /**
33
+ * Get current push token
34
+ */
35
+ getToken(): Promise<string | null>;
36
+ /**
37
+ * Delete push token (when user revokes permission)
38
+ */
39
+ deleteToken(): Promise<boolean>;
40
+ /**
41
+ * Get badge count
42
+ */
43
+ getBadgeCount(): Promise<number>;
44
+ /**
45
+ * Set badge count
46
+ */
47
+ setBadgeCount(count: number): Promise<boolean>;
48
+ /**
49
+ * Create notification channel (Android)
50
+ */
51
+ createNotificationChannel(channelId: string, channelName: string, importance?: number, description?: string): Promise<string | null>;
52
+ /**
53
+ * Delete notification channel (Android only)
54
+ */
55
+ deleteNotificationChannel(channelId: string): Promise<boolean>;
56
+ /**
57
+ * Add event listener (delegates to provider)
58
+ */
59
+ addEventListener(eventName: string, callback: (data: any) => void): void;
60
+ /**
61
+ * Remove event listener (delegates to provider)
62
+ */
63
+ removeEventListener(eventName: string, callback: (data: any) => void): void;
64
+ /**
65
+ * Setup listeners for provider events (token refresh, notifications)
66
+ */
67
+ private setupProviderListeners;
68
+ /**
69
+ * Add event listener
70
+ */
71
+ on(eventName: string, callback: EventCallback): () => void;
72
+ /**
73
+ * Emit event to listeners
74
+ */
75
+ private emit;
76
+ /**
77
+ * Cleanup
78
+ */
79
+ cleanup(): void;
80
+ }
81
+ export {};
82
+ //# sourceMappingURL=PushTokenService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PushTokenService.d.ts","sourceRoot":"","sources":["../../../../../src/services/PushTokenService.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAC7E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AAGtF,KAAK,aAAa,GAAG,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;AAEzC;;;;;;;;;;;GAWG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAA2B;IAC3C,OAAO,CAAC,cAAc,CAAuC;gBAG3D,QAAQ,EAAE,wBAAwB,EAClC,cAAc,EAAE,yBAAyB;IAM3C;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC;IAmCpC;;OAEG;IACG,iBAAiB,IAAI,OAAO,CAAC,OAAO,CAAC;IA8B3C;;OAEG;IACG,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC;IASvC;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IASxC;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAYrC;;OAEG;IACG,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAYtC;;OAEG;IACG,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAYpD;;OAEG;IACG,yBAAyB,CAC7B,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,UAAU,CAAC,EAAE,MAAM,EACnB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAoBzB;;OAEG;IACG,yBAAyB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAepE;;OAEG;IACH,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,GAAG,IAAI;IAIxE;;OAEG;IACH,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,GAAG,IAAI;IAI3E;;OAEG;IACH,OAAO,CAAC,sBAAsB;IA+C9B;;OAEG;IACH,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,GAAG,MAAM,IAAI;IAgB1D;;OAEG;IACH,OAAO,CAAC,IAAI;IAgBZ;;OAEG;IACH,OAAO,IAAI,IAAI;CAMhB"}
@@ -0,0 +1,61 @@
1
+ export declare enum AuthState {
2
+ LOGGED_OUT = "logged_out",
3
+ LOGGING_IN = "logging_in",
4
+ LOGGED_IN = "logged_in",
5
+ LOGGING_OUT = "logging_out",
6
+ ERROR = "error"
7
+ }
8
+ type StateChangeListener = (change: {
9
+ from: AuthState;
10
+ to: AuthState;
11
+ }) => void;
12
+ /**
13
+ * State machine for authentication flow (login/logout).
14
+ * Replaces isLoggingIn and isLoggingOut boolean flags.
15
+ *
16
+ * States:
17
+ * - LOGGED_OUT: No user logged in (anonymous profile)
18
+ * - LOGGING_IN: Login in progress
19
+ * - LOGGED_IN: User logged in (currentCDID set)
20
+ * - LOGGING_OUT: Logout in progress
21
+ * - ERROR: Login/logout failed
22
+ */
23
+ export declare class AuthStateMachine {
24
+ private state;
25
+ private listeners;
26
+ private loginPromise;
27
+ private logoutPromise;
28
+ getState(): AuthState;
29
+ /**
30
+ * Subscribe to state changes
31
+ */
32
+ on(listener: StateChangeListener): () => void;
33
+ /**
34
+ * Execute login with duplicate call protection
35
+ */
36
+ login(loginFn: () => Promise<any>): Promise<any>;
37
+ /**
38
+ * Execute logout with duplicate call protection
39
+ */
40
+ logout(logoutFn: () => Promise<any>): Promise<any>;
41
+ /**
42
+ * Check if user is logged in
43
+ */
44
+ isLoggedIn(): boolean;
45
+ /**
46
+ * Check if login/logout operation is in progress
47
+ */
48
+ isOperationInProgress(): boolean;
49
+ /**
50
+ * Reset to logged out state
51
+ */
52
+ reset(): void;
53
+ /**
54
+ * Restore state from stored credentials (used during SDK initialization)
55
+ * @param isLoggedIn Whether user has currentCDID in stored credentials
56
+ */
57
+ restoreState(isLoggedIn: boolean): void;
58
+ private transition;
59
+ }
60
+ export {};
61
+ //# sourceMappingURL=AuthStateMachine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthStateMachine.d.ts","sourceRoot":"","sources":["../../../../../src/state/AuthStateMachine.ts"],"names":[],"mappings":"AAEA,oBAAY,SAAS;IACnB,UAAU,eAAe;IACzB,UAAU,eAAe;IACzB,SAAS,cAAc;IACvB,WAAW,gBAAgB;IAC3B,KAAK,UAAU;CAChB;AAED,KAAK,mBAAmB,GAAG,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,EAAE,EAAE,SAAS,CAAA;CAAE,KAAK,IAAI,CAAC;AAEhF;;;;;;;;;;GAUG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,KAAK,CAAmC;IAChD,OAAO,CAAC,SAAS,CAA6B;IAC9C,OAAO,CAAC,YAAY,CAA6B;IACjD,OAAO,CAAC,aAAa,CAA6B;IAElD,QAAQ,IAAI,SAAS;IAIrB;;OAEG;IACH,EAAE,CAAC,QAAQ,EAAE,mBAAmB,GAAG,MAAM,IAAI;IAQ7C;;OAEG;IACG,KAAK,CAAC,OAAO,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC;IAgCtD;;OAEG;IACG,MAAM,CAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC;IAgCxD;;OAEG;IACH,UAAU,IAAI,OAAO;IAIrB;;OAEG;IACH,qBAAqB,IAAI,OAAO;IAIhC;;OAEG;IACH,KAAK,IAAI,IAAI;IAOb;;;OAGG;IACH,YAAY,CAAC,UAAU,EAAE,OAAO,GAAG,IAAI;IAKvC,OAAO,CAAC,UAAU;CAoBnB"}
@@ -0,0 +1,51 @@
1
+ export declare enum DeviceState {
2
+ UNINITIALIZED = "uninitialized",
3
+ REGISTERING = "registering",
4
+ REGISTERED = "registered",
5
+ FAILED = "failed"
6
+ }
7
+ export interface DeviceCredentials {
8
+ deviceId: string;
9
+ generatedCDID: string;
10
+ currentCDID?: string | null;
11
+ first_seen_at?: string;
12
+ deviceActivatedAt?: string;
13
+ pushNotificationToken?: string;
14
+ pushPermission?: boolean;
15
+ isProduction: 'STAGE' | 'PROD';
16
+ [key: string]: any;
17
+ }
18
+ type StateChangeListener = (change: {
19
+ from: DeviceState;
20
+ to: DeviceState;
21
+ }) => void;
22
+ /**
23
+ * State machine for device registration flow.
24
+ * Eliminates race conditions from boolean flags.
25
+ *
26
+ * States: UNINITIALIZED → REGISTERING → REGISTERED → FAILED
27
+ */
28
+ export declare class DeviceStateMachine {
29
+ private state;
30
+ private registrationPromise;
31
+ private listeners;
32
+ getState(): DeviceState;
33
+ /**
34
+ * Subscribe to state changes
35
+ */
36
+ on(listener: StateChangeListener): () => void;
37
+ /**
38
+ * Register device with race condition protection.
39
+ * If already registered, returns cached credentials.
40
+ * If registration in progress, waits for existing promise.
41
+ * Otherwise, starts new registration.
42
+ */
43
+ register(registrationFn: () => Promise<DeviceCredentials>): Promise<DeviceCredentials>;
44
+ /**
45
+ * Reset state machine (useful for testing or logout scenarios)
46
+ */
47
+ reset(): void;
48
+ private transition;
49
+ }
50
+ export {};
51
+ //# sourceMappingURL=DeviceStateMachine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeviceStateMachine.d.ts","sourceRoot":"","sources":["../../../../../src/state/DeviceStateMachine.ts"],"names":[],"mappings":"AAEA,oBAAY,WAAW;IACrB,aAAa,kBAAkB;IAC/B,WAAW,gBAAgB;IAC3B,UAAU,eAAe;IACzB,MAAM,WAAW;CAClB;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,YAAY,EAAE,OAAO,GAAG,MAAM,CAAC;IAC/B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,KAAK,mBAAmB,GAAG,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,EAAE,EAAE,WAAW,CAAA;CAAE,KAAK,IAAI,CAAC;AAEpF;;;;;GAKG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,KAAK,CAA0C;IACvD,OAAO,CAAC,mBAAmB,CAA2C;IACtE,OAAO,CAAC,SAAS,CAA6B;IAE9C,QAAQ,IAAI,WAAW;IAIvB;;OAEG;IACH,EAAE,CAAC,QAAQ,EAAE,mBAAmB,GAAG,MAAM,IAAI;IAQ7C;;;;;OAKG;IACG,QAAQ,CACZ,cAAc,EAAE,MAAM,OAAO,CAAC,iBAAiB,CAAC,GAC/C,OAAO,CAAC,iBAAiB,CAAC;IA8B7B;;OAEG;IACH,KAAK,IAAI,IAAI;IAMb,OAAO,CAAC,UAAU;CAoBnB"}
@@ -0,0 +1,61 @@
1
+ export declare enum PushState {
2
+ DISABLED = "disabled",
3
+ INITIALIZING = "initializing",
4
+ READY = "ready",
5
+ PERMISSION_DENIED = "permission_denied",
6
+ TOKEN_PENDING = "token_pending",
7
+ ACTIVE = "active",
8
+ ERROR = "error"
9
+ }
10
+ type StateChangeListener = (change: {
11
+ from: PushState;
12
+ to: PushState;
13
+ }) => void;
14
+ /**
15
+ * State machine for push notification lifecycle.
16
+ * Manages the complex flow of permission → token → active states.
17
+ *
18
+ * States:
19
+ * - DISABLED: Push notifications not enabled in config
20
+ * - INITIALIZING: Loading Firebase provider
21
+ * - READY: Provider initialized, ready to request permission
22
+ * - PERMISSION_DENIED: User denied permission
23
+ * - TOKEN_PENDING: Permission granted, waiting for FCM token
24
+ * - ACTIVE: Token received and registered with backend
25
+ * - ERROR: Push initialization failed
26
+ */
27
+ export declare class PushStateMachine {
28
+ private state;
29
+ private listeners;
30
+ getState(): PushState;
31
+ /**
32
+ * Subscribe to state changes
33
+ */
34
+ on(listener: StateChangeListener): () => void;
35
+ /**
36
+ * Transition to a new state
37
+ */
38
+ transition(newState: PushState): void;
39
+ /**
40
+ * Reset to disabled state
41
+ */
42
+ reset(): void;
43
+ /**
44
+ * Check if push is active (token received and synced)
45
+ */
46
+ isActive(): boolean;
47
+ /**
48
+ * Check if push is in error state
49
+ */
50
+ isError(): boolean;
51
+ /**
52
+ * Check if push is disabled
53
+ */
54
+ isDisabled(): boolean;
55
+ /**
56
+ * Validate state transitions (optional - for debugging)
57
+ */
58
+ private isValidTransition;
59
+ }
60
+ export {};
61
+ //# sourceMappingURL=PushStateMachine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PushStateMachine.d.ts","sourceRoot":"","sources":["../../../../../src/state/PushStateMachine.ts"],"names":[],"mappings":"AAEA,oBAAY,SAAS;IACnB,QAAQ,aAAa;IACrB,YAAY,iBAAiB;IAC7B,KAAK,UAAU;IACf,iBAAiB,sBAAsB;IACvC,aAAa,kBAAkB;IAC/B,MAAM,WAAW;IACjB,KAAK,UAAU;CAChB;AAED,KAAK,mBAAmB,GAAG,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,EAAE,EAAE,SAAS,CAAA;CAAE,KAAK,IAAI,CAAC;AAEhF;;;;;;;;;;;;GAYG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,KAAK,CAAiC;IAC9C,OAAO,CAAC,SAAS,CAA6B;IAE9C,QAAQ,IAAI,SAAS;IAIrB;;OAEG;IACH,EAAE,CAAC,QAAQ,EAAE,mBAAmB,GAAG,MAAM,IAAI;IAQ7C;;OAEG;IACH,UAAU,CAAC,QAAQ,EAAE,SAAS,GAAG,IAAI;IA4BrC;;OAEG;IACH,KAAK,IAAI,IAAI;IAKb;;OAEG;IACH,QAAQ,IAAI,OAAO;IAInB;;OAEG;IACH,OAAO,IAAI,OAAO;IAIlB;;OAEG;IACH,UAAU,IAAI,OAAO;IAIrB;;OAEG;IACH,OAAO,CAAC,iBAAiB;CAc1B"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Type definitions for Event Batching System
3
+ * Supports offline queuing, batching, and fault-tolerant event delivery
4
+ */
5
+ /**
6
+ * Event stored in the queue
7
+ */
8
+ export interface QueuedEvent {
9
+ id: string;
10
+ eventName: string;
11
+ eventData: any;
12
+ timestamp: number;
13
+ priority: number;
14
+ retryCount: number;
15
+ status: 'pending' | 'sending' | 'failed';
16
+ createdAt: number;
17
+ lastAttemptAt?: number;
18
+ }
19
+ /**
20
+ * Configuration for batch processing
21
+ */
22
+ export interface BatchConfiguration {
23
+ batchSize: number;
24
+ flushInterval: number;
25
+ maxQueueSize: number;
26
+ maxRetries: number;
27
+ retryBaseDelay: number;
28
+ enableCompression: boolean;
29
+ queueCleanupDays: number;
30
+ }
31
+ /**
32
+ * Batch payload sent to backend
33
+ */
34
+ export interface BatchPayload {
35
+ common: {
36
+ appId: string;
37
+ deviceId: string;
38
+ sdkVersion: string;
39
+ platform: string;
40
+ };
41
+ events: BatchEvent[];
42
+ isBatch: boolean;
43
+ }
44
+ /**
45
+ * Individual event within a batch
46
+ */
47
+ export interface BatchEvent {
48
+ id: string;
49
+ name: string;
50
+ timestamp: number;
51
+ data: any;
52
+ userId: string;
53
+ currentCDID: string | null;
54
+ generatedCDID: string;
55
+ }
56
+ /**
57
+ * Response from batch endpoint
58
+ */
59
+ export interface BatchResponse {
60
+ success: boolean;
61
+ processedCount: number;
62
+ failedCount: number;
63
+ results: BatchResult[];
64
+ }
65
+ /**
66
+ * Result for individual event in batch
67
+ */
68
+ export interface BatchResult {
69
+ id: string;
70
+ success: boolean;
71
+ CDID?: string;
72
+ profileSwitched?: boolean;
73
+ error?: string;
74
+ }
75
+ /**
76
+ * Queue call type constants
77
+ * Used to distinguish different network call types in the queue
78
+ */
79
+ export declare const QUEUE_CALL_TYPES: {
80
+ readonly PUSH_SUBSCRIBE: "PUSH_SUBSCRIBE";
81
+ readonly PUSH_UNSUBSCRIBE: "PUSH_UNSUBSCRIBE";
82
+ readonly PROFILE_ENRICH: "PROFILE_ENRICH";
83
+ readonly NOTIFICATION_ACK: "SWAN_NOTIFICATION_ACK";
84
+ };
85
+ //# sourceMappingURL=EventQueue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EventQueue.d.ts","sourceRoot":"","sources":["../../../../../src/types/EventQueue.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,GAAG,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE;QACN,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,GAAG,CAAC;IACV,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,WAAW,EAAE,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;;;CASnB,CAAC"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * SDK Configuration Types
3
+ */
4
+ /**
5
+ * Swan SDK Configuration
6
+ *
7
+ * Push notifications are DISABLED by default.
8
+ * Apps must explicitly opt-in to use push functionality.
9
+ */
10
+ export interface SwanSDKConfig {
11
+ /**
12
+ * Push notification configuration
13
+ * If not specified, push notifications are disabled.
14
+ */
15
+ pushNotifications?: {
16
+ /**
17
+ * Enable push notifications (default: false)
18
+ */
19
+ enabled: boolean;
20
+ /**
21
+ * Automatically request notification permission on init (default: false)
22
+ * If false, app must call requestNotificationPermission() manually
23
+ */
24
+ autoRequestPermission?: boolean;
25
+ /**
26
+ * Push provider to use (default: 'firebase')
27
+ * Future: can support custom providers
28
+ */
29
+ provider?: 'firebase' | 'custom';
30
+ /**
31
+ * Custom provider instance (for advanced use cases)
32
+ */
33
+ customProvider?: any;
34
+ };
35
+ /**
36
+ * Enable debug logging (default: false)
37
+ */
38
+ logging?: boolean;
39
+ /**
40
+ * Enable production environment (default: false)
41
+ */
42
+ isProduction?: boolean;
43
+ }
44
+ /**
45
+ * Event callback type
46
+ */
47
+ export type EventCallback = (data: any) => void;
48
+ /**
49
+ * Event subscription
50
+ */
51
+ export interface EventSubscription {
52
+ remove: () => void;
53
+ }
54
+ //# sourceMappingURL=SDK.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SDK.d.ts","sourceRoot":"","sources":["../../../../../src/types/SDK.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,iBAAiB,CAAC,EAAE;QAClB;;WAEG;QACH,OAAO,EAAE,OAAO,CAAC;QAEjB;;;WAGG;QACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;QAEhC;;;WAGG;QACH,QAAQ,CAAC,EAAE,UAAU,GAAG,QAAQ,CAAC;QAEjC;;WAEG;QACH,cAAc,CAAC,EAAE,GAAG,CAAC;KACtB,CAAC;IAEF;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;AAEhD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB"}