@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.
- package/README.md +100 -47
- package/SwissKnifePurchases.podspec +8 -5
- package/android/src/main/java/com/swissknife/purchases/SwissKnifePurchasesModule.kt +18 -1
- package/android/vendor/java/com/appswissknife/context/DeviceContext.kt +1 -1
- package/android/vendor/java/com/appswissknife/net/IngestClient.kt +1 -1
- package/android/vendor/java/com/appswissknife/purchases/BillingClientGateway.kt +53 -9
- package/ios/SwissKnifeCrashReporting.swift +59 -18
- package/ios/SwissKnifePurchases.swift +16 -1
- 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 +324 -218
- 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 +309 -212
- 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 +103 -95
- 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 +103 -95
- 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 +320 -228
- package/src/swiss-knife.ts +134 -0
- package/src/types.ts +14 -0
|
@@ -1,96 +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
|
-
* and the RC-parity identity aliases that route through the store gateway on
|
|
5
|
-
* Android. Checks the JS "configure was called" flag.
|
|
6
|
-
*/
|
|
7
|
-
declare function throwIfNotConfigured(): void;
|
|
8
|
-
/**
|
|
9
|
-
* Guard for surfaces that only need CORE — the subscriber-attribute setters.
|
|
10
|
-
*
|
|
11
|
-
* Attributes describe the *person*, not the purchase: natively they land in
|
|
12
|
-
* `AttributesClient` → `POST /api/sdk/users/attributes` → `app_users.properties`,
|
|
13
|
-
* which is what the dashboard person card reads. Neither platform's attributes
|
|
14
|
-
* path touches StoreKit or Play Billing — iOS gates on `SwissKnife.isCoreConfigured`
|
|
15
|
-
* (`SwissKnife.currentAnonymousIdForAttributes`), and Android's `configureCore`
|
|
16
|
-
* wires `AttributesClient` with an `Identity`-snapshot id fallback precisely so a
|
|
17
|
-
* store-less app still resolves ids. Gating these on the purchase flag left an app
|
|
18
|
-
* that uses `configureCore` (because another library owns the store) with **no way
|
|
19
|
-
* at all** to populate the person card.
|
|
20
|
-
*
|
|
21
|
-
* Two-step check, and the second step is load-bearing:
|
|
4
|
+
* RC-compatible subscriptions SDK entry point. Process-wide singleton.
|
|
22
5
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* {@link isCoreConfigured} documents. Skipping this step would keep the most
|
|
28
|
-
* common core-only integration broken.
|
|
29
|
-
*
|
|
30
|
-
* Never consults the purchase flag. Strictly more permissive than
|
|
31
|
-
* {@link throwIfNotConfigured}, so no existing caller can break.
|
|
32
|
-
*/
|
|
33
|
-
declare function throwIfCoreNotConfigured(): Promise<void>;
|
|
34
|
-
/**
|
|
35
|
-
* RC-compatible subscriptions SDK entry point. Process-wide singleton; call
|
|
36
|
-
* `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.
|
|
37
10
|
*/
|
|
38
11
|
export declare class Purchases {
|
|
39
12
|
/**
|
|
40
13
|
* Configure the SDK. Must be called before any other method. Calling again
|
|
41
|
-
* with the same API key is a no-op
|
|
42
|
-
*
|
|
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.
|
|
43
18
|
*/
|
|
44
|
-
static configure
|
|
45
|
-
logLevel?: LOG_LEVEL;
|
|
46
|
-
}): void;
|
|
19
|
+
static configure: typeof configure;
|
|
47
20
|
/**
|
|
48
21
|
* Configure everything EXCEPT the store: ingest, `Identity`, `Attribution`,
|
|
49
|
-
*
|
|
22
|
+
* `Attributes`. Use it when another library already owns in-app purchases.
|
|
50
23
|
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* neither, and registers no install as a side effect.
|
|
56
|
-
*
|
|
57
|
-
* Analytics-only apps don't even need this: `Analytics.init(...)` already
|
|
58
|
-
* wires core natively. Reach for `configureCore` when you want to pass an
|
|
59
|
-
* `appUserID`, an attribution configuration, or a log level up front.
|
|
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.
|
|
60
28
|
*/
|
|
61
|
-
static configureCore
|
|
62
|
-
logLevel?: LOG_LEVEL;
|
|
63
|
-
}): void;
|
|
29
|
+
static configureCore: typeof configureCore;
|
|
64
30
|
/**
|
|
65
31
|
* Whether the PURCHASE engine has been configured — i.e. whether the store
|
|
66
|
-
* APIs
|
|
67
|
-
*
|
|
68
|
-
* **Native is the source of truth.** This does not consult the JS-side
|
|
69
|
-
* "configure was called" flag: a brownfield app can configure the SDK from
|
|
70
|
-
* native code, and `Purchases.configure` itself is fire-and-forget, so the
|
|
71
|
-
* JS flag is a request, not a fact.
|
|
32
|
+
* APIs below can work. Native is the source of truth; never throws or rejects.
|
|
72
33
|
*
|
|
73
|
-
*
|
|
74
|
-
* not linked — see {@link nativeBoolean}. Exactly the same failure semantics
|
|
75
|
-
* as {@link isCoreConfigured}; the two differ only in which native flag they
|
|
76
|
-
* report.
|
|
34
|
+
* RC-compatibility alias for `SwissKnife.isConfigured()`.
|
|
77
35
|
*/
|
|
78
|
-
static isConfigured
|
|
36
|
+
static isConfigured: typeof isConfigured;
|
|
79
37
|
/**
|
|
80
|
-
* Whether the CORE (ingest / Identity / Attribution /
|
|
38
|
+
* Whether the CORE (ingest / Identity / Attribution / Attributes) is
|
|
81
39
|
* configured. True after `configure`, `configureCore`, or `Analytics.init`.
|
|
40
|
+
* Native is the source of truth; never throws or rejects.
|
|
82
41
|
*
|
|
83
|
-
*
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
*
|
|
88
|
-
*
|
|
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.
|
|
89
48
|
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
49
|
+
* Alias for `SwissKnife.setLogLevel(...)`, which is where a process-wide
|
|
50
|
+
* setting belongs (and where both native SDKs already put it).
|
|
92
51
|
*/
|
|
93
|
-
static
|
|
52
|
+
static setLogLevel: typeof setLogLevel;
|
|
94
53
|
/** Latest CustomerInfo (entitlements + subscriptions), computed server-side. */
|
|
95
54
|
static getCustomerInfo(): Promise<CustomerInfo>;
|
|
96
55
|
/** Current + all offerings configured for this app. */
|
|
@@ -102,41 +61,90 @@ export declare class Purchases {
|
|
|
102
61
|
/** Restore purchases tied to the underlying store account. */
|
|
103
62
|
static restorePurchases(): Promise<CustomerInfo>;
|
|
104
63
|
/**
|
|
105
|
-
* Identify the user
|
|
64
|
+
* Identify the user, merging the anonymous subject into `appUserID`
|
|
65
|
+
* server-side.
|
|
106
66
|
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
67
|
+
* Exactly `Identity.logIn(appUserID)` with the RevenueCat name. On both
|
|
68
|
+
* platforms this POSTs `(anonymous_id, user_id)` to
|
|
69
|
+
* `/api/sdk/users/identify` and resolves once the backend ack and the
|
|
70
|
+
* post-identify entitlements refresh complete; a rejection means the device
|
|
71
|
+
* is NOT merged server-side and the call must be retried. Repeat calls with
|
|
72
|
+
* the id already in effect are free (no bridge hop, no request).
|
|
73
|
+
*
|
|
74
|
+
* Works after `SwissKnife.configure`, `SwissKnife.configureCore`, or
|
|
75
|
+
* `Analytics.init` — the store does not have to be ours.
|
|
76
|
+
*
|
|
77
|
+
* @deprecated Wave 1 — prefer `Identity.logIn(userId)`. This alias exists so
|
|
78
|
+
* RevenueCat migrations compile unchanged; it is a pure delegation, so there
|
|
79
|
+
* is nothing to gain by keeping it and one less name to learn by dropping it.
|
|
111
80
|
*/
|
|
112
81
|
static logIn(appUserID: string): Promise<LogInResult>;
|
|
113
82
|
/**
|
|
114
|
-
* Log out the current user and revert to anonymous.
|
|
83
|
+
* Log out the current user and revert to anonymous. The device id survives,
|
|
84
|
+
* so analytics continuity for the same physical install is preserved.
|
|
85
|
+
*
|
|
86
|
+
* Exactly `Identity.logOut()` with the RevenueCat name, plus RC's
|
|
87
|
+
* `CustomerInfo` return: after the logout lands, the post-logout customer
|
|
88
|
+
* info is read back from the store engine. **When no store engine is
|
|
89
|
+
* configured** (`configureCore`, `Analytics.init`) there is nothing to read,
|
|
90
|
+
* and you get an entitlement-free `CustomerInfo` for the anonymous subject —
|
|
91
|
+
* the same record, built in JS, on both platforms. Do not read that as a
|
|
92
|
+
* store error; if you want real entitlements, call `getCustomerInfo()`.
|
|
115
93
|
*
|
|
116
|
-
* @deprecated Wave 1 — prefer `Identity.logOut()
|
|
94
|
+
* @deprecated Wave 1 — prefer `Identity.logOut()`, which does not pretend to
|
|
95
|
+
* return store state.
|
|
117
96
|
*/
|
|
118
97
|
static logOut(): Promise<CustomerInfo>;
|
|
119
|
-
/**
|
|
98
|
+
/**
|
|
99
|
+
* The current subject id — the identified user id if there is one, else the
|
|
100
|
+
* SDK's anonymous id (`$SKAnonymousID:`-prefixed, stable across launches).
|
|
101
|
+
*
|
|
102
|
+
* Exactly `(await Identity.current()).userId ?? .anonymousId`. Note this is
|
|
103
|
+
* the *Identity* subject on both platforms; on Android the purchase
|
|
104
|
+
* gateway's own anonymous id is a different, per-process value, and this
|
|
105
|
+
* alias deliberately does not report it.
|
|
106
|
+
*
|
|
107
|
+
* @deprecated Wave 1 — prefer `Identity.current()`, which hands back the
|
|
108
|
+
* anonymous id, the user id and `isAnonymous` in one read instead of forcing
|
|
109
|
+
* two calls that can interleave.
|
|
110
|
+
*/
|
|
120
111
|
static getAppUserID(): Promise<string>;
|
|
121
|
-
/**
|
|
112
|
+
/**
|
|
113
|
+
* Whether the current subject is the SDK-generated anonymous id.
|
|
114
|
+
*
|
|
115
|
+
* Exactly `(await Identity.current()).isAnonymous`, so it tracks
|
|
116
|
+
* `Identity.reset()` and `Identity.wipe()` on both platforms.
|
|
117
|
+
*
|
|
118
|
+
* @deprecated Wave 1 — prefer `Identity.current()`; see
|
|
119
|
+
* {@link getAppUserID}.
|
|
120
|
+
*/
|
|
122
121
|
static isAnonymous(): Promise<boolean>;
|
|
123
|
-
/**
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
static
|
|
129
|
-
/** Reserved attribute:
|
|
130
|
-
static
|
|
131
|
-
/** Reserved attribute:
|
|
132
|
-
static
|
|
133
|
-
/**
|
|
134
|
-
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>;
|
|
135
136
|
/** Subscribe to CustomerInfo changes (purchase, renewal, dashboard grant). */
|
|
136
137
|
static addCustomerInfoUpdateListener(listener: CustomerInfoUpdateListener): void;
|
|
137
138
|
/** Remove a previously-registered CustomerInfo update listener. */
|
|
138
139
|
static removeCustomerInfoUpdateListener(listener: CustomerInfoUpdateListener): void;
|
|
139
|
-
/**
|
|
140
|
+
/**
|
|
141
|
+
* @internal Test seam: reset singleton state between tests.
|
|
142
|
+
*
|
|
143
|
+
* Also resets `Identity`'s caches, because the RC-parity aliases delegate
|
|
144
|
+
* there: without it, a `Purchases.logIn("u")` in one test would leave
|
|
145
|
+
* `Identity`'s `lastLogIn` primed and the next test's identical call would
|
|
146
|
+
* short-circuit before reaching the (freshly mocked) bridge.
|
|
147
|
+
*/
|
|
140
148
|
static __resetForTests(): void;
|
|
141
149
|
}
|
|
142
150
|
export { throwIfNotConfigured as __throwIfNotConfigured, throwIfCoreNotConfigured as __throwIfCoreNotConfigured, };
|
|
@@ -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,aAAa,uBAAiB;IAErC;;;;;OAKG;IACH,MAAM,CAAC,YAAY,sBAAgB;IAEnC;;;;;;OAMG;IACH,MAAM,CAAC,gBAAgB,0BAAoB;IAE3C;;;;;;OAMG;IACH,MAAM,CAAC,WAAW,qBAAe;IAOjC,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;IA2EtD;;;;;;;;;;;;;;;;;OAiBG;WACU,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAK3D;;;;;;;;;;;;;;OAcG;WACU,MAAM,IAAI,OAAO,CAAC,YAAY,CAAC;IAM5C;;;;;;;;;;;;OAYG;WACU,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC;IAM5C;;;;;;;;OAQG;WACU,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAe5C;;;;OAIG;IACH,MAAM,CAAC,aAAa,+DAAkB;IAEtC,uEAAuE;IACvE,MAAM,CAAC,QAAQ,0CAAuB;IAEtC,oFAAoF;IACpF,MAAM,CAAC,cAAc,gDAA6B;IAElD,oFAAoF;IACpF,MAAM,CAAC,cAAc,gDAA6B;IAElD,gFAAgF;IAChF,MAAM,CAAC,YAAY,8CAA2B;IAO9C,8EAA8E;IAC9E,MAAM,CAAC,6BAA6B,CAClC,QAAQ,EAAE,0BAA0B,GACnC,IAAI;IAQP,mEAAmE;IACnE,MAAM,CAAC,gCAAgC,CACrC,QAAQ,EAAE,0BAA0B,GACnC,IAAI;IAQP;;;;;;;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,gBAAg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,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;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,gBAAgB,GAAG,sBAAsB,GAAG;IACtD,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,CAAC;AAIF;;;;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.
|
|
3
|
+
"version": "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
|