3 #import <Foundation/Foundation.h>
4 #import "keychain/ckks/CKKSPeer.h"
6 NS_ASSUME_NONNULL_BEGIN
8 @protocol CKKSPeerUpdateListener
;
9 @
class CKKSPeerProviderState
;
11 #pragma mark - CKKSPeerProvider protocol
12 @protocol CKKSPeerProvider
<NSObject
>
13 @
property (readonly
) NSString
* providerID
;
14 @property BOOL essential
;
16 - (CKKSSelves
* _Nullable
)fetchSelfPeers
:(NSError
* _Nullable __autoreleasing
* _Nullable
)error
;
17 - (NSSet
<id
<CKKSRemotePeerProtocol
>>* _Nullable
)fetchTrustedPeers
:(NSError
* _Nullable __autoreleasing
* _Nullable
)error
;
18 // Trusted peers should include self peers
20 - (void)registerForPeerChangeUpdates
:(id
<CKKSPeerUpdateListener
>)listener
;
21 - (void)sendSelfPeerChangedUpdate
;
22 - (void)sendTrustedPeerSetChangedUpdate
;
24 - (CKKSPeerProviderState
*)currentState
;
27 #pragma mark - CKKSPeerUpdateListener protocol
28 // A CKKSPeerUpdateListener wants to be notified when a CKKSPeerProvider has new information
29 @protocol CKKSPeerUpdateListener
<NSObject
>
30 - (void)selfPeerChanged
:(id
<CKKSPeerProvider
> _Nullable
)provider
;
31 - (void)trustedPeerSetChanged
:(id
<CKKSPeerProvider
> _Nullable
)provider
;
35 #pragma mark - CKKSPeerProviderState
37 @interface CKKSPeerProviderState
: NSObject
38 @property NSString
* peerProviderID
;
40 // The peer provider believes trust in this state is essential. Any subsystem using
41 // a peer provider state should fail and pause if this is YES and there are trust errors.
42 @property BOOL essential
;
44 @
property (nonatomic
, readonly
, nullable
) CKKSSelves
* currentSelfPeers
;
45 @
property (nonatomic
, readonly
, nullable
) NSError
* currentSelfPeersError
;
46 @
property (nonatomic
, readonly
, nullable
) NSSet
<id
<CKKSRemotePeerProtocol
>>* currentTrustedPeers
;
47 @
property (nonatomic
, readonly
, nullable
) NSSet
<NSString
*>* currentTrustedPeerIDs
;
48 @
property (nonatomic
, readonly
, nullable
) NSError
* currentTrustedPeersError
;
50 - (instancetype
)initWithPeerProviderID
:(NSString
*)providerID
51 essential
:(BOOL
)essential
52 selfPeers
:(CKKSSelves
* _Nullable
)selfPeers
53 selfPeersError
:(NSError
* _Nullable
)selfPeersError
54 trustedPeers
:(NSSet
<id
<CKKSPeer
>>* _Nullable
)currentTrustedPeers
55 trustedPeersError
:(NSError
* _Nullable
)trustedPeersError
;
57 + (CKKSPeerProviderState
*)noPeersState
:(id
<CKKSPeerProvider
>)provider
;
59 // Intended for use in PeerProviders. Thread-safety is up to the PeerProvider.
60 + (CKKSPeerProviderState
*)createFromProvider
:(id
<CKKSPeerProvider
>)provider
;