@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.
- package/README.md +354 -0
- package/dist/hooks/ServiceProvider.d.ts +15 -0
- package/dist/hooks/ServiceProvider.d.ts.map +1 -0
- package/dist/hooks/ServiceProvider.js +21 -0
- package/dist/hooks/ServiceProvider.js.map +1 -0
- package/dist/hooks/addresses/index.d.ts +2 -0
- package/dist/hooks/addresses/index.d.ts.map +1 -0
- package/dist/hooks/addresses/index.js +2 -0
- package/dist/hooks/addresses/index.js.map +1 -0
- package/dist/hooks/addresses/useWildduckGetAddresses.d.ts +232 -0
- package/dist/hooks/addresses/useWildduckGetAddresses.d.ts.map +1 -0
- package/dist/hooks/addresses/useWildduckGetAddresses.js +34 -0
- package/dist/hooks/addresses/useWildduckGetAddresses.js.map +1 -0
- package/dist/hooks/autoreply/index.d.ts +4 -0
- package/dist/hooks/autoreply/index.d.ts.map +1 -0
- package/dist/hooks/autoreply/index.js +4 -0
- package/dist/hooks/autoreply/index.js.map +1 -0
- package/dist/hooks/autoreply/useWildduckDeleteAutoreply.d.ts +13 -0
- package/dist/hooks/autoreply/useWildduckDeleteAutoreply.d.ts.map +1 -0
- package/dist/hooks/autoreply/useWildduckDeleteAutoreply.js +46 -0
- package/dist/hooks/autoreply/useWildduckDeleteAutoreply.js.map +1 -0
- package/dist/hooks/autoreply/useWildduckGetAutoreply.d.ts +172 -0
- package/dist/hooks/autoreply/useWildduckGetAutoreply.d.ts.map +1 -0
- package/dist/hooks/autoreply/useWildduckGetAutoreply.js +39 -0
- package/dist/hooks/autoreply/useWildduckGetAutoreply.js.map +1 -0
- package/dist/hooks/autoreply/useWildduckUpdateAutoreply.d.ts +13 -0
- package/dist/hooks/autoreply/useWildduckUpdateAutoreply.d.ts.map +1 -0
- package/dist/hooks/autoreply/useWildduckUpdateAutoreply.js +46 -0
- package/dist/hooks/autoreply/useWildduckUpdateAutoreply.js.map +1 -0
- package/dist/hooks/index.d.ts +19 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +16 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/mailboxes/index.d.ts +6 -0
- package/dist/hooks/mailboxes/index.d.ts.map +1 -0
- package/dist/hooks/mailboxes/index.js +6 -0
- package/dist/hooks/mailboxes/index.js.map +1 -0
- package/dist/hooks/mailboxes/useWildduckCreateMailbox.d.ts +13 -0
- package/dist/hooks/mailboxes/useWildduckCreateMailbox.d.ts.map +1 -0
- package/dist/hooks/mailboxes/useWildduckCreateMailbox.js +43 -0
- package/dist/hooks/mailboxes/useWildduckCreateMailbox.js.map +1 -0
- package/dist/hooks/mailboxes/useWildduckDeleteMailbox.d.ts +13 -0
- package/dist/hooks/mailboxes/useWildduckDeleteMailbox.d.ts.map +1 -0
- package/dist/hooks/mailboxes/useWildduckDeleteMailbox.js +48 -0
- package/dist/hooks/mailboxes/useWildduckDeleteMailbox.js.map +1 -0
- package/dist/hooks/mailboxes/useWildduckGetMailbox.d.ts +173 -0
- package/dist/hooks/mailboxes/useWildduckGetMailbox.d.ts.map +1 -0
- package/dist/hooks/mailboxes/useWildduckGetMailbox.js +47 -0
- package/dist/hooks/mailboxes/useWildduckGetMailbox.js.map +1 -0
- package/dist/hooks/mailboxes/useWildduckGetMailboxes.d.ts +233 -0
- package/dist/hooks/mailboxes/useWildduckGetMailboxes.d.ts.map +1 -0
- package/dist/hooks/mailboxes/useWildduckGetMailboxes.js +34 -0
- package/dist/hooks/mailboxes/useWildduckGetMailboxes.js.map +1 -0
- package/dist/hooks/mailboxes/useWildduckUpdateMailbox.d.ts +13 -0
- package/dist/hooks/mailboxes/useWildduckUpdateMailbox.d.ts.map +1 -0
- package/dist/hooks/mailboxes/useWildduckUpdateMailbox.js +48 -0
- package/dist/hooks/mailboxes/useWildduckUpdateMailbox.js.map +1 -0
- package/dist/hooks/messages/index.d.ts +12 -0
- package/dist/hooks/messages/index.d.ts.map +1 -0
- package/dist/hooks/messages/index.js +12 -0
- package/dist/hooks/messages/index.js.map +1 -0
- package/dist/hooks/messages/useWildduckDeleteMessage.d.ts +13 -0
- package/dist/hooks/messages/useWildduckDeleteMessage.d.ts.map +1 -0
- package/dist/hooks/messages/useWildduckDeleteMessage.js +48 -0
- package/dist/hooks/messages/useWildduckDeleteMessage.js.map +1 -0
- package/dist/hooks/messages/useWildduckForwardMessage.d.ts +13 -0
- package/dist/hooks/messages/useWildduckForwardMessage.d.ts.map +1 -0
- package/dist/hooks/messages/useWildduckForwardMessage.js +51 -0
- package/dist/hooks/messages/useWildduckForwardMessage.js.map +1 -0
- package/dist/hooks/messages/useWildduckGetMessage.d.ts +653 -0
- package/dist/hooks/messages/useWildduckGetMessage.d.ts.map +1 -0
- package/dist/hooks/messages/useWildduckGetMessage.js +37 -0
- package/dist/hooks/messages/useWildduckGetMessage.js.map +1 -0
- package/dist/hooks/messages/useWildduckGetMessageAttachment.d.ts +13 -0
- package/dist/hooks/messages/useWildduckGetMessageAttachment.d.ts.map +1 -0
- package/dist/hooks/messages/useWildduckGetMessageAttachment.js +40 -0
- package/dist/hooks/messages/useWildduckGetMessageAttachment.js.map +1 -0
- package/dist/hooks/messages/useWildduckGetMessageSource.d.ts +12 -0
- package/dist/hooks/messages/useWildduckGetMessageSource.d.ts.map +1 -0
- package/dist/hooks/messages/useWildduckGetMessageSource.js +35 -0
- package/dist/hooks/messages/useWildduckGetMessageSource.js.map +1 -0
- package/dist/hooks/messages/useWildduckGetMessages.d.ts +11 -0
- package/dist/hooks/messages/useWildduckGetMessages.d.ts.map +1 -0
- package/dist/hooks/messages/useWildduckGetMessages.js +18 -0
- package/dist/hooks/messages/useWildduckGetMessages.js.map +1 -0
- package/dist/hooks/messages/useWildduckSearchMessages.d.ts +12 -0
- package/dist/hooks/messages/useWildduckSearchMessages.d.ts.map +1 -0
- package/dist/hooks/messages/useWildduckSearchMessages.js +46 -0
- package/dist/hooks/messages/useWildduckSearchMessages.js.map +1 -0
- package/dist/hooks/messages/useWildduckSendMessage.d.ts +13 -0
- package/dist/hooks/messages/useWildduckSendMessage.d.ts.map +1 -0
- package/dist/hooks/messages/useWildduckSendMessage.js +48 -0
- package/dist/hooks/messages/useWildduckSendMessage.js.map +1 -0
- package/dist/hooks/messages/useWildduckSubmitDraft.d.ts +13 -0
- package/dist/hooks/messages/useWildduckSubmitDraft.d.ts.map +1 -0
- package/dist/hooks/messages/useWildduckSubmitDraft.js +44 -0
- package/dist/hooks/messages/useWildduckSubmitDraft.js.map +1 -0
- package/dist/hooks/messages/useWildduckUpdateMessage.d.ts +13 -0
- package/dist/hooks/messages/useWildduckUpdateMessage.d.ts.map +1 -0
- package/dist/hooks/messages/useWildduckUpdateMessage.js +53 -0
- package/dist/hooks/messages/useWildduckUpdateMessage.js.map +1 -0
- package/dist/hooks/messages/useWildduckUploadMessage.d.ts +13 -0
- package/dist/hooks/messages/useWildduckUploadMessage.d.ts.map +1 -0
- package/dist/hooks/messages/useWildduckUploadMessage.js +51 -0
- package/dist/hooks/messages/useWildduckUploadMessage.js.map +1 -0
- package/dist/hooks/mocks.d.ts +354 -0
- package/dist/hooks/mocks.d.ts.map +1 -0
- package/dist/hooks/mocks.js +404 -0
- package/dist/hooks/mocks.js.map +1 -0
- package/dist/hooks/query-config.d.ts +9 -0
- package/dist/hooks/query-config.d.ts.map +1 -0
- package/dist/hooks/query-config.js +9 -0
- package/dist/hooks/query-config.js.map +1 -0
- package/dist/hooks/query-keys.d.ts +31 -0
- package/dist/hooks/query-keys.d.ts.map +1 -0
- package/dist/hooks/query-keys.js +40 -0
- package/dist/hooks/query-keys.js.map +1 -0
- package/dist/hooks/useServices.d.ts +14 -0
- package/dist/hooks/useServices.d.ts.map +1 -0
- package/dist/hooks/useServices.js +36 -0
- package/dist/hooks/useServices.js.map +1 -0
- package/dist/hooks/useWildduckAddresses.d.ts +67 -0
- package/dist/hooks/useWildduckAddresses.d.ts.map +1 -0
- package/dist/hooks/useWildduckAddresses.js +313 -0
- package/dist/hooks/useWildduckAddresses.js.map +1 -0
- package/dist/hooks/useWildduckAuth.d.ts +28 -0
- package/dist/hooks/useWildduckAuth.d.ts.map +1 -0
- package/dist/hooks/useWildduckAuth.js +249 -0
- package/dist/hooks/useWildduckAuth.js.map +1 -0
- package/dist/hooks/useWildduckFilters.d.ts +89 -0
- package/dist/hooks/useWildduckFilters.d.ts.map +1 -0
- package/dist/hooks/useWildduckFilters.js +209 -0
- package/dist/hooks/useWildduckFilters.js.map +1 -0
- package/dist/hooks/useWildduckHealth.d.ts +45 -0
- package/dist/hooks/useWildduckHealth.d.ts.map +1 -0
- package/dist/hooks/useWildduckHealth.js +110 -0
- package/dist/hooks/useWildduckHealth.js.map +1 -0
- package/dist/hooks/useWildduckMailboxes.d.ts +29 -0
- package/dist/hooks/useWildduckMailboxes.d.ts.map +1 -0
- package/dist/hooks/useWildduckMailboxes.js +195 -0
- package/dist/hooks/useWildduckMailboxes.js.map +1 -0
- package/dist/hooks/useWildduckMessages.d.ts +76 -0
- package/dist/hooks/useWildduckMessages.d.ts.map +1 -0
- package/dist/hooks/useWildduckMessages.js +264 -0
- package/dist/hooks/useWildduckMessages.js.map +1 -0
- package/dist/hooks/useWildduckQueries.d.ts +50 -0
- package/dist/hooks/useWildduckQueries.d.ts.map +1 -0
- package/dist/hooks/useWildduckQueries.js +640 -0
- package/dist/hooks/useWildduckQueries.js.map +1 -0
- package/dist/hooks/useWildduckSettings.d.ts +22 -0
- package/dist/hooks/useWildduckSettings.d.ts.map +1 -0
- package/dist/hooks/useWildduckSettings.js +153 -0
- package/dist/hooks/useWildduckSettings.js.map +1 -0
- package/dist/hooks/useWildduckUsers.d.ts +31 -0
- package/dist/hooks/useWildduckUsers.d.ts.map +1 -0
- package/dist/hooks/useWildduckUsers.js +114 -0
- package/dist/hooks/useWildduckUsers.js.map +1 -0
- package/dist/hooks/users/index.d.ts +12 -0
- package/dist/hooks/users/index.d.ts.map +1 -0
- package/dist/hooks/users/index.js +12 -0
- package/dist/hooks/users/index.js.map +1 -0
- package/dist/hooks/users/useWildduckCreateUser.d.ts +13 -0
- package/dist/hooks/users/useWildduckCreateUser.d.ts.map +1 -0
- package/dist/hooks/users/useWildduckCreateUser.js +44 -0
- package/dist/hooks/users/useWildduckCreateUser.js.map +1 -0
- package/dist/hooks/users/useWildduckDeleteUser.d.ts +13 -0
- package/dist/hooks/users/useWildduckDeleteUser.d.ts.map +1 -0
- package/dist/hooks/users/useWildduckDeleteUser.js +44 -0
- package/dist/hooks/users/useWildduckDeleteUser.js.map +1 -0
- package/dist/hooks/users/useWildduckGetUser.d.ts +397 -0
- package/dist/hooks/users/useWildduckGetUser.d.ts.map +1 -0
- package/dist/hooks/users/useWildduckGetUser.js +45 -0
- package/dist/hooks/users/useWildduckGetUser.js.map +1 -0
- package/dist/hooks/users/useWildduckUpdateUser.d.ts +13 -0
- package/dist/hooks/users/useWildduckUpdateUser.d.ts.map +1 -0
- package/dist/hooks/users/useWildduckUpdateUser.js +44 -0
- package/dist/hooks/users/useWildduckUpdateUser.js.map +1 -0
- package/dist/hooks/users/useWildduckUser2FA.d.ts +25 -0
- package/dist/hooks/users/useWildduckUser2FA.d.ts.map +1 -0
- package/dist/hooks/users/useWildduckUser2FA.js +70 -0
- package/dist/hooks/users/useWildduckUser2FA.js.map +1 -0
- package/dist/hooks/users/useWildduckUserEncryption.d.ts +40 -0
- package/dist/hooks/users/useWildduckUserEncryption.d.ts.map +1 -0
- package/dist/hooks/users/useWildduckUserEncryption.js +94 -0
- package/dist/hooks/users/useWildduckUserEncryption.js.map +1 -0
- package/dist/hooks/users/useWildduckUserForwarding.d.ts +44 -0
- package/dist/hooks/users/useWildduckUserForwarding.d.ts.map +1 -0
- package/dist/hooks/users/useWildduckUserForwarding.js +122 -0
- package/dist/hooks/users/useWildduckUserForwarding.js.map +1 -0
- package/dist/hooks/users/useWildduckUserLimits.d.ts +63 -0
- package/dist/hooks/users/useWildduckUserLimits.d.ts.map +1 -0
- package/dist/hooks/users/useWildduckUserLimits.js +60 -0
- package/dist/hooks/users/useWildduckUserLimits.js.map +1 -0
- package/dist/hooks/users/useWildduckUserProfile.d.ts +78 -0
- package/dist/hooks/users/useWildduckUserProfile.d.ts.map +1 -0
- package/dist/hooks/users/useWildduckUserProfile.js +139 -0
- package/dist/hooks/users/useWildduckUserProfile.js.map +1 -0
- package/dist/hooks/users/useWildduckUserQuota.d.ts +31 -0
- package/dist/hooks/users/useWildduckUserQuota.d.ts.map +1 -0
- package/dist/hooks/users/useWildduckUserQuota.js +66 -0
- package/dist/hooks/users/useWildduckUserQuota.js.map +1 -0
- package/dist/hooks/users/useWildduckUserSpam.d.ts +54 -0
- package/dist/hooks/users/useWildduckUserSpam.d.ts.map +1 -0
- package/dist/hooks/users/useWildduckUserSpam.js +137 -0
- package/dist/hooks/users/useWildduckUserSpam.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/network/index.d.ts +2 -0
- package/dist/network/index.d.ts.map +1 -0
- package/dist/network/index.js +2 -0
- package/dist/network/index.js.map +1 -0
- package/dist/network/wildduck-client.d.ts +54 -0
- package/dist/network/wildduck-client.d.ts.map +1 -0
- package/dist/network/wildduck-client.js +572 -0
- package/dist/network/wildduck-client.js.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/advanced-settings.d.ts +36 -0
- package/dist/utils/advanced-settings.d.ts.map +1 -0
- package/dist/utils/advanced-settings.js +99 -0
- package/dist/utils/advanced-settings.js.map +1 -0
- package/dist/utils/autoreply.d.ts +34 -0
- package/dist/utils/autoreply.d.ts.map +1 -0
- package/dist/utils/autoreply.js +39 -0
- package/dist/utils/autoreply.js.map +1 -0
- package/dist/utils/client.d.ts +4 -0
- package/dist/utils/client.d.ts.map +1 -0
- package/dist/utils/client.js +11 -0
- package/dist/utils/client.js.map +1 -0
- package/dist/utils/filters.d.ts +26 -0
- package/dist/utils/filters.d.ts.map +1 -0
- package/dist/utils/filters.js +50 -0
- package/dist/utils/filters.js.map +1 -0
- package/dist/utils/forwarding.d.ts +12 -0
- package/dist/utils/forwarding.d.ts.map +1 -0
- package/dist/utils/forwarding.js +29 -0
- package/dist/utils/forwarding.js.map +1 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +7 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/spam-settings.d.ts +21 -0
- package/dist/utils/spam-settings.d.ts.map +1 -0
- package/dist/utils/spam-settings.js +53 -0
- package/dist/utils/spam-settings.js.map +1 -0
- package/dist/utils/user-settings.d.ts +30 -0
- package/dist/utils/user-settings.d.ts.map +1 -0
- package/dist/utils/user-settings.js +21 -0
- package/dist/utils/user-settings.js.map +1 -0
- package/package.json +82 -0
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
import { type NetworkClient } from "@sudobility/di";
|
|
2
|
+
import { type WildduckConfig } from "@sudobility/types";
|
|
3
|
+
import type { WildduckUserAuth } from "@sudobility/types";
|
|
4
|
+
export interface UseWildduckGetUserParams {
|
|
5
|
+
userAuth?: WildduckUserAuth;
|
|
6
|
+
devMode?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const useWildduckGetUser: (networkClient: NetworkClient, config: WildduckConfig, params?: UseWildduckGetUserParams) => {
|
|
9
|
+
data: import("@sudobility/types").WildduckUserResponse | {
|
|
10
|
+
success: boolean;
|
|
11
|
+
id: string;
|
|
12
|
+
username: string;
|
|
13
|
+
name: string;
|
|
14
|
+
address: string;
|
|
15
|
+
quota: {
|
|
16
|
+
allowed: number;
|
|
17
|
+
used: number;
|
|
18
|
+
};
|
|
19
|
+
hasPasswordSet: boolean;
|
|
20
|
+
activated: boolean;
|
|
21
|
+
disabled: boolean;
|
|
22
|
+
suspended: boolean;
|
|
23
|
+
error: null;
|
|
24
|
+
};
|
|
25
|
+
error: Error;
|
|
26
|
+
isError: true;
|
|
27
|
+
isPending: false;
|
|
28
|
+
isLoading: false;
|
|
29
|
+
isLoadingError: false;
|
|
30
|
+
isRefetchError: true;
|
|
31
|
+
isSuccess: false;
|
|
32
|
+
isPlaceholderData: false;
|
|
33
|
+
status: "error";
|
|
34
|
+
dataUpdatedAt: number;
|
|
35
|
+
errorUpdatedAt: number;
|
|
36
|
+
failureCount: number;
|
|
37
|
+
failureReason: Error | null;
|
|
38
|
+
errorUpdateCount: number;
|
|
39
|
+
isFetched: boolean;
|
|
40
|
+
isFetchedAfterMount: boolean;
|
|
41
|
+
isFetching: boolean;
|
|
42
|
+
isInitialLoading: boolean;
|
|
43
|
+
isPaused: boolean;
|
|
44
|
+
isRefetching: boolean;
|
|
45
|
+
isStale: boolean;
|
|
46
|
+
isEnabled: boolean;
|
|
47
|
+
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<import("@sudobility/types").WildduckUserResponse | {
|
|
48
|
+
success: boolean;
|
|
49
|
+
id: string;
|
|
50
|
+
username: string;
|
|
51
|
+
name: string;
|
|
52
|
+
address: string;
|
|
53
|
+
quota: {
|
|
54
|
+
allowed: number;
|
|
55
|
+
used: number;
|
|
56
|
+
};
|
|
57
|
+
hasPasswordSet: boolean;
|
|
58
|
+
activated: boolean;
|
|
59
|
+
disabled: boolean;
|
|
60
|
+
suspended: boolean;
|
|
61
|
+
error: null;
|
|
62
|
+
}, Error>>;
|
|
63
|
+
fetchStatus: import("@tanstack/query-core").FetchStatus;
|
|
64
|
+
promise: Promise<import("@sudobility/types").WildduckUserResponse | {
|
|
65
|
+
success: boolean;
|
|
66
|
+
id: string;
|
|
67
|
+
username: string;
|
|
68
|
+
name: string;
|
|
69
|
+
address: string;
|
|
70
|
+
quota: {
|
|
71
|
+
allowed: number;
|
|
72
|
+
used: number;
|
|
73
|
+
};
|
|
74
|
+
hasPasswordSet: boolean;
|
|
75
|
+
activated: boolean;
|
|
76
|
+
disabled: boolean;
|
|
77
|
+
suspended: boolean;
|
|
78
|
+
error: null;
|
|
79
|
+
}>;
|
|
80
|
+
} | {
|
|
81
|
+
data: import("@sudobility/types").WildduckUserResponse | {
|
|
82
|
+
success: boolean;
|
|
83
|
+
id: string;
|
|
84
|
+
username: string;
|
|
85
|
+
name: string;
|
|
86
|
+
address: string;
|
|
87
|
+
quota: {
|
|
88
|
+
allowed: number;
|
|
89
|
+
used: number;
|
|
90
|
+
};
|
|
91
|
+
hasPasswordSet: boolean;
|
|
92
|
+
activated: boolean;
|
|
93
|
+
disabled: boolean;
|
|
94
|
+
suspended: boolean;
|
|
95
|
+
error: null;
|
|
96
|
+
};
|
|
97
|
+
error: null;
|
|
98
|
+
isError: false;
|
|
99
|
+
isPending: false;
|
|
100
|
+
isLoading: false;
|
|
101
|
+
isLoadingError: false;
|
|
102
|
+
isRefetchError: false;
|
|
103
|
+
isSuccess: true;
|
|
104
|
+
isPlaceholderData: false;
|
|
105
|
+
status: "success";
|
|
106
|
+
dataUpdatedAt: number;
|
|
107
|
+
errorUpdatedAt: number;
|
|
108
|
+
failureCount: number;
|
|
109
|
+
failureReason: Error | null;
|
|
110
|
+
errorUpdateCount: number;
|
|
111
|
+
isFetched: boolean;
|
|
112
|
+
isFetchedAfterMount: boolean;
|
|
113
|
+
isFetching: boolean;
|
|
114
|
+
isInitialLoading: boolean;
|
|
115
|
+
isPaused: boolean;
|
|
116
|
+
isRefetching: boolean;
|
|
117
|
+
isStale: boolean;
|
|
118
|
+
isEnabled: boolean;
|
|
119
|
+
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<import("@sudobility/types").WildduckUserResponse | {
|
|
120
|
+
success: boolean;
|
|
121
|
+
id: string;
|
|
122
|
+
username: string;
|
|
123
|
+
name: string;
|
|
124
|
+
address: string;
|
|
125
|
+
quota: {
|
|
126
|
+
allowed: number;
|
|
127
|
+
used: number;
|
|
128
|
+
};
|
|
129
|
+
hasPasswordSet: boolean;
|
|
130
|
+
activated: boolean;
|
|
131
|
+
disabled: boolean;
|
|
132
|
+
suspended: boolean;
|
|
133
|
+
error: null;
|
|
134
|
+
}, Error>>;
|
|
135
|
+
fetchStatus: import("@tanstack/query-core").FetchStatus;
|
|
136
|
+
promise: Promise<import("@sudobility/types").WildduckUserResponse | {
|
|
137
|
+
success: boolean;
|
|
138
|
+
id: string;
|
|
139
|
+
username: string;
|
|
140
|
+
name: string;
|
|
141
|
+
address: string;
|
|
142
|
+
quota: {
|
|
143
|
+
allowed: number;
|
|
144
|
+
used: number;
|
|
145
|
+
};
|
|
146
|
+
hasPasswordSet: boolean;
|
|
147
|
+
activated: boolean;
|
|
148
|
+
disabled: boolean;
|
|
149
|
+
suspended: boolean;
|
|
150
|
+
error: null;
|
|
151
|
+
}>;
|
|
152
|
+
} | {
|
|
153
|
+
data: undefined;
|
|
154
|
+
error: Error;
|
|
155
|
+
isError: true;
|
|
156
|
+
isPending: false;
|
|
157
|
+
isLoading: false;
|
|
158
|
+
isLoadingError: true;
|
|
159
|
+
isRefetchError: false;
|
|
160
|
+
isSuccess: false;
|
|
161
|
+
isPlaceholderData: false;
|
|
162
|
+
status: "error";
|
|
163
|
+
dataUpdatedAt: number;
|
|
164
|
+
errorUpdatedAt: number;
|
|
165
|
+
failureCount: number;
|
|
166
|
+
failureReason: Error | null;
|
|
167
|
+
errorUpdateCount: number;
|
|
168
|
+
isFetched: boolean;
|
|
169
|
+
isFetchedAfterMount: boolean;
|
|
170
|
+
isFetching: boolean;
|
|
171
|
+
isInitialLoading: boolean;
|
|
172
|
+
isPaused: boolean;
|
|
173
|
+
isRefetching: boolean;
|
|
174
|
+
isStale: boolean;
|
|
175
|
+
isEnabled: boolean;
|
|
176
|
+
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<import("@sudobility/types").WildduckUserResponse | {
|
|
177
|
+
success: boolean;
|
|
178
|
+
id: string;
|
|
179
|
+
username: string;
|
|
180
|
+
name: string;
|
|
181
|
+
address: string;
|
|
182
|
+
quota: {
|
|
183
|
+
allowed: number;
|
|
184
|
+
used: number;
|
|
185
|
+
};
|
|
186
|
+
hasPasswordSet: boolean;
|
|
187
|
+
activated: boolean;
|
|
188
|
+
disabled: boolean;
|
|
189
|
+
suspended: boolean;
|
|
190
|
+
error: null;
|
|
191
|
+
}, Error>>;
|
|
192
|
+
fetchStatus: import("@tanstack/query-core").FetchStatus;
|
|
193
|
+
promise: Promise<import("@sudobility/types").WildduckUserResponse | {
|
|
194
|
+
success: boolean;
|
|
195
|
+
id: string;
|
|
196
|
+
username: string;
|
|
197
|
+
name: string;
|
|
198
|
+
address: string;
|
|
199
|
+
quota: {
|
|
200
|
+
allowed: number;
|
|
201
|
+
used: number;
|
|
202
|
+
};
|
|
203
|
+
hasPasswordSet: boolean;
|
|
204
|
+
activated: boolean;
|
|
205
|
+
disabled: boolean;
|
|
206
|
+
suspended: boolean;
|
|
207
|
+
error: null;
|
|
208
|
+
}>;
|
|
209
|
+
} | {
|
|
210
|
+
data: undefined;
|
|
211
|
+
error: null;
|
|
212
|
+
isError: false;
|
|
213
|
+
isPending: true;
|
|
214
|
+
isLoading: true;
|
|
215
|
+
isLoadingError: false;
|
|
216
|
+
isRefetchError: false;
|
|
217
|
+
isSuccess: false;
|
|
218
|
+
isPlaceholderData: false;
|
|
219
|
+
status: "pending";
|
|
220
|
+
dataUpdatedAt: number;
|
|
221
|
+
errorUpdatedAt: number;
|
|
222
|
+
failureCount: number;
|
|
223
|
+
failureReason: Error | null;
|
|
224
|
+
errorUpdateCount: number;
|
|
225
|
+
isFetched: boolean;
|
|
226
|
+
isFetchedAfterMount: boolean;
|
|
227
|
+
isFetching: boolean;
|
|
228
|
+
isInitialLoading: boolean;
|
|
229
|
+
isPaused: boolean;
|
|
230
|
+
isRefetching: boolean;
|
|
231
|
+
isStale: boolean;
|
|
232
|
+
isEnabled: boolean;
|
|
233
|
+
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<import("@sudobility/types").WildduckUserResponse | {
|
|
234
|
+
success: boolean;
|
|
235
|
+
id: string;
|
|
236
|
+
username: string;
|
|
237
|
+
name: string;
|
|
238
|
+
address: string;
|
|
239
|
+
quota: {
|
|
240
|
+
allowed: number;
|
|
241
|
+
used: number;
|
|
242
|
+
};
|
|
243
|
+
hasPasswordSet: boolean;
|
|
244
|
+
activated: boolean;
|
|
245
|
+
disabled: boolean;
|
|
246
|
+
suspended: boolean;
|
|
247
|
+
error: null;
|
|
248
|
+
}, Error>>;
|
|
249
|
+
fetchStatus: import("@tanstack/query-core").FetchStatus;
|
|
250
|
+
promise: Promise<import("@sudobility/types").WildduckUserResponse | {
|
|
251
|
+
success: boolean;
|
|
252
|
+
id: string;
|
|
253
|
+
username: string;
|
|
254
|
+
name: string;
|
|
255
|
+
address: string;
|
|
256
|
+
quota: {
|
|
257
|
+
allowed: number;
|
|
258
|
+
used: number;
|
|
259
|
+
};
|
|
260
|
+
hasPasswordSet: boolean;
|
|
261
|
+
activated: boolean;
|
|
262
|
+
disabled: boolean;
|
|
263
|
+
suspended: boolean;
|
|
264
|
+
error: null;
|
|
265
|
+
}>;
|
|
266
|
+
} | {
|
|
267
|
+
data: undefined;
|
|
268
|
+
error: null;
|
|
269
|
+
isError: false;
|
|
270
|
+
isPending: true;
|
|
271
|
+
isLoadingError: false;
|
|
272
|
+
isRefetchError: false;
|
|
273
|
+
isSuccess: false;
|
|
274
|
+
isPlaceholderData: false;
|
|
275
|
+
status: "pending";
|
|
276
|
+
dataUpdatedAt: number;
|
|
277
|
+
errorUpdatedAt: number;
|
|
278
|
+
failureCount: number;
|
|
279
|
+
failureReason: Error | null;
|
|
280
|
+
errorUpdateCount: number;
|
|
281
|
+
isFetched: boolean;
|
|
282
|
+
isFetchedAfterMount: boolean;
|
|
283
|
+
isFetching: boolean;
|
|
284
|
+
isLoading: boolean;
|
|
285
|
+
isInitialLoading: boolean;
|
|
286
|
+
isPaused: boolean;
|
|
287
|
+
isRefetching: boolean;
|
|
288
|
+
isStale: boolean;
|
|
289
|
+
isEnabled: boolean;
|
|
290
|
+
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<import("@sudobility/types").WildduckUserResponse | {
|
|
291
|
+
success: boolean;
|
|
292
|
+
id: string;
|
|
293
|
+
username: string;
|
|
294
|
+
name: string;
|
|
295
|
+
address: string;
|
|
296
|
+
quota: {
|
|
297
|
+
allowed: number;
|
|
298
|
+
used: number;
|
|
299
|
+
};
|
|
300
|
+
hasPasswordSet: boolean;
|
|
301
|
+
activated: boolean;
|
|
302
|
+
disabled: boolean;
|
|
303
|
+
suspended: boolean;
|
|
304
|
+
error: null;
|
|
305
|
+
}, Error>>;
|
|
306
|
+
fetchStatus: import("@tanstack/query-core").FetchStatus;
|
|
307
|
+
promise: Promise<import("@sudobility/types").WildduckUserResponse | {
|
|
308
|
+
success: boolean;
|
|
309
|
+
id: string;
|
|
310
|
+
username: string;
|
|
311
|
+
name: string;
|
|
312
|
+
address: string;
|
|
313
|
+
quota: {
|
|
314
|
+
allowed: number;
|
|
315
|
+
used: number;
|
|
316
|
+
};
|
|
317
|
+
hasPasswordSet: boolean;
|
|
318
|
+
activated: boolean;
|
|
319
|
+
disabled: boolean;
|
|
320
|
+
suspended: boolean;
|
|
321
|
+
error: null;
|
|
322
|
+
}>;
|
|
323
|
+
} | {
|
|
324
|
+
data: import("@sudobility/types").WildduckUserResponse | {
|
|
325
|
+
success: boolean;
|
|
326
|
+
id: string;
|
|
327
|
+
username: string;
|
|
328
|
+
name: string;
|
|
329
|
+
address: string;
|
|
330
|
+
quota: {
|
|
331
|
+
allowed: number;
|
|
332
|
+
used: number;
|
|
333
|
+
};
|
|
334
|
+
hasPasswordSet: boolean;
|
|
335
|
+
activated: boolean;
|
|
336
|
+
disabled: boolean;
|
|
337
|
+
suspended: boolean;
|
|
338
|
+
error: null;
|
|
339
|
+
};
|
|
340
|
+
isError: false;
|
|
341
|
+
error: null;
|
|
342
|
+
isPending: false;
|
|
343
|
+
isLoading: false;
|
|
344
|
+
isLoadingError: false;
|
|
345
|
+
isRefetchError: false;
|
|
346
|
+
isSuccess: true;
|
|
347
|
+
isPlaceholderData: true;
|
|
348
|
+
status: "success";
|
|
349
|
+
dataUpdatedAt: number;
|
|
350
|
+
errorUpdatedAt: number;
|
|
351
|
+
failureCount: number;
|
|
352
|
+
failureReason: Error | null;
|
|
353
|
+
errorUpdateCount: number;
|
|
354
|
+
isFetched: boolean;
|
|
355
|
+
isFetchedAfterMount: boolean;
|
|
356
|
+
isFetching: boolean;
|
|
357
|
+
isInitialLoading: boolean;
|
|
358
|
+
isPaused: boolean;
|
|
359
|
+
isRefetching: boolean;
|
|
360
|
+
isStale: boolean;
|
|
361
|
+
isEnabled: boolean;
|
|
362
|
+
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<import("@sudobility/types").WildduckUserResponse | {
|
|
363
|
+
success: boolean;
|
|
364
|
+
id: string;
|
|
365
|
+
username: string;
|
|
366
|
+
name: string;
|
|
367
|
+
address: string;
|
|
368
|
+
quota: {
|
|
369
|
+
allowed: number;
|
|
370
|
+
used: number;
|
|
371
|
+
};
|
|
372
|
+
hasPasswordSet: boolean;
|
|
373
|
+
activated: boolean;
|
|
374
|
+
disabled: boolean;
|
|
375
|
+
suspended: boolean;
|
|
376
|
+
error: null;
|
|
377
|
+
}, Error>>;
|
|
378
|
+
fetchStatus: import("@tanstack/query-core").FetchStatus;
|
|
379
|
+
promise: Promise<import("@sudobility/types").WildduckUserResponse | {
|
|
380
|
+
success: boolean;
|
|
381
|
+
id: string;
|
|
382
|
+
username: string;
|
|
383
|
+
name: string;
|
|
384
|
+
address: string;
|
|
385
|
+
quota: {
|
|
386
|
+
allowed: number;
|
|
387
|
+
used: number;
|
|
388
|
+
};
|
|
389
|
+
hasPasswordSet: boolean;
|
|
390
|
+
activated: boolean;
|
|
391
|
+
disabled: boolean;
|
|
392
|
+
suspended: boolean;
|
|
393
|
+
error: null;
|
|
394
|
+
}>;
|
|
395
|
+
};
|
|
396
|
+
export type UseWildduckGetUserReturn = ReturnType<typeof useWildduckGetUser>;
|
|
397
|
+
//# sourceMappingURL=useWildduckGetUser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWildduckGetUser.d.ts","sourceRoot":"","sources":["../../../src/hooks/users/useWildduckGetUser.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,wBAAwB;IACvC,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAWD,eAAO,MAAM,kBAAkB,GAC7B,eAAe,aAAa,EAC5B,QAAQ,cAAc,EACtB,SAAQ,wBAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkDtC,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { useCallback, useMemo } from "react";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { WildduckAPI } from "../../network/wildduck-client";
|
|
4
|
+
export const useWildduckGetUser = (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.getUser(userAuth);
|
|
12
|
+
}
|
|
13
|
+
catch (err) {
|
|
14
|
+
if (devMode) {
|
|
15
|
+
console.warn("[DevMode] getUser failed, returning mock data:", err);
|
|
16
|
+
return {
|
|
17
|
+
success: true,
|
|
18
|
+
id: userAuth.userId,
|
|
19
|
+
username: `${userAuth.userId}@example.com`,
|
|
20
|
+
name: `Mock User ${userAuth.userId}`,
|
|
21
|
+
address: `${userAuth.userId}@example.com`,
|
|
22
|
+
quota: {
|
|
23
|
+
allowed: 1073741824,
|
|
24
|
+
used: 134217728,
|
|
25
|
+
},
|
|
26
|
+
hasPasswordSet: false,
|
|
27
|
+
activated: true,
|
|
28
|
+
disabled: false,
|
|
29
|
+
suspended: false,
|
|
30
|
+
error: null,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
throw err;
|
|
34
|
+
}
|
|
35
|
+
}, [userAuth, api, devMode]);
|
|
36
|
+
const query = useQuery({
|
|
37
|
+
queryKey: ["wildduck-user", userAuth?.userId],
|
|
38
|
+
queryFn,
|
|
39
|
+
enabled: !!userAuth,
|
|
40
|
+
});
|
|
41
|
+
return useMemo(() => ({
|
|
42
|
+
...query,
|
|
43
|
+
}), [query]);
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=useWildduckGetUser.js.map
|
|
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E,SAAS;qBAChB;oBACD,cAAc,EAAE,KAAK;oBACrB,SAAS,EAAE,IAAI;oBACf,QAAQ,EAAE,KAAK;oBACf,SAAS,EAAE,KAAK;oBAChB,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,eAAe,EAAE,QAAQ,EAAE,MAAM,CAAC;QAC7C,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"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Optional } from "@sudobility/types";
|
|
2
|
+
import { type NetworkClient } from "@sudobility/di";
|
|
3
|
+
import { type WildduckConfig } from "@sudobility/types";
|
|
4
|
+
import type { WildduckSuccessResponse, WildduckUpdateUserRequest, WildduckUserAuth } from "@sudobility/types";
|
|
5
|
+
interface UseUpdateUserReturn {
|
|
6
|
+
updateUser: (userAuth: WildduckUserAuth, params: WildduckUpdateUserRequest) => Promise<WildduckSuccessResponse>;
|
|
7
|
+
isLoading: boolean;
|
|
8
|
+
error: Optional<Error>;
|
|
9
|
+
clearError: () => void;
|
|
10
|
+
}
|
|
11
|
+
export declare const useWildduckUpdateUser: (networkClient: NetworkClient, config: WildduckConfig, devMode?: boolean) => UseUpdateUserReturn;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=useWildduckUpdateUser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWildduckUpdateUser.d.ts","sourceRoot":"","sources":["../../../src/hooks/users/useWildduckUpdateUser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGlD,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,KAAK,EACV,uBAAuB,EACvB,yBAAyB,EACzB,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAE3B,UAAU,mBAAmB;IAC3B,UAAU,EAAE,CACV,QAAQ,EAAE,gBAAgB,EAC1B,MAAM,EAAE,yBAAyB,KAC9B,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACtC,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;IACvB,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB;AAYD,eAAO,MAAM,qBAAqB,GAChC,eAAe,aAAa,EAC5B,QAAQ,cAAc,EACtB,UAAS,OAAe,KACvB,mBAiEF,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { useCallback, useMemo } from "react";
|
|
2
|
+
import { WildduckAPI } from "../../network/wildduck-client";
|
|
3
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
4
|
+
export const useWildduckUpdateUser = (networkClient, config, devMode = false) => {
|
|
5
|
+
const queryClient = useQueryClient();
|
|
6
|
+
const wildduckClient = useMemo(() => new WildduckAPI(networkClient, config), [networkClient, config]);
|
|
7
|
+
const updateMutation = useMutation({
|
|
8
|
+
mutationKey: [
|
|
9
|
+
"wildduck-update-user",
|
|
10
|
+
config.cloudflareWorkerUrl || config.backendUrl,
|
|
11
|
+
],
|
|
12
|
+
mutationFn: async ({ userAuth, params, }) => {
|
|
13
|
+
try {
|
|
14
|
+
return await wildduckClient.updateUser(userAuth, params);
|
|
15
|
+
}
|
|
16
|
+
catch (err) {
|
|
17
|
+
if (devMode) {
|
|
18
|
+
console.warn("[DevMode] updateUser failed, returning mock data:", err);
|
|
19
|
+
return { success: true };
|
|
20
|
+
}
|
|
21
|
+
throw err;
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
onSuccess: (_, variables) => {
|
|
25
|
+
queryClient.invalidateQueries({
|
|
26
|
+
queryKey: ["wildduck-user", variables.userAuth.userId],
|
|
27
|
+
});
|
|
28
|
+
queryClient.invalidateQueries({
|
|
29
|
+
queryKey: ["wildduck-users"],
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
const updateUser = useCallback(async (userAuth, params) => {
|
|
34
|
+
return updateMutation.mutateAsync({ userAuth, params });
|
|
35
|
+
}, [updateMutation]);
|
|
36
|
+
const clearError = useCallback(() => updateMutation.reset(), [updateMutation]);
|
|
37
|
+
return useMemo(() => ({
|
|
38
|
+
updateUser,
|
|
39
|
+
isLoading: updateMutation.isPending,
|
|
40
|
+
error: updateMutation.error,
|
|
41
|
+
clearError,
|
|
42
|
+
}), [updateUser, updateMutation.isPending, updateMutation.error, clearError]);
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=useWildduckUpdateUser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWildduckUpdateUser.js","sourceRoot":"","sources":["../../../src/hooks/users/useWildduckUpdateUser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAG5D,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AA2BpE,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,aAA4B,EAC5B,MAAsB,EACtB,UAAmB,KAAK,EACH,EAAE;IACvB,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;IAErC,MAAM,cAAc,GAAG,OAAO,CAC5B,GAAG,EAAE,CAAC,IAAI,WAAW,CAAC,aAAa,EAAE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AO,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC;QACL,UAAU;QACV,SAAS,EAAE,cAAc,CAAC,SAAS;QACnC,KAAK,EAAE,cAAc,CAAC,KAAK;QAC3B,UAAU;KACX,CAAC,EACF,CAAC,UAAU,EAAE,cAAc,CAAC,SAAS,EAAE,cAAc,CAAC,KAAK,EAAE,UAAU,CAAC,CACzE,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { WildduckAPI } from "../../network/wildduck-client";
|
|
2
|
+
import type { WildduckUserAuth } from "@sudobility/types";
|
|
3
|
+
export interface TwoFASettings {
|
|
4
|
+
enabled2fa: string[];
|
|
5
|
+
}
|
|
6
|
+
export interface DisableTwoFAParams {
|
|
7
|
+
userAuth: WildduckUserAuth;
|
|
8
|
+
}
|
|
9
|
+
export declare const useWildduckUser2FA: (api: WildduckAPI, userAuth?: WildduckUserAuth) => {
|
|
10
|
+
twoFA: TwoFASettings | undefined;
|
|
11
|
+
enabled2fa: string[];
|
|
12
|
+
isEnabled: boolean;
|
|
13
|
+
isLoading: boolean;
|
|
14
|
+
isError: boolean;
|
|
15
|
+
error: Error | null;
|
|
16
|
+
hasMethod: (method: string) => boolean;
|
|
17
|
+
hasTOTP: boolean;
|
|
18
|
+
hasU2F: boolean;
|
|
19
|
+
hasWebAuthn: boolean;
|
|
20
|
+
disable2FA: import("@tanstack/react-query").UseMutateFunction<import("@sudobility/types").WildduckSuccessResponse, Error, DisableTwoFAParams, unknown>;
|
|
21
|
+
disable2FAAsync: import("@tanstack/react-query").UseMutateAsyncFunction<import("@sudobility/types").WildduckSuccessResponse, Error, DisableTwoFAParams, unknown>;
|
|
22
|
+
isDisabling: boolean;
|
|
23
|
+
disableError: Error | null;
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=useWildduckUser2FA.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWildduckUser2FA.d.ts","sourceRoot":"","sources":["../../../src/hooks/users/useWildduckUser2FA.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAwB,MAAM,mBAAmB,CAAC;AAEhF,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,gBAAgB,CAAC;CAC5B;AAUD,eAAO,MAAM,kBAAkB,GAC7B,KAAK,WAAW,EAChB,WAAW,gBAAgB;;;;;;;wBA4ChB,MAAM,KAAG,OAAO;;;;;;;;CAsD5B,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { useCallback, useMemo } from "react";
|
|
2
|
+
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
export const useWildduckUser2FA = (api, userAuth) => {
|
|
4
|
+
const queryClient = useQueryClient();
|
|
5
|
+
const userId = userAuth?.userId;
|
|
6
|
+
const twoFAQueryFn = useCallback(async () => {
|
|
7
|
+
if (!userAuth)
|
|
8
|
+
throw new Error("User auth is required");
|
|
9
|
+
const user = (await api.getUser(userAuth));
|
|
10
|
+
return {
|
|
11
|
+
enabled2fa: user.enabled2fa || [],
|
|
12
|
+
};
|
|
13
|
+
}, [userAuth, api]);
|
|
14
|
+
const twoFAQuery = useQuery({
|
|
15
|
+
queryKey: ["user", userId, "2fa"],
|
|
16
|
+
queryFn: twoFAQueryFn,
|
|
17
|
+
enabled: !!userAuth,
|
|
18
|
+
});
|
|
19
|
+
const disable2FA = useMutation({
|
|
20
|
+
mutationFn: async ({ userAuth }) => {
|
|
21
|
+
return await api.updateUser(userAuth, { disable2fa: true });
|
|
22
|
+
},
|
|
23
|
+
onSuccess: (_, variables) => {
|
|
24
|
+
queryClient.invalidateQueries({
|
|
25
|
+
queryKey: ["user", variables.userAuth.userId],
|
|
26
|
+
});
|
|
27
|
+
queryClient.invalidateQueries({
|
|
28
|
+
queryKey: ["user", variables.userAuth.userId, "2fa"],
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
const isEnabled = (twoFAQuery.data?.enabled2fa?.length ?? 0) > 0;
|
|
33
|
+
const hasMethod = useCallback((method) => {
|
|
34
|
+
return twoFAQuery.data?.enabled2fa?.includes(method) ?? false;
|
|
35
|
+
}, [twoFAQuery.data?.enabled2fa]);
|
|
36
|
+
const hasTOTP = hasMethod("totp");
|
|
37
|
+
const hasU2F = hasMethod("u2f");
|
|
38
|
+
const hasWebAuthn = hasMethod("webauthn");
|
|
39
|
+
return useMemo(() => ({
|
|
40
|
+
twoFA: twoFAQuery.data,
|
|
41
|
+
enabled2fa: twoFAQuery.data?.enabled2fa || [],
|
|
42
|
+
isEnabled,
|
|
43
|
+
isLoading: twoFAQuery.isLoading,
|
|
44
|
+
isError: twoFAQuery.isError,
|
|
45
|
+
error: twoFAQuery.error,
|
|
46
|
+
hasMethod,
|
|
47
|
+
hasTOTP,
|
|
48
|
+
hasU2F,
|
|
49
|
+
hasWebAuthn,
|
|
50
|
+
disable2FA: disable2FA.mutate,
|
|
51
|
+
disable2FAAsync: disable2FA.mutateAsync,
|
|
52
|
+
isDisabling: disable2FA.isPending,
|
|
53
|
+
disableError: disable2FA.error,
|
|
54
|
+
}), [
|
|
55
|
+
twoFAQuery.data,
|
|
56
|
+
isEnabled,
|
|
57
|
+
twoFAQuery.isLoading,
|
|
58
|
+
twoFAQuery.isError,
|
|
59
|
+
twoFAQuery.error,
|
|
60
|
+
hasMethod,
|
|
61
|
+
hasTOTP,
|
|
62
|
+
hasU2F,
|
|
63
|
+
hasWebAuthn,
|
|
64
|
+
disable2FA.mutate,
|
|
65
|
+
disable2FA.mutateAsync,
|
|
66
|
+
disable2FA.isPending,
|
|
67
|
+
disable2FA.error,
|
|
68
|
+
]);
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=useWildduckUser2FA.js.map
|
|
@@ -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KAAK;KAO/B,CAAC,EACF;QACE,UAAU,CAAC,IAAI;QACf,SAAS;QACT,UAAU,CAAC,SAAS;QACpB,UAAU,CAAC,OAAO;QAClB,UAAU,CAAC,KAAK;QAChB,SAAS;QACT,OAAO;QACP,MAAM;QACN,WAAW;QACX,UAAU,CAAC,MAAM;QACjB,UAAU,CAAC,WAAW;QACtB,UAAU,CAAC,SAAS;QACpB,UAAU,CAAC,KAAK;KACjB,CACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { WildduckAPI } from "../../network/wildduck-client";
|
|
2
|
+
import type { WildduckKeyInfo, WildduckUserAuth } from "@sudobility/types";
|
|
3
|
+
export interface EncryptionSettings {
|
|
4
|
+
encryptMessages: boolean;
|
|
5
|
+
encryptForwarded: boolean;
|
|
6
|
+
pubKey: string;
|
|
7
|
+
keyInfo?: WildduckKeyInfo;
|
|
8
|
+
}
|
|
9
|
+
export interface UpdateEncryptionParams {
|
|
10
|
+
userAuth: WildduckUserAuth;
|
|
11
|
+
encryptMessages?: boolean;
|
|
12
|
+
encryptForwarded?: boolean;
|
|
13
|
+
pubKey?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare const useWildduckUserEncryption: (api: WildduckAPI, userAuth?: WildduckUserAuth) => {
|
|
16
|
+
encryption: EncryptionSettings | undefined;
|
|
17
|
+
isLoading: boolean;
|
|
18
|
+
isError: boolean;
|
|
19
|
+
error: Error | null;
|
|
20
|
+
encryptMessages: boolean | undefined;
|
|
21
|
+
encryptForwarded: boolean | undefined;
|
|
22
|
+
pubKey: string | undefined;
|
|
23
|
+
keyInfo: WildduckKeyInfo | undefined;
|
|
24
|
+
updateEncryption: import("@tanstack/react-query").UseMutateFunction<import("@sudobility/types").WildduckSuccessResponse, Error, UpdateEncryptionParams, unknown>;
|
|
25
|
+
updateEncryptionAsync: import("@tanstack/react-query").UseMutateAsyncFunction<import("@sudobility/types").WildduckSuccessResponse, Error, UpdateEncryptionParams, unknown>;
|
|
26
|
+
isUpdating: boolean;
|
|
27
|
+
updatePubKey: import("@tanstack/react-query").UseMutateFunction<import("@sudobility/types").WildduckSuccessResponse, Error, {
|
|
28
|
+
userAuth: WildduckUserAuth;
|
|
29
|
+
pubKey: string;
|
|
30
|
+
}, unknown>;
|
|
31
|
+
updatePubKeyAsync: import("@tanstack/react-query").UseMutateAsyncFunction<import("@sudobility/types").WildduckSuccessResponse, Error, {
|
|
32
|
+
userAuth: WildduckUserAuth;
|
|
33
|
+
pubKey: string;
|
|
34
|
+
}, unknown>;
|
|
35
|
+
isUpdatingKey: boolean;
|
|
36
|
+
removePubKey: import("@tanstack/react-query").UseMutateFunction<import("@sudobility/types").WildduckSuccessResponse, Error, WildduckUserAuth, unknown>;
|
|
37
|
+
removePubKeyAsync: import("@tanstack/react-query").UseMutateAsyncFunction<import("@sudobility/types").WildduckSuccessResponse, Error, WildduckUserAuth, unknown>;
|
|
38
|
+
isRemovingKey: boolean;
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=useWildduckUserEncryption.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWildduckUserEncryption.d.ts","sourceRoot":"","sources":["../../../src/hooks/users/useWildduckUserEncryption.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,KAAK,EACV,eAAe,EACf,gBAAgB,EAEjB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,WAAW,kBAAkB;IACjC,eAAe,EAAE,OAAO,CAAC;IACzB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,eAAe,CAAC;CAC3B;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAMD,eAAO,MAAM,yBAAyB,GACpC,KAAK,WAAW,EAChB,WAAW,gBAAgB;;;;;;;;;;;;;kBAiDb,gBAAgB;gBAClB,MAAM;;;kBADJ,gBAAgB;gBAClB,MAAM;;;;;;CAsEnB,CAAC"}
|