@dynamic-labs/utils 2.1.0-alpha.3 → 2.1.0-alpha.30

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.
Files changed (42) hide show
  1. package/CHANGELOG.md +253 -0
  2. package/package.json +5 -5
  3. package/src/errors/AccessBlockedError.cjs +11 -0
  4. package/src/errors/AccessBlockedError.d.ts +3 -0
  5. package/src/errors/AccessBlockedError.js +7 -0
  6. package/src/errors/CookieInvalidError.cjs +14 -0
  7. package/src/errors/CookieInvalidError.d.ts +4 -0
  8. package/src/errors/CookieInvalidError.js +10 -0
  9. package/src/errors/CustomFieldNotUniqueError.cjs +14 -0
  10. package/src/errors/CustomFieldNotUniqueError.d.ts +4 -0
  11. package/src/errors/CustomFieldNotUniqueError.js +10 -0
  12. package/src/errors/EmbeddedWalletException.cjs +14 -0
  13. package/src/errors/EmbeddedWalletException.d.ts +4 -0
  14. package/src/errors/EmbeddedWalletException.js +10 -0
  15. package/src/errors/InvalidPhoneNumberError.cjs +2 -2
  16. package/src/errors/InvalidPhoneNumberError.d.ts +1 -1
  17. package/src/errors/InvalidPhoneNumberError.js +2 -2
  18. package/src/errors/MfaInvalidOtpError.cjs +14 -0
  19. package/src/errors/MfaInvalidOtpError.d.ts +4 -0
  20. package/src/errors/MfaInvalidOtpError.js +10 -0
  21. package/src/errors/index.d.ts +5 -0
  22. package/src/getTLD/getTLD.cjs +4 -11
  23. package/src/getTLD/getTLD.js +4 -11
  24. package/src/index.cjs +16 -0
  25. package/src/index.d.ts +2 -0
  26. package/src/index.js +8 -0
  27. package/src/logger/logger.cjs +1 -1
  28. package/src/logger/logger.js +1 -1
  29. package/src/services/FetchService/FetchService.cjs +24 -0
  30. package/src/services/FetchService/FetchService.d.ts +10 -0
  31. package/src/services/FetchService/FetchService.js +20 -0
  32. package/src/services/FetchService/index.d.ts +2 -0
  33. package/src/services/FetchService/types.d.ts +3 -0
  34. package/src/services/PlatformService/PlatformService.cjs +39 -0
  35. package/src/services/PlatformService/PlatformService.d.ts +12 -0
  36. package/src/services/PlatformService/PlatformService.js +35 -0
  37. package/src/services/PlatformService/createBrowserPlatformService/createBrowserPlatformService.cjs +33 -0
  38. package/src/services/PlatformService/createBrowserPlatformService/createBrowserPlatformService.d.ts +2 -0
  39. package/src/services/PlatformService/createBrowserPlatformService/createBrowserPlatformService.js +29 -0
  40. package/src/services/PlatformService/createBrowserPlatformService/index.d.ts +1 -0
  41. package/src/services/PlatformService/index.d.ts +3 -0
  42. package/src/services/PlatformService/types.d.ts +29 -0
package/CHANGELOG.md CHANGED
@@ -1,4 +1,257 @@
1
1
 
