@dynamic-labs/solana 4.0.0-alpha.2 → 4.0.0-alpha.21
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 +185 -0
- package/package.cjs +8 -0
- package/package.js +4 -0
- package/package.json +12 -18
- package/src/CoinbaseSolana.cjs +1 -6
- package/src/CoinbaseSolana.js +1 -6
- package/src/Phantom.cjs +1 -1
- package/src/Phantom.js +1 -1
- package/src/SolanaWalletStandardConnector/SolanaWalletStandardConnector.cjs +1 -1
- package/src/SolanaWalletStandardConnector/SolanaWalletStandardConnector.js +1 -1
- package/src/SolanaWalletStandardConnector/utils/createSolanaSignerFromWalletStandard/createSolanaSignerFromWalletStandard.cjs +2 -2
- package/src/SolanaWalletStandardConnector/utils/createSolanaSignerFromWalletStandard/createSolanaSignerFromWalletStandard.d.ts +1 -1
- package/src/SolanaWalletStandardConnector/utils/createSolanaSignerFromWalletStandard/createSolanaSignerFromWalletStandard.js +1 -1
- package/src/index.cjs +5 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +4 -0
- package/src/phantomRedirect/{PhantomRedirect.cjs → PhantomRedirect/PhantomRedirect.cjs} +27 -24
- package/src/phantomRedirect/{PhantomRedirect.d.ts → PhantomRedirect/PhantomRedirect.d.ts} +2 -2
- package/src/phantomRedirect/{PhantomRedirect.js → PhantomRedirect/PhantomRedirect.js} +8 -5
- package/src/phantomRedirect/PhantomRedirect/index.d.ts +1 -0
- package/src/phantomRedirect/buildUrl/buildUrl.cjs +8 -0
- package/src/phantomRedirect/buildUrl/buildUrl.d.ts +1 -0
- package/src/phantomRedirect/buildUrl/buildUrl.js +4 -0
- package/src/phantomRedirect/buildUrl/index.d.ts +1 -0
- package/src/phantomRedirect/decryptPayload/decryptPayload.cjs +34 -0
- package/src/phantomRedirect/decryptPayload/decryptPayload.d.ts +1 -0
- package/src/phantomRedirect/decryptPayload/decryptPayload.js +25 -0
- package/src/phantomRedirect/decryptPayload/index.d.ts +1 -0
- package/src/phantomRedirect/encryptPayload/encryptPayload.cjs +18 -0
- package/src/phantomRedirect/encryptPayload/encryptPayload.d.ts +1 -0
- package/src/phantomRedirect/encryptPayload/encryptPayload.js +10 -0
- package/src/phantomRedirect/encryptPayload/index.d.ts +1 -0
- package/src/phantomRedirect/fetchCluster/fetchCluster.cjs +33 -0
- package/src/phantomRedirect/fetchCluster/fetchCluster.d.ts +1 -0
- package/src/phantomRedirect/fetchCluster/fetchCluster.js +29 -0
- package/src/phantomRedirect/fetchCluster/index.d.ts +1 -0
- package/src/phantomRedirect/storage/index.d.ts +1 -0
- package/src/phantomRedirect/{storage.d.ts → storage/storage.d.ts} +1 -1
- package/src/solProviderHelper.cjs +15 -2
- package/src/solProviderHelper.js +16 -3
- package/src/utils/logger.cjs +10 -0
- package/src/utils/logger.d.ts +2 -0
- package/src/utils/logger.js +6 -0
- package/src/phantomRedirect/utils.cjs +0 -56
- package/src/phantomRedirect/utils.d.ts +0 -4
- package/src/phantomRedirect/utils.js +0 -44
- /package/src/phantomRedirect/{storage.cjs → storage/storage.cjs} +0 -0
- /package/src/phantomRedirect/{storage.js → storage/storage.js} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,189 @@
|
|
|
1
1
|
|
|
2
|
+
## [4.0.0-alpha.21](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.20...v4.0.0-alpha.21) (2024-10-30)
|
|
3
|
+
|
|
4
|
+
## [4.0.0-alpha.20](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.19...v4.0.0-alpha.20) (2024-10-30)
|
|
5
|
+
|
|
6
|
+
## [4.0.0-alpha.19](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.18...v4.0.0-alpha.19) (2024-10-29)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* ensure the client js will emit a change event after the value update ([#7284](https://github.com/dynamic-labs/dynamic-auth/issues/7284)) ([930d2e9](https://github.com/dynamic-labs/dynamic-auth/commit/930d2e9fdc75fd4a38da8ef6efc9d3e29152285b))
|
|
12
|
+
|
|
13
|
+
## [4.0.0-alpha.18](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.17...v4.0.0-alpha.18) (2024-10-29)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* **web-extension:** add color scheme style to prevent broken style ([#7247](https://github.com/dynamic-labs/dynamic-auth/issues/7247)) ([c525c50](https://github.com/dynamic-labs/dynamic-auth/commit/c525c50ac02997f3baf220fd2e67c6c4b3d10903))
|
|
19
|
+
|
|
20
|
+
## [4.0.0-alpha.17](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.16...v4.0.0-alpha.17) (2024-10-28)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Features
|
|
24
|
+
|
|
25
|
+
* add support for eclipse ([#7255](https://github.com/dynamic-labs/dynamic-auth/issues/7255)) ([70e9830](https://github.com/dynamic-labs/dynamic-auth/commit/70e9830c6c801e0298825b914ee825b578350cf0))
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Bug Fixes
|
|
29
|
+
|
|
30
|
+
* adds missing packages to zerodev-extension package ([#7187](https://github.com/dynamic-labs/dynamic-auth/issues/7187)) ([052a7e7](https://github.com/dynamic-labs/dynamic-auth/commit/052a7e7c08d458996d1be56f7697448ad5a9a1c9))
|
|
31
|
+
* unpin reactivity package for vue projects ([#7246](https://github.com/dynamic-labs/dynamic-auth/issues/7246)) ([18013e0](https://github.com/dynamic-labs/dynamic-auth/commit/18013e00d6855f8b371c9edb97594a08764c3868))
|
|
32
|
+
|
|
33
|
+
## [4.0.0-alpha.16](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.15...v4.0.0-alpha.16) (2024-10-27)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
### Features
|
|
37
|
+
|
|
38
|
+
* add passkey to web-extension ([#7096](https://github.com/dynamic-labs/dynamic-auth/issues/7096)) ([a4b4643](https://github.com/dynamic-labs/dynamic-auth/commit/a4b4643e5307358425c878067bae095090f322ca))
|
|
39
|
+
* add social to web extension ([#7106](https://github.com/dynamic-labs/dynamic-auth/issues/7106)) ([422bc8e](https://github.com/dynamic-labs/dynamic-auth/commit/422bc8e2d276d960a7a76ad55a7b244c3fd83173))
|
|
40
|
+
* add support for compass and leap wallets ([9738749](https://github.com/dynamic-labs/dynamic-auth/commit/9738749bb5ed8e07a2582df255f683e4d408db93))
|
|
41
|
+
* add support for epicgames social ([#7220](https://github.com/dynamic-labs/dynamic-auth/issues/7220)) ([cb5bc30](https://github.com/dynamic-labs/dynamic-auth/commit/cb5bc30bc17d063bdaa9b427a9358b30124c4589))
|
|
42
|
+
* add web-extension to client ([#7180](https://github.com/dynamic-labs/dynamic-auth/issues/7180)) ([e2ccbb7](https://github.com/dynamic-labs/dynamic-auth/commit/e2ccbb77bdd0250d000a6cc4d89a2e5d7d2f4bb2))
|
|
43
|
+
|
|
44
|
+
## [4.0.0-alpha.15](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.14...v4.0.0-alpha.15) (2024-10-19)
|
|
45
|
+
|
|
46
|
+
## [4.0.0-alpha.14](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.13...v4.0.0-alpha.14) (2024-10-18)
|
|
47
|
+
|
|
48
|
+
## [4.0.0-alpha.13](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.12...v4.0.0-alpha.13) (2024-10-18)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
### Bug Fixes
|
|
52
|
+
|
|
53
|
+
* improve displayed chain name in network switcher ([#7153](https://github.com/dynamic-labs/dynamic-auth/issues/7153)) ([55d2e5a](https://github.com/dynamic-labs/dynamic-auth/commit/55d2e5a9954bf0255b5caf7aba7a6f1f2e215967))
|
|
54
|
+
|
|
55
|
+
## [4.0.0-alpha.12](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.11...v4.0.0-alpha.12) (2024-10-18)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
### Features
|
|
59
|
+
|
|
60
|
+
* add support for xverse account change event ([#7114](https://github.com/dynamic-labs/dynamic-auth/issues/7114)) ([79df047](https://github.com/dynamic-labs/dynamic-auth/commit/79df04775edb297a339e2d74adcc873584a6d8af))
|
|
61
|
+
* solana embedded signall headless ([#7132](https://github.com/dynamic-labs/dynamic-auth/issues/7132)) ([fe16b71](https://github.com/dynamic-labs/dynamic-auth/commit/fe16b71a4c0ad775f8de87ca899cfdd1071f11d6))
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
### Bug Fixes
|
|
65
|
+
|
|
66
|
+
* bug where embeddedWalletCreated event was fired before listener … ([#7151](https://github.com/dynamic-labs/dynamic-auth/issues/7151)) ([ae9da56](https://github.com/dynamic-labs/dynamic-auth/commit/ae9da56850130491384a2d5f47c1617815dcce5b))
|
|
67
|
+
* edge case where wallet book fails to load ([#7148](https://github.com/dynamic-labs/dynamic-auth/issues/7148)) ([805dc6d](https://github.com/dynamic-labs/dynamic-auth/commit/805dc6d7cc4cdf0b23748d82b3bd8216d88d55b5))
|
|
68
|
+
* issues where native currency icons were incorrect ([#7126](https://github.com/dynamic-labs/dynamic-auth/issues/7126)) ([8b8891a](https://github.com/dynamic-labs/dynamic-auth/commit/8b8891a52397e17cc127ea3a09ade14c4b70a8ee))
|
|
69
|
+
* remove now-unused sessionTimeout from useSocial ([#7123](https://github.com/dynamic-labs/dynamic-auth/issues/7123)) ([7959a8a](https://github.com/dynamic-labs/dynamic-auth/commit/7959a8a4c8ceb76c5c4f1ae91af204bf9c5cae7b))
|
|
70
|
+
* Revert: Update Exodus extension version " ([#7130](https://github.com/dynamic-labs/dynamic-auth/issues/7130)) ([f2274ae](https://github.com/dynamic-labs/dynamic-auth/commit/f2274aefd29bb9f3fb6de8493e4a5f73946a5600)), closes [#7129](https://github.com/dynamic-labs/dynamic-auth/issues/7129)
|
|
71
|
+
* use embedded primaryChain when passing undefined chains list to createTurnkeyWallet ([#7149](https://github.com/dynamic-labs/dynamic-auth/issues/7149)) ([c73a3ae](https://github.com/dynamic-labs/dynamic-auth/commit/c73a3aeeda8045b936d218f7078ad79967c321ef))
|
|
72
|
+
|
|
73
|
+
## [4.0.0-alpha.11](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.10...v4.0.0-alpha.11) (2024-10-15)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
### Bug Fixes
|
|
77
|
+
|
|
78
|
+
* missing null check in property accessor ([#7122](https://github.com/dynamic-labs/dynamic-auth/issues/7122)) ([bbb5e76](https://github.com/dynamic-labs/dynamic-auth/commit/bbb5e76c1284edad2829605444dda24971027a57))
|
|
79
|
+
|
|
80
|
+
## [4.0.0-alpha.10](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.9...v4.0.0-alpha.10) (2024-10-15)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
### Bug Fixes
|
|
84
|
+
|
|
85
|
+
* epicgames key name without dash ([#7119](https://github.com/dynamic-labs/dynamic-auth/issues/7119)) ([7388d6c](https://github.com/dynamic-labs/dynamic-auth/commit/7388d6cf98f6ee92e12003549dfd1ad81951119e))
|
|
86
|
+
|
|
87
|
+
## [4.0.0-alpha.9](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.8...v4.0.0-alpha.9) (2024-10-11)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
### Features
|
|
91
|
+
|
|
92
|
+
* add support for fordefi wallet ([#7109](https://github.com/dynamic-labs/dynamic-auth/issues/7109)) ([1adb6b1](https://github.com/dynamic-labs/dynamic-auth/commit/1adb6b15b7f8e9156207ac7addf4368d27c1e371))
|
|
93
|
+
* support ability to define additional oauth scopes ([#7105](https://github.com/dynamic-labs/dynamic-auth/issues/7105)) ([b303203](https://github.com/dynamic-labs/dynamic-auth/commit/b303203e8041c0cbf5f8968df0d3cde04ed1b22a))
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
### Bug Fixes
|
|
97
|
+
|
|
98
|
+
* add eip6963 for exodus evm ([#7094](https://github.com/dynamic-labs/dynamic-auth/issues/7094)) ([c1ec5ef](https://github.com/dynamic-labs/dynamic-auth/commit/c1ec5ef4b6a531c563be4b690aa5f2bd4e7e6a16))
|
|
99
|
+
|
|
100
|
+
## [4.0.0-alpha.8](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.7...v4.0.0-alpha.8) (2024-10-07)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
### Features
|
|
104
|
+
|
|
105
|
+
* add support for dynamic event callbacks in rn ([#6997](https://github.com/dynamic-labs/dynamic-auth/issues/6997)) ([f9ac402](https://github.com/dynamic-labs/dynamic-auth/commit/f9ac40259d9168dfe69dafd5fd44478ba0e69505))
|
|
106
|
+
* add support for dynamic handlers in rn ([#7032](https://github.com/dynamic-labs/dynamic-auth/issues/7032)) ([f61f926](https://github.com/dynamic-labs/dynamic-auth/commit/f61f92666b6df8483dde2c47304fd4fb02690f7d))
|
|
107
|
+
* Support for multi-chain AA ([#6829](https://github.com/dynamic-labs/dynamic-auth/issues/6829)) ([b4a0c0a](https://github.com/dynamic-labs/dynamic-auth/commit/b4a0c0a4de48231a3748826600407c25abf6894d))
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
### Bug Fixes
|
|
111
|
+
|
|
112
|
+
* persist isHardwareWalletEnabled on wallet connector ([#7025](https://github.com/dynamic-labs/dynamic-auth/issues/7025)) ([#7034](https://github.com/dynamic-labs/dynamic-auth/issues/7034)) ([4bfc301](https://github.com/dynamic-labs/dynamic-auth/commit/4bfc301d891f10db8c0bd31e5164c489a882c5c3))
|
|
113
|
+
|
|
114
|
+
## [4.0.0-alpha.7](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.6...v4.0.0-alpha.7) (2024-10-03)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
### Features
|
|
118
|
+
|
|
119
|
+
* add account abstraction module to client ([#7002](https://github.com/dynamic-labs/dynamic-auth/issues/7002)) ([2f06975](https://github.com/dynamic-labs/dynamic-auth/commit/2f06975083dfa9d40537ef4a99b414eda1a68e01))
|
|
120
|
+
* add support for wallet events in rn ([#7061](https://github.com/dynamic-labs/dynamic-auth/issues/7061)) ([c7c4ce5](https://github.com/dynamic-labs/dynamic-auth/commit/c7c4ce51f27a2b84a1710c120d7006a00920c1e7))
|
|
121
|
+
* add zerodev extension for react native ([#7028](https://github.com/dynamic-labs/dynamic-auth/issues/7028)) ([858b8a8](https://github.com/dynamic-labs/dynamic-auth/commit/858b8a851cfa0cddc8e4559541b03992cf5ccdfc))
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
### Bug Fixes
|
|
125
|
+
|
|
126
|
+
* do not modify sol tx blockhash as tx could have been signed already ([#7050](https://github.com/dynamic-labs/dynamic-auth/issues/7050)) ([770edb4](https://github.com/dynamic-labs/dynamic-auth/commit/770edb49ddc231b75fb45a9f6d563f22e5185df2))
|
|
127
|
+
* ensure the correct auth mode is used on social redirect ([#7047](https://github.com/dynamic-labs/dynamic-auth/issues/7047)) ([7c27172](https://github.com/dynamic-labs/dynamic-auth/commit/7c271721d5ddf19e3fd1bf56ddb1d49e0e2bca07))
|
|
128
|
+
* prevent react native message timeout before sdk is ready ([#7051](https://github.com/dynamic-labs/dynamic-auth/issues/7051)) ([6421237](https://github.com/dynamic-labs/dynamic-auth/commit/6421237d677d788b824d53432c1a75b9d571aa78))
|
|
129
|
+
* update version error text ([#7054](https://github.com/dynamic-labs/dynamic-auth/issues/7054)) ([713dacb](https://github.com/dynamic-labs/dynamic-auth/commit/713dacb79c2513323c2e6840d7418716011c2dcd))
|
|
130
|
+
* use project settings sdk network for send flow ([#7011](https://github.com/dynamic-labs/dynamic-auth/issues/7011)) ([983e796](https://github.com/dynamic-labs/dynamic-auth/commit/983e79632762f71ee0502c92057a32ea985ae19c))
|
|
131
|
+
|
|
132
|
+
## [4.0.0-alpha.6](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.5...v4.0.0-alpha.6) (2024-10-01)
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
### ⚠ BREAKING CHANGES
|
|
136
|
+
|
|
137
|
+
* remove support to magic ([#7033](https://github.com/dynamic-labs/dynamic-auth/issues/7033)) ([0fdc41f](https://github.com/dynamic-labs/dynamic-auth/commit/0fdc41f05f87b32f56b73db068f984f18bdf69a0))
|
|
138
|
+
|
|
139
|
+
### Features
|
|
140
|
+
|
|
141
|
+
* global connectivity disconnect ([#7008](https://github.com/dynamic-labs/dynamic-auth/issues/7008)) ([80d705b](https://github.com/dynamic-labs/dynamic-auth/commit/80d705ba252aa3b01cbf4861507fed00e460215f))
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
### Bug Fixes
|
|
145
|
+
|
|
146
|
+
* add popper context to send balance ([#7016](https://github.com/dynamic-labs/dynamic-auth/issues/7016)) ([73aa6f1](https://github.com/dynamic-labs/dynamic-auth/commit/73aa6f122afe0db660ebb654f3e018ae7bf445c5))
|
|
147
|
+
* add retry to useConnectWithOtp ([#7012](https://github.com/dynamic-labs/dynamic-auth/issues/7012)) ([d551d72](https://github.com/dynamic-labs/dynamic-auth/commit/d551d72a463f8a03964858b30ec174d41985a7b1))
|
|
148
|
+
* don't re-fetch wallet address on network change ([#7019](https://github.com/dynamic-labs/dynamic-auth/issues/7019)) ([4e7900c](https://github.com/dynamic-labs/dynamic-auth/commit/4e7900cc24b3abda736bc81466eda7512cf7fc61))
|
|
149
|
+
* fix sign message with solana wallet standard provider ([#7014](https://github.com/dynamic-labs/dynamic-auth/issues/7014)) ([ffaf972](https://github.com/dynamic-labs/dynamic-auth/commit/ffaf972e8b190b0b8cd0103e0ef67bfdee6c8f7c))
|
|
150
|
+
* update wallet reference when user switches wallet in connect-only ([#7030](https://github.com/dynamic-labs/dynamic-auth/issues/7030)) ([75d9aa6](https://github.com/dynamic-labs/dynamic-auth/commit/75d9aa66f63fc5536caeff12d8b860c0ba86106f))
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
## [4.0.0-alpha.5](https://github.com/dynamic-labs/DynamicAuth/compare/v4.0.0-alpha.4...v4.0.0-alpha.5) (2024-09-25)
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
### Features
|
|
157
|
+
|
|
158
|
+
* add isInstalledOnBrowser prop to wallet options in useWalletOptions ([#6976](https://github.com/dynamic-labs/DynamicAuth/issues/6976)) ([0fda409](https://github.com/dynamic-labs/DynamicAuth/commit/0fda409b293c83d73869d791c3d38ac421dcdecb))
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
### Bug Fixes
|
|
162
|
+
|
|
163
|
+
* **client:** return user profile when using sign in with external jwt ([#7004](https://github.com/dynamic-labs/DynamicAuth/issues/7004)) ([927cfb6](https://github.com/dynamic-labs/DynamicAuth/commit/927cfb69f3dd7f8b00e3f0f975277a84c99c830b))
|
|
164
|
+
* react-native-extension to include esm ([#6965](https://github.com/dynamic-labs/DynamicAuth/issues/6965)) ([336825b](https://github.com/dynamic-labs/DynamicAuth/commit/336825b50142002bbc67c6f8850bd63030bf384b))
|
|
165
|
+
|
|
166
|
+
## [4.0.0-alpha.4](https://github.com/dynamic-labs/DynamicAuth/compare/v4.0.0-alpha.3...v4.0.0-alpha.4) (2024-09-23)
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
### Bug Fixes
|
|
170
|
+
|
|
171
|
+
* issue where builtin stream module was a dependency ([#6968](https://github.com/dynamic-labs/DynamicAuth/issues/6968)) ([0661129](https://github.com/dynamic-labs/DynamicAuth/commit/0661129920ba70ebbcd4d17ee5aa988c51d1b477))
|
|
172
|
+
* update in memory secure storage ([#6955](https://github.com/dynamic-labs/DynamicAuth/issues/6955)) ([697fc20](https://github.com/dynamic-labs/DynamicAuth/commit/697fc20740b243fa31ecf06e8b2ed9d09932a544))
|
|
173
|
+
|
|
174
|
+
## [4.0.0-alpha.3](https://github.com/dynamic-labs/DynamicAuth/compare/v4.0.0-alpha.2...v4.0.0-alpha.3) (2024-09-20)
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
### Features
|
|
178
|
+
|
|
179
|
+
* developers provide global connectivity appkit project id ([#6941](https://github.com/dynamic-labs/DynamicAuth/issues/6941)) ([83760ea](https://github.com/dynamic-labs/DynamicAuth/commit/83760ea57591685b12caee945f173f6a7f9312d1))
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
### Bug Fixes
|
|
183
|
+
|
|
184
|
+
* don't try to set up event listeners if wallet provider doesn't support it ([#6943](https://github.com/dynamic-labs/DynamicAuth/issues/6943)) ([439f1bb](https://github.com/dynamic-labs/DynamicAuth/commit/439f1bbb3c765959756cfc6eeb8429e4018e0379))
|
|
185
|
+
* dont verify all signatures for solana embedded multisig tx ([#6953](https://github.com/dynamic-labs/DynamicAuth/issues/6953)) ([7a7973e](https://github.com/dynamic-labs/DynamicAuth/commit/7a7973e05f0960421b348a55c6a00c9fd873b0b7))
|
|
186
|
+
|
|
2
187
|
## [4.0.0-alpha.2](https://github.com/dynamic-labs/DynamicAuth/compare/v4.0.0-alpha.1...v4.0.0-alpha.2) (2024-09-18)
|
|
3
188
|
|
|
4
189
|
|
package/package.cjs
ADDED
package/package.js
ADDED
package/package.json
CHANGED
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/solana",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
4
|
-
"repository": {
|
|
5
|
-
"type": "git",
|
|
6
|
-
"url": "git+https://github.com/dynamic-labs/dynamic-auth.git",
|
|
7
|
-
"directory": "packages/solana"
|
|
8
|
-
},
|
|
3
|
+
"version": "4.0.0-alpha.21",
|
|
9
4
|
"description": "A React SDK for implementing wallet web3 authentication and authorization to your website.",
|
|
10
|
-
"bugs": {
|
|
11
|
-
"url": "https://github.com/dynamic-labs/DynamicAuth/issues"
|
|
12
|
-
},
|
|
13
|
-
"homepage": "https://github.com/dynamic-labs/DynamicAuth#readme",
|
|
14
5
|
"author": "Dynamic Labs, Inc.",
|
|
15
6
|
"license": "MIT",
|
|
16
7
|
"main": "./src/index.cjs",
|
|
@@ -25,6 +16,7 @@
|
|
|
25
16
|
},
|
|
26
17
|
"./package.json": "./package.json"
|
|
27
18
|
},
|
|
19
|
+
"homepage": "https://www.dynamic.xyz/",
|
|
28
20
|
"dependencies": {
|
|
29
21
|
"@solana/web3.js": "1.92.1",
|
|
30
22
|
"@wallet-standard/app": "1.0.1",
|
|
@@ -33,14 +25,16 @@
|
|
|
33
25
|
"@wallet-standard/experimental-features": "0.1.1",
|
|
34
26
|
"bs58": "5.0.0",
|
|
35
27
|
"tweetnacl": "1.0.3",
|
|
36
|
-
"@dynamic-labs/
|
|
37
|
-
"@dynamic-labs/
|
|
38
|
-
"@dynamic-labs/
|
|
39
|
-
"@dynamic-labs/
|
|
40
|
-
"@dynamic-labs/
|
|
41
|
-
"@dynamic-labs/
|
|
42
|
-
"@dynamic-labs/
|
|
43
|
-
"@dynamic-labs/
|
|
28
|
+
"@dynamic-labs/assert-package-version": "4.0.0-alpha.21",
|
|
29
|
+
"@dynamic-labs/embedded-wallet-solana": "4.0.0-alpha.21",
|
|
30
|
+
"@dynamic-labs/logger": "4.0.0-alpha.21",
|
|
31
|
+
"@dynamic-labs/rpc-providers": "4.0.0-alpha.21",
|
|
32
|
+
"@dynamic-labs/sdk-api-core": "0.0.559",
|
|
33
|
+
"@dynamic-labs/solana-core": "4.0.0-alpha.21",
|
|
34
|
+
"@dynamic-labs/types": "4.0.0-alpha.21",
|
|
35
|
+
"@dynamic-labs/utils": "4.0.0-alpha.21",
|
|
36
|
+
"@dynamic-labs/wallet-book": "4.0.0-alpha.21",
|
|
37
|
+
"@dynamic-labs/wallet-connector-core": "4.0.0-alpha.21"
|
|
44
38
|
},
|
|
45
39
|
"peerDependencies": {}
|
|
46
40
|
}
|
package/src/CoinbaseSolana.cjs
CHANGED
|
@@ -6,13 +6,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
6
6
|
var _tslib = require('../_virtual/_tslib.cjs');
|
|
7
7
|
var utils = require('@dynamic-labs/utils');
|
|
8
8
|
var walletBook = require('@dynamic-labs/wallet-book');
|
|
9
|
-
require('
|
|
10
|
-
require('@dynamic-labs/solana-core');
|
|
11
|
-
require('tweetnacl');
|
|
12
|
-
require('bs58');
|
|
13
|
-
require('@solana/web3.js');
|
|
9
|
+
require('./index.cjs');
|
|
14
10
|
var InjectedWalletBase = require('./injected/InjectedWalletBase.cjs');
|
|
15
|
-
require('./SolanaWalletStandardConnector/SolanaWalletStandardConnector.cjs');
|
|
16
11
|
var isSignedMessage = require('./utils/isSignedMessage.cjs');
|
|
17
12
|
|
|
18
13
|
class CoinbaseSolana extends InjectedWalletBase.InjectedWalletBase {
|
package/src/CoinbaseSolana.js
CHANGED
|
@@ -2,13 +2,8 @@
|
|
|
2
2
|
import { __awaiter } from '../_virtual/_tslib.js';
|
|
3
3
|
import { bufferToBase64 } from '@dynamic-labs/utils';
|
|
4
4
|
import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
|
|
5
|
-
import '
|
|
6
|
-
import '@dynamic-labs/solana-core';
|
|
7
|
-
import 'tweetnacl';
|
|
8
|
-
import 'bs58';
|
|
9
|
-
import '@solana/web3.js';
|
|
5
|
+
import './index.js';
|
|
10
6
|
import { InjectedWalletBase } from './injected/InjectedWalletBase.js';
|
|
11
|
-
import './SolanaWalletStandardConnector/SolanaWalletStandardConnector.js';
|
|
12
7
|
import { isSignedMessage } from './utils/isSignedMessage.js';
|
|
13
8
|
|
|
14
9
|
class CoinbaseSolana extends InjectedWalletBase {
|
package/src/Phantom.cjs
CHANGED
|
@@ -7,7 +7,7 @@ var _tslib = require('../_virtual/_tslib.cjs');
|
|
|
7
7
|
var walletBook = require('@dynamic-labs/wallet-book');
|
|
8
8
|
var utils = require('@dynamic-labs/utils');
|
|
9
9
|
var solanaCore = require('@dynamic-labs/solana-core');
|
|
10
|
-
var PhantomRedirect = require('./phantomRedirect/PhantomRedirect.cjs');
|
|
10
|
+
var PhantomRedirect = require('./phantomRedirect/PhantomRedirect/PhantomRedirect.cjs');
|
|
11
11
|
var PhantomInjected = require('./injected/PhantomInjected.cjs');
|
|
12
12
|
|
|
13
13
|
class Phantom extends solanaCore.SolWalletConnector {
|
package/src/Phantom.js
CHANGED
|
@@ -3,7 +3,7 @@ import { __awaiter } from '../_virtual/_tslib.js';
|
|
|
3
3
|
import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
|
|
4
4
|
import { isMobile } from '@dynamic-labs/utils';
|
|
5
5
|
import { SolWalletConnector } from '@dynamic-labs/solana-core';
|
|
6
|
-
import { PhantomRedirect } from './phantomRedirect/PhantomRedirect.js';
|
|
6
|
+
import { PhantomRedirect } from './phantomRedirect/PhantomRedirect/PhantomRedirect.js';
|
|
7
7
|
import { PhantomInjected } from './injected/PhantomInjected.js';
|
|
8
8
|
|
|
9
9
|
class Phantom extends SolWalletConnector {
|
|
@@ -58,7 +58,7 @@ class SolanaWalletStandardConnector extends solanaCore.SolWalletConnector {
|
|
|
58
58
|
throw new Error('Signer not found');
|
|
59
59
|
}
|
|
60
60
|
const message = encoder.encode(messageToSign);
|
|
61
|
-
const signature = yield signer.signMessage(message);
|
|
61
|
+
const { signature } = yield signer.signMessage(message);
|
|
62
62
|
if (!(signature instanceof Uint8Array)) {
|
|
63
63
|
throw new Error('Signature not found');
|
|
64
64
|
}
|
|
@@ -54,7 +54,7 @@ class SolanaWalletStandardConnector extends SolWalletConnector {
|
|
|
54
54
|
throw new Error('Signer not found');
|
|
55
55
|
}
|
|
56
56
|
const message = encoder.encode(messageToSign);
|
|
57
|
-
const signature = yield signer.signMessage(message);
|
|
57
|
+
const { signature } = yield signer.signMessage(message);
|
|
58
58
|
if (!(signature instanceof Uint8Array)) {
|
|
59
59
|
throw new Error('Signature not found');
|
|
60
60
|
}
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
|
|
6
6
|
var _tslib = require('../../../../_virtual/_tslib.cjs');
|
|
7
7
|
var web3_js = require('@solana/web3.js');
|
|
8
|
-
var
|
|
8
|
+
var fetchCluster = require('../../../phantomRedirect/fetchCluster/fetchCluster.cjs');
|
|
9
9
|
|
|
10
10
|
const isVersionedTransaction = (transaction) => !('instructions' in transaction);
|
|
11
11
|
const createSolanaSignerFromWalletStandard = (wallet, walletConnector) => {
|
|
@@ -21,7 +21,7 @@ const createSolanaSignerFromWalletStandard = (wallet, walletConnector) => {
|
|
|
21
21
|
const getChain = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
22
22
|
var _a, _b;
|
|
23
23
|
const rpc = (_b = (_a = walletConnector.solNetworks[0].privateCustomerRpcUrls) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : walletConnector.solNetworks[0].rpcUrls[0];
|
|
24
|
-
const cluster = yield
|
|
24
|
+
const cluster = yield fetchCluster.fetchCluster(rpc);
|
|
25
25
|
return `solana:${cluster}`;
|
|
26
26
|
});
|
|
27
27
|
const signTransaction = (transaction) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Wallet } from '@wallet-standard/base';
|
|
2
|
-
import {
|
|
2
|
+
import { ISolana, SolWalletConnector } from '@dynamic-labs/solana-core';
|
|
3
3
|
export declare const createSolanaSignerFromWalletStandard: (wallet: Wallet, walletConnector: SolWalletConnector) => ISolana;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../_virtual/_tslib.js';
|
|
3
3
|
import { PublicKey, VersionedTransaction, Transaction } from '@solana/web3.js';
|
|
4
|
-
import { fetchCluster } from '../../../phantomRedirect/
|
|
4
|
+
import { fetchCluster } from '../../../phantomRedirect/fetchCluster/fetchCluster.js';
|
|
5
5
|
|
|
6
6
|
const isVersionedTransaction = (transaction) => !('instructions' in transaction);
|
|
7
7
|
const createSolanaSignerFromWalletStandard = (wallet, walletConnector) => {
|
package/src/index.cjs
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
+
var assertPackageVersion = require('@dynamic-labs/assert-package-version');
|
|
6
7
|
var embeddedWalletSolana = require('@dynamic-labs/embedded-wallet-solana');
|
|
8
|
+
var _package = require('../package.cjs');
|
|
7
9
|
var Phantom = require('./Phantom.cjs');
|
|
8
10
|
var fetchInjectedWalletConnectors = require('./injected/fetchInjectedWalletConnectors.cjs');
|
|
9
11
|
var UnknownInjected = require('./injected/UnknownInjected.cjs');
|
|
@@ -11,8 +13,10 @@ var FallbackSolanaConnector = require('./injected/FallbackSolanaConnector.cjs');
|
|
|
11
13
|
var isSignedMessage = require('./utils/isSignedMessage.cjs');
|
|
12
14
|
var isBackpackSolanaSigner = require('./utils/isBackpackSolanaSigner.cjs');
|
|
13
15
|
var solanaCore = require('@dynamic-labs/solana-core');
|
|
16
|
+
var BackpackSol = require('./injected/BackpackSol.cjs');
|
|
14
17
|
|
|
15
18
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
19
|
+
assertPackageVersion.assertPackageVersion('@dynamic-labs/solana', _package.version);
|
|
16
20
|
const SolanaWalletConnectors = (props) => [
|
|
17
21
|
...fetchInjectedWalletConnectors.injectedWalletOverrides,
|
|
18
22
|
...fetchInjectedWalletConnectors.fetchInjectedWalletConnectors(props),
|
|
@@ -28,4 +32,5 @@ Object.defineProperty(exports, 'isSolanaWallet', {
|
|
|
28
32
|
enumerable: true,
|
|
29
33
|
get: function () { return solanaCore.isSolanaWallet; }
|
|
30
34
|
});
|
|
35
|
+
exports.BackpackConnector = BackpackSol.BackpackSol;
|
|
31
36
|
exports.SolanaWalletConnectors = SolanaWalletConnectors;
|
package/src/index.d.ts
CHANGED
|
@@ -4,3 +4,4 @@ export { isSignedMessage } from './utils/isSignedMessage';
|
|
|
4
4
|
export { isBackpackSolanaSigner } from './utils/isBackpackSolanaSigner';
|
|
5
5
|
export type { IEmbeddedWalletSolanaSigner } from '@dynamic-labs/embedded-wallet-solana';
|
|
6
6
|
export { isSolanaWallet } from '@dynamic-labs/solana-core';
|
|
7
|
+
export { BackpackSol as BackpackConnector } from './injected/BackpackSol';
|
package/src/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
|
+
import { assertPackageVersion } from '@dynamic-labs/assert-package-version';
|
|
2
3
|
import { TurnkeySolanaWalletConnectors } from '@dynamic-labs/embedded-wallet-solana';
|
|
4
|
+
import { version } from '../package.js';
|
|
3
5
|
import { Phantom } from './Phantom.js';
|
|
4
6
|
import { injectedWalletOverrides, fetchInjectedWalletConnectors } from './injected/fetchInjectedWalletConnectors.js';
|
|
5
7
|
import { UnknownInjected } from './injected/UnknownInjected.js';
|
|
@@ -7,8 +9,10 @@ import { FallbackSolanaConnector } from './injected/FallbackSolanaConnector.js';
|
|
|
7
9
|
export { isSignedMessage } from './utils/isSignedMessage.js';
|
|
8
10
|
export { isBackpackSolanaSigner } from './utils/isBackpackSolanaSigner.js';
|
|
9
11
|
export { isSolanaWallet } from '@dynamic-labs/solana-core';
|
|
12
|
+
export { BackpackSol as BackpackConnector } from './injected/BackpackSol.js';
|
|
10
13
|
|
|
11
14
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
15
|
+
assertPackageVersion('@dynamic-labs/solana', version);
|
|
12
16
|
const SolanaWalletConnectors = (props) => [
|
|
13
17
|
...injectedWalletOverrides,
|
|
14
18
|
...fetchInjectedWalletConnectors(props),
|
|
@@ -3,18 +3,21 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
-
var _tslib = require('
|
|
7
|
-
var nacl = require('tweetnacl');
|
|
8
|
-
var bs58 = require('bs58');
|
|
6
|
+
var _tslib = require('../../../_virtual/_tslib.cjs');
|
|
9
7
|
var web3_js = require('@solana/web3.js');
|
|
8
|
+
var bs58 = require('bs58');
|
|
9
|
+
var nacl = require('tweetnacl');
|
|
10
10
|
var solanaCore = require('@dynamic-labs/solana-core');
|
|
11
|
-
var
|
|
12
|
-
var
|
|
11
|
+
var buildUrl = require('../buildUrl/buildUrl.cjs');
|
|
12
|
+
var decryptPayload = require('../decryptPayload/decryptPayload.cjs');
|
|
13
|
+
var encryptPayload = require('../encryptPayload/encryptPayload.cjs');
|
|
14
|
+
var fetchCluster = require('../fetchCluster/fetchCluster.cjs');
|
|
15
|
+
var storage = require('../storage/storage.cjs');
|
|
13
16
|
|
|
14
17
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
15
18
|
|
|
16
|
-
var nacl__default = /*#__PURE__*/_interopDefaultLegacy(nacl);
|
|
17
19
|
var bs58__default = /*#__PURE__*/_interopDefaultLegacy(bs58);
|
|
20
|
+
var nacl__default = /*#__PURE__*/_interopDefaultLegacy(nacl);
|
|
18
21
|
|
|
19
22
|
class PhantomRedirect extends solanaCore.SolWalletConnector {
|
|
20
23
|
constructor(props) {
|
|
@@ -48,11 +51,11 @@ class PhantomRedirect extends solanaCore.SolWalletConnector {
|
|
|
48
51
|
const rpc = (_b = (_a = this.solNetworks[0].privateCustomerRpcUrls) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : this.solNetworks[0].rpcUrls[0];
|
|
49
52
|
const params = new URLSearchParams({
|
|
50
53
|
app_url: isLocalHost ? 'https://demo.dynamic.xyz' : window.location.href,
|
|
51
|
-
cluster: yield
|
|
54
|
+
cluster: yield fetchCluster.fetchCluster(rpc),
|
|
52
55
|
dapp_encryption_public_key: bs58__default["default"].encode(keyPair.publicKey),
|
|
53
56
|
redirect_link: window.location.href,
|
|
54
57
|
});
|
|
55
|
-
const url =
|
|
58
|
+
const url = buildUrl.buildUrl('connect', params);
|
|
56
59
|
window.location.href = url;
|
|
57
60
|
});
|
|
58
61
|
}
|
|
@@ -62,7 +65,7 @@ class PhantomRedirect extends solanaCore.SolWalletConnector {
|
|
|
62
65
|
const { data, nonce, phantom_encryption_public_key: phantomEncryptionPublicKey, encryptionSecretKey, } = this.getInputsOrThrow('getSession', ['data', 'nonce', 'phantom_encryption_public_key'], ['encryptionSecretKey']);
|
|
63
66
|
const sharedSecret = nacl__default["default"].box.before(bs58__default["default"].decode(phantomEncryptionPublicKey), encryptionSecretKey);
|
|
64
67
|
storage.storage.sharedSecret.set(sharedSecret);
|
|
65
|
-
const connectData =
|
|
68
|
+
const connectData = decryptPayload.decryptPayload(data, nonce, sharedSecret);
|
|
66
69
|
storage.storage.session.set(connectData.session);
|
|
67
70
|
storage.storage.address.set(new web3_js.PublicKey(connectData.public_key));
|
|
68
71
|
params.delete('phantom_encryption_public_key');
|
|
@@ -80,14 +83,14 @@ class PhantomRedirect extends solanaCore.SolWalletConnector {
|
|
|
80
83
|
message: bs58__default["default"].encode(Buffer.from(messageToSign)),
|
|
81
84
|
session,
|
|
82
85
|
};
|
|
83
|
-
const [nonce, encryptedPayload] =
|
|
86
|
+
const [nonce, encryptedPayload] = encryptPayload.encryptPayload(payload, sharedSecret);
|
|
84
87
|
const params = new URLSearchParams({
|
|
85
88
|
dapp_encryption_public_key: bs58__default["default"].encode(encryptionPublicKey),
|
|
86
89
|
nonce: bs58__default["default"].encode(nonce),
|
|
87
90
|
payload: bs58__default["default"].encode(encryptedPayload),
|
|
88
91
|
redirect_link: window.location.href,
|
|
89
92
|
});
|
|
90
|
-
const url =
|
|
93
|
+
const url = buildUrl.buildUrl('signMessage', params);
|
|
91
94
|
storage.storage.method.set('signMessage');
|
|
92
95
|
window.location.href = url;
|
|
93
96
|
// throwing this to prevent local storage from being cleared.
|
|
@@ -104,7 +107,7 @@ class PhantomRedirect extends solanaCore.SolWalletConnector {
|
|
|
104
107
|
extractSignature() {
|
|
105
108
|
const params = new URLSearchParams(window.location.search);
|
|
106
109
|
const { data, nonce, sharedSecret, message } = this.getInputsOrThrow('extractSignature', ['data', 'nonce'], ['sharedSecret', 'message']);
|
|
107
|
-
const signMessageData =
|
|
110
|
+
const signMessageData = decryptPayload.decryptPayload(data, nonce, sharedSecret);
|
|
108
111
|
params.delete('data');
|
|
109
112
|
params.delete('nonce');
|
|
110
113
|
history.replaceState(null, '', `${window.location.origin}${window.location.pathname}?${params.toString()}`);
|
|
@@ -116,7 +119,7 @@ class PhantomRedirect extends solanaCore.SolWalletConnector {
|
|
|
116
119
|
extractTransactions() {
|
|
117
120
|
const params = new URLSearchParams(window.location.search);
|
|
118
121
|
const { data, nonce, sharedSecret } = this.getInputsOrThrow('extractTransactions', ['data', 'nonce'], ['sharedSecret']);
|
|
119
|
-
const signAllTransactionsData =
|
|
122
|
+
const signAllTransactionsData = decryptPayload.decryptPayload(data, nonce, sharedSecret);
|
|
120
123
|
const decodedTransactions = signAllTransactionsData.transactions.map((t) => web3_js.Transaction.from(bs58__default["default"].decode(t)));
|
|
121
124
|
params.delete('data');
|
|
122
125
|
params.delete('nonce');
|
|
@@ -126,7 +129,7 @@ class PhantomRedirect extends solanaCore.SolWalletConnector {
|
|
|
126
129
|
extractTransaction() {
|
|
127
130
|
const params = new URLSearchParams(window.location.search);
|
|
128
131
|
const { data, nonce, sharedSecret } = this.getInputsOrThrow('extractTransaction', ['data', 'nonce'], ['sharedSecret']);
|
|
129
|
-
const signTransactionData =
|
|
132
|
+
const signTransactionData = decryptPayload.decryptPayload(data, nonce, sharedSecret);
|
|
130
133
|
const decodedTransaction = web3_js.Transaction.from(bs58__default["default"].decode(signTransactionData.transaction));
|
|
131
134
|
params.delete('data');
|
|
132
135
|
params.delete('nonce');
|
|
@@ -200,14 +203,14 @@ class PhantomRedirect extends solanaCore.SolWalletConnector {
|
|
|
200
203
|
session,
|
|
201
204
|
transactions: serializedTransactions,
|
|
202
205
|
};
|
|
203
|
-
const [nonce, encryptedPayload] =
|
|
206
|
+
const [nonce, encryptedPayload] = encryptPayload.encryptPayload(payload, sharedSecret);
|
|
204
207
|
const params = new URLSearchParams({
|
|
205
208
|
dapp_encryption_public_key: bs58__default["default"].encode(encryptionPublicKey),
|
|
206
209
|
nonce: bs58__default["default"].encode(nonce),
|
|
207
210
|
payload: bs58__default["default"].encode(encryptedPayload),
|
|
208
211
|
redirect_link: window.location.href,
|
|
209
212
|
});
|
|
210
|
-
const url =
|
|
213
|
+
const url = buildUrl.buildUrl('signAllTransactions', params);
|
|
211
214
|
window.location.href = url;
|
|
212
215
|
// actual signatures will be retrieved upon redirect back to dapp
|
|
213
216
|
return [];
|
|
@@ -219,14 +222,14 @@ class PhantomRedirect extends solanaCore.SolWalletConnector {
|
|
|
219
222
|
session,
|
|
220
223
|
transaction: bs58__default["default"].encode(transaction.serialize({ requireAllSignatures: false })),
|
|
221
224
|
};
|
|
222
|
-
const [nonce, encryptedPayload] =
|
|
225
|
+
const [nonce, encryptedPayload] = encryptPayload.encryptPayload(payload, sharedSecret);
|
|
223
226
|
const params = new URLSearchParams({
|
|
224
227
|
dapp_encryption_public_key: bs58__default["default"].encode(encryptionPublicKey),
|
|
225
228
|
nonce: bs58__default["default"].encode(nonce),
|
|
226
229
|
payload: bs58__default["default"].encode(encryptedPayload),
|
|
227
230
|
redirect_link: window.location.href,
|
|
228
231
|
});
|
|
229
|
-
const url =
|
|
232
|
+
const url = buildUrl.buildUrl('signAndSendTransaction', params);
|
|
230
233
|
storage.storage.method.set('signAndSendTransaction');
|
|
231
234
|
window.location.href = url;
|
|
232
235
|
// actual signature will be retrived upon redirect back to dapp
|
|
@@ -238,14 +241,14 @@ class PhantomRedirect extends solanaCore.SolWalletConnector {
|
|
|
238
241
|
message: bs58__default["default"].encode(Buffer.from(message)),
|
|
239
242
|
session,
|
|
240
243
|
};
|
|
241
|
-
const [nonce, encryptedPayload] =
|
|
244
|
+
const [nonce, encryptedPayload] = encryptPayload.encryptPayload(payload, sharedSecret);
|
|
242
245
|
const params = new URLSearchParams({
|
|
243
246
|
dapp_encryption_public_key: bs58__default["default"].encode(encryptionPublicKey),
|
|
244
247
|
nonce: bs58__default["default"].encode(nonce),
|
|
245
248
|
payload: bs58__default["default"].encode(encryptedPayload),
|
|
246
249
|
redirect_link: window.location.href,
|
|
247
250
|
});
|
|
248
|
-
const url =
|
|
251
|
+
const url = buildUrl.buildUrl('signMessage', params);
|
|
249
252
|
window.location.href = url;
|
|
250
253
|
// actual signature will be retrived upon redirect back to dapp
|
|
251
254
|
return { signature: Buffer.from('') };
|
|
@@ -259,14 +262,14 @@ class PhantomRedirect extends solanaCore.SolWalletConnector {
|
|
|
259
262
|
session,
|
|
260
263
|
transaction: serializedTransaction,
|
|
261
264
|
};
|
|
262
|
-
const [nonce, encryptedPayload] =
|
|
265
|
+
const [nonce, encryptedPayload] = encryptPayload.encryptPayload(payload, sharedSecret);
|
|
263
266
|
const params = new URLSearchParams({
|
|
264
267
|
dapp_encryption_public_key: bs58__default["default"].encode(encryptionPublicKey),
|
|
265
268
|
nonce: bs58__default["default"].encode(nonce),
|
|
266
269
|
payload: bs58__default["default"].encode(encryptedPayload),
|
|
267
270
|
redirect_link: window.location.href,
|
|
268
271
|
});
|
|
269
|
-
const url =
|
|
272
|
+
const url = buildUrl.buildUrl('signTransaction', params);
|
|
270
273
|
window.location.href = url;
|
|
271
274
|
return transaction;
|
|
272
275
|
}),
|
|
@@ -291,14 +294,14 @@ class PhantomRedirect extends solanaCore.SolWalletConnector {
|
|
|
291
294
|
if (!address || !session || !encryptionPublicKey || !sharedSecret)
|
|
292
295
|
return;
|
|
293
296
|
const payload = { session };
|
|
294
|
-
const [nonce, encryptedPayload] =
|
|
297
|
+
const [nonce, encryptedPayload] = encryptPayload.encryptPayload(payload, sharedSecret);
|
|
295
298
|
const params = new URLSearchParams({
|
|
296
299
|
dapp_encryption_public_key: bs58__default["default"].encode(encryptionPublicKey),
|
|
297
300
|
nonce: bs58__default["default"].encode(nonce),
|
|
298
301
|
payload: bs58__default["default"].encode(encryptedPayload),
|
|
299
302
|
redirect_link: window.location.href,
|
|
300
303
|
});
|
|
301
|
-
const url =
|
|
304
|
+
const url = buildUrl.buildUrl('disconnect', params);
|
|
302
305
|
window.location.href = url;
|
|
303
306
|
});
|
|
304
307
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Transaction } from '@solana/web3.js';
|
|
2
|
-
import { IPhantomRedirectConnector } from '@dynamic-labs/wallet-connector-core';
|
|
3
2
|
import { SolWalletConnector, type ISolana } from '@dynamic-labs/solana-core';
|
|
4
|
-
import {
|
|
3
|
+
import { IPhantomRedirectConnector } from '@dynamic-labs/wallet-connector-core';
|
|
4
|
+
import { Method } from '../types';
|
|
5
5
|
export declare class PhantomRedirect extends SolWalletConnector implements IPhantomRedirectConnector {
|
|
6
6
|
name: string;
|
|
7
7
|
overrideKey: string;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
import { __awaiter } from '
|
|
3
|
-
import nacl from 'tweetnacl';
|
|
4
|
-
import bs58 from 'bs58';
|
|
2
|
+
import { __awaiter } from '../../../_virtual/_tslib.js';
|
|
5
3
|
import { PublicKey, Transaction } from '@solana/web3.js';
|
|
4
|
+
import bs58 from 'bs58';
|
|
5
|
+
import nacl from 'tweetnacl';
|
|
6
6
|
import { SolWalletConnector } from '@dynamic-labs/solana-core';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { buildUrl } from '../buildUrl/buildUrl.js';
|
|
8
|
+
import { decryptPayload } from '../decryptPayload/decryptPayload.js';
|
|
9
|
+
import { encryptPayload } from '../encryptPayload/encryptPayload.js';
|
|
10
|
+
import { fetchCluster } from '../fetchCluster/fetchCluster.js';
|
|
11
|
+
import { storage, clearStorage } from '../storage/storage.js';
|
|
9
12
|
|
|
10
13
|
class PhantomRedirect extends SolWalletConnector {
|
|
11
14
|
constructor(props) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './PhantomRedirect';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const buildUrl: (path: string, params: URLSearchParams) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './buildUrl';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var bs58 = require('bs58');
|
|
7
|
+
var nacl = require('tweetnacl');
|
|
8
|
+
var logger = require('../../utils/logger.cjs');
|
|
9
|
+
|
|
10
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
11
|
+
|
|
12
|
+
var bs58__default = /*#__PURE__*/_interopDefaultLegacy(bs58);
|
|
13
|
+
var nacl__default = /*#__PURE__*/_interopDefaultLegacy(nacl);
|
|
14
|
+
|
|
15
|
+
const failForMissingParam = (paramName, param) => {
|
|
16
|
+
const message = `Failed to decrypt phantom redirect payload: ${paramName} was invalid (${param})`;
|
|
17
|
+
logger.logger.error(message);
|
|
18
|
+
throw new Error(message);
|
|
19
|
+
};
|
|
20
|
+
const decryptPayload = (data, nonce, sharedSecret) => {
|
|
21
|
+
if (!data)
|
|
22
|
+
failForMissingParam('data', data);
|
|
23
|
+
if (!nonce)
|
|
24
|
+
failForMissingParam('nonce', nonce);
|
|
25
|
+
if (!sharedSecret)
|
|
26
|
+
failForMissingParam('sharedSecret', sharedSecret);
|
|
27
|
+
const decryptedData = nacl__default["default"].box.open.after(bs58__default["default"].decode(data), bs58__default["default"].decode(nonce), sharedSecret);
|
|
28
|
+
if (!decryptedData) {
|
|
29
|
+
throw new Error('Unable to decrypt data');
|
|
30
|
+
}
|
|
31
|
+
return JSON.parse(Buffer.from(decryptedData).toString('utf8'));
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
exports.decryptPayload = decryptPayload;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const decryptPayload: (data: string, nonce: string, sharedSecret: Uint8Array) => any;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import bs58 from 'bs58';
|
|
3
|
+
import nacl from 'tweetnacl';
|
|
4
|
+
import { logger } from '../../utils/logger.js';
|
|
5
|
+
|
|
6
|
+
const failForMissingParam = (paramName, param) => {
|
|
7
|
+
const message = `Failed to decrypt phantom redirect payload: ${paramName} was invalid (${param})`;
|
|
8
|
+
logger.error(message);
|
|
9
|
+
throw new Error(message);
|
|
10
|
+
};
|
|
11
|
+
const decryptPayload = (data, nonce, sharedSecret) => {
|
|
12
|
+
if (!data)
|
|
13
|
+
failForMissingParam('data', data);
|
|
14
|
+
if (!nonce)
|
|
15
|
+
failForMissingParam('nonce', nonce);
|
|
16
|
+
if (!sharedSecret)
|
|
17
|
+
failForMissingParam('sharedSecret', sharedSecret);
|
|
18
|
+
const decryptedData = nacl.box.open.after(bs58.decode(data), bs58.decode(nonce), sharedSecret);
|
|
19
|
+
if (!decryptedData) {
|
|
20
|
+
throw new Error('Unable to decrypt data');
|
|
21
|
+
}
|
|
22
|
+
return JSON.parse(Buffer.from(decryptedData).toString('utf8'));
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export { decryptPayload };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './decryptPayload';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var nacl = require('tweetnacl');
|
|
7
|
+
|
|
8
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
|
+
|
|
10
|
+
var nacl__default = /*#__PURE__*/_interopDefaultLegacy(nacl);
|
|
11
|
+
|
|
12
|
+
const encryptPayload = (payload, sharedSecret) => {
|
|
13
|
+
const nonce = nacl__default["default"].randomBytes(24);
|
|
14
|
+
const encryptedPayload = nacl__default["default"].box.after(Buffer.from(JSON.stringify(payload)), nonce, sharedSecret);
|
|
15
|
+
return [nonce, encryptedPayload];
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
exports.encryptPayload = encryptPayload;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const encryptPayload: (payload: any, sharedSecret: Uint8Array) => Uint8Array[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import nacl from 'tweetnacl';
|
|
3
|
+
|
|
4
|
+
const encryptPayload = (payload, sharedSecret) => {
|
|
5
|
+
const nonce = nacl.randomBytes(24);
|
|
6
|
+
const encryptedPayload = nacl.box.after(Buffer.from(JSON.stringify(payload)), nonce, sharedSecret);
|
|
7
|
+
return [nonce, encryptedPayload];
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export { encryptPayload };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './encryptPayload';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../_virtual/_tslib.cjs');
|
|
7
|
+
|
|
8
|
+
const GENESIS_HASHES = {
|
|
9
|
+
'4uhcVJyU9pJkvQyS88uRDiswHXSCkY3zQawwpjk2NsNY': 'testnet',
|
|
10
|
+
'5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d': 'mainnet-beta',
|
|
11
|
+
EtWTRABZaYq6iMfeYKouRu166VU2xqa1wcaWoxPkrZBG: 'devnet',
|
|
12
|
+
};
|
|
13
|
+
const fetchCluster = (rpc) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
14
|
+
try {
|
|
15
|
+
const { result } = yield (yield fetch(rpc, {
|
|
16
|
+
body: JSON.stringify({
|
|
17
|
+
id: 1,
|
|
18
|
+
jsonrpc: '2.0',
|
|
19
|
+
method: 'getGenesisHash',
|
|
20
|
+
}),
|
|
21
|
+
headers: {
|
|
22
|
+
'Content-Type': 'application/json',
|
|
23
|
+
},
|
|
24
|
+
method: 'POST',
|
|
25
|
+
})).json();
|
|
26
|
+
return GENESIS_HASHES[result];
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
return 'mainnet-beta';
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
exports.fetchCluster = fetchCluster;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const fetchCluster: (rpc: string) => Promise<string>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../_virtual/_tslib.js';
|
|
3
|
+
|
|
4
|
+
const GENESIS_HASHES = {
|
|
5
|
+
'4uhcVJyU9pJkvQyS88uRDiswHXSCkY3zQawwpjk2NsNY': 'testnet',
|
|
6
|
+
'5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d': 'mainnet-beta',
|
|
7
|
+
EtWTRABZaYq6iMfeYKouRu166VU2xqa1wcaWoxPkrZBG: 'devnet',
|
|
8
|
+
};
|
|
9
|
+
const fetchCluster = (rpc) => __awaiter(void 0, void 0, void 0, function* () {
|
|
10
|
+
try {
|
|
11
|
+
const { result } = yield (yield fetch(rpc, {
|
|
12
|
+
body: JSON.stringify({
|
|
13
|
+
id: 1,
|
|
14
|
+
jsonrpc: '2.0',
|
|
15
|
+
method: 'getGenesisHash',
|
|
16
|
+
}),
|
|
17
|
+
headers: {
|
|
18
|
+
'Content-Type': 'application/json',
|
|
19
|
+
},
|
|
20
|
+
method: 'POST',
|
|
21
|
+
})).json();
|
|
22
|
+
return GENESIS_HASHES[result];
|
|
23
|
+
}
|
|
24
|
+
catch (err) {
|
|
25
|
+
return 'mainnet-beta';
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export { fetchCluster };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './fetchCluster';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './storage';
|
|
@@ -134,8 +134,21 @@ class SolProviderHelper {
|
|
|
134
134
|
}
|
|
135
135
|
_setupEventListeners(walletConnector) {
|
|
136
136
|
const provider = this.findProvider();
|
|
137
|
-
|
|
138
|
-
|
|
137
|
+
if (!provider) {
|
|
138
|
+
walletConnectorCore.logger.warn('Provider not found', {
|
|
139
|
+
connector: walletConnector,
|
|
140
|
+
});
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if (!('on' in provider)) {
|
|
144
|
+
walletConnectorCore.logger.warn('Provider does not support event listeners', {
|
|
145
|
+
connector: walletConnector,
|
|
146
|
+
provider,
|
|
147
|
+
});
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
provider.on('accountChanged', (publicKey) => this.handleAccountChange(walletConnector, provider, publicKey));
|
|
151
|
+
provider.on('disconnect', () => walletConnector.emit('disconnect'));
|
|
139
152
|
}
|
|
140
153
|
_teardownEventListeners() {
|
|
141
154
|
const provider = this.findProvider();
|
package/src/solProviderHelper.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../_virtual/_tslib.js';
|
|
3
3
|
import { getProvidersFromWindow, bufferToBase64 } from '@dynamic-labs/utils';
|
|
4
|
-
import { ProviderLookup } from '@dynamic-labs/wallet-connector-core';
|
|
4
|
+
import { ProviderLookup, logger } from '@dynamic-labs/wallet-connector-core';
|
|
5
5
|
import { isSignedMessage } from './utils/isSignedMessage.js';
|
|
6
6
|
import { findWalletProviderFromWalletStandard } from './utils/findWalletProviderFromWalletStandard/findWalletProviderFromWalletStandard.js';
|
|
7
7
|
|
|
@@ -130,8 +130,21 @@ class SolProviderHelper {
|
|
|
130
130
|
}
|
|
131
131
|
_setupEventListeners(walletConnector) {
|
|
132
132
|
const provider = this.findProvider();
|
|
133
|
-
|
|
134
|
-
|
|
133
|
+
if (!provider) {
|
|
134
|
+
logger.warn('Provider not found', {
|
|
135
|
+
connector: walletConnector,
|
|
136
|
+
});
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
if (!('on' in provider)) {
|
|
140
|
+
logger.warn('Provider does not support event listeners', {
|
|
141
|
+
connector: walletConnector,
|
|
142
|
+
provider,
|
|
143
|
+
});
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
provider.on('accountChanged', (publicKey) => this.handleAccountChange(walletConnector, provider, publicKey));
|
|
147
|
+
provider.on('disconnect', () => walletConnector.emit('disconnect'));
|
|
135
148
|
}
|
|
136
149
|
_teardownEventListeners() {
|
|
137
150
|
const provider = this.findProvider();
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
-
|
|
6
|
-
var _tslib = require('../../_virtual/_tslib.cjs');
|
|
7
|
-
var nacl = require('tweetnacl');
|
|
8
|
-
var bs58 = require('bs58');
|
|
9
|
-
|
|
10
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
11
|
-
|
|
12
|
-
var nacl__default = /*#__PURE__*/_interopDefaultLegacy(nacl);
|
|
13
|
-
var bs58__default = /*#__PURE__*/_interopDefaultLegacy(bs58);
|
|
14
|
-
|
|
15
|
-
const buildUrl = (path, params) => `https://phantom.app/ul/v1/${path}?${params.toString()}`;
|
|
16
|
-
const decryptPayload = (data, nonce, sharedSecret) => {
|
|
17
|
-
const decryptedData = nacl__default["default"].box.open.after(bs58__default["default"].decode(data), bs58__default["default"].decode(nonce), sharedSecret);
|
|
18
|
-
if (!decryptedData) {
|
|
19
|
-
throw new Error('Unable to decrypt data');
|
|
20
|
-
}
|
|
21
|
-
return JSON.parse(Buffer.from(decryptedData).toString('utf8'));
|
|
22
|
-
};
|
|
23
|
-
const encryptPayload = (payload, sharedSecret) => {
|
|
24
|
-
const nonce = nacl__default["default"].randomBytes(24);
|
|
25
|
-
const encryptedPayload = nacl__default["default"].box.after(Buffer.from(JSON.stringify(payload)), nonce, sharedSecret);
|
|
26
|
-
return [nonce, encryptedPayload];
|
|
27
|
-
};
|
|
28
|
-
const GENESIS_HASHES = {
|
|
29
|
-
'4uhcVJyU9pJkvQyS88uRDiswHXSCkY3zQawwpjk2NsNY': 'testnet',
|
|
30
|
-
'5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d': 'mainnet-beta',
|
|
31
|
-
EtWTRABZaYq6iMfeYKouRu166VU2xqa1wcaWoxPkrZBG: 'devnet',
|
|
32
|
-
};
|
|
33
|
-
const fetchCluster = (rpc) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
-
try {
|
|
35
|
-
const { result } = yield (yield fetch(rpc, {
|
|
36
|
-
body: JSON.stringify({
|
|
37
|
-
id: 1,
|
|
38
|
-
jsonrpc: '2.0',
|
|
39
|
-
method: 'getGenesisHash',
|
|
40
|
-
}),
|
|
41
|
-
headers: {
|
|
42
|
-
'Content-Type': 'application/json',
|
|
43
|
-
},
|
|
44
|
-
method: 'POST',
|
|
45
|
-
})).json();
|
|
46
|
-
return GENESIS_HASHES[result];
|
|
47
|
-
}
|
|
48
|
-
catch (err) {
|
|
49
|
-
return 'mainnet-beta';
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
exports.buildUrl = buildUrl;
|
|
54
|
-
exports.decryptPayload = decryptPayload;
|
|
55
|
-
exports.encryptPayload = encryptPayload;
|
|
56
|
-
exports.fetchCluster = fetchCluster;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export declare const buildUrl: (path: string, params: URLSearchParams) => string;
|
|
2
|
-
export declare const decryptPayload: (data: string, nonce: string, sharedSecret: Uint8Array) => any;
|
|
3
|
-
export declare const encryptPayload: (payload: any, sharedSecret: Uint8Array) => Uint8Array[];
|
|
4
|
-
export declare const fetchCluster: (rpc: string) => Promise<string>;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
import { __awaiter } from '../../_virtual/_tslib.js';
|
|
3
|
-
import nacl from 'tweetnacl';
|
|
4
|
-
import bs58 from 'bs58';
|
|
5
|
-
|
|
6
|
-
const buildUrl = (path, params) => `https://phantom.app/ul/v1/${path}?${params.toString()}`;
|
|
7
|
-
const decryptPayload = (data, nonce, sharedSecret) => {
|
|
8
|
-
const decryptedData = nacl.box.open.after(bs58.decode(data), bs58.decode(nonce), sharedSecret);
|
|
9
|
-
if (!decryptedData) {
|
|
10
|
-
throw new Error('Unable to decrypt data');
|
|
11
|
-
}
|
|
12
|
-
return JSON.parse(Buffer.from(decryptedData).toString('utf8'));
|
|
13
|
-
};
|
|
14
|
-
const encryptPayload = (payload, sharedSecret) => {
|
|
15
|
-
const nonce = nacl.randomBytes(24);
|
|
16
|
-
const encryptedPayload = nacl.box.after(Buffer.from(JSON.stringify(payload)), nonce, sharedSecret);
|
|
17
|
-
return [nonce, encryptedPayload];
|
|
18
|
-
};
|
|
19
|
-
const GENESIS_HASHES = {
|
|
20
|
-
'4uhcVJyU9pJkvQyS88uRDiswHXSCkY3zQawwpjk2NsNY': 'testnet',
|
|
21
|
-
'5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d': 'mainnet-beta',
|
|
22
|
-
EtWTRABZaYq6iMfeYKouRu166VU2xqa1wcaWoxPkrZBG: 'devnet',
|
|
23
|
-
};
|
|
24
|
-
const fetchCluster = (rpc) => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
|
-
try {
|
|
26
|
-
const { result } = yield (yield fetch(rpc, {
|
|
27
|
-
body: JSON.stringify({
|
|
28
|
-
id: 1,
|
|
29
|
-
jsonrpc: '2.0',
|
|
30
|
-
method: 'getGenesisHash',
|
|
31
|
-
}),
|
|
32
|
-
headers: {
|
|
33
|
-
'Content-Type': 'application/json',
|
|
34
|
-
},
|
|
35
|
-
method: 'POST',
|
|
36
|
-
})).json();
|
|
37
|
-
return GENESIS_HASHES[result];
|
|
38
|
-
}
|
|
39
|
-
catch (err) {
|
|
40
|
-
return 'mainnet-beta';
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
export { buildUrl, decryptPayload, encryptPayload, fetchCluster };
|
|
File without changes
|
|
File without changes
|