react-native-iap 15.2.0 → 15.2.2

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.
Files changed (95) hide show
  1. package/android/src/main/java/com/margelo/nitro/iap/HybridRnIap.kt +117 -114
  2. package/android/src/main/java/com/margelo/nitro/iap/ProductQueryHelpers.kt +42 -0
  3. package/android/src/test/java/com/margelo/nitro/iap/ProductQueryHelpersTest.kt +140 -0
  4. package/ios/HybridRnIap.swift +33 -0
  5. package/lib/module/hooks/useIAP.js.map +1 -1
  6. package/lib/module/hooks/useWebhookEvents.js +113 -0
  7. package/lib/module/hooks/useWebhookEvents.js.map +1 -0
  8. package/lib/module/index.js +331 -131
  9. package/lib/module/index.js.map +1 -1
  10. package/lib/module/kit-api.js +161 -0
  11. package/lib/module/kit-api.js.map +1 -0
  12. package/lib/module/types.js +16 -0
  13. package/lib/module/types.js.map +1 -1
  14. package/lib/module/utils/error.js.map +1 -1
  15. package/lib/module/utils/errorMapping.js +6 -0
  16. package/lib/module/utils/errorMapping.js.map +1 -1
  17. package/lib/module/webhook-client.js +164 -0
  18. package/lib/module/webhook-client.js.map +1 -0
  19. package/lib/typescript/plugin/src/withIAP.d.ts +1 -1
  20. package/lib/typescript/src/hooks/useIAP.d.ts +162 -2
  21. package/lib/typescript/src/hooks/useIAP.d.ts.map +1 -1
  22. package/lib/typescript/src/hooks/useWebhookEvents.d.ts +55 -0
  23. package/lib/typescript/src/hooks/useWebhookEvents.d.ts.map +1 -0
  24. package/lib/typescript/src/index.d.ts +282 -129
  25. package/lib/typescript/src/index.d.ts.map +1 -1
  26. package/lib/typescript/src/kit-api.d.ts +54 -0
  27. package/lib/typescript/src/kit-api.d.ts.map +1 -0
  28. package/lib/typescript/src/specs/RnIap.nitro.d.ts +7 -0
  29. package/lib/typescript/src/specs/RnIap.nitro.d.ts.map +1 -1
  30. package/lib/typescript/src/types.d.ts +304 -74
  31. package/lib/typescript/src/types.d.ts.map +1 -1
  32. package/lib/typescript/src/utils/error.d.ts +3 -0
  33. package/lib/typescript/src/utils/error.d.ts.map +1 -1
  34. package/lib/typescript/src/utils/errorMapping.d.ts +6 -0
  35. package/lib/typescript/src/utils/errorMapping.d.ts.map +1 -1
  36. package/lib/typescript/src/webhook-client.d.ts +82 -0
  37. package/lib/typescript/src/webhook-client.d.ts.map +1 -0
  38. package/nitrogen/generated/android/NitroIap+autolinking.cmake +3 -0
  39. package/nitrogen/generated/android/c++/JAdvancedCommerceInfoIOS.hpp +118 -0
  40. package/nitrogen/generated/android/c++/JAdvancedCommerceItemDetailsIOS.hpp +62 -0
  41. package/nitrogen/generated/android/c++/JAdvancedCommerceItemIOS.hpp +78 -0
  42. package/nitrogen/generated/android/c++/JAdvancedCommerceRefundIOS.hpp +62 -0
  43. package/nitrogen/generated/android/c++/JHybridRnIapSpec.cpp +44 -0
  44. package/nitrogen/generated/android/c++/JHybridRnIapSpec.hpp +1 -0
  45. package/nitrogen/generated/android/c++/JPurchase.hpp +11 -0
  46. package/nitrogen/generated/android/c++/JPurchaseIOS.hpp +16 -1
  47. package/nitrogen/generated/android/c++/JRequestPurchaseResult.hpp +11 -0
  48. package/nitrogen/generated/android/c++/JVariant_NullType_AdvancedCommerceInfoIOS.cpp +26 -0
  49. package/nitrogen/generated/android/c++/JVariant_NullType_AdvancedCommerceInfoIOS.hpp +84 -0
  50. package/nitrogen/generated/android/c++/JVariant_NullType_AdvancedCommerceItemDetailsIOS.cpp +26 -0
  51. package/nitrogen/generated/android/c++/JVariant_NullType_AdvancedCommerceItemDetailsIOS.hpp +74 -0
  52. package/nitrogen/generated/android/c++/JVariant_NullType_Array_AdvancedCommerceRefundIOS_.cpp +35 -0
  53. package/nitrogen/generated/android/c++/JVariant_NullType_Array_AdvancedCommerceRefundIOS_.hpp +84 -0
  54. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/AdvancedCommerceInfoIOS.kt +59 -0
  55. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/AdvancedCommerceItemDetailsIOS.kt +38 -0
  56. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/AdvancedCommerceItemIOS.kt +44 -0
  57. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/AdvancedCommerceRefundIOS.kt +38 -0
  58. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/HybridRnIapSpec.kt +4 -0
  59. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/PurchaseIOS.kt +5 -2
  60. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/Variant_NullType_AdvancedCommerceInfoIOS.kt +53 -0
  61. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/Variant_NullType_AdvancedCommerceItemDetailsIOS.kt +53 -0
  62. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/Variant_NullType_Array_AdvancedCommerceRefundIOS_.kt +53 -0
  63. package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Bridge.hpp +166 -0
  64. package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Umbrella.hpp +12 -0
  65. package/nitrogen/generated/ios/c++/HybridRnIapSpecSwift.hpp +20 -0
  66. package/nitrogen/generated/ios/swift/AdvancedCommerceInfoIOS.swift +294 -0
  67. package/nitrogen/generated/ios/swift/AdvancedCommerceItemDetailsIOS.swift +61 -0
  68. package/nitrogen/generated/ios/swift/AdvancedCommerceItemIOS.swift +141 -0
  69. package/nitrogen/generated/ios/swift/AdvancedCommerceRefundIOS.swift +61 -0
  70. package/nitrogen/generated/ios/swift/HybridRnIapSpec.swift +1 -0
  71. package/nitrogen/generated/ios/swift/HybridRnIapSpec_cxx.swift +25 -0
  72. package/nitrogen/generated/ios/swift/PurchaseIOS.swift +39 -2
  73. package/nitrogen/generated/ios/swift/Variant_NullType_AdvancedCommerceInfoIOS.swift +18 -0
  74. package/nitrogen/generated/ios/swift/Variant_NullType_AdvancedCommerceItemDetailsIOS.swift +18 -0
  75. package/nitrogen/generated/ios/swift/Variant_NullType__AdvancedCommerceRefundIOS_.swift +18 -0
  76. package/nitrogen/generated/shared/c++/AdvancedCommerceInfoIOS.hpp +117 -0
  77. package/nitrogen/generated/shared/c++/AdvancedCommerceItemDetailsIOS.hpp +86 -0
  78. package/nitrogen/generated/shared/c++/AdvancedCommerceItemIOS.hpp +99 -0
  79. package/nitrogen/generated/shared/c++/AdvancedCommerceRefundIOS.hpp +86 -0
  80. package/nitrogen/generated/shared/c++/HybridRnIapSpec.cpp +1 -0
  81. package/nitrogen/generated/shared/c++/HybridRnIapSpec.hpp +1 -0
  82. package/nitrogen/generated/shared/c++/PurchaseIOS.hpp +9 -2
  83. package/openiap-versions.json +3 -3
  84. package/package.json +1 -1
  85. package/plugin/build/withIAP.d.ts +1 -1
  86. package/plugin/src/withIAP.ts +1 -1
  87. package/src/hooks/useIAP.ts +162 -2
  88. package/src/hooks/useWebhookEvents.ts +180 -0
  89. package/src/index.ts +348 -130
  90. package/src/kit-api.ts +225 -0
  91. package/src/specs/RnIap.nitro.ts +8 -0
  92. package/src/types.ts +314 -74
  93. package/src/utils/error.ts +3 -0
  94. package/src/utils/errorMapping.ts +12 -0
  95. package/src/webhook-client.ts +312 -0
