@app-swiss-knife/react-native-sdk 0.1.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.
Files changed (218) hide show
  1. package/README.md +182 -0
  2. package/SwissKnifePurchases.podspec +40 -0
  3. package/android/build.gradle +89 -0
  4. package/android/gradle.properties +3 -0
  5. package/android/src/main/AndroidManifest.xml +26 -0
  6. package/android/src/main/java/com/swissknife/crashreporting/SKCrashReportingModule.kt +216 -0
  7. package/android/src/main/java/com/swissknife/crashreporting/SKCrashReportingPackage.kt +17 -0
  8. package/android/src/main/java/com/swissknife/purchases/Conversions.kt +15 -0
  9. package/android/src/main/java/com/swissknife/purchases/SwissKnifeJson.kt +371 -0
  10. package/android/src/main/java/com/swissknife/purchases/SwissKnifePurchasesModule.kt +497 -0
  11. package/android/src/main/java/com/swissknife/purchases/SwissKnifePurchasesPackage.kt +25 -0
  12. package/android/vendor/GENERATED.md +10 -0
  13. package/android/vendor/java/com/appswissknife/SwissKnife.kt +533 -0
  14. package/android/vendor/java/com/appswissknife/analytics/EventQueueStore.kt +326 -0
  15. package/android/vendor/java/com/appswissknife/analytics/FlushEventsWorker.kt +296 -0
  16. package/android/vendor/java/com/appswissknife/analytics/SKAnalytics.kt +503 -0
  17. package/android/vendor/java/com/appswissknife/attributes/AttributesClient.kt +188 -0
  18. package/android/vendor/java/com/appswissknife/attributes/SetAttributesWorker.kt +204 -0
  19. package/android/vendor/java/com/appswissknife/attribution/Attribution.kt +447 -0
  20. package/android/vendor/java/com/appswissknife/context/AppLifecycle.kt +120 -0
  21. package/android/vendor/java/com/appswissknife/context/Clock.kt +70 -0
  22. package/android/vendor/java/com/appswissknife/context/DeviceContext.kt +138 -0
  23. package/android/vendor/java/com/appswissknife/context/IDs.kt +55 -0
  24. package/android/vendor/java/com/appswissknife/context/Reachability.kt +145 -0
  25. package/android/vendor/java/com/appswissknife/context/Session.kt +192 -0
  26. package/android/vendor/java/com/appswissknife/crashreporting/SKCrashReporting.kt +945 -0
  27. package/android/vendor/java/com/appswissknife/crashreporting/SKScreenshot.kt +201 -0
  28. package/android/vendor/java/com/appswissknife/device/DeviceID.kt +172 -0
  29. package/android/vendor/java/com/appswissknife/diagnostics/SKLog.kt +97 -0
  30. package/android/vendor/java/com/appswissknife/entitlements/EntitlementsRepository.kt +495 -0
  31. package/android/vendor/java/com/appswissknife/identity/Identity.kt +522 -0
  32. package/android/vendor/java/com/appswissknife/models/CustomerInfo.kt +67 -0
  33. package/android/vendor/java/com/appswissknife/models/Enums.kt +35 -0
  34. package/android/vendor/java/com/appswissknife/models/Offerings.kt +80 -0
  35. package/android/vendor/java/com/appswissknife/models/PurchasesError.kt +89 -0
  36. package/android/vendor/java/com/appswissknife/models/StoreTransaction.kt +17 -0
  37. package/android/vendor/java/com/appswissknife/net/BackendHttpClient.kt +507 -0
  38. package/android/vendor/java/com/appswissknife/net/ExponentialBackoff.kt +69 -0
  39. package/android/vendor/java/com/appswissknife/net/IngestClient.kt +582 -0
  40. package/android/vendor/java/com/appswissknife/net/OfflineQueueStore.kt +320 -0
  41. package/android/vendor/java/com/appswissknife/offerings/OfferingsRepository.kt +219 -0
  42. package/android/vendor/java/com/appswissknife/performance/SKFrameTracker.kt +94 -0
  43. package/android/vendor/java/com/appswissknife/performance/SKPerformance.kt +428 -0
  44. package/android/vendor/java/com/appswissknife/purchases/BillingClientGateway.kt +560 -0
  45. package/android/vendor/java/com/appswissknife/purchases/PlayPriceEnrichmentProvider.kt +100 -0
  46. package/android/vendor/java/com/appswissknife/purchases/PriceEnrichmentProvider.kt +36 -0
  47. package/android/vendor/java/com/appswissknife/purchases/PurchasesGateway.kt +120 -0
  48. package/android/vendor/res/xml/swissknife_data_extraction_rules.xml +20 -0
  49. package/ios/SwissKnifeCrashReporting.m +32 -0
  50. package/ios/SwissKnifeCrashReporting.swift +186 -0
  51. package/ios/SwissKnifeJSON.swift +347 -0
  52. package/ios/SwissKnifePurchases.m +124 -0
  53. package/ios/SwissKnifePurchases.swift +523 -0
  54. package/ios/vendor/GENERATED.md +10 -0
  55. package/ios/vendor/SwissKnifeiOS/Analytics/SKAnalytics.swift +488 -0
  56. package/ios/vendor/SwissKnifeiOS/AttributesClient.swift +460 -0
  57. package/ios/vendor/SwissKnifeiOS/Attribution/Attribution.swift +307 -0
  58. package/ios/vendor/SwissKnifeiOS/Attribution/AttributionNetwork.swift +92 -0
  59. package/ios/vendor/SwissKnifeiOS/Attribution/AttributionState.swift +141 -0
  60. package/ios/vendor/SwissKnifeiOS/Context/AppLifecycle.swift +130 -0
  61. package/ios/vendor/SwissKnifeiOS/Context/Clock.swift +100 -0
  62. package/ios/vendor/SwissKnifeiOS/Context/DeviceContext.swift +190 -0
  63. package/ios/vendor/SwissKnifeiOS/Context/IDs.swift +64 -0
  64. package/ios/vendor/SwissKnifeiOS/Context/Reachability.swift +121 -0
  65. package/ios/vendor/SwissKnifeiOS/Context/Session.swift +223 -0
  66. package/ios/vendor/SwissKnifeiOS/CrashReporting/SKCrashReporting.swift +1287 -0
  67. package/ios/vendor/SwissKnifeiOS/CrashReporting/SKScreenshot.swift +175 -0
  68. package/ios/vendor/SwissKnifeiOS/DeviceID.swift +161 -0
  69. package/ios/vendor/SwissKnifeiOS/Diagnostics/SKLog.swift +128 -0
  70. package/ios/vendor/SwissKnifeiOS/Identity/Identity.swift +323 -0
  71. package/ios/vendor/SwissKnifeiOS/Identity/IdentityNetwork.swift +70 -0
  72. package/ios/vendor/SwissKnifeiOS/Net/BackendHttpClient.swift +329 -0
  73. package/ios/vendor/SwissKnifeiOS/Net/ExponentialBackoff.swift +87 -0
  74. package/ios/vendor/SwissKnifeiOS/Net/IngestClient.swift +681 -0
  75. package/ios/vendor/SwissKnifeiOS/Net/OfflineQueueStore.swift +409 -0
  76. package/ios/vendor/SwissKnifeiOS/Performance/SKFrameTracker.swift +89 -0
  77. package/ios/vendor/SwissKnifeiOS/Performance/SKPerformance.swift +440 -0
  78. package/ios/vendor/SwissKnifeiOS/Performance/SKURLSessionDelegate.swift +87 -0
  79. package/ios/vendor/SwissKnifeiOS/Services/EntitlementsService.swift +646 -0
  80. package/ios/vendor/SwissKnifeiOS/Services/OfferingsService.swift +458 -0
  81. package/ios/vendor/SwissKnifeiOS/Services/PurchaseService.swift +374 -0
  82. package/ios/vendor/SwissKnifeiOS/SwissKnife+Analytics.swift +46 -0
  83. package/ios/vendor/SwissKnifeiOS/SwissKnife+DeviceID.swift +30 -0
  84. package/ios/vendor/SwissKnifeiOS/SwissKnife+Session.swift +47 -0
  85. package/ios/vendor/SwissKnifeiOS/SwissKnife.swift +417 -0
  86. package/ios/vendor/SwissKnifeiOS/Types.swift +496 -0
  87. package/lib/commonjs/attribution.js +55 -0
  88. package/lib/commonjs/attribution.js.map +1 -0
  89. package/lib/commonjs/identity.js +126 -0
  90. package/lib/commonjs/identity.js.map +1 -0
  91. package/lib/commonjs/index.js +118 -0
  92. package/lib/commonjs/index.js.map +1 -0
  93. package/lib/commonjs/modules/analytics.js +646 -0
  94. package/lib/commonjs/modules/analytics.js.map +1 -0
  95. package/lib/commonjs/modules/attachments.js +169 -0
  96. package/lib/commonjs/modules/attachments.js.map +1 -0
  97. package/lib/commonjs/modules/crash-reporting.js +1327 -0
  98. package/lib/commonjs/modules/crash-reporting.js.map +1 -0
  99. package/lib/commonjs/modules/ids.js +50 -0
  100. package/lib/commonjs/modules/ids.js.map +1 -0
  101. package/lib/commonjs/modules/log.js +59 -0
  102. package/lib/commonjs/modules/log.js.map +1 -0
  103. package/lib/commonjs/modules/offline-store.js +44 -0
  104. package/lib/commonjs/modules/offline-store.js.map +1 -0
  105. package/lib/commonjs/modules/performance.js +494 -0
  106. package/lib/commonjs/modules/performance.js.map +1 -0
  107. package/lib/commonjs/native/module.js +41 -0
  108. package/lib/commonjs/native/module.js.map +1 -0
  109. package/lib/commonjs/native/spec.js +26 -0
  110. package/lib/commonjs/native/spec.js.map +1 -0
  111. package/lib/commonjs/package.json +1 -0
  112. package/lib/commonjs/purchases.js +194 -0
  113. package/lib/commonjs/purchases.js.map +1 -0
  114. package/lib/commonjs/types.js +236 -0
  115. package/lib/commonjs/types.js.map +1 -0
  116. package/lib/module/attribution.js +51 -0
  117. package/lib/module/attribution.js.map +1 -0
  118. package/lib/module/identity.js +122 -0
  119. package/lib/module/identity.js.map +1 -0
  120. package/lib/module/index.js +36 -0
  121. package/lib/module/index.js.map +1 -0
  122. package/lib/module/modules/analytics.js +642 -0
  123. package/lib/module/modules/analytics.js.map +1 -0
  124. package/lib/module/modules/attachments.js +162 -0
  125. package/lib/module/modules/attachments.js.map +1 -0
  126. package/lib/module/modules/crash-reporting.js +1320 -0
  127. package/lib/module/modules/crash-reporting.js.map +1 -0
  128. package/lib/module/modules/ids.js +44 -0
  129. package/lib/module/modules/ids.js.map +1 -0
  130. package/lib/module/modules/log.js +54 -0
  131. package/lib/module/modules/log.js.map +1 -0
  132. package/lib/module/modules/offline-store.js +39 -0
  133. package/lib/module/modules/offline-store.js.map +1 -0
  134. package/lib/module/modules/performance.js +491 -0
  135. package/lib/module/modules/performance.js.map +1 -0
  136. package/lib/module/native/module.js +34 -0
  137. package/lib/module/native/module.js.map +1 -0
  138. package/lib/module/native/spec.js +22 -0
  139. package/lib/module/native/spec.js.map +1 -0
  140. package/lib/module/package.json +1 -0
  141. package/lib/module/purchases.js +187 -0
  142. package/lib/module/purchases.js.map +1 -0
  143. package/lib/module/types.js +230 -0
  144. package/lib/module/types.js.map +1 -0
  145. package/lib/typescript/commonjs/attribution.d.ts +24 -0
  146. package/lib/typescript/commonjs/attribution.d.ts.map +1 -0
  147. package/lib/typescript/commonjs/identity.d.ts +37 -0
  148. package/lib/typescript/commonjs/identity.d.ts.map +1 -0
  149. package/lib/typescript/commonjs/index.d.ts +15 -0
  150. package/lib/typescript/commonjs/index.d.ts.map +1 -0
  151. package/lib/typescript/commonjs/modules/analytics.d.ts +127 -0
  152. package/lib/typescript/commonjs/modules/analytics.d.ts.map +1 -0
  153. package/lib/typescript/commonjs/modules/attachments.d.ts +50 -0
  154. package/lib/typescript/commonjs/modules/attachments.d.ts.map +1 -0
  155. package/lib/typescript/commonjs/modules/crash-reporting.d.ts +175 -0
  156. package/lib/typescript/commonjs/modules/crash-reporting.d.ts.map +1 -0
  157. package/lib/typescript/commonjs/modules/ids.d.ts +17 -0
  158. package/lib/typescript/commonjs/modules/ids.d.ts.map +1 -0
  159. package/lib/typescript/commonjs/modules/log.d.ts +12 -0
  160. package/lib/typescript/commonjs/modules/log.d.ts.map +1 -0
  161. package/lib/typescript/commonjs/modules/offline-store.d.ts +9 -0
  162. package/lib/typescript/commonjs/modules/offline-store.d.ts.map +1 -0
  163. package/lib/typescript/commonjs/modules/performance.d.ts +75 -0
  164. package/lib/typescript/commonjs/modules/performance.d.ts.map +1 -0
  165. package/lib/typescript/commonjs/native/module.d.ts +6 -0
  166. package/lib/typescript/commonjs/native/module.d.ts.map +1 -0
  167. package/lib/typescript/commonjs/native/spec.d.ts +119 -0
  168. package/lib/typescript/commonjs/native/spec.d.ts.map +1 -0
  169. package/lib/typescript/commonjs/package.json +1 -0
  170. package/lib/typescript/commonjs/purchases.d.ts +68 -0
  171. package/lib/typescript/commonjs/purchases.d.ts.map +1 -0
  172. package/lib/typescript/commonjs/types.d.ts +384 -0
  173. package/lib/typescript/commonjs/types.d.ts.map +1 -0
  174. package/lib/typescript/module/attribution.d.ts +24 -0
  175. package/lib/typescript/module/attribution.d.ts.map +1 -0
  176. package/lib/typescript/module/identity.d.ts +37 -0
  177. package/lib/typescript/module/identity.d.ts.map +1 -0
  178. package/lib/typescript/module/index.d.ts +15 -0
  179. package/lib/typescript/module/index.d.ts.map +1 -0
  180. package/lib/typescript/module/modules/analytics.d.ts +127 -0
  181. package/lib/typescript/module/modules/analytics.d.ts.map +1 -0
  182. package/lib/typescript/module/modules/attachments.d.ts +50 -0
  183. package/lib/typescript/module/modules/attachments.d.ts.map +1 -0
  184. package/lib/typescript/module/modules/crash-reporting.d.ts +175 -0
  185. package/lib/typescript/module/modules/crash-reporting.d.ts.map +1 -0
  186. package/lib/typescript/module/modules/ids.d.ts +17 -0
  187. package/lib/typescript/module/modules/ids.d.ts.map +1 -0
  188. package/lib/typescript/module/modules/log.d.ts +12 -0
  189. package/lib/typescript/module/modules/log.d.ts.map +1 -0
  190. package/lib/typescript/module/modules/offline-store.d.ts +9 -0
  191. package/lib/typescript/module/modules/offline-store.d.ts.map +1 -0
  192. package/lib/typescript/module/modules/performance.d.ts +75 -0
  193. package/lib/typescript/module/modules/performance.d.ts.map +1 -0
  194. package/lib/typescript/module/native/module.d.ts +6 -0
  195. package/lib/typescript/module/native/module.d.ts.map +1 -0
  196. package/lib/typescript/module/native/spec.d.ts +119 -0
  197. package/lib/typescript/module/native/spec.d.ts.map +1 -0
  198. package/lib/typescript/module/package.json +1 -0
  199. package/lib/typescript/module/purchases.d.ts +68 -0
  200. package/lib/typescript/module/purchases.d.ts.map +1 -0
  201. package/lib/typescript/module/types.d.ts +384 -0
  202. package/lib/typescript/module/types.d.ts.map +1 -0
  203. package/package.json +115 -0
  204. package/react-native.config.js +23 -0
  205. package/src/attribution.ts +56 -0
  206. package/src/identity.ts +133 -0
  207. package/src/index.ts +54 -0
  208. package/src/modules/analytics.ts +689 -0
  209. package/src/modules/attachments.ts +222 -0
  210. package/src/modules/crash-reporting.ts +1577 -0
  211. package/src/modules/ids.ts +41 -0
  212. package/src/modules/log.ts +56 -0
  213. package/src/modules/offline-store.ts +51 -0
  214. package/src/modules/performance.ts +589 -0
  215. package/src/native/module.ts +47 -0
  216. package/src/native/spec.ts +183 -0
  217. package/src/purchases.ts +214 -0
  218. package/src/types.ts +470 -0
