@flare-engine/iap-revenuecat 0.2.1 → 0.3.1
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/LICENSE +201 -21
- package/NOTICE +2 -0
- package/README.md +4 -2
- package/dist/index.d.mts +47 -39
- package/dist/index.d.mts.map +1 -0
- package/dist/index.d.ts +47 -39
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +141 -175
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +140 -138
- package/dist/index.mjs.map +1 -1
- package/package.json +17 -9
package/LICENSE
CHANGED
|
@@ -1,21 +1,201 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Grzegorz Otto
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/NOTICE
ADDED
package/README.md
CHANGED
|
@@ -30,6 +30,8 @@ export function App() {
|
|
|
30
30
|
|
|
31
31
|
`react-native-purchases` is a **peer dependency** and is never bundled into this package. The SDK is lazy-imported on first use, so platforms without it (e.g. web) are unaffected until `getProducts`, `purchase`, or `restore` is called.
|
|
32
32
|
|
|
33
|
-
##
|
|
33
|
+
## Env-gated fallback
|
|
34
34
|
|
|
35
|
-
In
|
|
35
|
+
In CI or dev builds without RevenueCat keys, select `NoopIAPProvider` from
|
|
36
|
+
`@flare-engine/iap` instead of this adapter behind your own env flag, so nothing
|
|
37
|
+
touches the native SDK until real keys are present.
|
package/dist/index.d.mts
CHANGED
|
@@ -1,55 +1,63 @@
|
|
|
1
|
-
import { IAPProvider } from
|
|
2
|
-
|
|
1
|
+
import { IAPProvider } from "@flare-engine/iap";
|
|
2
|
+
//#region src/types.d.ts
|
|
3
3
|
interface RevenueCatConfig {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
apiKeyIos: string;
|
|
5
|
+
apiKeyAndroid: string;
|
|
6
|
+
appUserId?: string;
|
|
7
|
+
/** Passed verbatim as the react-native-purchases getProducts category/type argument
|
|
8
|
+
* (e.g. 'subs'/'inapp' or your SDK's PRODUCT_CATEGORY constant). Undefined → SDK default. */
|
|
9
|
+
productCategory?: string;
|
|
10
|
+
/** Observe errors that getProducts/restore otherwise swallow into []. */
|
|
11
|
+
onError?: (err: unknown) => void;
|
|
7
12
|
}
|
|
8
13
|
/** Minimal interface for the react-native-purchases SDK methods we call.
|
|
9
14
|
* Defined here so we don't hard-depend on its types at compile time. */
|
|
10
15
|
interface RevenueCatPurchasesModule {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
configure(params: {
|
|
17
|
+
apiKey: string;
|
|
18
|
+
appUserID: string | null;
|
|
19
|
+
}): void;
|
|
20
|
+
getProducts(ids: string[], type?: string): Promise<RevenueCatStoreProduct[]>;
|
|
21
|
+
purchaseStoreProduct(product: RevenueCatStoreProduct): Promise<{
|
|
22
|
+
customerInfo: RevenueCatCustomerInfo;
|
|
23
|
+
}>;
|
|
24
|
+
restorePurchases(): Promise<RevenueCatCustomerInfo>;
|
|
25
|
+
addCustomerInfoUpdateListener(listener: (info: RevenueCatCustomerInfo) => void): void;
|
|
26
|
+
removeCustomerInfoUpdateListener(listener: (info: RevenueCatCustomerInfo) => void): void;
|
|
22
27
|
}
|
|
23
28
|
interface RevenueCatStoreProduct {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
identifier: string;
|
|
30
|
+
title: string;
|
|
31
|
+
description: string;
|
|
32
|
+
priceString: string;
|
|
33
|
+
price: number;
|
|
34
|
+
currencyCode: string;
|
|
35
|
+
productCategory?: string;
|
|
36
|
+
productType?: string;
|
|
32
37
|
}
|
|
33
38
|
interface RevenueCatEntitlement {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
identifier: string;
|
|
40
|
+
productIdentifier: string;
|
|
41
|
+
purchaseDateMillis?: number;
|
|
42
|
+
expirationDate?: string | null;
|
|
43
|
+
latestPurchaseDate?: string;
|
|
39
44
|
}
|
|
40
45
|
interface RevenueCatNonSubscriptionTransaction {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
46
|
+
transactionIdentifier: string;
|
|
47
|
+
productIdentifier: string;
|
|
48
|
+
purchaseDateMillis?: number;
|
|
44
49
|
}
|
|
45
50
|
interface RevenueCatCustomerInfo {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
originalPurchaseDate?: string | null;
|
|
52
|
+
entitlements?: {
|
|
53
|
+
all?: Record<string, RevenueCatEntitlement>;
|
|
54
|
+
active?: Record<string, RevenueCatEntitlement>;
|
|
55
|
+
};
|
|
56
|
+
nonSubscriptionTransactions?: RevenueCatNonSubscriptionTransaction[];
|
|
51
57
|
}
|
|
52
|
-
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/provider.d.ts
|
|
53
60
|
declare function createRevenueCatProvider(config: RevenueCatConfig): IAPProvider;
|
|
54
|
-
|
|
61
|
+
//#endregion
|
|
55
62
|
export { type RevenueCatConfig, type RevenueCatPurchasesModule, createRevenueCatProvider };
|
|
63
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/provider.ts"],"mappings":";;UAAiB;EACf;EACA;EACA;;;EAGA;;EAEA,WAAW;;;;UAKI;EACf,UAAU;IAAU;IAAgB;;EACpC,YAAY,eAAe,gBAAgB,QAAQ;EACnD,qBACE,SAAS,yBACR;IAAU,cAAc;;EAC3B,oBAAoB,QAAQ;EAC5B,8BAA8B,WAAW,MAAM;EAC/C,iCAAiC,WAAW,MAAM;;UAGnC;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA;EACA;;UAGe;EACf;EACA;EACA;;UAGe;EACf;EACA;IACE,MAAM,eAAe;IACrB,SAAS,eAAe;;EAE1B,8BAA8B;;;;iBCwBhB,yBAAyB,QAAQ,mBAAmB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,55 +1,63 @@
|
|
|
1
|
-
import { IAPProvider } from
|
|
2
|
-
|
|
1
|
+
import { IAPProvider } from "@flare-engine/iap";
|
|
2
|
+
//#region src/types.d.ts
|
|
3
3
|
interface RevenueCatConfig {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
apiKeyIos: string;
|
|
5
|
+
apiKeyAndroid: string;
|
|
6
|
+
appUserId?: string;
|
|
7
|
+
/** Passed verbatim as the react-native-purchases getProducts category/type argument
|
|
8
|
+
* (e.g. 'subs'/'inapp' or your SDK's PRODUCT_CATEGORY constant). Undefined → SDK default. */
|
|
9
|
+
productCategory?: string;
|
|
10
|
+
/** Observe errors that getProducts/restore otherwise swallow into []. */
|
|
11
|
+
onError?: (err: unknown) => void;
|
|
7
12
|
}
|
|
8
13
|
/** Minimal interface for the react-native-purchases SDK methods we call.
|
|
9
14
|
* Defined here so we don't hard-depend on its types at compile time. */
|
|
10
15
|
interface RevenueCatPurchasesModule {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
configure(params: {
|
|
17
|
+
apiKey: string;
|
|
18
|
+
appUserID: string | null;
|
|
19
|
+
}): void;
|
|
20
|
+
getProducts(ids: string[], type?: string): Promise<RevenueCatStoreProduct[]>;
|
|
21
|
+
purchaseStoreProduct(product: RevenueCatStoreProduct): Promise<{
|
|
22
|
+
customerInfo: RevenueCatCustomerInfo;
|
|
23
|
+
}>;
|
|
24
|
+
restorePurchases(): Promise<RevenueCatCustomerInfo>;
|
|
25
|
+
addCustomerInfoUpdateListener(listener: (info: RevenueCatCustomerInfo) => void): void;
|
|
26
|
+
removeCustomerInfoUpdateListener(listener: (info: RevenueCatCustomerInfo) => void): void;
|
|
22
27
|
}
|
|
23
28
|
interface RevenueCatStoreProduct {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
identifier: string;
|
|
30
|
+
title: string;
|
|
31
|
+
description: string;
|
|
32
|
+
priceString: string;
|
|
33
|
+
price: number;
|
|
34
|
+
currencyCode: string;
|
|
35
|
+
productCategory?: string;
|
|
36
|
+
productType?: string;
|
|
32
37
|
}
|
|
33
38
|
interface RevenueCatEntitlement {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
identifier: string;
|
|
40
|
+
productIdentifier: string;
|
|
41
|
+
purchaseDateMillis?: number;
|
|
42
|
+
expirationDate?: string | null;
|
|
43
|
+
latestPurchaseDate?: string;
|
|
39
44
|
}
|
|
40
45
|
interface RevenueCatNonSubscriptionTransaction {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
46
|
+
transactionIdentifier: string;
|
|
47
|
+
productIdentifier: string;
|
|
48
|
+
purchaseDateMillis?: number;
|
|
44
49
|
}
|
|
45
50
|
interface RevenueCatCustomerInfo {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
originalPurchaseDate?: string | null;
|
|
52
|
+
entitlements?: {
|
|
53
|
+
all?: Record<string, RevenueCatEntitlement>;
|
|
54
|
+
active?: Record<string, RevenueCatEntitlement>;
|
|
55
|
+
};
|
|
56
|
+
nonSubscriptionTransactions?: RevenueCatNonSubscriptionTransaction[];
|
|
51
57
|
}
|
|
52
|
-
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/provider.d.ts
|
|
53
60
|
declare function createRevenueCatProvider(config: RevenueCatConfig): IAPProvider;
|
|
54
|
-
|
|
61
|
+
//#endregion
|
|
55
62
|
export { type RevenueCatConfig, type RevenueCatPurchasesModule, createRevenueCatProvider };
|
|
63
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/provider.ts"],"mappings":";;UAAiB;EACf;EACA;EACA;;;EAGA;;EAEA,WAAW;;;;UAKI;EACf,UAAU;IAAU;IAAgB;;EACpC,YAAY,eAAe,gBAAgB,QAAQ;EACnD,qBACE,SAAS,yBACR;IAAU,cAAc;;EAC3B,oBAAoB,QAAQ;EAC5B,8BAA8B,WAAW,MAAM;EAC/C,iCAAiC,WAAW,MAAM;;UAGnC;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA;EACA;;UAGe;EACf;EACA;EACA;;UAGe;EACf;EACA;IACE,MAAM,eAAe;IACrB,SAAS,eAAe;;EAE1B,8BAA8B;;;;iBCwBhB,yBAAyB,QAAQ,mBAAmB"}
|
package/dist/index.js
CHANGED
|
@@ -1,184 +1,150 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/index.ts
|
|
31
|
-
var index_exports = {};
|
|
32
|
-
__export(index_exports, {
|
|
33
|
-
createRevenueCatProvider: () => createRevenueCatProvider
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(index_exports);
|
|
36
|
-
|
|
37
|
-
// src/provider.ts
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/provider.ts
|
|
38
3
|
function mapProductType(category, type) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return void 0;
|
|
4
|
+
const typ = (type ?? "").toLowerCase();
|
|
5
|
+
const cat = (category ?? "").toLowerCase();
|
|
6
|
+
if (typ === "consumable") return "consumable";
|
|
7
|
+
if (typ === "non_consumable") return "non-consumable";
|
|
8
|
+
if (typ.includes("subscription") || cat === "subscription") return "subscription";
|
|
9
|
+
if (cat === "non_subscription") return "non-consumable";
|
|
46
10
|
}
|
|
47
11
|
function mapProduct(p) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
12
|
+
return {
|
|
13
|
+
id: p.identifier,
|
|
14
|
+
title: p.title,
|
|
15
|
+
description: p.description,
|
|
16
|
+
priceDisplay: p.priceString,
|
|
17
|
+
priceMicros: p.price * 1e6,
|
|
18
|
+
currency: p.currencyCode,
|
|
19
|
+
type: mapProductType(p.productCategory, p.productType)
|
|
20
|
+
};
|
|
57
21
|
}
|
|
58
22
|
function mapRestoreResults(info) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
23
|
+
const results = [];
|
|
24
|
+
for (const ent of Object.values(info.entitlements?.active ?? {})) results.push({
|
|
25
|
+
status: "purchased",
|
|
26
|
+
transaction: {
|
|
27
|
+
id: ent.identifier,
|
|
28
|
+
productId: ent.productIdentifier,
|
|
29
|
+
purchasedAt: ent.purchaseDateMillis ?? Date.now(),
|
|
30
|
+
raw: ent
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
for (const tx of info.nonSubscriptionTransactions ?? []) results.push({
|
|
34
|
+
status: "purchased",
|
|
35
|
+
transaction: {
|
|
36
|
+
id: tx.transactionIdentifier,
|
|
37
|
+
productId: tx.productIdentifier,
|
|
38
|
+
purchasedAt: tx.purchaseDateMillis ?? Date.now(),
|
|
39
|
+
raw: tx
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
return results;
|
|
43
|
+
}
|
|
44
|
+
function findPurchaseTx(info, productId) {
|
|
45
|
+
const txs = info.nonSubscriptionTransactions ?? [];
|
|
46
|
+
for (let i = txs.length - 1; i >= 0; i--) if (txs[i].productIdentifier === productId) return txs[i];
|
|
83
47
|
}
|
|
84
48
|
function createRevenueCatProvider(config) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
49
|
+
let sdkCache = null;
|
|
50
|
+
let configurePromise = null;
|
|
51
|
+
async function getSDK() {
|
|
52
|
+
if (sdkCache) return sdkCache;
|
|
53
|
+
const mod = await import("react-native-purchases");
|
|
54
|
+
sdkCache = mod.default ?? mod;
|
|
55
|
+
return sdkCache;
|
|
56
|
+
}
|
|
57
|
+
async function ensureConfigured() {
|
|
58
|
+
if (configurePromise === null) configurePromise = (async () => {
|
|
59
|
+
const Purchases = await getSDK();
|
|
60
|
+
const apiKey = (await import("react-native")).Platform.OS === "ios" ? config.apiKeyIos : config.apiKeyAndroid;
|
|
61
|
+
Purchases.configure({
|
|
62
|
+
apiKey,
|
|
63
|
+
appUserID: config.appUserId ?? null
|
|
64
|
+
});
|
|
65
|
+
return Purchases;
|
|
66
|
+
})();
|
|
67
|
+
const pending = configurePromise;
|
|
68
|
+
try {
|
|
69
|
+
return await pending;
|
|
70
|
+
} catch (err) {
|
|
71
|
+
if (configurePromise === pending) configurePromise = null;
|
|
72
|
+
throw err;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
async getProducts(ids) {
|
|
77
|
+
try {
|
|
78
|
+
return (await (await ensureConfigured()).getProducts([...ids], config.productCategory)).map(mapProduct);
|
|
79
|
+
} catch (err) {
|
|
80
|
+
config.onError?.(err);
|
|
81
|
+
return [];
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
async purchase(id) {
|
|
85
|
+
try {
|
|
86
|
+
const Purchases = await ensureConfigured();
|
|
87
|
+
const product = (await Purchases.getProducts([id], config.productCategory))[0];
|
|
88
|
+
if (!product) return {
|
|
89
|
+
status: "failed",
|
|
90
|
+
error: /* @__PURE__ */ new Error(`Product not found: ${id}`)
|
|
91
|
+
};
|
|
92
|
+
const { customerInfo } = await Purchases.purchaseStoreProduct(product);
|
|
93
|
+
const tx = findPurchaseTx(customerInfo, id);
|
|
94
|
+
return {
|
|
95
|
+
status: "purchased",
|
|
96
|
+
transaction: {
|
|
97
|
+
id: tx?.transactionIdentifier ?? customerInfo.originalPurchaseDate ?? String(Date.now()),
|
|
98
|
+
productId: id,
|
|
99
|
+
purchasedAt: tx?.purchaseDateMillis ?? Date.now(),
|
|
100
|
+
raw: customerInfo
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
} catch (err) {
|
|
104
|
+
if (err !== null && typeof err === "object" && "userCancelled" in err && err.userCancelled === true) return { status: "cancelled" };
|
|
105
|
+
return {
|
|
106
|
+
status: "failed",
|
|
107
|
+
error: err instanceof Error ? err : new Error(String(err))
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
async restore() {
|
|
112
|
+
try {
|
|
113
|
+
return mapRestoreResults(await (await ensureConfigured()).restorePurchases());
|
|
114
|
+
} catch (err) {
|
|
115
|
+
config.onError?.(err);
|
|
116
|
+
return [];
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
onTransaction(cb) {
|
|
120
|
+
let cancelled = false;
|
|
121
|
+
let registered = null;
|
|
122
|
+
getSDK().then((Purchases) => {
|
|
123
|
+
if (cancelled) return;
|
|
124
|
+
const listener = (info) => {
|
|
125
|
+
for (const ent of Object.values(info.entitlements?.active ?? {})) cb({
|
|
126
|
+
id: ent.identifier,
|
|
127
|
+
productId: ent.productIdentifier,
|
|
128
|
+
purchasedAt: ent.purchaseDateMillis ?? Date.now(),
|
|
129
|
+
raw: info
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
registered = listener;
|
|
133
|
+
Purchases.addCustomerInfoUpdateListener(listener);
|
|
134
|
+
}).catch(() => {});
|
|
135
|
+
return () => {
|
|
136
|
+
cancelled = true;
|
|
137
|
+
const listener = registered;
|
|
138
|
+
if (listener === null) return;
|
|
139
|
+
registered = null;
|
|
140
|
+
getSDK().then((Purchases) => {
|
|
141
|
+
Purchases.removeCustomerInfoUpdateListener(listener);
|
|
142
|
+
}).catch(() => {});
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
};
|
|
179
146
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
});
|
|
147
|
+
//#endregion
|
|
148
|
+
exports.createRevenueCatProvider = createRevenueCatProvider;
|
|
149
|
+
|
|
184
150
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/provider.ts"],"sourcesContent":["export { createRevenueCatProvider } from './provider.js';\nexport type {\n RevenueCatConfig,\n RevenueCatPurchasesModule,\n} from './types.js';\n","import type {\n IAPProvider,\n Product,\n ProductId,\n PurchaseResult,\n Transaction,\n Unsubscribe,\n} from '@flare-engine/iap';\nimport type {\n RevenueCatConfig,\n RevenueCatCustomerInfo,\n RevenueCatPurchasesModule,\n RevenueCatStoreProduct,\n} from './types.js';\n\nfunction mapProductType(category?: string, type?: string): Product['type'] {\n const typ = (type ?? '').toLowerCase();\n const cat = (category ?? '').toLowerCase();\n if (typ === 'consumable') return 'consumable';\n if (typ === 'non_consumable') return 'non-consumable';\n if (typ.includes('subscription') || cat === 'subscription') return 'subscription';\n if (cat === 'non_subscription') return 'non-consumable';\n return undefined;\n}\n\nfunction mapProduct(p: RevenueCatStoreProduct): Product {\n return {\n id: p.identifier,\n title: p.title,\n description: p.description,\n priceDisplay: p.priceString,\n priceMicros: p.price * 1e6,\n currency: p.currencyCode,\n type: mapProductType(p.productCategory, p.productType),\n };\n}\n\nfunction mapRestoreResults(info: RevenueCatCustomerInfo): readonly PurchaseResult[] {\n const results: PurchaseResult[] = [];\n\n for (const ent of Object.values(info.entitlements?.all ?? {})) {\n results.push({\n status: 'purchased',\n transaction: {\n id: ent.identifier,\n productId: ent.productIdentifier,\n purchasedAt: ent.purchaseDateMillis ?? Date.now(),\n raw: ent,\n },\n });\n }\n\n for (const tx of info.nonSubscriptionTransactions ?? []) {\n results.push({\n status: 'purchased',\n transaction: {\n id: tx.transactionIdentifier,\n productId: tx.productIdentifier,\n purchasedAt: tx.purchaseDateMillis ?? Date.now(),\n raw: tx,\n },\n });\n }\n\n return results;\n}\n\nexport function createRevenueCatProvider(config: RevenueCatConfig): IAPProvider {\n // Per-instance cache so multiple providers are independent (and tests are isolated).\n let sdkCache: RevenueCatPurchasesModule | null = null;\n let configured = false;\n\n // Lazy-import keeps react-native-purchases off the module graph on platforms\n // (e.g., web) where it is not installed or not needed.\n async function getSDK(): Promise<RevenueCatPurchasesModule> {\n if (sdkCache) return sdkCache;\n const mod = await import('react-native-purchases');\n sdkCache = (mod.default ?? mod) as RevenueCatPurchasesModule;\n return sdkCache;\n }\n\n async function ensureConfigured(): Promise<RevenueCatPurchasesModule> {\n const Purchases = await getSDK();\n if (!configured) {\n // react-native is also lazy-loaded so this module never hard-loads on web.\n const rn = await import('react-native');\n const apiKey = rn.Platform.OS === 'ios' ? config.apiKeyIos : config.apiKeyAndroid;\n Purchases.configure({ apiKey, appUserID: config.appUserId ?? null });\n configured = true;\n }\n return Purchases;\n }\n\n return {\n async getProducts(ids: readonly ProductId[]): Promise<readonly Product[]> {\n try {\n const Purchases = await ensureConfigured();\n const raw = await Purchases.getProducts([...ids]);\n return raw.map(mapProduct);\n } catch {\n return [];\n }\n },\n\n async purchase(id: ProductId): Promise<PurchaseResult> {\n // No-throw contract: all paths return PurchaseResult rather than throw.\n try {\n const Purchases = await ensureConfigured();\n const products = await Purchases.getProducts([id]);\n const product = products[0];\n if (!product) {\n return { status: 'failed', error: new Error(`Product not found: ${id}`) };\n }\n const { customerInfo } = await Purchases.purchaseStoreProduct(product);\n return {\n status: 'purchased',\n transaction: {\n id: customerInfo.originalPurchaseDate ?? String(Date.now()),\n productId: id,\n purchasedAt: Date.now(),\n raw: customerInfo,\n },\n };\n } catch (err) {\n if (\n err !== null &&\n typeof err === 'object' &&\n 'userCancelled' in err &&\n (err as { userCancelled: unknown }).userCancelled === true\n ) {\n return { status: 'cancelled' };\n }\n return {\n status: 'failed',\n error: err instanceof Error ? err : new Error(String(err)),\n };\n }\n },\n\n async restore(): Promise<readonly PurchaseResult[]> {\n try {\n const Purchases = await ensureConfigured();\n const info = await Purchases.restorePurchases();\n return mapRestoreResults(info);\n } catch {\n return [];\n }\n },\n\n onTransaction(cb: (tx: Transaction) => void): Unsubscribe {\n let listener: ((info: RevenueCatCustomerInfo) => void) | null = null;\n\n getSDK()\n .then((Purchases) => {\n listener = (info: RevenueCatCustomerInfo) => {\n const entitlements = Object.values(info.entitlements?.all ?? {});\n const ent = entitlements[0];\n if (ent) {\n cb({\n id: ent.identifier,\n productId: ent.productIdentifier,\n purchasedAt: ent.purchaseDateMillis ?? Date.now(),\n raw: info,\n });\n }\n };\n Purchases.addCustomerInfoUpdateListener(listener);\n })\n .catch(() => {});\n\n return () => {\n if (listener !== null) {\n getSDK()\n .then((Purchases) => {\n Purchases.removeCustomerInfoUpdateListener(listener!);\n })\n .catch(() => {});\n listener = null;\n }\n };\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACeA,SAAS,eAAe,UAAmB,MAAgC;AACzE,QAAM,OAAO,QAAQ,IAAI,YAAY;AACrC,QAAM,OAAO,YAAY,IAAI,YAAY;AACzC,MAAI,QAAQ,aAAc,QAAO;AACjC,MAAI,QAAQ,iBAA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AAA,IAEA,MAAM,UAA8C;AAClD,UAAI;AACF,cAAM,YAAY,MAAM,iBAAiB;AACzC,cAAM,OAAO,MAAM,UAAU,iBAAiB;AAC9C,eAAO,kBAAkB,IAAI;AAAA,MAC/B,QAAQ;AACN,eAAO,CAAC;AAAA,MACV;AAAA,IACF;AAAA,IAEA,cAAc,IAA4C;AACxD,UAAI,WAA4D;AAEhE,aAAO,EACJ,KAAK,CAAC,cAAc;AACnB,mBAAW,CAAC,SAAiC;AAC3C,gBAAM,eAAe,OAAO,OAAO,KAAK,cAAc,OAAO,CAAC,CAAC;AAC/D,gBAAM,MAAM,aAAa,CAAC;AAC1B,cAAI,KAAK;AACP,eAAG;AAAA,cACD,IAAI,IAAI;AAAA,cACR,WAAW,IAAI;AAAA,cACf,aAAa,IAAI,sBAAsB,KAAK,IAAI;AAAA,cAChD,KAAK;AAAA,YACP,CAAC;AAAA,UACH;AAAA,QACF;AACA,kBAAU,8BAA8B,QAAQ;AAAA,MAClD,CAAC,EACA,MAAM,MAAM;AAAA,MAAC,CAAC;AAEjB,aAAO,MAAM;AACX,YAAI,aAAa,MAAM;AACrB,iBAAO,EACJ,KAAK,CAAC,cAAc;AACnB,sBAAU,iCAAiC,QAAS;AAAA,UACtD,CAAC,EACA,MAAM,MAAM;AAAA,UAAC,CAAC;AACjB,qBAAW;AAAA,QACb;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/provider.ts"],"sourcesContent":["import type {\n IAPProvider,\n Product,\n ProductId,\n PurchaseResult,\n Transaction,\n Unsubscribe,\n} from '@flare-engine/iap';\nimport type {\n RevenueCatConfig,\n RevenueCatCustomerInfo,\n RevenueCatNonSubscriptionTransaction,\n RevenueCatPurchasesModule,\n RevenueCatStoreProduct,\n} from './types.js';\n\nfunction mapProductType(category?: string, type?: string): Product['type'] {\n const typ = (type ?? '').toLowerCase();\n const cat = (category ?? '').toLowerCase();\n if (typ === 'consumable') return 'consumable';\n if (typ === 'non_consumable') return 'non-consumable';\n if (typ.includes('subscription') || cat === 'subscription') return 'subscription';\n if (cat === 'non_subscription') return 'non-consumable';\n return undefined;\n}\n\nfunction mapProduct(p: RevenueCatStoreProduct): Product {\n return {\n id: p.identifier,\n title: p.title,\n description: p.description,\n priceDisplay: p.priceString,\n priceMicros: p.price * 1e6,\n currency: p.currencyCode,\n type: mapProductType(p.productCategory, p.productType),\n };\n}\n\nfunction mapRestoreResults(info: RevenueCatCustomerInfo): readonly PurchaseResult[] {\n const results: PurchaseResult[] = [];\n\n for (const ent of Object.values(info.entitlements?.active ?? {})) {\n results.push({\n status: 'purchased',\n transaction: {\n id: ent.identifier,\n productId: ent.productIdentifier,\n purchasedAt: ent.purchaseDateMillis ?? Date.now(),\n raw: ent,\n },\n });\n }\n\n for (const tx of info.nonSubscriptionTransactions ?? []) {\n results.push({\n status: 'purchased',\n transaction: {\n id: tx.transactionIdentifier,\n productId: tx.productIdentifier,\n purchasedAt: tx.purchaseDateMillis ?? Date.now(),\n raw: tx,\n },\n });\n }\n\n return results;\n}\n\nfunction findPurchaseTx(\n info: RevenueCatCustomerInfo,\n productId: string,\n): RevenueCatNonSubscriptionTransaction | undefined {\n const txs = info.nonSubscriptionTransactions ?? [];\n for (let i = txs.length - 1; i >= 0; i--) {\n if (txs[i]!.productIdentifier === productId) return txs[i];\n }\n return undefined;\n}\n\nexport function createRevenueCatProvider(config: RevenueCatConfig): IAPProvider {\n // Per-instance cache so multiple providers are independent (and tests are isolated).\n let sdkCache: RevenueCatPurchasesModule | null = null;\n // Memoize the whole configure sequence, not a post-await boolean: a boolean flips\n // only after two awaits, so concurrent first callers (e.g. Promise.all([getProducts,\n // restore])) all pass the guard and double-call Purchases.configure (which RevenueCat\n // rejects). A shared promise makes configure run exactly once for all in-flight callers.\n let configurePromise: Promise<RevenueCatPurchasesModule> | null = null;\n\n // Lazy-import keeps react-native-purchases off the module graph on platforms\n // (e.g., web) where it is not installed or not needed.\n async function getSDK(): Promise<RevenueCatPurchasesModule> {\n if (sdkCache) return sdkCache;\n const mod = await import('react-native-purchases');\n sdkCache = (mod.default ?? mod) as RevenueCatPurchasesModule;\n return sdkCache;\n }\n\n async function ensureConfigured(): Promise<RevenueCatPurchasesModule> {\n if (configurePromise === null) {\n configurePromise = (async () => {\n const Purchases = await getSDK();\n // react-native is also lazy-loaded so this module never hard-loads on web.\n const rn = await import('react-native');\n const apiKey = rn.Platform.OS === 'ios' ? config.apiKeyIos : config.apiKeyAndroid;\n Purchases.configure({ apiKey, appUserID: config.appUserId ?? null });\n return Purchases;\n })();\n }\n const pending = configurePromise;\n try {\n return await pending;\n } catch (err) {\n // A failed configure must not poison every future call: clear the memo so a later\n // call retries (mirrors the old flag, which stayed false when configure threw).\n // Compare-and-clear: only null OUR attempt — a later caller may already have\n // installed a fresh promise, which must not be wiped out from under it.\n if (configurePromise === pending) configurePromise = null;\n throw err;\n }\n }\n\n return {\n async getProducts(ids: readonly ProductId[]): Promise<readonly Product[]> {\n try {\n const Purchases = await ensureConfigured();\n const raw = await Purchases.getProducts([...ids], config.productCategory);\n return raw.map(mapProduct);\n } catch (err) {\n config.onError?.(err);\n return [];\n }\n },\n\n async purchase(id: ProductId): Promise<PurchaseResult> {\n // No-throw contract: all paths return PurchaseResult rather than throw.\n try {\n const Purchases = await ensureConfigured();\n const products = await Purchases.getProducts([id], config.productCategory);\n const product = products[0];\n if (!product) {\n return { status: 'failed', error: new Error(`Product not found: ${id}`) };\n }\n const { customerInfo } = await Purchases.purchaseStoreProduct(product);\n const tx = findPurchaseTx(customerInfo, id);\n return {\n status: 'purchased',\n transaction: {\n // Prefer the store's real transaction id; the date fallback is a documented\n // best-effort only when the SDK surface exposes no transaction id (not a real id).\n id:\n tx?.transactionIdentifier ?? customerInfo.originalPurchaseDate ?? String(Date.now()),\n productId: id,\n purchasedAt: tx?.purchaseDateMillis ?? Date.now(),\n raw: customerInfo,\n },\n };\n } catch (err) {\n if (\n err !== null &&\n typeof err === 'object' &&\n 'userCancelled' in err &&\n (err as { userCancelled: unknown }).userCancelled === true\n ) {\n return { status: 'cancelled' };\n }\n return {\n status: 'failed',\n error: err instanceof Error ? err : new Error(String(err)),\n };\n }\n },\n\n async restore(): Promise<readonly PurchaseResult[]> {\n try {\n const Purchases = await ensureConfigured();\n const info = await Purchases.restorePurchases();\n return mapRestoreResults(info);\n } catch (err) {\n config.onError?.(err);\n return [];\n }\n },\n\n onTransaction(cb: (tx: Transaction) => void): Unsubscribe {\n let cancelled = false;\n let registered: ((info: RevenueCatCustomerInfo) => void) | null = null;\n\n getSDK()\n .then((Purchases) => {\n if (cancelled) return; // pre-resolution unsubscribe → never register\n const listener = (info: RevenueCatCustomerInfo) => {\n for (const ent of Object.values(info.entitlements?.active ?? {})) {\n cb({\n id: ent.identifier,\n productId: ent.productIdentifier,\n purchasedAt: ent.purchaseDateMillis ?? Date.now(),\n raw: info,\n });\n }\n };\n registered = listener;\n Purchases.addCustomerInfoUpdateListener(listener);\n })\n .catch(() => {});\n\n return () => {\n cancelled = true;\n const listener = registered;\n if (listener === null) return; // not registered yet (suppressed above) or already removed → idempotent\n registered = null;\n getSDK()\n .then((Purchases) => {\n Purchases.removeCustomerInfoUpdateListener(listener);\n })\n .catch(() => {});\n };\n },\n };\n}\n"],"mappings":";;AAgBA,SAAS,eAAe,UAAmB,MAAgC;CACzE,MAAM,OAAO,QAAQ,GAAA,CAAI,YAAY;CACrC,MAAM,OAAO,YAAY,GAAA,CAAI,YAAY;CACzC,IAAI,QAAQ,cAAc,OAAO;CACjC,IAAI,QAAQ,kBAAkB,OAAO;CACrC,IAAI,IAAI,SAAS,cAAc,KAAK,QAAQ,gBAAgB,OAAO;CACnE,IAAI,QAAQ,oBAAoB,OAAO;AAEzC;AAEA,SAAS,WAAW,GAAoC;CACtD,OAAO;EACL,IAAI,EAAE;EACN,OAAO,EAAE;EACT,aAAa,EAAE;EACf,cAAc,EAAE;EAChB,aAAa,EAAE,QAAQ;EACvB,U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OAAO,CAAC,CACL,MAAM,cAAc;IACnB,IAAI,WAAW;IACf,MAAM,YAAY,SAAiC;KACjD,KAAK,MAAM,OAAO,OAAO,OAAO,KAAK,cAAc,UAAU,CAAC,CAAC,GAC7D,GAAG;MACD,IAAI,IAAI;MACR,WAAW,IAAI;MACf,aAAa,IAAI,sBAAsB,KAAK,IAAI;MAChD,KAAK;KACP,CAAC;IAEL;IACA,aAAa;IACb,UAAU,8BAA8B,QAAQ;GAClD,CAAC,CAAC,CACD,YAAY,CAAC,CAAC;GAEjB,aAAa;IACX,YAAY;IACZ,MAAM,WAAW;IACjB,IAAI,aAAa,MAAM;IACvB,aAAa;IACb,OAAO,CAAC,CACL,MAAM,cAAc;KACnB,UAAU,iCAAiC,QAAQ;IACrD,CAAC,CAAC,CACD,YAAY,CAAC,CAAC;GACnB;EACF;CACF;AACF"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,147 +1,149 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/provider.ts
|
|
2
2
|
function mapProductType(category, type) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return void 0;
|
|
3
|
+
const typ = (type ?? "").toLowerCase();
|
|
4
|
+
const cat = (category ?? "").toLowerCase();
|
|
5
|
+
if (typ === "consumable") return "consumable";
|
|
6
|
+
if (typ === "non_consumable") return "non-consumable";
|
|
7
|
+
if (typ.includes("subscription") || cat === "subscription") return "subscription";
|
|
8
|
+
if (cat === "non_subscription") return "non-consumable";
|
|
10
9
|
}
|
|
11
10
|
function mapProduct(p) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
return {
|
|
12
|
+
id: p.identifier,
|
|
13
|
+
title: p.title,
|
|
14
|
+
description: p.description,
|
|
15
|
+
priceDisplay: p.priceString,
|
|
16
|
+
priceMicros: p.price * 1e6,
|
|
17
|
+
currency: p.currencyCode,
|
|
18
|
+
type: mapProductType(p.productCategory, p.productType)
|
|
19
|
+
};
|
|
21
20
|
}
|
|
22
21
|
function mapRestoreResults(info) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
22
|
+
const results = [];
|
|
23
|
+
for (const ent of Object.values(info.entitlements?.active ?? {})) results.push({
|
|
24
|
+
status: "purchased",
|
|
25
|
+
transaction: {
|
|
26
|
+
id: ent.identifier,
|
|
27
|
+
productId: ent.productIdentifier,
|
|
28
|
+
purchasedAt: ent.purchaseDateMillis ?? Date.now(),
|
|
29
|
+
raw: ent
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
for (const tx of info.nonSubscriptionTransactions ?? []) results.push({
|
|
33
|
+
status: "purchased",
|
|
34
|
+
transaction: {
|
|
35
|
+
id: tx.transactionIdentifier,
|
|
36
|
+
productId: tx.productIdentifier,
|
|
37
|
+
purchasedAt: tx.purchaseDateMillis ?? Date.now(),
|
|
38
|
+
raw: tx
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
return results;
|
|
42
|
+
}
|
|
43
|
+
function findPurchaseTx(info, productId) {
|
|
44
|
+
const txs = info.nonSubscriptionTransactions ?? [];
|
|
45
|
+
for (let i = txs.length - 1; i >= 0; i--) if (txs[i].productIdentifier === productId) return txs[i];
|
|
47
46
|
}
|
|
48
47
|
function createRevenueCatProvider(config) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
48
|
+
let sdkCache = null;
|
|
49
|
+
let configurePromise = null;
|
|
50
|
+
async function getSDK() {
|
|
51
|
+
if (sdkCache) return sdkCache;
|
|
52
|
+
const mod = await import("react-native-purchases");
|
|
53
|
+
sdkCache = mod.default ?? mod;
|
|
54
|
+
return sdkCache;
|
|
55
|
+
}
|
|
56
|
+
async function ensureConfigured() {
|
|
57
|
+
if (configurePromise === null) configurePromise = (async () => {
|
|
58
|
+
const Purchases = await getSDK();
|
|
59
|
+
const apiKey = (await import("react-native")).Platform.OS === "ios" ? config.apiKeyIos : config.apiKeyAndroid;
|
|
60
|
+
Purchases.configure({
|
|
61
|
+
apiKey,
|
|
62
|
+
appUserID: config.appUserId ?? null
|
|
63
|
+
});
|
|
64
|
+
return Purchases;
|
|
65
|
+
})();
|
|
66
|
+
const pending = configurePromise;
|
|
67
|
+
try {
|
|
68
|
+
return await pending;
|
|
69
|
+
} catch (err) {
|
|
70
|
+
if (configurePromise === pending) configurePromise = null;
|
|
71
|
+
throw err;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
async getProducts(ids) {
|
|
76
|
+
try {
|
|
77
|
+
return (await (await ensureConfigured()).getProducts([...ids], config.productCategory)).map(mapProduct);
|
|
78
|
+
} catch (err) {
|
|
79
|
+
config.onError?.(err);
|
|
80
|
+
return [];
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
async purchase(id) {
|
|
84
|
+
try {
|
|
85
|
+
const Purchases = await ensureConfigured();
|
|
86
|
+
const product = (await Purchases.getProducts([id], config.productCategory))[0];
|
|
87
|
+
if (!product) return {
|
|
88
|
+
status: "failed",
|
|
89
|
+
error: /* @__PURE__ */ new Error(`Product not found: ${id}`)
|
|
90
|
+
};
|
|
91
|
+
const { customerInfo } = await Purchases.purchaseStoreProduct(product);
|
|
92
|
+
const tx = findPurchaseTx(customerInfo, id);
|
|
93
|
+
return {
|
|
94
|
+
status: "purchased",
|
|
95
|
+
transaction: {
|
|
96
|
+
id: tx?.transactionIdentifier ?? customerInfo.originalPurchaseDate ?? String(Date.now()),
|
|
97
|
+
productId: id,
|
|
98
|
+
purchasedAt: tx?.purchaseDateMillis ?? Date.now(),
|
|
99
|
+
raw: customerInfo
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
} catch (err) {
|
|
103
|
+
if (err !== null && typeof err === "object" && "userCancelled" in err && err.userCancelled === true) return { status: "cancelled" };
|
|
104
|
+
return {
|
|
105
|
+
status: "failed",
|
|
106
|
+
error: err instanceof Error ? err : new Error(String(err))
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
async restore() {
|
|
111
|
+
try {
|
|
112
|
+
return mapRestoreResults(await (await ensureConfigured()).restorePurchases());
|
|
113
|
+
} catch (err) {
|
|
114
|
+
config.onError?.(err);
|
|
115
|
+
return [];
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
onTransaction(cb) {
|
|
119
|
+
let cancelled = false;
|
|
120
|
+
let registered = null;
|
|
121
|
+
getSDK().then((Purchases) => {
|
|
122
|
+
if (cancelled) return;
|
|
123
|
+
const listener = (info) => {
|
|
124
|
+
for (const ent of Object.values(info.entitlements?.active ?? {})) cb({
|
|
125
|
+
id: ent.identifier,
|
|
126
|
+
productId: ent.productIdentifier,
|
|
127
|
+
purchasedAt: ent.purchaseDateMillis ?? Date.now(),
|
|
128
|
+
raw: info
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
registered = listener;
|
|
132
|
+
Purchases.addCustomerInfoUpdateListener(listener);
|
|
133
|
+
}).catch(() => {});
|
|
134
|
+
return () => {
|
|
135
|
+
cancelled = true;
|
|
136
|
+
const listener = registered;
|
|
137
|
+
if (listener === null) return;
|
|
138
|
+
registered = null;
|
|
139
|
+
getSDK().then((Purchases) => {
|
|
140
|
+
Purchases.removeCustomerInfoUpdateListener(listener);
|
|
141
|
+
}).catch(() => {});
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
};
|
|
143
145
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
146
|
+
//#endregion
|
|
147
|
+
export { createRevenueCatProvider };
|
|
148
|
+
|
|
147
149
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/provider.ts"],"sourcesContent":["import type {\n IAPProvider,\n Product,\n ProductId,\n PurchaseResult,\n Transaction,\n Unsubscribe,\n} from '@flare-engine/iap';\nimport type {\n RevenueCatConfig,\n RevenueCatCustomerInfo,\n RevenueCatPurchasesModule,\n RevenueCatStoreProduct,\n} from './types.js';\n\nfunction mapProductType(category?: string, type?: string): Product['type'] {\n const typ = (type ?? '').toLowerCase();\n const cat = (category ?? '').toLowerCase();\n if (typ === 'consumable') return 'consumable';\n if (typ === 'non_consumable') return 'non-consumable';\n if (typ.includes('subscription') || cat === 'subscription') return 'subscription';\n if (cat === 'non_subscription') return 'non-consumable';\n return undefined;\n}\n\nfunction mapProduct(p: RevenueCatStoreProduct): Product {\n return {\n id: p.identifier,\n title: p.title,\n description: p.description,\n priceDisplay: p.priceString,\n priceMicros: p.price * 1e6,\n currency: p.currencyCode,\n type: mapProductType(p.productCategory, p.productType),\n };\n}\n\nfunction mapRestoreResults(info: RevenueCatCustomerInfo): readonly PurchaseResult[] {\n const results: PurchaseResult[] = [];\n\n for (const ent of Object.values(info.entitlements?.all ?? {})) {\n results.push({\n status: 'purchased',\n transaction: {\n id: ent.identifier,\n productId: ent.productIdentifier,\n purchasedAt: ent.purchaseDateMillis ?? Date.now(),\n raw: ent,\n },\n });\n }\n\n for (const tx of info.nonSubscriptionTransactions ?? []) {\n results.push({\n status: 'purchased',\n transaction: {\n id: tx.transactionIdentifier,\n productId: tx.productIdentifier,\n purchasedAt: tx.purchaseDateMillis ?? Date.now(),\n raw: tx,\n },\n });\n }\n\n return results;\n}\n\nexport function createRevenueCatProvider(config: RevenueCatConfig): IAPProvider {\n // Per-instance cache so multiple providers are independent (and tests are isolated).\n let sdkCache: RevenueCatPurchasesModule | null = null;\n let configured = false;\n\n // Lazy-import keeps react-native-purchases off the module graph on platforms\n // (e.g., web) where it is not installed or not needed.\n async function getSDK(): Promise<RevenueCatPurchasesModule> {\n if (sdkCache) return sdkCache;\n const mod = await import('react-native-purchases');\n sdkCache = (mod.default ?? mod) as RevenueCatPurchasesModule;\n return sdkCache;\n }\n\n async function ensureConfigured(): Promise<RevenueCatPurchasesModule> {\n const Purchases = await getSDK();\n if (!configured) {\n // react-native is also lazy-loaded so this module never hard-loads on web.\n const rn = await import('react-native');\n const apiKey = rn.Platform.OS === 'ios' ? config.apiKeyIos : config.apiKeyAndroid;\n Purchases.configure({ apiKey, appUserID: config.appUserId ?? null });\n configured = true;\n }\n return Purchases;\n }\n\n return {\n async getProducts(ids: readonly ProductId[]): Promise<readonly Product[]> {\n try {\n const Purchases = await ensureConfigured();\n const raw = await Purchases.getProducts([...ids]);\n return raw.map(mapProduct);\n } catch {\n return [];\n }\n },\n\n async purchase(id: ProductId): Promise<PurchaseResult> {\n // No-throw contract: all paths return PurchaseResult rather than throw.\n try {\n const Purchases = await ensureConfigured();\n const products = await Purchases.getProducts([id]);\n const product = products[0];\n if (!product) {\n return { status: 'failed', error: new Error(`Product not found: ${id}`) };\n }\n const { customerInfo } = await Purchases.purchaseStoreProduct(product);\n return {\n status: 'purchased',\n transaction: {\n id: customerInfo.originalPurchaseDate ?? String(Date.now()),\n productId: id,\n purchasedAt: Date.now(),\n raw: customerInfo,\n },\n };\n } catch (err) {\n if (\n err !== null &&\n typeof err === 'object' &&\n 'userCancelled' in err &&\n (err as { userCancelled: unknown }).userCancelled === true\n ) {\n return { status: 'cancelled' };\n }\n return {\n status: 'failed',\n error: err instanceof Error ? err : new Error(String(err)),\n };\n }\n },\n\n async restore(): Promise<readonly PurchaseResult[]> {\n try {\n const Purchases = await ensureConfigured();\n const info = await Purchases.restorePurchases();\n return mapRestoreResults(info);\n } catch {\n return [];\n }\n },\n\n onTransaction(cb: (tx: Transaction) => void): Unsubscribe {\n let listener: ((info: RevenueCatCustomerInfo) => void) | null = null;\n\n getSDK()\n .then((Purchases) => {\n listener = (info: RevenueCatCustomerInfo) => {\n const entitlements = Object.values(info.entitlements?.all ?? {});\n const ent = entitlements[0];\n if (ent) {\n cb({\n id: ent.identifier,\n productId: ent.productIdentifier,\n purchasedAt: ent.purchaseDateMillis ?? Date.now(),\n raw: info,\n });\n }\n };\n Purchases.addCustomerInfoUpdateListener(listener);\n })\n .catch(() => {});\n\n return () => {\n if (listener !== null) {\n getSDK()\n .then((Purchases) => {\n Purchases.removeCustomerInfoUpdateListener(listener!);\n })\n .catch(() => {});\n listener = null;\n }\n };\n },\n };\n}\n"],"mappings":";AAeA,SAAS,eAAe,UAAmB,MAAgC;AACzE,QAAM,OAAO,QAAQ,IAAI,YAAY;AACrC,QAAM,OAAO,YAAY,IAAI,YAAY;AACzC,MAAI,QAAQ,aAAc,QAAO;AACjC,MAAI,QAAQ,iBAAkB,QAAO;AACrC,MAAI,IAAI,SAAS,cAAc,KAAK,QAAQ,eAAgB,QAAO;AACnE,MAAI,QAAQ,mBAAoB,QAAO;AACvC,SAAO;AACT;AAEA,SAAS,WAAW,GAAoC;AACtD,SAAO;AAAA,IACL,IAAI,EAAE;AAAA,IACN,OAAO,EAAE;AAAA,IACT,aAAa,EAAE;AAAA,IACf,cAAc,EAAE;AAAA,IAChB,aAAa,EAAE,QAAQ;AAAA,IACvB,UAAU,EAAE;AAAA,IACZ,MAAM,eAAe,EAAE,iBAAiB,EAAE,WAAW;AAAA,EACvD;AACF;AAEA,SAAS,kBAAkB,MAAyD;AAClF,QAAM,UAA4B,CAAC;AAEnC,aAAW,OAAO,OAAO,OAAO,KAAK,cAAc,OAAO,CAAC,CAAC,GAAG;AAC7D,YAAQ,KAAK;AAAA,MACX,QAAQ;AAAA,MACR,aAAa;AAAA,QACX,IAAI,IAAI;AAAA,QACR,WAAW,IAAI;AAAA,QACf,aAAa,IAAI,sBAAsB,KAAK,IAAI;AAAA,QAChD,KAAK;AAAA,MACP;AAAA,IACF,CAAC;AAAA,EACH;AAEA,aAAW,MAAM,KAAK,+BAA+B,CAAC,GAAG;AACvD,YAAQ,KAAK;AAAA,MACX,QAAQ;AAAA,MACR,aAAa;AA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AM;AAAA,UAAC,CAAC;AACjB,qBAAW;AAAA,QACb;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/provider.ts"],"sourcesContent":["import type {\n IAPProvider,\n Product,\n ProductId,\n PurchaseResult,\n Transaction,\n Unsubscribe,\n} from '@flare-engine/iap';\nimport type {\n RevenueCatConfig,\n RevenueCatCustomerInfo,\n RevenueCatNonSubscriptionTransaction,\n RevenueCatPurchasesModule,\n RevenueCatStoreProduct,\n} from './types.js';\n\nfunction mapProductType(category?: string, type?: string): Product['type'] {\n const typ = (type ?? '').toLowerCase();\n const cat = (category ?? '').toLowerCase();\n if (typ === 'consumable') return 'consumable';\n if (typ === 'non_consumable') return 'non-consumable';\n if (typ.includes('subscription') || cat === 'subscription') return 'subscription';\n if (cat === 'non_subscription') return 'non-consumable';\n return undefined;\n}\n\nfunction mapProduct(p: RevenueCatStoreProduct): Product {\n return {\n id: p.identifier,\n title: p.title,\n description: p.description,\n priceDisplay: p.priceString,\n priceMicros: p.price * 1e6,\n currency: p.currencyCode,\n type: mapProductType(p.productCategory, p.productType),\n };\n}\n\nfunction mapRestoreResults(info: RevenueCatCustomerInfo): readonly PurchaseResult[] {\n const results: PurchaseResult[] = [];\n\n for (const ent of Object.values(info.entitlements?.active ?? {})) {\n results.push({\n status: 'purchased',\n transaction: {\n id: ent.identifier,\n productId: ent.productIdentifier,\n purchasedAt: ent.purchaseDateMillis ?? Date.now(),\n raw: ent,\n },\n });\n }\n\n for (const tx of info.nonSubscriptionTransactions ?? []) {\n results.push({\n status: 'purchased',\n transaction: {\n id: tx.transactionIdentifier,\n productId: tx.productIdentifier,\n purchasedAt: tx.purchaseDateMillis ?? Date.now(),\n raw: tx,\n },\n });\n }\n\n return results;\n}\n\nfunction findPurchaseTx(\n info: RevenueCatCustomerInfo,\n productId: string,\n): RevenueCatNonSubscriptionTransaction | undefined {\n const txs = info.nonSubscriptionTransactions ?? [];\n for (let i = txs.length - 1; i >= 0; i--) {\n if (txs[i]!.productIdentifier === productId) return txs[i];\n }\n return undefined;\n}\n\nexport function createRevenueCatProvider(config: RevenueCatConfig): IAPProvider {\n // Per-instance cache so multiple providers are independent (and tests are isolated).\n let sdkCache: RevenueCatPurchasesModule | null = null;\n // Memoize the whole configure sequence, not a post-await boolean: a boolean flips\n // only after two awaits, so concurrent first callers (e.g. Promise.all([getProducts,\n // restore])) all pass the guard and double-call Purchases.configure (which RevenueCat\n // rejects). A shared promise makes configure run exactly once for all in-flight callers.\n let configurePromise: Promise<RevenueCatPurchasesModule> | null = null;\n\n // Lazy-import keeps react-native-purchases off the module graph on platforms\n // (e.g., web) where it is not installed or not needed.\n async function getSDK(): Promise<RevenueCatPurchasesModule> {\n if (sdkCache) return sdkCache;\n const mod = await import('react-native-purchases');\n sdkCache = (mod.default ?? mod) as RevenueCatPurchasesModule;\n return sdkCache;\n }\n\n async function ensureConfigured(): Promise<RevenueCatPurchasesModule> {\n if (configurePromise === null) {\n configurePromise = (async () => {\n const Purchases = await getSDK();\n // react-native is also lazy-loaded so this module never hard-loads on web.\n const rn = await import('react-native');\n const apiKey = rn.Platform.OS === 'ios' ? config.apiKeyIos : config.apiKeyAndroid;\n Purchases.configure({ apiKey, appUserID: config.appUserId ?? null });\n return Purchases;\n })();\n }\n const pending = configurePromise;\n try {\n return await pending;\n } catch (err) {\n // A failed configure must not poison every future call: clear the memo so a later\n // call retries (mirrors the old flag, which stayed false when configure threw).\n // Compare-and-clear: only null OUR attempt — a later caller may already have\n // installed a fresh promise, which must not be wiped out from under it.\n if (configurePromise === pending) configurePromise = null;\n throw err;\n }\n }\n\n return {\n async getProducts(ids: readonly ProductId[]): Promise<readonly Product[]> {\n try {\n const Purchases = await ensureConfigured();\n const raw = await Purchases.getProducts([...ids], config.productCategory);\n return raw.map(mapProduct);\n } catch (err) {\n config.onError?.(err);\n return [];\n }\n },\n\n async purchase(id: ProductId): Promise<PurchaseResult> {\n // No-throw contract: all paths return PurchaseResult rather than throw.\n try {\n const Purchases = await ensureConfigured();\n const products = await Purchases.getProducts([id], config.productCategory);\n const product = products[0];\n if (!product) {\n return { status: 'failed', error: new Error(`Product not found: ${id}`) };\n }\n const { customerInfo } = await Purchases.purchaseStoreProduct(product);\n const tx = findPurchaseTx(customerInfo, id);\n return {\n status: 'purchased',\n transaction: {\n // Prefer the store's real transaction id; the date fallback is a documented\n // best-effort only when the SDK surface exposes no transaction id (not a real id).\n id:\n tx?.transactionIdentifier ?? customerInfo.originalPurchaseDate ?? String(Date.now()),\n productId: id,\n purchasedAt: tx?.purchaseDateMillis ?? Date.now(),\n raw: customerInfo,\n },\n };\n } catch (err) {\n if (\n err !== null &&\n typeof err === 'object' &&\n 'userCancelled' in err &&\n (err as { userCancelled: unknown }).userCancelled === true\n ) {\n return { status: 'cancelled' };\n }\n return {\n status: 'failed',\n error: err instanceof Error ? err : new Error(String(err)),\n };\n }\n },\n\n async restore(): Promise<readonly PurchaseResult[]> {\n try {\n const Purchases = await ensureConfigured();\n const info = await Purchases.restorePurchases();\n return mapRestoreResults(info);\n } catch (err) {\n config.onError?.(err);\n return [];\n }\n },\n\n onTransaction(cb: (tx: Transaction) => void): Unsubscribe {\n let cancelled = false;\n let registered: ((info: RevenueCatCustomerInfo) => void) | null = null;\n\n getSDK()\n .then((Purchases) => {\n if (cancelled) return; // pre-resolution unsubscribe → never register\n const listener = (info: RevenueCatCustomerInfo) => {\n for (const ent of Object.values(info.entitlements?.active ?? {})) {\n cb({\n id: ent.identifier,\n productId: ent.productIdentifier,\n purchasedAt: ent.purchaseDateMillis ?? Date.now(),\n raw: info,\n });\n }\n };\n registered = listener;\n Purchases.addCustomerInfoUpdateListener(listener);\n })\n .catch(() => {});\n\n return () => {\n cancelled = true;\n const listener = registered;\n if (listener === null) return; // not registered yet (suppressed above) or already removed → idempotent\n registered = null;\n getSDK()\n .then((Purchases) => {\n Purchases.removeCustomerInfoUpdateListener(listener);\n })\n .catch(() => {});\n };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,KAAK;IACZ,IACE,QAAQ,QACR,OAAO,QAAQ,YACf,mBAAmB,OAClB,IAAmC,kBAAkB,MAEtD,OAAO,EAAE,QAAQ,YAAY;IAE/B,OAAO;KACL,QAAQ;KACR,OAAO,eAAe,QAAQ,MAAM,IAAI,MAAM,OAAO,GAAG,CAAC;IAC3D;GACF;EACF;EAEA,MAAM,UAA8C;GAClD,IAAI;IAGF,OAAO,kBAAkB,OADN,MADK,iBAAiB,EAAA,CACZ,iBAAiB,CACjB;GAC/B,SAAS,KAAK;IACZ,OAAO,UAAU,GAAG;IACpB,OAAO,CAAC;GACV;EACF;EAEA,cAAc,IAA4C;GACxD,IAAI,YAAY;GAChB,IAAI,aAA8D;GAElE,OAAO,CAAC,CACL,MAAM,cAAc;IACnB,IAAI,WAAW;IACf,MAAM,YAAY,SAAiC;KACjD,KAAK,MAAM,OAAO,OAAO,OAAO,KAAK,cAAc,UAAU,CAAC,CAAC,GAC7D,GAAG;MACD,IAAI,IAAI;MACR,WAAW,IAAI;MACf,aAAa,IAAI,sBAAsB,KAAK,IAAI;MAChD,KAAK;KACP,CAAC;IAEL;IACA,aAAa;IACb,UAAU,8BAA8B,QAAQ;GAClD,CAAC,CAAC,CACD,YAAY,CAAC,CAAC;GAEjB,aAAa;IACX,YAAY;IACZ,MAAM,WAAW;IACjB,IAAI,aAAa,MAAM;IACvB,aAAa;IACb,OAAO,CAAC,CACL,MAAM,cAAc;KACnB,UAAU,iCAAiC,QAAQ;IACrD,CAAC,CAAC,CACD,YAAY,CAAC,CAAC;GACnB;EACF;CACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flare-engine/iap-revenuecat",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "RevenueCat IAPProvider adapter for @flare-engine/iap",
|
|
5
5
|
"keywords": ["flare-engine", "iap", "revenuecat", "in-app-purchase", "adapter"],
|
|
6
|
-
"license": "
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
7
|
"author": "Grzegorz Otto",
|
|
8
8
|
"homepage": "https://github.com/grzott/flare-engine#readme",
|
|
9
9
|
"bugs": {
|
|
@@ -19,25 +19,33 @@
|
|
|
19
19
|
"types": "dist/index.d.ts",
|
|
20
20
|
"exports": {
|
|
21
21
|
".": {
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
"import": {
|
|
23
|
+
"types": "./dist/index.d.mts",
|
|
24
|
+
"default": "./dist/index.mjs"
|
|
25
|
+
},
|
|
26
|
+
"require": {
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"default": "./dist/index.js"
|
|
29
|
+
}
|
|
25
30
|
}
|
|
26
31
|
},
|
|
27
|
-
"files": ["dist", "README.md", "LICENSE"],
|
|
32
|
+
"files": ["dist", "README.md", "LICENSE", "NOTICE"],
|
|
28
33
|
"scripts": {
|
|
29
|
-
"build": "
|
|
34
|
+
"build": "tsdown",
|
|
30
35
|
"test": "bun test",
|
|
31
36
|
"lint": "biome check src/",
|
|
32
37
|
"typecheck": "tsc --noEmit"
|
|
33
38
|
},
|
|
34
39
|
"dependencies": {
|
|
35
|
-
"@flare-engine/iap": "^0.
|
|
40
|
+
"@flare-engine/iap": "^0.3.1"
|
|
36
41
|
},
|
|
37
42
|
"peerDependencies": {
|
|
38
|
-
"react": ">=
|
|
43
|
+
"react-native": ">=0.79.0",
|
|
39
44
|
"react-native-purchases": ">=8.0.0"
|
|
40
45
|
},
|
|
46
|
+
"engines": {
|
|
47
|
+
"node": ">=20"
|
|
48
|
+
},
|
|
41
49
|
"publishConfig": {
|
|
42
50
|
"access": "restricted",
|
|
43
51
|
"registry": "https://registry.npmjs.org/"
|