@app-swiss-knife/react-native-sdk 0.2.5 → 0.2.7
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/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/SwissKnifePurchases.swift +16 -1
- package/ios/vendor/SwissKnifeiOS/Context/DeviceContext.swift +1 -1
- package/lib/commonjs/purchases.js +195 -32
- package/lib/commonjs/purchases.js.map +1 -1
- package/lib/module/purchases.js +196 -33
- package/lib/module/purchases.js.map +1 -1
- package/lib/typescript/commonjs/purchases.d.ts +65 -13
- package/lib/typescript/commonjs/purchases.d.ts.map +1 -1
- package/lib/typescript/module/purchases.d.ts +65 -13
- package/lib/typescript/module/purchases.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/purchases.ts +196 -33
package/lib/module/purchases.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
// src/purchases.ts
|
|
4
|
+
import { Identity } from "./identity.js";
|
|
4
5
|
import { getNativeModule, getEventEmitter } from "./native/module.js";
|
|
5
6
|
import { CUSTOMER_INFO_UPDATED_EVENT } from "./native/spec.js";
|
|
6
|
-
import { UninitializedPurchasesError } from "./types.js";
|
|
7
|
+
import { UninitializedPurchasesError, VERIFICATION_RESULT } from "./types.js";
|
|
7
8
|
let configured = false;
|
|
8
9
|
let configuredApiKey = null;
|
|
9
10
|
let coreConfigured = false;
|
|
@@ -37,9 +38,14 @@ function nativeBoolean(read) {
|
|
|
37
38
|
const customerInfoSubscriptions = new Map();
|
|
38
39
|
|
|
39
40
|
/**
|
|
40
|
-
* Guard for surfaces that genuinely need the PURCHASE engine —
|
|
41
|
-
*
|
|
42
|
-
*
|
|
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`.
|
|
43
49
|
*/
|
|
44
50
|
function throwIfNotConfigured() {
|
|
45
51
|
if (!configured) {
|
|
@@ -78,6 +84,66 @@ async function throwIfCoreNotConfigured() {
|
|
|
78
84
|
throw new UninitializedPurchasesError("Purchases core is not configured. Call Purchases.configure(), " + "Purchases.configureCore(), or Analytics.init() first.");
|
|
79
85
|
}
|
|
80
86
|
|
|
87
|
+
/**
|
|
88
|
+
* The `CustomerInfo` RC's `logOut()` resolves with, for a device that just
|
|
89
|
+
* became anonymous.
|
|
90
|
+
*
|
|
91
|
+
* The store engine is the preferred source, so an app that owns the store
|
|
92
|
+
* keeps getting real post-logout state. Whether it can answer is decided by
|
|
93
|
+
* `isConfigured()` — native truth on both platforms — rather than by trying
|
|
94
|
+
* the read and interpreting the failure, because an *unconfigured* store does
|
|
95
|
+
* not fail the same way on the two platforms: iOS rejects `getCustomerInfo`
|
|
96
|
+
* with `notConfigured`, Android's unconfigured gateway resolves an empty
|
|
97
|
+
* record of its own construction. Discovering the state from the error would
|
|
98
|
+
* hand back two different objects for one situation, in the very module that
|
|
99
|
+
* exists to stop that happening.
|
|
100
|
+
*
|
|
101
|
+
* With no store engine — or with one that cannot answer right now (cold cache
|
|
102
|
+
* plus offline) — the caller gets the entitlement-free record below, built in
|
|
103
|
+
* JS so it is identical on both platforms. Logging out is not a store
|
|
104
|
+
* operation and must not fail because the store is unreachable.
|
|
105
|
+
*/
|
|
106
|
+
async function customerInfoAfterLogOut() {
|
|
107
|
+
if (await nativeBoolean(native => native.isConfigured())) {
|
|
108
|
+
try {
|
|
109
|
+
return await getNativeModule().getCustomerInfo();
|
|
110
|
+
} catch {
|
|
111
|
+
// Fall through to the empty record.
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const snapshot = await Identity.current();
|
|
115
|
+
return emptyCustomerInfo(snapshot.userId ?? snapshot.anonymousId);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** An entitlement-free `CustomerInfo` for `subjectId`. Mirrors the native
|
|
119
|
+
* `CustomerInfo.empty(originalAppUserId:)` constructors. */
|
|
120
|
+
function emptyCustomerInfo(subjectId) {
|
|
121
|
+
const now = new Date();
|
|
122
|
+
return {
|
|
123
|
+
entitlements: {
|
|
124
|
+
all: {},
|
|
125
|
+
active: {},
|
|
126
|
+
verification: VERIFICATION_RESULT.NOT_REQUESTED
|
|
127
|
+
},
|
|
128
|
+
activeSubscriptions: [],
|
|
129
|
+
allPurchasedProductIdentifiers: [],
|
|
130
|
+
allPurchaseDates: {},
|
|
131
|
+
subscriptionsByProductIdentifier: {},
|
|
132
|
+
nonSubscriptionTransactions: [],
|
|
133
|
+
firstSeen: now.toISOString(),
|
|
134
|
+
firstSeenMillis: now.getTime(),
|
|
135
|
+
originalAppUserId: subjectId,
|
|
136
|
+
requestDate: now.toISOString(),
|
|
137
|
+
requestDateMillis: now.getTime(),
|
|
138
|
+
latestExpirationDate: null,
|
|
139
|
+
latestExpirationDateMillis: null,
|
|
140
|
+
originalPurchaseDate: null,
|
|
141
|
+
originalPurchaseDateMillis: null,
|
|
142
|
+
originalApplicationVersion: null,
|
|
143
|
+
managementURL: null
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
81
147
|
/**
|
|
82
148
|
* RC-compatible subscriptions SDK entry point. Process-wide singleton; call
|
|
83
149
|
* `Purchases.configure(...)` once at app start, then use the static methods.
|
|
@@ -216,51 +282,140 @@ export class Purchases {
|
|
|
216
282
|
return getNativeModule().restorePurchases();
|
|
217
283
|
}
|
|
218
284
|
|
|
219
|
-
//
|
|
220
|
-
//
|
|
221
|
-
//
|
|
222
|
-
//
|
|
223
|
-
//
|
|
224
|
-
//
|
|
225
|
-
//
|
|
226
|
-
//
|
|
227
|
-
//
|
|
228
|
-
//
|
|
229
|
-
// Identity on
|
|
285
|
+
// MARK: - RC-parity identity aliases
|
|
286
|
+
//
|
|
287
|
+
// ## The guarantee
|
|
288
|
+
//
|
|
289
|
+
// Each of the four aliases below is *exactly* its {@link Identity}
|
|
290
|
+
// counterpart with the RevenueCat name and the RevenueCat return type, on
|
|
291
|
+
// BOTH platforms. There is no per-platform behaviour left in them: they are
|
|
292
|
+
// one-line delegations to `Identity`, which reaches the `identityLogIn` /
|
|
293
|
+
// `identityLogOut` / `identityCurrent` native bridge methods — and those go
|
|
294
|
+
// to the unified native `Identity` (`SwissKnife.Identity` on iOS,
|
|
295
|
+
// `com.appswissknife.identity.Identity` on Android) on both. Concretely, a
|
|
296
|
+
// `Purchases.logIn(...)` POSTs `/api/sdk/users/identify` on iOS AND on
|
|
297
|
+
// Android. Pinned by `identity-parity.test.ts`.
|
|
298
|
+
//
|
|
299
|
+
// ## Why they are written as delegations rather than bridge calls
|
|
300
|
+
//
|
|
301
|
+
// They used to call the legacy `logIn` / `logOut` / `getAppUserID` /
|
|
302
|
+
// `isAnonymous` bridge methods, which bottom out in the *deprecated native
|
|
303
|
+
// facades* — and those facades do NOT agree across platforms:
|
|
304
|
+
//
|
|
305
|
+
// - `logOut`: iOS `SwissKnife.logOut` routes to `Identity.logOut`;
|
|
306
|
+
// Android's routes straight to the purchases `gateway` and only
|
|
307
|
+
// back-syncs Identity's snapshot afterwards.
|
|
308
|
+
// - `getAppUserID`: iOS returns the Identity-synced subject (a stable
|
|
309
|
+
// `$SKAnonymousID:`+DeviceID value when anonymous); Android returns
|
|
310
|
+
// `gateway.getAppUserID()`, whose anonymous form is a fresh random UUID
|
|
311
|
+
// minted per process and unrelated to `Identity.current().anonymousId`.
|
|
312
|
+
// - `isAnonymous`: iOS reads Identity-synced state; Android reads the
|
|
313
|
+
// gateway's, which `Identity.reset()` / `Identity.wipe()` never touch.
|
|
314
|
+
//
|
|
315
|
+
// Delegating in JS makes the RN surface immune to all of that, and it is the
|
|
316
|
+
// only version of the fix that is verifiable from this repo's test suites.
|
|
317
|
+
// The legacy bridge methods stay on the native-module spec (removing them
|
|
318
|
+
// would break the native contract) but nothing in this package calls them
|
|
319
|
+
// any more.
|
|
320
|
+
//
|
|
321
|
+
// ## Second bug this closes
|
|
322
|
+
//
|
|
323
|
+
// `Identity` keeps JS-side caches (`lastSnapshot`, `lastLogIn`) that let a
|
|
324
|
+
// repeat `Identity.logIn(sameId)` skip the bridge. An alias that mutated
|
|
325
|
+
// native identity behind `Identity`'s back left those caches describing a
|
|
326
|
+
// world that no longer existed — after `Identity.logIn("u")` +
|
|
327
|
+
// `Purchases.logOut()`, a following `Identity.logIn("u")` short-circuited on
|
|
328
|
+
// the stale cache and resolved "logged in" without the device ever being
|
|
329
|
+
// re-identified. Routing through `Identity` means one owner for that state.
|
|
330
|
+
//
|
|
331
|
+
// ## The guard
|
|
332
|
+
//
|
|
333
|
+
// These sit on {@link throwIfCoreNotConfigured}, not on the purchase guard.
|
|
334
|
+
// Identity is a core capability — natively both platforms gate it on
|
|
335
|
+
// `isCoreConfigured` — and the single most likely caller of
|
|
336
|
+
// `Purchases.logIn` is an app migrating off RevenueCat that still lets
|
|
337
|
+
// RevenueCat own the store, i.e. one that called `configureCore`. Gating the
|
|
338
|
+
// RC-named alias on the purchase engine would reject exactly that app while
|
|
339
|
+
// the identical `Identity.logIn` call succeeded. The guard is not dropped
|
|
340
|
+
// entirely, because `Identity.current()` before any configure returns a
|
|
341
|
+
// real snapshot on iOS and a `{anonymousId: ""}` placeholder on Android —
|
|
342
|
+
// requiring core is what makes even that case agree.
|
|
230
343
|
|
|
231
344
|
/**
|
|
232
|
-
* Identify the user
|
|
345
|
+
* Identify the user, merging the anonymous subject into `appUserID`
|
|
346
|
+
* server-side.
|
|
347
|
+
*
|
|
348
|
+
* Exactly `Identity.logIn(appUserID)` with the RevenueCat name. On both
|
|
349
|
+
* platforms this POSTs `(anonymous_id, user_id)` to
|
|
350
|
+
* `/api/sdk/users/identify` and resolves once the backend ack and the
|
|
351
|
+
* post-identify entitlements refresh complete; a rejection means the device
|
|
352
|
+
* is NOT merged server-side and the call must be retried. Repeat calls with
|
|
353
|
+
* the id already in effect are free (no bridge hop, no request).
|
|
354
|
+
*
|
|
355
|
+
* Works after `Purchases.configure`, `Purchases.configureCore`, or
|
|
356
|
+
* `Analytics.init` — the store does not have to be ours.
|
|
233
357
|
*
|
|
234
|
-
* @deprecated Wave 1 — prefer `Identity.logIn(userId)`.
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
-
* `Identity.logIn(...)`.
|
|
358
|
+
* @deprecated Wave 1 — prefer `Identity.logIn(userId)`. This alias exists so
|
|
359
|
+
* RevenueCat migrations compile unchanged; it is a pure delegation, so there
|
|
360
|
+
* is nothing to gain by keeping it and one less name to learn by dropping it.
|
|
238
361
|
*/
|
|
239
362
|
static async logIn(appUserID) {
|
|
240
|
-
|
|
241
|
-
return
|
|
363
|
+
await throwIfCoreNotConfigured();
|
|
364
|
+
return Identity.logIn(appUserID);
|
|
242
365
|
}
|
|
243
366
|
|
|
244
367
|
/**
|
|
245
|
-
* Log out the current user and revert to anonymous.
|
|
368
|
+
* Log out the current user and revert to anonymous. The device id survives,
|
|
369
|
+
* so analytics continuity for the same physical install is preserved.
|
|
246
370
|
*
|
|
247
|
-
*
|
|
371
|
+
* Exactly `Identity.logOut()` with the RevenueCat name, plus RC's
|
|
372
|
+
* `CustomerInfo` return: after the logout lands, the post-logout customer
|
|
373
|
+
* info is read back from the store engine. **When no store engine is
|
|
374
|
+
* configured** (`configureCore`, `Analytics.init`) there is nothing to read,
|
|
375
|
+
* and you get an entitlement-free `CustomerInfo` for the anonymous subject —
|
|
376
|
+
* the same record, built in JS, on both platforms. Do not read that as a
|
|
377
|
+
* store error; if you want real entitlements, call `getCustomerInfo()`.
|
|
378
|
+
*
|
|
379
|
+
* @deprecated Wave 1 — prefer `Identity.logOut()`, which does not pretend to
|
|
380
|
+
* return store state.
|
|
248
381
|
*/
|
|
249
382
|
static async logOut() {
|
|
250
|
-
|
|
251
|
-
|
|
383
|
+
await throwIfCoreNotConfigured();
|
|
384
|
+
await Identity.logOut();
|
|
385
|
+
return customerInfoAfterLogOut();
|
|
252
386
|
}
|
|
253
387
|
|
|
254
|
-
/**
|
|
388
|
+
/**
|
|
389
|
+
* The current subject id — the identified user id if there is one, else the
|
|
390
|
+
* SDK's anonymous id (`$SKAnonymousID:`-prefixed, stable across launches).
|
|
391
|
+
*
|
|
392
|
+
* Exactly `(await Identity.current()).userId ?? .anonymousId`. Note this is
|
|
393
|
+
* the *Identity* subject on both platforms; on Android the purchase
|
|
394
|
+
* gateway's own anonymous id is a different, per-process value, and this
|
|
395
|
+
* alias deliberately does not report it.
|
|
396
|
+
*
|
|
397
|
+
* @deprecated Wave 1 — prefer `Identity.current()`, which hands back the
|
|
398
|
+
* anonymous id, the user id and `isAnonymous` in one read instead of forcing
|
|
399
|
+
* two calls that can interleave.
|
|
400
|
+
*/
|
|
255
401
|
static async getAppUserID() {
|
|
256
|
-
|
|
257
|
-
|
|
402
|
+
await throwIfCoreNotConfigured();
|
|
403
|
+
const snapshot = await Identity.current();
|
|
404
|
+
return snapshot.userId ?? snapshot.anonymousId;
|
|
258
405
|
}
|
|
259
406
|
|
|
260
|
-
/**
|
|
407
|
+
/**
|
|
408
|
+
* Whether the current subject is the SDK-generated anonymous id.
|
|
409
|
+
*
|
|
410
|
+
* Exactly `(await Identity.current()).isAnonymous`, so it tracks
|
|
411
|
+
* `Identity.reset()` and `Identity.wipe()` on both platforms.
|
|
412
|
+
*
|
|
413
|
+
* @deprecated Wave 1 — prefer `Identity.current()`; see
|
|
414
|
+
* {@link getAppUserID}.
|
|
415
|
+
*/
|
|
261
416
|
static async isAnonymous() {
|
|
262
|
-
|
|
263
|
-
return
|
|
417
|
+
await throwIfCoreNotConfigured();
|
|
418
|
+
return (await Identity.current()).isAnonymous;
|
|
264
419
|
}
|
|
265
420
|
|
|
266
421
|
// Subscriber attributes. CORE, not store — see {@link throwIfCoreNotConfigured}.
|
|
@@ -317,12 +472,20 @@ export class Purchases {
|
|
|
317
472
|
}
|
|
318
473
|
}
|
|
319
474
|
|
|
320
|
-
/**
|
|
475
|
+
/**
|
|
476
|
+
* @internal Test seam: reset singleton state between tests.
|
|
477
|
+
*
|
|
478
|
+
* Also resets `Identity`'s caches, because the RC-parity aliases delegate
|
|
479
|
+
* there: without it, a `Purchases.logIn("u")` in one test would leave
|
|
480
|
+
* `Identity`'s `lastLogIn` primed and the next test's identical call would
|
|
481
|
+
* short-circuit before reaching the (freshly mocked) bridge.
|
|
482
|
+
*/
|
|
321
483
|
static __resetForTests() {
|
|
322
484
|
configured = false;
|
|
323
485
|
coreConfigured = false;
|
|
324
486
|
configuredApiKey = null;
|
|
325
487
|
customerInfoSubscriptions.clear();
|
|
488
|
+
Identity.__resetForTests();
|
|
326
489
|
}
|
|
327
490
|
}
|
|
328
491
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getNativeModule","getEventEmitter","CUSTOMER_INFO_UPDATED_EVENT","UninitializedPurchasesError","configured","configuredApiKey","coreConfigured","nativeBoolean","read","Promise","resolve","catch","customerInfoSubscriptions","Map","throwIfNotConfigured","throwIfCoreNotConfigured","native","isCoreConfigured","Purchases","configure","options","apiKey","nativeOptions","appUserID","proxyURL","diagnosticsEnabled","storeKitVersion","useAmazon","autoPromptATT","sendInstallOnFirstLaunch","logLevel","configureCore","
|
|
1
|
+
{"version":3,"names":["Identity","getNativeModule","getEventEmitter","CUSTOMER_INFO_UPDATED_EVENT","UninitializedPurchasesError","VERIFICATION_RESULT","configured","configuredApiKey","coreConfigured","nativeBoolean","read","Promise","resolve","catch","customerInfoSubscriptions","Map","throwIfNotConfigured","throwIfCoreNotConfigured","native","isCoreConfigured","customerInfoAfterLogOut","isConfigured","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","configure","options","apiKey","nativeOptions","appUserID","proxyURL","diagnosticsEnabled","storeKitVersion","useAmazon","autoPromptATT","sendInstallOnFirstLaunch","logLevel","configureCore","getOfferings","purchasePackage","pkg","offeringId","presentedOfferingContext","offeringIdentifier","identifier","purchaseStoreProduct","product","restorePurchases","logIn","logOut","getAppUserID","isAnonymous","setAttributes","attributes","setEmail","email","setDisplayName","displayName","setPhoneNumber","phoneNumber","setPushToken","pushToken","setLogLevel","level","addCustomerInfoUpdateListener","listener","sub","addListener","event","set","removeCustomerInfoUpdateListener","get","remove","delete","__resetForTests","clear","__throwIfNotConfigured","__throwIfCoreNotConfigured"],"sourceRoot":"../../src","sources":["purchases.ts"],"mappings":";;AAAA;AACA,SAASA,QAAQ,QAAQ,eAAY;AACrC,SAASC,eAAe,EAAEC,eAAe,QAAQ,oBAAiB;AAClE,SAASC,2BAA2B,QAAQ,kBAAe;AAC3D,SAASC,2BAA2B,EAAEC,mBAAmB,QAAQ,YAAS;AAkB1E,IAAIC,UAAU,GAAG,KAAK;AACtB,IAAIC,gBAA+B,GAAG,IAAI;AAC1C,IAAIC,cAAc,GAAG,KAAK;;AAE1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,aAAaA,CACpBC,IAAmE,EACjD;EAClB,IAAI;IACF,OAAOC,OAAO,CAACC,OAAO,CAACF,IAAI,CAACT,eAAe,CAAC,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S,eAAeA,CAAA,EAAS;IAC7BlG,UAAU,GAAG,KAAK;IAClBE,cAAc,GAAG,KAAK;IACtBD,gBAAgB,GAAG,IAAI;IACvBO,yBAAyB,CAAC2F,KAAK,CAAC,CAAC;IACjCzG,QAAQ,CAACwG,eAAe,CAAC,CAAC;EAC5B;AACF;;AAEA;AACA,SACExF,oBAAoB,IAAI0F,sBAAsB,EAC9CzF,wBAAwB,IAAI0F,0BAA0B;AAGxD,eAAerD,SAAS","ignoreList":[]}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import type { PurchasesConfiguration, LOG_LEVEL, CustomerInfo, PurchasesOfferings, PurchasesPackage, PurchasesStoreProduct, MakePurchaseResult, LogInResult, CustomerInfoUpdateListener } from "./types";
|
|
2
2
|
/**
|
|
3
|
-
* Guard for surfaces that genuinely need the PURCHASE engine —
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* Guard for surfaces that genuinely need the PURCHASE engine — `getOfferings`,
|
|
4
|
+
* `purchasePackage`, `restorePurchases` and friends. Checks the JS "configure
|
|
5
|
+
* was called" flag.
|
|
6
|
+
*
|
|
7
|
+
* The RC-parity identity aliases used to sit here too, on the grounds that the
|
|
8
|
+
* legacy native bridge methods they called meant different things on iOS and
|
|
9
|
+
* Android. They now delegate to `Identity` and sit on
|
|
10
|
+
* {@link throwIfCoreNotConfigured} — see the block above `logIn`.
|
|
6
11
|
*/
|
|
7
12
|
declare function throwIfNotConfigured(): void;
|
|
8
13
|
/**
|
|
@@ -102,23 +107,63 @@ export declare class Purchases {
|
|
|
102
107
|
/** Restore purchases tied to the underlying store account. */
|
|
103
108
|
static restorePurchases(): Promise<CustomerInfo>;
|
|
104
109
|
/**
|
|
105
|
-
* Identify the user
|
|
110
|
+
* Identify the user, merging the anonymous subject into `appUserID`
|
|
111
|
+
* server-side.
|
|
112
|
+
*
|
|
113
|
+
* Exactly `Identity.logIn(appUserID)` with the RevenueCat name. On both
|
|
114
|
+
* platforms this POSTs `(anonymous_id, user_id)` to
|
|
115
|
+
* `/api/sdk/users/identify` and resolves once the backend ack and the
|
|
116
|
+
* post-identify entitlements refresh complete; a rejection means the device
|
|
117
|
+
* is NOT merged server-side and the call must be retried. Repeat calls with
|
|
118
|
+
* the id already in effect are free (no bridge hop, no request).
|
|
106
119
|
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
* `Identity.logIn(
|
|
120
|
+
* Works after `Purchases.configure`, `Purchases.configureCore`, or
|
|
121
|
+
* `Analytics.init` — the store does not have to be ours.
|
|
122
|
+
*
|
|
123
|
+
* @deprecated Wave 1 — prefer `Identity.logIn(userId)`. This alias exists so
|
|
124
|
+
* RevenueCat migrations compile unchanged; it is a pure delegation, so there
|
|
125
|
+
* is nothing to gain by keeping it and one less name to learn by dropping it.
|
|
111
126
|
*/
|
|
112
127
|
static logIn(appUserID: string): Promise<LogInResult>;
|
|
113
128
|
/**
|
|
114
|
-
* Log out the current user and revert to anonymous.
|
|
129
|
+
* Log out the current user and revert to anonymous. The device id survives,
|
|
130
|
+
* so analytics continuity for the same physical install is preserved.
|
|
131
|
+
*
|
|
132
|
+
* Exactly `Identity.logOut()` with the RevenueCat name, plus RC's
|
|
133
|
+
* `CustomerInfo` return: after the logout lands, the post-logout customer
|
|
134
|
+
* info is read back from the store engine. **When no store engine is
|
|
135
|
+
* configured** (`configureCore`, `Analytics.init`) there is nothing to read,
|
|
136
|
+
* and you get an entitlement-free `CustomerInfo` for the anonymous subject —
|
|
137
|
+
* the same record, built in JS, on both platforms. Do not read that as a
|
|
138
|
+
* store error; if you want real entitlements, call `getCustomerInfo()`.
|
|
115
139
|
*
|
|
116
|
-
* @deprecated Wave 1 — prefer `Identity.logOut()
|
|
140
|
+
* @deprecated Wave 1 — prefer `Identity.logOut()`, which does not pretend to
|
|
141
|
+
* return store state.
|
|
117
142
|
*/
|
|
118
143
|
static logOut(): Promise<CustomerInfo>;
|
|
119
|
-
/**
|
|
144
|
+
/**
|
|
145
|
+
* The current subject id — the identified user id if there is one, else the
|
|
146
|
+
* SDK's anonymous id (`$SKAnonymousID:`-prefixed, stable across launches).
|
|
147
|
+
*
|
|
148
|
+
* Exactly `(await Identity.current()).userId ?? .anonymousId`. Note this is
|
|
149
|
+
* the *Identity* subject on both platforms; on Android the purchase
|
|
150
|
+
* gateway's own anonymous id is a different, per-process value, and this
|
|
151
|
+
* alias deliberately does not report it.
|
|
152
|
+
*
|
|
153
|
+
* @deprecated Wave 1 — prefer `Identity.current()`, which hands back the
|
|
154
|
+
* anonymous id, the user id and `isAnonymous` in one read instead of forcing
|
|
155
|
+
* two calls that can interleave.
|
|
156
|
+
*/
|
|
120
157
|
static getAppUserID(): Promise<string>;
|
|
121
|
-
/**
|
|
158
|
+
/**
|
|
159
|
+
* Whether the current subject is the SDK-generated anonymous id.
|
|
160
|
+
*
|
|
161
|
+
* Exactly `(await Identity.current()).isAnonymous`, so it tracks
|
|
162
|
+
* `Identity.reset()` and `Identity.wipe()` on both platforms.
|
|
163
|
+
*
|
|
164
|
+
* @deprecated Wave 1 — prefer `Identity.current()`; see
|
|
165
|
+
* {@link getAppUserID}.
|
|
166
|
+
*/
|
|
122
167
|
static isAnonymous(): Promise<boolean>;
|
|
123
168
|
/** Set arbitrary subscriber attributes. null clears an attribute. */
|
|
124
169
|
static setAttributes(attributes: Record<string, string | null>): Promise<void>;
|
|
@@ -136,7 +181,14 @@ export declare class Purchases {
|
|
|
136
181
|
static addCustomerInfoUpdateListener(listener: CustomerInfoUpdateListener): void;
|
|
137
182
|
/** Remove a previously-registered CustomerInfo update listener. */
|
|
138
183
|
static removeCustomerInfoUpdateListener(listener: CustomerInfoUpdateListener): void;
|
|
139
|
-
/**
|
|
184
|
+
/**
|
|
185
|
+
* @internal Test seam: reset singleton state between tests.
|
|
186
|
+
*
|
|
187
|
+
* Also resets `Identity`'s caches, because the RC-parity aliases delegate
|
|
188
|
+
* there: without it, a `Purchases.logIn("u")` in one test would leave
|
|
189
|
+
* `Identity`'s `lastLogIn` primed and the next test's identical call would
|
|
190
|
+
* short-circuit before reaching the (freshly mocked) bridge.
|
|
191
|
+
*/
|
|
140
192
|
static __resetForTests(): void;
|
|
141
193
|
}
|
|
142
194
|
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":"AAMA,OAAO,KAAK,EACV,sBAAsB,EACtB,SAAS,EACT,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,EACrB,kBAAkB,EAClB,WAAW,EACX,0BAA0B,EAC3B,MAAM,SAAS,CAAC;AA2CjB;;;;;;;;;GASG;AACH,iBAAS,oBAAoB,IAAI,IAAI,CAIpC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,iBAAe,wBAAwB,IAAI,OAAO,CAAC,IAAI,CAAC,CAOvD;AA8DD;;;GAGG;AACH,qBAAa,SAAS;IACpB;;;;OAIG;IACH,MAAM,CAAC,SAAS,CACd,OAAO,EAAE,sBAAsB,GAAG;QAAE,QAAQ,CAAC,EAAE,SAAS,CAAA;KAAE,GACzD,IAAI;IA2BP;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,aAAa,CAClB,OAAO,EAAE,sBAAsB,GAAG;QAAE,QAAQ,CAAC,EAAE,SAAS,CAAA;KAAE,GACzD,IAAI;IAoBP;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,YAAY,IAAI,OAAO,CAAC,OAAO,CAAC;IAIvC;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,gBAAgB,IAAI,OAAO,CAAC,OAAO,CAAC;IAI3C,gFAAgF;WACnE,eAAe,IAAI,OAAO,CAAC,YAAY,CAAC;IAKrD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Q,EAAE,0BAA0B,GACnC,IAAI;IAQP,mEAAmE;IACnE,MAAM,CAAC,gCAAgC,CACrC,QAAQ,EAAE,0BAA0B,GACnC,IAAI;IAQP;;;;;;;OAOG;IACH,MAAM,CAAC,eAAe,IAAI,IAAI;CAO/B;AAGD,OAAO,EACL,oBAAoB,IAAI,sBAAsB,EAC9C,wBAAwB,IAAI,0BAA0B,GACvD,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import type { PurchasesConfiguration, LOG_LEVEL, CustomerInfo, PurchasesOfferings, PurchasesPackage, PurchasesStoreProduct, MakePurchaseResult, LogInResult, CustomerInfoUpdateListener } from "./types.js";
|
|
2
2
|
/**
|
|
3
|
-
* Guard for surfaces that genuinely need the PURCHASE engine —
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* Guard for surfaces that genuinely need the PURCHASE engine — `getOfferings`,
|
|
4
|
+
* `purchasePackage`, `restorePurchases` and friends. Checks the JS "configure
|
|
5
|
+
* was called" flag.
|
|
6
|
+
*
|
|
7
|
+
* The RC-parity identity aliases used to sit here too, on the grounds that the
|
|
8
|
+
* legacy native bridge methods they called meant different things on iOS and
|
|
9
|
+
* Android. They now delegate to `Identity` and sit on
|
|
10
|
+
* {@link throwIfCoreNotConfigured} — see the block above `logIn`.
|
|
6
11
|
*/
|
|
7
12
|
declare function throwIfNotConfigured(): void;
|
|
8
13
|
/**
|
|
@@ -102,23 +107,63 @@ export declare class Purchases {
|
|
|
102
107
|
/** Restore purchases tied to the underlying store account. */
|
|
103
108
|
static restorePurchases(): Promise<CustomerInfo>;
|
|
104
109
|
/**
|
|
105
|
-
* Identify the user
|
|
110
|
+
* Identify the user, merging the anonymous subject into `appUserID`
|
|
111
|
+
* server-side.
|
|
112
|
+
*
|
|
113
|
+
* Exactly `Identity.logIn(appUserID)` with the RevenueCat name. On both
|
|
114
|
+
* platforms this POSTs `(anonymous_id, user_id)` to
|
|
115
|
+
* `/api/sdk/users/identify` and resolves once the backend ack and the
|
|
116
|
+
* post-identify entitlements refresh complete; a rejection means the device
|
|
117
|
+
* is NOT merged server-side and the call must be retried. Repeat calls with
|
|
118
|
+
* the id already in effect are free (no bridge hop, no request).
|
|
106
119
|
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
* `Identity.logIn(
|
|
120
|
+
* Works after `Purchases.configure`, `Purchases.configureCore`, or
|
|
121
|
+
* `Analytics.init` — the store does not have to be ours.
|
|
122
|
+
*
|
|
123
|
+
* @deprecated Wave 1 — prefer `Identity.logIn(userId)`. This alias exists so
|
|
124
|
+
* RevenueCat migrations compile unchanged; it is a pure delegation, so there
|
|
125
|
+
* is nothing to gain by keeping it and one less name to learn by dropping it.
|
|
111
126
|
*/
|
|
112
127
|
static logIn(appUserID: string): Promise<LogInResult>;
|
|
113
128
|
/**
|
|
114
|
-
* Log out the current user and revert to anonymous.
|
|
129
|
+
* Log out the current user and revert to anonymous. The device id survives,
|
|
130
|
+
* so analytics continuity for the same physical install is preserved.
|
|
131
|
+
*
|
|
132
|
+
* Exactly `Identity.logOut()` with the RevenueCat name, plus RC's
|
|
133
|
+
* `CustomerInfo` return: after the logout lands, the post-logout customer
|
|
134
|
+
* info is read back from the store engine. **When no store engine is
|
|
135
|
+
* configured** (`configureCore`, `Analytics.init`) there is nothing to read,
|
|
136
|
+
* and you get an entitlement-free `CustomerInfo` for the anonymous subject —
|
|
137
|
+
* the same record, built in JS, on both platforms. Do not read that as a
|
|
138
|
+
* store error; if you want real entitlements, call `getCustomerInfo()`.
|
|
115
139
|
*
|
|
116
|
-
* @deprecated Wave 1 — prefer `Identity.logOut()
|
|
140
|
+
* @deprecated Wave 1 — prefer `Identity.logOut()`, which does not pretend to
|
|
141
|
+
* return store state.
|
|
117
142
|
*/
|
|
118
143
|
static logOut(): Promise<CustomerInfo>;
|
|
119
|
-
/**
|
|
144
|
+
/**
|
|
145
|
+
* The current subject id — the identified user id if there is one, else the
|
|
146
|
+
* SDK's anonymous id (`$SKAnonymousID:`-prefixed, stable across launches).
|
|
147
|
+
*
|
|
148
|
+
* Exactly `(await Identity.current()).userId ?? .anonymousId`. Note this is
|
|
149
|
+
* the *Identity* subject on both platforms; on Android the purchase
|
|
150
|
+
* gateway's own anonymous id is a different, per-process value, and this
|
|
151
|
+
* alias deliberately does not report it.
|
|
152
|
+
*
|
|
153
|
+
* @deprecated Wave 1 — prefer `Identity.current()`, which hands back the
|
|
154
|
+
* anonymous id, the user id and `isAnonymous` in one read instead of forcing
|
|
155
|
+
* two calls that can interleave.
|
|
156
|
+
*/
|
|
120
157
|
static getAppUserID(): Promise<string>;
|
|
121
|
-
/**
|
|
158
|
+
/**
|
|
159
|
+
* Whether the current subject is the SDK-generated anonymous id.
|
|
160
|
+
*
|
|
161
|
+
* Exactly `(await Identity.current()).isAnonymous`, so it tracks
|
|
162
|
+
* `Identity.reset()` and `Identity.wipe()` on both platforms.
|
|
163
|
+
*
|
|
164
|
+
* @deprecated Wave 1 — prefer `Identity.current()`; see
|
|
165
|
+
* {@link getAppUserID}.
|
|
166
|
+
*/
|
|
122
167
|
static isAnonymous(): Promise<boolean>;
|
|
123
168
|
/** Set arbitrary subscriber attributes. null clears an attribute. */
|
|
124
169
|
static setAttributes(attributes: Record<string, string | null>): Promise<void>;
|
|
@@ -136,7 +181,14 @@ export declare class Purchases {
|
|
|
136
181
|
static addCustomerInfoUpdateListener(listener: CustomerInfoUpdateListener): void;
|
|
137
182
|
/** Remove a previously-registered CustomerInfo update listener. */
|
|
138
183
|
static removeCustomerInfoUpdateListener(listener: CustomerInfoUpdateListener): void;
|
|
139
|
-
/**
|
|
184
|
+
/**
|
|
185
|
+
* @internal Test seam: reset singleton state between tests.
|
|
186
|
+
*
|
|
187
|
+
* Also resets `Identity`'s caches, because the RC-parity aliases delegate
|
|
188
|
+
* there: without it, a `Purchases.logIn("u")` in one test would leave
|
|
189
|
+
* `Identity`'s `lastLogIn` primed and the next test's identical call would
|
|
190
|
+
* short-circuit before reaching the (freshly mocked) bridge.
|
|
191
|
+
*/
|
|
140
192
|
static __resetForTests(): void;
|
|
141
193
|
}
|
|
142
194
|
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":"AAMA,OAAO,KAAK,EACV,sBAAsB,EACtB,SAAS,EACT,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,EACrB,kBAAkB,EAClB,WAAW,EACX,0BAA0B,EAC3B,MAAM,YAAS,CAAC;AA2CjB;;;;;;;;;GASG;AACH,iBAAS,oBAAoB,IAAI,IAAI,CAIpC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,iBAAe,wBAAwB,IAAI,OAAO,CAAC,IAAI,CAAC,CAOvD;AA8DD;;;GAGG;AACH,qBAAa,SAAS;IACpB;;;;OAIG;IACH,MAAM,CAAC,SAAS,CACd,OAAO,EAAE,sBAAsB,GAAG;QAAE,QAAQ,CAAC,EAAE,SAAS,CAAA;KAAE,GACzD,IAAI;IA2BP;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,aAAa,CAClB,OAAO,EAAE,sBAAsB,GAAG;QAAE,QAAQ,CAAC,EAAE,SAAS,CAAA;KAAE,GACzD,IAAI;IAoBP;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,YAAY,IAAI,OAAO,CAAC,OAAO,CAAC;IAIvC;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,gBAAgB,IAAI,OAAO,CAAC,OAAO,CAAC;IAI3C,gFAAgF;WACnE,eAAe,IAAI,OAAO,CAAC,YAAY,CAAC;IAKrD,uDAAuD;WAC1C,YAAY,IA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AAI;IAQP,mEAAmE;IACnE,MAAM,CAAC,gCAAgC,CACrC,QAAQ,EAAE,0BAA0B,GACnC,IAAI;IAQP;;;;;;;OAOG;IACH,MAAM,CAAC,eAAe,IAAI,IAAI;CAO/B;AAGD,OAAO,EACL,oBAAoB,IAAI,sBAAsB,EAC9C,wBAAwB,IAAI,0BAA0B,GACvD,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@app-swiss-knife/react-native-sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
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",
|