@sudobility/wildduck_client 0.0.14

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 (254) hide show
  1. package/README.md +354 -0
  2. package/dist/hooks/ServiceProvider.d.ts +15 -0
  3. package/dist/hooks/ServiceProvider.d.ts.map +1 -0
  4. package/dist/hooks/ServiceProvider.js +21 -0
  5. package/dist/hooks/ServiceProvider.js.map +1 -0
  6. package/dist/hooks/addresses/index.d.ts +2 -0
  7. package/dist/hooks/addresses/index.d.ts.map +1 -0
  8. package/dist/hooks/addresses/index.js +2 -0
  9. package/dist/hooks/addresses/index.js.map +1 -0
  10. package/dist/hooks/addresses/useWildduckGetAddresses.d.ts +232 -0
  11. package/dist/hooks/addresses/useWildduckGetAddresses.d.ts.map +1 -0
  12. package/dist/hooks/addresses/useWildduckGetAddresses.js +34 -0
  13. package/dist/hooks/addresses/useWildduckGetAddresses.js.map +1 -0
  14. package/dist/hooks/autoreply/index.d.ts +4 -0
  15. package/dist/hooks/autoreply/index.d.ts.map +1 -0
  16. package/dist/hooks/autoreply/index.js +4 -0
  17. package/dist/hooks/autoreply/index.js.map +1 -0
  18. package/dist/hooks/autoreply/useWildduckDeleteAutoreply.d.ts +13 -0
  19. package/dist/hooks/autoreply/useWildduckDeleteAutoreply.d.ts.map +1 -0
  20. package/dist/hooks/autoreply/useWildduckDeleteAutoreply.js +46 -0
  21. package/dist/hooks/autoreply/useWildduckDeleteAutoreply.js.map +1 -0
  22. package/dist/hooks/autoreply/useWildduckGetAutoreply.d.ts +172 -0
  23. package/dist/hooks/autoreply/useWildduckGetAutoreply.d.ts.map +1 -0
  24. package/dist/hooks/autoreply/useWildduckGetAutoreply.js +39 -0
  25. package/dist/hooks/autoreply/useWildduckGetAutoreply.js.map +1 -0
  26. package/dist/hooks/autoreply/useWildduckUpdateAutoreply.d.ts +13 -0
  27. package/dist/hooks/autoreply/useWildduckUpdateAutoreply.d.ts.map +1 -0
  28. package/dist/hooks/autoreply/useWildduckUpdateAutoreply.js +46 -0
  29. package/dist/hooks/autoreply/useWildduckUpdateAutoreply.js.map +1 -0
  30. package/dist/hooks/index.d.ts +19 -0
  31. package/dist/hooks/index.d.ts.map +1 -0
  32. package/dist/hooks/index.js +16 -0
  33. package/dist/hooks/index.js.map +1 -0
  34. package/dist/hooks/mailboxes/index.d.ts +6 -0
  35. package/dist/hooks/mailboxes/index.d.ts.map +1 -0
  36. package/dist/hooks/mailboxes/index.js +6 -0
  37. package/dist/hooks/mailboxes/index.js.map +1 -0
  38. package/dist/hooks/mailboxes/useWildduckCreateMailbox.d.ts +13 -0
  39. package/dist/hooks/mailboxes/useWildduckCreateMailbox.d.ts.map +1 -0
  40. package/dist/hooks/mailboxes/useWildduckCreateMailbox.js +43 -0
  41. package/dist/hooks/mailboxes/useWildduckCreateMailbox.js.map +1 -0
  42. package/dist/hooks/mailboxes/useWildduckDeleteMailbox.d.ts +13 -0
  43. package/dist/hooks/mailboxes/useWildduckDeleteMailbox.d.ts.map +1 -0
  44. package/dist/hooks/mailboxes/useWildduckDeleteMailbox.js +48 -0
  45. package/dist/hooks/mailboxes/useWildduckDeleteMailbox.js.map +1 -0
  46. package/dist/hooks/mailboxes/useWildduckGetMailbox.d.ts +173 -0
  47. package/dist/hooks/mailboxes/useWildduckGetMailbox.d.ts.map +1 -0
  48. package/dist/hooks/mailboxes/useWildduckGetMailbox.js +47 -0
  49. package/dist/hooks/mailboxes/useWildduckGetMailbox.js.map +1 -0
  50. package/dist/hooks/mailboxes/useWildduckGetMailboxes.d.ts +233 -0
  51. package/dist/hooks/mailboxes/useWildduckGetMailboxes.d.ts.map +1 -0
  52. package/dist/hooks/mailboxes/useWildduckGetMailboxes.js +34 -0
  53. package/dist/hooks/mailboxes/useWildduckGetMailboxes.js.map +1 -0
  54. package/dist/hooks/mailboxes/useWildduckUpdateMailbox.d.ts +13 -0
  55. package/dist/hooks/mailboxes/useWildduckUpdateMailbox.d.ts.map +1 -0
  56. package/dist/hooks/mailboxes/useWildduckUpdateMailbox.js +48 -0
  57. package/dist/hooks/mailboxes/useWildduckUpdateMailbox.js.map +1 -0
  58. package/dist/hooks/messages/index.d.ts +12 -0
  59. package/dist/hooks/messages/index.d.ts.map +1 -0
  60. package/dist/hooks/messages/index.js +12 -0
  61. package/dist/hooks/messages/index.js.map +1 -0
  62. package/dist/hooks/messages/useWildduckDeleteMessage.d.ts +13 -0
  63. package/dist/hooks/messages/useWildduckDeleteMessage.d.ts.map +1 -0
  64. package/dist/hooks/messages/useWildduckDeleteMessage.js +48 -0
  65. package/dist/hooks/messages/useWildduckDeleteMessage.js.map +1 -0
  66. package/dist/hooks/messages/useWildduckForwardMessage.d.ts +13 -0
  67. package/dist/hooks/messages/useWildduckForwardMessage.d.ts.map +1 -0
  68. package/dist/hooks/messages/useWildduckForwardMessage.js +51 -0
  69. package/dist/hooks/messages/useWildduckForwardMessage.js.map +1 -0
  70. package/dist/hooks/messages/useWildduckGetMessage.d.ts +653 -0
  71. package/dist/hooks/messages/useWildduckGetMessage.d.ts.map +1 -0
  72. package/dist/hooks/messages/useWildduckGetMessage.js +37 -0
  73. package/dist/hooks/messages/useWildduckGetMessage.js.map +1 -0
  74. package/dist/hooks/messages/useWildduckGetMessageAttachment.d.ts +13 -0
  75. package/dist/hooks/messages/useWildduckGetMessageAttachment.d.ts.map +1 -0
  76. package/dist/hooks/messages/useWildduckGetMessageAttachment.js +40 -0
  77. package/dist/hooks/messages/useWildduckGetMessageAttachment.js.map +1 -0
  78. package/dist/hooks/messages/useWildduckGetMessageSource.d.ts +12 -0
  79. package/dist/hooks/messages/useWildduckGetMessageSource.d.ts.map +1 -0
  80. package/dist/hooks/messages/useWildduckGetMessageSource.js +35 -0
  81. package/dist/hooks/messages/useWildduckGetMessageSource.js.map +1 -0
  82. package/dist/hooks/messages/useWildduckGetMessages.d.ts +11 -0
  83. package/dist/hooks/messages/useWildduckGetMessages.d.ts.map +1 -0
  84. package/dist/hooks/messages/useWildduckGetMessages.js +18 -0
  85. package/dist/hooks/messages/useWildduckGetMessages.js.map +1 -0
  86. package/dist/hooks/messages/useWildduckSearchMessages.d.ts +12 -0
  87. package/dist/hooks/messages/useWildduckSearchMessages.d.ts.map +1 -0
  88. package/dist/hooks/messages/useWildduckSearchMessages.js +46 -0
  89. package/dist/hooks/messages/useWildduckSearchMessages.js.map +1 -0
  90. package/dist/hooks/messages/useWildduckSendMessage.d.ts +13 -0
  91. package/dist/hooks/messages/useWildduckSendMessage.d.ts.map +1 -0
  92. package/dist/hooks/messages/useWildduckSendMessage.js +48 -0
  93. package/dist/hooks/messages/useWildduckSendMessage.js.map +1 -0
  94. package/dist/hooks/messages/useWildduckSubmitDraft.d.ts +13 -0
  95. package/dist/hooks/messages/useWildduckSubmitDraft.d.ts.map +1 -0
  96. package/dist/hooks/messages/useWildduckSubmitDraft.js +44 -0
  97. package/dist/hooks/messages/useWildduckSubmitDraft.js.map +1 -0
  98. package/dist/hooks/messages/useWildduckUpdateMessage.d.ts +13 -0
  99. package/dist/hooks/messages/useWildduckUpdateMessage.d.ts.map +1 -0
  100. package/dist/hooks/messages/useWildduckUpdateMessage.js +53 -0
  101. package/dist/hooks/messages/useWildduckUpdateMessage.js.map +1 -0
  102. package/dist/hooks/messages/useWildduckUploadMessage.d.ts +13 -0
  103. package/dist/hooks/messages/useWildduckUploadMessage.d.ts.map +1 -0
  104. package/dist/hooks/messages/useWildduckUploadMessage.js +51 -0
  105. package/dist/hooks/messages/useWildduckUploadMessage.js.map +1 -0
  106. package/dist/hooks/mocks.d.ts +354 -0
  107. package/dist/hooks/mocks.d.ts.map +1 -0
  108. package/dist/hooks/mocks.js +404 -0
  109. package/dist/hooks/mocks.js.map +1 -0
  110. package/dist/hooks/query-config.d.ts +9 -0
  111. package/dist/hooks/query-config.d.ts.map +1 -0
  112. package/dist/hooks/query-config.js +9 -0
  113. package/dist/hooks/query-config.js.map +1 -0
  114. package/dist/hooks/query-keys.d.ts +31 -0
  115. package/dist/hooks/query-keys.d.ts.map +1 -0
  116. package/dist/hooks/query-keys.js +40 -0
  117. package/dist/hooks/query-keys.js.map +1 -0
  118. package/dist/hooks/useServices.d.ts +14 -0
  119. package/dist/hooks/useServices.d.ts.map +1 -0
  120. package/dist/hooks/useServices.js +36 -0
  121. package/dist/hooks/useServices.js.map +1 -0
  122. package/dist/hooks/useWildduckAddresses.d.ts +67 -0
  123. package/dist/hooks/useWildduckAddresses.d.ts.map +1 -0
  124. package/dist/hooks/useWildduckAddresses.js +313 -0
  125. package/dist/hooks/useWildduckAddresses.js.map +1 -0
  126. package/dist/hooks/useWildduckAuth.d.ts +28 -0
  127. package/dist/hooks/useWildduckAuth.d.ts.map +1 -0
  128. package/dist/hooks/useWildduckAuth.js +249 -0
  129. package/dist/hooks/useWildduckAuth.js.map +1 -0
  130. package/dist/hooks/useWildduckFilters.d.ts +89 -0
  131. package/dist/hooks/useWildduckFilters.d.ts.map +1 -0
  132. package/dist/hooks/useWildduckFilters.js +209 -0
  133. package/dist/hooks/useWildduckFilters.js.map +1 -0
  134. package/dist/hooks/useWildduckHealth.d.ts +45 -0
  135. package/dist/hooks/useWildduckHealth.d.ts.map +1 -0
  136. package/dist/hooks/useWildduckHealth.js +110 -0
  137. package/dist/hooks/useWildduckHealth.js.map +1 -0
  138. package/dist/hooks/useWildduckMailboxes.d.ts +29 -0
  139. package/dist/hooks/useWildduckMailboxes.d.ts.map +1 -0
  140. package/dist/hooks/useWildduckMailboxes.js +195 -0
  141. package/dist/hooks/useWildduckMailboxes.js.map +1 -0
  142. package/dist/hooks/useWildduckMessages.d.ts +76 -0
  143. package/dist/hooks/useWildduckMessages.d.ts.map +1 -0
  144. package/dist/hooks/useWildduckMessages.js +264 -0
  145. package/dist/hooks/useWildduckMessages.js.map +1 -0
  146. package/dist/hooks/useWildduckQueries.d.ts +50 -0
  147. package/dist/hooks/useWildduckQueries.d.ts.map +1 -0
  148. package/dist/hooks/useWildduckQueries.js +640 -0
  149. package/dist/hooks/useWildduckQueries.js.map +1 -0
  150. package/dist/hooks/useWildduckSettings.d.ts +22 -0
  151. package/dist/hooks/useWildduckSettings.d.ts.map +1 -0
  152. package/dist/hooks/useWildduckSettings.js +153 -0
  153. package/dist/hooks/useWildduckSettings.js.map +1 -0
  154. package/dist/hooks/useWildduckUsers.d.ts +31 -0
  155. package/dist/hooks/useWildduckUsers.d.ts.map +1 -0
  156. package/dist/hooks/useWildduckUsers.js +114 -0
  157. package/dist/hooks/useWildduckUsers.js.map +1 -0
  158. package/dist/hooks/users/index.d.ts +12 -0
  159. package/dist/hooks/users/index.d.ts.map +1 -0
  160. package/dist/hooks/users/index.js +12 -0
  161. package/dist/hooks/users/index.js.map +1 -0
  162. package/dist/hooks/users/useWildduckCreateUser.d.ts +13 -0
  163. package/dist/hooks/users/useWildduckCreateUser.d.ts.map +1 -0
  164. package/dist/hooks/users/useWildduckCreateUser.js +44 -0
  165. package/dist/hooks/users/useWildduckCreateUser.js.map +1 -0
  166. package/dist/hooks/users/useWildduckDeleteUser.d.ts +13 -0
  167. package/dist/hooks/users/useWildduckDeleteUser.d.ts.map +1 -0
  168. package/dist/hooks/users/useWildduckDeleteUser.js +44 -0
  169. package/dist/hooks/users/useWildduckDeleteUser.js.map +1 -0
  170. package/dist/hooks/users/useWildduckGetUser.d.ts +397 -0
  171. package/dist/hooks/users/useWildduckGetUser.d.ts.map +1 -0
  172. package/dist/hooks/users/useWildduckGetUser.js +45 -0
  173. package/dist/hooks/users/useWildduckGetUser.js.map +1 -0
  174. package/dist/hooks/users/useWildduckUpdateUser.d.ts +13 -0
  175. package/dist/hooks/users/useWildduckUpdateUser.d.ts.map +1 -0
  176. package/dist/hooks/users/useWildduckUpdateUser.js +44 -0
  177. package/dist/hooks/users/useWildduckUpdateUser.js.map +1 -0
  178. package/dist/hooks/users/useWildduckUser2FA.d.ts +25 -0
  179. package/dist/hooks/users/useWildduckUser2FA.d.ts.map +1 -0
  180. package/dist/hooks/users/useWildduckUser2FA.js +70 -0
  181. package/dist/hooks/users/useWildduckUser2FA.js.map +1 -0
  182. package/dist/hooks/users/useWildduckUserEncryption.d.ts +40 -0
  183. package/dist/hooks/users/useWildduckUserEncryption.d.ts.map +1 -0
  184. package/dist/hooks/users/useWildduckUserEncryption.js +94 -0
  185. package/dist/hooks/users/useWildduckUserEncryption.js.map +1 -0
  186. package/dist/hooks/users/useWildduckUserForwarding.d.ts +44 -0
  187. package/dist/hooks/users/useWildduckUserForwarding.d.ts.map +1 -0
  188. package/dist/hooks/users/useWildduckUserForwarding.js +122 -0
  189. package/dist/hooks/users/useWildduckUserForwarding.js.map +1 -0
  190. package/dist/hooks/users/useWildduckUserLimits.d.ts +63 -0
  191. package/dist/hooks/users/useWildduckUserLimits.d.ts.map +1 -0
  192. package/dist/hooks/users/useWildduckUserLimits.js +60 -0
  193. package/dist/hooks/users/useWildduckUserLimits.js.map +1 -0
  194. package/dist/hooks/users/useWildduckUserProfile.d.ts +78 -0
  195. package/dist/hooks/users/useWildduckUserProfile.d.ts.map +1 -0
  196. package/dist/hooks/users/useWildduckUserProfile.js +139 -0
  197. package/dist/hooks/users/useWildduckUserProfile.js.map +1 -0
  198. package/dist/hooks/users/useWildduckUserQuota.d.ts +31 -0
  199. package/dist/hooks/users/useWildduckUserQuota.d.ts.map +1 -0
  200. package/dist/hooks/users/useWildduckUserQuota.js +66 -0
  201. package/dist/hooks/users/useWildduckUserQuota.js.map +1 -0
  202. package/dist/hooks/users/useWildduckUserSpam.d.ts +54 -0
  203. package/dist/hooks/users/useWildduckUserSpam.d.ts.map +1 -0
  204. package/dist/hooks/users/useWildduckUserSpam.js +137 -0
  205. package/dist/hooks/users/useWildduckUserSpam.js.map +1 -0
  206. package/dist/index.d.ts +7 -0
  207. package/dist/index.d.ts.map +1 -0
  208. package/dist/index.js +7 -0
  209. package/dist/index.js.map +1 -0
  210. package/dist/network/index.d.ts +2 -0
  211. package/dist/network/index.d.ts.map +1 -0
  212. package/dist/network/index.js +2 -0
  213. package/dist/network/index.js.map +1 -0
  214. package/dist/network/wildduck-client.d.ts +54 -0
  215. package/dist/network/wildduck-client.d.ts.map +1 -0
  216. package/dist/network/wildduck-client.js +572 -0
  217. package/dist/network/wildduck-client.js.map +1 -0
  218. package/dist/types/index.d.ts +2 -0
  219. package/dist/types/index.d.ts.map +1 -0
  220. package/dist/types/index.js +2 -0
  221. package/dist/types/index.js.map +1 -0
  222. package/dist/utils/advanced-settings.d.ts +36 -0
  223. package/dist/utils/advanced-settings.d.ts.map +1 -0
  224. package/dist/utils/advanced-settings.js +99 -0
  225. package/dist/utils/advanced-settings.js.map +1 -0
  226. package/dist/utils/autoreply.d.ts +34 -0
  227. package/dist/utils/autoreply.d.ts.map +1 -0
  228. package/dist/utils/autoreply.js +39 -0
  229. package/dist/utils/autoreply.js.map +1 -0
  230. package/dist/utils/client.d.ts +4 -0
  231. package/dist/utils/client.d.ts.map +1 -0
  232. package/dist/utils/client.js +11 -0
  233. package/dist/utils/client.js.map +1 -0
  234. package/dist/utils/filters.d.ts +26 -0
  235. package/dist/utils/filters.d.ts.map +1 -0
  236. package/dist/utils/filters.js +50 -0
  237. package/dist/utils/filters.js.map +1 -0
  238. package/dist/utils/forwarding.d.ts +12 -0
  239. package/dist/utils/forwarding.d.ts.map +1 -0
  240. package/dist/utils/forwarding.js +29 -0
  241. package/dist/utils/forwarding.js.map +1 -0
  242. package/dist/utils/index.d.ts +7 -0
  243. package/dist/utils/index.d.ts.map +1 -0
  244. package/dist/utils/index.js +7 -0
  245. package/dist/utils/index.js.map +1 -0
  246. package/dist/utils/spam-settings.d.ts +21 -0
  247. package/dist/utils/spam-settings.d.ts.map +1 -0
  248. package/dist/utils/spam-settings.js +53 -0
  249. package/dist/utils/spam-settings.js.map +1 -0
  250. package/dist/utils/user-settings.d.ts +30 -0
  251. package/dist/utils/user-settings.d.ts.map +1 -0
  252. package/dist/utils/user-settings.js +21 -0
  253. package/dist/utils/user-settings.js.map +1 -0
  254. package/package.json +82 -0
