@rovenue/react-native-sdk 0.24.0 → 0.26.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/dist/index.d.mts CHANGED
@@ -236,7 +236,7 @@ interface TrackParams {
236
236
  */
237
237
  declare function track(eventType: string, params?: TrackParams): Promise<void>;
238
238
 
239
- declare const ERROR_KINDS: readonly ["NetworkUnavailable", "Timeout", "RateLimited", "ServerError", "InvalidApiKey", "Forbidden", "NotFound", "InvalidRequest", "Conflict", "InvalidArgument", "SandboxKeyInRelease", "InsufficientCredits", "FunnelTokenNotFound", "FunnelTokenExpired", "FunnelTokenAlreadyClaimed", "FunnelConfigUnsupported", "FunnelInvalid", "SubscriberUnresolvable", "PurchaseCanceled", "ProductNotAvailable", "AlreadyOwned", "PaymentDeclined", "StoreServiceUnavailable", "Ineligible", "ReceiptInvalid", "StoreProblem", "Storage", "Internal"];
239
+ declare const ERROR_KINDS: readonly ["NetworkUnavailable", "Timeout", "RateLimited", "ServerError", "InvalidApiKey", "Forbidden", "NotFound", "InvalidRequest", "Conflict", "InvalidArgument", "SandboxKeyInRelease", "InsufficientCredits", "FunnelTokenNotFound", "FunnelTokenExpired", "FunnelTokenAlreadyClaimed", "FunnelConfigUnsupported", "FunnelInvalid", "SubscriberUnresolvable", "IdentityTokenInvalid", "PurchaseCanceled", "ProductNotAvailable", "AlreadyOwned", "PaymentDeclined", "StoreServiceUnavailable", "Ineligible", "ReceiptInvalid", "StoreProblem", "Storage", "Internal"];
240
240
  type ErrorKind = (typeof ERROR_KINDS)[number];
241
241
  interface ErrorExtras {
242
242
  serverCode?: string;
@@ -370,20 +370,29 @@ declare function configure(opts: RovenueConfig): void;
370
370
  */
371
371
  declare function currentUser(): Promise<User>;
372
372
  /**
373
- * Link the anonymous device identity to `appUserId`. The local write
374
- * always succeeds; the `POST /v1/identify` to the server is best-effort —
375
- * if it fails (offline/5xx) the link is retried automatically later, not
376
- * surfaced as an error here. `IDENTITY_CHANGED` fires after the bind and
373
+ * Link the anonymous device identity to `appUserId`.
374
+ *
375
+ * `identityToken` vouches for `appUserId`: your backend mints it with the
376
+ * secret key (`POST /v1/identity-tokens`) for the signed-in user and hands
377
+ * it to the app. It is valid for 15 minutes; fetch a fresh one for each
378
+ * identify.
379
+ *
380
+ * The local write always succeeds; the `POST /v1/identify` to the server is
381
+ * best-effort — if it fails (offline/5xx) the link is retried automatically
382
+ * later with the same token, not surfaced as an error here. `IDENTITY_CHANGED` fires after the bind and
377
383
  * an entitlements refresh attempt: after a delivered bind the native core
378
384
  * fetches entitlements once (firing `ENTITLEMENTS_CHANGED` when it lands)
379
385
  * and this promise resolves after that fetch. When the bind is not
380
386
  * delivered (offline, server error, refused) it fires right after the
381
387
  * local link. Rejects on
382
- * validation failure (e.g. a blank id), and with `SubscriberUnresolvable`
383
- * when the server cannot resolve this install's subscriber (corrupt merge
384
- * history) — the local link stands, unsynced, until the data is repaired.
385
- */
386
- declare function identify(appUserId: string): Promise<void>;
388
+ * validation failure (a blank id or token), with `IdentityTokenInvalid` when
389
+ * the server refuses the token (expired, or minted for another user, project
390
+ * or environment: the bind is dropped, so identify again with a fresh
391
+ * token), and with `SubscriberUnresolvable` when the server cannot resolve
392
+ * this install's subscriber (corrupt merge history) — the local link stands,
393
+ * unsynced, until the data is repaired.
394
+ */
395
+ declare function identify(appUserId: string, identityToken: string): Promise<void>;
387
396
  /**
388
397
  * Log out the current user: mints a fresh anonymous `rovenueId` and drops
389
398
  * `appUserId`, so the next identity starts clean — including a new Apple
package/dist/index.d.ts CHANGED
@@ -236,7 +236,7 @@ interface TrackParams {
236
236
  */
237
237
  declare function track(eventType: string, params?: TrackParams): Promise<void>;
238
238
 
239
- declare const ERROR_KINDS: readonly ["NetworkUnavailable", "Timeout", "RateLimited", "ServerError", "InvalidApiKey", "Forbidden", "NotFound", "InvalidRequest", "Conflict", "InvalidArgument", "SandboxKeyInRelease", "InsufficientCredits", "FunnelTokenNotFound", "FunnelTokenExpired", "FunnelTokenAlreadyClaimed", "FunnelConfigUnsupported", "FunnelInvalid", "SubscriberUnresolvable", "PurchaseCanceled", "ProductNotAvailable", "AlreadyOwned", "PaymentDeclined", "StoreServiceUnavailable", "Ineligible", "ReceiptInvalid", "StoreProblem", "Storage", "Internal"];
239
+ declare const ERROR_KINDS: readonly ["NetworkUnavailable", "Timeout", "RateLimited", "ServerError", "InvalidApiKey", "Forbidden", "NotFound", "InvalidRequest", "Conflict", "InvalidArgument", "SandboxKeyInRelease", "InsufficientCredits", "FunnelTokenNotFound", "FunnelTokenExpired", "FunnelTokenAlreadyClaimed", "FunnelConfigUnsupported", "FunnelInvalid", "SubscriberUnresolvable", "IdentityTokenInvalid", "PurchaseCanceled", "ProductNotAvailable", "AlreadyOwned", "PaymentDeclined", "StoreServiceUnavailable", "Ineligible", "ReceiptInvalid", "StoreProblem", "Storage", "Internal"];
240
240
  type ErrorKind = (typeof ERROR_KINDS)[number];
241
241
  interface ErrorExtras {
242
242
  serverCode?: string;
@@ -370,20 +370,29 @@ declare function configure(opts: RovenueConfig): void;
370
370
  */
371
371
  declare function currentUser(): Promise<User>;
372
372
  /**
373
- * Link the anonymous device identity to `appUserId`. The local write
374
- * always succeeds; the `POST /v1/identify` to the server is best-effort —
375
- * if it fails (offline/5xx) the link is retried automatically later, not
376
- * surfaced as an error here. `IDENTITY_CHANGED` fires after the bind and
373
+ * Link the anonymous device identity to `appUserId`.
374
+ *
375
+ * `identityToken` vouches for `appUserId`: your backend mints it with the
376
+ * secret key (`POST /v1/identity-tokens`) for the signed-in user and hands
377
+ * it to the app. It is valid for 15 minutes; fetch a fresh one for each
378
+ * identify.
379
+ *
380
+ * The local write always succeeds; the `POST /v1/identify` to the server is
381
+ * best-effort — if it fails (offline/5xx) the link is retried automatically
382
+ * later with the same token, not surfaced as an error here. `IDENTITY_CHANGED` fires after the bind and
377
383
  * an entitlements refresh attempt: after a delivered bind the native core
378
384
  * fetches entitlements once (firing `ENTITLEMENTS_CHANGED` when it lands)
379
385
  * and this promise resolves after that fetch. When the bind is not
380
386
  * delivered (offline, server error, refused) it fires right after the
381
387
  * local link. Rejects on
382
- * validation failure (e.g. a blank id), and with `SubscriberUnresolvable`
383
- * when the server cannot resolve this install's subscriber (corrupt merge
384
- * history) — the local link stands, unsynced, until the data is repaired.
385
- */
386
- declare function identify(appUserId: string): Promise<void>;
388
+ * validation failure (a blank id or token), with `IdentityTokenInvalid` when
389
+ * the server refuses the token (expired, or minted for another user, project
390
+ * or environment: the bind is dropped, so identify again with a fresh
391
+ * token), and with `SubscriberUnresolvable` when the server cannot resolve
392
+ * this install's subscriber (corrupt merge history) — the local link stands,
393
+ * unsynced, until the data is repaired.
394
+ */
395
+ declare function identify(appUserId: string, identityToken: string): Promise<void>;
387
396
  /**
388
397
  * Log out the current user: mints a fresh anonymous `rovenueId` and drops
389
398
  * `appUserId`, so the next identity starts clean — including a new Apple
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  SDK_VERSION
3
- } from "./chunk-ETC46J2X.js";
3
+ } from "./chunk-BORMJJTI.js";
4
4
 
5
5
  // src/events.ts
6
6
  var EVENT_WIRE_VERSION = 1;
@@ -51,6 +51,10 @@ var ERROR_KINDS = [
51
51
  // The server cannot resolve this device's subscriber (corrupt merge
52
52
  // chain, backend SUBSCRIBER_UNRESOLVABLE). Terminal: not retryable.
53
53
  "SubscriberUnresolvable",
54
+ // The server refused the identity token identify() sent (backend
55
+ // IDENTITY_TOKEN_INVALID, 401): expired, or minted for another user,
56
+ // project or environment. Not retryable: identify again with a fresh token.
57
+ "IdentityTokenInvalid",
54
58
  "PurchaseCanceled",
55
59
  "ProductNotAvailable",
56
60
  "AlreadyOwned",
@@ -523,8 +527,8 @@ async function call2(fn) {
523
527
  async function currentUser() {
524
528
  return call2(() => getNative().currentUser());
525
529
  }
526
- async function identify(appUserId) {
527
- return call2(() => getNative().identify(appUserId));
530
+ async function identify(appUserId, identityToken) {
531
+ return call2(() => getNative().identify(appUserId, identityToken));
528
532
  }
529
533
  async function logOut() {
530
534
  return call2(() => getNative().logOut());