@@ -0,0 +1,164 @@
1
+ "use strict";
2
+
3
+ // Transport-agnostic webhook client for the openiap kit SSE stream
4
+ // (`GET /v1/webhooks/stream/{apiKey}`). Used by the JavaScript / TS
5
+ // wrappers (react-native-iap, expo-iap) but written without React or
6
+ // React-Native imports so it can also run in plain Node, browser, or
7
+ // any other JS runtime.
8
+ //
9
+ // The wire format is documented in `packages/kit/server/api/v1/webhooks.ts`
10
+ // and matches the GraphQL `WebhookEvent` shape from `webhook.graphql`.
11
+ //
12
+ // Parser logic is split out from the connection so it can be unit-
13
+ // tested without a live server. See `webhook-client.test.ts`.
14
+
15
+ export const WEBHOOK_EVENT_TYPES = ["SubscriptionStarted", "SubscriptionRenewed", "SubscriptionExpired", "SubscriptionInGracePeriod", "SubscriptionInBillingRetry", "SubscriptionRecovered", "SubscriptionCanceled", "SubscriptionUncanceled", "SubscriptionRevoked", "SubscriptionPriceChange", "SubscriptionProductChanged", "SubscriptionPaused", "SubscriptionResumed", "PurchaseRefunded", "PurchaseConsumptionRequest", "TestNotification"];
16
+ const DEFAULT_BASE_URL = "https://kit.openiap.dev";
17
+ export function connectWebhookStream(options) {
18
+ const baseUrl = options.baseUrl ?? DEFAULT_BASE_URL;
19
+ const url = `${trimTrailingSlash(baseUrl)}/v1/webhooks/stream/${encodeURIComponent(options.apiKey)}`;
20
+ const factory = options.eventSourceFactory ?? defaultEventSourceFactory;
21
+ let stream;
22
+ try {
23
+ stream = factory(url, {});
24
+ } catch (error) {
25
+ options.onError?.({
26
+ code: "NO_EVENTSOURCE",
27
+ message: error instanceof Error ? error.message : "EventSource constructor unavailable in this runtime",
28
+ cause: error
29
+ });
30
+ return {
31
+ close: () => {}
32
+ };
33
+ }
34
+ const seenIds = new Set();
35
+ const seenOrder = [];
36
+ const markSeen = id => {
37
+ if (seenIds.has(id)) {
38
+ return true;
39
+ }
40
+ seenIds.add(id);
41
+ seenOrder.push(id);
42
+ if (seenOrder.length > 1024) {
43
+ const evicted = seenOrder.shift();
44
+ if (evicted !== undefined) {
45
+ seenIds.delete(evicted);
46
+ }
47
+ }
48
+ return false;
49
+ };
50
+ const handleData = raw => {
51
+ const parsed = parseWebhookEventData(raw);
52
+ if (parsed.kind === "error") {
53
+ options.onError?.({
54
+ code: "PARSE_ERROR",
55
+ message: parsed.message
56
+ });
57
+ return;
58
+ }
59
+ if (parsed.kind === "skip") {
60
+ return;
61
+ }
62
+ if (markSeen(parsed.event.id)) {
63
+ return;
64
+ }
65
+ options.onEvent(parsed.event);
66
+ };
67
+ if (typeof stream.addEventListener === "function") {
68
+ stream.addEventListener("message", event => handleData(event.data));
69
+ // WHATWG EventSource dispatches frames with `event: Foo` only to
70
+ // listeners registered for `Foo`, not to `message` / `onmessage`.
71
+ // Kit emits webhook frames as typed SSE events, so subscribe to
72
+ // every known webhook type and keep `message` for older servers or
73
+ // polyfills that collapse typed frames into the generic channel.
74
+ for (const eventType of WEBHOOK_EVENT_TYPES) {
75
+ stream.addEventListener(eventType, event => handleData(event.data));
76
+ }
77
+ } else {
78
+ stream.onmessage = event => handleData(event.data);
79
+ }
80
+ stream.onerror = error => {
81
+ options.onError?.({
82
+ code: "TRANSPORT_ERROR",
83
+ message: "SSE transport error (auto-reconnecting)",
84
+ cause: error
85
+ });
86
+ };
87
+ return {
88
+ close: () => {
89
+ try {
90
+ stream.close();
91
+ } catch {
92
+ // Closing an already-closed EventSource is a no-op in browsers
93
+ // but throws in some polyfills.
94
+ }
95
+ }
96
+ };
97
+ }
98
+
99
+ // ---------------------------------------------------------------------------
100
+ // Pure helpers (exported for testing).
101
+ // ---------------------------------------------------------------------------
102
+
103
+ export function parseWebhookEventData(raw) {
104
+ if (!raw) {
105
+ return {
106
+ kind: "skip",
107
+ reason: "heartbeat"
108
+ };
109
+ }
110
+ let parsed;
111
+ try {
112
+ parsed = JSON.parse(raw);
113
+ } catch (error) {
114
+ return {
115
+ kind: "error",
116
+ message: error instanceof Error ? `Failed to parse SSE payload: ${error.message}` : "Failed to parse SSE payload"
117
+ };
118
+ }
119
+ if (typeof parsed !== "object" || parsed === null || !("type" in parsed) || typeof parsed.type !== "string") {
120
+ // Stream-control messages (the `ready`/`stream-error` envelopes
121
+ // emitted by the kit server) have no `type` and are surfaced as
122
+ // skips so consumers don't see them as events.
123
+ return {
124
+ kind: "skip",
125
+ reason: "stream-control"
126
+ };
127
+ }
128
+ const event = parsed;
129
+ if (typeof event.id !== "string" || typeof event.occurredAt !== "number" || typeof event.receivedAt !== "number") {
130
+ return {
131
+ kind: "error",
132
+ message: `WebhookEvent missing required fields (id/occurredAt/receivedAt)`
133
+ };
134
+ }
135
+ // purchaseToken is required for every event type *except*
136
+ // TestNotification — Apple ASN v2 / Google RTDN test payloads
137
+ // carry no transaction. Hard-rejecting here would surface valid
138
+ // test webhooks as MALFORMED_EVENT and never reach listeners.
139
+ if (event.type !== "TestNotification" && typeof event.purchaseToken !== "string") {
140
+ return {
141
+ kind: "error",
142
+ message: `WebhookEvent missing required field purchaseToken`
143
+ };
144
+ }
145
+ return {
146
+ kind: "ok",
147
+ event
148
+ };
149
+ }
150
+ function trimTrailingSlash(url) {
151
+ return url.endsWith("/") ? url.slice(0, -1) : url;
152
+ }
153
+ function defaultEventSourceFactory(url, _headers) {
154
+ // EventSource is part of the WHATWG spec and available in all
155
+ // browser environments and most JS runtimes (Bun, Node 22+, Deno).
156
+ // RN does not ship it natively — consumers must pass
157
+ // `eventSourceFactory` from `react-native-sse` or similar.
158
+ const ctor = globalThis.EventSource;
159
+ if (!ctor) {
160
+ throw new Error("EventSource is not defined. Pass `eventSourceFactory` for runtimes without a built-in EventSource.");
161
+ }
162
+ return new ctor(url);
163
+ }
164
+ //# sourceMappingURL=webhook-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["WEBHOOK_EVENT_TYPES","DEFAULT_BASE_URL","connectWebhookStream","options","baseUrl","url","trimTrailingSlash","encodeURIComponent","apiKey","factory","eventSourceFactory","defaultEventSourceFactory","stream","error","onError","code","message","Error","cause","close","seenIds","Set","seenOrder","markSeen","id","has","add","push","length","evicted","shift","undefined","delete","handleData","raw","parsed","parseWebhookEventData","kind","event","onEvent","addEventListener","data","eventType","onmessage","onerror","reason","JSON","parse","type","occurredAt","receivedAt","purchaseToken","endsWith","slice","_headers","ctor","globalThis","EventSource"],"sourceRoot":"../../src","sources":["webhook-client.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAoBA,OAAO,MAAMA,mBAAmB,GAAG,CACjC,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,2BAA2B,EAC3B,4BAA4B,EAC5B,uBAAuB,EACvB,sBAAsB,EACtB,wBAAwB,EACxB,qBAAqB,EACrB,yBAAyB,EACzB,4BAA4B,EAC5B,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,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;AAEA,SAAShC,iBAAiBA,CAACD,GAAW,EAAU;EAC9C,OAAOA,GAAG,CAAC+C,QAAQ,CAAC,GAAG,CAAC,GAAG/C,GAAG,CAACgD,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAGhD,GAAG;AACnD;AAEA,SAASM,yBAAyBA,CAChCN,GAAW,EACXiD,QAAgC,EACZ;EACpB;EACA;EACA;EACA;EACA,MAAMC,IAAI,GACRC,UAAU,CAGVC,WAAW;EACb,IAAI,CAACF,IAAI,EAAE;IACT,MAAM,IAAItC,KAAK,CACb,oGACF,CAAC;EACH;EACA,OAAO,IAAIsC,IAAI,CAAClD,GAAG,CAAC;AACtB","ignoreList":[]}
@@ -34,7 +34,7 @@ type IapPluginProps = {
34
34
  /**
35
35
  * IAPKit API key for purchase verification.
36
36
  * This key will be added to AndroidManifest.xml (as meta-data) and Info.plist.
37
- * Get your API key from https://iapkit.com
37
+ * Get your API key from https://kit.openiap.dev
38
38
  */
39
39
  iapkitApiKey?: string;
40
40
  };
