@appboxo/web-sdk 1.3.2 → 1.4.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.
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Geodata Handler
3
+ * Handles geolocation requests from miniapp
4
+ */
5
+ import type { GeodataRequest } from "../types";
6
+ export interface GeodataHandlerConfig {
7
+ log: (message: string, data?: any) => void;
8
+ sendResponseToMiniapp: (response: any) => void;
9
+ sendErrorResponse: (eventType: string, error: any, requestId?: string | number) => void;
10
+ }
11
+ /**
12
+ * Handle geodata events
13
+ */
14
+ export declare function handleGeodataEvent(params: GeodataRequest, requestId: string | number | undefined, config: GeodataHandlerConfig): Promise<void>;
15
+ //# sourceMappingURL=geodataHandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geodataHandler.d.ts","sourceRoot":"","sources":["../../src/handlers/geodataHandler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,KAAK,EAAE,cAAc,EAAmB,MAAM,UAAU,CAAC;AAEhE,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IAC3C,qBAAqB,EAAE,CAAC,QAAQ,EAAE,GAAG,KAAK,IAAI,CAAC;IAC/C,iBAAiB,EAAE,CACjB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,GAAG,EACV,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,KACxB,IAAI,CAAC;CACX;AAwBD;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,cAAc,EACtB,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,EACtC,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,IAAI,CAAC,CA6Ff"}
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Geodata Handler
3
+ * Handles geolocation requests from miniapp
4
+ */
5
+ import { EVENT_TYPES } from "../constants";
6
+ import { createHostResponse, } from "../utils/messageHelpers";
7
+ /**
8
+ * Get geolocation using browser Geolocation API
9
+ */
10
+ function getBrowserGeolocation() {
11
+ return new Promise((resolve, reject) => {
12
+ if (!navigator.geolocation) {
13
+ reject(new Error("Geolocation is not supported by this browser"));
14
+ return;
15
+ }
16
+ navigator.geolocation.getCurrentPosition((position) => resolve(position), (error) => reject(error), {
17
+ enableHighAccuracy: false,
18
+ timeout: 10000,
19
+ maximumAge: 300000, // 5 minutes
20
+ });
21
+ });
22
+ }
23
+ /**
24
+ * Handle geodata events
25
+ */
26
+ export async function handleGeodataEvent(params, requestId, config) {
27
+ try {
28
+ config.log("Handling geodata event", params);
29
+ // Check if geolocation is supported
30
+ if (!navigator.geolocation) {
31
+ const error = new Error("Geolocation is not supported by this browser");
32
+ config.log("Geolocation not supported", error);
33
+ config.sendErrorResponse("AppBoxoWebAppGetGeodata", error, requestId);
34
+ return;
35
+ }
36
+ // Check permission status (if Permissions API is available) - for logging only
37
+ // Note: We still try to get geolocation even if permission is denied,
38
+ // because permission state in hostapp context may differ from iframe context
39
+ let permissionState = null;
40
+ if ("permissions" in navigator) {
41
+ try {
42
+ const result = await navigator.permissions.query({
43
+ name: "geolocation",
44
+ });
45
+ permissionState = result.state;
46
+ config.log("Geolocation permission state", permissionState);
47
+ // If permission is denied, log but still try (user might have denied in iframe but not in hostapp)
48
+ if (permissionState === "denied") {
49
+ config.log("Permission state is denied, but attempting anyway (hostapp context may differ)");
50
+ }
51
+ }
52
+ catch (error) {
53
+ // Permissions API not supported or failed, continue anyway
54
+ config.log("Permissions API not available, proceeding with geolocation request");
55
+ }
56
+ }
57
+ // Always try to get geolocation - even if permission appears denied
58
+ // This allows the browser to show permission prompt in hostapp context
59
+ // The browser will handle permission denial gracefully
60
+ const position = await getBrowserGeolocation();
61
+ const geodataResponse = {
62
+ available: true,
63
+ lat: position.coords.latitude.toString(),
64
+ long: position.coords.longitude.toString(),
65
+ };
66
+ const response = createHostResponse(EVENT_TYPES.GEODATA, geodataResponse, requestId);
67
+ config.sendResponseToMiniapp(response);
68
+ config.log("Geodata sent to miniapp", geodataResponse);
69
+ }
70
+ catch (error) {
71
+ config.log("Geodata failed", error);
72
+ config.log("Geodata error details", {
73
+ error,
74
+ type: typeof error,
75
+ hasCode: error && typeof error === "object" && "code" in error,
76
+ code: error && typeof error === "object" && "code" in error
77
+ ? error.code
78
+ : undefined,
79
+ message: error instanceof Error ? error.message : String(error),
80
+ });
81
+ // Handle specific geolocation errors
82
+ if (error && typeof error === "object" && "code" in error) {
83
+ let errorMessage = "Failed to get geolocation";
84
+ const geolocationError = error;
85
+ if (geolocationError.code === 1) {
86
+ errorMessage = "Geolocation permission denied";
87
+ config.log("Permission denied - user needs to enable in browser settings");
88
+ }
89
+ else if (geolocationError.code === 2) {
90
+ errorMessage = "Geolocation position unavailable";
91
+ }
92
+ else if (geolocationError.code === 3) {
93
+ errorMessage = "Geolocation request timeout";
94
+ }
95
+ config.sendErrorResponse("AppBoxoWebAppGetGeodata", new Error(errorMessage), requestId);
96
+ }
97
+ else {
98
+ config.sendErrorResponse("AppBoxoWebAppGetGeodata", error, requestId);
99
+ }
100
+ }
101
+ }
102
+ //# sourceMappingURL=geodataHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geodataHandler.js","sourceRoot":"","sources":["../../src/handlers/geodataHandler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EACL,kBAAkB,GAEnB,MAAM,yBAAyB,CAAC;AAajC;;GAEG;AACH,SAAS,qBAAqB;IAC5B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC;YAC3B,MAAM,CAAC,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC,CAAC;YAClE,OAAO;QACT,CAAC;QAED,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,MAAM,KAAK,IAAI,CAAC;CACzF;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,eAAe,EACvB,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,EACtC,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,IAAI,CAAC,CAiFf"}
1
+ {"version":3,"file":"initDataHandler.d.ts","sourceRoot":"","sources":["../../src/handlers/initDataHandler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAoB,SAAS,EAAE,MAAM,UAAU,CAAC;AAyB7E,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,SAAS,CAAC;IAClB,GAAG,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IAC3C,qBAAqB,EAAE,CAAC,QAAQ,EAAE,GAAG,KAAK,IAAI,CAAC;IAC/C,iBAAiB,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,KAAK,IAAI,CAAC;CACzF;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,eAAe,EACvB,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,EACtC,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,IAAI,CAAC,CAkGf"}
@@ -4,6 +4,24 @@
4
4
  */
5
5
  import { EVENT_TYPES } from '../constants';
6
6
  import { createHostResponse } from '../utils/messageHelpers';
7
+ /**
8
+ * Detect if running in Telegram WebView environment
9
+ * Checks multiple indicators to determine if the host app is running inside Telegram WebView
10
+ */
11
+ function detectTelegramWebView() {
12
+ if (typeof window === 'undefined') {
13
+ return false;
14
+ }
15
+ // Check URL parameters
16
+ const urlParams = window.location.hash.includes('tgWebApp') ||
17
+ window.location.search.includes('tgWebApp');
18
+ // Check user agent
19
+ const userAgent = navigator.userAgent.includes('Telegram') ||
20
+ navigator.userAgent.includes('WebView');
21
+ // Check for Telegram SDK
22
+ const hasTelegramSDK = !!window.Telegram?.WebApp;
23
+ return urlParams || userAgent || hasTelegramSDK;
24
+ }
7
25
  /**
8
26
  * Handle init data events
9
27
  */
@@ -25,6 +43,8 @@ export async function handleInitDataEvent(params, requestId, config) {
25
43
  supportedHandlers.push('AppBoxoWebAppPay');
26
44
  config.log('Payment handler supported (onPaymentRequest configured)');
27
45
  }
46
+ // Detect Telegram WebView environment
47
+ const isTelegramWebView = detectTelegramWebView();
28
48
  // Use app_id and client_id from SDK config if params are missing/undefined
29
49
  // This ensures InitData always has valid values even if miniapp sends undefined
30
50
  const initData = {
@@ -37,7 +57,9 @@ export async function handleInitDataEvent(params, requestId, config) {
37
57
  handlers: supportedHandlers,
38
58
  capabilities: supportedHandlers,
39
59
  // Include locale if configured
40
- ...(config.config.locale && { locale: config.config.locale })
60
+ ...(config.config.locale && { locale: config.config.locale }),
61
+ // Include Telegram WebView detection result
62
+ isTelegramWebView: isTelegramWebView
41
63
  },
42
64
  sandbox_mode: config.config.sandboxMode
43
65
  };
@@ -64,6 +86,18 @@ export async function handleInitDataEvent(params, requestId, config) {
64
86
  console.log(`[AppboxoWebSDK] No locale configured - miniapp will not receive locale`);
65
87
  }
66
88
  }
