-
Notifications
You must be signed in to change notification settings - Fork 28
/
keyserver-conn-types.js
73 lines (66 loc) · 2.05 KB
/
keyserver-conn-types.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// @flow
import type {
LogInActionSource,
LogInStartingPayload,
LogInResult,
} from '../types/account-types.js';
import type { Endpoint } from '../types/endpoints.js';
import type { Dispatch } from '../types/redux-types.js';
import type {
ClientSessionChange,
PreRequestUserState,
} from '../types/session-types.js';
import type {
CallSingleKeyserverEndpoint,
CallSingleKeyserverEndpointOptions,
} from '../utils/call-single-keyserver-endpoint.js';
export type ActionTypes<
STARTED_ACTION_TYPE: string,
SUCCESS_ACTION_TYPE: string,
FAILED_ACTION_TYPE: string,
> = {
started: STARTED_ACTION_TYPE,
success: SUCCESS_ACTION_TYPE,
failed: FAILED_ACTION_TYPE,
};
export type DispatchRecoveryAttempt = (
actionTypes: ActionTypes<'LOG_IN_STARTED', 'LOG_IN_SUCCESS', 'LOG_IN_FAILED'>,
promise: Promise<LogInResult>,
startingPayload: LogInStartingPayload,
) => Promise<boolean>;
const setNewSessionActionType = 'SET_NEW_SESSION';
function setNewSession(
dispatch: Dispatch,
sessionChange: ClientSessionChange,
preRequestUserState: ?PreRequestUserState,
error: ?string,
logInActionSource: ?LogInActionSource,
keyserverID: string,
) {
dispatch({
type: setNewSessionActionType,
payload: {
sessionChange,
preRequestUserState,
error,
logInActionSource,
keyserverID,
},
});
}
export type SingleKeyserverActionFunc<F> = (
callSingleKeyserverEndpoint: CallSingleKeyserverEndpoint,
) => F;
export type CallKeyserverEndpoint = (
endpoint: Endpoint,
requests: { +[keyserverID: string]: ?{ +[string]: mixed } },
options?: ?CallSingleKeyserverEndpointOptions,
) => Promise<{ +[keyserverID: string]: any }>;
export type ActionFunc<Args: mixed, Return> = (
callSingleKeyserverEndpoint: CallKeyserverEndpoint,
// The second argument is only used in actions that call all keyservers,
// and the request to all keyservers are exactly the same.
// An example of such action is fetchEntries.
allKeyserverIDs: $ReadOnlyArray<string>,
) => Args => Promise<Return>;
export { setNewSessionActionType, setNewSession };