@dynamic-labs/utils 2.1.0-alpha.2 → 2.1.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.
Files changed (35) hide show
  1. package/CHANGELOG.md +170 -0
  2. package/package.json +4 -4
  3. package/src/errors/CookieInvalidError.cjs +14 -0
  4. package/src/errors/CookieInvalidError.d.ts +4 -0
  5. package/src/errors/CookieInvalidError.js +10 -0
  6. package/src/errors/CustomFieldNotUniqueError.cjs +14 -0
  7. package/src/errors/CustomFieldNotUniqueError.d.ts +4 -0
  8. package/src/errors/CustomFieldNotUniqueError.js +10 -0
  9. package/src/errors/MergeAccountsConfirmationError.d.ts +2 -2
  10. package/src/errors/index.d.ts +2 -0
  11. package/src/getTLD/getTLD.cjs +3 -11
  12. package/src/getTLD/getTLD.js +3 -11
  13. package/src/index.cjs +12 -0
  14. package/src/index.d.ts +2 -0
  15. package/src/index.js +6 -0
  16. package/src/logger/logger.cjs +1 -1
  17. package/src/logger/logger.js +1 -1
  18. package/src/services/FetchService/FetchService.cjs +24 -0
  19. package/src/services/FetchService/FetchService.d.ts +10 -0
  20. package/src/services/FetchService/FetchService.js +20 -0
  21. package/src/services/FetchService/index.d.ts +2 -0
  22. package/src/services/FetchService/types.d.ts +3 -0
  23. package/src/services/LocationService/LocationService.cjs +26 -0
  24. package/src/services/LocationService/LocationService.d.ts +8 -0
  25. package/src/services/LocationService/LocationService.js +22 -0
  26. package/src/services/LocationService/index.d.ts +3 -0
  27. package/src/services/LocationService/types.d.ts +4 -0
  28. package/src/services/LocationService/utils/createLocationFromOrigin/createLocationFromOrigin.cjs +14 -0
  29. package/src/services/LocationService/utils/createLocationFromOrigin/createLocationFromOrigin.d.ts +2 -0
  30. package/src/services/LocationService/utils/createLocationFromOrigin/createLocationFromOrigin.js +10 -0
  31. package/src/services/LocationService/utils/createLocationFromOrigin/index.d.ts +1 -0
  32. package/src/services/LocationService/utils/createLocationFromWindow/createLocationFromWindow.cjs +24 -0
  33. package/src/services/LocationService/utils/createLocationFromWindow/createLocationFromWindow.d.ts +2 -0
  34. package/src/services/LocationService/utils/createLocationFromWindow/createLocationFromWindow.js +20 -0
  35. package/src/services/LocationService/utils/createLocationFromWindow/index.d.ts +1 -0
package/CHANGELOG.md CHANGED
@@ -1,4 +1,174 @@
1
1
 