89
+ // Log Telegram WebView detection for debugging
90
+ if (isTelegramWebView) {
91
+ config.log('Telegram WebView detected, isTelegramWebView included in InitData', {
92
+ isTelegramWebView: true
93
+ });
94
+ if (config.config.debug) {
95
+ console.log(`[AppboxoWebSDK] Telegram WebView detected - isTelegramWebView: true included in InitData response to miniapp`);
96
+ }
97
+ }
98
+ else if (config.config.debug) {
99
+ console.log(`[AppboxoWebSDK] Not in Telegram WebView - isTelegramWebView: false included in InitData response to miniapp`);
100
+ }
67
101
  const response = createHostResponse(EVENT_TYPES.INIT_DATA, initData, requestId);
68
102
  config.sendResponseToMiniapp(response);
69
103
  config.log('Init data sent to miniapp', { initData, supportedHandlers });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,CAAC,CAAC;QAEvC,MAAM,CAAC,GAAG,CAAC,2BAA2B,EAAE,EAAE,QAAQ,EAAE,iBAAiB,EAAE,CAAC,CAAC;QACzE,qCAAqC;QACrC,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YACxB,OAAO,CAAC,GAAG,CAAC,mDAAmD,EAAE;gBAC/D,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,IAAI,SAAS;gBACzC,iBAAiB;gBACjB,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM;aAClC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,GAAG,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;QACtC,MAAM,CAAC,iBAAiB,CAAC,0BAA0B,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;IACzE,CAAC;AACH,CAAC"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2024 Boxo pte. ltd.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import type { StorageGetRequest, StorageSetRequest, StorageRemoveRequest, StorageClearRequest, SDKConfig } from '../types';
