Files
discord-decomp/utils/PurchaseTokenUtils.tsx
T
2026-11-01 12:12:55 +02:00

40 lines
1.2 KiB
TypeScript

// Metro module 4518 (f4519).
import Durations from "./Durations";
import { Storage } from "../_bundle/Module595";
import { v4 } from "../_bundle/Module514";
import { HermesBuiltin } from "../_hermes/prelude";
let c2726_3, c2726_4;
const getPurchaseToken = function getPurchaseToken() {
const r13 = Storage.get(c2726_3);
if (r13 != null && r13.expires >= Date.now()) {
return r13.purchaseToken;
}
const purchaseToken = v4();
Storage.set(c2726_3, {
purchaseToken,
expires: Date.now() + c2726_4
});
return purchaseToken;
};
c2726_3 = "purchase_token";
c2726_4 = 60 * Durations.Millis.DAY;
export { getPurchaseToken };
export async function getPurchaseTokenHash() {
let c25234_0;
let env29402;
const r10 = env29402 = {};
let c25234_1 = r10;
env29402[0] = void 0;
env29402[0] = await window.crypto.subtle.digest({
name: "SHA-256"
}, new Uint8Array(getPurchaseToken().split("").map((item) => item.charCodeAt(0))));
const r58 = btoa;
const r59 = String;
const fromCharCode = r59.fromCharCode;
c25234_0 = 0;
const uint8Array = new Uint8Array(env29402[0]);
const r66 = [];
c25234_0 = HermesBuiltin.arraySpread(r66, uint8Array, c25234_0);
return r58(fromCharCode.apply(r59, r66));
}