Files
discord-decomp/_bundle/fetchJsonOrThrow.js
T
2026-11-01 12:12:55 +02:00

123 lines
3.6 KiB
JavaScript

// Metro module 6344 (f6345).
import { NativeModules, Linking } from "react-native";
import { getIosModule, isIosStorekit2 } from "./Module6336";
let fetchJsonOrThrow, requestAgnosticReceiptValidationIos;
let c4046_0;
let c4047_0;
let c4048_0;
let c4049_0;
let c4050_0;
let env4044 = {};
const RNIapIos = NativeModules.RNIapIos;
let c4045_0 = async () => getIosModule().getPendingTransactions();
c4046_0 = void 0;
c4046_0 = async (c25820_0) => {
let r49;
let c25820_1, c25820_3;
c25820_3 = void 0;
let c29749_0 = c25820_0.forceRefresh;
await void 0;
if (isIosStorekit2()) {
r49 = Promise.reject("Only available on Sk1");
} else {
c25820_1 = c29749_0;
if (c29749_0 == null) {
c25820_1 = false;
}
r49 = RNIapIos.requestReceipt(c25820_1);
}
return r49;
};
c4047_0 = void 0;
c4047_0 = async () => getIosModule().presentCodeRedemptionSheet();
c4048_0 = void 0;
c4048_0 = async (c25822_0, c25822_1) => {
let c29750_0 = await fetch(c25822_0, {
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/json"
},
body: JSON.stringify(c25822_1)
});
if (!c29750_0.ok) {
throw Object.assign(new Error(c29750_0.statusText), {
statusCode: c29750_0.status
});
}
return c29750_0.json();
};
fetchJsonOrThrow = function fetchJsonOrThrow(a0, a1) {
const apply = c4048_0.apply;
return c4048_0.apply(this, arguments);
};
c4049_0 = void 0;
c4049_0 = async (c25823_0) => {
let r45, r70;
let c25823_2;
let c29751_0, c29751_1;
L15: {
L13: {
c25823_2 = void 0;
c29751_0 = c25823_0;
c29751_1 = void 0;
c29751_1 = await fetchJsonOrThrow("https://buy.itunes.apple.com/verifyReceipt", c25823_0);
if (c29751_1 && c29751_1.status === 21007) {
r70 = await (0, fetchJsonOrThrow)("https://sandbox.itunes.apple.com/verifyReceipt", c29751_0);
break L13;
}
r45 = c29751_1;
break L15;
}
return r70;
}
return r45;
};
requestAgnosticReceiptValidationIos = function requestAgnosticReceiptValidationIos(a0) {
const apply = c4049_0.apply;
return c4049_0.apply(this, arguments);
};
c4050_0 = void 0;
c4050_0 = async (c25824_0) => {
let r81;
let c25824_2;
let c29752_0, c29752_1, c29752_2;
L16: {
c25824_2 = void 0;
c29752_0 = void 0;
c29752_1 = void 0;
c29752_0 = c25824_0.receiptBody;
c29752_1 = c25824_0.isTest;
c29752_2 = void 0;
await void 0;
if (c29752_1 == null) {
r81 = await (0, requestAgnosticReceiptValidationIos)(c29752_0);
break L16;
}
c29752_2 = c29752_1 ? "https://sandbox.itunes.apple.com/verifyReceipt" : "https://buy.itunes.apple.com/verifyReceipt";
return await (0, fetchJsonOrThrow)(c29752_2, c29752_0);
}
return r81;
};
export function getPendingPurchasesIOS() {
const apply = c4045_0.apply;
return c4045_0.apply(this, arguments);
}
export function getReceiptIOS(a0) {
const apply = c4046_0.apply;
return c4046_0.apply(this, arguments);
}
export function presentCodeRedemptionSheetIOS() {
const apply = c4047_0.apply;
return c4047_0.apply(this, arguments);
}
export const getPromotedProductIOS = () => isIosStorekit2() ? Promise.reject("Only available on Sk1") : RNIapIos.promotedProduct();
export const buyPromotedProductIOS = () => getIosModule().buyPromotedProduct();
export function validateReceiptIos(a0) {
const apply = c4050_0.apply;
return c4050_0.apply(this, arguments);
}
export const clearTransactionIOS = () => getIosModule().clearTransaction();
export const clearProductsIOS = () => getIosModule().clearProducts();
export const deepLinkToSubscriptionsIos = () => Linking.openURL("https://apps.apple.com/account/subscriptions");