@dynamic-labs/solana 4.8.3 → 4.8.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 +13 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +10 -10
- package/src/injected/InjectedWalletBase/InjectedWalletBase.cjs +2 -1
- package/src/injected/InjectedWalletBase/InjectedWalletBase.js +2 -1
- package/src/phantomRedirect/PhantomRedirect/PhantomRedirect.cjs +14 -29
- package/src/phantomRedirect/PhantomRedirect/PhantomRedirect.js +14 -29
- package/src/phantomRedirect/clearRedirectUrlForPhantom/clearRedirectUrlForPhantom.cjs +29 -0
- package/src/phantomRedirect/clearRedirectUrlForPhantom/clearRedirectUrlForPhantom.d.ts +9 -0
- package/src/phantomRedirect/clearRedirectUrlForPhantom/clearRedirectUrlForPhantom.js +25 -0
- package/src/phantomRedirect/clearRedirectUrlForPhantom/index.d.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
|
|
2
|
+
### [4.8.4](https://github.com/dynamic-labs/dynamic-auth/compare/v4.8.3...v4.8.4) (2025-03-05)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* add iframe deeplink support for iOS Safari ([#8168](https://github.com/dynamic-labs/dynamic-auth/issues/8168)) ([cc4a6b9](https://github.com/dynamic-labs/dynamic-auth/commit/cc4a6b94b8e1b36b303ea5bf86734ba2e73bcef9))
|
|
8
|
+
* add binance bitcoin wallet support ([#8089](ttps://github.com/dynamic-labs/dynamic-auth/issues/8089)) ([c8a3a41](https://github.com/dynamic-labs/dynamic-auth/commit/c8a3a418e4f431b3442e5bc7332530b777e223c8))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* mobile wallet iframe redirects ([#8213](https://github.com/dynamic-labs/dynamic-auth/issues/8213)) ([96ea428](https://github.com/dynamic-labs/dynamic-auth/commit/96ea428375232e57379faef6e2a61dd818325777))
|
|
14
|
+
|
|
2
15
|
### [4.8.3](https://github.com/dynamic-labs/dynamic-auth/compare/v4.8.2...v4.8.3) (2025-03-04)
|
|
3
16
|
|
|
4
17
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/solana",
|
|
3
|
-
"version": "4.8.
|
|
3
|
+
"version": "4.8.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",
|
|
@@ -25,16 +25,16 @@
|
|
|
25
25
|
"@wallet-standard/experimental-features": "0.1.1",
|
|
26
26
|
"bs58": "5.0.0",
|
|
27
27
|
"tweetnacl": "1.0.3",
|
|
28
|
-
"@dynamic-labs/assert-package-version": "4.8.
|
|
29
|
-
"@dynamic-labs/embedded-wallet-solana": "4.8.
|
|
30
|
-
"@dynamic-labs/logger": "4.8.
|
|
31
|
-
"@dynamic-labs/rpc-providers": "4.8.
|
|
28
|
+
"@dynamic-labs/assert-package-version": "4.8.4",
|
|
29
|
+
"@dynamic-labs/embedded-wallet-solana": "4.8.4",
|
|
30
|
+
"@dynamic-labs/logger": "4.8.4",
|
|
31
|
+
"@dynamic-labs/rpc-providers": "4.8.4",
|
|
32
32
|
"@dynamic-labs/sdk-api-core": "0.0.638",
|
|
33
|
-
"@dynamic-labs/solana-core": "4.8.
|
|
34
|
-
"@dynamic-labs/types": "4.8.
|
|
35
|
-
"@dynamic-labs/utils": "4.8.
|
|
36
|
-
"@dynamic-labs/wallet-book": "4.8.
|
|
37
|
-
"@dynamic-labs/wallet-connector-core": "4.8.
|
|
33
|
+
"@dynamic-labs/solana-core": "4.8.4",
|
|
34
|
+
"@dynamic-labs/types": "4.8.4",
|
|
35
|
+
"@dynamic-labs/utils": "4.8.4",
|
|
36
|
+
"@dynamic-labs/wallet-book": "4.8.4",
|
|
37
|
+
"@dynamic-labs/wallet-connector-core": "4.8.4"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {}
|
|
40
40
|
}
|
|
@@ -85,8 +85,9 @@ class InjectedWalletBase extends solanaCore.SolanaWalletConnector {
|
|
|
85
85
|
((_a = this.metadata) === null || _a === void 0 ? void 0 : _a.inAppBrowserUrl) &&
|
|
86
86
|
this.mobileExperience === 'in-app-browser') {
|
|
87
87
|
const inAppBrowserCompiledTemplate = utils.template(this.metadata.inAppBrowserUrl);
|
|
88
|
+
const { href } = utils.PlatformService.getUrl();
|
|
88
89
|
const deepLink = inAppBrowserCompiledTemplate({
|
|
89
|
-
encodedDappURI: encodeURIComponent(
|
|
90
|
+
encodedDappURI: encodeURIComponent(href),
|
|
90
91
|
});
|
|
91
92
|
utils.PlatformService.openURL(deepLink);
|
|
92
93
|
}
|
|
@@ -81,8 +81,9 @@ class InjectedWalletBase extends SolanaWalletConnector {
|
|
|
81
81
|
((_a = this.metadata) === null || _a === void 0 ? void 0 : _a.inAppBrowserUrl) &&
|
|
82
82
|
this.mobileExperience === 'in-app-browser') {
|
|
83
83
|
const inAppBrowserCompiledTemplate = template(this.metadata.inAppBrowserUrl);
|
|
84
|
+
const { href } = PlatformService.getUrl();
|
|
84
85
|
const deepLink = inAppBrowserCompiledTemplate({
|
|
85
|
-
encodedDappURI: encodeURIComponent(
|
|
86
|
+
encodedDappURI: encodeURIComponent(href),
|
|
86
87
|
});
|
|
87
88
|
PlatformService.openURL(deepLink);
|
|
88
89
|
}
|
|
@@ -13,6 +13,7 @@ var buildUrl = require('../buildUrl/buildUrl.cjs');
|
|
|
13
13
|
var decryptPayload = require('../decryptPayload/decryptPayload.cjs');
|
|
14
14
|
var encryptPayload = require('../encryptPayload/encryptPayload.cjs');
|
|
15
15
|
var storage = require('../storage/storage.cjs');
|
|
16
|
+
var clearRedirectUrlForPhantom = require('../clearRedirectUrlForPhantom/clearRedirectUrlForPhantom.cjs');
|
|
16
17
|
|
|
17
18
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
18
19
|
|
|
@@ -57,16 +58,17 @@ class PhantomRedirect extends solanaCore.SolanaWalletConnector {
|
|
|
57
58
|
const keyPair = nacl__default["default"].box.keyPair();
|
|
58
59
|
storage.storage.encryptionPublicKey.set(keyPair.publicKey);
|
|
59
60
|
storage.storage.encryptionSecretKey.set(keyPair.secretKey);
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
const { href } = utils.PlatformService.getUrl();
|
|
62
|
+
const isLocalHost = href.includes('localhost') ||
|
|
63
|
+
href.includes('0.0.0.0') ||
|
|
64
|
+
href.includes('127.0.0.1');
|
|
63
65
|
const currentNetwork = this.getSelectedNetwork();
|
|
64
66
|
const cluster = (_a = currentNetwork === null || currentNetwork === void 0 ? void 0 : currentNetwork.cluster) !== null && _a !== void 0 ? _a : 'mainnet-beta';
|
|
65
67
|
const params = new URLSearchParams({
|
|
66
|
-
app_url: isLocalHost ? 'https://demo.dynamic.xyz' :
|
|
68
|
+
app_url: isLocalHost ? 'https://demo.dynamic.xyz' : href,
|
|
67
69
|
cluster,
|
|
68
70
|
dapp_encryption_public_key: bs58__default["default"].encode(keyPair.publicKey),
|
|
69
|
-
redirect_link:
|
|
71
|
+
redirect_link: clearRedirectUrlForPhantom.clearRedirectUrlForPhantom(utils.PlatformService.getUrl()),
|
|
70
72
|
});
|
|
71
73
|
const url = buildUrl.buildUrl('connect', params);
|
|
72
74
|
utils.PlatformService.openURL(url);
|
|
@@ -74,17 +76,12 @@ class PhantomRedirect extends solanaCore.SolanaWalletConnector {
|
|
|
74
76
|
}
|
|
75
77
|
getSession() {
|
|
76
78
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
77
|
-
const params = new URLSearchParams(window.location.search);
|
|
78
79
|
const { data, nonce, phantom_encryption_public_key: phantomEncryptionPublicKey, encryptionSecretKey, } = this.getInputsOrThrow('getSession', ['data', 'nonce', 'phantom_encryption_public_key'], ['encryptionSecretKey']);
|
|
79
80
|
const sharedSecret = nacl__default["default"].box.before(bs58__default["default"].decode(phantomEncryptionPublicKey), encryptionSecretKey);
|
|
80
81
|
storage.storage.sharedSecret.set(sharedSecret);
|
|
81
82
|
const connectData = decryptPayload.decryptPayload(data, nonce, sharedSecret);
|
|
82
83
|
storage.storage.session.set(connectData.session);
|
|
83
84
|
storage.storage.address.set(new web3_js.PublicKey(connectData.public_key));
|
|
84
|
-
params.delete('phantom_encryption_public_key');
|
|
85
|
-
params.delete('data');
|
|
86
|
-
params.delete('nonce');
|
|
87
|
-
history.replaceState(null, '', `${window.location.origin}${window.location.pathname}?${params.toString()}`);
|
|
88
85
|
return connectData.public_key;
|
|
89
86
|
});
|
|
90
87
|
}
|
|
@@ -101,7 +98,7 @@ class PhantomRedirect extends solanaCore.SolanaWalletConnector {
|
|
|
101
98
|
dapp_encryption_public_key: bs58__default["default"].encode(encryptionPublicKey),
|
|
102
99
|
nonce: bs58__default["default"].encode(nonce),
|
|
103
100
|
payload: bs58__default["default"].encode(encryptedPayload),
|
|
104
|
-
redirect_link:
|
|
101
|
+
redirect_link: clearRedirectUrlForPhantom.clearRedirectUrlForPhantom(utils.PlatformService.getUrl()),
|
|
105
102
|
});
|
|
106
103
|
const url = buildUrl.buildUrl('signMessage', params);
|
|
107
104
|
storage.storage.method.set('signMessage');
|
|
@@ -118,35 +115,23 @@ class PhantomRedirect extends solanaCore.SolanaWalletConnector {
|
|
|
118
115
|
});
|
|
119
116
|
}
|
|
120
117
|
extractSignature() {
|
|
121
|
-
const params = new URLSearchParams(window.location.search);
|
|
122
118
|
const { data, nonce, sharedSecret, message } = this.getInputsOrThrow('extractSignature', ['data', 'nonce'], ['sharedSecret', 'message']);
|
|
123
119
|
const signMessageData = decryptPayload.decryptPayload(data, nonce, sharedSecret);
|
|
124
|
-
params.delete('data');
|
|
125
|
-
params.delete('nonce');
|
|
126
|
-
history.replaceState(null, '', `${window.location.origin}${window.location.pathname}?${params.toString()}`);
|
|
127
120
|
return {
|
|
128
121
|
message,
|
|
129
122
|
signature: signMessageData.signature,
|
|
130
123
|
};
|
|
131
124
|
}
|
|
132
125
|
extractTransactions() {
|
|
133
|
-
const params = new URLSearchParams(window.location.search);
|
|
134
126
|
const { data, nonce, sharedSecret } = this.getInputsOrThrow('extractTransactions', ['data', 'nonce'], ['sharedSecret']);
|
|
135
127
|
const signAllTransactionsData = decryptPayload.decryptPayload(data, nonce, sharedSecret);
|
|
136
128
|
const decodedTransactions = signAllTransactionsData.transactions.map((t) => web3_js.Transaction.from(bs58__default["default"].decode(t)));
|
|
137
|
-
params.delete('data');
|
|
138
|
-
params.delete('nonce');
|
|
139
|
-
history.replaceState(null, '', `${window.location.origin}${window.location.pathname}?${params.toString()}`);
|
|
140
129
|
return decodedTransactions;
|
|
141
130
|
}
|
|
142
131
|
extractTransaction() {
|
|
143
|
-
const params = new URLSearchParams(window.location.search);
|
|
144
132
|
const { data, nonce, sharedSecret } = this.getInputsOrThrow('extractTransaction', ['data', 'nonce'], ['sharedSecret']);
|
|
145
133
|
const signTransactionData = decryptPayload.decryptPayload(data, nonce, sharedSecret);
|
|
146
134
|
const decodedTransaction = web3_js.Transaction.from(bs58__default["default"].decode(signTransactionData.transaction));
|
|
147
|
-
params.delete('data');
|
|
148
|
-
params.delete('nonce');
|
|
149
|
-
history.replaceState(null, '', `${window.location.origin}${window.location.pathname}?${params.toString()}`);
|
|
150
135
|
return decodedTransaction;
|
|
151
136
|
}
|
|
152
137
|
consumeMethod() {
|
|
@@ -221,7 +206,7 @@ class PhantomRedirect extends solanaCore.SolanaWalletConnector {
|
|
|
221
206
|
dapp_encryption_public_key: bs58__default["default"].encode(encryptionPublicKey),
|
|
222
207
|
nonce: bs58__default["default"].encode(nonce),
|
|
223
208
|
payload: bs58__default["default"].encode(encryptedPayload),
|
|
224
|
-
redirect_link:
|
|
209
|
+
redirect_link: clearRedirectUrlForPhantom.clearRedirectUrlForPhantom(utils.PlatformService.getUrl()),
|
|
225
210
|
});
|
|
226
211
|
const url = buildUrl.buildUrl('signAllTransactions', params);
|
|
227
212
|
utils.PlatformService.openURL(url);
|
|
@@ -240,7 +225,7 @@ class PhantomRedirect extends solanaCore.SolanaWalletConnector {
|
|
|
240
225
|
dapp_encryption_public_key: bs58__default["default"].encode(encryptionPublicKey),
|
|
241
226
|
nonce: bs58__default["default"].encode(nonce),
|
|
242
227
|
payload: bs58__default["default"].encode(encryptedPayload),
|
|
243
|
-
redirect_link:
|
|
228
|
+
redirect_link: clearRedirectUrlForPhantom.clearRedirectUrlForPhantom(utils.PlatformService.getUrl()),
|
|
244
229
|
});
|
|
245
230
|
const url = buildUrl.buildUrl('signAndSendTransaction', params);
|
|
246
231
|
storage.storage.method.set('signAndSendTransaction');
|
|
@@ -259,7 +244,7 @@ class PhantomRedirect extends solanaCore.SolanaWalletConnector {
|
|
|
259
244
|
dapp_encryption_public_key: bs58__default["default"].encode(encryptionPublicKey),
|
|
260
245
|
nonce: bs58__default["default"].encode(nonce),
|
|
261
246
|
payload: bs58__default["default"].encode(encryptedPayload),
|
|
262
|
-
redirect_link:
|
|
247
|
+
redirect_link: clearRedirectUrlForPhantom.clearRedirectUrlForPhantom(utils.PlatformService.getUrl()),
|
|
263
248
|
});
|
|
264
249
|
const url = buildUrl.buildUrl('signMessage', params);
|
|
265
250
|
utils.PlatformService.openURL(url);
|
|
@@ -280,7 +265,7 @@ class PhantomRedirect extends solanaCore.SolanaWalletConnector {
|
|
|
280
265
|
dapp_encryption_public_key: bs58__default["default"].encode(encryptionPublicKey),
|
|
281
266
|
nonce: bs58__default["default"].encode(nonce),
|
|
282
267
|
payload: bs58__default["default"].encode(encryptedPayload),
|
|
283
|
-
redirect_link:
|
|
268
|
+
redirect_link: clearRedirectUrlForPhantom.clearRedirectUrlForPhantom(utils.PlatformService.getUrl()),
|
|
284
269
|
});
|
|
285
270
|
const url = buildUrl.buildUrl('signTransaction', params);
|
|
286
271
|
utils.PlatformService.openURL(url);
|
|
@@ -312,7 +297,7 @@ class PhantomRedirect extends solanaCore.SolanaWalletConnector {
|
|
|
312
297
|
dapp_encryption_public_key: bs58__default["default"].encode(encryptionPublicKey),
|
|
313
298
|
nonce: bs58__default["default"].encode(nonce),
|
|
314
299
|
payload: bs58__default["default"].encode(encryptedPayload),
|
|
315
|
-
redirect_link:
|
|
300
|
+
redirect_link: clearRedirectUrlForPhantom.clearRedirectUrlForPhantom(utils.PlatformService.getUrl()),
|
|
316
301
|
});
|
|
317
302
|
const url = buildUrl.buildUrl('disconnect', params);
|
|
318
303
|
utils.PlatformService.openURL(url);
|
|
@@ -331,7 +316,7 @@ class PhantomRedirect extends solanaCore.SolanaWalletConnector {
|
|
|
331
316
|
*/
|
|
332
317
|
getInputsOrThrow(methodName, queryParams, storageParams) {
|
|
333
318
|
const inputs = {};
|
|
334
|
-
const queryString =
|
|
319
|
+
const queryString = utils.PlatformService.getUrl().searchParams;
|
|
335
320
|
queryParams.forEach((param) => {
|
|
336
321
|
const value = queryString.get(param);
|
|
337
322
|
if (!value) {
|
|
@@ -9,6 +9,7 @@ import { buildUrl } from '../buildUrl/buildUrl.js';
|
|
|
9
9
|
import { decryptPayload } from '../decryptPayload/decryptPayload.js';
|
|
10
10
|
import { encryptPayload } from '../encryptPayload/encryptPayload.js';
|
|
11
11
|
import { storage, clearStorage } from '../storage/storage.js';
|
|
12
|
+
import { clearRedirectUrlForPhantom } from '../clearRedirectUrlForPhantom/clearRedirectUrlForPhantom.js';
|
|
12
13
|
|
|
13
14
|
class PhantomRedirect extends SolanaWalletConnector {
|
|
14
15
|
constructor(props) {
|
|
@@ -48,16 +49,17 @@ class PhantomRedirect extends SolanaWalletConnector {
|
|
|
48
49
|
const keyPair = nacl.box.keyPair();
|
|
49
50
|
storage.encryptionPublicKey.set(keyPair.publicKey);
|
|
50
51
|
storage.encryptionSecretKey.set(keyPair.secretKey);
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
const { href } = PlatformService.getUrl();
|
|
53
|
+
const isLocalHost = href.includes('localhost') ||
|
|
54
|
+
href.includes('0.0.0.0') ||
|
|
55
|
+
href.includes('127.0.0.1');
|
|
54
56
|
const currentNetwork = this.getSelectedNetwork();
|
|
55
57
|
const cluster = (_a = currentNetwork === null || currentNetwork === void 0 ? void 0 : currentNetwork.cluster) !== null && _a !== void 0 ? _a : 'mainnet-beta';
|
|
56
58
|
const params = new URLSearchParams({
|
|
57
|
-
app_url: isLocalHost ? 'https://demo.dynamic.xyz' :
|
|
59
|
+
app_url: isLocalHost ? 'https://demo.dynamic.xyz' : href,
|
|
58
60
|
cluster,
|
|
59
61
|
dapp_encryption_public_key: bs58.encode(keyPair.publicKey),
|
|
60
|
-
redirect_link:
|
|
62
|
+
redirect_link: clearRedirectUrlForPhantom(PlatformService.getUrl()),
|
|
61
63
|
});
|
|
62
64
|
const url = buildUrl('connect', params);
|
|
63
65
|
PlatformService.openURL(url);
|
|
@@ -65,17 +67,12 @@ class PhantomRedirect extends SolanaWalletConnector {
|
|
|
65
67
|
}
|
|
66
68
|
getSession() {
|
|
67
69
|
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
-
const params = new URLSearchParams(window.location.search);
|
|
69
70
|
const { data, nonce, phantom_encryption_public_key: phantomEncryptionPublicKey, encryptionSecretKey, } = this.getInputsOrThrow('getSession', ['data', 'nonce', 'phantom_encryption_public_key'], ['encryptionSecretKey']);
|
|
70
71
|
const sharedSecret = nacl.box.before(bs58.decode(phantomEncryptionPublicKey), encryptionSecretKey);
|
|
71
72
|
storage.sharedSecret.set(sharedSecret);
|
|
72
73
|
const connectData = decryptPayload(data, nonce, sharedSecret);
|
|
73
74
|
storage.session.set(connectData.session);
|
|
74
75
|
storage.address.set(new PublicKey(connectData.public_key));
|
|
75
|
-
params.delete('phantom_encryption_public_key');
|
|
76
|
-
params.delete('data');
|
|
77
|
-
params.delete('nonce');
|
|
78
|
-
history.replaceState(null, '', `${window.location.origin}${window.location.pathname}?${params.toString()}`);
|
|
79
76
|
return connectData.public_key;
|
|
80
77
|
});
|
|
81
78
|
}
|
|
@@ -92,7 +89,7 @@ class PhantomRedirect extends SolanaWalletConnector {
|
|
|
92
89
|
dapp_encryption_public_key: bs58.encode(encryptionPublicKey),
|
|
93
90
|
nonce: bs58.encode(nonce),
|
|
94
91
|
payload: bs58.encode(encryptedPayload),
|
|
95
|
-
redirect_link:
|
|
92
|
+
redirect_link: clearRedirectUrlForPhantom(PlatformService.getUrl()),
|
|
96
93
|
});
|
|
97
94
|
const url = buildUrl('signMessage', params);
|
|
98
95
|
storage.method.set('signMessage');
|
|
@@ -109,35 +106,23 @@ class PhantomRedirect extends SolanaWalletConnector {
|
|
|
109
106
|
});
|
|
110
107
|
}
|
|
111
108
|
extractSignature() {
|
|
112
|
-
const params = new URLSearchParams(window.location.search);
|
|
113
109
|
const { data, nonce, sharedSecret, message } = this.getInputsOrThrow('extractSignature', ['data', 'nonce'], ['sharedSecret', 'message']);
|
|
114
110
|
const signMessageData = decryptPayload(data, nonce, sharedSecret);
|
|
115
|
-
params.delete('data');
|
|
116
|
-
params.delete('nonce');
|
|
117
|
-
history.replaceState(null, '', `${window.location.origin}${window.location.pathname}?${params.toString()}`);
|
|
118
111
|
return {
|
|
119
112
|
message,
|
|
120
113
|
signature: signMessageData.signature,
|
|
121
114
|
};
|
|
122
115
|
}
|
|
123
116
|
extractTransactions() {
|
|
124
|
-
const params = new URLSearchParams(window.location.search);
|
|
125
117
|
const { data, nonce, sharedSecret } = this.getInputsOrThrow('extractTransactions', ['data', 'nonce'], ['sharedSecret']);
|
|
126
118
|
const signAllTransactionsData = decryptPayload(data, nonce, sharedSecret);
|
|
127
119
|
const decodedTransactions = signAllTransactionsData.transactions.map((t) => Transaction.from(bs58.decode(t)));
|
|
128
|
-
params.delete('data');
|
|
129
|
-
params.delete('nonce');
|
|
130
|
-
history.replaceState(null, '', `${window.location.origin}${window.location.pathname}?${params.toString()}`);
|
|
131
120
|
return decodedTransactions;
|
|
132
121
|
}
|
|
133
122
|
extractTransaction() {
|
|
134
|
-
const params = new URLSearchParams(window.location.search);
|
|
135
123
|
const { data, nonce, sharedSecret } = this.getInputsOrThrow('extractTransaction', ['data', 'nonce'], ['sharedSecret']);
|
|
136
124
|
const signTransactionData = decryptPayload(data, nonce, sharedSecret);
|
|
137
125
|
const decodedTransaction = Transaction.from(bs58.decode(signTransactionData.transaction));
|
|
138
|
-
params.delete('data');
|
|
139
|
-
params.delete('nonce');
|
|
140
|
-
history.replaceState(null, '', `${window.location.origin}${window.location.pathname}?${params.toString()}`);
|
|
141
126
|
return decodedTransaction;
|
|
142
127
|
}
|
|
143
128
|
consumeMethod() {
|
|
@@ -212,7 +197,7 @@ class PhantomRedirect extends SolanaWalletConnector {
|
|
|
212
197
|
dapp_encryption_public_key: bs58.encode(encryptionPublicKey),
|
|
213
198
|
nonce: bs58.encode(nonce),
|
|
214
199
|
payload: bs58.encode(encryptedPayload),
|
|
215
|
-
redirect_link:
|
|
200
|
+
redirect_link: clearRedirectUrlForPhantom(PlatformService.getUrl()),
|
|
216
201
|
});
|
|
217
202
|
const url = buildUrl('signAllTransactions', params);
|
|
218
203
|
PlatformService.openURL(url);
|
|
@@ -231,7 +216,7 @@ class PhantomRedirect extends SolanaWalletConnector {
|
|
|
231
216
|
dapp_encryption_public_key: bs58.encode(encryptionPublicKey),
|
|
232
217
|
nonce: bs58.encode(nonce),
|
|
233
218
|
payload: bs58.encode(encryptedPayload),
|
|
234
|
-
redirect_link:
|
|
219
|
+
redirect_link: clearRedirectUrlForPhantom(PlatformService.getUrl()),
|
|
235
220
|
});
|
|
236
221
|
const url = buildUrl('signAndSendTransaction', params);
|
|
237
222
|
storage.method.set('signAndSendTransaction');
|
|
@@ -250,7 +235,7 @@ class PhantomRedirect extends SolanaWalletConnector {
|
|
|
250
235
|
dapp_encryption_public_key: bs58.encode(encryptionPublicKey),
|
|
251
236
|
nonce: bs58.encode(nonce),
|
|
252
237
|
payload: bs58.encode(encryptedPayload),
|
|
253
|
-
redirect_link:
|
|
238
|
+
redirect_link: clearRedirectUrlForPhantom(PlatformService.getUrl()),
|
|
254
239
|
});
|
|
255
240
|
const url = buildUrl('signMessage', params);
|
|
256
241
|
PlatformService.openURL(url);
|
|
@@ -271,7 +256,7 @@ class PhantomRedirect extends SolanaWalletConnector {
|
|
|
271
256
|
dapp_encryption_public_key: bs58.encode(encryptionPublicKey),
|
|
272
257
|
nonce: bs58.encode(nonce),
|
|
273
258
|
payload: bs58.encode(encryptedPayload),
|
|
274
|
-
redirect_link:
|
|
259
|
+
redirect_link: clearRedirectUrlForPhantom(PlatformService.getUrl()),
|
|
275
260
|
});
|
|
276
261
|
const url = buildUrl('signTransaction', params);
|
|
277
262
|
PlatformService.openURL(url);
|
|
@@ -303,7 +288,7 @@ class PhantomRedirect extends SolanaWalletConnector {
|
|
|
303
288
|
dapp_encryption_public_key: bs58.encode(encryptionPublicKey),
|
|
304
289
|
nonce: bs58.encode(nonce),
|
|
305
290
|
payload: bs58.encode(encryptedPayload),
|
|
306
|
-
redirect_link:
|
|
291
|
+
redirect_link: clearRedirectUrlForPhantom(PlatformService.getUrl()),
|
|
307
292
|
});
|
|
308
293
|
const url = buildUrl('disconnect', params);
|
|
309
294
|
PlatformService.openURL(url);
|
|
@@ -322,7 +307,7 @@ class PhantomRedirect extends SolanaWalletConnector {
|
|
|
322
307
|
*/
|
|
323
308
|
getInputsOrThrow(methodName, queryParams, storageParams) {
|
|
324
309
|
const inputs = {};
|
|
325
|
-
const queryString =
|
|
310
|
+
const queryString = PlatformService.getUrl().searchParams;
|
|
326
311
|
queryParams.forEach((param) => {
|
|
327
312
|
const value = queryString.get(param);
|
|
328
313
|
if (!value) {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Clear the redirect link phantom will use to return to the dapp
|
|
8
|
+
*
|
|
9
|
+
* This is necessary because the redirect link is used to return to the dapp
|
|
10
|
+
* and it contains params that cause issues when the SDK is loading.
|
|
11
|
+
* For example the redirect may include the errorCode or errorMessage which
|
|
12
|
+
* will cause the SDK to throw an error and not complete the redirect.
|
|
13
|
+
*/
|
|
14
|
+
const clearRedirectUrlForPhantom = (url) => {
|
|
15
|
+
const phantomUrlParamsToRemove = [
|
|
16
|
+
'data',
|
|
17
|
+
'nonce',
|
|
18
|
+
'phantom_encryption_public_key',
|
|
19
|
+
'errorCode',
|
|
20
|
+
'errorMessage',
|
|
21
|
+
'data',
|
|
22
|
+
];
|
|
23
|
+
phantomUrlParamsToRemove.forEach((param) => {
|
|
24
|
+
url.searchParams.delete(param);
|
|
25
|
+
});
|
|
26
|
+
return url.toString();
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
exports.clearRedirectUrlForPhantom = clearRedirectUrlForPhantom;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clear the redirect link phantom will use to return to the dapp
|
|
3
|
+
*
|
|
4
|
+
* This is necessary because the redirect link is used to return to the dapp
|
|
5
|
+
* and it contains params that cause issues when the SDK is loading.
|
|
6
|
+
* For example the redirect may include the errorCode or errorMessage which
|
|
7
|
+
* will cause the SDK to throw an error and not complete the redirect.
|
|
8
|
+
*/
|
|
9
|
+
export declare const clearRedirectUrlForPhantom: (url: URL) => string;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
/**
|
|
3
|
+
* Clear the redirect link phantom will use to return to the dapp
|
|
4
|
+
*
|
|
5
|
+
* This is necessary because the redirect link is used to return to the dapp
|
|
6
|
+
* and it contains params that cause issues when the SDK is loading.
|
|
7
|
+
* For example the redirect may include the errorCode or errorMessage which
|
|
8
|
+
* will cause the SDK to throw an error and not complete the redirect.
|
|
9
|
+
*/
|
|
10
|
+
const clearRedirectUrlForPhantom = (url) => {
|
|
11
|
+
const phantomUrlParamsToRemove = [
|
|
12
|
+
'data',
|
|
13
|
+
'nonce',
|
|
14
|
+
'phantom_encryption_public_key',
|
|
15
|
+
'errorCode',
|
|
16
|
+
'errorMessage',
|
|
17
|
+
'data',
|
|
18
|
+
];
|
|
19
|
+
phantomUrlParamsToRemove.forEach((param) => {
|
|
20
|
+
url.searchParams.delete(param);
|
|
21
|
+
});
|
|
22
|
+
return url.toString();
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export { clearRedirectUrlForPhantom };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { clearRedirectUrlForPhantom } from './clearRedirectUrlForPhantom';
|