2
+ ## [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)
3
+
4
+ ## [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)
5
+
6
+
7
+ ### Features
8
+
9
+ * adds client.networks module ([#5650](https://github.com/dynamic-labs/DynamicAuth/issues/5650)) ([70f7fe5](https://github.com/dynamic-labs/DynamicAuth/commit/70f7fe5f437756c51e787ac12183be0a23c51b89))
10
+ * user fields supports custom fields ([#5639](https://github.com/dynamic-labs/DynamicAuth/issues/5639)) ([8eb5788](https://github.com/dynamic-labs/DynamicAuth/commit/8eb5788fc3e1286929f5949ecb57736b21b13fb5))
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * add webcredentials to expo ([#5640](https://github.com/dynamic-labs/DynamicAuth/issues/5640)) ([9026fbf](https://github.com/dynamic-labs/DynamicAuth/commit/9026fbf0108537e884588f3adcdb9f0db04a159b))
16
+ * 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))
17
+
18
+ ## [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)
19
+
20
+
21
+ ### Features
22
+
23
+ * add createUserProfileFromSDKUser ([#5596](https://github.com/dynamic-labs/DynamicAuth/issues/5596)) ([d37a1b4](https://github.com/dynamic-labs/DynamicAuth/commit/d37a1b4119f5ff4fff1e987d157f6d5abf105a8b))
24
+ * add headless social sign-in ([#5439](https://github.com/dynamic-labs/DynamicAuth/issues/5439)) ([e32fdf8](https://github.com/dynamic-labs/DynamicAuth/commit/e32fdf863718d661b90b592c8df734e92386ddf3))
25
+ * 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))
26
+
27
+
28
+ ### Bug Fixes
29
+
30
+ * include applinks details to AASA ([#5635](https://github.com/dynamic-labs/DynamicAuth/issues/5635)) ([ce94fec](https://github.com/dynamic-labs/DynamicAuth/commit/ce94fec80adbb3eb4efcb79d1aa2cc6eb35eab6f))
31
+ * 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))
32
+ * 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))
33
+
34
+ ## [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)
35
+
36
+ ## [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)
37
+
38
+
39
+ ### Features
40
+
41
+ * add coinbaseWalletPreference prop ([#5607](https://github.com/dynamic-labs/DynamicAuth/issues/5607)) ([1ac3b2c](https://github.com/dynamic-labs/DynamicAuth/commit/1ac3b2ce7abb136465f4aa88b045dfb70d99aad7))
42
+
43
+ ## [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)
44
+
45
+
46
+ ### Features
47
+
48
+ * 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))
49
+ * 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))
50
+ * 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))
51
+
52
+ ## [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)
53
+
54
+
55
+ ### Bug Fixes
56
+
57
+ * 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))
58
+
59
+ ## [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)
60
+
61
+
62
+ ### Features
63
+
64
+ * add useSwitchWallet ([#5575](https://github.com/dynamic-labs/DynamicAuth/issues/5575)) ([d3053d9](https://github.com/dynamic-labs/DynamicAuth/commit/d3053d920110c26ef8052e77bf59e07dedc7c683))
65
+
66
+
67
+ ### Bug Fixes
68
+
69
+ * linking phantom wallets in mobile ([#5524](https://github.com/dynamic-labs/DynamicAuth/issues/5524)) ([28d90f5](https://github.com/dynamic-labs/DynamicAuth/commit/28d90f5126b9c22535b63a3797cc060ef089fc63))
70
+ * 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))
71
+ * remove goerli testnets and add sepolia ([#5565](https://github.com/dynamic-labs/DynamicAuth/issues/5565)) ([888eb03](https://github.com/dynamic-labs/DynamicAuth/commit/888eb031ef6f4dbbdc3015265cce8647d2c720b0))
72
+
73
+ ## [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)
74
+
75
+
76
+ ### Bug Fixes
77
+
78
+ * ensure Farcaster QR uses useSocialAuth hook ([#5550](https://github.com/dynamic-labs/DynamicAuth/issues/5550)) ([57fcd97](https://github.com/dynamic-labs/DynamicAuth/commit/57fcd97c44e3f52065dcf856acf7bca7b24fabc7))
79
+
80
+ ## [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)
81
+
82
+
83
+ ### Features
84
+
85
+ * 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))
86
+
87
+ ## [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)
88
+
89
+
90
+ ### Features
91
+
92
+ * **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))
93
+ * headless reveal embedded wallet key ([#5518](https://github.com/dynamic-labs/DynamicAuth/issues/5518)) ([77c1536](https://github.com/dynamic-labs/DynamicAuth/commit/77c15360b2b28c52cbdeafb3ce8ca7e80dbecf57))
94
+
95
+
96
+ ### Bug Fixes
97
+
98
+ * 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))
99
+
100
+ ## [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)
101
+
102
+
103
+ ### Features
104
+
105
+ * 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))
106
+
107
+ ## [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)
108
+
109
+
110
+ ### Features
111
+
112
+ * 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))
113
+
114
+ ## [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)
115
+
116
+
117
+ ### Bug Fixes
118
+
119
+ * 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))
120
+ * 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))
121
+ * network with keplr ([#5485](https://github.com/dynamic-labs/DynamicAuth/issues/5485)) ([b86f2fc](https://github.com/dynamic-labs/DynamicAuth/commit/b86f2fce491f9752e80a86643916da9ac7fb9276))
122
+ * refetch nameservice data and display properly ([#5476](https://github.com/dynamic-labs/DynamicAuth/issues/5476)) ([2aee798](https://github.com/dynamic-labs/DynamicAuth/commit/2aee798846f69496201bec7aa52e7ec1f370b7c3))
123
+ * 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))
124
+
125
+ ## [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)
126
+
127
+
128
+ ### Bug Fixes
129
+
130
+ * 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))
131
+
132
+ ## [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)
133
+
134
+
135
+ ### Bug Fixes
136
+
137
+ * embedded wallets headless session control fixes ([#5469](https://github.com/dynamic-labs/DynamicAuth/issues/5469)) ([92e6c35](https://github.com/dynamic-labs/DynamicAuth/commit/92e6c359d2710fd4f5f5a6fedc4acf6c4bab78ba))
138
+
139
+ ## [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)
140
+
141
+
142
+ ### Bug Fixes
143
+
144
+ * 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))
145
+
146
+ ## [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)
147
+
148
+
149
+ ### Features
150
+
151
+ * 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))
152
+ * headless create passkeys for embedded wallets ([#5395](https://github.com/dynamic-labs/DynamicAuth/issues/5395)) ([0b64099](https://github.com/dynamic-labs/DynamicAuth/commit/0b6409968457f65886248f0a0879e39ec3803fd0))
153
+
154
+
155
+ ### Bug Fixes
156
+
157
+ * 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))
158
+
159
+ ## [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)
160
+
161
+
162
+ ### Features
163
+
164
+ * add merge user accounts flow ([#5429](https://github.com/dynamic-labs/DynamicAuth/issues/5429)) ([41d4239](https://github.com/dynamic-labs/DynamicAuth/commit/41d423906625e28004ba8f20baf57847ed8bf5d0))
165
+
166
+
167
+ ### Bug Fixes
168
+
169
+ * disconnect wallet on lock in connect-only ([#5422](https://github.com/dynamic-labs/DynamicAuth/issues/5422)) ([a26f9fe](https://github.com/dynamic-labs/DynamicAuth/commit/a26f9fe93cf8568f1482e10b831de98c77fb2a2d))
170
+ * useReactiveProxy to stop proxing when it finds a reactive value ([#5428](https://github.com/dynamic-labs/DynamicAuth/issues/5428)) ([838dce9](https://github.com/dynamic-labs/DynamicAuth/commit/838dce9ee953361e41772239a91adb1dd8d40234))
171
+
2
172
  ## [2.1.0-alpha.2](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.1...v2.1.0-alpha.2) (2024-04-19)
3
173
 
4
174
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/utils",
3
- "version": "2.1.0-alpha.2",
3
+ "version": "2.1.0-alpha.21",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/dynamic-labs/DynamicAuth.git",
@@ -26,10 +26,10 @@
26
26
  "./package.json": "./package.json"
27
27
  },
28
28
  "dependencies": {
29
- "@dynamic-labs/sdk-api-core": "0.0.423",
29
+ "@dynamic-labs/sdk-api-core": "0.0.447",
30
30
  "tldts": "6.0.16",
31
- "@dynamic-labs/logger": "2.1.0-alpha.2",
32
- "@dynamic-labs/types": "2.1.0-alpha.2",
31
+ "@dynamic-labs/logger": "2.1.0-alpha.21",
32
+ "@dynamic-labs/types": "2.1.0-alpha.21",
33
33
  "buffer": "6.0.3"
34
34
  },
35
35
  "peerDependencies": {
@@ -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 };
@@ -2,11 +2,11 @@ import { MergeConflicts } from '@dynamic-labs/sdk-api-core';
2
2
  import { DynamicError } from './DynamicError';
3
3
  export type MergeAccountsConfirmationErrorProps = {
4
4
  code: string;
5
- mergeConflicts?: MergeConflicts[];
5
+ mergeConflicts?: MergeConflicts;
6
6
  walletAddress?: string;
7
7
  };
8
8
  export declare class MergeAccountsConfirmationError extends DynamicError {
9
- mergeConflicts: MergeConflicts[] | undefined;
9
+ mergeConflicts: MergeConflicts | undefined;
10
10
  walletAddress: string | undefined;
11
11
  constructor({ code, mergeConflicts, walletAddress, }: MergeAccountsConfirmationErrorProps);
12
12
  }
@@ -24,3 +24,5 @@ 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';
@@ -3,17 +3,9 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var tldts = require('tldts');
6
+ var LocationService = require('../services/LocationService/LocationService.cjs');
7
+ require('tldts');
7
8
 
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
- };
9
+ const getTLD = () => LocationService.LocationService.getTLD();
18
10
 
19
11
  exports.getTLD = getTLD;
@@ -1,15 +1,7 @@
1
1
  'use client'
2
- import { parse } from 'tldts';
2
+ import { LocationService } from '../services/LocationService/LocationService.js';
3
+ import 'tldts';
3
4
 
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
- };
5
+ const getTLD = () => LocationService.getTLD();
14
6
 
15
7
  export { getTLD };
package/src/index.cjs CHANGED
@@ -30,6 +30,8 @@ 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');
33
35
  var CancellablePromise = require('./CancellablePromise/CancellablePromise.cjs');
34
36
  var isFunction = require('./isFunction/isFunction.cjs');
35
37
  var isMobile = require('./isMobile.cjs');
@@ -51,6 +53,10 @@ var ceil = require('./ceil/ceil.cjs');
51
53
  var trimEnd = require('./trimEnd/trimEnd.cjs');
52
54
  var isLedgerAddressViaVerifiedCredentials = require('./isLedgerAddressViaVerifiedCredentials.cjs');
53
55
  var runSafe = require('./runSafe/runSafe.cjs');
56
+ var LocationService = require('./services/LocationService/LocationService.cjs');
57
+ var createLocationFromWindow = require('./services/LocationService/utils/createLocationFromWindow/createLocationFromWindow.cjs');
58
+ var createLocationFromOrigin = require('./services/LocationService/utils/createLocationFromOrigin/createLocationFromOrigin.cjs');
59
+ var FetchService = require('./services/FetchService/FetchService.cjs');
54
60
 
55
61
 
56
62
 
@@ -81,6 +87,8 @@ exports.TooManyEmailVerificationsError = TooManyEmailVerificationsError.TooManyE
81
87
  exports.VerificationDataCollectionError = VerificationDataCollectionError.VerificationDataCollectionError;
82
88
  exports.InvalidPhoneNumberError = InvalidPhoneNumberError.InvalidPhoneNumberError;
83
89
  exports.MergeAccountsConfirmationError = MergeAccountsConfirmationError.MergeAccountsConfirmationError;
90
+ exports.CustomFieldNotUniqueError = CustomFieldNotUniqueError.CustomFieldNotUniqueError;
91
+ exports.CookieInvalidError = CookieInvalidError.CookieInvalidError;
84
92
  exports.CancellablePromise = CancellablePromise.CancellablePromise;
85
93
  exports.isFunction = isFunction.isFunction;
86
94
  exports.getAndroidVersion = isMobile.getAndroidVersion;
@@ -116,3 +124,7 @@ exports.ceil = ceil.ceil;
116
124
  exports.trimEnd = trimEnd.trimEnd;
117
125
  exports.isLedgerAddressViaVerifiedCredentials = isLedgerAddressViaVerifiedCredentials.isLedgerAddressViaVerifiedCredentials;
118
126
  exports.runSafe = runSafe.runSafe;
127
+ exports.LocationService = LocationService.LocationService;
128
+ exports.createLocationFromWindow = createLocationFromWindow.createLocationFromWindow;
129
+ exports.createLocationFromOrigin = createLocationFromOrigin.createLocationFromOrigin;
130
+ 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 { LocationService, createLocationFromOrigin, createLocationFromWindow, } from './services/LocationService';
26
+ export { FetchService } from './services/FetchService';
package/src/index.js CHANGED
@@ -26,6 +26,8 @@ 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';
29
31
  export { CancellablePromise } from './CancellablePromise/CancellablePromise.js';
30
32
  export { isFunction } from './isFunction/isFunction.js';
31
33
  export { getAndroidVersion, isAndroid, isIOS, isIPad, isIPhone, isIPhone8OrEarlier, isLegacySafari, isMobile, isSamsungBrowser, isWindows } from './isMobile.js';
@@ -47,3 +49,7 @@ export { ceil } from './ceil/ceil.js';
47
49
  export { trimEnd } from './trimEnd/trimEnd.js';
48
50
  export { isLedgerAddressViaVerifiedCredentials } from './isLedgerAddressViaVerifiedCredentials.js';
49
51
  export { runSafe } from './runSafe/runSafe.js';
52
+ export { LocationService } from './services/LocationService/LocationService.js';
53
+ export { createLocationFromWindow } from './services/LocationService/utils/createLocationFromWindow/createLocationFromWindow.js';
54
+ export { createLocationFromOrigin } from './services/LocationService/utils/createLocationFromOrigin/createLocationFromOrigin.js';
55
+ 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 };
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 };
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,26 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var createLocationFromWindow = require('./utils/createLocationFromWindow/createLocationFromWindow.cjs');
7
+
8
+ class LocationService {
9
+ static get implementation() {
10
+ if (!LocationService._implementation) {
11
+ return createLocationFromWindow.createLocationFromWindow(window);
12
+ }
13
+ return LocationService._implementation;
14
+ }
15
+ static setImplementation(implementation) {
16
+ LocationService._implementation = implementation;
17
+ }
18
+ static get getHostname() {
19
+ return LocationService.implementation.getHostname;
20
+ }
21
+ static get getTLD() {
22
+ return LocationService.implementation.getTLD;
23
+ }
24
+ }
25
+
26
+ exports.LocationService = LocationService;
@@ -0,0 +1,8 @@
1
+ import { ILocation } from './types';
2
+ export declare class LocationService {
3
+ static _implementation: ILocation;
4
+ static get implementation(): ILocation;
5
+ static setImplementation(implementation: ILocation): void;
6
+ static get getHostname(): () => string;
7
+ static get getTLD(): () => string | undefined;
8
+ }
@@ -0,0 +1,22 @@
1
+ 'use client'
2
+ import { createLocationFromWindow } from './utils/createLocationFromWindow/createLocationFromWindow.js';
3
+
4
+ class LocationService {
5
+ static get implementation() {
6
+ if (!LocationService._implementation) {
7
+ return createLocationFromWindow(window);
8
+ }
9
+ return LocationService._implementation;
10
+ }
11
+ static setImplementation(implementation) {
12
+ LocationService._implementation = implementation;
13
+ }
14
+ static get getHostname() {
15
+ return LocationService.implementation.getHostname;
16
+ }
17
+ static get getTLD() {
18
+ return LocationService.implementation.getTLD;
19
+ }
20
+ }
21
+
22
+ export { LocationService };
@@ -0,0 +1,3 @@
1
+ export { LocationService } from './LocationService';
2
+ export { createLocationFromWindow } from './utils/createLocationFromWindow';
3
+ export { createLocationFromOrigin } from './utils/createLocationFromOrigin';
@@ -0,0 +1,4 @@
1
+ export interface ILocation {
2
+ getHostname(): string;
3
+ getTLD(): string | undefined;
4
+ }
@@ -0,0 +1,14 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ const createLocationFromOrigin = (origin) => {
7
+ const url = new URL(origin);
8
+ return {
9
+ getHostname: () => url.hostname,
10
+ getTLD: () => url.hostname,
11
+ };
12
+ };
13
+
14
+ exports.createLocationFromOrigin = createLocationFromOrigin;
@@ -0,0 +1,2 @@
1
+ import { ILocation } from '../../types';
2
+ export declare const createLocationFromOrigin: (origin: string) => ILocation;
@@ -0,0 +1,10 @@
1
+ 'use client'
2
+ const createLocationFromOrigin = (origin) => {
3
+ const url = new URL(origin);
4
+ return {
5
+ getHostname: () => url.hostname,
6
+ getTLD: () => url.hostname,
7
+ };
8
+ };
9
+
10
+ export { createLocationFromOrigin };
@@ -0,0 +1 @@
1
+ export { createLocationFromOrigin } from './createLocationFromOrigin';
@@ -0,0 +1,24 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var tldts = require('tldts');
7
+
8
+ const createLocationFromWindow = (window) => ({
9
+ getHostname: () => window.location.hostname,
10
+ getTLD: () => {
11
+ // Passing the allowPrivateDomains option prevents returning the actual TLD
12
+ // for domains that have delegated subdomains like herokuapp.com or s3.amazonaws.com
13
+ // full list is contained here https://publicsuffix.org/list/effective_tld_names.dat
14
+ // separated by ICANN DOMAINS and PRIVATE DOMAINS
15
+ // so for instance parse('someapp.herokuapp.com') will return 'someapp.herokuapp.com' as the domain
16
+ // whereas parse('app.dynamic.xyz') will return 'dynamic.xyz'
17
+ const data = tldts.parse(window.location.hostname, {
18
+ allowPrivateDomains: true,
19
+ });
20
+ return data.domain || undefined;
21
+ },
22
+ });
23
+
24
+ exports.createLocationFromWindow = createLocationFromWindow;
@@ -0,0 +1,2 @@
1
+ import { ILocation } from '../../types';
2
+ export declare const createLocationFromWindow: (window: Window) => ILocation;
@@ -0,0 +1,20 @@
1
+ 'use client'
2
+ import { parse } from 'tldts';
3
+
4
+ const createLocationFromWindow = (window) => ({
5
+ getHostname: () => window.location.hostname,
6
+ getTLD: () => {
7
+ // Passing the allowPrivateDomains option prevents returning the actual TLD
8
+ // for domains that have delegated subdomains like herokuapp.com or s3.amazonaws.com
9
+ // full list is contained here https://publicsuffix.org/list/effective_tld_names.dat
10
+ // separated by ICANN DOMAINS and PRIVATE DOMAINS
11
+ // so for instance parse('someapp.herokuapp.com') will return 'someapp.herokuapp.com' as the domain
12
+ // whereas parse('app.dynamic.xyz') will return 'dynamic.xyz'
13
+ const data = parse(window.location.hostname, {
14
+ allowPrivateDomains: true,
15
+ });
16
+ return data.domain || undefined;
17
+ },
18
+ });
19
+
20
+ export { createLocationFromWindow };
@@ -0,0 +1 @@
1
+ export { createLocationFromWindow } from './createLocationFromWindow';