@dynamic-labs/utils 2.1.0-alpha.2 → 2.1.0-alpha.20

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 (32) hide show
  1. package/CHANGELOG.md +168 -0
  2. package/package.json +4 -4
  3. package/src/errors/CustomFieldNotUniqueError.cjs +14 -0
  4. package/src/errors/CustomFieldNotUniqueError.d.ts +4 -0
  5. package/src/errors/CustomFieldNotUniqueError.js +10 -0
  6. package/src/errors/MergeAccountsConfirmationError.d.ts +2 -2
  7. package/src/errors/index.d.ts +1 -0
  8. package/src/getTLD/getTLD.cjs +3 -11
  9. package/src/getTLD/getTLD.js +3 -11
  10. package/src/index.cjs +10 -0
  11. package/src/index.d.ts +2 -0
  12. package/src/index.js +5 -0
  13. package/src/logger/logger.cjs +1 -1
  14. package/src/logger/logger.js +1 -1
  15. package/src/services/FetchService/FetchService.cjs +24 -0
  16. package/src/services/FetchService/FetchService.d.ts +10 -0
  17. package/src/services/FetchService/FetchService.js +20 -0
  18. package/src/services/FetchService/index.d.ts +2 -0
  19. package/src/services/FetchService/types.d.ts +3 -0
  20. package/src/services/LocationService/LocationService.cjs +26 -0
  21. package/src/services/LocationService/LocationService.d.ts +8 -0
  22. package/src/services/LocationService/LocationService.js +22 -0
  23. package/src/services/LocationService/index.d.ts +3 -0
  24. package/src/services/LocationService/types.d.ts +4 -0
  25. package/src/services/LocationService/utils/createLocationFromOrigin/createLocationFromOrigin.cjs +14 -0
  26. package/src/services/LocationService/utils/createLocationFromOrigin/createLocationFromOrigin.d.ts +2 -0
  27. package/src/services/LocationService/utils/createLocationFromOrigin/createLocationFromOrigin.js +10 -0
  28. package/src/services/LocationService/utils/createLocationFromOrigin/index.d.ts +1 -0
  29. package/src/services/LocationService/utils/createLocationFromWindow/createLocationFromWindow.cjs +24 -0
  30. package/src/services/LocationService/utils/createLocationFromWindow/createLocationFromWindow.d.ts +2 -0
  31. package/src/services/LocationService/utils/createLocationFromWindow/createLocationFromWindow.js +20 -0
  32. package/src/services/LocationService/utils/createLocationFromWindow/index.d.ts +1 -0
package/CHANGELOG.md CHANGED
@@ -1,4 +1,172 @@
1
1
 
