@idosgames/core 0.16.0 → 0.17.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.
@@ -1 +1,2 @@
1
- 'use strict';var n=class{getString(e){if(typeof localStorage>"u")return null;try{return localStorage.getItem(e)}catch{return null}}setString(e,t){if(!(typeof localStorage>"u"))try{localStorage.setItem(e,t);}catch{}}remove(e){if(!(typeof localStorage>"u"))try{localStorage.removeItem(e);}catch{}}},o=class{map=new Map;getString(e){return this.map.get(e)??null}setString(e,t){this.map.set(e,t);}remove(e){this.map.delete(e);}};function r(){return globalThis.Telegram?.WebApp??null}function l(){return crypto.randomUUID()}var s="idos_device_id",i=class{storage;constructor(e=new n){this.storage=e;}getPlatform(){return r()?.platform??"Web"}getFullURL(){return typeof location<"u"?location.href:""}getStartParameter(){let e=r()?.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=r()?.initData;return e&&e.length>0?e:null}getDeviceID(){let e=this.storage.getString(s);return e||(e=l(),this.storage.setString(s,e)),e}getDeviceModel(){return typeof navigator<"u"&&navigator.userAgent?navigator.userAgent:"Web"}shareLink(e){let t=r();if(t?.openTelegramLink){t.openTelegramLink(e);return}typeof window<"u"&&window.open(e,"_blank");}openInvoice(e){let t=r();if(t?.openInvoice){t.openInvoice(e);return}typeof window<"u"&&window.open(e,"_blank");}async showAd(e){let t=globalThis;typeof t.showAd=="function"&&await t.showAd(e);}async copyToClipboard(e){typeof navigator<"u"&&navigator.clipboard&&await navigator.clipboard.writeText(e);}};var p="idos_device_id",g=class{storage;constructor(e=new o){this.storage=e;}getPlatform(){return "Web"}getFullURL(){return ""}getStartParameter(){return null}getTelegramInitDataRaw(){return null}getDeviceID(){let e=this.storage.getString(p);return e||(e="noop-device",this.storage.setString(p,e)),e}getDeviceModel(){return "Noop"}shareLink(){}openInvoice(){}async showAd(){}async copyToClipboard(){}};exports.BrowserPlatformAdapter=i;exports.BrowserStorage=n;exports.MemoryStorage=o;exports.NoopPlatformAdapter=g;exports.getTelegramWebApp=r;
1
+ 'use strict';var o=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{}}},a=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 s(){return crypto.randomUUID()}var g="idos_device_id",i=class{storage;constructor(e=new o){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(g);return e||(e=s(),this.storage.setString(g,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 p="idos_device_id",l=class{storage;constructor(e=new a){this.storage=e;}getPlatform(){return "Web"}getFullURL(){return ""}getStartParameter(){return null}getTelegramInitDataRaw(){return null}getDeviceID(){let e=this.storage.getString(p);return e||(e="noop-device",this.storage.setString(p,e)),e}getDeviceModel(){return "Noop"}shareLink(){}openInvoice(){}async showAd(){}async copyToClipboard(){}};var u=["https://idosgames.com","https://www.idosgames.com"];function m(t){return t==="localhost"||t==="127.0.0.1"||t==="[::1]"||t.endsWith(".localhost")}function f(t){if(u.includes(t))return true;if(typeof window>"u"||!m(window.location.hostname))return false;try{return m(new URL(t).hostname)}catch{return false}}
2
+ exports.BrowserPlatformAdapter=i;exports.BrowserStorage=o;exports.MemoryStorage=a;exports.NoopPlatformAdapter=l;exports.PLATFORM_ORIGINS=u;exports.getTelegramWebApp=n;exports.isPlatformParentOrigin=f;
@@ -91,4 +91,19 @@ interface TelegramWebApp {
91
91
  }
92
92
  declare function getTelegramWebApp(): TelegramWebApp | null;
93
93
 
94
- export { BrowserPlatformAdapter, BrowserStorage, type KeyValueStorage, MemoryStorage, NoopPlatformAdapter, type PlatformAdapter, type TelegramInitDataUnsafe, type TelegramWebApp, getTelegramWebApp };
94
+ declare const PLATFORM_ORIGINS: readonly string[];
95
+ /**
96
+ * Is `origin` the platform page that framed us — including the local stand?
97
+ *
98
+ * The local allowance is deliberately symmetric: a localhost parent is accepted ONLY while this
99
+ * game is itself served from localhost. A shipped build lives on `{id}.idos.games`, so it answers
100
+ * nothing but the real site — a page on the player's own machine cannot ask it for anything.
101
+ * That is what makes the allowance safe enough to ship, instead of a build-time flag that has to
102
+ * survive four bundlers.
103
+ *
104
+ * Use this for bridges a game exposes to its parent. A bridge that must NOT widen its existing
105
+ * behaviour (the wallet's) keeps checking {@link PLATFORM_ORIGINS} directly.
106
+ */
107
+ declare function isPlatformParentOrigin(origin: string): boolean;
108
+
109
+ export { BrowserPlatformAdapter, BrowserStorage, type KeyValueStorage, MemoryStorage, NoopPlatformAdapter, PLATFORM_ORIGINS, type PlatformAdapter, type TelegramInitDataUnsafe, type TelegramWebApp, getTelegramWebApp, isPlatformParentOrigin };
@@ -91,4 +91,19 @@ interface TelegramWebApp {
91
91
  }
92
92
  declare function getTelegramWebApp(): TelegramWebApp | null;
93
93
 
94
- export { BrowserPlatformAdapter, BrowserStorage, type KeyValueStorage, MemoryStorage, NoopPlatformAdapter, type PlatformAdapter, type TelegramInitDataUnsafe, type TelegramWebApp, getTelegramWebApp };
94
+ declare const PLATFORM_ORIGINS: readonly string[];
95
+ /**
96
+ * Is `origin` the platform page that framed us — including the local stand?
97
+ *
98
+ * The local allowance is deliberately symmetric: a localhost parent is accepted ONLY while this
99
+ * game is itself served from localhost. A shipped build lives on `{id}.idos.games`, so it answers
100
+ * nothing but the real site — a page on the player's own machine cannot ask it for anything.
101
+ * That is what makes the allowance safe enough to ship, instead of a build-time flag that has to
102
+ * survive four bundlers.
103
+ *
104
+ * Use this for bridges a game exposes to its parent. A bridge that must NOT widen its existing
105
+ * behaviour (the wallet's) keeps checking {@link PLATFORM_ORIGINS} directly.
106
+ */
107
+ declare function isPlatformParentOrigin(origin: string): boolean;
108
+
109
+ export { BrowserPlatformAdapter, BrowserStorage, type KeyValueStorage, MemoryStorage, NoopPlatformAdapter, PLATFORM_ORIGINS, type PlatformAdapter, type TelegramInitDataUnsafe, type TelegramWebApp, getTelegramWebApp, isPlatformParentOrigin };
@@ -1 +1 @@
1
- export{e as BrowserPlatformAdapter,a as BrowserStorage,b as MemoryStorage,f as NoopPlatformAdapter,c as getTelegramWebApp}from'../chunk-MEUEUF7D.js';
1
+ export{e as BrowserPlatformAdapter,a as BrowserStorage,b as MemoryStorage,h as NoopPlatformAdapter,f as PLATFORM_ORIGINS,c as getTelegramWebApp,g as isPlatformParentOrigin}from'../chunk-DE75YD5H.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@idosgames/core",
3
- "version": "0.16.0",
3
+ "version": "0.17.0",
4
4
  "description": "Engine-agnostic core of the IDosGames SDK (transport, auth, cache, services, events).",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1 +0,0 @@
1
- var n=class{getString(e){if(typeof localStorage>"u")return null;try{return localStorage.getItem(e)}catch{return null}}setString(e,t){if(!(typeof localStorage>"u"))try{localStorage.setItem(e,t);}catch{}}remove(e){if(!(typeof localStorage>"u"))try{localStorage.removeItem(e);}catch{}}},o=class{map=new Map;getString(e){return this.map.get(e)??null}setString(e,t){this.map.set(e,t);}remove(e){this.map.delete(e);}};function r(){return globalThis.Telegram?.WebApp??null}function l(){return crypto.randomUUID()}var s="idos_device_id",i=class{storage;constructor(e=new n){this.storage=e;}getPlatform(){return r()?.platform??"Web"}getFullURL(){return typeof location<"u"?location.href:""}getStartParameter(){let e=r()?.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=r()?.initData;return e&&e.length>0?e:null}getDeviceID(){let e=this.storage.getString(s);return e||(e=l(),this.storage.setString(s,e)),e}getDeviceModel(){return typeof navigator<"u"&&navigator.userAgent?navigator.userAgent:"Web"}shareLink(e){let t=r();if(t?.openTelegramLink){t.openTelegramLink(e);return}typeof window<"u"&&window.open(e,"_blank");}openInvoice(e){let t=r();if(t?.openInvoice){t.openInvoice(e);return}typeof window<"u"&&window.open(e,"_blank");}async showAd(e){let t=globalThis;typeof t.showAd=="function"&&await t.showAd(e);}async copyToClipboard(e){typeof navigator<"u"&&navigator.clipboard&&await navigator.clipboard.writeText(e);}};var p="idos_device_id",g=class{storage;constructor(e=new o){this.storage=e;}getPlatform(){return "Web"}getFullURL(){return ""}getStartParameter(){return null}getTelegramInitDataRaw(){return null}getDeviceID(){let e=this.storage.getString(p);return e||(e="noop-device",this.storage.setString(p,e)),e}getDeviceModel(){return "Noop"}shareLink(){}openInvoice(){}async showAd(){}async copyToClipboard(){}};export{n as a,o as b,r as c,l as d,i as e,g as f};