@blazium/ton-connect-mobile 1.0.0 → 1.0.1
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/README.md +16 -0
- package/dist/adapters/web.js +18 -9
- package/package.json +2 -2
- package/src/adapters/web.ts +23 -9
package/README.md
CHANGED
|
@@ -10,6 +10,7 @@ Production-ready TON Connect Mobile SDK for React Native and Expo. This SDK impl
|
|
|
10
10
|
- ✅ **Transaction Signing** - Send and sign transactions
|
|
11
11
|
- ✅ **Signature Verification** - Verifies wallet signatures
|
|
12
12
|
- ✅ **Cross-Platform** - Works with Expo Managed, Expo Bare, and React Native CLI
|
|
13
|
+
- ⚠️ **Web Limitation** - Deep links (`tonconnect://`) only work on mobile devices (Android/iOS), not in web browsers
|
|
13
14
|
- ✅ **TypeScript** - Fully typed with TypeScript
|
|
14
15
|
- ✅ **Production Ready** - No placeholders, no mocks, ready for production use
|
|
15
16
|
|
|
@@ -125,6 +126,21 @@ try {
|
|
|
125
126
|
}
|
|
126
127
|
```
|
|
127
128
|
|
|
129
|
+
### Platform Support
|
|
130
|
+
|
|
131
|
+
**⚠️ Important**: TON Connect deep links (`tonconnect://`) only work on **mobile devices** (Android/iOS). They do not work in web browsers.
|
|
132
|
+
|
|
133
|
+
- ✅ **Android**: Full support via Expo or React Native CLI
|
|
134
|
+
- ✅ **iOS**: Full support via Expo or React Native CLI
|
|
135
|
+
- ⚠️ **Web**: Deep links are not supported. The SDK will throw a clear error message if you try to use it in a web browser.
|
|
136
|
+
|
|
137
|
+
**Why?** The `tonconnect://` protocol is a custom URI scheme that requires a mobile app handler. Web browsers cannot handle these custom protocols.
|
|
138
|
+
|
|
139
|
+
**Testing**: To test wallet connections, use:
|
|
140
|
+
- Android device or emulator
|
|
141
|
+
- iOS device or simulator
|
|
142
|
+
- Not web browsers
|
|
143
|
+
|
|
128
144
|
### Disconnect
|
|
129
145
|
|
|
130
146
|
```typescript
|
package/dist/adapters/web.js
CHANGED
|
@@ -45,18 +45,26 @@ class WebAdapter {
|
|
|
45
45
|
async openURL(url) {
|
|
46
46
|
try {
|
|
47
47
|
if (typeof window !== 'undefined') {
|
|
48
|
-
// For web,
|
|
49
|
-
//
|
|
48
|
+
// For web, tonconnect:// deep links don't work
|
|
49
|
+
// They only work on mobile devices (Android/iOS)
|
|
50
50
|
if (url.startsWith('tonconnect://')) {
|
|
51
|
-
//
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
// Show user-friendly error message
|
|
52
|
+
const errorMessage = 'TON Connect deep links only work on mobile devices (Android/iOS).\n\n' +
|
|
53
|
+
'Please test this on a mobile device or use the mobile app.\n\n' +
|
|
54
|
+
'Deep link: ' + url.substring(0, 100) + '...';
|
|
55
|
+
// Try to show alert (if available)
|
|
56
|
+
if (typeof window.alert !== 'undefined') {
|
|
57
|
+
window.alert(errorMessage);
|
|
56
58
|
}
|
|
57
|
-
|
|
59
|
+
else {
|
|
60
|
+
console.error('TON Connect Web Error:', errorMessage);
|
|
61
|
+
}
|
|
62
|
+
// Throw error so SDK can handle it properly
|
|
63
|
+
throw new Error('TON Connect deep links are not supported in web browsers. ' +
|
|
64
|
+
'Please use this SDK on a mobile device (Android/iOS) or test with a mobile app.');
|
|
58
65
|
}
|
|
59
66
|
else {
|
|
67
|
+
// Regular HTTP/HTTPS URLs work fine
|
|
60
68
|
window.location.href = url;
|
|
61
69
|
return true;
|
|
62
70
|
}
|
|
@@ -64,7 +72,8 @@ class WebAdapter {
|
|
|
64
72
|
return false;
|
|
65
73
|
}
|
|
66
74
|
catch (error) {
|
|
67
|
-
|
|
75
|
+
// Re-throw the error so SDK can handle it
|
|
76
|
+
throw error;
|
|
68
77
|
}
|
|
69
78
|
}
|
|
70
79
|
async getInitialURL() {
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blazium/ton-connect-mobile",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
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",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "https://github.com/blaziumdev/ton-connect-mobile.git"
|
|
9
|
+
"url": "git+https://github.com/blaziumdev/ton-connect-mobile.git"
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
12
12
|
"build": "tsc",
|
package/src/adapters/web.ts
CHANGED
|
@@ -11,6 +11,7 @@ declare const window: {
|
|
|
11
11
|
open(url: string, target?: string): any;
|
|
12
12
|
addEventListener(type: string, listener: () => void): void;
|
|
13
13
|
removeEventListener(type: string, listener: () => void): void;
|
|
14
|
+
alert(message: string): void;
|
|
14
15
|
localStorage: {
|
|
15
16
|
setItem(key: string, value: string): void;
|
|
16
17
|
getItem(key: string): string | null;
|
|
@@ -68,24 +69,37 @@ export class WebAdapter implements PlatformAdapter {
|
|
|
68
69
|
async openURL(url: string): Promise<boolean> {
|
|
69
70
|
try {
|
|
70
71
|
if (typeof window !== 'undefined') {
|
|
71
|
-
// For web,
|
|
72
|
-
//
|
|
72
|
+
// For web, tonconnect:// deep links don't work
|
|
73
|
+
// They only work on mobile devices (Android/iOS)
|
|
73
74
|
if (url.startsWith('tonconnect://')) {
|
|
74
|
-
//
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
// Show user-friendly error message
|
|
76
|
+
const errorMessage =
|
|
77
|
+
'TON Connect deep links only work on mobile devices (Android/iOS).\n\n' +
|
|
78
|
+
'Please test this on a mobile device or use the mobile app.\n\n' +
|
|
79
|
+
'Deep link: ' + url.substring(0, 100) + '...';
|
|
80
|
+
|
|
81
|
+
// Try to show alert (if available)
|
|
82
|
+
if (typeof window.alert !== 'undefined') {
|
|
83
|
+
window.alert(errorMessage);
|
|
84
|
+
} else {
|
|
85
|
+
console.error('TON Connect Web Error:', errorMessage);
|
|
79
86
|
}
|
|
80
|
-
|
|
87
|
+
|
|
88
|
+
// Throw error so SDK can handle it properly
|
|
89
|
+
throw new Error(
|
|
90
|
+
'TON Connect deep links are not supported in web browsers. ' +
|
|
91
|
+
'Please use this SDK on a mobile device (Android/iOS) or test with a mobile app.'
|
|
92
|
+
);
|
|
81
93
|
} else {
|
|
94
|
+
// Regular HTTP/HTTPS URLs work fine
|
|
82
95
|
window.location.href = url;
|
|
83
96
|
return true;
|
|
84
97
|
}
|
|
85
98
|
}
|
|
86
99
|
return false;
|
|
87
100
|
} catch (error) {
|
|
88
|
-
|
|
101
|
+
// Re-throw the error so SDK can handle it
|
|
102
|
+
throw error;
|
|
89
103
|
}
|
|
90
104
|
}
|
|
91
105
|
|