import Base64 from "crypto-js/enc-base64"; import HmacSHA256 from "crypto-js/hmac-sha256"; import sha256 from "crypto-js/sha256"; import { getUser } from "../services/context/userManager"; async function getHeaders() { // let _standalone = undefined; const platform = __PLATFORM__ as "web" | "native" | "pwa" | "pwa-standalone"; // if (typeof window !== "undefined") { // //@ts-ignore // _standalone = window?.navigator?.standalone === true; // } // if (_standalone && isIOS()) { // platform = "pwa-standalone"; // } const user = await getUser(); const authorized = !!user?.access_token; const time = Date.now(); const hashDigest = sha256(time.toString()); const sign = Base64.stringify(HmacSHA256(hashDigest, "SECRET")); return { time, sign, platform, hashDigest, user, authorized, // _standalone, }; } export { getHeaders };