@app-swiss-knife/react-native-sdk 0.2.7 → 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.
- package/README.md +100 -47
- package/SwissKnifePurchases.podspec +8 -5
- package/android/vendor/java/com/appswissknife/context/DeviceContext.kt +1 -1
- package/android/vendor/java/com/appswissknife/net/IngestClient.kt +1 -1
- package/ios/SwissKnifeCrashReporting.swift +59 -18
- package/ios/vendor/SwissKnifeiOS/Context/DeviceContext.swift +1 -1
- package/ios/vendor/SwissKnifeiOS/Context/Reachability.swift +1 -1
- package/ios/vendor/SwissKnifeiOS/CrashReporting/SKCrashReporting.swift +24 -0
- package/ios/vendor/SwissKnifeiOS/DeviceID.swift +22 -1
- package/ios/vendor/SwissKnifeiOS/Identity/Identity.swift +49 -0
- package/ios/vendor/SwissKnifeiOS/Net/IngestClient.swift +14 -0
- package/lib/commonjs/attributes.js +103 -0
- package/lib/commonjs/attributes.js.map +1 -0
- package/lib/commonjs/index.js +31 -2
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/internal/config.js +237 -0
- package/lib/commonjs/internal/config.js.map +1 -0
- package/lib/commonjs/purchases.js +152 -209
- package/lib/commonjs/purchases.js.map +1 -1
- package/lib/commonjs/swiss-knife.js +115 -0
- package/lib/commonjs/swiss-knife.js.map +1 -0
- package/lib/commonjs/types.js +11 -0
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/attributes.js +100 -0
- package/lib/module/attributes.js.map +1 -0
- package/lib/module/index.js +19 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/internal/config.js +225 -0
- package/lib/module/internal/config.js.map +1 -0
- package/lib/module/purchases.js +132 -198
- package/lib/module/purchases.js.map +1 -1
- package/lib/module/swiss-knife.js +112 -0
- package/lib/module/swiss-knife.js.map +1 -0
- package/lib/module/types.js +11 -0
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/commonjs/attributes.d.ts +41 -0
- package/lib/typescript/commonjs/attributes.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +2 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/internal/config.d.ts +121 -0
- package/lib/typescript/commonjs/internal/config.d.ts.map +1 -0
- package/lib/typescript/commonjs/purchases.d.ts +47 -91
- package/lib/typescript/commonjs/purchases.d.ts.map +1 -1
- package/lib/typescript/commonjs/swiss-knife.d.ts +56 -0
- package/lib/typescript/commonjs/swiss-knife.d.ts.map +1 -0
- package/lib/typescript/commonjs/types.d.ts +13 -0
- package/lib/typescript/commonjs/types.d.ts.map +1 -1
- package/lib/typescript/module/attributes.d.ts +41 -0
- package/lib/typescript/module/attributes.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +2 -0
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/internal/config.d.ts +121 -0
- package/lib/typescript/module/internal/config.d.ts.map +1 -0
- package/lib/typescript/module/purchases.d.ts +47 -91
- package/lib/typescript/module/purchases.d.ts.map +1 -1
- package/lib/typescript/module/swiss-knife.d.ts +56 -0
- package/lib/typescript/module/swiss-knife.d.ts.map +1 -0
- package/lib/typescript/module/types.d.ts +13 -0
- package/lib/typescript/module/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/attributes.ts +97 -0
- package/src/index.ts +19 -2
- package/src/internal/config.ts +233 -0
- package/src/purchases.ts +142 -213
- package/src/swiss-knife.ts +134 -0
- package/src/types.ts +14 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import type { LOG_LEVEL, ConfigureOptions } from "../types.js";
|
|
2
|
+
import type { SwissKnifePurchasesNativeModule } from "../native/spec.js";
|
|
3
|
+
/**
|
|
4
|
+
* Read a boolean off the native module without ever letting a missing native
|
|
5
|
+
* module escape as an exception.
|
|
6
|
+
*
|
|
7
|
+
* `getNativeModule()` THROWS when the module is not linked (Expo Go, a bare RN
|
|
8
|
+
* app that skipped `pod install` / a Gradle sync, web) — precisely the state a
|
|
9
|
+
* developer is in while wiring the SDK up, and precisely when they are most
|
|
10
|
+
* likely to be calling one of these accessors to find out what is wrong. A
|
|
11
|
+
* boolean accessor rejecting with "native module is not linked" is a worse
|
|
12
|
+
* answer than `false`: an unlinked module cannot have configured anything, so
|
|
13
|
+
* `false` is not merely safe, it is correct.
|
|
14
|
+
*
|
|
15
|
+
* The `.catch` covers the adjacent case where the module IS linked but predates
|
|
16
|
+
* the method (JS upgraded without rebuilding the app) — same reasoning, same
|
|
17
|
+
* answer. Mirrors the tolerance `Analytics.init` already applies to
|
|
18
|
+
* `configureObservability`.
|
|
19
|
+
*/
|
|
20
|
+
export declare function nativeBoolean(read: (native: SwissKnifePurchasesNativeModule) => Promise<boolean>): Promise<boolean>;
|
|
21
|
+
/**
|
|
22
|
+
* Configure the SDK. Must be called before any other method. Calling again
|
|
23
|
+
* with the same API key is a no-op (matches the common "configure once" guard);
|
|
24
|
+
* the native layer owns full reconfiguration.
|
|
25
|
+
*/
|
|
26
|
+
export declare function configure(options: ConfigureOptions): void;
|
|
27
|
+
/**
|
|
28
|
+
* Configure everything EXCEPT the store: ingest, `Identity`, `Attribution`,
|
|
29
|
+
* `Attributes`.
|
|
30
|
+
*
|
|
31
|
+
* Use this when another library already owns in-app purchases. `configure`
|
|
32
|
+
* starts a `StoreKit.Transaction.updates` observer on iOS (whose handler
|
|
33
|
+
* calls `transaction.finish()`) and builds a `BillingClient` on Android —
|
|
34
|
+
* both of which contend with an incumbent IAP SDK. `configureCore` creates
|
|
35
|
+
* neither, and registers no install as a side effect.
|
|
36
|
+
*
|
|
37
|
+
* Analytics-only apps don't even need this: `Analytics.init(...)` already
|
|
38
|
+
* wires core natively. Reach for `configureCore` when you want to pass an
|
|
39
|
+
* `appUserID`, an attribution configuration, or a log level up front.
|
|
40
|
+
*/
|
|
41
|
+
export declare function configureCore(options: ConfigureOptions): void;
|
|
42
|
+
/**
|
|
43
|
+
* Whether the PURCHASE engine has been configured — i.e. whether the store
|
|
44
|
+
* APIs (`getOfferings`, `purchasePackage`, `restorePurchases`, …) can work.
|
|
45
|
+
*
|
|
46
|
+
* **Native is the source of truth.** This does not consult the JS-side
|
|
47
|
+
* "configure was called" flag: a brownfield app can configure the SDK from
|
|
48
|
+
* native code, and `configure` itself is fire-and-forget, so the JS flag is a
|
|
49
|
+
* request, not a fact.
|
|
50
|
+
*
|
|
51
|
+
* Never throws and never rejects. Resolves `false` when the native module is
|
|
52
|
+
* not linked — see {@link nativeBoolean}. Exactly the same failure semantics
|
|
53
|
+
* as {@link isCoreConfigured}; the two differ only in which native flag they
|
|
54
|
+
* report.
|
|
55
|
+
*/
|
|
56
|
+
export declare function isConfigured(): Promise<boolean>;
|
|
57
|
+
/**
|
|
58
|
+
* Whether the CORE (ingest / Identity / Attribution / Attributes) is
|
|
59
|
+
* configured. True after `configure`, `configureCore`, or `Analytics.init`.
|
|
60
|
+
*
|
|
61
|
+
* **Native is the source of truth**, and here that is load-bearing rather
|
|
62
|
+
* than merely principled: `Analytics.init` wires core natively via
|
|
63
|
+
* `configureObservability` and touches no JS configure flag, so an
|
|
64
|
+
* analytics-only app has core configured while every JS flag reads false.
|
|
65
|
+
* Short-circuiting on JS state would report `false` in the single most
|
|
66
|
+
* common core-only integration.
|
|
67
|
+
*
|
|
68
|
+
* Never throws and never rejects. Resolves `false` when the native module is
|
|
69
|
+
* not linked — see {@link nativeBoolean}.
|
|
70
|
+
*/
|
|
71
|
+
export declare function isCoreConfigured(): Promise<boolean>;
|
|
72
|
+
/**
|
|
73
|
+
* Set the native log level. Process-wide: it is read by the store engine, the
|
|
74
|
+
* ingest client, Identity, Attribution and the observability modules alike,
|
|
75
|
+
* which is why it belongs on the SDK root and not on any one namespace.
|
|
76
|
+
*
|
|
77
|
+
* Deliberately ungated — a log level you can only raise *after* a successful
|
|
78
|
+
* configure is useless for debugging a configure that is going wrong. It does
|
|
79
|
+
* still require the native module to be linked, and rejects if it is not.
|
|
80
|
+
*/
|
|
81
|
+
export declare function setLogLevel(level: LOG_LEVEL): Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Guard for surfaces that genuinely need the PURCHASE engine — `getOfferings`,
|
|
84
|
+
* `purchasePackage`, `restorePurchases` and friends. Checks the JS "configure
|
|
85
|
+
* was called" flag.
|
|
86
|
+
*
|
|
87
|
+
* The RC-parity identity aliases used to sit here too, on the grounds that the
|
|
88
|
+
* legacy native bridge methods they called meant different things on iOS and
|
|
89
|
+
* Android. They now delegate to `Identity` and sit on
|
|
90
|
+
* {@link throwIfCoreNotConfigured} — see the block above `Purchases.logIn`.
|
|
91
|
+
*/
|
|
92
|
+
export declare function throwIfNotConfigured(): void;
|
|
93
|
+
/**
|
|
94
|
+
* Guard for surfaces that only need CORE — the `Attributes` setters.
|
|
95
|
+
*
|
|
96
|
+
* Attributes describe the *person*, not the purchase: natively they land in
|
|
97
|
+
* `AttributesClient` → `POST /api/sdk/users/attributes` → `app_users.properties`,
|
|
98
|
+
* which is what the dashboard person card reads. Neither platform's attributes
|
|
99
|
+
* path touches StoreKit or Play Billing — iOS gates on `SwissKnife.isCoreConfigured`
|
|
100
|
+
* (`SwissKnife.currentAnonymousIdForAttributes`), and Android's `configureCore`
|
|
101
|
+
* wires `AttributesClient` with an `Identity`-snapshot id fallback precisely so a
|
|
102
|
+
* store-less app still resolves ids. Gating these on the purchase flag left an app
|
|
103
|
+
* that uses `configureCore` (because another library owns the store) with **no way
|
|
104
|
+
* at all** to populate the person card.
|
|
105
|
+
*
|
|
106
|
+
* Two-step check, and the second step is load-bearing:
|
|
107
|
+
*
|
|
108
|
+
* 1. The JS flag, set by `configure` / `configureCore`. Free, no bridge hop.
|
|
109
|
+
* 2. Native truth. `Analytics.init(...)` wires core natively via
|
|
110
|
+
* `configureObservability` and touches no JS flag, so an analytics-only app
|
|
111
|
+
* has core configured while every JS flag reads `false` — exactly the case
|
|
112
|
+
* {@link isCoreConfigured} documents. Skipping this step would keep the most
|
|
113
|
+
* common core-only integration broken.
|
|
114
|
+
*
|
|
115
|
+
* Never consults the purchase flag. Strictly more permissive than
|
|
116
|
+
* {@link throwIfNotConfigured}, so no existing caller can break.
|
|
117
|
+
*/
|
|
118
|
+
export declare function throwIfCoreNotConfigured(): Promise<void>;
|
|
119
|
+
/** @internal Test seam: drop the process-wide configure state. */
|
|
120
|
+
export declare function resetConfigForTests(): void;
|
|
121
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../src/internal/config.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,aAAU,CAAC;AAC5D,OAAO,KAAK,EAEV,+BAA+B,EAChC,MAAM,mBAAgB,CAAC;AAMxB;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,CAAC,MAAM,EAAE,+BAA+B,KAAK,OAAO,CAAC,OAAO,CAAC,GAClE,OAAO,CAAC,OAAO,CAAC,CAMlB;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAyBzD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAkB7D;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,IAAI,OAAO,CAAC,OAAO,CAAC,CAE/C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,IAAI,OAAO,CAAC,OAAO,CAAC,CAEnD;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAE3D;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CAI3C;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,wBAAwB,IAAI,OAAO,CAAC,IAAI,CAAC,CAO9D;AAED,kEAAkE;AAClE,wBAAgB,mBAAmB,IAAI,IAAI,CAI1C"}
|
|
@@ -1,101 +1,55 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { configure, configureCore, isConfigured, isCoreConfigured, setLogLevel, throwIfCoreNotConfigured, throwIfNotConfigured } from "./internal/config.js";
|
|
2
|
+
import type { CustomerInfo, PurchasesOfferings, PurchasesPackage, PurchasesStoreProduct, MakePurchaseResult, LogInResult, CustomerInfoUpdateListener } from "./types.js";
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
-
* `purchasePackage`, `restorePurchases` and friends. Checks the JS "configure
|
|
5
|
-
* was called" flag.
|
|
4
|
+
* RC-compatible subscriptions SDK entry point. Process-wide singleton.
|
|
6
5
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*/
|
|
12
|
-
declare function throwIfNotConfigured(): void;
|
|
13
|
-
/**
|
|
14
|
-
* Guard for surfaces that only need CORE — the subscriber-attribute setters.
|
|
15
|
-
*
|
|
16
|
-
* Attributes describe the *person*, not the purchase: natively they land in
|
|
17
|
-
* `AttributesClient` → `POST /api/sdk/users/attributes` → `app_users.properties`,
|
|
18
|
-
* which is what the dashboard person card reads. Neither platform's attributes
|
|
19
|
-
* path touches StoreKit or Play Billing — iOS gates on `SwissKnife.isCoreConfigured`
|
|
20
|
-
* (`SwissKnife.currentAnonymousIdForAttributes`), and Android's `configureCore`
|
|
21
|
-
* wires `AttributesClient` with an `Identity`-snapshot id fallback precisely so a
|
|
22
|
-
* store-less app still resolves ids. Gating these on the purchase flag left an app
|
|
23
|
-
* that uses `configureCore` (because another library owns the store) with **no way
|
|
24
|
-
* at all** to populate the person card.
|
|
25
|
-
*
|
|
26
|
-
* Two-step check, and the second step is load-bearing:
|
|
27
|
-
*
|
|
28
|
-
* 1. The JS flag, set by `configure` / `configureCore`. Free, no bridge hop.
|
|
29
|
-
* 2. Native truth. `Analytics.init(...)` wires core natively via
|
|
30
|
-
* `configureObservability` and touches no JS flag, so an analytics-only app
|
|
31
|
-
* has core configured while every JS flag reads `false` — exactly the case
|
|
32
|
-
* {@link isCoreConfigured} documents. Skipping this step would keep the most
|
|
33
|
-
* common core-only integration broken.
|
|
34
|
-
*
|
|
35
|
-
* Never consults the purchase flag. Strictly more permissive than
|
|
36
|
-
* {@link throwIfNotConfigured}, so no existing caller can break.
|
|
37
|
-
*/
|
|
38
|
-
declare function throwIfCoreNotConfigured(): Promise<void>;
|
|
39
|
-
/**
|
|
40
|
-
* RC-compatible subscriptions SDK entry point. Process-wide singleton; call
|
|
41
|
-
* `Purchases.configure(...)` once at app start, then use the static methods.
|
|
6
|
+
* New code should bootstrap through {@link SwissKnife} — `SwissKnife.configure(…)`
|
|
7
|
+
* — and reach the store through this class. Code migrating from
|
|
8
|
+
* `react-native-purchases` can keep calling `Purchases.configure(…)`: it is the
|
|
9
|
+
* same function.
|
|
42
10
|
*/
|
|
43
11
|
export declare class Purchases {
|
|
44
12
|
/**
|
|
45
13
|
* Configure the SDK. Must be called before any other method. Calling again
|
|
46
|
-
* with the same API key is a no-op
|
|
47
|
-
*
|
|
14
|
+
* with the same API key is a no-op; the native layer owns full reconfiguration.
|
|
15
|
+
*
|
|
16
|
+
* RC-compatibility alias for `SwissKnife.configure(...)` — the same function
|
|
17
|
+
* under the name `react-native-purchases` uses. Neither is deprecated.
|
|
48
18
|
*/
|
|
49
|
-
static configure
|
|
50
|
-
logLevel?: LOG_LEVEL;
|
|
51
|
-
}): void;
|
|
19
|
+
static configure: typeof configure;
|
|
52
20
|
/**
|
|
53
21
|
* Configure everything EXCEPT the store: ingest, `Identity`, `Attribution`,
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* Use this when another library already owns in-app purchases. `configure`
|
|
57
|
-
* starts a `StoreKit.Transaction.updates` observer on iOS (whose handler
|
|
58
|
-
* calls `transaction.finish()`) and builds a `BillingClient` on Android —
|
|
59
|
-
* both of which contend with an incumbent IAP SDK. `configureCore` creates
|
|
60
|
-
* neither, and registers no install as a side effect.
|
|
22
|
+
* `Attributes`. Use it when another library already owns in-app purchases.
|
|
61
23
|
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
24
|
+
* Alias for `SwissKnife.configureCore(...)`, which is the name that actually
|
|
25
|
+
* describes the call — nothing about this method concerns purchases, and it is
|
|
26
|
+
* only spelled `Purchases.configureCore` here so that no existing call site
|
|
27
|
+
* breaks. Prefer the `SwissKnife` spelling in new code.
|
|
65
28
|
*/
|
|
66
|
-
static configureCore
|
|
67
|
-
logLevel?: LOG_LEVEL;
|
|
68
|
-
}): void;
|
|
29
|
+
static configureCore: typeof configureCore;
|
|
69
30
|
/**
|
|
70
31
|
* Whether the PURCHASE engine has been configured — i.e. whether the store
|
|
71
|
-
* APIs
|
|
32
|
+
* APIs below can work. Native is the source of truth; never throws or rejects.
|
|
72
33
|
*
|
|
73
|
-
*
|
|
74
|
-
* "configure was called" flag: a brownfield app can configure the SDK from
|
|
75
|
-
* native code, and `Purchases.configure` itself is fire-and-forget, so the
|
|
76
|
-
* JS flag is a request, not a fact.
|
|
77
|
-
*
|
|
78
|
-
* Never throws and never rejects. Resolves `false` when the native module is
|
|
79
|
-
* not linked — see {@link nativeBoolean}. Exactly the same failure semantics
|
|
80
|
-
* as {@link isCoreConfigured}; the two differ only in which native flag they
|
|
81
|
-
* report.
|
|
34
|
+
* RC-compatibility alias for `SwissKnife.isConfigured()`.
|
|
82
35
|
*/
|
|
83
|
-
static isConfigured
|
|
36
|
+
static isConfigured: typeof isConfigured;
|
|
84
37
|
/**
|
|
85
|
-
* Whether the CORE (ingest / Identity / Attribution /
|
|
38
|
+
* Whether the CORE (ingest / Identity / Attribution / Attributes) is
|
|
86
39
|
* configured. True after `configure`, `configureCore`, or `Analytics.init`.
|
|
40
|
+
* Native is the source of truth; never throws or rejects.
|
|
87
41
|
*
|
|
88
|
-
*
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
*
|
|
93
|
-
*
|
|
42
|
+
* Alias for `SwissKnife.isCoreConfigured()`.
|
|
43
|
+
*/
|
|
44
|
+
static isCoreConfigured: typeof isCoreConfigured;
|
|
45
|
+
/**
|
|
46
|
+
* Set the native log level. Process-wide — it governs the store engine, the
|
|
47
|
+
* ingest client, Identity, Attribution and the observability modules alike.
|
|
94
48
|
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
49
|
+
* Alias for `SwissKnife.setLogLevel(...)`, which is where a process-wide
|
|
50
|
+
* setting belongs (and where both native SDKs already put it).
|
|
97
51
|
*/
|
|
98
|
-
static
|
|
52
|
+
static setLogLevel: typeof setLogLevel;
|
|
99
53
|
/** Latest CustomerInfo (entitlements + subscriptions), computed server-side. */
|
|
100
54
|
static getCustomerInfo(): Promise<CustomerInfo>;
|
|
101
55
|
/** Current + all offerings configured for this app. */
|
|
@@ -117,7 +71,7 @@ export declare class Purchases {
|
|
|
117
71
|
* is NOT merged server-side and the call must be retried. Repeat calls with
|
|
118
72
|
* the id already in effect are free (no bridge hop, no request).
|
|
119
73
|
*
|
|
120
|
-
* Works after `
|
|
74
|
+
* Works after `SwissKnife.configure`, `SwissKnife.configureCore`, or
|
|
121
75
|
* `Analytics.init` — the store does not have to be ours.
|
|
122
76
|
*
|
|
123
77
|
* @deprecated Wave 1 — prefer `Identity.logIn(userId)`. This alias exists so
|
|
@@ -165,18 +119,20 @@ export declare class Purchases {
|
|
|
165
119
|
* {@link getAppUserID}.
|
|
166
120
|
*/
|
|
167
121
|
static isAnonymous(): Promise<boolean>;
|
|
168
|
-
/**
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
static
|
|
174
|
-
/** Reserved attribute:
|
|
175
|
-
static
|
|
176
|
-
/** Reserved attribute:
|
|
177
|
-
static
|
|
178
|
-
/**
|
|
179
|
-
static
|
|
122
|
+
/**
|
|
123
|
+
* Set arbitrary subscriber attributes. `null` clears an attribute.
|
|
124
|
+
*
|
|
125
|
+
* RC-compatibility alias for `Attributes.set(...)`. Not deprecated.
|
|
126
|
+
*/
|
|
127
|
+
static setAttributes: (attributes: Record<string, string | null>) => Promise<void>;
|
|
128
|
+
/** Reserved attribute: email. Alias for `Attributes.setEmail(...)`. */
|
|
129
|
+
static setEmail: (email: string | null) => Promise<void>;
|
|
130
|
+
/** Reserved attribute: display name. Alias for `Attributes.setDisplayName(...)`. */
|
|
131
|
+
static setDisplayName: (displayName: string | null) => Promise<void>;
|
|
132
|
+
/** Reserved attribute: phone number. Alias for `Attributes.setPhoneNumber(...)`. */
|
|
133
|
+
static setPhoneNumber: (phoneNumber: string | null) => Promise<void>;
|
|
134
|
+
/** Reserved attribute: push token. Alias for `Attributes.setPushToken(...)`. */
|
|
135
|
+
static setPushToken: (pushToken: string | null) => Promise<void>;
|
|
180
136
|
/** Subscribe to CustomerInfo changes (purchase, renewal, dashboard grant). */
|
|
181
137
|
static addCustomerInfoUpdateListener(listener: CustomerInfoUpdateListener): void;
|
|
182
138
|
/** Remove a previously-registered CustomerInfo update listener. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"purchases.d.ts","sourceRoot":"","sources":["../../../src/purchases.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"purchases.d.ts","sourceRoot":"","sources":["../../../src/purchases.ts"],"names":[],"mappings":"AAgDA,OAAO,EACL,SAAS,EACT,aAAa,EACb,YAAY,EACZ,gBAAgB,EAEhB,WAAW,EACX,wBAAwB,EACxB,oBAAoB,EAErB,MAAM,sBAAmB,CAAC;AAK3B,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,EACrB,kBAAkB,EAClB,WAAW,EACX,0BAA0B,EAC3B,MAAM,YAAS,CAAC;AAoEjB;;;;;;;GAOG;AACH,qBAAa,SAAS;IAOpB;;;;;;OAMG;IACH,MAAM,CAAC,SAAS,mBAAa;IAE7B;;;;;;;;OAQG;IACH,MAAM,CAAC,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;;;;;;OAOG;IACH,MAAM,CAAC,eAAe,IAAI,IAAI;CAK/B;AAGD,OAAO,EACL,oBAAoB,IAAI,sBAAsB,EAC9C,wBAAwB,IAAI,0BAA0B,GACvD,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { configure, configureCore, isConfigured, isCoreConfigured, setLogLevel } from "./internal/config.js";
|
|
2
|
+
import { Attributes } from "./attributes.js";
|
|
3
|
+
import { Attribution } from "./attribution.js";
|
|
4
|
+
import { Identity } from "./identity.js";
|
|
5
|
+
import { Purchases } from "./purchases.js";
|
|
6
|
+
import { Analytics } from "./modules/analytics.js";
|
|
7
|
+
import { CrashReporting } from "./modules/crash-reporting.js";
|
|
8
|
+
import { Performance } from "./modules/performance.js";
|
|
9
|
+
/**
|
|
10
|
+
* The shape of {@link SwissKnife}.
|
|
11
|
+
*
|
|
12
|
+
* Written out rather than inferred because `declaration: true` cannot emit an
|
|
13
|
+
* inferred object type whose members reference types their own module does not
|
|
14
|
+
* export (TS4023) — `CrashReporting`'s internals are the case in point. Every
|
|
15
|
+
* member is a `typeof` query on the thing it re-exports, so this stays a
|
|
16
|
+
* restatement of the wiring and can never disagree with it.
|
|
17
|
+
*/
|
|
18
|
+
export interface SwissKnifeSDK {
|
|
19
|
+
configure: typeof configure;
|
|
20
|
+
configureCore: typeof configureCore;
|
|
21
|
+
isConfigured: typeof isConfigured;
|
|
22
|
+
isCoreConfigured: typeof isCoreConfigured;
|
|
23
|
+
setLogLevel: typeof setLogLevel;
|
|
24
|
+
Purchases: typeof Purchases;
|
|
25
|
+
Identity: typeof Identity;
|
|
26
|
+
Attributes: typeof Attributes;
|
|
27
|
+
Attribution: typeof Attribution;
|
|
28
|
+
Analytics: typeof Analytics;
|
|
29
|
+
CrashReporting: typeof CrashReporting;
|
|
30
|
+
Performance: typeof Performance;
|
|
31
|
+
/** @internal */
|
|
32
|
+
__resetForTests(): void;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The Swiss Knife SDK root — bootstrap plus a handle on every namespace.
|
|
36
|
+
*
|
|
37
|
+
* ```ts
|
|
38
|
+
* import { SwissKnife } from "@app-swiss-knife/react-native-sdk";
|
|
39
|
+
*
|
|
40
|
+
* // Full SDK, we own the store:
|
|
41
|
+
* SwissKnife.configure({ apiKey: "sk_live_…", proxyURL: "https://…" });
|
|
42
|
+
*
|
|
43
|
+
* // Another library owns in-app purchases:
|
|
44
|
+
* SwissKnife.configureCore({ apiKey: "sk_live_…", proxyURL: "https://…" });
|
|
45
|
+
*
|
|
46
|
+
* await SwissKnife.Identity.logIn("user_42");
|
|
47
|
+
* await SwissKnife.Attributes.setEmail("ann@example.com");
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* `Purchases.configure` / `Purchases.configureCore` are RC-compatibility
|
|
51
|
+
* aliases for the first two and remain fully supported — they are the *same
|
|
52
|
+
* functions*, so an app that mixes the spellings shares one bootstrap state.
|
|
53
|
+
*/
|
|
54
|
+
export declare const SwissKnife: SwissKnifeSDK;
|
|
55
|
+
export default SwissKnife;
|
|
56
|
+
//# sourceMappingURL=swiss-knife.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swiss-knife.d.ts","sourceRoot":"","sources":["../../../src/swiss-knife.ts"],"names":[],"mappings":"AAsCA,OAAO,EACL,SAAS,EACT,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACZ,MAAM,sBAAmB,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAc,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAe,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAY,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAqB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA2B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAAuB,CAAC;AAEpD;;;;;;;;GAQG;AACH,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,OAAO,SAAS,CAAC;IAC5B,aAAa,EAAE,OAAO,aAAa,CAAC;IACpC,YAAY,EAAE,OAAO,YAAY,CAAC;IAClC,gBAAgB,EAAE,OAAO,gBAAgB,CAAC;IAC1C,WAAW,EAAE,OAAO,WAAW,CAAC;IAChC,SAAS,EAAE,OAAO,SAAS,CAAC;IAC5B,QAAQ,EAAE,OAAO,QAAQ,CAAC;IAC1B,UAAU,EAAE,OAAO,UAAU,CAAC;IAC9B,WAAW,EAAE,OAAO,WAAW,CAAC;IAChC,SAAS,EAAE,OAAO,SAAS,CAAC;IAC5B,cAAc,EAAE,OAAO,cAAc,CAAC;IACtC,WAAW,EAAE,OAAO,WAAW,CAAC;IAChC,gBAAgB;IAChB,eAAe,IAAI,IAAI,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,UAAU,EAAE,aAgCxB,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -384,6 +384,19 @@ export interface PurchasesConfiguration {
|
|
|
384
384
|
entitlementVerificationMode?: string;
|
|
385
385
|
pendingTransactionsForPrepaidPlansEnabled?: boolean;
|
|
386
386
|
}
|
|
387
|
+
/**
|
|
388
|
+
* Options accepted by `SwissKnife.configure(...)` / `SwissKnife.configureCore(...)`
|
|
389
|
+
* — and, identically, by their `Purchases.*` RC-compatibility aliases.
|
|
390
|
+
*
|
|
391
|
+
* A name for what the two bootstrap entry points have always taken:
|
|
392
|
+
* `PurchasesConfiguration & { logLevel?: LOG_LEVEL }`. `logLevel` is not part of
|
|
393
|
+
* RevenueCat's `PurchasesConfiguration`, so it cannot go on that interface
|
|
394
|
+
* without breaking the mirror; it is accepted here because setting the log level
|
|
395
|
+
* *after* configure is too late to debug the configure itself.
|
|
396
|
+
*/
|
|
397
|
+
export type ConfigureOptions = PurchasesConfiguration & {
|
|
398
|
+
logLevel?: LOG_LEVEL;
|
|
399
|
+
};
|
|
387
400
|
/**
|
|
388
401
|
* Callback signature for `Purchases.addCustomerInfoUpdateListener(fn)`. Fires
|
|
389
402
|
* on every CustomerInfo refresh (post-purchase, post-restore, dashboard-grant
|
|
@@ -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,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0.3.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",
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// packages/react-native-sdk/src/attributes.ts
|
|
2
|
+
//
|
|
3
|
+
// Subscriber attributes as a peer namespace, alongside `Identity`,
|
|
4
|
+
// `Attribution`, `Analytics`, `CrashReporting` and `Performance`.
|
|
5
|
+
//
|
|
6
|
+
// ## Why this is not on `Purchases`
|
|
7
|
+
//
|
|
8
|
+
// Attributes describe the *person*, not the purchase. They are the only path to
|
|
9
|
+
// `POST /api/sdk/users/attributes` → `app_users.properties`, which is what the
|
|
10
|
+
// dashboard person card renders — and an app with no in-app purchases at all
|
|
11
|
+
// still wants that card filled in. Reaching it through an object named
|
|
12
|
+
// `Purchases` is a false statement about what the call does, and in practice it
|
|
13
|
+
// is the single hardest surface in this SDK to find: "which call fills the
|
|
14
|
+
// person card?" was the question that cost our integrators the most time.
|
|
15
|
+
//
|
|
16
|
+
// It also disagreed with the guard. These five have been gated on
|
|
17
|
+
// `throwIfCoreNotConfigured` — *not* the purchase guard — since the
|
|
18
|
+
// core/purchases split, precisely because a `configureCore` app (another
|
|
19
|
+
// library owns the store) must still be able to set them. A method that works
|
|
20
|
+
// without the store had no business living on the store namespace.
|
|
21
|
+
//
|
|
22
|
+
// ## Method naming
|
|
23
|
+
//
|
|
24
|
+
// `set` rather than `setAttributes`: `Attributes.setAttributes({...})` stutters,
|
|
25
|
+
// and the namespace already says what is being set. The four reserved keys keep
|
|
26
|
+
// their `setX` spelling — `Attributes.setEmail(...)` reads correctly, does not
|
|
27
|
+
// stutter, and matches the native spelling on both platforms
|
|
28
|
+
// (`SwissKnife.setEmail` on iOS, the `setEmail` bridge method on Android), so
|
|
29
|
+
// there is one name to learn across all three SDKs. Dropping the prefix
|
|
30
|
+
// (`Attributes.email(...)`) would read as a getter.
|
|
31
|
+
//
|
|
32
|
+
// The RC-compatible spellings on `Purchases` are the *same function objects* as
|
|
33
|
+
// these — see `src/internal/config.ts` for why that matters and
|
|
34
|
+
// `src/namespaces.test.ts` for the assertion.
|
|
35
|
+
|
|
36
|
+
import { getNativeModule } from "./native/module";
|
|
37
|
+
import { throwIfCoreNotConfigured } from "./internal/config";
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Set arbitrary subscriber attributes. `null` clears an attribute.
|
|
41
|
+
*
|
|
42
|
+
* Works after `SwissKnife.configure`, `SwissKnife.configureCore`, or
|
|
43
|
+
* `Analytics.init` — the store does not have to be ours, and does not have to
|
|
44
|
+
* exist.
|
|
45
|
+
*/
|
|
46
|
+
async function set(attributes: Record<string, string | null>): Promise<void> {
|
|
47
|
+
await throwIfCoreNotConfigured();
|
|
48
|
+
return getNativeModule().setAttributes(attributes);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Reserved attribute: email. `null` clears it. */
|
|
52
|
+
async function setEmail(email: string | null): Promise<void> {
|
|
53
|
+
await throwIfCoreNotConfigured();
|
|
54
|
+
return getNativeModule().setEmail(email);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Reserved attribute: display name. `null` clears it. */
|
|
58
|
+
async function setDisplayName(displayName: string | null): Promise<void> {
|
|
59
|
+
await throwIfCoreNotConfigured();
|
|
60
|
+
return getNativeModule().setDisplayName(displayName);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Reserved attribute: phone number. `null` clears it. */
|
|
64
|
+
async function setPhoneNumber(phoneNumber: string | null): Promise<void> {
|
|
65
|
+
await throwIfCoreNotConfigured();
|
|
66
|
+
return getNativeModule().setPhoneNumber(phoneNumber);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Reserved attribute: push token. `null` clears it. */
|
|
70
|
+
async function setPushToken(pushToken: string | null): Promise<void> {
|
|
71
|
+
await throwIfCoreNotConfigured();
|
|
72
|
+
return getNativeModule().setPushToken(pushToken);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Subscriber attributes — the data behind the dashboard person card.
|
|
77
|
+
*
|
|
78
|
+
* ```ts
|
|
79
|
+
* import { Attributes } from "@app-swiss-knife/react-native-sdk";
|
|
80
|
+
*
|
|
81
|
+
* await Attributes.setEmail("ann@example.com");
|
|
82
|
+
* await Attributes.setDisplayName("Ann");
|
|
83
|
+
* await Attributes.set({ plan: "gold", cohort: "2026-08" });
|
|
84
|
+
* await Attributes.set({ cohort: null }); // clear
|
|
85
|
+
* ```
|
|
86
|
+
*
|
|
87
|
+
* Every method requires core to be configured and rejects with
|
|
88
|
+
* `UninitializedPurchasesError` otherwise. None of them touch StoreKit or Play
|
|
89
|
+
* Billing.
|
|
90
|
+
*/
|
|
91
|
+
export const Attributes = {
|
|
92
|
+
set,
|
|
93
|
+
setEmail,
|
|
94
|
+
setDisplayName,
|
|
95
|
+
setPhoneNumber,
|
|
96
|
+
setPushToken,
|
|
97
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -7,9 +7,26 @@ export default Purchases;
|
|
|
7
7
|
// Named export of the class for `import { Purchases } from '...'`.
|
|
8
8
|
export { Purchases };
|
|
9
9
|
|
|
10
|
+
// The SDK root — bootstrap (`configure`, `configureCore`, `isConfigured`,
|
|
11
|
+
// `isCoreConfigured`, `setLogLevel`) plus a handle on every namespace, so
|
|
12
|
+
// `SwissKnife.` lists the whole SDK. Mirrors the native SDKs, which have rooted
|
|
13
|
+
// everything under `SwissKnife` (iOS) / `com.appswissknife.SwissKnife`
|
|
14
|
+
// (Android) all along; JS had no root at all until now.
|
|
15
|
+
//
|
|
16
|
+
// `Purchases.configure` and friends remain — they are the SAME functions, not
|
|
17
|
+
// wrappers, so mixing the spellings shares one bootstrap state.
|
|
18
|
+
export { SwissKnife } from "./swiss-knife";
|
|
19
|
+
|
|
20
|
+
// Subscriber attributes as a peer namespace. This is the surface behind the
|
|
21
|
+
// dashboard person card (`POST /api/sdk/users/attributes`), and it needs only
|
|
22
|
+
// core — an app with no in-app purchases still wants it. The RC-compatible
|
|
23
|
+
// `Purchases.setAttributes` / `setEmail` / … aliases are the same functions.
|
|
24
|
+
export { Attributes } from "./attributes";
|
|
25
|
+
|
|
10
26
|
// Public type/enum/error surface (CustomerInfo, PurchasesOfferings,
|
|
11
|
-
// PURCHASES_ERROR_CODE, LOG_LEVEL, the enums,
|
|
12
|
-
// defined in ./types (Phase 7: own definitions, no RC
|
|
27
|
+
// PURCHASES_ERROR_CODE, LOG_LEVEL, ConfigureOptions, the enums,
|
|
28
|
+
// PurchasesError, etc.) — defined in ./types (Phase 7: own definitions, no RC
|
|
29
|
+
// dependency).
|
|
13
30
|
export * from "./types";
|
|
14
31
|
|
|
15
32
|
// Wave 1 — unified Identity surface. Routes through native
|