@@ -8,25 +8,170 @@ type UseIap = {
8
8
  availablePurchases: Purchase[];
9
9
  promotedProductIOS?: Product;
10
10
  activeSubscriptions: ActiveSubscription[];
11
+ /**
12
+ * Complete a purchase transaction. Call after server-side verification to remove it
13
+ * from the queue.
14
+ *
15
+ * @param args.purchase The `Purchase` to finalize.
16
+ * @param args.isConsumable `true` for consumables (consumes the token so the SKU can be
17
+ * re-bought, e.g. coins); `false` (default) for non-consumables and subscriptions.
18
+ * @returns Promise that resolves once the platform finalizes the transaction.
19
+ * @throws When the platform finalize call fails.
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * purchaseUpdatedListener(async (purchase) => {
24
+ * if (await verifyOnServer(purchase)) {
25
+ * await finishTransaction({ purchase, isConsumable: false });
26
+ * }
27
+ * });
28
+ * ```
29
+ *
30
+ * @remarks **Critical:** Android purchases must be finalized within 3 days or Google
31
+ * auto-refunds. iOS unfinished transactions replay on every app launch.
32
+ *
33
+ * @see {@link https://www.openiap.dev/docs/apis/finish-transaction}
34
+ */
11
35
  finishTransaction: (args: MutationFinishTransactionArgs) => Promise<void>;
36
+ /**
37
+ * List the user's unfinished purchases — non-consumables, active subscriptions, and any
38
+ * pending transactions not yet finished.
39
+ *
40
+ * @param options Optional `PurchaseOptions`.
41
+ * - iOS: `alsoPublishToEventListenerIOS`, `onlyIncludeActiveItemsIOS`.
42
+ * - Android: `includeSuspendedAndroid` (include subscriptions in a paused/grace state).
43
+ * @returns Promise that resolves when the request is dispatched; results land in the
44
+ * hook's reactive `availablePurchases` state — read from there, don't expect a return value.
45
+ * @throws When the platform query fails.
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * const { availablePurchases, getAvailablePurchases, finishTransaction } = useIAP();
50
+ *
51
+ * useEffect(() => {
52
+ * void getAvailablePurchases();
53
+ * }, [getAvailablePurchases]);
54
+ *
55
+ * useEffect(() => {
56
+ * for (const p of availablePurchases) {
57
+ * void verifyOnServer(p).then((ok) => {
58
+ * if (ok) finishTransaction({ purchase: p, isConsumable: false });
59
+ * });
60
+ * }
61
+ * }, [availablePurchases, finishTransaction]);
62
+ * ```
63
+ *
64
+ * @see {@link https://www.openiap.dev/docs/apis/get-available-purchases}
65
+ */
12
66
  getAvailablePurchases: (options?: PurchaseOptions) => Promise<void>;
67
+ /**
68
+ * Retrieve products or subscriptions from the store by SKU.
69
+ *
70
+ * @param params `ProductRequest` — `skus` (string[]) and optional `type`
71
+ * (`'in-app' | 'subs' | 'all'`, defaults to `'in-app'`).
72
+ * @returns Promise that resolves when the request is dispatched; results land in the
73
+ * hook's reactive `products` / `subscriptions` state — read from there, don't expect a return value.
74
+ * @throws When the store rejects the request (empty `skus`, not connected,
75
+ * network/store error). Unknown SKUs are simply omitted from the result, not thrown.
76
+ *
77
+ * @example
78
+ * ```ts
79
+ * const { products, fetchProducts } = useIAP();
80
+ *
81
+ * useEffect(() => {
82
+ * void fetchProducts({
83
+ * skus: ['com.app.coins_100', 'com.app.premium'],
84
+ * type: 'in-app',
85
+ * });
86
+ * }, [fetchProducts]);
87
+ *
88
+ * // Render `products` directly from hook state.
89
+ * ```
90
+ *
91
+ * @remarks This is a regular promise-based call. Don't confuse with `request*` APIs
92
+ * (`requestPurchase`), which are event-based.
93
+ *
94
+ * @see {@link https://www.openiap.dev/docs/apis/fetch-products}
95
+ */
13
96
  fetchProducts: (params: {
14
97
  skus: string[];
15
98
  type?: ProductQueryType | null;
16
99
  }) => Promise<void>;
100
+ /**
101
+ * Initiate a purchase or subscription flow. The result is delivered through
102
+ * `purchaseUpdatedListener` — NOT the return value.
103
+ *
104
+ * @param props `RequestPurchaseProps`, discriminated by `type`:
105
+ * - `type: 'in-app'` — pass `request.apple.sku` (iOS) and/or `request.google.skus` (Android).
106
+ * - `type: 'subs'` — same shape, plus `request.google.subscriptionOffers: [{ sku, offerToken }]`.
107
+ * @returns Promise that resolves when the request is dispatched; results land in the
108
+ * hook's `onPurchaseSuccess` / `onPurchaseError` callbacks.
109
+ * @throws Synchronous rejection from the store (e.g. `E_NOT_PREPARED`, validation failure).
110
+ *
111
+ * @example
112
+ * ```ts
113
+ * await requestPurchase({
114
+ * request: {
115
+ * apple: { sku: 'com.app.premium' },
116
+ * google: { skus: ['com.app.premium'] },
117
+ * },
118
+ * type: 'in-app',
119
+ * });
120
+ * ```
121
+ *
122
+ * @remarks Event-based. Listen for the result via {@link purchaseUpdatedListener} /
123
+ * {@link purchaseErrorListener}, or use `useIAP({ onPurchaseSuccess, onPurchaseError })`.
124
+ *
125
+ * @see {@link https://www.openiap.dev/docs/apis/request-purchase}
126
+ */
17
127
  requestPurchase: (params: RequestPurchaseProps) => Promise<void>;
18
128
  /**
19
129
  * @deprecated Use `verifyPurchase` instead. This function will be removed in a future version.
130
+ *
131
+ * @see {@link https://www.openiap.dev/docs/apis/validate-receipt}
20
132
  */
21
133
  validateReceipt: (options: VerifyPurchaseProps) => Promise<VerifyPurchaseResult>;
22
- /** Verify purchase with the configured providers */
134
+ /**
135
+ * Verify a purchase against your own backend (returns isValid + raw store metadata).
136
+ *
137
+ * @see {@link https://www.openiap.dev/docs/features/validation#verify-purchase}
138
+ */
23
139
  verifyPurchase: (options: VerifyPurchaseProps) => Promise<VerifyPurchaseResult>;
24
- /** Verify purchase with a specific provider (e.g., IAPKit) */
140
+ /**
141
+ * Verify via a managed provider — currently only `iapkit` (IAPKit). The PurchaseVerificationProvider enum exposes no other provider literal today.
142
+ *
143
+ * @see {@link https://www.openiap.dev/docs/features/validation#verify-purchase-with-provider}
144
+ */
25
145
  verifyPurchaseWithProvider: (options: VerifyPurchaseWithProviderProps) => Promise<VerifyPurchaseWithProviderResult>;
146
+ /**
147
+ * Restore non-consumable and active subscription purchases.
148
+ *
149
+ * @see {@link https://www.openiap.dev/docs/apis/restore-purchases}
150
+ */
26
151
  restorePurchases: (options?: PurchaseOptions) => Promise<void>;
152
+ /**
153
+ * Read the App Store-promoted product, if any.
154
+ *
155
+ * @see {@link https://www.openiap.dev/docs/apis/ios/get-promoted-product-ios}
156
+ */
27
157
  getPromotedProductIOS: () => Promise<Product | null>;
158
+ /**
159
+ * Buy the currently promoted product.
160
+ *
161
+ * @see {@link https://www.openiap.dev/docs/apis/ios/request-purchase-on-promoted-product-ios}
162
+ */
28
163
  requestPurchaseOnPromotedProductIOS: () => Promise<boolean>;
164
+ /**
165
+ * Get details of all currently active subscriptions.
166
+ *
167
+ * @see {@link https://www.openiap.dev/docs/apis/get-active-subscriptions}
168
+ */
29
169
  getActiveSubscriptions: (subscriptionIds?: string[]) => Promise<ActiveSubscription[]>;
170
+ /**
171
+ * Check whether the user has any active subscription.
172
+ *
173
+ * @see {@link https://www.openiap.dev/docs/apis/has-active-subscriptions}
174
+ */
30
175
  hasActiveSubscriptions: (subscriptionIds?: string[]) => Promise<boolean>;
31
176
  /**
32
177
  * Manually retry the store connection.
@@ -34,8 +179,23 @@ type UseIap = {
34
179
  * Updates the `connected` state on success.
35
180
  */
36
181
  reconnect: () => Promise<boolean>;
182
+ /**
183
+ * Check whether alternative billing is available for the user.
184
+ *
185
+ * @see {@link https://www.openiap.dev/docs/apis/android/check-alternative-billing-availability-android}
186
+ */
37
187
  checkAlternativeBillingAvailabilityAndroid?: () => Promise<boolean>;
188
+ /**
189
+ * Display Google's alternative billing information dialog.
190
+ *
191
+ * @see {@link https://www.openiap.dev/docs/apis/android/show-alternative-billing-dialog-android}
192
+ */
38
193
  showAlternativeBillingDialogAndroid?: () => Promise<boolean>;
194
+ /**
195
+ * Create a reporting token for an alternative billing flow.
196
+ *
197
+ * @see {@link https://www.openiap.dev/docs/apis/android/create-alternative-billing-token-android}
198
+ */
39
199
  createAlternativeBillingTokenAndroid?: (sku?: string) => Promise<string | null>;
40
200
  };
