@app-swiss-knife/react-native-sdk 0.2.5 → 0.3.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 (69) hide show
  1. package/README.md +100 -47
  2. package/SwissKnifePurchases.podspec +8 -5
  3. package/android/src/main/java/com/swissknife/purchases/SwissKnifePurchasesModule.kt +18 -1
  4. package/android/vendor/java/com/appswissknife/context/DeviceContext.kt +1 -1
  5. package/android/vendor/java/com/appswissknife/net/IngestClient.kt +1 -1
  6. package/android/vendor/java/com/appswissknife/purchases/BillingClientGateway.kt +53 -9
  7. package/ios/SwissKnifeCrashReporting.swift +59 -18
  8. package/ios/SwissKnifePurchases.swift +16 -1
  9. package/ios/vendor/SwissKnifeiOS/Context/DeviceContext.swift +1 -1
  10. package/ios/vendor/SwissKnifeiOS/Context/Reachability.swift +1 -1
  11. package/ios/vendor/SwissKnifeiOS/CrashReporting/SKCrashReporting.swift +24 -0
  12. package/ios/vendor/SwissKnifeiOS/DeviceID.swift +22 -1
  13. package/ios/vendor/SwissKnifeiOS/Identity/Identity.swift +49 -0
  14. package/ios/vendor/SwissKnifeiOS/Net/IngestClient.swift +14 -0
  15. package/lib/commonjs/attributes.js +103 -0
  16. package/lib/commonjs/attributes.js.map +1 -0
  17. package/lib/commonjs/index.js +31 -2
  18. package/lib/commonjs/index.js.map +1 -1
  19. package/lib/commonjs/internal/config.js +237 -0
  20. package/lib/commonjs/internal/config.js.map +1 -0
  21. package/lib/commonjs/purchases.js +324 -218
  22. package/lib/commonjs/purchases.js.map +1 -1
  23. package/lib/commonjs/swiss-knife.js +115 -0
  24. package/lib/commonjs/swiss-knife.js.map +1 -0
  25. package/lib/commonjs/types.js +11 -0
  26. package/lib/commonjs/types.js.map +1 -1
  27. package/lib/module/attributes.js +100 -0
  28. package/lib/module/attributes.js.map +1 -0
  29. package/lib/module/index.js +19 -2
  30. package/lib/module/index.js.map +1 -1
  31. package/lib/module/internal/config.js +225 -0
  32. package/lib/module/internal/config.js.map +1 -0
  33. package/lib/module/purchases.js +309 -212
  34. package/lib/module/purchases.js.map +1 -1
  35. package/lib/module/swiss-knife.js +112 -0
  36. package/lib/module/swiss-knife.js.map +1 -0
  37. package/lib/module/types.js +11 -0
  38. package/lib/module/types.js.map +1 -1
  39. package/lib/typescript/commonjs/attributes.d.ts +41 -0
  40. package/lib/typescript/commonjs/attributes.d.ts.map +1 -0
  41. package/lib/typescript/commonjs/index.d.ts +2 -0
  42. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  43. package/lib/typescript/commonjs/internal/config.d.ts +121 -0
  44. package/lib/typescript/commonjs/internal/config.d.ts.map +1 -0
  45. package/lib/typescript/commonjs/purchases.d.ts +103 -95
  46. package/lib/typescript/commonjs/purchases.d.ts.map +1 -1
  47. package/lib/typescript/commonjs/swiss-knife.d.ts +56 -0
  48. package/lib/typescript/commonjs/swiss-knife.d.ts.map +1 -0
  49. package/lib/typescript/commonjs/types.d.ts +13 -0
  50. package/lib/typescript/commonjs/types.d.ts.map +1 -1
  51. package/lib/typescript/module/attributes.d.ts +41 -0
  52. package/lib/typescript/module/attributes.d.ts.map +1 -0
  53. package/lib/typescript/module/index.d.ts +2 -0
  54. package/lib/typescript/module/index.d.ts.map +1 -1
  55. package/lib/typescript/module/internal/config.d.ts +121 -0
  56. package/lib/typescript/module/internal/config.d.ts.map +1 -0
  57. package/lib/typescript/module/purchases.d.ts +103 -95
  58. package/lib/typescript/module/purchases.d.ts.map +1 -1
  59. package/lib/typescript/module/swiss-knife.d.ts +56 -0
  60. package/lib/typescript/module/swiss-knife.d.ts.map +1 -0
  61. package/lib/typescript/module/types.d.ts +13 -0
  62. package/lib/typescript/module/types.d.ts.map +1 -1
  63. package/package.json +1 -1
  64. package/src/attributes.ts +97 -0
  65. package/src/index.ts +19 -2
  66. package/src/internal/config.ts +233 -0
  67. package/src/purchases.ts +320 -228
  68. package/src/swiss-knife.ts +134 -0
  69. package/src/types.ts +14 -0
