@chipmobilesdk/rn-payment 0.5.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 +172 -0
- package/README.md +47 -16
- 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
- package/skills/sdk-rn-payment/SKILL.md +4 -4
- package/src/adapter/iap-adapter.ts +12 -216
- package/src/adapter/iapShapes.ts +232 -0
- package/src/config/types.ts +8 -0
- package/src/config/validate.ts +19 -4
- package/src/core/retry.ts +1 -58
- package/src/diagnostics/events.ts +1 -1
- package/src/engine/connection.ts +194 -0
- package/src/engine/engine.ts +140 -700
- package/src/engine/internals.ts +40 -0
- package/src/engine/products.ts +39 -17
- package/src/engine/purchase.ts +22 -130
- package/src/engine/purchaseFailure.ts +48 -0
- package/src/engine/receiptValidation.ts +101 -0
- package/src/engine/state.ts +253 -0
- package/src/engine/sync.ts +161 -0
- package/src/entitlements/aggregate.ts +3 -5
- package/src/entitlements/mapping.ts +0 -22
- package/src/persistence/mmkv-store.ts +10 -3
- package/src/persistence/snapshot.ts +102 -27
- package/src/react/PaymentProvider.tsx +73 -24
- package/src/react/hooks.ts +13 -3
|
@@ -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;A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ACC,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":"../../../src","sources":["diagnostics/messageKeys.ts"],"mappings":";;;;;;;;AAgBA,IAAAA,OAAA,GAAAC,OAAA;AAhBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAiBA;;AAeO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
|
|
5
|
+
});
|
|
6
|
+
exports.createConnection = createConnection;
|
|
7
|
+
var _retry = require("../core/retry.js");
|
|
8
|
+
var _mutex = require("../core/mutex.js");
|
|
9
|
+
var _errors = require("../diagnostics/errors.js");
|
|
10
|
+
/**
|
|
11
|
+
* The billing connection: connecting, watching it, and reconnecting with bounded
|
|
12
|
+
* backoff (FR-018 – FR-024, PAY-10).
|
|
13
|
+
*
|
|
14
|
+
* A reconnect is always a full teardown-then-connect cycle. The upstream
|
|
15
|
+
* binding's own `reconnect()` has reported success without rebuilding anything
|
|
16
|
+
* (openiap#408), so no shortcut is trusted here.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
function createConnection(state, onPurchase) {
|
|
20
|
+
const {
|
|
21
|
+
provider,
|
|
22
|
+
resolved
|
|
23
|
+
} = state;
|
|
24
|
+
let connectionSub;
|
|
25
|
+
let purchaseSub;
|
|
26
|
+
let reconnectTimer;
|
|
27
|
+
let reconnectAttempts = 0;
|
|
28
|
+
/**
|
|
29
|
+
* Set once a connection succeeded. Recovery after an exhausted budget is only
|
|
30
|
+
* meaningful from there; a first connection that failed is the app's to retry
|
|
31
|
+
* through `initialize`.
|
|
32
|
+
*/
|
|
33
|
+
let everConnected = false;
|
|
34
|
+
function scheduleReconnect() {
|
|
35
|
+
if (state.disposed) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (reconnectAttempts >= resolved.retry.reconnect.maxAttempts) {
|
|
39
|
+
// Out of budget for now, not for good: a retryable failure rather than a
|
|
40
|
+
// `connecting` that promised a reconnect nobody was going to make.
|
|
41
|
+
state.setStatus({
|
|
42
|
+
kind: 'failed',
|
|
43
|
+
retryable: true,
|
|
44
|
+
reconnectAttempts
|
|
45
|
+
});
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const attempt = reconnectAttempts + 1;
|
|
49
|
+
reconnectTimer = setTimeout(() => {
|
|
50
|
+
reconnectTimer = undefined;
|
|
51
|
+
if (state.disposed) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
reconnectAttempts = attempt;
|
|
55
|
+
state.setStatus({
|
|
56
|
+
kind: 'connecting',
|
|
57
|
+
reconnectAttempts
|
|
58
|
+
});
|
|
59
|
+
reconnectOnce().catch(() => undefined);
|
|
60
|
+
}, (0, _retry.backoffDelayMs)(attempt, resolved.retry.reconnect));
|
|
61
|
+
}
|
|
62
|
+
async function reconnectOnce() {
|
|
63
|
+
try {
|
|
64
|
+
await provider.disconnect();
|
|
65
|
+
} catch {
|
|
66
|
+
// Already down; nothing to tear down.
|
|
67
|
+
}
|
|
68
|
+
const outcome = await provider.connect();
|
|
69
|
+
if (state.disposed) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (outcome.ok) {
|
|
73
|
+
reconnectAttempts = 0;
|
|
74
|
+
state.setStatus({
|
|
75
|
+
kind: 'ready',
|
|
76
|
+
reconnectAttempts: 0
|
|
77
|
+
});
|
|
78
|
+
} else {
|
|
79
|
+
scheduleReconnect();
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Replaced, never stacked: a second subscription would hear everything twice. */
|
|
84
|
+
function watch() {
|
|
85
|
+
connectionSub?.();
|
|
86
|
+
connectionSub = provider.observeConnection((connected, reason) => {
|
|
87
|
+
if (state.disposed) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
state.emit({
|
|
91
|
+
type: 'connection_changed',
|
|
92
|
+
connected,
|
|
93
|
+
reason,
|
|
94
|
+
attempt: reconnectAttempts
|
|
95
|
+
});
|
|
96
|
+
if (!connected && state.status.kind === 'ready') {
|
|
97
|
+
state.setStatus({
|
|
98
|
+
kind: 'connecting'
|
|
99
|
+
});
|
|
100
|
+
scheduleReconnect();
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
// Session-long: a pending purchase settling between sessions arrives here
|
|
104
|
+
// (FR-039), not only while a purchase is open.
|
|
105
|
+
purchaseSub?.();
|
|
106
|
+
purchaseSub = provider.observePurchases(purchase => {
|
|
107
|
+
if (!state.disposed) {
|
|
108
|
+
onPurchase(purchase);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
async connect() {
|
|
114
|
+
const outcome = await (0, _mutex.withTimeout)(provider.connect(), resolved.timeouts.connectMs, () => new _errors.PaymentError({
|
|
115
|
+
code: 'PAYMENT_TIMEOUT',
|
|
116
|
+
message: 'Connecting to the billing service timed out',
|
|
117
|
+
operation: 'initialize',
|
|
118
|
+
retryable: true
|
|
119
|
+
})).catch(error => ({
|
|
120
|
+
ok: false,
|
|
121
|
+
reason: 'store_error',
|
|
122
|
+
retryable: error.retryable
|
|
123
|
+
}));
|
|
124
|
+
if (!outcome.ok) {
|
|
125
|
+
if (outcome.reason === 'store_error') {
|
|
126
|
+
state.setStatus({
|
|
127
|
+
kind: 'failed',
|
|
128
|
+
retryable: outcome.retryable
|
|
129
|
+
});
|
|
130
|
+
return {
|
|
131
|
+
ok: false,
|
|
132
|
+
error: new _errors.PaymentError({
|
|
133
|
+
code: 'PAYMENT_STORE_ERROR',
|
|
134
|
+
message: 'Could not connect to the billing service',
|
|
135
|
+
operation: 'initialize',
|
|
136
|
+
retryable: outcome.retryable
|
|
137
|
+
})
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
// No billing service, an outdated one, or an unsupported platform: each
|
|
141
|
+
// distinguishable, and none of them may break the host app (FR-021, FR-023).
|
|
142
|
+
state.setStatus({
|
|
143
|
+
kind: 'unavailable',
|
|
144
|
+
unavailableReason: outcome.reason,
|
|
145
|
+
retryable: outcome.retryable
|
|
146
|
+
});
|
|
147
|
+
return {
|
|
148
|
+
ok: false,
|
|
149
|
+
error: new _errors.PaymentError({
|
|
150
|
+
code: outcome.reason === 'platform_unsupported' ? 'PAYMENT_UNSUPPORTED_PLATFORM' : 'PAYMENT_UNAVAILABLE',
|
|
151
|
+
message: `Billing unavailable: ${outcome.reason}`,
|
|
152
|
+
operation: 'initialize',
|
|
153
|
+
retryable: outcome.retryable
|
|
154
|
+
})
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
watch();
|
|
158
|
+
everConnected = true;
|
|
159
|
+
state.setStatus({
|
|
160
|
+
kind: 'ready',
|
|
161
|
+
reconnectAttempts: 0
|
|
162
|
+
});
|
|
163
|
+
return {
|
|
164
|
+
ok: true
|
|
165
|
+
};
|
|
166
|
+
},
|
|
167
|
+
async recover() {
|
|
168
|
+
if (everConnected && !state.disposed && state.status.kind === 'failed' && reconnectTimer === undefined) {
|
|
169
|
+
reconnectAttempts = 0;
|
|
170
|
+
state.setStatus({
|
|
171
|
+
kind: 'connecting',
|
|
172
|
+
reconnectAttempts: 0
|
|
173
|
+
});
|
|
174
|
+
await reconnectOnce().catch(() => undefined);
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
dispose() {
|
|
178
|
+
connectionSub?.();
|
|
179
|
+
connectionSub = undefined;
|
|
180
|
+
purchaseSub?.();
|
|
181
|
+
purchaseSub = undefined;
|
|
182
|
+
if (reconnectTimer !== undefined) {
|
|
183
|
+
clearTimeout(reconnectTimer);
|
|
184
|
+
reconnectTimer = undefined;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
//# sourceMappingURL=connection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_retry","require","_mutex","_errors","createConnection","state","onPurchase","provider","resolved","connectionSub","purchaseSub","reconnectTimer","reconnectAttempts","everConnected","scheduleReconnect","disposed","retry","reconnect","maxAttempts","setStatus","kind","retryable","attempt","setTimeout","undefined","reconnectOnce","catch","backoffDelayMs","disconnect","outcome","connect","ok","watch","observeConnection","connected","reason","emit","type","status","observePurchases","purchase","withTimeout","timeouts","connectMs","PaymentError","code","message","operation","error","unavailableReason","recover","dispose","clearTimeout"],"sourceRoot":"../../../src","sources":["engine/connection.ts"],"mappings":";;;;;;AAUA,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