2
+ ## [2.1.0-alpha.30](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.29...v2.1.0-alpha.30) (2024-05-31)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * ensure initExpirationTime is called automatically after authenticating ([#5797](https://github.com/dynamic-labs/DynamicAuth/issues/5797)) ([87eb802](https://github.com/dynamic-labs/DynamicAuth/commit/87eb802e0c2d3af2ca116e07099bfef426d30a1f))
8
+ * initExpirationTime should use expiresAt from storage ([#5799](https://github.com/dynamic-labs/DynamicAuth/issues/5799)) ([384ed17](https://github.com/dynamic-labs/DynamicAuth/commit/384ed1747d9b813ac0d34aaee36eb6480cb256d3))
9
+ * only run useValidateSession once on rerender ([#5795](https://github.com/dynamic-labs/DynamicAuth/issues/5795)) ([ba4446d](https://github.com/dynamic-labs/DynamicAuth/commit/ba4446df95726248b877a84def959cabe81ad9b6))
10
+ * store expiresAt timestamp from VerifyResponse in local storage for use in initExpirationTime ([#5796](https://github.com/dynamic-labs/DynamicAuth/issues/5796)) ([5f8aaeb](https://github.com/dynamic-labs/DynamicAuth/commit/5f8aaeb1cd45b10cb007f9eac25d18f50f142d8f))
11
+
12
+ ## [2.1.0-alpha.29](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.28...v2.1.0-alpha.29) (2024-05-30)
13
+
14
+
15
+ ### Features
16
+
17
+ * add account and chain to coinbase walletClient ([#5776](https://github.com/dynamic-labs/DynamicAuth/issues/5776)) ([557091c](https://github.com/dynamic-labs/DynamicAuth/commit/557091c0efaec11273bd40b53c8bcd633c1bf48d))
18
+ * add support for phantom btc ([#5717](https://github.com/dynamic-labs/DynamicAuth/issues/5717)) ([c61ca4f](https://github.com/dynamic-labs/DynamicAuth/commit/c61ca4f437796be2b420902de7e7de730725d122))
19
+
20
+
21
+ ### Bug Fixes
22
+
23
+ * add phantom btc mobile redirect ([#5789](https://github.com/dynamic-labs/DynamicAuth/issues/5789)) ([aaa2654](https://github.com/dynamic-labs/DynamicAuth/commit/aaa26548668b0733e7930c1d7f5cc3937b3dfb50))
24
+ * clear settings and configurations when logged out on page load ([#5787](https://github.com/dynamic-labs/DynamicAuth/issues/5787)) ([53c4d0b](https://github.com/dynamic-labs/DynamicAuth/commit/53c4d0b4686debdb43b1ab1b8b9e296ed4dd74b6))
25
+ * lookup projectSettings from store to check if cookie enabled ([#5790](https://github.com/dynamic-labs/DynamicAuth/issues/5790)) ([6f2314b](https://github.com/dynamic-labs/DynamicAuth/commit/6f2314b0afef984e6caea79ead73d12c5c6d83f0))
26
+
27
+ ## [2.1.0-alpha.28](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.27...v2.1.0-alpha.28) (2024-05-29)
28
+
29
+
30
+ ### Features
31
+
32
+ * adds solana standard wallet connector ([#5752](https://github.com/dynamic-labs/DynamicAuth/issues/5752)) ([0040940](https://github.com/dynamic-labs/DynamicAuth/commit/0040940fd1adb37ab3106bb0e4dfe79403bc41f2))
33
+
34
+
35
+ ### Bug Fixes
36
+
37
+ * farcaster fetch url fix ([#5767](https://github.com/dynamic-labs/DynamicAuth/issues/5767)) ([1408ba9](https://github.com/dynamic-labs/DynamicAuth/commit/1408ba92680363b9db7820a63d5e3d15dc26ad22))
38
+
39
+ ## [2.1.0-alpha.27](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.26...v2.1.0-alpha.27) (2024-05-29)
40
+
41
+
42
+ ### Bug Fixes
43
+
44
+ * coinbase connection ([#5764](https://github.com/dynamic-labs/DynamicAuth/issues/5764)) ([aeacd1c](https://github.com/dynamic-labs/DynamicAuth/commit/aeacd1c55dc471fbf8c14eb05ab356b0a90aa239))
45
+
46
+ ## [2.1.0-alpha.26](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.25...v2.1.0-alpha.26) (2024-05-29)
47
+
48
+
49
+ ### Features
50
+
51
+ * add farcaster login to react native ([#5713](https://github.com/dynamic-labs/DynamicAuth/issues/5713)) ([08f4473](https://github.com/dynamic-labs/DynamicAuth/commit/08f4473eec9b32b82b6f703fa4d5136514a61b25))
52
+
53
+
54
+ ### Bug Fixes
55
+
56
+ * better error handling of invalid mfa otp ([#5759](https://github.com/dynamic-labs/DynamicAuth/issues/5759)) ([72ab01f](https://github.com/dynamic-labs/DynamicAuth/commit/72ab01f8f919f147eeedfabf8b4838802abf308a))
57
+ * show correct status for magic eden btc wallets after ([#5748](https://github.com/dynamic-labs/DynamicAuth/issues/5748)) ([b8f20bb](https://github.com/dynamic-labs/DynamicAuth/commit/b8f20bb796b9a2e88817ef3b0da6ac32e9012b18))
58
+
59
+ ## [2.1.0-alpha.25](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.24...v2.1.0-alpha.25) (2024-05-27)
60
+
61
+
62
+ ### Bug Fixes
63
+
64
+ * btc balance calculation ([#5737](https://github.com/dynamic-labs/DynamicAuth/issues/5737)) ([9b5ceb3](https://github.com/dynamic-labs/DynamicAuth/commit/9b5ceb32d543037f60d7104f0b81b3abc86ebd10))
65
+
66
+ ## [2.1.0-alpha.24](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.23...v2.1.0-alpha.24) (2024-05-26)
67
+
68
+
69
+ ### Features
70
+
71
+ * add onMfaCompleteOnce to useMfa ([#5702](https://github.com/dynamic-labs/DynamicAuth/issues/5702)) ([6451e33](https://github.com/dynamic-labs/DynamicAuth/commit/6451e3369ef1b4ba116378f0dd3fe4e82007e670))
72
+ * prompt custom fields during onboarding ([#5302](https://github.com/dynamic-labs/DynamicAuth/issues/5302)) ([8664223](https://github.com/dynamic-labs/DynamicAuth/commit/86642232cf2b490a820169f48ba8dc093010e1a0))
73
+
74
+
75
+ ### Bug Fixes
76
+
77
+ * correct text on pending signature screen to match the embedded widget modal text ([#5707](https://github.com/dynamic-labs/DynamicAuth/issues/5707)) ([44a6a06](https://github.com/dynamic-labs/DynamicAuth/commit/44a6a0664e08d4b9fc25dd86c0e30f8d585558e0))
78
+ * pass captcha token for farcaster login ([#5706](https://github.com/dynamic-labs/DynamicAuth/issues/5706)) ([32bcb6e](https://github.com/dynamic-labs/DynamicAuth/commit/32bcb6e0e06c6e273c07f32893dfd550deeb6a19))
79
+ * use coinbase provider to get connected accounts for consistency ([#5711](https://github.com/dynamic-labs/DynamicAuth/issues/5711)) ([b9e9170](https://github.com/dynamic-labs/DynamicAuth/commit/b9e9170dad1ac27a85a44a7177b82055ce0035cb))
80
+
81
+ ## [2.1.0-alpha.23](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.22...v2.1.0-alpha.23) (2024-05-23)
82
+
83
+
84
+ ### Features
85
+
86
+ * add authFailure and authInit events ([#5659](https://github.com/dynamic-labs/DynamicAuth/issues/5659)) ([f4f592a](https://github.com/dynamic-labs/DynamicAuth/commit/f4f592aaacd96fae9333b803c235c5f1fea0e20e))
87
+ * prompt mfa on signup and signin ([#5599](https://github.com/dynamic-labs/DynamicAuth/issues/5599)) ([8d4ecf4](https://github.com/dynamic-labs/DynamicAuth/commit/8d4ecf4c69c59c1fb14e79511fb2f9b33a7e3d89))
88
+
89
+
90
+ ### Bug Fixes
91
+
92
+ * close auth modal if create embedded wallet throws ([#5683](https://github.com/dynamic-labs/DynamicAuth/issues/5683)) ([5331d73](https://github.com/dynamic-labs/DynamicAuth/commit/5331d731a171bb52a598eb5b25f7ba80cef7a64c))
93
+ * prevent state update when the webview is unmounted ([#5688](https://github.com/dynamic-labs/DynamicAuth/issues/5688)) ([8e4ecbd](https://github.com/dynamic-labs/DynamicAuth/commit/8e4ecbdcdb5f48c57ecaad90d663c66529013192))
94
+ * show phone number in use error message ([#5681](https://github.com/dynamic-labs/DynamicAuth/issues/5681)) ([e62f7b7](https://github.com/dynamic-labs/DynamicAuth/commit/e62f7b7b6a5e217944346faf2410028433cecad4))
95
+
96
+ ## [2.1.0-alpha.22](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.21...v2.1.0-alpha.22) (2024-05-21)
97
+
98
+ ## [2.1.0-alpha.21](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.20...v2.1.0-alpha.21) (2024-05-21)
99
+
100
+ ## [2.1.0-alpha.20](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.19...v2.1.0-alpha.20) (2024-05-21)
101
+
102
+
103
+ ### Features
104
+
105
+ * adds client.networks module ([#5650](https://github.com/dynamic-labs/DynamicAuth/issues/5650)) ([70f7fe5](https://github.com/dynamic-labs/DynamicAuth/commit/70f7fe5f437756c51e787ac12183be0a23c51b89))
106
+ * user fields supports custom fields ([#5639](https://github.com/dynamic-labs/DynamicAuth/issues/5639)) ([8eb5788](https://github.com/dynamic-labs/DynamicAuth/commit/8eb5788fc3e1286929f5949ecb57736b21b13fb5))
107
+
108
+
109
+ ### Bug Fixes
110
+
111
+ * add webcredentials to expo ([#5640](https://github.com/dynamic-labs/DynamicAuth/issues/5640)) ([9026fbf](https://github.com/dynamic-labs/DynamicAuth/commit/9026fbf0108537e884588f3adcdb9f0db04a159b))
112
+ * init ethers web3provider without a network if selected network is unsupported ([#5651](https://github.com/dynamic-labs/DynamicAuth/issues/5651)) ([e82040f](https://github.com/dynamic-labs/DynamicAuth/commit/e82040f424b17a70fac4400ab5b85a0dc6c0e35a))
113
+
114
+ ## [2.1.0-alpha.19](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.18...v2.1.0-alpha.19) (2024-05-17)
115
+
116
+
117
+ ### Features
118
+
119
+ * add createUserProfileFromSDKUser ([#5596](https://github.com/dynamic-labs/DynamicAuth/issues/5596)) ([d37a1b4](https://github.com/dynamic-labs/DynamicAuth/commit/d37a1b4119f5ff4fff1e987d157f6d5abf105a8b))
120
+ * add headless social sign-in ([#5439](https://github.com/dynamic-labs/DynamicAuth/issues/5439)) ([e32fdf8](https://github.com/dynamic-labs/DynamicAuth/commit/e32fdf863718d661b90b592c8df734e92386ddf3))
121
+ * fetch custom fields in profile and update user ([#5627](https://github.com/dynamic-labs/DynamicAuth/issues/5627)) ([3940c25](https://github.com/dynamic-labs/DynamicAuth/commit/3940c2542bb330f3ed9a8eb98eed9d05c8fcb03a))
122
+
123
+
124
+ ### Bug Fixes
125
+
126
+ * include applinks details to AASA ([#5635](https://github.com/dynamic-labs/DynamicAuth/issues/5635)) ([ce94fec](https://github.com/dynamic-labs/DynamicAuth/commit/ce94fec80adbb3eb4efcb79d1aa2cc6eb35eab6f))
127
+ * include the appOrigin to every api call to create correct passkey ([#5636](https://github.com/dynamic-labs/DynamicAuth/issues/5636)) ([ee64df3](https://github.com/dynamic-labs/DynamicAuth/commit/ee64df3b90037bd29cca161e601973ef202c58f0))
128
+ * use PromptModal when using the DynamicMultiWalletPromptsWidget for pending connection views ([#5594](https://github.com/dynamic-labs/DynamicAuth/issues/5594)) ([c095b6e](https://github.com/dynamic-labs/DynamicAuth/commit/c095b6e4c974f02cfe632963be92d16bb201dfa5))
129
+
130
+ ## [2.1.0-alpha.18](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.17...v2.1.0-alpha.18) (2024-05-15)
131
+
132
+ ## [2.1.0-alpha.17](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.16...v2.1.0-alpha.17) (2024-05-15)
133
+
134
+
135
+ ### Features
136
+
137
+ * add coinbaseWalletPreference prop ([#5607](https://github.com/dynamic-labs/DynamicAuth/issues/5607)) ([1ac3b2c](https://github.com/dynamic-labs/DynamicAuth/commit/1ac3b2ce7abb136465f4aa88b045dfb70d99aad7))
138
+
139
+ ## [2.1.0-alpha.16](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.15...v2.1.0-alpha.16) (2024-05-14)
140
+
141
+
142
+ ### Features
143
+
144
+ * add client.sdk.error with errors from the webview ([#5520](https://github.com/dynamic-labs/DynamicAuth/issues/5520)) ([a886927](https://github.com/dynamic-labs/DynamicAuth/commit/a8869273bf361c870d6e3cb82a28d9ccec65905b))
145
+ * add setDefaultTabIndex to default the selected wallets tab ([#5593](https://github.com/dynamic-labs/DynamicAuth/issues/5593)) ([6e8ce05](https://github.com/dynamic-labs/DynamicAuth/commit/6e8ce053c4f6f009acc57dac55a8e9c74fbcc73b))
146
+ * add visibility/auth-flow/user-profile to react-native ([#5564](https://github.com/dynamic-labs/DynamicAuth/issues/5564)) ([d93cea8](https://github.com/dynamic-labs/DynamicAuth/commit/d93cea82a123c6ec4d3d594a7dc064f4db2981c2))
147
+
148
+ ## [2.1.0-alpha.15](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.14...v2.1.0-alpha.15) (2024-05-13)
149
+
150
+
151
+ ### Bug Fixes
152
+
153
+ * when a pregen is created, primaryWallet is not being setup ([#5584](https://github.com/dynamic-labs/DynamicAuth/issues/5584)) ([de08721](https://github.com/dynamic-labs/DynamicAuth/commit/de0872151e09f91dcbfaf1d043cf830f9df8d799))
154
+
155
+ ## [2.1.0-alpha.14](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.13...v2.1.0-alpha.14) (2024-05-09)
156
+
157
+
158
+ ### Features
159
+
160
+ * add useSwitchWallet ([#5575](https://github.com/dynamic-labs/DynamicAuth/issues/5575)) ([d3053d9](https://github.com/dynamic-labs/DynamicAuth/commit/d3053d920110c26ef8052e77bf59e07dedc7c683))
161
+
162
+
163
+ ### Bug Fixes
164
+
165
+ * linking phantom wallets in mobile ([#5524](https://github.com/dynamic-labs/DynamicAuth/issues/5524)) ([28d90f5](https://github.com/dynamic-labs/DynamicAuth/commit/28d90f5126b9c22535b63a3797cc060ef089fc63))
166
+ * only show farcaster QR code if Social Login is enabled ([#5559](https://github.com/dynamic-labs/DynamicAuth/issues/5559)) ([fa71aaf](https://github.com/dynamic-labs/DynamicAuth/commit/fa71aaf0f80da31d397600b2fd0cbea99b3689a4))
167
+ * remove goerli testnets and add sepolia ([#5565](https://github.com/dynamic-labs/DynamicAuth/issues/5565)) ([888eb03](https://github.com/dynamic-labs/DynamicAuth/commit/888eb031ef6f4dbbdc3015265cce8647d2c720b0))
168
+
169
+ ## [2.1.0-alpha.13](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.12...v2.1.0-alpha.13) (2024-05-03)
170
+
171
+
172
+ ### Bug Fixes
173
+
174
+ * ensure Farcaster QR uses useSocialAuth hook ([#5550](https://github.com/dynamic-labs/DynamicAuth/issues/5550)) ([57fcd97](https://github.com/dynamic-labs/DynamicAuth/commit/57fcd97c44e3f52065dcf856acf7bca7b24fabc7))
175
+
176
+ ## [2.1.0-alpha.12](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.11...v2.1.0-alpha.12) (2024-05-02)
177
+
178
+
179
+ ### Features
180
+
181
+ * display Farcaster QR code when it is the only login option ([#5514](https://github.com/dynamic-labs/DynamicAuth/issues/5514)) ([7b166d9](https://github.com/dynamic-labs/DynamicAuth/commit/7b166d9a30c581746f0e2edb71c44fc015dc128e))
182
+
183
+ ## [2.1.0-alpha.11](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.10...v2.1.0-alpha.11) (2024-05-02)
184
+
185
+
186
+ ### Features
187
+
188
+ * **GVTY-1050:** add account token balances hook ([#5521](https://github.com/dynamic-labs/DynamicAuth/issues/5521)) ([5a6f937](https://github.com/dynamic-labs/DynamicAuth/commit/5a6f93733019f3b8d5c7a2c7a5537172a1e7eba4))
189
+ * headless reveal embedded wallet key ([#5518](https://github.com/dynamic-labs/DynamicAuth/issues/5518)) ([77c1536](https://github.com/dynamic-labs/DynamicAuth/commit/77c15360b2b28c52cbdeafb3ce8ca7e80dbecf57))
190
+
191
+
192
+ ### Bug Fixes
193
+
194
+ * fallback to walletconnect for zerion on mobile ([#5536](https://github.com/dynamic-labs/DynamicAuth/issues/5536)) ([f0e5bfe](https://github.com/dynamic-labs/DynamicAuth/commit/f0e5bfea0b2ab271fd4c1475c8ce708ecb1a5926))
195
+
196
+ ## [2.1.0-alpha.10](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.9...v2.1.0-alpha.10) (2024-04-30)
197
+
198
+
199
+ ### Features
200
+
201
+ * bump @coinbase/wallet-sdk to latest beta ([#5388](https://github.com/dynamic-labs/DynamicAuth/issues/5388)) ([9225546](https://github.com/dynamic-labs/DynamicAuth/commit/922554630ccf2ef98bc297521309918f922bc671))
202
+
203
+ ## [2.1.0-alpha.9](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.8...v2.1.0-alpha.9) (2024-04-30)
204
+
205
+
206
+ ### Features
207
+
208
+ * headless create embedded wallet with optional passkey data parameter ([#5487](https://github.com/dynamic-labs/DynamicAuth/issues/5487)) ([891c3d7](https://github.com/dynamic-labs/DynamicAuth/commit/891c3d77a02a019140bcb8dd03b62b1afd69710e))
209
+
210
+ ## [2.1.0-alpha.8](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.7...v2.1.0-alpha.8) (2024-04-26)
211
+
212
+
213
+ ### Bug Fixes
214
+
215
+ * display wallet tabs when linking a wallet ([#5491](https://github.com/dynamic-labs/DynamicAuth/issues/5491)) ([10fd6b4](https://github.com/dynamic-labs/DynamicAuth/commit/10fd6b4d9aec7596338c50e17f79f6be534cf2c1))
216
+ * ensure zerodev viem client handles eth_accounts call ([#5477](https://github.com/dynamic-labs/DynamicAuth/issues/5477)) ([1132e1e](https://github.com/dynamic-labs/DynamicAuth/commit/1132e1e8655b58e81cb56789453ba56a059f52ec))
217
+ * network with keplr ([#5485](https://github.com/dynamic-labs/DynamicAuth/issues/5485)) ([b86f2fc](https://github.com/dynamic-labs/DynamicAuth/commit/b86f2fce491f9752e80a86643916da9ac7fb9276))
218
+ * refetch nameservice data and display properly ([#5476](https://github.com/dynamic-labs/DynamicAuth/issues/5476)) ([2aee798](https://github.com/dynamic-labs/DynamicAuth/commit/2aee798846f69496201bec7aa52e7ec1f370b7c3))
219
+ * use embeddedWallet create response authToken in embeddedWalletCreated ([#5478](https://github.com/dynamic-labs/DynamicAuth/issues/5478)) ([51772da](https://github.com/dynamic-labs/DynamicAuth/commit/51772daf557a72984c757efd8301e2b510dc37f1))
220
+
221
+ ## [2.1.0-alpha.7](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.6...v2.1.0-alpha.7) (2024-04-25)
222
+
223
+
224
+ ### Bug Fixes
225
+
226
+ * restore embedded wallet session iframe element conflict ([#5474](https://github.com/dynamic-labs/DynamicAuth/issues/5474)) ([c157477](https://github.com/dynamic-labs/DynamicAuth/commit/c157477ea126b3130b13b711796bdd06215e7af1))
227
+
228
+ ## [2.1.0-alpha.6](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.5...v2.1.0-alpha.6) (2024-04-24)
229
+
230
+
231
+ ### Bug Fixes
232
+
233
+ * embedded wallets headless session control fixes ([#5469](https://github.com/dynamic-labs/DynamicAuth/issues/5469)) ([92e6c35](https://github.com/dynamic-labs/DynamicAuth/commit/92e6c359d2710fd4f5f5a6fedc4acf6c4bab78ba))
234
+
235
+ ## [2.1.0-alpha.5](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.4...v2.1.0-alpha.5) (2024-04-23)
236
+
237
+
238
+ ### Bug Fixes
239
+
240
+ * get embedded wallet checking the wrong chain enum ([#5458](https://github.com/dynamic-labs/DynamicAuth/issues/5458)) ([ed1c523](https://github.com/dynamic-labs/DynamicAuth/commit/ed1c523ca14cd4d21c00181ab40802f876c02b80))
241
+
242
+ ## [2.1.0-alpha.4](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.3...v2.1.0-alpha.4) (2024-04-23)
243
+
244
+
245
+ ### Features
246
+
247
+ * add email and sms to client auth module ([#5436](https://github.com/dynamic-labs/DynamicAuth/issues/5436)) ([5420476](https://github.com/dynamic-labs/DynamicAuth/commit/5420476d1ba38fd4f987f28e9aefbfb3e61ea2bf))
248
+ * headless create passkeys for embedded wallets ([#5395](https://github.com/dynamic-labs/DynamicAuth/issues/5395)) ([0b64099](https://github.com/dynamic-labs/DynamicAuth/commit/0b6409968457f65886248f0a0879e39ec3803fd0))
249
+
250
+
251
+ ### Bug Fixes
252
+
253
+ * prevent wagmi from reconnect when DynamicContextProvider rerender ([#5446](https://github.com/dynamic-labs/DynamicAuth/issues/5446)) ([33337af](https://github.com/dynamic-labs/DynamicAuth/commit/33337af76786963cb3db7fa7c58c1292c529d0ac))
254
+
2
255
  ## [2.1.0-alpha.3](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.2...v2.1.0-alpha.3) (2024-04-23)
3
256
 
4
257
 
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@dynamic-labs/utils",
3
- "version": "2.1.0-alpha.3",
3
+ "version": "2.1.0-alpha.30",
4
4
  "repository": {
5
5
  "type": "git",
6
- "url": "https://github.com/dynamic-labs/DynamicAuth.git",
6
+ "url": "git+https://github.com/dynamic-labs/dynamic-auth.git",
7
7
  "directory": "packages/utils"
8
8
  },
9
9
  "description": "A React SDK for implementing wallet web3 authentication and authorization to your website.",
@@ -26,10 +26,10 @@
26
26
  "./package.json": "./package.json"
27
27
  },
28
28
  "dependencies": {
29
- "@dynamic-labs/sdk-api-core": "0.0.425",
29
+ "@dynamic-labs/sdk-api-core": "0.0.453",
30
30
  "tldts": "6.0.16",
31
- "@dynamic-labs/logger": "2.1.0-alpha.3",
32
- "@dynamic-labs/types": "2.1.0-alpha.3",
31
+ "@dynamic-labs/logger": "2.1.0-alpha.30",
32
+ "@dynamic-labs/types": "2.1.0-alpha.30",
33
33
  "buffer": "6.0.3"
34
34
  },
35
35
  "peerDependencies": {
@@ -0,0 +1,11 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var DynamicError = require('./DynamicError.cjs');
7
+
8
+ class AccessBlockedError extends DynamicError.DynamicError {
9
+ }
10
+
11
+ exports.AccessBlockedError = AccessBlockedError;
@@ -0,0 +1,3 @@
1
+ import { DynamicError } from './DynamicError';
2
+ export declare class AccessBlockedError extends DynamicError {
3
+ }
@@ -0,0 +1,7 @@
1
+ 'use client'
2
+ import { DynamicError } from './DynamicError.js';
3
+
4
+ class AccessBlockedError extends DynamicError {
5
+ }
6
+
7
+ export { AccessBlockedError };
@@ -0,0 +1,14 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var DynamicError = require('./DynamicError.cjs');
7
+
8
+ class CookieInvalidError extends DynamicError.DynamicError {
9
+ constructor() {
10
+ super('The cookie is invalid or expired');
11
+ }
12
+ }
13
+
14
+ exports.CookieInvalidError = CookieInvalidError;
@@ -0,0 +1,4 @@
1
+ import { DynamicError } from './DynamicError';
2
+ export declare class CookieInvalidError extends DynamicError {
3
+ constructor();
4
+ }
@@ -0,0 +1,10 @@
1
+ 'use client'
2
+ import { DynamicError } from './DynamicError.js';
3
+
4
+ class CookieInvalidError extends DynamicError {
5
+ constructor() {
6
+ super('The cookie is invalid or expired');
7
+ }
8
+ }
9
+
10
+ export { CookieInvalidError };
@@ -0,0 +1,14 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var DynamicError = require('./DynamicError.cjs');
7
+
8
+ class CustomFieldNotUniqueError extends DynamicError.DynamicError {
9
+ constructor() {
10
+ super('Custom Field for user must be unique within the environment', 'custom_field_data_not_unique');
11
+ }
12
+ }
13
+
14
+ exports.CustomFieldNotUniqueError = CustomFieldNotUniqueError;
@@ -0,0 +1,4 @@
1
+ import { DynamicError } from './DynamicError';
2
+ export declare class CustomFieldNotUniqueError extends DynamicError {
3
+ constructor();
4
+ }
@@ -0,0 +1,10 @@
1
+ 'use client'
2
+ import { DynamicError } from './DynamicError.js';
3
+
4
+ class CustomFieldNotUniqueError extends DynamicError {
5
+ constructor() {
6
+ super('Custom Field for user must be unique within the environment', 'custom_field_data_not_unique');
7
+ }
8
+ }
9
+
10
+ export { CustomFieldNotUniqueError };
@@ -0,0 +1,14 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var DynamicError = require('./DynamicError.cjs');
7
+
8
+ class EmbeddedWalletException extends DynamicError.DynamicError {
9
+ constructor(message) {
10
+ super(message);
11
+ }
12
+ }
13
+
14
+ exports.EmbeddedWalletException = EmbeddedWalletException;
@@ -0,0 +1,4 @@
1
+ import { DynamicError } from './DynamicError';
2
+ export declare class EmbeddedWalletException extends DynamicError {
3
+ constructor(message: string);
4
+ }
@@ -0,0 +1,10 @@
1
+ 'use client'
2
+ import { DynamicError } from './DynamicError.js';
3
+
4
+ class EmbeddedWalletException extends DynamicError {
5
+ constructor(message) {
6
+ super(message);
7
+ }
8
+ }
9
+
10
+ export { EmbeddedWalletException };
@@ -6,8 +6,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
6
6
  var DynamicError = require('./DynamicError.cjs');
7
7
 
8
8
  class InvalidPhoneNumberError extends DynamicError.DynamicError {
9
- constructor() {
10
- super('Invalid phone number.');
9
+ constructor(error) {
10
+ super(error !== null && error !== void 0 ? error : 'Invalid phone number.');
11
11
  }
12
12
  }
13
13
 
@@ -1,4 +1,4 @@
1
1
  import { DynamicError } from './DynamicError';
2
2
  export declare class InvalidPhoneNumberError extends DynamicError {
3
- constructor();
3
+ constructor(error?: string);
4
4
  }
@@ -2,8 +2,8 @@
2
2
  import { DynamicError } from './DynamicError.js';
3
3
 
4
4
  class InvalidPhoneNumberError extends DynamicError {
5
- constructor() {
6
- super('Invalid phone number.');
5
+ constructor(error) {
6
+ super(error !== null && error !== void 0 ? error : 'Invalid phone number.');
7
7
  }
8
8
  }
9
9
 
@@ -0,0 +1,14 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var DynamicError = require('./DynamicError.cjs');
7
+
8
+ class MfaInvalidOtpError extends DynamicError.DynamicError {
9
+ constructor() {
10
+ super('Invalid MFA OTP');
11
+ }
12
+ }
13
+
14
+ exports.MfaInvalidOtpError = MfaInvalidOtpError;
@@ -0,0 +1,4 @@
1
+ import { DynamicError } from './DynamicError';
2
+ export declare class MfaInvalidOtpError extends DynamicError {
3
+ constructor();
4
+ }
@@ -0,0 +1,10 @@
1
+ 'use client'
2
+ import { DynamicError } from './DynamicError.js';
3
+
4
+ class MfaInvalidOtpError extends DynamicError {
5
+ constructor() {
6
+ super('Invalid MFA OTP');
7
+ }
8
+ }
9
+
10
+ export { MfaInvalidOtpError };
@@ -24,3 +24,8 @@ export * from './TooManyEmailVerificationsError';
24
24
  export * from './VerificationDataCollectionError';
25
25
  export * from './InvalidPhoneNumberError';
26
26
  export * from './MergeAccountsConfirmationError';
27
+ export * from './CustomFieldNotUniqueError';
28
+ export * from './CookieInvalidError';
29
+ export * from './AccessBlockedError';
30
+ export * from './EmbeddedWalletException';
31
+ export * from './MfaInvalidOtpError';
@@ -3,17 +3,10 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var tldts = require('tldts');
6
+ var PlatformService = require('../services/PlatformService/PlatformService.cjs');
7
+ require('../../_virtual/_tslib.cjs');
8
+ require('tldts');
7
9
 
8
- const getTLD = () => {
9
- // Passing the allowPrivateDomains option prevents returning the actual TLD
10
- // for domains that have delegated subdomains like herokuapp.com or s3.amazonaws.com
11
- // full list is contained here https://publicsuffix.org/list/effective_tld_names.dat
12
- // separated by ICANN DOMAINS and PRIVATE DOMAINS
13
- // so for instance parse('someapp.herokuapp.com') will return 'someapp.herokuapp.com' as the domain
14
- // whereas parse('app.dynamic.xyz') will return 'dynamic.xyz'
15
- const data = tldts.parse(window.location.hostname, { allowPrivateDomains: true });
16
- return data.domain || undefined;
17
- };
10
+ const getTLD = () => PlatformService.PlatformService.getTLD();
18
11
 
19
12
  exports.getTLD = getTLD;
@@ -1,15 +1,8 @@
1
1
  'use client'
2
- import { parse } from 'tldts';
2
+ import { PlatformService } from '../services/PlatformService/PlatformService.js';
3
+ import '../../_virtual/_tslib.js';
4
+ import 'tldts';
3
5
 
4
- const getTLD = () => {
5
- // Passing the allowPrivateDomains option prevents returning the actual TLD
6
- // for domains that have delegated subdomains like herokuapp.com or s3.amazonaws.com
7
- // full list is contained here https://publicsuffix.org/list/effective_tld_names.dat
8
- // separated by ICANN DOMAINS and PRIVATE DOMAINS
9
- // so for instance parse('someapp.herokuapp.com') will return 'someapp.herokuapp.com' as the domain
10
- // whereas parse('app.dynamic.xyz') will return 'dynamic.xyz'
11
- const data = parse(window.location.hostname, { allowPrivateDomains: true });
12
- return data.domain || undefined;
13
- };
6
+ const getTLD = () => PlatformService.getTLD();
14
7
 
15
8
  export { getTLD };
package/src/index.cjs CHANGED
@@ -30,6 +30,11 @@ var TooManyEmailVerificationsError = require('./errors/TooManyEmailVerifications
30
30
  var VerificationDataCollectionError = require('./errors/VerificationDataCollectionError.cjs');
31
31
  var InvalidPhoneNumberError = require('./errors/InvalidPhoneNumberError.cjs');
32
32
  var MergeAccountsConfirmationError = require('./errors/MergeAccountsConfirmationError.cjs');
33
+ var CustomFieldNotUniqueError = require('./errors/CustomFieldNotUniqueError.cjs');
34
+ var CookieInvalidError = require('./errors/CookieInvalidError.cjs');
35
+ var AccessBlockedError = require('./errors/AccessBlockedError.cjs');
36
+ var EmbeddedWalletException = require('./errors/EmbeddedWalletException.cjs');
37
+ var MfaInvalidOtpError = require('./errors/MfaInvalidOtpError.cjs');
33
38
  var CancellablePromise = require('./CancellablePromise/CancellablePromise.cjs');
34
39
  var isFunction = require('./isFunction/isFunction.cjs');
35
40
  var isMobile = require('./isMobile.cjs');
@@ -51,6 +56,9 @@ var ceil = require('./ceil/ceil.cjs');
51
56
  var trimEnd = require('./trimEnd/trimEnd.cjs');
52
57
  var isLedgerAddressViaVerifiedCredentials = require('./isLedgerAddressViaVerifiedCredentials.cjs');
53
58
  var runSafe = require('./runSafe/runSafe.cjs');
59
+ var PlatformService = require('./services/PlatformService/PlatformService.cjs');
60
+ var createBrowserPlatformService = require('./services/PlatformService/createBrowserPlatformService/createBrowserPlatformService.cjs');
61
+ var FetchService = require('./services/FetchService/FetchService.cjs');
54
62
 
55
63
 
56
64
 
@@ -81,6 +89,11 @@ exports.TooManyEmailVerificationsError = TooManyEmailVerificationsError.TooManyE
81
89
  exports.VerificationDataCollectionError = VerificationDataCollectionError.VerificationDataCollectionError;
82
90
  exports.InvalidPhoneNumberError = InvalidPhoneNumberError.InvalidPhoneNumberError;
83
91
  exports.MergeAccountsConfirmationError = MergeAccountsConfirmationError.MergeAccountsConfirmationError;
92
+ exports.CustomFieldNotUniqueError = CustomFieldNotUniqueError.CustomFieldNotUniqueError;
93
+ exports.CookieInvalidError = CookieInvalidError.CookieInvalidError;
94
+ exports.AccessBlockedError = AccessBlockedError.AccessBlockedError;
95
+ exports.EmbeddedWalletException = EmbeddedWalletException.EmbeddedWalletException;
96
+ exports.MfaInvalidOtpError = MfaInvalidOtpError.MfaInvalidOtpError;
84
97
  exports.CancellablePromise = CancellablePromise.CancellablePromise;
85
98
  exports.isFunction = isFunction.isFunction;
86
99
  exports.getAndroidVersion = isMobile.getAndroidVersion;
@@ -116,3 +129,6 @@ exports.ceil = ceil.ceil;
116
129
  exports.trimEnd = trimEnd.trimEnd;
117
130
  exports.isLedgerAddressViaVerifiedCredentials = isLedgerAddressViaVerifiedCredentials.isLedgerAddressViaVerifiedCredentials;
118
131
  exports.runSafe = runSafe.runSafe;
132
+ exports.PlatformService = PlatformService.PlatformService;
133
+ exports.createBrowserPlatformService = createBrowserPlatformService.createBrowserPlatformService;
134
+ exports.FetchService = FetchService.FetchService;
package/src/index.d.ts CHANGED
@@ -22,3 +22,5 @@ export * from './ceil';
22
22
  export * from './trimEnd';
23
23
  export * from './isLedgerAddressViaVerifiedCredentials';
24
24
  export { runSafe } from './runSafe';
25
+ export { PlatformService, createBrowserPlatformService, type IPlatformService, } from './services/PlatformService';
26
+ export { FetchService } from './services/FetchService';
package/src/index.js CHANGED
@@ -26,6 +26,11 @@ export { TooManyEmailVerificationsError } from './errors/TooManyEmailVerificatio
26
26
  export { VerificationDataCollectionError } from './errors/VerificationDataCollectionError.js';
27
27
  export { InvalidPhoneNumberError } from './errors/InvalidPhoneNumberError.js';
28
28
  export { MergeAccountsConfirmationError } from './errors/MergeAccountsConfirmationError.js';
29
+ export { CustomFieldNotUniqueError } from './errors/CustomFieldNotUniqueError.js';
30
+ export { CookieInvalidError } from './errors/CookieInvalidError.js';
31
+ export { AccessBlockedError } from './errors/AccessBlockedError.js';
32
+ export { EmbeddedWalletException } from './errors/EmbeddedWalletException.js';
33
+ export { MfaInvalidOtpError } from './errors/MfaInvalidOtpError.js';
29
34
  export { CancellablePromise } from './CancellablePromise/CancellablePromise.js';
30
35
  export { isFunction } from './isFunction/isFunction.js';
31
36
  export { getAndroidVersion, isAndroid, isIOS, isIPad, isIPhone, isIPhone8OrEarlier, isLegacySafari, isMobile, isSamsungBrowser, isWindows } from './isMobile.js';
@@ -47,3 +52,6 @@ export { ceil } from './ceil/ceil.js';
47
52
  export { trimEnd } from './trimEnd/trimEnd.js';
48
53
  export { isLedgerAddressViaVerifiedCredentials } from './isLedgerAddressViaVerifiedCredentials.js';
49
54
  export { runSafe } from './runSafe/runSafe.js';
55
+ export { PlatformService } from './services/PlatformService/PlatformService.js';
56
+ export { createBrowserPlatformService } from './services/PlatformService/createBrowserPlatformService/createBrowserPlatformService.js';
57
+ export { FetchService } from './services/FetchService/FetchService.js';
@@ -5,6 +5,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var logger$1 = require('@dynamic-labs/logger');
7
7
 
8
- const logger = new logger$1.Logger('magic');
8
+ const logger = new logger$1.Logger('utils');
9
9
 
10
10
  exports.logger = logger;
@@ -1,6 +1,6 @@
1
1
  'use client'
2
2
  import { Logger } from '@dynamic-labs/logger';
3
3
 
4
- const logger = new Logger('magic');
4
+ const logger = new Logger('utils');
5
5
 
6
6
  export { logger };
@@ -0,0 +1,24 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ /**
7
+ * Class implementing the fetch service with a configurable fetch implementation.
8
+ */
9
+ class FetchService {
10
+ static get implementation() {
11
+ if (!FetchService._implementation) {
12
+ return { fetch: window.fetch.bind(window) };
13
+ }
14
+ return FetchService._implementation;
15
+ }
16
+ static setImplementation(implementation) {
17
+ FetchService._implementation = implementation;
18
+ }
19
+ static get fetch() {
20
+ return FetchService.implementation.fetch;
21
+ }
22
+ }
23
+
24
+ exports.FetchService = FetchService;
@@ -0,0 +1,10 @@
1
+ import { IFetchService } from './types';
2
+ /**
3
+ * Class implementing the fetch service with a configurable fetch implementation.
4
+ */
5
+ export declare class FetchService {
6
+ static _implementation: IFetchService;
7
+ static get implementation(): IFetchService;
8
+ static setImplementation(implementation: IFetchService): void;
9
+ static get fetch(): (input: RequestInfo, init?: RequestInit | undefined) => Promise<Response>;
10
+ }
@@ -0,0 +1,20 @@
1
+ 'use client'
2
+ /**
3
+ * Class implementing the fetch service with a configurable fetch implementation.
4
+ */
5
+ class FetchService {
6
+ static get implementation() {
7
+ if (!FetchService._implementation) {
8
+ return { fetch: window.fetch.bind(window) };
9
+ }
10
+ return FetchService._implementation;
11
+ }
12
+ static setImplementation(implementation) {
13
+ FetchService._implementation = implementation;
14
+ }
15
+ static get fetch() {
16
+ return FetchService.implementation.fetch;
17
+ }
18
+ }
19
+
20
+ export { FetchService };
@@ -0,0 +1,2 @@
1
+ export { FetchService } from './FetchService';
2
+ export type { IFetchService } from './types';
@@ -0,0 +1,3 @@
1
+ export type IFetchService = {
2
+ fetch: (input: RequestInfo, init?: RequestInit) => Promise<Response>;
3
+ };
@@ -0,0 +1,39 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var createBrowserPlatformService = require('./createBrowserPlatformService/createBrowserPlatformService.cjs');
7
+
8
+ class PlatformService {
9
+ static get implementation() {
10
+ if (!PlatformService._implementation) {
11
+ return createBrowserPlatformService.createBrowserPlatformService(window);
12
+ }
13
+ return PlatformService._implementation;
14
+ }
15
+ static setImplementation(implementation) {
16
+ PlatformService._implementation = implementation;
17
+ }
18
+ static get getOrigin() {
19
+ return PlatformService.implementation.getOrigin;
20
+ }
21
+ static get getHost() {
22
+ return PlatformService.implementation.getHost;
23
+ }
24
+ static get getHostname() {
25
+ return PlatformService.implementation.getHostname;
26
+ }
27
+ static get getTLD() {
28
+ return PlatformService.implementation.getTLD;
29
+ }
30
+ // Deeplink handling
31
+ static get openURL() {
32
+ return PlatformService.implementation.openURL;
33
+ }
34
+ static get openNewWindow() {
35
+ return PlatformService.implementation.openNewWindow;
36
+ }
37
+ }
38
+
39
+ exports.PlatformService = PlatformService;
@@ -0,0 +1,12 @@
1
+ import { IPlatformService } from './types';
2
+ export declare class PlatformService {
3
+ static _implementation: IPlatformService;
4
+ static get implementation(): IPlatformService;
5
+ static setImplementation(implementation: IPlatformService): void;
6
+ static get getOrigin(): () => string;
7
+ static get getHost(): () => string;
8
+ static get getHostname(): () => string;
9
+ static get getTLD(): () => string | undefined;
10
+ static get openURL(): (url: string) => Promise<void>;
11
+ static get openNewWindow(): (url: string) => Promise<void>;
12
+ }
@@ -0,0 +1,35 @@
1
+ 'use client'
2
+ import { createBrowserPlatformService } from './createBrowserPlatformService/createBrowserPlatformService.js';
3
+
4
+ class PlatformService {
5
+ static get implementation() {
6
+ if (!PlatformService._implementation) {
7
+ return createBrowserPlatformService(window);
8
+ }
9
+ return PlatformService._implementation;
10
+ }
11
+ static setImplementation(implementation) {
12
+ PlatformService._implementation = implementation;
13
+ }
14
+ static get getOrigin() {
15
+ return PlatformService.implementation.getOrigin;
16
+ }
17
+ static get getHost() {
18
+ return PlatformService.implementation.getHost;
19
+ }
20
+ static get getHostname() {
21
+ return PlatformService.implementation.getHostname;
22
+ }
23
+ static get getTLD() {
24
+ return PlatformService.implementation.getTLD;
25
+ }
26
+ // Deeplink handling
27
+ static get openURL() {
28
+ return PlatformService.implementation.openURL;
29
+ }
30
+ static get openNewWindow() {
31
+ return PlatformService.implementation.openNewWindow;
32
+ }
33
+ }
34
+
35
+ export { PlatformService };
@@ -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
+ var tldts = require('tldts');
8
+
9
+ const createBrowserPlatformService = (window) => ({
10
+ getHost: () => window.location.host,
11
+ getHostname: () => window.location.hostname,
12
+ getOrigin: () => window.location.origin,
13
+ getTLD: () => {
14
+ // Passing the allowPrivateDomains option prevents returning the actual TLD
15
+ // for domains that have delegated subdomains like herokuapp.com or s3.amazonaws.com
16
+ // full list is contained here https://publicsuffix.org/list/effective_tld_names.dat
17
+ // separated by ICANN DOMAINS and PRIVATE DOMAINS
18
+ // so for instance parse('someapp.herokuapp.com') will return 'someapp.herokuapp.com' as the domain
19
+ // whereas parse('app.dynamic.xyz') will return 'dynamic.xyz'
20
+ const data = tldts.parse(window.location.hostname, {
21
+ allowPrivateDomains: true,
22
+ });
23
+ return data.domain || undefined;
24
+ },
25
+ openNewWindow: (url) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
26
+ window.open(url);
27
+ }),
28
+ openURL: (url) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
29
+ window.location.assign(url);
30
+ }),
31
+ });
32
+
33
+ exports.createBrowserPlatformService = createBrowserPlatformService;
@@ -0,0 +1,2 @@
1
+ import { IPlatformService } from '../types';
2
+ export declare const createBrowserPlatformService: (window: Window) => IPlatformService;
@@ -0,0 +1,29 @@
1
+ 'use client'
2
+ import { __awaiter } from '../../../../_virtual/_tslib.js';
3
+ import { parse } from 'tldts';
4
+
5
+ const createBrowserPlatformService = (window) => ({
6
+ getHost: () => window.location.host,
7
+ getHostname: () => window.location.hostname,
8
+ getOrigin: () => window.location.origin,
9
+ getTLD: () => {
10
+ // Passing the allowPrivateDomains option prevents returning the actual TLD
11
+ // for domains that have delegated subdomains like herokuapp.com or s3.amazonaws.com
12
+ // full list is contained here https://publicsuffix.org/list/effective_tld_names.dat
13
+ // separated by ICANN DOMAINS and PRIVATE DOMAINS
14
+ // so for instance parse('someapp.herokuapp.com') will return 'someapp.herokuapp.com' as the domain
15
+ // whereas parse('app.dynamic.xyz') will return 'dynamic.xyz'
16
+ const data = parse(window.location.hostname, {
17
+ allowPrivateDomains: true,
18
+ });
19
+ return data.domain || undefined;
20
+ },
21
+ openNewWindow: (url) => __awaiter(void 0, void 0, void 0, function* () {
22
+ window.open(url);
23
+ }),
24
+ openURL: (url) => __awaiter(void 0, void 0, void 0, function* () {
25
+ window.location.assign(url);
26
+ }),
27
+ });
28
+
29
+ export { createBrowserPlatformService };
@@ -0,0 +1 @@
1
+ export { createBrowserPlatformService } from './createBrowserPlatformService';
@@ -0,0 +1,3 @@
1
+ export * from './PlatformService';
2
+ export * from './createBrowserPlatformService';
3
+ export * from './types';
@@ -0,0 +1,29 @@
1
+ export interface IPlatformService {
2
+ /**
3
+ * Gets the hostname of the current location.
4
+ *
5
+ * @example window.location.hostname
6
+ */
7
+ getHostname(): string;
8
+ /**
9
+ * Gets the host of the current location.
10
+ *
11
+ * @example window.location.host
12
+ */
13
+ getHost(): string;
14
+ /**
15
+ * Gets the origin of the current location.
16
+ *
17
+ * @example window.location.origin
18
+ */
19
+ getOrigin(): string;
20
+ getTLD(): string | undefined;
21
+ /**
22
+ * Opens a URL. If possible, should avoid new windows.
23
+ */
24
+ openURL(url: string): Promise<void>;
25
+ /**
26
+ * Opens a given URL in a new window.
27
+ */
28
+ openNewWindow(url: string): Promise<void>;
29
+ }