@@ -1 +1 @@
1
- {"version":3,"names":["_module","require","_spec","_types","configured","configuredApiKey","coreConfigured","nativeBoolean","read","Promise","resolve","getNativeModule","catch","customerInfoSubscriptions","Map","throwIfNotConfigured","UninitializedPurchasesError","throwIfCoreNotConfigured","native","isCoreConfigured","Purchases","configure","options","apiKey","nativeOptions","appUserID","proxyURL","diagnosticsEnabled","storeKitVersion","useAmazon","autoPromptATT","sendInstallOnFirstLaunch","logLevel","configureCore","isConfigured","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;;AAqBA,IAAIG,UAAU,GAAG,KAAK;AACtB,IAAIC,gBAA+B,GAAG,IAAI;AAC1C,IAAIC,cAAc,GAAG,KAAK;;AAE1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,aAAaA,CACpBC,IAAmE,EACjD;EAClB,IAAI;IACF,OAAOC,OAAO,CAACC,OAAO,CAACF,IAAI,CAAC,IAAAG,uBAAe,EAAC,CAAC,CAAC,CAAC,CAACC,KAAK,CAAC,MAAM,KAAK,CAAC;EACpE,CAAC,CAAC,MAAM;IACN,OAAOH,OAAO,CAACC,OAAO,CAAC,KAAK,CAAC;EAC/B;AACF;;AAEA;AACA,MAAMG,yBAAyB,GAAG,IAAIC,GAAG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A6BA,CAClCC,QAAoC,EAC9B;IACN,MAAMC,GAAG,GAAG,IAAAC,uBAAe,EAAC,CAAC,CAACC,WAAW,CACvCC,iCAA2B,EAC1BC,KAAK,IAAKL,QAAQ,CAACK,KAAkD,CACxE,CAAC;IACDvD,yBAAyB,CAACwD,GAAG,CAACN,QAAQ,EAAEC,GAAG,CAAC;EAC9C;;EAEA;EACA,OAAOM,gCAAgCA,CACrCP,QAAoC,EAC9B;IACN,MAAMC,GAAG,GAAGnD,yBAAyB,CAAC0D,GAAG,CAACR,QAAQ,CAAC;IACnD,IAAIC,GAAG,EAAE;MACPA,GAAG,CAACQ,MAAM,CAAC,CAAC;MACZ3D,yBAAyB,CAAC4D,MAAM,CAACV,QAAQ,CAAC;IAC5C;EACF;;EAEA;EACA,OAAOW,eAAeA,CAAA,EAAS;IAC7BtE,UAAU,GAAG,KAAK;IAClBE,cAAc,GAAG,KAAK;IACtBD,gBAAgB,GAAG,IAAI;IACvBQ,yBAAyB,CAAC8D,KAAK,CAAC,CAAC;EACnC;AACF;;AAEA;AAAAC,OAAA,CAAAxD,SAAA,GAAAA,SAAA;AAAA,IAAAyD,QAAA,GAAAD,OAAA,CAAAE,OAAA,GAMe1D,SAAS","ignoreList":[]}
1
+ {"version":3,"names":["_attributes","require","_identity","_config","_module","_spec","_types","customerInfoSubscriptions","Map","customerInfoAfterLogOut","nativeBoolean","native","isConfigured","getNativeModule","getCustomerInfo","snapshot","Identity","current","emptyCustomerInfo","userId","anonymousId","subjectId","now","Date","entitlements","all","active","verification","VERIFICATION_RESULT","NOT_REQUESTED","activeSubscriptions","allPurchasedProductIdentifiers","allPurchaseDates","subscriptionsByProductIdentifier","nonSubscriptionTransactions","firstSeen","toISOString","firstSeenMillis","getTime","originalAppUserId","requestDate","requestDateMillis","latestExpirationDate","latestExpirationDateMillis","originalPurchaseDate","originalPurchaseDateMillis","originalApplicationVersion","managementURL","Purchases","configure","configureCore","isCoreConfigured","setLogLevel","throwIfNotConfigured","getOfferings","purchasePackage","pkg","offeringId","presentedOfferingContext","offeringIdentifier","identifier","purchaseStoreProduct","product","restorePurchases","logIn","appUserID","throwIfCoreNotConfigured","logOut","getAppUserID","isAnonymous","setAttributes","Attributes","set","setEmail","setDisplayName","setPhoneNumber","setPushToken","addCustomerInfoUpdateListener","listener","sub","getEventEmitter","addListener","CUSTOMER_INFO_UPDATED_EVENT","event","removeCustomerInfoUpdateListener","get","remove","delete","__resetForTests","resetConfigForTests","clear","exports","_default","default"],"sourceRoot":"../../src","sources":["purchases.ts"],"mappings":";;;;;;;;;;;;;;;;;;;AA8CA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAWA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AA7DA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA6BA;AACA,MAAMM,yBAAyB,GAAG,IAAIC,GAAG,CAGvC,CAAC;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAeC,uBAAuBA,CAAA,EAA0B;EAC9D,IAAI,MAAM,IAAAC,qBAAa,EAAEC,MAAM,IAAKA,MAAM,CAACC,YAAY,CAAC,CAAC,CAAC,EAAE;IAC1D,IAAI;MACF,OAAO,MAAM,IAAAC,uBAAe,EAAC,CAAC,CAACC,eAAe,CAAC,CAAC;IAClD,CAAC,CAAC,MAAM;MACN;IAAA;EAEJ;EACA,MAAMC,QAAQ,GAAG,MAAMC,kBAAQ,CAACC,OAAO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A;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,aAAaC,KAAKA,CAACC,SAAiB,EAAwB;IAC1D,MAAM,IAAAC,gCAAwB,EAAC,CAAC;IAChC,OAAOlD,kBAAQ,CAACgD,KAAK,CAACC,SAAS,CAAC;EAClC;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,aAAaE,MAAMA,CAAA,EAA0B;IAC3C,MAAM,IAAAD,gCAAwB,EAAC,CAAC;IAChC,MAAMlD,kBAAQ,CAACmD,MAAM,CAAC,CAAC;IACvB,OAAO1D,uBAAuB,CAAC,CAAC;EAClC;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,aAAa2D,YAAYA,CAAA,EAAoB;IAC3C,MAAM,IAAAF,gCAAwB,EAAC,CAAC;IAChC,MAAMnD,QAAQ,GAAG,MAAMC,kBAAQ,CAACC,OAAO,CAAC,CAAC;IACzC,OAAOF,QAAQ,CAACI,MAAM,IAAIJ,QAAQ,CAACK,WAAW;EAChD;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,aAAaiD,WAAWA,CAAA,EAAqB;IAC3C,MAAM,IAAAH,gCAAwB,EAAC,CAAC;IAChC,OAAO,CAAC,MAAMlD,kBAAQ,CAACC,OAAO,CAAC,CAAC,EAAEoD,WAAW;EAC/C;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;AACF;AACA;AACA;AACA;EACE,OAAOC,aAAa,GAAGC,sBAAU,CAACC,GAAG;;EAErC;EACA,OAAOC,QAAQ,GAAGF,sBAAU,CAACE,QAAQ;;EAErC;EACA,OAAOC,cAAc,GAAGH,sBAAU,CAACG,cAAc;;EAEjD;EACA,OAAOC,cAAc,GAAGJ,sBAAU,CAACI,cAAc;;EAEjD;EACA,OAAOC,YAAY,GAAGL,sBAAU,CAACK,YAAY;;EAE7C;EACA;EACA;EACA;;EAEA;EACA,OAAOC,6BAA6BA,CAClCC,QAAoC,EAC9B;IACN,MAAMC,GAAG,GAAG,IAAAC,uBAAe,EAAC,CAAC,CAACC,WAAW,CACvCC,iCAA2B,EAC1BC,KAAK,IAAKL,QAAQ,CAACK,KAAkD,CACxE,CAAC;IACD5E,yBAAyB,CAACiE,GAAG,CAACM,QAAQ,EAAEC,GAAG,CAAC;EAC9C;;EAEA;EACA,OAAOK,gCAAgCA,CACrCN,QAAoC,EAC9B;IACN,MAAMC,GAAG,GAAGxE,yBAAyB,CAAC8E,GAAG,CAACP,QAAQ,CAAC;IACnD,IAAIC,GAAG,EAAE;MACPA,GAAG,CAACO,MAAM,CAAC,CAAC;MACZ/E,yBAAyB,CAACgF,MAAM,CAACT,QAAQ,CAAC;IAC5C;EACF;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACE,OAAOU,eAAeA,CAAA,EAAS;IAC7B,IAAAC,2BAAmB,EAAC,CAAC;IACrBlF,yBAAyB,CAACmF,KAAK,CAAC,CAAC;IACjC1E,kBAAQ,CAACwE,eAAe,CAAC,CAAC;EAC5B;AACF;;AAEA;AAAAG,OAAA,CAAA3C,SAAA,GAAAA,SAAA;AAAA,IAAA4C,QAAA,GAAAD,OAAA,CAAAE,OAAA,GAMe7C,SAAS","ignoreList":[]}
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.SwissKnife = void 0;
7
+ var _config = require("./internal/config.js");
8
+ var _attributes = require("./attributes.js");
9
+ var _attribution = require("./attribution.js");
10
+ var _identity = require("./identity.js");
11
+ var _purchases = require("./purchases.js");
12
+ var _analytics = require("./modules/analytics.js");
13
+ var _crashReporting = require("./modules/crash-reporting.js");
14
+ var _performance = require("./modules/performance.js");
15
+ // packages/react-native-sdk/src/swiss-knife.ts
16
+ //
17
+ // The SDK root. Mirror of `SwissKnife` on iOS (`SwissKnifeiOS`, a public final
18
+ // class with `configure` / `configureCore` / `isConfigured` /
19
+ // `isCoreConfigured` / `setLogLevel` statics and `SwissKnife.Identity`,
20
+ // `SwissKnife.Attribution` extensions) and of `com.appswissknife.SwissKnife` on
21
+ // Android.
22
+ //
23
+ // ## Why this exists
24
+ //
25
+ // Until now JS had no root at all. Both bootstraps lived on `Purchases`, which
26
+ // made `Purchases.configureCore()` — a call whose entire meaning is "I do not
27
+ // want the store" — read as a contradiction, and left the SDK running two
28
+ // organising principles at once: a god-object for some concerns, peer
29
+ // namespaces (`Identity`, `Attribution`, `Analytics`, `CrashReporting`,
30
+ // `Performance`) for the rest. The native SDKs never had that problem. This
31
+ // closes the gap in the direction of the two that were already right.
32
+ //
33
+ // ## What belongs here, and what does not
34
+ //
35
+ // Bootstrap and process-wide settings: the two `configure` entry points, the
36
+ // two readback flags, and `setLogLevel`. `setLogLevel` earns its place three
37
+ // ways — it is on the native root on both platforms; it is read by every
38
+ // subsystem (store engine, ingest client, Identity, Attribution, the
39
+ // observability modules), so no single namespace owns it; and it is the one
40
+ // member of the old `Purchases` surface with no configure guard at all, which
41
+ // is the tell that it was never a purchase method.
42
+ //
43
+ // The store surface stays on `Purchases` and is reachable as
44
+ // `SwissKnife.Purchases`. Hoisting `getOfferings` / `purchasePackage` /
45
+ // `restorePurchases` / the CustomerInfo listeners onto the root would recreate
46
+ // the junk drawer at a new address. (iOS does put them on its root; iOS has no
47
+ // RC-compatibility object competing for the name, and we do.)
48
+ //
49
+ // The namespace handles below make the root the one thing you have to know:
50
+ // typing `SwissKnife.` lists the entire SDK. They are the same objects the
51
+ // package exports by name — `SwissKnife.Identity === Identity` — not copies.
52
+
53
+ /**
54
+ * The shape of {@link SwissKnife}.
55
+ *
56
+ * Written out rather than inferred because `declaration: true` cannot emit an
57
+ * inferred object type whose members reference types their own module does not
58
+ * export (TS4023) — `CrashReporting`'s internals are the case in point. Every
59
+ * member is a `typeof` query on the thing it re-exports, so this stays a
60
+ * restatement of the wiring and can never disagree with it.
61
+ */
62
+
63
+ /**
64
+ * The Swiss Knife SDK root — bootstrap plus a handle on every namespace.
65
+ *
66
+ * ```ts
67
+ * import { SwissKnife } from "@app-swiss-knife/react-native-sdk";
68
+ *
69
+ * // Full SDK, we own the store:
70
+ * SwissKnife.configure({ apiKey: "sk_live_…", proxyURL: "https://…" });
71
+ *
72
+ * // Another library owns in-app purchases:
73
+ * SwissKnife.configureCore({ apiKey: "sk_live_…", proxyURL: "https://…" });
74
+ *
75
+ * await SwissKnife.Identity.logIn("user_42");
76
+ * await SwissKnife.Attributes.setEmail("ann@example.com");
77
+ * ```
78
+ *
79
+ * `Purchases.configure` / `Purchases.configureCore` are RC-compatibility
80
+ * aliases for the first two and remain fully supported — they are the *same
81
+ * functions*, so an app that mixes the spellings shares one bootstrap state.
82
+ */
83
+ const SwissKnife = exports.SwissKnife = {
84
+ // MARK: - Bootstrap
85
+ configure: _config.configure,
86
+ configureCore: _config.configureCore,
87
+ isConfigured: _config.isConfigured,
88
+ isCoreConfigured: _config.isCoreConfigured,
89
+ setLogLevel: _config.setLogLevel,
90
+ // MARK: - Namespaces
91
+ /** In-app purchases + the RevenueCat-compatible surface. */
92
+ Purchases: _purchases.Purchases,
93
+ /** Who this device is. `logIn` / `logOut` / `current` / `reset` / `wipe`. */
94
+ Identity: _identity.Identity,
95
+ /** Subscriber attributes — the dashboard person card. */
96
+ Attributes: _attributes.Attributes,
97
+ /** Install attribution: ATT / IDFA / advertising id / install referrer. */
98
+ Attribution: _attribution.Attribution,
99
+ /** Product analytics: `init` / `track` / `identify` / `screen`. */
100
+ Analytics: _analytics.Analytics,
101
+ /** Crash + error reporting. */
102
+ CrashReporting: _crashReporting.CrashReporting,
103
+ /** Performance transactions and spans. */
104
+ Performance: _performance.Performance,
105
+ /**
106
+ * @internal Test seam: reset the process-wide configure state and `Identity`'s
107
+ * caches. Identical to `Purchases.__resetForTests()` — it is the same call, so
108
+ * a suite written against either namespace resets the same singletons.
109
+ */
110
+ __resetForTests() {
111
+ _purchases.Purchases.__resetForTests();
112
+ }
113
+ };
114
+ var _default = exports.default = SwissKnife;
115
+ //# sourceMappingURL=swiss-knife.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_config","require","_attributes","_attribution","_identity","_purchases","_analytics","_crashReporting","_performance","SwissKnife","exports","configure","configureCore","isConfigured","isCoreConfigured","setLogLevel","Purchases","Identity","Attributes","Attribution","Analytics","CrashReporting","Performance","__resetForTests","_default","default"],"sourceRoot":"../../src","sources":["swiss-knife.ts"],"mappings":";;;;;;AAsCA,IAAAA,OAAA,GAAAC,OAAA;AAOA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,UAAA,GAAAL,OAAA;AACA,IAAAM,eAAA,GAAAN,OAAA;AACA,IAAAO,YAAA,GAAAP,OAAA;AAnDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAiBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAkBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMQ,UAAyB,GAAAC,OAAA,CAAAD,UAAA,GAAG;EACvC;EACAE,SAAS,EAATA,iBAAS;EACTC,aAAa,EAAbA,qBAAa;EACbC,YAAY,EAAZA,oBAAY;EACZC,gBAAgB,EAAhBA,wBAAgB;EAChBC,WAAW,EAAXA,mBAAW;EAEX;EACA;EACAC,SAAS,EAATA,oBAAS;EACT;EACAC,QAAQ,EAARA,kBAAQ;EACR;EACAC,UAAU,EAAVA,sBAAU;EACV;EACAC,WAAW,EAAXA,wBAAW;EACX;EACAC,SAAS,EAATA,oBAAS;EACT;EACAC,cAAc,EAAdA,8BAAc;EACd;EACAC,WAAW,EAAXA,wBAAW;EAEX;AACF;AACA;AACA;AACA;EACEC,eAAeA,CAAA,EAAS;IACtBP,oBAAS,CAACO,eAAe,CAAC,CAAC;EAC7B;AACF,CAAC;AAAC,IAAAC,QAAA,GAAAd,OAAA,CAAAe,OAAA,GAEahB,UAAU","ignoreList":[]}
@@ -225,6 +225,17 @@ class UnsupportedPlatformError extends Error {
225
225
 
226
226
  /** Options accepted by `Purchases.configure(...)`. Mirror of `PurchasesConfiguration`. */
227
227
 
228
+ /**
229
+ * Options accepted by `SwissKnife.configure(...)` / `SwissKnife.configureCore(...)`
230
+ * — and, identically, by their `Purchases.*` RC-compatibility aliases.
231
+ *
232
+ * A name for what the two bootstrap entry points have always taken:
233
+ * `PurchasesConfiguration & { logLevel?: LOG_LEVEL }`. `logLevel` is not part of
234
+ * RevenueCat's `PurchasesConfiguration`, so it cannot go on that interface
235
+ * without breaking the mirror; it is accepted here because setting the log level
236
+ * *after* configure is too late to debug the configure itself.
237
+ */
238
+
228
239
  // MARK: - Event listeners
229
240
 
230
241
  /**
@@ -1 +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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACO,MAAMA,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAG;EACvBE,OAAO,EAAE,SAAS;EAClBC,KAAK,EAAE,OAAO;EACdC,IAAI,EAAE,MAAM;EACZC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAE;AACT,CAAU;AAGV;AACO,MAAMC,YAAY,GAAAN,OAAA,CAAAM,YAAA,GAAG;EAC1BC,OAAO,EAAE,SAAS;EAClBC,MAA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I;EAC3BC,mCAAmC,EAAE,IAAI;EACzCC,4BAA4B,EAAE,IAAI;EAClCC,mBAAmB,EAAE,IAAI;EACzBC,iBAAiB,EAAE,IAAI;EACvBC,iCAAiC,EAAE,IAAI;EACvCC,mBAAmB,EAAE;AACvB,CAAU;AAIV;;AAEA;AACA;AACA;AACA;AACA;AACO,MAAMC,2BAA2B,SAASC,KAAK,CAAC;EACrDC,WAAWA,CACTC,OAAe,GAAG,gEAAgE,EAClF;IACA,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,6BAA6B;EAC3C;AACF;;AAEA;AACA;AACA;AACA;AAHAzD,OAAA,CAAAqD,2BAAA,GAAAA,2BAAA;AAIO,MAAMK,wBAAwB,SAASJ,KAAK,CAAC;EAClDC,WAAWA,CACTC,OAAe,GAAG,uDAAuD,EACzE;IACA,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,0BAA0B;EACxC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAQA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAiCA;;AAOA;;AAmBA;;AASA;AACA;AACA;AACA;;AA0BA;;AAEA;;AAUA;;AAMA;;AAWA;;AA6BA;AACA;AACA;AACA;;AAOA;;AAUA;;AAiBA;;AAMA;;AAEA;;AAOA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA;;AAMA;;AAEA;AACA;AACA;AACA;AACA;;AAUA;;AAOA;;AAEA;;AAyCA;;AAEA;AACA;AACA;AACA;AACA;AAJAzD,OAAA,CAAA0D,wBAAA,GAAAA,wBAAA","ignoreList":[]}
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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACO,MAAMA,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAG;EACvBE,OAAO,EAAE,SAAS;EAClBC,KAAK,EAAE,OAAO;EACdC,IAAI,EAAE,MAAM;EACZC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAE;AACT,CAAU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,EAAE,IAAI;EAC1CC,gBAAgB,EAAE,IAAI;EACtBC,8BAA8B,EAAE,IAAI;EACpCC,qBAAqB,EAAE,IAAI;EAC3BC,mCAAmC,EAAE,IAAI;EACzCC,4BAA4B,EAAE,IAAI;EAClCC,mBAAmB,EAAE,IAAI;EACzBC,iBAAiB,EAAE,IAAI;EACvBC,iCAAiC,EAAE,IAAI;EACvCC,mBAAmB,EAAE;AACvB,CAAU;AAIV;;AAEA;AACA;AACA;AACA;AACA;AACO,MAAMC,2BAA2B,SAASC,KAAK,CAAC;EACrDC,WAAWA,CACTC,OAAe,GAAG,gEAAgE,EAClF;IACA,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,6BAA6B;EAC3C;AACF;;AAEA;AACA;AACA;AACA;AAHAzD,OAAA,CAAAqD,2BAAA,GAAAA,2BAAA;AAIO,MAAMK,wBAAwB,SAASJ,KAAK,CAAC;EAClDC,WAAWA,CACTC,OAAe,GAAG,uDAAuD,EACzE;IACA,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,0BAA0B;EACxC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAQA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAiCA;;AAOA;;AAmBA;;AASA;AACA;AACA;AACA;;AA0BA;;AAEA;;AAUA;;AAMA;;AAWA;;AA6BA;AACA;AACA;AACA;;AAOA;;AAUA;;AAiBA;;AAMA;;AAEA;;AAOA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA;;AAMA;;AAEA;AACA;AACA;AACA;AACA;;AAUA;;AAOA;;AAEA;;AAyCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA;;AAEA;AACA;AACA;AACA;AACA;AAJAzD,OAAA,CAAA0D,wBAAA,GAAAA,wBAAA","ignoreList":[]}
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+
3
+ // packages/react-native-sdk/src/attributes.ts
4
+ //
5
+ // Subscriber attributes as a peer namespace, alongside `Identity`,
6
+ // `Attribution`, `Analytics`, `CrashReporting` and `Performance`.
7
+ //
8
+ // ## Why this is not on `Purchases`
9
+ //
10
+ // Attributes describe the *person*, not the purchase. They are the only path to
11
+ // `POST /api/sdk/users/attributes` → `app_users.properties`, which is what the
12
+ // dashboard person card renders — and an app with no in-app purchases at all
13
+ // still wants that card filled in. Reaching it through an object named
14
+ // `Purchases` is a false statement about what the call does, and in practice it
15
+ // is the single hardest surface in this SDK to find: "which call fills the
16
+ // person card?" was the question that cost our integrators the most time.
17
+ //
18
+ // It also disagreed with the guard. These five have been gated on
19
+ // `throwIfCoreNotConfigured` — *not* the purchase guard — since the
20
+ // core/purchases split, precisely because a `configureCore` app (another
21
+ // library owns the store) must still be able to set them. A method that works
22
+ // without the store had no business living on the store namespace.
23
+ //
24
+ // ## Method naming
25
+ //
26
+ // `set` rather than `setAttributes`: `Attributes.setAttributes({...})` stutters,
27
+ // and the namespace already says what is being set. The four reserved keys keep
28
+ // their `setX` spelling — `Attributes.setEmail(...)` reads correctly, does not
29
+ // stutter, and matches the native spelling on both platforms
30
+ // (`SwissKnife.setEmail` on iOS, the `setEmail` bridge method on Android), so
31
+ // there is one name to learn across all three SDKs. Dropping the prefix
32
+ // (`Attributes.email(...)`) would read as a getter.
33
+ //
34
+ // The RC-compatible spellings on `Purchases` are the *same function objects* as
35
+ // these — see `src/internal/config.ts` for why that matters and
36
+ // `src/namespaces.test.ts` for the assertion.
37
+
38
+ import { getNativeModule } from "./native/module.js";
39
+ import { throwIfCoreNotConfigured } from "./internal/config.js";
40
+
41
+ /**
42
+ * Set arbitrary subscriber attributes. `null` clears an attribute.
43
+ *
44
+ * Works after `SwissKnife.configure`, `SwissKnife.configureCore`, or
45
+ * `Analytics.init` — the store does not have to be ours, and does not have to
46
+ * exist.
47
+ */
48
+ async function set(attributes) {
49
+ await throwIfCoreNotConfigured();
50
+ return getNativeModule().setAttributes(attributes);
51
+ }
52
+
53
+ /** Reserved attribute: email. `null` clears it. */
54
+ async function setEmail(email) {
55
+ await throwIfCoreNotConfigured();
56
+ return getNativeModule().setEmail(email);
57
+ }
58
+
59
+ /** Reserved attribute: display name. `null` clears it. */
60
+ async function setDisplayName(displayName) {
61
+ await throwIfCoreNotConfigured();
62
+ return getNativeModule().setDisplayName(displayName);
63
+ }
64
+
65
+ /** Reserved attribute: phone number. `null` clears it. */
66
+ async function setPhoneNumber(phoneNumber) {
67
+ await throwIfCoreNotConfigured();
68
+ return getNativeModule().setPhoneNumber(phoneNumber);
69
+ }
70
+
71
+ /** Reserved attribute: push token. `null` clears it. */
72
+ async function setPushToken(pushToken) {
73
+ await throwIfCoreNotConfigured();
74
+ return getNativeModule().setPushToken(pushToken);
75
+ }
76
+
77
+ /**
78
+ * Subscriber attributes — the data behind the dashboard person card.
79
+ *
80
+ * ```ts
81
+ * import { Attributes } from "@app-swiss-knife/react-native-sdk";
82
+ *
83
+ * await Attributes.setEmail("ann@example.com");
84
+ * await Attributes.setDisplayName("Ann");
85
+ * await Attributes.set({ plan: "gold", cohort: "2026-08" });
86
+ * await Attributes.set({ cohort: null }); // clear
87
+ * ```
88
+ *
89
+ * Every method requires core to be configured and rejects with
90
+ * `UninitializedPurchasesError` otherwise. None of them touch StoreKit or Play
91
+ * Billing.
92
+ */
93
+ export const Attributes = {
94
+ set,
95
+ setEmail,
96
+ setDisplayName,
97
+ setPhoneNumber,
98
+ setPushToken
99
+ };
100
+ //# sourceMappingURL=attributes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getNativeModule","throwIfCoreNotConfigured","set","attributes","setAttributes","setEmail","email","setDisplayName","displayName","setPhoneNumber","phoneNumber","setPushToken","pushToken","Attributes"],"sourceRoot":"../../src","sources":["attributes.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,eAAe,QAAQ,oBAAiB;AACjD,SAASC,wBAAwB,QAAQ,sBAAmB;;AAE5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAeC,GAAGA,CAACC,UAAyC,EAAiB;EAC3E,MAAMF,wBAAwB,CAAC,CAAC;EAChC,OAAOD,eAAe,CAAC,CAAC,CAACI,aAAa,CAACD,UAAU,CAAC;AACpD;;AAEA;AACA,eAAeE,QAAQA,CAACC,KAAoB,EAAiB;EAC3D,MAAML,wBAAwB,CAAC,CAAC;EAChC,OAAOD,eAAe,CAAC,CAAC,CAACK,QAAQ,CAACC,KAAK,CAAC;AAC1C;;AAEA;AACA,eAAeC,cAAcA,CAACC,WAA0B,EAAiB;EACvE,MAAMP,wBAAwB,CAAC,CAAC;EAChC,OAAOD,eAAe,CAAC,CAAC,CAACO,cAAc,CAACC,WAAW,CAAC;AACtD;;AAEA;AACA,eAAeC,cAAcA,CAACC,WAA0B,EAAiB;EACvE,MAAMT,wBAAwB,CAAC,CAAC;EAChC,OAAOD,eAAe,CAAC,CAAC,CAACS,cAAc,CAACC,WAAW,CAAC;AACtD;;AAEA;AACA,eAAeC,YAAYA,CAACC,SAAwB,EAAiB;EACnE,MAAMX,wBAAwB,CAAC,CAAC;EAChC,OAAOD,eAAe,CAAC,CAAC,CAACW,YAAY,CAACC,SAAS,CAAC;AAClD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,UAAU,GAAG;EACxBX,GAAG;EACHG,QAAQ;EACRE,cAAc;EACdE,cAAc;EACdE;AACF,CAAC","ignoreList":[]}
@@ -9,9 +9,26 @@ export default Purchases;
9
9
  // Named export of the class for `import { Purchases } from '...'`.
10
10
  export { Purchases };
11
11
 
12
+ // The SDK root — bootstrap (`configure`, `configureCore`, `isConfigured`,
13
+ // `isCoreConfigured`, `setLogLevel`) plus a handle on every namespace, so
14
+ // `SwissKnife.` lists the whole SDK. Mirrors the native SDKs, which have rooted
15
+ // everything under `SwissKnife` (iOS) / `com.appswissknife.SwissKnife`
16
+ // (Android) all along; JS had no root at all until now.
17
+ //
18
+ // `Purchases.configure` and friends remain — they are the SAME functions, not
19
+ // wrappers, so mixing the spellings shares one bootstrap state.
20
+ export { SwissKnife } from "./swiss-knife.js";
21
+
22
+ // Subscriber attributes as a peer namespace. This is the surface behind the
23
+ // dashboard person card (`POST /api/sdk/users/attributes`), and it needs only
24
+ // core — an app with no in-app purchases still wants it. The RC-compatible
25
+ // `Purchases.setAttributes` / `setEmail` / … aliases are the same functions.
26
+ export { Attributes } from "./attributes.js";
27
+
12
28
  // 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).
29
+ // PURCHASES_ERROR_CODE, LOG_LEVEL, ConfigureOptions, the enums,
30
+ // PurchasesError, etc.) — defined in ./types (Phase 7: own definitions, no RC
31
+ // dependency).
15
32
  export * from "./types.js";
16
33
 
17
34
  // Wave 1 — unified Identity surface. Routes through native
@@ -1 +1 @@
1
- {"version":3,"names":["Purchases","Identity","Attribution","Analytics","SKIdentify","SKRevenue","CrashReporting","SKErrorBoundary","parseStackTrace","Performance"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA;AACA,OAAOA,SAAS,MAAM,gBAAa;;AAEnC;AACA,eAAeA,SAAS;;AAExB;AACA,SAASA,SAAS;;AAElB;AACA;AACA;AACA,cAAc,YAAS;;AAEvB;AACA;AACA;AACA;AACA;AACA,SAASC,QAAQ,QAAQ,eAAY;AAGrC;AACA;AACA;AACA;AACA;AACA,SAASC,WAAW,QAAQ,kBAAe;AAG3C;AACA;AACA;AACA;AACA,SAASC,SAAS,EAAEC,UAAU,EAAEC,SAAS,QAAQ,wBAAqB;AAEtE,SACEC,cAAc,EACdC,eAAe,EACfC,eAAe,QACV,8BAA2B;AAOlC,SAASC,WAAW,QAAQ,0BAAuB","ignoreList":[]}
1
+ {"version":3,"names":["Purchases","SwissKnife","Attributes","Identity","Attribution","Analytics","SKIdentify","SKRevenue","CrashReporting","SKErrorBoundary","parseStackTrace","Performance"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA;AACA,OAAOA,SAAS,MAAM,gBAAa;;AAEnC;AACA,eAAeA,SAAS;;AAExB;AACA,SAASA,SAAS;;AAElB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,UAAU,QAAQ,kBAAe;;AAE1C;AACA;AACA;AACA;AACA,SAASC,UAAU,QAAQ,iBAAc;;AAEzC;AACA;AACA;AACA;AACA,cAAc,YAAS;;AAEvB;AACA;AACA;AACA;AACA;AACA,SAASC,QAAQ,QAAQ,eAAY;AAGrC;AACA;AACA;AACA;AACA;AACA,SAASC,WAAW,QAAQ,kBAAe;AAG3C;AACA;AACA;AACA;AACA,SAASC,SAAS,EAAEC,UAAU,EAAEC,SAAS,QAAQ,wBAAqB;AAEtE,SACEC,cAAc,EACdC,eAAe,EACfC,eAAe,QACV,8BAA2B;AAOlC,SAASC,WAAW,QAAQ,0BAAuB","ignoreList":[]}
@@ -0,0 +1,225 @@
1
+ "use strict";
2
+
3
+ // src/internal/config.ts
4
+ //
5
+ // The SDK's bootstrap: the process-wide "have we been configured?" state, the
6
+ // two configure entry points, the two readback flags, the log level, and the
7
+ // guards every public surface is gated on.
8
+ //
9
+ // ## Why this is a module of its own rather than statics on a namespace
10
+ //
11
+ // `SwissKnife.configure(...)` and `Purchases.configure(...)` are one call under
12
+ // two names. If each namespace owned its own copy of `configured` /
13
+ // `coreConfigured`, an app that bootstrapped through one name and then used a
14
+ // surface guarded by the other would be told it had never configured anything —
15
+ // precisely the class of bug a namespace split invites. There is exactly one
16
+ // implementation here, and every public namespace exports a *reference to it*.
17
+ // That makes `SwissKnife.configure === Purchases.configure` literally true (and
18
+ // `Attributes.set === Purchases.setAttributes`, and so on), so the compatibility
19
+ // aliases cannot drift from the canonical methods by construction rather than by
20
+ // diligence. Pinned in `src/namespaces.test.ts`.
21
+ //
22
+ // Nothing in here is part of the published API. It is reachable via the
23
+ // package's `./*` subpath export, as every file under `src/` is; the `internal/`
24
+ // segment is the signal not to.
25
+
26
+ import { getNativeModule } from "../native/module.js";
27
+ import { UninitializedPurchasesError } from "../types.js";
28
+ let configured = false;
29
+ let configuredApiKey = null;
30
+ let coreConfigured = false;
31
+
32
+ /**
33
+ * Read a boolean off the native module without ever letting a missing native
34
+ * module escape as an exception.
35
+ *
36
+ * `getNativeModule()` THROWS when the module is not linked (Expo Go, a bare RN
37
+ * app that skipped `pod install` / a Gradle sync, web) — precisely the state a
38
+ * developer is in while wiring the SDK up, and precisely when they are most
39
+ * likely to be calling one of these accessors to find out what is wrong. A
40
+ * boolean accessor rejecting with "native module is not linked" is a worse
41
+ * answer than `false`: an unlinked module cannot have configured anything, so
42
+ * `false` is not merely safe, it is correct.
43
+ *
44
+ * The `.catch` covers the adjacent case where the module IS linked but predates
45
+ * the method (JS upgraded without rebuilding the app) — same reasoning, same
46
+ * answer. Mirrors the tolerance `Analytics.init` already applies to
47
+ * `configureObservability`.
48
+ */
49
+ export function nativeBoolean(read) {
50
+ try {
51
+ return Promise.resolve(read(getNativeModule())).catch(() => false);
52
+ } catch {
53
+ return Promise.resolve(false);
54
+ }
55
+ }
56
+
57
+ /**
58
+ * Configure the SDK. Must be called before any other method. Calling again
59
+ * with the same API key is a no-op (matches the common "configure once" guard);
60
+ * the native layer owns full reconfiguration.
61
+ */
62
+ export function configure(options) {
63
+ if (configured && configuredApiKey === options.apiKey) return;
64
+ const native = getNativeModule();
65
+ const nativeOptions = {
66
+ apiKey: options.apiKey,
67
+ appUserID: options.appUserID ?? null,
68
+ // proxyURL points the native SDK at the Swiss Knife backend. Without it the
69
+ // native layer falls back to its hardcoded default host (api.swiss-knife.dev),
70
+ // which is unreachable for self-hosted tenants. Forward it so callers can
71
+ // target their own backend (e.g. https://swiss.remneys.com).
72
+ proxyURL: options.proxyURL ?? null,
73
+ // Hardening pass (spec): diagnostics opt-in only — default OFF.
74
+ diagnosticsEnabled: options.diagnosticsEnabled ?? false,
75
+ storeKitVersion: options.storeKitVersion,
76
+ useAmazon: options.useAmazon,
77
+ // iOS ATT — default off (no tracking prompt) unless the host opts in.
78
+ autoPromptATT: options.autoPromptATT,
79
+ sendInstallOnFirstLaunch: options.sendInstallOnFirstLaunch,
80
+ logLevel: options.logLevel
81
+ };
82
+ // Fire-and-forget: native configure resolves async but RC's configure is sync.
83
+ void native.configure(nativeOptions);
84
+ configured = true;
85
+ coreConfigured = true;
86
+ configuredApiKey = options.apiKey;
87
+ }
88
+
89
+ /**
90
+ * Configure everything EXCEPT the store: ingest, `Identity`, `Attribution`,
91
+ * `Attributes`.
92
+ *
93
+ * Use this when another library already owns in-app purchases. `configure`
94
+ * starts a `StoreKit.Transaction.updates` observer on iOS (whose handler
95
+ * calls `transaction.finish()`) and builds a `BillingClient` on Android —
96
+ * both of which contend with an incumbent IAP SDK. `configureCore` creates
97
+ * neither, and registers no install as a side effect.
98
+ *
99
+ * Analytics-only apps don't even need this: `Analytics.init(...)` already
100
+ * wires core natively. Reach for `configureCore` when you want to pass an
101
+ * `appUserID`, an attribution configuration, or a log level up front.
102
+ */
103
+ export function configureCore(options) {
104
+ if (coreConfigured && configuredApiKey === options.apiKey) return;
105
+ const native = getNativeModule();
106
+ const nativeOptions = {
107
+ apiKey: options.apiKey,
108
+ appUserID: options.appUserID ?? null,
109
+ proxyURL: options.proxyURL ?? null,
110
+ diagnosticsEnabled: options.diagnosticsEnabled ?? false,
111
+ autoPromptATT: options.autoPromptATT,
112
+ // Forwarded but inert on this path — core never auto-registers an
113
+ // install. Kept on the payload so the same options object can be handed
114
+ // to `configure` later without surprises.
115
+ sendInstallOnFirstLaunch: options.sendInstallOnFirstLaunch,
116
+ logLevel: options.logLevel
117
+ };
118
+ void native.configureCore(nativeOptions);
119
+ coreConfigured = true;
120
+ configuredApiKey = options.apiKey;
121
+ }
122
+
123
+ /**
124
+ * Whether the PURCHASE engine has been configured — i.e. whether the store
125
+ * APIs (`getOfferings`, `purchasePackage`, `restorePurchases`, …) can work.
126
+ *
127
+ * **Native is the source of truth.** This does not consult the JS-side
128
+ * "configure was called" flag: a brownfield app can configure the SDK from
129
+ * native code, and `configure` itself is fire-and-forget, so the JS flag is a
130
+ * request, not a fact.
131
+ *
132
+ * Never throws and never rejects. Resolves `false` when the native module is
133
+ * not linked — see {@link nativeBoolean}. Exactly the same failure semantics
134
+ * as {@link isCoreConfigured}; the two differ only in which native flag they
135
+ * report.
136
+ */
137
+ export function isConfigured() {
138
+ return nativeBoolean(native => native.isConfigured());
139
+ }
140
+
141
+ /**
142
+ * Whether the CORE (ingest / Identity / Attribution / Attributes) is
143
+ * configured. True after `configure`, `configureCore`, or `Analytics.init`.
144
+ *
145
+ * **Native is the source of truth**, and here that is load-bearing rather
146
+ * than merely principled: `Analytics.init` wires core natively via
147
+ * `configureObservability` and touches no JS configure flag, so an
148
+ * analytics-only app has core configured while every JS flag reads false.
149
+ * Short-circuiting on JS state would report `false` in the single most
150
+ * common core-only integration.
151
+ *
152
+ * Never throws and never rejects. Resolves `false` when the native module is
153
+ * not linked — see {@link nativeBoolean}.
154
+ */
155
+ export function isCoreConfigured() {
156
+ return nativeBoolean(native => native.isCoreConfigured());
157
+ }
158
+
159
+ /**
160
+ * Set the native log level. Process-wide: it is read by the store engine, the
161
+ * ingest client, Identity, Attribution and the observability modules alike,
162
+ * which is why it belongs on the SDK root and not on any one namespace.
163
+ *
164
+ * Deliberately ungated — a log level you can only raise *after* a successful
165
+ * configure is useless for debugging a configure that is going wrong. It does
166
+ * still require the native module to be linked, and rejects if it is not.
167
+ */
168
+ export function setLogLevel(level) {
169
+ return getNativeModule().setLogLevel(level);
170
+ }
171
+
172
+ /**
173
+ * Guard for surfaces that genuinely need the PURCHASE engine — `getOfferings`,
174
+ * `purchasePackage`, `restorePurchases` and friends. Checks the JS "configure
175
+ * was called" flag.
176
+ *
177
+ * The RC-parity identity aliases used to sit here too, on the grounds that the
178
+ * legacy native bridge methods they called meant different things on iOS and
179
+ * Android. They now delegate to `Identity` and sit on
180
+ * {@link throwIfCoreNotConfigured} — see the block above `Purchases.logIn`.
181
+ */
182
+ export function throwIfNotConfigured() {
183
+ if (!configured) {
184
+ throw new UninitializedPurchasesError();
185
+ }
186
+ }
187
+
188
+ /**
189
+ * Guard for surfaces that only need CORE — the `Attributes` setters.
190
+ *
191
+ * Attributes describe the *person*, not the purchase: natively they land in
192
+ * `AttributesClient` → `POST /api/sdk/users/attributes` → `app_users.properties`,
193
+ * which is what the dashboard person card reads. Neither platform's attributes
194
+ * path touches StoreKit or Play Billing — iOS gates on `SwissKnife.isCoreConfigured`
195
+ * (`SwissKnife.currentAnonymousIdForAttributes`), and Android's `configureCore`
196
+ * wires `AttributesClient` with an `Identity`-snapshot id fallback precisely so a
197
+ * store-less app still resolves ids. Gating these on the purchase flag left an app
198
+ * that uses `configureCore` (because another library owns the store) with **no way
199
+ * at all** to populate the person card.
200
+ *
201
+ * Two-step check, and the second step is load-bearing:
202
+ *
203
+ * 1. The JS flag, set by `configure` / `configureCore`. Free, no bridge hop.
204
+ * 2. Native truth. `Analytics.init(...)` wires core natively via
205
+ * `configureObservability` and touches no JS flag, so an analytics-only app
206
+ * has core configured while every JS flag reads `false` — exactly the case
207
+ * {@link isCoreConfigured} documents. Skipping this step would keep the most
208
+ * common core-only integration broken.
209
+ *
210
+ * Never consults the purchase flag. Strictly more permissive than
211
+ * {@link throwIfNotConfigured}, so no existing caller can break.
212
+ */
213
+ export async function throwIfCoreNotConfigured() {
214
+ if (coreConfigured) return;
215
+ if (await nativeBoolean(native => native.isCoreConfigured())) return;
216
+ throw new UninitializedPurchasesError("Swiss Knife core is not configured. Call SwissKnife.configure(), " + "SwissKnife.configureCore(), or Analytics.init() first.");
217
+ }
218
+
219
+ /** @internal Test seam: drop the process-wide configure state. */
220
+ export function resetConfigForTests() {
221
+ configured = false;
222
+ coreConfigured = false;
223
+ configuredApiKey = null;
224
+ }
225
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getNativeModule","UninitializedPurchasesError","configured","configuredApiKey","coreConfigured","nativeBoolean","read","Promise","resolve","catch","configure","options","apiKey","native","nativeOptions","appUserID","proxyURL","diagnosticsEnabled","storeKitVersion","useAmazon","autoPromptATT","sendInstallOnFirstLaunch","logLevel","configureCore","isConfigured","isCoreConfigured","setLogLevel","level","throwIfNotConfigured","throwIfCoreNotConfigured","resetConfigForTests"],"sourceRoot":"../../../src","sources":["internal/config.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,eAAe,QAAQ,qBAAkB;AAClD,SAASC,2BAA2B,QAAQ,aAAU;AAOtD,IAAIC,UAAU,GAAG,KAAK;AACtB,IAAIC,gBAA+B,GAAG,IAAI;AAC1C,IAAIC,cAAc,GAAG,KAAK;;AAE1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAC3BC,IAAmE,EACjD;EAClB,IAAI;IACF,OAAOC,OAAO,CAACC,OAAO,CAACF,IAAI,CAACN,eAAe,CAAC,CAAC,CAAC,CAAC,CAACS,KAAK,CAAC,MAAM,KAAK,CAAC;EACpE,CAAC,CAAC,MAAM;IACN,OAAOF,OAAO,CAACC,OAAO,CAAC,KAAK,CAAC;EAC/B;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,SAASA,CAACC,OAAyB,EAAQ;EACzD,IAAIT,UAAU,IAAIC,gBAAgB,KAAKQ,OAAO,CAACC,MAAM,EAAE;EACvD,MAAMC,MAAM,GAAGb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AAA,EAAS;EAC1C5B,UAAU,GAAG,KAAK;EAClBE,cAAc,GAAG,KAAK;EACtBD,gBAAgB,GAAG,IAAI;AACzB","ignoreList":[]}