@blazium/ton-connect-mobile 1.0.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.
- package/LICENSE +22 -0
- package/README.md +271 -0
- package/dist/adapters/expo.d.ts +25 -0
- package/dist/adapters/expo.js +145 -0
- package/dist/adapters/index.d.ts +6 -0
- package/dist/adapters/index.js +12 -0
- package/dist/adapters/react-native.d.ts +25 -0
- package/dist/adapters/react-native.js +133 -0
- package/dist/adapters/web.d.ts +27 -0
- package/dist/adapters/web.js +147 -0
- package/dist/core/crypto.d.ts +28 -0
- package/dist/core/crypto.js +183 -0
- package/dist/core/index.d.ts +5 -0
- package/dist/core/index.js +21 -0
- package/dist/core/protocol.d.ts +50 -0
- package/dist/core/protocol.js +260 -0
- package/dist/index.d.ts +112 -0
- package/dist/index.js +502 -0
- package/dist/types/index.d.ts +192 -0
- package/dist/types/index.js +6 -0
- package/package.json +57 -0
- package/src/adapters/expo.ts +160 -0
- package/src/adapters/index.ts +8 -0
- package/src/adapters/react-native.ts +148 -0
- package/src/adapters/web.ts +176 -0
- package/src/core/crypto.ts +238 -0
- package/src/core/index.ts +7 -0
- package/src/core/protocol.ts +330 -0
- package/src/index.d.ts +19 -0
- package/src/index.ts +578 -0
- package/src/types/index.ts +206 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core types for TON Connect Mobile SDK
|
|
3
|
+
* These types define the protocol structure for TonConnect
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Wallet information returned after successful connection
|
|
8
|
+
*/
|
|
9
|
+
export interface WalletInfo {
|
|
10
|
+
/** Wallet name (e.g., "Tonkeeper", "MyTonWallet") */
|
|
11
|
+
name: string;
|
|
12
|
+
/** Wallet app name */
|
|
13
|
+
appName: string;
|
|
14
|
+
/** Wallet app version */
|
|
15
|
+
version: string;
|
|
16
|
+
/** Platform (ios/android) */
|
|
17
|
+
platform: 'ios' | 'android' | 'unknown';
|
|
18
|
+
/** TON address of the connected wallet */
|
|
19
|
+
address: string;
|
|
20
|
+
/** Public key in hex format */
|
|
21
|
+
publicKey: string;
|
|
22
|
+
/** Wallet icon URL */
|
|
23
|
+
icon?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Connection status
|
|
28
|
+
*/
|
|
29
|
+
export interface ConnectionStatus {
|
|
30
|
+
/** Whether a wallet is currently connected */
|
|
31
|
+
connected: boolean;
|
|
32
|
+
/** Wallet information if connected, null otherwise */
|
|
33
|
+
wallet: WalletInfo | null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Transaction message to send
|
|
38
|
+
*/
|
|
39
|
+
export interface TransactionMessage {
|
|
40
|
+
/** Recipient address in TON format (EQ...) */
|
|
41
|
+
address: string;
|
|
42
|
+
/** Amount in nanotons (1 TON = 1,000,000,000 nanotons) */
|
|
43
|
+
amount: string;
|
|
44
|
+
/** Optional message payload (base64 encoded) */
|
|
45
|
+
payload?: string;
|
|
46
|
+
/** Optional state init (base64 encoded) */
|
|
47
|
+
stateInit?: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Transaction request parameters
|
|
52
|
+
*/
|
|
53
|
+
export interface SendTransactionRequest {
|
|
54
|
+
/** Unix timestamp (ms) when the request expires */
|
|
55
|
+
validUntil: number;
|
|
56
|
+
/** Array of messages to send */
|
|
57
|
+
messages: TransactionMessage[];
|
|
58
|
+
/** Optional network (mainnet/testnet) */
|
|
59
|
+
network?: 'mainnet' | 'testnet';
|
|
60
|
+
/** Optional from address */
|
|
61
|
+
from?: string;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Transaction response from wallet
|
|
66
|
+
*/
|
|
67
|
+
export interface TransactionResponse {
|
|
68
|
+
/** Base64 encoded BOC of the transaction */
|
|
69
|
+
boc: string;
|
|
70
|
+
/** Transaction signature */
|
|
71
|
+
signature: string;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Connection request payload (sent to wallet)
|
|
76
|
+
*/
|
|
77
|
+
export interface ConnectionRequestPayload {
|
|
78
|
+
/** Manifest URL for the app */
|
|
79
|
+
manifestUrl: string;
|
|
80
|
+
/** Items requested from wallet */
|
|
81
|
+
items: Array<{
|
|
82
|
+
name: 'ton_addr';
|
|
83
|
+
}>;
|
|
84
|
+
/** Return URL scheme */
|
|
85
|
+
returnStrategy?: 'back' | 'none';
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Connection response payload (received from wallet)
|
|
90
|
+
*/
|
|
91
|
+
export interface ConnectionResponsePayload {
|
|
92
|
+
/** Session ID */
|
|
93
|
+
session: string;
|
|
94
|
+
/** Wallet information */
|
|
95
|
+
name: string;
|
|
96
|
+
/** Wallet app name */
|
|
97
|
+
appName: string;
|
|
98
|
+
/** Wallet version */
|
|
99
|
+
version: string;
|
|
100
|
+
/** Platform */
|
|
101
|
+
platform: 'ios' | 'android' | 'unknown';
|
|
102
|
+
/** TON address */
|
|
103
|
+
address: string;
|
|
104
|
+
/** Public key in hex */
|
|
105
|
+
publicKey: string;
|
|
106
|
+
/** Wallet icon URL */
|
|
107
|
+
icon?: string;
|
|
108
|
+
/** Proof (signature) for verification */
|
|
109
|
+
proof?: {
|
|
110
|
+
timestamp: number;
|
|
111
|
+
domain: {
|
|
112
|
+
lengthBytes: number;
|
|
113
|
+
value: string;
|
|
114
|
+
};
|
|
115
|
+
signature: string;
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Transaction request payload (sent to wallet)
|
|
121
|
+
*/
|
|
122
|
+
export interface TransactionRequestPayload {
|
|
123
|
+
/** Manifest URL */
|
|
124
|
+
manifestUrl: string;
|
|
125
|
+
/** Transaction request */
|
|
126
|
+
request: {
|
|
127
|
+
/** Unix timestamp (ms) when request expires */
|
|
128
|
+
validUntil: number;
|
|
129
|
+
/** Array of messages */
|
|
130
|
+
messages: Array<{
|
|
131
|
+
address: string;
|
|
132
|
+
amount: string;
|
|
133
|
+
payload?: string;
|
|
134
|
+
stateInit?: string;
|
|
135
|
+
}>;
|
|
136
|
+
/** Optional network */
|
|
137
|
+
network?: 'mainnet' | 'testnet';
|
|
138
|
+
/** Optional from address */
|
|
139
|
+
from?: string;
|
|
140
|
+
};
|
|
141
|
+
/** Return URL scheme */
|
|
142
|
+
returnStrategy?: 'back' | 'none';
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Transaction response payload (received from wallet)
|
|
147
|
+
*/
|
|
148
|
+
export interface TransactionResponsePayload {
|
|
149
|
+
/** Base64 encoded BOC */
|
|
150
|
+
boc: string;
|
|
151
|
+
/** Transaction signature */
|
|
152
|
+
signature: string;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Error response from wallet
|
|
157
|
+
*/
|
|
158
|
+
export interface ErrorResponse {
|
|
159
|
+
/** Error code */
|
|
160
|
+
error: {
|
|
161
|
+
code: number;
|
|
162
|
+
message: string;
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Platform adapter interface for deep linking and storage
|
|
168
|
+
*/
|
|
169
|
+
export interface PlatformAdapter {
|
|
170
|
+
/** Open a deep link URL */
|
|
171
|
+
openURL(url: string): Promise<boolean>;
|
|
172
|
+
/** Get initial URL when app was opened via deep link */
|
|
173
|
+
getInitialURL(): Promise<string | null>;
|
|
174
|
+
/** Add listener for URL changes */
|
|
175
|
+
addURLListener(callback: (url: string) => void): () => void;
|
|
176
|
+
/** Store data */
|
|
177
|
+
setItem(key: string, value: string): Promise<void>;
|
|
178
|
+
/** Retrieve data */
|
|
179
|
+
getItem(key: string): Promise<string | null>;
|
|
180
|
+
/** Remove data */
|
|
181
|
+
removeItem(key: string): Promise<void>;
|
|
182
|
+
/** Generate random bytes */
|
|
183
|
+
randomBytes(length: number): Promise<Uint8Array>;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* SDK configuration
|
|
188
|
+
*/
|
|
189
|
+
export interface TonConnectMobileConfig {
|
|
190
|
+
/** Manifest URL (required) */
|
|
191
|
+
manifestUrl: string;
|
|
192
|
+
/** Deep link scheme for callbacks (required) */
|
|
193
|
+
scheme: string;
|
|
194
|
+
/** Optional storage key prefix */
|
|
195
|
+
storageKeyPrefix?: string;
|
|
196
|
+
/** Optional connection timeout in ms (default: 300000 = 5 minutes) */
|
|
197
|
+
connectionTimeout?: number;
|
|
198
|
+
/** Optional transaction timeout in ms (default: 300000 = 5 minutes) */
|
|
199
|
+
transactionTimeout?: number;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Event listener callback type
|
|
204
|
+
*/
|
|
205
|
+
export type StatusChangeCallback = (status: ConnectionStatus) => void;
|
|
206
|
+
|