4 #import <Foundation/Foundation.h>
5 #import "keychain/ckks/CKKSResultOperation.h"
6 #import "keychain/ckks/CKKSAnalytics.h"
7 #import "keychain/ot/OctagonStateMachineHelpers.h"
9 NS_ASSUME_NONNULL_BEGIN
11 @interface OctagonStateTransitionPathStep
: NSObject
12 @property BOOL successState
;
13 @
property (readonly
) NSDictionary
<OctagonState
*, OctagonStateTransitionPathStep
*>* followStates
;
15 - (instancetype
)initAsSuccess
;
16 - (instancetype
)initWithPath
:(NSDictionary
<OctagonState
*, OctagonStateTransitionPathStep
*>*)followStates
;
20 + (OctagonStateTransitionPathStep
*)success
;
22 // Dict should be a map of states to either:
23 // 1. A dictionary matching this specifiction
24 // 2. an OctagonStateTransitionPathStep object (which is likely a success object, but doesn't have to be)
25 // Any other object will be ignored. A malformed dictionary will be converted into an empty success path.
26 + (OctagonStateTransitionPathStep
*)pathFromDictionary
:(NSDictionary
<OctagonState
*, id
>*)pathDict
;
30 @interface OctagonStateTransitionPath
: NSObject
31 @property OctagonState
* initialState
;
32 @property OctagonStateTransitionPathStep
* pathStep
;
34 - (instancetype
)initWithState
:(OctagonState
*)initialState
35 pathStep
:(OctagonStateTransitionPathStep
*)pathSteps
;
37 - (OctagonStateTransitionPathStep
*)asPathStep
;
39 // Uses the same rules as OctagonStateTransitionPathStep pathFromDictionary, but selects one of the top-level dictionary keys
40 // to be the path initialization state. Not well defined if you pass in two keys in the top-level dictionary.
41 // If the dictionary has no keys in it, returns nil.
42 + (OctagonStateTransitionPath
* _Nullable
)pathFromDictionary
:(NSDictionary
<OctagonState
*, id
>*)pathDict
;
47 @interface OctagonStateTransitionWatcher
: NSObject
48 @
property (readonly
) NSString
* name
;
49 @
property (readonly
) CKKSResultOperation
* result
;
50 @
property (readonly
) OctagonStateTransitionPath
* intendedPath
;
52 // If the initial request times out, the watcher will fail as well.
53 - (instancetype
)initNamed
:(NSString
*)name
54 serialQueue
:(dispatch_queue_t
)queue
55 path
:(OctagonStateTransitionPath
*)path
56 initialRequest
:(OctagonStateTransitionRequest
* _Nullable
)initialRequest
;
58 - (instancetype
)timeout
:(dispatch_time_t
)timeout
;
60 - (void)onqueueHandleTransition
:(CKKSResultOperation
<OctagonStateTransitionOperationProtocol
>*)attempt
;