2
+ ## [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)
3
+
4
+
5
+ ### Features
6
+
7
+ * adds client.networks module ([#5650](https://github.com/dynamic-labs/DynamicAuth/issues/5650)) ([70f7fe5](https://github.com/dynamic-labs/DynamicAuth/commit/70f7fe5f437756c51e787ac12183be0a23c51b89))
8
+ * user fields supports custom fields ([#5639](https://github.com/dynamic-labs/DynamicAuth/issues/5639)) ([8eb5788](https://github.com/dynamic-labs/DynamicAuth/commit/8eb5788fc3e1286929f5949ecb57736b21b13fb5))
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * add webcredentials to expo ([#5640](https://github.com/dynamic-labs/DynamicAuth/issues/5640)) ([9026fbf](https://github.com/dynamic-labs/DynamicAuth/commit/9026fbf0108537e884588f3adcdb9f0db04a159b))
14
+ * 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))
15
+
16
+ ## [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)
17
+
18
+
19
+ ### Features
20
+
21
+ * add createUserProfileFromSDKUser ([#5596](https://github.com/dynamic-labs/DynamicAuth/issues/5596)) ([d37a1b4](https://github.com/dynamic-labs/DynamicAuth/commit/d37a1b4119f5ff4fff1e987d157f6d5abf105a8b))
22
+ * add headless social sign-in ([#5439](https://github.com/dynamic-labs/DynamicAuth/issues/5439)) ([e32fdf8](https://github.com/dynamic-labs/DynamicAuth/commit/e32fdf863718d661b90b592c8df734e92386ddf3))
23
+ * 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))
24
+
25
+
26
+ ### Bug Fixes
27
+
28
+ * include applinks details to AASA ([#5635](https://github.com/dynamic-labs/DynamicAuth/issues/5635)) ([ce94fec](https://github.com/dynamic-labs/DynamicAuth/commit/ce94fec80adbb3eb4efcb79d1aa2cc6eb35eab6f))
29
+ * 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))
30
+ * 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))
31
+
32
+ ## [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)
33
+
34
+ ## [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)
35
+
36
+
37
+ ### Features
38
+
39
+ * add coinbaseWalletPreference prop ([#5607](https://github.com/dynamic-labs/DynamicAuth/issues/5607)) ([1ac3b2c](https://github.com/dynamic-labs/DynamicAuth/commit/1ac3b2ce7abb136465f4aa88b045dfb70d99aad7))
40
+
41
+ ## [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)
42
+
43
+
44
+ ### Features
45
+
46
+ * 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))
47
+ * 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))
48
+ * 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))
49
+
50
+ ## [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)
51
+
52
+
53
+ ### Bug Fixes
54
+
55
+ * 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))
56
+
57
+ ## [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)
58
+
59
+
60
+ ### Features
61
+
62
+ * add useSwitchWallet ([#5575](https://github.com/dynamic-labs/DynamicAuth/issues/5575)) ([d3053d9](https://github.com/dynamic-labs/DynamicAuth/commit/d3053d920110c26ef8052e77bf59e07dedc7c683))
63
+
64
+
65
+ ### Bug Fixes
66
+
67
+ * linking phantom wallets in mobile ([#5524](https://github.com/dynamic-labs/DynamicAuth/issues/5524)) ([28d90f5](https://github.com/dynamic-labs/DynamicAuth/commit/28d90f5126b9c22535b63a3797cc060ef089fc63))
68
+ * 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))
69
+ * remove goerli testnets and add sepolia ([#5565](https://github.com/dynamic-labs/DynamicAuth/issues/5565)) ([888eb03](https://github.com/dynamic-labs/DynamicAuth/commit/888eb031ef6f4dbbdc3015265cce8647d2c720b0))
70
+
71
+ ## [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)
72
+
73
+
74
+ ### Bug Fixes
75
+
76
+ * ensure Farcaster QR uses useSocialAuth hook ([#5550](https://github.com/dynamic-labs/DynamicAuth/issues/5550)) ([57fcd97](https://github.com/dynamic-labs/DynamicAuth/commit/57fcd97c44e3f52065dcf856acf7bca7b24fabc7))
77
+
78
+ ## [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)
79
+
80
+
81
+ ### Features
82
+
83
+ * 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))
84
+
85
+ ## [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)
86
+
87
+
88
+ ### Features
89
+
90
+ * **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))
91
+ * headless reveal embedded wallet key ([#5518](https://github.com/dynamic-labs/DynamicAuth/issues/5518)) ([77c1536](https://github.com/dynamic-labs/DynamicAuth/commit/77c15360b2b28c52cbdeafb3ce8ca7e80dbecf57))
92
+
93
+
94
+ ### Bug Fixes
95
+
96
+ * 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))
97
+
98
+ ## [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)
99
+
100
+
101
+ ### Features
102
+
103
+ * 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))
104
+
105
+ ## [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)
106
+
107
+
108
+ ### Features
109
+
110
+ * 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))
111
+
112
+ ## [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)
113
+
114
+
115
+ ### Bug Fixes
116
+
117
+ * 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))
118
+ * 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))
119
+ * network with keplr ([#5485](https://github.com/dynamic-labs/DynamicAuth/issues/5485)) ([b86f2fc](https://github.com/dynamic-labs/DynamicAuth/commit/b86f2fce491f9752e80a86643916da9ac7fb9276))
120
+ * refetch nameservice data and display properly ([#5476](https://github.com/dynamic-labs/DynamicAuth/issues/5476)) ([2aee798](https://github.com/dynamic-labs/DynamicAuth/commit/2aee798846f69496201bec7aa52e7ec1f370b7c3))
121
+ * 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))
122
+
123
+ ## [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)
124
+
125
+
126
+ ### Bug Fixes
127
+
128
+ * 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))
129
+
130
+ ## [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)
131
+
132
+
133
+ ### Bug Fixes
134
+
135
+ * embedded wallets headless session control fixes ([#5469](https://github.com/dynamic-labs/DynamicAuth/issues/5469)) ([92e6c35](https://github.com/dynamic-labs/DynamicAuth/commit/92e6c359d2710fd4f5f5a6fedc4acf6c4bab78ba))
136
+
137
+ ## [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)
138
+
139
+
140
+ ### Bug Fixes
141
+
142
+ * 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))
143
+
144
+ ## [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)
145
+
146
+
147
+ ### Features
148
+
149
+ * 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))
150
+ * headless create passkeys for embedded wallets ([#5395](https://github.com/dynamic-labs/DynamicAuth/issues/5395)) ([0b64099](https://github.com/dynamic-labs/DynamicAuth/commit/0b6409968457f65886248f0a0879e39ec3803fd0))
151
+
152
+
153
+ ### Bug Fixes
154
+
155
+ * 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))
156
+
157
+ ## [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)
158
+
159
+
160
+ ### Features
161
+
162
+ * add merge user accounts flow ([#5429](https://github.com/dynamic-labs/DynamicAuth/issues/5429)) ([41d4239](https://github.com/dynamic-labs/DynamicAuth/commit/41d423906625e28004ba8f20baf57847ed8bf5d0))
163
+
164
+
165
+ ### Bug Fixes
166
+
167
+ * 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))
168
+ * 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))
169
+
2
170
  ## [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