18
+ /**
19
+ * Handler context interface
20
+ */
21
+ interface StorageHandlerContext {
22
+ config: SDKConfig;
23
+ log: (message: string, data?: any) => void;
24
+ sendResponseToMiniapp: (response: any) => void;
25
+ sendErrorResponse: (eventType: string, error: any, requestId?: string | number) => void;
26
+ }
27
+ /**
28
+ * Handle StorageGet request
29
+ */
30
+ export declare function handleStorageGetEvent(params: StorageGetRequest, requestId: string | number | undefined, context: StorageHandlerContext): void;
31
+ /**
32
+ * Handle StorageSet request
33
+ */
34
+ export declare function handleStorageSetEvent(params: StorageSetRequest, requestId: string | number | undefined, context: StorageHandlerContext): void;
35
+ /**
36
+ * Handle StorageRemove request
37
+ */
38
+ export declare function handleStorageRemoveEvent(params: StorageRemoveRequest, requestId: string | number | undefined, context: StorageHandlerContext): void;
39
+ /**
40
+ * Handle StorageClear request
41
+ */
42
+ export declare function handleStorageClearEvent(params: StorageClearRequest, requestId: string | number | undefined, context: StorageHandlerContext): void;
43
+ export {};
44
+ //# sourceMappingURL=storageHandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storageHandler.d.ts","sourceRoot":"","sources":["../../src/handlers/storageHandler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EAKnB,SAAS,EACV,MAAM,UAAU,CAAC;AAMlB;;GAEG;AACH,UAAU,qBAAqB;IAC7B,MAAM,EAAE,SAAS,CAAC;IAClB,GAAG,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IAC3C,qBAAqB,EAAE,CAAC,QAAQ,EAAE,GAAG,KAAK,IAAI,CAAC;IAC/C,iBAAiB,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,KAAK,IAAI,CAAC;CACzF;AAiCD;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,iBAAiB,EACzB,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,EACtC,OAAO,EAAE,qBAAqB,GAC7B,IAAI,CAoEN;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,iBAAiB,EACzB,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,EACtC,OAAO,EAAE,qBAAqB,GAC7B,IAAI,CA4DN;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,oBAAoB,EAC5B,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,EACtC,OAAO,EAAE,qBAAqB,GAC7B,IAAI,CA4DN;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,mBAAmB,EAC3B,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,EACtC,OAAO,EAAE,qBAAqB,GAC7B,IAAI,CAuDN"}
@@ -0,0 +1,263 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2024 Boxo pte. ltd.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { createHostResponse } from '../utils/messageHelpers';
18
+ // Storage key prefix to avoid conflicts with host app's own storage
19
+ const STORAGE_PREFIX = 'boxo_miniapp_';
20
+ /**
21
+ * Check if Telegram CloudStorage is available
22
+ */
23
+ function isTelegramCloudStorageAvailable() {
24
+ return !!(typeof window !== 'undefined' &&
25
+ window.Telegram?.WebApp?.CloudStorage);
26
+ }
27
+ /**
28
+ * Get storage backend (CloudStorage or localStorage)
29
+ */
30
+ function getStorageBackend() {
31
+ if (isTelegramCloudStorageAvailable()) {
32
+ return {
33
+ type: 'cloudStorage',
34
+ storage: window.Telegram.WebApp.CloudStorage,
35
+ };
36
+ }
37
+ if (typeof window !== 'undefined' && window.localStorage) {
38
+ return {
39
+ type: 'localStorage',
40
+ storage: window.localStorage,
41
+ };
42
+ }
43
+ return null;
44
+ }
45
+ /**
46
+ * Handle StorageGet request
47
+ */
48
+ export function handleStorageGetEvent(params, requestId, context) {
49
+ const { log, sendResponseToMiniapp, sendErrorResponse, config } = context;
50
+ const { key } = params;
51
+ log('Storage GET request', { key, requestId });
52
+ const backend = getStorageBackend();
53
+ if (!backend) {
54
+ log('No storage backend available');
55
+ sendErrorResponse('AppBoxoWebAppStorageGet', 'Storage not available', requestId);
56
+ return;
57
+ }
58
+ if (backend.type === 'cloudStorage') {
59
+ // Use Telegram CloudStorage (async)
60
+ backend.storage.getItem(key, (error, value) => {
61
+ if (error) {
62
+ log('CloudStorage getItem error', error);
63
+ const response = {
64
+ key,
65
+ value: null,
66
+ success: false,
67
+ error: String(error),
68
+ };
69
+ sendResponseToMiniapp(createHostResponse('AppBoxoWebAppStorageGet', response, requestId));
70
+ }
71
+ else {
72
+ log('CloudStorage getItem success', { key, value });
73
+ const response = {
74
+ key,
75
+ value: value || null,
76
+ success: true,
77
+ };
78
+ sendResponseToMiniapp(createHostResponse('AppBoxoWebAppStorageGet', response, requestId));
79
+ }
80
+ });
81
+ }
82
+ else {
83
+ // Use localStorage (sync)
84
+ try {
85
+ const prefixedKey = STORAGE_PREFIX + key;
86
+ const value = backend.storage.getItem(prefixedKey);
87
+ log('localStorage getItem success', { key, value });
88
+ const response = {
89
+ key,
90
+ value: value || null,
91
+ success: true,
92
+ };
93
+ sendResponseToMiniapp(createHostResponse('AppBoxoWebAppStorageGet', response, requestId));
94
+ }
95
+ catch (error) {
96
+ log('localStorage getItem error', error);
97
+ const response = {
98
+ key,
99
+ value: null,
100
+ success: false,
101
+ error: error instanceof Error ? error.message : String(error),
102
+ };
103
+ sendResponseToMiniapp(createHostResponse('AppBoxoWebAppStorageGet', response, requestId));
104
+ }
105
+ }
106
+ }
107
+ /**
108
+ * Handle StorageSet request
109
+ */
110
+ export function handleStorageSetEvent(params, requestId, context) {
111
+ const { log, sendResponseToMiniapp, sendErrorResponse } = context;
112
+ const { key, value } = params;
113
+ log('Storage SET request', { key, value, requestId });
114
+ const backend = getStorageBackend();
115
+ if (!backend) {
116
+ log('No storage backend available');
117
+ sendErrorResponse('AppBoxoWebAppStorageSet', 'Storage not available', requestId);
118
+ return;
119
+ }
120
+ if (backend.type === 'cloudStorage') {
121
+ // Use Telegram CloudStorage (async)
122
+ backend.storage.setItem(key, value, (error, success) => {
123
+ if (error) {
124
+ log('CloudStorage setItem error', error);
125
+ const response = {
126
+ success: false,
127
+ error: String(error),
128
+ };
129
+ sendResponseToMiniapp(createHostResponse('AppBoxoWebAppStorageSet', response, requestId));
130
+ }
131
+ else {
132
+ log('CloudStorage setItem success', { key });
133
+ const response = {
134
+ success: true,
135
+ };
136
+ sendResponseToMiniapp(createHostResponse('AppBoxoWebAppStorageSet', response, requestId));
137
+ }
138
+ });
139
+ }
140
+ else {
141
+ // Use localStorage (sync)
142
+ try {
143
+ const prefixedKey = STORAGE_PREFIX + key;
144
+ backend.storage.setItem(prefixedKey, value);
145
+ log('localStorage setItem success', { key });
146
+ const response = {
147
+ success: true,
148
+ };
149
+ sendResponseToMiniapp(createHostResponse('AppBoxoWebAppStorageSet', response, requestId));
150
+ }
151
+ catch (error) {
152
+ log('localStorage setItem error', error);
153
+ const response = {
154
+ success: false,
155
+ error: error instanceof Error ? error.message : String(error),
156
+ };
157
+ sendResponseToMiniapp(createHostResponse('AppBoxoWebAppStorageSet', response, requestId));
158
+ }
159
+ }
160
+ }
161
+ /**
162
+ * Handle StorageRemove request
163
+ */
164
+ export function handleStorageRemoveEvent(params, requestId, context) {
165
+ const { log, sendResponseToMiniapp, sendErrorResponse } = context;
166
+ const { key } = params;
167
+ log('Storage REMOVE request', { key, requestId });
168
+ const backend = getStorageBackend();
169
+ if (!backend) {
170
+ log('No storage backend available');
171
+ sendErrorResponse('AppBoxoWebAppStorageRemove', 'Storage not available', requestId);
172
+ return;
173
+ }
174
+ if (backend.type === 'cloudStorage') {
175
+ // Use Telegram CloudStorage (async)
176
+ backend.storage.removeItem(key, (error, success) => {
177
+ if (error) {
178
+ log('CloudStorage removeItem error', error);
179
+ const response = {
180
+ success: false,
181
+ error: String(error),
182
+ };
183
+ sendResponseToMiniapp(createHostResponse('AppBoxoWebAppStorageRemove', response, requestId));
184
+ }
185
+ else {
186
+ log('CloudStorage removeItem success', { key });
187
+ const response = {
188
+ success: true,
189
+ };
190
+ sendResponseToMiniapp(createHostResponse('AppBoxoWebAppStorageRemove', response, requestId));
191
+ }
192
+ });
193
+ }
194
+ else {
195
+ // Use localStorage (sync)
196
+ try {
197
+ const prefixedKey = STORAGE_PREFIX + key;
198
+ backend.storage.removeItem(prefixedKey);
199
+ log('localStorage removeItem success', { key });
200
+ const response = {
201
+ success: true,
202
+ };
203
+ sendResponseToMiniapp(createHostResponse('AppBoxoWebAppStorageRemove', response, requestId));
204
+ }
205
+ catch (error) {
206
+ log('localStorage removeItem error', error);
207
+ const response = {
208
+ success: false,
209
+ error: error instanceof Error ? error.message : String(error),
210
+ };
211
+ sendResponseToMiniapp(createHostResponse('AppBoxoWebAppStorageRemove', response, requestId));
212
+ }
213
+ }
214
+ }
215
+ /**
216
+ * Handle StorageClear request
217
+ */
218
+ export function handleStorageClearEvent(params, requestId, context) {
219
+ const { log, sendResponseToMiniapp, sendErrorResponse } = context;
220
+ log('Storage CLEAR request', { requestId });
221
+ const backend = getStorageBackend();
222
+ if (!backend) {
223
+ log('No storage backend available');
224
+ sendErrorResponse('AppBoxoWebAppStorageClear', 'Storage not available', requestId);
225
+ return;
226
+ }
227
+ if (backend.type === 'cloudStorage') {
228
+ // Use Telegram CloudStorage - remove all keys
229
+ // Note: CloudStorage doesn't have a native "clear all" method
230
+ // We would need to track keys ourselves or use a different approach
231
+ // For now, we'll return an error suggesting to use removeItem instead
232
+ log('CloudStorage clear not supported - use removeItem for specific keys');
233
+ const response = {
234
+ success: false,
235
+ error: 'CloudStorage does not support clear operation. Use removeItem for specific keys.',
236
+ };
237
+ sendResponseToMiniapp(createHostResponse('AppBoxoWebAppStorageClear', response, requestId));
238
+ }
239
+ else {
240
+ // Use localStorage - clear only miniapp prefixed keys
241
+ try {
242
+ const keys = Object.keys(backend.storage);
243
+ const miniappKeys = keys.filter(k => k.startsWith(STORAGE_PREFIX));
244
+ miniappKeys.forEach(key => {
245
+ backend.storage.removeItem(key);
246
+ });
247
+ log('localStorage clear success', { clearedKeys: miniappKeys.length });
248
+ const response = {
249
+ success: true,
250
+ };
251
+ sendResponseToMiniapp(createHostResponse('AppBoxoWebAppStorageClear', response, requestId));
252
+ }
253
+ catch (error) {
254
+ log('localStorage clear error', error);
255
+ const response = {
256
+ success: false,
257
+ error: error instanceof Error ? error.message : String(error),
258
+ };
259
+ sendResponseToMiniapp(createHostResponse('AppBoxoWebAppStorageClear', response, requestId));
260
+ }
261
+ }
262
+ }
263
+ //# sourceMappingURL=storageHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storageHandler.js","sourceRoot":"","sources":["../../src/handlers/storageHandler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAaH,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,oEAAoE;AACpE,MAAM,cAAc,GAAG,eAAe,CAAC;AAYvC;;GAEG;AACH,SAAS,+BAA+B;IACtC,OAAO,CAAC,CAAC,CACP,OAAO,MAAM,KAAK,WAAW;QAC5B,MAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,CAC/C,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAS,iBAAiB;IACxB,IAAI,+BAA+B,EAAE,EAAE,CAAC;QACtC,OAAO;YACL,IAAI,EAAE,cAAuB;YAC7B,OAAO,EAAG,MAAc,CAAC,QAAQ,CAAC,MAAM,CAAC,YAAY;SACtD,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;QAC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U,CAAC,GAAG,CAAC,CAAC;YAClC,CAAC,CAAC,CAAC;YAEH,GAAG,CAAC,4BAA4B,EAAE,EAAE,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC;YAEvE,MAAM,QAAQ,GAAyB;gBACrC,OAAO,EAAE,IAAI;aACd,CAAC;YACF,qBAAqB,CACnB,kBAAkB,CAAC,2BAA2B,EAAE,QAAQ,EAAE,SAAS,CAAC,CACrE,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,GAAG,CAAC,0BAA0B,EAAE,KAAK,CAAC,CAAC;YACvC,MAAM,QAAQ,GAAyB;gBACrC,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;aAC9D,CAAC;YACF,qBAAqB,CACnB,kBAAkB,CAAC,2BAA2B,EAAE,QAAQ,EAAE,SAAS,CAAC,CACrE,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Telegram Storage Helper
3
+ * Provides storage access that works in Telegram Mini App iframe environment
4
+ * Falls back to postMessage communication when localStorage is not accessible
5
+ */
6
+ export interface TelegramStorageConfig {
7
+ parentOrigin?: string;
8
+ usePostMessage?: boolean;
9
+ log?: (message: string, data?: any) => void;
10
+ }
11
+ /**
12
+ * Storage adapter that works in Telegram Mini App iframe environment
13
+ */
14
+ export declare class TelegramStorage {
15
+ private config;
16
+ private isTelegram;
17
+ private isInIframe;
18
+ private parentOrigin;
19
+ constructor(config?: TelegramStorageConfig);
20
+ /**
21
+ * Detect if running in Telegram Mini App
22
+ */
23
+ private detectTelegram;
24
+ /**
25
+ * Detect if running in iframe
26
+ */
27
+ private detectIframe;
28
+ /**
29
+ * Detect parent window origin
30
+ */
31
+ private detectParentOrigin;
32
+ /**
33
+ * Check if localStorage is accessible
34
+ */
35
+ private isLocalStorageAccessible;
36
+ /**
37
+ * Should use postMessage for storage access
38
+ */
39
+ private shouldUsePostMessage;
40
+ /**
41
+ * Get item from storage
42
+ */
43
+ getItem(key: string): Promise<string | null>;
44
+ /**
45
+ * Set item in storage
46
+ */
47
+ setItem(key: string, value: string): Promise<void>;
48
+ /**
49
+ * Remove item from storage
50
+ */
51
+ removeItem(key: string): Promise<void>;
52
+ /**
53
+ * Get item via postMessage
54
+ */
55
+ private getItemViaPostMessage;
56
+ /**
57
+ * Set item via postMessage
58
+ */
59
+ private setItemViaPostMessage;
60
+ /**
61
+ * Remove item via postMessage
62
+ */
63
+ private removeItemViaPostMessage;
64
+ }
65
+ //# sourceMappingURL=telegramStorage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"telegramStorage.d.ts","sourceRoot":"","sources":["../../src/utils/telegramStorage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,qBAAqB;IACpC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;CAC7C;AAED;;GAEG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAwB;IACtC,OAAO,CAAC,UAAU,CAAU;IAC5B,OAAO,CAAC,UAAU,CAAU;IAC5B,OAAO,CAAC,YAAY,CAAuB;gBAE/B,MAAM,GAAE,qBAA0B;IAc9C;;OAEG;IACH,OAAO,CAAC,cAAc;IAItB;;OAEG;IACH,OAAO,CAAC,YAAY;IASpB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAmC1B;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAWhC;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAoB5B;;OAEG;IACG,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAclD;;OAEG;IACG,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAexD;;OAEG;IACG,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAe5C;;OAEG;IACH,OAAO,CAAC,qBAAqB;IA6D7B;;OAEG;IACH,OAAO,CAAC,qBAAqB;IA8D7B;;OAEG;IACH,OAAO,CAAC,wBAAwB;CA4DjC"}
@@ -0,0 +1,315 @@
1
+ /**
2
+ * Telegram Storage Helper
3
+ * Provides storage access that works in Telegram Mini App iframe environment
4
+ * Falls back to postMessage communication when localStorage is not accessible
5
+ */
6
+ /**
7
+ * Storage adapter that works in Telegram Mini App iframe environment
8
+ */
9
+ export class TelegramStorage {
10
+ constructor(config = {}) {
11
+ this.parentOrigin = null;
12
+ this.config = config;
13
+ this.isTelegram = this.detectTelegram();
14
+ this.isInIframe = this.detectIframe();
15
+ this.parentOrigin = config.parentOrigin || this.detectParentOrigin();
16
+ this.config.log?.('TelegramStorage initialized', {
17
+ isTelegram: this.isTelegram,
18
+ isInIframe: this.isInIframe,
19
+ parentOrigin: this.parentOrigin,
20
+ usePostMessage: config.usePostMessage,
21
+ });
22
+ }
23
+ /**
24
+ * Detect if running in Telegram Mini App
25
+ */
26
+ detectTelegram() {
27
+ return !!window.Telegram?.WebApp;
28
+ }
29
+ /**
30
+ * Detect if running in iframe
31
+ */
32
+ detectIframe() {
33
+ try {
34
+ return window.self !== window.top;
35
+ }
36
+ catch (e) {
37
+ // Cross-origin iframe will throw error
38
+ return true;
39
+ }
40
+ }
41
+ /**
42
+ * Detect parent window origin
43
+ */
44
+ detectParentOrigin() {
45
+ try {
46
+ if (this.isInIframe && window.parent) {
47
+ // Try to get origin from referrer or document.referrer
48
+ const referrer = document.referrer;
49
+ if (referrer) {
50
+ try {
51
+ const url = new URL(referrer);
52
+ this.config.log?.('Detected parent origin from referrer', { origin: url.origin });
53
+ return url.origin;
54
+ }
55
+ catch (e) {
56
+ // Invalid URL
57
+ }
58
+ }
59
+ // Also try to get from window.location (for same-origin iframes)
60
+ try {
61
+ // If we can access parent, try to get its origin
62
+ if (window.parent.location) {
63
+ const parentOrigin = window.parent.location.origin;
64
+ this.config.log?.('Detected parent origin from window.parent.location', { origin: parentOrigin });
65
+ return parentOrigin;
66
+ }
67
+ }
68
+ catch (e) {
69
+ // Cross-origin access denied, that's expected
70
+ this.config.log?.('Cannot access parent.location (cross-origin), will use referrer or *', { referrer });
71
+ }
72
+ }
73
+ }
74
+ catch (e) {
75
+ // Cross-origin access denied
76
+ this.config.log?.('Error detecting parent origin', { error: e });
77
+ }
78
+ return null;
79
+ }
80
+ /**
81
+ * Check if localStorage is accessible
82
+ */
83
+ isLocalStorageAccessible() {
84
+ try {
85
+ const test = '__telegram_storage_test__';
86
+ localStorage.setItem(test, test);
87
+ localStorage.removeItem(test);
88
+ return true;
89
+ }
90
+ catch (e) {
91
+ return false;
92
+ }
93
+ }
94
+ /**
95
+ * Should use postMessage for storage access
96
+ */
97
+ shouldUsePostMessage() {
98
+ if (this.config.usePostMessage) {
99
+ return true;
100
+ }
101
+ // Use postMessage if:
102
+ // 1. In Telegram environment AND in iframe
103
+ // 2. In iframe (even without Telegram, iframe localStorage may be isolated)
104
+ // 3. localStorage is not accessible
105
+ //
106
+ // Note: When running in iframe within Telegram Mini App, the iframe itself
107
+ // doesn't have window.Telegram.WebApp (it's in parent window), but we still
108
+ // need postMessage because localStorage may be isolated or unreliable.
109
+ return ((this.isTelegram && this.isInIframe) ||
110
+ this.isInIframe || // Always use postMessage in iframe for reliability
111
+ !this.isLocalStorageAccessible());
112
+ }
113
+ /**
114
+ * Get item from storage
115
+ */
116
+ async getItem(key) {
117
+ if (!this.shouldUsePostMessage()) {
118
+ // Use regular localStorage
119
+ try {
120
+ return localStorage.getItem(key);
121
+ }
122
+ catch (e) {
123
+ this.config.log?.('localStorage.getItem failed, falling back to postMessage', e);
124
+ return this.getItemViaPostMessage(key);
125
+ }
126
+ }
127
+ return this.getItemViaPostMessage(key);
128
+ }
129
+ /**
130
+ * Set item in storage
131
+ */
132
+ async setItem(key, value) {
133
+ if (!this.shouldUsePostMessage()) {
134
+ // Use regular localStorage
135
+ try {
136
+ localStorage.setItem(key, value);
137
+ return;
138
+ }
139
+ catch (e) {
140
+ this.config.log?.('localStorage.setItem failed, falling back to postMessage', e);
141
+ return this.setItemViaPostMessage(key, value);
142
+ }
143
+ }
144
+ return this.setItemViaPostMessage(key, value);
145
+ }
146
+ /**
147
+ * Remove item from storage
148
+ */
149
+ async removeItem(key) {
150
+ if (!this.shouldUsePostMessage()) {
151
+ // Use regular localStorage
152
+ try {
153
+ localStorage.removeItem(key);
154
+ return;
155
+ }
156
+ catch (e) {
157
+ this.config.log?.('localStorage.removeItem failed, falling back to postMessage', e);
158
+ return this.removeItemViaPostMessage(key);
159
+ }
160
+ }
161
+ return this.removeItemViaPostMessage(key);
162
+ }
163
+ /**
164
+ * Get item via postMessage
165
+ */
166
+ getItemViaPostMessage(key) {
167
+ return new Promise((resolve, reject) => {
168
+ if (!this.isInIframe || !window.parent) {
169
+ reject(new Error('Not in iframe, cannot use postMessage'));
170
+ return;
171
+ }
172
+ const requestId = `storage_req_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
173
+ const timeout = setTimeout(() => {
174
+ window.removeEventListener('message', handler);
175
+ reject(new Error('Storage request timeout'));
176
+ }, 5000);
177
+ const handler = (event) => {
178
+ // Security: Verify origin if parentOrigin is set
179
+ if (this.parentOrigin && event.origin !== this.parentOrigin) {
180
+ return;
181
+ }
182
+ try {
183
+ const data = typeof event.data === 'string' ? JSON.parse(event.data) : event.data;
184
+ if (data.type === 'STORAGE_RESPONSE' &&
185
+ data.requestId === requestId) {
186
+ clearTimeout(timeout);
187
+ window.removeEventListener('message', handler);
188
+ resolve(data.payload?.value || null);
189
+ }
190
+ else if (data.type === 'STORAGE_ERROR' &&
191
+ data.requestId === requestId) {
192
+ clearTimeout(timeout);
193
+ window.removeEventListener('message', handler);
194
+ reject(new Error(data.payload?.error || 'Storage error'));
195
+ }
196
+ }
197
+ catch (e) {
198
+ // Ignore non-JSON messages
199
+ }
200
+ };
201
+ window.addEventListener('message', handler);
202
+ // Send request to parent
203
+ const message = {
204
+ type: 'STORAGE_REQUEST',
205
+ action: 'get',
206
+ key,
207
+ requestId,
208
+ };
209
+ window.parent.postMessage(JSON.stringify(message), this.parentOrigin || '*');
210
+ this.config.log?.('Sent storage get request via postMessage', { key, requestId });
211
+ });
212
+ }
213
+ /**
214
+ * Set item via postMessage
215
+ */
216
+ setItemViaPostMessage(key, value) {
217
+ return new Promise((resolve, reject) => {
218
+ if (!this.isInIframe || !window.parent) {
219
+ reject(new Error('Not in iframe, cannot use postMessage'));
220
+ return;
221
+ }
222
+ const requestId = `storage_req_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
223
+ const timeout = setTimeout(() => {
224
+ window.removeEventListener('message', handler);
225
+ reject(new Error('Storage request timeout'));
226
+ }, 5000);
227
+ const handler = (event) => {
228
+ // Security: Verify origin if parentOrigin is set
229
+ if (this.parentOrigin && event.origin !== this.parentOrigin) {
230
+ return;
231
+ }
232
+ try {
233
+ const data = typeof event.data === 'string' ? JSON.parse(event.data) : event.data;
234
+ if (data.type === 'STORAGE_RESPONSE' &&
235
+ data.requestId === requestId) {
236
+ clearTimeout(timeout);
237
+ window.removeEventListener('message', handler);
238
+ resolve();
239
+ }
240
+ else if (data.type === 'STORAGE_ERROR' &&
241
+ data.requestId === requestId) {
242
+ clearTimeout(timeout);
243
+ window.removeEventListener('message', handler);
244
+ reject(new Error(data.payload?.error || 'Storage error'));
245
+ }
246
+ }
247
+ catch (e) {
248
+ // Ignore non-JSON messages
249
+ }
250
+ };
251
+ window.addEventListener('message', handler);
252
+ // Send request to parent
253
+ const message = {
254
+ type: 'STORAGE_REQUEST',
255
+ action: 'set',
256
+ key,
257
+ value,
258
+ requestId,
259
+ };
260
+ window.parent.postMessage(JSON.stringify(message), this.parentOrigin || '*');
261
+ this.config.log?.('Sent storage set request via postMessage', { key, requestId });
262
+ });
263
+ }
264
+ /**
265
+ * Remove item via postMessage
266
+ */
267
+ removeItemViaPostMessage(key) {
268
+ return new Promise((resolve, reject) => {
269
+ if (!this.isInIframe || !window.parent) {
270
+ reject(new Error('Not in iframe, cannot use postMessage'));
271
+ return;
272
+ }
273
+ const requestId = `storage_req_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
274
+ const timeout = setTimeout(() => {
275
+ window.removeEventListener('message', handler);
276
+ reject(new Error('Storage request timeout'));
277
+ }, 5000);
278
+ const handler = (event) => {
279
+ // Security: Verify origin if parentOrigin is set
280
+ if (this.parentOrigin && event.origin !== this.parentOrigin) {
281
+ return;
282
+ }
283
+ try {
284
+ const data = typeof event.data === 'string' ? JSON.parse(event.data) : event.data;
285
+ if (data.type === 'STORAGE_RESPONSE' &&
286
+ data.requestId === requestId) {
287
+ clearTimeout(timeout);
288
+ window.removeEventListener('message', handler);
289
+ resolve();
290
+ }
291
+ else if (data.type === 'STORAGE_ERROR' &&
292
+ data.requestId === requestId) {
293
+ clearTimeout(timeout);
294
+ window.removeEventListener('message', handler);
295
+ reject(new Error(data.payload?.error || 'Storage error'));
296
+ }
297
+ }
298
+ catch (e) {
299
+ // Ignore non-JSON messages
300
+ }
301
+ };
302
+ window.addEventListener('message', handler);
303
+ // Send request to parent
304
+ const message = {
305
+ type: 'STORAGE_REQUEST',
306
+ action: 'remove',
307
+ key,
308
+ requestId,
309
+ };
310
+ window.parent.postMessage(JSON.stringify(message), this.parentOrigin || '*');
311
+ this.config.log?.('Sent storage remove request via postMessage', { key, requestId });
312
+ });
313
+ }
314
+ }
315
+ //# sourceMappingURL=telegramStorage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"telegramStorage.js","sourceRoot":"","sources":["../../src/utils/telegramStorage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH;;GAEG;AACH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AC7B,IAAI,CAAC,SAAS,KAAK,SAAS,EAC5B,CAAC;wBACD,YAAY,CAAC,OAAO,CAAC,CAAC;wBACtB,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;wBAC/C,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,IAAI,eAAe,CAAC,CAAC,CAAC;oBAC5D,CAAC;gBACH,CAAC;gBAAC,OAAO,CAAC,EAAE,CAAC;oBACX,2BAA2B;gBAC7B,CAAC;YACH,CAAC,CAAC;YAEF,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;YAE5C,yBAAyB;YACzB,MAAM,OAAO,GAAG;gBACd,IAAI,EAAE,iBAAiB;gBACvB,MAAM,EAAE,QAAQ;gBAChB,GAAG;gBACH,SAAS;aACV,CAAC;YAEF,MAAM,CAAC,MAAM,CAAC,WAAW,CACvB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EACvB,IAAI,CAAC,YAAY,IAAI,GAAG,CACzB,CAAC;YAEF,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,6CAA6C,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC;QACvF,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appboxo/web-sdk",
3
- "version": "1.3.2",
3
+ "version": "1.4.0",
4
4
  "description": "Boxo Desktop Host App SDK for handling miniapp events",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",