@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,155 @@
1
+ "use strict";
2
+
3
+ import Logger from "../utils/Logger.js";
4
+ export let AuthState = /*#__PURE__*/function (AuthState) {
5
+ AuthState["LOGGED_OUT"] = "logged_out";
6
+ AuthState["LOGGING_IN"] = "logging_in";
7
+ AuthState["LOGGED_IN"] = "logged_in";
8
+ AuthState["LOGGING_OUT"] = "logging_out";
9
+ AuthState["ERROR"] = "error";
10
+ return AuthState;
11
+ }({});
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 class AuthStateMachine {
24
+ state = AuthState.LOGGED_OUT;
25
+ listeners = [];
26
+ loginPromise = null;
27
+ logoutPromise = null;
28
+ getState() {
29
+ return this.state;
30
+ }
31
+
32
+ /**
33
+ * Subscribe to state changes
34
+ */
35
+ on(listener) {
36
+ this.listeners.push(listener);
37
+ // Return unsubscribe function
38
+ return () => {
39
+ this.listeners = this.listeners.filter(l => l !== listener);
40
+ };
41
+ }
42
+
43
+ /**
44
+ * Execute login with duplicate call protection
45
+ */
46
+ async login(loginFn) {
47
+ // Already logged in
48
+ if (this.state === AuthState.LOGGED_IN) {
49
+ Logger.warn('[AuthStateMachine] Already logged in');
50
+ return;
51
+ }
52
+
53
+ // Login in progress - wait for existing promise
54
+ if (this.state === AuthState.LOGGING_IN && this.loginPromise) {
55
+ Logger.warn('[AuthStateMachine] Login already in progress, ignoring duplicate call');
56
+ return this.loginPromise;
57
+ }
58
+ this.transition(AuthState.LOGGING_IN);
59
+ this.loginPromise = loginFn().then(result => {
60
+ this.transition(AuthState.LOGGED_IN);
61
+ return result;
62
+ }).catch(error => {
63
+ this.transition(AuthState.ERROR);
64
+ this.loginPromise = null;
65
+ throw error;
66
+ }).finally(() => {
67
+ this.loginPromise = null;
68
+ });
69
+ return this.loginPromise;
70
+ }
71
+
72
+ /**
73
+ * Execute logout with duplicate call protection
74
+ */
75
+ async logout(logoutFn) {
76
+ // Already logged out
77
+ if (this.state === AuthState.LOGGED_OUT) {
78
+ Logger.warn('[AuthStateMachine] Already logged out');
79
+ return;
80
+ }
81
+
82
+ // Logout in progress - wait for existing promise
83
+ if (this.state === AuthState.LOGGING_OUT && this.logoutPromise) {
84
+ Logger.warn('[AuthStateMachine] Logout already in progress, ignoring duplicate call');
85
+ return this.logoutPromise;
86
+ }
87
+ this.transition(AuthState.LOGGING_OUT);
88
+ this.logoutPromise = logoutFn().then(result => {
89
+ this.transition(AuthState.LOGGED_OUT);
90
+ return result;
91
+ }).catch(error => {
92
+ this.transition(AuthState.ERROR);
93
+ this.logoutPromise = null;
94
+ throw error;
95
+ }).finally(() => {
96
+ this.logoutPromise = null;
97
+ });
98
+ return this.logoutPromise;
99
+ }
100
+
101
+ /**
102
+ * Check if user is logged in
103
+ */
104
+ isLoggedIn() {
105
+ return this.state === AuthState.LOGGED_IN;
106
+ }
107
+
108
+ /**
109
+ * Check if login/logout operation is in progress
110
+ */
111
+ isOperationInProgress() {
112
+ return this.state === AuthState.LOGGING_IN || this.state === AuthState.LOGGING_OUT;
113
+ }
114
+
115
+ /**
116
+ * Reset to logged out state
117
+ */
118
+ reset() {
119
+ this.state = AuthState.LOGGED_OUT;
120
+ this.loginPromise = null;
121
+ this.logoutPromise = null;
122
+ Logger.log('[AuthStateMachine] State reset to LOGGED_OUT');
123
+ }
124
+
125
+ /**
126
+ * Restore state from stored credentials (used during SDK initialization)
127
+ * @param isLoggedIn Whether user has currentCDID in stored credentials
128
+ */
129
+ restoreState(isLoggedIn) {
130
+ this.state = isLoggedIn ? AuthState.LOGGED_IN : AuthState.LOGGED_OUT;
131
+ Logger.log(`[AuthStateMachine] State restored: ${this.state} (from credentials)`);
132
+ }
133
+ transition(newState) {
134
+ const oldState = this.state;
135
+ if (oldState === newState) {
136
+ return; // No transition needed
137
+ }
138
+ this.state = newState;
139
+ Logger.log(`[AuthStateMachine] State transition: ${oldState} → ${newState}`);
140
+
141
+ // Notify listeners
142
+ const change = {
143
+ from: oldState,
144
+ to: newState
145
+ };
146
+ this.listeners.forEach(listener => {
147
+ try {
148
+ listener(change);
149
+ } catch (error) {
150
+ Logger.error('[AuthStateMachine] Error in state change listener:', error);
151
+ }
152
+ });
153
+ }
154
+ }
155
+ //# sourceMappingURL=AuthStateMachine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Logger","AuthState","AuthStateMachine","state","LOGGED_OUT","listeners","loginPromise","logoutPromise","getState","on","listener","push","filter","l","login","loginFn","LOGGED_IN","warn","LOGGING_IN","transition","then","result","catch","error","ERROR","finally","logout","logoutFn","LOGGING_OUT","isLoggedIn","isOperationInProgress","reset","log","restoreState","newState","oldState","change","from","to","forEach"],"sourceRoot":"../../../src","sources":["state/AuthStateMachine.ts"],"mappings":";;AAAA,OAAOA,MAAM,MAAM,oBAAiB;AAEpC,WAAYC,SAAS,0BAATA,SAAS;EAATA,SAAS;EAATA,SAAS;EAATA,SAAS;EAATA,SAAS;EAATA,SAAS;EAAA,OAATA,SAAS;AAAA;AAUrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,CAAC;EACpBC,KAAK,GAAcF,SAAS,CAACG,UAAU;EACvCC,SAAS,GAA0B,EAAE;EACrCC,YAAY,GAAwB,IAAI;EACxCC,aAAa,GAAwB,IAAI;EAEjDC,QAAQA,CAAA,EAAc;IACpB,OAAO,IAAI,CAACL,KAAK;EACnB;;EAEA;AACF;AACA;EACEM,EAAEA,CAACC,QAA6B,EAAc;IAC5C,IAAI,CAACL,SAAS,CAACM,IAAI,CAACD,QAAQ,CAAC;IAC7B;IACA,OAAO,MAAM;MACX,IAAI,CAACL,SAAS,GAAG,IAAI,CAACA,SAAS,CAACO,MAAM,CAACC,CAAC,IAAIA,CAAC,KAAKH,QAAQ,CAAC;IAC7D,CAAC;EACH;;EAEA;AACF;AACA;EACE,MAAMI,KAAKA,CAACC,OAA2B,EAAgB;IACrD;IACA,IAAI,IAAI,CAACZ,KAAK,KAAKF,SAAS,CAACe,SAAS,EAAE;MACtChB,MAAM,CAACiB,IAAI,CAAC,sCAAsC,CAAC;MACnD;IACF;;IAEA;IACA,IAAI,IAAI,CAACd,KAAK,KAAKF,SAAS,CAACiB,UAAU,IAAI,IAAI,CAACZ,YAAY,EAAE;MAC5DN,MAAM,CAACiB,IAAI,CAAC,uEAAuE,CAAC;MACpF,OAA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;MAAEG,EAAE,EAAEJ;IAAS,CAAC;IAC/C,IAAI,CAAC7B,SAAS,CAACkC,OAAO,CAAC7B,QAAQ,IAAI;MACjC,IAAI;QACFA,QAAQ,CAAC0B,MAAM,CAAC;MAClB,CAAC,CAAC,OAAOb,KAAK,EAAE;QACdvB,MAAM,CAACuB,KAAK,CAAC,oDAAoD,EAAEA,KAAK,CAAC;MAC3E;IACF,CAAC,CAAC;EACJ;AACF","ignoreList":[]}
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+
3
+ import Logger from "../utils/Logger.js";
4
+ export let DeviceState = /*#__PURE__*/function (DeviceState) {
5
+ DeviceState["UNINITIALIZED"] = "uninitialized";
6
+ DeviceState["REGISTERING"] = "registering";
7
+ DeviceState["REGISTERED"] = "registered";
8
+ DeviceState["FAILED"] = "failed";
9
+ return DeviceState;
10
+ }({});
11
+ /**
12
+ * State machine for device registration flow.
13
+ * Eliminates race conditions from boolean flags.
14
+ *
15
+ * States: UNINITIALIZED → REGISTERING → REGISTERED → FAILED
16
+ */
17
+ export class DeviceStateMachine {
18
+ state = DeviceState.UNINITIALIZED;
19
+ registrationPromise = null;
20
+ listeners = [];
21
+ getState() {
22
+ return this.state;
23
+ }
24
+
25
+ /**
26
+ * Subscribe to state changes
27
+ */
28
+ on(listener) {
29
+ this.listeners.push(listener);
30
+ // Return unsubscribe function
31
+ return () => {
32
+ this.listeners = this.listeners.filter(l => l !== listener);
33
+ };
34
+ }
35
+
36
+ /**
37
+ * Register device with race condition protection.
38
+ * If already registered, returns cached credentials.
39
+ * If registration in progress, waits for existing promise.
40
+ * Otherwise, starts new registration.
41
+ */
42
+ async register(registrationFn) {
43
+ // Already registered - return cached result
44
+ if (this.state === DeviceState.REGISTERED && this.registrationPromise) {
45
+ Logger.log('[DeviceStateMachine] Device already registered, returning cached credentials');
46
+ return this.registrationPromise;
47
+ }
48
+
49
+ // Registration in progress - wait for it
50
+ if (this.state === DeviceState.REGISTERING && this.registrationPromise) {
51
+ Logger.log('[DeviceStateMachine] Device registration in progress, waiting...');
52
+ return this.registrationPromise;
53
+ }
54
+
55
+ // Start new registration
56
+ this.transition(DeviceState.REGISTERING);
57
+ this.registrationPromise = registrationFn().then(credentials => {
58
+ this.transition(DeviceState.REGISTERED);
59
+ return credentials;
60
+ }).catch(error => {
61
+ this.transition(DeviceState.FAILED);
62
+ this.registrationPromise = null; // Allow retry on failure
63
+ throw error;
64
+ });
65
+ return this.registrationPromise;
66
+ }
67
+
68
+ /**
69
+ * Reset state machine (useful for testing or logout scenarios)
70
+ */
71
+ reset() {
72
+ this.state = DeviceState.UNINITIALIZED;
73
+ this.registrationPromise = null;
74
+ Logger.log('[DeviceStateMachine] State reset to UNINITIALIZED');
75
+ }
76
+ transition(newState) {
77
+ const oldState = this.state;
78
+ if (oldState === newState) {
79
+ return; // No transition needed
80
+ }
81
+ this.state = newState;
82
+ Logger.log(`[DeviceStateMachine] State transition: ${oldState} → ${newState}`);
83
+
84
+ // Notify listeners
85
+ const change = {
86
+ from: oldState,
87
+ to: newState
88
+ };
89
+ this.listeners.forEach(listener => {
90
+ try {
91
+ listener(change);
92
+ } catch (error) {
93
+ Logger.error('[DeviceStateMachine] Error in state change listener:', error);
94
+ }
95
+ });
96
+ }
97
+ }
98
+ //# sourceMappingURL=DeviceStateMachine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Logger","DeviceState","DeviceStateMachine","state","UNINITIALIZED","registrationPromise","listeners","getState","on","listener","push","filter","l","register","registrationFn","REGISTERED","log","REGISTERING","transition","then","credentials","catch","error","FAILED","reset","newState","oldState","change","from","to","forEach"],"sourceRoot":"../../../src","sources":["state/DeviceStateMachine.ts"],"mappings":";;AAAA,OAAOA,MAAM,MAAM,oBAAiB;AAEpC,WAAYC,WAAW,0BAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAA,OAAXA,WAAW;AAAA;AAqBvB;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,M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AI,CAAC,CAAC;MACjC,MAAMiB,KAAK;IACb,CAAC,CAAC;IAEJ,OAAO,IAAI,CAACjB,mBAAmB;EACjC;;EAEA;AACF;AACA;EACEmB,KAAKA,CAAA,EAAS;IACZ,IAAI,CAACrB,KAAK,GAAGF,WAAW,CAACG,aAAa;IACtC,IAAI,CAACC,mBAAmB,GAAG,IAAI;IAC/BL,MAAM,CAACgB,GAAG,CAAC,mDAAmD,CAAC;EACjE;EAEQE,UAAUA,CAACO,QAAqB,EAAQ;IAC9C,MAAMC,QAAQ,GAAG,IAAI,CAACvB,KAAK;IAE3B,IAAIuB,QAAQ,KAAKD,QAAQ,EAAE;MACzB,OAAO,CAAC;IACV;IAEA,IAAI,CAACtB,KAAK,GAAGsB,QAAQ;IACrBzB,MAAM,CAACgB,GAAG,CAAC,0CAA0CU,QAAQ,MAAMD,QAAQ,EAAE,CAAC;;IAE9E;IACA,MAAME,MAAM,GAAG;MAAEC,IAAI,EAAEF,QAAQ;MAAEG,EAAE,EAAEJ;IAAS,CAAC;IAC/C,IAAI,CAACnB,SAAS,CAACwB,OAAO,CAACrB,QAAQ,IAAI;MACjC,IAAI;QACFA,QAAQ,CAACkB,MAAM,CAAC;MAClB,CAAC,CAAC,OAAOL,KAAK,EAAE;QACdtB,MAAM,CAACsB,KAAK,CAAC,sDAAsD,EAAEA,KAAK,CAAC;MAC7E;IACF,CAAC,CAAC;EACJ;AACF","ignoreList":[]}
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+
3
+ import Logger from "../utils/Logger.js";
4
+ export let PushState = /*#__PURE__*/function (PushState) {
5
+ PushState["DISABLED"] = "disabled";
6
+ PushState["INITIALIZING"] = "initializing";
7
+ PushState["READY"] = "ready";
8
+ PushState["PERMISSION_DENIED"] = "permission_denied";
9
+ PushState["TOKEN_PENDING"] = "token_pending";
10
+ PushState["ACTIVE"] = "active";
11
+ PushState["ERROR"] = "error";
12
+ return PushState;
13
+ }({});
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 class PushStateMachine {
28
+ state = PushState.DISABLED;
29
+ listeners = [];
30
+ getState() {
31
+ return this.state;
32
+ }
33
+
34
+ /**
35
+ * Subscribe to state changes
36
+ */
37
+ on(listener) {
38
+ this.listeners.push(listener);
39
+ // Return unsubscribe function
40
+ return () => {
41
+ this.listeners = this.listeners.filter(l => l !== listener);
42
+ };
43
+ }
44
+
45
+ /**
46
+ * Transition to a new state
47
+ */
48
+ transition(newState) {
49
+ const oldState = this.state;
50
+ if (oldState === newState) {
51
+ return; // No transition needed
52
+ }
53
+
54
+ // Validate state transitions (optional - can be removed for flexibility)
55
+ if (!this.isValidTransition(oldState, newState)) {
56
+ Logger.warn(`[PushStateMachine] Unexpected state transition: ${oldState} → ${newState}`);
57
+ }
58
+ this.state = newState;
59
+ Logger.log(`[PushStateMachine] State transition: ${oldState} → ${newState}`);
60
+
61
+ // Notify listeners
62
+ const change = {
63
+ from: oldState,
64
+ to: newState
65
+ };
66
+ this.listeners.forEach(listener => {
67
+ try {
68
+ listener(change);
69
+ } catch (error) {
70
+ Logger.error('[PushStateMachine] Error in state change listener:', error);
71
+ }
72
+ });
73
+ }
74
+
75
+ /**
76
+ * Reset to disabled state
77
+ */
78
+ reset() {
79
+ this.state = PushState.DISABLED;
80
+ Logger.log('[PushStateMachine] State reset to DISABLED');
81
+ }
82
+
83
+ /**
84
+ * Check if push is active (token received and synced)
85
+ */
86
+ isActive() {
87
+ return this.state === PushState.ACTIVE;
88
+ }
89
+
90
+ /**
91
+ * Check if push is in error state
92
+ */
93
+ isError() {
94
+ return this.state === PushState.ERROR;
95
+ }
96
+
97
+ /**
98
+ * Check if push is disabled
99
+ */
100
+ isDisabled() {
101
+ return this.state === PushState.DISABLED;
102
+ }
103
+
104
+ /**
105
+ * Validate state transitions (optional - for debugging)
106
+ */
107
+ isValidTransition(from, to) {
108
+ const validTransitions = {
109
+ [PushState.DISABLED]: [PushState.INITIALIZING],
110
+ [PushState.INITIALIZING]: [PushState.READY, PushState.ERROR],
111
+ [PushState.READY]: [PushState.PERMISSION_DENIED, PushState.TOKEN_PENDING, PushState.ERROR],
112
+ [PushState.PERMISSION_DENIED]: [PushState.READY],
113
+ // Can retry permission
114
+ [PushState.TOKEN_PENDING]: [PushState.ACTIVE, PushState.ERROR],
115
+ [PushState.ACTIVE]: [PushState.TOKEN_PENDING],
116
+ // Token refresh
117
+ [PushState.ERROR]: [PushState.INITIALIZING] // Can retry initialization
118
+ };
119
+ const allowedTransitions = validTransitions[from];
120
+ return allowedTransitions ? allowedTransitions.includes(to) : false;
121
+ }
122
+ }
123
+ //# sourceMappingURL=PushStateMachine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Logger","PushState","PushStateMachine","state","DISABLED","listeners","getState","on","listener","push","filter","l","transition","newState","oldState","isValidTransition","warn","log","change","from","to","forEach","error","reset","isActive","ACTIVE","isError","ERROR","isDisabled","validTransitions","INITIALIZING","READY","PERMISSION_DENIED","TOKEN_PENDING","allowedTransitions","includes"],"sourceRoot":"../../../src","sources":["state/PushStateMachine.ts"],"mappings":";;AAAA,OAAOA,MAAM,MAAM,oBAAiB;AAEpC,WAAYC,SAAS,0BAATA,SAAS;EAATA,SAAS;EAATA,SAAS;EAATA,SAAS;EAATA,SAAS;EAATA,SAAS;EAATA,SAAS;EAATA,SAAS;EAAA,OAATA,SAAS;AAAA;AAYrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,CAAC;EACpBC,KAAK,GAAcF,SAAS,CAACG,QAAQ;EACrCC,S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K;EACrE;AACF","ignoreList":[]}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Type definitions for Event Batching System
5
+ * Supports offline queuing, batching, and fault-tolerant event delivery
6
+ */
7
+
8
+ /**
9
+ * Event stored in the queue
10
+ */
11
+
12
+ /**
13
+ * Configuration for batch processing
14
+ */
15
+
16
+ /**
17
+ * Batch payload sent to backend
18
+ */
19
+
20
+ /**
21
+ * Individual event within a batch
22
+ */
23
+
24
+ /**
25
+ * Response from batch endpoint
26
+ */
27
+
28
+ /**
29
+ * Result for individual event in batch
30
+ */
31
+
32
+ /**
33
+ * Queue call type constants
34
+ * Used to distinguish different network call types in the queue
35
+ */
36
+ export const QUEUE_CALL_TYPES = {
37
+ // Standard events use their actual event names (no prefix)
38
+ // e.g., 'productViewed', 'userLogin', etc.
39
+
40
+ // Special call types for non-event network operations
41
+ PUSH_SUBSCRIBE: 'PUSH_SUBSCRIBE',
42
+ PUSH_UNSUBSCRIBE: 'PUSH_UNSUBSCRIBE',
43
+ PROFILE_ENRICH: 'PROFILE_ENRICH',
44
+ NOTIFICATION_ACK: 'SWAN_NOTIFICATION_ACK' // Already exists
45
+ };
46
+ //# sourceMappingURL=EventQueue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["QUEUE_CALL_TYPES","PUSH_SUBSCRIBE","PUSH_UNSUBSCRIBE","PROFILE_ENRICH","NOTIFICATION_ACK"],"sourceRoot":"../../../src","sources":["types/EventQueue.ts"],"mappings":";;AAAA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAaA;AACA;AACA;;AAWA;AACA;AACA;;AAYA;AACA;AACA;;AAWA;AACA;AACA;;AAQA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA,OAAO,MAAMA,gBAAgB,GAAG;EAC9B;EACA;;EAEA;EACAC,cAAc,EAAE,gBAAgB;EAChCC,gBAAgB,EAAE,kBAAkB;EACpCC,cAAc,EAAE,gBAAgB;EAChCC,gBAAgB,EAAE,uBAAuB,CAAE;AAC7C,CAAU","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=SDK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/SDK.ts"],"mappings":"","ignoreList":[]}