package/README.md ADDED
@@ -0,0 +1,354 @@
1
+ # WildDuck Client Library
2
+
3
+ TypeScript client library for the WildDuck email API with React and React Native support.
4
+
5
+ [![npm version](https://badge.fury.io/js/@sudobility%2Fwildduck_client.svg)](https://www.npmjs.com/package/@sudobility/wildduck_client)
6
+ [![CI/CD](https://github.com/0xmail/wildduck_client/actions/workflows/ci-cd.yml/badge.svg)](https://github.com/0xmail/wildduck_client/actions/workflows/ci-cd.yml)
7
+
8
+ ## Features
9
+
10
+ - ✅ **Complete Type Safety** - Full TypeScript support with comprehensive type definitions
11
+ - ✅ **React Integration** - Built-in hooks using @tanstack/react-query for optimal data fetching
12
+ - ✅ **Crypto Authentication** - SIWE (Sign-in with Ethereum) and traditional password authentication
13
+ - ✅ **Comprehensive API** - User, mailbox, message, address, filter, and autoreply management
14
+ - ✅ **Development Mode** - Mock data for testing without a live server
15
+ - ✅ **Integration Tests** - Full test coverage with real WildDuck server testing
16
+ - ✅ **Cloudflare Worker Support** - Optional worker URL configuration for proxying requests
17
+
18
+ ## Installation
19
+
20
+ ```bash
21
+ npm install @sudobility/wildduck_client
22
+ ```
23
+
24
+ ### Peer Dependencies
25
+
26
+ This library requires the following peer dependencies:
27
+
28
+ ```bash
29
+ npm install react @tanstack/react-query @sudobility/di @sudobility/types axios
30
+ ```
31
+
32
+ ## Quick Start
33
+
34
+ ### 1. Authentication
35
+
36
+ ```typescript
37
+ import { useWildduckAuth } from '@sudobility/wildduck_client';
38
+
39
+ function LoginComponent() {
40
+ const networkClient = useNetworkClient();
41
+ const config = { endpoint: 'https://api.wildduck.example.com' };
42
+
43
+ const { authenticate, isAuthenticated } = useWildduckAuth(
44
+ networkClient,
45
+ config
46
+ );
47
+
48
+ // Authenticate with crypto signature (SIWE)
49
+ const handleCryptoLogin = async () => {
50
+ await authenticate({
51
+ username: 'user@example.com',
52
+ signature: '0x...',
53
+ message: 'Sign-in with Ethereum message',
54
+ nonce: 'random-nonce',
55
+ signer: '0xWalletAddress'
56
+ });
57
+ };
58
+
59
+ // Or authenticate with password
60
+ const handlePasswordLogin = async () => {
61
+ await authenticate({
62
+ username: 'user@example.com',
63
+ password: 'your-password'
64
+ });
65
+ };
66
+
67
+ return (
68
+ <div>
69
+ {isAuthenticated ? (
70
+ <p>Logged in!</p>
71
+ ) : (
72
+ <>
73
+ <button onClick={handleCryptoLogin}>Login with Wallet</button>
74
+ <button onClick={handlePasswordLogin}>Login with Password</button>
75
+ </>
76
+ )}
77
+ </div>
78
+ );
79
+ }
80
+ ```
81
+
82
+ ### 2. Fetching Messages
83
+
84
+ ```typescript
85
+ import { useWildduckGetMessages } from '@sudobility/wildduck_client';
86
+
87
+ function MessageList({ userAuth, mailboxId }) {
88
+ const networkClient = useNetworkClient();
89
+ const config = { endpoint: 'https://api.wildduck.example.com' };
90
+
91
+ const { getMessages } = useWildduckGetMessages(networkClient, config);
92
+ const [messages, setMessages] = useState([]);
93
+
94
+ useEffect(() => {
95
+ async function fetchMessages() {
96
+ const result = await getMessages(userAuth, mailboxId, {
97
+ limit: 50,
98
+ unseen: true, // Only unread messages
99
+ order: 'desc'
100
+ });
101
+ setMessages(result.results);
102
+ }
103
+ fetchMessages();
104
+ }, [mailboxId]);
105
+
106
+ return (
107
+ <div>
108
+ {messages.map(msg => (
109
+ <div key={msg.id}>
110
+ <h3>{msg.subject}</h3>
111
+ <p>From: {msg.from.address}</p>
112
+ <span>{msg.unseen ? '🔵 Unread' : '✓ Read'}</span>
113
+ </div>
114
+ ))}
115
+ </div>
116
+ );
117
+ }
118
+ ```
119
+
120
+ ### 3. Sending Messages
121
+
122
+ ```typescript
123
+ import { useWildduckSendMessage } from '@sudobility/wildduck_client';
124
+
125
+ function ComposeEmail({ userAuth }) {
126
+ const networkClient = useNetworkClient();
127
+ const config = { endpoint: 'https://api.wildduck.example.com' };
128
+
129
+ const { sendMessage } = useWildduckSendMessage(networkClient, config);
130
+
131
+ const handleSend = async () => {
132
+ await sendMessage(userAuth, {
133
+ to: [{ name: 'John Doe', address: 'john@example.com' }],
134
+ subject: 'Hello from WildDuck Client',
135
+ text: 'This is a test message',
136
+ html: '<p>This is a <strong>test</strong> message</p>'
137
+ });
138
+ };
139
+
140
+ return <button onClick={handleSend}>Send Email</button>;
141
+ }
142
+ ```
143
+
144
+ ## API Coverage
145
+
146
+ Currently implements ~15% of the WildDuck API endpoints (see [GAP_ANALYSIS.md](./GAP_ANALYSIS.md) for details):
147
+
148
+ ### Implemented Endpoints
149
+
150
+ | Category | Status | Coverage |
151
+ |----------|--------|----------|
152
+ | Authentication | ✅ Complete | 100% |
153
+ | Users | ⚠️ Partial | ~12% |
154
+ | Mailboxes | ✅ Mostly Complete | 80% |
155
+ | Messages | ⚠️ Partial | ~31% |
156
+ | Addresses | ✅ Mostly Complete | 64% |
157
+ | Filters | ✅ Complete | 100% |
158
+ | Autoreply | ⚠️ Partial | ~67% |
159
+ | Health | ✅ Complete | 100% |
160
+ | Settings | ✅ Mostly Complete | 67% |
161
+
162
+ ### Priority Features to Implement
163
+
164
+ See [GAP_ANALYSIS.md](./GAP_ANALYSIS.md) for a comprehensive breakdown of missing endpoints and implementation priorities.
165
+
166
+ ## Available Hooks
167
+
168
+ ### Messages
169
+ - `useWildduckGetMessages` - List messages in a mailbox
170
+ - `useWildduckGetMessage` - Get a single message
171
+ - `useWildduckUpdateMessage` - Update message properties (mark as read, move, flag)
172
+ - `useWildduckDeleteMessage` - Delete a message
173
+ - `useWildduckSearchMessages` - Search messages across mailboxes
174
+ - `useWildduckGetMessageSource` - Get raw RFC822 message source
175
+ - `useWildduckGetMessageAttachment` - Download message attachment
176
+ - `useWildduckForwardMessage` - Forward a message
177
+ - `useWildduckSendMessage` - Send a new email
178
+ - `useWildduckUploadMessage` - Upload raw message to mailbox
179
+ - `useWildduckSubmitDraft` - Submit a draft for delivery
180
+
181
+ ### Mailboxes
182
+ - `useWildduckGetMailboxes` - List all mailboxes
183
+ - `useWildduckGetMailbox` - Get specific mailbox info
184
+ - `useWildduckCreateMailbox` - Create new mailbox/folder
185
+ - `useWildduckUpdateMailbox` - Update mailbox properties
186
+ - `useWildduckDeleteMailbox` - Delete a mailbox
187
+
188
+ ### Users
189
+ - `useWildduckGetUser` - Get user information
190
+ - `useWildduckCreateUser` - Create new user (admin)
191
+ - `useWildduckUpdateUser` - Update user settings
192
+ - `useWildduckDeleteUser` - Delete user account
193
+
194
+ ### Addresses
195
+ - `useWildduckGetAddresses` - List user's email addresses
196
+ - Additional address management hooks
197
+
198
+ ### Autoreply
199
+ - `useWildduckGetAutoreply` - Get autoreply settings
200
+ - `useWildduckUpdateAutoreply` - Update autoreply (vacation mode)
201
+ - `useWildduckDeleteAutoreply` - Delete autoreply
202
+
203
+ ### Filters
204
+ - Complete filter management hooks
205
+
206
+ ### Other
207
+ - `useWildduckHealth` - Server health check
208
+ - `useWildduckSettings` - Settings management
209
+
210
+ For detailed documentation on all hooks, see [HOOKS_DOCUMENTATION.md](./HOOKS_DOCUMENTATION.md).
211
+
212
+ ## Development
213
+
214
+ ### Setup
215
+
216
+ ```bash
217
+ # Install dependencies
218
+ npm install
219
+
220
+ # Run type checking
221
+ npm run typecheck
222
+
223
+ # Run linting
224
+ npm run lint
225
+
226
+ # Run unit tests
227
+ npm test
228
+
229
+ # Run integration tests (requires WildDuck server)
230
+ WILDDUCK_ENDPOINT=http://localhost:8080 npm run test:integration
231
+
232
+ # Build the library
233
+ npm run build
234
+ ```
235
+
236
+ ### Development Scripts
237
+
238
+ ```bash
239
+ npm run build # Build for production
240
+ npm run build:watch # Build in watch mode
241
+ npm run clean # Clean build artifacts
242
+ npm run test # Run tests in watch mode
243
+ npm run test:run # Run tests once
244
+ npm run test:coverage # Run tests with coverage
245
+ npm run test:integration # Run integration tests
246
+ npm run lint # Run ESLint
247
+ npm run lint:fix # Fix linting issues
248
+ npm run format # Format code with Prettier
249
+ npm run typecheck # Run TypeScript type checking
250
+ npm run check-all # Run all checks (lint + typecheck + test)
251
+ ```
252
+
253
+ ## Testing
254
+
255
+ ### Unit Tests
256
+
257
+ ```bash
258
+ npm run test:run
259
+ ```
260
+
261
+ ### Integration Tests
262
+
263
+ Integration tests require a live WildDuck server running in crypto mode:
264
+
265
+ ```bash
266
+ # Set required environment variables
267
+ export WILDDUCK_ENDPOINT=http://localhost:8080
268
+ export WILDDUCK_EMAIL_DOMAIN=example.com # Optional
269
+
270
+ # Run integration tests
271
+ npm run test:integration
272
+ ```
273
+
274
+ For more details, see [INTEGRATION_TESTS.md](./INTEGRATION_TESTS.md).
275
+
276
+ ## Documentation
277
+
278
+ - **[HOOKS_DOCUMENTATION.md](./HOOKS_DOCUMENTATION.md)** - Comprehensive hook documentation with examples
279
+ - **[WILDDUCK_API_ENDPOINTS.md](./WILDDUCK_API_ENDPOINTS.md)** - Complete API endpoint reference
280
+ - **[GAP_ANALYSIS.md](./GAP_ANALYSIS.md)** - Analysis of implemented vs. missing endpoints
281
+ - **[INTEGRATION_TESTS.md](./INTEGRATION_TESTS.md)** - Integration testing guide
282
+ - **[CI_CD_SETUP.md](./CI_CD_SETUP.md)** - CI/CD workflow documentation
283
+ - **[DEPLOYMENT.md](./DEPLOYMENT.md)** - Deployment guide
284
+
285
+ ## Architecture
286
+
287
+ ```
288
+ wildduck_client/
289
+ ├── src/
290
+ │ ├── network/ # API client and HTTP layer
291
+ │ ├── hooks/ # React hooks for data fetching
292
+ │ │ ├── messages/ # Message-related hooks
293
+ │ │ ├── mailboxes/ # Mailbox-related hooks
294
+ │ │ ├── addresses/ # Address-related hooks
295
+ │ │ ├── autoreply/ # Autoreply-related hooks
296
+ │ │ └── users/ # User-related hooks
297
+ │ ├── types/ # TypeScript type definitions
298
+ │ ├── utils/ # Utility functions
299
+ │ └── __tests__/ # Test files
300
+ │ └── integration/ # Integration tests
301
+ ├── dist/ # Compiled output
302
+ └── docs/ # Documentation files
303
+ ```
304
+
305
+ ## Contributing
306
+
307
+ 1. Fork the repository
308
+ 2. Create a feature branch: `git checkout -b feature/my-feature`
309
+ 3. Make your changes and add tests
310
+ 4. Run checks: `npm run check-all`
311
+ 5. Commit your changes: `git commit -m "Add my feature"`
312
+ 6. Push to the branch: `git push origin feature/my-feature`
313
+ 7. Open a pull request
314
+
315
+ ### Code Quality
316
+
317
+ This project maintains high code quality standards:
318
+
319
+ - TypeScript with strict mode enabled
320
+ - ESLint for code linting
321
+ - Prettier for code formatting
322
+ - Comprehensive unit and integration tests
323
+ - CI/CD pipeline that runs on every push
324
+
325
+ ## Deployment
326
+
327
+ ### NPM Publishing
328
+
329
+ The library is automatically published to NPM when you push to the `main` branch:
330
+
331
+ 1. Update version: `npm version patch|minor|major`
332
+ 2. Push to main: `git push origin main --tags`
333
+ 3. CI/CD automatically publishes to NPM
334
+
335
+ For more details, see [DEPLOYMENT.md](./DEPLOYMENT.md).
336
+
337
+ ## License
338
+
339
+ MIT
340
+
341
+ ## Related Projects
342
+
343
+ - [WildDuck](https://github.com/nodemailer/wildduck) - The WildDuck email server
344
+ - [@sudobility/types](https://www.npmjs.com/package/@sudobility/types) - Shared type definitions
345
+ - [0xmail](https://github.com/0xmail) - Blockchain-based email platform
346
+
347
+ ## Support
348
+
349
+ - [GitHub Issues](https://github.com/0xmail/wildduck_client/issues)
350
+ - [API Documentation](https://docs.wildduck.email/api/)
351
+
352
+ ## Changelog
353
+
354
+ See [GitHub Releases](https://github.com/0xmail/wildduck_client/releases) for version history and release notes.
@@ -0,0 +1,15 @@
1
+ export interface ServiceContainer {
2
+ get<T>(key: string): T;
3
+ register<T>(key: string, factory: (container: ServiceContainer) => T, singleton?: boolean): void;
4
+ }
5
+ export interface ServiceResolver {
6
+ getStorage(): any;
7
+ getAnalytics(): any;
8
+ getConfig(): any;
9
+ }
10
+ declare const ServiceContainerContext: import("react").Context<ServiceContainer | null>;
11
+ declare const ServiceResolverContext: import("react").Context<ServiceResolver | null>;
12
+ declare const useServiceContainer: () => ServiceContainer;
13
+ declare const useServiceResolver: () => ServiceResolver;
14
+ export { ServiceContainerContext, ServiceResolverContext, useServiceContainer, useServiceResolver, };
15
+ //# sourceMappingURL=ServiceProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ServiceProvider.d.ts","sourceRoot":"","sources":["../../src/hooks/ServiceProvider.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,gBAAgB;IAC/B,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,CAAC;IACvB,QAAQ,CAAC,CAAC,EACR,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,CAAC,SAAS,EAAE,gBAAgB,KAAK,CAAC,EAC3C,SAAS,CAAC,EAAE,OAAO,GAClB,IAAI,CAAC;CACT;AAMD,MAAM,WAAW,eAAe;IAC9B,UAAU,IAAI,GAAG,CAAC;IAClB,YAAY,IAAI,GAAG,CAAC;IACpB,SAAS,IAAI,GAAG,CAAC;CAClB;AAGD,QAAA,MAAM,uBAAuB,kDAA+C,CAAC;AAG7E,QAAA,MAAM,sBAAsB,iDAA8C,CAAC;AAM3E,QAAA,MAAM,mBAAmB,QAAO,gBAS/B,CAAC;AAMF,QAAA,MAAM,kBAAkB,QAAO,eAS9B,CAAC;AAGF,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,mBAAmB,EACnB,kBAAkB,GACnB,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { createContext, useContext } from "react";
2
+ const ServiceContainerContext = createContext(null);
3
+ const ServiceResolverContext = createContext(null);
4
+ const useServiceContainer = () => {
5
+ const container = useContext(ServiceContainerContext);
6
+ if (!container) {
7
+ throw new Error("useServiceContainer must be used within a ServiceProvider. " +
8
+ "Make sure to set up the service container properly in your app.");
9
+ }
10
+ return container;
11
+ };
12
+ const useServiceResolver = () => {
13
+ const resolver = useContext(ServiceResolverContext);
14
+ if (!resolver) {
15
+ throw new Error("useServiceResolver must be used within a ServiceProvider. " +
16
+ "Make sure to set up the service container properly in your app.");
17
+ }
18
+ return resolver;
19
+ };
20
+ export { ServiceContainerContext, ServiceResolverContext, useServiceContainer, useServiceResolver, };
21
+ //# sourceMappingURL=ServiceProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ServiceProvider.js","sourceRoot":"","sources":["../../src/hooks/ServiceProvider.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AA0BlD,MAAM,uBAAuB,GAAG,aAAa,CAA0B,IAAI,CAAC,CAAC;AAG7E,MAAM,sBAAsB,GAAG,aAAa,CAAyB,IAAI,CAAC,CAAC;AAM3E,MAAM,mBAAmB,GAAG,GAAqB,EAAE;IACjD,MAAM,SAAS,GAAG,UAAU,CAAC,uBAAuB,CAAC,CAAC;IACtD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,6DAA6D;YAC3D,iEAAiE,CACpE,CAAC;IACJ,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAMF,MAAM,kBAAkB,GAAG,GAAoB,EAAE;IAC/C,MAAM,QAAQ,GAAG,UAAU,CAAC,sBAAsB,CAAC,CAAC;IACpD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CACb,4DAA4D;YAC1D,iEAAiE,CACpE,CAAC;IACJ,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAGF,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,mBAAmB,EACnB,kBAAkB,GACnB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./useWildduckGetAddresses";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/addresses/index.ts"],"names":[],"mappings":"AAMA,cAAc,2BAA2B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./useWildduckGetAddresses";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/addresses/index.ts"],"names":[],"mappings":"AAMA,cAAc,2BAA2B,CAAC"}
@@ -0,0 +1,232 @@
1
+ import { type NetworkClient } from "@sudobility/di";
2
+ import { type WildduckConfig } from "@sudobility/types";
3
+ import type { WildduckUserAuth } from "@sudobility/types";
4
+ export interface UseWildduckGetAddressesParams {
5
+ userAuth?: WildduckUserAuth;
6
+ devMode?: boolean;
7
+ }
8
+ export declare const useWildduckGetAddresses: (networkClient: NetworkClient, config: WildduckConfig, params?: UseWildduckGetAddressesParams) => {
9
+ data: import("@sudobility/types").WildduckAddressResponse | {
10
+ success: boolean;
11
+ results: never[];
12
+ error: null;
13
+ };
14
+ error: Error;
15
+ isError: true;
16
+ isPending: false;
17
+ isLoading: false;
18
+ isLoadingError: false;
19
+ isRefetchError: true;
20
+ isSuccess: false;
21
+ isPlaceholderData: false;
22
+ status: "error";
23
+ dataUpdatedAt: number;
24
+ errorUpdatedAt: number;
25
+ failureCount: number;
26
+ failureReason: Error | null;
27
+ errorUpdateCount: number;
28
+ isFetched: boolean;
29
+ isFetchedAfterMount: boolean;
30
+ isFetching: boolean;
31
+ isInitialLoading: boolean;
32
+ isPaused: boolean;
33
+ isRefetching: boolean;
34
+ isStale: boolean;
35
+ isEnabled: boolean;
36
+ refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<import("@sudobility/types").WildduckAddressResponse | {
37
+ success: boolean;
38
+ results: never[];
39
+ error: null;
40
+ }, Error>>;
41
+ fetchStatus: import("@tanstack/query-core").FetchStatus;
42
+ promise: Promise<import("@sudobility/types").WildduckAddressResponse | {
43
+ success: boolean;
44
+ results: never[];
45
+ error: null;
46
+ }>;
47
+ } | {
48
+ data: import("@sudobility/types").WildduckAddressResponse | {
49
+ success: boolean;
50
+ results: never[];
51
+ error: null;
52
+ };
53
+ error: null;
54
+ isError: false;
55
+ isPending: false;
56
+ isLoading: false;
57
+ isLoadingError: false;
58
+ isRefetchError: false;
59
+ isSuccess: true;
60
+ isPlaceholderData: false;
61
+ status: "success";
62
+ dataUpdatedAt: number;
63
+ errorUpdatedAt: number;
64
+ failureCount: number;
65
+ failureReason: Error | null;
66
+ errorUpdateCount: number;
67
+ isFetched: boolean;
68
+ isFetchedAfterMount: boolean;
69
+ isFetching: boolean;
70
+ isInitialLoading: boolean;
71
+ isPaused: boolean;
72
+ isRefetching: boolean;
73
+ isStale: boolean;
74
+ isEnabled: boolean;
75
+ refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<import("@sudobility/types").WildduckAddressResponse | {
76
+ success: boolean;
77
+ results: never[];
78
+ error: null;
79
+ }, Error>>;
80
+ fetchStatus: import("@tanstack/query-core").FetchStatus;
81
+ promise: Promise<import("@sudobility/types").WildduckAddressResponse | {
82
+ success: boolean;
83
+ results: never[];
84
+ error: null;
85
+ }>;
86
+ } | {
87
+ data: undefined;
88
+ error: Error;
89
+ isError: true;
90
+ isPending: false;
91
+ isLoading: false;
92
+ isLoadingError: true;
93
+ isRefetchError: false;
94
+ isSuccess: false;
95
+ isPlaceholderData: false;
96
+ status: "error";
97
+ dataUpdatedAt: number;
98
+ errorUpdatedAt: number;
99
+ failureCount: number;
100
+ failureReason: Error | null;
101
+ errorUpdateCount: number;
102
+ isFetched: boolean;
103
+ isFetchedAfterMount: boolean;
104
+ isFetching: boolean;
105
+ isInitialLoading: boolean;
106
+ isPaused: boolean;
107
+ isRefetching: boolean;
108
+ isStale: boolean;
109
+ isEnabled: boolean;
110
+ refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<import("@sudobility/types").WildduckAddressResponse | {
111
+ success: boolean;
112
+ results: never[];
113
+ error: null;
114
+ }, Error>>;
115
+ fetchStatus: import("@tanstack/query-core").FetchStatus;
116
+ promise: Promise<import("@sudobility/types").WildduckAddressResponse | {
117
+ success: boolean;
118
+ results: never[];
119
+ error: null;
120
+ }>;
121
+ } | {
122
+ data: undefined;
123
+ error: null;
124
+ isError: false;
125
+ isPending: true;
126
+ isLoading: true;
127
+ isLoadingError: false;
128
+ isRefetchError: false;
129
+ isSuccess: false;
130
+ isPlaceholderData: false;
131
+ status: "pending";
132
+ dataUpdatedAt: number;
133
+ errorUpdatedAt: number;
134
+ failureCount: number;
135
+ failureReason: Error | null;
136
+ errorUpdateCount: number;
137
+ isFetched: boolean;
138
+ isFetchedAfterMount: boolean;
139
+ isFetching: boolean;
140
+ isInitialLoading: boolean;
141
+ isPaused: boolean;
142
+ isRefetching: boolean;
143
+ isStale: boolean;
144
+ isEnabled: boolean;
145
+ refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<import("@sudobility/types").WildduckAddressResponse | {
146
+ success: boolean;
147
+ results: never[];
148
+ error: null;
149
+ }, Error>>;
150
+ fetchStatus: import("@tanstack/query-core").FetchStatus;
151
+ promise: Promise<import("@sudobility/types").WildduckAddressResponse | {
152
+ success: boolean;
153
+ results: never[];
154
+ error: null;
155
+ }>;
156
+ } | {
157
+ data: undefined;
158
+ error: null;
159
+ isError: false;
160
+ isPending: true;
161
+ isLoadingError: false;
162
+ isRefetchError: false;
163
+ isSuccess: false;
164
+ isPlaceholderData: false;
165
+ status: "pending";
166
+ dataUpdatedAt: number;
167
+ errorUpdatedAt: number;
168
+ failureCount: number;
169
+ failureReason: Error | null;
170
+ errorUpdateCount: number;
171
+ isFetched: boolean;
172
+ isFetchedAfterMount: boolean;
173
+ isFetching: boolean;
174
+ isLoading: boolean;
175
+ isInitialLoading: boolean;
176
+ isPaused: boolean;
177
+ isRefetching: boolean;
178
+ isStale: boolean;
179
+ isEnabled: boolean;
180
+ refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<import("@sudobility/types").WildduckAddressResponse | {
181
+ success: boolean;
182
+ results: never[];
183
+ error: null;
184
+ }, Error>>;
185
+ fetchStatus: import("@tanstack/query-core").FetchStatus;
186
+ promise: Promise<import("@sudobility/types").WildduckAddressResponse | {
187
+ success: boolean;
188
+ results: never[];
189
+ error: null;
190
+ }>;
191
+ } | {
192
+ data: import("@sudobility/types").WildduckAddressResponse | {
193
+ success: boolean;
194
+ results: never[];
195
+ error: null;
196
+ };
197
+ isError: false;
198
+ error: null;
199
+ isPending: false;
200
+ isLoading: false;
201
+ isLoadingError: false;
202
+ isRefetchError: false;
203
+ isSuccess: true;
204
+ isPlaceholderData: true;
205
+ status: "success";
206
+ dataUpdatedAt: number;
207
+ errorUpdatedAt: number;
208
+ failureCount: number;
209
+ failureReason: Error | null;
210
+ errorUpdateCount: number;
211
+ isFetched: boolean;
212
+ isFetchedAfterMount: boolean;
213
+ isFetching: boolean;
214
+ isInitialLoading: boolean;
215
+ isPaused: boolean;
216
+ isRefetching: boolean;
217
+ isStale: boolean;
218
+ isEnabled: boolean;
219
+ refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<import("@sudobility/types").WildduckAddressResponse | {
220
+ success: boolean;
221
+ results: never[];
222
+ error: null;
223
+ }, Error>>;
224
+ fetchStatus: import("@tanstack/query-core").FetchStatus;
225
+ promise: Promise<import("@sudobility/types").WildduckAddressResponse | {
226
+ success: boolean;
227
+ results: never[];
228
+ error: null;
229
+ }>;
230
+ };
231
+ export type UseWildduckGetAddressesReturn = ReturnType<typeof useWildduckGetAddresses>;
232
+ //# sourceMappingURL=useWildduckGetAddresses.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useWildduckGetAddresses.d.ts","sourceRoot":"","sources":["../../../src/hooks/addresses/useWildduckGetAddresses.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAWD,eAAO,MAAM,uBAAuB,GAClC,eAAe,aAAa,EAC5B,QAAQ,cAAc,EACtB,SAAQ,6BAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0C3C,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG,UAAU,CACpD,OAAO,uBAAuB,CAC/B,CAAC"}
@@ -0,0 +1,34 @@
1
+ import { useCallback, useMemo } from "react";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { WildduckAPI } from "../../network/wildduck-client";
4
+ export const useWildduckGetAddresses = (networkClient, config, params = {}) => {
5
+ const { userAuth, devMode = false } = params;
6
+ const api = useMemo(() => new WildduckAPI(networkClient, config), [networkClient, config]);
7
+ const queryFn = useCallback(async () => {
8
+ if (!userAuth)
9
+ throw new Error("userAuth is required");
10
+ try {
11
+ return await api.getAddresses(userAuth);
12
+ }
13
+ catch (err) {
14
+ if (devMode) {
15
+ console.warn("[DevMode] getAddresses failed, returning mock data:", err);
16
+ return {
17
+ success: true,
18
+ results: [],
19
+ error: null,
20
+ };
21
+ }
22
+ throw err;
23
+ }
24
+ }, [userAuth, api, devMode]);
25
+ const query = useQuery({
26
+ queryKey: ["wildduck-addresses", userAuth?.userId],
27
+ queryFn,
28
+ enabled: !!userAuth,
29
+ });
30
+ return useMemo(() => ({
31
+ ...query,
32
+ }), [query]);
33
+ };
34
+ //# sourceMappingURL=useWildduckGetAddresses.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useWildduckGetAddresses.js","sourceRoot":"","sources":["../../../src/hooks/addresses/useWildduckGetAddresses.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAmB5D,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,aAA4B,EAC5B,MAAsB,EACtB,SAAwC,EAAE,EAC1C,EAAE;IACF,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,KAAK,EAAE,GAAG,MAAM,CAAC;IAE7C,MAAM,GAAG,GAAG,OAAO,CACjB,GAAG,EAAE,CAAC,IAAI,WAAW,CAAC,aAAa,EAAE,MAAM,CAAC,EAC5C,CAAC,aAAa,EAAE,MAAM,CAAC,CACxB,CAAC;IAEF,MAAM,OAAO,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE;QACrC,IAAI,CAAC,QAAQ;YAAE,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;QAEvD,IAAI,CAAC;YACH,OAAO,MAAM,GAAG,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QAC1C,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,OAAO,EAAE,CAAC;gBACZ,OAAO,CAAC,IAAI,CACV,qDAAqD,EACrD,GAAG,CACJ,CAAC;gBACF,OAAO;oBACL,OAAO,EAAE,IAAI;oBACb,OAAO,EAAE,EAAE;oBACX,KAAK,EAAE,IAAI;iBACZ,CAAC;YACJ,CAAC;YACD,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;IAE7B,MAAM,KAAK,GAAG,QAAQ,CAAC;QACrB,QAAQ,EAAE,CAAC,oBAAoB,EAAE,QAAQ,EAAE,MAAM,CAAC;QAClD,OAAO;QACP,OAAO,EAAE,CAAC,CAAC,QAAQ;KACpB,CAAC,CAAC;IAEH,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC;QACL,GAAG,KAAK;KACT,CAAC,EACF,CAAC,KAAK,CAAC,CACR,CAAC;AACJ,CAAC,CAAC"}