@app-swiss-knife/react-native-sdk 0.1.1 → 0.2.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 (53) hide show
  1. package/README.md +51 -0
  2. package/android/build.gradle +7 -0
  3. package/android/consumer-rules.pro +64 -0
  4. package/android/src/main/java/com/swissknife/purchases/Conversions.kt +85 -0
  5. package/android/src/main/java/com/swissknife/purchases/SwissKnifePurchasesModule.kt +37 -30
  6. package/android/vendor/java/com/appswissknife/SwissKnife.kt +219 -51
  7. package/android/vendor/java/com/appswissknife/attribution/Attribution.kt +177 -25
  8. package/android/vendor/java/com/appswissknife/context/DeviceContext.kt +1 -1
  9. package/android/vendor/java/com/appswissknife/identity/Identity.kt +15 -0
  10. package/android/vendor/java/com/appswissknife/net/IngestClient.kt +1 -1
  11. package/ios/SwissKnifePurchases.m +8 -0
  12. package/ios/SwissKnifePurchases.swift +35 -0
  13. package/ios/vendor/SwissKnifeiOS/Attribution/Attribution.swift +25 -7
  14. package/ios/vendor/SwissKnifeiOS/Context/DeviceContext.swift +1 -1
  15. package/ios/vendor/SwissKnifeiOS/Identity/Identity.swift +8 -2
  16. package/ios/vendor/SwissKnifeiOS/Net/BackendHttpClient.swift +32 -1
  17. package/ios/vendor/SwissKnifeiOS/Services/EntitlementsService.swift +35 -5
  18. package/ios/vendor/SwissKnifeiOS/Services/PurchaseService.swift +39 -22
  19. package/ios/vendor/SwissKnifeiOS/SwissKnife+DeviceID.swift +12 -2
  20. package/ios/vendor/SwissKnifeiOS/SwissKnife.swift +270 -32
  21. package/lib/commonjs/identity.js +59 -4
  22. package/lib/commonjs/identity.js.map +1 -1
  23. package/lib/commonjs/native/spec.js.map +1 -1
  24. package/lib/commonjs/purchases.js +95 -3
  25. package/lib/commonjs/purchases.js.map +1 -1
  26. package/lib/commonjs/types.js.map +1 -1
  27. package/lib/module/identity.js +59 -4
  28. package/lib/module/identity.js.map +1 -1
  29. package/lib/module/native/spec.js.map +1 -1
  30. package/lib/module/purchases.js +95 -3
  31. package/lib/module/purchases.js.map +1 -1
  32. package/lib/module/types.js.map +1 -1
  33. package/lib/typescript/commonjs/identity.d.ts +30 -4
  34. package/lib/typescript/commonjs/identity.d.ts.map +1 -1
  35. package/lib/typescript/commonjs/native/spec.d.ts +27 -0
  36. package/lib/typescript/commonjs/native/spec.d.ts.map +1 -1
  37. package/lib/typescript/commonjs/purchases.d.ts +46 -1
  38. package/lib/typescript/commonjs/purchases.d.ts.map +1 -1
  39. package/lib/typescript/commonjs/types.d.ts +11 -2
  40. package/lib/typescript/commonjs/types.d.ts.map +1 -1
  41. package/lib/typescript/module/identity.d.ts +30 -4
  42. package/lib/typescript/module/identity.d.ts.map +1 -1
  43. package/lib/typescript/module/native/spec.d.ts +27 -0
  44. package/lib/typescript/module/native/spec.d.ts.map +1 -1
  45. package/lib/typescript/module/purchases.d.ts +46 -1
  46. package/lib/typescript/module/purchases.d.ts.map +1 -1
  47. package/lib/typescript/module/types.d.ts +11 -2
  48. package/lib/typescript/module/types.d.ts.map +1 -1
  49. package/package.json +1 -1
  50. package/src/identity.ts +63 -4
  51. package/src/native/spec.ts +30 -0
  52. package/src/purchases.ts +103 -4
  53. package/src/types.ts +11 -2
