@app-swiss-knife/react-native-sdk 0.2.7 → 0.3.1
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 +51 -1
- package/ios/vendor/SwissKnifeiOS/DeviceID.swift +22 -1
- package/ios/vendor/SwissKnifeiOS/Identity/Identity.swift +105 -7
- 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
package/lib/module/purchases.js
CHANGED
|
@@ -1,89 +1,60 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
// src/purchases.ts
|
|
4
|
+
//
|
|
5
|
+
// The RevenueCat-compatible surface. Everything a `react-native-purchases`
|
|
6
|
+
// migration can call, spelled the way RevenueCat spells it.
|
|
7
|
+
//
|
|
8
|
+
// ## What this file is, after the namespace split
|
|
9
|
+
//
|
|
10
|
+
// `Purchases` used to be the whole SDK: the store, both bootstraps, subscriber
|
|
11
|
+
// attributes and the identity aliases, twenty-one statics across four unrelated
|
|
12
|
+
// concerns — while `Identity`, `Attribution`, `Analytics`, `CrashReporting` and
|
|
13
|
+
// `Performance` sat beside it as peer namespaces. Two organising principles at
|
|
14
|
+
// once, and the seams showed: `Purchases.configureCore()` is a call whose entire
|
|
15
|
+
// meaning is "I do not want the store", and an app with no purchases in it set
|
|
16
|
+
// its user data through `Purchases.setAttributes`.
|
|
17
|
+
//
|
|
18
|
+
// The store methods below are the ones that genuinely belong here. The rest are
|
|
19
|
+
// **RC-compatibility aliases**, and they are not going anywhere:
|
|
20
|
+
//
|
|
21
|
+
// - bootstrap → `SwissKnife.configure` / `configureCore` / `isConfigured` /
|
|
22
|
+
// `isCoreConfigured` / `setLogLevel` (src/swiss-knife.ts)
|
|
23
|
+
// - attributes → `Attributes.set` / `setEmail` / `setDisplayName` /
|
|
24
|
+
// `setPhoneNumber` / `setPushToken` (src/attributes.ts)
|
|
25
|
+
// - identity → `Identity.logIn` / `logOut` / `current` (src/identity.ts)
|
|
26
|
+
//
|
|
27
|
+
// ## Why the aliases are not deprecated
|
|
28
|
+
//
|
|
29
|
+
// This class exists so that someone migrating off `react-native-purchases` can
|
|
30
|
+
// keep their call sites. Emitting deprecation warnings at exactly those call
|
|
31
|
+
// sites would punish the users the compatibility surface was built for — the
|
|
32
|
+
// migration would arrive pre-broken, with a console full of warnings for code
|
|
33
|
+
// that is doing the right thing. They are documented as aliases and left alone.
|
|
34
|
+
//
|
|
35
|
+
// The four identity aliases are the exception and keep their `@deprecated` tags,
|
|
36
|
+
// because they are a different case: `Identity` is genuinely the canonical home,
|
|
37
|
+
// and the RC names carry return types (`logOut` resolving a `CustomerInfo`) that
|
|
38
|
+
// misdescribe what the call does in a store-less app.
|
|
39
|
+
//
|
|
40
|
+
// ## Why they cannot drift
|
|
41
|
+
//
|
|
42
|
+
// The aliases are not re-implementations and not one-line wrappers: they are the
|
|
43
|
+
// *same function objects* as the canonical methods, assigned as static fields
|
|
44
|
+
// from the modules that own them. `Purchases.configure === SwissKnife.configure`
|
|
45
|
+
// and `Purchases.setAttributes === Attributes.set` are literally true. There is
|
|
46
|
+
// no second copy of the bootstrap state either — see `src/internal/config.ts`.
|
|
47
|
+
// Pinned by `src/namespaces.test.ts`.
|
|
48
|
+
|
|
49
|
+
import { Attributes } from "./attributes.js";
|
|
4
50
|
import { Identity } from "./identity.js";
|
|
51
|
+
import { configure, configureCore, isConfigured, isCoreConfigured, nativeBoolean, setLogLevel, throwIfCoreNotConfigured, throwIfNotConfigured, resetConfigForTests } from "./internal/config.js";
|
|
5
52
|
import { getNativeModule, getEventEmitter } from "./native/module.js";
|
|
6
53
|
import { CUSTOMER_INFO_UPDATED_EVENT } from "./native/spec.js";
|
|
7
|
-
import {
|
|
8
|
-
let configured = false;
|
|
9
|
-
let configuredApiKey = null;
|
|
10
|
-
let coreConfigured = false;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Read a boolean off the native module without ever letting a missing native
|
|
14
|
-
* module escape as an exception.
|
|
15
|
-
*
|
|
16
|
-
* `getNativeModule()` THROWS when the module is not linked (Expo Go, a bare RN
|
|
17
|
-
* app that skipped `pod install` / a Gradle sync, web) — precisely the state a
|
|
18
|
-
* developer is in while wiring the SDK up, and precisely when they are most
|
|
19
|
-
* likely to be calling one of these accessors to find out what is wrong. A
|
|
20
|
-
* boolean accessor rejecting with "native module is not linked" is a worse
|
|
21
|
-
* answer than `false`: an unlinked module cannot have configured anything, so
|
|
22
|
-
* `false` is not merely safe, it is correct.
|
|
23
|
-
*
|
|
24
|
-
* The `.catch` covers the adjacent case where the module IS linked but predates
|
|
25
|
-
* the method (JS upgraded without rebuilding the app) — same reasoning, same
|
|
26
|
-
* answer. Mirrors the tolerance `Analytics.init` already applies to
|
|
27
|
-
* `configureObservability`.
|
|
28
|
-
*/
|
|
29
|
-
function nativeBoolean(read) {
|
|
30
|
-
try {
|
|
31
|
-
return Promise.resolve(read(getNativeModule())).catch(() => false);
|
|
32
|
-
} catch {
|
|
33
|
-
return Promise.resolve(false);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
54
|
+
import { VERIFICATION_RESULT } from "./types.js";
|
|
37
55
|
// Maps a caller's listener fn to its native subscription so we can remove it.
|
|
38
56
|
const customerInfoSubscriptions = new Map();
|
|
39
57
|
|
|
40
|
-
/**
|
|
41
|
-
* Guard for surfaces that genuinely need the PURCHASE engine — `getOfferings`,
|
|
42
|
-
* `purchasePackage`, `restorePurchases` and friends. Checks the JS "configure
|
|
43
|
-
* was called" flag.
|
|
44
|
-
*
|
|
45
|
-
* The RC-parity identity aliases used to sit here too, on the grounds that the
|
|
46
|
-
* legacy native bridge methods they called meant different things on iOS and
|
|
47
|
-
* Android. They now delegate to `Identity` and sit on
|
|
48
|
-
* {@link throwIfCoreNotConfigured} — see the block above `logIn`.
|
|
49
|
-
*/
|
|
50
|
-
function throwIfNotConfigured() {
|
|
51
|
-
if (!configured) {
|
|
52
|
-
throw new UninitializedPurchasesError();
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Guard for surfaces that only need CORE — the subscriber-attribute setters.
|
|
58
|
-
*
|
|
59
|
-
* Attributes describe the *person*, not the purchase: natively they land in
|
|
60
|
-
* `AttributesClient` → `POST /api/sdk/users/attributes` → `app_users.properties`,
|
|
61
|
-
* which is what the dashboard person card reads. Neither platform's attributes
|
|
62
|
-
* path touches StoreKit or Play Billing — iOS gates on `SwissKnife.isCoreConfigured`
|
|
63
|
-
* (`SwissKnife.currentAnonymousIdForAttributes`), and Android's `configureCore`
|
|
64
|
-
* wires `AttributesClient` with an `Identity`-snapshot id fallback precisely so a
|
|
65
|
-
* store-less app still resolves ids. Gating these on the purchase flag left an app
|
|
66
|
-
* that uses `configureCore` (because another library owns the store) with **no way
|
|
67
|
-
* at all** to populate the person card.
|
|
68
|
-
*
|
|
69
|
-
* Two-step check, and the second step is load-bearing:
|
|
70
|
-
*
|
|
71
|
-
* 1. The JS flag, set by `configure` / `configureCore`. Free, no bridge hop.
|
|
72
|
-
* 2. Native truth. `Analytics.init(...)` wires core natively via
|
|
73
|
-
* `configureObservability` and touches no JS flag, so an analytics-only app
|
|
74
|
-
* has core configured while every JS flag reads `false` — exactly the case
|
|
75
|
-
* {@link isCoreConfigured} documents. Skipping this step would keep the most
|
|
76
|
-
* common core-only integration broken.
|
|
77
|
-
*
|
|
78
|
-
* Never consults the purchase flag. Strictly more permissive than
|
|
79
|
-
* {@link throwIfNotConfigured}, so no existing caller can break.
|
|
80
|
-
*/
|
|
81
|
-
async function throwIfCoreNotConfigured() {
|
|
82
|
-
if (coreConfigured) return;
|
|
83
|
-
if (await nativeBoolean(native => native.isCoreConfigured())) return;
|
|
84
|
-
throw new UninitializedPurchasesError("Purchases core is not configured. Call Purchases.configure(), " + "Purchases.configureCore(), or Analytics.init() first.");
|
|
85
|
-
}
|
|
86
|
-
|
|
87
58
|
/**
|
|
88
59
|
* The `CustomerInfo` RC's `logOut()` resolves with, for a device that just
|
|
89
60
|
* became anonymous.
|
|
@@ -145,111 +116,70 @@ function emptyCustomerInfo(subjectId) {
|
|
|
145
116
|
}
|
|
146
117
|
|
|
147
118
|
/**
|
|
148
|
-
* RC-compatible subscriptions SDK entry point. Process-wide singleton
|
|
149
|
-
*
|
|
119
|
+
* RC-compatible subscriptions SDK entry point. Process-wide singleton.
|
|
120
|
+
*
|
|
121
|
+
* New code should bootstrap through {@link SwissKnife} — `SwissKnife.configure(…)`
|
|
122
|
+
* — and reach the store through this class. Code migrating from
|
|
123
|
+
* `react-native-purchases` can keep calling `Purchases.configure(…)`: it is the
|
|
124
|
+
* same function.
|
|
150
125
|
*/
|
|
151
126
|
export class Purchases {
|
|
127
|
+
// MARK: - Bootstrap (RC-compatibility aliases for `SwissKnife.*`)
|
|
128
|
+
//
|
|
129
|
+
// Assigned, not wrapped: these ARE `SwissKnife.configure` and friends. The
|
|
130
|
+
// configure state lives in one module (`./internal/config`), so mixing the two
|
|
131
|
+
// spellings in one app is not merely allowed, it is indistinguishable.
|
|
132
|
+
|
|
152
133
|
/**
|
|
153
134
|
* Configure the SDK. Must be called before any other method. Calling again
|
|
154
|
-
* with the same API key is a no-op
|
|
155
|
-
*
|
|
135
|
+
* with the same API key is a no-op; the native layer owns full reconfiguration.
|
|
136
|
+
*
|
|
137
|
+
* RC-compatibility alias for `SwissKnife.configure(...)` — the same function
|
|
138
|
+
* under the name `react-native-purchases` uses. Neither is deprecated.
|
|
156
139
|
*/
|
|
157
|
-
static configure
|
|
158
|
-
if (configured && configuredApiKey === options.apiKey) return;
|
|
159
|
-
const native = getNativeModule();
|
|
160
|
-
const nativeOptions = {
|
|
161
|
-
apiKey: options.apiKey,
|
|
162
|
-
appUserID: options.appUserID ?? null,
|
|
163
|
-
// proxyURL points the native SDK at the Swiss Knife backend. Without it the
|
|
164
|
-
// native layer falls back to its hardcoded default host (api.swiss-knife.dev),
|
|
165
|
-
// which is unreachable for self-hosted tenants. Forward it so callers can
|
|
166
|
-
// target their own backend (e.g. https://swiss.remneys.com).
|
|
167
|
-
proxyURL: options.proxyURL ?? null,
|
|
168
|
-
// Hardening pass (spec): diagnostics opt-in only — default OFF.
|
|
169
|
-
diagnosticsEnabled: options.diagnosticsEnabled ?? false,
|
|
170
|
-
storeKitVersion: options.storeKitVersion,
|
|
171
|
-
useAmazon: options.useAmazon,
|
|
172
|
-
// iOS ATT — default off (no tracking prompt) unless the host opts in.
|
|
173
|
-
autoPromptATT: options.autoPromptATT,
|
|
174
|
-
sendInstallOnFirstLaunch: options.sendInstallOnFirstLaunch,
|
|
175
|
-
logLevel: options.logLevel
|
|
176
|
-
};
|
|
177
|
-
// Fire-and-forget: native configure resolves async but RC's configure is sync.
|
|
178
|
-
void native.configure(nativeOptions);
|
|
179
|
-
configured = true;
|
|
180
|
-
coreConfigured = true;
|
|
181
|
-
configuredApiKey = options.apiKey;
|
|
182
|
-
}
|
|
140
|
+
static configure = configure;
|
|
183
141
|
|
|
184
142
|
/**
|
|
185
143
|
* Configure everything EXCEPT the store: ingest, `Identity`, `Attribution`,
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
* Use this when another library already owns in-app purchases. `configure`
|
|
189
|
-
* starts a `StoreKit.Transaction.updates` observer on iOS (whose handler
|
|
190
|
-
* calls `transaction.finish()`) and builds a `BillingClient` on Android —
|
|
191
|
-
* both of which contend with an incumbent IAP SDK. `configureCore` creates
|
|
192
|
-
* neither, and registers no install as a side effect.
|
|
144
|
+
* `Attributes`. Use it when another library already owns in-app purchases.
|
|
193
145
|
*
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
*
|
|
146
|
+
* Alias for `SwissKnife.configureCore(...)`, which is the name that actually
|
|
147
|
+
* describes the call — nothing about this method concerns purchases, and it is
|
|
148
|
+
* only spelled `Purchases.configureCore` here so that no existing call site
|
|
149
|
+
* breaks. Prefer the `SwissKnife` spelling in new code.
|
|
197
150
|
*/
|
|
198
|
-
static configureCore
|
|
199
|
-
if (coreConfigured && configuredApiKey === options.apiKey) return;
|
|
200
|
-
const native = getNativeModule();
|
|
201
|
-
const nativeOptions = {
|
|
202
|
-
apiKey: options.apiKey,
|
|
203
|
-
appUserID: options.appUserID ?? null,
|
|
204
|
-
proxyURL: options.proxyURL ?? null,
|
|
205
|
-
diagnosticsEnabled: options.diagnosticsEnabled ?? false,
|
|
206
|
-
autoPromptATT: options.autoPromptATT,
|
|
207
|
-
// Forwarded but inert on this path — core never auto-registers an
|
|
208
|
-
// install. Kept on the payload so the same options object can be handed
|
|
209
|
-
// to `configure` later without surprises.
|
|
210
|
-
sendInstallOnFirstLaunch: options.sendInstallOnFirstLaunch,
|
|
211
|
-
logLevel: options.logLevel
|
|
212
|
-
};
|
|
213
|
-
void native.configureCore(nativeOptions);
|
|
214
|
-
coreConfigured = true;
|
|
215
|
-
configuredApiKey = options.apiKey;
|
|
216
|
-
}
|
|
151
|
+
static configureCore = configureCore;
|
|
217
152
|
|
|
218
153
|
/**
|
|
219
154
|
* Whether the PURCHASE engine has been configured — i.e. whether the store
|
|
220
|
-
* APIs
|
|
221
|
-
*
|
|
222
|
-
* **Native is the source of truth.** This does not consult the JS-side
|
|
223
|
-
* "configure was called" flag: a brownfield app can configure the SDK from
|
|
224
|
-
* native code, and `Purchases.configure` itself is fire-and-forget, so the
|
|
225
|
-
* JS flag is a request, not a fact.
|
|
155
|
+
* APIs below can work. Native is the source of truth; never throws or rejects.
|
|
226
156
|
*
|
|
227
|
-
*
|
|
228
|
-
* not linked — see {@link nativeBoolean}. Exactly the same failure semantics
|
|
229
|
-
* as {@link isCoreConfigured}; the two differ only in which native flag they
|
|
230
|
-
* report.
|
|
157
|
+
* RC-compatibility alias for `SwissKnife.isConfigured()`.
|
|
231
158
|
*/
|
|
232
|
-
static isConfigured
|
|
233
|
-
return nativeBoolean(native => native.isConfigured());
|
|
234
|
-
}
|
|
159
|
+
static isConfigured = isConfigured;
|
|
235
160
|
|
|
236
161
|
/**
|
|
237
|
-
* Whether the CORE (ingest / Identity / Attribution /
|
|
162
|
+
* Whether the CORE (ingest / Identity / Attribution / Attributes) is
|
|
238
163
|
* configured. True after `configure`, `configureCore`, or `Analytics.init`.
|
|
164
|
+
* Native is the source of truth; never throws or rejects.
|
|
239
165
|
*
|
|
240
|
-
*
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
*
|
|
166
|
+
* Alias for `SwissKnife.isCoreConfigured()`.
|
|
167
|
+
*/
|
|
168
|
+
static isCoreConfigured = isCoreConfigured;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Set the native log level. Process-wide — it governs the store engine, the
|
|
172
|
+
* ingest client, Identity, Attribution and the observability modules alike.
|
|
246
173
|
*
|
|
247
|
-
*
|
|
248
|
-
*
|
|
174
|
+
* Alias for `SwissKnife.setLogLevel(...)`, which is where a process-wide
|
|
175
|
+
* setting belongs (and where both native SDKs already put it).
|
|
249
176
|
*/
|
|
250
|
-
static
|
|
251
|
-
|
|
252
|
-
|
|
177
|
+
static setLogLevel = setLogLevel;
|
|
178
|
+
|
|
179
|
+
// MARK: - The store
|
|
180
|
+
//
|
|
181
|
+
// These are the methods that genuinely belong on `Purchases`. All of them are
|
|
182
|
+
// gated on the PURCHASE flag.
|
|
253
183
|
|
|
254
184
|
/** Latest CustomerInfo (entitlements + subscriptions), computed server-side. */
|
|
255
185
|
static async getCustomerInfo() {
|
|
@@ -328,9 +258,20 @@ export class Purchases {
|
|
|
328
258
|
// the stale cache and resolved "logged in" without the device ever being
|
|
329
259
|
// re-identified. Routing through `Identity` means one owner for that state.
|
|
330
260
|
//
|
|
261
|
+
// ## Why these four ARE deprecated, when the aliases above are not
|
|
262
|
+
//
|
|
263
|
+
// The bootstrap and attribute aliases are pure renames: same arguments, same
|
|
264
|
+
// return type, same behaviour, and keeping them costs a migrating app nothing.
|
|
265
|
+
// These four are not. `logOut` returns a `CustomerInfo` that is fabricated in
|
|
266
|
+
// a store-less app, `getAppUserID` collapses a three-field snapshot into one
|
|
267
|
+
// string, and `isAnonymous` forces a second round trip to learn what
|
|
268
|
+
// `Identity.current()` already returned. The RC names describe the RC model,
|
|
269
|
+
// not ours, so `Identity.*` is genuinely the better call and not merely the
|
|
270
|
+
// better-organised one. They still work, and will keep working.
|
|
271
|
+
//
|
|
331
272
|
// ## The guard
|
|
332
273
|
//
|
|
333
|
-
// These sit on
|
|
274
|
+
// These sit on `throwIfCoreNotConfigured`, not on the purchase guard.
|
|
334
275
|
// Identity is a core capability — natively both platforms gate it on
|
|
335
276
|
// `isCoreConfigured` — and the single most likely caller of
|
|
336
277
|
// `Purchases.logIn` is an app migrating off RevenueCat that still lets
|
|
@@ -352,7 +293,7 @@ export class Purchases {
|
|
|
352
293
|
* is NOT merged server-side and the call must be retried. Repeat calls with
|
|
353
294
|
* the id already in effect are free (no bridge hop, no request).
|
|
354
295
|
*
|
|
355
|
-
* Works after `
|
|
296
|
+
* Works after `SwissKnife.configure`, `SwissKnife.configureCore`, or
|
|
356
297
|
* `Analytics.init` — the store does not have to be ours.
|
|
357
298
|
*
|
|
358
299
|
* @deprecated Wave 1 — prefer `Identity.logIn(userId)`. This alias exists so
|
|
@@ -418,44 +359,39 @@ export class Purchases {
|
|
|
418
359
|
return (await Identity.current()).isAnonymous;
|
|
419
360
|
}
|
|
420
361
|
|
|
421
|
-
// Subscriber attributes
|
|
422
|
-
//
|
|
423
|
-
//
|
|
362
|
+
// MARK: - Subscriber attributes (RC-compatibility aliases for `Attributes.*`)
|
|
363
|
+
//
|
|
364
|
+
// CORE, not store: all five are gated on `throwIfCoreNotConfigured`, so they
|
|
365
|
+
// work in an app that only called `configureCore` (another library owns the
|
|
366
|
+
// store) or only `Analytics.init`. That is the tell that they never belonged
|
|
367
|
+
// on this class — an app with no purchases at all still needs them, because
|
|
368
|
+
// they are the only path to the dashboard person card.
|
|
369
|
+
//
|
|
370
|
+
// Assigned, not wrapped: `Purchases.setAttributes === Attributes.set`.
|
|
424
371
|
|
|
425
|
-
/**
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
372
|
+
/**
|
|
373
|
+
* Set arbitrary subscriber attributes. `null` clears an attribute.
|
|
374
|
+
*
|
|
375
|
+
* RC-compatibility alias for `Attributes.set(...)`. Not deprecated.
|
|
376
|
+
*/
|
|
377
|
+
static setAttributes = Attributes.set;
|
|
430
378
|
|
|
431
|
-
/** Reserved attribute: email. */
|
|
432
|
-
static
|
|
433
|
-
await throwIfCoreNotConfigured();
|
|
434
|
-
return getNativeModule().setEmail(email);
|
|
435
|
-
}
|
|
379
|
+
/** Reserved attribute: email. Alias for `Attributes.setEmail(...)`. */
|
|
380
|
+
static setEmail = Attributes.setEmail;
|
|
436
381
|
|
|
437
|
-
/** Reserved attribute: display name. */
|
|
438
|
-
static
|
|
439
|
-
await throwIfCoreNotConfigured();
|
|
440
|
-
return getNativeModule().setDisplayName(displayName);
|
|
441
|
-
}
|
|
382
|
+
/** Reserved attribute: display name. Alias for `Attributes.setDisplayName(...)`. */
|
|
383
|
+
static setDisplayName = Attributes.setDisplayName;
|
|
442
384
|
|
|
443
|
-
/** Reserved attribute: phone number. */
|
|
444
|
-
static
|
|
445
|
-
await throwIfCoreNotConfigured();
|
|
446
|
-
return getNativeModule().setPhoneNumber(phoneNumber);
|
|
447
|
-
}
|
|
385
|
+
/** Reserved attribute: phone number. Alias for `Attributes.setPhoneNumber(...)`. */
|
|
386
|
+
static setPhoneNumber = Attributes.setPhoneNumber;
|
|
448
387
|
|
|
449
|
-
/** Reserved attribute: push token. */
|
|
450
|
-
static
|
|
451
|
-
await throwIfCoreNotConfigured();
|
|
452
|
-
return getNativeModule().setPushToken(pushToken);
|
|
453
|
-
}
|
|
388
|
+
/** Reserved attribute: push token. Alias for `Attributes.setPushToken(...)`. */
|
|
389
|
+
static setPushToken = Attributes.setPushToken;
|
|
454
390
|
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
391
|
+
// MARK: - CustomerInfo listeners
|
|
392
|
+
//
|
|
393
|
+
// Store surface: these fire on purchase, renewal and dashboard grant, so they
|
|
394
|
+
// stay here rather than moving to the root.
|
|
459
395
|
|
|
460
396
|
/** Subscribe to CustomerInfo changes (purchase, renewal, dashboard grant). */
|
|
461
397
|
static addCustomerInfoUpdateListener(listener) {
|
|
@@ -481,9 +417,7 @@ export class Purchases {
|
|
|
481
417
|
* short-circuit before reaching the (freshly mocked) bridge.
|
|
482
418
|
*/
|
|
483
419
|
static __resetForTests() {
|
|
484
|
-
|
|
485
|
-
coreConfigured = false;
|
|
486
|
-
configuredApiKey = null;
|
|
420
|
+
resetConfigForTests();
|
|
487
421
|
customerInfoSubscriptions.clear();
|
|
488
422
|
Identity.__resetForTests();
|
|
489
423
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["Attributes","Identity","configure","configureCore","isConfigured","isCoreConfigured","nativeBoolean","setLogLevel","throwIfCoreNotConfigured","throwIfNotConfigured","resetConfigForTests","getNativeModule","getEventEmitter","CUSTOMER_INFO_UPDATED_EVENT","VERIFICATION_RESULT","customerInfoSubscriptions","Map","customerInfoAfterLogOut","native","getCustomerInfo","snapshot","current","emptyCustomerInfo","userId","anonymousId","subjectId","now","Date","entitlements","all","active","verification","NOT_REQUESTED","activeSubscriptions","allPurchasedProductIdentifiers","allPurchaseDates","subscriptionsByProductIdentifier","nonSubscriptionTransactions","firstSeen","toISOString","firstSeenMillis","getTime","originalAppUserId","requestDate","requestDateMillis","latestExpirationDate","latestExpirationDateMillis","originalPurchaseDate","originalPurchaseDateMillis","originalApplicationVersion","managementURL","Purchases","getOfferings","purchasePackage","pkg","offeringId","presentedOfferingContext","offeringIdentifier","identifier","purchaseStoreProduct","product","restorePurchases","logIn","appUserID","logOut","getAppUserID","isAnonymous","setAttributes","set","setEmail","setDisplayName","setPhoneNumber","setPushToken","addCustomerInfoUpdateListener","listener","sub","addListener","event","removeCustomerInfoUpdateListener","get","remove","delete","__resetForTests","clear","__throwIfNotConfigured","__throwIfCoreNotConfigured"],"sourceRoot":"../../src","sources":["purchases.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,UAAU,QAAQ,iBAAc;AACzC,SAASC,QAAQ,QAAQ,eAAY;AACrC,SACEC,SAAS,EACTC,aAAa,EACbC,YAAY,EACZC,gBAAgB,EAChBC,aAAa,EACbC,WAAW,EACXC,wBAAwB,EACxBC,oBAAoB,EACpBC,mBAAmB,QACd,sBAAmB;AAC1B,SAASC,eAAe,EAAEC,eAAe,QAAQ,oBAAiB;AAClE,SAASC,2BAA2B,QAAQ,kBAAe;AAC3D,SAASC,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AAC,CAAC,CAACgD,oBAAoB,CAACC,OAAO,CAACF,UAAU,CAAC;EACnE;;EAEA;EACA,aAAaG,gBAAgBA,CAAA,EAA0B;IACrDpD,oBAAoB,CAAC,CAAC;IACtB,OAAOE,eAAe,CAAC,CAAC,CAACkD,gBAAgB,CAAC,CAAC;EAC7C;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,aAAaC,KAAKA,CAACC,SAAiB,EAAwB;IAC1D,MAAMvD,wBAAwB,CAAC,CAAC;IAChC,OAAOP,QAAQ,CAAC6D,KAAK,CAACC,SAAS,CAAC;EAClC;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,aAAaC,MAAMA,CAAA,EAA0B;IAC3C,MAAMxD,wBAAwB,CAAC,CAAC;IAChC,MAAMP,QAAQ,CAAC+D,MAAM,CAAC,CAAC;IACvB,OAAO/C,uBAAuB,CAAC,CAAC;EAClC;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,aAAagD,YAAYA,CAAA,EAAoB;IAC3C,MAAMzD,wBAAwB,CAAC,CAAC;IAChC,MAAMY,QAAQ,GAAG,MAAMnB,QAAQ,CAACoB,OAAO,CAAC,CAAC;IACzC,OAAOD,QAAQ,CAACG,MAAM,IAAIH,QA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AAe,CAAC,CAAC;EAC5B;AACF;;AAEA;AACA,SACEzE,oBAAoB,IAAI2E,sBAAsB,EAC9C5E,wBAAwB,IAAI6E,0BAA0B;AAGxD,eAAelC,SAAS","ignoreList":[]}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// packages/react-native-sdk/src/swiss-knife.ts
|
|
4
|
+
//
|
|
5
|
+
// The SDK root. Mirror of `SwissKnife` on iOS (`SwissKnifeiOS`, a public final
|
|
6
|
+
// class with `configure` / `configureCore` / `isConfigured` /
|
|
7
|
+
// `isCoreConfigured` / `setLogLevel` statics and `SwissKnife.Identity`,
|
|
8
|
+
// `SwissKnife.Attribution` extensions) and of `com.appswissknife.SwissKnife` on
|
|
9
|
+
// Android.
|
|
10
|
+
//
|
|
11
|
+
// ## Why this exists
|
|
12
|
+
//
|
|
13
|
+
// Until now JS had no root at all. Both bootstraps lived on `Purchases`, which
|
|
14
|
+
// made `Purchases.configureCore()` — a call whose entire meaning is "I do not
|
|
15
|
+
// want the store" — read as a contradiction, and left the SDK running two
|
|
16
|
+
// organising principles at once: a god-object for some concerns, peer
|
|
17
|
+
// namespaces (`Identity`, `Attribution`, `Analytics`, `CrashReporting`,
|
|
18
|
+
// `Performance`) for the rest. The native SDKs never had that problem. This
|
|
19
|
+
// closes the gap in the direction of the two that were already right.
|
|
20
|
+
//
|
|
21
|
+
// ## What belongs here, and what does not
|
|
22
|
+
//
|
|
23
|
+
// Bootstrap and process-wide settings: the two `configure` entry points, the
|
|
24
|
+
// two readback flags, and `setLogLevel`. `setLogLevel` earns its place three
|
|
25
|
+
// ways — it is on the native root on both platforms; it is read by every
|
|
26
|
+
// subsystem (store engine, ingest client, Identity, Attribution, the
|
|
27
|
+
// observability modules), so no single namespace owns it; and it is the one
|
|
28
|
+
// member of the old `Purchases` surface with no configure guard at all, which
|
|
29
|
+
// is the tell that it was never a purchase method.
|
|
30
|
+
//
|
|
31
|
+
// The store surface stays on `Purchases` and is reachable as
|
|
32
|
+
// `SwissKnife.Purchases`. Hoisting `getOfferings` / `purchasePackage` /
|
|
33
|
+
// `restorePurchases` / the CustomerInfo listeners onto the root would recreate
|
|
34
|
+
// the junk drawer at a new address. (iOS does put them on its root; iOS has no
|
|
35
|
+
// RC-compatibility object competing for the name, and we do.)
|
|
36
|
+
//
|
|
37
|
+
// The namespace handles below make the root the one thing you have to know:
|
|
38
|
+
// typing `SwissKnife.` lists the entire SDK. They are the same objects the
|
|
39
|
+
// package exports by name — `SwissKnife.Identity === Identity` — not copies.
|
|
40
|
+
|
|
41
|
+
import { configure, configureCore, isConfigured, isCoreConfigured, setLogLevel } from "./internal/config.js";
|
|
42
|
+
import { Attributes } from "./attributes.js";
|
|
43
|
+
import { Attribution } from "./attribution.js";
|
|
44
|
+
import { Identity } from "./identity.js";
|
|
45
|
+
import { Purchases } from "./purchases.js";
|
|
46
|
+
import { Analytics } from "./modules/analytics.js";
|
|
47
|
+
import { CrashReporting } from "./modules/crash-reporting.js";
|
|
48
|
+
import { Performance } from "./modules/performance.js";
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The shape of {@link SwissKnife}.
|
|
52
|
+
*
|
|
53
|
+
* Written out rather than inferred because `declaration: true` cannot emit an
|
|
54
|
+
* inferred object type whose members reference types their own module does not
|
|
55
|
+
* export (TS4023) — `CrashReporting`'s internals are the case in point. Every
|
|
56
|
+
* member is a `typeof` query on the thing it re-exports, so this stays a
|
|
57
|
+
* restatement of the wiring and can never disagree with it.
|
|
58
|
+
*/
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The Swiss Knife SDK root — bootstrap plus a handle on every namespace.
|
|
62
|
+
*
|
|
63
|
+
* ```ts
|
|
64
|
+
* import { SwissKnife } from "@app-swiss-knife/react-native-sdk";
|
|
65
|
+
*
|
|
66
|
+
* // Full SDK, we own the store:
|
|
67
|
+
* SwissKnife.configure({ apiKey: "sk_live_…", proxyURL: "https://…" });
|
|
68
|
+
*
|
|
69
|
+
* // Another library owns in-app purchases:
|
|
70
|
+
* SwissKnife.configureCore({ apiKey: "sk_live_…", proxyURL: "https://…" });
|
|
71
|
+
*
|
|
72
|
+
* await SwissKnife.Identity.logIn("user_42");
|
|
73
|
+
* await SwissKnife.Attributes.setEmail("ann@example.com");
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* `Purchases.configure` / `Purchases.configureCore` are RC-compatibility
|
|
77
|
+
* aliases for the first two and remain fully supported — they are the *same
|
|
78
|
+
* functions*, so an app that mixes the spellings shares one bootstrap state.
|
|
79
|
+
*/
|
|
80
|
+
export const SwissKnife = {
|
|
81
|
+
// MARK: - Bootstrap
|
|
82
|
+
configure,
|
|
83
|
+
configureCore,
|
|
84
|
+
isConfigured,
|
|
85
|
+
isCoreConfigured,
|
|
86
|
+
setLogLevel,
|
|
87
|
+
// MARK: - Namespaces
|
|
88
|
+
/** In-app purchases + the RevenueCat-compatible surface. */
|
|
89
|
+
Purchases,
|
|
90
|
+
/** Who this device is. `logIn` / `logOut` / `current` / `reset` / `wipe`. */
|
|
91
|
+
Identity,
|
|
92
|
+
/** Subscriber attributes — the dashboard person card. */
|
|
93
|
+
Attributes,
|
|
94
|
+
/** Install attribution: ATT / IDFA / advertising id / install referrer. */
|
|
95
|
+
Attribution,
|
|
96
|
+
/** Product analytics: `init` / `track` / `identify` / `screen`. */
|
|
97
|
+
Analytics,
|
|
98
|
+
/** Crash + error reporting. */
|
|
99
|
+
CrashReporting,
|
|
100
|
+
/** Performance transactions and spans. */
|
|
101
|
+
Performance,
|
|
102
|
+
/**
|
|
103
|
+
* @internal Test seam: reset the process-wide configure state and `Identity`'s
|
|
104
|
+
* caches. Identical to `Purchases.__resetForTests()` — it is the same call, so
|
|
105
|
+
* a suite written against either namespace resets the same singletons.
|
|
106
|
+
*/
|
|
107
|
+
__resetForTests() {
|
|
108
|
+
Purchases.__resetForTests();
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
export default SwissKnife;
|
|
112
|
+
//# sourceMappingURL=swiss-knife.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["configure","configureCore","isConfigured","isCoreConfigured","setLogLevel","Attributes","Attribution","Identity","Purchases","Analytics","CrashReporting","Performance","SwissKnife","__resetForTests"],"sourceRoot":"../../src","sources":["swiss-knife.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SACEA,SAAS,EACTC,aAAa,EACbC,YAAY,EACZC,gBAAgB,EAChBC,WAAW,QACN,sBAAmB;AAC1B,SAASC,UAAU,QAAQ,iBAAc;AACzC,SAASC,WAAW,QAAQ,kBAAe;AAC3C,SAASC,QAAQ,QAAQ,eAAY;AACrC,SAASC,SAAS,QAAQ,gBAAa;AACvC,SAASC,SAAS,QAAQ,wBAAqB;AAC/C,SAASC,cAAc,QAAQ,8BAA2B;AAC1D,SAASC,WAAW,QAAQ,0BAAuB;;AAEnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAkBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,UAAyB,GAAG;EACvC;EACAZ,SAAS;EACTC,aAAa;EACbC,YAAY;EACZC,gBAAgB;EAChBC,WAAW;EAEX;EACA;EACAI,SAAS;EACT;EACAD,QAAQ;EACR;EACAF,UAAU;EACV;EACAC,WAAW;EACX;EACAG,SAAS;EACT;EACAC,cAAc;EACd;EACAC,WAAW;EAEX;AACF;AACA;AACA;AACA;EACEE,eAAeA,CAAA,EAAS;IACtBL,SAAS,CAACK,eAAe,CAAC,CAAC;EAC7B;AACF,CAAC;AAED,eAAeD,UAAU","ignoreList":[]}
|
package/lib/module/types.js
CHANGED
|
@@ -220,6 +220,17 @@ export class UnsupportedPlatformError extends Error {
|
|
|
220
220
|
|
|
221
221
|
/** Options accepted by `Purchases.configure(...)`. Mirror of `PurchasesConfiguration`. */
|
|
222
222
|
|
|
223
|
+
/**
|
|
224
|
+
* Options accepted by `SwissKnife.configure(...)` / `SwissKnife.configureCore(...)`
|
|
225
|
+
* — and, identically, by their `Purchases.*` RC-compatibility aliases.
|
|
226
|
+
*
|
|
227
|
+
* A name for what the two bootstrap entry points have always taken:
|
|
228
|
+
* `PurchasesConfiguration & { logLevel?: LOG_LEVEL }`. `logLevel` is not part of
|
|
229
|
+
* RevenueCat's `PurchasesConfiguration`, so it cannot go on that interface
|
|
230
|
+
* without breaking the mirror; it is accepted here because setting the log level
|
|
231
|
+
* *after* configure is too late to debug the configure itself.
|
|
232
|
+
*/
|
|
233
|
+
|
|
223
234
|
// MARK: - Event listeners
|
|
224
235
|
|
|
225
236
|
/**
|
package/lib/module/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["LOG_LEVEL","VERBOSE","DEBUG","INFO","WARN","ERROR","PACKAGE_TYPE","UNKNOWN","CUSTOM","LIFETIME","ANNUAL","SIX_MONTH","THREE_MONTH","TWO_MONTH","MONTHLY","WEEKLY","STOREKIT_VERSION","DEFAULT","STOREKIT_1","STOREKIT_2","VERIFICATION_RESULT","NOT_REQUESTED","VERIFIED","FAILED","VERIFIED_ON_DEVICE","PURCHASES_ERROR_CODE","UNKNOWN_ERROR","PURCHASE_CANCELLED_ERROR","STORE_PROBLEM_ERROR","PURCHASE_NOT_ALLOWED_ERROR","PURCHASE_INVALID_ERROR","PRODUCT_NOT_AVAILABLE_FOR_PURCHASE_ERROR","PRODUCT_ALREADY_PURCHASED_ERROR","RECEIPT_ALREADY_IN_USE_ERROR","INVALID_RECEIPT_ERROR","MISSING_RECEIPT_FILE_ERROR","NETWORK_ERROR","INVALID_CREDENTIALS_ERROR","UNEXPECTED_BACKEND_RESPONSE_ERROR","RECEIPT_IN_USE_BY_OTHER_SUBSCRIBER_ERROR","INVALID_APP_USER_ID_ERROR","OPERATION_ALREADY_IN_PROGRESS_ERROR","UNKNOWN_BACKEND_ERROR","INVALID_APPLE_SUBSCRIPTION_KEY_ERROR","INELIGIBLE_ERROR","INSUFFICIENT_PERMISSIONS_ERROR","PAYMENT_PENDING_ERROR","INVALID_SUBSCRIBER_ATTRIBUTES_ERROR","LOG_OUT_ANONYMOUS_USER_ERROR","CONFIGURATION_ERROR","UNSUPPORTED_ERROR","EMPTY_SUBSCRIBER_ATTRIBUTES_ERROR","CUSTOMER_INFO_ERROR","UninitializedPurchasesError","Error","constructor","message","name","UnsupportedPlatformError"],"sourceRoot":"../../src","sources":["types.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,OAAO,MAAMA,SAAS,GAAG;EACvBC,OAAO,EAAE,SAAS;EAClBC,KAAK,EAAE,OAAO;EACdC,IAAI,EAAE,MAAM;EACZC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAE;AACT,CAAU;AAGV;AACA,OAAO,MAAMC,YAAY,GAAG;EAC1BC,OAAO,EAAE,SAAS;EAClBC,MAAM,EAAE,QAAQ;EAChBC,QAAQ,EAAE,UAAU;EACpBC,MAAM,EAAE,QAAQ;EAChBC,SAAS,EAAE,WAAW;EACtBC,WAAW,EAAE,aAAa;EAC1BC,SAAS,EAAE,WAAW;EACtBC,OAAO,EAAE,SAAS;EAClBC,MAAM,EAAE;AACV,CAAU;AAGV;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,GAAG;EAC9BC,OAAO,EAAE,SAAS;EAClBC,UAAU,EAAE,YAAY;EACxBC,UAAU,EA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A;AACA,OAAO,MAAMC,wBAAwB,SAASJ,KAAK,CAAC;EAClDC,WAAWA,CACTC,OAAe,GAAG,uDAAuD,EACzE;IACA,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,0BAA0B;EACxC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAQA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAiCA;;AAOA;;AAmBA;;AASA;AACA;AACA;AACA;;AA0BA;;AAEA;;AAUA;;AAMA;;AAWA;;AA6BA;AACA;AACA;AACA;;AAOA;;AAUA;;AAiBA;;AAMA;;AAEA;;AAOA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA;;AAMA;;AAEA;AACA;AACA;AACA;AACA;;AAUA;;AAOA;;AAEA;;AAyCA;;AAEA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["LOG_LEVEL","VERBOSE","DEBUG","INFO","WARN","ERROR","PACKAGE_TYPE","UNKNOWN","CUSTOM","LIFETIME","ANNUAL","SIX_MONTH","THREE_MONTH","TWO_MONTH","MONTHLY","WEEKLY","STOREKIT_VERSION","DEFAULT","STOREKIT_1","STOREKIT_2","VERIFICATION_RESULT","NOT_REQUESTED","VERIFIED","FAILED","VERIFIED_ON_DEVICE","PURCHASES_ERROR_CODE","UNKNOWN_ERROR","PURCHASE_CANCELLED_ERROR","STORE_PROBLEM_ERROR","PURCHASE_NOT_ALLOWED_ERROR","PURCHASE_INVALID_ERROR","PRODUCT_NOT_AVAILABLE_FOR_PURCHASE_ERROR","PRODUCT_ALREADY_PURCHASED_ERROR","RECEIPT_ALREADY_IN_USE_ERROR","INVALID_RECEIPT_ERROR","MISSING_RECEIPT_FILE_ERROR","NETWORK_ERROR","INVALID_CREDENTIALS_ERROR","UNEXPECTED_BACKEND_RESPONSE_ERROR","RECEIPT_IN_USE_BY_OTHER_SUBSCRIBER_ERROR","INVALID_APP_USER_ID_ERROR","OPERATION_ALREADY_IN_PROGRESS_ERROR","UNKNOWN_BACKEND_ERROR","INVALID_APPLE_SUBSCRIPTION_KEY_ERROR","INELIGIBLE_ERROR","INSUFFICIENT_PERMISSIONS_ERROR","PAYMENT_PENDING_ERROR","INVALID_SUBSCRIBER_ATTRIBUTES_ERROR","LOG_OUT_ANONYMOUS_USER_ERROR","CONFIGURATION_ERROR","UNSUPPORTED_ERROR","EMPTY_SUBSCRIBER_ATTRIBUTES_ERROR","CUSTOMER_INFO_ERROR","UninitializedPurchasesError","Error","constructor","message","name","UnsupportedPlatformError"],"sourceRoot":"../../src","sources":["types.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,OAAO,MAAMA,SAAS,GAAG;EACvBC,OAAO,EAAE,SAAS;EAClBC,KAAK,EAAE,OAAO;EACdC,IAAI,EAAE,MAAM;EACZC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAE;AACT,CAAU;AAGV;AACA,OAAO,MAAMC,YAAY,GAAG;EAC1BC,OAAO,EAAE,SAAS;EAClBC,MAAM,EAAE,QAAQ;EAChBC,QAAQ,EAAE,UAAU;EACpBC,MAAM,EAAE,QAAQ;EAChBC,SAAS,EAAE,WAAW;EACtBC,WAAW,EAAE,aAAa;EAC1BC,SAAS,EAAE,WAAW;EACtBC,OAAO,EAAE,SAAS;EAClBC,MAAM,EAAE;AACV,CAAU;AAGV;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,GAAG;EAC9BC,OAAO,EAAE,SAAS;EAClBC,UAAU,EAAE,YAAY;EACxBC,UAAU,EAAE;AACd,CAAU;AAGV;AACA,OAAO,MAAMC,mBAAmB,GAAG;EACjCC,aAAa,EAAE,eAAe;EAC9BC,QAAQ,EA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