@chipmobilesdk/rn-payment 0.6.0 → 0.7.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/CHANGELOG.md +111 -0
- package/README.md +1 -1
- package/lib/commonjs/adapter/createStoreProvider.js +110 -0
- package/lib/commonjs/adapter/createStoreProvider.js.map +1 -0
- package/lib/commonjs/adapter/iap-adapter.js +393 -0
- package/lib/commonjs/adapter/iap-adapter.js.map +1 -0
- package/lib/commonjs/adapter/iapShapes.js +169 -0
- package/lib/commonjs/adapter/iapShapes.js.map +1 -0
- package/lib/commonjs/adapter/port.js +6 -0
- package/lib/commonjs/adapter/port.js.map +1 -0
- package/lib/commonjs/config/types.js +2 -0
- package/lib/commonjs/config/types.js.map +1 -0
- package/lib/commonjs/config/validate.js +181 -0
- package/lib/commonjs/config/validate.js.map +1 -0
- package/lib/commonjs/core/mutex.js +31 -0
- package/lib/commonjs/core/mutex.js.map +1 -0
- package/lib/commonjs/core/retry.js +37 -0
- package/lib/commonjs/core/retry.js.map +1 -0
- package/lib/commonjs/core/timers.js +207 -0
- package/lib/commonjs/core/timers.js.map +1 -0
- package/lib/commonjs/diagnostics/errors.js +83 -0
- package/lib/commonjs/diagnostics/errors.js.map +1 -0
- package/lib/commonjs/diagnostics/events.js +126 -0
- package/lib/commonjs/diagnostics/events.js.map +1 -0
- package/lib/commonjs/diagnostics/messageKeys.js +70 -0
- package/lib/commonjs/diagnostics/messageKeys.js.map +1 -0
- package/lib/commonjs/engine/connection.js +189 -0
- package/lib/commonjs/engine/connection.js.map +1 -0
- package/lib/commonjs/engine/engine.js +279 -0
- package/lib/commonjs/engine/engine.js.map +1 -0
- package/lib/commonjs/engine/finalize.js +325 -0
- package/lib/commonjs/engine/finalize.js.map +1 -0
- package/lib/commonjs/engine/foreground.js +26 -0
- package/lib/commonjs/engine/foreground.js.map +1 -0
- package/lib/commonjs/engine/internals.js +31 -0
- package/lib/commonjs/engine/internals.js.map +1 -0
- package/lib/commonjs/engine/pending.js +102 -0
- package/lib/commonjs/engine/pending.js.map +1 -0
- package/lib/commonjs/engine/products.js +198 -0
- package/lib/commonjs/engine/products.js.map +1 -0
- package/lib/commonjs/engine/purchase.js +395 -0
- package/lib/commonjs/engine/purchase.js.map +1 -0
- package/lib/commonjs/engine/purchaseFailure.js +77 -0
- package/lib/commonjs/engine/purchaseFailure.js.map +1 -0
- package/lib/commonjs/engine/receiptValidation.js +90 -0
- package/lib/commonjs/engine/receiptValidation.js.map +1 -0
- package/lib/commonjs/engine/state.js +201 -0
- package/lib/commonjs/engine/state.js.map +1 -0
- package/lib/commonjs/engine/subscriptions.js +122 -0
- package/lib/commonjs/engine/subscriptions.js.map +1 -0
- package/lib/commonjs/engine/sync.js +163 -0
- package/lib/commonjs/engine/sync.js.map +1 -0
- package/lib/commonjs/entitlements/aggregate.js +212 -0
- package/lib/commonjs/entitlements/aggregate.js.map +1 -0
- package/lib/commonjs/entitlements/mapping.js +41 -0
- package/lib/commonjs/entitlements/mapping.js.map +1 -0
- package/lib/commonjs/entitlements/policy.js +110 -0
- package/lib/commonjs/entitlements/policy.js.map +1 -0
- package/lib/commonjs/index.js +266 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/persistence/mmkv-store.js +149 -0
- package/lib/commonjs/persistence/mmkv-store.js.map +1 -0
- package/lib/commonjs/persistence/snapshot.js +229 -0
- package/lib/commonjs/persistence/snapshot.js.map +1 -0
- package/lib/commonjs/react/PaymentProvider.js +96 -0
- package/lib/commonjs/react/PaymentProvider.js.map +1 -0
- package/lib/commonjs/react/hooks.js +202 -0
- package/lib/commonjs/react/hooks.js.map +1 -0
- package/lib/commonjs/testing/conformance.js +136 -0
- package/lib/commonjs/testing/conformance.js.map +1 -0
- package/lib/commonjs/testing/fakeStore.js +281 -0
- package/lib/commonjs/testing/fakeStore.js.map +1 -0
- package/lib/commonjs/testing/index.js +45 -0
- package/lib/commonjs/testing/index.js.map +1 -0
- package/lib/module/adapter/createStoreProvider.js +106 -0
- package/lib/module/adapter/createStoreProvider.js.map +1 -0
- package/lib/module/adapter/iap-adapter.js +383 -0
- package/lib/module/adapter/iap-adapter.js.map +1 -0
- package/lib/module/adapter/iapShapes.js +160 -0
- package/lib/module/adapter/iapShapes.js.map +1 -0
- package/lib/module/adapter/port.js +4 -0
- package/lib/module/adapter/port.js.map +1 -0
- package/lib/module/config/types.js +2 -0
- package/lib/module/config/types.js.map +1 -0
- package/lib/module/config/validate.js +175 -0
- package/lib/module/config/validate.js.map +1 -0
- package/lib/module/core/mutex.js +22 -0
- package/lib/module/core/mutex.js.map +1 -0
- package/lib/module/core/retry.js +33 -0
- package/lib/module/core/retry.js.map +1 -0
- package/lib/module/core/timers.js +198 -0
- package/lib/module/core/timers.js.map +1 -0
- package/lib/module/diagnostics/errors.js +76 -0
- package/lib/module/diagnostics/errors.js.map +1 -0
- package/lib/module/diagnostics/events.js +117 -0
- package/lib/module/diagnostics/events.js.map +1 -0
- package/lib/module/diagnostics/messageKeys.js +64 -0
- package/lib/module/diagnostics/messageKeys.js.map +1 -0
- package/lib/module/engine/connection.js +185 -0
- package/lib/module/engine/connection.js.map +1 -0
- package/lib/module/engine/engine.js +274 -0
- package/lib/module/engine/engine.js.map +1 -0
- package/lib/module/engine/finalize.js +322 -0
- package/lib/module/engine/finalize.js.map +1 -0
- package/lib/module/engine/foreground.js +21 -0
- package/lib/module/engine/foreground.js.map +1 -0
- package/lib/module/engine/internals.js +26 -0
- package/lib/module/engine/internals.js.map +1 -0
- package/lib/module/engine/pending.js +95 -0
- package/lib/module/engine/pending.js.map +1 -0
- package/lib/module/engine/products.js +195 -0
- package/lib/module/engine/products.js.map +1 -0
- package/lib/module/engine/purchase.js +390 -0
- package/lib/module/engine/purchase.js.map +1 -0
- package/lib/module/engine/purchaseFailure.js +72 -0
- package/lib/module/engine/purchaseFailure.js.map +1 -0
- package/lib/module/engine/receiptValidation.js +87 -0
- package/lib/module/engine/receiptValidation.js.map +1 -0
- package/lib/module/engine/state.js +196 -0
- package/lib/module/engine/state.js.map +1 -0
- package/lib/module/engine/subscriptions.js +119 -0
- package/lib/module/engine/subscriptions.js.map +1 -0
- package/lib/module/engine/sync.js +158 -0
- package/lib/module/engine/sync.js.map +1 -0
- package/lib/module/entitlements/aggregate.js +204 -0
- package/lib/module/entitlements/aggregate.js.map +1 -0
- package/lib/module/entitlements/mapping.js +35 -0
- package/lib/module/entitlements/mapping.js.map +1 -0
- package/lib/module/entitlements/policy.js +104 -0
- package/lib/module/entitlements/policy.js.map +1 -0
- package/lib/module/index.js +59 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/persistence/mmkv-store.js +144 -0
- package/lib/module/persistence/mmkv-store.js.map +1 -0
- package/lib/module/persistence/snapshot.js +221 -0
- package/lib/module/persistence/snapshot.js.map +1 -0
- package/lib/module/react/PaymentProvider.js +90 -0
- package/lib/module/react/PaymentProvider.js.map +1 -0
- package/lib/module/react/hooks.js +192 -0
- package/lib/module/react/hooks.js.map +1 -0
- package/lib/module/testing/conformance.js +130 -0
- package/lib/module/testing/conformance.js.map +1 -0
- package/lib/module/testing/fakeStore.js +276 -0
- package/lib/module/testing/fakeStore.js.map +1 -0
- package/lib/module/testing/index.js +13 -0
- package/lib/module/testing/index.js.map +1 -0
- package/lib/typescript/commonjs/adapter/createStoreProvider.d.ts +45 -0
- package/lib/typescript/commonjs/adapter/createStoreProvider.d.ts.map +1 -0
- package/lib/typescript/commonjs/adapter/iap-adapter.d.ts +80 -0
- package/lib/typescript/commonjs/adapter/iap-adapter.d.ts.map +1 -0
- package/lib/typescript/commonjs/adapter/iapShapes.d.ts +94 -0
- package/lib/typescript/commonjs/adapter/iapShapes.d.ts.map +1 -0
- package/lib/typescript/commonjs/adapter/port.d.ts +184 -0
- package/lib/typescript/commonjs/adapter/port.d.ts.map +1 -0
- package/lib/typescript/commonjs/config/types.d.ts +326 -0
- package/lib/typescript/commonjs/config/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/config/validate.d.ts +63 -0
- package/lib/typescript/commonjs/config/validate.d.ts.map +1 -0
- package/lib/typescript/commonjs/core/mutex.d.ts +17 -0
- package/lib/typescript/commonjs/core/mutex.d.ts.map +1 -0
- package/lib/typescript/commonjs/core/retry.d.ts +19 -0
- package/lib/typescript/commonjs/core/retry.d.ts.map +1 -0
- package/lib/typescript/commonjs/core/timers.d.ts +142 -0
- package/lib/typescript/commonjs/core/timers.d.ts.map +1 -0
- package/lib/typescript/commonjs/diagnostics/errors.d.ts +55 -0
- package/lib/typescript/commonjs/diagnostics/errors.d.ts.map +1 -0
- package/lib/typescript/commonjs/diagnostics/events.d.ts +158 -0
- package/lib/typescript/commonjs/diagnostics/events.d.ts.map +1 -0
- package/lib/typescript/commonjs/diagnostics/messageKeys.d.ts +54 -0
- package/lib/typescript/commonjs/diagnostics/messageKeys.d.ts.map +1 -0
- package/lib/typescript/commonjs/engine/connection.d.ts +30 -0
- package/lib/typescript/commonjs/engine/connection.d.ts.map +1 -0
- package/lib/typescript/commonjs/engine/engine.d.ts +93 -0
- package/lib/typescript/commonjs/engine/engine.d.ts.map +1 -0
- package/lib/typescript/commonjs/engine/finalize.d.ts +53 -0
- package/lib/typescript/commonjs/engine/finalize.d.ts.map +1 -0
- package/lib/typescript/commonjs/engine/foreground.d.ts +15 -0
- package/lib/typescript/commonjs/engine/foreground.d.ts.map +1 -0
- package/lib/typescript/commonjs/engine/internals.d.ts +28 -0
- package/lib/typescript/commonjs/engine/internals.d.ts.map +1 -0
- package/lib/typescript/commonjs/engine/pending.d.ts +51 -0
- package/lib/typescript/commonjs/engine/pending.d.ts.map +1 -0
- package/lib/typescript/commonjs/engine/products.d.ts +82 -0
- package/lib/typescript/commonjs/engine/products.d.ts.map +1 -0
- package/lib/typescript/commonjs/engine/purchase.d.ts +61 -0
- package/lib/typescript/commonjs/engine/purchase.d.ts.map +1 -0
- package/lib/typescript/commonjs/engine/purchaseFailure.d.ts +15 -0
- package/lib/typescript/commonjs/engine/purchaseFailure.d.ts.map +1 -0
- package/lib/typescript/commonjs/engine/receiptValidation.d.ts +42 -0
- package/lib/typescript/commonjs/engine/receiptValidation.d.ts.map +1 -0
- package/lib/typescript/commonjs/engine/state.d.ts +46 -0
- package/lib/typescript/commonjs/engine/state.d.ts.map +1 -0
- package/lib/typescript/commonjs/engine/subscriptions.d.ts +61 -0
- package/lib/typescript/commonjs/engine/subscriptions.d.ts.map +1 -0
- package/lib/typescript/commonjs/engine/sync.d.ts +36 -0
- package/lib/typescript/commonjs/engine/sync.d.ts.map +1 -0
- package/lib/typescript/commonjs/entitlements/aggregate.d.ts +97 -0
- package/lib/typescript/commonjs/entitlements/aggregate.d.ts.map +1 -0
- package/lib/typescript/commonjs/entitlements/mapping.d.ts +27 -0
- package/lib/typescript/commonjs/entitlements/mapping.d.ts.map +1 -0
- package/lib/typescript/commonjs/entitlements/policy.d.ts +75 -0
- package/lib/typescript/commonjs/entitlements/policy.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +44 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/persistence/mmkv-store.d.ts +45 -0
- package/lib/typescript/commonjs/persistence/mmkv-store.d.ts.map +1 -0
- package/lib/typescript/commonjs/persistence/snapshot.d.ts +106 -0
- package/lib/typescript/commonjs/persistence/snapshot.d.ts.map +1 -0
- package/lib/typescript/commonjs/react/PaymentProvider.d.ts +57 -0
- package/lib/typescript/commonjs/react/PaymentProvider.d.ts.map +1 -0
- package/lib/typescript/commonjs/react/hooks.d.ts +80 -0
- package/lib/typescript/commonjs/react/hooks.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/conformance.d.ts +41 -0
- package/lib/typescript/commonjs/testing/conformance.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/fakeStore.d.ts +69 -0
- package/lib/typescript/commonjs/testing/fakeStore.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/index.d.ts +12 -0
- package/lib/typescript/commonjs/testing/index.d.ts.map +1 -0
- package/lib/typescript/module/adapter/createStoreProvider.d.ts +45 -0
- package/lib/typescript/module/adapter/createStoreProvider.d.ts.map +1 -0
- package/lib/typescript/module/adapter/iap-adapter.d.ts +80 -0
- package/lib/typescript/module/adapter/iap-adapter.d.ts.map +1 -0
- package/lib/typescript/module/adapter/iapShapes.d.ts +94 -0
- package/lib/typescript/module/adapter/iapShapes.d.ts.map +1 -0
- package/lib/typescript/module/adapter/port.d.ts +184 -0
- package/lib/typescript/module/adapter/port.d.ts.map +1 -0
- package/lib/typescript/module/config/types.d.ts +326 -0
- package/lib/typescript/module/config/types.d.ts.map +1 -0
- package/lib/typescript/module/config/validate.d.ts +63 -0
- package/lib/typescript/module/config/validate.d.ts.map +1 -0
- package/lib/typescript/module/core/mutex.d.ts +17 -0
- package/lib/typescript/module/core/mutex.d.ts.map +1 -0
- package/lib/typescript/module/core/retry.d.ts +19 -0
- package/lib/typescript/module/core/retry.d.ts.map +1 -0
- package/lib/typescript/module/core/timers.d.ts +142 -0
- package/lib/typescript/module/core/timers.d.ts.map +1 -0
- package/lib/typescript/module/diagnostics/errors.d.ts +55 -0
- package/lib/typescript/module/diagnostics/errors.d.ts.map +1 -0
- package/lib/typescript/module/diagnostics/events.d.ts +158 -0
- package/lib/typescript/module/diagnostics/events.d.ts.map +1 -0
- package/lib/typescript/module/diagnostics/messageKeys.d.ts +54 -0
- package/lib/typescript/module/diagnostics/messageKeys.d.ts.map +1 -0
- package/lib/typescript/module/engine/connection.d.ts +30 -0
- package/lib/typescript/module/engine/connection.d.ts.map +1 -0
- package/lib/typescript/module/engine/engine.d.ts +93 -0
- package/lib/typescript/module/engine/engine.d.ts.map +1 -0
- package/lib/typescript/module/engine/finalize.d.ts +53 -0
- package/lib/typescript/module/engine/finalize.d.ts.map +1 -0
- package/lib/typescript/module/engine/foreground.d.ts +15 -0
- package/lib/typescript/module/engine/foreground.d.ts.map +1 -0
- package/lib/typescript/module/engine/internals.d.ts +28 -0
- package/lib/typescript/module/engine/internals.d.ts.map +1 -0
- package/lib/typescript/module/engine/pending.d.ts +51 -0
- package/lib/typescript/module/engine/pending.d.ts.map +1 -0
- package/lib/typescript/module/engine/products.d.ts +82 -0
- package/lib/typescript/module/engine/products.d.ts.map +1 -0
- package/lib/typescript/module/engine/purchase.d.ts +61 -0
- package/lib/typescript/module/engine/purchase.d.ts.map +1 -0
- package/lib/typescript/module/engine/purchaseFailure.d.ts +15 -0
- package/lib/typescript/module/engine/purchaseFailure.d.ts.map +1 -0
- package/lib/typescript/module/engine/receiptValidation.d.ts +42 -0
- package/lib/typescript/module/engine/receiptValidation.d.ts.map +1 -0
- package/lib/typescript/module/engine/state.d.ts +46 -0
- package/lib/typescript/module/engine/state.d.ts.map +1 -0
- package/lib/typescript/module/engine/subscriptions.d.ts +61 -0
- package/lib/typescript/module/engine/subscriptions.d.ts.map +1 -0
- package/lib/typescript/module/engine/sync.d.ts +36 -0
- package/lib/typescript/module/engine/sync.d.ts.map +1 -0
- package/lib/typescript/module/entitlements/aggregate.d.ts +97 -0
- package/lib/typescript/module/entitlements/aggregate.d.ts.map +1 -0
- package/lib/typescript/module/entitlements/mapping.d.ts +27 -0
- package/lib/typescript/module/entitlements/mapping.d.ts.map +1 -0
- package/lib/typescript/module/entitlements/policy.d.ts +75 -0
- package/lib/typescript/module/entitlements/policy.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +44 -0
- package/lib/typescript/module/index.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/persistence/mmkv-store.d.ts +45 -0
- package/lib/typescript/module/persistence/mmkv-store.d.ts.map +1 -0
- package/lib/typescript/module/persistence/snapshot.d.ts +106 -0
- package/lib/typescript/module/persistence/snapshot.d.ts.map +1 -0
- package/lib/typescript/module/react/PaymentProvider.d.ts +57 -0
- package/lib/typescript/module/react/PaymentProvider.d.ts.map +1 -0
- package/lib/typescript/module/react/hooks.d.ts +80 -0
- package/lib/typescript/module/react/hooks.d.ts.map +1 -0
- package/lib/typescript/module/testing/conformance.d.ts +41 -0
- package/lib/typescript/module/testing/conformance.d.ts.map +1 -0
- package/lib/typescript/module/testing/fakeStore.d.ts +69 -0
- package/lib/typescript/module/testing/fakeStore.d.ts.map +1 -0
- package/lib/typescript/module/testing/index.d.ts +12 -0
- package/lib/typescript/module/testing/index.d.ts.map +1 -0
- package/package.json +49 -13
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.VALIDATE_TIMEOUT_BOUNDS = exports.SYNC_TIMEOUT_BOUNDS = exports.STALE_AFTER_BOUNDS = exports.PURCHASE_LAUNCH_TIMEOUT_BOUNDS = exports.PURCHASE_FLOW_CEILING_MS = exports.PRODUCT_QUERY_TIMEOUT_BOUNDS = exports.PRODUCT_CACHE_TTL_BOUNDS = exports.FOREGROUND_SYNC_MIN_INTERVAL_BOUNDS = exports.FINALIZE_ATTEMPT_TIMEOUT_BOUNDS = exports.DEFAULT_VALIDATE_TIMEOUT_MS = exports.DEFAULT_SYNC_TIMEOUT_MS = exports.DEFAULT_STALE_AFTER_MS = exports.DEFAULT_RECONNECT_BACKOFF = exports.DEFAULT_PURCHASE_LAUNCH_TIMEOUT_MS = exports.DEFAULT_PRODUCT_QUERY_TIMEOUT_MS = exports.DEFAULT_PRODUCT_CACHE_TTL_MS = exports.DEFAULT_FOREGROUND_SYNC_MIN_INTERVAL_MS = exports.DEFAULT_FINALIZE_BACKOFF = exports.DEFAULT_FINALIZE_ATTEMPT_TIMEOUT_MS = exports.DEFAULT_CONNECT_TIMEOUT_MS = exports.CONNECT_TIMEOUT_BOUNDS = exports.BACKOFF_MAX_DELAY_BOUNDS = exports.BACKOFF_INITIAL_DELAY_BOUNDS = exports.BACKOFF_FACTOR_BOUNDS = exports.BACKOFF_ATTEMPT_BOUNDS = void 0;
|
|
7
|
+
exports.resolveForegroundSyncMinIntervalMs = resolveForegroundSyncMinIntervalMs;
|
|
8
|
+
exports.resolveProductCacheTtlMs = resolveProductCacheTtlMs;
|
|
9
|
+
exports.resolveRetry = resolveRetry;
|
|
10
|
+
exports.resolveStaleAfterMs = resolveStaleAfterMs;
|
|
11
|
+
exports.resolveTimeouts = resolveTimeouts;
|
|
12
|
+
var _rnCore = require("@chipmobilesdk/rn-core");
|
|
13
|
+
var _errors = require("../diagnostics/errors.js");
|
|
14
|
+
/**
|
|
15
|
+
* Timeout, retry, and cache policy.
|
|
16
|
+
*
|
|
17
|
+
* Defaults and bounds live here rather than at each call site so there is one
|
|
18
|
+
* place to read what the package will wait for, and so consumers can read the
|
|
19
|
+
* values they are bound by instead of discovering them from a timeout in
|
|
20
|
+
* production.
|
|
21
|
+
*
|
|
22
|
+
* Out-of-band values are a configuration error rather than being silently
|
|
23
|
+
* clamped: quietly turning a 1-second timeout into 3 seconds would tell the app
|
|
24
|
+
* it configured something it did not.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/** Local IPC to Play Services. Slower than this means unavailable, not busy. */
|
|
28
|
+
const DEFAULT_CONNECT_TIMEOUT_MS = exports.DEFAULT_CONNECT_TIMEOUT_MS = 10_000;
|
|
29
|
+
/** A network round trip; a paywall that hangs longer should show its error state. */
|
|
30
|
+
const DEFAULT_PRODUCT_QUERY_TIMEOUT_MS = exports.DEFAULT_PRODUCT_QUERY_TIMEOUT_MS = 15_000;
|
|
31
|
+
/** Runs at startup, so it must not hold the first render hostage. */
|
|
32
|
+
const DEFAULT_SYNC_TIMEOUT_MS = exports.DEFAULT_SYNC_TIMEOUT_MS = 20_000;
|
|
33
|
+
/**
|
|
34
|
+
* Covers opening the store surface only.
|
|
35
|
+
*
|
|
36
|
+
* Time the user spends *inside* the store's own UI is deliberately excluded
|
|
37
|
+
* (FR-035): a user reading the terms, switching to their banking app for an OTP,
|
|
38
|
+
* or simply hesitating must never have their purchase cancelled by our clock.
|
|
39
|
+
*/
|
|
40
|
+
const DEFAULT_PURCHASE_LAUNCH_TIMEOUT_MS = exports.DEFAULT_PURCHASE_LAUNCH_TIMEOUT_MS = 30_000;
|
|
41
|
+
/** Per finalize attempt, not per transaction — the queue owns overall persistence. */
|
|
42
|
+
const DEFAULT_FINALIZE_ATTEMPT_TIMEOUT_MS = exports.DEFAULT_FINALIZE_ATTEMPT_TIMEOUT_MS = 15_000;
|
|
43
|
+
/** The app's backend hook. A user is waiting on a purchase result behind it. */
|
|
44
|
+
const DEFAULT_VALIDATE_TIMEOUT_MS = exports.DEFAULT_VALIDATE_TIMEOUT_MS = 15_000;
|
|
45
|
+
/**
|
|
46
|
+
* The ceiling on a purchase flow whose outcome includes the user's own time in
|
|
47
|
+
* the store UI, so is otherwise untimed (FR-035). Not a timeout on the user: it
|
|
48
|
+
* exists only so a binding that never answers cannot hold the purchase lock for
|
|
49
|
+
* the rest of the session. A purchase that completes later still arrives through
|
|
50
|
+
* the store update channel and is granted then.
|
|
51
|
+
*/
|
|
52
|
+
const PURCHASE_FLOW_CEILING_MS = exports.PURCHASE_FLOW_CEILING_MS = 10 * 60_000;
|
|
53
|
+
const CONNECT_TIMEOUT_BOUNDS = exports.CONNECT_TIMEOUT_BOUNDS = {
|
|
54
|
+
min: 3_000,
|
|
55
|
+
max: 60_000
|
|
56
|
+
};
|
|
57
|
+
const PRODUCT_QUERY_TIMEOUT_BOUNDS = exports.PRODUCT_QUERY_TIMEOUT_BOUNDS = {
|
|
58
|
+
min: 3_000,
|
|
59
|
+
max: 60_000
|
|
60
|
+
};
|
|
61
|
+
const SYNC_TIMEOUT_BOUNDS = exports.SYNC_TIMEOUT_BOUNDS = {
|
|
62
|
+
min: 5_000,
|
|
63
|
+
max: 120_000
|
|
64
|
+
};
|
|
65
|
+
const PURCHASE_LAUNCH_TIMEOUT_BOUNDS = exports.PURCHASE_LAUNCH_TIMEOUT_BOUNDS = {
|
|
66
|
+
min: 5_000,
|
|
67
|
+
max: 120_000
|
|
68
|
+
};
|
|
69
|
+
const FINALIZE_ATTEMPT_TIMEOUT_BOUNDS = exports.FINALIZE_ATTEMPT_TIMEOUT_BOUNDS = {
|
|
70
|
+
min: 3_000,
|
|
71
|
+
max: 60_000
|
|
72
|
+
};
|
|
73
|
+
const VALIDATE_TIMEOUT_BOUNDS = exports.VALIDATE_TIMEOUT_BOUNDS = {
|
|
74
|
+
min: 3_000,
|
|
75
|
+
max: 120_000
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Prices and offer eligibility are shown at the moment of purchase, so a short
|
|
80
|
+
* TTL with on-demand refresh beats a long one (FR-029).
|
|
81
|
+
*/
|
|
82
|
+
const DEFAULT_PRODUCT_CACHE_TTL_MS = exports.DEFAULT_PRODUCT_CACHE_TTL_MS = 900_000;
|
|
83
|
+
const PRODUCT_CACHE_TTL_BOUNDS = exports.PRODUCT_CACHE_TTL_BOUNDS = {
|
|
84
|
+
min: 60_000,
|
|
85
|
+
max: 86_400_000
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* How long a successful sync keeps entitlements trustworthy offline: **7 days**.
|
|
90
|
+
*
|
|
91
|
+
* Fixed by the specification (FR-055) after weighing both failure directions.
|
|
92
|
+
* The realistic offline cases — travel, poor coverage, a device left unused —
|
|
93
|
+
* resolve within days. Seven days covers a holiday without connectivity while
|
|
94
|
+
* bounding how long a refunded entitlement can outlive its refund to one week.
|
|
95
|
+
*
|
|
96
|
+
* Past this the entitlement becomes `unknown`, never `not_entitled` (FR-055a):
|
|
97
|
+
* the package stops asserting rather than telling a paying customer they did not
|
|
98
|
+
* pay.
|
|
99
|
+
*/
|
|
100
|
+
const DEFAULT_STALE_AFTER_MS = exports.DEFAULT_STALE_AFTER_MS = 604_800_000;
|
|
101
|
+
const STALE_AFTER_BOUNDS = exports.STALE_AFTER_BOUNDS = {
|
|
102
|
+
min: 3_600_000,
|
|
103
|
+
max: 7_776_000_000
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
/** Keeps rapid app switching from becoming a request storm (PERF-002). */
|
|
107
|
+
const DEFAULT_FOREGROUND_SYNC_MIN_INTERVAL_MS = exports.DEFAULT_FOREGROUND_SYNC_MIN_INTERVAL_MS = 60_000;
|
|
108
|
+
const FOREGROUND_SYNC_MIN_INTERVAL_BOUNDS = exports.FOREGROUND_SYNC_MIN_INTERVAL_BOUNDS = {
|
|
109
|
+
min: 0,
|
|
110
|
+
max: 3_600_000
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
/** Bounded so a dropped billing connection cannot become a retry storm (FR-020). */
|
|
114
|
+
const DEFAULT_RECONNECT_BACKOFF = exports.DEFAULT_RECONNECT_BACKOFF = {
|
|
115
|
+
initialDelayMs: 1_000,
|
|
116
|
+
maxDelayMs: 30_000,
|
|
117
|
+
factor: 2,
|
|
118
|
+
maxAttempts: 5,
|
|
119
|
+
jitter: true
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Finalize retry.
|
|
124
|
+
*
|
|
125
|
+
* Bounded **per session** but never permanently abandoned: Google auto-refunds
|
|
126
|
+
* an unacknowledged purchase after three days, so exhausting this session's
|
|
127
|
+
* attempts must leave the transaction queued for the next launch, not dropped
|
|
128
|
+
* (FR-045).
|
|
129
|
+
*/
|
|
130
|
+
const DEFAULT_FINALIZE_BACKOFF = exports.DEFAULT_FINALIZE_BACKOFF = {
|
|
131
|
+
initialDelayMs: 2_000,
|
|
132
|
+
maxDelayMs: 60_000,
|
|
133
|
+
factor: 2,
|
|
134
|
+
maxAttempts: 5,
|
|
135
|
+
jitter: true
|
|
136
|
+
};
|
|
137
|
+
const BACKOFF_MAX_DELAY_BOUNDS = exports.BACKOFF_MAX_DELAY_BOUNDS = {
|
|
138
|
+
min: 5_000,
|
|
139
|
+
max: 600_000
|
|
140
|
+
};
|
|
141
|
+
const BACKOFF_ATTEMPT_BOUNDS = exports.BACKOFF_ATTEMPT_BOUNDS = {
|
|
142
|
+
min: 1,
|
|
143
|
+
max: 10
|
|
144
|
+
};
|
|
145
|
+
/** A first retry sooner than this is a storm; later than this, the user has given up. */
|
|
146
|
+
const BACKOFF_INITIAL_DELAY_BOUNDS = exports.BACKOFF_INITIAL_DELAY_BOUNDS = {
|
|
147
|
+
min: 100,
|
|
148
|
+
max: 60_000
|
|
149
|
+
};
|
|
150
|
+
/** 1 is a constant delay; 0 or below would retry at once, forever (CORE-05). */
|
|
151
|
+
const BACKOFF_FACTOR_BOUNDS = exports.BACKOFF_FACTOR_BOUNDS = {
|
|
152
|
+
min: 1,
|
|
153
|
+
max: 10
|
|
154
|
+
};
|
|
155
|
+
function invalidConfig(label) {
|
|
156
|
+
return message => new _errors.PaymentConfigError({
|
|
157
|
+
code: 'PAYMENT_INVALID_CONFIG',
|
|
158
|
+
message,
|
|
159
|
+
operation: 'configure',
|
|
160
|
+
offenders: [label]
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
function requireInBounds(label, value, fallback, bounds, unit = 'ms') {
|
|
164
|
+
return value === undefined ? fallback : (0, _rnCore.checkRange)(label, value, bounds, invalidConfig(label), unit);
|
|
165
|
+
}
|
|
166
|
+
function resolveTimeouts(config) {
|
|
167
|
+
return {
|
|
168
|
+
connectMs: requireInBounds('timeouts.connectMs', config?.connectMs, DEFAULT_CONNECT_TIMEOUT_MS, CONNECT_TIMEOUT_BOUNDS),
|
|
169
|
+
productQueryMs: requireInBounds('timeouts.productQueryMs', config?.productQueryMs, DEFAULT_PRODUCT_QUERY_TIMEOUT_MS, PRODUCT_QUERY_TIMEOUT_BOUNDS),
|
|
170
|
+
syncMs: requireInBounds('timeouts.syncMs', config?.syncMs, DEFAULT_SYNC_TIMEOUT_MS, SYNC_TIMEOUT_BOUNDS),
|
|
171
|
+
purchaseLaunchMs: requireInBounds('timeouts.purchaseLaunchMs', config?.purchaseLaunchMs, DEFAULT_PURCHASE_LAUNCH_TIMEOUT_MS, PURCHASE_LAUNCH_TIMEOUT_BOUNDS),
|
|
172
|
+
finalizeAttemptMs: requireInBounds('timeouts.finalizeAttemptMs', config?.finalizeAttemptMs, DEFAULT_FINALIZE_ATTEMPT_TIMEOUT_MS, FINALIZE_ATTEMPT_TIMEOUT_BOUNDS),
|
|
173
|
+
validateMs: requireInBounds('timeouts.validateMs', config?.validateMs, DEFAULT_VALIDATE_TIMEOUT_MS, VALIDATE_TIMEOUT_BOUNDS)
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
function resolveBackoff(label, config, fallback) {
|
|
177
|
+
const maxDelayMs = requireInBounds(`${label}.maxDelayMs`, config?.maxDelayMs, fallback.maxDelayMs, BACKOFF_MAX_DELAY_BOUNDS);
|
|
178
|
+
const maxAttempts = requireInBounds(`${label}.maxAttempts`, config?.maxAttempts, fallback.maxAttempts, BACKOFF_ATTEMPT_BOUNDS, '');
|
|
179
|
+
const initialDelayMs = requireInBounds(`${label}.initialDelayMs`, config?.initialDelayMs, fallback.initialDelayMs, BACKOFF_INITIAL_DELAY_BOUNDS);
|
|
180
|
+
const factor = requireInBounds(`${label}.factor`, config?.factor, fallback.factor, BACKOFF_FACTOR_BOUNDS, '');
|
|
181
|
+
if (initialDelayMs > maxDelayMs) {
|
|
182
|
+
throw invalidConfig(`${label}.initialDelayMs`)(`${label}.initialDelayMs (${initialDelayMs}ms) exceeds ${label}.maxDelayMs (${maxDelayMs}ms)`);
|
|
183
|
+
}
|
|
184
|
+
return {
|
|
185
|
+
initialDelayMs,
|
|
186
|
+
maxDelayMs,
|
|
187
|
+
factor,
|
|
188
|
+
maxAttempts,
|
|
189
|
+
jitter: config?.jitter ?? fallback.jitter
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
function resolveRetry(config) {
|
|
193
|
+
return {
|
|
194
|
+
reconnect: resolveBackoff('retry.reconnect', config?.reconnect, DEFAULT_RECONNECT_BACKOFF),
|
|
195
|
+
finalize: resolveBackoff('retry.finalize', config?.finalize, DEFAULT_FINALIZE_BACKOFF)
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
function resolveStaleAfterMs(value) {
|
|
199
|
+
return requireInBounds('staleAfterMs', value, DEFAULT_STALE_AFTER_MS, STALE_AFTER_BOUNDS);
|
|
200
|
+
}
|
|
201
|
+
function resolveProductCacheTtlMs(value) {
|
|
202
|
+
return requireInBounds('productCacheTtlMs', value, DEFAULT_PRODUCT_CACHE_TTL_MS, PRODUCT_CACHE_TTL_BOUNDS);
|
|
203
|
+
}
|
|
204
|
+
function resolveForegroundSyncMinIntervalMs(value) {
|
|
205
|
+
return requireInBounds('foregroundSyncMinIntervalMs', value, DEFAULT_FOREGROUND_SYNC_MIN_INTERVAL_MS, FOREGROUND_SYNC_MIN_INTERVAL_BOUNDS);
|
|
206
|
+
}
|
|
207
|
+
//# sourceMappingURL=timers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_rnCore","require","_errors","DEFAULT_CONNECT_TIMEOUT_MS","exports","DEFAULT_PRODUCT_QUERY_TIMEOUT_MS","DEFAULT_SYNC_TIMEOUT_MS","DEFAULT_PURCHASE_LAUNCH_TIMEOUT_MS","DEFAULT_FINALIZE_ATTEMPT_TIMEOUT_MS","DEFAULT_VALIDATE_TIMEOUT_MS","PURCHASE_FLOW_CEILING_MS","CONNECT_TIMEOUT_BOUNDS","min","max","PRODUCT_QUERY_TIMEOUT_BOUNDS","SYNC_TIMEOUT_BOUNDS","PURCHASE_LAUNCH_TIMEOUT_BOUNDS","FINALIZE_ATTEMPT_TIMEOUT_BOUNDS","VALIDATE_TIMEOUT_BOUNDS","DEFAULT_PRODUCT_CACHE_TTL_MS","PRODUCT_CACHE_TTL_BOUNDS","DEFAULT_STALE_AFTER_MS","STALE_AFTER_BOUNDS","DEFAULT_FOREGROUND_SYNC_MIN_INTERVAL_MS","FOREGROUND_SYNC_MIN_INTERVAL_BOUNDS","DEFAULT_RECONNECT_BACKOFF","initialDelayMs","maxDelayMs","factor","maxAttempts","jitter","DEFAULT_FINALIZE_BACKOFF","BACKOFF_MAX_DELAY_BOUNDS","BACKOFF_ATTEMPT_BOUNDS","BACKOFF_INITIAL_DELAY_BOUNDS","BACKOFF_FACTOR_BOUNDS","invalidConfig","label","message","PaymentConfigError","code","operation","offenders","requireInBounds","value","fallback","bounds","unit","undefined","checkRange","resolveTimeouts","config","connectMs","productQueryMs","syncMs","purchaseLaunchMs","finalizeAttemptMs","validateMs","resolveBackoff","resolveRetry","reconnect","finalize","resolveStaleAfterMs","resolveProductCacheTtlMs","resolveForegroundSyncMinIntervalMs"],"sourceRoot":"../../../src","sources":["core/timers.ts"],"mappings":";;;;;;;;;;;AAaA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AAfA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA;AACO,MAAME,0BAA0B,GAAAC,OAAA,CAAAD,0BAAA,GAAG,MAAM;AAChD;AACO,MAAME,gCAAgC,GAAAD,OAAA,CAAAC,gCAAA,GAAG,MAAM;AACtD;AACO,MAAMC,uBAAuB,GAAAF,OAAA,CAAAE,uBAAA,GAAG,MAAM;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,kCAAkC,GAAAH,OAAA,CAAAG,kCAAA,GAAG,MAAM;AACxD;AACO,MAAMC,mCAAmC,GAAAJ,OAAA,CAAAI,mCAAA,GAAG,MAAM;AACzD;AACO,MAAMC,2BAA2B,GAAAL,OAAA,CAAAK,2BAAA,GAAG,MAAM;AACjD;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,wBAAwB,GAAAN,OAAA,CAAAM,wBAAA,GAAG,EAAE,GAAG,MAAM;AAE5C,MAAMC,sBAAsB,GAAAP,OAAA,CAAAO,sBAAA,GAAG;EAAEC,GAAG,EAAE,KAAK;EAAEC,GAAG,EAAE;AAAO,CAAU;AACnE,MAAMC,4BAA4B,GAAAV,OAAA,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|
|
6
|
+
exports.PaymentError = exports.PaymentConfigError = exports.PAYMENT_ERROR_CODES = void 0;
|
|
7
|
+
exports.redact = redact;
|
|
8
|
+
var _rnCore = require("@chipmobilesdk/rn-core");
|
|
9
|
+
/**
|
|
10
|
+
* Normalized public errors.
|
|
11
|
+
*
|
|
12
|
+
* Error codes are **public API**: renaming one is a breaking change (FR-078,
|
|
13
|
+
* LIB-008). They are the vocabulary an app branches on, so they must outlive any
|
|
14
|
+
* internal refactor and must never leak a store's own code.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const identifiers = (0, _rnCore.createRedactor)();
|
|
18
|
+
const PAYMENT_ERROR_CODES = exports.PAYMENT_ERROR_CODES = ['PAYMENT_NOT_CONFIGURED', 'PAYMENT_INVALID_CATALOG', 'PAYMENT_NOT_READY', 'PAYMENT_DISABLED', 'PAYMENT_UNAVAILABLE', 'PAYMENT_UNSUPPORTED_PLATFORM', 'PAYMENT_ENVIRONMENT_BLOCKED', 'PAYMENT_PRODUCTION_CONFIG_IN_NON_PRODUCTION_BUILD', 'PAYMENT_PURCHASE_IN_PROGRESS', 'PAYMENT_USER_CANCELLED', 'PAYMENT_PENDING', 'PAYMENT_ALREADY_OWNED', 'PAYMENT_INELIGIBLE', 'PAYMENT_UNKNOWN_PRODUCT', 'PAYMENT_PRODUCT_UNAVAILABLE_IN_REGION', 'PAYMENT_TIMEOUT', 'PAYMENT_NETWORK_ERROR', 'PAYMENT_STORE_ERROR', 'PAYMENT_FINALIZE_FAILED', 'PAYMENT_VALIDATION_REJECTED', 'PAYMENT_VALIDATION_UNAVAILABLE', 'PAYMENT_STORAGE_UNAVAILABLE', /** `consume` on a transaction that is not a consumable, added in 0.3.2. */
|
|
19
|
+
'PAYMENT_NOT_CONSUMABLE',
|
|
20
|
+
/**
|
|
21
|
+
* A timeout, backoff or interval outside its bounds, added in 0.5.0. These
|
|
22
|
+
* used to be reported as `PAYMENT_INVALID_CATALOG`, which is about products.
|
|
23
|
+
*/
|
|
24
|
+
'PAYMENT_INVALID_CONFIG'];
|
|
25
|
+
|
|
26
|
+
/** Which operation produced an error. Part of the public error shape (FR-078). */
|
|
27
|
+
|
|
28
|
+
/** The package's error; an `SdkError` (`@chipmobilesdk/rn-core`) with `pkg: 'rn-payment'`. */
|
|
29
|
+
class PaymentError extends _rnCore.SdkError {
|
|
30
|
+
/** Redacted where appropriate — never a raw receipt, token, or store object (FR-074). */
|
|
31
|
+
|
|
32
|
+
constructor(init) {
|
|
33
|
+
super('rn-payment', init.code, {
|
|
34
|
+
message: init.message,
|
|
35
|
+
retryable: init.retryable ?? false,
|
|
36
|
+
redactedCause: init.cause
|
|
37
|
+
});
|
|
38
|
+
this.name = 'PaymentError';
|
|
39
|
+
this.operation = init.operation;
|
|
40
|
+
this.cause = init.cause;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* A configuration problem the app can act on.
|
|
46
|
+
*
|
|
47
|
+
* Separate from `PaymentError` because configuration faults are developer-facing
|
|
48
|
+
* and must never be shown to an end user — the message-key map keeps that
|
|
49
|
+
* separation explicit (FR-085).
|
|
50
|
+
*/
|
|
51
|
+
exports.PaymentError = PaymentError;
|
|
52
|
+
class PaymentConfigError extends PaymentError {
|
|
53
|
+
/** The offending catalog entries or entitlement keys, named (FR-011). */
|
|
54
|
+
|
|
55
|
+
constructor(init) {
|
|
56
|
+
super({
|
|
57
|
+
...init,
|
|
58
|
+
retryable: false
|
|
59
|
+
});
|
|
60
|
+
this.name = 'PaymentConfigError';
|
|
61
|
+
this.offenders = init.offenders ?? [];
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Strips anything that must never reach a log or event.
|
|
67
|
+
*
|
|
68
|
+
* Applied at the boundary rather than trusted to call sites: a single forgotten
|
|
69
|
+
* interpolation is how receipts end up in logs (NFR-006).
|
|
70
|
+
*
|
|
71
|
+
* Identifier-only: what survives is what code defined, never what data carried.
|
|
72
|
+
* A `PaymentError` keeps its code and an `Error` its class name; every message
|
|
73
|
+
* and every string is dropped, because a store or consumer message can embed a
|
|
74
|
+
* purchase token or an account id and nothing here can tell which.
|
|
75
|
+
*/
|
|
76
|
+
exports.PaymentConfigError = PaymentConfigError;
|
|
77
|
+
function redact(value) {
|
|
78
|
+
// An SDK error reduces to its code and any other Error to its class name
|
|
79
|
+
// (rn-core's identifier-only redactor). Strings never survive here, not even
|
|
80
|
+
// a leading constant: a store message is free text from a payments SDK.
|
|
81
|
+
return value instanceof Error ? identifiers.text(value) : _rnCore.REDACTED;
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_rnCore","require","identifiers","createRedactor","PAYMENT_ERROR_CODES","exports","PaymentError","SdkError","constructor","init","code","message","retryable","redactedCause","cause","name","operation","PaymentConfigError","offenders","redact","value","Error","text","REDACTED"],"sourceRoot":"../../../src","sources":["diagnostics/errors.ts"],"mappings":";;;;;;;AAQA,IAAAA,OAAA,GAAAC,OAAA;AARA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,MAAMC,WAAW,GAAG,IAAAC,sBAAc,EAAC,CAAC;AAE7B,MAAMC,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA,GAAG,CAClC,wBAAwB,EACxB,yBAAyB,EACzB,mBAAmB,EACnB,kBAAkB,EAClB,qBAAqB,EACrB,8BAA8B,EAC9B,6BAA6B,EAC7B,mDAAmD,EACnD,8BAA8B,EAC9B,wBAAwB,EACxB,iBAAiB,EACjB,uBAAuB,EACvB,oBAAoB,EACpB,yBAAyB,EACzB,uCAAuC,EACvC,iBAAiB,EACjB,uBAAuB,EACvB,qBAAqB,EACrB,yBAAyB,EACzB,6BAA6B,EAC7B,gCAAgC,EAChC,6BAA6B,EAC7B;AACA,wBAAwB;AACxB;AACD;AACA;AACA;AACC,wBAAwB,CACf;;AAIV;;AAcA;AACO,MAAME,YAAY,SAASC,gBAAQ,CAAmB;EAE5D;;EAGAC,WAAWA,CAACC,IAMX,EAAE;IACF,KAAK,CAAC,YAAY,EAAEA,IAAI,CAACC,IAAI,EAAE;MAC9BC,OAAO,EAAEF,IAAI,CAACE,OAAO;MACrBC,SAAS,EAAEH,IAAI,CAACG,SAAS,IAAI,KAAK;MAClCC,aAAa,EAAEJ,IAAI,CAACK;IACrB,CAAC,CAAC;IACF,IAAI,CAACC,IAAI,GAAG,cAAc;IAC1B,IAAI,CAACC,SAAS,GAAGP,IAAI,CAACO,SAAS;IAC/B,IAAI,CAACF,KAAK,GAAGL,IAAI,CAACK,KAAK;EACxB;AACD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AANAT,OAAA,CAAAC,YAAA,GAAAA,YAAA;AAOO,MAAMW,kBAAkB,SAASX,YAAY,CAAC;EACpD;;EAGAE,WAAWA,CAACC,IAKX,EAAE;IACF,KAAK,CAAC;MAAE,GAAGA,IAAI;MAAEG,SAAS,EAAE;IAAM,CAAC,CAAC;IACpC,IAAI,CAACG,IAAI,GAAG,oBAAoB;IAChC,IAAI,CAACG,SAAS,GAAGT,IAAI,CAACS,SAAS,IAAI,EAAE;EACtC;AACD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAVAb,OAAA,CAAAY,kBAAA,GAAAA,kBAAA;AAWO,SAASE,MAAMA,CAACC,KAAc,EAAU;EAC9C;EACA;EACA;EACA,OAAOA,KAAK,YAAYC,KAAK,GAAGnB,WAAW,CAACoB,IAAI,CAACF,KAAK,CAAC,GAAGG,gBAAQ;AACnE","ignoreList":[]}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.FORBIDDEN_EVENT_FIELDS = void 0;
|
|
7
|
+
exports.createCorrelationId = createCorrelationId;
|
|
8
|
+
exports.createEmitter = createEmitter;
|
|
9
|
+
Object.defineProperty(exports, "redact", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () {
|
|
12
|
+
return _errors.redact;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
var _rnCore = require("@chipmobilesdk/rn-core");
|
|
16
|
+
var _errors = require("./errors.js");
|
|
17
|
+
/**
|
|
18
|
+
* Typed events and the emitter.
|
|
19
|
+
*
|
|
20
|
+
* The bar is FR-077: the event stream **alone** must be enough to reconstruct a
|
|
21
|
+
* transaction's full lifecycle, so that "the user says they paid but has no
|
|
22
|
+
* entitlement" can be investigated from logs without a reproduction.
|
|
23
|
+
*
|
|
24
|
+
* Forbidden in every payload, without exception (FR-076, FR-074): store objects,
|
|
25
|
+
* raw receipts, verification payloads, backend tokens, payment details, the
|
|
26
|
+
* obfuscated account identifier, and the cache-scope token.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/** Every delivered event also goes to the app's SDK sinks (`installSdkSink`, CORE-08). */
|
|
30
|
+
const channel = (0, _rnCore.createDiagnosticChannel)('rn-payment');
|
|
31
|
+
/**
|
|
32
|
+
* A `PaymentEvent` with the timestamp left to the emitter.
|
|
33
|
+
*
|
|
34
|
+
* Distributive on purpose: a plain `Omit<PaymentEvent, 'timestamp'>` collapses the
|
|
35
|
+
* discriminated union into one object type with only the shared keys, which would
|
|
36
|
+
* reject every variant-specific field. `T extends unknown` forces the mapping to
|
|
37
|
+
* apply per member and keeps the union discriminated.
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Creates the emitter.
|
|
42
|
+
*
|
|
43
|
+
* Two properties are deliberate:
|
|
44
|
+
*
|
|
45
|
+
* 1. **A throwing listener cannot break anything** (FR-081). Each listener is
|
|
46
|
+
* invoked defensively, the throw is handed to `onListenerError`, and delivery
|
|
47
|
+
* continues to the remaining listeners. One app's broken analytics callback
|
|
48
|
+
* must not stop the package granting an entitlement or stop another listener
|
|
49
|
+
* hearing about it.
|
|
50
|
+
*
|
|
51
|
+
* The failure is **not** re-emitted as an event, deliberately. A consumer's own
|
|
52
|
+
* bug is not a payment-lifecycle event, and reporting it through the channel
|
|
53
|
+
* that just failed would both invite recursion and double event traffic for
|
|
54
|
+
* every event while that listener stays broken. It goes to the logger instead.
|
|
55
|
+
*
|
|
56
|
+
* 2. **After `dispose`, nothing is emitted** (FR-082). A store callback can
|
|
57
|
+
* arrive after cleanup; it must be dropped silently rather than reach a
|
|
58
|
+
* listener whose component is gone.
|
|
59
|
+
*/
|
|
60
|
+
function createEmitter(onListenerError) {
|
|
61
|
+
// The event whose listeners are running, so a failure is reported against it.
|
|
62
|
+
let dispatching = null;
|
|
63
|
+
let isDisposed = false;
|
|
64
|
+
// rn-core's emitter: a snapshot per emit, each listener isolated, idempotent
|
|
65
|
+
// unsubscribe. Even the error reporter is isolated: if it throws, rn-core
|
|
66
|
+
// rethrows that on a fresh task rather than into the emit.
|
|
67
|
+
const emitter = (0, _rnCore.createEmitter)({
|
|
68
|
+
onListenerError: error => {
|
|
69
|
+
if (!dispatching) return;
|
|
70
|
+
try {
|
|
71
|
+
onListenerError?.(error, dispatching);
|
|
72
|
+
} catch {
|
|
73
|
+
// The app's own reporter failed: nothing in the app is left to tell, so
|
|
74
|
+
// the failure goes to the SDK sinks rather than becoming an uncaught
|
|
75
|
+
// error on some later tick (FR-080).
|
|
76
|
+
channel.emit('listener_reporter_failed', 'error', {
|
|
77
|
+
eventType: dispatching.type
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
return {
|
|
83
|
+
emit(event) {
|
|
84
|
+
if (isDisposed) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const previous = dispatching;
|
|
88
|
+
dispatching = event;
|
|
89
|
+
try {
|
|
90
|
+
if (emitter.emit(event)) {
|
|
91
|
+
// The type and the cycle only: payment events carry product and
|
|
92
|
+
// entitlement keys an app may treat as personal.
|
|
93
|
+
channel.emit(event.type, /failed|error|blocked|rejected|revoked/.test(event.type) ? 'warn' : 'info', undefined, event.correlationId);
|
|
94
|
+
}
|
|
95
|
+
} finally {
|
|
96
|
+
dispatching = previous;
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
subscribe(listener) {
|
|
100
|
+
return isDisposed ? () => undefined : emitter.subscribe(listener);
|
|
101
|
+
},
|
|
102
|
+
dispose() {
|
|
103
|
+
isDisposed = true;
|
|
104
|
+
emitter.dispose();
|
|
105
|
+
},
|
|
106
|
+
listenerCount: () => emitter.listenerCount(),
|
|
107
|
+
disposed: () => isDisposed
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Fields that must never appear in an event payload.
|
|
113
|
+
*
|
|
114
|
+
* Used by `__tests__/diagnostics.test.ts` to walk every emitted event across the
|
|
115
|
+
* whole suite. Enumerating the ban here rather than in the test keeps the rule
|
|
116
|
+
* next to the type it constrains.
|
|
117
|
+
*/
|
|
118
|
+
const FORBIDDEN_EVENT_FIELDS = exports.FORBIDDEN_EVENT_FIELDS = ['verificationPayload', 'receipt', 'purchaseToken', 'transactionReceipt', 'obfuscatedAccountId', 'scopeToken', 'token', 'signature'];
|
|
119
|
+
|
|
120
|
+
/** Correlation ids tie one purchase cycle together; no user data goes into them. */
|
|
121
|
+
function createCorrelationId(counter, prefix = 'pc') {
|
|
122
|
+
const id = `${prefix}_${counter.next.toString(36)}`;
|
|
123
|
+
counter.next += 1;
|
|
124
|
+
return id;
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_rnCore","require","_errors","channel","createDiagnosticChannel","createEmitter","onListenerError","dispatching","isDisposed","emitter","createCoreEmitter","error","emit","eventType","type","event","previous","test","undefined","correlationId","subscribe","listener","dispose","listenerCount","disposed","FORBIDDEN_EVENT_FIELDS","exports","createCorrelationId","counter","prefix","id","next","toString"],"sourceRoot":"../../../src","sources":["diagnostics/events.ts"],"mappings":";;;;;;;;;;;;;;AAYA,IAAAA,OAAA,GAAAC,OAAA;AAUA,IAAAC,OAAA,GAAAD,OAAA;AAtBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA;AACA,MAAME,OAAO,GAAG,IAAAC,+BAAuB,EACtC,YACD,CAAC;AAsID;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAgBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,aAAaA,CAC5BC,eAA+D,EAC9C;EACjB;EACA,IAAIC,WAAgC,GAAG,IAAI;EAC3C,IAAIC,UAAU,GAAG,KAAK;EACtB;EACA;EACA;EACA,MAAMC,OAAO,GAAG,IAAAC,qBAAiB,EAAe;IAC/CJ,eAAe,EAAEK,KAAK,IAAI;MACzB,IAAI,CAACJ,WAAW,EAAE;MAClB,IAAI;QACHD,eAAe,GAAGK,KAAK,EAAEJ,WAAW,CAAC;MACtC,CAAC,CAAC,MAAM;QACP;QACA;QACA;QACAJ,OAAO,CAACS,IAAI,CAAC,0BAA0B,EAAE,OAAO,EAAE;UACjDC,SAAS,EAAEN,WAAW,CAACO;QACxB,CAAC,CAAC;MACH;IACD;EACD,CAAC,CAAC;EAEF,OAAO;IACNF,IAAIA,CAACG,KAAK,EAAE;MACX,IAAIP,UAAU,EAAE;QACf;MACD;MACA,MAAMQ,QAAQ,GAAGT,WAAW;MAC5BA,WAAW,GAAGQ,KAAK;MACnB,IAAI;QACH,IAAIN,OAAO,CAACG,IAAI,CAACG,KAAK,CAAC,EAAE;UACxB;UACA;UACAZ,OAAO,CAACS,IAAI,CACXG,KAAK,CAACD,IAAI,EACV,uCAAuC,CAACG,IAAI,CAACF,KAAK,CAACD,IAAI,CAAC,GAAG,MAAM,GAAG,MAAM,EAC1EI,SAAS,EACTH,KAAK,CAACI,aACP,CAAC;QACF;MACD,CAAC,SAAS;QACTZ,WAAW,GAAGS,QAAQ;MACvB;IACD,CAAC;IACDI,SAASA,CAACC,QAA8B,EAAe;MACtD,OAAOb,UAAU,GAAG,MAAMU,SAAS,GAAGT,OAAO,CAACW,SAAS,CAACC,QAAQ,CAAC;IAClE,CAAC;IACDC,OAAOA,CAAA,EAAS;MACfd,UAAU,GAAG,IAAI;MACjBC,OAAO,CAACa,OAAO,CAAC,CAAC;IAClB,CAAC;IACDC,aAAa,EAAEA,CAAA,KAAMd,OAAO,CAACc,aAAa,CAAC,CAAC;IAC5CC,QAAQ,EAAEA,CAAA,KAAMhB;EACjB,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMiB,sBAAyC,GAAAC,OAAA,CAAAD,sBAAA,GAAG,CACxD,qBAAqB,EACrB,SAAS,EACT,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,YAAY,EACZ,OAAO,EACP,WAAW,CACX;;AAED;AACO,SAASE,mBAAmBA,CAACC,OAAyB,EAAEC,MAAM,GAAG,IAAI,EAAU;EACrF,MAAMC,EAAE,GAAG,GAAGD,MAAM,IAAID,OAAO,CAACG,IAAI,CAACC,QAAQ,CAAC,EAAE,CAAC,EAAE;EACnDJ,OAAO,CAACG,IAAI,IAAI,CAAC;EACjB,OAAOD,EAAE;AACV","ignoreList":[]}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.USER_MESSAGE_KEYS = exports.DEVELOPER_MESSAGE_KEYS = exports.DEFAULT_USER_MESSAGES = exports.DEFAULT_MESSAGES = exports.DEFAULT_DEVELOPER_MESSAGES = void 0;
|
|
7
|
+
exports.isUserMessageKey = isUserMessageKey;
|
|
8
|
+
exports.paymentMessages = void 0;
|
|
9
|
+
var _rnCore = require("@chipmobilesdk/rn-core");
|
|
10
|
+
/**
|
|
11
|
+
* Stable, localizable message keys with English default copy (FR-084, FR-085).
|
|
12
|
+
*
|
|
13
|
+
* The package takes no i18n runtime dependency: consuming apps map these keys to
|
|
14
|
+
* localized strings through whatever i18n system they already run. This is plain
|
|
15
|
+
* data, and the package never resolves or renders it.
|
|
16
|
+
*
|
|
17
|
+
* Message keys are **public API**: renaming one is a breaking change, on the
|
|
18
|
+
* same footing as an error code (FR-078).
|
|
19
|
+
*
|
|
20
|
+
* User-actionable copy and developer/configuration copy are kept in separate
|
|
21
|
+
* maps so an app cannot accidentally show "Payment catalog is invalid" to a
|
|
22
|
+
* customer — a configuration fault is a developer's problem, not a user's.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/** Copy an end user may reasonably be shown. */
|
|
26
|
+
|
|
27
|
+
/** Copy for developers and operators. **Never** surfaced to an end user. */
|
|
28
|
+
|
|
29
|
+
const DEFAULT_USER_MESSAGES = exports.DEFAULT_USER_MESSAGES = {
|
|
30
|
+
'payment.state.pending': 'Waiting for your payment to complete',
|
|
31
|
+
'payment.state.alreadyOwned': 'You already own this',
|
|
32
|
+
'payment.action.restore': 'Restore purchases',
|
|
33
|
+
'payment.restore.succeeded': 'Your purchases have been restored',
|
|
34
|
+
'payment.restore.nothingFound': 'No previous purchases found',
|
|
35
|
+
'payment.error.cancelled': 'Purchase cancelled',
|
|
36
|
+
'payment.error.network': "Couldn't reach the store. Check your connection and try again.",
|
|
37
|
+
'payment.error.unavailable': "Purchases aren't available on this device",
|
|
38
|
+
'payment.error.disabled': 'Purchases are currently unavailable',
|
|
39
|
+
'payment.subscription.grace': "There's a problem with your payment method",
|
|
40
|
+
'payment.subscription.hold': 'Your subscription is paused until payment is updated'
|
|
41
|
+
};
|
|
42
|
+
const DEFAULT_DEVELOPER_MESSAGES = exports.DEFAULT_DEVELOPER_MESSAGES = {
|
|
43
|
+
'payment.config.invalidCatalog': 'Payment catalog is invalid',
|
|
44
|
+
'payment.config.missingStoreId': 'Product is missing a store identifier for this platform',
|
|
45
|
+
'payment.config.productionInNonProductionBuild': 'Production payment configuration in a non-production build',
|
|
46
|
+
'payment.config.storageUnavailable': 'Local storage unavailable; entitlements will not survive restart',
|
|
47
|
+
'payment.config.environmentBlocked': 'Purchase blocked: this environment may not create a real transaction'
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The catalog as an rn-core message set. Register `paymentMessages.user` with
|
|
52
|
+
* rn-i18n to translate it like app copy; the developer copy stays out of bundles.
|
|
53
|
+
*/
|
|
54
|
+
const paymentMessages = exports.paymentMessages = (0, _rnCore.defineMessages)({
|
|
55
|
+
user: DEFAULT_USER_MESSAGES,
|
|
56
|
+
developer: DEFAULT_DEVELOPER_MESSAGES
|
|
57
|
+
});
|
|
58
|
+
const DEFAULT_MESSAGES = exports.DEFAULT_MESSAGES = paymentMessages.defaults;
|
|
59
|
+
|
|
60
|
+
/** Every user-actionable key, for an app building its translation resource. */
|
|
61
|
+
const USER_MESSAGE_KEYS = exports.USER_MESSAGE_KEYS = paymentMessages.userKeys;
|
|
62
|
+
|
|
63
|
+
/** Every developer-facing key, so an app can exclude them from user-visible bundles. */
|
|
64
|
+
const DEVELOPER_MESSAGE_KEYS = exports.DEVELOPER_MESSAGE_KEYS = paymentMessages.developerKeys;
|
|
65
|
+
|
|
66
|
+
/** True for keys safe to show an end user. Lets an app assert that at its boundary. */
|
|
67
|
+
function isUserMessageKey(key) {
|
|
68
|
+
return paymentMessages.audienceOf(key) === 'user';
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=messageKeys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_rnCore","require","DEFAULT_USER_MESSAGES","exports","DEFAULT_DEVELOPER_MESSAGES","paymentMessages","defineMessages","user","developer","DEFAULT_MESSAGES","defaults","USER_MESSAGE_KEYS","userKeys","DEVELOPER_MESSAGE_KEYS","developerKeys","isUserMessageKey","key","audienceOf"],"sourceRoot":"../../../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