@dynamic-labs/ton 4.61.2 → 4.61.4
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/CHANGELOG.md +16 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +8 -8
- package/src/connectors/TonConnectConnector/TonConnectConnector.cjs +34 -22
- package/src/connectors/TonConnectConnector/TonConnectConnector.d.ts +7 -0
- package/src/connectors/TonConnectConnector/TonConnectConnector.js +34 -22
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
|
|
2
|
+
### [4.61.4](https://github.com/dynamic-labs/dynamic-auth/compare/v4.61.3...v4.61.4) (2026-02-15)
|
|
3
|
+
|
|
4
|
+
### [4.61.3](https://github.com/dynamic-labs/dynamic-auth/compare/v4.61.2...v4.61.3) (2026-02-13)
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* add reset widget password flow for WaaS wallets ([#10437](https://github.com/dynamic-labs/dynamic-auth/issues/10437)) ([7490069](https://github.com/dynamic-labs/dynamic-auth/commit/7490069b70b04be5d70c472c17b132c6a5eddcd5))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* add broken ton wallet mobile connection ([#10435](https://github.com/dynamic-labs/dynamic-auth/issues/10435)) ([a71cd88](https://github.com/dynamic-labs/dynamic-auth/commit/a71cd88fd4e80af6a8956cdb5cc389a34e4e00f1))
|
|
15
|
+
* infinite loop when rapidly entering phone number ([#10434](https://github.com/dynamic-labs/dynamic-auth/issues/10434)) ([39a57cc](https://github.com/dynamic-labs/dynamic-auth/commit/39a57cc51b879abbb63bd129a489adcd8522b261))
|
|
16
|
+
* invalidate non matching ton connect proof ([#10438](https://github.com/dynamic-labs/dynamic-auth/issues/10438)) ([406ba34](https://github.com/dynamic-labs/dynamic-auth/commit/406ba34ba9053953a4b5a5d6ead6d7e8a1718423))
|
|
17
|
+
|
|
2
18
|
### [4.61.2](https://github.com/dynamic-labs/dynamic-auth/compare/v4.61.1...v4.61.2) (2026-02-12)
|
|
3
19
|
|
|
4
20
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/ton",
|
|
3
|
-
"version": "4.61.
|
|
3
|
+
"version": "4.61.4",
|
|
4
4
|
"description": "A React SDK for implementing wallet web3 authentication and authorization to your website.",
|
|
5
5
|
"author": "Dynamic Labs, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,14 +18,14 @@
|
|
|
18
18
|
},
|
|
19
19
|
"homepage": "https://www.dynamic.xyz/",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@dynamic-labs/assert-package-version": "4.61.
|
|
22
|
-
"@dynamic-labs/logger": "4.61.
|
|
21
|
+
"@dynamic-labs/assert-package-version": "4.61.4",
|
|
22
|
+
"@dynamic-labs/logger": "4.61.4",
|
|
23
23
|
"@dynamic-labs/sdk-api-core": "0.0.864",
|
|
24
|
-
"@dynamic-labs/types": "4.61.
|
|
25
|
-
"@dynamic-labs/utils": "4.61.
|
|
26
|
-
"@dynamic-labs/waas": "4.61.
|
|
27
|
-
"@dynamic-labs/wallet-book": "4.61.
|
|
28
|
-
"@dynamic-labs/wallet-connector-core": "4.61.
|
|
24
|
+
"@dynamic-labs/types": "4.61.4",
|
|
25
|
+
"@dynamic-labs/utils": "4.61.4",
|
|
26
|
+
"@dynamic-labs/waas": "4.61.4",
|
|
27
|
+
"@dynamic-labs/wallet-book": "4.61.4",
|
|
28
|
+
"@dynamic-labs/wallet-connector-core": "4.61.4",
|
|
29
29
|
"@ton/core": "0.62.0",
|
|
30
30
|
"@ton/crypto": "3.3.0",
|
|
31
31
|
"@ton/ton": "16.0.0",
|
|
@@ -57,6 +57,7 @@ class TonConnectConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
57
57
|
this.connectedChain = 'TON';
|
|
58
58
|
this.supportedChains = ['TON'];
|
|
59
59
|
this.canConnectViaQrCode = false;
|
|
60
|
+
this.canHandleMultipleConnections = false;
|
|
60
61
|
this.connectedWallet = null;
|
|
61
62
|
this.pendingProofPayload = null;
|
|
62
63
|
this.lastConnectionUrl = null;
|
|
@@ -160,8 +161,10 @@ class TonConnectConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
160
161
|
bridgeUrl: matchingWallet.bridgeUrl,
|
|
161
162
|
universalLink: matchingWallet.universalLink,
|
|
162
163
|
}, connectOptions);
|
|
163
|
-
|
|
164
|
-
|
|
164
|
+
// Append return strategy so the wallet redirects back to the browser
|
|
165
|
+
const urlWithReturn = this.appendReturnStrategy(connectionUrl);
|
|
166
|
+
this.lastConnectionUrl = urlWithReturn;
|
|
167
|
+
utils.PlatformService.openURL(urlWithReturn);
|
|
165
168
|
return;
|
|
166
169
|
}
|
|
167
170
|
tonConnect.connect(matchingWallet, connectOptions);
|
|
@@ -203,32 +206,24 @@ class TonConnectConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
203
206
|
if (tonConnect.connected && ((_a = tonConnect.account) === null || _a === void 0 ? void 0 : _a.address)) {
|
|
204
207
|
return this.convertAddressToUserFriendly(tonConnect.account.address);
|
|
205
208
|
}
|
|
206
|
-
//
|
|
207
|
-
//
|
|
208
|
-
//
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
// If not connected, initiate connection and wait for it to complete
|
|
209
|
+
// If not connected, initiate connection and wait for it to complete.
|
|
210
|
+
// connect() handles platform differences internally (injected provider,
|
|
211
|
+
// bridge deep link, etc.). Unlike other chain connectors whose
|
|
212
|
+
// providers return a promise that resolves on connection completion,
|
|
213
|
+
// TonConnect SDK's connect() on mobile bridge connections returns the
|
|
214
|
+
// URL synchronously and notifies later via onStatusChange. We poll
|
|
215
|
+
// until `tonConnect.connected` becomes true as a workaround.
|
|
214
216
|
try {
|
|
215
|
-
// Start the connection process (shows QR code/deep link)
|
|
216
217
|
yield this.connect();
|
|
217
|
-
// After connect() returns, the QR code is shown but connection is not yet established
|
|
218
|
-
// Wait for the connection to be established by polling or waiting for status change
|
|
219
|
-
// TON Connect SDK doesn't provide a clean way to wait, so we poll
|
|
220
218
|
const maxWaitTime = 300000; // 5 minutes
|
|
221
219
|
const pollInterval = 500; // Check every 500ms
|
|
222
220
|
const startTime = Date.now();
|
|
223
221
|
while (!tonConnect.connected && Date.now() - startTime < maxWaitTime) {
|
|
224
222
|
yield new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
225
|
-
// Check if connected after the delay
|
|
226
223
|
if (tonConnect.connected && ((_b = tonConnect.account) === null || _b === void 0 ? void 0 : _b.address)) {
|
|
227
|
-
|
|
228
|
-
return userFriendlyAddress;
|
|
224
|
+
return this.convertAddressToUserFriendly(tonConnect.account.address);
|
|
229
225
|
}
|
|
230
226
|
}
|
|
231
|
-
// If we get here, either timeout or still not connected
|
|
232
227
|
if (!tonConnect.connected) {
|
|
233
228
|
throw new utils.DynamicError('Connection timeout - user did not approve the connection');
|
|
234
229
|
}
|
|
@@ -558,6 +553,23 @@ class TonConnectConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
558
553
|
// Serialize to base64 BOC (Bag of Cells) format
|
|
559
554
|
return mainCell.toBoc().toString('base64');
|
|
560
555
|
}
|
|
556
|
+
/**
|
|
557
|
+
* Append a return strategy to a TonConnect universal link.
|
|
558
|
+
* The `ret` parameter tells the wallet where to redirect after approval.
|
|
559
|
+
* `back` instructs the wallet to return to the previous app (browser).
|
|
560
|
+
*/
|
|
561
|
+
appendReturnStrategy(url) {
|
|
562
|
+
try {
|
|
563
|
+
const parsed = new URL(url);
|
|
564
|
+
parsed.searchParams.append('ret', 'back');
|
|
565
|
+
return parsed.toString();
|
|
566
|
+
}
|
|
567
|
+
catch (_a) {
|
|
568
|
+
// If URL parsing fails, append as query string manually
|
|
569
|
+
const separator = url.includes('?') ? '&' : '?';
|
|
570
|
+
return `${url}${separator}ret=back`;
|
|
571
|
+
}
|
|
572
|
+
}
|
|
561
573
|
/**
|
|
562
574
|
* Check if error is a user rejection
|
|
563
575
|
*/
|
|
@@ -576,10 +588,10 @@ class TonConnectConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
576
588
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
577
589
|
var _a, _b, _c, _d, _e, _f;
|
|
578
590
|
const tonConnect = this.getTonConnect();
|
|
579
|
-
// If already connected with a proof, return it
|
|
591
|
+
// If already connected with a proof that matches the requested payload, return it
|
|
580
592
|
if ((_b = (_a = this.connectedWallet) === null || _a === void 0 ? void 0 : _a.connectItems) === null || _b === void 0 ? void 0 : _b.tonProof) {
|
|
581
593
|
const { tonProof } = this.connectedWallet.connectItems;
|
|
582
|
-
if ('proof' in tonProof) {
|
|
594
|
+
if ('proof' in tonProof && tonProof.proof.payload === payload) {
|
|
583
595
|
debugLog.debugLog('[TON Connect] Returning existing proof from connection');
|
|
584
596
|
return {
|
|
585
597
|
address: this.connectedWallet.account.address,
|
|
@@ -590,9 +602,9 @@ class TonConnectConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
590
602
|
};
|
|
591
603
|
}
|
|
592
604
|
}
|
|
593
|
-
// If connected but no proof, disconnect and reconnect with proof
|
|
605
|
+
// If connected but no matching proof, disconnect and reconnect with new proof
|
|
594
606
|
if (tonConnect.connected) {
|
|
595
|
-
debugLog.debugLog('[TON Connect] Already connected without proof, disconnecting to reconnect with tonProof');
|
|
607
|
+
debugLog.debugLog('[TON Connect] Already connected without matching proof, disconnecting to reconnect with tonProof');
|
|
596
608
|
yield tonConnect.disconnect();
|
|
597
609
|
this.connectedWallet = null;
|
|
598
610
|
}
|
|
@@ -17,6 +17,7 @@ export declare class TonConnectConnector extends WalletConnectorBase<typeof TonW
|
|
|
17
17
|
connectedChain: Chain;
|
|
18
18
|
supportedChains: Chain[];
|
|
19
19
|
canConnectViaQrCode: boolean;
|
|
20
|
+
canHandleMultipleConnections: boolean;
|
|
20
21
|
private tonConnect;
|
|
21
22
|
private tonNetworks;
|
|
22
23
|
private connectedWallet;
|
|
@@ -125,6 +126,12 @@ export declare class TonConnectConnector extends WalletConnectorBase<typeof TonW
|
|
|
125
126
|
* The Cell is then serialized to base64 BOC format for TON Connect SDK
|
|
126
127
|
*/
|
|
127
128
|
encodeComment(comment: string): string;
|
|
129
|
+
/**
|
|
130
|
+
* Append a return strategy to a TonConnect universal link.
|
|
131
|
+
* The `ret` parameter tells the wallet where to redirect after approval.
|
|
132
|
+
* `back` instructs the wallet to return to the previous app (browser).
|
|
133
|
+
*/
|
|
134
|
+
private appendReturnStrategy;
|
|
128
135
|
/**
|
|
129
136
|
* Check if error is a user rejection
|
|
130
137
|
*/
|
|
@@ -53,6 +53,7 @@ class TonConnectConnector extends WalletConnectorBase {
|
|
|
53
53
|
this.connectedChain = 'TON';
|
|
54
54
|
this.supportedChains = ['TON'];
|
|
55
55
|
this.canConnectViaQrCode = false;
|
|
56
|
+
this.canHandleMultipleConnections = false;
|
|
56
57
|
this.connectedWallet = null;
|
|
57
58
|
this.pendingProofPayload = null;
|
|
58
59
|
this.lastConnectionUrl = null;
|
|
@@ -156,8 +157,10 @@ class TonConnectConnector extends WalletConnectorBase {
|
|
|
156
157
|
bridgeUrl: matchingWallet.bridgeUrl,
|
|
157
158
|
universalLink: matchingWallet.universalLink,
|
|
158
159
|
}, connectOptions);
|
|
159
|
-
|
|
160
|
-
|
|
160
|
+
// Append return strategy so the wallet redirects back to the browser
|
|
161
|
+
const urlWithReturn = this.appendReturnStrategy(connectionUrl);
|
|
162
|
+
this.lastConnectionUrl = urlWithReturn;
|
|
163
|
+
PlatformService.openURL(urlWithReturn);
|
|
161
164
|
return;
|
|
162
165
|
}
|
|
163
166
|
tonConnect.connect(matchingWallet, connectOptions);
|
|
@@ -199,32 +202,24 @@ class TonConnectConnector extends WalletConnectorBase {
|
|
|
199
202
|
if (tonConnect.connected && ((_a = tonConnect.account) === null || _a === void 0 ? void 0 : _a.address)) {
|
|
200
203
|
return this.convertAddressToUserFriendly(tonConnect.account.address);
|
|
201
204
|
}
|
|
202
|
-
//
|
|
203
|
-
//
|
|
204
|
-
//
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
// If not connected, initiate connection and wait for it to complete
|
|
205
|
+
// If not connected, initiate connection and wait for it to complete.
|
|
206
|
+
// connect() handles platform differences internally (injected provider,
|
|
207
|
+
// bridge deep link, etc.). Unlike other chain connectors whose
|
|
208
|
+
// providers return a promise that resolves on connection completion,
|
|
209
|
+
// TonConnect SDK's connect() on mobile bridge connections returns the
|
|
210
|
+
// URL synchronously and notifies later via onStatusChange. We poll
|
|
211
|
+
// until `tonConnect.connected` becomes true as a workaround.
|
|
210
212
|
try {
|
|
211
|
-
// Start the connection process (shows QR code/deep link)
|
|
212
213
|
yield this.connect();
|
|
213
|
-
// After connect() returns, the QR code is shown but connection is not yet established
|
|
214
|
-
// Wait for the connection to be established by polling or waiting for status change
|
|
215
|
-
// TON Connect SDK doesn't provide a clean way to wait, so we poll
|
|
216
214
|
const maxWaitTime = 300000; // 5 minutes
|
|
217
215
|
const pollInterval = 500; // Check every 500ms
|
|
218
216
|
const startTime = Date.now();
|
|
219
217
|
while (!tonConnect.connected && Date.now() - startTime < maxWaitTime) {
|
|
220
218
|
yield new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
221
|
-
// Check if connected after the delay
|
|
222
219
|
if (tonConnect.connected && ((_b = tonConnect.account) === null || _b === void 0 ? void 0 : _b.address)) {
|
|
223
|
-
|
|
224
|
-
return userFriendlyAddress;
|
|
220
|
+
return this.convertAddressToUserFriendly(tonConnect.account.address);
|
|
225
221
|
}
|
|
226
222
|
}
|
|
227
|
-
// If we get here, either timeout or still not connected
|
|
228
223
|
if (!tonConnect.connected) {
|
|
229
224
|
throw new DynamicError('Connection timeout - user did not approve the connection');
|
|
230
225
|
}
|
|
@@ -554,6 +549,23 @@ class TonConnectConnector extends WalletConnectorBase {
|
|
|
554
549
|
// Serialize to base64 BOC (Bag of Cells) format
|
|
555
550
|
return mainCell.toBoc().toString('base64');
|
|
556
551
|
}
|
|
552
|
+
/**
|
|
553
|
+
* Append a return strategy to a TonConnect universal link.
|
|
554
|
+
* The `ret` parameter tells the wallet where to redirect after approval.
|
|
555
|
+
* `back` instructs the wallet to return to the previous app (browser).
|
|
556
|
+
*/
|
|
557
|
+
appendReturnStrategy(url) {
|
|
558
|
+
try {
|
|
559
|
+
const parsed = new URL(url);
|
|
560
|
+
parsed.searchParams.append('ret', 'back');
|
|
561
|
+
return parsed.toString();
|
|
562
|
+
}
|
|
563
|
+
catch (_a) {
|
|
564
|
+
// If URL parsing fails, append as query string manually
|
|
565
|
+
const separator = url.includes('?') ? '&' : '?';
|
|
566
|
+
return `${url}${separator}ret=back`;
|
|
567
|
+
}
|
|
568
|
+
}
|
|
557
569
|
/**
|
|
558
570
|
* Check if error is a user rejection
|
|
559
571
|
*/
|
|
@@ -572,10 +584,10 @@ class TonConnectConnector extends WalletConnectorBase {
|
|
|
572
584
|
return __awaiter(this, void 0, void 0, function* () {
|
|
573
585
|
var _a, _b, _c, _d, _e, _f;
|
|
574
586
|
const tonConnect = this.getTonConnect();
|
|
575
|
-
// If already connected with a proof, return it
|
|
587
|
+
// If already connected with a proof that matches the requested payload, return it
|
|
576
588
|
if ((_b = (_a = this.connectedWallet) === null || _a === void 0 ? void 0 : _a.connectItems) === null || _b === void 0 ? void 0 : _b.tonProof) {
|
|
577
589
|
const { tonProof } = this.connectedWallet.connectItems;
|
|
578
|
-
if ('proof' in tonProof) {
|
|
590
|
+
if ('proof' in tonProof && tonProof.proof.payload === payload) {
|
|
579
591
|
debugLog('[TON Connect] Returning existing proof from connection');
|
|
580
592
|
return {
|
|
581
593
|
address: this.connectedWallet.account.address,
|
|
@@ -586,9 +598,9 @@ class TonConnectConnector extends WalletConnectorBase {
|
|
|
586
598
|
};
|
|
587
599
|
}
|
|
588
600
|
}
|
|
589
|
-
// If connected but no proof, disconnect and reconnect with proof
|
|
601
|
+
// If connected but no matching proof, disconnect and reconnect with new proof
|
|
590
602
|
if (tonConnect.connected) {
|
|
591
|
-
debugLog('[TON Connect] Already connected without proof, disconnecting to reconnect with tonProof');
|
|
603
|
+
debugLog('[TON Connect] Already connected without matching proof, disconnecting to reconnect with tonProof');
|
|
592
604
|
yield tonConnect.disconnect();
|
|
593
605
|
this.connectedWallet = null;
|
|
594
606
|
}
|