@@ -0,0 +1,194 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Purchases = void 0;
7
+ exports.__throwIfNotConfigured = throwIfNotConfigured;
8
+ exports.default = void 0;
9
+ var _module = require("./native/module.js");
10
+ var _spec = require("./native/spec.js");
11
+ var _types = require("./types.js");
12
+ // src/purchases.ts
13
+
14
+ let configured = false;
15
+ let configuredApiKey = null;
16
+
17
+ // Maps a caller's listener fn to its native subscription so we can remove it.
18
+ const customerInfoSubscriptions = new Map();
19
+ function throwIfNotConfigured() {
20
+ if (!configured) {
21
+ throw new _types.UninitializedPurchasesError();
22
+ }
23
+ }
24
+
25
+ /**
26
+ * RC-compatible subscriptions SDK entry point. Process-wide singleton; call
27
+ * `Purchases.configure(...)` once at app start, then use the static methods.
28
+ */
29
+ class Purchases {
30
+ /**
31
+ * Configure the SDK. Must be called before any other method. Calling again
32
+ * with the same API key is a no-op (matches the common "configure once" guard);
33
+ * the native layer owns full reconfiguration.
34
+ */
35
+ static configure(options) {
36
+ if (configured && configuredApiKey === options.apiKey) return;
37
+ const native = (0, _module.getNativeModule)();
38
+ const nativeOptions = {
39
+ apiKey: options.apiKey,
40
+ appUserID: options.appUserID ?? null,
41
+ // proxyURL points the native SDK at the Swiss Knife backend. Without it the
42
+ // native layer falls back to its hardcoded default host (api.swiss-knife.dev),
43
+ // which is unreachable for self-hosted tenants. Forward it so callers can
44
+ // target their own backend (e.g. https://swiss.remneys.com).
45
+ proxyURL: options.proxyURL ?? null,
46
+ // Hardening pass (spec): diagnostics opt-in only — default OFF.
47
+ diagnosticsEnabled: options.diagnosticsEnabled ?? false,
48
+ storeKitVersion: options.storeKitVersion,
49
+ useAmazon: options.useAmazon,
50
+ // iOS ATT — default off (no tracking prompt) unless the host opts in.
51
+ autoPromptATT: options.autoPromptATT,
52
+ sendInstallOnFirstLaunch: options.sendInstallOnFirstLaunch,
53
+ logLevel: options.logLevel
54
+ };
55
+ // Fire-and-forget: native configure resolves async but RC's configure is sync.
56
+ void native.configure(nativeOptions);
57
+ configured = true;
58
+ configuredApiKey = options.apiKey;
59
+ }
60
+
61
+ /** Whether the SDK has been configured. Delegates to native. */
62
+ static isConfigured() {
63
+ if (!configured) return Promise.resolve(false);
64
+ return (0, _module.getNativeModule)().isConfigured();
65
+ }
66
+
67
+ /** Latest CustomerInfo (entitlements + subscriptions), computed server-side. */
68
+ static async getCustomerInfo() {
69
+ throwIfNotConfigured();
70
+ return (0, _module.getNativeModule)().getCustomerInfo();
71
+ }
72
+
73
+ /** Current + all offerings configured for this app. */
74
+ static async getOfferings() {
75
+ throwIfNotConfigured();
76
+ return (0, _module.getNativeModule)().getOfferings();
77
+ }
78
+
79
+ /** Purchase a package from an offering. Drives the native store payment sheet. */
80
+ static async purchasePackage(pkg) {
81
+ throwIfNotConfigured();
82
+ const offeringId = pkg.presentedOfferingContext?.offeringIdentifier ?? '';
83
+ return (0, _module.getNativeModule)().purchasePackage(pkg.identifier, offeringId);
84
+ }
85
+
86
+ /** Purchase a store product directly by its store SKU. */
87
+ static async purchaseStoreProduct(product) {
88
+ throwIfNotConfigured();
89
+ return (0, _module.getNativeModule)().purchaseStoreProduct(product.identifier);
90
+ }
91
+
92
+ /** Restore purchases tied to the underlying store account. */
93
+ static async restorePurchases() {
94
+ throwIfNotConfigured();
95
+ return (0, _module.getNativeModule)().restorePurchases();
96
+ }
97
+
98
+ /**
99
+ * Identify the user. Aliases/merges anonymous purchases server-side.
100
+ *
101
+ * @deprecated Wave 1 — prefer `Identity.logIn(userId)`. Routes through
102
+ * the unified Identity surface natively, so the bug fix (Android now
103
+ * POSTs `/api/sdk/users/identify`) applies whether you call this or
104
+ * `Identity.logIn(...)`.
105
+ */
106
+ static async logIn(appUserID) {
107
+ throwIfNotConfigured();
108
+ return (0, _module.getNativeModule)().logIn(appUserID);
109
+ }
110
+
111
+ /**
112
+ * Log out the current user and revert to anonymous.
113
+ *
114
+ * @deprecated Wave 1 — prefer `Identity.logOut()`.
115
+ */
116
+ static async logOut() {
117
+ throwIfNotConfigured();
118
+ return (0, _module.getNativeModule)().logOut();
119
+ }
120
+
121
+ /** The current app user id (anonymous or identified). */
122
+ static async getAppUserID() {
123
+ throwIfNotConfigured();
124
+ return (0, _module.getNativeModule)().getAppUserID();
125
+ }
126
+
127
+ /** Whether the current user id is an SDK-generated anonymous id. */
128
+ static async isAnonymous() {
129
+ throwIfNotConfigured();
130
+ return (0, _module.getNativeModule)().isAnonymous();
131
+ }
132
+
133
+ /** Set arbitrary subscriber attributes. null clears an attribute. */
134
+ static async setAttributes(attributes) {
135
+ throwIfNotConfigured();
136
+ return (0, _module.getNativeModule)().setAttributes(attributes);
137
+ }
138
+
139
+ /** Reserved attribute: email. */
140
+ static async setEmail(email) {
141
+ throwIfNotConfigured();
142
+ return (0, _module.getNativeModule)().setEmail(email);
143
+ }
144
+
145
+ /** Reserved attribute: display name. */
146
+ static async setDisplayName(displayName) {
147
+ throwIfNotConfigured();
148
+ return (0, _module.getNativeModule)().setDisplayName(displayName);
149
+ }
150
+
151
+ /** Reserved attribute: phone number. */
152
+ static async setPhoneNumber(phoneNumber) {
153
+ throwIfNotConfigured();
154
+ return (0, _module.getNativeModule)().setPhoneNumber(phoneNumber);
155
+ }
156
+
157
+ /** Reserved attribute: push token. */
158
+ static async setPushToken(pushToken) {
159
+ throwIfNotConfigured();
160
+ return (0, _module.getNativeModule)().setPushToken(pushToken);
161
+ }
162
+
163
+ /** Set the native log level. Accepts a LOG_LEVEL enum value. */
164
+ static async setLogLevel(level) {
165
+ return (0, _module.getNativeModule)().setLogLevel(level);
166
+ }
167
+
168
+ /** Subscribe to CustomerInfo changes (purchase, renewal, dashboard grant). */
169
+ static addCustomerInfoUpdateListener(listener) {
170
+ const sub = (0, _module.getEventEmitter)().addListener(_spec.CUSTOMER_INFO_UPDATED_EVENT, event => listener(event));
171
+ customerInfoSubscriptions.set(listener, sub);
172
+ }
173
+
174
+ /** Remove a previously-registered CustomerInfo update listener. */
175
+ static removeCustomerInfoUpdateListener(listener) {
176
+ const sub = customerInfoSubscriptions.get(listener);
177
+ if (sub) {
178
+ sub.remove();
179
+ customerInfoSubscriptions.delete(listener);
180
+ }
181
+ }
182
+
183
+ /** @internal Test seam: reset singleton state between tests. */
184
+ static __resetForTests() {
185
+ configured = false;
186
+ configuredApiKey = null;
187
+ customerInfoSubscriptions.clear();
188
+ }
189
+ }
190
+
191
+ // Internal helper shared with the rest of the class (defined across SP-2a tasks).
192
+ exports.Purchases = Purchases;
193
+ var _default = exports.default = Purchases;
194
+ //# sourceMappingURL=purchases.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_module","require","_spec","_types","configured","configuredApiKey","customerInfoSubscriptions","Map","throwIfNotConfigured","UninitializedPurchasesError","Purchases","configure","options","apiKey","native","getNativeModule","nativeOptions","appUserID","proxyURL","diagnosticsEnabled","storeKitVersion","useAmazon","autoPromptATT","sendInstallOnFirstLaunch","logLevel","isConfigured","Promise","resolve","getCustomerInfo","getOfferings","purchasePackage","pkg","offeringId","presentedOfferingContext","offeringIdentifier","identifier","purchaseStoreProduct","product","restorePurchases","logIn","logOut","getAppUserID","isAnonymous","setAttributes","attributes","setEmail","email","setDisplayName","displayName","setPhoneNumber","phoneNumber","setPushToken","pushToken","setLogLevel","level","addCustomerInfoUpdateListener","listener","sub","getEventEmitter","addListener","CUSTOMER_INFO_UPDATED_EVENT","event","set","removeCustomerInfoUpdateListener","get","remove","delete","__resetForTests","clear","exports","_default","default"],"sourceRoot":"../../src","sources":["purchases.ts"],"mappings":";;;;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAHA;;AAkBA,IAAIG,UAAU,GAAG,KAAK;AACtB,IAAIC,gBAA+B,GAAG,IAAI;;AAE1C;AACA,MAAMC,yBAAyB,GAAG,IAAIC,GAAG,CAGvC,CAAC;AAEH,SAASC,oBAAoBA,CAAA,EAAS;EACpC,IAAI,CAACJ,UAAU,EAAE;IACf,MAAM,IAAIK,kCAA2B,CAAC,CAAC;EACzC;AACF;;AAEA;AACA;AACA;AACA;AACO,MAAMC,SAAS,CAAC;EACrB;AACF;AACA;AACA;AACA;EACE,OAAOC,SAASA,CACdC,OAA0D,EACpD;IACN,IAAIR,UAAU,IAAIC,gBA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Q,CAAC;IAC5C;EACF;;EAEA;EACA,OAAOW,eAAeA,CAAA,EAAS;IAC7B/D,UAAU,GAAG,KAAK;IAClBC,gBAAgB,GAAG,IAAI;IACvBC,yBAAyB,CAAC8D,KAAK,CAAC,CAAC;EACnC;AACF;;AAEA;AAAAC,OAAA,CAAA3D,SAAA,GAAAA,SAAA;AAAA,IAAA4D,QAAA,GAAAD,OAAA,CAAAE,OAAA,GAGe7D,SAAS","ignoreList":[]}
@@ -0,0 +1,236 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.VERIFICATION_RESULT = exports.UnsupportedPlatformError = exports.UninitializedPurchasesError = exports.STOREKIT_VERSION = exports.PURCHASES_ERROR_CODE = exports.PACKAGE_TYPE = exports.LOG_LEVEL = void 0;
7
+ // packages/react-native-sdk/src/types.ts
8
+ //
9
+ // Phase 7 of the RC rip-and-replace: own TypeScript type definitions that
10
+ // REPLACE the previous star-export of `@revenuecat/purchases-typescript-internal`.
11
+ // Shape mirrors RC's public API (same field names, same semantics) per the
12
+ // user-locked decision in the Phase 7 plan, so consumers of this SDK keep
13
+ // working without any source change.
14
+ //
15
+ // Why mirror RC names?
16
+ // - The public JS surface (`Purchases.configure`, `Purchases.getCustomerInfo`,
17
+ // etc.) MUST stay byte-compatible with `react-native-purchases`. The native
18
+ // bridges in `ios/SwissKnifePurchases.swift` and
19
+ // `android/.../SwissKnifePurchasesModule.kt` JSON-encode our Swift/Kotlin
20
+ // types (defined in `packages/swiss-knife-{ios,android}`) into payloads
21
+ // that match these TS shapes. One contract on both sides of the bridge.
22
+ //
23
+ // What's gone:
24
+ // - The dep on `@revenuecat/purchases-typescript-internal` — removed from
25
+ // package.json. No more PHC-licensed code ships in the SDK.
26
+ //
27
+ // What's preserved:
28
+ // - Re-exported names (`PurchasesEntitlementInfo`, `PurchasesOfferings`,
29
+ // `MakePurchaseResult`, …) so existing callers `import { Foo } from
30
+ // '@app-swiss-knife/react-native-sdk'` still compile unchanged.
31
+ // - The string-numeric `PURCHASES_ERROR_CODE` values RC uses ("0", "1", "10")
32
+ // — that's what the native bridge `reject(...)` callsite emits, so the JS
33
+ // mapper has to keep matching.
34
+
35
+ // MARK: - Value enums (must remain runtime objects, not type-only)
36
+ //
37
+ // RC's TS package exposes these as TS `enum` declarations, which means callers
38
+ // can use them as runtime values (`if (lvl === LOG_LEVEL.DEBUG) …`). We
39
+ // preserve that shape with `as const` objects so consumers don't see a behavior
40
+ // change.
41
+
42
+ /**
43
+ * SDK log level. String values match `RC.LogLevel` so the native bridge keeps
44
+ * parsing the same vocabulary on iOS and Android.
45
+ */
46
+ const LOG_LEVEL = exports.LOG_LEVEL = {
47
+ VERBOSE: "VERBOSE",
48
+ DEBUG: "DEBUG",
49
+ INFO: "INFO",
50
+ WARN: "WARN",
51
+ ERROR: "ERROR"
52
+ };
53
+ /** Subscription package shape — same names as RC's `PACKAGE_TYPE`. */
54
+ const PACKAGE_TYPE = exports.PACKAGE_TYPE = {
55
+ UNKNOWN: "UNKNOWN",
56
+ CUSTOM: "CUSTOM",
57
+ LIFETIME: "LIFETIME",
58
+ ANNUAL: "ANNUAL",
59
+ SIX_MONTH: "SIX_MONTH",
60
+ THREE_MONTH: "THREE_MONTH",
61
+ TWO_MONTH: "TWO_MONTH",
62
+ MONTHLY: "MONTHLY",
63
+ WEEKLY: "WEEKLY"
64
+ };
65
+ /**
66
+ * StoreKit version selection on iOS. We only support StoreKit 2 in Phase 5+,
67
+ * but the enum stays for source compatibility — `configure({ storeKitVersion:
68
+ * STOREKIT_VERSION.STOREKIT_2 })` is a no-op now.
69
+ */
70
+ const STOREKIT_VERSION = exports.STOREKIT_VERSION = {
71
+ DEFAULT: "DEFAULT",
72
+ STOREKIT_1: "STOREKIT_1",
73
+ STOREKIT_2: "STOREKIT_2"
74
+ };
75
+ /** JWS / signed-response verification status. RC parity. */
76
+ const VERIFICATION_RESULT = exports.VERIFICATION_RESULT = {
77
+ NOT_REQUESTED: "NOT_REQUESTED",
78
+ VERIFIED: "VERIFIED",
79
+ FAILED: "FAILED",
80
+ VERIFIED_ON_DEVICE: "VERIFIED_ON_DEVICE"
81
+ };
82
+ /**
83
+ * Public error-code catalog. Values are string-numeric ("0", "1", "10", …)
84
+ * so they match what RC's TS package previously emitted. The native bridges
85
+ * `reject(code, ...)` with these stringified numeric codes and the JS mapper
86
+ * picks them up by string compare — DO NOT renumber.
87
+ *
88
+ * Code → name mapping is the RC catalog the platform-native sealed classes
89
+ * already mirror (see `PurchasesError.kt`/`Types.swift`). New codes go at the
90
+ * end, never reorder.
91
+ */
92
+ const PURCHASES_ERROR_CODE = exports.PURCHASES_ERROR_CODE = {
93
+ UNKNOWN_ERROR: "0",
94
+ PURCHASE_CANCELLED_ERROR: "1",
95
+ STORE_PROBLEM_ERROR: "2",
96
+ PURCHASE_NOT_ALLOWED_ERROR: "3",
97
+ PURCHASE_INVALID_ERROR: "4",
98
+ PRODUCT_NOT_AVAILABLE_FOR_PURCHASE_ERROR: "5",
99
+ PRODUCT_ALREADY_PURCHASED_ERROR: "6",
100
+ RECEIPT_ALREADY_IN_USE_ERROR: "7",
101
+ INVALID_RECEIPT_ERROR: "8",
102
+ MISSING_RECEIPT_FILE_ERROR: "9",
103
+ NETWORK_ERROR: "10",
104
+ INVALID_CREDENTIALS_ERROR: "11",
105
+ UNEXPECTED_BACKEND_RESPONSE_ERROR: "12",
106
+ RECEIPT_IN_USE_BY_OTHER_SUBSCRIBER_ERROR: "13",
107
+ INVALID_APP_USER_ID_ERROR: "14",
108
+ OPERATION_ALREADY_IN_PROGRESS_ERROR: "15",
109
+ UNKNOWN_BACKEND_ERROR: "16",
110
+ INVALID_APPLE_SUBSCRIPTION_KEY_ERROR: "17",
111
+ INELIGIBLE_ERROR: "18",
112
+ INSUFFICIENT_PERMISSIONS_ERROR: "19",
113
+ PAYMENT_PENDING_ERROR: "20",
114
+ INVALID_SUBSCRIBER_ATTRIBUTES_ERROR: "21",
115
+ LOG_OUT_ANONYMOUS_USER_ERROR: "22",
116
+ CONFIGURATION_ERROR: "23",
117
+ UNSUPPORTED_ERROR: "24",
118
+ EMPTY_SUBSCRIBER_ATTRIBUTES_ERROR: "25",
119
+ CUSTOMER_INFO_ERROR: "28"
120
+ };
121
+ // MARK: - Errors thrown / referenced by the Purchases class
122
+
123
+ /**
124
+ * Thrown by `Purchases.<method>()` when called before `Purchases.configure(...)`.
125
+ * Matches the name + shape of RC's `UninitializedPurchasesError` so callers
126
+ * catching by class name keep working.
127
+ */
128
+ class UninitializedPurchasesError extends Error {
129
+ constructor(message = "Purchases is not configured. Call Purchases.configure() first.") {
130
+ super(message);
131
+ this.name = "UninitializedPurchasesError";
132
+ }
133
+ }
134
+
135
+ /**
136
+ * Thrown when an API is called on an unsupported platform (e.g. web). Kept
137
+ * for source compatibility with RC.
138
+ */
139
+ exports.UninitializedPurchasesError = UninitializedPurchasesError;
140
+ class UnsupportedPlatformError extends Error {
141
+ constructor(message = "This method is not supported on the current platform.") {
142
+ super(message);
143
+ this.name = "UnsupportedPlatformError";
144
+ }
145
+ }
146
+
147
+ /**
148
+ * Plain-object error contract used on callback args and rejected promises.
149
+ * NOT an Error subclass — RC surfaces this as a value, not something thrown
150
+ * as a JS Error. Promise rejections from the native bridge come through as
151
+ * `Error` objects whose `code` and `message` fields match this shape.
152
+ */
153
+
154
+ // MARK: - Customer / Entitlement domain
155
+
156
+ /**
157
+ * Per-entitlement state. Field names match RC's `PurchasesEntitlementInfo`
158
+ * 1:1; populated by the native bridge from our own `EntitlementInfo` Swift /
159
+ * Kotlin types (see `packages/swiss-knife-{ios,android}`).
160
+ *
161
+ * Dates are ISO-8601 strings on the wire — JS doesn't get a native `Date`
162
+ * across the RN bridge.
163
+ */
164
+
165
+ /** All entitlements the user has ever owned + the currently-active subset. */
166
+
167
+ /** Subscription-only state per product (renewal status, period, etc.). */
168
+
169
+ /** One non-subscription IAP transaction (consumable/non-consumable). */
170
+
171
+ /**
172
+ * Top-level user-level state, populated from our own `CustomerInfo` types on
173
+ * the native side. Field names track RC's `CustomerInfo` shape.
174
+ */
175
+
176
+ // MARK: - Products / packages / offerings
177
+
178
+ /** Localized price + currency on a store product. Mirror of RC's `PurchasesStoreProductPrice`. */
179
+
180
+ /** Subscription period on a store product. */
181
+
182
+ /** Intro / promotional offer on a store product. */
183
+
184
+ /** One store product (subscription or non-subscription). */
185
+
186
+ /**
187
+ * The offering / package / target context surfaced when a package is presented.
188
+ * `targetingContext` is RC-server-driven A/B test metadata; preserved for parity.
189
+ */
190
+
191
+ /** A purchasable package inside an offering. */
192
+
193
+ /** A named group of packages — a paywall variant. */
194
+
195
+ /** Top-level offerings container. */
196
+
197
+ // MARK: - Public-method result types
198
+
199
+ /** Returned by `Purchases.logIn(appUserID)`. */
200
+
201
+ // MARK: - Identity (Wave 1)
202
+
203
+ /**
204
+ * Immutable snapshot of the current identity. Mirrors
205
+ * `SwissKnife.Identity.Snapshot` (iOS) and
206
+ * `com.appswissknife.identity.Identity.Snapshot` (Android).
207
+ *
208
+ * The `anonymousId` carries the unified `$SKAnonymousID:` prefix as of
209
+ * Wave 1 (was `$RCAnonymousID:` on Android pre-Wave-1).
210
+ */
211
+
212
+ /** Delivered to `Identity.addObserver` callbacks on every transition. */
213
+
214
+ // MARK: - Attribution (Wave 2)
215
+
216
+ /**
217
+ * Resolved attribution for the install. Mirrors
218
+ * `SwissKnife.Attribution.ResolvedAttribution` (iOS) and
219
+ * `Attribution.ResolvedAttribution` (Android).
220
+ */
221
+
222
+ /** Returned by `Purchases.purchasePackage(...)` / `purchaseStoreProduct(...)`. */
223
+
224
+ // MARK: - Configuration
225
+
226
+ /** Options accepted by `Purchases.configure(...)`. Mirror of `PurchasesConfiguration`. */
227
+
228
+ // MARK: - Event listeners
229
+
230
+ /**
231
+ * Callback signature for `Purchases.addCustomerInfoUpdateListener(fn)`. Fires
232
+ * on every CustomerInfo refresh (post-purchase, post-restore, dashboard-grant
233
+ * silent-push, etc.).
234
+ */
235
+ exports.UnsupportedPlatformError = UnsupportedPlatformError;
236
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["LOG_LEVEL","exports","VERBOSE","DEBUG","INFO","WARN","ERROR","PACKAGE_TYPE","UNKNOWN","CUSTOM","LIFETIME","ANNUAL","SIX_MONTH","THREE_MONTH","TWO_MONTH","MONTHLY","WEEKLY","STOREKIT_VERSION","DEFAULT","STOREKIT_1","STOREKIT_2","VERIFICATION_RESULT","NOT_REQUESTED","VERIFIED","FAILED","VERIFIED_ON_DEVICE","PURCHASES_ERROR_CODE","UNKNOWN_ERROR","PURCHASE_CANCELLED_ERROR","STORE_PROBLEM_ERROR","PURCHASE_NOT_ALLOWED_ERROR","PURCHASE_INVALID_ERROR","PRODUCT_NOT_AVAILABLE_FOR_PURCHASE_ERROR","PRODUCT_ALREADY_PURCHASED_ERROR","RECEIPT_ALREADY_IN_USE_ERROR","INVALID_RECEIPT_ERROR","MISSING_RECEIPT_FILE_ERROR","NETWORK_ERROR","INVALID_CREDENTIALS_ERROR","UNEXPECTED_BACKEND_RESPONSE_ERROR","RECEIPT_IN_USE_BY_OTHER_SUBSCRIBER_ERROR","INVALID_APP_USER_ID_ERROR","OPERATION_ALREADY_IN_PROGRESS_ERROR","UNKNOWN_BACKEND_ERROR","INVALID_APPLE_SUBSCRIPTION_KEY_ERROR","INELIGIBLE_ERROR","INSUFFICIENT_PERMISSIONS_ERROR","PAYMENT_PENDING_ERROR","INVALID_SUBSCRIBER_ATTRIBUTES_ERROR","LOG_OUT_ANONYMOUS_USER_ERROR","CONFIGURATION_ERROR","UNSUPPORTED_ERROR","EMPTY_SUBSCRIBER_ATTRIBUTES_ERROR","CUSTOMER_INFO_ERROR","UninitializedPurchasesError","Error","constructor","message","name","UnsupportedPlatformError"],"sourceRoot":"../../src","sources":["types.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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AACA;AACA;AACA;;AAOA;;AAMA;;AAEA;AACA;AACA;AACA;AACA;;AAUA;;AAOA;;AAEA;;AAgCA;;AAEA;AACA;AACA;AACA;AACA;AAJAzD,OAAA,CAAA0D,wBAAA,GAAAA,wBAAA","ignoreList":[]}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ // packages/react-native-sdk/src/attribution.ts
4
+ //
5
+ // Wave 2 — unified Attribution JS surface. Mirror of
6
+ // `SwissKnife.Attribution` (iOS, Swift) and
7
+ // `com.appswissknife.attribution.Attribution` (Android, Kotlin). All
8
+ // logic lives natively — this module is a thin passthrough.
9
+ //
10
+ // Why JS doesn't keep its own state
11
+ // ---------------------------------
12
+ // Same rationale as Identity: native is the single source of truth for
13
+ // the resolved attribution. JS reads via `resolved()` (cached snapshot
14
+ // from the native disk-backed cache) and writes via
15
+ // `requestAndRegister()` or `registerInstall(...)`. Idempotency lives
16
+ // natively — a second JS call to `registerInstall(...)` returns the
17
+ // cached value from the native cache without a second POST.
18
+ //
19
+ // ATT prompt orchestration is iOS-only and happens natively. JS callers
20
+ // just await `requestAndRegister()` — the native side handles
21
+ // `ATTrackingManager` (iOS) or the no-op Android path.
22
+
23
+ import { getNativeModule } from "./native/module.js";
24
+ export const Attribution = {
25
+ /**
26
+ * The most recent resolved attribution from the native disk-backed
27
+ * cache. Returns `null` when no install POST has succeeded yet.
28
+ * Cheap — does not hit the network.
29
+ */
30
+ async resolved() {
31
+ return getNativeModule().attributionResolved();
32
+ },
33
+ /**
34
+ * Auto-collect (ATT prompt + IDFA on iOS; advertising_id +
35
+ * install_referrer on Android) and POST `/api/sdk/attribution/install`.
36
+ * Idempotent — second call returns the cached resolution WITHOUT
37
+ * re-prompting or re-POSTing.
38
+ */
39
+ async requestAndRegister() {
40
+ return getNativeModule().attributionRequestAndRegister();
41
+ },
42
+ /**
43
+ * Manual install registration for hosts that prompt for tracking
44
+ * consent themselves or collect the advertising id outside the SDK.
45
+ * Pass `null` when consent was denied. Idempotent.
46
+ */
47
+ async registerInstall(advertisingId) {
48
+ return getNativeModule().attributionRegisterInstall(advertisingId ?? null);
49
+ }
50
+ };
51
+ //# sourceMappingURL=attribution.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getNativeModule","Attribution","resolved","attributionResolved","requestAndRegister","attributionRequestAndRegister","registerInstall","advertisingId","attributionRegisterInstall"],"sourceRoot":"../../src","sources":["attribution.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,eAAe,QAAQ,oBAAiB;AAGjD,OAAO,MAAMC,WAAW,GAAG;EACzB;AACF;AACA;AACA;AACA;EACE,MAAMC,QAAQA,CAAA,EAAwC;IACpD,OAAOF,eAAe,CAAC,CAAC,CAACG,mBAAmB,CAAC,CAAC;EAChD,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;EACE,MAAMC,kBAAkBA,CAAA,EAAwC;IAC9D,OAAOJ,eAAe,CAAC,CAAC,CAACK,6BAA6B,CAAC,CAAC;EAC1D,CAAC;EAED;AACF;AACA;AACA;AACA;EACE,MAAMC,eAAeA,CACnBC,aAA6B,EACQ;IACrC,OAAOP,eAAe,CAAC,CAAC,CAACQ,0BAA0B,CAACD,aAAa,IAAI,IAAI,CAAC;EAC5E;AACF,CAAC","ignoreList":[]}
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+
3
+ // packages/react-native-sdk/src/identity.ts
4
+ //
5
+ // Wave 1 — unified `Identity` JS surface. Mirror of `SwissKnife.Identity`
6
+ // on iOS (Swift) and `com.appswissknife.identity.Identity` on Android
7
+ // (Kotlin). All logic lives natively — this module is a thin
8
+ // passthrough.
9
+ //
10
+ // Why JS doesn't keep its own state
11
+ // ---------------------------------
12
+ // Before Wave 1, `modules/analytics.ts` kept a JS-local `_userId` that
13
+ // drifted from the native state. After `Purchases.logIn("u_42")`, an
14
+ // immediate `Analytics.track(...)` emitted with `user_id: ""` because
15
+ // the JS module never heard about the new user id. The fix is to make
16
+ // native the single source of truth and have JS derive `user_id` from
17
+ // the native `Identity.current()` snapshot at event-build time. See
18
+ // `modules/analytics.ts` for that derivation.
19
+ //
20
+ // Observers
21
+ // ---------
22
+ // Native does NOT currently emit identity-change events over a
23
+ // `NativeEventEmitter` channel (would require another bridge plumbing
24
+ // pass). For now JS-side observers fire on the next `logIn` / `logOut`
25
+ // / `reset` / `wipe` call that originates from JS — they are NOT
26
+ // notified about identity changes triggered natively (e.g. silent push
27
+ // rebinding). When we need that, add a `Purchases-IdentityChanged`
28
+ // event to the native event emitter and subscribe here.
29
+
30
+ import { getNativeModule } from "./native/module.js";
31
+ const observers = new Map();
32
+ let lastSnapshot = null;
33
+ function generateToken() {
34
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, c => {
35
+ const r = Math.random() * 16 | 0;
36
+ const v = c === "x" ? r : r & 0x3 | 0x8;
37
+ return v.toString(16);
38
+ });
39
+ }
40
+ async function snapshotAndNotify(reason) {
41
+ const previous = lastSnapshot;
42
+ const current = await getNativeModule().identityCurrent();
43
+ lastSnapshot = current;
44
+ if (previous && observers.size > 0) {
45
+ const change = {
46
+ previous,
47
+ current
48
+ };
49
+ // Fire observers off the awaited stack so a slow observer doesn't
50
+ // delay the caller's promise resolution.
51
+ void Promise.resolve().then(() => {
52
+ for (const observer of observers.values()) {
53
+ try {
54
+ observer(change);
55
+ } catch (e) {
56
+ console.warn(`[SwissKnife Identity] observer threw during ${reason}:`, e);
57
+ }
58
+ }
59
+ });
60
+ }
61
+ return current;
62
+ }
63
+ export const Identity = {
64
+ /**
65
+ * Latest known identity snapshot. The first call hits the bridge;
66
+ * subsequent calls return the cached value updated by
67
+ * `logIn` / `logOut` / `reset` / `wipe`. Returns `null` only before
68
+ * the bridge has resolved.
69
+ */
70
+ async current() {
71
+ const current = await getNativeModule().identityCurrent();
72
+ lastSnapshot = current;
73
+ return current;
74
+ },
75
+ /**
76
+ * Identify this device as a known user. Native posts the
77
+ * `(anonymous_id, user_id)` pair to `/api/sdk/users/identify` (the
78
+ * Wave 1 bug-fix; pre-Wave-1 Android did NOT post). Resolves once
79
+ * the backend ack + post-identify entitlements refresh complete.
80
+ */
81
+ async logIn(userId) {
82
+ const result = await getNativeModule().identityLogIn(userId);
83
+ await snapshotAndNotify("logIn");
84
+ return result;
85
+ },
86
+ /** Revert to anonymous. DeviceID stays stable across logout. */
87
+ async logOut() {
88
+ await getNativeModule().identityLogOut();
89
+ await snapshotAndNotify("logOut");
90
+ },
91
+ /**
92
+ * Rotate in-memory state but keep persistent storage. Matches the
93
+ * "switch test user" UX semantic.
94
+ */
95
+ async reset() {
96
+ await getNativeModule().identityReset();
97
+ await snapshotAndNotify("reset");
98
+ },
99
+ /**
100
+ * Hard wipe: clear Keychain (iOS) / EncryptedSharedPreferences
101
+ * (Android) DeviceID. GDPR-delete / test-build cleanup.
102
+ */
103
+ async wipe() {
104
+ await getNativeModule().identityWipe();
105
+ await snapshotAndNotify("wipe");
106
+ },
107
+ /** Subscribe to identity changes. Returns an unsubscribe token. */
108
+ addObserver(block) {
109
+ const token = generateToken();
110
+ observers.set(token, block);
111
+ return token;
112
+ },
113
+ removeObserver(token) {
114
+ observers.delete(token);
115
+ },
116
+ /** @internal Test seam — reset the cached snapshot + observers. */
117
+ __resetForTests() {
118
+ lastSnapshot = null;
119
+ observers.clear();
120
+ }
121
+ };
122
+ //# sourceMappingURL=identity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getNativeModule","observers","Map","lastSnapshot","generateToken","replace","c","r","Math","random","v","toString","snapshotAndNotify","reason","previous","current","identityCurrent","size","change","Promise","resolve","then","observer","values","e","console","warn","Identity","logIn","userId","result","identityLogIn","logOut","identityLogOut","reset","identityReset","wipe","identityWipe","addObserver","block","token","set","removeObserver","delete","__resetForTests","clear"],"sourceRoot":"../../src","sources":["identity.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA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EAAS;IACtBzC,YAAY,GAAG,IAAI;IACnBF,SAAS,CAAC4C,KAAK,CAAC,CAAC;EACnB;AACF,CAAC","ignoreList":[]}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ // src/index.ts
4
+ import Purchases from "./purchases.js";
5
+
6
+ // Default export mirrors react-native-purchases: `import Purchases from '...'`.
7
+ export default Purchases;
8
+
9
+ // Named export of the class for `import { Purchases } from '...'`.
10
+ export { Purchases };
11
+
12
+ // Public type/enum/error surface (CustomerInfo, PurchasesOfferings,
13
+ // PURCHASES_ERROR_CODE, LOG_LEVEL, the enums, PurchasesError, etc.) —
14
+ // defined in ./types (Phase 7: own definitions, no RC dependency).
15
+ export * from "./types.js";
16
+
17
+ // Wave 1 — unified Identity surface. Routes through native
18
+ // `SwissKnife.Identity` (iOS) / `com.appswissknife.identity.Identity`
19
+ // (Android). Decoupled from analytics: `Identity.logIn(...)` does NOT
20
+ // auto-emit a `$identify` event; call `Analytics.identify(...)`
21
+ // separately if you want retro-tagging.
22
+ export { Identity } from "./identity.js";
23
+ // Wave 2 — Attribution. Routes through native
24
+ // `SwissKnife.Attribution` (iOS) / `com.appswissknife.attribution.Attribution`
25
+ // (Android). Native owns the ATT prompt orchestration, IDFA /
26
+ // AdvertisingId / InstallReferrer collection, and the disk-backed
27
+ // idempotency cache.
28
+ export { Attribution } from "./attribution.js";
29
+ // Companion observability modules. These are used by the maestro-app E2E
30
+ // harness and any consumer that wants analytics / crash-reporting /
31
+ // performance alongside subscriptions. The Purchases surface is the SDK's
32
+ // primary product; these are additive.
33
+ export { Analytics, SKIdentify, SKRevenue } from "./modules/analytics.js";
34
+ export { CrashReporting, SKErrorBoundary, parseStackTrace } from "./modules/crash-reporting.js";
35
+ export { Performance } from "./modules/performance.js";
36
+ //# sourceMappingURL=index.js.map