@nosslabs/iap 7.0.0 → 7.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/dist/index.cjs +308 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +53 -1
- package/dist/index.d.ts +53 -1
- package/dist/index.js +308 -0
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,30 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); version
|
|
|
5
5
|
|
|
6
6
|
## [Unreleased]
|
|
7
7
|
|
|
8
|
+
## [7.1.0] — 2026-07-04
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- `iap.getStorefront(): Promise<Storefront | null>` — reads the user's App
|
|
13
|
+
Store / Google Play storefront (the country their store account is registered
|
|
14
|
+
to). Returns the new exported `Storefront` type, with `countryCode` normalized
|
|
15
|
+
to ISO 3166-1 alpha-2 across platforms (iOS reports alpha-3, Android alpha-2);
|
|
16
|
+
the raw native value is preserved on `countryCodeRaw`, plus the Apple
|
|
17
|
+
`storefrontId` (iOS only) and `platform`. Resolves `null` on web, when the
|
|
18
|
+
installed `@capgo/native-purchases` build doesn't register the native
|
|
19
|
+
`getStorefront` method, or when the storefront is unavailable (e.g. EU
|
|
20
|
+
alternative distribution). Read it live and treat it as a UX/targeting hint —
|
|
21
|
+
for compliance/entitlement decisions, trust the server-side signed storefront.
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
|
|
25
|
+
- Anchored the `7.x` line to **Capacitor 7**: peer dependencies narrowed to
|
|
26
|
+
`@capacitor/*: ^7.0.0` and `@capgo/native-purchases: ^7.16.2` (dropping the
|
|
27
|
+
`^8.0.0` allowances). The `^7.16.2` range admits the Capacitor-7 capgo build
|
|
28
|
+
that adds native `getStorefront`. Capacitor-8 support will ship in
|
|
29
|
+
`@nosslabs/iap` v8. (`getStorefront()` itself still degrades gracefully on
|
|
30
|
+
capgo builds that predate the native method.)
|
|
31
|
+
|
|
8
32
|
## [7.0.0] — 2026-05-14
|
|
9
33
|
|
|
10
34
|
**GA of the Capacitor 7+ line.** `@latest` on npm moves from `5.0.0`
|
package/dist/index.cjs
CHANGED
|
@@ -139,11 +139,293 @@ var init_platform = __esm({
|
|
|
139
139
|
}
|
|
140
140
|
});
|
|
141
141
|
|
|
142
|
+
// src/lib/iso-country.ts
|
|
143
|
+
function toAlpha2(code) {
|
|
144
|
+
if (!code) return null;
|
|
145
|
+
const normalized = code.trim().toUpperCase();
|
|
146
|
+
if (normalized.length === 2) return normalized;
|
|
147
|
+
if (normalized.length === 3) return ALPHA3_TO_ALPHA2[normalized] ?? null;
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
var ALPHA3_TO_ALPHA2;
|
|
151
|
+
var init_iso_country = __esm({
|
|
152
|
+
"src/lib/iso-country.ts"() {
|
|
153
|
+
ALPHA3_TO_ALPHA2 = {
|
|
154
|
+
ABW: "AW",
|
|
155
|
+
AFG: "AF",
|
|
156
|
+
AGO: "AO",
|
|
157
|
+
AIA: "AI",
|
|
158
|
+
ALA: "AX",
|
|
159
|
+
ALB: "AL",
|
|
160
|
+
AND: "AD",
|
|
161
|
+
ARE: "AE",
|
|
162
|
+
ARG: "AR",
|
|
163
|
+
ARM: "AM",
|
|
164
|
+
ASM: "AS",
|
|
165
|
+
ATA: "AQ",
|
|
166
|
+
ATF: "TF",
|
|
167
|
+
ATG: "AG",
|
|
168
|
+
AUS: "AU",
|
|
169
|
+
AUT: "AT",
|
|
170
|
+
AZE: "AZ",
|
|
171
|
+
BDI: "BI",
|
|
172
|
+
BEL: "BE",
|
|
173
|
+
BEN: "BJ",
|
|
174
|
+
BES: "BQ",
|
|
175
|
+
BFA: "BF",
|
|
176
|
+
BGD: "BD",
|
|
177
|
+
BGR: "BG",
|
|
178
|
+
BHR: "BH",
|
|
179
|
+
BHS: "BS",
|
|
180
|
+
BIH: "BA",
|
|
181
|
+
BLM: "BL",
|
|
182
|
+
BLR: "BY",
|
|
183
|
+
BLZ: "BZ",
|
|
184
|
+
BMU: "BM",
|
|
185
|
+
BOL: "BO",
|
|
186
|
+
BRA: "BR",
|
|
187
|
+
BRB: "BB",
|
|
188
|
+
BRN: "BN",
|
|
189
|
+
BTN: "BT",
|
|
190
|
+
BVT: "BV",
|
|
191
|
+
BWA: "BW",
|
|
192
|
+
CAF: "CF",
|
|
193
|
+
CAN: "CA",
|
|
194
|
+
CCK: "CC",
|
|
195
|
+
CHE: "CH",
|
|
196
|
+
CHL: "CL",
|
|
197
|
+
CHN: "CN",
|
|
198
|
+
CIV: "CI",
|
|
199
|
+
CMR: "CM",
|
|
200
|
+
COD: "CD",
|
|
201
|
+
COG: "CG",
|
|
202
|
+
COK: "CK",
|
|
203
|
+
COL: "CO",
|
|
204
|
+
COM: "KM",
|
|
205
|
+
CPV: "CV",
|
|
206
|
+
CRI: "CR",
|
|
207
|
+
CUB: "CU",
|
|
208
|
+
CUW: "CW",
|
|
209
|
+
CXR: "CX",
|
|
210
|
+
CYM: "KY",
|
|
211
|
+
CYP: "CY",
|
|
212
|
+
CZE: "CZ",
|
|
213
|
+
DEU: "DE",
|
|
214
|
+
DJI: "DJ",
|
|
215
|
+
DMA: "DM",
|
|
216
|
+
DNK: "DK",
|
|
217
|
+
DOM: "DO",
|
|
218
|
+
DZA: "DZ",
|
|
219
|
+
ECU: "EC",
|
|
220
|
+
EGY: "EG",
|
|
221
|
+
ERI: "ER",
|
|
222
|
+
ESH: "EH",
|
|
223
|
+
ESP: "ES",
|
|
224
|
+
EST: "EE",
|
|
225
|
+
ETH: "ET",
|
|
226
|
+
FIN: "FI",
|
|
227
|
+
FJI: "FJ",
|
|
228
|
+
FLK: "FK",
|
|
229
|
+
FRA: "FR",
|
|
230
|
+
FRO: "FO",
|
|
231
|
+
FSM: "FM",
|
|
232
|
+
GAB: "GA",
|
|
233
|
+
GBR: "GB",
|
|
234
|
+
GEO: "GE",
|
|
235
|
+
GGY: "GG",
|
|
236
|
+
GHA: "GH",
|
|
237
|
+
GIB: "GI",
|
|
238
|
+
GIN: "GN",
|
|
239
|
+
GLP: "GP",
|
|
240
|
+
GMB: "GM",
|
|
241
|
+
GNB: "GW",
|
|
242
|
+
GNQ: "GQ",
|
|
243
|
+
GRC: "GR",
|
|
244
|
+
GRD: "GD",
|
|
245
|
+
GRL: "GL",
|
|
246
|
+
GTM: "GT",
|
|
247
|
+
GUF: "GF",
|
|
248
|
+
GUM: "GU",
|
|
249
|
+
GUY: "GY",
|
|
250
|
+
HKG: "HK",
|
|
251
|
+
HMD: "HM",
|
|
252
|
+
HND: "HN",
|
|
253
|
+
HRV: "HR",
|
|
254
|
+
HTI: "HT",
|
|
255
|
+
HUN: "HU",
|
|
256
|
+
IDN: "ID",
|
|
257
|
+
IMN: "IM",
|
|
258
|
+
IND: "IN",
|
|
259
|
+
IOT: "IO",
|
|
260
|
+
IRL: "IE",
|
|
261
|
+
IRN: "IR",
|
|
262
|
+
IRQ: "IQ",
|
|
263
|
+
ISL: "IS",
|
|
264
|
+
ISR: "IL",
|
|
265
|
+
ITA: "IT",
|
|
266
|
+
JAM: "JM",
|
|
267
|
+
JEY: "JE",
|
|
268
|
+
JOR: "JO",
|
|
269
|
+
JPN: "JP",
|
|
270
|
+
KAZ: "KZ",
|
|
271
|
+
KEN: "KE",
|
|
272
|
+
KGZ: "KG",
|
|
273
|
+
KHM: "KH",
|
|
274
|
+
KIR: "KI",
|
|
275
|
+
KNA: "KN",
|
|
276
|
+
KOR: "KR",
|
|
277
|
+
KWT: "KW",
|
|
278
|
+
LAO: "LA",
|
|
279
|
+
LBN: "LB",
|
|
280
|
+
LBR: "LR",
|
|
281
|
+
LBY: "LY",
|
|
282
|
+
LCA: "LC",
|
|
283
|
+
LIE: "LI",
|
|
284
|
+
LKA: "LK",
|
|
285
|
+
LSO: "LS",
|
|
286
|
+
LTU: "LT",
|
|
287
|
+
LUX: "LU",
|
|
288
|
+
LVA: "LV",
|
|
289
|
+
MAC: "MO",
|
|
290
|
+
MAF: "MF",
|
|
291
|
+
MAR: "MA",
|
|
292
|
+
MCO: "MC",
|
|
293
|
+
MDA: "MD",
|
|
294
|
+
MDG: "MG",
|
|
295
|
+
MDV: "MV",
|
|
296
|
+
MEX: "MX",
|
|
297
|
+
MHL: "MH",
|
|
298
|
+
MKD: "MK",
|
|
299
|
+
MLI: "ML",
|
|
300
|
+
MLT: "MT",
|
|
301
|
+
MMR: "MM",
|
|
302
|
+
MNE: "ME",
|
|
303
|
+
MNG: "MN",
|
|
304
|
+
MNP: "MP",
|
|
305
|
+
MOZ: "MZ",
|
|
306
|
+
MRT: "MR",
|
|
307
|
+
MSR: "MS",
|
|
308
|
+
MTQ: "MQ",
|
|
309
|
+
MUS: "MU",
|
|
310
|
+
MWI: "MW",
|
|
311
|
+
MYS: "MY",
|
|
312
|
+
MYT: "YT",
|
|
313
|
+
NAM: "NA",
|
|
314
|
+
NCL: "NC",
|
|
315
|
+
NER: "NE",
|
|
316
|
+
NFK: "NF",
|
|
317
|
+
NGA: "NG",
|
|
318
|
+
NIC: "NI",
|
|
319
|
+
NIU: "NU",
|
|
320
|
+
NLD: "NL",
|
|
321
|
+
NOR: "NO",
|
|
322
|
+
NPL: "NP",
|
|
323
|
+
NRU: "NR",
|
|
324
|
+
NZL: "NZ",
|
|
325
|
+
OMN: "OM",
|
|
326
|
+
PAK: "PK",
|
|
327
|
+
PAN: "PA",
|
|
328
|
+
PCN: "PN",
|
|
329
|
+
PER: "PE",
|
|
330
|
+
PHL: "PH",
|
|
331
|
+
PLW: "PW",
|
|
332
|
+
PNG: "PG",
|
|
333
|
+
POL: "PL",
|
|
334
|
+
PRI: "PR",
|
|
335
|
+
PRK: "KP",
|
|
336
|
+
PRT: "PT",
|
|
337
|
+
PRY: "PY",
|
|
338
|
+
PSE: "PS",
|
|
339
|
+
PYF: "PF",
|
|
340
|
+
QAT: "QA",
|
|
341
|
+
REU: "RE",
|
|
342
|
+
ROU: "RO",
|
|
343
|
+
RUS: "RU",
|
|
344
|
+
RWA: "RW",
|
|
345
|
+
SAU: "SA",
|
|
346
|
+
SDN: "SD",
|
|
347
|
+
SEN: "SN",
|
|
348
|
+
SGP: "SG",
|
|
349
|
+
SGS: "GS",
|
|
350
|
+
SHN: "SH",
|
|
351
|
+
SJM: "SJ",
|
|
352
|
+
SLB: "SB",
|
|
353
|
+
SLE: "SL",
|
|
354
|
+
SLV: "SV",
|
|
355
|
+
SMR: "SM",
|
|
356
|
+
SOM: "SO",
|
|
357
|
+
SPM: "PM",
|
|
358
|
+
SRB: "RS",
|
|
359
|
+
SSD: "SS",
|
|
360
|
+
STP: "ST",
|
|
361
|
+
SUR: "SR",
|
|
362
|
+
SVK: "SK",
|
|
363
|
+
SVN: "SI",
|
|
364
|
+
SWE: "SE",
|
|
365
|
+
SWZ: "SZ",
|
|
366
|
+
SXM: "SX",
|
|
367
|
+
SYC: "SC",
|
|
368
|
+
SYR: "SY",
|
|
369
|
+
TCA: "TC",
|
|
370
|
+
TCD: "TD",
|
|
371
|
+
TGO: "TG",
|
|
372
|
+
THA: "TH",
|
|
373
|
+
TJK: "TJ",
|
|
374
|
+
TKL: "TK",
|
|
375
|
+
TKM: "TM",
|
|
376
|
+
TLS: "TL",
|
|
377
|
+
TON: "TO",
|
|
378
|
+
TTO: "TT",
|
|
379
|
+
TUN: "TN",
|
|
380
|
+
TUR: "TR",
|
|
381
|
+
TUV: "TV",
|
|
382
|
+
TWN: "TW",
|
|
383
|
+
TZA: "TZ",
|
|
384
|
+
UGA: "UG",
|
|
385
|
+
UKR: "UA",
|
|
386
|
+
UMI: "UM",
|
|
387
|
+
URY: "UY",
|
|
388
|
+
USA: "US",
|
|
389
|
+
UZB: "UZ",
|
|
390
|
+
VAT: "VA",
|
|
391
|
+
VCT: "VC",
|
|
392
|
+
VEN: "VE",
|
|
393
|
+
VGB: "VG",
|
|
394
|
+
VIR: "VI",
|
|
395
|
+
VNM: "VN",
|
|
396
|
+
VUT: "VU",
|
|
397
|
+
WLF: "WF",
|
|
398
|
+
WSM: "WS",
|
|
399
|
+
YEM: "YE",
|
|
400
|
+
ZAF: "ZA",
|
|
401
|
+
ZMB: "ZM",
|
|
402
|
+
ZWE: "ZW"
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
});
|
|
406
|
+
|
|
142
407
|
// src/adapters/native/capgo/native-adapter.ts
|
|
143
408
|
var native_adapter_exports = {};
|
|
144
409
|
__export(native_adapter_exports, {
|
|
145
410
|
CapgoNativeAdapter: () => CapgoNativeAdapter
|
|
146
411
|
});
|
|
412
|
+
function nativeStorefrontRegistered() {
|
|
413
|
+
const headers = core.Capacitor.PluginHeaders;
|
|
414
|
+
return headers?.find((h) => h.name === "NativePurchases")?.methods?.some((m) => m.name === "getStorefront") ?? false;
|
|
415
|
+
}
|
|
416
|
+
function normalizeStorefront(raw) {
|
|
417
|
+
const code = raw?.countryCode?.trim();
|
|
418
|
+
if (!code) return null;
|
|
419
|
+
const platform = getPlatform() === "android" ? "google" : "apple";
|
|
420
|
+
return {
|
|
421
|
+
// alpha-2 when recognized; otherwise the uppercased raw code as a
|
|
422
|
+
// best-effort fallback (see `Storefront.countryCode`).
|
|
423
|
+
countryCode: toAlpha2(code) ?? code.toUpperCase(),
|
|
424
|
+
countryCodeRaw: code,
|
|
425
|
+
storefrontId: raw.storefrontId,
|
|
426
|
+
platform
|
|
427
|
+
};
|
|
428
|
+
}
|
|
147
429
|
function normalizeProduct(p, type) {
|
|
148
430
|
const priceMicros = Math.round(p.price * 1e6).toString();
|
|
149
431
|
return {
|
|
@@ -219,6 +501,7 @@ var CapgoNativeAdapter;
|
|
|
219
501
|
var init_native_adapter = __esm({
|
|
220
502
|
"src/adapters/native/capgo/native-adapter.ts"() {
|
|
221
503
|
init_errors();
|
|
504
|
+
init_iso_country();
|
|
222
505
|
init_platform();
|
|
223
506
|
CapgoNativeAdapter = class {
|
|
224
507
|
async isAvailable() {
|
|
@@ -302,6 +585,24 @@ var init_native_adapter = __esm({
|
|
|
302
585
|
});
|
|
303
586
|
}
|
|
304
587
|
}
|
|
588
|
+
/**
|
|
589
|
+
* Read the current storefront from the native plugin — which is expected to
|
|
590
|
+
* source it from StoreKit 2 `Storefront.current` on iOS (alpha-3) and
|
|
591
|
+
* `getBillingConfigAsync()` on Android (alpha-2) — normalizing `countryCode`
|
|
592
|
+
* to alpha-2. Silent like {@link CapgoNativeAdapter.isAvailable}: any
|
|
593
|
+
* unavailability — older plugin (no native method registered), native
|
|
594
|
+
* rejection, or empty country — resolves to `null` rather than throwing.
|
|
595
|
+
*/
|
|
596
|
+
async getStorefront() {
|
|
597
|
+
if (!nativeStorefrontRegistered()) return null;
|
|
598
|
+
const np = nativePurchases.NativePurchases;
|
|
599
|
+
try {
|
|
600
|
+
const raw = await np.getStorefront?.();
|
|
601
|
+
return raw ? normalizeStorefront(raw) : null;
|
|
602
|
+
} catch {
|
|
603
|
+
return null;
|
|
604
|
+
}
|
|
605
|
+
}
|
|
305
606
|
async dispose() {
|
|
306
607
|
}
|
|
307
608
|
};
|
|
@@ -832,6 +1133,9 @@ var WebStubAdapter = class {
|
|
|
832
1133
|
message: "Subscription management is not supported on the web platform."
|
|
833
1134
|
});
|
|
834
1135
|
}
|
|
1136
|
+
async getStorefront() {
|
|
1137
|
+
return null;
|
|
1138
|
+
}
|
|
835
1139
|
};
|
|
836
1140
|
|
|
837
1141
|
// src/adapters/native/index.ts
|
|
@@ -1933,6 +2237,10 @@ function createIAP(input) {
|
|
|
1933
2237
|
}
|
|
1934
2238
|
return state.adapter.getProducts(state.products.map((p) => ({ id: p.id, type: p.type })));
|
|
1935
2239
|
},
|
|
2240
|
+
async getStorefront() {
|
|
2241
|
+
requireInitialized(state);
|
|
2242
|
+
return state.adapter?.getStorefront?.() ?? null;
|
|
2243
|
+
},
|
|
1936
2244
|
hasEntitlement(key) {
|
|
1937
2245
|
return state.entitlements.some((e) => e.key === key);
|
|
1938
2246
|
},
|