171
 
4
172
 
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.20",
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.20",
32
+ "@dynamic-labs/types": "2.1.0-alpha.20",
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 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,4 @@ export * from './TooManyEmailVerificationsError';
24
24
  export * from './VerificationDataCollectionError';
25
25
  export * from './InvalidPhoneNumberError';
26
26
  export * from './MergeAccountsConfirmationError';
27
+ export * from './CustomFieldNotUniqueError';
@@ -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,7 @@ 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');
33
34
  var CancellablePromise = require('./CancellablePromise/CancellablePromise.cjs');
34
35
  var isFunction = require('./isFunction/isFunction.cjs');
35
36
  var isMobile = require('./isMobile.cjs');
@@ -51,6 +52,10 @@ var ceil = require('./ceil/ceil.cjs');
51
52
  var trimEnd = require('./trimEnd/trimEnd.cjs');
52
53
  var isLedgerAddressViaVerifiedCredentials = require('./isLedgerAddressViaVerifiedCredentials.cjs');
53
54
  var runSafe = require('./runSafe/runSafe.cjs');
55
+ var LocationService = require('./services/LocationService/LocationService.cjs');
56
+ var createLocationFromWindow = require('./services/LocationService/utils/createLocationFromWindow/createLocationFromWindow.cjs');
57
+ var createLocationFromOrigin = require('./services/LocationService/utils/createLocationFromOrigin/createLocationFromOrigin.cjs');
58
+ var FetchService = require('./services/FetchService/FetchService.cjs');
54
59
 
55
60
 
56
61
 
@@ -81,6 +86,7 @@ exports.TooManyEmailVerificationsError = TooManyEmailVerificationsError.TooManyE
81
86
  exports.VerificationDataCollectionError = VerificationDataCollectionError.VerificationDataCollectionError;
82
87
  exports.InvalidPhoneNumberError = InvalidPhoneNumberError.InvalidPhoneNumberError;
83
88
  exports.MergeAccountsConfirmationError = MergeAccountsConfirmationError.MergeAccountsConfirmationError;
89
+ exports.CustomFieldNotUniqueError = CustomFieldNotUniqueError.CustomFieldNotUniqueError;
84
90
  exports.CancellablePromise = CancellablePromise.CancellablePromise;
85
91
  exports.isFunction = isFunction.isFunction;
86
92
  exports.getAndroidVersion = isMobile.getAndroidVersion;
@@ -116,3 +122,7 @@ exports.ceil = ceil.ceil;
116
122
  exports.trimEnd = trimEnd.trimEnd;
117
123
  exports.isLedgerAddressViaVerifiedCredentials = isLedgerAddressViaVerifiedCredentials.isLedgerAddressViaVerifiedCredentials;
118
124
  exports.runSafe = runSafe.runSafe;
125
+ exports.LocationService = LocationService.LocationService;
126
+ exports.createLocationFromWindow = createLocationFromWindow.createLocationFromWindow;
127
+ exports.createLocationFromOrigin = createLocationFromOrigin.createLocationFromOrigin;
128
+ 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,7 @@ 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';
29
30
  export { CancellablePromise } from './CancellablePromise/CancellablePromise.js';
30
31
  export { isFunction } from './isFunction/isFunction.js';
31
32
  export { getAndroidVersion, isAndroid, isIOS, isIPad, isIPhone, isIPhone8OrEarlier, isLegacySafari, isMobile, isSamsungBrowser, isWindows } from './isMobile.js';
@@ -47,3 +48,7 @@ export { ceil } from './ceil/ceil.js';
47
48
  export { trimEnd } from './trimEnd/trimEnd.js';
48
49
  export { isLedgerAddressViaVerifiedCredentials } from './isLedgerAddressViaVerifiedCredentials.js';
49
50
  export { runSafe } from './runSafe/runSafe.js';
51
+ export { LocationService } from './services/LocationService/LocationService.js';
52
+ export { createLocationFromWindow } from './services/LocationService/utils/createLocationFromWindow/createLocationFromWindow.js';
53
+ export { createLocationFromOrigin } from './services/LocationService/utils/createLocationFromOrigin/createLocationFromOrigin.js';
54
+ 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';