@blazium/ton-connect-mobile 1.1.3 → 1.1.5

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.
@@ -32,12 +32,22 @@ class ExpoAdapter {
32
32
  }
33
33
  setupURLListener() {
34
34
  if (!Linking) {
35
+ console.warn('[ExpoAdapter] Linking not available, URL listener not set up');
35
36
  return;
36
37
  }
37
38
  // Listen for deep links when app is already open
38
39
  this.subscription = Linking.addEventListener('url', (event) => {
39
- this.urlListeners.forEach((listener) => listener(event.url));
40
+ console.log('[ExpoAdapter] URL event received:', event.url);
41
+ this.urlListeners.forEach((listener) => {
42
+ try {
43
+ listener(event.url);
44
+ }
45
+ catch (error) {
46
+ console.error('[ExpoAdapter] Error in URL listener:', error);
47
+ }
48
+ });
40
49
  });
50
+ console.log('[ExpoAdapter] URL listener set up successfully');
41
51
  }
42
52
  async openURL(url, skipCanOpenURLCheck = true) {
43
53
  if (!Linking) {
@@ -75,12 +85,16 @@ class ExpoAdapter {
75
85
  }
76
86
  async getInitialURL() {
77
87
  if (!Linking) {
88
+ console.warn('[ExpoAdapter] Linking not available, cannot get initial URL');
78
89
  return null;
79
90
  }
80
91
  try {
81
- return await Linking.getInitialURL();
92
+ const url = await Linking.getInitialURL();
93
+ console.log('[ExpoAdapter] getInitialURL result:', url);
94
+ return url;
82
95
  }
83
96
  catch (error) {
97
+ console.error('[ExpoAdapter] Error getting initial URL:', error);
84
98
  return null;
85
99
  }
86
100
  }
@@ -18,7 +18,7 @@ exports.SUPPORTED_WALLETS = [
18
18
  universalLink: 'https://app.tonkeeper.com/ton-connect',
19
19
  deepLink: 'tonkeeper://',
20
20
  platforms: ['ios', 'android'],
21
- preferredReturnStrategy: 'back',
21
+ preferredReturnStrategy: 'post_redirect', // CRITICAL FIX: 'back' strategy may not send callback properly, use 'post_redirect'
22
22
  requiresReturnScheme: true, // CRITICAL FIX: Mobile apps need returnScheme for proper callback handling
23
23
  },
24
24
  {
package/dist/index.js CHANGED
@@ -182,9 +182,16 @@ class TonConnectMobile {
182
182
  */
183
183
  handleCallback(url) {
184
184
  console.log('[TON Connect] handleCallback called with URL:', url);
185
+ console.log('[TON Connect] Expected scheme:', this.config.scheme);
186
+ console.log('[TON Connect] URL starts with scheme?', url?.startsWith(`${this.config.scheme}://`));
185
187
  // CRITICAL FIX: Check if URL matches our scheme
186
- if (!url || !url.startsWith(`${this.config.scheme}://`)) {
188
+ if (!url || typeof url !== 'string') {
189
+ console.log('[TON Connect] Invalid URL, ignoring:', url);
190
+ return;
191
+ }
192
+ if (!url.startsWith(`${this.config.scheme}://`)) {
187
193
  console.log('[TON Connect] Callback URL does not match scheme, ignoring:', url);
194
+ console.log('[TON Connect] Expected prefix:', `${this.config.scheme}://`);
188
195
  return;
189
196
  }
190
197
  const parsed = (0, protocol_1.parseCallbackURL)(url, this.config.scheme);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blazium/ton-connect-mobile",
3
- "version": "1.1.3",
3
+ "version": "1.1.5",
4
4
  "description": "Production-ready TON Connect Mobile SDK for React Native and Expo. Implements the real TonConnect protocol for mobile applications using deep links and callbacks.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -40,12 +40,21 @@ export class ExpoAdapter implements PlatformAdapter {
40
40
 
41
41
  private setupURLListener(): void {
42
42
  if (!Linking) {
43
+ console.warn('[ExpoAdapter] Linking not available, URL listener not set up');
43
44
  return;
44
45
  }
45
46
  // Listen for deep links when app is already open
46
47
  this.subscription = Linking.addEventListener('url', (event: { url: string }) => {
47
- this.urlListeners.forEach((listener) => listener(event.url));
48
+ console.log('[ExpoAdapter] URL event received:', event.url);
49
+ this.urlListeners.forEach((listener) => {
50
+ try {
51
+ listener(event.url);
52
+ } catch (error) {
53
+ console.error('[ExpoAdapter] Error in URL listener:', error);
54
+ }
55
+ });
48
56
  });
57
+ console.log('[ExpoAdapter] URL listener set up successfully');
49
58
  }
50
59
 
51
60
  async openURL(url: string, skipCanOpenURLCheck: boolean = true): Promise<boolean> {
@@ -89,11 +98,15 @@ export class ExpoAdapter implements PlatformAdapter {
89
98
 
90
99
  async getInitialURL(): Promise<string | null> {
91
100
  if (!Linking) {
101
+ console.warn('[ExpoAdapter] Linking not available, cannot get initial URL');
92
102
  return null;
93
103
  }
94
104
  try {
95
- return await Linking.getInitialURL();
105
+ const url = await Linking.getInitialURL();
106
+ console.log('[ExpoAdapter] getInitialURL result:', url);
107
+ return url;
96
108
  } catch (error) {
109
+ console.error('[ExpoAdapter] Error getting initial URL:', error);
97
110
  return null;
98
111
  }
99
112
  }
@@ -32,7 +32,7 @@ export const SUPPORTED_WALLETS: WalletDefinition[] = [
32
32
  universalLink: 'https://app.tonkeeper.com/ton-connect',
33
33
  deepLink: 'tonkeeper://',
34
34
  platforms: ['ios', 'android'],
35
- preferredReturnStrategy: 'back',
35
+ preferredReturnStrategy: 'post_redirect', // CRITICAL FIX: 'back' strategy may not send callback properly, use 'post_redirect'
36
36
  requiresReturnScheme: true, // CRITICAL FIX: Mobile apps need returnScheme for proper callback handling
37
37
  },
38
38
  {
package/src/index.ts CHANGED
@@ -216,10 +216,18 @@ export class TonConnectMobile {
216
216
  */
217
217
  private handleCallback(url: string): void {
218
218
  console.log('[TON Connect] handleCallback called with URL:', url);
219
+ console.log('[TON Connect] Expected scheme:', this.config.scheme);
220
+ console.log('[TON Connect] URL starts with scheme?', url?.startsWith(`${this.config.scheme}://`));
219
221
 
220
222
  // CRITICAL FIX: Check if URL matches our scheme
221
- if (!url || !url.startsWith(`${this.config.scheme}://`)) {
223
+ if (!url || typeof url !== 'string') {
224
+ console.log('[TON Connect] Invalid URL, ignoring:', url);
225
+ return;
226
+ }
227
+
228
+ if (!url.startsWith(`${this.config.scheme}://`)) {
222
229
  console.log('[TON Connect] Callback URL does not match scheme, ignoring:', url);
230
+ console.log('[TON Connect] Expected prefix:', `${this.config.scheme}://`);
223
231
  return;
224
232
  }
225
233