6 #import <Foundation/Foundation.h>
7 #import <Security/SecureObjectSync/SOSTypes.h>
9 extern NSString
*kKCPairingChannelErrorDomain
;
11 #define KCPairingErrorNoControlChannel 1
12 #define KCPairingErrorTooManySteps 2
13 #define KCPairingErrorAccountCredentialMissing 3
14 #define KCPairingErrorOctagonMessageMissing 4
15 #define KCPairingErrorTypeConfusion 5
16 #define KCPairingErrorNoTrustAvailable 6
17 #define KCPairingErrorNoStashedCredential 7
19 typedef void(^KCPairingChannelCompletion
)(BOOL complete
, NSData
*packet
, NSError
*error
);
21 typedef NSString
* KCPairingIntent_Type NS_STRING_ENUM
;
22 extern KCPairingIntent_Type KCPairingIntent_Type_None
;
23 extern KCPairingIntent_Type KCPairingIntent_Type_SilentRepair
;
24 extern KCPairingIntent_Type KCPairingIntent_Type_UserDriven
;
26 @interface KCPairingChannelContext
: NSObject
<NSSecureCoding
>
27 @
property (strong
) NSString
*model
;
28 @
property (strong
) NSString
*modelVersion
;
29 @
property (strong
) NSString
*modelClass
;
30 @
property (strong
) NSString
*osVersion
;
31 @
property (strong
) NSString
*uniqueDeviceID
;
32 @
property (strong
) NSString
*uniqueClientID
;
33 @
property (strong
) KCPairingIntent_Type intent
;
37 * Pairing channel provides the channel used in OOBE / D2D and HomePod/AppleTV (TapToFix) setup.
39 * The initiator is the device that wants to get into the circle, the acceptor is the device that is already in.
40 * The interface require the caller to hold a lock assertion over the whole transaction, both on the initiator and acceptor.
43 @interface KCPairingChannel
: NSObject
45 @
property (assign
,readonly
) BOOL needInitialSync
;
47 + (instancetype
)pairingChannelInitiator
:(KCPairingChannelContext
*)peerVersionContext
;
48 + (instancetype
)pairingChannelAcceptor
:(KCPairingChannelContext
*)peerVersionContext
;
50 - (instancetype
)initAsInitiator
:(bool)initiator version
:(KCPairingChannelContext
*)peerVersionContext
;
51 - (void)validateStart
:(void(^)(bool result
, NSError
*error
))complete
;
53 - (NSData
*)exchangePacket
:(NSData
*)data complete
:(bool *)complete error
:(NSError
**)error
;
54 - (void)exchangePacket
:(NSData
*)inputCompressedData complete
:(KCPairingChannelCompletion
)complete
; /* async version of above */
56 /* for tests cases only */
57 - (void)setXPCConnectionObject
:(NSXPCConnection
*)connection
;
58 - (void)setControlObject
:(id
)control
;
59 - (void)setConfiguration
:(id
)config
;
60 - (void)setSOSMessageFailForTesting
:(BOOL
)value
;
61 - (void)setOctagonMessageFailForTesting
:(BOOL
)value
;
62 + (bool)isSupportedPlatform
;
63 - (void)setSessionSupportsOctagonForTesting
:(bool)value
;
65 + (NSData
*)pairingChannelCompressData
:(NSData
*)data
;
66 + (NSData
*)pairingChannelDecompressData
:(NSData
*)data
;