@@ -9,10 +9,36 @@ export declare const Identity: {
9
9
  */
10
10
  current(): Promise<IdentitySnapshot>;
11
11
  /**
12
- * Identify this device as a known user. Native posts the
13
- * `(anonymous_id, user_id)` pair to `/api/sdk/users/identify` (the
14
- * Wave 1 bug-fix; pre-Wave-1 Android did NOT post). Resolves once
15
- * the backend ack + post-identify entitlements refresh complete.
12
+ * Bind this device to a subject id.
13
+ *
14
+ * ## `logIn` does NOT mean "the human authenticated"
15
+ *
16
+ * The name is kept for RevenueCat parity, but the contract is narrower and
17
+ * more useful than the name suggests: it means *"from now on, this device's
18
+ * activity belongs to this subject id"*. Nothing about it asserts that a
19
+ * person proved who they are.
20
+ *
21
+ * It is therefore entirely legitimate — and often correct — to call this
22
+ * with an id that belongs to an anonymous subject. An app whose logged-out
23
+ * users are real rows in its own database (a deviceId-keyed row carrying
24
+ * progress and purchases) should pass that row's id here immediately, long
25
+ * before any sign-in. Doing so means the subsequent sign-in has a real
26
+ * previous subject to merge *from*, instead of stranding everything the
27
+ * person did while logged out.
28
+ *
29
+ * ## What happens on the wire
30
+ *
31
+ * Native posts the identifier pair to `/api/sdk/users/identify`, which
32
+ * re-points every row from the previous subject onto this one. That call
33
+ * either succeeds or rejects — a rejection means the device is identified
34
+ * locally but NOT merged server-side, so it must be retried rather than
35
+ * ignored. Resolves once the backend ack and the post-identify entitlements
36
+ * refresh complete.
37
+ *
38
+ * ## Repeat calls are free
39
+ *
40
+ * Calling this again with the id already in effect is a no-op: no bridge
41
+ * hop, no network request. Call it on every app start without a guard.
16
42
  */
17
43
  logIn(userId: string): Promise<LogInResult>;
18
44
  /** Revert to anonymous. DeviceID stays stable across logout. */
@@ -1 +1 @@
1
- {"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../../src/identity.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,YAAS,CAAC;AAE7E,KAAK,QAAQ,GAAG,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI,CAAC;AAmCjD,eAAO,MAAM,QAAQ;IACnB;;;;;OAKG;eACc,OAAO,CAAC,gBAAgB,CAAC;IAM1C;;;;;OAKG;kBACiB,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAMjD,gEAAgE;cAChD,OAAO,CAAC,IAAI,CAAC;IAK7B;;;OAGG;aACY,OAAO,CAAC,IAAI,CAAC;IAK5B;;;OAGG;YACW,OAAO,CAAC,IAAI,CAAC;IAK3B,mEAAmE;uBAChD,QAAQ,GAAG,MAAM;0BAMd,MAAM,GAAG,IAAI;IAInC,mEAAmE;uBAChD,IAAI;CAIxB,CAAC;AAEF,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,YAAS,CAAC"}
1
+ {"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../../src/identity.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,YAAS,CAAC;AAE7E,KAAK,QAAQ,GAAG,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI,CAAC;AA+CjD,eAAO,MAAM,QAAQ;IACnB;;;;;OAKG;eACc,OAAO,CAAC,gBAAgB,CAAC;IAM1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;kBACiB,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAuBjD,gEAAgE;cAChD,OAAO,CAAC,IAAI,CAAC;IAM7B;;;OAGG;aACY,OAAO,CAAC,IAAI,CAAC;IAM5B;;;OAGG;YACW,OAAO,CAAC,IAAI,CAAC;IAM3B,mEAAmE;uBAChD,QAAQ,GAAG,MAAM;0BAMd,MAAM,GAAG,IAAI;IAInC,mEAAmE;uBAChD,IAAI;CAKxB,CAAC;AAEF,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,YAAS,CAAC"}
@@ -14,7 +14,34 @@ export interface NativeConfigureOptions {
14
14
  export declare const CUSTOMER_INFO_UPDATED_EVENT = "Purchases-CustomerInfoUpdated";
15
15
  export interface SwissKnifePurchasesNativeModule extends TurboModule {
16
16
  configure(options: NativeConfigureOptions): Promise<void>;
17
+ /**
18
+ * Configure everything the SDK does WITHOUT owning the store: ingest,
19
+ * Identity, Attribution, subscriber attributes.
20
+ *
21
+ * Guarantees on both platforms (asserted natively by
22
+ * `StoreOwnershipSeparationTests.swift` / `StoreOwnershipSeparationTest.kt`):
23
+ * - **iOS:** no `StoreKit.Transaction.updates` observer is started. The
24
+ * SDK's observer calls `transaction.finish()`, so running it alongside
25
+ * another IAP library (RevenueCat, hand-rolled StoreKit) races that
26
+ * library on live renewals.
27
+ * - **Android:** no `BillingClient` is instantiated and no
28
+ * `PurchasesUpdatedListener` is registered.
29
+ * - Neither platform registers an install as a side effect
30
+ * (`sendInstallOnFirstLaunch` is honoured by `configure`, not by this).
31
+ *
32
+ * Use this when another library owns purchases. `configure` is core +
33
+ * purchases; there is no separate purchases-only entry point in JS because
34
+ * the store is the only reason to reach for `configure`.
35
+ */
36
+ configureCore(options: NativeConfigureOptions): Promise<void>;
17
37
  isConfigured(): Promise<boolean>;
38
+ /**
39
+ * Whether the CORE is configured (ingest / Identity / Attribution /
40
+ * attributes) — true after `configure`, `configureCore`, or
41
+ * `configureObservability`. `isConfigured` stays false in a core-only app
42
+ * because the purchase APIs genuinely cannot work without the store.
43
+ */
44
+ isCoreConfigured(): Promise<boolean>;
18
45
  getCustomerInfo(): Promise<CustomerInfo>;
19
46
  getOfferings(): Promise<PurchasesOfferings>;
20
47
  purchasePackage(packageIdentifier: string, presentedOfferingIdentifier: string): Promise<MakePurchaseResult>;
@@ -1 +1 @@
1
- {"version":3,"file":"spec.d.ts","sourceRoot":"","sources":["../../../../src/native/spec.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,EACrB,kBAAkB,EAClB,WAAW,EACX,gBAAgB,EAChB,mBAAmB,EACpB,MAAM,aAAU,CAAC;AAIlB,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAE1B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAEzB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,OAAO,CAAC;IAGpB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,wBAAwB,CAAC,EAAE,OAAO,CAAC;IAEnC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC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14
14
  logLevel?: LOG_LEVEL;
15
15
  }): void;
16
- /** Whether the SDK has been configured. Delegates to native. */
16
+ /**
17
+ * Configure everything EXCEPT the store: ingest, `Identity`, `Attribution`,
18
+ * subscriber attributes.
19
+ *
20
+ * Use this when another library already owns in-app purchases. `configure`
21
+ * starts a `StoreKit.Transaction.updates` observer on iOS (whose handler
22
+ * calls `transaction.finish()`) and builds a `BillingClient` on Android —
23
+ * both of which contend with an incumbent IAP SDK. `configureCore` creates
24
+ * neither, and registers no install as a side effect.
25
+ *
26
+ * Analytics-only apps don't even need this: `Analytics.init(...)` already
27
+ * wires core natively. Reach for `configureCore` when you want to pass an
28
+ * `appUserID`, an attribution configuration, or a log level up front.
29
+ */
30
+ static configureCore(options: PurchasesConfiguration & {
31
+ logLevel?: LOG_LEVEL;
32
+ }): void;
33
+ /**
34
+ * Whether the PURCHASE engine has been configured — i.e. whether the store
35
+ * APIs (`getOfferings`, `purchasePackage`, `restorePurchases`, …) can work.
36
+ *
37
+ * **Native is the source of truth.** This does not consult the JS-side
38
+ * "configure was called" flag: a brownfield app can configure the SDK from
39
+ * native code, and `Purchases.configure` itself is fire-and-forget, so the
40
+ * JS flag is a request, not a fact.
41
+ *
42
+ * Never throws and never rejects. Resolves `false` when the native module is
43
+ * not linked — see {@link nativeBoolean}. Exactly the same failure semantics
44
+ * as {@link isCoreConfigured}; the two differ only in which native flag they
45
+ * report.
46
+ */
17
47
  static isConfigured(): Promise<boolean>;
48
+ /**
49
+ * Whether the CORE (ingest / Identity / Attribution / attributes) is
50
+ * configured. True after `configure`, `configureCore`, or `Analytics.init`.
51
+ *
52
+ * **Native is the source of truth**, and here that is load-bearing rather
53
+ * than merely principled: `Analytics.init` wires core natively via
54
+ * `configureObservability` and touches no JS configure flag, so an
55
+ * analytics-only app has core configured while every JS flag reads false.
56
+ * Short-circuiting on JS state would report `false` in the single most
57
+ * common core-only integration.
58
+ *
59
+ * Never throws and never rejects. Resolves `false` when the native module is
60
+ * not linked — see {@link nativeBoolean}.
61
+ */
62
+ static isCoreConfigured(): Promise<boolean>;
18
63
  /** Latest CustomerInfo (entitlements + subscriptions), computed server-side. */
19
64
  static getCustomerInfo(): Promise<CustomerInfo>;
20
65
  /** Current + all offerings configured for this app. */
@@ -1 +1 @@
1
- {"version":3,"file":"purchases.d.ts","sourceRoot":"","sources":["../../../src/purchases.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,sBAAsB,EACtB,SAAS,EACT,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,EACrB,kBAAkB,EAClB,WAAW,EACX,0BAA0B,EAC3B,MAAM,YAAS,CAAC;AAYjB,iBAAS,oBAAoB,IAAI,IAAI,CAIpC;AAED;;;GAGG;AACH,qBAAa,SAAS;IACpB;;;;OAIG;IACH,MAAM,CAAC,SAAS,CACd,OAAO,EAAE,sBAAsB,GAAG;QAAE,QAAQ,CAAC,EAAE,SAAS,CAAA;KAAE,GACzD,IAAI;IA0BP,gEAAgE;IAChE,MAAM,CAAC,YAAY,IAAI,OAAO,CAAC,OAAO,CAAC;IAKvC,gFAAgF;WACnE,eAAe,IAAI,OAAO,CAAC,YAAY,CAAC;IAKrD,uDAAuD;WAC1C,YAAY,IAAI,OAAO,CAAC,kBAAkB,CAAC;IAKxD,kFAAkF;WACrE,eAAe,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAMhF,0DAA0D;WAC7C,oBAAoB,CAC/B,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,kBAAkB,CAAC;IAK9B,8DAA8D;WACjD,gBAAgB,IAAI,OAAO,CAAC,YAAY,CAAC;IAKtD;;;;;;;OAOG;WACU,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAK3D;;;;OAIG;WACU,MAAM,IAAI,OAAO,CAAC,YAAY,CAAC;IAK5C,yDAAyD;WAC5C,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC;I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AAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAK1D,wCAAwC;WAC3B,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAKtE,wCAAwC;WAC3B,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAKtE,sCAAsC;WACzB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAKlE,gEAAgE;WACnD,WAAW,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAIzD,8EAA8E;IAC9E,MAAM,CAAC,6BAA6B,CAClC,QAAQ,EAAE,0BAA0B,GACnC,IAAI;IAQP,mEAAmE;IACnE,MAAM,CAAC,gCAAgC,CACrC,QAAQ,EAAE,0BAA0B,GACnC,IAAI;IAQP,gEAAgE;IAChE,MAAM,CAAC,eAAe,IAAI,IAAI;CAM/B;AAGD,OAAO,EAAE,oBAAoB,IAAI,sBAAsB,EAAE,CAAC;AAE1D,eAAe,SAAS,CAAC"}
@@ -357,12 +357,21 @@ export interface PurchasesConfiguration {
357
357
  * iOS App Tracking Transparency. When `true`, the SDK shows the system ATT
358
358
  * prompt on first launch (requires `NSUserTrackingUsageDescription` in
359
359
  * Info.plist). **Defaults to `false`** — the SDK never prompts for tracking
360
- * unless you opt in. iOS-only; ignored on Android.
360
+ * unless you opt in.
361
+ *
362
+ * Forwarded to both platforms, but **only iOS acts on it** — Android has no
363
+ * runtime tracking prompt for the SDK to raise; advertising-ID access there
364
+ * is governed by Play Services consent and the user's device settings.
361
365
  */
362
366
  autoPromptATT?: boolean;
363
367
  /**
364
368
  * Register an organic install on first launch (no IDFA, no prompt) so
365
- * attribution still resolves without ATT. Default `true`. iOS-only.
369
+ * attribution still resolves without ATT. Default `true`. Honoured on **both
370
+ * platforms** by `Purchases.configure`.
371
+ *
372
+ * Accepted by `configureCore` too, and carried through to native, but inert
373
+ * on that path: core never registers an install as a side effect. Call
374
+ * `Attribution.registerInstall(...)` explicitly from a core-only app.
366
375
  */
367
376
  sendInstallOnFirstLaunch?: boolean;
368
377
  /** Reserved for the Amazon flavor — ignored on iOS / Play Android. */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAmCA;;;GAGG;AACH,eAAO,MAAM,SAAS;;;;;;CAMZ,CAAC;AACX,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,OAAO,SAAS,CAAC,CAAC;AAEnE,sEAAsE;AACtE,eAAO,MAAM,YAAY;;;;;;;;;;CAUf,CAAC;AACX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC;AAE5E;;;;GAIG;AACH,eAAO,MAAM,gBAAgB;;;;CAInB,CAAC;AACX,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,OAAO,gBAAgB,CAAC,CAAC;AAExF,4DAA4D;AAC5D,eAAO,MAAM,mBAAmB;;;;;CAKtB,CAAC;AACX,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,OAAO,mBAAmB,CAAC,CAAC;AAEjG;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BvB,CAAC;AACX,MAAM,MAAM,oBAAoB,GAC9B,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,OAAO,oBAAoB,CAAC,CAAC;AAInE;;;;GAIG;AACH,qBAAa,2BAA4B,SAAQ,KAAK;gBAElD,OAAO,GAAE,MAAyE;CAKrF;AAED;;;GAGG;AACH,qBAAa,wBAAyB,SAAQ,KAAK;gBAE/C,OAAO,GAAE,MAAgE;CAK5E;AAED;;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IACf,iFAAiF;IACjF,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,gEAAgE;IAChE,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,kFAAkF;AAClF,MAAM,WAAW,kBAAkB;IACjC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,YAAY,EAAE,YAAY,CAAC;IAC3B,WAAW,EAAE,yBAAyB,GAAG,IAAI,CAAC;CAC/C;AAID,0FAA0F;AAC1F,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,oHAAoH;IACpH,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,uEAAuE;IACvE,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,eAAe,CAAC,EAAE,gBAAgB,CAAC;IACnC;;;;;;;;;OASG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;;;;;OAQG;IACH,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,sEAAsE;IACtE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,+CAA+C;IAC/C,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,gFAAgF;IAChF,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,oCAAoC,CAAC,EAAE,OAAO,CAAC;IAC/C,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,yCAAyC,CAAC,EAAE,OAAO,CAAC;CACrD;AAID;;;;GAIG;AACH,MAAM,MAAM,0BAA0B,GAAG,CAAC,YAAY,EAAE,YAAY,KAAK,IAAI,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@app-swiss-knife/react-native-sdk",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "Subscriptions-only React Native SDK for App Swiss Knife — a drop-in replacement for RevenueCat's react-native-purchases public API.",
5
5
  "source": "./src/index.ts",
6
6
  "main": "./lib/commonjs/index.js",
package/src/identity.ts CHANGED
@@ -34,6 +34,18 @@ const observers = new Map<string, Observer>();
34
34
 
35
35
  let lastSnapshot: IdentitySnapshot | null = null;
36
36
 
37
+ /**
38
+ * Result of the last `logIn` that actually reached native, so a repeat call
39
+ * with the same subject id can be answered without touching the bridge.
40
+ *
41
+ * Hosts are expected to call `logIn` on every app start and after every
42
+ * auth-state read — that is the correct usage, not a misuse — so the repeat
43
+ * case is the common case, and each one would otherwise cost a bridge hop
44
+ * plus a `/api/sdk/users/identify` round trip that can only ever conclude
45
+ * "nothing to merge".
46
+ */
47
+ let lastLogIn: { userId: string; result: LogInResult } | null = null;
48
+
37
49
  function generateToken(): string {
38
50
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
39
51
  const r = (Math.random() * 16) | 0;
@@ -77,19 +89,63 @@ export const Identity = {
77
89
  },
78
90
 
79
91
  /**
80
- * Identify this device as a known user. Native posts the
81
- * `(anonymous_id, user_id)` pair to `/api/sdk/users/identify` (the
82
- * Wave 1 bug-fix; pre-Wave-1 Android did NOT post). Resolves once
83
- * the backend ack + post-identify entitlements refresh complete.
92
+ * Bind this device to a subject id.
93
+ *
94
+ * ## `logIn` does NOT mean "the human authenticated"
95
+ *
96
+ * The name is kept for RevenueCat parity, but the contract is narrower and
97
+ * more useful than the name suggests: it means *"from now on, this device's
98
+ * activity belongs to this subject id"*. Nothing about it asserts that a
99
+ * person proved who they are.
100
+ *
101
+ * It is therefore entirely legitimate — and often correct — to call this
102
+ * with an id that belongs to an anonymous subject. An app whose logged-out
103
+ * users are real rows in its own database (a deviceId-keyed row carrying
104
+ * progress and purchases) should pass that row's id here immediately, long
105
+ * before any sign-in. Doing so means the subsequent sign-in has a real
106
+ * previous subject to merge *from*, instead of stranding everything the
107
+ * person did while logged out.
108
+ *
109
+ * ## What happens on the wire
110
+ *
111
+ * Native posts the identifier pair to `/api/sdk/users/identify`, which
112
+ * re-points every row from the previous subject onto this one. That call
113
+ * either succeeds or rejects — a rejection means the device is identified
114
+ * locally but NOT merged server-side, so it must be retried rather than
115
+ * ignored. Resolves once the backend ack and the post-identify entitlements
116
+ * refresh complete.
117
+ *
118
+ * ## Repeat calls are free
119
+ *
120
+ * Calling this again with the id already in effect is a no-op: no bridge
121
+ * hop, no network request. Call it on every app start without a guard.
84
122
  */
85
123
  async logIn(userId: string): Promise<LogInResult> {
124
+ // Cheap no-op: the subject is already in effect for this process. Checked
125
+ // against the cached result AND the last known snapshot so a `logOut` /
126
+ // `reset` / `wipe` in between always forces a real call.
127
+ if (
128
+ lastLogIn !== null &&
129
+ lastLogIn.userId === userId &&
130
+ lastSnapshot !== null &&
131
+ lastSnapshot.userId === userId &&
132
+ !lastSnapshot.isAnonymous
133
+ ) {
134
+ return lastLogIn.result;
135
+ }
136
+
86
137
  const result = await getNativeModule().identityLogIn(userId);
138
+ // Only cache after native resolved. If the identify POST rejected, the
139
+ // throw propagates and nothing is cached, so the next call retries
140
+ // instead of silently reporting success for a merge that never happened.
141
+ lastLogIn = { userId, result };
87
142
  await snapshotAndNotify("logIn");
88
143
  return result;
89
144
  },
90
145
 
91
146
  /** Revert to anonymous. DeviceID stays stable across logout. */
92
147
  async logOut(): Promise<void> {
148
+ lastLogIn = null;
93
149
  await getNativeModule().identityLogOut();
94
150
  await snapshotAndNotify("logOut");
95
151
  },
@@ -99,6 +155,7 @@ export const Identity = {
99
155
  * "switch test user" UX semantic.
100
156
  */
101
157
  async reset(): Promise<void> {
158
+ lastLogIn = null;
102
159
  await getNativeModule().identityReset();
103
160
  await snapshotAndNotify("reset");
104
161
  },
@@ -108,6 +165,7 @@ export const Identity = {
108
165
  * (Android) DeviceID. GDPR-delete / test-build cleanup.
109
166
  */
110
167
  async wipe(): Promise<void> {
168
+ lastLogIn = null;
111
169
  await getNativeModule().identityWipe();
112
170
  await snapshotAndNotify("wipe");
113
171
  },
@@ -126,6 +184,7 @@ export const Identity = {
126
184
  /** @internal Test seam — reset the cached snapshot + observers. */
127
185
  __resetForTests(): void {
128
186
  lastSnapshot = null;
187
+ lastLogIn = null;
129
188
  observers.clear();
130
189
  },
131
190
  };
@@ -43,8 +43,38 @@ export const CUSTOMER_INFO_UPDATED_EVENT = "Purchases-CustomerInfoUpdated";
43
43
  // only adds an optional `getConstants?(): {}`, which the native side doesn't use.
44
44
  export interface SwissKnifePurchasesNativeModule extends TurboModule {
45
45
  configure(options: NativeConfigureOptions): Promise<void>;
46
+
47
+ /**
48
+ * Configure everything the SDK does WITHOUT owning the store: ingest,
49
+ * Identity, Attribution, subscriber attributes.
50
+ *
51
+ * Guarantees on both platforms (asserted natively by
52
+ * `StoreOwnershipSeparationTests.swift` / `StoreOwnershipSeparationTest.kt`):
53
+ * - **iOS:** no `StoreKit.Transaction.updates` observer is started. The
54
+ * SDK's observer calls `transaction.finish()`, so running it alongside
55
+ * another IAP library (RevenueCat, hand-rolled StoreKit) races that
56
+ * library on live renewals.
57
+ * - **Android:** no `BillingClient` is instantiated and no
58
+ * `PurchasesUpdatedListener` is registered.
59
+ * - Neither platform registers an install as a side effect
60
+ * (`sendInstallOnFirstLaunch` is honoured by `configure`, not by this).
61
+ *
62
+ * Use this when another library owns purchases. `configure` is core +
63
+ * purchases; there is no separate purchases-only entry point in JS because
64
+ * the store is the only reason to reach for `configure`.
65
+ */
66
+ configureCore(options: NativeConfigureOptions): Promise<void>;
67
+
46
68
  isConfigured(): Promise<boolean>;
47
69
 
70
+ /**
71
+ * Whether the CORE is configured (ingest / Identity / Attribution /
72
+ * attributes) — true after `configure`, `configureCore`, or
73
+ * `configureObservability`. `isConfigured` stays false in a core-only app
74
+ * because the purchase APIs genuinely cannot work without the store.
75
+ */
76
+ isCoreConfigured(): Promise<boolean>;
77
+
48
78
  getCustomerInfo(): Promise<CustomerInfo>;
49
79
  getOfferings(): Promise<PurchasesOfferings>;
50
80
 
package/src/purchases.ts CHANGED
@@ -14,10 +14,41 @@ import type {
14
14
  LogInResult,
15
15
  CustomerInfoUpdateListener,
16
16
  } from "./types";
17
- import type { NativeConfigureOptions } from "./native/spec";
17
+ import type {
18
+ NativeConfigureOptions,
19
+ SwissKnifePurchasesNativeModule,
20
+ } from "./native/spec";
18
21
 
19
22
  let configured = false;
20
23
  let configuredApiKey: string | null = null;
24
+ let coreConfigured = false;
25
+
26
+ /**
27
+ * Read a boolean off the native module without ever letting a missing native
28
+ * module escape as an exception.
29
+ *
30
+ * `getNativeModule()` THROWS when the module is not linked (Expo Go, a bare RN
31
+ * app that skipped `pod install` / a Gradle sync, web) — precisely the state a
32
+ * developer is in while wiring the SDK up, and precisely when they are most
33
+ * likely to be calling one of these accessors to find out what is wrong. A
34
+ * boolean accessor rejecting with "native module is not linked" is a worse
35
+ * answer than `false`: an unlinked module cannot have configured anything, so
36
+ * `false` is not merely safe, it is correct.
37
+ *
38
+ * The `.catch` covers the adjacent case where the module IS linked but predates
39
+ * the method (JS upgraded without rebuilding the app) — same reasoning, same
40
+ * answer. Mirrors the tolerance `Analytics.init` already applies to
41
+ * `configureObservability`.
42
+ */
43
+ function nativeBoolean(
44
+ read: (native: SwissKnifePurchasesNativeModule) => Promise<boolean>
45
+ ): Promise<boolean> {
46
+ try {
47
+ return Promise.resolve(read(getNativeModule())).catch(() => false);
48
+ } catch {
49
+ return Promise.resolve(false);
50
+ }
51
+ }
21
52
 
22
53
  // Maps a caller's listener fn to its native subscription so we can remove it.
23
54
  const customerInfoSubscriptions = new Map<
@@ -66,13 +97,80 @@ export class Purchases {
66
97
  // Fire-and-forget: native configure resolves async but RC's configure is sync.
67
98
  void native.configure(nativeOptions);
68
99
  configured = true;
100
+ coreConfigured = true;
69
101
  configuredApiKey = options.apiKey;
70
102
  }
71
103
 
72
- /** Whether the SDK has been configured. Delegates to native. */
104
+ /**
105
+ * Configure everything EXCEPT the store: ingest, `Identity`, `Attribution`,
106
+ * subscriber attributes.
107
+ *
108
+ * Use this when another library already owns in-app purchases. `configure`
109
+ * starts a `StoreKit.Transaction.updates` observer on iOS (whose handler
110
+ * calls `transaction.finish()`) and builds a `BillingClient` on Android —
111
+ * both of which contend with an incumbent IAP SDK. `configureCore` creates
112
+ * neither, and registers no install as a side effect.
113
+ *
114
+ * Analytics-only apps don't even need this: `Analytics.init(...)` already
115
+ * wires core natively. Reach for `configureCore` when you want to pass an
116
+ * `appUserID`, an attribution configuration, or a log level up front.
117
+ */
118
+ static configureCore(
119
+ options: PurchasesConfiguration & { logLevel?: LOG_LEVEL }
120
+ ): void {
121
+ if (coreConfigured && configuredApiKey === options.apiKey) return;
122
+ const native = getNativeModule();
123
+ const nativeOptions: NativeConfigureOptions = {
124
+ apiKey: options.apiKey,
125
+ appUserID: options.appUserID ?? null,
126
+ proxyURL: options.proxyURL ?? null,
127
+ diagnosticsEnabled: options.diagnosticsEnabled ?? false,
128
+ autoPromptATT: options.autoPromptATT,
129
+ // Forwarded but inert on this path — core never auto-registers an
130
+ // install. Kept on the payload so the same options object can be handed
131
+ // to `configure` later without surprises.
132
+ sendInstallOnFirstLaunch: options.sendInstallOnFirstLaunch,
133
+ logLevel: options.logLevel,
134
+ };
135
+ void native.configureCore(nativeOptions);
136
+ coreConfigured = true;
137
+ configuredApiKey = options.apiKey;
138
+ }
139
+
140
+ /**
141
+ * Whether the PURCHASE engine has been configured — i.e. whether the store
142
+ * APIs (`getOfferings`, `purchasePackage`, `restorePurchases`, …) can work.
143
+ *
144
+ * **Native is the source of truth.** This does not consult the JS-side
145
+ * "configure was called" flag: a brownfield app can configure the SDK from
146
+ * native code, and `Purchases.configure` itself is fire-and-forget, so the
147
+ * JS flag is a request, not a fact.
148
+ *
149
+ * Never throws and never rejects. Resolves `false` when the native module is
150
+ * not linked — see {@link nativeBoolean}. Exactly the same failure semantics
151
+ * as {@link isCoreConfigured}; the two differ only in which native flag they
152
+ * report.
153
+ */
73
154
  static isConfigured(): Promise<boolean> {
74
- if (!configured) return Promise.resolve(false);
75
- return getNativeModule().isConfigured();
155
+ return nativeBoolean((native) => native.isConfigured());
156
+ }
157
+
158
+ /**
159
+ * Whether the CORE (ingest / Identity / Attribution / attributes) is
160
+ * configured. True after `configure`, `configureCore`, or `Analytics.init`.
161
+ *
162
+ * **Native is the source of truth**, and here that is load-bearing rather
163
+ * than merely principled: `Analytics.init` wires core natively via
164
+ * `configureObservability` and touches no JS configure flag, so an
165
+ * analytics-only app has core configured while every JS flag reads false.
166
+ * Short-circuiting on JS state would report `false` in the single most
167
+ * common core-only integration.
168
+ *
169
+ * Never throws and never rejects. Resolves `false` when the native module is
170
+ * not linked — see {@link nativeBoolean}.
171
+ */
172
+ static isCoreConfigured(): Promise<boolean> {
173
+ return nativeBoolean((native) => native.isCoreConfigured());
76
174
  }
77
175
 
78
176
  /** Latest CustomerInfo (entitlements + subscriptions), computed server-side. */
@@ -203,6 +301,7 @@ export class Purchases {
203
301
  /** @internal Test seam: reset singleton state between tests. */
204
302
  static __resetForTests(): void {
205
303
  configured = false;
304
+ coreConfigured = false;
206
305
  configuredApiKey = null;
207
306
  customerInfoSubscriptions.clear();
208
307
  }
package/src/types.ts CHANGED
@@ -441,12 +441,21 @@ export interface PurchasesConfiguration {
441
441
  * iOS App Tracking Transparency. When `true`, the SDK shows the system ATT
442
442
  * prompt on first launch (requires `NSUserTrackingUsageDescription` in
443
443
  * Info.plist). **Defaults to `false`** — the SDK never prompts for tracking
444
- * unless you opt in. iOS-only; ignored on Android.
444
+ * unless you opt in.
445
+ *
446
+ * Forwarded to both platforms, but **only iOS acts on it** — Android has no
447
+ * runtime tracking prompt for the SDK to raise; advertising-ID access there
448
+ * is governed by Play Services consent and the user's device settings.
445
449
  */
446
450
  autoPromptATT?: boolean;
447
451
  /**
448
452
  * Register an organic install on first launch (no IDFA, no prompt) so
449
- * attribution still resolves without ATT. Default `true`. iOS-only.
453
+ * attribution still resolves without ATT. Default `true`. Honoured on **both
454
+ * platforms** by `Purchases.configure`.
455
+ *
456
+ * Accepted by `configureCore` too, and carried through to native, but inert
457
+ * on that path: core never registers an install as a side effect. Call
458
+ * `Attribution.registerInstall(...)` explicitly from a core-only app.
450
459
  */
451
460
  sendInstallOnFirstLaunch?: boolean;
452
461
  /** Reserved for the Amazon flavor — ignored on iOS / Play Android. */