41
201
  export interface UseIapOptions {
@@ -1 +1 @@
1
- {"version":3,"file":"useIAP.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useIAP.ts"],"names":[],"mappings":"AAiCA,OAAO,KAAK,EACV,gBAAgB,EAChB,oBAAoB,EACpB,6BAA6B,EAC7B,qBAAqB,EACrB,wBAAwB,EACxB,mBAAmB,EACnB,oBAAoB,EACpB,+BAA+B,EAC/B,gCAAgC,EAChC,eAAe,EAChB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EACV,kBAAkB,EAClB,OAAO,EACP,QAAQ,EACR,aAAa,EACb,mBAAmB,EACpB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAC,6BAA6B,EAAC,MAAM,UAAU,CAAC;AAO5D,KAAK,MAAM,GAAG;IACZ,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,aAAa,EAAE,mBAAmB,EAAE,CAAC;IACrC,kBAAkB,EAAE,QAAQ,EAAE,CAAC;IAC/B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,mBAAmB,EAAE,kBAAkB,EAAE,CAAC;IAC1C,iBAAiB,EAAE,CAAC,IAAI,EAAE,6BAA6B,KAAK,OAAO,CAAC,IAAI,CAAC,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CAAC,EAAE,6BAA6B,CAAC;IAC9D;;;;;OAKG;IACH,2BAA2B,CAAC,EAAE,qBAAqB,CAAC;CACrD;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,MAAM,CAwctD"}
@@ -0,0 +1,55 @@
1
+ import { type WebhookEventPayload, type WebhookEventStream, type WebhookListenerError } from '../webhook-client';
2
+ export type UseWebhookEventsOptions = {
3
+ /**
4
+ * kit project API key — same value used for receipt verification.
5
+ * Must be non-empty to start the stream; pass `null`/`undefined` to
6
+ * disable the listener (e.g. before the user is logged in).
7
+ */
8
+ apiKey: string | null | undefined;
9
+ /**
10
+ * Override the kit base URL. Defaults to https://kit.openiap.dev.
11
+ */
12
+ baseUrl?: string;
13
+ /**
14
+ * Optional EventSource factory. Required on React Native because RN
15
+ * does not ship a global EventSource — pass an instance from
16
+ * `react-native-sse` (or any compatible polyfill).
17
+ */
18
+ eventSourceFactory?: (url: string, headers: Record<string, string>) => WebhookEventStream;
19
+ /**
20
+ * Maximum number of events to retain in the in-memory ring buffer
21
+ * surfaced as `events`. Older entries are discarded. Defaults to 50.
22
+ * Set 0 to opt out of the buffer entirely (consume only via
23
+ * `onEvent`).
24
+ */
25
+ bufferSize?: number;
26
+ /**
27
+ * Called for every received event in addition to being appended to
28
+ * the buffer. Useful for side effects (toast, analytics, granting
29
+ * entitlement). Called with the latest stable callback identity.
30
+ */
31
+ onEvent?: (event: WebhookEventPayload) => void;
32
+ /**
33
+ * Called when the stream surfaces a transport / parse error.
34
+ * EventSource auto-reconnects regardless of this hook — this is
35
+ * primarily for telemetry + UI surfacing.
36
+ */
37
+ onError?: (error: WebhookListenerError) => void;
38
+ };
39
+ export type UseWebhookEventsResult = {
40
+ /** Most recent N events (most-recent-first). Capped at bufferSize. */
41
+ events: WebhookEventPayload[];
42
+ /** Last error reported by the underlying stream. Null when healthy. */
43
+ lastError: WebhookListenerError | null;
44
+ /**
45
+ * True once the first webhook event has been received from the
46
+ * stream. Remains false if the connection is open but idle (the
47
+ * underlying SSE bridge doesn't surface a "stream opened"
48
+ * lifecycle event we can hook into; isConnected is therefore an
49
+ * activity indicator, not a raw socket-state flag). Reset to
50
+ * false on cleanup / apiKey change.
51
+ */
52
+ isConnected: boolean;
53
+ };
54
+ export declare function useWebhookEvents({ apiKey, baseUrl, eventSourceFactory, bufferSize, onEvent, onError, }: UseWebhookEventsOptions): UseWebhookEventsResult;
55
+ //# sourceMappingURL=useWebhookEvents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useWebhookEvents.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useWebhookEvents.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EAEvB,KAAK,oBAAoB,EAC1B,MAAM,mBAAmB,CAAC;AAE3B,MAAM,MAAM,uBAAuB,GAAG;IACpC;;;;OAIG;IACH,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAClC;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,CACnB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAC5B,kBAAkB,CAAC;IACxB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAC/C;;;;OAIG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,IAAI,CAAC;CACjD,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,sEAAsE;IACtE,MAAM,EAAE,mBAAmB,EAAE,CAAC;IAC9B,uEAAuE;IACvE,SAAS,EAAE,oBAAoB,GAAG,IAAI,CAAC;IACvC;;;;;;;OAOG;IACH,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAaF,wBAAgB,gBAAgB,CAAC,EAC/B,MAAM,EACN,OAAO,EACP,kBAAkB,EAClB,UAAe,EACf,OAAO,EACP,OAAO,GACR,EAAE,uBAAuB,GAAG,sBAAsB,CA8FlD"}