@idosgames/core 0.21.1 → 0.21.3
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 +62 -0
- package/dist/{RealtimeSession-BUWeAEQT.d.ts → RealtimeSession-C5VICo95.d.ts} +211 -170
- package/dist/{RealtimeSession-DYW2tJ1g.d.cts → RealtimeSession-wV_8qMas.d.cts} +211 -170
- package/dist/chunk-CS7ACWDY.js +1 -0
- package/dist/chunk-YEBYHDZG.js +2 -0
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +16 -4
- package/dist/index.d.ts +16 -4
- package/dist/index.js +2 -2
- package/dist/platform/index.cjs +2 -2
- package/dist/platform/index.d.cts +55 -1
- package/dist/platform/index.d.ts +55 -1
- package/dist/platform/index.js +1 -1
- package/dist/realtime/index.cjs +1 -1
- package/dist/realtime/index.d.cts +2 -2
- package/dist/realtime/index.d.ts +2 -2
- package/dist/realtime/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-76ZM4DUB.js +0 -1
- package/dist/chunk-DE75YD5H.js +0 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function o(e){return {ok:true,data:e}}function t(e,r){return {ok:false,reason:e,error:r}}var n=t("unauthorized","Not logged in.");function a(e){return e.ok}function i(e){return !e.ok}export{o as a,t as b,n as c,a as d,i as e};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var i=class{getString(e){if(typeof localStorage>"u")return null;try{return localStorage.getItem(e)}catch{return null}}setString(e,r){if(!(typeof localStorage>"u"))try{localStorage.setItem(e,r);}catch{}}remove(e){if(!(typeof localStorage>"u"))try{localStorage.removeItem(e);}catch{}}},s=class{map=new Map;getString(e){return this.map.get(e)??null}setString(e,r){this.map.set(e,r);}remove(e){this.map.delete(e);}};function n(){return globalThis.Telegram?.WebApp??null}function I(){return crypto.randomUUID()}var S="idos_device_id",m=class{storage;constructor(e=new i){this.storage=e;}getPlatform(){return n()?.platform??"Web"}getFullURL(){return typeof location<"u"?location.href:""}getStartParameter(){let e=n()?.initDataUnsafe?.start_param;return typeof e=="string"?e:null}getReferrer(){if(typeof document>"u")return null;let e=document.referrer;return e&&e.length>0?e:null}getTelegramInitDataRaw(){let e=n()?.initData;return e&&e.length>0?e:null}getDeviceID(){let e=this.storage.getString(S);return e||(e=I(),this.storage.setString(S,e)),e}getDeviceModel(){return typeof navigator<"u"&&navigator.userAgent?navigator.userAgent:"Web"}shareLink(e){let r=n();if(r?.openTelegramLink){r.openTelegramLink(e);return}typeof window<"u"&&window.open(e,"_blank");}openInvoice(e){let r=n();if(r?.openInvoice){r.openInvoice(e);return}typeof window<"u"&&window.open(e,"_blank");}async showAd(e){let r=globalThis;typeof r.showAd=="function"&&await r.showAd(e);}async copyToClipboard(e){typeof navigator<"u"&&navigator.clipboard&&await navigator.clipboard.writeText(e);}};var _="idos_device_id",d=class{storage;constructor(e=new s){this.storage=e;}getPlatform(){return "Web"}getFullURL(){return ""}getStartParameter(){return null}getTelegramInitDataRaw(){return null}getDeviceID(){let e=this.storage.getString(_);return e||(e="noop-device",this.storage.setString(_,e)),e}getDeviceModel(){return "Noop"}shareLink(){}openInvoice(){}async showAd(){}async copyToClipboard(){}};var g=["https://idosgames.com","https://www.idosgames.com"];function v(t){return t==="localhost"||t==="127.0.0.1"||t==="[::1]"||t.endsWith(".localhost")}function p(t){if(g.includes(t))return true;if(typeof window>"u"||!v(window.location.hostname))return false;try{return v(new URL(t).hostname)}catch{return false}}var R="IDOS_PLATFORM_WALLET_ACK",U="PLATFORM_WALLET_UNAVAILABLE",h=5e3,E=18e4;function M(){let t=[...g],e=window.location.ancestorOrigins?.[0];return e&&!t.includes(e)&&p(e)&&t.push(e),t}function x(){return `wallet-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function c(t,e,r,D={}){let u={ok:false,error:U,data:{}};if(typeof window>"u"||window.self===window.top)return Promise.resolve(u);let P=window.parent;if(!P)return Promise.resolve(u);let T=x(),L=D.answerTimeoutMs??E;return new Promise(O=>{let A=false,l,f=a=>{A||(A=true,window.removeEventListener("message",y),clearTimeout(l),O(a));},y=a=>{if(!p(a.origin))return;let o=a.data;if(!(!o||o.requestId!==T)){if(o.type===R){clearTimeout(l),l=setTimeout(()=>f({ok:false,error:"TIMEOUT",data:{}}),L);return}o.type===e&&f({ok:o.ok===true,error:typeof o.error=="string"?o.error:void 0,data:o});}};l=setTimeout(()=>f(u),h),window.addEventListener("message",y);for(let a of M())try{P.postMessage({type:t,requestId:T,...r},a);}catch{}})}var w={request:"IDOS_PLATFORM_TOPUP_REQUEST",response:"IDOS_PLATFORM_TOPUP_RESPONSE"},k=15*6e4,b=/^[a-z0-9]{8}-preview\.idos\.games$/;function W(){if(typeof window>"u")return false;try{if(window.self===window.top||window.parent!==window.top)return !1}catch{return false}return !b.test(window.location.hostname.toLowerCase())}async function F(t){let e=await c(w.request,w.response,{titleID:t.titleID,userID:t.userID,currencyID:t.currencyID,amount:t.amount},{answerTimeoutMs:k});return e.ok?{ok:true}:{ok:false,error:e.error}}
|
|
2
|
+
export{i as a,s as b,n as c,I as d,m as e,g as f,p as g,R as h,U as i,c as j,w as k,W as l,F as m,d as n};
|