@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,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Android adapter over `react-native-iap` (Play Billing).
|
|
3
|
+
*
|
|
4
|
+
* **The only file in this package that touches the billing library.** Everything
|
|
5
|
+
* above it talks to `ProviderPort`, which is what keeps the binding replaceable
|
|
6
|
+
* and lets an iOS adapter be added without changing a consumer call (FR-002,
|
|
7
|
+
* FR-007). ESLint enforces that boundary.
|
|
8
|
+
*
|
|
9
|
+
* ## Verified against react-native-iap 16.7.3
|
|
10
|
+
*
|
|
11
|
+
* 0.3.0 was written before the binding was installed, from its documentation, and
|
|
12
|
+
* no purchase could complete on a device. Checked against the installed 16.7.3
|
|
13
|
+
* source for 0.3.1, two facts shape the purchase path:
|
|
14
|
+
*
|
|
15
|
+
* - The request is keyed by store: `google` / `apple`. 0.3.0 sent `android`, which
|
|
16
|
+
* the binding rejects (`empty-sku-list`) before Play opens. The request type is
|
|
17
|
+
* now the binding's own `RequestPurchaseProps`, so a renamed key fails to
|
|
18
|
+
* typecheck here instead of failing on a user's device.
|
|
19
|
+
* - On Android `requestPurchase` resolves with an **empty list** once the flow
|
|
20
|
+
* ends, whatever happened. The outcome (bought, pending, cancelled, failed)
|
|
21
|
+
* arrives only through `purchaseUpdatedListener` / `purchaseErrorListener`, so
|
|
22
|
+
* `launchPurchase` waits for those events.
|
|
23
|
+
*
|
|
24
|
+
* The module is still required lazily, and `IapModule` still names exactly the
|
|
25
|
+
* surface used. `__tests__/iap-adapter.test.ts` drives this file through a fake
|
|
26
|
+
* binding that behaves as 16.7.3 does; the rest of the suite uses the fake store.
|
|
27
|
+
*
|
|
28
|
+
* ## Known upstream defect this guards against
|
|
29
|
+
*
|
|
30
|
+
* openiap#408: the Android bridge did not clear its internal `isInitialized` flag
|
|
31
|
+
* on disconnect, so `connected` stayed true, later calls failed with
|
|
32
|
+
* `E_NOT_PREPARED`, and `reconnect()` reported success without rebuilding
|
|
33
|
+
* anything. This adapter therefore (a) tracks connection state itself rather than
|
|
34
|
+
* trusting the binding's flag, and (b) always performs a full
|
|
35
|
+
* `endConnection` + `initConnection` cycle instead of calling any reconnect
|
|
36
|
+
* shortcut.
|
|
37
|
+
*/
|
|
38
|
+
import type { RequestPurchaseProps } from 'react-native-iap';
|
|
39
|
+
import { type RawProduct, type RawPurchase, type RawPurchaseError } from './iapShapes.js';
|
|
40
|
+
import type { ProviderPort, ProviderPurchaseRequest } from './port.js';
|
|
41
|
+
export { toProviderPurchaseState } from './iapShapes.js';
|
|
42
|
+
/**
|
|
43
|
+
* Exactly what this adapter needs from the binding.
|
|
44
|
+
*
|
|
45
|
+
* Declared narrowly on purpose: it documents the coupling, and it means a binding
|
|
46
|
+
* upgrade that changes one of these shapes fails to typecheck here instead of
|
|
47
|
+
* failing silently at runtime on a user's device.
|
|
48
|
+
*/
|
|
49
|
+
interface IapModule {
|
|
50
|
+
initConnection(): Promise<boolean>;
|
|
51
|
+
endConnection(): Promise<void>;
|
|
52
|
+
fetchProducts(params: {
|
|
53
|
+
skus: string[];
|
|
54
|
+
type: 'in-app' | 'subs';
|
|
55
|
+
}): Promise<RawProduct[]>;
|
|
56
|
+
getAvailablePurchases(): Promise<RawPurchase[]>;
|
|
57
|
+
/** Typed by the binding itself, so a renamed request key fails to compile. */
|
|
58
|
+
requestPurchase(params: RequestPurchaseProps): Promise<unknown>;
|
|
59
|
+
finishTransaction(params: {
|
|
60
|
+
purchase: unknown;
|
|
61
|
+
isConsumable?: boolean;
|
|
62
|
+
}): Promise<unknown>;
|
|
63
|
+
purchaseUpdatedListener(listener: (purchase: RawPurchase) => void): {
|
|
64
|
+
remove(): void;
|
|
65
|
+
};
|
|
66
|
+
purchaseErrorListener(listener: (error: RawPurchaseError) => void): {
|
|
67
|
+
remove(): void;
|
|
68
|
+
};
|
|
69
|
+
deepLinkToSubscriptions?(params: {
|
|
70
|
+
skuAndroid?: string;
|
|
71
|
+
}): Promise<void>;
|
|
72
|
+
}
|
|
73
|
+
/** The request in the binding's 16.7 shape: keyed `google`, not `android`. */
|
|
74
|
+
export declare function toRequestProps(request: ProviderPurchaseRequest): RequestPurchaseProps;
|
|
75
|
+
export interface IapAdapterOptions {
|
|
76
|
+
/** Injected in tests that need to drive the mapping without the native module. */
|
|
77
|
+
module?: IapModule;
|
|
78
|
+
}
|
|
79
|
+
export declare function createIapAdapter(options?: IapAdapterOptions): ProviderPort;
|
|
80
|
+
//# sourceMappingURL=iap-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iap-adapter.d.ts","sourceRoot":"","sources":["../../../../src/adapter/iap-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAIH,OAAO,KAAK,EAAE,oBAAoB,EAAsC,MAAM,kBAAkB,CAAC;AAGjG,OAAO,EAIN,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,MAAM,gBAAa,CAAC;AAErB,OAAO,KAAK,EAGX,YAAY,EAKZ,uBAAuB,EAGvB,MAAM,WAAQ,CAAC;AAIhB,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAa,CAAC;AAEtD;;;;;;GAMG;AACH,UAAU,SAAS;IAClB,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IACnC,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,aAAa,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;IAC1F,qBAAqB,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IAChD,8EAA8E;IAC9E,eAAe,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAChE,iBAAiB,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,OAAO,CAAC;QAAC,YAAY,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3F,uBAAuB,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,WAAW,KAAK,IAAI,GAAG;QAAE,MAAM,IAAI,IAAI,CAAA;KAAE,CAAC;IACvF,qBAAqB,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,GAAG;QACnE,MAAM,IAAI,IAAI,CAAC;KACf,CAAC;IACF,uBAAuB,CAAC,CAAC,MAAM,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACzE;AAiBD,8EAA8E;AAC9E,wBAAgB,cAAc,CAAC,OAAO,EAAE,uBAAuB,GAAG,oBAAoB,CAoCrF;AA4CD,MAAM,WAAW,iBAAiB;IACjC,kFAAkF;IAClF,MAAM,CAAC,EAAE,SAAS,CAAC;CACnB;AAED,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,iBAAsB,GAAG,YAAY,CAsO9E"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The binding's shapes, and their translation into the port's vocabulary
|
|
3
|
+
* (PAY-12).
|
|
4
|
+
*
|
|
5
|
+
* The binding speaks Google Play: prices as micros in strings, offer tokens,
|
|
6
|
+
* numeric purchase states, store error codes. The port speaks this package's
|
|
7
|
+
* own. Keeping the translation here, with no I/O, no listeners and no module
|
|
8
|
+
* loading, is what makes it checkable against recorded payloads — and leaves
|
|
9
|
+
* the adapter next door about the calls it actually makes.
|
|
10
|
+
*
|
|
11
|
+
* The raw types are declared narrowly on purpose: they document the coupling,
|
|
12
|
+
* and a binding upgrade that changes one of these shapes fails to typecheck
|
|
13
|
+
* here rather than failing silently on a user's device.
|
|
14
|
+
*/
|
|
15
|
+
import type { ProductType } from '../config/types.js';
|
|
16
|
+
import type { ProviderFailureReason, ProviderProduct, ProviderPurchase } from './port.js';
|
|
17
|
+
export interface RawProduct {
|
|
18
|
+
id?: string;
|
|
19
|
+
productId?: string;
|
|
20
|
+
title?: string;
|
|
21
|
+
name?: string;
|
|
22
|
+
description?: string;
|
|
23
|
+
displayPrice?: string;
|
|
24
|
+
localizedPrice?: string;
|
|
25
|
+
currency?: string;
|
|
26
|
+
currencyCode?: string;
|
|
27
|
+
price?: string | number;
|
|
28
|
+
oneTimePurchaseOfferDetails?: {
|
|
29
|
+
formattedPrice?: string;
|
|
30
|
+
priceAmountMicros?: string | number;
|
|
31
|
+
priceCurrencyCode?: string;
|
|
32
|
+
};
|
|
33
|
+
subscriptionOfferDetails?: RawSubscriptionOffer[];
|
|
34
|
+
}
|
|
35
|
+
export interface RawSubscriptionOffer {
|
|
36
|
+
offerToken?: string;
|
|
37
|
+
offerId?: string;
|
|
38
|
+
basePlanId?: string;
|
|
39
|
+
pricingPhases?: {
|
|
40
|
+
pricingPhaseList?: Array<{
|
|
41
|
+
formattedPrice?: string;
|
|
42
|
+
priceAmountMicros?: string | number;
|
|
43
|
+
priceCurrencyCode?: string;
|
|
44
|
+
billingPeriod?: string;
|
|
45
|
+
recurrenceMode?: number;
|
|
46
|
+
billingCycleCount?: number;
|
|
47
|
+
}>;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export interface RawPurchase {
|
|
51
|
+
id?: string;
|
|
52
|
+
transactionId?: string;
|
|
53
|
+
productId?: string;
|
|
54
|
+
ids?: string[];
|
|
55
|
+
purchaseToken?: string;
|
|
56
|
+
purchaseStateAndroid?: number | null;
|
|
57
|
+
/** A string in the 16.x binding: `'pending' | 'purchased' | 'unknown'`. */
|
|
58
|
+
purchaseState?: number | string;
|
|
59
|
+
transactionDate?: number;
|
|
60
|
+
isAcknowledgedAndroid?: boolean;
|
|
61
|
+
isAcknowledged?: boolean;
|
|
62
|
+
autoRenewingAndroid?: boolean;
|
|
63
|
+
isAutoRenewing?: boolean;
|
|
64
|
+
expirationDateAndroid?: number;
|
|
65
|
+
transactionReceipt?: string;
|
|
66
|
+
dataAndroid?: string;
|
|
67
|
+
}
|
|
68
|
+
/** What `purchaseErrorListener` delivers. */
|
|
69
|
+
export interface RawPurchaseError {
|
|
70
|
+
code?: string;
|
|
71
|
+
message?: string;
|
|
72
|
+
productId?: string | null;
|
|
73
|
+
}
|
|
74
|
+
export declare function toMicros(value: string | number | undefined): number;
|
|
75
|
+
export declare function normalizeProduct(raw: RawProduct, productType: ProductType): ProviderProduct;
|
|
76
|
+
export declare function normalizeOffer(offer: RawSubscriptionOffer, fallbackCurrency: string): ProviderProduct['offers'][number];
|
|
77
|
+
/**
|
|
78
|
+
* Reads the purchase state from whichever field the binding filled.
|
|
79
|
+
*
|
|
80
|
+
* Pending is preserved, never flattened to purchased: that distinction is what
|
|
81
|
+
* stops an entitlement being granted for money that has not arrived (FR-037).
|
|
82
|
+
* And an unrecognized or missing state is `unspecified`, never `purchased`.
|
|
83
|
+
*
|
|
84
|
+
* 0.1.0 read only Play's numeric state and treated anything else as purchased.
|
|
85
|
+
* The 16.x binding hands JavaScript the *string* state and does not carry the
|
|
86
|
+
* numeric one across, so on a device every pending purchase arrived as a string,
|
|
87
|
+
* fell through to the default, and was granted. Unit tests could not see it: they
|
|
88
|
+
* drive the fake store, which never passes through here.
|
|
89
|
+
*/
|
|
90
|
+
export declare function toProviderPurchaseState(raw: Pick<RawPurchase, 'purchaseStateAndroid' | 'purchaseState'>): ProviderPurchase['state'];
|
|
91
|
+
export declare function normalizePurchase(raw: RawPurchase): ProviderPurchase;
|
|
92
|
+
/** Maps a binding error code onto the port's vocabulary, so no store code escapes. */
|
|
93
|
+
export declare function mapErrorCode(code: string | undefined): ProviderFailureReason;
|
|
94
|
+
//# sourceMappingURL=iapShapes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iapShapes.d.ts","sourceRoot":"","sources":["../../../../src/adapter/iapShapes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAiB,CAAC;AACnD,OAAO,KAAK,EAAE,qBAAqB,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,WAAQ,CAAC;AAEvF,MAAM,WAAW,UAAU;IAC1B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,2BAA2B,CAAC,EAAE;QAC7B,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,iBAAiB,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QACpC,iBAAiB,CAAC,EAAE,MAAM,CAAC;KAC3B,CAAC;IACF,wBAAwB,CAAC,EAAE,oBAAoB,EAAE,CAAC;CAClD;AAED,MAAM,WAAW,oBAAoB;IACpC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE;QACf,gBAAgB,CAAC,EAAE,KAAK,CAAC;YACx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Ae,CAgB3F;AAED,wBAAgB,cAAc,CAC7B,KAAK,EAAE,oBAAoB,EAC3B,gBAAgB,EAAE,MAAM,GACtB,eAAe,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CA4BnC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,CACtC,GAAG,EAAE,IAAI,CAAC,WAAW,EAAE,sBAAsB,GAAG,eAAe,CAAC,GAC9D,gBAAgB,CAAC,OAAO,CAAC,CAwB3B;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,WAAW,GAAG,gBAAgB,CAcpE;AAED,sFAAsF;AACtF,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,qBAAqB,CA0B5E"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The provider port — **private**, never exported from `src/index.ts`.
|
|
3
|
+
*
|
|
4
|
+
* This is the boundary between the platform-neutral engine and a store-specific
|
|
5
|
+
* adapter. It exists to make three things true:
|
|
6
|
+
*
|
|
7
|
+
* 1. No store type reaches the public surface, because only the adapter ever
|
|
8
|
+
* sees one (FR-002).
|
|
9
|
+
* 2. An iOS adapter can be added by implementing this interface, changing no
|
|
10
|
+
* consumer call (FR-007).
|
|
11
|
+
* 3. The fake store is a drop-in replacement, so every outcome and ordering is
|
|
12
|
+
* testable with no device, network, or store account (NFR-007).
|
|
13
|
+
*
|
|
14
|
+
* `Provider*` types are the port's **own** normalized shapes, not the binding's.
|
|
15
|
+
* The adapter translates; nothing above it sees a `react-native-iap` value.
|
|
16
|
+
*/
|
|
17
|
+
import type { ProductType, Unsubscribe } from '../config/types.js';
|
|
18
|
+
/** A store's own product identifier. Confined to configuration and this layer. */
|
|
19
|
+
export type StoreProductId = string;
|
|
20
|
+
/** Opaque handle the store uses to identify a transaction for finalization. */
|
|
21
|
+
export type ProviderToken = string;
|
|
22
|
+
export type ProviderPurchaseState = 'purchased' | 'pending' | 'unspecified';
|
|
23
|
+
export interface ProviderOffer {
|
|
24
|
+
offerKey: string;
|
|
25
|
+
billingPeriod: string;
|
|
26
|
+
formattedPrice: string;
|
|
27
|
+
priceAmountMicros: number;
|
|
28
|
+
currencyCode: string;
|
|
29
|
+
trialPeriod?: string;
|
|
30
|
+
introductoryPrice?: {
|
|
31
|
+
formattedPrice: string;
|
|
32
|
+
period: string;
|
|
33
|
+
cycles: number;
|
|
34
|
+
};
|
|
35
|
+
/** As the **store** determined it. Never computed locally (FR-026). */
|
|
36
|
+
isEligible: boolean;
|
|
37
|
+
}
|
|
38
|
+
export interface ProviderProduct {
|
|
39
|
+
storeProductId: StoreProductId;
|
|
40
|
+
productType: ProductType;
|
|
41
|
+
title: string;
|
|
42
|
+
description: string;
|
|
43
|
+
formattedPrice: string;
|
|
44
|
+
currencyCode: string;
|
|
45
|
+
priceAmountMicros: number;
|
|
46
|
+
offers: ProviderOffer[];
|
|
47
|
+
}
|
|
48
|
+
export interface ProviderPurchase {
|
|
49
|
+
storeProductId: StoreProductId;
|
|
50
|
+
transactionId: string;
|
|
51
|
+
token: ProviderToken;
|
|
52
|
+
state: ProviderPurchaseState;
|
|
53
|
+
purchasedAt: number;
|
|
54
|
+
isAcknowledged: boolean;
|
|
55
|
+
/** Subscription-only, and only where the platform supplies it. */
|
|
56
|
+
expiresAt?: number;
|
|
57
|
+
willAutoRenew?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Opaque material for the app's backend. Passed to the validation hook and
|
|
60
|
+
* **never** logged or put in an event (FR-074).
|
|
61
|
+
*/
|
|
62
|
+
verificationPayload?: string;
|
|
63
|
+
}
|
|
64
|
+
export type ProviderFailureReason = 'user_cancelled' | 'already_owned' | 'ineligible' | 'unknown_product' | 'product_unavailable_in_region' | 'not_ready' | 'network_error' | 'timeout' | 'store_error';
|
|
65
|
+
export type ProviderConnectOutcome = {
|
|
66
|
+
ok: true;
|
|
67
|
+
} | {
|
|
68
|
+
ok: false;
|
|
69
|
+
reason: 'no_billing_service' | 'billing_service_outdated' | 'platform_unsupported' | 'store_error';
|
|
70
|
+
retryable: boolean;
|
|
71
|
+
};
|
|
72
|
+
export type ProviderPurchaseOutcome = {
|
|
73
|
+
ok: true;
|
|
74
|
+
purchase: ProviderPurchase;
|
|
75
|
+
} | {
|
|
76
|
+
ok: false;
|
|
77
|
+
reason: ProviderFailureReason;
|
|
78
|
+
detail?: string;
|
|
79
|
+
};
|
|
80
|
+
export type ProviderPriceChangeOutcome = {
|
|
81
|
+
ok: true;
|
|
82
|
+
confirmed: boolean;
|
|
83
|
+
} | {
|
|
84
|
+
ok: false;
|
|
85
|
+
reason: ProviderFailureReason;
|
|
86
|
+
};
|
|
87
|
+
export interface ProviderPurchaseRequest {
|
|
88
|
+
storeProductId: StoreProductId;
|
|
89
|
+
productType: ProductType;
|
|
90
|
+
offerKey?: string;
|
|
91
|
+
/** App-supplied, passed straight through. Never generated or stored (FR-034). */
|
|
92
|
+
obfuscatedAccountId?: string;
|
|
93
|
+
/**
|
|
94
|
+
* Plan change: the token of the active subscription being replaced. The store
|
|
95
|
+
* migrates *that* purchase rather than creating a second one (FR-065).
|
|
96
|
+
*/
|
|
97
|
+
replacePurchaseToken?: ProviderToken;
|
|
98
|
+
/** Plan change: the store product id of the subscription being replaced. */
|
|
99
|
+
replaceStoreProductId?: StoreProductId;
|
|
100
|
+
prorationMode?: string;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* What the platform can actually do.
|
|
104
|
+
*
|
|
105
|
+
* This is how honest degradation is enforced rather than left to good intentions.
|
|
106
|
+
* `reportsGraceAndHoldDistinctly` is `false` on Android, because client-side Play
|
|
107
|
+
* Billing genuinely cannot separate the two: a grace-period subscription is still
|
|
108
|
+
* returned as active, and one in account hold stops being returned at all, making
|
|
109
|
+
* it indistinguishable from expired, cancelled, or refunded.
|
|
110
|
+
*
|
|
111
|
+
* The entitlement layer reads this flag and reports `indeterminate` instead of
|
|
112
|
+
* fabricating a distinction from `willAutoRenew` — which cannot separate grace
|
|
113
|
+
* from cancelled-but-valid either. Claiming otherwise would breach FR-058.
|
|
114
|
+
*/
|
|
115
|
+
export interface ProviderCapabilities {
|
|
116
|
+
supportsSubscriptions: boolean;
|
|
117
|
+
supportsPlanChange: boolean;
|
|
118
|
+
supportsPriceChangeConfirmation: boolean;
|
|
119
|
+
reportsGraceAndHoldDistinctly: boolean;
|
|
120
|
+
/** Externally-initiated purchases: false on Android, true for a future iOS adapter. */
|
|
121
|
+
supportsExternalTransactions: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Whether this adapter can move real money.
|
|
124
|
+
*
|
|
125
|
+
* `true` for the store adapter, `false` for the fake store. This is what lets
|
|
126
|
+
* FR-014's block be precise: the engine refuses a purchase when the
|
|
127
|
+
* environment may not create a production transaction **and** the provider is
|
|
128
|
+
* one that actually would. Without it the guard would either block the test
|
|
129
|
+
* suite — which must be able to buy things — or wave real purchases through in
|
|
130
|
+
* a development build.
|
|
131
|
+
*/
|
|
132
|
+
createsRealTransactions: boolean;
|
|
133
|
+
/**
|
|
134
|
+
* Whether `launchPurchase` settles only once the user has left the store's
|
|
135
|
+
* purchase surface.
|
|
136
|
+
*
|
|
137
|
+
* `true` for the Play adapter: the binding gives no "surface opened" signal and
|
|
138
|
+
* reports the outcome only when the flow ends, so the time the user spends in
|
|
139
|
+
* Play is inside the call. The engine then does not apply its launch timeout,
|
|
140
|
+
* which would otherwise cancel a user still choosing a payment method (FR-035).
|
|
141
|
+
* The binding always ends the flow with a result or an error, so the call
|
|
142
|
+
* cannot hang. `false` for the fake store, whose launch returns at once.
|
|
143
|
+
*/
|
|
144
|
+
purchaseOutcomeIncludesStoreTime: boolean;
|
|
145
|
+
}
|
|
146
|
+
export interface ProviderPort {
|
|
147
|
+
connect(): Promise<ProviderConnectOutcome>;
|
|
148
|
+
disconnect(): Promise<void>;
|
|
149
|
+
/**
|
|
150
|
+
* Reports a **real** disconnect.
|
|
151
|
+
*
|
|
152
|
+
* The engine must never infer connectivity from an unrelated call failing.
|
|
153
|
+
* The upstream binding historically left its `connected` flag true after a
|
|
154
|
+
* disconnect and had a `reconnect()` that could report success without
|
|
155
|
+
* rebuilding anything (openiap#408), so detection belongs here, behind a
|
|
156
|
+
* contract test.
|
|
157
|
+
*/
|
|
158
|
+
observeConnection(listener: (connected: boolean, reason?: string) => void): Unsubscribe;
|
|
159
|
+
queryProducts(storeProductIds: StoreProductId[], productType: ProductType): Promise<ProviderProduct[]>;
|
|
160
|
+
/** Owned and pending purchases. Pending ones are **flagged, never filtered** (FR-037). */
|
|
161
|
+
queryOwned(): Promise<ProviderPurchase[]>;
|
|
162
|
+
launchPurchase(request: ProviderPurchaseRequest): Promise<ProviderPurchaseOutcome>;
|
|
163
|
+
/** Store-initiated updates, including a pending purchase settling later (FR-039). */
|
|
164
|
+
observePurchases(listener: (purchase: ProviderPurchase) => void): Unsubscribe;
|
|
165
|
+
/**
|
|
166
|
+
* Why a pending purchase the store has stopped reporting ended, if the store
|
|
167
|
+
* says (FR-102). Optional, and synchronous because it is asked about a
|
|
168
|
+
* transaction the store already dropped, not fetched.
|
|
169
|
+
*
|
|
170
|
+
* Play gives no reason — a declined or abandoned pending purchase simply
|
|
171
|
+
* vanishes from `queryOwned` — so the Android adapter leaves this out and the
|
|
172
|
+
* engine reports `cancelled`. It is never inferred from age: guessing the
|
|
173
|
+
* store's pending window would be inventing a fact.
|
|
174
|
+
*/
|
|
175
|
+
pendingEndReason?(transactionId: string): 'cancelled' | 'expired' | undefined;
|
|
176
|
+
/** Must be safe to call for an already-finalized transaction (FR-044). */
|
|
177
|
+
acknowledge(token: ProviderToken): Promise<void>;
|
|
178
|
+
/** Must be safe to call twice; the item is granted once (FR-044). */
|
|
179
|
+
consume(token: ProviderToken): Promise<void>;
|
|
180
|
+
openSubscriptionManagement(storeProductId?: StoreProductId): Promise<void>;
|
|
181
|
+
confirmPriceChange(storeProductId: StoreProductId): Promise<ProviderPriceChangeOutcome>;
|
|
182
|
+
capabilities(): ProviderCapabilities;
|
|
183
|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